UNPKG

@jargon/actions-on-google

Version:

The Jargon Actions on Google SDK makes it easy to manage the content of your Google Action

133 lines (132 loc) 4.96 kB
import { RenderItem, ResourceManager } from '@jargon/sdk-core'; import { BasicCard, BrowseCarouselItem, Button, GoogleActionsV2UiElementsBasicCardImageDisplayOptions, GoogleActionsV2UiElementsButton, GoogleActionsV2UiElementsImage, GoogleActionsV2UiElementsOpenUrlAction, GoogleActionsV2UiElementsTableCardColumnPropertiesHorizontalAlignment, Image, LinkOutSuggestion, MediaObject, SimpleResponse, Suggestions, Table, TableColumn, TableRow } from 'actions-on-google'; /** * A Jargonized version of BasicCardOptions */ export interface JBasicCardOptions { title?: RenderItem; subtitle?: RenderItem; text?: RenderItem; image?: GoogleActionsV2UiElementsImage; buttons?: GoogleActionsV2UiElementsButton | GoogleActionsV2UiElementsButton[]; display?: GoogleActionsV2UiElementsBasicCardImageDisplayOptions; } /** * A Jargonized version of BrowseCarouselItemOptions */ export interface JBrowseCarouselItemOptions { title: RenderItem; url: string; description?: RenderItem; footer?: RenderItem; image?: GoogleActionsV2UiElementsImage; } /** * A Jargonized version of ButtonOptions */ export interface JButtonOptions { title: RenderItem; url?: string; action?: GoogleActionsV2UiElementsOpenUrlAction; } /** * A Jargonized version of ImageOptions */ export interface JImageOptions { url: string; alt: RenderItem; height?: number; width?: number; } /** * A Jargonized version of LinkOutSuggestionOptions */ export interface JLinkOutSuggestionOptions { name: RenderItem; url: string; } /** * A Jargonized version of MediaObjectOptions */ export interface JMediaObjectOptions { url: string; description?: RenderItem; name?: RenderItem; icon?: GoogleActionsV2UiElementsImage; image?: GoogleActionsV2UiElementsImage; } /** * A Jargonized version of SimpleResponseOptions */ export interface JSimpleResponseOptions { speech: RenderItem; text?: RenderItem; } /** * A Jargonized version of TableOptions */ export interface JTableOptions { title?: RenderItem; subtitle?: RenderItem; image?: GoogleActionsV2UiElementsImage; columns?: (TableColumn | string)[] | number; columnProperties?: (TableColumn | string)[]; rows: (TableRow | string[])[]; dividers?: boolean; buttons?: GoogleActionsV2UiElementsButton | GoogleActionsV2UiElementsButton[]; } /** * A Jargonized version of TableColumn */ export interface JTableColumn { header?: RenderItem; horizontalAlignment?: GoogleActionsV2UiElementsTableCardColumnPropertiesHorizontalAlignment; align?: GoogleActionsV2UiElementsTableCardColumnPropertiesHorizontalAlignment; } /** * A Jargonized version of TableRow */ export interface JTableRow { cells?: RenderItem[]; dividerAfter?: boolean; } /** * ResponseFactory simplifies the construction of response objects via the Jargon * SDK. The various options objects mirror the constructors for the associated Actions * on Google response objects, but take RenderItems instead of raw string parameters for * content that is spoken or displayed to the end user. * * Note that all of the methods in ResponseFactory return a Promise to the response object. */ export interface ResponseFactory { basicCard(options: JBasicCardOptions): Promise<BasicCard>; browseCarouselItem(options: JBrowseCarouselItemOptions): Promise<BrowseCarouselItem>; button(options: JButtonOptions): Promise<Button>; image(options: JImageOptions): Promise<Image>; linkOutSuggestion(options: JLinkOutSuggestionOptions): Promise<LinkOutSuggestion>; mediaObject(options: JMediaObjectOptions): Promise<MediaObject>; simple(options: JSimpleResponseOptions | RenderItem): Promise<SimpleResponse>; suggestions(...suggestions: RenderItem[]): Promise<Suggestions>; table(options: JTableOptions): Promise<Table>; tableColumn(column: JTableColumn): Promise<TableColumn>; tableRow(row: JTableRow): Promise<TableRow>; } /** * The core implementation of ResponseFactory */ export declare class CommonResponseFactory implements ResponseFactory { private _rm; constructor(_rm: ResourceManager); basicCard(options: JBasicCardOptions): Promise<BasicCard>; browseCarouselItem(options: JBrowseCarouselItemOptions): Promise<BrowseCarouselItem>; button(options: JButtonOptions): Promise<Button>; image(options: JImageOptions): Promise<Image>; linkOutSuggestion(options: JLinkOutSuggestionOptions): Promise<LinkOutSuggestion>; mediaObject(options: JMediaObjectOptions): Promise<MediaObject>; simple(options: JSimpleResponseOptions | RenderItem): Promise<SimpleResponse>; suggestions(...suggestions: RenderItem[]): Promise<Suggestions>; table(options: JTableOptions): Promise<Table>; tableColumn(column: JTableColumn): Promise<TableColumn>; tableRow(row: JTableRow): Promise<TableRow>; protected _render<J, G>(jOpts: J, fields: string[]): Promise<G>; }