@inploi/plugin-chatbot 3.15.0 → 3.16.1
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/cdn/index.js +11 -11
- package/dist/{chatbot-body-0131fc86.js → chatbot-body-59fab6f6.js} +754 -174
- package/dist/{chatbot-body-daedf7bd.cjs → chatbot-body-9bce9c3f.cjs} +754 -174
- package/dist/chatbot.d.ts +1 -3
- package/dist/chatbot.state.d.ts +127 -0
- package/dist/chatbot.utils.d.ts +10 -7
- package/dist/conditions.d.ts +3 -0
- package/dist/conditions.test.d.ts +1 -0
- package/dist/{index-51b0335a.cjs → index-154bf9a3.cjs} +3 -1
- package/dist/{index-b1d81d1c.js → index-dfe3ef24.js} +26 -24
- package/dist/interpreter.d.ts +8 -7
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +2 -2
- package/package.json +7 -6
package/dist/chatbot.d.ts
CHANGED
|
@@ -27,9 +27,7 @@ export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
|
|
|
27
27
|
mode: 'light' | 'dark';
|
|
28
28
|
};
|
|
29
29
|
/** @deprecated For internal usage only */
|
|
30
|
-
_internal_domManager?:
|
|
31
|
-
getOrCreateChatbotElement: () => HTMLElement;
|
|
32
|
-
} | undefined;
|
|
30
|
+
_internal_domManager?: ChatbotDomManager;
|
|
33
31
|
}) => ({ apiClient, logger, analytics }: {
|
|
34
32
|
apiClient: import("@inploi/sdk").ApiClient;
|
|
35
33
|
logger: import("@inploi/sdk").Logger;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { OpenChatbotParams } from '.';
|
|
2
|
+
import { Flow } from './chatbot.api';
|
|
3
|
+
import { ChatInput } from './components/chat-input/chat-input';
|
|
4
|
+
import { ChatbotFlowProgress } from './progress';
|
|
5
|
+
export declare const getCacheKey: (flow: Pick<StartedFlow, 'flowKeys' | 'id' | 'version'>) => string;
|
|
6
|
+
export type StartedFlow = Flow & {
|
|
7
|
+
flowKeys: string[];
|
|
8
|
+
title: string;
|
|
9
|
+
data: FlowStateData;
|
|
10
|
+
startedAt: Date;
|
|
11
|
+
context: Record<string, unknown>;
|
|
12
|
+
nodeIdToProgress: Record<string, ChatbotFlowProgress>;
|
|
13
|
+
};
|
|
14
|
+
type CurrentFlow = {
|
|
15
|
+
state: 'idle';
|
|
16
|
+
flow?: never;
|
|
17
|
+
error?: never;
|
|
18
|
+
} | {
|
|
19
|
+
state: 'loading';
|
|
20
|
+
flow?: never;
|
|
21
|
+
error?: never;
|
|
22
|
+
} | {
|
|
23
|
+
state: 'loaded';
|
|
24
|
+
flow: StartedFlow;
|
|
25
|
+
error?: never;
|
|
26
|
+
} | {
|
|
27
|
+
state: 'error';
|
|
28
|
+
flow?: never;
|
|
29
|
+
error: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const store: {
|
|
32
|
+
current$: import("@preact/signals").Signal<CurrentFlow>;
|
|
33
|
+
viewState$: import("@preact/signals").Signal<"maximised" | "minimised" | "closed">;
|
|
34
|
+
inputHeight$: import("@preact/signals").Signal<number>;
|
|
35
|
+
startFlow: ({ flow, context, flowKeys, title }: OpenChatbotParams) => Promise<void>;
|
|
36
|
+
cancelCurrentFlow: () => void;
|
|
37
|
+
markAsFinished: () => void;
|
|
38
|
+
setCurrentNodeId: (currentNodeId: string) => void;
|
|
39
|
+
restart: () => void;
|
|
40
|
+
addMessage: (message: ChatMessage, groupId?: string) => void;
|
|
41
|
+
/** Removes messages from nodeId, all the messages that have the groupId passed, until it reaches one that doesn't */
|
|
42
|
+
removeMessagesSentByNodeIds: (nodeIds: string[]) => void;
|
|
43
|
+
setSubmission: (fieldKey: string, submission: FlowSubmission | null) => void;
|
|
44
|
+
setInput: (input: ChatInput | undefined) => void;
|
|
45
|
+
};
|
|
46
|
+
export type MessageAuthor = 'bot' | 'user';
|
|
47
|
+
type SystemMessage = {
|
|
48
|
+
type: 'system';
|
|
49
|
+
text: string;
|
|
50
|
+
variant: 'info' | 'warning' | 'error' | 'success';
|
|
51
|
+
};
|
|
52
|
+
type TextMessage = {
|
|
53
|
+
author: MessageAuthor;
|
|
54
|
+
type: 'text';
|
|
55
|
+
text: string;
|
|
56
|
+
};
|
|
57
|
+
type LinkMessage = {
|
|
58
|
+
type: 'link';
|
|
59
|
+
href: string;
|
|
60
|
+
text: string;
|
|
61
|
+
};
|
|
62
|
+
type ImageMessage = {
|
|
63
|
+
author: MessageAuthor;
|
|
64
|
+
type: 'image';
|
|
65
|
+
url: string;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
type FileMessage = {
|
|
70
|
+
author: MessageAuthor;
|
|
71
|
+
type: 'file';
|
|
72
|
+
fileName: string;
|
|
73
|
+
fileSizeKb: number;
|
|
74
|
+
};
|
|
75
|
+
export type ChatMessage = TextMessage | ImageMessage | SystemMessage | FileMessage | LinkMessage;
|
|
76
|
+
export type FileToUpload = {
|
|
77
|
+
name: string;
|
|
78
|
+
data: string;
|
|
79
|
+
sizeKb: number;
|
|
80
|
+
};
|
|
81
|
+
export type FlowSubmissionAddress = {
|
|
82
|
+
value: Record<string, string | undefined>;
|
|
83
|
+
type: 'address';
|
|
84
|
+
};
|
|
85
|
+
export type FlowSubmissionFile = {
|
|
86
|
+
value: FileToUpload[];
|
|
87
|
+
type: 'file';
|
|
88
|
+
};
|
|
89
|
+
export type FlowSubmissionString = {
|
|
90
|
+
value: string;
|
|
91
|
+
type: 'string';
|
|
92
|
+
};
|
|
93
|
+
export type FlowSubmissionBoolean = {
|
|
94
|
+
value: boolean;
|
|
95
|
+
type: 'boolean';
|
|
96
|
+
};
|
|
97
|
+
export type FlowSubmissionNumber = {
|
|
98
|
+
value: number;
|
|
99
|
+
type: 'number';
|
|
100
|
+
};
|
|
101
|
+
export type FlowSubmissionEnum = {
|
|
102
|
+
value: string[];
|
|
103
|
+
type: 'enum';
|
|
104
|
+
};
|
|
105
|
+
export type FlowSubmissionIntegration = {
|
|
106
|
+
value: unknown;
|
|
107
|
+
type: 'integration';
|
|
108
|
+
};
|
|
109
|
+
export type FlowSubmission = FlowSubmissionString | FlowSubmissionBoolean | FlowSubmissionNumber | FlowSubmissionEnum | FlowSubmissionAddress | FlowSubmissionFile | FlowSubmissionIntegration;
|
|
110
|
+
export type KeyToSubmissionMap = {
|
|
111
|
+
[key: string]: FlowSubmission;
|
|
112
|
+
};
|
|
113
|
+
/** Dynamic part of a flow */
|
|
114
|
+
export type FlowStateData = {
|
|
115
|
+
/** History of messages left in the chat */
|
|
116
|
+
messages: (ChatMessage & {
|
|
117
|
+
groupId?: string;
|
|
118
|
+
})[];
|
|
119
|
+
submissions: KeyToSubmissionMap;
|
|
120
|
+
nodeHistory: string[];
|
|
121
|
+
/** Needs to be separate because a node can have many inputs */
|
|
122
|
+
currentInput: ChatInput | null;
|
|
123
|
+
isFinished: boolean;
|
|
124
|
+
sequence: number;
|
|
125
|
+
flowSessionId: string;
|
|
126
|
+
};
|
|
127
|
+
export {};
|
package/dist/chatbot.utils.d.ts
CHANGED
|
@@ -165,18 +165,20 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
|
|
|
165
165
|
isHead?: boolean | undefined;
|
|
166
166
|
nextId?: string | undefined;
|
|
167
167
|
};
|
|
168
|
-
export declare const getFlowSubmissionsPayload: (submissions: KeyToSubmissionMap) => Record<string,
|
|
169
|
-
export declare const isSubmissionOfType: <T extends "
|
|
168
|
+
export declare const getFlowSubmissionsPayload: (submissions: KeyToSubmissionMap) => Record<string, unknown>;
|
|
169
|
+
export declare const isSubmissionOfType: <T extends "string" | "number" | "boolean" | "enum" | "address" | "file" | "integration">(type: T) => (submission?: FlowSubmission) => submission is Extract<import("./chatbot.state").FlowSubmissionString, {
|
|
170
170
|
type: T;
|
|
171
|
-
}> | Extract<
|
|
171
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionBoolean, {
|
|
172
172
|
type: T;
|
|
173
|
-
}> | Extract<
|
|
173
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionNumber, {
|
|
174
174
|
type: T;
|
|
175
|
-
}> | Extract<
|
|
175
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionEnum, {
|
|
176
176
|
type: T;
|
|
177
|
-
}> | Extract<
|
|
177
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionAddress, {
|
|
178
178
|
type: T;
|
|
179
|
-
}> | Extract<
|
|
179
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionFile, {
|
|
180
|
+
type: T;
|
|
181
|
+
}> | Extract<import("./chatbot.state").FlowSubmissionIntegration, {
|
|
180
182
|
type: T;
|
|
181
183
|
}>;
|
|
182
184
|
export declare function gzip(string: string): string | Promise<string>;
|
|
@@ -184,3 +186,4 @@ export declare class AbortedError extends Error {
|
|
|
184
186
|
constructor();
|
|
185
187
|
}
|
|
186
188
|
export declare function debounce<TFn extends (...params: any[]) => void>(func: TFn, timeout?: number): TFn;
|
|
189
|
+
export declare const isString: (value: unknown) => value is string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4280,6 +4280,7 @@ function debounce(func, timeout = 300) {
|
|
|
4280
4280
|
}, timeout);
|
|
4281
4281
|
};
|
|
4282
4282
|
}
|
|
4283
|
+
const isString = (value) => typeof value === "string";
|
|
4283
4284
|
const db = typeof window === "undefined" ? void 0 : openDB("inploi-chatbot", 2, {
|
|
4284
4285
|
upgrade(db2) {
|
|
4285
4286
|
try {
|
|
@@ -4733,7 +4734,7 @@ const StatusBar = ({
|
|
|
4733
4734
|
})
|
|
4734
4735
|
});
|
|
4735
4736
|
};
|
|
4736
|
-
const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-
|
|
4737
|
+
const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-9bce9c3f.cjs")).then((module2) => module2.ChatbotBody));
|
|
4737
4738
|
const chatbotContentClass = cva("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none", {
|
|
4738
4739
|
variants: {
|
|
4739
4740
|
view: {
|
|
@@ -5205,6 +5206,7 @@ exports.getFlowSubmissionsPayload = getFlowSubmissionsPayload;
|
|
|
5205
5206
|
exports.getHeadOrThrow = getHeadOrThrow;
|
|
5206
5207
|
exports.h = h$1;
|
|
5207
5208
|
exports.invariant = invariant;
|
|
5209
|
+
exports.isString = isString;
|
|
5208
5210
|
exports.isSubmissionOfType = isSubmissionOfType;
|
|
5209
5211
|
exports.k = k$3;
|
|
5210
5212
|
exports.kbToReadableSize = kbToReadableSize;
|
|
@@ -4279,6 +4279,7 @@ function debounce(func, timeout = 300) {
|
|
|
4279
4279
|
}, timeout);
|
|
4280
4280
|
};
|
|
4281
4281
|
}
|
|
4282
|
+
const isString = (value) => typeof value === "string";
|
|
4282
4283
|
const db = typeof window === "undefined" ? void 0 : openDB("inploi-chatbot", 2, {
|
|
4283
4284
|
upgrade(db2) {
|
|
4284
4285
|
try {
|
|
@@ -4732,7 +4733,7 @@ const StatusBar = ({
|
|
|
4732
4733
|
})
|
|
4733
4734
|
});
|
|
4734
4735
|
};
|
|
4735
|
-
const ChatbotBody = M(() => import("./chatbot-body-
|
|
4736
|
+
const ChatbotBody = M(() => import("./chatbot-body-59fab6f6.js").then((module) => module.ChatbotBody));
|
|
4736
4737
|
const chatbotContentClass = cva("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none", {
|
|
4737
4738
|
variants: {
|
|
4738
4739
|
view: {
|
|
@@ -5187,40 +5188,41 @@ const chatbotPlugin = ({
|
|
|
5187
5188
|
});
|
|
5188
5189
|
export {
|
|
5189
5190
|
AbortedError as A,
|
|
5190
|
-
|
|
5191
|
+
email as B,
|
|
5191
5192
|
Cn as C,
|
|
5192
|
-
|
|
5193
|
-
|
|
5193
|
+
url as D,
|
|
5194
|
+
regex as E,
|
|
5194
5195
|
F$1 as F,
|
|
5195
|
-
|
|
5196
|
-
|
|
5196
|
+
cva as G,
|
|
5197
|
+
ERROR_MESSAGES as H,
|
|
5198
|
+
chatbotPlugin as I,
|
|
5197
5199
|
N,
|
|
5198
5200
|
ValiError as V,
|
|
5199
5201
|
_$3 as _,
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5202
|
+
invariant as a,
|
|
5203
|
+
getFlowSubmissionsPayload as b,
|
|
5204
|
+
_$4 as c,
|
|
5205
|
+
clsx as d,
|
|
5206
|
+
a as e,
|
|
5207
|
+
debounce as f,
|
|
5206
5208
|
getHeadOrThrow as g,
|
|
5207
5209
|
h$1 as h,
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
+
isString as i,
|
|
5211
|
+
k$3 as j,
|
|
5210
5212
|
kbToReadableSize as k,
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5213
|
+
parse$1 as l,
|
|
5214
|
+
picklist as m,
|
|
5215
|
+
isSubmissionOfType as n,
|
|
5214
5216
|
o,
|
|
5215
5217
|
p$3 as p,
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
+
parseAsync as q,
|
|
5219
|
+
object as r,
|
|
5218
5220
|
store as s,
|
|
5219
5221
|
transform as t,
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5222
|
+
maxLength as u,
|
|
5223
|
+
minLength as v,
|
|
5224
|
+
record as w,
|
|
5225
|
+
boolean as x,
|
|
5224
5226
|
y$2 as y,
|
|
5225
|
-
|
|
5227
|
+
string as z
|
|
5226
5228
|
};
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FlowNode } from '@inploi/core/flows';
|
|
2
2
|
import { AnalyticsService, ApiClient, Logger } from '@inploi/sdk';
|
|
3
|
-
import {
|
|
3
|
+
import { ChatbotInput } from './components/chat-input/chat-input';
|
|
4
4
|
import { ChatMessage, FlowSubmission, KeyToSubmissionMap } from './chatbot.state';
|
|
5
5
|
export declare const followNodes: ({ node, nodes, stopWhen, }: {
|
|
6
6
|
node: FlowNode;
|
|
7
7
|
nodes: FlowNode[];
|
|
8
|
-
stopWhen?: (
|
|
8
|
+
stopWhen?: (node: FlowNode) => boolean;
|
|
9
9
|
}) => FlowNode | undefined;
|
|
10
10
|
export type ChatServiceSendParams = {
|
|
11
11
|
signal?: AbortSignal;
|
|
@@ -14,14 +14,15 @@ export type ChatServiceSendParams = {
|
|
|
14
14
|
};
|
|
15
15
|
export type ChatService = {
|
|
16
16
|
send: (params: ChatServiceSendParams) => Promise<void>;
|
|
17
|
-
input: <TType extends
|
|
18
|
-
input:
|
|
17
|
+
input: <TType extends ChatbotInput['type']>(params: {
|
|
18
|
+
input: Pick<ChatbotInput & {
|
|
19
19
|
type: TType;
|
|
20
|
-
}>;
|
|
20
|
+
}, 'type' | 'config' | 'key'>;
|
|
21
21
|
signal?: AbortSignal;
|
|
22
|
-
}) => Promise<
|
|
22
|
+
}) => Promise<(ChatbotInput & {
|
|
23
23
|
type: TType;
|
|
24
|
-
}
|
|
24
|
+
})['submission']>;
|
|
25
|
+
addToSubmissions: (key: string, value: FlowSubmission) => void;
|
|
25
26
|
};
|
|
26
27
|
type ChatbotInterpreterParams<TContext extends Record<string, unknown>> = {
|
|
27
28
|
apiClient: ApiClient;
|
package/dist/plugin-chatbot.cjs
CHANGED
package/dist/plugin-chatbot.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/plugin-chatbot",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/plugin-chatbot.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"lodash": "^4.17.21",
|
|
19
20
|
"react-use-measure": "^2.1.1"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
@@ -26,14 +27,15 @@
|
|
|
26
27
|
"@hookform/resolvers": "^3.3.2",
|
|
27
28
|
"@preact/preset-vite": "^2.5.0",
|
|
28
29
|
"@preact/signals": "^1.2.2",
|
|
29
|
-
"@radix-ui/react-dialog": "
|
|
30
|
-
"@radix-ui/react-focus-guards": "
|
|
31
|
-
"@radix-ui/react-focus-scope": "
|
|
32
|
-
"@radix-ui/react-slot": "
|
|
30
|
+
"@radix-ui/react-dialog": "1.0.5",
|
|
31
|
+
"@radix-ui/react-focus-guards": "1.0.1",
|
|
32
|
+
"@radix-ui/react-focus-scope": "1.0.4",
|
|
33
|
+
"@radix-ui/react-slot": "1.0.2",
|
|
33
34
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
34
35
|
"@types/bun": "^1.0.8",
|
|
35
36
|
"@types/culori": "^2.0.4",
|
|
36
37
|
"@types/google.maps": "^3.55.4",
|
|
38
|
+
"@types/lodash": "^4.17.7",
|
|
37
39
|
"@types/node": "^20.10.0",
|
|
38
40
|
"@types/react-transition-group": "^4.4.9",
|
|
39
41
|
"autoprefixer": "^10.4.16",
|
|
@@ -60,7 +62,6 @@
|
|
|
60
62
|
"tailwindcss-touch": "^1.0.1",
|
|
61
63
|
"ts-pattern": "^5.0.6",
|
|
62
64
|
"ts-toolbelt": "^9.6.0",
|
|
63
|
-
"typescript": "^5.3.0",
|
|
64
65
|
"valibot": "^0.21.0",
|
|
65
66
|
"vite": "^4.4.5",
|
|
66
67
|
"vite-plugin-dts": "^3.7.0",
|