@inploi/plugin-chatbot 3.11.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chatbot.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Flow } from './chatbot.api';
1
2
  import { ChatbotDomManager } from './chatbot.dom';
2
3
  type RemoveInternal<T extends object> = {
3
4
  [P in keyof T as string extends P ? never : P extends `_${string}` ? never : P]: T[P];
@@ -5,6 +6,18 @@ type RemoveInternal<T extends object> = {
5
6
  export type ChatbotPlugin = typeof chatbotPlugin;
6
7
  export type ChatbotPluginParams = RemoveInternal<Parameters<ChatbotPlugin>[0]>;
7
8
  export type Chatbot = ReturnType<ReturnType<ChatbotPlugin>>;
9
+ export type OpenChatbotParams = {
10
+ flow: Flow;
11
+ /** Specify the cache keys for restoring this flow from local state.
12
+ * This will be appended to the flow id and version passed to `flow` property.
13
+ * @example [job.id] if you want the flows to be unique per job.
14
+ */
15
+ flowKeys: string[];
16
+ /** Context to be forwarded to analytics or used by nodes internally. */
17
+ context: Record<string, unknown>;
18
+ /** Title to display in the status bar */
19
+ title: string;
20
+ };
8
21
  export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
9
22
  theme: {
10
23
  /** Rotation for the hue. Between 0 and 360. */
@@ -22,11 +35,18 @@ export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
22
35
  logger: import("@inploi/sdk").Logger;
23
36
  analytics: import("@inploi/sdk").AnalyticsService;
24
37
  }) => {
25
- /** Optionally eagerly renders the interface ahead of application requests. */
38
+ /** Optionally eagerly renders the interface ahead of needing the chatbot. */
26
39
  prepare: () => Promise<void>;
27
- startApplication: ({ jobId }: {
28
- jobId: string;
29
- }) => Promise<void>;
30
- closeApplication: () => Promise<void>;
40
+ /** Fetches a flow by job ID.
41
+ * @param jobId - The job ID to fetch the flow for. This is the job ID according to the **ATS**, and not the inploi job ID.
42
+ */
43
+ fetchFlowByJobId: (jobId: string) => Promise<OpenChatbotParams>;
44
+ fetchFlowById: (flowId: string) => Promise<OpenChatbotParams>;
45
+ open: (params: OpenChatbotParams | Promise<OpenChatbotParams>) => Promise<void>;
46
+ /** @deprecated - Please use `open` instead. */
47
+ startApplication: never;
48
+ /** @deprecated - Please use `close` instead */
49
+ closeApplication: never;
50
+ close: () => Promise<void>;
31
51
  };
32
52
  export {};
@@ -1,9 +1,17 @@
1
- import { JobApplication } from './chatbot.api';
2
- import { ApplicationData } from './chatbot.state';
1
+ import { Flow } from './chatbot.api';
2
+ import { ChatMessage, KeyToSubmissionMap, StartedFlow } from './chatbot.state';
3
+ import { ChatInput } from './components/chat-input/chat-input';
3
4
  export declare const idb: {
4
- getApplicationData: (application: JobApplication) => Promise<ApplicationData | undefined>;
5
- setApplicationData: (params: {
6
- application: JobApplication;
7
- data: ApplicationData;
8
- }) => Promise<void>;
5
+ getStateData: (flow: Flow, flowKeys: string[]) => Promise<{
6
+ currentInput: ChatInput | null;
7
+ nodeHistory: string[];
8
+ flowSessionId: string;
9
+ isFinished: boolean;
10
+ messages: (ChatMessage & {
11
+ groupId?: string;
12
+ })[];
13
+ sequence: number;
14
+ submissions: KeyToSubmissionMap;
15
+ } | undefined>;
16
+ setStateData: (params: StartedFlow) => Promise<string | undefined>;
9
17
  };
@@ -1,5 +1,5 @@
1
1
  import { FlowNode } from '@inploi/core/flows';
2
- import { ApplicationSubmission, KeyToSubmissionMap } from './chatbot.state';
2
+ import { FlowSubmission, KeyToSubmissionMap } from './chatbot.state';
3
3
  export type DistributivePick<T, K extends keyof T> = T extends unknown ? Pick<T, K> : never;
4
4
  export declare const kbToReadableSize: (kb: number) => string;
5
5
  export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
@@ -159,17 +159,20 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
159
159
  isHead?: boolean | undefined;
160
160
  nextId?: string | undefined;
161
161
  };
162
- export declare const getApplicationSubmissionsPayload: (submissions: KeyToSubmissionMap) => Record<string, string | string[] | import("./components/chat-input/chat-input.file").FileToUpload[] | null>;
163
- export declare const isSubmissionOfType: <T extends "boolean" | "text" | "multiple-choice" | "file">(type: T) => (submission?: ApplicationSubmission) => submission is Extract<Pick<import("./components/chat-input/chat-input.text").TextPayload, "value" | "type">, {
162
+ export declare const getFlowSubmissionsPayload: (submissions: KeyToSubmissionMap) => Record<string, string | string[] | import("./components/chat-input/chat-input.file").FileToUpload[] | null>;
163
+ export declare const isSubmissionOfType: <T extends "boolean" | "text" | "multiple-choice" | "file" | "submit">(type: T) => (submission?: FlowSubmission) => submission is Extract<Pick<import("./components/chat-input/chat-input.text").TextPayload, "type" | "value">, {
164
164
  type: T;
165
- }> | Extract<Pick<import("./components/chat-input/chat-input.multiple-choice").MultipleChoicePayload, "value" | "type">, {
165
+ }> | Extract<Pick<import("./components/chat-input/chat-input.multiple-choice").MultipleChoicePayload, "type" | "value">, {
166
166
  type: T;
167
- }> | Extract<Pick<import("./components/chat-input/chat-input.boolean").BooleanChoicePayload, "value" | "type">, {
167
+ }> | Extract<Pick<import("./components/chat-input/chat-input.boolean").BooleanChoicePayload, "type" | "value">, {
168
168
  type: T;
169
- }> | Extract<Pick<import("./components/chat-input/chat-input.file").FilePayload, "value" | "type">, {
169
+ }> | Extract<Pick<import("./components/chat-input/chat-input.file").FilePayload, "type" | "value">, {
170
+ type: T;
171
+ }> | Extract<Pick<import("./components/chat-input/chat-input.submit").SubmitPayload, "type" | "value">, {
170
172
  type: T;
171
173
  }>;
172
174
  export declare function gzip(string: string): string | Promise<string>;
173
175
  export declare class AbortedError extends Error {
174
176
  constructor();
175
177
  }
178
+ export declare function debounce<TFn extends (...params: any[]) => void>(func: TFn, timeout?: number): TFn;