@inploi/plugin-chatbot 14.17.3 → 14.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.
@@ -0,0 +1,40 @@
1
+ import { BeaconFields, BeaconKind } from '@inploi/flows/beacon';
2
+ import { ApiClient, InploiSdkEnvironment } from '@inploi/sdk';
3
+
4
+ /**
5
+ * The CDN build's own directory (`…/@inploi/plugin-chatbot[@<v>]/cdn/`), whose one file is `index.js`; undefined for an
6
+ * npm build, which is part of a host's bundle (Studio's), where no frame can be told to be the chatbot's.
7
+ */
8
+ export declare const ownBuild: (scriptUrl: string) => string | undefined;
9
+ /**
10
+ * A caught error's safe detail (`errorDetail`). Its stack keeps only frames of the CDN build's `index.js`, so no other
11
+ * file's name (a host frame whose URL embeds this build's, in its query or fragment) is ever sent; an npm build keeps
12
+ * none (a newline never occurs in a stack line, so no frame is its own).
13
+ */
14
+ export declare const chatbotDetail: (error: unknown, cdnBuild: string | undefined, eventMessage?: string) => {
15
+ stack: string[];
16
+ name: string;
17
+ message: string;
18
+ foreign: string[];
19
+ thrown: import('@inploi/flows/beacon').ThrownShape;
20
+ };
21
+ export declare const chatbotError: (error: unknown) => {
22
+ stack: string[];
23
+ name: string;
24
+ message: string;
25
+ foreign: string[];
26
+ thrown: import('@inploi/flows/beacon').ThrownShape;
27
+ };
28
+ /**
29
+ * An api answer's HTTP status. Read from the error's shape, not its class: the CDN build bundles its own SDK, so the
30
+ * host SDK's errors are another class's instances.
31
+ */
32
+ export declare const statusOf: (error: unknown) => number | undefined;
33
+ export declare const chatbotBeacon: (kind: BeaconKind, reason?: string, fields?: BeaconFields) => void | undefined;
34
+ /**
35
+ * One set of beacons per document, from the first chatbot the page registers; none without the build's settings.
36
+ * `scriptUrl`: where this code was loaded from (tests pass a CDN one).
37
+ */
38
+ export declare const startBeacons: (env: InploiSdkEnvironment | undefined, publishableKey: string | undefined, scriptUrl?: string) => void;
39
+ /** `/flow/submit` with no answer from any server (network, CORS, blocked), and the retry that got through. */
40
+ export declare const withSubmitBeacons: (apiClient: ApiClient) => ApiClient;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ var u = "https://maps.inploi.com", d = (r, e) => {
2
+ const s = new URL(`/${r}`, u);
3
+ return s.search = new URLSearchParams({
4
+ q: e.query,
5
+ limit: "5",
6
+ surface: e.surface,
7
+ seed: e.seed
8
+ }).toString(), e.country && s.searchParams.set("country", e.country), s;
9
+ }, c = (r) => typeof r == "object" && r !== null && !Array.isArray(r), f = (r) => {
10
+ if (!c(r) || typeof r.label != "string" || !c(r.address) || r.country !== void 0 && typeof r.country != "string")
11
+ return;
12
+ const e = {};
13
+ for (const s of ["line1", "line2", "line3", "city", "state", "postcode", "country"]) {
14
+ const t = r.address[s];
15
+ if (t !== void 0 && typeof t != "string")
16
+ return;
17
+ t !== void 0 && (e[s] = t);
18
+ }
19
+ return { id: r.label, label: r.label, country: r.country, address: e };
20
+ }, y = async (r, e, s) => {
21
+ const t = await fetch(r.href, { signal: s });
22
+ if (!t.ok)
23
+ return;
24
+ const n = t.headers.get("X-Geo-Arm"), a = await t.json();
25
+ if (n !== "inploi" && n !== "mapbox" || !c(a) || !Array.isArray(a.results) || a.source !== "photon" && a.source !== "mapbox" && a.source !== "places" || typeof a.attribution != "string")
26
+ return;
27
+ const i = [];
28
+ for (const l of a.results) {
29
+ const o = e(l);
30
+ if (o === void 0)
31
+ return;
32
+ i.push(o);
33
+ }
34
+ return { results: i, arm: n, source: a.source };
35
+ }, g = (r) => {
36
+ const e = d("address", { ...r, seed: r.session });
37
+ return e.searchParams.set("session", r.session), r.lat !== void 0 && r.lng !== void 0 && Number.isFinite(r.lat) && Number.isFinite(r.lng) && r.lat >= -90 && r.lat <= 90 && r.lng >= -180 && r.lng <= 180 && (e.searchParams.set("lat", String(r.lat)), e.searchParams.set("lng", String(r.lng))), y(e, f, r.signal);
38
+ };
39
+ export {
40
+ g as lookupAddress
41
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var u="https://maps.inploi.com",d=(r,e)=>{const s=new URL(`/${r}`,u);return s.search=new URLSearchParams({q:e.query,limit:"5",surface:e.surface,seed:e.seed}).toString(),e.country&&s.searchParams.set("country",e.country),s},c=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),f=r=>{if(!c(r)||typeof r.label!="string"||!c(r.address)||r.country!==void 0&&typeof r.country!="string")return;const e={};for(const s of["line1","line2","line3","city","state","postcode","country"]){const t=r.address[s];if(t!==void 0&&typeof t!="string")return;t!==void 0&&(e[s]=t)}return{id:r.label,label:r.label,country:r.country,address:e}},y=async(r,e,s)=>{const t=await fetch(r.href,{signal:s});if(!t.ok)return;const n=t.headers.get("X-Geo-Arm"),a=await t.json();if(n!=="inploi"&&n!=="mapbox"||!c(a)||!Array.isArray(a.results)||a.source!=="photon"&&a.source!=="mapbox"&&a.source!=="places"||typeof a.attribution!="string")return;const i=[];for(const l of a.results){const o=e(l);if(o===void 0)return;i.push(o)}return{results:i,arm:n,source:a.source}},g=r=>{const e=d("address",{...r,seed:r.session});return e.searchParams.set("session",r.session),r.lat!==void 0&&r.lng!==void 0&&Number.isFinite(r.lat)&&Number.isFinite(r.lng)&&r.lat>=-90&&r.lat<=90&&r.lng>=-180&&r.lng<=180&&(e.searchParams.set("lat",String(r.lat)),e.searchParams.set("lng",String(r.lng))),y(e,f,r.signal)};exports.lookupAddress=g;