@inploi/plugin-chatbot 3.6.2 → 3.6.5
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 +14 -14
- package/dist/chatbot.state.d.ts +1 -1
- package/dist/chatbot.utils.d.ts +1 -1
- package/dist/{index-873a3e2d.js → index-b130eeef.js} +28 -63
- package/dist/{index-7659d6f8.cjs → index-ebce8046.cjs} +6 -41
- package/dist/{job-application-content-ff6165e9.cjs → job-application-content-bacb82b9.cjs} +128 -90
- package/dist/{job-application-content-425367df.js → job-application-content-f45a3311.js} +118 -80
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +2 -2
- package/package.json +4 -4
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import { _,
|
|
1
|
+
import { _, N, i as invariant, o as o$1, c as clsx, a as _$1, p, b as parse, d as picklist, y, k, e as application, h, C as Cn, f as parseAsync, V as ValiError, g as object, t as transform, m as maxLength, j as minLength, r as record, l as boolean, s as string, n as email, u as url, q as regex, T, v as inputHeight, w as m, A as AnimatePresence, F, x as viewState, E as ERROR_MESSAGES } from "./index-b130eeef.js";
|
|
2
2
|
import "@inploi/sdk";
|
|
3
|
+
const getHeadOrThrow = (nodes) => {
|
|
4
|
+
const head = nodes.find((n2) => n2.isHead);
|
|
5
|
+
if (!head)
|
|
6
|
+
throw new Error("No head node found");
|
|
7
|
+
return head;
|
|
8
|
+
};
|
|
9
|
+
const getApplicationSubmissionsPayload = (submissions) => {
|
|
10
|
+
const payload = Object.entries(submissions).reduce((acc, [key, submission]) => {
|
|
11
|
+
acc[key] = submission.value;
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
return payload;
|
|
15
|
+
};
|
|
16
|
+
const isSubmissionOfType = (type) => (submission) => {
|
|
17
|
+
if (!submission)
|
|
18
|
+
return false;
|
|
19
|
+
return submission.type === type;
|
|
20
|
+
};
|
|
21
|
+
class AbortedError extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Aborted");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
3
26
|
const followNodes = ({
|
|
4
27
|
node,
|
|
5
28
|
nodes,
|
|
@@ -458,7 +481,7 @@ async function interpretEndFlowNode({
|
|
|
458
481
|
await chat.sendMessage({
|
|
459
482
|
type: "system",
|
|
460
483
|
variant: "info",
|
|
461
|
-
text: node.data.systemMessage
|
|
484
|
+
text: node.data.systemMessage
|
|
462
485
|
});
|
|
463
486
|
end();
|
|
464
487
|
}
|
|
@@ -552,7 +575,7 @@ const ChatInputBoolean = ({
|
|
|
552
575
|
onHeightChange();
|
|
553
576
|
return o$1("form", {
|
|
554
577
|
noValidate: true,
|
|
555
|
-
class: "flex items-center gap-2",
|
|
578
|
+
class: "flex items-center gap-2 p-2.5",
|
|
556
579
|
onSubmit: (e) => {
|
|
557
580
|
e.preventDefault();
|
|
558
581
|
const value = N(e).with({
|
|
@@ -586,55 +609,45 @@ const InputError = ({
|
|
|
586
609
|
error,
|
|
587
610
|
onAnimationComplete
|
|
588
611
|
}) => {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
width: "2",
|
|
623
|
-
height: "5",
|
|
624
|
-
fill: "currentColor"
|
|
625
|
-
}), o$1("rect", {
|
|
626
|
-
x: "7",
|
|
627
|
-
y: "10",
|
|
628
|
-
width: "2",
|
|
629
|
-
height: "2",
|
|
630
|
-
fill: "currentColor"
|
|
631
|
-
})]
|
|
632
|
-
}), o$1("p", {
|
|
633
|
-
class: "truncate pr-1 text-sm",
|
|
634
|
-
children: error.message
|
|
612
|
+
y(() => {
|
|
613
|
+
if (error) {
|
|
614
|
+
onAnimationComplete();
|
|
615
|
+
}
|
|
616
|
+
}, [error, onAnimationComplete]);
|
|
617
|
+
return error ? o$1("div", {
|
|
618
|
+
role: "alert",
|
|
619
|
+
class: "text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",
|
|
620
|
+
children: [o$1("svg", {
|
|
621
|
+
class: "text-error-10",
|
|
622
|
+
width: "16",
|
|
623
|
+
height: "16",
|
|
624
|
+
viewBox: "0 0 16 16",
|
|
625
|
+
fill: "none",
|
|
626
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
627
|
+
children: [o$1("circle", {
|
|
628
|
+
cx: "8",
|
|
629
|
+
cy: "8",
|
|
630
|
+
r: "6.3",
|
|
631
|
+
stroke: "currentColor",
|
|
632
|
+
"stroke-width": "1.4"
|
|
633
|
+
}), o$1("rect", {
|
|
634
|
+
x: "7",
|
|
635
|
+
y: "4",
|
|
636
|
+
width: "2",
|
|
637
|
+
height: "5",
|
|
638
|
+
fill: "currentColor"
|
|
639
|
+
}), o$1("rect", {
|
|
640
|
+
x: "7",
|
|
641
|
+
y: "10",
|
|
642
|
+
width: "2",
|
|
643
|
+
height: "2",
|
|
644
|
+
fill: "currentColor"
|
|
635
645
|
})]
|
|
636
|
-
})
|
|
637
|
-
|
|
646
|
+
}), o$1("p", {
|
|
647
|
+
class: "truncate pr-1 text-sm",
|
|
648
|
+
children: error.message
|
|
649
|
+
})]
|
|
650
|
+
}) : o$1(k, {});
|
|
638
651
|
};
|
|
639
652
|
const toBase64 = (file) => new Promise((resolve, reject) => {
|
|
640
653
|
const reader = new FileReader();
|
|
@@ -696,7 +709,7 @@ const ChatInputFile = ({
|
|
|
696
709
|
const totalSize = addFileSizesKb(files);
|
|
697
710
|
const focusRef = useFocusOnMount();
|
|
698
711
|
return o$1("form", {
|
|
699
|
-
class: "flex flex-col gap-1",
|
|
712
|
+
class: "flex flex-col gap-1 p-2.5",
|
|
700
713
|
onSubmit: (e) => {
|
|
701
714
|
e.preventDefault();
|
|
702
715
|
setError(void 0);
|
|
@@ -2284,6 +2297,9 @@ var a = function(r, e) {
|
|
|
2284
2297
|
}
|
|
2285
2298
|
};
|
|
2286
2299
|
};
|
|
2300
|
+
const LABEL_HEIGHT = 27;
|
|
2301
|
+
const GAP = 12;
|
|
2302
|
+
const PADDING = 10;
|
|
2287
2303
|
const submitIfSingleChecked = (form) => {
|
|
2288
2304
|
const formObj = Object.fromEntries(new FormData(form).entries());
|
|
2289
2305
|
const isSingleChecked = Object.keys(formObj).length;
|
|
@@ -2326,7 +2342,7 @@ const ChatInputMultipleChoice = ({
|
|
|
2326
2342
|
const isSingleChoice = input.config.minSelected === 1 && input.config.maxSelected === 1;
|
|
2327
2343
|
return o$1("form", {
|
|
2328
2344
|
noValidate: true,
|
|
2329
|
-
class: "flex flex-col gap-1",
|
|
2345
|
+
class: "flex flex-col gap-1 pr-2.5",
|
|
2330
2346
|
onChange: (e) => {
|
|
2331
2347
|
if (isSingleChoice) {
|
|
2332
2348
|
submitIfSingleChecked(e.currentTarget);
|
|
@@ -2337,9 +2353,12 @@ const ChatInputMultipleChoice = ({
|
|
|
2337
2353
|
onSubmitSuccess(checked);
|
|
2338
2354
|
}),
|
|
2339
2355
|
children: [o$1("div", {
|
|
2340
|
-
class: "flex items-center gap-
|
|
2341
|
-
children: [o$1("
|
|
2342
|
-
|
|
2356
|
+
class: "flex items-center gap-1",
|
|
2357
|
+
children: [o$1("ul", {
|
|
2358
|
+
style: {
|
|
2359
|
+
maxHeight: 6.5 * LABEL_HEIGHT + 5 * GAP + 2 * PADDING
|
|
2360
|
+
},
|
|
2361
|
+
class: clsx("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4", {
|
|
2343
2362
|
"justify-center": input.config.options.length === 1
|
|
2344
2363
|
}),
|
|
2345
2364
|
children: input.config.options.map((option, i2) => {
|
|
@@ -2348,7 +2367,8 @@ const ChatInputMultipleChoice = ({
|
|
|
2348
2367
|
ref: setRef,
|
|
2349
2368
|
...props
|
|
2350
2369
|
} = register(id);
|
|
2351
|
-
return o$1("
|
|
2370
|
+
return o$1("li", {
|
|
2371
|
+
class: "relative",
|
|
2352
2372
|
children: [o$1("input", {
|
|
2353
2373
|
autoFocus: i2 === 0,
|
|
2354
2374
|
ref: (e) => {
|
|
@@ -2359,7 +2379,7 @@ const ChatInputMultipleChoice = ({
|
|
|
2359
2379
|
},
|
|
2360
2380
|
id,
|
|
2361
2381
|
...props,
|
|
2362
|
-
class: "peer sr-only",
|
|
2382
|
+
class: "peer sr-only h-full",
|
|
2363
2383
|
type: "checkbox"
|
|
2364
2384
|
}), o$1("label", {
|
|
2365
2385
|
class: "bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-neutral-12/5 text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 duration-snappy block rounded-2xl px-2.5 py-1 outline outline-2 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4 peer-focus-visible:ring-offset-2",
|
|
@@ -2369,9 +2389,12 @@ const ChatInputMultipleChoice = ({
|
|
|
2369
2389
|
}, option.value);
|
|
2370
2390
|
})
|
|
2371
2391
|
}), !isSingleChoice && o$1(SendButton, {})]
|
|
2372
|
-
}), o$1(
|
|
2373
|
-
|
|
2374
|
-
|
|
2392
|
+
}), o$1("div", {
|
|
2393
|
+
class: "px-1",
|
|
2394
|
+
children: o$1(InputError, {
|
|
2395
|
+
onAnimationComplete: onHeightChange,
|
|
2396
|
+
error: (_b = errors2.checked) == null ? void 0 : _b.root
|
|
2397
|
+
})
|
|
2375
2398
|
})]
|
|
2376
2399
|
});
|
|
2377
2400
|
};
|
|
@@ -2444,7 +2467,7 @@ const ChatInputText = ({
|
|
|
2444
2467
|
}, []);
|
|
2445
2468
|
return o$1("form", {
|
|
2446
2469
|
noValidate: true,
|
|
2447
|
-
class: "flex flex-col gap-1",
|
|
2470
|
+
class: "flex flex-col gap-1 p-2.5",
|
|
2448
2471
|
onSubmit: handleSubmit((submission2) => {
|
|
2449
2472
|
onSubmitSuccess(submission2.text);
|
|
2450
2473
|
}),
|
|
@@ -2506,7 +2529,7 @@ const ChatInput = ({
|
|
|
2506
2529
|
class: "bg-neutral-2/80 absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",
|
|
2507
2530
|
children: o$1("div", {
|
|
2508
2531
|
ref: inputWrapperRef,
|
|
2509
|
-
class: "border-neutral-12/5 border-t
|
|
2532
|
+
class: "border-neutral-12/5 border-t",
|
|
2510
2533
|
children: N({
|
|
2511
2534
|
application,
|
|
2512
2535
|
input,
|
|
@@ -2514,7 +2537,7 @@ const ChatInput = ({
|
|
|
2514
2537
|
}).with({
|
|
2515
2538
|
input: _.nullish
|
|
2516
2539
|
}, () => o$1("div", {
|
|
2517
|
-
class: "flex items-center gap-2",
|
|
2540
|
+
class: "flex items-center gap-2 p-2.5",
|
|
2518
2541
|
children: [o$1("input", {
|
|
2519
2542
|
"aria-hidden": "true",
|
|
2520
2543
|
id: "chat-input",
|
|
@@ -2866,14 +2889,27 @@ const JobApplicationContent = ({
|
|
|
2866
2889
|
} = application.current$.peek();
|
|
2867
2890
|
if (state !== "loaded")
|
|
2868
2891
|
throw new Error(ERROR_MESSAGES.invalid_state);
|
|
2869
|
-
|
|
2892
|
+
let fromNodeId = currentApplication2.data.currentNodeId;
|
|
2870
2893
|
scrollToEnd({
|
|
2871
2894
|
behavior: "instant"
|
|
2872
2895
|
});
|
|
2873
2896
|
application.setInput(void 0);
|
|
2874
2897
|
if (currentApplication2.data.isFinished)
|
|
2875
2898
|
return;
|
|
2876
|
-
|
|
2899
|
+
if (fromNodeId === null) {
|
|
2900
|
+
fromNodeId = getHeadOrThrow(flow.nodes).id;
|
|
2901
|
+
application.setCurrentNodeId(fromNodeId);
|
|
2902
|
+
analytics.log({
|
|
2903
|
+
event: "APPLY_START",
|
|
2904
|
+
attributionKey: `job_${job.id}`,
|
|
2905
|
+
properties: {
|
|
2906
|
+
job_id: job.id,
|
|
2907
|
+
flow_id: flow.id
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
} else {
|
|
2911
|
+
application.removeLastGroupMessagesById(fromNodeId);
|
|
2912
|
+
}
|
|
2877
2913
|
const {
|
|
2878
2914
|
interpret: interpret2,
|
|
2879
2915
|
abort
|
|
@@ -2895,20 +2931,22 @@ const JobApplicationContent = ({
|
|
|
2895
2931
|
onInterpret: (node, prevNode) => {
|
|
2896
2932
|
const currentState = application.current$.peek().application;
|
|
2897
2933
|
invariant(currentState);
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2934
|
+
if (prevNode) {
|
|
2935
|
+
currentState.data.sequence = currentState.data.sequence + 1;
|
|
2936
|
+
analytics.log({
|
|
2937
|
+
event: "FLOW_NODE",
|
|
2938
|
+
attributionKey: `job_${job.id}`,
|
|
2939
|
+
properties: {
|
|
2940
|
+
flow_id: flow.id,
|
|
2941
|
+
flow_version: flow.version,
|
|
2942
|
+
job_id: job.id,
|
|
2943
|
+
from_node_id: prevNode.id,
|
|
2944
|
+
to_node_id: node.id,
|
|
2945
|
+
sequence: currentState.data.sequence,
|
|
2946
|
+
flow_session_id: currentState.data.flowSessionId
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2912
2950
|
application.setCurrentNodeId(node.id);
|
|
2913
2951
|
},
|
|
2914
2952
|
onFlowEnd: async () => {
|
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.6.
|
|
3
|
+
"version": "3.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/plugin-chatbot.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"vite": "^4.4.5",
|
|
64
64
|
"vite-plugin-dts": "^3.7.0",
|
|
65
65
|
"vite-tsconfig-paths": "^4.2.1",
|
|
66
|
-
"@inploi/core": "1.11.
|
|
67
|
-
"@inploi/sdk": "1.11.
|
|
66
|
+
"@inploi/core": "1.11.3",
|
|
67
|
+
"@inploi/sdk": "1.11.4",
|
|
68
68
|
"eslint-config-custom": "0.1.0",
|
|
69
69
|
"tsconfig": "0.1.0"
|
|
70
70
|
},
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"build": "concurrently 'pnpm build:npm' 'pnpm run build:cdn'",
|
|
79
79
|
"setup-local": "cp -n .env.example .env || true",
|
|
80
80
|
"check": "eslint src --fix --max-warnings 0 && tsc",
|
|
81
|
-
"test
|
|
81
|
+
"test": "bun test src/",
|
|
82
82
|
"test:int": "playwright test",
|
|
83
83
|
"test:ui": "playwright test --ui",
|
|
84
84
|
"preview": "vite preview"
|