@inploi/flows 0.0.0 → 2.0.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
  import { FlowNode } from '@inploi/core/flows';
2
- import { ApiClient, AnalyticsService, Logger } from '@inploi/sdk';
3
- import { F as FlowSubmissions, a as FlowInput, R as Result, I as Issues } from './result-6033e9fc.js';
2
+ import { InploiRpcClient, AnalyticsService, Logger } from '@inploi/sdk';
3
+ import { F as FlowSubmissions, a as FlowInput, R as Result, V as ValiError } from './result-3e1b4efe.js';
4
4
  import * as _inploi_i18n_translation from '@inploi/i18n/translation';
5
5
  import { LinkedList } from './linked-list.mjs';
6
6
 
@@ -12,7 +12,6 @@ declare const useTranslation: <T extends {
12
12
  readonly maximize: "Maximise";
13
13
  readonly minimize: "Minimise";
14
14
  readonly close_application: "Close application";
15
- readonly applying_for: "Applying for “{{title}}”";
16
15
  /** When an application is at an invalid state, the user will get this error. */
17
16
  readonly invalid_state: "Invalid application state";
18
17
  readonly redirect_url_error: "Couldn’t get the redirect URL.";
@@ -66,7 +65,6 @@ declare const useTranslation: <T extends {
66
65
  readonly maximize: "Maximise";
67
66
  readonly minimize: "Minimise";
68
67
  readonly close_application: "Close application";
69
- readonly applying_for: "Applying for “{{title}}”";
70
68
  /** When an application is at an invalid state, the user will get this error. */
71
69
  readonly invalid_state: "Invalid application state";
72
70
  readonly redirect_url_error: "Couldn’t get the redirect URL.";
@@ -161,12 +159,12 @@ type FlowInterpreterYield = {
161
159
  type: I;
162
160
  })['submission']>['value'] | null) => MaybePromise<Result<NonNullable<(FlowInput & {
163
161
  type: I;
164
- })['submission']>['value'] | null, Issues>>;
162
+ })['submission']>['value'] | null, ValiError<any>['issues']>>;
165
163
  };
166
164
  }[FlowInput['type']];
167
165
  };
168
166
  type FlowInterpreterParams = {
169
- apiClient: ApiClient;
167
+ rpcClient: InploiRpcClient;
170
168
  analytics: {
171
169
  service: AnalyticsService;
172
170
  customProperties?: Record<string, unknown>;
@@ -203,7 +201,7 @@ type FlowActions = {
203
201
  type: T;
204
202
  }>(type: T, params: {
205
203
  config: Input['config'];
206
- validate: (input: NonNullable<Input['submission']>['value'] | null) => MaybePromise<Result<NonNullable<Input['submission']>['value'] | null, Issues>>;
204
+ validate: (input: NonNullable<Input['submission']>['value'] | null) => MaybePromise<Result<NonNullable<Input['submission']>['value'] | null, ValiError<any>['issues']>>;
207
205
  }) => FlowInterpreterYield;
208
206
  };
209
207
  declare const createFlowInterpreter: (params: FlowInterpreterParams) => {
@@ -1,2 +1,2 @@
1
- import{A as m,B as f,C as J,E as Z,F as _,G as j,H as ee,I as O,J as te,a as L,b as q,c as K,d as $,e as p,f as h,g as B,h as T,i as G,j as R,k as F,l as I,m as A,n as V,o as g,p as Q,q as v,r as D,s as E,t as U,u as x,v as W,w as k,x as X,y as Y,z as H}from"./chunk-3QWHH45C.mjs";var z=K(B());var ae=({condition:r,context:e,submissions:u,ifBlock:s})=>{let[i,...n]=r.compareKey.split(".");if(!i)return!1;let a=j({context:e,key:i,path:n,submissions:u});if(!a)return!1;switch(a.type){case"address":{let t=(0,z.default)(a.value,n.join("."));switch(r.compare){case"equals":return t===r.compareValue;case"contains":return t?t.includes(r.compareValue):!1;case"notEquals":return t!==r.compareValue;case"notContains":return t?!t.includes(r.compareValue):!0}break}case"integration":{if(typeof a.value!="object"||Array.isArray(a.value))return!1;let t=(0,z.default)(a.value,n.join(".")),o=q(L({},s),{data:q(L({},s.data),{compareKey:"_temp"})});switch(typeof t){case"boolean":return C(o,{submissions:{_temp:{value:t,type:"boolean"}},context:e});case"string":return C(o,{submissions:{_temp:{value:t,type:"string"}},context:e});case"number":return C(o,{submissions:{_temp:{value:t,type:"number"}},context:e});case"object":return Array.isArray(t)&&t.every(l=>typeof l=="string")?C(o,{submissions:{_temp:{value:t,type:"enum"}},context:e}):!1}break}case"boolean":{let t=r.compareValue==="true";switch(r.compare){case"equals":return a.value===t;case"notEquals":return a.value!==t}break}case"phone":case"string":{let t=a.type==="phone"?a.value.countryCode+a.value.phoneNumber:a.value;switch(r.compare){case"equals":return t===r.compareValue;case"contains":return t?t.includes(r.compareValue):!1;case"notEquals":return t!==r.compareValue;case"notContains":return t?!t.includes(r.compareValue):!0}break}case"number":{try{let t=Number(r.compareValue);switch(r.compare){case"equals":return a.value===t;case"notEquals":return a.value!==t;case"greaterThan":return a.value>t;case"greaterThanOrEqualTo":return a.value>=t;case"lessThan":return a.value<t;case"lessThanOrEqualTo":return a.value<=t}}catch(t){return console.error(`Failed to parse number in if-block ${s.id}`,a.value),!1}break}case"enum":switch(r.compare){case"equals":return a.value.length===1&&a.value[0]===r.compareValue;case"notEquals":return a.value.length===1&&a.value[0]!==r.compareValue;case"contains":return a.value.includes(r.compareValue);case"notContains":return!a.value.includes(r.compareValue)}break;case"file":break;default:break}},C=(r,{context:e,submissions:u})=>{let s="combinator"in r.data?r.data.conditions:[r.data];if(("combinator"in r.data?r.data.combinator:"and")==="or"){for(let n of s)if(ae({condition:n,context:e,submissions:u,ifBlock:r}))return!0;return!1}else{for(let n of s)if(!ae({condition:n,context:e,submissions:u,ifBlock:r}))return!1;return!0}};var re=K(B());var ye=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,N=(r,{context:e,submissions:u})=>r.replace(ye,(s,i,n="")=>{let[a,...t]=i.trim().split("."),o=j({key:a,path:t,submissions:u,context:e});if(!o)return n;switch(o.type){case"boolean":return o.value===!0?"true":"false";case"file":return o.value.map(l=>`${l.name} (${O(l.sizeKb)})`).join(", ");case"enum":return o.value.join(", ");case"address":return Object.values(o.value).filter(l=>l&&l.trim().length>0).join(", ");case"number":case"string":return o.value?o.value.toString():n;case"phone":return te(o.value);case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))break;let l=(0,re.default)(o.value,t.join("."));switch(typeof l){case"boolean":return l===!0?"true":"false";case"string":return l;case"number":return l.toString();case"object":if(Array.isArray(l)&&l.every(d=>typeof d=="string"))return l.join(", ")}break}default:}return n});function ne(r){return p(this,null,function*(){let{node:e,config:{logger:u,analytics:s,submissions:i,next:n}}=r;return s.service.log({event:"IDENTIFY",properties:{identifier:_({key:e.data.key,submissions:i}).toString(),first_name:e.data.firstName?_({key:e.data.firstName,submissions:i}).toString():void 0,last_name:e.data.lastName?_({key:e.data.lastName,submissions:i}).toString():void 0,email:e.data.email?_({key:e.data.email,submissions:i}).toString():void 0,phone_number:e.data.phoneNumber?_({key:e.data.phoneNumber,submissions:i}).toString():void 0,custom_traits:e.data.customTraits?Object.fromEntries(e.data.customTraits.map(({key:a,value:t})=>{var o;return[a,(o=i[t])==null?void 0:o.value]})):void 0}}).catch(u.error),n(e.nextId)})}var ge=I({success:G(),integration_response:I({service:A(g()),status:F(),data:Q(),error:R(I({message:g(),data:Q()}))})});function oe(r){return p(this,null,function*(){var l;let{node:e,config:{apiClient:u,submissions:s,actions:i,next:n,analytics:a,logger:t,context:o}}=r;return e.data.skipConfirmation!==!0&&(yield i.input("submit",{config:{key:(l=e.data.key)!=null?l:"_SUBMIT",label:e.data.submitLabel},validate:()=>$(this,null,function*(){let c=J(a.service.getSessionInfo)();c.err&&t.error(c.val.originalError);try{let y=yield u.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:e.data.integrationId,anonymous_id:c.ok?c.val.anonymous_id:void 0,session_id:c.ok?c.val.session_id:void 0,job:o.job,submissions:Z(s)})}),b=v(ge,y);return b.success===!1?f(b.issues):m(b.output)}catch(y){let b=[{input:y,origin:"value",reason:"unknown",validation:"API error",message:y instanceof Error?y.message:"toString"in y?y.toString():"Unknown error"}];return f(b)}})})),n(e.nextId)})}var S=R(A(g())),ve=({node:r})=>{var u,s,i,n,a,t,o;let e=r.data.keys;return I({[(u=e.line1)!=null?u:"line1"]:S,[(s=e.line2)!=null?s:"line2"]:S,[(i=e.line3)!=null?i:"line3"]:S,[(n=e.city)!=null?n:"city"]:S,[(a=e.country)!=null?a:"country"]:S,[(t=e.postcode)!=null?t:"postcode"]:S,[(o=e.state)!=null?o:"state"]:S})};function se(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=r;return yield s.text({author:"bot",message:e.data.question}),yield s.input("address",{config:{key:e.data.key,keys:e.data.keys,placeholder:e.data.placeholder,optional:e.data.optional},validate:n=>{if(e.data.optional&&n===null)return m(n);let a=ve(r),t=v(a,n);return t.success===!1?f(t.issues):(u[e.data.key]={type:"address",value:t.output},m(n))}}),i(e.nextId)})}var be=["true","false"],he=V(be);function ie(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=r;return yield s.text({author:"bot",message:e.data.question}),yield s.input("boolean",{config:{key:e.data.key,labels:{false:e.data.falseLabel,true:e.data.trueLabel},optional:e.data.optional},validate:n=>{if(e.data.optional&&n===null)return m(n);let a=v(he,n);return a.success===!1?f(a.issues):(u[e.data.key]={type:"boolean",value:a.output==="true"},m(n))}}),i(e.nextId)})}function ue(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=r;yield s.text({author:"bot",message:e.data.question});let n=T(V(e.data.options.map(a=>a.value)));return yield s.input("multiple-choice",{config:{key:e.data.key,options:e.data.options,maxSelected:e.data.maxSelected,minSelected:e.data.minSelected},validate:a=>{if(e.data.minSelected===0&&a===null)return m(a);let t=v(n,a);return t.success===!1?f(t.issues):(u[e.data.key]={type:"enum",value:t.output},m(a))}}),i(e.nextId)})}function le(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i,t:n}}=r;return yield s.text({author:"bot",message:e.data.question}),yield s.input("file",{config:{key:e.data.key,allowMultiple:e.data.multiple===!0,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb,optional:e.data.optional},validate:a=>{var b;if(e.data.optional&&a===null)return m(a);let t=e.data.optional?0:1,o=e.data.multiple?Number.POSITIVE_INFINITY:1,l=(b=e.data.maxSizeKb)!=null?b:0,d=e.data.extensions.map(P=>P.toLowerCase()),c=T(I({name:g(n("validation_empty"),[E(P=>{let M=ee(P);return M.ok===!1?!1:d.includes(M.val.toLowerCase())},n("validation_file_ext",{ext:d.join(", ")}))]),data:g(),sizeKb:F()}),[k(t,n("validation_file_min",{count:t})),x(o,n("validation_file_max",{count:o})),E(P=>P.reduce((pe,fe)=>pe+fe.sizeKb,0)<=l,n("validation_file_size",{size:O(l)}))]),y=v(c,a);return y.success===!1?f(y.issues):(u[e.data.key]={type:"file",value:y.output},m(a))}}),i(e.nextId)})}var Ie=({node:r,config:{t:e}})=>{var n,a,t;let u=(n=r.data.min)!=null?n:Number.MIN_SAFE_INTEGER,s=(a=r.data.max)!=null?a:Number.MAX_SAFE_INTEGER,i=(t=r.data.decimalCases)!=null?t:0;return F(e("validation_number"),[X(u,e("validation_number_min",{min:u})),W(s,e("validation_number_max",{max:s})),E(o=>o===Number(o.toFixed(i)),e("validation_number_decimal_cases",{count:i}))])};function de(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=r;yield s.text({author:"bot",message:e.data.question});let n=u[e.data.key];return yield s.input("number",{config:{key:e.data.key,placeholder:e.data.placeholder,optional:e.data.optional,decimalCases:e.data.decimalCases,max:e.data.max,min:e.data.min,defaultValue:(n==null?void 0:n.type)==="number"?n.value.toString():void 0},validate:a=>{if(e.data.optional&&a===null)return m(a);let t=Ie(r),o=v(t,a);return o.success===!1?f(o.issues):(u[e.data.key]={type:"number",value:o.output},m(a))}}),i(e.nextId)})}var xe=({node:r,config:{t:e}})=>I({countryCode:g(e("validation_country_code"),[Y(/^\+?[0-9 -]+$/,e("validation_country_code"))]),phoneNumber:D(g(e("validation_phone"),[Y(/^\+?[0-9 -]+$/,e("validation_phone")),k(r.data.minChars,e("validation_min_chars",{count:r.data.minChars})),x(r.data.maxChars,e("validation_max_chars",{count:r.data.maxChars}))]),u=>u.replace(/[^0-9]/g,""),[])});function me(r){return p(this,null,function*(){let{node:e,config:{actions:u,next:s,submissions:i}}=r;yield u.text({author:"bot",message:e.data.question});let n=i[e.data.key];return yield u.input("phone",{config:{key:e.data.key,minChars:e.data.minChars,maxChars:e.data.maxChars,defaultValue:(n==null?void 0:n.type)==="phone"?n.value:{countryCode:e.data.defaultCountryCode},placeholder:e.data.placeholder,submissionFormat:"phone",optional:e.data.optional},validate:a=>{if(e.data.optional&&a===null)return m(a);let t=xe(r),o=v(t,a);return o.success===!1?f(o.issues):(i[e.data.key]={type:"address",value:o.output},m(a))}}),s(e.nextId)})}var ke=({node:r,config:{t:e,logger:u}})=>{var i,n,a,t,o,l,d,c,y,b;let s={email:e("validation_email"),url:e("validation_url"),maxLength:e("validation_max_chars",{count:(i=r.data.maxChars)!=null?i:999}),minLength:e("validation_min_chars",{count:(n=r.data.minChars)!=null?n:1})};switch(r.data.format){case"email":return g(s.email,[U(s.email),k((a=r.data.minChars)!=null?a:1,s.minLength),x((t=r.data.maxChars)!=null?t:1/0,s.maxLength)]);case"text":return g([k((o=r.data.minChars)!=null?o:1,s.minLength),x((l=r.data.maxChars)!=null?l:1/0,s.maxLength)]);case"url":return g([H(s.url),k((d=r.data.minChars)!=null?d:1,s.minLength),x((c=r.data.maxChars)!=null?c:1/0,s.maxLength)]);case"phone":return g([k((y=r.data.minChars)!=null?y:1,s.minLength),x((b=r.data.maxChars)!=null?b:1/0,s.maxLength)]);default:return r.data.format,u.error(`Unsupported question-text format: ${r.data.format}`),null}};function ce(r){return p(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=r;yield s.text({author:"bot",message:e.data.question});let n=u[e.data.key];return yield s.input("text",{config:{key:e.data.key,maxChars:e.data.maxChars,minChars:e.data.minChars,placeholder:e.data.placeholder,format:e.data.format,optional:e.data.optional,defaultValue:(n==null?void 0:n.type)==="string"?n.value:void 0},validate:a=>{if(e.data.optional&&a===null)return m(a);let t=ke(r);if(t===null)return m(a);let o=v(t,a);return o.success===!1?f(o.issues):(u[e.data.key]={type:"string",value:o.output},m(a))}}),i(e.nextId)})}var ft=r=>{let e={};return{interpret:function(n){return p(this,arguments,function*({nodes:s,context:i}){let a={error:({message:d})=>({type:"error",message:N(d,{submissions:e,context:i})}),info:({message:d})=>({type:"info",message:N(d,{submissions:e,context:i})}),success:({message:d})=>({type:"success",message:N(d,{submissions:e,context:i})}),text:({message:d,author:c})=>({type:"text",author:c,message:N(d,{submissions:e,context:i})}),image:({url:d,height:c,width:y})=>({type:"image",url:N(d,{submissions:e,context:i}),height:c,width:y}),state:d=>({type:"state",state:d}),link:({href:d,message:c})=>({type:"link",href:N(d,{submissions:e,context:i}),message:N(c,{submissions:e,context:i})}),submissions:d=>({type:"submissions",submissions:d}),input:(d,c)=>({type:"input",input:{type:d,config:c.config,validate:c.validate}})};if(!s.headId)return{type:"error",message:"No head node found"};let t=s.items[s.headId],o=d=>{if(!d)return t=void 0,{type:"next",nodeId:void 0};let c=s.items[d];if(!c)throw new Error(`Next node with id ${d} not found`);return t=c,{type:"next",nodeId:d}},l=q(L({},r),{context:i,submissions:e,next:o,actions:a});for(;t;){switch(t.type){case"text":yield a.text({author:"bot",message:t.data.text}),o(t.nextId);break;case"image":yield a.image(t.data),o(t.nextId);break;case"link":yield a.link({href:t.data.href,message:t.data.cta}),o(t.nextId);break;case"add-submission":e[t.data.key]={type:"string",value:t.data.value},o(t.nextId);break;case"jump":o(t.data.targetId);break;case"question-text":yield*h(ce({config:l,node:t}));break;case"question-phone":yield*h(me({config:l,node:t}));break;case"question-boolean":yield*h(ie({config:l,node:t}));break;case"question-number":yield*h(de({config:l,node:t}));break;case"question-address":yield*h(se({config:l,node:t}));break;case"question-enum":yield*h(ue({config:l,node:t}));break;case"question-file":yield*h(le({config:l,node:t}));break;case"identify":{yield*h(ne({config:l,node:t}));break}case"if-block":{let d=C(t,{context:l.context,submissions:e})?t.branchId:t.nextId;o(d);break}case"integration-application-submit":yield*h(oe({config:l,node:t}));break;case"feedback":yield a.error({message:"Not implemented"});break;case"integration-workflow-get":yield a.error({message:"This message should never be reached"});break;case"end-flow":t=void 0;break}yield a.submissions(e)}yield{type:"end"}})}}};export{ft as createFlowInterpreter};
1
+ import{A as v,B as m,C as f,D as Z,F as ee,G as P,H as M,I as te,J as Q,K as re,a as q,b as L,c as B,d as G,e as c,f as I,g as D,h as R,i as U,j as w,k as W,l as x,m as X,n as z,o as T,p as H,q as V,r as J,s as A,t as F,u as k,v as j,w as O,x as g,y as K,z as b}from"./chunk-VKMPK5WA.mjs";var $=B(D());var ne=({condition:n,context:e,submissions:u,ifBlock:s})=>{let[i,...a]=n.compareKey.split(".");if(!i)return!1;let r=M({context:e,key:i,path:a,submissions:u});if(!r)return!1;switch(r.type){case"address":{let t=(0,$.default)(r.value,a.join("."));switch(n.compare){case"equals":return t===n.compareValue;case"contains":return t?t.includes(n.compareValue):!1;case"notEquals":return t!==n.compareValue;case"notContains":return t?!t.includes(n.compareValue):!0}break}case"integration":{if(typeof r.value!="object"||Array.isArray(r.value))return!1;let t=(0,$.default)(r.value,a.join(".")),o=L(q({},s),{data:L(q({},s.data),{compareKey:"_temp"})});switch(typeof t){case"boolean":return C(o,{submissions:{_temp:{value:t,type:"boolean"}},context:e});case"string":return C(o,{submissions:{_temp:{value:t,type:"string"}},context:e});case"number":return C(o,{submissions:{_temp:{value:t,type:"number"}},context:e});case"object":return Array.isArray(t)&&t.every(l=>typeof l=="string")?C(o,{submissions:{_temp:{value:t,type:"enum"}},context:e}):!1}break}case"boolean":{let t=n.compareValue==="true";switch(n.compare){case"equals":return r.value===t;case"notEquals":return r.value!==t}break}case"phone":case"string":{let t=r.type==="phone"?r.value.countryCode+r.value.phoneNumber:r.value;switch(n.compare){case"equals":return t===n.compareValue;case"contains":return t?t.includes(n.compareValue):!1;case"notEquals":return t!==n.compareValue;case"notContains":return t?!t.includes(n.compareValue):!0}break}case"number":{try{let t=Number(n.compareValue);switch(n.compare){case"equals":return r.value===t;case"notEquals":return r.value!==t;case"greaterThan":return r.value>t;case"greaterThanOrEqualTo":return r.value>=t;case"lessThan":return r.value<t;case"lessThanOrEqualTo":return r.value<=t}}catch(t){return console.error(`Failed to parse number in if-block ${s.id}`,r.value),!1}break}case"enum":switch(n.compare){case"equals":return r.value.length===1&&r.value[0]===n.compareValue;case"notEquals":return r.value.length===1&&r.value[0]!==n.compareValue;case"contains":return r.value.includes(n.compareValue);case"notContains":return!r.value.includes(n.compareValue)}break;case"file":break;default:break}},C=(n,{context:e,submissions:u})=>{let s="combinator"in n.data?n.data.conditions:[n.data];if(("combinator"in n.data?n.data.combinator:"and")==="or"){for(let a of s)if(ne({condition:a,context:e,submissions:u,ifBlock:n}))return!0;return!1}else{for(let a of s)if(!ne({condition:a,context:e,submissions:u,ifBlock:n}))return!1;return!0}};var ae=B(D());var ve=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,N=(n,{context:e,submissions:u})=>n.replace(ve,(s,i,a="")=>{let[r,...t]=i.trim().split("."),o=M({key:r,path:t,submissions:u,context:e});if(!o)return a;switch(o.type){case"boolean":return o.value===!0?"true":"false";case"file":return o.value.map(l=>`${l.name} (${Q(l.sizeKb)})`).join(", ");case"enum":return o.value.join(", ");case"address":return Object.values(o.value).filter(l=>l&&l.trim().length>0).join(", ");case"number":case"string":return o.value?o.value.toString():a;case"phone":return re(o.value);case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))break;let l=(0,ae.default)(o.value,t.join("."));switch(typeof l){case"boolean":return l===!0?"true":"false";case"string":return l;case"number":return l.toString();case"object":if(Array.isArray(l)&&l.every(d=>typeof d=="string"))return l.join(", ")}break}default:}return a});function oe(n){return c(this,null,function*(){let{node:e,config:{logger:u,analytics:s,submissions:i,next:a}}=n;return s.service.log({event:"IDENTIFY",properties:{identifier:P({key:e.data.key,submissions:i}).toString(),first_name:e.data.firstName?P({key:e.data.firstName,submissions:i}).toString():void 0,last_name:e.data.lastName?P({key:e.data.lastName,submissions:i}).toString():void 0,email:e.data.email?P({key:e.data.email,submissions:i}).toString():void 0,phone_number:e.data.phoneNumber?P({key:e.data.phoneNumber,submissions:i}).toString():void 0,custom_traits:e.data.customTraits?Object.fromEntries(e.data.customTraits.map(({key:r,value:t})=>{var o;return[r,(o=i[t])==null?void 0:o.value]})):void 0}}).catch(u.error),a(e.nextId)})}import{endpoint as be,typed as he}from"@inploi/sdk";var se=k({success:J(),integration_response:k({service:j(g()),status:F(),data:K(),error:A(k({message:g(),data:K()}))})}),Ie=be({pathname:"/flow/submit",method:"POST",schema:{response:se,body:he()}});function ie(n){return c(this,null,function*(){var l;let{node:e,config:{rpcClient:u,submissions:s,actions:i,next:a,analytics:r,logger:t,context:o}}=n;return e.data.skipConfirmation!==!0&&(yield i.input("submit",{config:{key:(l=e.data.key)!=null?l:"_SUBMIT",label:e.data.submitLabel},validate:()=>G(this,null,function*(){let p=Z(r.service.getSessionInfo)();p.err&&t.error(p.val.originalError);try{let y=yield u.request(Ie,{body:{log_submit:!1,integration_id:e.data.integrationId,anonymous_id:p.ok?p.val.anonymous_id:void 0,session_id:p.ok?p.val.session_id:void 0,job:o.job,submissions:ee(s)}}),h=v(se,y);return h.success===!1?f(h.issues):m(h.output)}catch(y){let h=[{input:y,origin:"value",reason:"unknown",validation:"API error",message:y instanceof Error?y.message:"toString"in y?y.toString():"Unknown error"}];return f(h)}})})),a(e.nextId)})}var S=b(A(j(g())),T(n=>n===null?void 0:n)),ke=({node:n})=>{var u,s,i,a,r,t,o;let e=n.data.keys;return k({[(u=e.line1)!=null?u:"line1"]:S,[(s=e.line2)!=null?s:"line2"]:S,[(i=e.line3)!=null?i:"line3"]:S,[(a=e.city)!=null?a:"city"]:S,[(r=e.country)!=null?r:"country"]:S,[(t=e.postcode)!=null?t:"postcode"]:S,[(o=e.state)!=null?o:"state"]:S})};function ue(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=n;return yield s.text({author:"bot",message:e.data.question}),yield s.input("address",{config:{key:e.data.key,keys:e.data.keys,placeholder:e.data.placeholder,optional:e.data.optional},validate:a=>{if(e.data.optional&&a===null)return m(a);let r=ke(n),t=v(r,a);return t.success===!1?f(t.issues):(u[e.data.key]={type:"address",value:t.output},m(a))}}),i(e.nextId)})}var xe=["true","false"],Ne=O(xe);function le(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=n;return yield s.text({author:"bot",message:e.data.question}),yield s.input("boolean",{config:{key:e.data.key,labels:{false:e.data.falseLabel,true:e.data.trueLabel},optional:e.data.optional},validate:a=>{if(e.data.optional&&a===null)return m(a);let r=v(Ne,a);return r.success===!1?f(r.issues):(u[e.data.key]={type:"boolean",value:r.output==="true"},m(a))}}),i(e.nextId)})}function de(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=n;yield s.text({author:"bot",message:e.data.question});let a=V(O(e.data.options.map(r=>r.value)));return yield s.input("multiple-choice",{config:{key:e.data.key,options:e.data.options,maxSelected:e.data.maxSelected,minSelected:e.data.minSelected},validate:r=>{if(e.data.minSelected===0&&r===null)return m(r);let t=v(a,r);return t.success===!1?f(t.issues):(u[e.data.key]={type:"enum",value:t.output},m(r))}}),i(e.nextId)})}function me(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i,t:a}}=n;return yield s.text({author:"bot",message:e.data.question}),yield s.input("file",{config:{key:e.data.key,allowMultiple:e.data.multiple===!0,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb,optional:e.data.optional},validate:r=>{var h;if(e.data.optional&&r===null)return m(r);let t=e.data.optional?0:1,o=e.data.multiple?Number.POSITIVE_INFINITY:1,l=(h=e.data.maxSizeKb)!=null?h:0,d=e.data.extensions.map(E=>E.toLowerCase()),p=b(V(k({name:b(g(a("validation_empty")),R(E=>{let Y=te(E);return Y.ok===!1?!1:d.includes(Y.val.toLowerCase())},a("validation_file_ext",{ext:d.join(", ")}))),data:g(),sizeKb:F()})),x(t,a("validation_file_min",{count:t})),w(o,a("validation_file_max",{count:o})),R(E=>E.reduce((ye,ge)=>ye+ge.sizeKb,0)<=l,a("validation_file_size",{size:Q(l)}))),y=v(p,r);return y.success===!1?f(y.issues):(u[e.data.key]={type:"file",value:y.output},m(r))}}),i(e.nextId)})}var we=({node:n,config:{t:e}})=>{var a,r,t;let u=(a=n.data.min)!=null?a:Number.MIN_SAFE_INTEGER,s=(r=n.data.max)!=null?r:Number.MAX_SAFE_INTEGER,i=(t=n.data.decimalCases)!=null?t:0;return b(F(e("validation_number")),X(u,e("validation_number_min",{min:u})),W(s,e("validation_number_max",{max:s})),R(o=>o===Number(o.toFixed(i)),e("validation_number_decimal_cases",{count:i})))};function pe(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=n;yield s.text({author:"bot",message:e.data.question});let a=u[e.data.key];return yield s.input("number",{config:{key:e.data.key,placeholder:e.data.placeholder,optional:e.data.optional,decimalCases:e.data.decimalCases,max:e.data.max,min:e.data.min,defaultValue:(a==null?void 0:a.type)==="number"?a.value.toString():void 0},validate:r=>{if(e.data.optional&&r===null)return m(r);let t=we(n),o=v(t,r);return o.success===!1?f(o.issues):(u[e.data.key]={type:"number",value:o.output},m(r))}}),i(e.nextId)})}var _e=({node:n,config:{t:e}})=>k({countryCode:b(g(e("validation_country_code")),z(/^\+?[0-9 -]+$/,e("validation_country_code"))),phoneNumber:b(g(e("validation_phone")),z(/^\+?[0-9 -]+$/,e("validation_phone")),x(n.data.minChars,e("validation_min_chars",{count:n.data.minChars})),T(u=>u.replace(/[^0-9]/g,"")))});function ce(n){return c(this,null,function*(){let{node:e,config:{actions:u,next:s,submissions:i}}=n;yield u.text({author:"bot",message:e.data.question});let a=i[e.data.key];return yield u.input("phone",{config:{key:e.data.key,minChars:e.data.minChars,defaultValue:(a==null?void 0:a.type)==="phone"?a.value:{countryCode:e.data.defaultCountryCode},placeholder:e.data.placeholder,submissionFormat:"phone",optional:e.data.optional},validate:r=>{if(e.data.optional&&r===null)return m(r);let t=_e(n),o=v(t,r);return o.success===!1?f(o.issues):(i[e.data.key]={type:"address",value:o.output},m(r))}}),s(e.nextId)})}var Se=({node:n,config:{t:e,logger:u}})=>{var i,a,r,t,o,l,d,p,y,h;let s={email:e("validation_email"),url:e("validation_url"),maxLength:e("validation_max_chars",{count:(i=n.data.maxChars)!=null?i:999}),minLength:e("validation_min_chars",{count:(a=n.data.minChars)!=null?a:1})};switch(n.data.format){case"email":return b(g(s.email),U(s.email),x((r=n.data.minChars)!=null?r:1,s.minLength),w((t=n.data.maxChars)!=null?t:1/0,s.maxLength));case"text":return b(g(),x((o=n.data.minChars)!=null?o:1,s.minLength),w((l=n.data.maxChars)!=null?l:1/0,s.maxLength));case"url":return b(g(),H(s.url),x((d=n.data.minChars)!=null?d:1,s.minLength),w((p=n.data.maxChars)!=null?p:1/0,s.maxLength));case"phone":return b(g(),x((y=n.data.minChars)!=null?y:1,s.minLength),w((h=n.data.maxChars)!=null?h:1/0,s.maxLength));default:return n.data.format,u.error(`Unsupported question-text format: ${n.data.format}`),null}};function fe(n){return c(this,null,function*(){let{node:e,config:{submissions:u,actions:s,next:i}}=n;yield s.text({author:"bot",message:e.data.question});let a=u[e.data.key];return yield s.input("text",{config:{key:e.data.key,maxChars:e.data.maxChars,minChars:e.data.minChars,placeholder:e.data.placeholder,format:e.data.format,optional:e.data.optional,defaultValue:(a==null?void 0:a.type)==="string"?a.value:void 0},validate:r=>{if(e.data.optional&&r===null)return m(r);let t=Se(n);if(t===null)return m(r);let o=v(t,r);return o.success===!1?f(o.issues):(u[e.data.key]={type:"string",value:o.output},m(r))}}),i(e.nextId)})}var ht=n=>{let e={};return{interpret:function(a){return c(this,arguments,function*({nodes:s,context:i}){let r={error:({message:d})=>({type:"error",message:N(d,{submissions:e,context:i})}),info:({message:d})=>({type:"info",message:N(d,{submissions:e,context:i})}),success:({message:d})=>({type:"success",message:N(d,{submissions:e,context:i})}),text:({message:d,author:p})=>({type:"text",author:p,message:N(d,{submissions:e,context:i})}),image:({url:d,height:p,width:y})=>({type:"image",url:N(d,{submissions:e,context:i}),height:p,width:y}),state:d=>({type:"state",state:d}),link:({href:d,message:p})=>({type:"link",href:N(d,{submissions:e,context:i}),message:N(p,{submissions:e,context:i})}),submissions:d=>({type:"submissions",submissions:d}),input:(d,p)=>({type:"input",input:{type:d,config:p.config,validate:p.validate}})};if(!s.headId)return{type:"error",message:"No head node found"};let t=s.items[s.headId],o=d=>{if(!d)return t=void 0,{type:"next",nodeId:void 0};let p=s.items[d];if(!p)throw new Error(`Next node with id ${d} not found`);return t=p,{type:"next",nodeId:d}},l=L(q({},n),{context:i,submissions:e,next:o,actions:r});for(;t;){switch(t.type){case"text":yield r.text({author:"bot",message:t.data.text}),o(t.nextId);break;case"image":yield r.image(t.data),o(t.nextId);break;case"link":yield r.link({href:t.data.href,message:t.data.cta}),o(t.nextId);break;case"add-submission":e[t.data.key]={type:"string",value:t.data.value},o(t.nextId);break;case"jump":o(t.data.targetId);break;case"question-text":yield*I(fe({config:l,node:t}));break;case"question-phone":yield*I(ce({config:l,node:t}));break;case"question-boolean":yield*I(le({config:l,node:t}));break;case"question-number":yield*I(pe({config:l,node:t}));break;case"question-address":yield*I(ue({config:l,node:t}));break;case"question-enum":yield*I(de({config:l,node:t}));break;case"question-file":yield*I(me({config:l,node:t}));break;case"identify":{yield*I(oe({config:l,node:t}));break}case"if-block":{let d=C(t,{context:l.context,submissions:e})?t.branchId:t.nextId;o(d);break}case"integration-application-submit":yield*I(ie({config:l,node:t}));break;case"feedback":yield r.error({message:"Not implemented"});break;case"integration-workflow-get":yield r.error({message:"This message should never be reached"});break;case"end-flow":t=void 0;break}yield r.submissions(e)}yield{type:"end"}})}}};export{ht as createFlowInterpreter};
2
2
  //# sourceMappingURL=interpreter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/conditions.ts","../src/interpolation.ts","../src/interpreter.identify.ts","../src/interpreter.integration-application-submit.ts","../src/interpreter.question-address.ts","../src/interpreter.question-boolean.ts","../src/interpreter.question-enum.ts","../src/interpreter.question-file.ts","../src/interpreter.question-number.ts","../src/interpreter.question-phone.ts","../src/interpreter.question-text.ts","../src/interpreter.ts"],"sourcesContent":["import { IfBlockNode, IfBlockNodeCondition } from '@inploi/core/flows';\nimport get from 'lodash/get';\n\nimport { FlowSubmissions } from './flow.types';\nimport { getSubmissionValueToCheck } from './utils';\n\nconst isConditionMet = ({\n\tcondition,\n\tcontext,\n\tsubmissions,\n\tifBlock,\n}: {\n\tcontext: Record<string, unknown>;\n\tcondition: IfBlockNodeCondition;\n\tsubmissions: FlowSubmissions;\n\tifBlock: IfBlockNode;\n}) => {\n\tconst [firstSegment, ...path] = condition.compareKey.split('.');\n\tif (!firstSegment) return false;\n\n\tconst answer = getSubmissionValueToCheck({ context, key: firstSegment, path, submissions });\n\tif (!answer) return false;\n\n\tswitch (answer.type) {\n\t\tcase 'address': {\n\t\t\tconst value = get(answer.value, path.join('.'));\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn value === condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\tif (!value) return false;\n\t\t\t\t\treturn value.includes(condition.compareValue);\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn value !== condition.compareValue;\n\t\t\t\tcase 'notContains':\n\t\t\t\t\tif (!value) return true;\n\t\t\t\t\treturn !value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'integration': {\n\t\t\t/** We only handle objects as integration submissions for now. */\n\t\t\tif (typeof answer.value !== 'object') return false;\n\t\t\tif (Array.isArray(answer.value)) return false;\n\n\t\t\tconst value = get(answer.value, path.join('.'));\n\t\t\tconst newIfBlock = { ...ifBlock, data: { ...ifBlock.data, compareKey: '_temp' } };\n\t\t\tswitch (typeof value) {\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'boolean' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'string' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'number' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'object':\n\t\t\t\t\t/** We only handle enums if the result is an array of strings */\n\t\t\t\t\tif (Array.isArray(value) && value.every((value): value is string => typeof value === 'string')) {\n\t\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'enum' } },\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'boolean': {\n\t\t\tconst compareBoolean = condition.compareValue === 'true';\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn answer.value === compareBoolean;\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn answer.value !== compareBoolean;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'phone':\n\t\tcase 'string': {\n\t\t\tconst value = answer.type === 'phone' ? answer.value.countryCode + answer.value.phoneNumber : answer.value;\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn value === condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\tif (!value) return false;\n\t\t\t\t\treturn value.includes(condition.compareValue);\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn value !== condition.compareValue;\n\t\t\t\tcase 'notContains':\n\t\t\t\t\tif (!value) return true;\n\t\t\t\t\treturn !value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'number': {\n\t\t\ttry {\n\t\t\t\tconst compareNumber = Number(condition.compareValue);\n\t\t\t\tswitch (condition.compare) {\n\t\t\t\t\tcase 'equals':\n\t\t\t\t\t\treturn answer.value === compareNumber;\n\t\t\t\t\tcase 'notEquals':\n\t\t\t\t\t\treturn answer.value !== compareNumber;\n\t\t\t\t\tcase 'greaterThan':\n\t\t\t\t\t\treturn answer.value > compareNumber;\n\t\t\t\t\tcase 'greaterThanOrEqualTo':\n\t\t\t\t\t\treturn answer.value >= compareNumber;\n\t\t\t\t\tcase 'lessThan':\n\t\t\t\t\t\treturn answer.value < compareNumber;\n\t\t\t\t\tcase 'lessThanOrEqualTo':\n\t\t\t\t\t\treturn answer.value <= compareNumber;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tconsole.error(`Failed to parse number in if-block ${ifBlock.id}`, answer.value);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'enum':\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn answer.value.length === 1 && answer.value[0] === condition.compareValue;\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn answer.value.length === 1 && answer.value[0] !== condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\treturn answer.value.includes(condition.compareValue);\n\t\t\t\tcase 'notContains':\n\t\t\t\t\treturn !answer.value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'file':\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tanswer satisfies never;\n\t\t\tbreak;\n\t}\n};\n\nexport const isIfBlockConditionMet = (\n\tifBlock: IfBlockNode,\n\t{ context, submissions }: { submissions: FlowSubmissions; context: Record<string, unknown> },\n): boolean => {\n\tconst conditions = 'combinator' in ifBlock.data ? ifBlock.data.conditions : [ifBlock.data];\n\tconst combinator = 'combinator' in ifBlock.data ? ifBlock.data.combinator : 'and';\n\n\tif (combinator === 'or') {\n\t\tfor (const condition of conditions) {\n\t\t\tconst isMet = isConditionMet({ condition, context, submissions, ifBlock });\n\t\t\tif (isMet) return true;\n\t\t}\n\t\treturn false;\n\t} else {\n\t\tfor (const condition of conditions) {\n\t\t\tconst isMet = isConditionMet({ condition, context, submissions, ifBlock });\n\t\t\tif (!isMet) return false;\n\t\t}\n\t\treturn true;\n\t}\n};\n","import get from 'lodash/get';\n\nimport { FlowSubmissions } from './flow.types';\nimport { formatPhoneNumber, getSubmissionValueToCheck, kbToReadableSize } from './utils';\n\nconst HANDLEBARS_REGEXP = /{{\\s*([^}]+?)\\s*(?:\\|\\s*([^}]+?)\\s*)?}}/g;\n\nexport const interpolateWithData = (\n\tstr: string,\n\t{ context, submissions }: { submissions: FlowSubmissions; context: Record<string, unknown> },\n) => {\n\treturn str.replace(HANDLEBARS_REGEXP, (_, key, defaultValue = '') => {\n\t\tconst [firstSegment, ...path] = key.trim().split('.');\n\t\tconst entity = getSubmissionValueToCheck({ key: firstSegment, path, submissions, context });\n\t\tif (!entity) return defaultValue;\n\n\t\tswitch (entity.type) {\n\t\t\tcase 'boolean':\n\t\t\t\treturn entity.value === true ? 'true' : 'false';\n\t\t\tcase 'file':\n\t\t\t\treturn entity.value.map(file => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(', ');\n\t\t\tcase 'enum':\n\t\t\t\treturn entity.value.join(', ');\n\t\t\tcase 'address':\n\t\t\t\treturn Object.values(entity.value)\n\t\t\t\t\t.filter(line => line && line.trim().length > 0)\n\t\t\t\t\t.join(', ');\n\t\t\tcase 'number':\n\t\t\tcase 'string':\n\t\t\t\tif (!entity.value) return defaultValue;\n\t\t\t\treturn entity.value.toString();\n\t\t\tcase 'phone':\n\t\t\t\treturn formatPhoneNumber(entity.value);\n\t\t\tcase 'integration': {\n\t\t\t\t/** We only handle objects as integration submissions for now. */\n\t\t\t\tif (typeof entity.value !== 'object') break;\n\t\t\t\tif (Array.isArray(entity.value)) break;\n\n\t\t\t\tconst value = get(entity.value, path.join('.'));\n\t\t\t\tswitch (typeof value) {\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\treturn value === true ? 'true' : 'false';\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\treturn value;\n\t\t\t\t\tcase 'number':\n\t\t\t\t\t\treturn value.toString();\n\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t/** We only handle enums if the result is an array of strings */\n\t\t\t\t\t\tif (Array.isArray(value) && value.every((i): i is string => typeof i === 'string')) {\n\t\t\t\t\t\t\treturn value.join(', ');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tentity satisfies never;\n\t\t}\n\t\treturn defaultValue;\n\t});\n};\n","import { InterpretNodeParams } from './interpreter';\nimport { getSubmissionValue } from './utils';\n\nexport async function* interpretIdentifyNode(params: InterpretNodeParams<'identify'>) {\n\tconst {\n\t\tnode,\n\t\tconfig: { logger, analytics, submissions, next },\n\t} = params;\n\n\tanalytics.service\n\t\t.log({\n\t\t\tevent: 'IDENTIFY',\n\t\t\tproperties: {\n\t\t\t\tidentifier: getSubmissionValue({ key: node.data.key, submissions }).toString(),\n\t\t\t\tfirst_name:\n\t\t\t\t\tnode.data.firstName ? getSubmissionValue({ key: node.data.firstName, submissions }).toString() : undefined,\n\t\t\t\tlast_name:\n\t\t\t\t\tnode.data.lastName ? getSubmissionValue({ key: node.data.lastName, submissions }).toString() : undefined,\n\t\t\t\temail: node.data.email ? getSubmissionValue({ key: node.data.email, submissions }).toString() : undefined,\n\t\t\t\tphone_number:\n\t\t\t\t\tnode.data.phoneNumber ?\n\t\t\t\t\t\tgetSubmissionValue({ key: node.data.phoneNumber, submissions }).toString()\n\t\t\t\t\t:\tundefined,\n\t\t\t\tcustom_traits:\n\t\t\t\t\tnode.data.customTraits ?\n\t\t\t\t\t\tObject.fromEntries(node.data.customTraits.map(({ key, value }) => [key, submissions[value]?.value]))\n\t\t\t\t\t:\tundefined,\n\t\t\t},\n\t\t})\n\t\t.catch(logger.error);\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok, tryCatch } from './result';\nimport { getFlowSubmissionsPayload } from './utils';\n\nconst responseSchema = v.object({\n\t/** Not necessarily true when we receive a positive response because the API considers only 200 as success */\n\tsuccess: v.boolean(),\n\tintegration_response: v.object({\n\t\tservice: v.optional(v.string()),\n\t\tstatus: v.number(),\n\t\tdata: v.unknown(),\n\t\terror: v.nullable(v.object({ message: v.string(), data: v.unknown() })),\n\t}),\n});\nexport type IntegrationResponse = v.Output<typeof responseSchema>;\n\nexport async function* interpretIntegrationApplicationSubmitNode(\n\tparams: InterpretNodeParams<'integration-application-submit'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { apiClient, submissions, actions, next, analytics, logger, context },\n\t} = params;\n\n\tif (node.data.skipConfirmation !== true) {\n\t\tyield actions.input('submit', {\n\t\t\tconfig: {\n\t\t\t\tkey: node.data.key ?? '_SUBMIT',\n\t\t\t\tlabel: node.data.submitLabel,\n\t\t\t},\n\t\t\t/** move all submitting logic to the validate, makes much more sense */\n\t\t\tvalidate: async () => {\n\t\t\t\tconst getSessionInfoSafe = tryCatch(analytics.service.getSessionInfo);\n\t\t\t\tconst sessionInfo = getSessionInfoSafe();\n\t\t\t\tif (sessionInfo.err) logger.error(sessionInfo.val.originalError);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await apiClient.fetch(`/flow/submit`, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\t\tlog_submit: false,\n\t\t\t\t\t\t\tintegration_id: node.data.integrationId,\n\t\t\t\t\t\t\tanonymous_id: sessionInfo.ok ? sessionInfo.val.anonymous_id : undefined,\n\t\t\t\t\t\t\tsession_id: sessionInfo.ok ? sessionInfo.val.session_id : undefined,\n\t\t\t\t\t\t\tjob: context.job,\n\t\t\t\t\t\t\tsubmissions: getFlowSubmissionsPayload(submissions),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconst parsed = v.safeParse(responseSchema, response);\n\t\t\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\t\t\treturn Ok(parsed.output);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst issues: v.Issues = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tinput: e,\n\t\t\t\t\t\t\torigin: 'value',\n\t\t\t\t\t\t\treason: 'unknown',\n\t\t\t\t\t\t\tvalidation: 'API error',\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\te instanceof Error ? e.message\n\t\t\t\t\t\t\t\t: 'toString' in (e as any) ? (e as any).toString()\n\t\t\t\t\t\t\t\t: 'Unknown error',\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t\treturn Err(issues);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst fieldValueSchema = v.nullable(v.optional(v.string()));\nconst getValidationSchema = ({ node }: InterpretNodeParams<'question-address'>) => {\n\tconst keys = node.data.keys;\n\treturn v.object({\n\t\t[keys.line1 ?? 'line1']: fieldValueSchema,\n\t\t[keys.line2 ?? 'line2']: fieldValueSchema,\n\t\t[keys.line3 ?? 'line3']: fieldValueSchema,\n\t\t[keys.city ?? 'city']: fieldValueSchema,\n\t\t[keys.country ?? 'country']: fieldValueSchema,\n\t\t[keys.postcode ?? 'postcode']: fieldValueSchema,\n\t\t[keys.state ?? 'state']: fieldValueSchema,\n\t});\n};\n\nexport async function* interpretQuestionAddressNode(\n\tparams: InterpretNodeParams<'question-address'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('address', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tkeys: node.data.keys,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'address', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst options = ['true', 'false'] as const;\nconst schema = v.picklist(options);\n\nexport async function* interpretQuestionBooleanNode(\n\tparams: InterpretNodeParams<'question-boolean'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('boolean', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tlabels: {\n\t\t\t\tfalse: node.data.falseLabel,\n\t\t\t\ttrue: node.data.trueLabel,\n\t\t\t},\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'boolean', value: parsed.output === 'true' };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import { NonEmptyArray } from '@inploi/core/common';\nimport * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nexport async function* interpretQuestionEnumNode(params: InterpretNodeParams<'question-enum'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst schema = v.array(v.picklist(node.data.options.map(o => o.value) as NonEmptyArray<string>));\n\tyield actions.input('multiple-choice', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\toptions: node.data.options,\n\t\t\tmaxSelected: node.data.maxSelected,\n\t\t\tminSelected: node.data.minSelected,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.minSelected === 0 && submission === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'enum', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\nimport { getFileExtension, kbToReadableSize } from './utils';\n\nexport async function* interpretQuestionFileNode(params: InterpretNodeParams<'question-file'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next, t },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('file', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tallowMultiple: node.data.multiple === true,\n\t\t\textensions: node.data.extensions,\n\t\t\tfileSizeLimitKib: node.data.maxSizeKb,\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst minFiles = node.data.optional ? 0 : 1;\n\t\t\tconst maxFiles = node.data.multiple ? Number.POSITIVE_INFINITY : 1;\n\t\t\tconst maxSize = node.data.maxSizeKb ?? 0;\n\t\t\tconst allowedExtensions = node.data.extensions.map(ext => ext.toLowerCase());\n\t\t\tconst schema = v.array(\n\t\t\t\tv.object({\n\t\t\t\t\tname: v.string(t('validation_empty'), [\n\t\t\t\t\t\tv.custom(\n\t\t\t\t\t\t\tfilename => {\n\t\t\t\t\t\t\t\tconst extension = getFileExtension(filename);\n\t\t\t\t\t\t\t\tif (extension.ok === false) return false;\n\t\t\t\t\t\t\t\treturn allowedExtensions.includes(extension.val.toLowerCase());\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tt('validation_file_ext', { ext: allowedExtensions.join(', ') }),\n\t\t\t\t\t\t),\n\t\t\t\t\t]),\n\t\t\t\t\tdata: v.string(),\n\t\t\t\t\tsizeKb: v.number(),\n\t\t\t\t}),\n\t\t\t\t[\n\t\t\t\t\tv.minLength(minFiles, t('validation_file_min', { count: minFiles })),\n\t\t\t\t\tv.maxLength(maxFiles, t('validation_file_max', { count: maxFiles })),\n\t\t\t\t\tv.custom(\n\t\t\t\t\t\tfiles => {\n\t\t\t\t\t\t\tconst totalSize = files.reduce((acc, cur) => acc + cur.sizeKb, 0);\n\t\t\t\t\t\t\treturn totalSize <= maxSize;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tt('validation_file_size', { size: kbToReadableSize(maxSize) }),\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t);\n\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'file', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t } }: InterpretNodeParams<'question-number'>) => {\n\tconst min = node.data.min ?? Number.MIN_SAFE_INTEGER;\n\tconst max = node.data.max ?? Number.MAX_SAFE_INTEGER;\n\tconst decimalCases = node.data.decimalCases ?? 0;\n\n\treturn v.number(t('validation_number'), [\n\t\tv.minValue(min, t('validation_number_min', { min })),\n\t\tv.maxValue(max, t('validation_number_max', { max })),\n\t\tv.custom(\n\t\t\tvalue => {\n\t\t\t\treturn value === Number(value.toFixed(decimalCases));\n\t\t\t},\n\t\t\tt('validation_number_decimal_cases', { count: decimalCases }),\n\t\t),\n\t]);\n};\n\nexport async function* interpretQuestionNumberNode(\n\tparams: InterpretNodeParams<'question-number'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('number', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\toptional: node.data.optional,\n\t\t\tdecimalCases: node.data.decimalCases,\n\t\t\tmax: node.data.max,\n\t\t\tmin: node.data.min,\n\t\t\tdefaultValue: thisSubmission?.type === 'number' ? thisSubmission.value.toString() : undefined,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'number', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t } }: InterpretNodeParams<'question-phone'>) => {\n\treturn v.object({\n\t\tcountryCode: v.string(t('validation_country_code'), [v.regex(/^\\+?[0-9 -]+$/, t('validation_country_code'))]),\n\t\tphoneNumber: v.transform(\n\t\t\tv.string(t('validation_phone'), [\n\t\t\t\tv.regex(/^\\+?[0-9 -]+$/, t('validation_phone')),\n\t\t\t\tv.minLength(node.data.minChars, t('validation_min_chars', { count: node.data.minChars })),\n\t\t\t\tv.maxLength(node.data.maxChars, t('validation_max_chars', { count: node.data.maxChars })),\n\t\t\t]),\n\t\t\tvalue => value.replace(/[^0-9]/g, ''),\n\t\t\t[],\n\t\t),\n\t});\n};\n\nexport async function* interpretQuestionPhoneNode(params: InterpretNodeParams<'question-phone'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { actions, next, submissions },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('phone', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tminChars: node.data.minChars,\n\t\t\tmaxChars: node.data.maxChars,\n\t\t\tdefaultValue:\n\t\t\t\tthisSubmission?.type === 'phone' ?\n\t\t\t\t\tthisSubmission.value\n\t\t\t\t:\t{\n\t\t\t\t\t\tcountryCode: node.data.defaultCountryCode,\n\t\t\t\t\t},\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\tsubmissionFormat: 'phone',\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'address', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t, logger } }: InterpretNodeParams<'question-text'>) => {\n\tconst errors = {\n\t\temail: t('validation_email'),\n\t\turl: t('validation_url'),\n\t\tmaxLength: t('validation_max_chars', { count: node.data.maxChars ?? 999 }),\n\t\tminLength: t('validation_min_chars', { count: node.data.minChars ?? 1 }),\n\t};\n\n\tswitch (node.data.format) {\n\t\tcase 'email':\n\t\t\treturn v.string(errors.email, [\n\t\t\t\tv.email(errors.email),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t]);\n\t\tcase 'text':\n\t\t\treturn v.string([\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t]);\n\t\tcase 'url':\n\t\t\treturn v.string([\n\t\t\t\tv.url(errors.url),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t]);\n\t\tcase 'phone':\n\t\t\treturn v.string([\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t]);\n\t\tdefault:\n\t\t\tnode.data.format satisfies never;\n\t\t\tlogger.error(`Unsupported question-text format: ${node.data.format}`);\n\t\t\treturn null;\n\t}\n};\n\nexport async function* interpretQuestionTextNode(params: InterpretNodeParams<'question-text'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('text', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tmaxChars: node.data.maxChars,\n\t\t\tminChars: node.data.minChars,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\tformat: node.data.format,\n\t\t\toptional: node.data.optional,\n\t\t\tdefaultValue: thisSubmission?.type === 'string' ? thisSubmission.value : undefined,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tif (schema === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'string', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import { FlowNode } from '@inploi/core/flows';\nimport { AnalyticsService, ApiClient, Logger } from '@inploi/sdk';\nimport { Issues } from 'valibot';\n\nimport { isIfBlockConditionMet } from './conditions';\nimport { FlowSubmissions } from './flow.types';\nimport { TFunction } from './i18n';\nimport { FlowInput } from './inputs';\nimport { interpolateWithData } from './interpolation';\nimport { interpretIdentifyNode } from './interpreter.identify';\nimport { interpretIntegrationApplicationSubmitNode } from './interpreter.integration-application-submit';\nimport { interpretQuestionAddressNode } from './interpreter.question-address';\nimport { interpretQuestionBooleanNode } from './interpreter.question-boolean';\nimport { interpretQuestionEnumNode } from './interpreter.question-enum';\nimport { interpretQuestionFileNode } from './interpreter.question-file';\nimport { interpretQuestionNumberNode } from './interpreter.question-number';\nimport { interpretQuestionPhoneNode } from './interpreter.question-phone';\nimport { interpretQuestionTextNode } from './interpreter.question-text';\nimport { LinkedList, LinkedListItem } from './linked-list';\nimport { Result } from './result';\n\ntype MaybePromise<T> = T | Promise<T>;\ntype FlowInterpreterYield =\n\t| { type: 'submissions'; submissions: FlowSubmissions }\n\t| { type: 'state'; state: 'loading' | 'idle' }\n\t| { type: 'error'; message: string }\n\t| { type: 'info'; message: string }\n\t| { type: 'success'; message: string }\n\t| { type: 'text'; author: 'user' | 'bot'; message: string }\n\t| { type: 'image'; url: string; height: number; width: number }\n\t| { type: 'link'; href: string; message: string }\n\t| { type: 'end' }\n\t| {\n\t\t\ttype: 'input';\n\t\t\tinput: {\n\t\t\t\t[I in FlowInput['type']]: {\n\t\t\t\t\ttype: I;\n\t\t\t\t\tconfig: (FlowInput & { type: I })['config'];\n\t\t\t\t\tvalidate: (\n\t\t\t\t\t\tinput: NonNullable<(FlowInput & { type: I })['submission']>['value'] | null,\n\t\t\t\t\t) => MaybePromise<Result<NonNullable<(FlowInput & { type: I })['submission']>['value'] | null, Issues>>;\n\t\t\t\t};\n\t\t\t}[FlowInput['type']];\n\t };\n\nexport type FlowInterpreterParams = {\n\tapiClient: ApiClient;\n\tanalytics: {\n\t\tservice: AnalyticsService;\n\t\tcustomProperties?: Record<string, unknown>;\n\t};\n\tlogger: Logger;\n\tt: TFunction;\n};\n\nexport type FlowActions = {\n\terror: ({ message }: { message: string }) => FlowInterpreterYield;\n\tinfo: ({ message }: { message: string }) => FlowInterpreterYield;\n\tsuccess: ({ message }: { message: string }) => FlowInterpreterYield;\n\ttext: ({ message, author }: { message: string; author: 'bot' | 'user' }) => FlowInterpreterYield;\n\timage: ({ url, height, width }: { url: string; height: number; width: number }) => FlowInterpreterYield;\n\tlink: ({ href, message }: { href: string; message: string }) => FlowInterpreterYield;\n\tsubmissions: (submissions: FlowSubmissions) => FlowInterpreterYield;\n\tstate: (state: 'loading' | 'idle') => FlowInterpreterYield;\n\tinput: <T extends FlowInput['type'], Input extends FlowInput & { type: T }>(\n\t\ttype: T,\n\t\tparams: {\n\t\t\tconfig: Input['config'];\n\t\t\tvalidate: (\n\t\t\t\tinput: NonNullable<Input['submission']>['value'] | null,\n\t\t\t) => MaybePromise<Result<NonNullable<Input['submission']>['value'] | null, Issues>>;\n\t\t},\n\t) => FlowInterpreterYield;\n};\n\nexport const createFlowInterpreter = (params: FlowInterpreterParams) => {\n\tconst submissions: FlowSubmissions = {};\n\n\treturn {\n\t\tinterpret: async function* interpret({\n\t\t\tnodes,\n\t\t\tcontext,\n\t\t}: {\n\t\t\tnodes: LinkedList<FlowNode>;\n\t\t\tcontext: Record<string, unknown>;\n\t\t}): AsyncGenerator<FlowInterpreterYield> {\n\t\t\tconst actions: FlowActions = {\n\t\t\t\terror: ({ message }) => ({ type: 'error', message: interpolateWithData(message, { submissions, context }) }),\n\t\t\t\tinfo: ({ message }) => ({ type: 'info', message: interpolateWithData(message, { submissions, context }) }),\n\t\t\t\tsuccess: ({ message }) => ({\n\t\t\t\t\ttype: 'success',\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\ttext: ({ message, author }) => ({\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tauthor,\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\timage: ({ url, height, width }) => ({\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\turl: interpolateWithData(url, { submissions, context }),\n\t\t\t\t\theight,\n\t\t\t\t\twidth,\n\t\t\t\t}),\n\t\t\t\tstate: state => ({ type: 'state', state }),\n\t\t\t\tlink: ({ href, message }) => ({\n\t\t\t\t\ttype: 'link',\n\t\t\t\t\thref: interpolateWithData(href, { submissions, context }),\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\tsubmissions: submissions => ({ type: 'submissions', submissions }),\n\t\t\t\tinput: (type, params) => {\n\t\t\t\t\treturn { type: 'input', input: { type, config: params.config, validate: params.validate } as any };\n\t\t\t\t},\n\t\t\t};\n\t\t\tif (!nodes.headId) return { type: 'error', message: 'No head node found' };\n\t\t\tlet node: LinkedListItem<FlowNode> | undefined = nodes.items[nodes.headId];\n\t\t\tconst next = (nextId: string | undefined): { type: 'next'; nodeId: string | undefined } => {\n\t\t\t\tif (!nextId) {\n\t\t\t\t\tnode = undefined;\n\t\t\t\t\treturn { type: 'next', nodeId: undefined };\n\t\t\t\t}\n\t\t\t\tconst nextNode = nodes.items[nextId];\n\t\t\t\tif (!nextNode) throw new Error(`Next node with id ${nextId} not found`);\n\t\t\t\tnode = nextNode;\n\t\t\t\treturn { type: 'next', nodeId: nextId };\n\t\t\t};\n\t\t\tconst config = { ...params, context, submissions, next, actions };\n\n\t\t\twhile (node) {\n\t\t\t\tswitch (node.type) {\n\t\t\t\t\tcase 'text':\n\t\t\t\t\t\tyield actions.text({ author: 'bot', message: node.data.text });\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'image':\n\t\t\t\t\t\tyield actions.image(node.data);\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'link':\n\t\t\t\t\t\tyield actions.link({ href: node.data.href, message: node.data.cta });\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'add-submission':\n\t\t\t\t\t\tsubmissions[node.data.key] = { type: 'string', value: node.data.value };\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'jump':\n\t\t\t\t\t\tnext(node.data.targetId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-text':\n\t\t\t\t\t\tyield* interpretQuestionTextNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-phone':\n\t\t\t\t\t\tyield* interpretQuestionPhoneNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-boolean':\n\t\t\t\t\t\tyield* interpretQuestionBooleanNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-number':\n\t\t\t\t\t\tyield* interpretQuestionNumberNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-address':\n\t\t\t\t\t\tyield* interpretQuestionAddressNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-enum':\n\t\t\t\t\t\tyield* interpretQuestionEnumNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-file':\n\t\t\t\t\t\tyield* interpretQuestionFileNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'identify': {\n\t\t\t\t\t\tyield* interpretIdentifyNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'if-block': {\n\t\t\t\t\t\tconst nextNodeId =\n\t\t\t\t\t\t\tisIfBlockConditionMet(node, { context: config.context, submissions }) ? node.branchId : node.nextId;\n\t\t\t\t\t\tnext(nextNodeId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'integration-application-submit':\n\t\t\t\t\t\tyield* interpretIntegrationApplicationSubmitNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'feedback':\n\t\t\t\t\t\tyield actions.error({ message: 'Not implemented' });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'integration-workflow-get':\n\t\t\t\t\t\tyield actions.error({ message: 'This message should never be reached' });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'end-flow':\n\t\t\t\t\t\tnode = undefined;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield actions.submissions(submissions);\n\t\t\t}\n\t\t\tyield { type: 'end' };\n\t\t},\n\t};\n};\n\nexport type InterpretNodeParams<TNodeType extends FlowNode['type']> = {\n\tnode: FlowNode & { type: TNodeType };\n\tconfig: FlowInterpreterParams & {\n\t\tsubmissions: FlowSubmissions;\n\t\tcontext: Record<string, unknown>;\n\t\tnext: (nextId: string | undefined) => { type: 'next'; nodeId: string | undefined };\n\t\tactions: FlowActions;\n\t};\n};\n\nexport type InterpretNodeReturn = AsyncGenerator<FlowInterpreterYield, { type: 'next'; nodeId: string | undefined }>;\n"],"mappings":"yRACA,IAAAA,EAAgB,OAKhB,IAAMC,GAAiB,CAAC,CACvB,UAAAC,EACA,QAAAC,EACA,YAAAC,EACA,QAAAC,CACD,IAKM,CACL,GAAM,CAACC,EAAc,GAAGC,CAAI,EAAIL,EAAU,WAAW,MAAM,GAAG,EAC9D,GAAI,CAACI,EAAc,MAAO,GAE1B,IAAME,EAASC,EAA0B,CAAE,QAAAN,EAAS,IAAKG,EAAc,KAAAC,EAAM,YAAAH,CAAY,CAAC,EAC1F,GAAI,CAACI,EAAQ,MAAO,GAEpB,OAAQA,EAAO,KAAM,CACpB,IAAK,UAAW,CACf,IAAME,KAAQ,EAAAC,SAAIH,EAAO,MAAOD,EAAK,KAAK,GAAG,CAAC,EAC9C,OAAQL,EA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WAAY,CAChB,IAAMgB,EACLC,EAAsBjB,EAAM,CAAE,QAASI,EAAO,QAAS,YAAAnB,CAAY,CAAC,EAAIe,EAAK,SAAWA,EAAK,OAC9FC,EAAKe,CAAU,EACf,KACD,CACA,IAAK,iCACJ,MAAAT,EAAOW,GAA0C,CAAE,OAAAd,EAAQ,KAAAJ,CAAK,CAAC,GACjE,MACD,IAAK,WACJ,MAAMV,EAAQ,MAAM,CAAE,QAAS,iBAAkB,CAAC,EAClD,MACD,IAAK,2BACJ,MAAMA,EAAQ,MAAM,CAAE,QAAS,sCAAuC,CAAC,EACvE,MACD,IAAK,WACJU,EAAO,OACP,KACF,CACA,MAAMV,EAAQ,YAAYL,CAAW,CACtC,CACA,KAAM,CAAE,KAAM,KAAM,CACrB,GACD,CACD","names":["import_get","isConditionMet","condition","context","submissions","ifBlock","firstSegment","path","answer","getSubmissionValueToCheck","value","get","newIfBlock","__spreadProps","__spreadValues","isIfBlockConditionMet","compareBoolean","compareNumber","e","conditions","import_get","HANDLEBARS_REGEXP","interpolateWithData","str","context","submissions","_","key","defaultValue","firstSegment","path","entity","getSubmissionValueToCheck","file","kbToReadableSize","line","formatPhoneNumber","value","get","i","interpretIdentifyNode","params","__asyncGenerator","node","logger","analytics","submissions","next","getSubmissionValue","key","value","_a","responseSchema","object","boolean","optional","string","number","unknown","nullable","interpretIntegrationApplicationSubmitNode","params","__asyncGenerator","_a","node","apiClient","submissions","actions","next","analytics","logger","context","__async","sessionInfo","tryCatch","response","getFlowSubmissionsPayload","parsed","safeParse","Err","Ok","e","issues","fieldValueSchema","nullable","optional","string","getValidationSchema","node","_a","_b","_c","_d","_e","_f","_g","keys","object","interpretQuestionAddressNode","params","__asyncGenerator","submissions","actions","next","submission","Ok","schema","parsed","safeParse","Err","options","schema","picklist","interpretQuestionBooleanNode","params","__asyncGenerator","node","submissions","actions","next","submission","Ok","parsed","safeParse","Err","interpretQuestionEnumNode","params","__asyncGenerator","node","submissions","actions","next","schema","array","picklist","o","submission","Ok","parsed","safeParse","Err","interpretQuestionFileNode","params","__asyncGenerator","node","submissions","actions","next","t","submission","_a","Ok","minFiles","maxFiles","maxSize","allowedExtensions","ext","schema","array","object","string","custom","filename","extension","getFileExtension","number","minLength","maxLength","files","acc","cur","kbToReadableSize","parsed","safeParse","Err","getValidationSchema","node","t","_a","_b","_c","min","max","decimalCases","number","minValue","maxValue","custom","value","interpretQuestionNumberNode","params","__asyncGenerator","submissions","actions","next","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","getValidationSchema","node","t","object","string","regex","transform","minLength","maxLength","value","interpretQuestionPhoneNode","params","__asyncGenerator","actions","next","submissions","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","getValidationSchema","node","t","logger","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","errors","string","email","minLength","maxLength","url","interpretQuestionTextNode","params","__asyncGenerator","submissions","actions","next","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","createFlowInterpreter","params","submissions","_0","__asyncGenerator","nodes","context","actions","message","interpolateWithData","author","url","height","width","state","href","type","node","next","nextId","nextNode","config","__spreadProps","__spreadValues","__yieldStar","interpretQuestionTextNode","interpretQuestionPhoneNode","interpretQuestionBooleanNode","interpretQuestionNumberNode","interpretQuestionAddressNode","interpretQuestionEnumNode","interpretQuestionFileNode","interpretIdentifyNode","nextNodeId","isIfBlockConditionMet","interpretIntegrationApplicationSubmitNode"]}
1
+ {"version":3,"sources":["../src/conditions.ts","../src/interpolation.ts","../src/interpreter.identify.ts","../src/interpreter.integration-application-submit.ts","../src/interpreter.question-address.ts","../src/interpreter.question-boolean.ts","../src/interpreter.question-enum.ts","../src/interpreter.question-file.ts","../src/interpreter.question-number.ts","../src/interpreter.question-phone.ts","../src/interpreter.question-text.ts","../src/interpreter.ts"],"sourcesContent":["import { IfBlockNode, IfBlockNodeCondition } from '@inploi/core/flows';\nimport get from 'lodash/get';\n\nimport { FlowSubmissions } from './flow.types';\nimport { getSubmissionValueToCheck } from './utils';\n\nconst isConditionMet = ({\n\tcondition,\n\tcontext,\n\tsubmissions,\n\tifBlock,\n}: {\n\tcontext: Record<string, unknown>;\n\tcondition: IfBlockNodeCondition;\n\tsubmissions: FlowSubmissions;\n\tifBlock: IfBlockNode;\n}) => {\n\tconst [firstSegment, ...path] = condition.compareKey.split('.');\n\tif (!firstSegment) return false;\n\n\tconst answer = getSubmissionValueToCheck({ context, key: firstSegment, path, submissions });\n\tif (!answer) return false;\n\n\tswitch (answer.type) {\n\t\tcase 'address': {\n\t\t\tconst value = get(answer.value, path.join('.'));\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn value === condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\tif (!value) return false;\n\t\t\t\t\treturn value.includes(condition.compareValue);\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn value !== condition.compareValue;\n\t\t\t\tcase 'notContains':\n\t\t\t\t\tif (!value) return true;\n\t\t\t\t\treturn !value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'integration': {\n\t\t\t/** We only handle objects as integration submissions for now. */\n\t\t\tif (typeof answer.value !== 'object') return false;\n\t\t\tif (Array.isArray(answer.value)) return false;\n\n\t\t\tconst value = get(answer.value, path.join('.'));\n\t\t\tconst newIfBlock = { ...ifBlock, data: { ...ifBlock.data, compareKey: '_temp' } };\n\t\t\tswitch (typeof value) {\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'boolean' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'string' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'number' } },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t});\n\t\t\t\tcase 'object':\n\t\t\t\t\t/** We only handle enums if the result is an array of strings */\n\t\t\t\t\tif (Array.isArray(value) && value.every((value): value is string => typeof value === 'string')) {\n\t\t\t\t\t\treturn isIfBlockConditionMet(newIfBlock, {\n\t\t\t\t\t\t\tsubmissions: { ['_temp']: { value: value, type: 'enum' } },\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'boolean': {\n\t\t\tconst compareBoolean = condition.compareValue === 'true';\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn answer.value === compareBoolean;\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn answer.value !== compareBoolean;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'phone':\n\t\tcase 'string': {\n\t\t\tconst value = answer.type === 'phone' ? answer.value.countryCode + answer.value.phoneNumber : answer.value;\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn value === condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\tif (!value) return false;\n\t\t\t\t\treturn value.includes(condition.compareValue);\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn value !== condition.compareValue;\n\t\t\t\tcase 'notContains':\n\t\t\t\t\tif (!value) return true;\n\t\t\t\t\treturn !value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'number': {\n\t\t\ttry {\n\t\t\t\tconst compareNumber = Number(condition.compareValue);\n\t\t\t\tswitch (condition.compare) {\n\t\t\t\t\tcase 'equals':\n\t\t\t\t\t\treturn answer.value === compareNumber;\n\t\t\t\t\tcase 'notEquals':\n\t\t\t\t\t\treturn answer.value !== compareNumber;\n\t\t\t\t\tcase 'greaterThan':\n\t\t\t\t\t\treturn answer.value > compareNumber;\n\t\t\t\t\tcase 'greaterThanOrEqualTo':\n\t\t\t\t\t\treturn answer.value >= compareNumber;\n\t\t\t\t\tcase 'lessThan':\n\t\t\t\t\t\treturn answer.value < compareNumber;\n\t\t\t\t\tcase 'lessThanOrEqualTo':\n\t\t\t\t\t\treturn answer.value <= compareNumber;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tconsole.error(`Failed to parse number in if-block ${ifBlock.id}`, answer.value);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 'enum':\n\t\t\tswitch (condition.compare) {\n\t\t\t\tcase 'equals':\n\t\t\t\t\treturn answer.value.length === 1 && answer.value[0] === condition.compareValue;\n\t\t\t\tcase 'notEquals':\n\t\t\t\t\treturn answer.value.length === 1 && answer.value[0] !== condition.compareValue;\n\t\t\t\tcase 'contains':\n\t\t\t\t\treturn answer.value.includes(condition.compareValue);\n\t\t\t\tcase 'notContains':\n\t\t\t\t\treturn !answer.value.includes(condition.compareValue);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'file':\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tanswer satisfies never;\n\t\t\tbreak;\n\t}\n};\n\nexport const isIfBlockConditionMet = (\n\tifBlock: IfBlockNode,\n\t{ context, submissions }: { submissions: FlowSubmissions; context: Record<string, unknown> },\n): boolean => {\n\tconst conditions = 'combinator' in ifBlock.data ? ifBlock.data.conditions : [ifBlock.data];\n\tconst combinator = 'combinator' in ifBlock.data ? ifBlock.data.combinator : 'and';\n\n\tif (combinator === 'or') {\n\t\tfor (const condition of conditions) {\n\t\t\tconst isMet = isConditionMet({ condition, context, submissions, ifBlock });\n\t\t\tif (isMet) return true;\n\t\t}\n\t\treturn false;\n\t} else {\n\t\tfor (const condition of conditions) {\n\t\t\tconst isMet = isConditionMet({ condition, context, submissions, ifBlock });\n\t\t\tif (!isMet) return false;\n\t\t}\n\t\treturn true;\n\t}\n};\n","import get from 'lodash/get';\n\nimport { FlowSubmissions } from './flow.types';\nimport { formatPhoneNumber, getSubmissionValueToCheck, kbToReadableSize } from './utils';\n\nconst HANDLEBARS_REGEXP = /{{\\s*([^}]+?)\\s*(?:\\|\\s*([^}]+?)\\s*)?}}/g;\n\nexport const interpolateWithData = (\n\tstr: string,\n\t{ context, submissions }: { submissions: FlowSubmissions; context: Record<string, unknown> },\n) => {\n\treturn str.replace(HANDLEBARS_REGEXP, (_, key, defaultValue = '') => {\n\t\tconst [firstSegment, ...path] = key.trim().split('.');\n\t\tconst entity = getSubmissionValueToCheck({ key: firstSegment, path, submissions, context });\n\t\tif (!entity) return defaultValue;\n\n\t\tswitch (entity.type) {\n\t\t\tcase 'boolean':\n\t\t\t\treturn entity.value === true ? 'true' : 'false';\n\t\t\tcase 'file':\n\t\t\t\treturn entity.value.map(file => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(', ');\n\t\t\tcase 'enum':\n\t\t\t\treturn entity.value.join(', ');\n\t\t\tcase 'address':\n\t\t\t\treturn Object.values(entity.value)\n\t\t\t\t\t.filter(line => line && line.trim().length > 0)\n\t\t\t\t\t.join(', ');\n\t\t\tcase 'number':\n\t\t\tcase 'string':\n\t\t\t\tif (!entity.value) return defaultValue;\n\t\t\t\treturn entity.value.toString();\n\t\t\tcase 'phone':\n\t\t\t\treturn formatPhoneNumber(entity.value);\n\t\t\tcase 'integration': {\n\t\t\t\t/** We only handle objects as integration submissions for now. */\n\t\t\t\tif (typeof entity.value !== 'object') break;\n\t\t\t\tif (Array.isArray(entity.value)) break;\n\n\t\t\t\tconst value = get(entity.value, path.join('.'));\n\t\t\t\tswitch (typeof value) {\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\treturn value === true ? 'true' : 'false';\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\treturn value;\n\t\t\t\t\tcase 'number':\n\t\t\t\t\t\treturn value.toString();\n\t\t\t\t\tcase 'object':\n\t\t\t\t\t\t/** We only handle enums if the result is an array of strings */\n\t\t\t\t\t\tif (Array.isArray(value) && value.every((i): i is string => typeof i === 'string')) {\n\t\t\t\t\t\t\treturn value.join(', ');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tentity satisfies never;\n\t\t}\n\t\treturn defaultValue;\n\t});\n};\n","import { InterpretNodeParams } from './interpreter';\nimport { getSubmissionValue } from './utils';\n\nexport async function* interpretIdentifyNode(params: InterpretNodeParams<'identify'>) {\n\tconst {\n\t\tnode,\n\t\tconfig: { logger, analytics, submissions, next },\n\t} = params;\n\n\tanalytics.service\n\t\t.log({\n\t\t\tevent: 'IDENTIFY',\n\t\t\tproperties: {\n\t\t\t\tidentifier: getSubmissionValue({ key: node.data.key, submissions }).toString(),\n\t\t\t\tfirst_name:\n\t\t\t\t\tnode.data.firstName ? getSubmissionValue({ key: node.data.firstName, submissions }).toString() : undefined,\n\t\t\t\tlast_name:\n\t\t\t\t\tnode.data.lastName ? getSubmissionValue({ key: node.data.lastName, submissions }).toString() : undefined,\n\t\t\t\temail: node.data.email ? getSubmissionValue({ key: node.data.email, submissions }).toString() : undefined,\n\t\t\t\tphone_number:\n\t\t\t\t\tnode.data.phoneNumber ?\n\t\t\t\t\t\tgetSubmissionValue({ key: node.data.phoneNumber, submissions }).toString()\n\t\t\t\t\t:\tundefined,\n\t\t\t\tcustom_traits:\n\t\t\t\t\tnode.data.customTraits ?\n\t\t\t\t\t\tObject.fromEntries(node.data.customTraits.map(({ key, value }) => [key, submissions[value]?.value]))\n\t\t\t\t\t:\tundefined,\n\t\t\t},\n\t\t})\n\t\t.catch(logger.error);\n\n\treturn next(node.nextId);\n}\n","import { endpoint, typed } from '@inploi/sdk';\nimport * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok, tryCatch } from './result';\nimport { getFlowSubmissionsPayload } from './utils';\n\nconst responseSchema = v.object({\n\t/** Not necessarily true when we receive a positive response because the API considers only 200 as success */\n\tsuccess: v.boolean(),\n\tintegration_response: v.object({\n\t\tservice: v.optional(v.string()),\n\t\tstatus: v.number(),\n\t\tdata: v.unknown(),\n\t\terror: v.nullable(v.object({ message: v.string(), data: v.unknown() })),\n\t}),\n});\nexport type IntegrationResponse = v.InferOutput<typeof responseSchema>;\n\nconst submitEndpoint = endpoint({\n\tpathname: '/flow/submit',\n\tmethod: 'POST',\n\tschema: {\n\t\tresponse: responseSchema,\n\t\tbody: typed<{\n\t\t\tlog_submit: boolean;\n\t\t\tintegration_id: string;\n\t\t\tanonymous_id: string | null | undefined;\n\t\t\tsession_id: string | null | undefined;\n\t\t\tjob: unknown;\n\t\t\tsubmissions: Record<string, unknown>;\n\t\t}>(),\n\t},\n});\n\nexport async function* interpretIntegrationApplicationSubmitNode(\n\tparams: InterpretNodeParams<'integration-application-submit'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { rpcClient, submissions, actions, next, analytics, logger, context },\n\t} = params;\n\n\tif (node.data.skipConfirmation !== true) {\n\t\tyield actions.input('submit', {\n\t\t\tconfig: {\n\t\t\t\tkey: node.data.key ?? '_SUBMIT',\n\t\t\t\tlabel: node.data.submitLabel,\n\t\t\t},\n\t\t\t/** for submit node, validating _is_ submitting */\n\t\t\tvalidate: async () => {\n\t\t\t\tconst getSessionInfoSafe = tryCatch(analytics.service.getSessionInfo);\n\t\t\t\tconst sessionInfo = getSessionInfoSafe();\n\t\t\t\tif (sessionInfo.err) logger.error(sessionInfo.val.originalError);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await rpcClient.request(submitEndpoint, {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tlog_submit: false,\n\t\t\t\t\t\t\tintegration_id: node.data.integrationId,\n\t\t\t\t\t\t\tanonymous_id: sessionInfo.ok ? sessionInfo.val.anonymous_id : undefined,\n\t\t\t\t\t\t\tsession_id: sessionInfo.ok ? sessionInfo.val.session_id : undefined,\n\t\t\t\t\t\t\tjob: context.job,\n\t\t\t\t\t\t\tsubmissions: getFlowSubmissionsPayload(submissions),\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tconst parsed = v.safeParse(responseSchema, response);\n\t\t\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\t\t\treturn Ok(parsed.output);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst issues: v.ValiError<any>['issues'] = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tinput: e,\n\t\t\t\t\t\t\torigin: 'value',\n\t\t\t\t\t\t\treason: 'unknown',\n\t\t\t\t\t\t\tvalidation: 'API error',\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\te instanceof Error ? e.message\n\t\t\t\t\t\t\t\t: 'toString' in (e as any) ? (e as any).toString()\n\t\t\t\t\t\t\t\t: 'Unknown error',\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t\treturn Err(issues);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst fieldValueSchema = v.pipe(\n\tv.nullable(v.optional(v.string())),\n\tv.transform(i => (i === null ? undefined : i)),\n);\nconst getValidationSchema = ({ node }: InterpretNodeParams<'question-address'>) => {\n\tconst keys = node.data.keys;\n\treturn v.object({\n\t\t[keys.line1 ?? 'line1']: fieldValueSchema,\n\t\t[keys.line2 ?? 'line2']: fieldValueSchema,\n\t\t[keys.line3 ?? 'line3']: fieldValueSchema,\n\t\t[keys.city ?? 'city']: fieldValueSchema,\n\t\t[keys.country ?? 'country']: fieldValueSchema,\n\t\t[keys.postcode ?? 'postcode']: fieldValueSchema,\n\t\t[keys.state ?? 'state']: fieldValueSchema,\n\t});\n};\n\nexport async function* interpretQuestionAddressNode(\n\tparams: InterpretNodeParams<'question-address'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('address', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tkeys: node.data.keys,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'address', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst options = ['true', 'false'] as const;\nconst schema = v.picklist(options);\n\nexport async function* interpretQuestionBooleanNode(\n\tparams: InterpretNodeParams<'question-boolean'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('boolean', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tlabels: {\n\t\t\t\tfalse: node.data.falseLabel,\n\t\t\t\ttrue: node.data.trueLabel,\n\t\t\t},\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'boolean', value: parsed.output === 'true' };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import { NonEmptyArray } from '@inploi/core/common';\nimport * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nexport async function* interpretQuestionEnumNode(params: InterpretNodeParams<'question-enum'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst schema = v.array(v.picklist(node.data.options.map(o => o.value) as NonEmptyArray<string>));\n\tyield actions.input('multiple-choice', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\toptions: node.data.options,\n\t\t\tmaxSelected: node.data.maxSelected,\n\t\t\tminSelected: node.data.minSelected,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.minSelected === 0 && submission === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'enum', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\nimport { getFileExtension, kbToReadableSize } from './utils';\n\nexport async function* interpretQuestionFileNode(params: InterpretNodeParams<'question-file'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next, t },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tyield actions.input('file', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tallowMultiple: node.data.multiple === true,\n\t\t\textensions: node.data.extensions,\n\t\t\tfileSizeLimitKib: node.data.maxSizeKb,\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst minFiles = node.data.optional ? 0 : 1;\n\t\t\tconst maxFiles = node.data.multiple ? Number.POSITIVE_INFINITY : 1;\n\t\t\tconst maxSize = node.data.maxSizeKb ?? 0;\n\t\t\tconst allowedExtensions = node.data.extensions.map(ext => ext.toLowerCase());\n\t\t\tconst schema = v.pipe(\n\t\t\t\tv.array(\n\t\t\t\t\tv.object({\n\t\t\t\t\t\tname: v.pipe(\n\t\t\t\t\t\t\tv.string(t('validation_empty')),\n\t\t\t\t\t\t\tv.check(\n\t\t\t\t\t\t\t\tfilename => {\n\t\t\t\t\t\t\t\t\tconst extension = getFileExtension(filename);\n\t\t\t\t\t\t\t\t\tif (extension.ok === false) return false;\n\t\t\t\t\t\t\t\t\treturn allowedExtensions.includes(extension.val.toLowerCase());\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tt('validation_file_ext', { ext: allowedExtensions.join(', ') }),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdata: v.string(),\n\t\t\t\t\t\tsizeKb: v.number(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t\tv.minLength(minFiles, t('validation_file_min', { count: minFiles })),\n\t\t\t\tv.maxLength(maxFiles, t('validation_file_max', { count: maxFiles })),\n\t\t\t\tv.check(\n\t\t\t\t\tfiles => {\n\t\t\t\t\t\tconst totalSize = files.reduce((acc, cur) => acc + cur.sizeKb, 0);\n\t\t\t\t\t\treturn totalSize <= maxSize;\n\t\t\t\t\t},\n\t\t\t\t\tt('validation_file_size', { size: kbToReadableSize(maxSize) }),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'file', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t } }: InterpretNodeParams<'question-number'>) => {\n\tconst min = node.data.min ?? Number.MIN_SAFE_INTEGER;\n\tconst max = node.data.max ?? Number.MAX_SAFE_INTEGER;\n\tconst decimalCases = node.data.decimalCases ?? 0;\n\n\treturn v.pipe(\n\t\tv.number(t('validation_number')),\n\t\tv.minValue(min, t('validation_number_min', { min })),\n\t\tv.maxValue(max, t('validation_number_max', { max })),\n\t\tv.check(\n\t\t\tvalue => {\n\t\t\t\treturn value === Number(value.toFixed(decimalCases));\n\t\t\t},\n\t\t\tt('validation_number_decimal_cases', { count: decimalCases }),\n\t\t),\n\t);\n};\n\nexport async function* interpretQuestionNumberNode(\n\tparams: InterpretNodeParams<'question-number'>,\n): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('number', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\toptional: node.data.optional,\n\t\t\tdecimalCases: node.data.decimalCases,\n\t\t\tmax: node.data.max,\n\t\t\tmin: node.data.min,\n\t\t\tdefaultValue: thisSubmission?.type === 'number' ? thisSubmission.value.toString() : undefined,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'number', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t } }: InterpretNodeParams<'question-phone'>) => {\n\treturn v.object({\n\t\tcountryCode: v.pipe(v.string(t('validation_country_code')), v.regex(/^\\+?[0-9 -]+$/, t('validation_country_code'))),\n\t\tphoneNumber: v.pipe(\n\t\t\tv.string(t('validation_phone')),\n\t\t\tv.regex(/^\\+?[0-9 -]+$/, t('validation_phone')),\n\t\t\tv.minLength(node.data.minChars, t('validation_min_chars', { count: node.data.minChars })),\n\t\t\tv.transform(value => value.replace(/[^0-9]/g, '')),\n\t\t),\n\t});\n};\n\nexport async function* interpretQuestionPhoneNode(params: InterpretNodeParams<'question-phone'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { actions, next, submissions },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('phone', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tminChars: node.data.minChars,\n\t\t\tdefaultValue:\n\t\t\t\tthisSubmission?.type === 'phone' ?\n\t\t\t\t\tthisSubmission.value\n\t\t\t\t:\t{\n\t\t\t\t\t\tcountryCode: node.data.defaultCountryCode,\n\t\t\t\t\t},\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\tsubmissionFormat: 'phone',\n\t\t\toptional: node.data.optional,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'address', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import * as v from 'valibot';\n\nimport { InterpretNodeParams, InterpretNodeReturn } from './interpreter';\nimport { Err, Ok } from './result';\n\nconst getValidationSchema = ({ node, config: { t, logger } }: InterpretNodeParams<'question-text'>) => {\n\tconst errors = {\n\t\temail: t('validation_email'),\n\t\turl: t('validation_url'),\n\t\tmaxLength: t('validation_max_chars', { count: node.data.maxChars ?? 999 }),\n\t\tminLength: t('validation_min_chars', { count: node.data.minChars ?? 1 }),\n\t};\n\n\tswitch (node.data.format) {\n\t\tcase 'email':\n\t\t\treturn v.pipe(\n\t\t\t\tv.string(errors.email),\n\t\t\t\tv.email(errors.email),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t);\n\n\t\tcase 'text':\n\t\t\treturn v.pipe(\n\t\t\t\tv.string(),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t);\n\t\tcase 'url':\n\t\t\treturn v.pipe(\n\t\t\t\tv.string(),\n\t\t\t\tv.url(errors.url),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t);\n\t\tcase 'phone':\n\t\t\treturn v.pipe(\n\t\t\t\tv.string(),\n\t\t\t\tv.minLength(node.data.minChars ?? 1, errors.minLength),\n\t\t\t\tv.maxLength(node.data.maxChars ?? Infinity, errors.maxLength),\n\t\t\t);\n\t\tdefault:\n\t\t\tnode.data.format satisfies never;\n\t\t\tlogger.error(`Unsupported question-text format: ${node.data.format}`);\n\t\t\treturn null;\n\t}\n};\n\nexport async function* interpretQuestionTextNode(params: InterpretNodeParams<'question-text'>): InterpretNodeReturn {\n\tconst {\n\t\tnode,\n\t\tconfig: { submissions, actions, next },\n\t} = params;\n\tyield actions.text({ author: 'bot', message: node.data.question });\n\n\tconst thisSubmission = submissions[node.data.key];\n\tyield actions.input('text', {\n\t\tconfig: {\n\t\t\tkey: node.data.key,\n\t\t\tmaxChars: node.data.maxChars,\n\t\t\tminChars: node.data.minChars,\n\t\t\tplaceholder: node.data.placeholder,\n\t\t\tformat: node.data.format,\n\t\t\toptional: node.data.optional,\n\t\t\tdefaultValue: thisSubmission?.type === 'string' ? thisSubmission.value : undefined,\n\t\t},\n\t\tvalidate: submission => {\n\t\t\tif (node.data.optional && submission === null) return Ok(submission);\n\t\t\tconst schema = getValidationSchema(params);\n\t\t\tif (schema === null) return Ok(submission);\n\t\t\tconst parsed = v.safeParse(schema, submission);\n\t\t\tif (parsed.success === false) return Err(parsed.issues);\n\t\t\tsubmissions[node.data.key] = { type: 'string', value: parsed.output };\n\t\t\treturn Ok(submission);\n\t\t},\n\t});\n\n\treturn next(node.nextId);\n}\n","import { FlowNode } from '@inploi/core/flows';\nimport { AnalyticsService, InploiRpcClient, Logger } from '@inploi/sdk';\nimport { ValiError } from 'valibot';\n\nimport { isIfBlockConditionMet } from './conditions';\nimport { FlowSubmissions } from './flow.types';\nimport { TFunction } from './i18n';\nimport { FlowInput } from './inputs';\nimport { interpolateWithData } from './interpolation';\nimport { interpretIdentifyNode } from './interpreter.identify';\nimport { interpretIntegrationApplicationSubmitNode } from './interpreter.integration-application-submit';\nimport { interpretQuestionAddressNode } from './interpreter.question-address';\nimport { interpretQuestionBooleanNode } from './interpreter.question-boolean';\nimport { interpretQuestionEnumNode } from './interpreter.question-enum';\nimport { interpretQuestionFileNode } from './interpreter.question-file';\nimport { interpretQuestionNumberNode } from './interpreter.question-number';\nimport { interpretQuestionPhoneNode } from './interpreter.question-phone';\nimport { interpretQuestionTextNode } from './interpreter.question-text';\nimport { LinkedList, LinkedListItem } from './linked-list';\nimport { Result } from './result';\n\ntype MaybePromise<T> = T | Promise<T>;\ntype FlowInterpreterYield =\n\t| { type: 'submissions'; submissions: FlowSubmissions }\n\t| { type: 'state'; state: 'loading' | 'idle' }\n\t| { type: 'error'; message: string }\n\t| { type: 'info'; message: string }\n\t| { type: 'success'; message: string }\n\t| { type: 'text'; author: 'user' | 'bot'; message: string }\n\t| { type: 'image'; url: string; height: number; width: number }\n\t| { type: 'link'; href: string; message: string }\n\t| { type: 'end' }\n\t| {\n\t\t\ttype: 'input';\n\t\t\tinput: {\n\t\t\t\t[I in FlowInput['type']]: {\n\t\t\t\t\ttype: I;\n\t\t\t\t\tconfig: (FlowInput & { type: I })['config'];\n\t\t\t\t\tvalidate: (\n\t\t\t\t\t\tinput: NonNullable<(FlowInput & { type: I })['submission']>['value'] | null,\n\t\t\t\t\t) => MaybePromise<\n\t\t\t\t\t\tResult<NonNullable<(FlowInput & { type: I })['submission']>['value'] | null, ValiError<any>['issues']>\n\t\t\t\t\t>;\n\t\t\t\t};\n\t\t\t}[FlowInput['type']];\n\t };\n\nexport type FlowInterpreterParams = {\n\trpcClient: InploiRpcClient;\n\tanalytics: {\n\t\tservice: AnalyticsService;\n\t\tcustomProperties?: Record<string, unknown>;\n\t};\n\tlogger: Logger;\n\tt: TFunction;\n};\n\nexport type FlowActions = {\n\terror: ({ message }: { message: string }) => FlowInterpreterYield;\n\tinfo: ({ message }: { message: string }) => FlowInterpreterYield;\n\tsuccess: ({ message }: { message: string }) => FlowInterpreterYield;\n\ttext: ({ message, author }: { message: string; author: 'bot' | 'user' }) => FlowInterpreterYield;\n\timage: ({ url, height, width }: { url: string; height: number; width: number }) => FlowInterpreterYield;\n\tlink: ({ href, message }: { href: string; message: string }) => FlowInterpreterYield;\n\tsubmissions: (submissions: FlowSubmissions) => FlowInterpreterYield;\n\tstate: (state: 'loading' | 'idle') => FlowInterpreterYield;\n\tinput: <T extends FlowInput['type'], Input extends FlowInput & { type: T }>(\n\t\ttype: T,\n\t\tparams: {\n\t\t\tconfig: Input['config'];\n\t\t\tvalidate: (\n\t\t\t\tinput: NonNullable<Input['submission']>['value'] | null,\n\t\t\t) => MaybePromise<Result<NonNullable<Input['submission']>['value'] | null, ValiError<any>['issues']>>;\n\t\t},\n\t) => FlowInterpreterYield;\n};\n\nexport const createFlowInterpreter = (params: FlowInterpreterParams) => {\n\tconst submissions: FlowSubmissions = {};\n\n\treturn {\n\t\tinterpret: async function* interpret({\n\t\t\tnodes,\n\t\t\tcontext,\n\t\t}: {\n\t\t\tnodes: LinkedList<FlowNode>;\n\t\t\tcontext: Record<string, unknown>;\n\t\t}): AsyncGenerator<FlowInterpreterYield> {\n\t\t\tconst actions: FlowActions = {\n\t\t\t\terror: ({ message }) => ({ type: 'error', message: interpolateWithData(message, { submissions, context }) }),\n\t\t\t\tinfo: ({ message }) => ({ type: 'info', message: interpolateWithData(message, { submissions, context }) }),\n\t\t\t\tsuccess: ({ message }) => ({\n\t\t\t\t\ttype: 'success',\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\ttext: ({ message, author }) => ({\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tauthor,\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\timage: ({ url, height, width }) => ({\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\turl: interpolateWithData(url, { submissions, context }),\n\t\t\t\t\theight,\n\t\t\t\t\twidth,\n\t\t\t\t}),\n\t\t\t\tstate: state => ({ type: 'state', state }),\n\t\t\t\tlink: ({ href, message }) => ({\n\t\t\t\t\ttype: 'link',\n\t\t\t\t\thref: interpolateWithData(href, { submissions, context }),\n\t\t\t\t\tmessage: interpolateWithData(message, { submissions, context }),\n\t\t\t\t}),\n\t\t\t\tsubmissions: submissions => ({ type: 'submissions', submissions }),\n\t\t\t\tinput: (type, params) => {\n\t\t\t\t\treturn { type: 'input', input: { type, config: params.config, validate: params.validate } as any };\n\t\t\t\t},\n\t\t\t};\n\t\t\tif (!nodes.headId) return { type: 'error', message: 'No head node found' };\n\t\t\tlet node: LinkedListItem<FlowNode> | undefined = nodes.items[nodes.headId];\n\t\t\tconst next = (nextId: string | undefined): { type: 'next'; nodeId: string | undefined } => {\n\t\t\t\tif (!nextId) {\n\t\t\t\t\tnode = undefined;\n\t\t\t\t\treturn { type: 'next', nodeId: undefined };\n\t\t\t\t}\n\t\t\t\tconst nextNode = nodes.items[nextId];\n\t\t\t\tif (!nextNode) throw new Error(`Next node with id ${nextId} not found`);\n\t\t\t\tnode = nextNode;\n\t\t\t\treturn { type: 'next', nodeId: nextId };\n\t\t\t};\n\t\t\tconst config = { ...params, context, submissions, next, actions };\n\n\t\t\twhile (node) {\n\t\t\t\tswitch (node.type) {\n\t\t\t\t\tcase 'text':\n\t\t\t\t\t\tyield actions.text({ author: 'bot', message: node.data.text });\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'image':\n\t\t\t\t\t\tyield actions.image(node.data);\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'link':\n\t\t\t\t\t\tyield actions.link({ href: node.data.href, message: node.data.cta });\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'add-submission':\n\t\t\t\t\t\tsubmissions[node.data.key] = { type: 'string', value: node.data.value };\n\t\t\t\t\t\tnext(node.nextId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'jump':\n\t\t\t\t\t\tnext(node.data.targetId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-text':\n\t\t\t\t\t\tyield* interpretQuestionTextNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-phone':\n\t\t\t\t\t\tyield* interpretQuestionPhoneNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-boolean':\n\t\t\t\t\t\tyield* interpretQuestionBooleanNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-number':\n\t\t\t\t\t\tyield* interpretQuestionNumberNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-address':\n\t\t\t\t\t\tyield* interpretQuestionAddressNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-enum':\n\t\t\t\t\t\tyield* interpretQuestionEnumNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'question-file':\n\t\t\t\t\t\tyield* interpretQuestionFileNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'identify': {\n\t\t\t\t\t\tyield* interpretIdentifyNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'if-block': {\n\t\t\t\t\t\tconst nextNodeId =\n\t\t\t\t\t\t\tisIfBlockConditionMet(node, { context: config.context, submissions }) ? node.branchId : node.nextId;\n\t\t\t\t\t\tnext(nextNodeId);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'integration-application-submit':\n\t\t\t\t\t\tyield* interpretIntegrationApplicationSubmitNode({ config, node });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'feedback':\n\t\t\t\t\t\tyield actions.error({ message: 'Not implemented' });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'integration-workflow-get':\n\t\t\t\t\t\tyield actions.error({ message: 'This message should never be reached' });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'end-flow':\n\t\t\t\t\t\tnode = undefined;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield actions.submissions(submissions);\n\t\t\t}\n\t\t\tyield { type: 'end' };\n\t\t},\n\t};\n};\n\nexport type InterpretNodeParams<TNodeType extends FlowNode['type']> = {\n\tnode: FlowNode & { type: TNodeType };\n\tconfig: FlowInterpreterParams & {\n\t\tsubmissions: FlowSubmissions;\n\t\tcontext: Record<string, unknown>;\n\t\tnext: (nextId: string | undefined) => { type: 'next'; nodeId: string | undefined };\n\t\tactions: FlowActions;\n\t};\n};\n\nexport type InterpretNodeReturn = AsyncGenerator<FlowInterpreterYield, { type: 'next'; nodeId: string | undefined }>;\n"],"mappings":"iSACA,IAAAA,EAAgB,OAKhB,IAAMC,GAAiB,CAAC,CACvB,UAAAC,EACA,QAAAC,EACA,YAAAC,EACA,QAAAC,CACD,IAKM,CACL,GAAM,CAACC,EAAc,GAAGC,CAAI,EAAIL,EAAU,WAAW,MAAM,GAAG,EAC9D,GAAI,CAACI,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OAAAR,EAAQ,KAAAJ,CAAK,CAAC,GACpD,MACD,IAAK,gBACJ,MAAAO,EAAOM,GAA0B,CAAE,OAAAT,EAAQ,KAAAJ,CAAK,CAAC,GACjD,MACD,IAAK,gBACJ,MAAAO,EAAOO,GAA0B,CAAE,OAAAV,EAAQ,KAAAJ,CAAK,CAAC,GACjD,MACD,IAAK,WAAY,CAChB,MAAAO,EAAOQ,GAAsB,CAAE,OAAAX,EAAQ,KAAAJ,CAAK,CAAC,GAC7C,KACD,CACA,IAAK,WAAY,CAChB,IAAMgB,EACLC,EAAsBjB,EAAM,CAAE,QAASI,EAAO,QAAS,YAAAnB,CAAY,CAAC,EAAIe,EAAK,SAAWA,EAAK,OAC9FC,EAAKe,CAAU,EACf,KACD,CACA,IAAK,iCACJ,MAAAT,EAAOW,GAA0C,CAAE,OAAAd,EAAQ,KAAAJ,CAAK,CAAC,GACjE,MACD,IAAK,WACJ,MAAMV,EAAQ,MAAM,CAAE,QAAS,iBAAkB,CAAC,EAClD,MACD,IAAK,2BACJ,MAAMA,EAAQ,MAAM,CAAE,QAAS,sCAAuC,CAAC,EACvE,MACD,IAAK,WACJU,EAAO,OACP,KACF,CACA,MAAMV,EAAQ,YAAYL,CAAW,CACtC,CACA,KAAM,CAAE,KAAM,KAAM,CACrB,GACD,CACD","names":["import_get","isConditionMet","condition","context","submissions","ifBlock","firstSegment","path","answer","getSubmissionValueToCheck","value","get","newIfBlock","__spreadProps","__spreadValues","isIfBlockConditionMet","compareBoolean","compareNumber","e","conditions","import_get","HANDLEBARS_REGEXP","interpolateWithData","str","context","submissions","_","key","defaultValue","firstSegment","path","entity","getSubmissionValueToCheck","file","kbToReadableSize","line","formatPhoneNumber","value","get","i","interpretIdentifyNode","params","__asyncGenerator","node","logger","analytics","submissions","next","getSubmissionValue","key","value","_a","endpoint","typed","responseSchema","object","boolean","optional","string","number","unknown","nullable","submitEndpoint","endpoint","typed","interpretIntegrationApplicationSubmitNode","params","__asyncGenerator","_a","node","rpcClient","submissions","actions","next","analytics","logger","context","__async","sessionInfo","tryCatch","response","getFlowSubmissionsPayload","parsed","safeParse","Err","Ok","e","issues","fieldValueSchema","pipe","nullable","optional","string","transform","i","getValidationSchema","node","_a","_b","_c","_d","_e","_f","_g","keys","object","interpretQuestionAddressNode","params","__asyncGenerator","submissions","actions","next","submission","Ok","schema","parsed","safeParse","Err","options","schema","picklist","interpretQuestionBooleanNode","params","__asyncGenerator","node","submissions","actions","next","submission","Ok","parsed","safeParse","Err","interpretQuestionEnumNode","params","__asyncGenerator","node","submissions","actions","next","schema","array","picklist","o","submission","Ok","parsed","safeParse","Err","interpretQuestionFileNode","params","__asyncGenerator","node","submissions","actions","next","t","submission","_a","Ok","minFiles","maxFiles","maxSize","allowedExtensions","ext","schema","pipe","array","object","string","check","filename","extension","getFileExtension","number","minLength","maxLength","files","acc","cur","kbToReadableSize","parsed","safeParse","Err","getValidationSchema","node","t","_a","_b","_c","min","max","decimalCases","pipe","number","minValue","maxValue","check","value","interpretQuestionNumberNode","params","__asyncGenerator","submissions","actions","next","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","getValidationSchema","node","t","object","pipe","string","regex","minLength","transform","value","interpretQuestionPhoneNode","params","__asyncGenerator","actions","next","submissions","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","getValidationSchema","node","t","logger","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","errors","pipe","string","email","minLength","maxLength","url","interpretQuestionTextNode","params","__asyncGenerator","submissions","actions","next","thisSubmission","submission","Ok","schema","parsed","safeParse","Err","createFlowInterpreter","params","submissions","_0","__asyncGenerator","nodes","context","actions","message","interpolateWithData","author","url","height","width","state","href","type","node","next","nextId","nextNode","config","__spreadProps","__spreadValues","__yieldStar","interpretQuestionTextNode","interpretQuestionPhoneNode","interpretQuestionBooleanNode","interpretQuestionNumberNode","interpretQuestionAddressNode","interpretQuestionEnumNode","interpretQuestionFileNode","interpretIdentifyNode","nextNodeId","isIfBlockConditionMet","interpretIntegrationApplicationSubmitNode"]}
@@ -1,2 +1,2 @@
1
- import{D as o,a as i,b as f}from"./chunk-3QWHH45C.mjs";var h={create:()=>({headId:null,items:{}}),addItem:(e,r,d={})=>{var I;let t=i({id:o()},r);if(!e.headId)return f(i({},e),{headId:t.id,items:{[t.id]:t}});if(d.afterId){let m=e.items[d.afterId];if(!m)throw new Error(`Item with afterId ${d.afterId} not found`);let a=i({},e.items);return t.prevId=d.afterId,t.nextId=m.nextId,a[d.afterId]=f(i({},m),{nextId:t.id}),m.nextId&&(a[m.nextId]=f(i({},a[m.nextId]),{prevId:t.id})),a[t.id]=t,f(i({},e),{items:a})}let s=e.headId;for(;s;){let m=(I=e.items[s])==null?void 0:I.nextId;if(!m)break;s=m}let n=f(i({},e.items[s]),{nextId:t.id});return t.prevId=s,f(i({},e),{items:f(i({},e.items),{[s]:n,[t.id]:t})})},removeItem:(e,r)=>{var s;let d=e.items[r];if(!d)throw new Error(`Item with id ${r} not found`);let t=i({},e.items);return delete t[r],d.prevId&&d.nextId?(t[d.prevId]=f(i({},t[d.prevId]),{nextId:d.nextId}),t[d.nextId]=f(i({},t[d.nextId]),{prevId:d.prevId})):d.prevId?t[d.prevId]=f(i({},t[d.prevId]),{nextId:void 0}):d.nextId&&(t[d.nextId]=f(i({},t[d.nextId]),{prevId:void 0})),f(i({},e),{headId:r===e.headId?(s=d.nextId)!=null?s:null:e.headId,items:t})},moveItem:(e,r,d)=>{let t=e.items[r];if(!t)throw new Error(`Item with id ${r} not found`);let s=h.removeItem(e,r);if(d.beforeId){let n=e.items[d.beforeId];if(!n)throw new Error(`Target item with id ${d.beforeId} not found`);let I=s.items;return I[r]=f(i({},t),{nextId:d.beforeId,prevId:n.prevId}),I[d.beforeId]=f(i({},n),{prevId:r,nextId:n.nextId===r?t.nextId:n.nextId}),n.prevId&&(I[n.prevId]=f(i({},I[n.prevId]),{nextId:r})),f(i({},e),{headId:n.prevId?s.headId:r,items:I})}else if(d.afterId){let n=e.items[d.afterId];if(!n)throw new Error(`Target item with id ${d.afterId} not found`);let I=i({},s.items);return I[r]=f(i({},t),{prevId:d.afterId,nextId:n.nextId}),I[d.afterId]=f(i({},n),{prevId:n.prevId===r?t.prevId:n.prevId,nextId:r}),n.nextId&&(I[n.nextId]=f(i({},I[n.nextId]),{prevId:r})),f(i({},e),{headId:s.headId,items:I})}throw new Error("Invalid options")},asArray:e=>{let r=[];if(!("headId"in e)||e.headId===null)return r;let d=new Set,t=e.headId;for(;t;){if(d.has(t))throw new Error(`Circular reference detected: item ${t} was encountered twice`);let s=e.items[t];if(!s)throw new Error(`Invalid list structure: item with id ${t} not found`);d.add(t),r.push(s),t=s.nextId}return r},getInvalidItemKeys:e=>{var s;let r=[],d=new Set,t=new Set;for(let[n,I]of Object.entries(e.items)){if(I.id!==n&&r.push(n),I.nextId&&!e.items[I.nextId]&&r.push(n),I.prevId&&!e.items[I.prevId]&&r.push(n),I.nextId){let m=e.items[I.nextId];m&&m.prevId!==I.id&&r.push(n)}if(I.prevId){let m=e.items[I.prevId];m&&m.nextId!==I.id&&r.push(n)}}if(e.headId)if(!e.items[e.headId])r.push(e.headId);else{let n=e.headId;for(;n;){if(t.has(n)){for(let I of t)r.push(I);break}t.add(n),d.add(n),n=(s=e.items[n])==null?void 0:s.nextId}}for(let n of Object.keys(e.items))d.has(n)||r.push(n);return[...new Set(r)]},isLinkedList:e=>e!==null&&typeof e=="object"&&"headId"in e&&"items"in e};export{h as LinkedList};
1
+ import{E as o,a as i,b as f}from"./chunk-VKMPK5WA.mjs";var h={create:()=>({headId:null,items:{}}),addItem:(e,r,d={})=>{var I;let t=i({id:o()},r);if(!e.headId)return f(i({},e),{headId:t.id,items:{[t.id]:t}});if(d.afterId){let m=e.items[d.afterId];if(!m)throw new Error(`Item with afterId ${d.afterId} not found`);let a=i({},e.items);return t.prevId=d.afterId,t.nextId=m.nextId,a[d.afterId]=f(i({},m),{nextId:t.id}),m.nextId&&(a[m.nextId]=f(i({},a[m.nextId]),{prevId:t.id})),a[t.id]=t,f(i({},e),{items:a})}let s=e.headId;for(;s;){let m=(I=e.items[s])==null?void 0:I.nextId;if(!m)break;s=m}let n=f(i({},e.items[s]),{nextId:t.id});return t.prevId=s,f(i({},e),{items:f(i({},e.items),{[s]:n,[t.id]:t})})},removeItem:(e,r)=>{var s;let d=e.items[r];if(!d)throw new Error(`Item with id ${r} not found`);let t=i({},e.items);return delete t[r],d.prevId&&d.nextId?(t[d.prevId]=f(i({},t[d.prevId]),{nextId:d.nextId}),t[d.nextId]=f(i({},t[d.nextId]),{prevId:d.prevId})):d.prevId?t[d.prevId]=f(i({},t[d.prevId]),{nextId:void 0}):d.nextId&&(t[d.nextId]=f(i({},t[d.nextId]),{prevId:void 0})),f(i({},e),{headId:r===e.headId?(s=d.nextId)!=null?s:null:e.headId,items:t})},moveItem:(e,r,d)=>{let t=e.items[r];if(!t)throw new Error(`Item with id ${r} not found`);let s=h.removeItem(e,r);if(d.beforeId){let n=e.items[d.beforeId];if(!n)throw new Error(`Target item with id ${d.beforeId} not found`);let I=s.items;return I[r]=f(i({},t),{nextId:d.beforeId,prevId:n.prevId}),I[d.beforeId]=f(i({},n),{prevId:r,nextId:n.nextId===r?t.nextId:n.nextId}),n.prevId&&(I[n.prevId]=f(i({},I[n.prevId]),{nextId:r})),f(i({},e),{headId:n.prevId?s.headId:r,items:I})}else if(d.afterId){let n=e.items[d.afterId];if(!n)throw new Error(`Target item with id ${d.afterId} not found`);let I=i({},s.items);return I[r]=f(i({},t),{prevId:d.afterId,nextId:n.nextId}),I[d.afterId]=f(i({},n),{prevId:n.prevId===r?t.prevId:n.prevId,nextId:r}),n.nextId&&(I[n.nextId]=f(i({},I[n.nextId]),{prevId:r})),f(i({},e),{headId:s.headId,items:I})}throw new Error("Invalid options")},asArray:e=>{let r=[];if(!("headId"in e)||e.headId===null)return r;let d=new Set,t=e.headId;for(;t;){if(d.has(t))throw new Error(`Circular reference detected: item ${t} was encountered twice`);let s=e.items[t];if(!s)throw new Error(`Invalid list structure: item with id ${t} not found`);d.add(t),r.push(s),t=s.nextId}return r},getInvalidItemKeys:e=>{var s;let r=[],d=new Set,t=new Set;for(let[n,I]of Object.entries(e.items)){if(I.id!==n&&r.push(n),I.nextId&&!e.items[I.nextId]&&r.push(n),I.prevId&&!e.items[I.prevId]&&r.push(n),I.nextId){let m=e.items[I.nextId];m&&m.prevId!==I.id&&r.push(n)}if(I.prevId){let m=e.items[I.prevId];m&&m.nextId!==I.id&&r.push(n)}}if(e.headId)if(!e.items[e.headId])r.push(e.headId);else{let n=e.headId;for(;n;){if(t.has(n)){for(let I of t)r.push(I);break}t.add(n),d.add(n),n=(s=e.items[n])==null?void 0:s.nextId}}for(let n of Object.keys(e.items))d.has(n)||r.push(n);return[...new Set(r)]},isLinkedList:e=>e!==null&&typeof e=="object"&&"headId"in e&&"items"in e};export{h as LinkedList};
2
2
  //# sourceMappingURL=linked-list.mjs.map