@inploi/plugin-chatbot 3.9.0 → 3.10.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.
@@ -8284,7 +8284,7 @@ const StatusBar = ({
8284
8284
  })]
8285
8285
  });
8286
8286
  };
8287
- const JobApplicationContent = M(() => import("./job-application-content-6683c944.js").then((module) => module.JobApplicationContent));
8287
+ const JobApplicationContent = M(() => import("./job-application-content-c89a480d.js").then((module) => module.JobApplicationContent));
8288
8288
  const MotionProvider = ({
8289
8289
  children
8290
8290
  }) => {
@@ -8285,7 +8285,7 @@ const StatusBar = ({
8285
8285
  })]
8286
8286
  });
8287
8287
  };
8288
- const JobApplicationContent = M(() => Promise.resolve().then(() => require("./job-application-content-cdd9aeb2.cjs")).then((module2) => module2.JobApplicationContent));
8288
+ const JobApplicationContent = M(() => Promise.resolve().then(() => require("./job-application-content-191ecc14.cjs")).then((module2) => module2.JobApplicationContent));
8289
8289
  const MotionProvider = ({
8290
8290
  children
8291
8291
  }) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-210f3179.cjs");
3
+ const index = require("./index-2d0cac15.cjs");
4
4
  require("@inploi/sdk");
5
5
  const kbToReadableSize = (kb) => index.N(kb).with(index._.number.lte(1e3), () => `${Math.round(kb)}KB`).with(index._.number.lt(1e3 * 10), () => `${(kb / 1e3).toFixed(1)}MB`).otherwise(() => `${Math.round(kb / 1e3)}MB`);
6
6
  const getHeadOrThrow = (nodes) => {
@@ -232,12 +232,17 @@ async function interpretSubmitNode({
232
232
  variant: "info",
233
233
  text: "Submitting your application…"
234
234
  });
235
+ const {
236
+ anonymous_id,
237
+ session_id
238
+ } = analytics.getSessionInfo();
235
239
  const response = await apiClient.fetch(`/flow/apply`, {
236
240
  method: "POST",
237
241
  body: JSON.stringify({
238
242
  ...context,
239
243
  integration_id: node.data.integrationId,
240
- anonymous_id: analytics.getAnonymousId(),
244
+ anonymous_id,
245
+ session_id,
241
246
  submissions: getApplicationSubmissionsPayload(submissions || {})
242
247
  })
243
248
  }).catch((e) => e);
@@ -251,10 +256,9 @@ async function interpretSubmitNode({
251
256
  author: "bot",
252
257
  text: "Almost there! Please finalise your application on our partner’s website."
253
258
  });
254
- const currentAnonymousId = analytics.getAnonymousId();
255
259
  const href = new URL(response2.ats_data.redirect_url);
256
- if (currentAnonymousId && !href.searchParams.has("anonymous_id")) {
257
- href.searchParams.set("anonymous_id", currentAnonymousId);
260
+ if (anonymous_id && !href.searchParams.has("anonymous_id")) {
261
+ href.searchParams.set("anonymous_id", anonymous_id);
258
262
  }
259
263
  logApplyComplete();
260
264
  await chat.sendMessage({
@@ -981,6 +985,19 @@ const FilenameBadge = ({
981
985
  class: index.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1", className),
982
986
  ...props
983
987
  });
988
+ const getFileExtension = (fileName) => {
989
+ const extension = fileName.split(".").pop();
990
+ if (!extension)
991
+ throw new Error("No file extension found");
992
+ return extension ? "." + extension : "";
993
+ };
994
+ const validateExtensions = ({
995
+ allowedExtensions,
996
+ files
997
+ }) => {
998
+ const normalisedExtensions = allowedExtensions.map((ext) => ext.toLowerCase());
999
+ return files.every((file) => normalisedExtensions.includes(getFileExtension(file.name).toLowerCase()));
1000
+ };
984
1001
  const ChatInputFile = ({
985
1002
  input,
986
1003
  onSubmitSuccess,
@@ -1004,6 +1021,15 @@ const ChatInputFile = ({
1004
1021
  message: "Please select a file"
1005
1022
  });
1006
1023
  }
1024
+ if (input.config.extensions.length > 0 && !validateExtensions({
1025
+ allowedExtensions: input.config.extensions,
1026
+ files
1027
+ })) {
1028
+ return setError({
1029
+ type: "validate",
1030
+ message: `Please upload ${input.config.extensions.join(", ")} files only`
1031
+ });
1032
+ }
1007
1033
  if (input.config.fileSizeLimitKib && totalSize > input.config.fileSizeLimitKib) {
1008
1034
  return setError({
1009
1035
  type: "max",
@@ -1,4 +1,4 @@
1
- import { N, _, h as hasProp, i as invariant, o as o$1, c as clsx, a as _$1, p, b as parse, d as picklist, y, e as application, f as h, k, C as Cn, g as parseAsync, V as ValiError, j as object, t as transform, m as maxLength, l as minLength, r as record, n as boolean, s as string, q as email, u as url, v as regex, T, w as inputHeight, x as m, A as AnimatePresence, F, z as viewState, E as ERROR_MESSAGES } from "./index-6a43f107.js";
1
+ import { N, _, h as hasProp, i as invariant, o as o$1, c as clsx, a as _$1, p, b as parse, d as picklist, y, e as application, f as h, k, C as Cn, g as parseAsync, V as ValiError, j as object, t as transform, m as maxLength, l as minLength, r as record, n as boolean, s as string, q as email, u as url, v as regex, T, w as inputHeight, x as m, A as AnimatePresence, F, z as viewState, E as ERROR_MESSAGES } from "./index-122b2522.js";
2
2
  import "@inploi/sdk";
3
3
  const kbToReadableSize = (kb) => N(kb).with(_.number.lte(1e3), () => `${Math.round(kb)}KB`).with(_.number.lt(1e3 * 10), () => `${(kb / 1e3).toFixed(1)}MB`).otherwise(() => `${Math.round(kb / 1e3)}MB`);
4
4
  const getHeadOrThrow = (nodes) => {
@@ -230,12 +230,17 @@ async function interpretSubmitNode({
230
230
  variant: "info",
231
231
  text: "Submitting your application…"
232
232
  });
233
+ const {
234
+ anonymous_id,
235
+ session_id
236
+ } = analytics.getSessionInfo();
233
237
  const response = await apiClient.fetch(`/flow/apply`, {
234
238
  method: "POST",
235
239
  body: JSON.stringify({
236
240
  ...context,
237
241
  integration_id: node.data.integrationId,
238
- anonymous_id: analytics.getAnonymousId(),
242
+ anonymous_id,
243
+ session_id,
239
244
  submissions: getApplicationSubmissionsPayload(submissions || {})
240
245
  })
241
246
  }).catch((e) => e);
@@ -249,10 +254,9 @@ async function interpretSubmitNode({
249
254
  author: "bot",
250
255
  text: "Almost there! Please finalise your application on our partner’s website."
251
256
  });
252
- const currentAnonymousId = analytics.getAnonymousId();
253
257
  const href = new URL(response2.ats_data.redirect_url);
254
- if (currentAnonymousId && !href.searchParams.has("anonymous_id")) {
255
- href.searchParams.set("anonymous_id", currentAnonymousId);
258
+ if (anonymous_id && !href.searchParams.has("anonymous_id")) {
259
+ href.searchParams.set("anonymous_id", anonymous_id);
256
260
  }
257
261
  logApplyComplete();
258
262
  await chat.sendMessage({
@@ -979,6 +983,19 @@ const FilenameBadge = ({
979
983
  class: clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1", className),
980
984
  ...props
981
985
  });
986
+ const getFileExtension = (fileName) => {
987
+ const extension = fileName.split(".").pop();
988
+ if (!extension)
989
+ throw new Error("No file extension found");
990
+ return extension ? "." + extension : "";
991
+ };
992
+ const validateExtensions = ({
993
+ allowedExtensions,
994
+ files
995
+ }) => {
996
+ const normalisedExtensions = allowedExtensions.map((ext) => ext.toLowerCase());
997
+ return files.every((file) => normalisedExtensions.includes(getFileExtension(file.name).toLowerCase()));
998
+ };
982
999
  const ChatInputFile = ({
983
1000
  input,
984
1001
  onSubmitSuccess,
@@ -1002,6 +1019,15 @@ const ChatInputFile = ({
1002
1019
  message: "Please select a file"
1003
1020
  });
1004
1021
  }
1022
+ if (input.config.extensions.length > 0 && !validateExtensions({
1023
+ allowedExtensions: input.config.extensions,
1024
+ files
1025
+ })) {
1026
+ return setError({
1027
+ type: "validate",
1028
+ message: `Please upload ${input.config.extensions.join(", ")} files only`
1029
+ });
1030
+ }
1005
1031
  if (input.config.fileSizeLimitKib && totalSize > input.config.fileSizeLimitKib) {
1006
1032
  return setError({
1007
1033
  type: "max",
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-210f3179.cjs");
3
+ const index = require("./index-2d0cac15.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { B } from "./index-6a43f107.js";
1
+ import { B } from "./index-122b2522.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  B as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",
@@ -67,7 +67,7 @@
67
67
  "vite-tsconfig-paths": "^4.2.1",
68
68
  "@inploi/core": "1.11.5",
69
69
  "@inploi/design-tokens": "0.2.0",
70
- "@inploi/sdk": "1.11.4",
70
+ "@inploi/sdk": "1.12.0",
71
71
  "eslint-config-custom": "0.1.0",
72
72
  "tsconfig": "0.1.0"
73
73
  },