@stackone/connect-sdk 1.36.1 → 1.37.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.
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -23,5 +23,5 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
23
23
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
25
25
|
path: iss.path ? [${w(e)}, ...iss.path] : [${w(e)}]
|
|
26
|
-
})));`),t.write(`newResult[${w(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=T,o=!ie.jitless,s=le,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?un(e,s,t,f):R(e,s,t))):i?un(r,s,t,f):R(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],ee=u.keySet,h=l._zod,te=h.def.type;for(let e of Object.keys(f)){if(ee.has(e))continue;if(te===`never`){m.push(e);continue}let t=h.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>R(t,s,e))):R(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function fn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>M(e,r,v())))}),t}const pn=g(`$ZodUnion`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),C(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),C(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),C(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>S(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>fn(t,n,e,r)):fn(a,n,e,r)}}),mn=g(`$ZodDiscriminatedUnion`,(e,t)=>{pn.init(e,t);let n=e._zod.parse;C(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=b(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!T(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),hn=g(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>_n(e,t,n)):_n(e,i,a)}});function gn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(E(e)&&E(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=gn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=gn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _n(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;let r=gn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const vn=g(`$ZodRecord`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!E(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...j(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...j(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>M(e,r,v())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...j(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...j(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),yn=g(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=ae(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>ue.has(typeof e)).map(e=>typeof e==`string`?D(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),bn=g(`$ZodLiteral`,(e,t)=>{I.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?D(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),xn=g(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new _;return e.value=r,e}}),Sn=g(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Cn=g(`$ZodNullable`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)}|null)$`):void 0}),C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wn=g(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Tn(e,t)):Tn(r,t)}});function Tn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const En=g(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Dn=g(`$ZodNonOptional`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>On(t,e)):On(i,e)}});function On(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const kn=g(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)}}),An=g(`$ZodPipe`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>t.in._zod.values),C(e._zod,`optin`,()=>t.in._zod.optin),C(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jn(e,t,n)):jn(r,t,n)}});function jn(e,t,n){return A(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Mn=g(`$ZodReadonly`,(e,t)=>{I.init(e,t),C(e._zod,`propValues`,()=>t.innerType._zod.propValues),C(e._zod,`values`,()=>t.innerType._zod.values),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Nn):Nn(r)}});function Nn(e){return e.value=Object.freeze(e.value),e}const Pn=g(`$ZodCustom`,(e,t)=>{F.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fn(t,n,r,e));Fn(i,n,r,e)}});function Fn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}const In=Symbol(`ZodOutput`),Ln=Symbol(`ZodInput`);var Rn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function zn(){return new Rn}const z=zn();function Bn(e,t){return new e({type:`string`,...k(t)})}function Vn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Hn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Un(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function Wn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function Gn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function Kn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function qn(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function Jn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Yn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function Xn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Zn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Qn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function $n(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function er(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function tr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function nr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function rr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function ir(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function ar(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function or(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function lr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function ur(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function fr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function pr(e,t){return new e({type:`number`,checks:[],...k(t)})}function mr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function hr(e,t){return new e({type:`boolean`,...k(t)})}function gr(e){return new e({type:`any`})}function _r(e){return new e({type:`unknown`})}function vr(e,t){return new e({type:`never`,...k(t)})}function yr(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!1})}function br(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!0})}function xr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!1})}function Sr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Cr(e,t){return new pt({check:`multiple_of`,...k(t),value:e})}function wr(e,t){let n=new ht({check:`max_length`,...k(t),maximum:e});return n}function B(e,t){return new gt({check:`min_length`,...k(t),minimum:e})}function Tr(e,t){return new _t({check:`length_equals`,...k(t),length:e})}function Er(e,t){return new yt({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Dr(e){return new bt({check:`string_format`,format:`lowercase`,...k(e)})}function Or(e){return new xt({check:`string_format`,format:`uppercase`,...k(e)})}function kr(e,t){return new St({check:`string_format`,format:`includes`,...k(t),includes:e})}function Ar(e,t){return new Ct({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function jr(e,t){return new wt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function V(e){return new Tt({check:`overwrite`,tx:e})}function Mr(e){return V(t=>t.normalize(e))}function Nr(){return V(e=>e.trim())}function Pr(){return V(e=>e.toLowerCase())}function Fr(){return V(e=>e.toUpperCase())}function Ir(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Lr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...k(n)});return r}const Rr=g(`ZodISODateTime`,(e,t)=>{Bt.init(e,t),G.init(e,t)});function zr(e){return lr(Rr,e)}const Br=g(`ZodISODate`,(e,t)=>{Vt.init(e,t),G.init(e,t)});function Vr(e){return ur(Br,e)}const Hr=g(`ZodISOTime`,(e,t)=>{Ht.init(e,t),G.init(e,t)});function Ur(e){return dr(Hr,e)}const Wr=g(`ZodISODuration`,(e,t)=>{Ut.init(e,t),G.init(e,t)});function Gr(e){return fr(Wr,e)}const Kr=(e,t)=>{Se.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>we(e,t)},flatten:{value:t=>Ce(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},qr=g(`ZodError`,Kr),H=g(`ZodError`,Kr,{Parent:Error}),Jr=Te(H),Yr=De(H),Xr=ke(H),Zr=je(H),U=g(`ZodType`,(e,t)=>(I.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>O(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>Jr(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Xr(e,t,n),e.parseAsync=async(t,n)=>Yr(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zr(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(oa(t,n)),e.superRefine=t=>e.check(sa(t)),e.overwrite=t=>e.check(V(t)),e.optional=()=>Ui(e),e.nullable=()=>Gi(e),e.nullish=()=>Ui(Gi(e)),e.nonoptional=t=>Zi(e,t),e.array=()=>Oi(e),e.or=t=>ji([e,t]),e.and=t=>Fi(e,t),e.transform=t=>ta(e,Vi(t)),e.default=t=>qi(e,t),e.prefault=t=>Yi(e,t),e.catch=t=>$i(e,t),e.pipe=t=>ta(e,t),e.readonly=()=>ra(e),e.describe=t=>{let n=e.clone();return z.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return z.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return z.get(e);let n=e.clone();return z.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Qr=g(`_ZodString`,(e,t)=>{Ot.init(e,t),U.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Er(...t)),e.includes=(...t)=>e.check(kr(...t)),e.startsWith=(...t)=>e.check(Ar(...t)),e.endsWith=(...t)=>e.check(jr(...t)),e.min=(...t)=>e.check(B(...t)),e.max=(...t)=>e.check(wr(...t)),e.length=(...t)=>e.check(Tr(...t)),e.nonempty=(...t)=>e.check(B(1,...t)),e.lowercase=t=>e.check(Dr(t)),e.uppercase=t=>e.check(Or(t)),e.trim=()=>e.check(Nr()),e.normalize=(...t)=>e.check(Mr(...t)),e.toLowerCase=()=>e.check(Pr()),e.toUpperCase=()=>e.check(Fr())}),$r=g(`ZodString`,(e,t)=>{Ot.init(e,t),Qr.init(e,t),e.email=t=>e.check(Vn(ei,t)),e.url=t=>e.check(qn(ni,t)),e.jwt=t=>e.check(cr(_i,t)),e.emoji=t=>e.check(Jn(ri,t)),e.guid=t=>e.check(Hn(ti,t)),e.uuid=t=>e.check(Un(K,t)),e.uuidv4=t=>e.check(Wn(K,t)),e.uuidv6=t=>e.check(Gn(K,t)),e.uuidv7=t=>e.check(Kn(K,t)),e.nanoid=t=>e.check(Yn(ii,t)),e.guid=t=>e.check(Hn(ti,t)),e.cuid=t=>e.check(Xn(ai,t)),e.cuid2=t=>e.check(Zn(oi,t)),e.ulid=t=>e.check(Qn(si,t)),e.base64=t=>e.check(ar(mi,t)),e.base64url=t=>e.check(or(hi,t)),e.xid=t=>e.check($n(ci,t)),e.ksuid=t=>e.check(er(li,t)),e.ipv4=t=>e.check(tr(ui,t)),e.ipv6=t=>e.check(nr(di,t)),e.cidrv4=t=>e.check(rr(fi,t)),e.cidrv6=t=>e.check(ir(pi,t)),e.e164=t=>e.check(sr(gi,t)),e.datetime=t=>e.check(zr(t)),e.date=t=>e.check(Vr(t)),e.time=t=>e.check(Ur(t)),e.duration=t=>e.check(Gr(t))});function W(e){return Bn($r,e)}const G=g(`ZodStringFormat`,(e,t)=>{L.init(e,t),Qr.init(e,t)}),ei=g(`ZodEmail`,(e,t)=>{jt.init(e,t),G.init(e,t)}),ti=g(`ZodGUID`,(e,t)=>{kt.init(e,t),G.init(e,t)}),K=g(`ZodUUID`,(e,t)=>{At.init(e,t),G.init(e,t)}),ni=g(`ZodURL`,(e,t)=>{Mt.init(e,t),G.init(e,t)}),ri=g(`ZodEmoji`,(e,t)=>{Nt.init(e,t),G.init(e,t)}),ii=g(`ZodNanoID`,(e,t)=>{Pt.init(e,t),G.init(e,t)}),ai=g(`ZodCUID`,(e,t)=>{Ft.init(e,t),G.init(e,t)}),oi=g(`ZodCUID2`,(e,t)=>{It.init(e,t),G.init(e,t)}),si=g(`ZodULID`,(e,t)=>{Lt.init(e,t),G.init(e,t)}),ci=g(`ZodXID`,(e,t)=>{Rt.init(e,t),G.init(e,t)}),li=g(`ZodKSUID`,(e,t)=>{zt.init(e,t),G.init(e,t)}),ui=g(`ZodIPv4`,(e,t)=>{Wt.init(e,t),G.init(e,t)}),di=g(`ZodIPv6`,(e,t)=>{Gt.init(e,t),G.init(e,t)}),fi=g(`ZodCIDRv4`,(e,t)=>{Kt.init(e,t),G.init(e,t)}),pi=g(`ZodCIDRv6`,(e,t)=>{qt.init(e,t),G.init(e,t)}),mi=g(`ZodBase64`,(e,t)=>{Yt.init(e,t),G.init(e,t)}),hi=g(`ZodBase64URL`,(e,t)=>{Zt.init(e,t),G.init(e,t)}),gi=g(`ZodE164`,(e,t)=>{Qt.init(e,t),G.init(e,t)}),_i=g(`ZodJWT`,(e,t)=>{en.init(e,t),G.init(e,t)}),vi=g(`ZodNumber`,(e,t)=>{tn.init(e,t),U.init(e,t),e.gt=(t,n)=>e.check(xr(t,n)),e.gte=(t,n)=>e.check(Sr(t,n)),e.min=(t,n)=>e.check(Sr(t,n)),e.lt=(t,n)=>e.check(yr(t,n)),e.lte=(t,n)=>e.check(br(t,n)),e.max=(t,n)=>e.check(br(t,n)),e.int=t=>e.check(bi(t)),e.safe=t=>e.check(bi(t)),e.positive=t=>e.check(xr(0,t)),e.nonnegative=t=>e.check(Sr(0,t)),e.negative=t=>e.check(yr(0,t)),e.nonpositive=t=>e.check(br(0,t)),e.multipleOf=(t,n)=>e.check(Cr(t,n)),e.step=(t,n)=>e.check(Cr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function q(e){return pr(vi,e)}const yi=g(`ZodNumberFormat`,(e,t)=>{nn.init(e,t),vi.init(e,t)});function bi(e){return mr(yi,e)}const xi=g(`ZodBoolean`,(e,t)=>{rn.init(e,t),U.init(e,t)});function J(e){return hr(xi,e)}const Si=g(`ZodAny`,(e,t)=>{an.init(e,t),U.init(e,t)});function Ci(){return gr(Si)}const wi=g(`ZodUnknown`,(e,t)=>{on.init(e,t),U.init(e,t)});function Y(){return _r(wi)}const Ti=g(`ZodNever`,(e,t)=>{sn.init(e,t),U.init(e,t)});function Ei(e){return vr(Ti,e)}const Di=g(`ZodArray`,(e,t)=>{ln.init(e,t),U.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(B(t,n)),e.nonempty=t=>e.check(B(1,t)),e.max=(t,n)=>e.check(wr(t,n)),e.length=(t,n)=>e.check(Tr(t,n)),e.unwrap=()=>e.element});function Oi(e,t){return Ir(Di,e,t)}const ki=g(`ZodObject`,(e,t)=>{dn.init(e,t),U.init(e,t),C(e,`shape`,()=>t.shape),e.keyof=()=>Q(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Y()}),e.loose=()=>e.clone({...e._zod.def,catchall:Y()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ei()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>he(e,t),e.merge=t=>ge(e,t),e.pick=t=>pe(e,t),e.omit=t=>me(e,t),e.partial=(...t)=>_e(Hi,e,t[0]),e.required=(...t)=>ve(Xi,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return se(this,`shape`,{...e}),this.shape},...k(t)};return new ki(n)}const Ai=g(`ZodUnion`,(e,t)=>{pn.init(e,t),U.init(e,t),e.options=t.options});function ji(e,t){return new Ai({type:`union`,options:e,...k(t)})}const Mi=g(`ZodDiscriminatedUnion`,(e,t)=>{Ai.init(e,t),mn.init(e,t)});function Ni(e,t,n){return new Mi({type:`union`,options:t,discriminator:e,...k(n)})}const Pi=g(`ZodIntersection`,(e,t)=>{hn.init(e,t),U.init(e,t)});function Fi(e,t){return new Pi({type:`intersection`,left:e,right:t})}const Ii=g(`ZodRecord`,(e,t)=>{vn.init(e,t),U.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new Ii({type:`record`,keyType:e,valueType:t,...k(n)})}const Li=g(`ZodEnum`,(e,t)=>{yn.init(e,t),U.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})}});function Q(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Li({type:`enum`,entries:n,...k(t)})}const Ri=g(`ZodLiteral`,(e,t)=>{bn.init(e,t),U.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function zi(e,t){return new Ri({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const Bi=g(`ZodTransform`,(e,t)=>{xn.init(e,t),U.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(N(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(N(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vi(e){return new Bi({type:`transform`,transform:e})}const Hi=g(`ZodOptional`,(e,t)=>{Sn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Hi({type:`optional`,innerType:e})}const Wi=g(`ZodNullable`,(e,t)=>{Cn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Gi(e){return new Wi({type:`nullable`,innerType:e})}const Ki=g(`ZodDefault`,(e,t)=>{wn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qi(e,t){return new Ki({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Ji=g(`ZodPrefault`,(e,t)=>{En.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Yi(e,t){return new Ji({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Xi=g(`ZodNonOptional`,(e,t)=>{Dn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zi(e,t){return new Xi({type:`nonoptional`,innerType:e,...k(t)})}const Qi=g(`ZodCatch`,(e,t)=>{kn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $i(e,t){return new Qi({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const ea=g(`ZodPipe`,(e,t)=>{An.init(e,t),U.init(e,t),e.in=t.in,e.out=t.out});function ta(e,t){return new ea({type:`pipe`,in:e,out:t})}const na=g(`ZodReadonly`,(e,t)=>{Mn.init(e,t),U.init(e,t)});function ra(e){return new na({type:`readonly`,innerType:e})}const ia=g(`ZodCustom`,(e,t)=>{Pn.init(e,t),U.init(e,t)});function aa(e,t){let n=new F({check:`custom`,...k(t)});return n._zod.check=e,n}function oa(e,t={}){return Lr(ia,e,t)}function sa(e,t){let n=aa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(N(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(N(r))}},e(t.value,t)),t);return n}const ca=25,la=e=>{switch(e){case`list`:return{statusCode:200,description:`The list of records was retrieved.`};case`get`:return{statusCode:200,description:`The record with the given identifier was retrieved.`};case`create`:return{statusCode:201,description:`The record was created successfully.`};case`update`:return{statusCode:200,description:`The record was updated successfully.`};case`delete`:return{statusCode:204,description:`The record was deleted successfully.`};case`custom`:return{statusCode:200,description:`The operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},ua=()=>{let e={400:{statusCode:400,description:`Invalid request.`},401:{statusCode:401,description:`Unauthorized access.`},403:{statusCode:403,description:`Forbidden.`},404:{statusCode:404,description:`Resource not found.`},500:{statusCode:500,description:`Server error while executing the request.`}};return e},da={key:W(),label:W(),required:J().optional().default(!1),secret:J().optional().default(!1),readOnly:J().optional().default(!1),placeholder:W().optional(),description:W().optional(),tooltip:W().optional()},fa=Ni(`type`,[X({...da,type:Q([`text`,`password`])}),X({...da,type:zi(`select`),options:X({value:W(),label:W()}).array()})]),pa=X({operationId:W(),categories:W().array(),operationType:Q([`list`,`get`,`create`,`update`,`delete`,`custom`,`unknown`]),schema:W().optional(),entrypointUrl:W().optional(),entrypointHttpMethod:W().optional(),description:W(),responses:X({statusCode:q(),description:W()}).array().optional(),inputs:X({name:W(),type:W(),required:J(),description:W(),in:W()}).array().optional(),cursor:X({enabled:J(),pageSize:q()}).optional(),compositeIdentifiers:X({enabled:J(),version:q().optional(),fields:X({targetFieldKey:W(),remote:W().optional(),components:W().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:J(),type:Q([`data_sync`]),schedule:W(),description:W(),requestParams:X({fields:W().array().optional(),expand:W().array().optional(),filter:Z(W(),W()).optional()}).optional(),syncFilter:X({name:Q([`updated_after`,`created_after`]),initialLoopbackPeriod:W(),incrementalLoopbackPeriod:W()}).optional()}).array().optional(),fieldConfigs:X({targetFieldKey:W(),alias:W().optional(),expression:W(),type:Q([`string`,`number`,`boolean`,`datetime_string`,`enum`]),custom:J().default(!1),hidden:J().default(!1),enumMapper:X({matcher:Q([`country_alpha2code_by_alpha2code`,`country_alpha3code_by_alpha3code`,`country_code_by_country_code`,`country_name_by_country_name`,`country_name_by_alpha3code`,`country_name_by_alpha2code`,`country_name_by_country_code`,`country_alpha3code_by_alpha2code`,`country_alpha3code_by_country_name`,`country_alpha3code_by_country_code`,`country_alpha2code_by_alpha3code`,`country_alpha2code_by_country_name`,`country_alpha2code_by_country_code`,`country_code_by_alpha2code`,`country_code_by_alpha3code`,`country_code_by_country_name`,`country_subdivisions_by_alpha2code`,`country_subdivision_code_by_subdivision_name`,`country_alpha2code_by_citizenship`,`country_subdivision_name_by_subdivision_code`]).or(X({matchExpression:W(),value:W()}).array())}).optional()}).array().optional(),steps:X({stepId:W(),description:W(),stepFunction:X({functionName:W(),version:W().optional(),parameters:Z(W(),Y())}),condition:W().optional(),ignoreError:J().optional()}).array(),result:W().or(Z(W(),Y())).optional()}),ma=X({StackOne:W(),info:X({title:W(),version:W(),key:W(),description:W().optional()}),baseUrl:W(),authentication:Z(W(),X({type:W(),label:W(),authorization:u.AUTHENTICATION_SCHEMA,environments:X({key:W(),name:W()}).array(),support:X({link:W(),description:W().optional()}),configFields:fa.array().optional(),setupFields:fa.array().optional(),testOperationsIds:W().array().optional()})).array().optional(),operations:pa.array().optional()});function ha(e){try{let t=(0,f.parse)(e),n=ma.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},i=va(n),a={baseUrl:n.baseUrl,authentication:ga(i)},o=Ca(n,a);return r.operations=o,r.authentication=i,(0,d.notMissing)(o)&&(r.categories=_a(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const ga=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,testOperationsIds:o,...s}=r;t[n]=ga(s)}else t[n]=r;return t},_a=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},va=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:i,name:a}=r,{environments:o,...s}=n[e];return t[i]={...s,envKey:i,envName:a},t},{});t[e]=r}return t},ya=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,ba=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,xa=e=>e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`,Sa=e=>{let t={success:la(e.operationType),errors:ua()},n=e.responses?.reduce((e,t)=>{let n=(0,c.isSuccessStatusCode)(t.statusCode);return n?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e},t);return n??t},Ca=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=ya(n),i=ba(n),a=xa(n),o=Sa(n),s=Da(n),c=n.inputs||[];return s.enabled&&c?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`}),e[r??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??`get`,responses:o,cursor:s,compositeIdentifiers:Oa(n),scheduledJobs:ka(n),inputs:c,steps:n.steps.reduce((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{...r.stepFunction.parameters,...Aa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:n.fieldConfigs}:{}}}},e),{}),result:n.result},e},{});return n},wa=(e,t)=>{if(!e.inputs)return{};let n=Ea(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ta=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=W();break;case`number`:n=q();break;case`boolean`:n=J();break;default:n=Ci()}t[e.name]=e.required?n:n.optional()}),X(t)},Ea=e=>{let t=e.filter(e=>e.in===`path`),n=e.filter(e=>e.in===`query`),r=e.filter(e=>e.in===`body`),i=e.filter(e=>e.in===`headers`);return X({path:Ta(t).optional(),query:Ta(n).optional(),body:Ta(r).optional(),headers:Ta(i).optional()})},Da=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ca};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Oa=e=>{if((0,d.isMissing)(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=(0,d.notMissing)(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:u.COMPOSITE_ID_LATEST_VERSION,fields:n}}let t=[];for(let n of e.compositeIdentifiers?.fields??[]){let r=n.components.map(t=>{let n=e.fieldConfigs?.find(e=>e.targetFieldKey===t);return{name:t,alias:n?.alias}});t.push({targetFieldKey:n.targetFieldKey,remote:n.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},ka=e=>{if(!(0,d.isMissing)(e.scheduledJobs))return e.scheduledJobs},Aa=(e,t,n={})=>{if(e===`request`||e===`paginated_request`){let e=[{receivedStatus:500,targetStatus:502}],r=n.customErrors&&Array.isArray(n.customErrors)?n.customErrors:[],i=[...r,...e];return{...t,customErrors:i}}else return{}},ja=e=>{try{let t=[],n=(0,f.parse)(e),r=ma.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=Ma(n.path,e);t.push({line:r,message:n.message,field:n.path.join(`.`)})}),t.length>0?{success:!1,errors:t}:{success:!0}}catch(e){let t=e.message,n=t.match(/at line (\d+)/),r=n?parseInt(n[1],10):1;return{success:!1,errors:[{line:r,message:`The YAML connector file is not valid. Please check the syntax and structure.`,field:void 0}]}}},Ma=(e,t)=>{let n=t.split(`
|
|
26
|
+
})));`),t.write(`newResult[${w(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=T,o=!ie.jitless,s=le,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?un(e,s,t,f):R(e,s,t))):i?un(r,s,t,f):R(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],ee=u.keySet,h=l._zod,te=h.def.type;for(let e of Object.keys(f)){if(ee.has(e))continue;if(te===`never`){m.push(e);continue}let t=h.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>R(t,s,e))):R(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function fn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>M(e,r,v())))}),t}const pn=g(`$ZodUnion`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),C(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),C(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),C(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>S(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>fn(t,n,e,r)):fn(a,n,e,r)}}),mn=g(`$ZodDiscriminatedUnion`,(e,t)=>{pn.init(e,t);let n=e._zod.parse;C(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=b(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!T(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),hn=g(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>_n(e,t,n)):_n(e,i,a)}});function gn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(E(e)&&E(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=gn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=gn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _n(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;let r=gn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const vn=g(`$ZodRecord`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!E(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...j(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...j(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>M(e,r,v())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...j(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...j(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),yn=g(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=ae(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>ue.has(typeof e)).map(e=>typeof e==`string`?D(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),bn=g(`$ZodLiteral`,(e,t)=>{I.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?D(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),xn=g(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new _;return e.value=r,e}}),Sn=g(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Cn=g(`$ZodNullable`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)}|null)$`):void 0}),C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wn=g(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Tn(e,t)):Tn(r,t)}});function Tn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const En=g(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Dn=g(`$ZodNonOptional`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>On(t,e)):On(i,e)}});function On(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const kn=g(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)}}),An=g(`$ZodPipe`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>t.in._zod.values),C(e._zod,`optin`,()=>t.in._zod.optin),C(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jn(e,t,n)):jn(r,t,n)}});function jn(e,t,n){return A(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Mn=g(`$ZodReadonly`,(e,t)=>{I.init(e,t),C(e._zod,`propValues`,()=>t.innerType._zod.propValues),C(e._zod,`values`,()=>t.innerType._zod.values),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Nn):Nn(r)}});function Nn(e){return e.value=Object.freeze(e.value),e}const Pn=g(`$ZodCustom`,(e,t)=>{F.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fn(t,n,r,e));Fn(i,n,r,e)}});function Fn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}const In=Symbol(`ZodOutput`),Ln=Symbol(`ZodInput`);var Rn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function zn(){return new Rn}const z=zn();function Bn(e,t){return new e({type:`string`,...k(t)})}function Vn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Hn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Un(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function Wn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function Gn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function Kn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function qn(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function Jn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Yn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function Xn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Zn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Qn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function $n(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function er(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function tr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function nr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function rr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function ir(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function ar(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function or(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function lr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function ur(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function fr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function pr(e,t){return new e({type:`number`,checks:[],...k(t)})}function mr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function hr(e,t){return new e({type:`boolean`,...k(t)})}function gr(e){return new e({type:`any`})}function _r(e){return new e({type:`unknown`})}function vr(e,t){return new e({type:`never`,...k(t)})}function yr(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!1})}function br(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!0})}function xr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!1})}function Sr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Cr(e,t){return new pt({check:`multiple_of`,...k(t),value:e})}function wr(e,t){let n=new ht({check:`max_length`,...k(t),maximum:e});return n}function B(e,t){return new gt({check:`min_length`,...k(t),minimum:e})}function Tr(e,t){return new _t({check:`length_equals`,...k(t),length:e})}function Er(e,t){return new yt({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Dr(e){return new bt({check:`string_format`,format:`lowercase`,...k(e)})}function Or(e){return new xt({check:`string_format`,format:`uppercase`,...k(e)})}function kr(e,t){return new St({check:`string_format`,format:`includes`,...k(t),includes:e})}function Ar(e,t){return new Ct({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function jr(e,t){return new wt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function V(e){return new Tt({check:`overwrite`,tx:e})}function Mr(e){return V(t=>t.normalize(e))}function Nr(){return V(e=>e.trim())}function Pr(){return V(e=>e.toLowerCase())}function Fr(){return V(e=>e.toUpperCase())}function Ir(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Lr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...k(n)});return r}const Rr=g(`ZodISODateTime`,(e,t)=>{Bt.init(e,t),G.init(e,t)});function zr(e){return lr(Rr,e)}const Br=g(`ZodISODate`,(e,t)=>{Vt.init(e,t),G.init(e,t)});function Vr(e){return ur(Br,e)}const Hr=g(`ZodISOTime`,(e,t)=>{Ht.init(e,t),G.init(e,t)});function Ur(e){return dr(Hr,e)}const Wr=g(`ZodISODuration`,(e,t)=>{Ut.init(e,t),G.init(e,t)});function Gr(e){return fr(Wr,e)}const Kr=(e,t)=>{Se.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>we(e,t)},flatten:{value:t=>Ce(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},qr=g(`ZodError`,Kr),H=g(`ZodError`,Kr,{Parent:Error}),Jr=Te(H),Yr=De(H),Xr=ke(H),Zr=je(H),U=g(`ZodType`,(e,t)=>(I.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>O(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>Jr(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Xr(e,t,n),e.parseAsync=async(t,n)=>Yr(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zr(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(oa(t,n)),e.superRefine=t=>e.check(sa(t)),e.overwrite=t=>e.check(V(t)),e.optional=()=>Ui(e),e.nullable=()=>Gi(e),e.nullish=()=>Ui(Gi(e)),e.nonoptional=t=>Zi(e,t),e.array=()=>Oi(e),e.or=t=>ji([e,t]),e.and=t=>Fi(e,t),e.transform=t=>ta(e,Vi(t)),e.default=t=>qi(e,t),e.prefault=t=>Yi(e,t),e.catch=t=>$i(e,t),e.pipe=t=>ta(e,t),e.readonly=()=>ra(e),e.describe=t=>{let n=e.clone();return z.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return z.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return z.get(e);let n=e.clone();return z.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Qr=g(`_ZodString`,(e,t)=>{Ot.init(e,t),U.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Er(...t)),e.includes=(...t)=>e.check(kr(...t)),e.startsWith=(...t)=>e.check(Ar(...t)),e.endsWith=(...t)=>e.check(jr(...t)),e.min=(...t)=>e.check(B(...t)),e.max=(...t)=>e.check(wr(...t)),e.length=(...t)=>e.check(Tr(...t)),e.nonempty=(...t)=>e.check(B(1,...t)),e.lowercase=t=>e.check(Dr(t)),e.uppercase=t=>e.check(Or(t)),e.trim=()=>e.check(Nr()),e.normalize=(...t)=>e.check(Mr(...t)),e.toLowerCase=()=>e.check(Pr()),e.toUpperCase=()=>e.check(Fr())}),$r=g(`ZodString`,(e,t)=>{Ot.init(e,t),Qr.init(e,t),e.email=t=>e.check(Vn(ei,t)),e.url=t=>e.check(qn(ni,t)),e.jwt=t=>e.check(cr(_i,t)),e.emoji=t=>e.check(Jn(ri,t)),e.guid=t=>e.check(Hn(ti,t)),e.uuid=t=>e.check(Un(K,t)),e.uuidv4=t=>e.check(Wn(K,t)),e.uuidv6=t=>e.check(Gn(K,t)),e.uuidv7=t=>e.check(Kn(K,t)),e.nanoid=t=>e.check(Yn(ii,t)),e.guid=t=>e.check(Hn(ti,t)),e.cuid=t=>e.check(Xn(ai,t)),e.cuid2=t=>e.check(Zn(oi,t)),e.ulid=t=>e.check(Qn(si,t)),e.base64=t=>e.check(ar(mi,t)),e.base64url=t=>e.check(or(hi,t)),e.xid=t=>e.check($n(ci,t)),e.ksuid=t=>e.check(er(li,t)),e.ipv4=t=>e.check(tr(ui,t)),e.ipv6=t=>e.check(nr(di,t)),e.cidrv4=t=>e.check(rr(fi,t)),e.cidrv6=t=>e.check(ir(pi,t)),e.e164=t=>e.check(sr(gi,t)),e.datetime=t=>e.check(zr(t)),e.date=t=>e.check(Vr(t)),e.time=t=>e.check(Ur(t)),e.duration=t=>e.check(Gr(t))});function W(e){return Bn($r,e)}const G=g(`ZodStringFormat`,(e,t)=>{L.init(e,t),Qr.init(e,t)}),ei=g(`ZodEmail`,(e,t)=>{jt.init(e,t),G.init(e,t)}),ti=g(`ZodGUID`,(e,t)=>{kt.init(e,t),G.init(e,t)}),K=g(`ZodUUID`,(e,t)=>{At.init(e,t),G.init(e,t)}),ni=g(`ZodURL`,(e,t)=>{Mt.init(e,t),G.init(e,t)}),ri=g(`ZodEmoji`,(e,t)=>{Nt.init(e,t),G.init(e,t)}),ii=g(`ZodNanoID`,(e,t)=>{Pt.init(e,t),G.init(e,t)}),ai=g(`ZodCUID`,(e,t)=>{Ft.init(e,t),G.init(e,t)}),oi=g(`ZodCUID2`,(e,t)=>{It.init(e,t),G.init(e,t)}),si=g(`ZodULID`,(e,t)=>{Lt.init(e,t),G.init(e,t)}),ci=g(`ZodXID`,(e,t)=>{Rt.init(e,t),G.init(e,t)}),li=g(`ZodKSUID`,(e,t)=>{zt.init(e,t),G.init(e,t)}),ui=g(`ZodIPv4`,(e,t)=>{Wt.init(e,t),G.init(e,t)}),di=g(`ZodIPv6`,(e,t)=>{Gt.init(e,t),G.init(e,t)}),fi=g(`ZodCIDRv4`,(e,t)=>{Kt.init(e,t),G.init(e,t)}),pi=g(`ZodCIDRv6`,(e,t)=>{qt.init(e,t),G.init(e,t)}),mi=g(`ZodBase64`,(e,t)=>{Yt.init(e,t),G.init(e,t)}),hi=g(`ZodBase64URL`,(e,t)=>{Zt.init(e,t),G.init(e,t)}),gi=g(`ZodE164`,(e,t)=>{Qt.init(e,t),G.init(e,t)}),_i=g(`ZodJWT`,(e,t)=>{en.init(e,t),G.init(e,t)}),vi=g(`ZodNumber`,(e,t)=>{tn.init(e,t),U.init(e,t),e.gt=(t,n)=>e.check(xr(t,n)),e.gte=(t,n)=>e.check(Sr(t,n)),e.min=(t,n)=>e.check(Sr(t,n)),e.lt=(t,n)=>e.check(yr(t,n)),e.lte=(t,n)=>e.check(br(t,n)),e.max=(t,n)=>e.check(br(t,n)),e.int=t=>e.check(bi(t)),e.safe=t=>e.check(bi(t)),e.positive=t=>e.check(xr(0,t)),e.nonnegative=t=>e.check(Sr(0,t)),e.negative=t=>e.check(yr(0,t)),e.nonpositive=t=>e.check(br(0,t)),e.multipleOf=(t,n)=>e.check(Cr(t,n)),e.step=(t,n)=>e.check(Cr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function q(e){return pr(vi,e)}const yi=g(`ZodNumberFormat`,(e,t)=>{nn.init(e,t),vi.init(e,t)});function bi(e){return mr(yi,e)}const xi=g(`ZodBoolean`,(e,t)=>{rn.init(e,t),U.init(e,t)});function J(e){return hr(xi,e)}const Si=g(`ZodAny`,(e,t)=>{an.init(e,t),U.init(e,t)});function Ci(){return gr(Si)}const wi=g(`ZodUnknown`,(e,t)=>{on.init(e,t),U.init(e,t)});function Y(){return _r(wi)}const Ti=g(`ZodNever`,(e,t)=>{sn.init(e,t),U.init(e,t)});function Ei(e){return vr(Ti,e)}const Di=g(`ZodArray`,(e,t)=>{ln.init(e,t),U.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(B(t,n)),e.nonempty=t=>e.check(B(1,t)),e.max=(t,n)=>e.check(wr(t,n)),e.length=(t,n)=>e.check(Tr(t,n)),e.unwrap=()=>e.element});function Oi(e,t){return Ir(Di,e,t)}const ki=g(`ZodObject`,(e,t)=>{dn.init(e,t),U.init(e,t),C(e,`shape`,()=>t.shape),e.keyof=()=>Q(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Y()}),e.loose=()=>e.clone({...e._zod.def,catchall:Y()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ei()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>he(e,t),e.merge=t=>ge(e,t),e.pick=t=>pe(e,t),e.omit=t=>me(e,t),e.partial=(...t)=>_e(Hi,e,t[0]),e.required=(...t)=>ve(Xi,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return se(this,`shape`,{...e}),this.shape},...k(t)};return new ki(n)}const Ai=g(`ZodUnion`,(e,t)=>{pn.init(e,t),U.init(e,t),e.options=t.options});function ji(e,t){return new Ai({type:`union`,options:e,...k(t)})}const Mi=g(`ZodDiscriminatedUnion`,(e,t)=>{Ai.init(e,t),mn.init(e,t)});function Ni(e,t,n){return new Mi({type:`union`,options:t,discriminator:e,...k(n)})}const Pi=g(`ZodIntersection`,(e,t)=>{hn.init(e,t),U.init(e,t)});function Fi(e,t){return new Pi({type:`intersection`,left:e,right:t})}const Ii=g(`ZodRecord`,(e,t)=>{vn.init(e,t),U.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new Ii({type:`record`,keyType:e,valueType:t,...k(n)})}const Li=g(`ZodEnum`,(e,t)=>{yn.init(e,t),U.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})}});function Q(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Li({type:`enum`,entries:n,...k(t)})}const Ri=g(`ZodLiteral`,(e,t)=>{bn.init(e,t),U.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function zi(e,t){return new Ri({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const Bi=g(`ZodTransform`,(e,t)=>{xn.init(e,t),U.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(N(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(N(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vi(e){return new Bi({type:`transform`,transform:e})}const Hi=g(`ZodOptional`,(e,t)=>{Sn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Hi({type:`optional`,innerType:e})}const Wi=g(`ZodNullable`,(e,t)=>{Cn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Gi(e){return new Wi({type:`nullable`,innerType:e})}const Ki=g(`ZodDefault`,(e,t)=>{wn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qi(e,t){return new Ki({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Ji=g(`ZodPrefault`,(e,t)=>{En.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Yi(e,t){return new Ji({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Xi=g(`ZodNonOptional`,(e,t)=>{Dn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zi(e,t){return new Xi({type:`nonoptional`,innerType:e,...k(t)})}const Qi=g(`ZodCatch`,(e,t)=>{kn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $i(e,t){return new Qi({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const ea=g(`ZodPipe`,(e,t)=>{An.init(e,t),U.init(e,t),e.in=t.in,e.out=t.out});function ta(e,t){return new ea({type:`pipe`,in:e,out:t})}const na=g(`ZodReadonly`,(e,t)=>{Mn.init(e,t),U.init(e,t)});function ra(e){return new na({type:`readonly`,innerType:e})}const ia=g(`ZodCustom`,(e,t)=>{Pn.init(e,t),U.init(e,t)});function aa(e,t){let n=new F({check:`custom`,...k(t)});return n._zod.check=e,n}function oa(e,t={}){return Lr(ia,e,t)}function sa(e,t){let n=aa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(N(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(N(r))}},e(t.value,t)),t);return n}const ca=25,la=e=>{switch(e){case`list`:return{statusCode:200,description:`The list of records was retrieved.`};case`get`:return{statusCode:200,description:`The record with the given identifier was retrieved.`};case`create`:return{statusCode:201,description:`The record was created successfully.`};case`update`:return{statusCode:200,description:`The record was updated successfully.`};case`delete`:return{statusCode:204,description:`The record was deleted successfully.`};case`custom`:return{statusCode:200,description:`The operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},ua=()=>{let e={400:{statusCode:400,description:`Invalid request.`},401:{statusCode:401,description:`Unauthorized access.`},403:{statusCode:403,description:`Forbidden.`},404:{statusCode:404,description:`Resource not found.`},500:{statusCode:500,description:`Server error while executing the request.`}};return e},da={key:W(),label:W(),required:J().optional().default(!1),secret:J().optional().default(!1),readOnly:J().optional().default(!1),placeholder:W().optional(),description:W().optional(),tooltip:W().optional()},fa=Ni(`type`,[X({...da,type:Q([`text`,`password`])}),X({...da,type:zi(`select`),options:X({value:W(),label:W()}).array()})]),pa=X({operationId:W(),categories:W().array(),operationType:Q([`list`,`get`,`create`,`update`,`delete`,`custom`,`unknown`]),schema:W().optional(),entrypointUrl:W().optional(),entrypointHttpMethod:W().optional(),description:W(),responses:X({statusCode:q(),description:W()}).array().optional(),inputs:X({name:W(),type:W(),required:J(),description:W(),in:W()}).array().optional(),cursor:X({enabled:J(),pageSize:q()}).optional(),compositeIdentifiers:X({enabled:J(),version:q().optional(),fields:X({targetFieldKey:W(),remote:W().optional(),components:W().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:J(),type:Q([`data_sync`]),schedule:W(),description:W(),requestParams:X({fields:W().array().optional(),expand:W().array().optional(),filter:Z(W(),W()).optional()}).optional(),syncFilter:X({name:Q([`updated_after`,`created_after`]),initialLoopbackPeriod:W(),incrementalLoopbackPeriod:W()}).optional()}).array().optional(),fieldConfigs:X({targetFieldKey:W(),alias:W().optional(),expression:W(),type:Q([`string`,`number`,`boolean`,`datetime_string`,`enum`]),custom:J().default(!1),hidden:J().default(!1),enumMapper:X({matcher:Q([`country_alpha2code_by_alpha2code`,`country_alpha3code_by_alpha3code`,`country_code_by_country_code`,`country_name_by_country_name`,`country_name_by_alpha3code`,`country_name_by_alpha2code`,`country_name_by_country_code`,`country_alpha3code_by_alpha2code`,`country_alpha3code_by_country_name`,`country_alpha3code_by_country_code`,`country_alpha2code_by_alpha3code`,`country_alpha2code_by_country_name`,`country_alpha2code_by_country_code`,`country_code_by_alpha2code`,`country_code_by_alpha3code`,`country_code_by_country_name`,`country_subdivisions_by_alpha2code`,`country_subdivision_code_by_subdivision_name`,`country_alpha2code_by_citizenship`,`country_subdivision_name_by_subdivision_code`]).or(X({matchExpression:W(),value:W()}).array())}).optional()}).array().optional(),steps:X({stepId:W(),description:W(),stepFunction:X({functionName:W(),version:W().optional(),parameters:Z(W(),Y())}),condition:W().optional(),ignoreError:J().optional()}).array(),result:W().or(Z(W(),Y())).optional()}),ma=X({StackOne:W(),info:X({title:W(),version:W(),key:W(),assets:X({icon:W()}),description:W().optional()}),baseUrl:W(),authentication:Z(W(),X({type:W(),label:W(),authorization:u.AUTHENTICATION_SCHEMA,environments:X({key:W(),name:W()}).array(),support:X({link:W(),description:W().optional()}),configFields:fa.array().optional(),setupFields:fa.array().optional(),testOperationsIds:W().array().optional()})).array().optional(),operations:pa.array().optional()});function ha(e){try{let t=(0,f.parse)(e),n=ma.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description},i=va(n),a={baseUrl:n.baseUrl,authentication:ga(i)},o=Ca(n,a);return r.operations=o,r.authentication=i,(0,d.notMissing)(o)&&(r.categories=_a(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const ga=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,testOperationsIds:o,...s}=r;t[n]=ga(s)}else t[n]=r;return t},_a=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},va=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:i,name:a}=r,{environments:o,...s}=n[e];return t[i]={...s,envKey:i,envName:a},t},{});t[e]=r}return t},ya=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,ba=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,xa=e=>e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`,Sa=e=>{let t={success:la(e.operationType),errors:ua()},n=e.responses?.reduce((e,t)=>{let n=(0,c.isSuccessStatusCode)(t.statusCode);return n?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e},t);return n??t},Ca=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=ya(n),i=ba(n),a=xa(n),o=Sa(n),s=Da(n),c=n.inputs||[];return s.enabled&&c?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`}),e[r??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??`get`,responses:o,cursor:s,compositeIdentifiers:Oa(n),scheduledJobs:ka(n),inputs:c,steps:n.steps.reduce((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{...r.stepFunction.parameters,...Aa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:n.fieldConfigs}:{}}}},e),{}),result:n.result},e},{});return n},wa=(e,t)=>{if(!e.inputs)return{};let n=Ea(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ta=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=W();break;case`number`:n=q();break;case`boolean`:n=J();break;default:n=Ci()}t[e.name]=e.required?n:n.optional()}),X(t)},Ea=e=>{let t=e.filter(e=>e.in===`path`),n=e.filter(e=>e.in===`query`),r=e.filter(e=>e.in===`body`),i=e.filter(e=>e.in===`headers`);return X({path:Ta(t).optional(),query:Ta(n).optional(),body:Ta(r).optional(),headers:Ta(i).optional()})},Da=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ca};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Oa=e=>{if((0,d.isMissing)(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=(0,d.notMissing)(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:u.COMPOSITE_ID_LATEST_VERSION,fields:n}}let t=[];for(let n of e.compositeIdentifiers?.fields??[]){let r=n.components.map(t=>{let n=e.fieldConfigs?.find(e=>e.targetFieldKey===t);return{name:t,alias:n?.alias}});t.push({targetFieldKey:n.targetFieldKey,remote:n.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},ka=e=>{if(!(0,d.isMissing)(e.scheduledJobs))return e.scheduledJobs},Aa=(e,t,n={})=>{if(e===`request`||e===`paginated_request`){let e=[{receivedStatus:500,targetStatus:502}],r=n.customErrors&&Array.isArray(n.customErrors)?n.customErrors:[],i=[...r,...e];return{...t,customErrors:i}}else return{}},ja=e=>{try{let t=[],n=(0,f.parse)(e),r=ma.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=Ma(n.path,e);t.push({line:r,message:n.message,field:n.path.join(`.`)})}),t.length>0?{success:!1,errors:t}:{success:!0}}catch(e){let t=e.message,n=t.match(/at line (\d+)/),r=n?parseInt(n[1],10):1;return{success:!1,errors:[{line:r,message:`The YAML connector file is not valid. Please check the syntax and structure.`,field:void 0}]}}},Ma=(e,t)=>{let n=t.split(`
|
|
27
27
|
`),r=0,i=-1,a=0;for(let t=0;t<n.length;t++){let o=n[t],s=o.match(/^(\s*)/)?.[1]?.length||0,c=o.replace(`- `,``).trim();if(c.startsWith(`#`)||c===``||s<=i)continue;let l=(0,d.notMissing)(e[r])?`${String(e[r])}`:``;if((0,d.isMissing)(l))return a+1;if(isNaN(Number(l))){if(c.startsWith(`${l}:`)){if(r===e.length-1)return t+1;i=s,a=t,r++}}else{let e=parseInt(l,10),i=-1;for(let o=t;o<n.length;o++){let s=n[o],c=s.trim();if(c.startsWith(`-`)&&i++,i===e){r++,a=t,t--;break}else t++}}}return a+1};var $=class e extends Error{errorType;context;constructor(t,n,r){super(r),this.name=`ConnectSDKError`,this.errorType=t,this.context=n,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}},Na=class extends ${constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},Pa=class extends ${constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},Fa=class extends ${constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},Ia=class extends ${constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const La=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=u.StepFunctionsFactory.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===u.StepFunctionName.MAP_FIELDS?{[u.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},Ra=({category:e,connectorKey:t,connectorVersion:n,authConfigKey:r,environment:i=`production`,operation:a,accountSecureId:o,projectSecureId:s})=>({projectSecureId:s,accountSecureId:o,connectorKey:t,connectorVersion:n,category:e,service:``,resource:``,schema:a?.schema?.key,operationType:a?.operationType??`unknown`,authenticationType:r,environment:i}),za=e=>{let t=e.operation?.compositeIdentifiers,n={...e.inputs??{}};if(!t?.enabled||(0,d.isMissing)(n))return e;let r=t.fields?.reduce((e,t)=>(t.components.forEach(t=>{t.alias&&(e[t.name]=t.alias)}),e),{}),i={version:t.version??u.COMPOSITE_ID_LATEST_VERSION,aliases:r};return Ba(n,i,e.logger),{...e,inputs:n}},Ba=(e,t,n)=>{for(let r in e){let i=e[r];if(typeof i==`string`||Array.isArray(i)&&i.every(e=>typeof e==`string`))Ka(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)Ba(e,t,n);else typeof i==`object`&&i&&Ba(i,t,n)}},Va=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=(0,u.decodeCompositeId)(o,n);i.push(e)}catch(e){r?.debug({message:`Received ${t} with invalid composite ID, assuming it is not a composite ID`,category:`processCompositeId`,context:{key:t,inputElement:o,compositeIdentifierConfig:n,error:e}}),a.push(o)}return{compositeIdComponents:i,nonCompositeIds:a}},Ha=(e,t,n,r)=>{let i=n.filter(e=>Object.keys(e).length>1);i.length>0&&(e.decoded_ids={...e.decoded_ids??{},[t]:r?i:i[0]})},Ua=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},Wa=(e,t,n,r,i)=>{n.every(Ua)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},Ga=(e,t,n)=>{e instanceof u.CoreError&&e.type===`COMPOSITE_ID_MISSING_HEADER_ERROR`?n?.debug({message:`Received ${t} with no composite ID header, assuming it is not a composite ID`}):n?.warning({message:`Error processing composite ID for ${t}, ignoring it`,error:e})},Ka=(e,t,n,r,i)=>{try{let a=Array.isArray(e),o=a?e:[e];if(o.length===0)return;let{compositeIdComponents:s,nonCompositeIds:c}=Va(o,t,r,i);Ha(n,t,s,a),Wa(n,t,s,c,a)}catch(e){Ga(e,t,i)}},qa=`remote_`,Ja=e=>{let t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;let n=`data`,r=e.outputs?.[n];if((0,d.isMissing)(r))return e;let i=Array.isArray(r)?r.map(e=>Ya(e,t)):Ya(r,t);return{...e,outputs:{...e.outputs??{},[n]:i}}},Ya=(e,t)=>{let n=Xa(e,t),r=io(n);return{...e,...(0,d.isObject)(r)?r:{}}},Xa=(e,t)=>{let n=t.version??u.COMPOSITE_ID_LATEST_VERSION,r={};return t.fields?.forEach(t=>{let i={},a=[];t.components.forEach(t=>{t.alias&&(i[t.name]=t.alias),a.push({key:t.name,value:e[t.name]})});let o=a.length===1?a[0]:{identifiers:a},s={version:n,aliases:Object.keys(i).length>0?i:void 0},c=(0,u.encodeCompositeId)(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${qa}${t.remote}`]=e[t.remote])}),{...e,...r}},Za=e=>e===`id`||/.+_id(s)?$/.test(e),Qa=e=>Array.isArray(e)&&e.every(e=>(0,d.isString)(e)&&e.length>0),$a=(e,t)=>(0,u.isCompositeId)(e)||t.startsWith(qa),eo=(e,t)=>{try{return(0,u.encodeCompositeId)({key:e,value:t},{version:u.COMPOSITE_ID_LATEST_VERSION})}catch{return t}},to=(e,t,n)=>{let r=t.map(t=>(0,d.isString)(t)&&t.length>0&&!(0,u.isCompositeId)(t)?eo(e,t):t);n[e]=r,n[`${qa}${e}`]=t},no=(e,t,n)=>{if($a(t,e))return;let r=(0,u.encodeCompositeId)({key:e,value:t},{version:u.COMPOSITE_ID_LATEST_VERSION});n[e]=r,n[`remote_${e}`]=t},ro=(e,t,n)=>{Qa(t)?to(e,t,n):(0,d.isString)(t)&&t.length>0&&no(e,t,n)},io=e=>{if(Array.isArray(e))return e.map(e=>io(e));if(!(0,d.isObject)(e))return e;let t={...e};for(let[n,r]of Object.entries(e))((0,d.isObject)(r)||Array.isArray(r)&&r.length>0&&(0,d.isObject)(r[0]))&&(t[n]=io(r)),Za(n)&&ro(n,r,t);return t},ao=(e,t)=>{let n=Number(e.inputs?.page_size),r=(0,d.notMissing)(e.inputs?.page_size)&&(0,d.isNumber)(n)&&!Number.isNaN(n)?n:e.operation?.cursor?.pageSize??t;return r},oo=(e,t,n,r)=>{let i=(0,d.isMissing)(e)?void 0:e.data,a=Object.keys(n).length+1,o=(0,u.isCursorEmpty)({cursor:r,ignoreStepIndex:a});if(!(0,d.isObject)(e)||(0,d.isMissing)(i)||(i?.length??0)<=t)return{result:e,next:(0,d.notMissing)(r)&&!o?(0,u.minifyCursor)(r):null};let s=r?.remote?.[a]?.pageNumber??1,c=(s-1)*t,l=c+t,f=i.slice(c,l),p=i.length>l||!o,m=(0,u.updateCursor)({cursor:r,stepIndex:a,pageNumber:s+1});return{result:{...e,data:f},next:p?(0,u.minifyCursor)(m):null}},so=async({block:e,buildStepFunction:t=u.StepFunctionsFactory.build,virtualPaginateResultFn:n=oo,encodeResultCompositeIds:r=Ja,decodeInputCompositeIds:i=za})=>{let a=i(e),o=await mo({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},co=(e,t)=>e.condition?!(0,p.safeEvaluate)(e.condition,t):!1,lo=(e,t,n)=>{let r=e.stepFunction;return t.operation?.cursor.enabled?{...r.params??{},cursor:{token:t.nextCursor?.remote?.[n]?.providerPageCursor,position:t.nextCursor?.remote?.[n]?.position}}:r.params??{}},uo=(e,t,n,r,i)=>{let a=go({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},fo=async(e,t,n,r,i,a)=>{let o=n[e],s=o.stepFunction,c=a.buildStepFunction({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(co(o,r))return go({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return go({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=lo(o,r,t),d=await c({block:r,params:l});if(d.successful===!1)return uo(r,e,d,o,i);let f=r.operation?.cursor.enabled?(0,u.updateCursor)({cursor:r.nextCursor,stepIndex:t,providerPageCursor:d.output?.next,position:d.output?.position}):void 0;return go({block:{...d.block,nextCursor:f},stepId:e,functionOutput:d})},po=(e,t,n,r,i)=>{let a=!n.hasFatalError,o=a?e.operation?.responses.success.statusCode??200:n.errorStatusCode??500,s=(0,d.notMissing)(i)&&(0,d.isObject)(i.result)?{next:i.next,...i.result}:r;return{...t,outputs:s,response:{successful:a,statusCode:o,message:a?void 0:e.operation?.responses?.errors?.[o]?.description??c.HttpErrorMessages?.[o]??`Error while processing the request`}}},mo=async({block:e,buildStepFunction:t=u.StepFunctionsFactory.build,virtualPaginateResultFn:n=oo})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=ao(e,ca),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await fo(t,e,r,i,s,c);let l=e.operation?.result?ho(e.operation.result,i):void 0,d=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return po(e,i,s,l,d)},ho=(e,t)=>(0,d.isObject)(e)?(0,p.safeEvaluateRecord)(e,t):(0,p.safeEvaluate)(e,t),go=({block:e,stepId:t,successful:n,functionOutput:r,skipped:i,message:a})=>({...e,steps:{...e.steps,[t]:{successful:n??r?.successful??!1,errors:r?.errors,output:r?.output,skipped:i,message:a}}}),_o=async({account:e,connector:t,category:n,path:r,method:i=`get`,queryParams:a,body:o,headers:s,logger:c,parseConnector:l=ha,getOperationFromUrlFn:u=ee,parseOperationInputsFn:f=wa,createBlockContextFn:p=Ra,createBlockFn:h=m,runStepOperationFn:te=so})=>{let ne=e.authConfigKey,g=e.environment??`production`,re=e.secureId,_=e.projectSecureId,ie=e.credentials,v=p({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:ne,environment:g,accountSecureId:re,projectSecureId:_}),ae;try{ae=(0,d.isString)(t)?l(t):t}catch{throw new Na(v,`Error while parsing connector`)}let y=u(ae,r,i);if((0,d.isMissing)(y))throw new Pa(v,`No matching operation found`);v.operationType=y.operation.operationType,v.schema=y.operation.schema?.key;let b=vo(a,v),x;try{x=f(y.operation,{query:a,body:o,headers:s,path:y.params})}catch{throw new Fa(v,`Error while parsing operation inputs`)}let S=await h({inputs:x,context:v,operation:y.operation,credentials:ie,nextCursor:b,logger:c});return await te({block:S})},vo=(e,t)=>{let n=e?.next,r=(0,d.notMissing)(n)&&t.operationType===`list`?(0,u.expandCursor)(n):void 0;if(r===null)throw new Ia(t,`Invalid cursor.`);return r};exports.ConnectSDKError=$,exports.createBlock=m,exports.executeStepFunction=La,exports.getOperationFromUrl=ee,exports.parseOperationInputs=wa,exports.parseYamlConnector=ha,exports.runConnectorOperation=_o,exports.runStepOperation=so,exports.validateYamlConnector=ja;
|
package/dist/index.mjs
CHANGED
|
@@ -23,5 +23,5 @@ import{HttpClientManager as e,HttpErrorMessages as t,isSuccessStatusCode as n}fr
|
|
|
23
23
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
25
25
|
path: iss.path ? [${E(e)}, ...iss.path] : [${E(e)}]
|
|
26
|
-
})));`),t.write(`newResult[${E(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=_e,o=!ce.jitless,s=ve,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?yn(e,s,t,f):z(e,s,t))):i?yn(r,s,t,f):z(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,ee=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(ee===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>z(t,s,e))):z(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function xn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>N(e,r,w())))}),t}const Sn=S(`$ZodUnion`,(e,t)=>{L.init(e,t),T(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),T(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>pe(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>xn(t,n,e,r)):xn(a,n,e,r)}}),Cn=S(`$ZodDiscriminatedUnion`,(e,t)=>{Sn.init(e,t);let n=e._zod.parse;T(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=de(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!_e(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),wn=S(`$ZodIntersection`,(e,t)=>{L.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>En(e,t,n)):En(e,i,a)}});function Tn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ye(e)&&ye(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Tn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Tn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function En(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;let r=Tn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Dn=S(`$ZodRecord`,(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ye(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...j(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...j(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>N(e,r,w())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...j(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...j(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),On=S(`$ZodEnum`,(e,t)=>{L.init(e,t);let n=le(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>be.has(typeof e)).map(e=>typeof e==`string`?D(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),kn=S(`$ZodLiteral`,(e,t)=>{L.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?D(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),An=S(`$ZodTransform`,(e,t)=>{L.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new C;return e.value=r,e}}),jn=S(`$ZodOptional`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pe(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Mn=S(`$ZodNullable`,(e,t)=>{L.init(e,t),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pe(e.source)}|null)$`):void 0}),T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Nn=S(`$ZodDefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Pn(e,t)):Pn(r,t)}});function Pn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Fn=S(`$ZodPrefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),In=S(`$ZodNonOptional`,(e,t)=>{L.init(e,t),T(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ln(t,e)):Ln(i,e)}});function Ln(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Rn=S(`$ZodCatch`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>N(e,n,w()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>N(e,n,w()))},input:e.value}),e.issues=[]),e)}}),zn=S(`$ZodPipe`,(e,t)=>{L.init(e,t),T(e._zod,`values`,()=>t.in._zod.values),T(e._zod,`optin`,()=>t.in._zod.optin),T(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t,n)):Bn(r,t,n)}});function Bn(e,t,n){return A(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Vn=S(`$ZodReadonly`,(e,t)=>{L.init(e,t),T(e._zod,`propValues`,()=>t.innerType._zod.propValues),T(e._zod,`values`,()=>t.innerType._zod.values),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hn):Hn(r)}});function Hn(e){return e.value=Object.freeze(e.value),e}const Un=S(`$ZodCustom`,(e,t)=>{F.init(e,t),L.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Wn(t,n,r,e));Wn(i,n,r,e)}});function Wn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(P(e))}}const Gn=Symbol(`ZodOutput`),Kn=Symbol(`ZodInput`);var qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Jn(){return new qn}const B=Jn();function Yn(e,t){return new e({type:`string`,...k(t)})}function Xn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Zn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Qn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function nr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function rr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function ir(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function ar(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function or(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function sr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function cr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function lr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function ur(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function dr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function fr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function pr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function mr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function hr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function gr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function _r(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function vr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function yr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function br(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function xr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Sr(e,t){return new e({type:`number`,checks:[],...k(t)})}function Cr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function wr(e,t){return new e({type:`boolean`,...k(t)})}function Tr(e){return new e({type:`any`})}function Er(e){return new e({type:`unknown`})}function Dr(e,t){return new e({type:`never`,...k(t)})}function Or(e,t){return new xt({check:`less_than`,...k(t),value:e,inclusive:!1})}function kr(e,t){return new xt({check:`less_than`,...k(t),value:e,inclusive:!0})}function Ar(e,t){return new St({check:`greater_than`,...k(t),value:e,inclusive:!1})}function jr(e,t){return new St({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Mr(e,t){return new Ct({check:`multiple_of`,...k(t),value:e})}function Nr(e,t){let n=new Tt({check:`max_length`,...k(t),maximum:e});return n}function V(e,t){return new Et({check:`min_length`,...k(t),minimum:e})}function Pr(e,t){return new Dt({check:`length_equals`,...k(t),length:e})}function Fr(e,t){return new Ot({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Ir(e){return new kt({check:`string_format`,format:`lowercase`,...k(e)})}function Lr(e){return new At({check:`string_format`,format:`uppercase`,...k(e)})}function Rr(e,t){return new jt({check:`string_format`,format:`includes`,...k(t),includes:e})}function zr(e,t){return new Mt({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function Br(e,t){return new Nt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function H(e){return new Pt({check:`overwrite`,tx:e})}function Vr(e){return H(t=>t.normalize(e))}function Hr(){return H(e=>e.trim())}function Ur(){return H(e=>e.toLowerCase())}function Wr(){return H(e=>e.toUpperCase())}function Gr(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Kr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...k(n)});return r}const qr=S(`ZodISODateTime`,(e,t)=>{Yt.init(e,t),K.init(e,t)});function Jr(e){return vr(qr,e)}const Yr=S(`ZodISODate`,(e,t)=>{Xt.init(e,t),K.init(e,t)});function Xr(e){return yr(Yr,e)}const Zr=S(`ZodISOTime`,(e,t)=>{Zt.init(e,t),K.init(e,t)});function Qr(e){return br(Zr,e)}const $r=S(`ZodISODuration`,(e,t)=>{Qt.init(e,t),K.init(e,t)});function ei(e){return xr($r,e)}const ti=(e,t)=>{je.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Pe(e,t)},flatten:{value:t=>Ne(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},ni=S(`ZodError`,ti),U=S(`ZodError`,ti,{Parent:Error}),ri=Fe(U),ii=Le(U),ai=ze(U),oi=Ve(U),W=S(`ZodType`,(e,t)=>(L.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>O(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>ri(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ai(e,t,n),e.parseAsync=async(t,n)=>ii(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>oi(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(_a(t,n)),e.superRefine=t=>e.check(va(t)),e.overwrite=t=>e.check(H(t)),e.optional=()=>ea(e),e.nullable=()=>na(e),e.nullish=()=>ea(na(e)),e.nonoptional=t=>ca(e,t),e.array=()=>Ri(e),e.or=t=>Vi([e,t]),e.and=t=>Gi(e,t),e.transform=t=>fa(e,Qi(t)),e.default=t=>ia(e,t),e.prefault=t=>oa(e,t),e.catch=t=>ua(e,t),e.pipe=t=>fa(e,t),e.readonly=()=>ma(e),e.describe=t=>{let n=e.clone();return B.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return B.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return B.get(e);let n=e.clone();return B.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),si=S(`_ZodString`,(e,t)=>{Lt.init(e,t),W.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Fr(...t)),e.includes=(...t)=>e.check(Rr(...t)),e.startsWith=(...t)=>e.check(zr(...t)),e.endsWith=(...t)=>e.check(Br(...t)),e.min=(...t)=>e.check(V(...t)),e.max=(...t)=>e.check(Nr(...t)),e.length=(...t)=>e.check(Pr(...t)),e.nonempty=(...t)=>e.check(V(1,...t)),e.lowercase=t=>e.check(Ir(t)),e.uppercase=t=>e.check(Lr(t)),e.trim=()=>e.check(Hr()),e.normalize=(...t)=>e.check(Vr(...t)),e.toLowerCase=()=>e.check(Ur()),e.toUpperCase=()=>e.check(Wr())}),ci=S(`ZodString`,(e,t)=>{Lt.init(e,t),si.init(e,t),e.email=t=>e.check(Xn(li,t)),e.url=t=>e.check(nr(di,t)),e.jwt=t=>e.check(_r(Ei,t)),e.emoji=t=>e.check(rr(fi,t)),e.guid=t=>e.check(Zn(ui,t)),e.uuid=t=>e.check(Qn(q,t)),e.uuidv4=t=>e.check($n(q,t)),e.uuidv6=t=>e.check(er(q,t)),e.uuidv7=t=>e.check(tr(q,t)),e.nanoid=t=>e.check(ir(pi,t)),e.guid=t=>e.check(Zn(ui,t)),e.cuid=t=>e.check(ar(mi,t)),e.cuid2=t=>e.check(or(hi,t)),e.ulid=t=>e.check(sr(gi,t)),e.base64=t=>e.check(mr(Ci,t)),e.base64url=t=>e.check(hr(wi,t)),e.xid=t=>e.check(cr(_i,t)),e.ksuid=t=>e.check(lr(vi,t)),e.ipv4=t=>e.check(ur(yi,t)),e.ipv6=t=>e.check(dr(bi,t)),e.cidrv4=t=>e.check(fr(xi,t)),e.cidrv6=t=>e.check(pr(Si,t)),e.e164=t=>e.check(gr(Ti,t)),e.datetime=t=>e.check(Jr(t)),e.date=t=>e.check(Xr(t)),e.time=t=>e.check(Qr(t)),e.duration=t=>e.check(ei(t))});function G(e){return Yn(ci,e)}const K=S(`ZodStringFormat`,(e,t)=>{R.init(e,t),si.init(e,t)}),li=S(`ZodEmail`,(e,t)=>{Bt.init(e,t),K.init(e,t)}),ui=S(`ZodGUID`,(e,t)=>{Rt.init(e,t),K.init(e,t)}),q=S(`ZodUUID`,(e,t)=>{zt.init(e,t),K.init(e,t)}),di=S(`ZodURL`,(e,t)=>{Vt.init(e,t),K.init(e,t)}),fi=S(`ZodEmoji`,(e,t)=>{Ht.init(e,t),K.init(e,t)}),pi=S(`ZodNanoID`,(e,t)=>{Ut.init(e,t),K.init(e,t)}),mi=S(`ZodCUID`,(e,t)=>{Wt.init(e,t),K.init(e,t)}),hi=S(`ZodCUID2`,(e,t)=>{Gt.init(e,t),K.init(e,t)}),gi=S(`ZodULID`,(e,t)=>{Kt.init(e,t),K.init(e,t)}),_i=S(`ZodXID`,(e,t)=>{qt.init(e,t),K.init(e,t)}),vi=S(`ZodKSUID`,(e,t)=>{Jt.init(e,t),K.init(e,t)}),yi=S(`ZodIPv4`,(e,t)=>{$t.init(e,t),K.init(e,t)}),bi=S(`ZodIPv6`,(e,t)=>{en.init(e,t),K.init(e,t)}),xi=S(`ZodCIDRv4`,(e,t)=>{tn.init(e,t),K.init(e,t)}),Si=S(`ZodCIDRv6`,(e,t)=>{nn.init(e,t),K.init(e,t)}),Ci=S(`ZodBase64`,(e,t)=>{an.init(e,t),K.init(e,t)}),wi=S(`ZodBase64URL`,(e,t)=>{sn.init(e,t),K.init(e,t)}),Ti=S(`ZodE164`,(e,t)=>{cn.init(e,t),K.init(e,t)}),Ei=S(`ZodJWT`,(e,t)=>{un.init(e,t),K.init(e,t)}),Di=S(`ZodNumber`,(e,t)=>{dn.init(e,t),W.init(e,t),e.gt=(t,n)=>e.check(Ar(t,n)),e.gte=(t,n)=>e.check(jr(t,n)),e.min=(t,n)=>e.check(jr(t,n)),e.lt=(t,n)=>e.check(Or(t,n)),e.lte=(t,n)=>e.check(kr(t,n)),e.max=(t,n)=>e.check(kr(t,n)),e.int=t=>e.check(ki(t)),e.safe=t=>e.check(ki(t)),e.positive=t=>e.check(Ar(0,t)),e.nonnegative=t=>e.check(jr(0,t)),e.negative=t=>e.check(Or(0,t)),e.nonpositive=t=>e.check(kr(0,t)),e.multipleOf=(t,n)=>e.check(Mr(t,n)),e.step=(t,n)=>e.check(Mr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function J(e){return Sr(Di,e)}const Oi=S(`ZodNumberFormat`,(e,t)=>{fn.init(e,t),Di.init(e,t)});function ki(e){return Cr(Oi,e)}const Ai=S(`ZodBoolean`,(e,t)=>{pn.init(e,t),W.init(e,t)});function Y(e){return wr(Ai,e)}const ji=S(`ZodAny`,(e,t)=>{mn.init(e,t),W.init(e,t)});function Mi(){return Tr(ji)}const Ni=S(`ZodUnknown`,(e,t)=>{hn.init(e,t),W.init(e,t)});function Pi(){return Er(Ni)}const Fi=S(`ZodNever`,(e,t)=>{gn.init(e,t),W.init(e,t)});function Ii(e){return Dr(Fi,e)}const Li=S(`ZodArray`,(e,t)=>{vn.init(e,t),W.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(V(t,n)),e.nonempty=t=>e.check(V(1,t)),e.max=(t,n)=>e.check(Nr(t,n)),e.length=(t,n)=>e.check(Pr(t,n)),e.unwrap=()=>e.element});function Ri(e,t){return Gr(Li,e,t)}const zi=S(`ZodObject`,(e,t)=>{bn.init(e,t),W.init(e,t),T(e,`shape`,()=>t.shape),e.keyof=()=>Z(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pi()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pi()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ii()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Te(e,t),e.merge=t=>Ee(e,t),e.pick=t=>Ce(e,t),e.omit=t=>we(e,t),e.partial=(...t)=>De($i,e,t[0]),e.required=(...t)=>Oe(sa,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return he(this,`shape`,{...e}),this.shape},...k(t)};return new zi(n)}const Bi=S(`ZodUnion`,(e,t)=>{Sn.init(e,t),W.init(e,t),e.options=t.options});function Vi(e,t){return new Bi({type:`union`,options:e,...k(t)})}const Hi=S(`ZodDiscriminatedUnion`,(e,t)=>{Bi.init(e,t),Cn.init(e,t)});function Ui(e,t,n){return new Hi({type:`union`,options:t,discriminator:e,...k(n)})}const Wi=S(`ZodIntersection`,(e,t)=>{wn.init(e,t),W.init(e,t)});function Gi(e,t){return new Wi({type:`intersection`,left:e,right:t})}const Ki=S(`ZodRecord`,(e,t)=>{Dn.init(e,t),W.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function qi(e,t,n){return new Ki({type:`record`,keyType:e,valueType:t,...k(n)})}const Ji=S(`ZodEnum`,(e,t)=>{On.init(e,t),W.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ji({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ji({...t,checks:[],...k(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ji({type:`enum`,entries:n,...k(t)})}const Yi=S(`ZodLiteral`,(e,t)=>{kn.init(e,t),W.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Xi(e,t){return new Yi({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const Zi=S(`ZodTransform`,(e,t)=>{An.init(e,t),W.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(P(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(P(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Qi(e){return new Zi({type:`transform`,transform:e})}const $i=S(`ZodOptional`,(e,t)=>{jn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ea(e){return new $i({type:`optional`,innerType:e})}const ta=S(`ZodNullable`,(e,t)=>{Mn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function na(e){return new ta({type:`nullable`,innerType:e})}const ra=S(`ZodDefault`,(e,t)=>{Nn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ia(e,t){return new ra({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const aa=S(`ZodPrefault`,(e,t)=>{Fn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function oa(e,t){return new aa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const sa=S(`ZodNonOptional`,(e,t)=>{In.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ca(e,t){return new sa({type:`nonoptional`,innerType:e,...k(t)})}const la=S(`ZodCatch`,(e,t)=>{Rn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ua(e,t){return new la({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const da=S(`ZodPipe`,(e,t)=>{zn.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function fa(e,t){return new da({type:`pipe`,in:e,out:t})}const pa=S(`ZodReadonly`,(e,t)=>{Vn.init(e,t),W.init(e,t)});function ma(e){return new pa({type:`readonly`,innerType:e})}const ha=S(`ZodCustom`,(e,t)=>{Un.init(e,t),W.init(e,t)});function ga(e,t){let n=new F({check:`custom`,...k(t)});return n._zod.check=e,n}function _a(e,t={}){return Kr(ha,e,t)}function va(e,t){let n=ga(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(P(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(P(r))}},e(t.value,t)),t);return n}const ya=25,ba=e=>{switch(e){case`list`:return{statusCode:200,description:`The list of records was retrieved.`};case`get`:return{statusCode:200,description:`The record with the given identifier was retrieved.`};case`create`:return{statusCode:201,description:`The record was created successfully.`};case`update`:return{statusCode:200,description:`The record was updated successfully.`};case`delete`:return{statusCode:204,description:`The record was deleted successfully.`};case`custom`:return{statusCode:200,description:`The operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},xa=()=>{let e={400:{statusCode:400,description:`Invalid request.`},401:{statusCode:401,description:`Unauthorized access.`},403:{statusCode:403,description:`Forbidden.`},404:{statusCode:404,description:`Resource not found.`},500:{statusCode:500,description:`Server error while executing the request.`}};return e},Sa={key:G(),label:G(),required:Y().optional().default(!1),secret:Y().optional().default(!1),readOnly:Y().optional().default(!1),placeholder:G().optional(),description:G().optional(),tooltip:G().optional()},Ca=Ui(`type`,[X({...Sa,type:Z([`text`,`password`])}),X({...Sa,type:Xi(`select`),options:X({value:G(),label:G()}).array()})]),wa=X({operationId:G(),categories:G().array(),operationType:Z([`list`,`get`,`create`,`update`,`delete`,`custom`,`unknown`]),schema:G().optional(),entrypointUrl:G().optional(),entrypointHttpMethod:G().optional(),description:G(),responses:X({statusCode:J(),description:G()}).array().optional(),inputs:X({name:G(),type:G(),required:Y(),description:G(),in:G()}).array().optional(),cursor:X({enabled:Y(),pageSize:J()}).optional(),compositeIdentifiers:X({enabled:Y(),version:J().optional(),fields:X({targetFieldKey:G(),remote:G().optional(),components:G().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:Y(),type:Z([`data_sync`]),schedule:G(),description:G(),requestParams:X({fields:G().array().optional(),expand:G().array().optional(),filter:qi(G(),G()).optional()}).optional(),syncFilter:X({name:Z([`updated_after`,`created_after`]),initialLoopbackPeriod:G(),incrementalLoopbackPeriod:G()}).optional()}).array().optional(),fieldConfigs:X({targetFieldKey:G(),alias:G().optional(),expression:G(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`enum`]),custom:Y().default(!1),hidden:Y().default(!1),enumMapper:X({matcher:Z([`country_alpha2code_by_alpha2code`,`country_alpha3code_by_alpha3code`,`country_code_by_country_code`,`country_name_by_country_name`,`country_name_by_alpha3code`,`country_name_by_alpha2code`,`country_name_by_country_code`,`country_alpha3code_by_alpha2code`,`country_alpha3code_by_country_name`,`country_alpha3code_by_country_code`,`country_alpha2code_by_alpha3code`,`country_alpha2code_by_country_name`,`country_alpha2code_by_country_code`,`country_code_by_alpha2code`,`country_code_by_alpha3code`,`country_code_by_country_name`,`country_subdivisions_by_alpha2code`,`country_subdivision_code_by_subdivision_name`,`country_alpha2code_by_citizenship`,`country_subdivision_name_by_subdivision_code`]).or(X({matchExpression:G(),value:G()}).array())}).optional()}).array().optional(),steps:X({stepId:G(),description:G(),stepFunction:X({functionName:G(),version:G().optional(),parameters:qi(G(),Pi())}),condition:G().optional(),ignoreError:Y().optional()}).array(),result:G().or(qi(G(),Pi())).optional()}),Ta=X({StackOne:G(),info:X({title:G(),version:G(),key:G(),description:G().optional()}),baseUrl:G(),authentication:qi(G(),X({type:G(),label:G(),authorization:i,environments:X({key:G(),name:G()}).array(),support:X({link:G(),description:G().optional()}),configFields:Ca.array().optional(),setupFields:Ca.array().optional(),testOperationsIds:G().array().optional()})).array().optional(),operations:wa.array().optional()});function Ea(e){try{let t=te(e),n=Ta.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},i=ka(n),a={baseUrl:n.baseUrl,authentication:Da(i)},o=Pa(n,a);return r.operations=o,r.authentication=i,y(o)&&(r.categories=Oa(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Da=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,testOperationsIds:o,...s}=r;t[n]=Da(s)}else t[n]=r;return t},Oa=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},ka=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:i,name:a}=r,{environments:o,...s}=n[e];return t[i]={...s,envKey:i,envName:a},t},{});t[e]=r}return t},Aa=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,ja=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Ma=e=>e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`,Na=e=>{let t={success:ba(e.operationType),errors:xa()},r=e.responses?.reduce((e,t)=>{let r=n(t.statusCode);return r?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e},t);return r??t},Pa=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=Aa(n),i=ja(n),a=Ma(n),o=Na(n),s=Ra(n),c=n.inputs||[];return s.enabled&&c?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`}),e[r??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??`get`,responses:o,cursor:s,compositeIdentifiers:za(n),scheduledJobs:Ba(n),inputs:c,steps:n.steps.reduce((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{...r.stepFunction.parameters,...Va(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:n.fieldConfigs}:{}}}},e),{}),result:n.result},e},{});return n},Fa=(e,t)=>{if(!e.inputs)return{};let n=La(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ia=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=G();break;case`number`:n=J();break;case`boolean`:n=Y();break;default:n=Mi()}t[e.name]=e.required?n:n.optional()}),X(t)},La=e=>{let t=e.filter(e=>e.in===`path`),n=e.filter(e=>e.in===`query`),r=e.filter(e=>e.in===`body`),i=e.filter(e=>e.in===`headers`);return X({path:Ia(t).optional(),query:Ia(n).optional(),body:Ia(r).optional(),headers:Ia(i).optional()})},Ra=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ya};return{enabled:n.enabled&&t,pageSize:n.pageSize}},za=e=>{if(g(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=y(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:a,fields:n}}let t=[];for(let n of e.compositeIdentifiers?.fields??[]){let r=n.components.map(t=>{let n=e.fieldConfigs?.find(e=>e.targetFieldKey===t);return{name:t,alias:n?.alias}});t.push({targetFieldKey:n.targetFieldKey,remote:n.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},Ba=e=>{if(!g(e.scheduledJobs))return e.scheduledJobs},Va=(e,t,n={})=>{if(e===`request`||e===`paginated_request`){let e=[{receivedStatus:500,targetStatus:502}],r=n.customErrors&&Array.isArray(n.customErrors)?n.customErrors:[],i=[...r,...e];return{...t,customErrors:i}}else return{}},Ha=e=>{try{let t=[],n=te(e),r=Ta.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=Ua(n.path,e);t.push({line:r,message:n.message,field:n.path.join(`.`)})}),t.length>0?{success:!1,errors:t}:{success:!0}}catch(e){let t=e.message,n=t.match(/at line (\d+)/),r=n?parseInt(n[1],10):1;return{success:!1,errors:[{line:r,message:`The YAML connector file is not valid. Please check the syntax and structure.`,field:void 0}]}}},Ua=(e,t)=>{let n=t.split(`
|
|
26
|
+
})));`),t.write(`newResult[${E(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=_e,o=!ce.jitless,s=ve,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?yn(e,s,t,f):z(e,s,t))):i?yn(r,s,t,f):z(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,ee=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(ee===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>z(t,s,e))):z(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function xn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>N(e,r,w())))}),t}const Sn=S(`$ZodUnion`,(e,t)=>{L.init(e,t),T(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),T(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>pe(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>xn(t,n,e,r)):xn(a,n,e,r)}}),Cn=S(`$ZodDiscriminatedUnion`,(e,t)=>{Sn.init(e,t);let n=e._zod.parse;T(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=de(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!_e(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),wn=S(`$ZodIntersection`,(e,t)=>{L.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>En(e,t,n)):En(e,i,a)}});function Tn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ye(e)&&ye(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Tn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Tn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function En(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;let r=Tn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Dn=S(`$ZodRecord`,(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ye(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...j(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...j(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>N(e,r,w())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...j(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...j(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),On=S(`$ZodEnum`,(e,t)=>{L.init(e,t);let n=le(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>be.has(typeof e)).map(e=>typeof e==`string`?D(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),kn=S(`$ZodLiteral`,(e,t)=>{L.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?D(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),An=S(`$ZodTransform`,(e,t)=>{L.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new C;return e.value=r,e}}),jn=S(`$ZodOptional`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pe(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Mn=S(`$ZodNullable`,(e,t)=>{L.init(e,t),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pe(e.source)}|null)$`):void 0}),T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Nn=S(`$ZodDefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Pn(e,t)):Pn(r,t)}});function Pn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Fn=S(`$ZodPrefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),In=S(`$ZodNonOptional`,(e,t)=>{L.init(e,t),T(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ln(t,e)):Ln(i,e)}});function Ln(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Rn=S(`$ZodCatch`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>N(e,n,w()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>N(e,n,w()))},input:e.value}),e.issues=[]),e)}}),zn=S(`$ZodPipe`,(e,t)=>{L.init(e,t),T(e._zod,`values`,()=>t.in._zod.values),T(e._zod,`optin`,()=>t.in._zod.optin),T(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t,n)):Bn(r,t,n)}});function Bn(e,t,n){return A(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Vn=S(`$ZodReadonly`,(e,t)=>{L.init(e,t),T(e._zod,`propValues`,()=>t.innerType._zod.propValues),T(e._zod,`values`,()=>t.innerType._zod.values),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hn):Hn(r)}});function Hn(e){return e.value=Object.freeze(e.value),e}const Un=S(`$ZodCustom`,(e,t)=>{F.init(e,t),L.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Wn(t,n,r,e));Wn(i,n,r,e)}});function Wn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(P(e))}}const Gn=Symbol(`ZodOutput`),Kn=Symbol(`ZodInput`);var qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Jn(){return new qn}const B=Jn();function Yn(e,t){return new e({type:`string`,...k(t)})}function Xn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Zn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Qn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function nr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function rr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function ir(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function ar(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function or(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function sr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function cr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function lr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function ur(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function dr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function fr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function pr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function mr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function hr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function gr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function _r(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function vr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function yr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function br(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function xr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Sr(e,t){return new e({type:`number`,checks:[],...k(t)})}function Cr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function wr(e,t){return new e({type:`boolean`,...k(t)})}function Tr(e){return new e({type:`any`})}function Er(e){return new e({type:`unknown`})}function Dr(e,t){return new e({type:`never`,...k(t)})}function Or(e,t){return new xt({check:`less_than`,...k(t),value:e,inclusive:!1})}function kr(e,t){return new xt({check:`less_than`,...k(t),value:e,inclusive:!0})}function Ar(e,t){return new St({check:`greater_than`,...k(t),value:e,inclusive:!1})}function jr(e,t){return new St({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Mr(e,t){return new Ct({check:`multiple_of`,...k(t),value:e})}function Nr(e,t){let n=new Tt({check:`max_length`,...k(t),maximum:e});return n}function V(e,t){return new Et({check:`min_length`,...k(t),minimum:e})}function Pr(e,t){return new Dt({check:`length_equals`,...k(t),length:e})}function Fr(e,t){return new Ot({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Ir(e){return new kt({check:`string_format`,format:`lowercase`,...k(e)})}function Lr(e){return new At({check:`string_format`,format:`uppercase`,...k(e)})}function Rr(e,t){return new jt({check:`string_format`,format:`includes`,...k(t),includes:e})}function zr(e,t){return new Mt({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function Br(e,t){return new Nt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function H(e){return new Pt({check:`overwrite`,tx:e})}function Vr(e){return H(t=>t.normalize(e))}function Hr(){return H(e=>e.trim())}function Ur(){return H(e=>e.toLowerCase())}function Wr(){return H(e=>e.toUpperCase())}function Gr(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Kr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...k(n)});return r}const qr=S(`ZodISODateTime`,(e,t)=>{Yt.init(e,t),K.init(e,t)});function Jr(e){return vr(qr,e)}const Yr=S(`ZodISODate`,(e,t)=>{Xt.init(e,t),K.init(e,t)});function Xr(e){return yr(Yr,e)}const Zr=S(`ZodISOTime`,(e,t)=>{Zt.init(e,t),K.init(e,t)});function Qr(e){return br(Zr,e)}const $r=S(`ZodISODuration`,(e,t)=>{Qt.init(e,t),K.init(e,t)});function ei(e){return xr($r,e)}const ti=(e,t)=>{je.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Pe(e,t)},flatten:{value:t=>Ne(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},ni=S(`ZodError`,ti),U=S(`ZodError`,ti,{Parent:Error}),ri=Fe(U),ii=Le(U),ai=ze(U),oi=Ve(U),W=S(`ZodType`,(e,t)=>(L.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>O(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>ri(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ai(e,t,n),e.parseAsync=async(t,n)=>ii(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>oi(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(_a(t,n)),e.superRefine=t=>e.check(va(t)),e.overwrite=t=>e.check(H(t)),e.optional=()=>ea(e),e.nullable=()=>na(e),e.nullish=()=>ea(na(e)),e.nonoptional=t=>ca(e,t),e.array=()=>Ri(e),e.or=t=>Vi([e,t]),e.and=t=>Gi(e,t),e.transform=t=>fa(e,Qi(t)),e.default=t=>ia(e,t),e.prefault=t=>oa(e,t),e.catch=t=>ua(e,t),e.pipe=t=>fa(e,t),e.readonly=()=>ma(e),e.describe=t=>{let n=e.clone();return B.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return B.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return B.get(e);let n=e.clone();return B.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),si=S(`_ZodString`,(e,t)=>{Lt.init(e,t),W.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Fr(...t)),e.includes=(...t)=>e.check(Rr(...t)),e.startsWith=(...t)=>e.check(zr(...t)),e.endsWith=(...t)=>e.check(Br(...t)),e.min=(...t)=>e.check(V(...t)),e.max=(...t)=>e.check(Nr(...t)),e.length=(...t)=>e.check(Pr(...t)),e.nonempty=(...t)=>e.check(V(1,...t)),e.lowercase=t=>e.check(Ir(t)),e.uppercase=t=>e.check(Lr(t)),e.trim=()=>e.check(Hr()),e.normalize=(...t)=>e.check(Vr(...t)),e.toLowerCase=()=>e.check(Ur()),e.toUpperCase=()=>e.check(Wr())}),ci=S(`ZodString`,(e,t)=>{Lt.init(e,t),si.init(e,t),e.email=t=>e.check(Xn(li,t)),e.url=t=>e.check(nr(di,t)),e.jwt=t=>e.check(_r(Ei,t)),e.emoji=t=>e.check(rr(fi,t)),e.guid=t=>e.check(Zn(ui,t)),e.uuid=t=>e.check(Qn(q,t)),e.uuidv4=t=>e.check($n(q,t)),e.uuidv6=t=>e.check(er(q,t)),e.uuidv7=t=>e.check(tr(q,t)),e.nanoid=t=>e.check(ir(pi,t)),e.guid=t=>e.check(Zn(ui,t)),e.cuid=t=>e.check(ar(mi,t)),e.cuid2=t=>e.check(or(hi,t)),e.ulid=t=>e.check(sr(gi,t)),e.base64=t=>e.check(mr(Ci,t)),e.base64url=t=>e.check(hr(wi,t)),e.xid=t=>e.check(cr(_i,t)),e.ksuid=t=>e.check(lr(vi,t)),e.ipv4=t=>e.check(ur(yi,t)),e.ipv6=t=>e.check(dr(bi,t)),e.cidrv4=t=>e.check(fr(xi,t)),e.cidrv6=t=>e.check(pr(Si,t)),e.e164=t=>e.check(gr(Ti,t)),e.datetime=t=>e.check(Jr(t)),e.date=t=>e.check(Xr(t)),e.time=t=>e.check(Qr(t)),e.duration=t=>e.check(ei(t))});function G(e){return Yn(ci,e)}const K=S(`ZodStringFormat`,(e,t)=>{R.init(e,t),si.init(e,t)}),li=S(`ZodEmail`,(e,t)=>{Bt.init(e,t),K.init(e,t)}),ui=S(`ZodGUID`,(e,t)=>{Rt.init(e,t),K.init(e,t)}),q=S(`ZodUUID`,(e,t)=>{zt.init(e,t),K.init(e,t)}),di=S(`ZodURL`,(e,t)=>{Vt.init(e,t),K.init(e,t)}),fi=S(`ZodEmoji`,(e,t)=>{Ht.init(e,t),K.init(e,t)}),pi=S(`ZodNanoID`,(e,t)=>{Ut.init(e,t),K.init(e,t)}),mi=S(`ZodCUID`,(e,t)=>{Wt.init(e,t),K.init(e,t)}),hi=S(`ZodCUID2`,(e,t)=>{Gt.init(e,t),K.init(e,t)}),gi=S(`ZodULID`,(e,t)=>{Kt.init(e,t),K.init(e,t)}),_i=S(`ZodXID`,(e,t)=>{qt.init(e,t),K.init(e,t)}),vi=S(`ZodKSUID`,(e,t)=>{Jt.init(e,t),K.init(e,t)}),yi=S(`ZodIPv4`,(e,t)=>{$t.init(e,t),K.init(e,t)}),bi=S(`ZodIPv6`,(e,t)=>{en.init(e,t),K.init(e,t)}),xi=S(`ZodCIDRv4`,(e,t)=>{tn.init(e,t),K.init(e,t)}),Si=S(`ZodCIDRv6`,(e,t)=>{nn.init(e,t),K.init(e,t)}),Ci=S(`ZodBase64`,(e,t)=>{an.init(e,t),K.init(e,t)}),wi=S(`ZodBase64URL`,(e,t)=>{sn.init(e,t),K.init(e,t)}),Ti=S(`ZodE164`,(e,t)=>{cn.init(e,t),K.init(e,t)}),Ei=S(`ZodJWT`,(e,t)=>{un.init(e,t),K.init(e,t)}),Di=S(`ZodNumber`,(e,t)=>{dn.init(e,t),W.init(e,t),e.gt=(t,n)=>e.check(Ar(t,n)),e.gte=(t,n)=>e.check(jr(t,n)),e.min=(t,n)=>e.check(jr(t,n)),e.lt=(t,n)=>e.check(Or(t,n)),e.lte=(t,n)=>e.check(kr(t,n)),e.max=(t,n)=>e.check(kr(t,n)),e.int=t=>e.check(ki(t)),e.safe=t=>e.check(ki(t)),e.positive=t=>e.check(Ar(0,t)),e.nonnegative=t=>e.check(jr(0,t)),e.negative=t=>e.check(Or(0,t)),e.nonpositive=t=>e.check(kr(0,t)),e.multipleOf=(t,n)=>e.check(Mr(t,n)),e.step=(t,n)=>e.check(Mr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function J(e){return Sr(Di,e)}const Oi=S(`ZodNumberFormat`,(e,t)=>{fn.init(e,t),Di.init(e,t)});function ki(e){return Cr(Oi,e)}const Ai=S(`ZodBoolean`,(e,t)=>{pn.init(e,t),W.init(e,t)});function Y(e){return wr(Ai,e)}const ji=S(`ZodAny`,(e,t)=>{mn.init(e,t),W.init(e,t)});function Mi(){return Tr(ji)}const Ni=S(`ZodUnknown`,(e,t)=>{hn.init(e,t),W.init(e,t)});function Pi(){return Er(Ni)}const Fi=S(`ZodNever`,(e,t)=>{gn.init(e,t),W.init(e,t)});function Ii(e){return Dr(Fi,e)}const Li=S(`ZodArray`,(e,t)=>{vn.init(e,t),W.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(V(t,n)),e.nonempty=t=>e.check(V(1,t)),e.max=(t,n)=>e.check(Nr(t,n)),e.length=(t,n)=>e.check(Pr(t,n)),e.unwrap=()=>e.element});function Ri(e,t){return Gr(Li,e,t)}const zi=S(`ZodObject`,(e,t)=>{bn.init(e,t),W.init(e,t),T(e,`shape`,()=>t.shape),e.keyof=()=>Z(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pi()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pi()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ii()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Te(e,t),e.merge=t=>Ee(e,t),e.pick=t=>Ce(e,t),e.omit=t=>we(e,t),e.partial=(...t)=>De($i,e,t[0]),e.required=(...t)=>Oe(sa,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return he(this,`shape`,{...e}),this.shape},...k(t)};return new zi(n)}const Bi=S(`ZodUnion`,(e,t)=>{Sn.init(e,t),W.init(e,t),e.options=t.options});function Vi(e,t){return new Bi({type:`union`,options:e,...k(t)})}const Hi=S(`ZodDiscriminatedUnion`,(e,t)=>{Bi.init(e,t),Cn.init(e,t)});function Ui(e,t,n){return new Hi({type:`union`,options:t,discriminator:e,...k(n)})}const Wi=S(`ZodIntersection`,(e,t)=>{wn.init(e,t),W.init(e,t)});function Gi(e,t){return new Wi({type:`intersection`,left:e,right:t})}const Ki=S(`ZodRecord`,(e,t)=>{Dn.init(e,t),W.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function qi(e,t,n){return new Ki({type:`record`,keyType:e,valueType:t,...k(n)})}const Ji=S(`ZodEnum`,(e,t)=>{On.init(e,t),W.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ji({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ji({...t,checks:[],...k(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ji({type:`enum`,entries:n,...k(t)})}const Yi=S(`ZodLiteral`,(e,t)=>{kn.init(e,t),W.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Xi(e,t){return new Yi({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const Zi=S(`ZodTransform`,(e,t)=>{An.init(e,t),W.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(P(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(P(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Qi(e){return new Zi({type:`transform`,transform:e})}const $i=S(`ZodOptional`,(e,t)=>{jn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ea(e){return new $i({type:`optional`,innerType:e})}const ta=S(`ZodNullable`,(e,t)=>{Mn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function na(e){return new ta({type:`nullable`,innerType:e})}const ra=S(`ZodDefault`,(e,t)=>{Nn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ia(e,t){return new ra({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const aa=S(`ZodPrefault`,(e,t)=>{Fn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function oa(e,t){return new aa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const sa=S(`ZodNonOptional`,(e,t)=>{In.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ca(e,t){return new sa({type:`nonoptional`,innerType:e,...k(t)})}const la=S(`ZodCatch`,(e,t)=>{Rn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ua(e,t){return new la({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const da=S(`ZodPipe`,(e,t)=>{zn.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function fa(e,t){return new da({type:`pipe`,in:e,out:t})}const pa=S(`ZodReadonly`,(e,t)=>{Vn.init(e,t),W.init(e,t)});function ma(e){return new pa({type:`readonly`,innerType:e})}const ha=S(`ZodCustom`,(e,t)=>{Un.init(e,t),W.init(e,t)});function ga(e,t){let n=new F({check:`custom`,...k(t)});return n._zod.check=e,n}function _a(e,t={}){return Kr(ha,e,t)}function va(e,t){let n=ga(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(P(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(P(r))}},e(t.value,t)),t);return n}const ya=25,ba=e=>{switch(e){case`list`:return{statusCode:200,description:`The list of records was retrieved.`};case`get`:return{statusCode:200,description:`The record with the given identifier was retrieved.`};case`create`:return{statusCode:201,description:`The record was created successfully.`};case`update`:return{statusCode:200,description:`The record was updated successfully.`};case`delete`:return{statusCode:204,description:`The record was deleted successfully.`};case`custom`:return{statusCode:200,description:`The operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},xa=()=>{let e={400:{statusCode:400,description:`Invalid request.`},401:{statusCode:401,description:`Unauthorized access.`},403:{statusCode:403,description:`Forbidden.`},404:{statusCode:404,description:`Resource not found.`},500:{statusCode:500,description:`Server error while executing the request.`}};return e},Sa={key:G(),label:G(),required:Y().optional().default(!1),secret:Y().optional().default(!1),readOnly:Y().optional().default(!1),placeholder:G().optional(),description:G().optional(),tooltip:G().optional()},Ca=Ui(`type`,[X({...Sa,type:Z([`text`,`password`])}),X({...Sa,type:Xi(`select`),options:X({value:G(),label:G()}).array()})]),wa=X({operationId:G(),categories:G().array(),operationType:Z([`list`,`get`,`create`,`update`,`delete`,`custom`,`unknown`]),schema:G().optional(),entrypointUrl:G().optional(),entrypointHttpMethod:G().optional(),description:G(),responses:X({statusCode:J(),description:G()}).array().optional(),inputs:X({name:G(),type:G(),required:Y(),description:G(),in:G()}).array().optional(),cursor:X({enabled:Y(),pageSize:J()}).optional(),compositeIdentifiers:X({enabled:Y(),version:J().optional(),fields:X({targetFieldKey:G(),remote:G().optional(),components:G().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:Y(),type:Z([`data_sync`]),schedule:G(),description:G(),requestParams:X({fields:G().array().optional(),expand:G().array().optional(),filter:qi(G(),G()).optional()}).optional(),syncFilter:X({name:Z([`updated_after`,`created_after`]),initialLoopbackPeriod:G(),incrementalLoopbackPeriod:G()}).optional()}).array().optional(),fieldConfigs:X({targetFieldKey:G(),alias:G().optional(),expression:G(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`enum`]),custom:Y().default(!1),hidden:Y().default(!1),enumMapper:X({matcher:Z([`country_alpha2code_by_alpha2code`,`country_alpha3code_by_alpha3code`,`country_code_by_country_code`,`country_name_by_country_name`,`country_name_by_alpha3code`,`country_name_by_alpha2code`,`country_name_by_country_code`,`country_alpha3code_by_alpha2code`,`country_alpha3code_by_country_name`,`country_alpha3code_by_country_code`,`country_alpha2code_by_alpha3code`,`country_alpha2code_by_country_name`,`country_alpha2code_by_country_code`,`country_code_by_alpha2code`,`country_code_by_alpha3code`,`country_code_by_country_name`,`country_subdivisions_by_alpha2code`,`country_subdivision_code_by_subdivision_name`,`country_alpha2code_by_citizenship`,`country_subdivision_name_by_subdivision_code`]).or(X({matchExpression:G(),value:G()}).array())}).optional()}).array().optional(),steps:X({stepId:G(),description:G(),stepFunction:X({functionName:G(),version:G().optional(),parameters:qi(G(),Pi())}),condition:G().optional(),ignoreError:Y().optional()}).array(),result:G().or(qi(G(),Pi())).optional()}),Ta=X({StackOne:G(),info:X({title:G(),version:G(),key:G(),assets:X({icon:G()}),description:G().optional()}),baseUrl:G(),authentication:qi(G(),X({type:G(),label:G(),authorization:i,environments:X({key:G(),name:G()}).array(),support:X({link:G(),description:G().optional()}),configFields:Ca.array().optional(),setupFields:Ca.array().optional(),testOperationsIds:G().array().optional()})).array().optional(),operations:wa.array().optional()});function Ea(e){try{let t=te(e),n=Ta.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description},i=ka(n),a={baseUrl:n.baseUrl,authentication:Da(i)},o=Pa(n,a);return r.operations=o,r.authentication=i,y(o)&&(r.categories=Oa(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Da=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,testOperationsIds:o,...s}=r;t[n]=Da(s)}else t[n]=r;return t},Oa=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},ka=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:i,name:a}=r,{environments:o,...s}=n[e];return t[i]={...s,envKey:i,envName:a},t},{});t[e]=r}return t},Aa=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,ja=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Ma=e=>e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`,Na=e=>{let t={success:ba(e.operationType),errors:xa()},r=e.responses?.reduce((e,t)=>{let r=n(t.statusCode);return r?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e},t);return r??t},Pa=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=Aa(n),i=ja(n),a=Ma(n),o=Na(n),s=Ra(n),c=n.inputs||[];return s.enabled&&c?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`}),e[r??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??`get`,responses:o,cursor:s,compositeIdentifiers:za(n),scheduledJobs:Ba(n),inputs:c,steps:n.steps.reduce((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{...r.stepFunction.parameters,...Va(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:n.fieldConfigs}:{}}}},e),{}),result:n.result},e},{});return n},Fa=(e,t)=>{if(!e.inputs)return{};let n=La(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ia=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=G();break;case`number`:n=J();break;case`boolean`:n=Y();break;default:n=Mi()}t[e.name]=e.required?n:n.optional()}),X(t)},La=e=>{let t=e.filter(e=>e.in===`path`),n=e.filter(e=>e.in===`query`),r=e.filter(e=>e.in===`body`),i=e.filter(e=>e.in===`headers`);return X({path:Ia(t).optional(),query:Ia(n).optional(),body:Ia(r).optional(),headers:Ia(i).optional()})},Ra=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ya};return{enabled:n.enabled&&t,pageSize:n.pageSize}},za=e=>{if(g(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=y(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:a,fields:n}}let t=[];for(let n of e.compositeIdentifiers?.fields??[]){let r=n.components.map(t=>{let n=e.fieldConfigs?.find(e=>e.targetFieldKey===t);return{name:t,alias:n?.alias}});t.push({targetFieldKey:n.targetFieldKey,remote:n.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},Ba=e=>{if(!g(e.scheduledJobs))return e.scheduledJobs},Va=(e,t,n={})=>{if(e===`request`||e===`paginated_request`){let e=[{receivedStatus:500,targetStatus:502}],r=n.customErrors&&Array.isArray(n.customErrors)?n.customErrors:[],i=[...r,...e];return{...t,customErrors:i}}else return{}},Ha=e=>{try{let t=[],n=te(e),r=Ta.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=Ua(n.path,e);t.push({line:r,message:n.message,field:n.path.join(`.`)})}),t.length>0?{success:!1,errors:t}:{success:!0}}catch(e){let t=e.message,n=t.match(/at line (\d+)/),r=n?parseInt(n[1],10):1;return{success:!1,errors:[{line:r,message:`The YAML connector file is not valid. Please check the syntax and structure.`,field:void 0}]}}},Ua=(e,t)=>{let n=t.split(`
|
|
27
27
|
`),r=0,i=-1,a=0;for(let t=0;t<n.length;t++){let o=n[t],s=o.match(/^(\s*)/)?.[1]?.length||0,c=o.replace(`- `,``).trim();if(c.startsWith(`#`)||c===``||s<=i)continue;let l=y(e[r])?`${String(e[r])}`:``;if(g(l))return a+1;if(isNaN(Number(l))){if(c.startsWith(`${l}:`)){if(r===e.length-1)return t+1;i=s,a=t,r++}}else{let e=parseInt(l,10),i=-1;for(let o=t;o<n.length;o++){let s=n[o],c=s.trim();if(c.startsWith(`-`)&&i++,i===e){r++,a=t,t--;break}else t++}}}return a+1};var Q=class e extends Error{errorType;context;constructor(t,n,r){super(r),this.name=`ConnectSDKError`,this.errorType=t,this.context=n,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}},Wa=class extends Q{constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},Ga=class extends Q{constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},Ka=class extends Q{constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},qa=class extends Q{constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const Ja=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=c.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===s.MAP_FIELDS?{[s.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},Ya=({category:e,connectorKey:t,connectorVersion:n,authConfigKey:r,environment:i=`production`,operation:a,accountSecureId:o,projectSecureId:s})=>({projectSecureId:s,accountSecureId:o,connectorKey:t,connectorVersion:n,category:e,service:``,resource:``,schema:a?.schema?.key,operationType:a?.operationType??`unknown`,authenticationType:r,environment:i}),Xa=e=>{let t=e.operation?.compositeIdentifiers,n={...e.inputs??{}};if(!t?.enabled||g(n))return e;let r=t.fields?.reduce((e,t)=>(t.components.forEach(t=>{t.alias&&(e[t.name]=t.alias)}),e),{}),i={version:t.version??a,aliases:r};return Za(n,i,e.logger),{...e,inputs:n}},Za=(e,t,n)=>{for(let r in e){let i=e[r];if(typeof i==`string`||Array.isArray(i)&&i.every(e=>typeof e==`string`))ro(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)Za(e,t,n);else typeof i==`object`&&i&&Za(i,t,n)}},Qa=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=l(o,n);i.push(e)}catch(e){r?.debug({message:`Received ${t} with invalid composite ID, assuming it is not a composite ID`,category:`processCompositeId`,context:{key:t,inputElement:o,compositeIdentifierConfig:n,error:e}}),a.push(o)}return{compositeIdComponents:i,nonCompositeIds:a}},$a=(e,t,n,r)=>{let i=n.filter(e=>Object.keys(e).length>1);i.length>0&&(e.decoded_ids={...e.decoded_ids??{},[t]:r?i:i[0]})},eo=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},to=(e,t,n,r,i)=>{n.every(eo)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},no=(e,t,n)=>{e instanceof o&&e.type===`COMPOSITE_ID_MISSING_HEADER_ERROR`?n?.debug({message:`Received ${t} with no composite ID header, assuming it is not a composite ID`}):n?.warning({message:`Error processing composite ID for ${t}, ignoring it`,error:e})},ro=(e,t,n,r,i)=>{try{let a=Array.isArray(e),o=a?e:[e];if(o.length===0)return;let{compositeIdComponents:s,nonCompositeIds:c}=Qa(o,t,r,i);$a(n,t,s,a),to(n,t,s,c,a)}catch(e){no(e,t,i)}},io=`remote_`,ao=e=>{let t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;let n=`data`,r=e.outputs?.[n];if(g(r))return e;let i=Array.isArray(r)?r.map(e=>oo(e,t)):oo(r,t);return{...e,outputs:{...e.outputs??{},[n]:i}}},oo=(e,t)=>{let n=so(e,t),r=go(n);return{...e,..._(r)?r:{}}},so=(e,t)=>{let n=t.version??a,r={};return t.fields?.forEach(t=>{let i={},a=[];t.components.forEach(t=>{t.alias&&(i[t.name]=t.alias),a.push({key:t.name,value:e[t.name]})});let o=a.length===1?a[0]:{identifiers:a},s={version:n,aliases:Object.keys(i).length>0?i:void 0},c=u(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${io}${t.remote}`]=e[t.remote])}),{...e,...r}},co=e=>e===`id`||/.+_id(s)?$/.test(e),lo=e=>Array.isArray(e)&&e.every(e=>v(e)&&e.length>0),uo=(e,t)=>f(e)||t.startsWith(io),fo=(e,t)=>{try{return u({key:e,value:t},{version:a})}catch{return t}},po=(e,t,n)=>{let r=t.map(t=>v(t)&&t.length>0&&!f(t)?fo(e,t):t);n[e]=r,n[`${io}${e}`]=t},mo=(e,t,n)=>{if(uo(t,e))return;let r=u({key:e,value:t},{version:a});n[e]=r,n[`remote_${e}`]=t},ho=(e,t,n)=>{lo(t)?po(e,t,n):v(t)&&t.length>0&&mo(e,t,n)},go=e=>{if(Array.isArray(e))return e.map(e=>go(e));if(!_(e))return e;let t={...e};for(let[n,r]of Object.entries(e))(_(r)||Array.isArray(r)&&r.length>0&&_(r[0]))&&(t[n]=go(r)),co(n)&&ho(n,r,t);return t},_o=(e,t)=>{let n=Number(e.inputs?.page_size),r=y(e.inputs?.page_size)&&ee(n)&&!Number.isNaN(n)?n:e.operation?.cursor?.pageSize??t;return r},vo=(e,t,n,r)=>{let i=g(e)?void 0:e.data,a=Object.keys(n).length+1,o=p({cursor:r,ignoreStepIndex:a});if(!_(e)||g(i)||(i?.length??0)<=t)return{result:e,next:y(r)&&!o?m(r):null};let s=r?.remote?.[a]?.pageNumber??1,c=(s-1)*t,l=c+t,u=i.slice(c,l),d=i.length>l||!o,f=h({cursor:r,stepIndex:a,pageNumber:s+1});return{result:{...e,data:u},next:d?m(f):null}},yo=async({block:e,buildStepFunction:t=c.build,virtualPaginateResultFn:n=vo,encodeResultCompositeIds:r=ao,decodeInputCompositeIds:i=Xa})=>{let a=i(e),o=await To({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},bo=(e,t)=>e.condition?!b(e.condition,t):!1,xo=(e,t,n)=>{let r=e.stepFunction;return t.operation?.cursor.enabled?{...r.params??{},cursor:{token:t.nextCursor?.remote?.[n]?.providerPageCursor,position:t.nextCursor?.remote?.[n]?.position}}:r.params??{}},So=(e,t,n,r,i)=>{let a=$({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},Co=async(e,t,n,r,i,a)=>{let o=n[e],s=o.stepFunction,c=a.buildStepFunction({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(bo(o,r))return $({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return $({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=xo(o,r,t),u=await c({block:r,params:l});if(u.successful===!1)return So(r,e,u,o,i);let d=r.operation?.cursor.enabled?h({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return $({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},wo=(e,n,r,i,a)=>{let o=!r.hasFatalError,s=o?e.operation?.responses.success.statusCode??200:r.errorStatusCode??500,c=y(a)&&_(a.result)?{next:a.next,...a.result}:i;return{...n,outputs:c,response:{successful:o,statusCode:s,message:o?void 0:e.operation?.responses?.errors?.[s]?.description??t?.[s]??`Error while processing the request`}}},To=async({block:e,buildStepFunction:t=c.build,virtualPaginateResultFn:n=vo})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=_o(e,ya),s={hasFatalError:!1,errorStatusCode:null},l={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await Co(t,e,r,i,s,l);let u=e.operation?.result?Eo(e.operation.result,i):void 0,d=e.operation?.cursor.enabled?n(u,o,r,i.nextCursor):void 0;return wo(e,i,s,u,d)},Eo=(e,t)=>_(e)?ne(e,t):b(e,t),$=({block:e,stepId:t,successful:n,functionOutput:r,skipped:i,message:a})=>({...e,steps:{...e.steps,[t]:{successful:n??r?.successful??!1,errors:r?.errors,output:r?.output,skipped:i,message:a}}}),Do=async({account:e,connector:t,category:n,path:r,method:i=`get`,queryParams:a,body:o,headers:s,logger:c,parseConnector:l=Ea,getOperationFromUrlFn:u=ie,parseOperationInputsFn:d=Fa,createBlockContextFn:f=Ya,createBlockFn:p=re,runStepOperationFn:m=yo})=>{let h=e.authConfigKey,ee=e.environment??`production`,_=e.secureId,y=e.projectSecureId,te=e.credentials,b=f({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:h,environment:ee,accountSecureId:_,projectSecureId:y}),ne;try{ne=v(t)?l(t):t}catch{throw new Wa(b,`Error while parsing connector`)}let x=u(ne,r,i);if(g(x))throw new Ga(b,`No matching operation found`);b.operationType=x.operation.operationType,b.schema=x.operation.schema?.key;let ae=Oo(a,b),oe;try{oe=d(x.operation,{query:a,body:o,headers:s,path:x.params})}catch{throw new Ka(b,`Error while parsing operation inputs`)}let S=await p({inputs:oe,context:b,operation:x.operation,credentials:te,nextCursor:ae,logger:c});return await m({block:S})},Oo=(e,t)=>{let n=e?.next,r=y(n)&&t.operationType===`list`?d(n):void 0;if(r===null)throw new qa(t,`Invalid cursor.`);return r};export{Q as ConnectSDKError,re as createBlock,Ja as executeStepFunction,ie as getOperationFromUrl,Fa as parseOperationInputs,Ea as parseYamlConnector,Do as runConnectorOperation,yo as runStepOperation,Ha as validateYamlConnector};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/connect-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"lint:fix": "npm run code:check:fix",
|
|
35
35
|
"test": "FORCE_COLOR=1 vitest run",
|
|
36
36
|
"test:watch": "FORCE_COLOR=1 vitest watch --silent",
|
|
37
|
+
"test:typecheck": "tsc --noEmit --project tsconfig.tests.json",
|
|
37
38
|
"publish-release": "npm publish --access=public"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [],
|