From 0eaacc5ca4e8776d2a11b9177a341db4cd9c1189 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Tue, 21 Nov 2017 19:00:51 +0530 Subject: [PATCH 1/8] Updated types to alexa-sdk@1.0.20. Separated files temporarily. --- types/alexa-sdk/index.d.ts | 184 ++++---------------- types/alexa-sdk/responseBuilder.d.ts | 170 +++++++++++++++++++ types/alexa-sdk/services.d.ts | 199 ++++++++++++++++++++++ types/alexa-sdk/templateBuilders.d.ts | 232 ++++++++++++++++++++++++++ types/alexa-sdk/tsconfig.json | 7 +- types/alexa-sdk/types.d.ts | 208 +++++++++++++++++++++++ types/alexa-sdk/utils.d.ts | 96 +++++++++++ 7 files changed, 940 insertions(+), 156 deletions(-) create mode 100644 types/alexa-sdk/responseBuilder.d.ts create mode 100644 types/alexa-sdk/services.d.ts create mode 100644 types/alexa-sdk/templateBuilders.d.ts create mode 100644 types/alexa-sdk/types.d.ts create mode 100644 types/alexa-sdk/utils.d.ts diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 1c39755b2d..bf64ff08df 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,3 +1,6 @@ + +import { utils } from './utils'; +import { AlexaObject, Image, TextField, TextContent, RequestBody, Context } from './types'; // Type definitions for Alexa SDK for Node.js 1.0 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle @@ -9,163 +12,34 @@ export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; 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 { - _event: any; - _context: any; - _callback: any; - state: any; - appId: any; - response: any; - resources: any; - dynamoDBTableName: any; - saveBeforeResponse: boolean; - registerHandlers: (...handlers: Array>) => any; - execute: () => void; +export namespace directives { + export class VoicePlayerSpeakDirective { + /** + * Creates an instance of VoicePlayerSpeakDirective. + * @param {string} requestId - requestId from which the call is originated from + * @param {string} speechContent - Contents of the speech directive either in plain text or SSML. + * @memberof DirectiveService + */ + constructor(requestId: string, speechContent: string); + } } +//#region exports from other modules +export { templateBuilders } from "./templateBuilders"; -export interface Handlers { - [intent: string]: (this: Handler) => void; -} +export { services } from "./services"; -export interface Handler { - on: any; - emit(event: string, ...args: any[]): boolean; - emitWithState: any; - state: any; - handler: any; - event: RequestBody; - attributes: any; - context: any; - name: any; - isOverriden: any; - t: (token: string, ...args: any[]) => void; -} +export { + AlexaObject, Image, CardImage, TextField, + TextContent, RequestBody, Context, Handler, IntentRequest, + ListItem, Template, Handlers, Session, SessionApplication, + SessionUser, LaunchRequest, SessionEndedRequest, + Request, ResolutionStatus, ResolutionValue, + ResolutionValueContainer, Resolutions, SlotValue, + Intent, ResponseBody, Response, OutputSpeech, + Card, Reprompt, ConfirmationStatuses, DialogStates, + StateString -export interface Context { - callbackWaitsForEmptyEventLoop: boolean; - logGroupName: string; - logStreamName: string; - functionName: string; - memoryLimitInMB: string; - functionVersion: string; - invokeid: string; - awsRequestId: string; -} - -export interface RequestBody { - version: string; - session: Session; - request: T; -} - -export interface Session { - new: boolean; - sessionId: string; - attributes: any; - application: SessionApplication; - user: SessionUser; -} - -export interface SessionApplication { - applicationId: string; -} - -export interface SessionUser { - userId: string; - accessToken?: string; -} - -export interface LaunchRequest extends Request { } - -export interface IntentRequest extends Request { - dialogState?: DialogStates; - intent?: Intent; -} - -export interface SessionEndedRequest extends Request { - reason?: string; -} - -export interface Request { - type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; - requestId: string; - timestamp: string; - locale?: string; -} - -export interface ResolutionStatus { - code: string; -} - -export interface ResolutionValue { - name: string; - id: string; -} - -export interface ResolutionValueContainer { - value: ResolutionValue; -} - -export interface Resolution { - authority: string; - status: ResolutionStatus; - values: ResolutionValueContainer[]; -} - -export interface Resolutions { - resolutionsPerAuthority: Resolution[]; -} - -export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; - name: string; - value?: any; - resolutions?: Resolutions; -} - -export interface Intent { - confirmationStatus?: ConfirmationStatuses; - name: string; - slots: Record; -} - -export interface ResponseBody { - version: string; - sessionAttributes?: any; - response: Response; -} - -export interface Response { - outputSpeech?: OutputSpeech; - card?: Card; - reprompt?: Reprompt; - shouldEndSession: boolean; -} - -export interface OutputSpeech { - type: "PlainText" | "SSML"; - text?: string; - ssml?: string; -} - -export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; - title?: string; - content?: string; - text?: string; - image?: Image; -} - -export interface Image { - smallImageUrl: string; - largeImageUrl: string; -} - -export interface Reprompt { - outputSpeech: OutputSpeech; -} +} from './types'; +export { utils } from './utils'; +//#endregion \ No newline at end of file diff --git a/types/alexa-sdk/responseBuilder.d.ts b/types/alexa-sdk/responseBuilder.d.ts new file mode 100644 index 0000000000..83d32cf4f0 --- /dev/null +++ b/types/alexa-sdk/responseBuilder.d.ts @@ -0,0 +1,170 @@ +import { Handler, Request, Template, Image, CardImage } from './types'; +export declare const CARD_TYPES: { + STANDARD: 'Standard', + SIMPLE: 'Simple', + LINK_ACCOUNT: 'LinkAccount', + ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' +}; + +export declare const HINT_TYPES: { + PLAIN_TEXT: 'PlainText' +}; + +export declare const DIRECTIVE_TYPES: { + AUDIOPLAYER: { + PLAY: 'AudioPlayer.Play', + STOP: 'AudioPlayer.Stop', + CLEAR_QUEUE: 'AudioPlayer.ClearQueue' + }, + DISPLAY: { + RENDER_TEMPLATE: 'Display.RenderTemplate' + }, + HINT: 'Hint', + VIDEOAPP: { + LAUNCH: 'VideoApp.Launch' + } +}; + +/** + * Responsible for building JSON responses as per the Alexa skills kit interface + * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax + * + * @class ResponseBuilder + */ +export class ResponseBuilder { + constructor(alexaHandler: Handler); + + /** + * Have Alexa say the provided speechOutput to the user + * + * @param {string} speechOutput + * @returns + * @memberof ResponseBuilder + */ + speak(speechOutput: string): ResponseBuilder; + + /** + * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds + * then have alexa reprompt with the provided reprompt speech + * @param {string} repromptSpeech + * @returns + * @memberof ResponseBuilder + */ + listen(repromptSpeech: string): ResponseBuilder; + + /** + * Render a card with the following title, content and image + * + * @param {string} cardTitle + * @param {string} cardContent + * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage + * @returns + * @memberof ResponseBuilder + */ + cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; + + /** + * Render a link account card + * + * @returns + * @memberof ResponseBuilder + */ + linkAccountCard(): ResponseBuilder; + + /** + * Render a askForPermissionsConsent card + * @param {[{ [key: string]: string }]} permissions + * @returns + * @memberOf ResponseBuilder + */ + askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; + + /** + * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. + * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead + * @param {string} directiveType + * @param {string} behavior + * @param {string} url + * @param {string} token + * @param {string} expectedPreviousToken + * @param {number} offsetInMilliseconds + * @returns + * @memberof ResponseBuilder + */ + audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer play directive + * + * @param {string} behavior Describes playback behavior. Accepted values: + * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. + * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. + * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. + * @param {string} url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. + * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param {string} expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * if requests to progress through a playlist and change tracks occur at the same time. + * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream + * @returns + * @memberof ResponseBuilder + */ + audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer Stop directive - Stops the current audio Playback + * + * @returns + * @memberof ResponseBuilder + */ + audioPlayerStop(): ResponseBuilder; + + /** + * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, + * or clear the queue and stop any currently playing stream. + * + * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream + * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). + * @returns + * @memberof ResponseBuilder + */ + audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; + + /** + * Creates a Display RenderTemplate Directive + * + * Use a template builder to generate a template object + * + * @param {Template} template + * @returns + * @memberof ResponseBuilder + */ + renderTemplate(template: Template): ResponseBuilder; + + /** + * Creates a hint directive - show a hint on the screen of the echo show + * + * @param {string} hintText text to show on the hint + * @param {string} hintType (optional) Default value : PlainText + * @returns + * @memberof ResponseBuilder + */ + hint(hintText: string, hintType: string): ResponseBuilder; + + /** + * Creates a VideoApp play directive to play a video + * + * @param {string} source Identifies the location of video content at a remote HTTPS location. + * The video file must be hosted at an Internet-accessible HTTPS endpoint. + * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * information that can be displayed on VideoApp. + * @returns + * @memberof ResponseBuilder + */ + playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; +} \ No newline at end of file diff --git a/types/alexa-sdk/services.d.ts b/types/alexa-sdk/services.d.ts new file mode 100644 index 0000000000..1498f17cbe --- /dev/null +++ b/types/alexa-sdk/services.d.ts @@ -0,0 +1,199 @@ +export namespace services { + export interface ApiClientOptions { hostname: string; port: string; path: string; protocol: string; headers: string; method: string } + export interface ApiClientResponse { statusCode: string; statusText: string; body: Object; headers: Object } + export interface ListItemObject { value: string, status: string, version: any } + export interface ListObject { name: string, status: string, version: any } + export interface ApiClient { + /** + * Make a POST API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + post(uri: string, headers: Object, body?: string): Promise; + /** + * Make a PUT API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + put(uri: string, headers: Object, body?: string): Promise; + /** + * Make a GET API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + * @memberof ApiClient + */ + get(uri: string, headers: Object): Promise; + /** + * Make a DELETE API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + */ + delete(uri: string, headers: Object): Promise; + } + export class DeviceAddressService { + /** + * Create an instance of DeviceAddressService + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberOf DeviceAddressService + */ + constructor(apiClient: ApiClient); + + /** + * Get full address information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + + /** + * Get country and postal information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + } + export class DirectiveService { + + /** + * Creates an instance of DirectiveService. + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberof DirectiveService + */ + constructor(apiClient: ApiClient); + + /** + * Send the specified directiveObj to Alexa directive service + * + * @param {Object} directive directive to send to service + * @param {string} apiEndpoint API endpoint from Alexa request + * @param {string} token bearer token for directive service + * @returns {Promise} + * @memberof DirectiveService + */ + enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + } + export class ListManagementService { + + /** + * Create an instance of ListManagementService + * @param apiClient + */ + constructor(apiClient: ApiClient); + + /** + * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * @param apiEndpoint + * @returns void + * @memberOf ListManagementService + */ + setApiEndpoint(apiEndpoint: string): void; + + /** + * Get currently set apiEndpoint address + * @returns {string} + * @memberOf ListManagementService + */ + getApiEndpoint(): string; + + /** + * Retrieve the metadata for all customer lists, including the customer's default lists + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListsMetadata(token: string): Promise; + + /** + * Create a custom list. The new list name must be different than any existing list name + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createList(listObject: ListObject, token: string): Promise + + /** + * Retrieve list metadata including the items in the list with requested status + * @param {string} listId unique Id associated with the list + * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getList(listId: string, itemStatus: string, token: string): Promise; + + /** + * Update a custom list. Only the list name or state can be updated + * @param {string} listId unique Id associated with the list + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateList(listId: string, listObject: ListObject, token: string): Promise; + + /** + * Delete a custom list + * @param {string} listId unique Id associated with the list + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteList(listId: string, token: string): Promise; + + /** + * Create an item in an active list or in a default list + * @param {string} listId unique Id associated with the list + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Retrieve single item within any list by listId and itemId + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListItem(listId: string, itemId: string, token: string): Promise; + + /** + * Update an item value or item status + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Delete an item in the specified list + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteListItem(listId: string, itemId: string, token: string): Promise; + } +} \ No newline at end of file diff --git a/types/alexa-sdk/templateBuilders.d.ts b/types/alexa-sdk/templateBuilders.d.ts new file mode 100644 index 0000000000..03834ca54a --- /dev/null +++ b/types/alexa-sdk/templateBuilders.d.ts @@ -0,0 +1,232 @@ +import { Image, TextField, ListItem, Template } from './types'; +export namespace templateBuilders { + export interface SetTextContent> { + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + export interface SetListItems> { + setListItems(listItems: ListItem[]): T; + } + export abstract class TemplateBuilder> { + public template: Template; + constructor(); + + /** + * Sets the title of the template + * + * @param {string} title + * @returns + * @memberof TemplateBuilder + */ + public setTitle(title: string): T; + + /** + * Sets the token of the template + * + * @param {string} token + * @returns + * @memberof TemplateBuilder + */ + public setToken(token: string): T; + + /** + * Sets the background image of the template + * + * @param {Image} image + * @returns + * @memberof TemplateBuilder + */ + public setBackgroundImage(image: Image): T; + + /** + * Sets the backButton behavior + * + * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns + * @memberof TemplateBuilder + */ + public setBackButtonBehavior(backButtonBehavior: string): T; + + /** + * Builds the template JSON object + * + * @returns + * @memberof TemplateBuilder + */ + public build(): Template; + // /** + // * Sets the text content for the template + // * + // * @param {TextField} primaryText + // * @param {TextField} secondaryText + // * @param {TextField} tertiaryText + // * @returns TemplateBuilder + // * @memberof TemplateBuilder + // */ + // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + /** + * Used to build a list of ListItems for ListTemplate + * + * @class ListItemBuilder + */ + export class ListItemBuilder { + constructor(); + public items: ListItem[]; + /** + * Add an item to the list of template + * + * @param {Image} image + * @param {string} token + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @memberof ListItemBuilder + */ + public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + + public build(): ListItem[]; + } + /** + * Used to create BodyTemplate1 objects + * + * @class BodyTemplate1Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + constructor(); + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate1Builder + * @memberof BodyTemplate1Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + } + /** + * Used to create BodyTemplate2 objects + * + * @class BodyTemplate2Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate2Builder + */ + public setImage(image: Image): BodyTemplate2Builder + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate2Builder + * @memberof BodyTemplate2Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + } + /** + * Used to create BodyTemplate3 objects + * + * @class BodyTemplate3Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate3Builder + */ + public setImage(image: any): BodyTemplate3Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate3Builder + * @memberof BodyTemplate3Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + } + /** + * Used to create BodyTemplate6 objects + * + * @class BodyTemplate6Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate6Builder + */ + public setImage(image: any): BodyTemplate6Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate6Builder + * @memberof BodyTemplate6Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + } + /** + * Used to create ListTemplate1 objects + * + * @class ListTemplate1Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate1Builder + */ + setListItems(listItems: ListItem[]): ListTemplate1Builder; + } + /** + * Used to create ListTemplate2 objects + * + * @class ListTemplate2Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate2Builder + */ + setListItems(listItems: ListItem[]): ListTemplate2Builder; + } + +} \ No newline at end of file diff --git a/types/alexa-sdk/tsconfig.json b/types/alexa-sdk/tsconfig.json index acc11c8263..e5b9d60424 100644 --- a/types/alexa-sdk/tsconfig.json +++ b/types/alexa-sdk/tsconfig.json @@ -19,5 +19,10 @@ "files": [ "index.d.ts", "alexa-sdk-tests.ts" + "responseBuilder.d.ts", + "services.d.ts", + "templateBuilders.d.ts", + "types.d.ts", + "utils.d.ts", ] -} \ No newline at end of file +} diff --git a/types/alexa-sdk/types.d.ts b/types/alexa-sdk/types.d.ts new file mode 100644 index 0000000000..42daa46f60 --- /dev/null +++ b/types/alexa-sdk/types.d.ts @@ -0,0 +1,208 @@ +import { i18n } from "../i18next"; +import { ResponseBuilder } from "./responseBuilder"; +export let StateString: string; + +export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; +export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; + +export interface CardImage { + smallImageUrl: string; + largeImageUrl: string; +} +export interface Image { + smallImageUrl: string; + largeImageUrl: string; + contentDescription: string; + sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; +} +export type TextField = { + text: string, + type: string +}; +export type TextContent = { + primaryText: TextField, + secondaryText: TextField, + tertiaryText: TextField, +} +export type ListItem = { image: Image; token: string; textContent: TextContent; }; +export type Template = { + title: string; + token: string; + backgroundImage: Image; + backButton: string; + type: string; + image: Image; + listItems: ListItem[]; +}; + +export interface AlexaObject extends Handler { + _event: any; + _context: any; + _callback: any; + state: any; + appId: any; + response: any; + resources: any; + dynamoDBTableName: any; + saveBeforeResponse: boolean; + registerHandlers: (...handlers: Array>) => any; + execute: () => void; +} + +export interface Handlers { + [intent: string]: (this: Handler) => void; +} + +export interface Handler { + on: any; + emit(event: string, ...args: any[]): boolean; + emitWithState: any; + state: any; + handler: any; + i18n: i18n, + locale: any, + event: RequestBody; + attributes: any; + context: any; + callback: Function; + name: any; + isOverriden: any; + t: (token: string, ...args: any[]) => void; + response: ResponseBuilder; +} +export enum PLAYER_ACTIVITY { + IDLE = 'IDLE', + PAUSED = 'PAUSED', + PLAYING = 'PLAYING', + BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', + FINISHED = 'FINISHED', + STOPPED = 'STOPPED' +} +export interface Context { + System: System + AudioPlayer: AudioPlayer +} +export interface System { + apiAccessToken: string; + apiEndpoint: string; + application: any; + device: any; + user: any; +} +export interface AudioPlayer { + token: string; + offsetInMilliseconds: number; + playerActivity: PLAYER_ACTIVITY; +} +export interface RequestBody { + version: string; + session: Session; + request: T; +} + +export interface Session { + new: boolean; + sessionId: string; + attributes: any; + application: SessionApplication; + user: SessionUser; +} + +export interface SessionApplication { + applicationId: string; +} + +export interface SessionUser { + userId: string; + accessToken?: string; + /** + * @deprecated + */ + permissions: any; +} + +export interface LaunchRequest extends Request { } + +export interface IntentRequest extends Request { + dialogState?: DialogStates; + intent?: Intent; +} + +export interface SessionEndedRequest extends Request { + reason?: string; +} + +export interface Request { + type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; + requestId: string; + timestamp: string; + locale?: string; +} + +export interface ResolutionStatus { + code: string; +} + +export interface ResolutionValue { + name: string; + id: string; +} + +export interface ResolutionValueContainer { + value: ResolutionValue; +} + +export interface Resolution { + authority: string; + status: ResolutionStatus; + values: ResolutionValueContainer[]; +} + +export interface Resolutions { + resolutionsPerAuthority: Resolution[]; +} + +export interface SlotValue { + confirmationStatus?: ConfirmationStatuses; + name: string; + value?: any; + resolutions?: Resolutions; +} + +export interface Intent { + confirmationStatus?: ConfirmationStatuses; + name: string; + slots: Record; +} + +export interface ResponseBody { + version: string; + sessionAttributes?: any; + response: Response; +} + +export interface Response { + outputSpeech?: OutputSpeech; + card?: Card; + reprompt?: Reprompt; + directives?: any; + shouldEndSession?: boolean; +} + +export interface OutputSpeech { + type: "PlainText" | "SSML"; + text?: string; + ssml?: string; +} + +export interface Card { + type: "Simple" | "Standard" | "LinkAccount"; + title?: string; + content?: string; + text?: string; + image?: Image; +} + +export interface Reprompt { + outputSpeech: OutputSpeech; +} \ No newline at end of file diff --git a/types/alexa-sdk/utils.d.ts b/types/alexa-sdk/utils.d.ts new file mode 100644 index 0000000000..056a52530e --- /dev/null +++ b/types/alexa-sdk/utils.d.ts @@ -0,0 +1,96 @@ + +import { TextField, TextContent, Image } from "./types"; +export namespace utils { + export class ImageUtils { + /** + * Creates an image object with a single source + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * + * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * + * @static + * @param {string} url url of the image + * @param {number} widthPixels (optional) width of the image in pixels + * @param {number} heightPixels (optional) height of the image in pixels + * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + /** + * + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @static + * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + } + /** + * Utility methods for building TextField objects + * + * @class TextUtils + */ + export class TextUtils { + + /** + * Creates a plain TextField object with contents : text + * + * @static + * @param {string} text contents of plain text object + * @returns + * @memberof TextUtils + */ + public static makePlainText(text: string): TextField; + + /** + * Creates a rich TextField object with contents : text + * + * @static + * @param {string} text + * @returns + * @memberof TextUtils + */ + public static makeRichText(text: string): TextField; + + /** + * Creates a textContent + * + * @static + * @param {{type : string, text : string}} primaryText + * @param {{type : string, text : string}} secondaryText + * @param {{type : string, text : string}} tertiaryText + * @returns + * @memberof TextUtils + */ + public static makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + } +} \ No newline at end of file From 860ffb8e9c585e3c9e2f2f2ea0f3bd5b56511c8a Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 12:19:54 +0530 Subject: [PATCH 2/8] Clubbed into one file. Added support for Alexa SDK for Node.js version 1.0.21 --- types/alexa-sdk/alexa-sdk-tests.ts | 20 - types/alexa-sdk/index.d.ts | 974 +++++++++++++++++++++++++- types/alexa-sdk/responseBuilder.d.ts | 170 ----- types/alexa-sdk/services.d.ts | 199 ------ types/alexa-sdk/templateBuilders.d.ts | 232 ------ types/alexa-sdk/tsconfig.json | 5 - types/alexa-sdk/types.d.ts | 208 ------ types/alexa-sdk/utils.d.ts | 96 --- 8 files changed, 952 insertions(+), 952 deletions(-) delete mode 100644 types/alexa-sdk/alexa-sdk-tests.ts delete mode 100644 types/alexa-sdk/responseBuilder.d.ts delete mode 100644 types/alexa-sdk/services.d.ts delete mode 100644 types/alexa-sdk/templateBuilders.d.ts delete mode 100644 types/alexa-sdk/types.d.ts delete mode 100644 types/alexa-sdk/utils.d.ts diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts deleted file mode 100644 index c77bc93091..0000000000 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as Alexa from "alexa-sdk"; - -const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { - const alexa = Alexa.handler(event, context); - alexa.resources = {}; - alexa.registerHandlers(handlers); - alexa.execute(); -}; - -const handlers: Alexa.Handlers = { - 'LaunchRequest': function() { - this.emit('SayHello'); - }, - 'HelloWorldIntent': function() { - this.emit('SayHello'); - }, - 'SayHello': function() { - this.emit(':tell', 'Hello World!'); - } -}; diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index bf64ff08df..744523b2ac 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,18 +1,870 @@ - -import { utils } from './utils'; -import { AlexaObject, Image, TextField, TextContent, RequestBody, Context } from './types'; -// Type definitions for Alexa SDK for Node.js 1.0 +// Type definitions for Alexa SDK for Node.js 1.0.21 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle // Huw // pascalwhoop // Ben +// rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - +// TypeScript Version: 2.7 +import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; +export let StateString: string; +//#region Types +export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; +export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; + +export interface CardImage { + smallImageUrl: string; + largeImageUrl: string; +} +export interface Image { + smallImageUrl: string; + largeImageUrl: string; + contentDescription: string; + sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; +} +export type TextField = { + text: string, + type: string +}; +export type TextContent = { + primaryText: TextField, + secondaryText: TextField, + tertiaryText: TextField, +} +export type ListItem = { image: Image; token: string; textContent: TextContent; }; +export type Template = { + title: string; + token: string; + backgroundImage: Image; + backButton: string; + type: string; + image: Image; + listItems: ListItem[]; +}; + +export interface AlexaObject extends Handler { + _event: any; + _context: any; + _callback: any; + state: any; + appId: any; + response: any; + resources: any; + dynamoDBTableName: any; + saveBeforeResponse: boolean; + registerHandlers: (...handlers: Array>) => any; + execute: () => void; +} + +export interface Handlers { + [intent: string]: (this: Handler) => void; +} + +export interface Handler { + on: any; + emit(event: string, ...args: any[]): boolean; + emitWithState: any; + state: any; + handler: any; + i18n: i18n, + locale: any, + event: RequestBody; + attributes: any; + context: any; + callback: Function; + name: any; + isOverriden: any; + t: (token: string, ...args: any[]) => void; + response: ResponseBuilder; +} +export enum PLAYER_ACTIVITY { + IDLE = 'IDLE', + PAUSED = 'PAUSED', + PLAYING = 'PLAYING', + BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', + FINISHED = 'FINISHED', + STOPPED = 'STOPPED' +} +export interface Context { + System: System + AudioPlayer: AudioPlayer +} +export interface Application { + applicationId: string; + [key: string]: string; +} +export interface System { + apiAccessToken: string; + apiEndpoint: string; + application: Application; + device: any; + user: any; +} +export interface AudioPlayer { + token: string; + offsetInMilliseconds: number; + playerActivity: PLAYER_ACTIVITY; +} +export interface RequestBody { + version: string; + session: Session; + request: T; +} + +export interface Session { + new: boolean; + sessionId: string; + attributes: { [key: string]: any }; + application: Application; + user: SessionUser; +} + +export interface SessionUser { + userId: string; + accessToken?: string; + /** + * @deprecated + */ + permissions: Permissions; +} +export interface Permissions { + consentToken: string; + [key: string]: string; +} +export interface LaunchRequest extends Request { } + +export interface IntentRequest extends Request { + dialogState?: DialogStates; + intent?: Intent; +} + +export interface SessionEndedRequest extends Request { + reason?: string; +} + +export interface Request { + type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; + requestId: string; + timestamp: string; + locale?: string; +} + +export interface ResolutionStatus { + code: string; +} + +export interface ResolutionValue { + name: string; + id: string; +} + +export interface ResolutionValueContainer { + value: ResolutionValue; +} + +export interface Resolution { + authority: string; + status: ResolutionStatus; + values: ResolutionValueContainer[]; +} + +export interface Resolutions { + resolutionsPerAuthority: Resolution[]; +} + +export interface SlotValue { + confirmationStatus?: ConfirmationStatuses; + name: string; + value?: any; + resolutions?: Resolutions; +} + +export interface Intent { + confirmationStatus?: ConfirmationStatuses; + name: string; + slots: Record; +} + +export interface ResponseBody { + version: string; + sessionAttributes?: any; + response: Response; +} + +export interface Response { + outputSpeech?: OutputSpeech; + card?: Card; + reprompt?: Reprompt; + directives?: any; + shouldEndSession?: boolean; +} + +export interface OutputSpeech { + type: "PlainText" | "SSML"; + text?: string; + ssml?: string; +} + +export interface Card { + type: "Simple" | "Standard" | "LinkAccount"; + title?: string; + content?: string; + text?: string; + image?: Image; +} + +export interface Reprompt { + outputSpeech: OutputSpeech; +} +export declare const CARD_TYPES: { + STANDARD: 'Standard', + SIMPLE: 'Simple', + LINK_ACCOUNT: 'LinkAccount', + ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' +}; + +export declare const HINT_TYPES: { + PLAIN_TEXT: 'PlainText' +}; + +export declare const DIRECTIVE_TYPES: { + AUDIOPLAYER: { + PLAY: 'AudioPlayer.Play', + STOP: 'AudioPlayer.Stop', + CLEAR_QUEUE: 'AudioPlayer.ClearQueue' + }, + DISPLAY: { + RENDER_TEMPLATE: 'Display.RenderTemplate' + }, + HINT: 'Hint', + VIDEOAPP: { + LAUNCH: 'VideoApp.Launch' + } +}; +export interface ApiClientOptions { + hostname: string; + port: string; + path: string; + protocol: string; + headers: string; + method: string; +} +export interface ApiClientResponse { + statusCode: string; + statusText: string; + body: Object; + headers: Object +} +export interface ListItemObject { + value: string, + status: string, + version: any +} +export interface ListObject { + name: string, + status: string, + version: any +} +//#endregion +//#region templateBuilders + +export namespace templateBuilders { + export interface SetTextContent> { + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + export interface SetListItems> { + setListItems(listItems: ListItem[]): T; + } + export abstract class TemplateBuilder> { + public template: Template; + constructor(); + + /** + * Sets the title of the template + * + * @param {string} title + * @returns + * @memberof TemplateBuilder + */ + public setTitle(title: string): T; + + /** + * Sets the token of the template + * + * @param {string} token + * @returns + * @memberof TemplateBuilder + */ + public setToken(token: string): T; + + /** + * Sets the background image of the template + * + * @param {Image} image + * @returns + * @memberof TemplateBuilder + */ + public setBackgroundImage(image: Image): T; + + /** + * Sets the backButton behavior + * + * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns + * @memberof TemplateBuilder + */ + public setBackButtonBehavior(backButtonBehavior: string): T; + + /** + * Builds the template JSON object + * + * @returns + * @memberof TemplateBuilder + */ + public build(): Template; + // /** + // * Sets the text content for the template + // * + // * @param {TextField} primaryText + // * @param {TextField} secondaryText + // * @param {TextField} tertiaryText + // * @returns TemplateBuilder + // * @memberof TemplateBuilder + // */ + // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + /** + * Used to build a list of ListItems for ListTemplate + * + * @class ListItemBuilder + */ + export class ListItemBuilder { + constructor(); + public items: ListItem[]; + /** + * Add an item to the list of template + * + * @param {Image} image + * @param {string} token + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @memberof ListItemBuilder + */ + public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + + public build(): ListItem[]; + } + /** + * Used to create BodyTemplate1 objects + * + * @class BodyTemplate1Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + constructor(); + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate1Builder + * @memberof BodyTemplate1Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + } + /** + * Used to create BodyTemplate2 objects + * + * @class BodyTemplate2Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate2Builder + */ + public setImage(image: Image): BodyTemplate2Builder + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate2Builder + * @memberof BodyTemplate2Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + } + /** + * Used to create BodyTemplate3 objects + * + * @class BodyTemplate3Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate3Builder + */ + public setImage(image: any): BodyTemplate3Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate3Builder + * @memberof BodyTemplate3Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + } + /** + * Used to create BodyTemplate6 objects + * + * @class BodyTemplate6Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate6Builder + */ + public setImage(image: any): BodyTemplate6Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate6Builder + * @memberof BodyTemplate6Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + } + /** + * Used to create BodyTemplate7 objects + * + * @class BodyTemplate7Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate7Builder extends TemplateBuilder { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate7Builder + */ + setImage(image: Image): BodyTemplate7Builder + } + /** + * Used to create ListTemplate1 objects + * + * @class ListTemplate1Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate1Builder + */ + setListItems(listItems: ListItem[]): ListTemplate1Builder; + } + /** + * Used to create ListTemplate2 objects + * + * @class ListTemplate2Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate2Builder + */ + setListItems(listItems: ListItem[]): ListTemplate2Builder; + } + +} +//#endregion +//#region services +export namespace services { + export interface ApiClient { + /** + * Make a POST API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + post(uri: string, headers: Object, body?: string): Promise; + /** + * Make a PUT API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + put(uri: string, headers: Object, body?: string): Promise; + /** + * Make a GET API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + * @memberof ApiClient + */ + get(uri: string, headers: Object): Promise; + /** + * Make a DELETE API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + */ + delete(uri: string, headers: Object): Promise; + } + export class DeviceAddressService { + /** + * Create an instance of DeviceAddressService + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberOf DeviceAddressService + */ + constructor(apiClient: ApiClient); + + /** + * Get full address information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + + /** + * Get country and postal information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + } + export class DirectiveService { + + /** + * Creates an instance of DirectiveService. + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberof DirectiveService + */ + constructor(apiClient: ApiClient); + + /** + * Send the specified directiveObj to Alexa directive service + * + * @param {Object} directive directive to send to service + * @param {string} apiEndpoint API endpoint from Alexa request + * @param {string} token bearer token for directive service + * @returns {Promise} + * @memberof DirectiveService + */ + enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + } + export class ListManagementService { + + /** + * Create an instance of ListManagementService + * @param apiClient + */ + constructor(apiClient: ApiClient); + + /** + * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * @param apiEndpoint + * @returns void + * @memberOf ListManagementService + */ + setApiEndpoint(apiEndpoint: string): void; + + /** + * Get currently set apiEndpoint address + * @returns {string} + * @memberOf ListManagementService + */ + getApiEndpoint(): string; + + /** + * Retrieve the metadata for all customer lists, including the customer's default lists + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListsMetadata(token: string): Promise; + + /** + * Create a custom list. The new list name must be different than any existing list name + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createList(listObject: ListObject, token: string): Promise + + /** + * Retrieve list metadata including the items in the list with requested status + * @param {string} listId unique Id associated with the list + * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getList(listId: string, itemStatus: string, token: string): Promise; + + /** + * Update a custom list. Only the list name or state can be updated + * @param {string} listId unique Id associated with the list + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateList(listId: string, listObject: ListObject, token: string): Promise; + + /** + * Delete a custom list + * @param {string} listId unique Id associated with the list + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteList(listId: string, token: string): Promise; + + /** + * Create an item in an active list or in a default list + * @param {string} listId unique Id associated with the list + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Retrieve single item within any list by listId and itemId + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListItem(listId: string, itemId: string, token: string): Promise; + + /** + * Update an item value or item status + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Delete an item in the specified list + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteListItem(listId: string, itemId: string, token: string): Promise; + } +} +//#endregion +//#region ResponseBuilder +/** + * Responsible for building JSON responses as per the Alexa skills kit interface + * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax + * + * @class ResponseBuilder + */ +export class ResponseBuilder { + constructor(alexaHandler: Handler); + + /** + * Have Alexa say the provided speechOutput to the user + * + * @param {string} speechOutput + * @returns + * @memberof ResponseBuilder + */ + speak(speechOutput: string): ResponseBuilder; + + /** + * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds + * then have alexa reprompt with the provided reprompt speech + * @param {string} repromptSpeech + * @returns + * @memberof ResponseBuilder + */ + listen(repromptSpeech: string): ResponseBuilder; + + /** + * Render a card with the following title, content and image + * + * @param {string} cardTitle + * @param {string} cardContent + * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage + * @returns + * @memberof ResponseBuilder + */ + cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; + + /** + * Render a link account card + * + * @returns + * @memberof ResponseBuilder + */ + linkAccountCard(): ResponseBuilder; + + /** + * Render a askForPermissionsConsent card + * @param {[{ [key: string]: string }]} permissions + * @returns + * @memberOf ResponseBuilder + */ + askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; + + /** + * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. + * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead + * @param {string} directiveType + * @param {string} behavior + * @param {string} url + * @param {string} token + * @param {string} expectedPreviousToken + * @param {number} offsetInMilliseconds + * @returns + * @memberof ResponseBuilder + */ + audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer play directive + * + * @param {string} behavior Describes playback behavior. Accepted values: + * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. + * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. + * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. + * @param {string} url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. + * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param {string} expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * if requests to progress through a playlist and change tracks occur at the same time. + * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream + * @returns + * @memberof ResponseBuilder + */ + audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer Stop directive - Stops the current audio Playback + * + * @returns + * @memberof ResponseBuilder + */ + audioPlayerStop(): ResponseBuilder; + + /** + * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, + * or clear the queue and stop any currently playing stream. + * + * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream + * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). + * @returns + * @memberof ResponseBuilder + */ + audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; + + /** + * Creates a Display RenderTemplate Directive + * + * Use a template builder to generate a template object + * + * @param {Template} template + * @returns + * @memberof ResponseBuilder + */ + renderTemplate(template: Template): ResponseBuilder; + + /** + * Creates a hint directive - show a hint on the screen of the echo show + * + * @param {string} hintText text to show on the hint + * @param {string} hintType (optional) Default value : PlainText + * @returns + * @memberof ResponseBuilder + */ + hint(hintText: string, hintType: string): ResponseBuilder; + + /** + * Creates a VideoApp play directive to play a video + * + * @param {string} source Identifies the location of video content at a remote HTTPS location. + * The video file must be hosted at an Internet-accessible HTTPS endpoint. + * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * information that can be displayed on VideoApp. + * @returns + * @memberof ResponseBuilder + */ + playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; +} +//#endregion +//#region directives export namespace directives { export class VoicePlayerSpeakDirective { /** @@ -24,22 +876,100 @@ export namespace directives { constructor(requestId: string, speechContent: string); } } -//#region exports from other modules -export { templateBuilders } from "./templateBuilders"; +//#endregion +//#region utils +export namespace utils { + export class ImageUtils { + /** + * Creates an image object with a single source + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * + * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * + * @static + * @param {string} url url of the image + * @param {number} widthPixels (optional) width of the image in pixels + * @param {number} heightPixels (optional) height of the image in pixels + * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + /** + * + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @static + * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + } + /** + * Utility methods for building TextField objects + * + * @class TextUtils + */ + export class TextUtils { -export { services } from "./services"; + /** + * Creates a plain TextField object with contents : text + * + * @static + * @param {string} text contents of plain text object + * @returns + * @memberof TextUtils + */ + public static makePlainText(text: string): TextField; -export { - AlexaObject, Image, CardImage, TextField, - TextContent, RequestBody, Context, Handler, IntentRequest, - ListItem, Template, Handlers, Session, SessionApplication, - SessionUser, LaunchRequest, SessionEndedRequest, - Request, ResolutionStatus, ResolutionValue, - ResolutionValueContainer, Resolutions, SlotValue, - Intent, ResponseBody, Response, OutputSpeech, - Card, Reprompt, ConfirmationStatuses, DialogStates, - StateString + /** + * Creates a rich TextField object with contents : text + * + * @static + * @param {string} text + * @returns + * @memberof TextUtils + */ + public static makeRichText(text: string): TextField; -} from './types'; -export { utils } from './utils'; -//#endregion \ No newline at end of file + /** + * Creates a textContent + * + * @static + * @param {{type : string, text : string}} primaryText + * @param {{type : string, text : string}} secondaryText + * @param {{type : string, text : string}} tertiaryText + * @returns + * @memberof TextUtils + */ + public static makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + } +} +//#endregion diff --git a/types/alexa-sdk/responseBuilder.d.ts b/types/alexa-sdk/responseBuilder.d.ts deleted file mode 100644 index 83d32cf4f0..0000000000 --- a/types/alexa-sdk/responseBuilder.d.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { Handler, Request, Template, Image, CardImage } from './types'; -export declare const CARD_TYPES: { - STANDARD: 'Standard', - SIMPLE: 'Simple', - LINK_ACCOUNT: 'LinkAccount', - ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' -}; - -export declare const HINT_TYPES: { - PLAIN_TEXT: 'PlainText' -}; - -export declare const DIRECTIVE_TYPES: { - AUDIOPLAYER: { - PLAY: 'AudioPlayer.Play', - STOP: 'AudioPlayer.Stop', - CLEAR_QUEUE: 'AudioPlayer.ClearQueue' - }, - DISPLAY: { - RENDER_TEMPLATE: 'Display.RenderTemplate' - }, - HINT: 'Hint', - VIDEOAPP: { - LAUNCH: 'VideoApp.Launch' - } -}; - -/** - * Responsible for building JSON responses as per the Alexa skills kit interface - * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax - * - * @class ResponseBuilder - */ -export class ResponseBuilder { - constructor(alexaHandler: Handler); - - /** - * Have Alexa say the provided speechOutput to the user - * - * @param {string} speechOutput - * @returns - * @memberof ResponseBuilder - */ - speak(speechOutput: string): ResponseBuilder; - - /** - * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds - * then have alexa reprompt with the provided reprompt speech - * @param {string} repromptSpeech - * @returns - * @memberof ResponseBuilder - */ - listen(repromptSpeech: string): ResponseBuilder; - - /** - * Render a card with the following title, content and image - * - * @param {string} cardTitle - * @param {string} cardContent - * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage - * @returns - * @memberof ResponseBuilder - */ - cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; - - /** - * Render a link account card - * - * @returns - * @memberof ResponseBuilder - */ - linkAccountCard(): ResponseBuilder; - - /** - * Render a askForPermissionsConsent card - * @param {[{ [key: string]: string }]} permissions - * @returns - * @memberOf ResponseBuilder - */ - askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; - - /** - * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. - * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead - * @param {string} directiveType - * @param {string} behavior - * @param {string} url - * @param {string} token - * @param {string} expectedPreviousToken - * @param {number} offsetInMilliseconds - * @returns - * @memberof ResponseBuilder - */ - audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; - - /** - * Creates an AudioPlayer play directive - * - * @param {string} behavior Describes playback behavior. Accepted values: - * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. - * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. - * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. - * @param {string} url Identifies the location of audio content at a remote HTTPS location. - * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the - * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. - * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. - * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters - * @param {string} expectedPreviousToken A token that represents the expected previous stream. - * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions - * if requests to progress through a playlist and change tracks occur at the same time. - * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. - * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream - * @returns - * @memberof ResponseBuilder - */ - audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; - - /** - * Creates an AudioPlayer Stop directive - Stops the current audio Playback - * - * @returns - * @memberof ResponseBuilder - */ - audioPlayerStop(): ResponseBuilder; - - /** - * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, - * or clear the queue and stop any currently playing stream. - * - * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: - * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream - * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). - * @returns - * @memberof ResponseBuilder - */ - audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; - - /** - * Creates a Display RenderTemplate Directive - * - * Use a template builder to generate a template object - * - * @param {Template} template - * @returns - * @memberof ResponseBuilder - */ - renderTemplate(template: Template): ResponseBuilder; - - /** - * Creates a hint directive - show a hint on the screen of the echo show - * - * @param {string} hintText text to show on the hint - * @param {string} hintType (optional) Default value : PlainText - * @returns - * @memberof ResponseBuilder - */ - hint(hintText: string, hintType: string): ResponseBuilder; - - /** - * Creates a VideoApp play directive to play a video - * - * @param {string} source Identifies the location of video content at a remote HTTPS location. - * The video file must be hosted at an Internet-accessible HTTPS endpoint. - * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the - * information that can be displayed on VideoApp. - * @returns - * @memberof ResponseBuilder - */ - playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; -} \ No newline at end of file diff --git a/types/alexa-sdk/services.d.ts b/types/alexa-sdk/services.d.ts deleted file mode 100644 index 1498f17cbe..0000000000 --- a/types/alexa-sdk/services.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -export namespace services { - export interface ApiClientOptions { hostname: string; port: string; path: string; protocol: string; headers: string; method: string } - export interface ApiClientResponse { statusCode: string; statusText: string; body: Object; headers: Object } - export interface ListItemObject { value: string, status: string, version: any } - export interface ListObject { name: string, status: string, version: any } - export interface ApiClient { - /** - * Make a POST API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient - */ - post(uri: string, headers: Object, body?: string): Promise; - /** - * Make a PUT API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient - */ - put(uri: string, headers: Object, body?: string): Promise; - /** - * Make a GET API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - * @memberof ApiClient - */ - get(uri: string, headers: Object): Promise; - /** - * Make a DELETE API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - */ - delete(uri: string, headers: Object): Promise; - } - export class DeviceAddressService { - /** - * Create an instance of DeviceAddressService - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberOf DeviceAddressService - */ - constructor(apiClient: ApiClient); - - /** - * Get full address information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService - */ - getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; - - /** - * Get country and postal information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService - */ - getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; - } - export class DirectiveService { - - /** - * Creates an instance of DirectiveService. - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberof DirectiveService - */ - constructor(apiClient: ApiClient); - - /** - * Send the specified directiveObj to Alexa directive service - * - * @param {Object} directive directive to send to service - * @param {string} apiEndpoint API endpoint from Alexa request - * @param {string} token bearer token for directive service - * @returns {Promise} - * @memberof DirectiveService - */ - enqueue(directive: Object, apiEndpoint: string, token: string): Promise; - } - export class ListManagementService { - - /** - * Create an instance of ListManagementService - * @param apiClient - */ - constructor(apiClient: ApiClient); - - /** - * Set apiEndpoint address, default is 'https://api.amazonalexa.com' - * @param apiEndpoint - * @returns void - * @memberOf ListManagementService - */ - setApiEndpoint(apiEndpoint: string): void; - - /** - * Get currently set apiEndpoint address - * @returns {string} - * @memberOf ListManagementService - */ - getApiEndpoint(): string; - - /** - * Retrieve the metadata for all customer lists, including the customer's default lists - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getListsMetadata(token: string): Promise; - - /** - * Create a custom list. The new list name must be different than any existing list name - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - createList(listObject: ListObject, token: string): Promise - - /** - * Retrieve list metadata including the items in the list with requested status - * @param {string} listId unique Id associated with the list - * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getList(listId: string, itemStatus: string, token: string): Promise; - - /** - * Update a custom list. Only the list name or state can be updated - * @param {string} listId unique Id associated with the list - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - updateList(listId: string, listObject: ListObject, token: string): Promise; - - /** - * Delete a custom list - * @param {string} listId unique Id associated with the list - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - deleteList(listId: string, token: string): Promise; - - /** - * Create an item in an active list or in a default list - * @param {string} listId unique Id associated with the list - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; - - /** - * Retrieve single item within any list by listId and itemId - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getListItem(listId: string, itemId: string, token: string): Promise; - - /** - * Update an item value or item status - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; - - /** - * Delete an item in the specified list - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - deleteListItem(listId: string, itemId: string, token: string): Promise; - } -} \ No newline at end of file diff --git a/types/alexa-sdk/templateBuilders.d.ts b/types/alexa-sdk/templateBuilders.d.ts deleted file mode 100644 index 03834ca54a..0000000000 --- a/types/alexa-sdk/templateBuilders.d.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { Image, TextField, ListItem, Template } from './types'; -export namespace templateBuilders { - export interface SetTextContent> { - setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; - } - export interface SetListItems> { - setListItems(listItems: ListItem[]): T; - } - export abstract class TemplateBuilder> { - public template: Template; - constructor(); - - /** - * Sets the title of the template - * - * @param {string} title - * @returns - * @memberof TemplateBuilder - */ - public setTitle(title: string): T; - - /** - * Sets the token of the template - * - * @param {string} token - * @returns - * @memberof TemplateBuilder - */ - public setToken(token: string): T; - - /** - * Sets the background image of the template - * - * @param {Image} image - * @returns - * @memberof TemplateBuilder - */ - public setBackgroundImage(image: Image): T; - - /** - * Sets the backButton behavior - * - * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' - * @returns - * @memberof TemplateBuilder - */ - public setBackButtonBehavior(backButtonBehavior: string): T; - - /** - * Builds the template JSON object - * - * @returns - * @memberof TemplateBuilder - */ - public build(): Template; - // /** - // * Sets the text content for the template - // * - // * @param {TextField} primaryText - // * @param {TextField} secondaryText - // * @param {TextField} tertiaryText - // * @returns TemplateBuilder - // * @memberof TemplateBuilder - // */ - // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; - } - /** - * Used to build a list of ListItems for ListTemplate - * - * @class ListItemBuilder - */ - export class ListItemBuilder { - constructor(); - public items: ListItem[]; - /** - * Add an item to the list of template - * - * @param {Image} image - * @param {string} token - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @memberof ListItemBuilder - */ - public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; - - public build(): ListItem[]; - } - /** - * Used to create BodyTemplate1 objects - * - * @class BodyTemplate1Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ - constructor(); - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate1Builder - * @memberof BodyTemplate1Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; - } - /** - * Used to create BodyTemplate2 objects - * - * @class BodyTemplate2Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate2Builder - */ - public setImage(image: Image): BodyTemplate2Builder - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate2Builder - * @memberof BodyTemplate2Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; - } - /** - * Used to create BodyTemplate3 objects - * - * @class BodyTemplate3Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate3Builder - */ - public setImage(image: any): BodyTemplate3Builder; - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate3Builder - * @memberof BodyTemplate3Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; - } - /** - * Used to create BodyTemplate6 objects - * - * @class BodyTemplate6Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate6Builder - */ - public setImage(image: any): BodyTemplate6Builder; - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate6Builder - * @memberof BodyTemplate6Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; - } - /** - * Used to create ListTemplate1 objects - * - * @class ListTemplate1Builder - * @extends {TemplateBuilder} - */ - export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { - constructor(); - - /** - * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate1Builder - */ - setListItems(listItems: ListItem[]): ListTemplate1Builder; - } - /** - * Used to create ListTemplate2 objects - * - * @class ListTemplate2Builder - * @extends {TemplateBuilder} - */ - export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { - constructor(); - - /** - * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate2Builder - */ - setListItems(listItems: ListItem[]): ListTemplate2Builder; - } - -} \ No newline at end of file diff --git a/types/alexa-sdk/tsconfig.json b/types/alexa-sdk/tsconfig.json index e5b9d60424..d1932fa469 100644 --- a/types/alexa-sdk/tsconfig.json +++ b/types/alexa-sdk/tsconfig.json @@ -19,10 +19,5 @@ "files": [ "index.d.ts", "alexa-sdk-tests.ts" - "responseBuilder.d.ts", - "services.d.ts", - "templateBuilders.d.ts", - "types.d.ts", - "utils.d.ts", ] } diff --git a/types/alexa-sdk/types.d.ts b/types/alexa-sdk/types.d.ts deleted file mode 100644 index 42daa46f60..0000000000 --- a/types/alexa-sdk/types.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -import { i18n } from "../i18next"; -import { ResponseBuilder } from "./responseBuilder"; -export let StateString: string; - -export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; -export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; - -export interface CardImage { - smallImageUrl: string; - largeImageUrl: string; -} -export interface Image { - smallImageUrl: string; - largeImageUrl: string; - contentDescription: string; - sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; -} -export type TextField = { - text: string, - type: string -}; -export type TextContent = { - primaryText: TextField, - secondaryText: TextField, - tertiaryText: TextField, -} -export type ListItem = { image: Image; token: string; textContent: TextContent; }; -export type Template = { - title: string; - token: string; - backgroundImage: Image; - backButton: string; - type: string; - image: Image; - listItems: ListItem[]; -}; - -export interface AlexaObject extends Handler { - _event: any; - _context: any; - _callback: any; - state: any; - appId: any; - response: any; - resources: any; - dynamoDBTableName: any; - saveBeforeResponse: boolean; - registerHandlers: (...handlers: Array>) => any; - execute: () => void; -} - -export interface Handlers { - [intent: string]: (this: Handler) => void; -} - -export interface Handler { - on: any; - emit(event: string, ...args: any[]): boolean; - emitWithState: any; - state: any; - handler: any; - i18n: i18n, - locale: any, - event: RequestBody; - attributes: any; - context: any; - callback: Function; - name: any; - isOverriden: any; - t: (token: string, ...args: any[]) => void; - response: ResponseBuilder; -} -export enum PLAYER_ACTIVITY { - IDLE = 'IDLE', - PAUSED = 'PAUSED', - PLAYING = 'PLAYING', - BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', - FINISHED = 'FINISHED', - STOPPED = 'STOPPED' -} -export interface Context { - System: System - AudioPlayer: AudioPlayer -} -export interface System { - apiAccessToken: string; - apiEndpoint: string; - application: any; - device: any; - user: any; -} -export interface AudioPlayer { - token: string; - offsetInMilliseconds: number; - playerActivity: PLAYER_ACTIVITY; -} -export interface RequestBody { - version: string; - session: Session; - request: T; -} - -export interface Session { - new: boolean; - sessionId: string; - attributes: any; - application: SessionApplication; - user: SessionUser; -} - -export interface SessionApplication { - applicationId: string; -} - -export interface SessionUser { - userId: string; - accessToken?: string; - /** - * @deprecated - */ - permissions: any; -} - -export interface LaunchRequest extends Request { } - -export interface IntentRequest extends Request { - dialogState?: DialogStates; - intent?: Intent; -} - -export interface SessionEndedRequest extends Request { - reason?: string; -} - -export interface Request { - type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; - requestId: string; - timestamp: string; - locale?: string; -} - -export interface ResolutionStatus { - code: string; -} - -export interface ResolutionValue { - name: string; - id: string; -} - -export interface ResolutionValueContainer { - value: ResolutionValue; -} - -export interface Resolution { - authority: string; - status: ResolutionStatus; - values: ResolutionValueContainer[]; -} - -export interface Resolutions { - resolutionsPerAuthority: Resolution[]; -} - -export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; - name: string; - value?: any; - resolutions?: Resolutions; -} - -export interface Intent { - confirmationStatus?: ConfirmationStatuses; - name: string; - slots: Record; -} - -export interface ResponseBody { - version: string; - sessionAttributes?: any; - response: Response; -} - -export interface Response { - outputSpeech?: OutputSpeech; - card?: Card; - reprompt?: Reprompt; - directives?: any; - shouldEndSession?: boolean; -} - -export interface OutputSpeech { - type: "PlainText" | "SSML"; - text?: string; - ssml?: string; -} - -export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; - title?: string; - content?: string; - text?: string; - image?: Image; -} - -export interface Reprompt { - outputSpeech: OutputSpeech; -} \ No newline at end of file diff --git a/types/alexa-sdk/utils.d.ts b/types/alexa-sdk/utils.d.ts deleted file mode 100644 index 056a52530e..0000000000 --- a/types/alexa-sdk/utils.d.ts +++ /dev/null @@ -1,96 +0,0 @@ - -import { TextField, TextContent, Image } from "./types"; -export namespace utils { - export class ImageUtils { - /** - * Creates an image object with a single source - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * - * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') - * - * @static - * @param {string} url url of the image - * @param {number} widthPixels (optional) width of the image in pixels - * @param {number} heightPixels (optional) height of the image in pixels - * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; - /** - * - * Creates an image object with a multiple sources, source images are provided as an array of image objects - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * example : - * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, - * ] - * ImageUtils.makeImage(imgArr, 'image description') - * - * @static - * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; - } - /** - * Utility methods for building TextField objects - * - * @class TextUtils - */ - export class TextUtils { - - /** - * Creates a plain TextField object with contents : text - * - * @static - * @param {string} text contents of plain text object - * @returns - * @memberof TextUtils - */ - public static makePlainText(text: string): TextField; - - /** - * Creates a rich TextField object with contents : text - * - * @static - * @param {string} text - * @returns - * @memberof TextUtils - */ - public static makeRichText(text: string): TextField; - - /** - * Creates a textContent - * - * @static - * @param {{type : string, text : string}} primaryText - * @param {{type : string, text : string}} secondaryText - * @param {{type : string, text : string}} tertiaryText - * @returns - * @memberof TextUtils - */ - public static makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent - } -} \ No newline at end of file From 5838284de2e44af57f6f7733b26fe59f8f8ca250 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 12:29:21 +0530 Subject: [PATCH 3/8] Reverted alexa-sdk-tests.ts --- types/alexa-sdk/alexa-sdk-tests.ts | 20 ++++++++++++++++++++ types/alexa-sdk/tslint.json | 19 ++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 types/alexa-sdk/alexa-sdk-tests.ts diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts new file mode 100644 index 0000000000..0c511979d4 --- /dev/null +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -0,0 +1,20 @@ +import * as Alexa from "alexa-sdk"; + +const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { + const alexa = Alexa.handler(event, context); + alexa.resources = {}; + alexa.registerHandlers(handlers); + alexa.execute(); +}; + +const handlers: Alexa.Handlers = { + 'LaunchRequest': function () { + this.emit('SayHello'); + }, + 'HelloWorldIntent': function () { + this.emit('SayHello'); + }, + 'SayHello': function () { + this.emit(':tell', 'Hello World!'); + } +}; diff --git a/types/alexa-sdk/tslint.json b/types/alexa-sdk/tslint.json index 78f1939ba2..32a9916641 100644 --- a/types/alexa-sdk/tslint.json +++ b/types/alexa-sdk/tslint.json @@ -1,10 +1,11 @@ -{ "extends": "dtslint/dt.json", - "rules": { - "object-literal-shorthand": false, - "object-literal-key-quote": false, - "no-empty-interface": false, - "prefer-method-signature": false, - "object-literal-key-quotes": false, - "no-any": false - } +{ + "extends": "dtslint/dt.json", + "rules": { + "object-literal-shorthand": false, + "object-literal-key-quote": false, + "no-empty-interface": false, + "prefer-method-signature": false, + "object-literal-key-quotes": false, + "no-any": false + } } From 26bb67e8d7db5735ca266ba4fb0ec7257a5c72b7 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 17:44:33 +0530 Subject: [PATCH 4/8] Fixed lint errors for alexa-sdk --- types/alexa-sdk/alexa-sdk-tests.ts | 6 +- types/alexa-sdk/index.d.ts | 821 ++++++++++++++--------------- 2 files changed, 394 insertions(+), 433 deletions(-) diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts index 0c511979d4..c77bc93091 100644 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -8,13 +8,13 @@ const handler = (event: Alexa.RequestBody, context: Alexa.Context }; const handlers: Alexa.Handlers = { - 'LaunchRequest': function () { + 'LaunchRequest': function() { this.emit('SayHello'); }, - 'HelloWorldIntent': function () { + 'HelloWorldIntent': function() { this.emit('SayHello'); }, - 'SayHello': function () { + 'SayHello': function() { this.emit(':tell', 'Hello World!'); } }; diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 744523b2ac..e4ea78c104 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Alexa SDK for Node.js 1.0.21 +// Type definitions for Alexa SDK for Node.js 1.0 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle // Huw @@ -6,45 +6,66 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 +// TypeScript Version: 2.2 import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; //#region Types -export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; -export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; - export interface CardImage { + /** + * Recommended size (in px): 720w x 480h + */ smallImageUrl: string; + /** + * Recommended size (in px): 1200w x 800h + */ largeImageUrl: string; } +export interface ImageSource { + url: string; + widthPixels?: number; + heightPixels?: number; + /** + * Possible values: 'X_SMALL' | 'SMALL' | 'MEDIUM' | 'LARGE' | 'X_LARGE' + * Recommended size respectively (in px): 480 x 320 | 720 x 480 | 960 x 640 | 1200 x 800 | 1920 x 1280 + */ + size?: string; +} export interface Image { - smallImageUrl: string; - largeImageUrl: string; contentDescription: string; - sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; + sources: ImageSource[]; } -export type TextField = { - text: string, - type: string -}; -export type TextContent = { - primaryText: TextField, - secondaryText: TextField, - tertiaryText: TextField, -} -export type ListItem = { image: Image; token: string; textContent: TextContent; }; -export type Template = { - title: string; - token: string; - backgroundImage: Image; - backButton: string; +export interface TextField { + text: string; type: string; - image: Image; - listItems: ListItem[]; -}; +} +export interface TextContent { + primaryText?: TextField; + secondaryText?: TextField; + tertiaryText?: TextField; +} +export interface ListItem { + image?: Image; + token: string; + textContent?: TextContent; +} +export interface Template { + title?: string; + token: string; + backgroundImage?: Image; + /** + * Possible values 'HIDDEN' | 'VISIBLE' + */ + backButton?: string; + /** + * Possible values 'BodyTemplate1' | 'BodyTemplate2'| 'BodyTemplate3'| 'BodyTemplate6'| 'ListTemplate1'| 'ListTemplate2' + */ + type: string; + image?: Image; + listItems?: ListItem[]; +} export interface AlexaObject extends Handler { _event: any; @@ -70,28 +91,21 @@ export interface Handler { emitWithState: any; state: any; handler: any; - i18n: i18n, - locale: any, + i18n: i18n; + locale: any; event: RequestBody; attributes: any; context: any; - callback: Function; + callback: (param: any) => void; name: any; isOverriden: any; t: (token: string, ...args: any[]) => void; response: ResponseBuilder; } -export enum PLAYER_ACTIVITY { - IDLE = 'IDLE', - PAUSED = 'PAUSED', - PLAYING = 'PLAYING', - BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', - FINISHED = 'FINISHED', - STOPPED = 'STOPPED' -} + export interface Context { - System: System - AudioPlayer: AudioPlayer + System: System; + AudioPlayer: AudioPlayer; } export interface Application { applicationId: string; @@ -107,7 +121,10 @@ export interface System { export interface AudioPlayer { token: string; offsetInMilliseconds: number; - playerActivity: PLAYER_ACTIVITY; + /** + * Possible values: 'IDLE'|'PAUSED'|'PLAYING'|'BUFFER_UNDERRUN'|'FINISHED'|'STOPPED' + */ + playerActivity: string; } export interface RequestBody { version: string; @@ -122,23 +139,25 @@ export interface Session { application: Application; user: SessionUser; } - export interface SessionUser { userId: string; accessToken?: string; - /** - * @deprecated - */ permissions: Permissions; } export interface Permissions { + /** + * @deprecated + */ consentToken: string; [key: string]: string; } export interface LaunchRequest extends Request { } export interface IntentRequest extends Request { - dialogState?: DialogStates; + /** + * Possible values: 'STARTED'| 'IN_PROGRESS'| 'COMPLETED' + */ + dialogState?: string; intent?: Intent; } @@ -177,14 +196,20 @@ export interface Resolutions { } export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; + /** + * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' + */ + confirmationStatus?: string; name: string; value?: any; resolutions?: Resolutions; } export interface Intent { - confirmationStatus?: ConfirmationStatuses; + /** + * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' + */ + confirmationStatus?: string; name: string; slots: Record; } @@ -214,24 +239,24 @@ export interface Card { title?: string; content?: string; text?: string; - image?: Image; + image?: CardImage; } export interface Reprompt { outputSpeech: OutputSpeech; } -export declare const CARD_TYPES: { +export const CARD_TYPES: { STANDARD: 'Standard', SIMPLE: 'Simple', LINK_ACCOUNT: 'LinkAccount', ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' }; -export declare const HINT_TYPES: { +export const HINT_TYPES: { PLAIN_TEXT: 'PlainText' }; -export declare const DIRECTIVE_TYPES: { +export const DIRECTIVE_TYPES: { AUDIOPLAYER: { PLAY: 'AudioPlayer.Play', STOP: 'AudioPlayer.Stop', @@ -256,466 +281,448 @@ export interface ApiClientOptions { export interface ApiClientResponse { statusCode: string; statusText: string; - body: Object; - headers: Object + body: object; + headers: object; } +/** + * Todo-ListItem class + * Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html + */ export interface ListItemObject { - value: string, - status: string, - version: any + /** + * item id (String, limit 60 characters) + */ + id: string; + /** + * item value (String, limit is 256 characters) + */ + value: string; + /** + * item status + * Possible values: "active" or "completed" + */ + status?: string; + /** + * item version (Positive integer | string) + */ + version?: any; + /** + * created time (ISO 8601 time format with time zone) + */ + createdTime: Date; + /** + * updated time (ISO 8601 time format with time zone) + */ + updatedTime: Date; + /** + * URL to retrieve the item (String) + */ + href?: string; } +/** + * Todo-List class + * Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html + */ export interface ListObject { - name: string, - status: string, - version: any + /** + * list id (String) + */ + listId: string; + /** + * list name (String) + */ + name: string; + /** + * "active" or "archived" (Enum) + */ + state?: string; + /** + * Possibly status of the list (or state?) + * Fetched from commit eebba0d at https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/ + * File path: alexa-skills-kit-sdk-for-nodejs/lib/services/listManagementService.js + */ + status?: string; + /** + * list version (long | string) + */ + version?: any; + /** + * Urls to active and completed items + * href is lint to the items having certain status. + * The status can be "active" or "completed". + */ + statusMap: { href: string; status: string; }; + /** + * Items that belong to this list. + */ + items: ListItemObject[]; } //#endregion //#region templateBuilders +/** + * Generates templates for Echo Show device. + */ export namespace templateBuilders { - export interface SetTextContent> { + interface SetTextContent> { setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; } - export interface SetListItems> { + interface SetListItems> { setListItems(listItems: ListItem[]): T; } - export abstract class TemplateBuilder> { - public template: Template; + /** + * Refer https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#image-sizes + */ + abstract class TemplateBuilder> { + template: Template; constructor(); /** * Sets the title of the template - * - * @param {string} title - * @returns - * @memberof TemplateBuilder + * @param title title + * @returns TemplateBuilder */ - public setTitle(title: string): T; + setTitle(title: string): T; /** * Sets the token of the template - * - * @param {string} token - * @returns - * @memberof TemplateBuilder + * @param token token + * @returns TemplateBuilder */ - public setToken(token: string): T; + setToken(token: string): T; /** * Sets the background image of the template - * - * @param {Image} image - * @returns - * @memberof TemplateBuilder + * @param image image + * @returns TemplateBuilder */ - public setBackgroundImage(image: Image): T; + setBackgroundImage(image: Image): T; /** * Sets the backButton behavior - * - * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' - * @returns - * @memberof TemplateBuilder + * @param backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns TemplateBuilder */ - public setBackButtonBehavior(backButtonBehavior: string): T; + setBackButtonBehavior(backButtonBehavior: string): T; /** * Builds the template JSON object - * - * @returns - * @memberof TemplateBuilder + * @returns Template */ - public build(): Template; - // /** - // * Sets the text content for the template - // * - // * @param {TextField} primaryText - // * @param {TextField} secondaryText - // * @param {TextField} tertiaryText - // * @returns TemplateBuilder - // * @memberof TemplateBuilder - // */ - // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + build(): Template; } /** * Used to build a list of ListItems for ListTemplate - * - * @class ListItemBuilder */ - export class ListItemBuilder { + class ListItemBuilder { constructor(); - public items: ListItem[]; + items: ListItem[]; /** * Add an item to the list of template - * - * @param {Image} image - * @param {string} token - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @memberof ListItemBuilder + * @param image image + * @param token token + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText */ - public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; - public build(): ListItem[]; + build(): ListItem[]; } /** * Used to create BodyTemplate1 objects - * - * @class BodyTemplate1Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate1Builder - * @memberof BodyTemplate1Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; } /** * Used to create BodyTemplate2 objects - * - * @class BodyTemplate2Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate2Builder + * @param image image + * @returns BodyTemplate2Builder */ - public setImage(image: Image): BodyTemplate2Builder + setImage(image: Image): BodyTemplate2Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate2Builder - * @memberof BodyTemplate2Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; } /** * Used to create BodyTemplate3 objects - * - * @class BodyTemplate3Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate3Builder + * @param image image + * @returns BodyTemplate3Builder */ - public setImage(image: any): BodyTemplate3Builder; + setImage(image: any): BodyTemplate3Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate3Builder - * @memberof BodyTemplate3Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; } /** * Used to create BodyTemplate6 objects - * - * @class BodyTemplate6Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate6Builder + * @param image image + * @returns BodyTemplate6Builder */ - public setImage(image: any): BodyTemplate6Builder; + setImage(image: any): BodyTemplate6Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate6Builder - * @memberof BodyTemplate6Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; } /** * Used to create BodyTemplate7 objects - * - * @class BodyTemplate7Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate7Builder extends TemplateBuilder { + class BodyTemplate7Builder extends TemplateBuilder { constructor(); /** * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate7Builder + * @param image image + * @returns BodyTemplate7Builder */ - setImage(image: Image): BodyTemplate7Builder + setImage(image: Image): BodyTemplate7Builder; } /** * Used to create ListTemplate1 objects - * - * @class ListTemplate1Builder - * @extends {TemplateBuilder} */ - export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + class ListTemplate1Builder extends TemplateBuilder implements SetListItems { constructor(); /** * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate1Builder + * @param listItems listItems + * @returns ListTemplate1Builder */ setListItems(listItems: ListItem[]): ListTemplate1Builder; } /** * Used to create ListTemplate2 objects - * - * @class ListTemplate2Builder - * @extends {TemplateBuilder} */ - export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + class ListTemplate2Builder extends TemplateBuilder implements SetListItems { constructor(); /** * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate2Builder + * @param listItems listItems + * @returns ListTemplate2Builder */ setListItems(listItems: ListItem[]): ListTemplate2Builder; } - } //#endregion //#region services export namespace services { - export interface ApiClient { + interface ApiClient { /** * Make a POST API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers Key value pair of headers + * @param body post body to send + * @returns Promise */ - post(uri: string, headers: Object, body?: string): Promise; + post(uri: string, headers: object, body?: string): Promise; /** * Make a PUT API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers Key value pair of headers + * @param body post body to send + * @returns Promise */ - put(uri: string, headers: Object, body?: string): Promise; + put(uri: string, headers: object, body?: string): Promise; /** * Make a GET API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers key value pair of headers + * @returns Promise */ - get(uri: string, headers: Object): Promise; + get(uri: string, headers: object): Promise; /** - * Make a DELETE API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - */ - delete(uri: string, headers: Object): Promise; + * Make a DELETE API call to the specified uri with headers + * @param uri http(s?) endpoint to call + * @param headers key value pair of headers + * @returns Promise + */ + delete(uri: string, headers: object): Promise; } - export class DeviceAddressService { + class DeviceAddressService { /** * Create an instance of DeviceAddressService - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberOf DeviceAddressService + * @param [apiClient=new ApiClient()] ApiClient */ constructor(apiClient: ApiClient); /** * Get full address information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService + * @param deviceId deviceId from Alexa request + * @param apiEndpoint API apiEndpoint from Alexa request + * @param token bearer token for device address permission + * @returns Promise */ - getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; /** * Get country and postal information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService + * @param deviceId deviceId from Alexa request + * @param apiEndpoint API apiEndpoint from Alexa request + * @param token bearer token for device address permission + * @returns Promise */ - getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; } - export class DirectiveService { - + class DirectiveService { /** * Creates an instance of DirectiveService. - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberof DirectiveService + * @param [apiClient=new ApiClient()] ApiClient */ constructor(apiClient: ApiClient); /** * Send the specified directiveObj to Alexa directive service * - * @param {Object} directive directive to send to service - * @param {string} apiEndpoint API endpoint from Alexa request - * @param {string} token bearer token for directive service - * @returns {Promise} - * @memberof DirectiveService + * @param directive directive to send to service + * @param apiEndpoint API endpoint from Alexa request + * @param token bearer token for directive service + * @returns Promise */ - enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + enqueue(directive: object, apiEndpoint: string, token: string): Promise; } - export class ListManagementService { - + class ListManagementService { /** * Create an instance of ListManagementService - * @param apiClient + * @param apiClient apiClient */ constructor(apiClient: ApiClient); /** * Set apiEndpoint address, default is 'https://api.amazonalexa.com' - * @param apiEndpoint + * @param apiEndpoint apiEndpoint * @returns void - * @memberOf ListManagementService */ setApiEndpoint(apiEndpoint: string): void; /** * Get currently set apiEndpoint address - * @returns {string} - * @memberOf ListManagementService + * @returns string */ getApiEndpoint(): string; /** * Retrieve the metadata for all customer lists, including the customer's default lists - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param token bearer token for list management permission + * @returns Promise */ - getListsMetadata(token: string): Promise; + getListsMetadata(token: string): Promise; /** * Create a custom list. The new list name must be different than any existing list name - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listObject listObject + * @param token bearer token for list management permission + * @returns Promise */ - createList(listObject: ListObject, token: string): Promise + createList(listObject: ListObject, token: string): Promise; /** * Retrieve list metadata including the items in the list with requested status - * @param {string} listId unique Id associated with the list - * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemStatus itemsStatus can be either 'active' or 'completed' + * @param token bearer token for list management permission + * @returns Promise */ - getList(listId: string, itemStatus: string, token: string): Promise; + getList(listId: string, itemStatus: string, token: string): Promise; /** * Update a custom list. Only the list name or state can be updated - * @param {string} listId unique Id associated with the list - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param listObject listObject + * @param token bearer token for list management permission + * @returns Promise */ - updateList(listId: string, listObject: ListObject, token: string): Promise; + updateList(listId: string, listObject: ListObject, token: string): Promise; /** * Delete a custom list - * @param {string} listId unique Id associated with the list - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param token bearer token for list management permission + * @returns Promise */ - deleteList(listId: string, token: string): Promise; + deleteList(listId: string, token: string): Promise; /** * Create an item in an active list or in a default list - * @param {string} listId unique Id associated with the list - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param listItemObject listItemObject + * @param token bearer token for list management permission + * @returns Promise */ - createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; /** * Retrieve single item within any list by listId and itemId - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param token bearer token for list management permission + * @returns Promise */ - getListItem(listId: string, itemId: string, token: string): Promise; + getListItem(listId: string, itemId: string, token: string): Promise; /** * Update an item value or item status - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param listItemObject listItemObject + * @param token bearer token for list management permission + * @returns Promise */ - updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; /** * Delete an item in the specified list - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param token bearer token for list management permission + * @returns Promise */ - deleteListItem(listId: string, itemId: string, token: string): Promise; + deleteListItem(listId: string, itemId: string, token: string): Promise; } } //#endregion @@ -723,155 +730,132 @@ export namespace services { /** * Responsible for building JSON responses as per the Alexa skills kit interface * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax - * - * @class ResponseBuilder */ export class ResponseBuilder { constructor(alexaHandler: Handler); /** * Have Alexa say the provided speechOutput to the user - * - * @param {string} speechOutput - * @returns - * @memberof ResponseBuilder + * @param speechOutput speechOutput + * @returns ResponseBuilder */ speak(speechOutput: string): ResponseBuilder; /** * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds * then have alexa reprompt with the provided reprompt speech - * @param {string} repromptSpeech - * @returns - * @memberof ResponseBuilder + * @param repromptSpeech repromptSpeech + * @returns ResponseBuilder */ listen(repromptSpeech: string): ResponseBuilder; /** * Render a card with the following title, content and image - * - * @param {string} cardTitle - * @param {string} cardContent - * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage - * @returns - * @memberof ResponseBuilder + * @param cardTitle cardTitle + * @param cardContent cardContent + * @param cardImage cardImage + * @returns ResponseBuilder */ cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; /** * Render a link account card - * - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ linkAccountCard(): ResponseBuilder; /** * Render a askForPermissionsConsent card - * @param {[{ [key: string]: string }]} permissions - * @returns - * @memberOf ResponseBuilder + * @param permissions permissions + * @returns ResponseBuilder */ askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; /** * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead - * @param {string} directiveType - * @param {string} behavior - * @param {string} url - * @param {string} token - * @param {string} expectedPreviousToken - * @param {number} offsetInMilliseconds - * @returns - * @memberof ResponseBuilder + * @param directiveType directiveType + * @param behavior behavior + * @param url url + * @param token token + * @param expectedPreviousToken expectedPreviousToken + * @param offsetInMilliseconds offsetInMilliseconds + * @returns ResponseBuilder */ audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; /** * Creates an AudioPlayer play directive - * - * @param {string} behavior Describes playback behavior. Accepted values: + * @param behavior Describes playback behavior. Accepted values: * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. - * @param {string} url Identifies the location of audio content at a remote HTTPS location. - * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the - * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * @param url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. - * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters - * @param {string} expectedPreviousToken A token that represents the expected previous stream. - * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * @param token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions * if requests to progress through a playlist and change tracks occur at the same time. - * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * @param offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; /** * Creates an AudioPlayer Stop directive - Stops the current audio Playback - * - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerStop(): ResponseBuilder; /** * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, * or clear the queue and stop any currently playing stream. - * - * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * @param clearBehavior Describes the clear queue behavior. Accepted values: * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; /** * Creates a Display RenderTemplate Directive - * * Use a template builder to generate a template object - * - * @param {Template} template - * @returns - * @memberof ResponseBuilder + * @param template template + * @returns ResponseBuilder */ renderTemplate(template: Template): ResponseBuilder; /** * Creates a hint directive - show a hint on the screen of the echo show - * - * @param {string} hintText text to show on the hint - * @param {string} hintType (optional) Default value : PlainText - * @returns - * @memberof ResponseBuilder + * @param hintText text to show on the hint + * @param hintType (optional) Default value : PlainText + * @returns ResponseBuilder */ hint(hintText: string, hintType: string): ResponseBuilder; /** * Creates a VideoApp play directive to play a video - * - * @param {string} source Identifies the location of video content at a remote HTTPS location. + * @param source Identifies the location of video content at a remote HTTPS location. * The video file must be hosted at an Internet-accessible HTTPS endpoint. - * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * @param metadata (optional) Contains an object that provides the * information that can be displayed on VideoApp. - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; } //#endregion //#region directives export namespace directives { - export class VoicePlayerSpeakDirective { + class VoicePlayerSpeakDirective { + header: { requestId: string }; + directive: { type: string, speech: string }; /** * Creates an instance of VoicePlayerSpeakDirective. - * @param {string} requestId - requestId from which the call is originated from - * @param {string} speechContent - Contents of the speech directive either in plain text or SSML. - * @memberof DirectiveService + * @param requestId - requestId from which the call is originated from + * @param speechContent - Contents of the speech directive either in plain text or SSML. */ constructor(requestId: string, speechContent: string); } @@ -879,97 +863,74 @@ export namespace directives { //#endregion //#region utils export namespace utils { - export class ImageUtils { + namespace ImageUtils { /** * Creates an image object with a single source - * * These images may be in either JPEG or PNG formats, with the appropriate file extensions. * An image cannot be larger than 2 MB * You must host the images at HTTPS URLs that are publicly accessible. * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, * which means that larger images will be downscaled for display on Echo Show if provided. - * * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') - * - * @static - * @param {string} url url of the image - * @param {number} widthPixels (optional) width of the image in pixels - * @param {number} heightPixels (optional) height of the image in pixels - * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils + * @param url url of the image + * @param widthPixels (optional) width of the image in pixels + * @param heightPixels (optional) height of the image in pixels + * @param size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param description text used to describe the image in a screen reader + * @returns Image */ - public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; /** - * - * Creates an image object with a multiple sources, source images are provided as an array of image objects - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * example : - * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, - * ] - * ImageUtils.makeImage(imgArr, 'image description') - * - * @static - * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @param imgArr Array of Image + * @param description text used to describe the image in a screen reader + * @returns Image + */ + function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; } /** * Utility methods for building TextField objects - * - * @class TextUtils */ - export class TextUtils { - + namespace TextUtils { /** * Creates a plain TextField object with contents : text - * - * @static - * @param {string} text contents of plain text object - * @returns - * @memberof TextUtils + * @param text contents of plain text object + * @returns TextField */ - public static makePlainText(text: string): TextField; + function makePlainText(text: string): TextField; /** * Creates a rich TextField object with contents : text - * - * @static - * @param {string} text - * @returns - * @memberof TextUtils + * @param text text + * @returns TextField */ - public static makeRichText(text: string): TextField; + function makeRichText(text: string): TextField; /** * Creates a textContent - * - * @static - * @param {{type : string, text : string}} primaryText - * @param {{type : string, text : string}} secondaryText - * @param {{type : string, text : string}} tertiaryText - * @returns - * @memberof TextUtils + * @param primaryText primary Text + * @param secondaryText secondary Text + * @param tertiaryText tertiary Text + * @returns TextContent */ - public static makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + function makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent; } } //#endregion From 79261ec1db0240e80d9699e1f8113d60bc49f102 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 17:57:01 +0530 Subject: [PATCH 5/8] Updated Typescript version to 2.3 for the dependency i18next. --- types/alexa-sdk/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index e4ea78c104..5f4f9cf6ff 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -6,7 +6,7 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; From 713261fb718e5175ad7b0fe87d98ca732057414f Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Fri, 24 Nov 2017 18:12:39 +0530 Subject: [PATCH 6/8] Fixing Travis issues. Reverting TypeScript version: 2.2. Updated Context interface. Since aws-lambda-mock-context depends on this (alexa-sdk) which has lower typescript version but alexa-sdk should ideally depend on i18next which has higher TS version. Removing i18next from "alexa-sdk" --- types/alexa-sdk/index.d.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 5f4f9cf6ff..a9c630269f 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -6,8 +6,8 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 -import { i18n } from "i18next"; +// TypeScript Version: 2.2 + export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; @@ -91,7 +91,7 @@ export interface Handler { emitWithState: any; state: any; handler: any; - i18n: i18n; + i18n: any; locale: any; event: RequestBody; attributes: any; @@ -104,8 +104,16 @@ export interface Handler { } export interface Context { - System: System; - AudioPlayer: AudioPlayer; + callbackWaitsForEmptyEventLoop: boolean; + logGroupName: string; + logStreamName: string; + functionName: string; + memoryLimitInMB: string; + functionVersion: string; + invokeid: string; + awsRequestId: string; + System?: System; + AudioPlayer?: AudioPlayer; } export interface Application { applicationId: string; From 90e335c7e86629de863f8ac172cf188fb728f4f9 Mon Sep 17 00:00:00 2001 From: rk-7 <30998401+rk-7@users.noreply.github.com> Date: Sat, 25 Nov 2017 19:44:54 +0530 Subject: [PATCH 7/8] alexa-sdk: Reverted the ConfirmationStatuses and DialogStates enum values to types. Added more types. --- types/alexa-sdk/index.d.ts | 116 +++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 64 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index a9c630269f..33fdc6dd7b 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -11,6 +11,18 @@ export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; 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 type ListItemObjectStatus = "active" | "completed"; +export type ListObjectState = "active" | "archived"; +export type ImageSourceSize = "X_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "X_LARGE"; +export type TemplateBackButtonVisibility = "HIDDEN" | "VISIBLE"; +export type TemplateType = "BodyTemplate1" | "BodyTemplate2" | "BodyTemplate3" | "BodyTemplate6" | "BodyTemplate6" | "ListTemplate1" | "ListTemplate2"; +export type AudioPlayerActivity = "IDLE" | "PAUSED" | "PLAYING" | "BUFFER_UNDERRUN" | "FINISHED" | "STOPPED"; +export type CardType = "Standard" | "Simple" | "LinkAccount" | "AskForPermissionsConsent"; +export type HintType = "PlainText"; +export type DirectiveTypes = "AudioPlayer.Play" | "AudioPlayer.Stop" | "AudioPlayer.ClearQueue" | "Display.RenderTemplate" | "Hint" | "VideoApp.Launch"; +export type TextContentType = "PlainText" | "RichText"; //#region Types export interface CardImage { @@ -28,10 +40,14 @@ export interface ImageSource { widthPixels?: number; heightPixels?: number; /** - * Possible values: 'X_SMALL' | 'SMALL' | 'MEDIUM' | 'LARGE' | 'X_LARGE' - * Recommended size respectively (in px): 480 x 320 | 720 x 480 | 960 x 640 | 1200 x 800 | 1920 x 1280 + * Recommended sizes for the following dimensions (in px): + * 480 x 320 for X_SMALL, + * 720 x 480 for SMALL, + * 960 x 640 for MEDIUM, + * 1200 x 800 for LARGE, + * 1920 x 1280 for X_LARGE */ - size?: string; + size?: ImageSourceSize; } export interface Image { contentDescription: string; @@ -51,18 +67,19 @@ export interface ListItem { token: string; textContent?: TextContent; } + export interface Template { title?: string; token: string; backgroundImage?: Image; /** - * Possible values 'HIDDEN' | 'VISIBLE' + * Visibility of the back button. */ - backButton?: string; + backButton?: TemplateBackButtonVisibility; /** - * Possible values 'BodyTemplate1' | 'BodyTemplate2'| 'BodyTemplate3'| 'BodyTemplate6'| 'ListTemplate1'| 'ListTemplate2' + * Template type. */ - type: string; + type: TemplateType; image?: Image; listItems?: ListItem[]; } @@ -130,9 +147,9 @@ export interface AudioPlayer { token: string; offsetInMilliseconds: number; /** - * Possible values: 'IDLE'|'PAUSED'|'PLAYING'|'BUFFER_UNDERRUN'|'FINISHED'|'STOPPED' + * Player activity */ - playerActivity: string; + playerActivity: AudioPlayerActivity; } export interface RequestBody { version: string; @@ -162,10 +179,7 @@ export interface Permissions { export interface LaunchRequest extends Request { } export interface IntentRequest extends Request { - /** - * Possible values: 'STARTED'| 'IN_PROGRESS'| 'COMPLETED' - */ - dialogState?: string; + dialogState?: DialogStates; intent?: Intent; } @@ -204,20 +218,14 @@ export interface Resolutions { } export interface SlotValue { - /** - * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' - */ - confirmationStatus?: string; + confirmationStatus?: ConfirmationStatuses; name: string; value?: any; resolutions?: Resolutions; } export interface Intent { - /** - * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' - */ - confirmationStatus?: string; + confirmationStatus?: ConfirmationStatuses; name: string; slots: Record; } @@ -243,7 +251,7 @@ export interface OutputSpeech { } export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; + type: CardType; title?: string; content?: string; text?: string; @@ -253,31 +261,7 @@ export interface Card { export interface Reprompt { outputSpeech: OutputSpeech; } -export const CARD_TYPES: { - STANDARD: 'Standard', - SIMPLE: 'Simple', - LINK_ACCOUNT: 'LinkAccount', - ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' -}; -export const HINT_TYPES: { - PLAIN_TEXT: 'PlainText' -}; - -export const DIRECTIVE_TYPES: { - AUDIOPLAYER: { - PLAY: 'AudioPlayer.Play', - STOP: 'AudioPlayer.Stop', - CLEAR_QUEUE: 'AudioPlayer.ClearQueue' - }, - DISPLAY: { - RENDER_TEMPLATE: 'Display.RenderTemplate' - }, - HINT: 'Hint', - VIDEOAPP: { - LAUNCH: 'VideoApp.Launch' - } -}; export interface ApiClientOptions { hostname: string; port: string; @@ -307,9 +291,8 @@ export interface ListItemObject { value: string; /** * item status - * Possible values: "active" or "completed" */ - status?: string; + status?: ListItemObjectStatus; /** * item version (Positive integer | string) */ @@ -341,9 +324,10 @@ export interface ListObject { */ name: string; /** + * state * "active" or "archived" (Enum) */ - state?: string; + state?: ListObjectState; /** * Possibly status of the list (or state?) * Fetched from commit eebba0d at https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/ @@ -359,15 +343,15 @@ export interface ListObject { * href is lint to the items having certain status. * The status can be "active" or "completed". */ - statusMap: { href: string; status: string; }; + statusMap: { href: string; status: ListItemObjectStatus; }; /** * Items that belong to this list. */ items: ListItemObject[]; } //#endregion -//#region templateBuilders +//#region templateBuilders /** * Generates templates for Echo Show device. */ @@ -408,7 +392,7 @@ export namespace templateBuilders { /** * Sets the backButton behavior - * @param backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @param backButtonBehavior "VISIBLE" or "HIDDEN" * @returns TemplateBuilder */ setBackButtonBehavior(backButtonBehavior: string): T; @@ -558,6 +542,7 @@ export namespace templateBuilders { } } //#endregion + //#region services export namespace services { interface ApiClient { @@ -642,7 +627,7 @@ export namespace services { constructor(apiClient: ApiClient); /** - * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * Set apiEndpoint address, default is "https://api.amazonalexa.com" * @param apiEndpoint apiEndpoint * @returns void */ @@ -672,11 +657,11 @@ export namespace services { /** * Retrieve list metadata including the items in the list with requested status * @param listId unique Id associated with the list - * @param itemStatus itemsStatus can be either 'active' or 'completed' + * @param itemStatus itemsStatus can be either "active" or "completed" * @param token bearer token for list management permission * @returns Promise */ - getList(listId: string, itemStatus: string, token: string): Promise; + getList(listId: string, itemStatus: ListItemObjectStatus, token: string): Promise; /** * Update a custom list. Only the list name or state can be updated @@ -734,6 +719,7 @@ export namespace services { } } //#endregion + //#region ResponseBuilder /** * Responsible for building JSON responses as per the Alexa skills kit interface @@ -842,7 +828,7 @@ export class ResponseBuilder { * @param hintType (optional) Default value : PlainText * @returns ResponseBuilder */ - hint(hintText: string, hintType: string): ResponseBuilder; + hint(hintText: string, hintType: HintType): ResponseBuilder; /** * Creates a VideoApp play directive to play a video @@ -855,6 +841,7 @@ export class ResponseBuilder { playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; } //#endregion + //#region directives export namespace directives { class VoicePlayerSpeakDirective { @@ -869,6 +856,7 @@ export namespace directives { } } //#endregion + //#region utils export namespace utils { namespace ImageUtils { @@ -881,7 +869,7 @@ export namespace utils { * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, * which means that larger images will be downscaled for display on Echo Show if provided. - * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * example : ImageUtils.makeImage("https://url/to/my/img.png", 300, 400, "SMALL", "image description") * @param url url of the image * @param widthPixels (optional) width of the image in pixels * @param heightPixels (optional) height of the image in pixels @@ -889,7 +877,7 @@ export namespace utils { * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: ImageSourceSize, description?: string): Image; /** * Creates an image object with a multiple sources, source images are provided as an array of image objects * These images may be in either JPEG or PNG formats, with the appropriate file extensions. @@ -901,16 +889,16 @@ export namespace utils { * which means that larger images will be downscaled for display on Echo Show if provided. * example : * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * { "https://url/to/my/small.png", 300, 400, "SMALL" }, + * { "https://url/to/my/large.png", 900, 1200, "LARGE" }, * ] - * ImageUtils.makeImage(imgArr, 'image description') + * ImageUtils.makeImage(imgArr, "image description") * * @param imgArr Array of Image * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: ImageSourceSize }>, description: string): Image; } /** * Utility methods for building TextField objects @@ -937,8 +925,8 @@ export namespace utils { * @param tertiaryText tertiary Text * @returns TextContent */ - function makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent; + function makeTextContent(primaryText: { type: TextContentType, text: string }, + secondaryText: { type: TextContentType, text: string }, tertiaryText: { type: TextContentType, text: string }): TextContent; } } //#endregion From 29ba5a506ac3582d12a9cc505450f6970214373c Mon Sep 17 00:00:00 2001 From: rk-7 <30998401+rk-7@users.noreply.github.com> Date: Sat, 25 Nov 2017 23:35:50 +0530 Subject: [PATCH 8/8] Fixed minor type annotion issues. --- types/alexa-sdk/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 33fdc6dd7b..02def0b4d6 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -294,9 +294,9 @@ export interface ListItemObject { */ status?: ListItemObjectStatus; /** - * item version (Positive integer | string) + * item version (Positive integer) */ - version?: any; + version?: number | string; /** * created time (ISO 8601 time format with time zone) */ @@ -335,9 +335,9 @@ export interface ListObject { */ status?: string; /** - * list version (long | string) + * list version (Positive integer) */ - version?: any; + version?: number; /** * Urls to active and completed items * href is lint to the items having certain status. @@ -468,7 +468,7 @@ export namespace templateBuilders { * @param image image * @returns BodyTemplate3Builder */ - setImage(image: any): BodyTemplate3Builder; + setImage(image: Image): BodyTemplate3Builder; /** * Sets the text content for the template @@ -490,7 +490,7 @@ export namespace templateBuilders { * @param image image * @returns BodyTemplate6Builder */ - setImage(image: any): BodyTemplate6Builder; + setImage(image: Image): BodyTemplate6Builder; /** * Sets the text content for the template @@ -828,7 +828,7 @@ export class ResponseBuilder { * @param hintType (optional) Default value : PlainText * @returns ResponseBuilder */ - hint(hintText: string, hintType: HintType): ResponseBuilder; + hint(hintText: string, hintType?: HintType): ResponseBuilder; /** * Creates a VideoApp play directive to play a video @@ -838,7 +838,7 @@ export class ResponseBuilder { * information that can be displayed on VideoApp. * @returns ResponseBuilder */ - playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; + playVideo(source: string, metadata?: { title: string, subtitle: string }): ResponseBuilder; } //#endregion @@ -898,7 +898,7 @@ export namespace utils { * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: ImageSourceSize }>, description: string): Image; + function makeImages(imgArr: Array<{ url: string, widthPixels?: number, heightPixels?: number, size: ImageSourceSize }>, description: string): Image; } /** * Utility methods for building TextField objects