@inploi/plugin-chatbot 3.17.1 → 3.18.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-65ebb99d.cjs");
3
+ const index = require("./index-8c1e1b09.cjs");
4
4
  require("@inploi/sdk");
5
5
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6
6
  function getDefaultExportFromCjs(x) {
@@ -794,77 +794,80 @@ async function interpretSubmitNode({
794
794
  context,
795
795
  analytics
796
796
  }) {
797
- if (node.data.skipConfirmation !== true) {
798
- await chat.userInput({
799
- type: "submit",
800
- key: void 0,
801
- config: {
802
- label: node.data.submitLabel
803
- }
804
- });
805
- }
806
- await chat.sendMessage({
807
- type: "system",
808
- variant: "info",
809
- text: "Submitting…"
810
- });
811
- const {
812
- anonymous_id,
813
- session_id
814
- } = analytics.getSessionInfo();
815
- const response = await apiClient.fetch(`/flow/apply`, {
816
- method: "POST",
817
- body: JSON.stringify({
818
- ...context,
819
- integration_id: node.data.integrationId,
820
- anonymous_id,
821
- session_id,
822
- submissions: index.getFlowSubmissionsPayload(submissions || {})
823
- })
824
- }).catch((e) => e);
825
- if (node.data.key)
826
- chat.addToSubmissions(node.data.key, {
827
- type: "integration",
828
- value: response
829
- });
830
- await index.N(response).with({
831
- ats_data: {
832
- redirect_url: index._.string
833
- }
834
- }, async (response2) => {
835
- await chat.sendMessage({
836
- type: "text",
837
- author: "bot",
838
- text: "Almost there! Please complete your submission here:"
839
- });
840
- const href = new URL(response2.ats_data.redirect_url);
841
- if (anonymous_id && !href.searchParams.has("anonymous_id")) {
842
- href.searchParams.set("anonymous_id", anonymous_id);
797
+ const submit = async (skipConfirmation) => {
798
+ if (skipConfirmation !== true) {
799
+ await chat.userInput({
800
+ type: "submit",
801
+ key: void 0,
802
+ config: {
803
+ label: node.data.submitLabel
804
+ }
805
+ });
843
806
  }
844
- await chat.sendMessage({
845
- type: "link",
846
- href: href.toString(),
847
- text: "Complete submission"
848
- });
849
- next(node.nextId);
850
- }).with({
851
- success: true
852
- }, async () => {
853
807
  await chat.sendMessage({
854
808
  type: "system",
855
- variant: "success",
856
- text: "Submission completed!"
809
+ variant: "info",
810
+ text: "Submitting…"
857
811
  });
858
- next(node.nextId);
859
- }).otherwise(async (response2) => {
860
- logger.error(response2);
861
- await chat.sendMessage({
862
- type: "system",
863
- variant: "error",
864
- text: "Failed to submit"
812
+ const {
813
+ anonymous_id,
814
+ session_id
815
+ } = analytics.getSessionInfo();
816
+ const response = await apiClient.fetch(`/flow/submit`, {
817
+ method: "POST",
818
+ body: JSON.stringify({
819
+ ...context,
820
+ integration_id: node.data.integrationId,
821
+ anonymous_id,
822
+ session_id,
823
+ submissions: index.getFlowSubmissionsPayload(submissions || {})
824
+ })
825
+ }).catch((e) => e);
826
+ if (node.data.key)
827
+ chat.addToSubmissions(node.data.key, {
828
+ type: "integration",
829
+ value: response
830
+ });
831
+ await index.N(response).with({
832
+ ats_data: {
833
+ redirect_url: index._.string
834
+ }
835
+ }, async (response2) => {
836
+ await chat.sendMessage({
837
+ type: "text",
838
+ author: "bot",
839
+ text: "Almost there! Please complete your submission here:"
840
+ });
841
+ const href = new URL(response2.ats_data.redirect_url);
842
+ if (anonymous_id && !href.searchParams.has("anonymous_id")) {
843
+ href.searchParams.set("anonymous_id", anonymous_id);
844
+ }
845
+ await chat.sendMessage({
846
+ type: "link",
847
+ href: href.toString(),
848
+ text: "Complete submission"
849
+ });
850
+ next(node.nextId);
851
+ }).with({
852
+ success: true
853
+ }, async () => {
854
+ await chat.sendMessage({
855
+ type: "system",
856
+ variant: "success",
857
+ text: "Submission completed!"
858
+ });
859
+ next(node.nextId);
860
+ }).otherwise(async (response2) => {
861
+ logger.error(response2);
862
+ await chat.sendMessage({
863
+ type: "system",
864
+ variant: "error",
865
+ text: "Failed to submit"
866
+ });
867
+ await submit(false);
865
868
  });
866
- next(node.id);
867
- });
869
+ };
870
+ await submit(node.data.skipConfirmation);
868
871
  }
869
872
  async function interpretLinkNode({
870
873
  chat,
@@ -1639,10 +1642,10 @@ const ChatInputAddress = ({
1639
1642
  const debouncedQuery = index.F(() => index.debounce((query2) => {
1640
1643
  index.invariant(enabled, "Query state should not be enabled if Google Places isn't available");
1641
1644
  setQuery(query2);
1642
- if (query2 === "") {
1645
+ if (query2 === "")
1643
1646
  setSuggestions([]);
1647
+ if (query2.length < 3)
1644
1648
  return;
1645
- }
1646
1649
  getPredictions(query2).then((predictions) => {
1647
1650
  setSuggestions(predictions);
1648
1651
  });
@@ -1,4 +1,4 @@
1
- import { i as isString$1, g as getHeadOrThrow, a as invariant, A as AbortedError, N, b as getFlowSubmissionsPayload, _, k as kbToReadableSize, h, c as _$1, p, F, o as o$1, d as clsx, y, s as store, e as a$2, f as debounce$1, j as k, l as parse, m as picklist, n as isSubmissionOfType, C as Cn, q as parseAsync, V as ValiError, r as object, t as transform, u as maxLength, v as minLength, w as record, x as boolean, z as number, B as minValue, D as maxValue, E as custom, G as string, H as email, I as url, J as regex, K as cva, L as ERROR_MESSAGES } from "./index-bc9ac6fc.js";
1
+ import { i as isString$1, g as getHeadOrThrow, a as invariant, A as AbortedError, N, k as kbToReadableSize, b as getFlowSubmissionsPayload, _, h, c as _$1, p, F, o as o$1, d as clsx, y, s as store, e as a$2, f as debounce$1, j as k, l as parse, m as picklist, n as isSubmissionOfType, C as Cn, q as parseAsync, V as ValiError, r as object, t as transform, u as maxLength, v as minLength, w as record, x as boolean, z as number, B as minValue, D as maxValue, E as custom, G as string, H as email, I as url, J as regex, K as cva, L as ERROR_MESSAGES } from "./index-a0ca0101.js";
2
2
  import "@inploi/sdk";
3
3
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
@@ -792,77 +792,80 @@ async function interpretSubmitNode({
792
792
  context,
793
793
  analytics
794
794
  }) {
795
- if (node.data.skipConfirmation !== true) {
796
- await chat.userInput({
797
- type: "submit",
798
- key: void 0,
799
- config: {
800
- label: node.data.submitLabel
801
- }
802
- });
803
- }
804
- await chat.sendMessage({
805
- type: "system",
806
- variant: "info",
807
- text: "Submitting…"
808
- });
809
- const {
810
- anonymous_id,
811
- session_id
812
- } = analytics.getSessionInfo();
813
- const response = await apiClient.fetch(`/flow/apply`, {
814
- method: "POST",
815
- body: JSON.stringify({
816
- ...context,
817
- integration_id: node.data.integrationId,
818
- anonymous_id,
819
- session_id,
820
- submissions: getFlowSubmissionsPayload(submissions || {})
821
- })
822
- }).catch((e) => e);
823
- if (node.data.key)
824
- chat.addToSubmissions(node.data.key, {
825
- type: "integration",
826
- value: response
827
- });
828
- await N(response).with({
829
- ats_data: {
830
- redirect_url: _.string
831
- }
832
- }, async (response2) => {
833
- await chat.sendMessage({
834
- type: "text",
835
- author: "bot",
836
- text: "Almost there! Please complete your submission here:"
837
- });
838
- const href = new URL(response2.ats_data.redirect_url);
839
- if (anonymous_id && !href.searchParams.has("anonymous_id")) {
840
- href.searchParams.set("anonymous_id", anonymous_id);
795
+ const submit = async (skipConfirmation) => {
796
+ if (skipConfirmation !== true) {
797
+ await chat.userInput({
798
+ type: "submit",
799
+ key: void 0,
800
+ config: {
801
+ label: node.data.submitLabel
802
+ }
803
+ });
841
804
  }
842
- await chat.sendMessage({
843
- type: "link",
844
- href: href.toString(),
845
- text: "Complete submission"
846
- });
847
- next(node.nextId);
848
- }).with({
849
- success: true
850
- }, async () => {
851
805
  await chat.sendMessage({
852
806
  type: "system",
853
- variant: "success",
854
- text: "Submission completed!"
807
+ variant: "info",
808
+ text: "Submitting…"
855
809
  });
856
- next(node.nextId);
857
- }).otherwise(async (response2) => {
858
- logger.error(response2);
859
- await chat.sendMessage({
860
- type: "system",
861
- variant: "error",
862
- text: "Failed to submit"
810
+ const {
811
+ anonymous_id,
812
+ session_id
813
+ } = analytics.getSessionInfo();
814
+ const response = await apiClient.fetch(`/flow/submit`, {
815
+ method: "POST",
816
+ body: JSON.stringify({
817
+ ...context,
818
+ integration_id: node.data.integrationId,
819
+ anonymous_id,
820
+ session_id,
821
+ submissions: getFlowSubmissionsPayload(submissions || {})
822
+ })
823
+ }).catch((e) => e);
824
+ if (node.data.key)
825
+ chat.addToSubmissions(node.data.key, {
826
+ type: "integration",
827
+ value: response
828
+ });
829
+ await N(response).with({
830
+ ats_data: {
831
+ redirect_url: _.string
832
+ }
833
+ }, async (response2) => {
834
+ await chat.sendMessage({
835
+ type: "text",
836
+ author: "bot",
837
+ text: "Almost there! Please complete your submission here:"
838
+ });
839
+ const href = new URL(response2.ats_data.redirect_url);
840
+ if (anonymous_id && !href.searchParams.has("anonymous_id")) {
841
+ href.searchParams.set("anonymous_id", anonymous_id);
842
+ }
843
+ await chat.sendMessage({
844
+ type: "link",
845
+ href: href.toString(),
846
+ text: "Complete submission"
847
+ });
848
+ next(node.nextId);
849
+ }).with({
850
+ success: true
851
+ }, async () => {
852
+ await chat.sendMessage({
853
+ type: "system",
854
+ variant: "success",
855
+ text: "Submission completed!"
856
+ });
857
+ next(node.nextId);
858
+ }).otherwise(async (response2) => {
859
+ logger.error(response2);
860
+ await chat.sendMessage({
861
+ type: "system",
862
+ variant: "error",
863
+ text: "Failed to submit"
864
+ });
865
+ await submit(false);
863
866
  });
864
- next(node.id);
865
- });
867
+ };
868
+ await submit(node.data.skipConfirmation);
866
869
  }
867
870
  async function interpretLinkNode({
868
871
  chat,
@@ -1637,10 +1640,10 @@ const ChatInputAddress = ({
1637
1640
  const debouncedQuery = F(() => debounce$1((query2) => {
1638
1641
  invariant(enabled, "Query state should not be enabled if Google Places isn't available");
1639
1642
  setQuery(query2);
1640
- if (query2 === "") {
1643
+ if (query2 === "")
1641
1644
  setSuggestions([]);
1645
+ if (query2.length < 3)
1642
1646
  return;
1643
- }
1644
1647
  getPredictions(query2).then((predictions) => {
1645
1648
  setSuggestions(predictions);
1646
1649
  });
@@ -4759,7 +4759,7 @@ const StatusBar = ({
4759
4759
  })
4760
4760
  });
4761
4761
  };
4762
- const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-ca0c18fa.cjs")).then((module2) => module2.ChatbotBody));
4762
+ const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-08b2c697.cjs")).then((module2) => module2.ChatbotBody));
4763
4763
  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", {
4764
4764
  variants: {
4765
4765
  view: {
@@ -4758,7 +4758,7 @@ const StatusBar = ({
4758
4758
  })
4759
4759
  });
4760
4760
  };
4761
- const ChatbotBody = M(() => import("./chatbot-body-7f24fa2b.js").then((module) => module.ChatbotBody));
4761
+ const ChatbotBody = M(() => import("./chatbot-body-29d96369.js").then((module) => module.ChatbotBody));
4762
4762
  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", {
4763
4763
  variants: {
4764
4764
  view: {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-65ebb99d.cjs");
3
+ const index = require("./index-8c1e1b09.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { M } from "./index-bc9ac6fc.js";
1
+ import { M } from "./index-a0ca0101.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  M as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.17.1",
3
+ "version": "3.18.0",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",