mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
add initial handler, request and context
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="./alexa-sdk.d.ts" />
|
||||
|
||||
'use strict';
|
||||
import Alexa = require("alexa-sdk");
|
||||
|
||||
exports.handler = function(event, context, callback) {
|
||||
exports.handler = function(event: Alexa.Request, context: Alexa.Context, callback) {
|
||||
var alexa = Alexa.handler(event, context);
|
||||
alexa.registerHandlers(handlers);
|
||||
alexa.execute();
|
||||
@@ -15,9 +14,9 @@ var handlers = {
|
||||
this.emit('SayHello');
|
||||
},
|
||||
'HelloWorldIntent': function () {
|
||||
this.emit('SayHello')
|
||||
this.emit('SayHello');
|
||||
},
|
||||
'SayHello': function () {
|
||||
this.emit(':tell', 'Hello World!');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
40
alexa-sdk/alexa-sdk.d.ts
vendored
40
alexa-sdk/alexa-sdk.d.ts
vendored
@@ -4,7 +4,9 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'alexa-sdk' {
|
||||
var handler: (event: any, context: any, callback?: any) => AlexaHandler;
|
||||
export function handler(event: Request, context: Context, callback?: () => void): AlexaHandler;
|
||||
export function CreateStateHandler(state: string, obj: any): any;
|
||||
export var StateString: string;
|
||||
|
||||
interface AlexaHandler {
|
||||
_event: any;
|
||||
@@ -14,8 +16,38 @@ declare module 'alexa-sdk' {
|
||||
appId: any;
|
||||
response: any;
|
||||
dynamoDBTableName: any;
|
||||
saveBeforeResponse: any;
|
||||
registerHandlers: any;
|
||||
execute: any;
|
||||
saveBeforeResponse: boolean;
|
||||
registerHandlers: (...handlers: any[]) => any;
|
||||
execute: () => void;
|
||||
}
|
||||
|
||||
interface Handler {
|
||||
on: any;
|
||||
emit: any;
|
||||
emitWithState: any;
|
||||
state: any;
|
||||
handler: any;
|
||||
event: any;
|
||||
attributes: any;
|
||||
context: any;
|
||||
name: any;
|
||||
isOverriden: any;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
version: string;
|
||||
request: any;
|
||||
session: any;
|
||||
}
|
||||
|
||||
interface Context {
|
||||
callbackWaitsForEmptyEventLoop: boolean;
|
||||
logGroupName: string;
|
||||
logStreamName: string;
|
||||
functionName: string;
|
||||
memoryLimitInMB: string;
|
||||
functionVersion: string;
|
||||
invokeid: string;
|
||||
awsRequestId: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user