@inploi/plugin-chatbot 3.23.0 → 3.23.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-d8265e0a.cjs");
3
+ const index = require("./index-fa87308a.cjs");
4
4
  require("@inploi/sdk");
5
5
  const isIfBlockConditionMet = (ifBlock, {
6
6
  context,
@@ -477,7 +477,8 @@ async function interpretSubmitNode({
477
477
  response: {
478
478
  status: integrationResponse.status,
479
479
  payload: "data" in integrationResponse ? integrationResponse.data : integrationResponse.error.data ?? null
480
- }
480
+ },
481
+ job: flow.job
481
482
  }
482
483
  });
483
484
  }).otherwise(() => {
@@ -510,7 +511,8 @@ async function interpretSubmitNode({
510
511
  flow_id: flow.id,
511
512
  flow_session_id: session_id,
512
513
  flow_version: flow.version,
513
- href: href.toString()
514
+ href: href.toString(),
515
+ job: flow.job
514
516
  }
515
517
  });
516
518
  }
@@ -4085,7 +4087,8 @@ const ChatbotBody = ({
4085
4087
  flow_id: flow.id,
4086
4088
  flow_version: flow.version,
4087
4089
  flow_session_id: currentApplication.data.flowSessionId,
4088
- flow_build: flow.build
4090
+ flow_build: flow.build,
4091
+ job: flow.job
4089
4092
  },
4090
4093
  customProperties: (_a = flow.analytics) == null ? void 0 : _a.customProperties
4091
4094
  });
@@ -4126,7 +4129,8 @@ const ChatbotBody = ({
4126
4129
  flow_build: flow.build,
4127
4130
  to_node_id: node.id,
4128
4131
  sequence: currentState.data.sequence,
4129
- flow_session_id: currentState.data.flowSessionId
4132
+ flow_session_id: currentState.data.flowSessionId,
4133
+ job: flow.job
4130
4134
  },
4131
4135
  customProperties: (_a2 = flow.analytics) == null ? void 0 : _a2.customProperties
4132
4136
  });
@@ -4144,7 +4148,8 @@ const ChatbotBody = ({
4144
4148
  flow_id: flow.id,
4145
4149
  flow_version: flow.version,
4146
4150
  flow_session_id: currentState.data.flowSessionId,
4147
- flow_build: flow.build
4151
+ flow_build: flow.build,
4152
+ job: flow.job
4148
4153
  },
4149
4154
  customProperties: (_a2 = flow.analytics) == null ? void 0 : _a2.customProperties
4150
4155
  });
@@ -1,4 +1,4 @@
1
- import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as debounce$1, m as k, n as k$1, q as getFormSubmitter, r as parse, t as picklist, u as isSubmissionOfType, C as Cn, v as parseAsync, V as ValiError, w as object, x as transform, z as cva, B as maxLength, D as minLength, E as record, G as boolean, H as number, I as minValue, J as maxValue, K as custom, L as string, M as email, O as url, P as regex, Q as ERROR_MESSAGES } from "./index-6e48d6e0.js";
1
+ import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as debounce$1, m as k, n as k$1, q as getFormSubmitter, r as parse, t as picklist, u as isSubmissionOfType, C as Cn, v as parseAsync, V as ValiError, w as object, x as transform, z as cva, B as maxLength, D as minLength, E as record, G as boolean, H as number, I as minValue, J as maxValue, K as custom, L as string, M as email, O as url, P as regex, Q as ERROR_MESSAGES } from "./index-5b559a08.js";
2
2
  import "@inploi/sdk";
3
3
  const isIfBlockConditionMet = (ifBlock, {
4
4
  context,
@@ -475,7 +475,8 @@ async function interpretSubmitNode({
475
475
  response: {
476
476
  status: integrationResponse.status,
477
477
  payload: "data" in integrationResponse ? integrationResponse.data : integrationResponse.error.data ?? null
478
- }
478
+ },
479
+ job: flow.job
479
480
  }
480
481
  });
481
482
  }).otherwise(() => {
@@ -508,7 +509,8 @@ async function interpretSubmitNode({
508
509
  flow_id: flow.id,
509
510
  flow_session_id: session_id,
510
511
  flow_version: flow.version,
511
- href: href.toString()
512
+ href: href.toString(),
513
+ job: flow.job
512
514
  }
513
515
  });
514
516
  }
@@ -4083,7 +4085,8 @@ const ChatbotBody = ({
4083
4085
  flow_id: flow.id,
4084
4086
  flow_version: flow.version,
4085
4087
  flow_session_id: currentApplication.data.flowSessionId,
4086
- flow_build: flow.build
4088
+ flow_build: flow.build,
4089
+ job: flow.job
4087
4090
  },
4088
4091
  customProperties: (_a = flow.analytics) == null ? void 0 : _a.customProperties
4089
4092
  });
@@ -4124,7 +4127,8 @@ const ChatbotBody = ({
4124
4127
  flow_build: flow.build,
4125
4128
  to_node_id: node.id,
4126
4129
  sequence: currentState.data.sequence,
4127
- flow_session_id: currentState.data.flowSessionId
4130
+ flow_session_id: currentState.data.flowSessionId,
4131
+ job: flow.job
4128
4132
  },
4129
4133
  customProperties: (_a2 = flow.analytics) == null ? void 0 : _a2.customProperties
4130
4134
  });
@@ -4142,7 +4146,8 @@ const ChatbotBody = ({
4142
4146
  flow_id: flow.id,
4143
4147
  flow_version: flow.version,
4144
4148
  flow_session_id: currentState.data.flowSessionId,
4145
- flow_build: flow.build
4149
+ flow_build: flow.build,
4150
+ job: flow.job
4146
4151
  },
4147
4152
  customProperties: (_a2 = flow.analytics) == null ? void 0 : _a2.customProperties
4148
4153
  });
package/dist/chatbot.d.ts CHANGED
@@ -22,6 +22,12 @@ export type OpenChatbotParams = {
22
22
  context?: Record<string, unknown>;
23
23
  /** Title to display in the status bar */
24
24
  title: string;
25
+ job?: {
26
+ id: string;
27
+ /** Whether the job id is an internal (inploi) or external.
28
+ * Use `external` if unsure */
29
+ id_type: 'internal' | 'external';
30
+ };
25
31
  };
26
32
  export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
27
33
  theme: {
@@ -34,7 +40,7 @@ export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
34
40
  /** @deprecated For internal usage only */
35
41
  _internal_domManager?: ChatbotDomManager;
36
42
  }) => ({ apiClient, logger, analytics }: {
37
- apiClient: import("@inploi/sdk").ApiClient;
43
+ apiClient: import("@inploi/sdk").ApiClient; /** Optionally eagerly renders the interface ahead of needing the chatbot. */
38
44
  logger: Logger;
39
45
  analytics: import("@inploi/sdk").AnalyticsService;
40
46
  }) => {
@@ -46,10 +52,6 @@ export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, }: {
46
52
  fetchFlowByJobId: (jobId: string, additionalProperties?: Partial<OpenChatbotParams>) => Promise<OpenChatbotParams>;
47
53
  fetchFlowById: (flowId: string, additionalProperties?: Partial<OpenChatbotParams>) => Promise<OpenChatbotParams>;
48
54
  open: (params: OpenChatbotParams | Promise<OpenChatbotParams>) => Promise<void>;
49
- /** @deprecated - Please use `open` instead. */
50
- startApplication: never;
51
- /** @deprecated - Please use `close` instead */
52
- closeApplication: never;
53
55
  close: () => Promise<void>;
54
56
  };
55
57
  export {};
@@ -9,6 +9,7 @@ export type StartedFlow = Flow & {
9
9
  data: FlowStateData;
10
10
  startedAt: Date;
11
11
  context: Record<string, unknown>;
12
+ job: OpenChatbotParams['job'];
12
13
  nodeIdToProgress: Record<string, ChatbotFlowProgress>;
13
14
  analytics: OpenChatbotParams['analytics'];
14
15
  };
@@ -33,7 +34,7 @@ export declare const store: {
33
34
  current$: import("@preact/signals").Signal<CurrentFlow>;
34
35
  viewState$: import("@preact/signals").Signal<"maximised" | "minimised" | "closed">;
35
36
  inputHeight$: import("@preact/signals").Signal<number>;
36
- startFlow: ({ flow, context, flowKeys, title, analytics }: OpenChatbotParams) => Promise<void>;
37
+ startFlow: ({ flow, context, flowKeys, title, analytics, job }: OpenChatbotParams) => Promise<void>;
37
38
  cancelCurrentFlow: () => void;
38
39
  markAsFinished: () => void;
39
40
  setCurrentNodeId: (currentNodeId: string) => void;
@@ -4972,7 +4972,8 @@ const store = {
4972
4972
  context = {},
4973
4973
  flowKeys,
4974
4974
  title,
4975
- analytics
4975
+ analytics,
4976
+ job
4976
4977
  }) => {
4977
4978
  const data = await idb.getStateData(flow, flowKeys) ?? initialiseFlowStateData();
4978
4979
  const startedFlow = {
@@ -4986,7 +4987,8 @@ const store = {
4986
4987
  build: flow.build,
4987
4988
  context,
4988
4989
  title,
4989
- analytics
4990
+ analytics,
4991
+ job
4990
4992
  };
4991
4993
  currentFlow.value = {
4992
4994
  state: "loaded",
@@ -5312,7 +5314,7 @@ const StatusBar = ({
5312
5314
  })
5313
5315
  });
5314
5316
  };
5315
- const ChatbotBody = M(() => import("./chatbot-body-364c9383.js").then((module) => module.ChatbotBody));
5317
+ const ChatbotBody = M(() => import("./chatbot-body-91e04292.js").then((module) => module.ChatbotBody));
5316
5318
  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", {
5317
5319
  variants: {
5318
5320
  view: {
@@ -5734,22 +5736,16 @@ const chatbotPlugin = ({
5734
5736
  * @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.
5735
5737
  */
5736
5738
  fetchFlowByJobId: async (jobId, additionalProperties) => apiClient.fetch(`/flow/job/${jobId}`).then((res) => {
5737
- var _a;
5738
5739
  const data = parse$1(FlowByJobPayloadSchema, res);
5739
5740
  return {
5740
5741
  flow: data.flow,
5741
5742
  title: `Applying for “${data.job.title}”`,
5742
5743
  flowKeys: [data.job.id, ...(additionalProperties == null ? void 0 : additionalProperties.flowKeys) ?? []],
5743
- ...additionalProperties,
5744
- analytics: {
5745
- customProperties: {
5746
- job_id: data.job.id,
5747
- key: "external_id",
5748
- flow_id: data.flow.id,
5749
- flow_version: data.flow.version,
5750
- ...(_a = additionalProperties == null ? void 0 : additionalProperties.analytics) == null ? void 0 : _a.customProperties
5751
- }
5752
- }
5744
+ job: {
5745
+ id: data.job.id,
5746
+ id_type: "external"
5747
+ },
5748
+ ...additionalProperties
5753
5749
  };
5754
5750
  }),
5755
5751
  fetchFlowById: async (flowId, additionalProperties) => apiClient.fetch(`/flow/id/${flowId}`).then((res) => {
@@ -5807,10 +5803,6 @@ const chatbotPlugin = ({
5807
5803
  logger.error("Error starting flow", error);
5808
5804
  }
5809
5805
  },
5810
- /** @deprecated - Please use `open` instead. */
5811
- startApplication: void 0,
5812
- /** @deprecated - Please use `close` instead */
5813
- closeApplication: void 0,
5814
5806
  close: async () => {
5815
5807
  if (typeof window === "undefined")
5816
5808
  return;
@@ -4973,7 +4973,8 @@ const store = {
4973
4973
  context = {},
4974
4974
  flowKeys,
4975
4975
  title,
4976
- analytics
4976
+ analytics,
4977
+ job
4977
4978
  }) => {
4978
4979
  const data = await idb.getStateData(flow, flowKeys) ?? initialiseFlowStateData();
4979
4980
  const startedFlow = {
@@ -4987,7 +4988,8 @@ const store = {
4987
4988
  build: flow.build,
4988
4989
  context,
4989
4990
  title,
4990
- analytics
4991
+ analytics,
4992
+ job
4991
4993
  };
4992
4994
  currentFlow.value = {
4993
4995
  state: "loaded",
@@ -5313,7 +5315,7 @@ const StatusBar = ({
5313
5315
  })
5314
5316
  });
5315
5317
  };
5316
- const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-e518eb9a.cjs")).then((module2) => module2.ChatbotBody));
5318
+ const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-36cdbd00.cjs")).then((module2) => module2.ChatbotBody));
5317
5319
  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", {
5318
5320
  variants: {
5319
5321
  view: {
@@ -5735,22 +5737,16 @@ const chatbotPlugin = ({
5735
5737
  * @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.
5736
5738
  */
5737
5739
  fetchFlowByJobId: async (jobId, additionalProperties) => apiClient.fetch(`/flow/job/${jobId}`).then((res) => {
5738
- var _a;
5739
5740
  const data = parse$1(FlowByJobPayloadSchema, res);
5740
5741
  return {
5741
5742
  flow: data.flow,
5742
5743
  title: `Applying for “${data.job.title}”`,
5743
5744
  flowKeys: [data.job.id, ...(additionalProperties == null ? void 0 : additionalProperties.flowKeys) ?? []],
5744
- ...additionalProperties,
5745
- analytics: {
5746
- customProperties: {
5747
- job_id: data.job.id,
5748
- key: "external_id",
5749
- flow_id: data.flow.id,
5750
- flow_version: data.flow.version,
5751
- ...(_a = additionalProperties == null ? void 0 : additionalProperties.analytics) == null ? void 0 : _a.customProperties
5752
- }
5753
- }
5745
+ job: {
5746
+ id: data.job.id,
5747
+ id_type: "external"
5748
+ },
5749
+ ...additionalProperties
5754
5750
  };
5755
5751
  }),
5756
5752
  fetchFlowById: async (flowId, additionalProperties) => apiClient.fetch(`/flow/id/${flowId}`).then((res) => {
@@ -5808,10 +5804,6 @@ const chatbotPlugin = ({
5808
5804
  logger.error("Error starting flow", error);
5809
5805
  }
5810
5806
  },
5811
- /** @deprecated - Please use `open` instead. */
5812
- startApplication: void 0,
5813
- /** @deprecated - Please use `close` instead */
5814
- closeApplication: void 0,
5815
5807
  close: async () => {
5816
5808
  if (typeof window === "undefined")
5817
5809
  return;
@@ -35,8 +35,6 @@ type ChatbotInterpreterParams = {
35
35
  flow: StartedFlow;
36
36
  getSubmissions: () => KeyToSubmissionMap | undefined;
37
37
  chatService: ChatService;
38
- /** When interpreter starts */
39
- beforeStart?: (firstNode: FlowNode) => Promise<void>;
40
38
  /** When flow has no more nodes to interpret */
41
39
  onFlowEnd?: (lastNode: FlowNode) => void;
42
40
  /** When node is interpreted */
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-d8265e0a.cjs");
3
+ const index = require("./index-fa87308a.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { R } from "./index-6e48d6e0.js";
1
+ import { R } from "./index-5b559a08.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  R as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.23.0",
3
+ "version": "3.23.1",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",
@@ -68,7 +68,7 @@
68
68
  "vite-tsconfig-paths": "^4.2.1",
69
69
  "@inploi/core": "1.14.2",
70
70
  "@inploi/design-tokens": "0.2.1",
71
- "@inploi/sdk": "1.14.2",
71
+ "@inploi/sdk": "1.14.3",
72
72
  "eslint-config-custom": "0.1.0",
73
73
  "tsconfig": "0.1.0"
74
74
  },