diff --git a/packages/botonic-core/index.d.ts b/packages/botonic-core/index.d.ts index f4fad009e3..6ca3181381 100644 --- a/packages/botonic-core/index.d.ts +++ b/packages/botonic-core/index.d.ts @@ -18,7 +18,6 @@ export interface Input { entities?: any } - export interface SessionUser { id: string // login @@ -45,10 +44,16 @@ export interface Session { } type StringMatcher = RegExp | string | ((data: string) => boolean) -type ParamsMatcher = { [key: string]: string } | ((params: { [key: string]: string }) => boolean) +type ParamsMatcher = + | { [key: string]: string } + | ((params: { [key: string]: string }) => boolean) type SessionMatcher = (session: Session) => boolean type InputMatcher = (input: Input) => boolean -type RouteMatcher = StringMatcher | ParamsMatcher| SessionMatcher | InputMatcher +type RouteMatcher = + | StringMatcher + | ParamsMatcher + | SessionMatcher + | InputMatcher export interface Route { path?: StringMatcher @@ -80,6 +85,7 @@ export class HandOffBuilder { withAgentEmail(email: string): HandOffBuilder withNoteURL(note: string): HandOffBuilder withCaseInfoURL(caseInfo: string): HandOffBuilder + withShadowing(shadowing?: boolean): HandOffBuilder handOff(): Promise } @@ -118,6 +124,13 @@ export declare function getAvailableAgents( session: Session ): Promise<{ agents: HubtypeAgentsInfo[] }> +export declare function cancelHandoff( + session: Session, + typification?: string +): void + +export declare function deleteUser(session: Session): void + export interface BotRequest { input: Input session: Session @@ -176,8 +189,18 @@ export class CoreBot { // Debug export class RouteInspector { - routeMatched(route: Route, routeKey: string, routeValue: RouteMatcher, input: Input): void; - routeNotMatched(route: Route, routeKey: string, routeValue: RouteMatcher, input: Input): void; + routeMatched( + route: Route, + routeKey: string, + routeValue: RouteMatcher, + input: Input + ): void + routeNotMatched( + route: Route, + routeKey: string, + routeValue: RouteMatcher, + input: Input + ): void } export class FocusRouteInspector extends RouteInspector { @@ -185,11 +208,10 @@ export class FocusRouteInspector extends RouteInspector { focusOnlyOnMatches(): FocusRouteInspector } -export class LogRouteInspector extends FocusRouteInspector { -} +export class LogRouteInspector extends FocusRouteInspector {} export class Inspector { - constructor(routeInspector: RouteInspector | undefined); + constructor(routeInspector: RouteInspector | undefined) - getRouteInspector(): RouteInspector; + getRouteInspector(): RouteInspector } diff --git a/packages/botonic-core/package.json b/packages/botonic-core/package.json index aab03565b8..7b295aee05 100644 --- a/packages/botonic-core/package.json +++ b/packages/botonic-core/package.json @@ -7,7 +7,7 @@ "test": "../../node_modules/.bin/jest --coverage", "prepare": "node ../../preinstall.js", "lint": "npm run lint_ci -- --fix", - "lint_ci": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.js*'", + "lint_ci": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.js*' '**/*.d.ts'", "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files" }, "repository": { diff --git a/packages/botonic-core/src/handoff.js b/packages/botonic-core/src/handoff.js index fd1130e228..d8a57e0caf 100644 --- a/packages/botonic-core/src/handoff.js +++ b/packages/botonic-core/src/handoff.js @@ -49,6 +49,11 @@ export class HandOffBuilder { return this } + withShadowing(shadowing = true) { + this._shadowing = shadowing + return this + } + async handOff() { return _humanHandOff( this._session, @@ -56,7 +61,8 @@ export class HandOffBuilder { this._onFinish, this._email, this._caseInfo, - this._note + this._note, + this._shadowing ) } } @@ -87,7 +93,8 @@ async function _humanHandOff( onFinish, agentEmail = '', caseInfo = '', - note = '' + note = '', + shadowing = false ) { const params = {} if (!queueNameOrId && agentEmail) { @@ -105,6 +112,9 @@ async function _humanHandOff( if (note) { params.note = note } + if (shadowing) { + params.shadowing = shadowing + } if (onFinish) { params.on_finish = onFinish @@ -151,3 +161,13 @@ export async function getAvailableAgents(session) { }) return resp.data } + +export function cancelHandoff(session, typification = null) { + let action = 'discard_case' + if (typification) action = `${action}:${JSON.stringify({ typification })}` + session._botonic_action = action +} + +export function deleteUser(session) { + session._botonic_action = `delete_user` +} diff --git a/packages/botonic-core/src/index.js b/packages/botonic-core/src/index.js index ef63e897a5..97edd9314a 100644 --- a/packages/botonic-core/src/index.js +++ b/packages/botonic-core/src/index.js @@ -6,6 +6,8 @@ export { HandOffBuilder, storeCaseRating, getAvailableAgents, + cancelHandoff, + deleteUser, } from './handoff' export { getNLU } from './nlu' export { isBrowser, isNode, isMobile, params2queryString } from './utils' diff --git a/packages/botonic-react/package.json b/packages/botonic-react/package.json index 6d7a78bdcb..9ca629e3db 100644 --- a/packages/botonic-react/package.json +++ b/packages/botonic-react/package.json @@ -9,7 +9,7 @@ "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files", "lint": "npm run lint_core -- --fix", "lint_ci": "npm run lint_core", - "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.js*' 'src/**/*.d.ts' 'tests/**/*.js' 'tests/**/*.jsx'" + "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.js*' '**/*.d.ts' 'tests/**/*.js' 'tests/**/*.jsx'" }, "sideEffects": [ "*.(scss|css)"