@inploi/plugin-chatbot 3.2.5 → 3.2.6

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.
@@ -0,0 +1,30 @@
1
+ import { FlowNode } from '@inploi/core/flows';
2
+ import { ApiClient, Logger } from '@inploi/sdk';
3
+ type Result<T> = {
4
+ ok: true;
5
+ value: T;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ };
10
+ export type JobApplication = {
11
+ job: {
12
+ id: string;
13
+ title: string;
14
+ };
15
+ company: {
16
+ name: string;
17
+ logo?: string;
18
+ };
19
+ flow: {
20
+ id: string;
21
+ version: number;
22
+ nodes: FlowNode[];
23
+ };
24
+ };
25
+ export declare function getApplicationData({ jobId, apiClient, logger, }: {
26
+ jobId: string;
27
+ apiClient: ApiClient;
28
+ logger: Logger;
29
+ }): Promise<Result<JobApplication>>;
30
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const CHATBOT_ELEMENT_ID = "isdk";
2
+ export declare const HEADER_HEIGHT = 44;
3
+ export declare const ERROR_MESSAGES: {
4
+ not_in_local_storage: string;
5
+ invalid_end_node: string;
6
+ no_submissions: string;
7
+ invalid_state: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ import { JobApplication } from './chatbot.api';
2
+ import { ApplicationData } from './chatbot.state';
3
+ export declare const idb: {
4
+ getApplicationData: (application: JobApplication) => Promise<ApplicationData | undefined>;
5
+ setApplicationData: (params: {
6
+ application: JobApplication;
7
+ data: ApplicationData;
8
+ }) => Promise<void>;
9
+ };
@@ -0,0 +1,90 @@
1
+ import { Signal } from '@preact/signals';
2
+ import { JobApplication } from './chatbot.api';
3
+ import { DistributivePick } from './chatbot.utils';
4
+ import { ChatInput } from './ui/chat-input/chat-input';
5
+ import { ChatbotInput } from './ui/chat-input/chat-input';
6
+ export declare const getCacheKey: (application: JobApplication) => string;
7
+ export type ViewState = 'maximised' | 'minimised';
8
+ export declare const viewState: Signal<ViewState>;
9
+ export declare const inputHeight: Signal<number>;
10
+ export type StartedJobApplication = JobApplication & {
11
+ data: ApplicationData;
12
+ startedAt: Date;
13
+ };
14
+ type CurrentApplication = {
15
+ state: 'idle';
16
+ application?: never;
17
+ error?: never;
18
+ } | {
19
+ state: 'loading';
20
+ application?: never;
21
+ error?: never;
22
+ } | {
23
+ state: 'loaded';
24
+ application: StartedJobApplication;
25
+ error?: never;
26
+ } | {
27
+ state: 'error';
28
+ application?: never;
29
+ error: string;
30
+ };
31
+ export declare const application: {
32
+ current$: Signal<CurrentApplication>;
33
+ start: (application: JobApplication) => Promise<void>;
34
+ cancel: () => void;
35
+ markAsFinished: () => Promise<void>;
36
+ setCurrentNodeId: (currentNodeId: string) => Promise<void>;
37
+ restart: () => void;
38
+ addMessage: (message: ChatMessage, groupId?: string) => Promise<void>;
39
+ /** Removes from the last message backwards, all the messages that have the groupId passed, until it reaches one that doesn't */
40
+ removeLastGroupMessagesById: (groupId: string) => void;
41
+ setSubmission: (fieldKey: string, submission: ApplicationSubmission) => Promise<void>;
42
+ setInput: (input: ChatInput | undefined) => Promise<void>;
43
+ };
44
+ export type MessageAuthor = 'bot' | 'user';
45
+ type SystemMessage = {
46
+ type: 'system';
47
+ text: string;
48
+ variant: 'info' | 'warning' | 'error' | 'success';
49
+ };
50
+ type TextMessage = {
51
+ author: MessageAuthor;
52
+ type: 'text';
53
+ text: string;
54
+ };
55
+ type LinkMessage = {
56
+ type: 'link';
57
+ href: string;
58
+ text: string;
59
+ };
60
+ type ImageMessage = {
61
+ author: MessageAuthor;
62
+ type: 'image';
63
+ url: string;
64
+ width: number;
65
+ height: number;
66
+ };
67
+ type FileMessage = {
68
+ author: MessageAuthor;
69
+ type: 'file';
70
+ fileName: string;
71
+ fileSizeKb: number;
72
+ };
73
+ export type ChatMessage = TextMessage | ImageMessage | SystemMessage | FileMessage | LinkMessage;
74
+ export type ApplicationSubmission = DistributivePick<ChatbotInput, 'type' | 'value'>;
75
+ export type KeyToSubmissionMap = {
76
+ [key: string]: ApplicationSubmission;
77
+ };
78
+ /** Dynamic part of an application */
79
+ export type ApplicationData = {
80
+ /** History of messages left in the chat */
81
+ messages: (ChatMessage & {
82
+ groupId?: string;
83
+ })[];
84
+ submissions: KeyToSubmissionMap;
85
+ currentNodeId: string;
86
+ /** Needs to be separate because a node can have many inputs */
87
+ currentInput?: ChatInput;
88
+ isFinished: boolean;
89
+ };
90
+ export {};
@@ -0,0 +1,160 @@
1
+ import { FlowNode } from '@inploi/core/flows';
2
+ import { ApplicationSubmission, KeyToSubmissionMap } from './chatbot.state';
3
+ export type DistributivePick<T, K extends keyof T> = T extends unknown ? Pick<T, K> : never;
4
+ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
5
+ id: string;
6
+ data: {
7
+ text: string;
8
+ };
9
+ type: "text";
10
+ isHead?: boolean | undefined;
11
+ nextId?: string | undefined;
12
+ } | {
13
+ id: string;
14
+ data: {
15
+ systemMessage?: string | undefined;
16
+ };
17
+ type: "end-flow";
18
+ isHead?: boolean | undefined;
19
+ nextId?: string | undefined;
20
+ } | {
21
+ id: string;
22
+ data: {
23
+ type: "ats";
24
+ };
25
+ type: "submit";
26
+ isHead?: boolean | undefined;
27
+ nextId?: string | undefined;
28
+ } | {
29
+ id: string;
30
+ data: {
31
+ href: string;
32
+ cta: string;
33
+ };
34
+ type: "link";
35
+ isHead?: boolean | undefined;
36
+ nextId?: string | undefined;
37
+ } | {
38
+ id: string;
39
+ data: {
40
+ url: string;
41
+ width: number;
42
+ height: number;
43
+ };
44
+ type: "image";
45
+ isHead?: boolean | undefined;
46
+ nextId?: string | undefined;
47
+ } | {
48
+ id: string;
49
+ data: {
50
+ key: string;
51
+ question: string;
52
+ trueLabel: string;
53
+ falseLabel: string;
54
+ };
55
+ type: "question-boolean";
56
+ isHead?: boolean | undefined;
57
+ nextId?: string | undefined;
58
+ } | {
59
+ id: string;
60
+ data: {
61
+ key: string;
62
+ question: string;
63
+ format: "text" | "url" | "email" | "phone";
64
+ placeholder?: string | undefined;
65
+ };
66
+ type: "question-text";
67
+ isHead?: boolean | undefined;
68
+ nextId?: string | undefined;
69
+ } | {
70
+ id: string;
71
+ data: {
72
+ key: string;
73
+ question: string;
74
+ placeholder?: string | undefined;
75
+ decimalCases?: number | undefined;
76
+ min?: number | undefined;
77
+ max?: number | undefined;
78
+ };
79
+ type: "question-number";
80
+ isHead?: boolean | undefined;
81
+ nextId?: string | undefined;
82
+ } | {
83
+ id: string;
84
+ data: {
85
+ options: {
86
+ value: string;
87
+ label: string;
88
+ }[];
89
+ key: string;
90
+ question: string;
91
+ maxSelected: number;
92
+ minSelected: number;
93
+ };
94
+ type: "question-enum";
95
+ isHead?: boolean | undefined;
96
+ nextId?: string | undefined;
97
+ } | {
98
+ id: string;
99
+ data: {
100
+ key: string;
101
+ question: string;
102
+ extensions: string[];
103
+ multiple?: boolean | undefined;
104
+ maxSizeKb?: number | undefined;
105
+ };
106
+ type: "question-file";
107
+ isHead?: boolean | undefined;
108
+ nextId?: string | undefined;
109
+ } | {
110
+ id: string;
111
+ data: {
112
+ keys: {
113
+ line1: string;
114
+ line2: string;
115
+ line3: string;
116
+ city: string;
117
+ state: string;
118
+ postcode: string;
119
+ country: string;
120
+ };
121
+ question: string;
122
+ placeholder?: string | undefined;
123
+ };
124
+ type: "question-address";
125
+ isHead?: boolean | undefined;
126
+ nextId?: string | undefined;
127
+ } | {
128
+ id: string;
129
+ data: {
130
+ compareKey: string;
131
+ compareValue: string;
132
+ compare: "equals" | "notEquals" | "contains" | "notContains";
133
+ };
134
+ type: "if-block";
135
+ isHead?: boolean | undefined;
136
+ nextId?: string | undefined;
137
+ branchId?: string | undefined;
138
+ } | {
139
+ id: string;
140
+ data: {
141
+ targetId: string;
142
+ };
143
+ type: "jump";
144
+ isHead?: boolean | undefined;
145
+ nextId?: string | undefined;
146
+ };
147
+ export declare const getApplicationSubmissionsPayload: (submissions: KeyToSubmissionMap) => Record<string, string | string[] | import("./ui/chat-input/chat-input.file").FileToUpload[]>;
148
+ export declare const isSubmissionOfType: <T extends "boolean" | "text" | "multiple-choice" | "file">(type: T) => (submission?: ApplicationSubmission) => submission is Extract<Pick<import("./ui/chat-input/chat-input.text").TextPayload, "value" | "type">, {
149
+ type: T;
150
+ }> | Extract<Pick<import("./ui/chat-input/chat-input.multiple-choice").MultipleChoicePayload, "value" | "type">, {
151
+ type: T;
152
+ }> | Extract<Pick<import("./ui/chat-input/chat-input.boolean").BooleanChoicePayload, "value" | "type">, {
153
+ type: T;
154
+ }> | Extract<Pick<import("./ui/chat-input/chat-input.file").FilePayload, "value" | "type">, {
155
+ type: T;
156
+ }>;
157
+ export declare function gzip(string: string): string | Promise<string>;
158
+ export declare class AbortedError extends Error {
159
+ constructor();
160
+ }