Merge pull request #17613 from pascalwhoop/master

updated i18n on alexa-sdk, fixed IntentRequest
This commit is contained in:
Ryan Cavanaugh
2017-07-10 10:18:45 -07:00
committed by GitHub
3 changed files with 32 additions and 30 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
import * as Alexa from "alexa-sdk";
const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => {
const handler = (event: Alexa.RequestBody<Alexa.Request>, context: Alexa.Context, callback: () => void) => {
let alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
let handlers: Alexa.Handlers = {
let handlers: Alexa.Handlers<Alexa.Request> = {
'LaunchRequest': function() {
this.emit('SayHello');
},
+28 -27
View File
@@ -6,14 +6,14 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void ): AlexaObject;
export function handler<T>(event: RequestBody<T>, context: Context, callback?: (err: any, response: any) => void ): AlexaObject<T>;
export function CreateStateHandler(state: string, obj: any): any;
export let StateString: string;
export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED";
export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED";
export interface AlexaObject extends Handler {
export interface AlexaObject<T> extends Handler<T> {
_event: any;
_context: any;
_callback: any;
@@ -22,26 +22,26 @@ export interface AlexaObject extends Handler {
response: any;
dynamoDBTableName: any;
saveBeforeResponse: boolean;
registerHandlers: (...handlers: Handlers[]) => any;
registerHandlers: (...handlers: Array<Handlers<T>>) => any;
execute: () => void;
}
export interface Handlers {
[intent: string]: (this: Handler) => void;
export interface Handlers<T> {
[intent: string]: (this: Handler<T>) => void;
}
export interface Handler {
export interface Handler<T> {
on: any;
emit(event: string, ...args: any[]): boolean;
emitWithState: any;
state: any;
handler: any;
event: RequestBody;
event: RequestBody<T>;
attributes: any;
context: any;
name: any;
isOverriden: any;
t: (token: string) => void;
t: (token: string, ...args: any[]) => void;
}
export interface Context {
@@ -55,10 +55,10 @@ export interface Context {
awsRequestId: string;
}
export interface RequestBody {
export interface RequestBody<T> {
version: string;
session: Session;
request: LaunchRequest | IntentRequest | SessionEndedRequest;
request: T;
}
export interface Session {
@@ -75,36 +75,37 @@ export interface SessionApplication {
export interface SessionUser {
userId: string;
accessToken: string;
accessToken?: string;
}
export interface LaunchRequest extends Request { }
export interface IntentRequest extends Request {
dialogState: DialogStates;
intent: Intent;
}
export interface SlotValue {
confirmationStatus: ConfirmationStatuses;
name: string;
value?: any;
}
export interface Intent {
confirmationStatus: ConfirmationStatuses;
name: string;
slots: Record<string, SlotValue>;
dialogState?: DialogStates;
intent?: Intent;
}
export interface SessionEndedRequest extends Request {
reason: string;
reason?: string;
}
export interface Request {
type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest";
requestId: string;
timeStamp: string;
timestamp: string;
locale?: string;
}
export interface SlotValue {
confirmationStatus?: ConfirmationStatuses;
name: string;
value?: any;
}
export interface Intent {
confirmationStatus?: ConfirmationStatuses;
name: string;
slots: Record<string, SlotValue>;
}
export interface ResponseBody {
+2 -1
View File
@@ -4,6 +4,7 @@
"object-literal-key-quote": false,
"no-empty-interface": false,
"prefer-method-signature": false,
"object-literal-key-quotes": false
"object-literal-key-quotes": false,
"no-any": false
}
}