iopa-bot
Version:
API-First Bot Framework for Internet of Things (IoT), based on Internet of Protocols Alliance (IOPA) specification
49 lines (48 loc) • 1.49 kB
TypeScript
import * as Iopa from 'iopa';
import type { ActionElement } from 'reactive-dialogs';
interface Db {
get<T>(path: string): Promise<T | null>;
put<T>(path: string, item: T): Promise<void>;
delete(path: string): Promise<void>;
}
export interface Session {
id: string;
updated: number;
[key: string]: any;
}
export interface SessionDbCapability {
get(id: string, timeout: number): Promise<Session>;
put(session: Partial<Session> & {
id: string;
}): any;
delete(id: string): any;
dispose(): any;
}
export interface SessionCurrentDialog {
id: string;
iopaBotVersion: '2.0';
lastDirective: number | null;
previousId: string;
lastPromptActions: ActionElement[] | null;
}
export interface ReactiveDialogsSession {
'id': string;
'bot:CurrentDialog': SessionCurrentDialog | null;
'bot:LastDialogEndedDate': number | null;
'bot:NewSession': boolean;
'bot:Skill': string;
'bot:SkillVersion': string;
'bot:Slots': string;
'bot:Variables': any;
'isMultiChoicePrompt': boolean;
[key: string]: any;
}
export declare const useBotSession: (context: Iopa.Context) => [Partial<ReactiveDialogsSession>, (newState: Partial<ReactiveDialogsSession>) => Promise<void>];
export default class SessionMiddleware implements Iopa.Component {
enabled: boolean;
app: Iopa.App | null;
db: Db | null;
constructor(app: Iopa.App);
invoke(context: any, next: any): Promise<any>;
}
export {};