wa-chat-server
Version:
Watson Assistant powered chat server
74 lines (73 loc) • 2.94 kB
TypeScript
import { IPostprocessingService } from './../interface/IPostprocessingService';
import AssistantV1 from 'ibm-watson/assistant/v1';
import { ILogger } from '../interface/ILogger';
import { IConversationAPI } from '../interface/IConversationAPI';
import { IConversationServices } from '../interface/IConversationServices';
import { IPreprocessingService } from '../interface/IPreprocessingService';
import { IWatsonWrapperRequest } from '../interface/IWatsonWrapperRequest';
import { IRequestMeta } from '../interface/IRequestMeta';
import { ISession } from '../interface/ISession';
/**
* This class
* 1) pre-process the request to be sent to Watson
* 2) transparently calls watson repeatedly if a conversation service call
* is reqested in the context
*/
export declare class WatsonWrapper {
private logger;
private adapter;
private conversationServices;
private preProcessingServices;
private postProcessingServices;
private request;
private meta;
private session;
private static successIntent;
private static failureIntent;
private static requestPrefix;
private static defaultResultPathInWatsonCtx;
private static defaultErrorPathInWatsonCtx;
private watsonReq;
private watsonRes;
private preProcessedReq;
private conversationServiceName;
private conversationService;
private conversationServiceReq;
private conversationServiceRes;
private conversationServiceError;
private callNum;
constructor(logger: ILogger, adapter: IConversationAPI, conversationServices: IConversationServices, preProcessingServices: Array<IPreprocessingService>, postProcessingServices: Array<IPostprocessingService>, request: IWatsonWrapperRequest, meta: IRequestMeta, session: ISession);
private copyWatsonReqFrom;
/**
* Adds user id to this.watsonReq
*/
private mapMetaInfoToContext;
/**
* Adds user id to this.watsonReq
*/
private handleUserId;
private copyContextFromResToReq;
private callWatson;
private getConversationService;
private callConversationService;
getResponse(): Promise<AssistantV1.Response>;
private getFinalWatsonRes;
private getMergedWatsonRes;
private addFailureIntentToWatsonReq;
private addSuccessIntentToWatsonReq;
private addIntentToWatsonReq;
/**
* Returns a function that can map the provided value to the given
* path of the watson context; the returned function can handle both
* primitive typed parameter as well as an object
*/
private createMapperToWatsonReqContext;
private addConversationServiceErrorToWatsonReq;
private addConversationServiceResultToWatsonReq;
private conversationServiceCallRequired;
private getRequestDirectiveFromWatsonRes;
private getConversationServiceName;
private validateServiceName;
private getConversationServiceRequest;
private callWatsonMessage;
}