@stackone/connect-sdk 1.53.0 → 1.54.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.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -358,10 +358,12 @@ type OperationType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom'
|
|
|
358
358
|
type InputLocation = 'body' | 'query' | 'path' | 'headers';
|
|
359
359
|
type Input = {
|
|
360
360
|
name: string;
|
|
361
|
-
type: string;
|
|
361
|
+
type: 'string' | 'number' | 'boolean' | 'datetime_string' | 'object';
|
|
362
362
|
required: boolean;
|
|
363
363
|
description: string;
|
|
364
364
|
in: InputLocation;
|
|
365
|
+
array?: boolean;
|
|
366
|
+
properties?: Omit<Input, 'in'>[];
|
|
365
367
|
};
|
|
366
368
|
type Operation = {
|
|
367
369
|
id: string;
|
|
@@ -747,6 +749,7 @@ declare const runConnectorAction: ({
|
|
|
747
749
|
operationId,
|
|
748
750
|
account,
|
|
749
751
|
connector,
|
|
752
|
+
pathParams,
|
|
750
753
|
queryParams,
|
|
751
754
|
body,
|
|
752
755
|
headers,
|
|
@@ -761,6 +764,7 @@ declare const runConnectorAction: ({
|
|
|
761
764
|
operationId: string;
|
|
762
765
|
account: Account;
|
|
763
766
|
connector: Connector;
|
|
767
|
+
pathParams?: unknown;
|
|
764
768
|
queryParams?: unknown;
|
|
765
769
|
body?: unknown;
|
|
766
770
|
headers?: Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -358,10 +358,12 @@ type OperationType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom'
|
|
|
358
358
|
type InputLocation = 'body' | 'query' | 'path' | 'headers';
|
|
359
359
|
type Input = {
|
|
360
360
|
name: string;
|
|
361
|
-
type: string;
|
|
361
|
+
type: 'string' | 'number' | 'boolean' | 'datetime_string' | 'object';
|
|
362
362
|
required: boolean;
|
|
363
363
|
description: string;
|
|
364
364
|
in: InputLocation;
|
|
365
|
+
array?: boolean;
|
|
366
|
+
properties?: Omit<Input, 'in'>[];
|
|
365
367
|
};
|
|
366
368
|
type Operation = {
|
|
367
369
|
id: string;
|
|
@@ -747,6 +749,7 @@ declare const runConnectorAction: ({
|
|
|
747
749
|
operationId,
|
|
748
750
|
account,
|
|
749
751
|
connector,
|
|
752
|
+
pathParams,
|
|
750
753
|
queryParams,
|
|
751
754
|
body,
|
|
752
755
|
headers,
|
|
@@ -761,6 +764,7 @@ declare const runConnectorAction: ({
|
|
|
761
764
|
operationId: string;
|
|
762
765
|
account: Account;
|
|
763
766
|
connector: Connector;
|
|
767
|
+
pathParams?: unknown;
|
|
764
768
|
queryParams?: unknown;
|
|
765
769
|
body?: unknown;
|
|
766
770
|
headers?: Record<string, string>;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`@stackone/utils`)),l=s(require(`fs`)),u=s(require(`path`)),d=s(require(`path-to-regexp`)),f=s(require(`@stackone/core`)),p=s(require(`@stackone/transport`)),m=s(require(`yaml`)),h=s(require(`@stackone/expressions`)),g=async({connector:e,inputs:t,context:n,operation:r,credentials:i,nextCursor:a,logger:o,getHttpClient:s})=>{if((0,c.isMissing)(s))throw Error(`getHttpClient function is required`);let l=await s();return{connector:e,inputs:t,fieldConfigs:[],context:n,operation:r,credentials:i,nextCursor:a,httpClient:l,logger:o}},_=e=>{if(!e.endsWith(`.s1.yaml`))throw Error(`File must have .s1.yaml extension`);try{let t=(0,l.readFileSync)(e,`utf8`);if(!t.includes(`:`)||!t.includes(`$ref:`))return t;let n=t.split(`
|
|
2
2
|
`),r=v(n,(0,u.dirname)(e));return r.join(`
|
|
3
|
-
`)}catch(e){throw Error(`Failed to process YAML file: ${e.message}`)}},v=(e,t)=>{let n=[];for(let r of e)if(y(r)){let e=r.match(/^(\s*)/)?.[1]?.length||0,i=r.split(`:`)[1]?.trim(),a=
|
|
4
|
-
`).filter(e=>e.trim()!==``)}catch(t){throw Error(`Failed to load partial file '${e}': ${t.message}`)}},ee=(e,t,n)=>{let r=n.toUpperCase();if(!e.operations)return;let i=Object.keys(e.operations),a=te(t,r,i);if(a)return{operation:e.operations?.[a.path],params:a.params}},x=e=>{let t=e.startsWith(`/`)?e.slice(1):e,n=t.endsWith(`/`)?t.slice(0,-1):t;return n},te=(e,t,n)=>{let r=x(e);for(let e of n)if(e.startsWith(t)){let n=e.replace(`${t} `,``).trim(),i=(0,d.match)(x(n)),a=i(x(r));if(a!==!1)return{path:e,params:a.params}}},ne=(e,t)=>{let n=Object.keys(e.operations??{}).find(n=>e.operations?.[n]?.id===t);if((0,c.notMissing)(n))return e.operations?.[n]},S=Object.freeze({status:`aborted`});function C(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const w=Symbol(`zod_brand`);var T=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const E={};function D(e){return e&&Object.assign(E,e),E}function re(e){let t=Object.values(e).filter(e=>typeof e==`number`),n=Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t);return n}function ie(e,t){return typeof t==`bigint`?t.toString():t}function ae(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function oe(e){return e==null}function se(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ce(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}function O(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function le(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function k(e){return JSON.stringify(e)}const ue=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function de(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const fe=ae(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function pe(e){if(de(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(de(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}const me=new Set([`string`,`number`,`symbol`]);function A(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function j(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function he(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const ge={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function _e(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;n[e]=r.shape[e]}return j(e,{...e._zod.def,shape:n,checks:[]})}function ve(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;delete n[e]}return j(e,{...e._zod.def,shape:n,checks:[]})}function ye(e,t){if(!pe(t))throw Error(`Invalid input to extend: expected a plain object`);let n={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return le(this,`shape`,n),n},checks:[]};return j(e,n)}function be(e,t){return j(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return le(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function xe(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t]}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return j(t,{...t._zod.def,shape:i,checks:[]})}function Se(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=new e({type:`nonoptional`,innerType:r[t]})}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return j(t,{...t._zod.def,shape:i,checks:[]})}function N(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function P(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ce(e){return typeof e==`string`?e:e?.message}function F(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(n.customError?.(e))??Ce(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function we(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function I(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Te=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,ie,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ee=C(`$ZodError`,Te),L=C(`$ZodError`,Te,{Parent:Error});function De(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Oe(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i],a=i===t.path.length-1;a?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const ke=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new T;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,D())));throw ue(t,i?.callee),t}return o.value},Ae=ke(L),je=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,D())));throw ue(t,i?.callee),t}return o.value},Me=je(L),Ne=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new T;return a.issues.length?{success:!1,error:new(e??Ee)(a.issues.map(e=>F(e,i,D())))}:{success:!0,data:a.value}},Pe=Ne(L),Fe=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>F(e,i,D())))}:{success:!0,data:a.value}},Ie=Fe(L),Le=/^[cC][^\s-]{8,}$/,Re=/^[0-9a-z]+$/,ze=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Be=/^[0-9a-vA-V]{20}$/,Ve=/^[A-Za-z0-9]{27}$/,He=/^[a-zA-Z0-9_-]{21}$/,Ue=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,We=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ge=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Ke=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Je(){return new RegExp(qe,`u`)}const Ye=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Ze=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,et=/^[A-Za-z0-9_-]*$/,tt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,nt=/^\+(?:[0-9]){6,14}[0-9]$/,rt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,it=RegExp(`^${rt}$`);function at(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`,n=typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;return n}function ot(e){return RegExp(`^${at(e)}$`)}function st(e){let t=at({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${rt}T(?:${r})$`)}const ct=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},lt=/^\d+$/,ut=/^-?\d+(?:\.\d+)?/i,dt=/true|false/i,ft=/^[^A-Z]*$/,pt=/^[^a-z]*$/,R=C(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mt={number:`number`,bigint:`bigint`,object:`date`},ht=C(`$ZodCheckLessThan`,(e,t)=>{R.init(e,t);let n=mt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gt=C(`$ZodCheckGreaterThan`,(e,t)=>{R.init(e,t);let n=mt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_t=C(`$ZodCheckMultipleOf`,(e,t)=>{R.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);let r=typeof n.value==`bigint`?n.value%t.value===BigInt(0):ce(n.value,t.value)===0;r||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),vt=C(`$ZodCheckNumberFormat`,(e,t)=>{R.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ge[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=lt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),yt=C(`$ZodCheckMaxLength`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!oe(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i<=t.maximum)return;let a=we(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bt=C(`$ZodCheckMinLength`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!oe(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i>=t.minimum)return;let a=we(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xt=C(`$ZodCheckLengthEquals`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!oe(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=we(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),z=C(`$ZodCheckStringFormat`,(e,t)=>{var n,r;R.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),St=C(`$ZodCheckRegex`,(e,t)=>{z.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ct=C(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ft,z.init(e,t)}),wt=C(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=pt,z.init(e,t)}),Tt=C(`$ZodCheckIncludes`,(e,t)=>{R.init(e,t);let n=A(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Et=C(`$ZodCheckStartsWith`,(e,t)=>{R.init(e,t);let n=RegExp(`^${A(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Dt=C(`$ZodCheckEndsWith`,(e,t)=>{R.init(e,t);let n=RegExp(`.*${A(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ot=C(`$ZodCheckOverwrite`,(e,t)=>{R.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var kt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e,n=t.split(`
|
|
3
|
+
`)}catch(e){throw Error(`Failed to process YAML file: ${e.message}`)}},v=(e,t)=>{let n=[];for(let r of e)if(y(r)){let e=r.match(/^(\s*)/)?.[1]?.length||0,i=r.split(`:`)[1]?.trim(),a=ee(i,t),o=a.map(t=>` `.repeat(e)+t);n.push(...o)}else n.push(r);return n},y=e=>e.includes(`$ref:`),ee=(e,t)=>{let n=(0,u.resolve)((0,u.join)(t,`${e.replaceAll(`'`,``)}.s1.partial.yaml`));try{let e=(0,l.readFileSync)(n,`utf8`);return e.split(`
|
|
4
|
+
`).filter(e=>e.trim()!==``)}catch(t){throw Error(`Failed to load partial file '${e}': ${t.message}`)}},b=(e,t,n)=>{let r=n.toUpperCase();if(!e.operations)return;let i=Object.keys(e.operations),a=S(t,r,i);if(a)return{operation:e.operations?.[a.path],params:a.params}},x=e=>{let t=e.startsWith(`/`)?e.slice(1):e,n=t.endsWith(`/`)?t.slice(0,-1):t;return n},S=(e,t,n)=>{let r=x(e);for(let e of n)if(e.startsWith(t)){let n=e.replace(`${t} `,``).trim(),i=(0,d.match)(x(n)),a=i(x(r));if(a!==!1)return{path:e,params:a.params}}},te=(e,t)=>{let n=Object.keys(e.operations??{}).find(n=>e.operations?.[n]?.id===t);if((0,c.notMissing)(n))return e.operations?.[n]},C=Object.freeze({status:`aborted`});function w(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const T=Symbol(`zod_brand`);var E=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const D={};function O(e){return e&&Object.assign(D,e),D}function ne(e){let t=Object.values(e).filter(e=>typeof e==`number`),n=Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t);return n}function re(e,t){return typeof t==`bigint`?t.toString():t}function ie(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function ae(e){return e==null}function oe(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function se(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}function k(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ce(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function A(e){return JSON.stringify(e)}const le=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const de=ie(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function fe(e){if(ue(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(ue(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}const pe=new Set([`string`,`number`,`symbol`]);function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function j(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function he(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const ge={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function _e(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;n[e]=r.shape[e]}return j(e,{...e._zod.def,shape:n,checks:[]})}function ve(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;delete n[e]}return j(e,{...e._zod.def,shape:n,checks:[]})}function ye(e,t){if(!fe(t))throw Error(`Invalid input to extend: expected a plain object`);let n={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ce(this,`shape`,n),n},checks:[]};return j(e,n)}function be(e,t){return j(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ce(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function xe(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t]}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return j(t,{...t._zod.def,shape:i,checks:[]})}function Se(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=new e({type:`nonoptional`,innerType:r[t]})}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return j(t,{...t._zod.def,shape:i,checks:[]})}function N(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function P(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ce(e){return typeof e==`string`?e:e?.message}function F(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(n.customError?.(e))??Ce(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function we(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function I(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Te=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,re,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ee=w(`$ZodError`,Te),De=w(`$ZodError`,Te,{Parent:Error});function Oe(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ke(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i],a=i===t.path.length-1;a?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const Ae=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new E;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,O())));throw le(t,i?.callee),t}return o.value},je=Ae(De),Me=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,O())));throw le(t,i?.callee),t}return o.value},Ne=Me(De),Pe=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;return a.issues.length?{success:!1,error:new(e??Ee)(a.issues.map(e=>F(e,i,O())))}:{success:!0,data:a.value}},Fe=Pe(De),Ie=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>F(e,i,O())))}:{success:!0,data:a.value}},Le=Ie(De),Re=/^[cC][^\s-]{8,}$/,ze=/^[0-9a-z]+$/,Be=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ve=/^[0-9a-vA-V]{20}$/,He=/^[A-Za-z0-9]{27}$/,Ue=/^[a-zA-Z0-9_-]{21}$/,We=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ge=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ke=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,qe=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Je=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Ye(){return new RegExp(Je,`u`)}const Xe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ze=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Qe=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,et=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tt=/^[A-Za-z0-9_-]*$/,nt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,rt=/^\+(?:[0-9]){6,14}[0-9]$/,it=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,at=RegExp(`^${it}$`);function ot(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`,n=typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;return n}function st(e){return RegExp(`^${ot(e)}$`)}function ct(e){let t=ot({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${it}T(?:${r})$`)}const lt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ut=/^\d+$/,dt=/^-?\d+(?:\.\d+)?/i,ft=/true|false/i,pt=/^[^A-Z]*$/,mt=/^[^a-z]*$/,L=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ht={number:`number`,bigint:`bigint`,object:`date`},gt=w(`$ZodCheckLessThan`,(e,t)=>{L.init(e,t);let n=ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_t=w(`$ZodCheckGreaterThan`,(e,t)=>{L.init(e,t);let n=ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vt=w(`$ZodCheckMultipleOf`,(e,t)=>{L.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);let r=typeof n.value==`bigint`?n.value%t.value===BigInt(0):se(n.value,t.value)===0;r||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yt=w(`$ZodCheckNumberFormat`,(e,t)=>{L.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ge[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ut)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),bt=w(`$ZodCheckMaxLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ae(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i<=t.maximum)return;let a=we(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xt=w(`$ZodCheckMinLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ae(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i>=t.minimum)return;let a=we(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),St=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ae(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=we(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ct=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;L.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),wt=w(`$ZodCheckRegex`,(e,t)=>{Ct.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Tt=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=pt,Ct.init(e,t)}),Et=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=mt,Ct.init(e,t)}),Dt=w(`$ZodCheckIncludes`,(e,t)=>{L.init(e,t);let n=me(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ot=w(`$ZodCheckStartsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`^${me(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),kt=w(`$ZodCheckEndsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`.*${me(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),At=w(`$ZodCheckOverwrite`,(e,t)=>{L.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var jt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e,n=t.split(`
|
|
5
5
|
`).filter(e=>e),r=Math.min(...n.map(e=>e.length-e.trimStart().length)),i=n.map(e=>e.slice(r)).map(e=>` `.repeat(this.indent*2)+e);for(let e of i)this.content.push(e)}compile(){let e=Function,t=this?.args,n=this?.content??[``],r=[...n.map(e=>` ${e}`)];return new e(...t,r.join(`
|
|
6
|
-
`))}};const
|
|
6
|
+
`))}};const Mt={major:4,minor:0,patch:0},R=w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=N(e),i;for(let a of t){if(a._zod.def.when){let t=a._zod.def.when(e);if(!t)continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new E;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=N(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=N(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new E;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=Fe(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Le(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Nt=w(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??lt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),z=w(`$ZodStringFormat`,(e,t)=>{Ct.init(e,t),Nt.init(e,t)}),Pt=w(`$ZodGUID`,(e,t)=>{t.pattern??=Ge,z.init(e,t)}),Ft=w(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8},n=e[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ke(n)}else t.pattern??=Ke();z.init(e,t)}),It=w(`$ZodEmail`,(e,t)=>{t.pattern??=qe,z.init(e,t)}),Lt=w(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:nt.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith(`/`)&&a.endsWith(`/`)?n.value=a.slice(0,-1):n.value=a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Rt=w(`$ZodEmoji`,(e,t)=>{t.pattern??=Ye(),z.init(e,t)}),zt=w(`$ZodNanoID`,(e,t)=>{t.pattern??=Ue,z.init(e,t)}),Bt=w(`$ZodCUID`,(e,t)=>{t.pattern??=Re,z.init(e,t)}),Vt=w(`$ZodCUID2`,(e,t)=>{t.pattern??=ze,z.init(e,t)}),Ht=w(`$ZodULID`,(e,t)=>{t.pattern??=Be,z.init(e,t)}),Ut=w(`$ZodXID`,(e,t)=>{t.pattern??=Ve,z.init(e,t)}),Wt=w(`$ZodKSUID`,(e,t)=>{t.pattern??=He,z.init(e,t)}),Gt=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=ct(t),z.init(e,t)}),Kt=w(`$ZodISODate`,(e,t)=>{t.pattern??=at,z.init(e,t)}),qt=w(`$ZodISOTime`,(e,t)=>{t.pattern??=st(t),z.init(e,t)}),Jt=w(`$ZodISODuration`,(e,t)=>{t.pattern??=We,z.init(e,t)}),Yt=w(`$ZodIPv4`,(e,t)=>{t.pattern??=Xe,z.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Xt=w(`$ZodIPv6`,(e,t)=>{t.pattern??=Ze,z.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Zt=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Qe,z.init(e,t)}),Qt=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=$e,z.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function $t(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const en=w(`$ZodBase64`,(e,t)=>{t.pattern??=et,z.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{$t(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function tn(e){if(!tt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return $t(n)}const nn=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=tt,z.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{tn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),rn=w(`$ZodE164`,(e,t)=>{t.pattern??=rt,z.init(e,t)});function an(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const on=w(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{an(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),sn=w(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??dt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),cn=w(`$ZodNumber`,(e,t)=>{yt.init(e,t),sn.init(e,t)}),ln=w(`$ZodBoolean`,(e,t)=>{R.init(e,t),e._zod.pattern=ft,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),un=w(`$ZodAny`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),dn=w(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),fn=w(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function pn(e,t,n){e.issues.length&&t.issues.push(...P(n,e.issues)),t.value[n]=e.value}const mn=w(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>pn(t,n,e))):pn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function hn(e,t,n){e.issues.length&&t.issues.push(...P(n,e.issues)),t.value[n]=e.value}function gn(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...P(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const _n=w(`$ZodObject`,(e,t)=>{R.init(e,t);let n=ie(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof R))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=he(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});k(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new jt([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=A(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=A(e);t.write(`
|
|
7
7
|
if (${n}.issues.length) {
|
|
8
8
|
if (input[${r}] === undefined) {
|
|
9
9
|
if (${r} in input) {
|
|
@@ -25,6 +25,6 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
25
25
|
`)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
26
26
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
27
27
|
...iss,
|
|
28
|
-
path: iss.path ? [${
|
|
29
|
-
})));`),t.write(`newResult[${k(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=de,o=!E.jitless,s=fe,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?pn(e,s,t,f):H(e,s,t))):i?pn(r,s,t,f):H(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>H(t,s,e))):H(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 hn(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=>F(e,r,D())))}),t}const gn=C(`$ZodUnion`,(e,t)=>{B.init(e,t),O(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),O(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),O(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),O(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=>se(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=>hn(t,n,e,r)):hn(a,n,e,r)}}),_n=C(`$ZodDiscriminatedUnion`,(e,t)=>{gn.init(e,t);let n=e._zod.parse;O(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=ae(()=>{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(!de(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)}}),vn=C(`$ZodIntersection`,(e,t)=>{B.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])=>bn(e,t,n)):bn(e,i,a)}});function yn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pe(e)&&pe(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=yn(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=yn(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 bn(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),N(e))return e;let r=yn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const xn=C(`$ZodRecord`,(e,t)=>{B.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!pe(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(...P(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...P(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=>F(e,r,D())),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(...P(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...P(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Sn=C(`$ZodEnum`,(e,t)=>{B.init(e,t);let n=re(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>me.has(typeof e)).map(e=>typeof e==`string`?A(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}}),Cn=C(`$ZodLiteral`,(e,t)=>{B.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?A(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}}),wn=C(`$ZodTransform`,(e,t)=>{B.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 T;return e.value=r,e}}),Tn=C(`$ZodOptional`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${se(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)}),En=C(`$ZodNullable`,(e,t)=>{B.init(e,t),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(e._zod,`optout`,()=>t.innerType._zod.optout),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${se(e.source)}|null)$`):void 0}),O(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)}),Dn=C(`$ZodDefault`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,O(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=>On(e,t)):On(r,t)}});function On(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const kn=C(`$ZodPrefault`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,O(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))}),An=C(`$ZodNonOptional`,(e,t)=>{B.init(e,t),O(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=>jn(t,e)):jn(i,e)}});function jn(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 Mn=C(`$ZodCatch`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,O(e._zod,`optout`,()=>t.innerType._zod.optout),O(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=>F(e,n,D()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>F(e,n,D()))},input:e.value}),e.issues=[]),e)}}),Nn=C(`$ZodPipe`,(e,t)=>{B.init(e,t),O(e._zod,`values`,()=>t.in._zod.values),O(e._zod,`optin`,()=>t.in._zod.optin),O(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=>Pn(e,t,n)):Pn(r,t,n)}});function Pn(e,t,n){return N(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Fn=C(`$ZodReadonly`,(e,t)=>{B.init(e,t),O(e._zod,`propValues`,()=>t.innerType._zod.propValues),O(e._zod,`values`,()=>t.innerType._zod.values),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(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(In):In(r)}});function In(e){return e.value=Object.freeze(e.value),e}const Ln=C(`$ZodLazy`,(e,t)=>{B.init(e,t),O(e._zod,`innerType`,()=>t.getter()),O(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),O(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),O(e._zod,`optin`,()=>e._zod.innerType._zod.optin),O(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>{let r=e._zod.innerType;return r._zod.run(t,n)}}),Rn=C(`$ZodCustom`,(e,t)=>{R.init(e,t),B.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=>zn(t,n,r,e));zn(i,n,r,e)}});function zn(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(I(e))}}const Bn=Symbol(`ZodOutput`),Vn=Symbol(`ZodInput`);var Hn=class{constructor(){this._map=new Map,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}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),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 Un(){return new Hn}const Wn=Un();function Gn(e,t){return new e({type:`string`,...M(t)})}function Kn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}function qn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}function Jn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}function Yn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}function Xn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}function Zn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}function Qn(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}function $n(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}function er(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}function tr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}function nr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}function rr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}function ir(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}function ar(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}function or(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}function sr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}function cr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}function lr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}function ur(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}function dr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}function fr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}function pr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}function mr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}function hr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}function gr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}function _r(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}function vr(e,t){return new e({type:`number`,checks:[],...M(t)})}function yr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}function br(e,t){return new e({type:`boolean`,...M(t)})}function xr(e){return new e({type:`any`})}function Sr(e){return new e({type:`unknown`})}function Cr(e,t){return new e({type:`never`,...M(t)})}function wr(e,t){return new ht({check:`less_than`,...M(t),value:e,inclusive:!1})}function Tr(e,t){return new ht({check:`less_than`,...M(t),value:e,inclusive:!0})}function Er(e,t){return new gt({check:`greater_than`,...M(t),value:e,inclusive:!1})}function Dr(e,t){return new gt({check:`greater_than`,...M(t),value:e,inclusive:!0})}function Or(e,t){return new _t({check:`multiple_of`,...M(t),value:e})}function kr(e,t){let n=new yt({check:`max_length`,...M(t),maximum:e});return n}function Ar(e,t){return new bt({check:`min_length`,...M(t),minimum:e})}function jr(e,t){return new xt({check:`length_equals`,...M(t),length:e})}function Mr(e,t){return new St({check:`string_format`,format:`regex`,...M(t),pattern:e})}function Nr(e){return new Ct({check:`string_format`,format:`lowercase`,...M(e)})}function Pr(e){return new wt({check:`string_format`,format:`uppercase`,...M(e)})}function Fr(e,t){return new Tt({check:`string_format`,format:`includes`,...M(t),includes:e})}function Ir(e,t){return new Et({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}function Lr(e,t){return new Dt({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}function U(e){return new Ot({check:`overwrite`,tx:e})}function Rr(e){return U(t=>t.normalize(e))}function zr(){return U(e=>e.trim())}function Br(){return U(e=>e.toLowerCase())}function Vr(){return U(e=>e.toUpperCase())}function Hr(e,t,n){return new e({type:`array`,element:t,...M(n)})}function Ur(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...M(n)});return r}const Wr=C(`ZodISODateTime`,(e,t)=>{Ut.init(e,t),K.init(e,t)});function Gr(e){return mr(Wr,e)}const Kr=C(`ZodISODate`,(e,t)=>{Wt.init(e,t),K.init(e,t)});function qr(e){return hr(Kr,e)}const Jr=C(`ZodISOTime`,(e,t)=>{Gt.init(e,t),K.init(e,t)});function Yr(e){return gr(Jr,e)}const Xr=C(`ZodISODuration`,(e,t)=>{Kt.init(e,t),K.init(e,t)});function Zr(e){return _r(Xr,e)}const Qr=(e,t)=>{Ee.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Oe(e,t)},flatten:{value:t=>De(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},$r=C(`ZodError`,Qr),ei=C(`ZodError`,Qr,{Parent:Error}),ti=ke(ei),ni=je(ei),ri=Ne(ei),ii=Fe(ei),W=C(`ZodType`,(e,t)=>(B.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)=>j(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ti(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ri(e,t,n),e.parseAsync=async(t,n)=>ni(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ii(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(ga(t,n)),e.superRefine=t=>e.check(_a(t)),e.overwrite=t=>e.check(U(t)),e.optional=()=>Zi(e),e.nullable=()=>$i(e),e.nullish=()=>Zi($i(e)),e.nonoptional=t=>aa(e,t),e.array=()=>Ii(e),e.or=t=>zi([e,t]),e.and=t=>Ui(e,t),e.transform=t=>la(e,Yi(t)),e.default=t=>ta(e,t),e.prefault=t=>ra(e,t),e.catch=t=>sa(e,t),e.pipe=t=>la(e,t),e.readonly=()=>da(e),e.describe=t=>{let n=e.clone();return Wn.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Wn.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Wn.get(e);let n=e.clone();return Wn.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ai=C(`_ZodString`,(e,t)=>{jt.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(Mr(...t)),e.includes=(...t)=>e.check(Fr(...t)),e.startsWith=(...t)=>e.check(Ir(...t)),e.endsWith=(...t)=>e.check(Lr(...t)),e.min=(...t)=>e.check(Ar(...t)),e.max=(...t)=>e.check(kr(...t)),e.length=(...t)=>e.check(jr(...t)),e.nonempty=(...t)=>e.check(Ar(1,...t)),e.lowercase=t=>e.check(Nr(t)),e.uppercase=t=>e.check(Pr(t)),e.trim=()=>e.check(zr()),e.normalize=(...t)=>e.check(Rr(...t)),e.toLowerCase=()=>e.check(Br()),e.toUpperCase=()=>e.check(Vr())}),oi=C(`ZodString`,(e,t)=>{jt.init(e,t),ai.init(e,t),e.email=t=>e.check(Kn(si,t)),e.url=t=>e.check(Qn(ui,t)),e.jwt=t=>e.check(pr(Ti,t)),e.emoji=t=>e.check($n(di,t)),e.guid=t=>e.check(qn(ci,t)),e.uuid=t=>e.check(Jn(li,t)),e.uuidv4=t=>e.check(Yn(li,t)),e.uuidv6=t=>e.check(Xn(li,t)),e.uuidv7=t=>e.check(Zn(li,t)),e.nanoid=t=>e.check(er(fi,t)),e.guid=t=>e.check(qn(ci,t)),e.cuid=t=>e.check(tr(pi,t)),e.cuid2=t=>e.check(nr(mi,t)),e.ulid=t=>e.check(rr(hi,t)),e.base64=t=>e.check(ur(Si,t)),e.base64url=t=>e.check(dr(Ci,t)),e.xid=t=>e.check(ir(gi,t)),e.ksuid=t=>e.check(ar(_i,t)),e.ipv4=t=>e.check(or(vi,t)),e.ipv6=t=>e.check(sr(yi,t)),e.cidrv4=t=>e.check(cr(bi,t)),e.cidrv6=t=>e.check(lr(xi,t)),e.e164=t=>e.check(fr(wi,t)),e.datetime=t=>e.check(Gr(t)),e.date=t=>e.check(qr(t)),e.time=t=>e.check(Yr(t)),e.duration=t=>e.check(Zr(t))});function G(e){return Gn(oi,e)}const K=C(`ZodStringFormat`,(e,t)=>{V.init(e,t),ai.init(e,t)}),si=C(`ZodEmail`,(e,t)=>{Pt.init(e,t),K.init(e,t)}),ci=C(`ZodGUID`,(e,t)=>{Mt.init(e,t),K.init(e,t)}),li=C(`ZodUUID`,(e,t)=>{Nt.init(e,t),K.init(e,t)}),ui=C(`ZodURL`,(e,t)=>{Ft.init(e,t),K.init(e,t)}),di=C(`ZodEmoji`,(e,t)=>{It.init(e,t),K.init(e,t)}),fi=C(`ZodNanoID`,(e,t)=>{Lt.init(e,t),K.init(e,t)}),pi=C(`ZodCUID`,(e,t)=>{Rt.init(e,t),K.init(e,t)}),mi=C(`ZodCUID2`,(e,t)=>{zt.init(e,t),K.init(e,t)}),hi=C(`ZodULID`,(e,t)=>{Bt.init(e,t),K.init(e,t)}),gi=C(`ZodXID`,(e,t)=>{Vt.init(e,t),K.init(e,t)}),_i=C(`ZodKSUID`,(e,t)=>{Ht.init(e,t),K.init(e,t)}),vi=C(`ZodIPv4`,(e,t)=>{qt.init(e,t),K.init(e,t)}),yi=C(`ZodIPv6`,(e,t)=>{Jt.init(e,t),K.init(e,t)}),bi=C(`ZodCIDRv4`,(e,t)=>{Yt.init(e,t),K.init(e,t)}),xi=C(`ZodCIDRv6`,(e,t)=>{Xt.init(e,t),K.init(e,t)}),Si=C(`ZodBase64`,(e,t)=>{Qt.init(e,t),K.init(e,t)}),Ci=C(`ZodBase64URL`,(e,t)=>{en.init(e,t),K.init(e,t)}),wi=C(`ZodE164`,(e,t)=>{tn.init(e,t),K.init(e,t)}),Ti=C(`ZodJWT`,(e,t)=>{rn.init(e,t),K.init(e,t)}),Ei=C(`ZodNumber`,(e,t)=>{an.init(e,t),W.init(e,t),e.gt=(t,n)=>e.check(Er(t,n)),e.gte=(t,n)=>e.check(Dr(t,n)),e.min=(t,n)=>e.check(Dr(t,n)),e.lt=(t,n)=>e.check(wr(t,n)),e.lte=(t,n)=>e.check(Tr(t,n)),e.max=(t,n)=>e.check(Tr(t,n)),e.int=t=>e.check(Oi(t)),e.safe=t=>e.check(Oi(t)),e.positive=t=>e.check(Er(0,t)),e.nonnegative=t=>e.check(Dr(0,t)),e.negative=t=>e.check(wr(0,t)),e.nonpositive=t=>e.check(Tr(0,t)),e.multipleOf=(t,n)=>e.check(Or(t,n)),e.step=(t,n)=>e.check(Or(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 vr(Ei,e)}const Di=C(`ZodNumberFormat`,(e,t)=>{on.init(e,t),Ei.init(e,t)});function Oi(e){return yr(Di,e)}const ki=C(`ZodBoolean`,(e,t)=>{sn.init(e,t),W.init(e,t)});function J(e){return br(ki,e)}const Ai=C(`ZodAny`,(e,t)=>{cn.init(e,t),W.init(e,t)});function ji(){return xr(Ai)}const Mi=C(`ZodUnknown`,(e,t)=>{ln.init(e,t),W.init(e,t)});function Y(){return Sr(Mi)}const Ni=C(`ZodNever`,(e,t)=>{un.init(e,t),W.init(e,t)});function Pi(e){return Cr(Ni,e)}const Fi=C(`ZodArray`,(e,t)=>{fn.init(e,t),W.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Ar(t,n)),e.nonempty=t=>e.check(Ar(1,t)),e.max=(t,n)=>e.check(kr(t,n)),e.length=(t,n)=>e.check(jr(t,n)),e.unwrap=()=>e.element});function Ii(e,t){return Hr(Fi,e,t)}const Li=C(`ZodObject`,(e,t)=>{mn.init(e,t),W.init(e,t),O(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:Y()}),e.loose=()=>e.clone({...e._zod.def,catchall:Y()}),e.strict=()=>e.clone({...e._zod.def,catchall:Pi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>ye(e,t),e.merge=t=>be(e,t),e.pick=t=>_e(e,t),e.omit=t=>ve(e,t),e.partial=(...t)=>xe(Xi,e,t[0]),e.required=(...t)=>Se(ia,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return le(this,`shape`,{...e}),this.shape},...M(t)};return new Li(n)}const Ri=C(`ZodUnion`,(e,t)=>{gn.init(e,t),W.init(e,t),e.options=t.options});function zi(e,t){return new Ri({type:`union`,options:e,...M(t)})}const Bi=C(`ZodDiscriminatedUnion`,(e,t)=>{Ri.init(e,t),_n.init(e,t)});function Vi(e,t,n){return new Bi({type:`union`,options:t,discriminator:e,...M(n)})}const Hi=C(`ZodIntersection`,(e,t)=>{vn.init(e,t),W.init(e,t)});function Ui(e,t){return new Hi({type:`intersection`,left:e,right:t})}const Wi=C(`ZodRecord`,(e,t)=>{xn.init(e,t),W.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Gi(e,t,n){return new Wi({type:`record`,keyType:e,valueType:t,...M(n)})}const Ki=C(`ZodEnum`,(e,t)=>{Sn.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 Ki({...t,checks:[],...M(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 Ki({...t,checks:[],...M(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ki({type:`enum`,entries:n,...M(t)})}const qi=C(`ZodLiteral`,(e,t)=>{Cn.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 Q(e,t){return new qi({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}const Ji=C(`ZodTransform`,(e,t)=>{wn.init(e,t),W.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(I(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(I(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Yi(e){return new Ji({type:`transform`,transform:e})}const Xi=C(`ZodOptional`,(e,t)=>{Tn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zi(e){return new Xi({type:`optional`,innerType:e})}const Qi=C(`ZodNullable`,(e,t)=>{En.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $i(e){return new Qi({type:`nullable`,innerType:e})}const ea=C(`ZodDefault`,(e,t)=>{Dn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ta(e,t){return new ea({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const na=C(`ZodPrefault`,(e,t)=>{kn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ra(e,t){return new na({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const ia=C(`ZodNonOptional`,(e,t)=>{An.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function aa(e,t){return new ia({type:`nonoptional`,innerType:e,...M(t)})}const oa=C(`ZodCatch`,(e,t)=>{Mn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sa(e,t){return new oa({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const ca=C(`ZodPipe`,(e,t)=>{Nn.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function la(e,t){return new ca({type:`pipe`,in:e,out:t})}const ua=C(`ZodReadonly`,(e,t)=>{Fn.init(e,t),W.init(e,t)});function da(e){return new ua({type:`readonly`,innerType:e})}const fa=C(`ZodLazy`,(e,t)=>{Ln.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.getter()});function pa(e){return new fa({type:`lazy`,getter:e})}const ma=C(`ZodCustom`,(e,t)=>{Rn.init(e,t),W.init(e,t)});function ha(e){let t=new R({check:`custom`});return t._zod.check=e,t}function ga(e,t={}){return Ur(ma,e,t)}function _a(e){let t=ha(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(I(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(I(r))}},e(n.value,n)));return t}const va=25,ya=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`refresh_token`:return{statusCode:200,description:`The refresh token operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},ba=()=>{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},xa={key:G(),label:G(),required:J().optional().default(!1),secret:J().optional().default(!1),readOnly:J().optional().default(!1),placeholder:G().optional(),description:G().optional(),tooltip:G().optional()},Sa=Vi(`type`,[X({...xa,type:Z([`text`,`password`])}),X({...xa,type:Q(`select`),options:X({value:G(),label:G()}).array()})]),Ca=X({targetFieldKey:G(),alias:G().optional(),expression:G().optional(),values:Y().optional(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:J().default(!1),custom:J().default(!1),hidden:J().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(),properties:pa(()=>Ca).array().optional()}),wa=X({operationId:G(),categories:G().array(),operationType:Z([`list`,`get`,`create`,`update`,`delete`,`custom`,`refresh_token`,`unknown`]),schema:G().optional(),schemaType:Z([`native`,`unified`]).optional().default(`native`),entrypointUrl:G().optional(),entrypointHttpMethod:G().optional(),label:G(),description:G(),tags:G().array().optional(),context:G().optional(),responses:X({statusCode:q(),description:G()}).array().optional(),inputs:X({name:G(),type:G(),required:J(),description:G(),in:G()}).array().optional(),cursor:X({enabled:J(),pageSize:q()}).optional(),compositeIdentifiers:X({enabled:J(),version:q().optional(),fields:X({targetFieldKey:G(),remote:G().optional(),components:G().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:J(),type:Z([`data_sync`]),schedule:G(),description:G(),requestParams:X({fields:G().array().optional(),expand:G().array().optional(),filter:Gi(G(),G()).optional()}).optional(),syncFilter:X({name:Z([`updated_after`,`created_after`]),initialLoopbackPeriod:G(),incrementalLoopbackPeriod:G()}).optional()}).array().optional(),fieldConfigs:Ca.array().optional(),steps:X({stepId:G(),description:G(),stepFunction:X({functionName:G(),version:G().optional(),parameters:Gi(G(),Y())}),condition:G().optional(),ignoreError:J().optional()}).array(),result:G().or(Gi(G(),Y())).optional()}),Ta=X({schedule:G().optional(),operation:wa.extend({operationType:Q(`refresh_token`)})}),Ea=X({mainRatelimit:q(),subPools:Ii(X({subPoolKey:G(),urlPattern:G(),rateLimit:q()})).optional(),mappedRateLimitErrors:Ii(X({errorStatus:q(),errorMessage:G(),errorMessagePath:G().optional(),retryAfterPath:G().optional(),retryAfterUnit:zi([Q(`seconds`),Q(`milliseconds`),Q(`date`)]).optional(),retryAfterValue:q().optional()})).optional()}),Da=X({mainMaxConcurrency:q(),subPools:Ii(X({subPoolKey:G(),urlPattern:G(),maxConcurrency:q()})).optional()}),Oa=X({StackOne:G(),info:X({title:G(),version:G(),key:G(),assets:X({icon:G()}),description:G().optional()}),context:G().optional(),baseUrl:G(),authentication:Gi(G(),X({type:G(),label:G(),authorization:f.AUTHENTICATION_SCHEMA,environments:X({key:G(),name:G()}).array(),support:X({link:G(),description:G().optional()}),configFields:Sa.array().optional(),setupFields:Sa.array().optional(),refreshAuthentication:Ta.optional(),testOperations:X({operation:G().or(wa),condition:G().optional(),required:J().default(!0)}).array().optional()})).array().optional(),operations:wa.array().optional(),rateLimit:Ea.optional(),concurrency:Da.optional()});function ka(e){try{let t=(0,m.parse)(e),n=Oa.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description,context:n.context,rateLimit:n.rateLimit,concurrency:n.concurrency},i=Na(n),a={baseUrl:n.baseUrl,authentication:Aa(i)},o=za(n,a);return r.operations=o,ja(i,o,a),r.authentication=i,(0,c.notMissing)(o)&&(r.categories=Ma(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Aa=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,refreshAuthentication:o,testOperations:s,...c}=r;t[n]=Aa(c)}else t[n]=r;return t},ja=(e,t,n)=>{if(!(!e||!t))for(let r of Object.values(e))for(let e of Object.values(r)){let r=e.testOperations;e.testOperations=r?.map(e=>{if((0,c.notMissing)(e.operation))if(typeof e.operation==`string`){let n=e.operation,r=Object.values(t).find(e=>e.id===n);if(r)return{...e,operation:r}}else{let t=Ba(e.operation,n);return{...e,operation:t}}return e})}},Ma=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},Na=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,refreshAuthentication:s,testOperations:l,...u}=n[e],d=(0,c.notMissing)(s)?{schedule:s.schedule,operation:Ba(s.operation)}:void 0;return t[i]={...u,refreshAuthentication:d,envKey:i,envName:a,testOperations:l},t},{});t[e]=r}return t},Pa=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,Fa=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Ia=e=>{if(e.operationType!==`refresh_token`)return e.entrypointHttpMethod??`get`},La=e=>{if(!(e.operationType===`refresh_token`||(0,c.isMissing)(e.schema)))return e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`},Ra=e=>{let t={success:ya(e.operationType),errors:ba()},n=e.responses?.reduce((e,t)=>{let n=(0,p.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},za=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=Pa(n),i=Fa(n);return e[r??i]=Ba(n,t),e},{});return n},Ba=(e,t)=>{let n=La(e),r=Ra(e),i=Wa(e),a=e.inputs||[];i.enabled&&a?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`});let o=Ia(e);return{id:e.operationId,categories:e.categories,label:e.label,description:e.description,operationType:e.operationType,schemaType:e.schemaType??`native`,entrypointUrl:e.entrypointUrl??n,entrypointHttpMethod:o,tags:e.tags,context:e.context,responses:r,cursor:i,compositeIdentifiers:Ga(e),scheduledJobs:Ka(e),inputs:a,steps:e.steps.reduce((n,r)=>(n[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,...qa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:r.stepFunction.parameters.fields??e.fieldConfigs}:{}}}},n),{}),result:e.result}},Va=(e,t)=>{if(!e.inputs)return{};let n=Ua(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ha=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=G();break;case`number`:n=q();break;case`boolean`:n=J();break;default:n=ji()}t[e.name]=e.required?n:n.optional()}),X(t)},Ua=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:Ha(t).optional(),query:Ha(n).optional(),body:Ha(r).optional(),headers:Ha(i).optional()})},Wa=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:va};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Ga=e=>{if(e.operationType===`refresh_token`)return{enabled:!1};if((0,c.isMissing)(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=(0,c.notMissing)(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:f.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,c.isMissing)(e.scheduledJobs))return e.scheduledJobs},qa=(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,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return;let r=e.authentication?.[t]?.[n]?.refreshAuthentication?.operation;if((0,c.notMissing)(r))return{operation:r,params:{}}},Ya=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return!1;let r=Ja(e,t,n);return(0,c.notMissing)(r)},Xa=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenExpiresIn},Za=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenRefreshExpiresIn},Qa=e=>{try{let t=[],n=(0,m.parse)(e),r=Oa.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=$a(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}]}}},$a=(e,t)=>{let n=t.split(`
|
|
30
|
-
`),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,l=o.replace(`- `,``).trim();if(l.startsWith(`#`)||l===``||s<=i)continue;let u=(0,c.notMissing)(e[r])?`${String(e[r])}`:``;if((0,c.isMissing)(u))return a+1;if(isNaN(Number(u))){if(l.startsWith(`${u}:`)){if(r===e.length-1)return t+1;i=s,a=t,r++}}else{let e=parseInt(u,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}`}},eo=class extends ${constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},to=class extends ${constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},no=class extends ${constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},ro=class extends ${constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const io=(e,t)=>{let n=Object.keys(e.authentication??{}).map(t=>({type:`custom`,label:e.authentication?.[t].production?.label||`Custom`,key:t})),r=Object.values(e?.operations??{}).map(e=>({id:e.id,description:e.description.replace(/\b\w/g,e=>e.toUpperCase()),label:e.label.replace(/\b\w/g,e=>e.toUpperCase()),schema_type:e.schemaType,tags:e.tags,authentication:n,operation_details:t?.includes(`operation_details`)?e:void 0}));return{version:e.version,name:e.description,key:e.key,icon:e.assets?.icon,description:e.description,authentication:n,actions:r}},ao=(e,t)=>e.map(e=>io(e,t)),oo=`stackone://internal//`,so=`${oo}refresh_token`,co=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=f.StepFunctionsFactory.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===f.StepFunctionName.MAP_FIELDS?{[f.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},lo=({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}),uo=e=>{let t=e.operation?.compositeIdentifiers,n={...e.inputs??{}};if(!t?.enabled||(0,c.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??f.COMPOSITE_ID_LATEST_VERSION,aliases:r};return fo(n,i,e.logger),{...e,inputs:n}},fo=(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`))vo(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)fo(e,t,n);else typeof i==`object`&&i&&fo(i,t,n)}},po=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=(0,f.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}},mo=(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]})},ho=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},go=(e,t,n,r,i)=>{n.every(ho)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},_o=(e,t,n)=>{e instanceof f.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})},vo=(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}=po(o,t,r,i);mo(n,t,s,a),go(n,t,s,c,a)}catch(e){_o(e,t,i)}},yo=`remote_`,bo=e=>{let t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;let n=`data`,r=e.outputs?.[n];if((0,c.isMissing)(r))return e;let i=Array.isArray(r)?r.map(e=>xo(e,t)):xo(r,t);return{...e,outputs:{...e.outputs??{},[n]:i}}},xo=(e,t)=>{let n=So(e,t),r=Ao(n);return{...e,...(0,c.isObject)(r)?r:{}}},So=(e,t)=>{let n=t.version??f.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,f.encodeCompositeId)(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${yo}${t.remote}`]=e[t.remote])}),{...e,...r}},Co=e=>e===`id`||/.+_id(s)?$/.test(e),wo=e=>Array.isArray(e)&&e.every(e=>(0,c.isString)(e)&&e.length>0),To=(e,t)=>(0,f.isCompositeId)(e)||t.startsWith(yo),Eo=(e,t)=>{try{return(0,f.encodeCompositeId)({key:e,value:t},{version:f.COMPOSITE_ID_LATEST_VERSION})}catch{return t}},Do=(e,t,n)=>{let r=t.map(t=>(0,c.isString)(t)&&t.length>0&&!(0,f.isCompositeId)(t)?Eo(e,t):t);n[e]=r,n[`${yo}${e}`]=t},Oo=(e,t,n)=>{if(To(t,e))return;let r=(0,f.encodeCompositeId)({key:e,value:t},{version:f.COMPOSITE_ID_LATEST_VERSION});n[e]=r,n[`remote_${e}`]=t},ko=(e,t,n)=>{wo(t)?Do(e,t,n):(0,c.isString)(t)&&t.length>0&&Oo(e,t,n)},Ao=e=>{if(Array.isArray(e))return e.map(e=>Ao(e));if(!(0,c.isObject)(e))return e;let t={...e};for(let[n,r]of Object.entries(e))((0,c.isObject)(r)||Array.isArray(r)&&r.length>0&&(0,c.isObject)(r[0]))&&(t[n]=Ao(r)),Co(n)&&ko(n,r,t);return t},jo=(e,t)=>{let n=Number(e.inputs?.page_size),r=(0,c.notMissing)(e.inputs?.page_size)&&(0,c.isNumber)(n)&&!Number.isNaN(n)?n:e.operation?.cursor?.pageSize??t;return r},Mo=(e,t,n,r)=>{let i=(0,c.isMissing)(e)?void 0:e.data,a=Object.keys(n).length+1,o=(0,f.isCursorEmpty)({cursor:r,ignoreStepIndex:a});if(!(0,c.isObject)(e)||(0,c.isMissing)(i)||(i?.length??0)<=t)return{result:e,next:(0,c.notMissing)(r)&&!o?(0,f.minifyCursor)(r):null};let s=r?.remote?.[a]?.pageNumber??1,l=(s-1)*t,u=l+t,d=i.slice(l,u),p=i.length>u||!o,m=(0,f.updateCursor)({cursor:r,stepIndex:a,pageNumber:s+1});return{result:{...e,data:d},next:p?(0,f.minifyCursor)(m):null}},No=async({block:e,buildStepFunction:t=f.StepFunctionsFactory.build,virtualPaginateResultFn:n=Mo,encodeResultCompositeIds:r=bo,decodeInputCompositeIds:i=uo})=>{let a=i(e),o=await zo({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},Po=(e,t)=>e.condition?!(0,h.safeEvaluate)(e.condition,t):!1,Fo=(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??{}},Io=(e,t,n,r,i)=>{let a=Vo({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},Lo=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(Po(o,r))return Vo({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return Vo({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=Fo(o,r,t),u=await c({block:r,params:l});if(u.successful===!1)return Io(r,e,u,o,i);let d=r.operation?.cursor.enabled?(0,f.updateCursor)({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return Vo({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},Ro=(e,t,n,r,i)=>{let a=!n.hasFatalError,o=a?e.operation?.responses.success.statusCode??200:n.errorStatusCode??500,s=(0,c.notMissing)(i)&&(0,c.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??p.HttpErrorMessages?.[o]??`Error while processing the request`}}},zo=async({block:e,buildStepFunction:t=f.StepFunctionsFactory.build,virtualPaginateResultFn:n=Mo})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=jo(e,va),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await Lo(t,e,r,i,s,c);let l=e.operation?.result?Bo(e.operation.result,i):void 0,u=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return Ro(e,i,s,l,u)},Bo=(e,t)=>(0,c.isObject)(e)?(0,h.safeEvaluateRecord)(e,t):(0,h.safeEvaluate)(e,t),Vo=({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}}}),Ho=async({operationId:e,account:t,connector:n,queryParams:r={},body:i,headers:a,logger:o,getHttpClient:s,parseConnector:l=ka,parseOperationInputsFn:u=Va,createBlockContextFn:d=lo,createBlockFn:f=g,runStepOperationFn:p=No})=>{let m=t.authConfigKey,h=t.environment??`production`,_=t.secureId,v=t.projectSecureId,y=t.credentials,b=d({category:`action`,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:m,environment:h,accountSecureId:_,projectSecureId:v}),ee;try{ee=(0,c.isString)(n)?l(n):n}catch{throw new eo(b,`Error while parsing connector`)}let x=ne(n,e);if((0,c.isMissing)(x))throw new to(b,`No matching operation found`);b.operationType=x.operationType,b.schema=x.schema?.key;let te=Uo(r,b),S;try{S=u(x,{query:r,body:i,headers:a})}catch{throw new no(b,`Error while parsing operation inputs`)}let C=await f({connector:ee,inputs:S,context:b,operation:x,credentials:y,nextCursor:te,logger:o,getHttpClient:s});return await p({block:C})},Uo=(e,t)=>{let n=e?.next,r=(0,c.notMissing)(n)&&t.operationType===`list`?(0,f.expandCursor)(n):void 0;if(r===null)throw new ro(t,`Invalid cursor.`);return r},Wo=async({account:e,connector:t,category:n,path:r,method:i=`get`,queryParams:a={},body:o,headers:s,logger:l,getHttpClient:u,parseConnector:d=ka,getOperationFromUrlFn:f=ee,getOperationForRefreshAuthenticationFn:p=Ja,parseOperationInputsFn:m=Va,createBlockContextFn:h=lo,createBlockFn:_=g,runStepOperationFn:v=No})=>{let y=e.authConfigKey,b=e.environment??`production`,x=e.secureId,te=e.projectSecureId,ne=e.credentials,S=h({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:y,environment:b,accountSecureId:x,projectSecureId:te}),C;try{C=(0,c.isString)(t)?d(t):t}catch{throw new eo(S,`Error while parsing connector`)}let w=Ko(r)?p(C,y,b):f(C,r,i);if((0,c.isMissing)(w))throw new to(S,`No matching operation found`);S.operationType=w.operation.operationType,S.schema=w.operation.schema?.key;let T=Go(a,S),E;try{E=m(w.operation,{query:a,body:o,headers:s,path:w.params})}catch{throw new no(S,`Error while parsing operation inputs`)}let D=await _({connector:C,inputs:E,context:S,operation:w.operation,credentials:ne,nextCursor:T,logger:l,getHttpClient:u});return await v({block:D})},Go=(e,t)=>{let n=e?.next,r=(0,c.notMissing)(n)&&t.operationType===`list`?(0,f.expandCursor)(n):void 0;if(r===null)throw new ro(t,`Invalid cursor.`);return r},Ko=e=>e===so,qo=(e,t,n)=>e.authentication?.[t]?.[n]?.testOperations,Jo=async({account:e,connector:t,logger:n,getHttpClient:r,parseConnector:i=ka,getTestOperationsFn:a=qo,createBlockContextFn:o=lo,createBlockFn:s=g,runStepOperationFn:l=No})=>{let u=e.authConfigKey,d=e.environment??`production`,f=e.secureId,p=e.projectSecureId,m=e.credentials,_=o({category:`internal`,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:u,environment:d,accountSecureId:f,projectSecureId:p}),v;try{v=(0,c.isString)(t)?i(t):t}catch{throw new eo(_,`Error while parsing connector`)}let y=a(v,u,d);if((0,c.isMissing)(y)||y.length===0)return!0;_.operationType=`test`;for(let e of y){let t=await s({connector:v,inputs:void 0,context:_,operation:e.operation,credentials:m,nextCursor:void 0,logger:n,getHttpClient:r}),i=(0,c.notMissing)(e.condition)?(0,h.evaluate)(e.condition,t):!0;if(!i)continue;let a=await l({block:t});if(((0,c.isMissing)(a?.response?.successful)||!a.response.successful)&&e.required)return n?.error({code:`TestOperationFailed`,message:`Test operation "${e.operation.id}" failed with error: ${a?.response?.message}`}),!1}return!0};exports.ConnectSDKError=$,exports.REFRESH_TOKEN_OPERATION_PATH=so,exports.buildActionsMetaFromConfig=io,exports.createBlock=g,exports.executeStepFunction=co,exports.getActionsMetaFromConfigs=ao,exports.getOperationFromUrl=ee,exports.getRefreshTokenExpiresIn=Za,exports.getTokenExpiresIn=Xa,exports.loadConnector=_,exports.parseOperationInputs=Va,exports.parseYamlConnector=ka,exports.runConnectorAction=Ho,exports.runConnectorOperation=Wo,exports.runStepOperation=No,exports.runTestOperations=Jo,exports.supportsRefreshAuthentication=Ya,exports.validateYamlConnector=Qa;
|
|
28
|
+
path: iss.path ? [${A(e)}, ...iss.path] : [${A(e)}]
|
|
29
|
+
})));`),t.write(`newResult[${A(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=ue,o=!D.jitless,s=de,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?gn(e,s,t,f):hn(e,s,t))):i?gn(r,s,t,f):hn(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>hn(t,s,e))):hn(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 vn(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=>F(e,r,O())))}),t}const yn=w(`$ZodUnion`,(e,t)=>{R.init(e,t),k(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),k(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),k(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=>oe(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=>vn(t,n,e,r)):vn(a,n,e,r)}}),bn=w(`$ZodDiscriminatedUnion`,(e,t)=>{yn.init(e,t);let n=e._zod.parse;k(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=ie(()=>{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(!ue(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)}}),xn=w(`$ZodIntersection`,(e,t)=>{R.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])=>Cn(e,t,n)):Cn(e,i,a)}});function Sn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(fe(e)&&fe(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=Sn(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=Sn(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 Cn(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),N(e))return e;let r=Sn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const wn=w(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!fe(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(...P(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...P(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=>F(e,r,O())),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(...P(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...P(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Tn=w(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=ne(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>pe.has(typeof e)).map(e=>typeof e==`string`?me(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}}),En=w(`$ZodLiteral`,(e,t)=>{R.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?me(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}}),Dn=w(`$ZodTransform`,(e,t)=>{R.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 E;return e.value=r,e}}),On=w(`$ZodOptional`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oe(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)}),kn=w(`$ZodNullable`,(e,t)=>{R.init(e,t),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oe(e.source)}|null)$`):void 0}),k(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)}),An=w(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,k(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=>jn(e,t)):jn(r,t)}});function jn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Mn=w(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,k(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))}),Nn=w(`$ZodNonOptional`,(e,t)=>{R.init(e,t),k(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=>Pn(t,e)):Pn(i,e)}});function Pn(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 Fn=w(`$ZodCatch`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,k(e._zod,`optout`,()=>t.innerType._zod.optout),k(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=>F(e,n,O()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>F(e,n,O()))},input:e.value}),e.issues=[]),e)}}),In=w(`$ZodPipe`,(e,t)=>{R.init(e,t),k(e._zod,`values`,()=>t.in._zod.values),k(e._zod,`optin`,()=>t.in._zod.optin),k(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=>Ln(e,t,n)):Ln(r,t,n)}});function Ln(e,t,n){return N(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Rn=w(`$ZodReadonly`,(e,t)=>{R.init(e,t),k(e._zod,`propValues`,()=>t.innerType._zod.propValues),k(e._zod,`values`,()=>t.innerType._zod.values),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(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(zn):zn(r)}});function zn(e){return e.value=Object.freeze(e.value),e}const Bn=w(`$ZodLazy`,(e,t)=>{R.init(e,t),k(e._zod,`innerType`,()=>t.getter()),k(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),k(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),k(e._zod,`optin`,()=>e._zod.innerType._zod.optin),k(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>{let r=e._zod.innerType;return r._zod.run(t,n)}}),Vn=w(`$ZodCustom`,(e,t)=>{L.init(e,t),R.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=>Hn(t,n,r,e));Hn(i,n,r,e)}});function Hn(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(I(e))}}const Un=Symbol(`ZodOutput`),Wn=Symbol(`ZodInput`);var Gn=class{constructor(){this._map=new Map,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}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),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 Kn(){return new Gn}const qn=Kn();function Jn(e,t){return new e({type:`string`,...M(t)})}function Yn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}function Xn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}function Zn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}function Qn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}function tr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}function nr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}function rr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}function ir(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}function ar(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}function or(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}function sr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}function cr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}function lr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}function ur(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}function dr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}function fr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}function pr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}function mr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}function hr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}function gr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}function _r(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}function vr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}function yr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}function br(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}function xr(e,t){return new e({type:`number`,checks:[],...M(t)})}function Sr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}function Cr(e,t){return new e({type:`boolean`,...M(t)})}function wr(e){return new e({type:`any`})}function Tr(e){return new e({type:`unknown`})}function Er(e,t){return new e({type:`never`,...M(t)})}function Dr(e,t){return new gt({check:`less_than`,...M(t),value:e,inclusive:!1})}function Or(e,t){return new gt({check:`less_than`,...M(t),value:e,inclusive:!0})}function kr(e,t){return new _t({check:`greater_than`,...M(t),value:e,inclusive:!1})}function Ar(e,t){return new _t({check:`greater_than`,...M(t),value:e,inclusive:!0})}function jr(e,t){return new vt({check:`multiple_of`,...M(t),value:e})}function Mr(e,t){let n=new bt({check:`max_length`,...M(t),maximum:e});return n}function Nr(e,t){return new xt({check:`min_length`,...M(t),minimum:e})}function Pr(e,t){return new St({check:`length_equals`,...M(t),length:e})}function Fr(e,t){return new wt({check:`string_format`,format:`regex`,...M(t),pattern:e})}function Ir(e){return new Tt({check:`string_format`,format:`lowercase`,...M(e)})}function Lr(e){return new Et({check:`string_format`,format:`uppercase`,...M(e)})}function Rr(e,t){return new Dt({check:`string_format`,format:`includes`,...M(t),includes:e})}function zr(e,t){return new Ot({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}function Br(e,t){return new kt({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}function B(e){return new At({check:`overwrite`,tx:e})}function Vr(e){return B(t=>t.normalize(e))}function Hr(){return B(e=>e.trim())}function Ur(){return B(e=>e.toLowerCase())}function Wr(){return B(e=>e.toUpperCase())}function Gr(e,t,n){return new e({type:`array`,element:t,...M(n)})}function Kr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...M(n)});return r}const qr=w(`ZodISODateTime`,(e,t)=>{Gt.init(e,t),U.init(e,t)});function Jr(e){return _r(qr,e)}const Yr=w(`ZodISODate`,(e,t)=>{Kt.init(e,t),U.init(e,t)});function Xr(e){return vr(Yr,e)}const Zr=w(`ZodISOTime`,(e,t)=>{qt.init(e,t),U.init(e,t)});function Qr(e){return yr(Zr,e)}const $r=w(`ZodISODuration`,(e,t)=>{Jt.init(e,t),U.init(e,t)});function ei(e){return br($r,e)}const ti=(e,t)=>{Ee.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ke(e,t)},flatten:{value:t=>Oe(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},ni=w(`ZodError`,ti),ri=w(`ZodError`,ti,{Parent:Error}),ii=Ae(ri),ai=Me(ri),oi=Pe(ri),si=Ie(ri),V=w(`ZodType`,(e,t)=>(R.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)=>j(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ii(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>oi(e,t,n),e.parseAsync=async(t,n)=>ai(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>si(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(B(t)),e.optional=()=>Qi(e),e.nullable=()=>ea(e),e.nullish=()=>Qi(ea(e)),e.nonoptional=t=>oa(e,t),e.array=()=>q(e),e.or=t=>Vi([e,t]),e.and=t=>Gi(e,t),e.transform=t=>ua(e,Xi(t)),e.default=t=>na(e,t),e.prefault=t=>ia(e,t),e.catch=t=>ca(e,t),e.pipe=t=>ua(e,t),e.readonly=()=>fa(e),e.describe=t=>{let n=e.clone();return qn.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return qn.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return qn.get(e);let n=e.clone();return qn.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ci=w(`_ZodString`,(e,t)=>{Nt.init(e,t),V.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(Nr(...t)),e.max=(...t)=>e.check(Mr(...t)),e.length=(...t)=>e.check(Pr(...t)),e.nonempty=(...t)=>e.check(Nr(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())}),li=w(`ZodString`,(e,t)=>{Nt.init(e,t),ci.init(e,t),e.email=t=>e.check(Yn(ui,t)),e.url=t=>e.check(tr(pi,t)),e.jwt=t=>e.check(gr(Oi,t)),e.emoji=t=>e.check(nr(mi,t)),e.guid=t=>e.check(Xn(di,t)),e.uuid=t=>e.check(Zn(fi,t)),e.uuidv4=t=>e.check(Qn(fi,t)),e.uuidv6=t=>e.check($n(fi,t)),e.uuidv7=t=>e.check(er(fi,t)),e.nanoid=t=>e.check(rr(hi,t)),e.guid=t=>e.check(Xn(di,t)),e.cuid=t=>e.check(ir(gi,t)),e.cuid2=t=>e.check(ar(_i,t)),e.ulid=t=>e.check(or(vi,t)),e.base64=t=>e.check(pr(Ti,t)),e.base64url=t=>e.check(mr(Ei,t)),e.xid=t=>e.check(sr(yi,t)),e.ksuid=t=>e.check(cr(bi,t)),e.ipv4=t=>e.check(lr(xi,t)),e.ipv6=t=>e.check(ur(Si,t)),e.cidrv4=t=>e.check(dr(Ci,t)),e.cidrv6=t=>e.check(fr(wi,t)),e.e164=t=>e.check(hr(Di,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 H(e){return Jn(li,e)}const U=w(`ZodStringFormat`,(e,t)=>{z.init(e,t),ci.init(e,t)}),ui=w(`ZodEmail`,(e,t)=>{It.init(e,t),U.init(e,t)}),di=w(`ZodGUID`,(e,t)=>{Pt.init(e,t),U.init(e,t)}),fi=w(`ZodUUID`,(e,t)=>{Ft.init(e,t),U.init(e,t)}),pi=w(`ZodURL`,(e,t)=>{Lt.init(e,t),U.init(e,t)}),mi=w(`ZodEmoji`,(e,t)=>{Rt.init(e,t),U.init(e,t)}),hi=w(`ZodNanoID`,(e,t)=>{zt.init(e,t),U.init(e,t)}),gi=w(`ZodCUID`,(e,t)=>{Bt.init(e,t),U.init(e,t)}),_i=w(`ZodCUID2`,(e,t)=>{Vt.init(e,t),U.init(e,t)}),vi=w(`ZodULID`,(e,t)=>{Ht.init(e,t),U.init(e,t)}),yi=w(`ZodXID`,(e,t)=>{Ut.init(e,t),U.init(e,t)}),bi=w(`ZodKSUID`,(e,t)=>{Wt.init(e,t),U.init(e,t)}),xi=w(`ZodIPv4`,(e,t)=>{Yt.init(e,t),U.init(e,t)}),Si=w(`ZodIPv6`,(e,t)=>{Xt.init(e,t),U.init(e,t)}),Ci=w(`ZodCIDRv4`,(e,t)=>{Zt.init(e,t),U.init(e,t)}),wi=w(`ZodCIDRv6`,(e,t)=>{Qt.init(e,t),U.init(e,t)}),Ti=w(`ZodBase64`,(e,t)=>{en.init(e,t),U.init(e,t)}),Ei=w(`ZodBase64URL`,(e,t)=>{nn.init(e,t),U.init(e,t)}),Di=w(`ZodE164`,(e,t)=>{rn.init(e,t),U.init(e,t)}),Oi=w(`ZodJWT`,(e,t)=>{on.init(e,t),U.init(e,t)}),ki=w(`ZodNumber`,(e,t)=>{sn.init(e,t),V.init(e,t),e.gt=(t,n)=>e.check(kr(t,n)),e.gte=(t,n)=>e.check(Ar(t,n)),e.min=(t,n)=>e.check(Ar(t,n)),e.lt=(t,n)=>e.check(Dr(t,n)),e.lte=(t,n)=>e.check(Or(t,n)),e.max=(t,n)=>e.check(Or(t,n)),e.int=t=>e.check(ji(t)),e.safe=t=>e.check(ji(t)),e.positive=t=>e.check(kr(0,t)),e.nonnegative=t=>e.check(Ar(0,t)),e.negative=t=>e.check(Dr(0,t)),e.nonpositive=t=>e.check(Or(0,t)),e.multipleOf=(t,n)=>e.check(jr(t,n)),e.step=(t,n)=>e.check(jr(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 W(e){return xr(ki,e)}const Ai=w(`ZodNumberFormat`,(e,t)=>{cn.init(e,t),ki.init(e,t)});function ji(e){return Sr(Ai,e)}const Mi=w(`ZodBoolean`,(e,t)=>{ln.init(e,t),V.init(e,t)});function G(e){return Cr(Mi,e)}const Ni=w(`ZodAny`,(e,t)=>{un.init(e,t),V.init(e,t)});function Pi(){return wr(Ni)}const Fi=w(`ZodUnknown`,(e,t)=>{dn.init(e,t),V.init(e,t)});function K(){return Tr(Fi)}const Ii=w(`ZodNever`,(e,t)=>{fn.init(e,t),V.init(e,t)});function Li(e){return Er(Ii,e)}const Ri=w(`ZodArray`,(e,t)=>{mn.init(e,t),V.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Nr(t,n)),e.nonempty=t=>e.check(Nr(1,t)),e.max=(t,n)=>e.check(Mr(t,n)),e.length=(t,n)=>e.check(Pr(t,n)),e.unwrap=()=>e.element});function q(e,t){return Gr(Ri,e,t)}const zi=w(`ZodObject`,(e,t)=>{_n.init(e,t),V.init(e,t),k(e,`shape`,()=>t.shape),e.keyof=()=>X(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:K()}),e.loose=()=>e.clone({...e._zod.def,catchall:K()}),e.strict=()=>e.clone({...e._zod.def,catchall:Li()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>ye(e,t),e.merge=t=>be(e,t),e.pick=t=>_e(e,t),e.omit=t=>ve(e,t),e.partial=(...t)=>xe(Zi,e,t[0]),e.required=(...t)=>Se(aa,e,t[0])});function J(e,t){let n={type:`object`,get shape(){return ce(this,`shape`,{...e}),this.shape},...M(t)};return new zi(n)}const Bi=w(`ZodUnion`,(e,t)=>{yn.init(e,t),V.init(e,t),e.options=t.options});function Vi(e,t){return new Bi({type:`union`,options:e,...M(t)})}const Hi=w(`ZodDiscriminatedUnion`,(e,t)=>{Bi.init(e,t),bn.init(e,t)});function Ui(e,t,n){return new Hi({type:`union`,options:t,discriminator:e,...M(n)})}const Wi=w(`ZodIntersection`,(e,t)=>{xn.init(e,t),V.init(e,t)});function Gi(e,t){return new Wi({type:`intersection`,left:e,right:t})}const Ki=w(`ZodRecord`,(e,t)=>{wn.init(e,t),V.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,n){return new Ki({type:`record`,keyType:e,valueType:t,...M(n)})}const qi=w(`ZodEnum`,(e,t)=>{Tn.init(e,t),V.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 qi({...t,checks:[],...M(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 qi({...t,checks:[],...M(r),entries:i})}});function X(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new qi({type:`enum`,entries:n,...M(t)})}const Ji=w(`ZodLiteral`,(e,t)=>{En.init(e,t),V.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 Z(e,t){return new Ji({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}const Yi=w(`ZodTransform`,(e,t)=>{Dn.init(e,t),V.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(I(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(I(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Xi(e){return new Yi({type:`transform`,transform:e})}const Zi=w(`ZodOptional`,(e,t)=>{On.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Qi(e){return new Zi({type:`optional`,innerType:e})}const $i=w(`ZodNullable`,(e,t)=>{kn.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ea(e){return new $i({type:`nullable`,innerType:e})}const ta=w(`ZodDefault`,(e,t)=>{An.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function na(e,t){return new ta({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const ra=w(`ZodPrefault`,(e,t)=>{Mn.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ia(e,t){return new ra({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const aa=w(`ZodNonOptional`,(e,t)=>{Nn.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function oa(e,t){return new aa({type:`nonoptional`,innerType:e,...M(t)})}const sa=w(`ZodCatch`,(e,t)=>{Fn.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ca(e,t){return new sa({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const la=w(`ZodPipe`,(e,t)=>{In.init(e,t),V.init(e,t),e.in=t.in,e.out=t.out});function ua(e,t){return new la({type:`pipe`,in:e,out:t})}const da=w(`ZodReadonly`,(e,t)=>{Rn.init(e,t),V.init(e,t)});function fa(e){return new da({type:`readonly`,innerType:e})}const pa=w(`ZodLazy`,(e,t)=>{Bn.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.getter()});function ma(e){return new pa({type:`lazy`,getter:e})}const ha=w(`ZodCustom`,(e,t)=>{Vn.init(e,t),V.init(e,t)});function ga(e){let t=new L({check:`custom`});return t._zod.check=e,t}function _a(e,t={}){return Kr(ha,e,t)}function va(e){let t=ga(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(I(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(I(r))}},e(n.value,n)));return t}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`refresh_token`:return{statusCode:200,description:`The refresh token 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:H(),label:H(),required:G().optional().default(!1),secret:G().optional().default(!1),readOnly:G().optional().default(!1),placeholder:H().optional(),description:H().optional(),tooltip:H().optional()},Ca=Ui(`type`,[J({...Sa,type:X([`text`,`password`])}),J({...Sa,type:Z(`select`),options:J({value:H(),label:H()}).array()})]),wa=J({targetFieldKey:H(),alias:H().optional(),expression:H().optional(),values:K().optional(),type:X([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:G().default(!1),custom:G().default(!1),hidden:G().default(!1),enumMapper:J({matcher:X([`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(J({matchExpression:H(),value:H()}).array())}).optional(),properties:ma(()=>wa).array().optional()}),Ta=J({name:H(),type:X([`string`,`number`,`boolean`,`datetime_string`,`object`]),required:G(),description:H(),array:G().optional().default(!1),in:X([`body`,`query`,`path`,`headers`]),properties:ma(()=>Ta.omit({in:!0})).array().optional()}),Ea=J({operationId:H(),categories:H().array(),operationType:X([`list`,`get`,`create`,`update`,`delete`,`custom`,`refresh_token`,`unknown`]),schema:H().optional(),schemaType:X([`native`,`unified`]).optional().default(`native`),entrypointUrl:H().optional(),entrypointHttpMethod:H().optional(),label:H(),description:H(),tags:H().array().optional(),context:H().optional(),responses:J({statusCode:W(),description:H()}).array().optional(),inputs:Ta.array().optional(),cursor:J({enabled:G(),pageSize:W()}).optional(),compositeIdentifiers:J({enabled:G(),version:W().optional(),fields:J({targetFieldKey:H(),remote:H().optional(),components:H().array()}).array().optional()}).optional(),scheduledJobs:J({enabled:G(),type:X([`data_sync`]),schedule:H(),description:H(),requestParams:J({fields:H().array().optional(),expand:H().array().optional(),filter:Y(H(),H()).optional()}).optional(),syncFilter:J({name:X([`updated_after`,`created_after`]),initialLoopbackPeriod:H(),incrementalLoopbackPeriod:H()}).optional()}).array().optional(),fieldConfigs:wa.array().optional(),steps:J({stepId:H(),description:H(),stepFunction:J({functionName:H(),version:H().optional(),parameters:Y(H(),K())}),condition:H().optional(),ignoreError:G().optional()}).array(),result:H().or(Y(H(),K())).optional()}),Da=J({schedule:H().optional(),operation:Ea.extend({operationType:Z(`refresh_token`)})}),Oa=J({mainRatelimit:W(),subPools:q(J({subPoolKey:H(),urlPattern:H(),rateLimit:W()})).optional(),mappedRateLimitErrors:q(J({errorStatus:W(),errorMessage:H(),errorMessagePath:H().optional(),retryAfterPath:H().optional(),retryAfterUnit:Vi([Z(`seconds`),Z(`milliseconds`),Z(`date`)]).optional(),retryAfterValue:W().optional()})).optional()}),ka=J({mainMaxConcurrency:W(),subPools:q(J({subPoolKey:H(),urlPattern:H(),maxConcurrency:W()})).optional()}),Aa=J({StackOne:H(),info:J({title:H(),version:H(),key:H(),assets:J({icon:H()}),description:H().optional()}),context:H().optional(),baseUrl:H(),authentication:Y(H(),J({type:H(),label:H(),authorization:f.AUTHENTICATION_SCHEMA,environments:J({key:H(),name:H()}).array(),support:J({link:H(),description:H().optional()}),configFields:Ca.array().optional(),setupFields:Ca.array().optional(),refreshAuthentication:Da.optional(),testOperations:J({operation:H().or(Ea),condition:H().optional(),required:G().default(!0)}).array().optional()})).array().optional(),operations:Ea.array().optional(),rateLimit:Oa.optional(),concurrency:ka.optional()});function ja(e){try{let t=(0,m.parse)(e),n=Aa.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description,context:n.context,rateLimit:n.rateLimit,concurrency:n.concurrency},i=Fa(n),a={baseUrl:n.baseUrl,authentication:Ma(i)},o=Va(n,a);return r.operations=o,Na(i,o,a),r.authentication=i,(0,c.notMissing)(o)&&(r.categories=Pa(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Ma=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,refreshAuthentication:o,testOperations:s,...c}=r;t[n]=Ma(c)}else t[n]=r;return t},Na=(e,t,n)=>{if(!(!e||!t))for(let r of Object.values(e))for(let e of Object.values(r)){let r=e.testOperations;e.testOperations=r?.map(e=>{if((0,c.notMissing)(e.operation))if(typeof e.operation==`string`){let n=e.operation,r=Object.values(t).find(e=>e.id===n);if(r)return{...e,operation:r}}else{let t=Ha(e.operation,n);return{...e,operation:t}}return e})}},Pa=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},Fa=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,refreshAuthentication:s,testOperations:l,...u}=n[e],d=(0,c.notMissing)(s)?{schedule:s.schedule,operation:Ha(s.operation)}:void 0;return t[i]={...u,refreshAuthentication:d,envKey:i,envName:a,testOperations:l},t},{});t[e]=r}return t},Ia=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,La=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Ra=e=>{if(e.operationType!==`refresh_token`)return e.entrypointHttpMethod??`get`},za=e=>{if(!(e.operationType===`refresh_token`||(0,c.isMissing)(e.schema)))return e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`},Ba=e=>{let t={success:ba(e.operationType),errors:xa()},n=e.responses?.reduce((e,t)=>{let n=(0,p.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},Va=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=Ia(n),i=La(n);return e[r??i]=Ha(n,t),e},{});return n},Ha=(e,t)=>{let n=za(e),r=Ba(e),i=Ga(e),a=e.inputs||[];i.enabled&&a?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`,array:!1});let o=Ra(e);return{id:e.operationId,categories:e.categories,label:e.label,description:e.description,operationType:e.operationType,schemaType:e.schemaType??`native`,entrypointUrl:e.entrypointUrl??n,entrypointHttpMethod:o,tags:e.tags,context:e.context,responses:r,cursor:i,compositeIdentifiers:Ka(e),scheduledJobs:qa(e),inputs:a,steps:e.steps.reduce((n,r)=>(n[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,...Ja(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:r.stepFunction.parameters.fields??e.fieldConfigs}:{}}}},n),{}),result:e.result}},Ua=(e,t)=>{if(!e.inputs)return{};let n=Wa(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Q=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=H();break;case`number`:n=W();break;case`boolean`:n=G();break;case`datetime_string`:n=H().refine(e=>!isNaN(Date.parse(e)),{message:`Invalid datetime string`});break;case`object`:n=e.properties?Q(e.properties):Y(H(),Pi());break;default:n=Pi()}let r=e.array?q(n):n;t[e.name]=e.required?r:r.optional()}),J(t)},Wa=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 J({path:Q(t).optional(),query:Q(n).optional(),body:Q(r).optional(),headers:Q(i).optional()})},Ga=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ya};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Ka=e=>{if(e.operationType===`refresh_token`)return{enabled:!1};if((0,c.isMissing)(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=(0,c.notMissing)(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:f.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}},qa=e=>{if(!(0,c.isMissing)(e.scheduledJobs))return e.scheduledJobs},Ja=(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{}},Ya=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return;let r=e.authentication?.[t]?.[n]?.refreshAuthentication?.operation;if((0,c.notMissing)(r))return{operation:r,params:{}}},Xa=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return!1;let r=Ya(e,t,n);return(0,c.notMissing)(r)},Za=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenExpiresIn},Qa=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenRefreshExpiresIn},$a=e=>{try{let t=[],n=(0,m.parse)(e),r=Aa.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=eo(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}]}}},eo=(e,t)=>{let n=t.split(`
|
|
30
|
+
`),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,l=o.replace(`- `,``).trim();if(l.startsWith(`#`)||l===``||s<=i)continue;let u=(0,c.notMissing)(e[r])?`${String(e[r])}`:``;if((0,c.isMissing)(u))return a+1;if(isNaN(Number(u))){if(l.startsWith(`${u}:`)){if(r===e.length-1)return t+1;i=s,a=t,r++}}else{let e=parseInt(u,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}`}},to=class extends ${constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},no=class extends ${constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},ro=class extends ${constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},io=class extends ${constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const ao=(e,t)=>{let n=Object.keys(e.authentication??{}).map(t=>({type:`custom`,label:e.authentication?.[t].production?.label||`Custom`,key:t})),r=Object.values(e?.operations??{}).map(e=>({id:e.id,description:e.description.replace(/\b\w/g,e=>e.toUpperCase()),label:e.label.replace(/\b\w/g,e=>e.toUpperCase()),schema_type:e.schemaType,tags:e.tags,authentication:n,operation_details:t?.includes(`operation_details`)?e:void 0}));return{version:e.version,name:e.description,key:e.key,icon:e.assets?.icon,description:e.description,authentication:n,actions:r}},oo=(e,t)=>e.map(e=>ao(e,t)),so=`stackone://internal//`,co=`${so}refresh_token`,lo=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=f.StepFunctionsFactory.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===f.StepFunctionName.MAP_FIELDS?{[f.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},uo=({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}),fo=e=>{let t=e.operation?.compositeIdentifiers,n={...e.inputs??{}};if(!t?.enabled||(0,c.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??f.COMPOSITE_ID_LATEST_VERSION,aliases:r};return po(n,i,e.logger),{...e,inputs:n}},po=(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`))yo(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)po(e,t,n);else typeof i==`object`&&i&&po(i,t,n)}},mo=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=(0,f.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}},ho=(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]})},go=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},_o=(e,t,n,r,i)=>{n.every(go)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},vo=(e,t,n)=>{e instanceof f.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})},yo=(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}=mo(o,t,r,i);ho(n,t,s,a),_o(n,t,s,c,a)}catch(e){vo(e,t,i)}},bo=`remote_`,xo=e=>{let t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;let n=`data`,r=e.outputs?.[n];if((0,c.isMissing)(r))return e;let i=Array.isArray(r)?r.map(e=>So(e,t)):So(r,t);return{...e,outputs:{...e.outputs??{},[n]:i}}},So=(e,t)=>{let n=Co(e,t),r=jo(n);return{...e,...(0,c.isObject)(r)?r:{}}},Co=(e,t)=>{let n=t.version??f.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,f.encodeCompositeId)(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${bo}${t.remote}`]=e[t.remote])}),{...e,...r}},wo=e=>e===`id`||/.+_id(s)?$/.test(e),To=e=>Array.isArray(e)&&e.every(e=>(0,c.isString)(e)&&e.length>0),Eo=(e,t)=>(0,f.isCompositeId)(e)||t.startsWith(bo),Do=(e,t)=>{try{return(0,f.encodeCompositeId)({key:e,value:t},{version:f.COMPOSITE_ID_LATEST_VERSION})}catch{return t}},Oo=(e,t,n)=>{let r=t.map(t=>(0,c.isString)(t)&&t.length>0&&!(0,f.isCompositeId)(t)?Do(e,t):t);n[e]=r,n[`${bo}${e}`]=t},ko=(e,t,n)=>{if(Eo(t,e))return;let r=(0,f.encodeCompositeId)({key:e,value:t},{version:f.COMPOSITE_ID_LATEST_VERSION});n[e]=r,n[`remote_${e}`]=t},Ao=(e,t,n)=>{To(t)?Oo(e,t,n):(0,c.isString)(t)&&t.length>0&&ko(e,t,n)},jo=e=>{if(Array.isArray(e))return e.map(e=>jo(e));if(!(0,c.isObject)(e))return e;let t={...e};for(let[n,r]of Object.entries(e))((0,c.isObject)(r)||Array.isArray(r)&&r.length>0&&(0,c.isObject)(r[0]))&&(t[n]=jo(r)),wo(n)&&Ao(n,r,t);return t},Mo=(e,t)=>{let n=Number(e.inputs?.page_size),r=(0,c.notMissing)(e.inputs?.page_size)&&(0,c.isNumber)(n)&&!Number.isNaN(n)?n:e.operation?.cursor?.pageSize??t;return r},No=(e,t,n,r)=>{let i=(0,c.isMissing)(e)?void 0:e.data,a=Object.keys(n).length+1,o=(0,f.isCursorEmpty)({cursor:r,ignoreStepIndex:a});if(!(0,c.isObject)(e)||(0,c.isMissing)(i)||(i?.length??0)<=t)return{result:e,next:(0,c.notMissing)(r)&&!o?(0,f.minifyCursor)(r):null};let s=r?.remote?.[a]?.pageNumber??1,l=(s-1)*t,u=l+t,d=i.slice(l,u),p=i.length>u||!o,m=(0,f.updateCursor)({cursor:r,stepIndex:a,pageNumber:s+1});return{result:{...e,data:d},next:p?(0,f.minifyCursor)(m):null}},Po=async({block:e,buildStepFunction:t=f.StepFunctionsFactory.build,virtualPaginateResultFn:n=No,encodeResultCompositeIds:r=xo,decodeInputCompositeIds:i=fo})=>{let a=i(e),o=await Bo({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},Fo=(e,t)=>e.condition?!(0,h.safeEvaluate)(e.condition,t):!1,Io=(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??{}},Lo=(e,t,n,r,i)=>{let a=Ho({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},Ro=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(Fo(o,r))return Ho({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return Ho({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=Io(o,r,t),u=await c({block:r,params:l});if(u.successful===!1)return Lo(r,e,u,o,i);let d=r.operation?.cursor.enabled?(0,f.updateCursor)({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return Ho({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},zo=(e,t,n,r,i)=>{let a=!n.hasFatalError,o=a?e.operation?.responses.success.statusCode??200:n.errorStatusCode??500,s=(0,c.notMissing)(i)&&(0,c.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??p.HttpErrorMessages?.[o]??`Error while processing the request`}}},Bo=async({block:e,buildStepFunction:t=f.StepFunctionsFactory.build,virtualPaginateResultFn:n=No})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=Mo(e,ya),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await Ro(t,e,r,i,s,c);let l=e.operation?.result?Vo(e.operation.result,i):void 0,u=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return zo(e,i,s,l,u)},Vo=(e,t)=>(0,c.isObject)(e)?(0,h.safeEvaluateRecord)(e,t):(0,h.safeEvaluate)(e,t),Ho=({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}}}),Uo=async({operationId:e,account:t,connector:n,pathParams:r={},queryParams:i={},body:a={},headers:o={},logger:s,getHttpClient:l,parseConnector:u=ja,parseOperationInputsFn:d=Ua,createBlockContextFn:f=uo,createBlockFn:p=g,runStepOperationFn:m=Po})=>{let h=t.authConfigKey,_=t.environment??`production`,v=t.secureId,y=t.projectSecureId,ee=t.credentials,b=f({category:`action`,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:h,environment:_,accountSecureId:v,projectSecureId:y}),x;try{x=(0,c.isString)(n)?u(n):n}catch{throw new to(b,`Error while parsing connector`)}let S=te(n,e);if((0,c.isMissing)(S))throw new no(b,`No matching operation found`);b.operationType=S.operationType,b.schema=S.schema?.key;let C=Wo(i,b),w;try{w=d(S,{path:r,query:i,body:a,headers:o})}catch{throw new ro(b,`Error while parsing operation inputs`)}let T=await p({connector:x,inputs:w,context:b,operation:S,credentials:ee,nextCursor:C,logger:s,getHttpClient:l});return await m({block:T})},Wo=(e,t)=>{let n=e?.next,r=(0,c.notMissing)(n)&&t.operationType===`list`?(0,f.expandCursor)(n):void 0;if(r===null)throw new io(t,`Invalid cursor.`);return r},Go=async({account:e,connector:t,category:n,path:r,method:i=`get`,queryParams:a={},body:o,headers:s,logger:l,getHttpClient:u,parseConnector:d=ja,getOperationFromUrlFn:f=b,getOperationForRefreshAuthenticationFn:p=Ya,parseOperationInputsFn:m=Ua,createBlockContextFn:h=uo,createBlockFn:_=g,runStepOperationFn:v=Po})=>{let y=e.authConfigKey,ee=e.environment??`production`,x=e.secureId,S=e.projectSecureId,te=e.credentials,C=h({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:y,environment:ee,accountSecureId:x,projectSecureId:S}),w;try{w=(0,c.isString)(t)?d(t):t}catch{throw new to(C,`Error while parsing connector`)}let T=qo(r)?p(w,y,ee):f(w,r,i);if((0,c.isMissing)(T))throw new no(C,`No matching operation found`);C.operationType=T.operation.operationType,C.schema=T.operation.schema?.key;let E=Ko(a,C),D;try{D=m(T.operation,{query:a,body:o,headers:s,path:T.params})}catch{throw new ro(C,`Error while parsing operation inputs`)}let O=await _({connector:w,inputs:D,context:C,operation:T.operation,credentials:te,nextCursor:E,logger:l,getHttpClient:u});return await v({block:O})},Ko=(e,t)=>{let n=e?.next,r=(0,c.notMissing)(n)&&t.operationType===`list`?(0,f.expandCursor)(n):void 0;if(r===null)throw new io(t,`Invalid cursor.`);return r},qo=e=>e===co,Jo=(e,t,n)=>e.authentication?.[t]?.[n]?.testOperations,Yo=async({account:e,connector:t,logger:n,getHttpClient:r,parseConnector:i=ja,getTestOperationsFn:a=Jo,createBlockContextFn:o=uo,createBlockFn:s=g,runStepOperationFn:l=Po})=>{let u=e.authConfigKey,d=e.environment??`production`,f=e.secureId,p=e.projectSecureId,m=e.credentials,_=o({category:`internal`,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:u,environment:d,accountSecureId:f,projectSecureId:p}),v;try{v=(0,c.isString)(t)?i(t):t}catch{throw new to(_,`Error while parsing connector`)}let y=a(v,u,d);if((0,c.isMissing)(y)||y.length===0)return!0;_.operationType=`test`;for(let e of y){let t=await s({connector:v,inputs:void 0,context:_,operation:e.operation,credentials:m,nextCursor:void 0,logger:n,getHttpClient:r}),i=(0,c.notMissing)(e.condition)?(0,h.evaluate)(e.condition,t):!0;if(!i)continue;let a=await l({block:t});if(((0,c.isMissing)(a?.response?.successful)||!a.response.successful)&&e.required)return n?.error({code:`TestOperationFailed`,message:`Test operation "${e.operation.id}" failed with error: ${a?.response?.message}`}),!1}return!0};exports.ConnectSDKError=$,exports.REFRESH_TOKEN_OPERATION_PATH=co,exports.buildActionsMetaFromConfig=ao,exports.createBlock=g,exports.executeStepFunction=lo,exports.getActionsMetaFromConfigs=oo,exports.getOperationFromUrl=b,exports.getRefreshTokenExpiresIn=Qa,exports.getTokenExpiresIn=Za,exports.loadConnector=_,exports.parseOperationInputs=Ua,exports.parseYamlConnector=ja,exports.runConnectorAction=Uo,exports.runConnectorOperation=Go,exports.runStepOperation=Po,exports.runTestOperations=Yo,exports.supportsRefreshAuthentication=Xa,exports.validateYamlConnector=$a;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{isMissing as e,isNumber as t,isObject as n,isString as r,notMissing as i}from"@stackone/utils";import{readFileSync as a}from"fs";import{dirname as o,join as s,resolve as c}from"path";import{match as l}from"path-to-regexp";import{AUTHENTICATION_SCHEMA as u,COMPOSITE_ID_LATEST_VERSION as d,CoreError as f,StepFunctionName as p,StepFunctionsFactory as m,decodeCompositeId as h,encodeCompositeId as g,expandCursor as _,isCompositeId as v,isCursorEmpty as y,minifyCursor as b,updateCursor as x}from"@stackone/core";import{HttpErrorMessages as
|
|
1
|
+
import{isMissing as e,isNumber as t,isObject as n,isString as r,notMissing as i}from"@stackone/utils";import{readFileSync as a}from"fs";import{dirname as o,join as s,resolve as c}from"path";import{match as l}from"path-to-regexp";import{AUTHENTICATION_SCHEMA as u,COMPOSITE_ID_LATEST_VERSION as d,CoreError as f,StepFunctionName as p,StepFunctionsFactory as m,decodeCompositeId as h,encodeCompositeId as g,expandCursor as _,isCompositeId as v,isCursorEmpty as y,minifyCursor as b,updateCursor as x}from"@stackone/core";import{HttpErrorMessages as ee,isSuccessStatusCode as S}from"@stackone/transport";import{parse as C}from"yaml";import{evaluate as w,safeEvaluate as T,safeEvaluateRecord as te}from"@stackone/expressions";const ne=async({connector:t,inputs:n,context:r,operation:i,credentials:a,nextCursor:o,logger:s,getHttpClient:c})=>{if(e(c))throw Error(`getHttpClient function is required`);let l=await c();return{connector:t,inputs:n,fieldConfigs:[],context:r,operation:i,credentials:a,nextCursor:o,httpClient:l,logger:s}},re=e=>{if(!e.endsWith(`.s1.yaml`))throw Error(`File must have .s1.yaml extension`);try{let t=a(e,`utf8`);if(!t.includes(`:`)||!t.includes(`$ref:`))return t;let n=t.split(`
|
|
2
2
|
`),r=ie(n,o(e));return r.join(`
|
|
3
3
|
`)}catch(e){throw Error(`Failed to process YAML file: ${e.message}`)}},ie=(e,t)=>{let n=[];for(let r of e)if(ae(r)){let e=r.match(/^(\s*)/)?.[1]?.length||0,i=r.split(`:`)[1]?.trim(),a=oe(i,t),o=a.map(t=>` `.repeat(e)+t);n.push(...o)}else n.push(r);return n},ae=e=>e.includes(`$ref:`),oe=(e,t)=>{let n=c(s(t,`${e.replaceAll(`'`,``)}.s1.partial.yaml`));try{let e=a(n,`utf8`);return e.split(`
|
|
4
4
|
`).filter(e=>e.trim()!==``)}catch(t){throw Error(`Failed to load partial file '${e}': ${t.message}`)}},se=(e,t,n)=>{let r=n.toUpperCase();if(!e.operations)return;let i=Object.keys(e.operations),a=le(t,r,i);if(a)return{operation:e.operations?.[a.path],params:a.params}},ce=e=>{let t=e.startsWith(`/`)?e.slice(1):e,n=t.endsWith(`/`)?t.slice(0,-1):t;return n},le=(e,t,n)=>{let r=ce(e);for(let e of n)if(e.startsWith(t)){let n=e.replace(`${t} `,``).trim(),i=l(ce(n)),a=i(ce(r));if(a!==!1)return{path:e,params:a.params}}},ue=(e,t)=>{let n=Object.keys(e.operations??{}).find(n=>e.operations?.[n]?.id===t);if(i(n))return e.operations?.[n]};Object.freeze({status:`aborted`});function E(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}Symbol(`zod_brand`);var D=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const de={};function O(e){return e&&Object.assign(de,e),de}function fe(e){let t=Object.values(e).filter(e=>typeof e==`number`),n=Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t);return n}function pe(e,t){return typeof t==`bigint`?t.toString():t}function me(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function he(e){return e==null}function ge(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _e(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}function k(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ve(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function A(e){return JSON.stringify(e)}const ye=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function be(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const xe=me(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function Se(e){if(be(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(be(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}const Ce=new Set([`string`,`number`,`symbol`]);function j(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function M(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function we(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Te={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ee(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;n[e]=r.shape[e]}return M(e,{...e._zod.def,shape:n,checks:[]})}function De(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;delete n[e]}return M(e,{...e._zod.def,shape:n,checks:[]})}function Oe(e,t){if(!Se(t))throw Error(`Invalid input to extend: expected a plain object`);let n={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ve(this,`shape`,n),n},checks:[]};return M(e,n)}function ke(e,t){return M(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ve(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function Ae(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t]}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return M(t,{...t._zod.def,shape:i,checks:[]})}function je(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=new e({type:`nonoptional`,innerType:r[t]})}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return M(t,{...t._zod.def,shape:i,checks:[]})}function P(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function F(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Me(e){return typeof e==`string`?e:e?.message}function I(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=Me(e.inst?._zod.def?.error?.(e))??Me(t?.error?.(e))??Me(n.customError?.(e))??Me(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ne(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function L(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Pe=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,pe,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Fe=E(`$ZodError`,Pe),Ie=E(`$ZodError`,Pe,{Parent:Error});function Le(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Re(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i],a=i===t.path.length-1;a?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const ze=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new D;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>I(e,a,O())));throw ye(t,i?.callee),t}return o.value},Be=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>I(e,a,O())));throw ye(t,i?.callee),t}return o.value},Ve=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new D;return a.issues.length?{success:!1,error:new(e??Fe)(a.issues.map(e=>I(e,i,O())))}:{success:!0,data:a.value}},He=Ve(Ie),Ue=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>I(e,i,O())))}:{success:!0,data:a.value}},We=Ue(Ie),Ge=/^[cC][^\s-]{8,}$/,Ke=/^[0-9a-z]+$/,qe=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Je=/^[0-9a-vA-V]{20}$/,Ye=/^[A-Za-z0-9]{27}$/,Xe=/^[a-zA-Z0-9_-]{21}$/,Ze=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$e=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,et=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function nt(){return new RegExp(tt,`u`)}const rt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,it=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,at=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ot=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,st=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ct=/^[A-Za-z0-9_-]*$/,lt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,ut=/^\+(?:[0-9]){6,14}[0-9]$/,dt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ft=RegExp(`^${dt}$`);function pt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`,n=typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;return n}function mt(e){return RegExp(`^${pt(e)}$`)}function ht(e){let t=pt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${dt}T(?:${r})$`)}const gt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},_t=/^\d+$/,vt=/^-?\d+(?:\.\d+)?/i,yt=/true|false/i,bt=/^[^A-Z]*$/,xt=/^[^a-z]*$/,R=E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),St={number:`number`,bigint:`bigint`,object:`date`},Ct=E(`$ZodCheckLessThan`,(e,t)=>{R.init(e,t);let n=St[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wt=E(`$ZodCheckGreaterThan`,(e,t)=>{R.init(e,t);let n=St[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tt=E(`$ZodCheckMultipleOf`,(e,t)=>{R.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);let r=typeof n.value==`bigint`?n.value%t.value===BigInt(0):_e(n.value,t.value)===0;r||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Et=E(`$ZodCheckNumberFormat`,(e,t)=>{R.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Te[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=_t)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Dt=E(`$ZodCheckMaxLength`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i<=t.maximum)return;let a=Ne(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ot=E(`$ZodCheckMinLength`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i>=t.minimum)return;let a=Ne(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kt=E(`$ZodCheckLengthEquals`,(e,t)=>{var n;R.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ne(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),At=E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;R.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),jt=E(`$ZodCheckRegex`,(e,t)=>{At.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Mt=E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=bt,At.init(e,t)}),Nt=E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=xt,At.init(e,t)}),Pt=E(`$ZodCheckIncludes`,(e,t)=>{R.init(e,t);let n=j(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ft=E(`$ZodCheckStartsWith`,(e,t)=>{R.init(e,t);let n=RegExp(`^${j(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),It=E(`$ZodCheckEndsWith`,(e,t)=>{R.init(e,t);let n=RegExp(`.*${j(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Lt=E(`$ZodCheckOverwrite`,(e,t)=>{R.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Rt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e,n=t.split(`
|
|
5
5
|
`).filter(e=>e),r=Math.min(...n.map(e=>e.length-e.trimStart().length)),i=n.map(e=>e.slice(r)).map(e=>` `.repeat(this.indent*2)+e);for(let e of i)this.content.push(e)}compile(){let e=Function,t=this?.args,n=this?.content??[``],r=[...n.map(e=>` ${e}`)];return new e(...t,r.join(`
|
|
6
|
-
`))}};const zt={major:4,minor:0,patch:0},z=E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=P(e),i;for(let a of t){if(a._zod.def.when){let t=a._zod.def.when(e);if(!t)continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new D;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=P(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=P(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new D;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=He(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return We(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Bt=E(`$ZodString`,(e,t)=>{z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=E(`$ZodStringFormat`,(e,t)=>{At.init(e,t),Bt.init(e,t)}),Vt=E(`$ZodGUID`,(e,t)=>{t.pattern??=Qe,B.init(e,t)}),Ht=E(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8},n=e[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=$e(n)}else t.pattern??=$e();B.init(e,t)}),Ut=E(`$ZodEmail`,(e,t)=>{t.pattern??=et,B.init(e,t)}),Wt=E(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:lt.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith(`/`)&&a.endsWith(`/`)?n.value=a.slice(0,-1):n.value=a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Gt=E(`$ZodEmoji`,(e,t)=>{t.pattern??=nt(),B.init(e,t)}),Kt=E(`$ZodNanoID`,(e,t)=>{t.pattern??=Xe,B.init(e,t)}),qt=E(`$ZodCUID`,(e,t)=>{t.pattern??=Ge,B.init(e,t)}),Jt=E(`$ZodCUID2`,(e,t)=>{t.pattern??=Ke,B.init(e,t)}),Yt=E(`$ZodULID`,(e,t)=>{t.pattern??=qe,B.init(e,t)}),Xt=E(`$ZodXID`,(e,t)=>{t.pattern??=Je,B.init(e,t)}),Zt=E(`$ZodKSUID`,(e,t)=>{t.pattern??=Ye,B.init(e,t)}),Qt=E(`$ZodISODateTime`,(e,t)=>{t.pattern??=ht(t),B.init(e,t)}),$t=E(`$ZodISODate`,(e,t)=>{t.pattern??=ft,B.init(e,t)}),en=E(`$ZodISOTime`,(e,t)=>{t.pattern??=mt(t),B.init(e,t)}),tn=E(`$ZodISODuration`,(e,t)=>{t.pattern??=Ze,B.init(e,t)}),nn=E(`$ZodIPv4`,(e,t)=>{t.pattern??=rt,B.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),rn=E(`$ZodIPv6`,(e,t)=>{t.pattern??=it,B.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),an=E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=at,B.init(e,t)}),on=E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ot,B.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function sn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const cn=E(`$ZodBase64`,(e,t)=>{t.pattern??=st,B.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{sn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ln(e){if(!ct.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return sn(n)}const un=E(`$ZodBase64URL`,(e,t)=>{t.pattern??=ct,B.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{ln(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),dn=E(`$ZodE164`,(e,t)=>{t.pattern??=ut,B.init(e,t)});function fn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const pn=E(`$ZodJWT`,(e,t)=>{B.init(e,t),e._zod.check=n=>{fn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),mn=E(`$ZodNumber`,(e,t)=>{z.init(e,t),e._zod.pattern=e._zod.bag.pattern??vt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),hn=E(`$ZodNumber`,(e,t)=>{Et.init(e,t),mn.init(e,t)}),gn=E(`$ZodBoolean`,(e,t)=>{z.init(e,t),e._zod.pattern=yt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),_n=E(`$ZodAny`,(e,t)=>{z.init(e,t),e._zod.parse=e=>e}),vn=E(`$ZodUnknown`,(e,t)=>{z.init(e,t),e._zod.parse=e=>e}),yn=E(`$ZodNever`,(e,t)=>{z.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function bn(e,t,n){e.issues.length&&t.issues.push(...F(n,e.issues)),t.value[n]=e.value}const xn=E(`$ZodArray`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>bn(t,n,e))):bn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function
|
|
6
|
+
`))}};const zt={major:4,minor:0,patch:0},z=E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=P(e),i;for(let a of t){if(a._zod.def.when){let t=a._zod.def.when(e);if(!t)continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new D;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=P(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=P(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new D;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=He(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return We(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Bt=E(`$ZodString`,(e,t)=>{z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=E(`$ZodStringFormat`,(e,t)=>{At.init(e,t),Bt.init(e,t)}),Vt=E(`$ZodGUID`,(e,t)=>{t.pattern??=Qe,B.init(e,t)}),Ht=E(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8},n=e[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=$e(n)}else t.pattern??=$e();B.init(e,t)}),Ut=E(`$ZodEmail`,(e,t)=>{t.pattern??=et,B.init(e,t)}),Wt=E(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:lt.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith(`/`)&&a.endsWith(`/`)?n.value=a.slice(0,-1):n.value=a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Gt=E(`$ZodEmoji`,(e,t)=>{t.pattern??=nt(),B.init(e,t)}),Kt=E(`$ZodNanoID`,(e,t)=>{t.pattern??=Xe,B.init(e,t)}),qt=E(`$ZodCUID`,(e,t)=>{t.pattern??=Ge,B.init(e,t)}),Jt=E(`$ZodCUID2`,(e,t)=>{t.pattern??=Ke,B.init(e,t)}),Yt=E(`$ZodULID`,(e,t)=>{t.pattern??=qe,B.init(e,t)}),Xt=E(`$ZodXID`,(e,t)=>{t.pattern??=Je,B.init(e,t)}),Zt=E(`$ZodKSUID`,(e,t)=>{t.pattern??=Ye,B.init(e,t)}),Qt=E(`$ZodISODateTime`,(e,t)=>{t.pattern??=ht(t),B.init(e,t)}),$t=E(`$ZodISODate`,(e,t)=>{t.pattern??=ft,B.init(e,t)}),en=E(`$ZodISOTime`,(e,t)=>{t.pattern??=mt(t),B.init(e,t)}),tn=E(`$ZodISODuration`,(e,t)=>{t.pattern??=Ze,B.init(e,t)}),nn=E(`$ZodIPv4`,(e,t)=>{t.pattern??=rt,B.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),rn=E(`$ZodIPv6`,(e,t)=>{t.pattern??=it,B.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),an=E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=at,B.init(e,t)}),on=E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ot,B.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function sn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const cn=E(`$ZodBase64`,(e,t)=>{t.pattern??=st,B.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{sn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ln(e){if(!ct.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return sn(n)}const un=E(`$ZodBase64URL`,(e,t)=>{t.pattern??=ct,B.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{ln(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),dn=E(`$ZodE164`,(e,t)=>{t.pattern??=ut,B.init(e,t)});function fn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const pn=E(`$ZodJWT`,(e,t)=>{B.init(e,t),e._zod.check=n=>{fn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),mn=E(`$ZodNumber`,(e,t)=>{z.init(e,t),e._zod.pattern=e._zod.bag.pattern??vt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),hn=E(`$ZodNumber`,(e,t)=>{Et.init(e,t),mn.init(e,t)}),gn=E(`$ZodBoolean`,(e,t)=>{z.init(e,t),e._zod.pattern=yt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),_n=E(`$ZodAny`,(e,t)=>{z.init(e,t),e._zod.parse=e=>e}),vn=E(`$ZodUnknown`,(e,t)=>{z.init(e,t),e._zod.parse=e=>e}),yn=E(`$ZodNever`,(e,t)=>{z.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function bn(e,t,n){e.issues.length&&t.issues.push(...F(n,e.issues)),t.value[n]=e.value}const xn=E(`$ZodArray`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>bn(t,n,e))):bn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Sn(e,t,n){e.issues.length&&t.issues.push(...F(n,e.issues)),t.value[n]=e.value}function Cn(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...F(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const wn=E(`$ZodObject`,(e,t)=>{z.init(e,t);let n=me(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof z))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=we(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});k(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new Rt([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=A(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=A(e);t.write(`
|
|
7
7
|
if (${n}.issues.length) {
|
|
8
8
|
if (input[${r}] === undefined) {
|
|
9
9
|
if (${r} in input) {
|
|
@@ -26,5 +26,5 @@ import{isMissing as e,isNumber as t,isObject as n,isString as r,notMissing as i}
|
|
|
26
26
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
27
27
|
...iss,
|
|
28
28
|
path: iss.path ? [${A(e)}, ...iss.path] : [${A(e)}]
|
|
29
|
-
})));`),t.write(`newResult[${A(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=be,o=!de.jitless,s=xe,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?Sn(e,s,t,f):V(e,s,t))):i?Sn(r,s,t,f):V(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>V(t,s,e))):V(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 wn(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=>I(e,r,O())))}),t}const Tn=E(`$ZodUnion`,(e,t)=>{z.init(e,t),k(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),k(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),k(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=>ge(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=>wn(t,n,e,r)):wn(a,n,e,r)}}),En=E(`$ZodDiscriminatedUnion`,(e,t)=>{Tn.init(e,t);let n=e._zod.parse;k(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=me(()=>{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(!be(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)}}),Dn=E(`$ZodIntersection`,(e,t)=>{z.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])=>kn(e,t,n)):kn(e,i,a)}});function On(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Se(e)&&Se(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=On(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=On(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 kn(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),P(e))return e;let r=On(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const An=E(`$ZodRecord`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Se(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(...F(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...F(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=>I(e,r,O())),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(...F(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...F(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),jn=E(`$ZodEnum`,(e,t)=>{z.init(e,t);let n=fe(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>Ce.has(typeof e)).map(e=>typeof e==`string`?j(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}}),Mn=E(`$ZodLiteral`,(e,t)=>{z.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?j(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}}),Nn=E(`$ZodTransform`,(e,t)=>{z.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 D;return e.value=r,e}}),Pn=E(`$ZodOptional`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(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)}),Fn=E(`$ZodNullable`,(e,t)=>{z.init(e,t),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(e.source)}|null)$`):void 0}),k(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)}),In=E(`$ZodDefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(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=>Ln(e,t)):Ln(r,t)}});function Ln(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Rn=E(`$ZodPrefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(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))}),zn=E(`$ZodNonOptional`,(e,t)=>{z.init(e,t),k(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=>Bn(t,e)):Bn(i,e)}});function Bn(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 Vn=E(`$ZodCatch`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(e._zod,`optout`,()=>t.innerType._zod.optout),k(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=>I(e,n,O()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>I(e,n,O()))},input:e.value}),e.issues=[]),e)}}),Hn=E(`$ZodPipe`,(e,t)=>{z.init(e,t),k(e._zod,`values`,()=>t.in._zod.values),k(e._zod,`optin`,()=>t.in._zod.optin),k(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=>Un(e,t,n)):Un(r,t,n)}});function Un(e,t,n){return P(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Wn=E(`$ZodReadonly`,(e,t)=>{z.init(e,t),k(e._zod,`propValues`,()=>t.innerType._zod.propValues),k(e._zod,`values`,()=>t.innerType._zod.values),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(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(Gn):Gn(r)}});function Gn(e){return e.value=Object.freeze(e.value),e}const Kn=E(`$ZodLazy`,(e,t)=>{z.init(e,t),k(e._zod,`innerType`,()=>t.getter()),k(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),k(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),k(e._zod,`optin`,()=>e._zod.innerType._zod.optin),k(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>{let r=e._zod.innerType;return r._zod.run(t,n)}}),qn=E(`$ZodCustom`,(e,t)=>{R.init(e,t),z.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=>Jn(t,n,r,e));Jn(i,n,r,e)}});function Jn(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(L(e))}}Symbol(`ZodOutput`),Symbol(`ZodInput`);var Yn=class{constructor(){this._map=new Map,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}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),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 Xn(){return new Yn}const H=Xn();function Zn(e,t){return new e({type:`string`,...N(t)})}function Qn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function $n(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function nr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function rr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function ir(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function ar(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function or(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function sr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function cr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function lr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function ur(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function dr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function fr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function pr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function mr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function hr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function gr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function _r(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function vr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function yr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function br(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function xr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Sr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function Cr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function wr(e,t){return new e({type:`number`,checks:[],...N(t)})}function Tr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Er(e,t){return new e({type:`boolean`,...N(t)})}function Dr(e){return new e({type:`any`})}function Or(e){return new e({type:`unknown`})}function kr(e,t){return new e({type:`never`,...N(t)})}function Ar(e,t){return new Ct({check:`less_than`,...N(t),value:e,inclusive:!1})}function jr(e,t){return new Ct({check:`less_than`,...N(t),value:e,inclusive:!0})}function Mr(e,t){return new wt({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Nr(e,t){return new wt({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Pr(e,t){return new Tt({check:`multiple_of`,...N(t),value:e})}function Fr(e,t){let n=new Dt({check:`max_length`,...N(t),maximum:e});return n}function Ir(e,t){return new Ot({check:`min_length`,...N(t),minimum:e})}function Lr(e,t){return new kt({check:`length_equals`,...N(t),length:e})}function Rr(e,t){return new jt({check:`string_format`,format:`regex`,...N(t),pattern:e})}function zr(e){return new Mt({check:`string_format`,format:`lowercase`,...N(e)})}function Br(e){return new Nt({check:`string_format`,format:`uppercase`,...N(e)})}function Vr(e,t){return new Pt({check:`string_format`,format:`includes`,...N(t),includes:e})}function Hr(e,t){return new Ft({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function Ur(e,t){return new It({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function U(e){return new Lt({check:`overwrite`,tx:e})}function Wr(e){return U(t=>t.normalize(e))}function Gr(){return U(e=>e.trim())}function Kr(){return U(e=>e.toLowerCase())}function qr(){return U(e=>e.toUpperCase())}function Jr(e,t,n){return new e({type:`array`,element:t,...N(n)})}function Yr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...N(n)});return r}const Xr=E(`ZodISODateTime`,(e,t)=>{Qt.init(e,t),K.init(e,t)});function Zr(e){return br(Xr,e)}const Qr=E(`ZodISODate`,(e,t)=>{$t.init(e,t),K.init(e,t)});function $r(e){return xr(Qr,e)}const ei=E(`ZodISOTime`,(e,t)=>{en.init(e,t),K.init(e,t)});function ti(e){return Sr(ei,e)}const ni=E(`ZodISODuration`,(e,t)=>{tn.init(e,t),K.init(e,t)});function ri(e){return Cr(ni,e)}const ii=(e,t)=>{Fe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Re(e,t)},flatten:{value:t=>Le(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};E(`ZodError`,ii);const ai=E(`ZodError`,ii,{Parent:Error}),oi=ze(ai),si=Be(ai),ci=Ve(ai),li=Ue(ai),W=E(`ZodType`,(e,t)=>(z.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)=>M(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>oi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ci(e,t,n),e.parseAsync=async(t,n)=>si(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>li(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(xa(t,n)),e.superRefine=t=>e.check(Sa(t)),e.overwrite=t=>e.check(U(t)),e.optional=()=>na(e),e.nullable=()=>ia(e),e.nullish=()=>na(ia(e)),e.nonoptional=t=>ua(e,t),e.array=()=>Vi(e),e.or=t=>Wi([e,t]),e.and=t=>Ji(e,t),e.transform=t=>ma(e,ea(t)),e.default=t=>oa(e,t),e.prefault=t=>ca(e,t),e.catch=t=>fa(e,t),e.pipe=t=>ma(e,t),e.readonly=()=>ga(e),e.describe=t=>{let n=e.clone();return H.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return H.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return H.get(e);let n=e.clone();return H.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ui=E(`_ZodString`,(e,t)=>{Bt.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(Rr(...t)),e.includes=(...t)=>e.check(Vr(...t)),e.startsWith=(...t)=>e.check(Hr(...t)),e.endsWith=(...t)=>e.check(Ur(...t)),e.min=(...t)=>e.check(Ir(...t)),e.max=(...t)=>e.check(Fr(...t)),e.length=(...t)=>e.check(Lr(...t)),e.nonempty=(...t)=>e.check(Ir(1,...t)),e.lowercase=t=>e.check(zr(t)),e.uppercase=t=>e.check(Br(t)),e.trim=()=>e.check(Gr()),e.normalize=(...t)=>e.check(Wr(...t)),e.toLowerCase=()=>e.check(Kr()),e.toUpperCase=()=>e.check(qr())}),di=E(`ZodString`,(e,t)=>{Bt.init(e,t),ui.init(e,t),e.email=t=>e.check(Qn(fi,t)),e.url=t=>e.check(ir(hi,t)),e.jwt=t=>e.check(yr(Ai,t)),e.emoji=t=>e.check(ar(gi,t)),e.guid=t=>e.check($n(pi,t)),e.uuid=t=>e.check(er(mi,t)),e.uuidv4=t=>e.check(tr(mi,t)),e.uuidv6=t=>e.check(nr(mi,t)),e.uuidv7=t=>e.check(rr(mi,t)),e.nanoid=t=>e.check(or(_i,t)),e.guid=t=>e.check($n(pi,t)),e.cuid=t=>e.check(sr(vi,t)),e.cuid2=t=>e.check(cr(yi,t)),e.ulid=t=>e.check(lr(bi,t)),e.base64=t=>e.check(gr(Di,t)),e.base64url=t=>e.check(_r(Oi,t)),e.xid=t=>e.check(ur(xi,t)),e.ksuid=t=>e.check(dr(Si,t)),e.ipv4=t=>e.check(fr(Ci,t)),e.ipv6=t=>e.check(pr(wi,t)),e.cidrv4=t=>e.check(mr(Ti,t)),e.cidrv6=t=>e.check(hr(Ei,t)),e.e164=t=>e.check(vr(ki,t)),e.datetime=t=>e.check(Zr(t)),e.date=t=>e.check($r(t)),e.time=t=>e.check(ti(t)),e.duration=t=>e.check(ri(t))});function G(e){return Zn(di,e)}const K=E(`ZodStringFormat`,(e,t)=>{B.init(e,t),ui.init(e,t)}),fi=E(`ZodEmail`,(e,t)=>{Ut.init(e,t),K.init(e,t)}),pi=E(`ZodGUID`,(e,t)=>{Vt.init(e,t),K.init(e,t)}),mi=E(`ZodUUID`,(e,t)=>{Ht.init(e,t),K.init(e,t)}),hi=E(`ZodURL`,(e,t)=>{Wt.init(e,t),K.init(e,t)}),gi=E(`ZodEmoji`,(e,t)=>{Gt.init(e,t),K.init(e,t)}),_i=E(`ZodNanoID`,(e,t)=>{Kt.init(e,t),K.init(e,t)}),vi=E(`ZodCUID`,(e,t)=>{qt.init(e,t),K.init(e,t)}),yi=E(`ZodCUID2`,(e,t)=>{Jt.init(e,t),K.init(e,t)}),bi=E(`ZodULID`,(e,t)=>{Yt.init(e,t),K.init(e,t)}),xi=E(`ZodXID`,(e,t)=>{Xt.init(e,t),K.init(e,t)}),Si=E(`ZodKSUID`,(e,t)=>{Zt.init(e,t),K.init(e,t)}),Ci=E(`ZodIPv4`,(e,t)=>{nn.init(e,t),K.init(e,t)}),wi=E(`ZodIPv6`,(e,t)=>{rn.init(e,t),K.init(e,t)}),Ti=E(`ZodCIDRv4`,(e,t)=>{an.init(e,t),K.init(e,t)}),Ei=E(`ZodCIDRv6`,(e,t)=>{on.init(e,t),K.init(e,t)}),Di=E(`ZodBase64`,(e,t)=>{cn.init(e,t),K.init(e,t)}),Oi=E(`ZodBase64URL`,(e,t)=>{un.init(e,t),K.init(e,t)}),ki=E(`ZodE164`,(e,t)=>{dn.init(e,t),K.init(e,t)}),Ai=E(`ZodJWT`,(e,t)=>{pn.init(e,t),K.init(e,t)}),ji=E(`ZodNumber`,(e,t)=>{mn.init(e,t),W.init(e,t),e.gt=(t,n)=>e.check(Mr(t,n)),e.gte=(t,n)=>e.check(Nr(t,n)),e.min=(t,n)=>e.check(Nr(t,n)),e.lt=(t,n)=>e.check(Ar(t,n)),e.lte=(t,n)=>e.check(jr(t,n)),e.max=(t,n)=>e.check(jr(t,n)),e.int=t=>e.check(Ni(t)),e.safe=t=>e.check(Ni(t)),e.positive=t=>e.check(Mr(0,t)),e.nonnegative=t=>e.check(Nr(0,t)),e.negative=t=>e.check(Ar(0,t)),e.nonpositive=t=>e.check(jr(0,t)),e.multipleOf=(t,n)=>e.check(Pr(t,n)),e.step=(t,n)=>e.check(Pr(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 wr(ji,e)}const Mi=E(`ZodNumberFormat`,(e,t)=>{hn.init(e,t),ji.init(e,t)});function Ni(e){return Tr(Mi,e)}const Pi=E(`ZodBoolean`,(e,t)=>{gn.init(e,t),W.init(e,t)});function J(e){return Er(Pi,e)}const Fi=E(`ZodAny`,(e,t)=>{_n.init(e,t),W.init(e,t)});function Ii(){return Dr(Fi)}const Li=E(`ZodUnknown`,(e,t)=>{vn.init(e,t),W.init(e,t)});function Y(){return Or(Li)}const Ri=E(`ZodNever`,(e,t)=>{yn.init(e,t),W.init(e,t)});function zi(e){return kr(Ri,e)}const Bi=E(`ZodArray`,(e,t)=>{xn.init(e,t),W.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Ir(t,n)),e.nonempty=t=>e.check(Ir(1,t)),e.max=(t,n)=>e.check(Fr(t,n)),e.length=(t,n)=>e.check(Lr(t,n)),e.unwrap=()=>e.element});function Vi(e,t){return Jr(Bi,e,t)}const Hi=E(`ZodObject`,(e,t)=>{Cn.init(e,t),W.init(e,t),k(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:Y()}),e.loose=()=>e.clone({...e._zod.def,catchall:Y()}),e.strict=()=>e.clone({...e._zod.def,catchall:zi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Oe(e,t),e.merge=t=>ke(e,t),e.pick=t=>Ee(e,t),e.omit=t=>De(e,t),e.partial=(...t)=>Ae(ta,e,t[0]),e.required=(...t)=>je(la,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return ve(this,`shape`,{...e}),this.shape},...N(t)};return new Hi(n)}const Ui=E(`ZodUnion`,(e,t)=>{Tn.init(e,t),W.init(e,t),e.options=t.options});function Wi(e,t){return new Ui({type:`union`,options:e,...N(t)})}const Gi=E(`ZodDiscriminatedUnion`,(e,t)=>{Ui.init(e,t),En.init(e,t)});function Ki(e,t,n){return new Gi({type:`union`,options:t,discriminator:e,...N(n)})}const qi=E(`ZodIntersection`,(e,t)=>{Dn.init(e,t),W.init(e,t)});function Ji(e,t){return new qi({type:`intersection`,left:e,right:t})}const Yi=E(`ZodRecord`,(e,t)=>{An.init(e,t),W.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Xi(e,t,n){return new Yi({type:`record`,keyType:e,valueType:t,...N(n)})}const Zi=E(`ZodEnum`,(e,t)=>{jn.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 Zi({...t,checks:[],...N(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 Zi({...t,checks:[],...N(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Zi({type:`enum`,entries:n,...N(t)})}const Qi=E(`ZodLiteral`,(e,t)=>{Mn.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 Q(e,t){return new Qi({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}const $i=E(`ZodTransform`,(e,t)=>{Nn.init(e,t),W.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(L(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(L(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ea(e){return new $i({type:`transform`,transform:e})}const ta=E(`ZodOptional`,(e,t)=>{Pn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function na(e){return new ta({type:`optional`,innerType:e})}const ra=E(`ZodNullable`,(e,t)=>{Fn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ia(e){return new ra({type:`nullable`,innerType:e})}const aa=E(`ZodDefault`,(e,t)=>{In.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function oa(e,t){return new aa({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const sa=E(`ZodPrefault`,(e,t)=>{Rn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ca(e,t){return new sa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const la=E(`ZodNonOptional`,(e,t)=>{zn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ua(e,t){return new la({type:`nonoptional`,innerType:e,...N(t)})}const da=E(`ZodCatch`,(e,t)=>{Vn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fa(e,t){return new da({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const pa=E(`ZodPipe`,(e,t)=>{Hn.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function ma(e,t){return new pa({type:`pipe`,in:e,out:t})}const ha=E(`ZodReadonly`,(e,t)=>{Wn.init(e,t),W.init(e,t)});function ga(e){return new ha({type:`readonly`,innerType:e})}const _a=E(`ZodLazy`,(e,t)=>{Kn.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.getter()});function va(e){return new _a({type:`lazy`,getter:e})}const ya=E(`ZodCustom`,(e,t)=>{qn.init(e,t),W.init(e,t)});function ba(e){let t=new R({check:`custom`});return t._zod.check=e,t}function xa(e,t={}){return Yr(ya,e,t)}function Sa(e){let t=ba(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(L(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(L(r))}},e(n.value,n)));return t}const Ca=25,wa=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`refresh_token`:return{statusCode:200,description:`The refresh token operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},Ta=()=>{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},Ea={key:G(),label:G(),required:J().optional().default(!1),secret:J().optional().default(!1),readOnly:J().optional().default(!1),placeholder:G().optional(),description:G().optional(),tooltip:G().optional()},Da=Ki(`type`,[X({...Ea,type:Z([`text`,`password`])}),X({...Ea,type:Q(`select`),options:X({value:G(),label:G()}).array()})]),Oa=X({targetFieldKey:G(),alias:G().optional(),expression:G().optional(),values:Y().optional(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:J().default(!1),custom:J().default(!1),hidden:J().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(),properties:va(()=>Oa).array().optional()}),ka=X({operationId:G(),categories:G().array(),operationType:Z([`list`,`get`,`create`,`update`,`delete`,`custom`,`refresh_token`,`unknown`]),schema:G().optional(),schemaType:Z([`native`,`unified`]).optional().default(`native`),entrypointUrl:G().optional(),entrypointHttpMethod:G().optional(),label:G(),description:G(),tags:G().array().optional(),context:G().optional(),responses:X({statusCode:q(),description:G()}).array().optional(),inputs:X({name:G(),type:G(),required:J(),description:G(),in:G()}).array().optional(),cursor:X({enabled:J(),pageSize:q()}).optional(),compositeIdentifiers:X({enabled:J(),version:q().optional(),fields:X({targetFieldKey:G(),remote:G().optional(),components:G().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:J(),type:Z([`data_sync`]),schedule:G(),description:G(),requestParams:X({fields:G().array().optional(),expand:G().array().optional(),filter:Xi(G(),G()).optional()}).optional(),syncFilter:X({name:Z([`updated_after`,`created_after`]),initialLoopbackPeriod:G(),incrementalLoopbackPeriod:G()}).optional()}).array().optional(),fieldConfigs:Oa.array().optional(),steps:X({stepId:G(),description:G(),stepFunction:X({functionName:G(),version:G().optional(),parameters:Xi(G(),Y())}),condition:G().optional(),ignoreError:J().optional()}).array(),result:G().or(Xi(G(),Y())).optional()}),Aa=X({schedule:G().optional(),operation:ka.extend({operationType:Q(`refresh_token`)})}),ja=X({mainRatelimit:q(),subPools:Vi(X({subPoolKey:G(),urlPattern:G(),rateLimit:q()})).optional(),mappedRateLimitErrors:Vi(X({errorStatus:q(),errorMessage:G(),errorMessagePath:G().optional(),retryAfterPath:G().optional(),retryAfterUnit:Wi([Q(`seconds`),Q(`milliseconds`),Q(`date`)]).optional(),retryAfterValue:q().optional()})).optional()}),Ma=X({mainMaxConcurrency:q(),subPools:Vi(X({subPoolKey:G(),urlPattern:G(),maxConcurrency:q()})).optional()}),Na=X({StackOne:G(),info:X({title:G(),version:G(),key:G(),assets:X({icon:G()}),description:G().optional()}),context:G().optional(),baseUrl:G(),authentication:Xi(G(),X({type:G(),label:G(),authorization:u,environments:X({key:G(),name:G()}).array(),support:X({link:G(),description:G().optional()}),configFields:Da.array().optional(),setupFields:Da.array().optional(),refreshAuthentication:Aa.optional(),testOperations:X({operation:G().or(ka),condition:G().optional(),required:J().default(!0)}).array().optional()})).array().optional(),operations:ka.array().optional(),rateLimit:ja.optional(),concurrency:Ma.optional()});function Pa(e){try{let t=C(e),n=Na.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description,context:n.context,rateLimit:n.rateLimit,concurrency:n.concurrency},a=Ra(n),o={baseUrl:n.baseUrl,authentication:Fa(a)},s=Wa(n,o);return r.operations=s,Ia(a,s,o),r.authentication=a,i(s)&&(r.categories=La(Object.values(s))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Fa=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,refreshAuthentication:o,testOperations:s,...c}=r;t[n]=Fa(c)}else t[n]=r;return t},Ia=(e,t,n)=>{if(!(!e||!t))for(let r of Object.values(e))for(let e of Object.values(r)){let r=e.testOperations;e.testOperations=r?.map(e=>{if(i(e.operation))if(typeof e.operation==`string`){let n=e.operation,r=Object.values(t).find(e=>e.id===n);if(r)return{...e,operation:r}}else{let t=Ga(e.operation,n);return{...e,operation:t}}return e})}},La=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},Ra=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:a,name:o}=r,{environments:s,refreshAuthentication:c,testOperations:l,...u}=n[e],d=i(c)?{schedule:c.schedule,operation:Ga(c.operation)}:void 0;return t[a]={...u,refreshAuthentication:d,envKey:a,envName:o,testOperations:l},t},{});t[e]=r}return t},za=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,Ba=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Va=e=>{if(e.operationType!==`refresh_token`)return e.entrypointHttpMethod??`get`},Ha=t=>{if(!(t.operationType===`refresh_token`||e(t.schema)))return t.operationType===`list`?`/${t.schema}`:`/${t.schema}/:id`},Ua=e=>{let t={success:wa(e.operationType),errors:Ta()},n=e.responses?.reduce((e,t)=>{let n=ee(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},Wa=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=za(n),i=Ba(n);return e[r??i]=Ga(n,t),e},{});return n},Ga=(e,t)=>{let n=Ha(e),r=Ua(e),i=Ya(e),a=e.inputs||[];i.enabled&&a?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`});let o=Va(e);return{id:e.operationId,categories:e.categories,label:e.label,description:e.description,operationType:e.operationType,schemaType:e.schemaType??`native`,entrypointUrl:e.entrypointUrl??n,entrypointHttpMethod:o,tags:e.tags,context:e.context,responses:r,cursor:i,compositeIdentifiers:Xa(e),scheduledJobs:Za(e),inputs:a,steps:e.steps.reduce((n,r)=>(n[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,...Qa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:r.stepFunction.parameters.fields??e.fieldConfigs}:{}}}},n),{}),result:e.result}},Ka=(e,t)=>{if(!e.inputs)return{};let n=Ja(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},qa=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=G();break;case`number`:n=q();break;case`boolean`:n=J();break;default:n=Ii()}t[e.name]=e.required?n:n.optional()}),X(t)},Ja=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:qa(t).optional(),query:qa(n).optional(),body:qa(r).optional(),headers:qa(i).optional()})},Ya=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:Ca};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Xa=t=>{if(t.operationType===`refresh_token`)return{enabled:!1};if(e(t.compositeIdentifiers)){let e=t.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=i(e)?[{targetFieldKey:e.targetFieldKey,remote:`id`,components:[{name:e.targetFieldKey,alias:e.alias}]}]:void 0;return{enabled:!0,version:d,fields:n}}let n=[];for(let e of t.compositeIdentifiers?.fields??[]){let r=e.components.map(e=>{let n=t.fieldConfigs?.find(t=>t.targetFieldKey===e);return{name:e,alias:n?.alias}});n.push({targetFieldKey:e.targetFieldKey,remote:e.remote,components:r})}return{enabled:t.compositeIdentifiers.enabled,version:t.compositeIdentifiers.version,fields:n.length>0?n:void 0}},Za=t=>{if(!e(t.scheduledJobs))return t.scheduledJobs},Qa=(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{}},$a=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return;let r=e.authentication?.[t]?.[n]?.refreshAuthentication?.operation;if(i(r))return{operation:r,params:{}}},eo=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return!1;let r=$a(e,t,n);return i(r)},to=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenExpiresIn},no=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenRefreshExpiresIn},ro=e=>{try{let t=[],n=C(e),r=Na.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=io(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}]}}},io=(t,n)=>{let r=n.split(`
|
|
30
|
-
`),a=0,o=-1,s=0;for(let n=0;n<r.length;n++){let c=r[n],l=c.match(/^(\s*)/)?.[1]?.length||0,u=c.replace(`- `,``).trim();if(u.startsWith(`#`)||u===``||l<=o)continue;let d=i(t[a])?`${String(t[a])}`:``;if(e(d))return s+1;if(isNaN(Number(d))){if(u.startsWith(`${d}:`)){if(a===t.length-1)return n+1;o=l,s=n,a++}}else{let e=parseInt(d,10),t=-1;for(let i=n;i<r.length;i++){let o=r[i],c=o.trim();if(c.startsWith(`-`)&&t++,t===e){a++,s=n,n--;break}else n++}}}return s+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}`}},ao=class extends ${constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},oo=class extends ${constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},so=class extends ${constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},co=class extends ${constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const lo=(e,t)=>{let n=Object.keys(e.authentication??{}).map(t=>({type:`custom`,label:e.authentication?.[t].production?.label||`Custom`,key:t})),r=Object.values(e?.operations??{}).map(e=>({id:e.id,description:e.description.replace(/\b\w/g,e=>e.toUpperCase()),label:e.label.replace(/\b\w/g,e=>e.toUpperCase()),schema_type:e.schemaType,tags:e.tags,authentication:n,operation_details:t?.includes(`operation_details`)?e:void 0}));return{version:e.version,name:e.description,key:e.key,icon:e.assets?.icon,description:e.description,authentication:n,actions:r}},uo=(e,t)=>e.map(e=>lo(e,t)),fo=`stackone://internal//`,po=`${fo}refresh_token`,mo=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=m.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===p.MAP_FIELDS?{[p.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},ho=({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}),go=t=>{let n=t.operation?.compositeIdentifiers,r={...t.inputs??{}};if(!n?.enabled||e(r))return t;let i=n.fields?.reduce((e,t)=>(t.components.forEach(t=>{t.alias&&(e[t.name]=t.alias)}),e),{}),a={version:n.version??d,aliases:i};return _o(r,a,t.logger),{...t,inputs:r}},_o=(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`))Co(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)_o(e,t,n);else typeof i==`object`&&i&&_o(i,t,n)}},vo=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=h(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}},yo=(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]})},bo=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},xo=(e,t,n,r,i)=>{n.every(bo)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},So=(e,t,n)=>{e instanceof f&&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})},Co=(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}=vo(o,t,r,i);yo(n,t,s,a),xo(n,t,s,c,a)}catch(e){So(e,t,i)}},wo=`remote_`,To=t=>{let n=t.operation?.compositeIdentifiers;if(!n?.enabled)return t;let r=`data`,i=t.outputs?.[r];if(e(i))return t;let a=Array.isArray(i)?i.map(e=>Eo(e,n)):Eo(i,n);return{...t,outputs:{...t.outputs??{},[r]:a}}},Eo=(e,t)=>{let r=Do(e,t),i=Fo(r);return{...e,...n(i)?i:{}}},Do=(e,t)=>{let n=t.version??d,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=g(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${wo}${t.remote}`]=e[t.remote])}),{...e,...r}},Oo=e=>e===`id`||/.+_id(s)?$/.test(e),ko=e=>Array.isArray(e)&&e.every(e=>r(e)&&e.length>0),Ao=(e,t)=>v(e)||t.startsWith(wo),jo=(e,t)=>{try{return g({key:e,value:t},{version:d})}catch{return t}},Mo=(e,t,n)=>{let i=t.map(t=>r(t)&&t.length>0&&!v(t)?jo(e,t):t);n[e]=i,n[`${wo}${e}`]=t},No=(e,t,n)=>{if(Ao(t,e))return;let r=g({key:e,value:t},{version:d});n[e]=r,n[`remote_${e}`]=t},Po=(e,t,n)=>{ko(t)?Mo(e,t,n):r(t)&&t.length>0&&No(e,t,n)},Fo=e=>{if(Array.isArray(e))return e.map(e=>Fo(e));if(!n(e))return e;let t={...e};for(let[r,i]of Object.entries(e))(n(i)||Array.isArray(i)&&i.length>0&&n(i[0]))&&(t[r]=Fo(i)),Oo(r)&&Po(r,i,t);return t},Io=(e,n)=>{let r=Number(e.inputs?.page_size),a=i(e.inputs?.page_size)&&t(r)&&!Number.isNaN(r)?r:e.operation?.cursor?.pageSize??n;return a},Lo=(t,r,a,o)=>{let s=e(t)?void 0:t.data,c=Object.keys(a).length+1,l=y({cursor:o,ignoreStepIndex:c});if(!n(t)||e(s)||(s?.length??0)<=r)return{result:t,next:i(o)&&!l?b(o):null};let u=o?.remote?.[c]?.pageNumber??1,d=(u-1)*r,f=d+r,p=s.slice(d,f),m=s.length>f||!l,h=x({cursor:o,stepIndex:c,pageNumber:u+1});return{result:{...t,data:p},next:m?b(h):null}},Ro=async({block:e,buildStepFunction:t=m.build,virtualPaginateResultFn:n=Lo,encodeResultCompositeIds:r=To,decodeInputCompositeIds:i=go})=>{let a=i(e),o=await Wo({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},zo=(e,t)=>e.condition?!T(e.condition,t):!1,Bo=(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??{}},Vo=(e,t,n,r,i)=>{let a=Ko({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},Ho=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(zo(o,r))return Ko({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return Ko({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=Bo(o,r,t),u=await c({block:r,params:l});if(u.successful===!1)return Vo(r,e,u,o,i);let d=r.operation?.cursor.enabled?x({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return Ko({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},Uo=(e,t,r,a,o)=>{let s=!r.hasFatalError,c=s?e.operation?.responses.success.statusCode??200:r.errorStatusCode??500,l=i(o)&&n(o.result)?{next:o.next,...o.result}:a;return{...t,outputs:l,response:{successful:s,statusCode:c,message:s?void 0:e.operation?.responses?.errors?.[c]?.description??S?.[c]??`Error while processing the request`}}},Wo=async({block:e,buildStepFunction:t=m.build,virtualPaginateResultFn:n=Lo})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=Io(e,Ca),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await Ho(t,e,r,i,s,c);let l=e.operation?.result?Go(e.operation.result,i):void 0,u=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return Uo(e,i,s,l,u)},Go=(e,t)=>n(e)?te(e,t):T(e,t),Ko=({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}}}),qo=async({operationId:t,account:n,connector:i,queryParams:a={},body:o,headers:s,logger:c,getHttpClient:l,parseConnector:u=Pa,parseOperationInputsFn:d=Ka,createBlockContextFn:f=ho,createBlockFn:p=ne,runStepOperationFn:m=Ro})=>{let h=n.authConfigKey,g=n.environment??`production`,_=n.secureId,v=n.projectSecureId,y=n.credentials,b=f({category:`action`,connectorKey:n.providerKey,connectorVersion:n.providerVersion,authConfigKey:h,environment:g,accountSecureId:_,projectSecureId:v}),x;try{x=r(i)?u(i):i}catch{throw new ao(b,`Error while parsing connector`)}let S=ue(i,t);if(e(S))throw new oo(b,`No matching operation found`);b.operationType=S.operationType,b.schema=S.schema?.key;let ee=Jo(a,b),C;try{C=d(S,{query:a,body:o,headers:s})}catch{throw new so(b,`Error while parsing operation inputs`)}let w=await p({connector:x,inputs:C,context:b,operation:S,credentials:y,nextCursor:ee,logger:c,getHttpClient:l});return await m({block:w})},Jo=(e,t)=>{let n=e?.next,r=i(n)&&t.operationType===`list`?_(n):void 0;if(r===null)throw new co(t,`Invalid cursor.`);return r},Yo=async({account:t,connector:n,category:i,path:a,method:o=`get`,queryParams:s={},body:c,headers:l,logger:u,getHttpClient:d,parseConnector:f=Pa,getOperationFromUrlFn:p=se,getOperationForRefreshAuthenticationFn:m=$a,parseOperationInputsFn:h=Ka,createBlockContextFn:g=ho,createBlockFn:_=ne,runStepOperationFn:v=Ro})=>{let y=t.authConfigKey,b=t.environment??`production`,x=t.secureId,S=t.projectSecureId,ee=t.credentials,C=g({category:i,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:y,environment:b,accountSecureId:x,projectSecureId:S}),w;try{w=r(n)?f(n):n}catch{throw new ao(C,`Error while parsing connector`)}let T=Zo(a)?m(w,y,b):p(w,a,o);if(e(T))throw new oo(C,`No matching operation found`);C.operationType=T.operation.operationType,C.schema=T.operation.schema?.key;let te=Xo(s,C),re;try{re=h(T.operation,{query:s,body:c,headers:l,path:T.params})}catch{throw new so(C,`Error while parsing operation inputs`)}let ie=await _({connector:w,inputs:re,context:C,operation:T.operation,credentials:ee,nextCursor:te,logger:u,getHttpClient:d});return await v({block:ie})},Xo=(e,t)=>{let n=e?.next,r=i(n)&&t.operationType===`list`?_(n):void 0;if(r===null)throw new co(t,`Invalid cursor.`);return r},Zo=e=>e===po,Qo=(e,t,n)=>e.authentication?.[t]?.[n]?.testOperations,$o=async({account:t,connector:n,logger:a,getHttpClient:o,parseConnector:s=Pa,getTestOperationsFn:c=Qo,createBlockContextFn:l=ho,createBlockFn:u=ne,runStepOperationFn:d=Ro})=>{let f=t.authConfigKey,p=t.environment??`production`,m=t.secureId,h=t.projectSecureId,g=t.credentials,_=l({category:`internal`,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:f,environment:p,accountSecureId:m,projectSecureId:h}),v;try{v=r(n)?s(n):n}catch{throw new ao(_,`Error while parsing connector`)}let y=c(v,f,p);if(e(y)||y.length===0)return!0;_.operationType=`test`;for(let t of y){let n=await u({connector:v,inputs:void 0,context:_,operation:t.operation,credentials:g,nextCursor:void 0,logger:a,getHttpClient:o}),r=i(t.condition)?w(t.condition,n):!0;if(!r)continue;let s=await d({block:n});if((e(s?.response?.successful)||!s.response.successful)&&t.required)return a?.error({code:`TestOperationFailed`,message:`Test operation "${t.operation.id}" failed with error: ${s?.response?.message}`}),!1}return!0};export{$ as ConnectSDKError,po as REFRESH_TOKEN_OPERATION_PATH,lo as buildActionsMetaFromConfig,ne as createBlock,mo as executeStepFunction,uo as getActionsMetaFromConfigs,se as getOperationFromUrl,no as getRefreshTokenExpiresIn,to as getTokenExpiresIn,re as loadConnector,Ka as parseOperationInputs,Pa as parseYamlConnector,qo as runConnectorAction,Yo as runConnectorOperation,Ro as runStepOperation,$o as runTestOperations,eo as supportsRefreshAuthentication,ro as validateYamlConnector};
|
|
29
|
+
})));`),t.write(`newResult[${A(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=be,o=!de.jitless,s=xe,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?Cn(e,s,t,f):Sn(e,s,t))):i?Cn(r,s,t,f):Sn(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>Sn(t,s,e))):Sn(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 Tn(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=>I(e,r,O())))}),t}const En=E(`$ZodUnion`,(e,t)=>{z.init(e,t),k(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),k(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),k(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=>ge(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=>Tn(t,n,e,r)):Tn(a,n,e,r)}}),Dn=E(`$ZodDiscriminatedUnion`,(e,t)=>{En.init(e,t);let n=e._zod.parse;k(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=me(()=>{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(!be(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)}}),On=E(`$ZodIntersection`,(e,t)=>{z.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])=>An(e,t,n)):An(e,i,a)}});function kn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Se(e)&&Se(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=kn(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=kn(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 An(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),P(e))return e;let r=kn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const jn=E(`$ZodRecord`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Se(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(...F(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...F(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=>I(e,r,O())),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(...F(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...F(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Mn=E(`$ZodEnum`,(e,t)=>{z.init(e,t);let n=fe(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>Ce.has(typeof e)).map(e=>typeof e==`string`?j(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}}),Nn=E(`$ZodLiteral`,(e,t)=>{z.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?j(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}}),Pn=E(`$ZodTransform`,(e,t)=>{z.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 D;return e.value=r,e}}),Fn=E(`$ZodOptional`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(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)}),In=E(`$ZodNullable`,(e,t)=>{z.init(e,t),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(e.source)}|null)$`):void 0}),k(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)}),Ln=E(`$ZodDefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(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=>Rn(e,t)):Rn(r,t)}});function Rn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zn=E(`$ZodPrefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(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))}),Bn=E(`$ZodNonOptional`,(e,t)=>{z.init(e,t),k(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=>Vn(t,e)):Vn(i,e)}});function Vn(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 Hn=E(`$ZodCatch`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,k(e._zod,`optout`,()=>t.innerType._zod.optout),k(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=>I(e,n,O()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>I(e,n,O()))},input:e.value}),e.issues=[]),e)}}),Un=E(`$ZodPipe`,(e,t)=>{z.init(e,t),k(e._zod,`values`,()=>t.in._zod.values),k(e._zod,`optin`,()=>t.in._zod.optin),k(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=>Wn(e,t,n)):Wn(r,t,n)}});function Wn(e,t,n){return P(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Gn=E(`$ZodReadonly`,(e,t)=>{z.init(e,t),k(e._zod,`propValues`,()=>t.innerType._zod.propValues),k(e._zod,`values`,()=>t.innerType._zod.values),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(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(Kn):Kn(r)}});function Kn(e){return e.value=Object.freeze(e.value),e}const qn=E(`$ZodLazy`,(e,t)=>{z.init(e,t),k(e._zod,`innerType`,()=>t.getter()),k(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),k(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),k(e._zod,`optin`,()=>e._zod.innerType._zod.optin),k(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>{let r=e._zod.innerType;return r._zod.run(t,n)}}),Jn=E(`$ZodCustom`,(e,t)=>{R.init(e,t),z.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=>Yn(t,n,r,e));Yn(i,n,r,e)}});function Yn(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(L(e))}}Symbol(`ZodOutput`),Symbol(`ZodInput`);var Xn=class{constructor(){this._map=new Map,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}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),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 Xn}const Qn=Zn();function $n(e,t){return new e({type:`string`,...N(t)})}function er(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function tr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function nr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function rr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function or(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function sr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function cr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function lr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function ur(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function dr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function fr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function pr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function mr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function hr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function gr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function _r(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function vr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function yr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function br(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function xr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Sr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function Cr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function wr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function Tr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Er(e,t){return new e({type:`number`,checks:[],...N(t)})}function Dr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Or(e,t){return new e({type:`boolean`,...N(t)})}function kr(e){return new e({type:`any`})}function Ar(e){return new e({type:`unknown`})}function jr(e,t){return new e({type:`never`,...N(t)})}function Mr(e,t){return new Ct({check:`less_than`,...N(t),value:e,inclusive:!1})}function Nr(e,t){return new Ct({check:`less_than`,...N(t),value:e,inclusive:!0})}function Pr(e,t){return new wt({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Fr(e,t){return new wt({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Ir(e,t){return new Tt({check:`multiple_of`,...N(t),value:e})}function Lr(e,t){let n=new Dt({check:`max_length`,...N(t),maximum:e});return n}function Rr(e,t){return new Ot({check:`min_length`,...N(t),minimum:e})}function zr(e,t){return new kt({check:`length_equals`,...N(t),length:e})}function Br(e,t){return new jt({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Vr(e){return new Mt({check:`string_format`,format:`lowercase`,...N(e)})}function Hr(e){return new Nt({check:`string_format`,format:`uppercase`,...N(e)})}function Ur(e,t){return new Pt({check:`string_format`,format:`includes`,...N(t),includes:e})}function Wr(e,t){return new Ft({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function Gr(e,t){return new It({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function V(e){return new Lt({check:`overwrite`,tx:e})}function Kr(e){return V(t=>t.normalize(e))}function qr(){return V(e=>e.trim())}function Jr(){return V(e=>e.toLowerCase())}function Yr(){return V(e=>e.toUpperCase())}function Xr(e,t,n){return new e({type:`array`,element:t,...N(n)})}function Zr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...N(n)});return r}const Qr=E(`ZodISODateTime`,(e,t)=>{Qt.init(e,t),W.init(e,t)});function $r(e){return Sr(Qr,e)}const ei=E(`ZodISODate`,(e,t)=>{$t.init(e,t),W.init(e,t)});function ti(e){return Cr(ei,e)}const ni=E(`ZodISOTime`,(e,t)=>{en.init(e,t),W.init(e,t)});function ri(e){return wr(ni,e)}const ii=E(`ZodISODuration`,(e,t)=>{tn.init(e,t),W.init(e,t)});function ai(e){return Tr(ii,e)}const oi=(e,t)=>{Fe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Re(e,t)},flatten:{value:t=>Le(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};E(`ZodError`,oi);const si=E(`ZodError`,oi,{Parent:Error}),ci=ze(si),li=Be(si),ui=Ve(si),di=Ue(si),H=E(`ZodType`,(e,t)=>(z.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)=>M(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ci(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ui(e,t,n),e.parseAsync=async(t,n)=>li(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>di(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(xa(t,n)),e.superRefine=t=>e.check(Sa(t)),e.overwrite=t=>e.check(V(t)),e.optional=()=>na(e),e.nullable=()=>ia(e),e.nullish=()=>na(ia(e)),e.nonoptional=t=>ua(e,t),e.array=()=>J(e),e.or=t=>Gi([e,t]),e.and=t=>Yi(e,t),e.transform=t=>ma(e,ea(t)),e.default=t=>oa(e,t),e.prefault=t=>ca(e,t),e.catch=t=>fa(e,t),e.pipe=t=>ma(e,t),e.readonly=()=>ga(e),e.describe=t=>{let n=e.clone();return Qn.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Qn.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Qn.get(e);let n=e.clone();return Qn.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),fi=E(`_ZodString`,(e,t)=>{Bt.init(e,t),H.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(Br(...t)),e.includes=(...t)=>e.check(Ur(...t)),e.startsWith=(...t)=>e.check(Wr(...t)),e.endsWith=(...t)=>e.check(Gr(...t)),e.min=(...t)=>e.check(Rr(...t)),e.max=(...t)=>e.check(Lr(...t)),e.length=(...t)=>e.check(zr(...t)),e.nonempty=(...t)=>e.check(Rr(1,...t)),e.lowercase=t=>e.check(Vr(t)),e.uppercase=t=>e.check(Hr(t)),e.trim=()=>e.check(qr()),e.normalize=(...t)=>e.check(Kr(...t)),e.toLowerCase=()=>e.check(Jr()),e.toUpperCase=()=>e.check(Yr())}),pi=E(`ZodString`,(e,t)=>{Bt.init(e,t),fi.init(e,t),e.email=t=>e.check(er(mi,t)),e.url=t=>e.check(or(_i,t)),e.jwt=t=>e.check(xr(Mi,t)),e.emoji=t=>e.check(sr(vi,t)),e.guid=t=>e.check(tr(hi,t)),e.uuid=t=>e.check(nr(gi,t)),e.uuidv4=t=>e.check(rr(gi,t)),e.uuidv6=t=>e.check(ir(gi,t)),e.uuidv7=t=>e.check(ar(gi,t)),e.nanoid=t=>e.check(cr(yi,t)),e.guid=t=>e.check(tr(hi,t)),e.cuid=t=>e.check(lr(bi,t)),e.cuid2=t=>e.check(ur(xi,t)),e.ulid=t=>e.check(dr(Si,t)),e.base64=t=>e.check(vr(ki,t)),e.base64url=t=>e.check(yr(Ai,t)),e.xid=t=>e.check(fr(Ci,t)),e.ksuid=t=>e.check(pr(wi,t)),e.ipv4=t=>e.check(mr(Ti,t)),e.ipv6=t=>e.check(hr(Ei,t)),e.cidrv4=t=>e.check(gr(Di,t)),e.cidrv6=t=>e.check(_r(Oi,t)),e.e164=t=>e.check(br(ji,t)),e.datetime=t=>e.check($r(t)),e.date=t=>e.check(ti(t)),e.time=t=>e.check(ri(t)),e.duration=t=>e.check(ai(t))});function U(e){return $n(pi,e)}const W=E(`ZodStringFormat`,(e,t)=>{B.init(e,t),fi.init(e,t)}),mi=E(`ZodEmail`,(e,t)=>{Ut.init(e,t),W.init(e,t)}),hi=E(`ZodGUID`,(e,t)=>{Vt.init(e,t),W.init(e,t)}),gi=E(`ZodUUID`,(e,t)=>{Ht.init(e,t),W.init(e,t)}),_i=E(`ZodURL`,(e,t)=>{Wt.init(e,t),W.init(e,t)}),vi=E(`ZodEmoji`,(e,t)=>{Gt.init(e,t),W.init(e,t)}),yi=E(`ZodNanoID`,(e,t)=>{Kt.init(e,t),W.init(e,t)}),bi=E(`ZodCUID`,(e,t)=>{qt.init(e,t),W.init(e,t)}),xi=E(`ZodCUID2`,(e,t)=>{Jt.init(e,t),W.init(e,t)}),Si=E(`ZodULID`,(e,t)=>{Yt.init(e,t),W.init(e,t)}),Ci=E(`ZodXID`,(e,t)=>{Xt.init(e,t),W.init(e,t)}),wi=E(`ZodKSUID`,(e,t)=>{Zt.init(e,t),W.init(e,t)}),Ti=E(`ZodIPv4`,(e,t)=>{nn.init(e,t),W.init(e,t)}),Ei=E(`ZodIPv6`,(e,t)=>{rn.init(e,t),W.init(e,t)}),Di=E(`ZodCIDRv4`,(e,t)=>{an.init(e,t),W.init(e,t)}),Oi=E(`ZodCIDRv6`,(e,t)=>{on.init(e,t),W.init(e,t)}),ki=E(`ZodBase64`,(e,t)=>{cn.init(e,t),W.init(e,t)}),Ai=E(`ZodBase64URL`,(e,t)=>{un.init(e,t),W.init(e,t)}),ji=E(`ZodE164`,(e,t)=>{dn.init(e,t),W.init(e,t)}),Mi=E(`ZodJWT`,(e,t)=>{pn.init(e,t),W.init(e,t)}),Ni=E(`ZodNumber`,(e,t)=>{mn.init(e,t),H.init(e,t),e.gt=(t,n)=>e.check(Pr(t,n)),e.gte=(t,n)=>e.check(Fr(t,n)),e.min=(t,n)=>e.check(Fr(t,n)),e.lt=(t,n)=>e.check(Mr(t,n)),e.lte=(t,n)=>e.check(Nr(t,n)),e.max=(t,n)=>e.check(Nr(t,n)),e.int=t=>e.check(Fi(t)),e.safe=t=>e.check(Fi(t)),e.positive=t=>e.check(Pr(0,t)),e.nonnegative=t=>e.check(Fr(0,t)),e.negative=t=>e.check(Mr(0,t)),e.nonpositive=t=>e.check(Nr(0,t)),e.multipleOf=(t,n)=>e.check(Ir(t,n)),e.step=(t,n)=>e.check(Ir(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 G(e){return Er(Ni,e)}const Pi=E(`ZodNumberFormat`,(e,t)=>{hn.init(e,t),Ni.init(e,t)});function Fi(e){return Dr(Pi,e)}const Ii=E(`ZodBoolean`,(e,t)=>{gn.init(e,t),H.init(e,t)});function K(e){return Or(Ii,e)}const Li=E(`ZodAny`,(e,t)=>{_n.init(e,t),H.init(e,t)});function Ri(){return kr(Li)}const zi=E(`ZodUnknown`,(e,t)=>{vn.init(e,t),H.init(e,t)});function q(){return Ar(zi)}const Bi=E(`ZodNever`,(e,t)=>{yn.init(e,t),H.init(e,t)});function Vi(e){return jr(Bi,e)}const Hi=E(`ZodArray`,(e,t)=>{xn.init(e,t),H.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Rr(t,n)),e.nonempty=t=>e.check(Rr(1,t)),e.max=(t,n)=>e.check(Lr(t,n)),e.length=(t,n)=>e.check(zr(t,n)),e.unwrap=()=>e.element});function J(e,t){return Xr(Hi,e,t)}const Ui=E(`ZodObject`,(e,t)=>{wn.init(e,t),H.init(e,t),k(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:q()}),e.loose=()=>e.clone({...e._zod.def,catchall:q()}),e.strict=()=>e.clone({...e._zod.def,catchall:Vi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Oe(e,t),e.merge=t=>ke(e,t),e.pick=t=>Ee(e,t),e.omit=t=>De(e,t),e.partial=(...t)=>Ae(ta,e,t[0]),e.required=(...t)=>je(la,e,t[0])});function Y(e,t){let n={type:`object`,get shape(){return ve(this,`shape`,{...e}),this.shape},...N(t)};return new Ui(n)}const Wi=E(`ZodUnion`,(e,t)=>{En.init(e,t),H.init(e,t),e.options=t.options});function Gi(e,t){return new Wi({type:`union`,options:e,...N(t)})}const Ki=E(`ZodDiscriminatedUnion`,(e,t)=>{Wi.init(e,t),Dn.init(e,t)});function qi(e,t,n){return new Ki({type:`union`,options:t,discriminator:e,...N(n)})}const Ji=E(`ZodIntersection`,(e,t)=>{On.init(e,t),H.init(e,t)});function Yi(e,t){return new Ji({type:`intersection`,left:e,right:t})}const Xi=E(`ZodRecord`,(e,t)=>{jn.init(e,t),H.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function X(e,t,n){return new Xi({type:`record`,keyType:e,valueType:t,...N(n)})}const Zi=E(`ZodEnum`,(e,t)=>{Mn.init(e,t),H.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 Zi({...t,checks:[],...N(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 Zi({...t,checks:[],...N(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Zi({type:`enum`,entries:n,...N(t)})}const Qi=E(`ZodLiteral`,(e,t)=>{Nn.init(e,t),H.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 Q(e,t){return new Qi({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}const $i=E(`ZodTransform`,(e,t)=>{Pn.init(e,t),H.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(L(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(L(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ea(e){return new $i({type:`transform`,transform:e})}const ta=E(`ZodOptional`,(e,t)=>{Fn.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType});function na(e){return new ta({type:`optional`,innerType:e})}const ra=E(`ZodNullable`,(e,t)=>{In.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ia(e){return new ra({type:`nullable`,innerType:e})}const aa=E(`ZodDefault`,(e,t)=>{Ln.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function oa(e,t){return new aa({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const sa=E(`ZodPrefault`,(e,t)=>{zn.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ca(e,t){return new sa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const la=E(`ZodNonOptional`,(e,t)=>{Bn.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ua(e,t){return new la({type:`nonoptional`,innerType:e,...N(t)})}const da=E(`ZodCatch`,(e,t)=>{Hn.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fa(e,t){return new da({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const pa=E(`ZodPipe`,(e,t)=>{Un.init(e,t),H.init(e,t),e.in=t.in,e.out=t.out});function ma(e,t){return new pa({type:`pipe`,in:e,out:t})}const ha=E(`ZodReadonly`,(e,t)=>{Gn.init(e,t),H.init(e,t)});function ga(e){return new ha({type:`readonly`,innerType:e})}const _a=E(`ZodLazy`,(e,t)=>{qn.init(e,t),H.init(e,t),e.unwrap=()=>e._zod.def.getter()});function va(e){return new _a({type:`lazy`,getter:e})}const ya=E(`ZodCustom`,(e,t)=>{Jn.init(e,t),H.init(e,t)});function ba(e){let t=new R({check:`custom`});return t._zod.check=e,t}function xa(e,t={}){return Zr(ya,e,t)}function Sa(e){let t=ba(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(L(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(L(r))}},e(n.value,n)));return t}const Ca=25,wa=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`refresh_token`:return{statusCode:200,description:`The refresh token operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},Ta=()=>{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},Ea={key:U(),label:U(),required:K().optional().default(!1),secret:K().optional().default(!1),readOnly:K().optional().default(!1),placeholder:U().optional(),description:U().optional(),tooltip:U().optional()},Da=qi(`type`,[Y({...Ea,type:Z([`text`,`password`])}),Y({...Ea,type:Q(`select`),options:Y({value:U(),label:U()}).array()})]),Oa=Y({targetFieldKey:U(),alias:U().optional(),expression:U().optional(),values:q().optional(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:K().default(!1),custom:K().default(!1),hidden:K().default(!1),enumMapper:Y({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(Y({matchExpression:U(),value:U()}).array())}).optional(),properties:va(()=>Oa).array().optional()}),ka=Y({name:U(),type:Z([`string`,`number`,`boolean`,`datetime_string`,`object`]),required:K(),description:U(),array:K().optional().default(!1),in:Z([`body`,`query`,`path`,`headers`]),properties:va(()=>ka.omit({in:!0})).array().optional()}),Aa=Y({operationId:U(),categories:U().array(),operationType:Z([`list`,`get`,`create`,`update`,`delete`,`custom`,`refresh_token`,`unknown`]),schema:U().optional(),schemaType:Z([`native`,`unified`]).optional().default(`native`),entrypointUrl:U().optional(),entrypointHttpMethod:U().optional(),label:U(),description:U(),tags:U().array().optional(),context:U().optional(),responses:Y({statusCode:G(),description:U()}).array().optional(),inputs:ka.array().optional(),cursor:Y({enabled:K(),pageSize:G()}).optional(),compositeIdentifiers:Y({enabled:K(),version:G().optional(),fields:Y({targetFieldKey:U(),remote:U().optional(),components:U().array()}).array().optional()}).optional(),scheduledJobs:Y({enabled:K(),type:Z([`data_sync`]),schedule:U(),description:U(),requestParams:Y({fields:U().array().optional(),expand:U().array().optional(),filter:X(U(),U()).optional()}).optional(),syncFilter:Y({name:Z([`updated_after`,`created_after`]),initialLoopbackPeriod:U(),incrementalLoopbackPeriod:U()}).optional()}).array().optional(),fieldConfigs:Oa.array().optional(),steps:Y({stepId:U(),description:U(),stepFunction:Y({functionName:U(),version:U().optional(),parameters:X(U(),q())}),condition:U().optional(),ignoreError:K().optional()}).array(),result:U().or(X(U(),q())).optional()}),ja=Y({schedule:U().optional(),operation:Aa.extend({operationType:Q(`refresh_token`)})}),Ma=Y({mainRatelimit:G(),subPools:J(Y({subPoolKey:U(),urlPattern:U(),rateLimit:G()})).optional(),mappedRateLimitErrors:J(Y({errorStatus:G(),errorMessage:U(),errorMessagePath:U().optional(),retryAfterPath:U().optional(),retryAfterUnit:Gi([Q(`seconds`),Q(`milliseconds`),Q(`date`)]).optional(),retryAfterValue:G().optional()})).optional()}),Na=Y({mainMaxConcurrency:G(),subPools:J(Y({subPoolKey:U(),urlPattern:U(),maxConcurrency:G()})).optional()}),Pa=Y({StackOne:U(),info:Y({title:U(),version:U(),key:U(),assets:Y({icon:U()}),description:U().optional()}),context:U().optional(),baseUrl:U(),authentication:X(U(),Y({type:U(),label:U(),authorization:u,environments:Y({key:U(),name:U()}).array(),support:Y({link:U(),description:U().optional()}),configFields:Da.array().optional(),setupFields:Da.array().optional(),refreshAuthentication:ja.optional(),testOperations:Y({operation:U().or(Aa),condition:U().optional(),required:K().default(!0)}).array().optional()})).array().optional(),operations:Aa.array().optional(),rateLimit:Ma.optional(),concurrency:Na.optional()});function Fa(e){try{let t=C(e),n=Pa.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description,context:n.context,rateLimit:n.rateLimit,concurrency:n.concurrency},a=za(n),o={baseUrl:n.baseUrl,authentication:Ia(a)},s=Ga(n,o);return r.operations=s,La(a,s,o),r.authentication=a,i(s)&&(r.categories=Ra(Object.values(s))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const Ia=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,refreshAuthentication:o,testOperations:s,...c}=r;t[n]=Ia(c)}else t[n]=r;return t},La=(e,t,n)=>{if(!(!e||!t))for(let r of Object.values(e))for(let e of Object.values(r)){let r=e.testOperations;e.testOperations=r?.map(e=>{if(i(e.operation))if(typeof e.operation==`string`){let n=e.operation,r=Object.values(t).find(e=>e.id===n);if(r)return{...e,operation:r}}else{let t=Ka(e.operation,n);return{...e,operation:t}}return e})}},Ra=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},za=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:a,name:o}=r,{environments:s,refreshAuthentication:c,testOperations:l,...u}=n[e],d=i(c)?{schedule:c.schedule,operation:Ka(c.operation)}:void 0;return t[a]={...u,refreshAuthentication:d,envKey:a,envName:o,testOperations:l},t},{});t[e]=r}return t},Ba=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,Va=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,Ha=e=>{if(e.operationType!==`refresh_token`)return e.entrypointHttpMethod??`get`},Ua=t=>{if(!(t.operationType===`refresh_token`||e(t.schema)))return t.operationType===`list`?`/${t.schema}`:`/${t.schema}/:id`},Wa=e=>{let t={success:wa(e.operationType),errors:Ta()},n=e.responses?.reduce((e,t)=>{let n=S(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},Ga=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=Ba(n),i=Va(n);return e[r??i]=Ka(n,t),e},{});return n},Ka=(e,t)=>{let n=Ua(e),r=Wa(e),i=Ya(e),a=e.inputs||[];i.enabled&&a?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`,array:!1});let o=Ha(e);return{id:e.operationId,categories:e.categories,label:e.label,description:e.description,operationType:e.operationType,schemaType:e.schemaType??`native`,entrypointUrl:e.entrypointUrl??n,entrypointHttpMethod:o,tags:e.tags,context:e.context,responses:r,cursor:i,compositeIdentifiers:Xa(e),scheduledJobs:Za(e),inputs:a,steps:e.steps.reduce((n,r)=>(n[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,...Qa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:r.stepFunction.parameters.fields??e.fieldConfigs}:{}}}},n),{}),result:e.result}},qa=(e,t)=>{if(!e.inputs)return{};let n=Ja(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},$=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=U();break;case`number`:n=G();break;case`boolean`:n=K();break;case`datetime_string`:n=U().refine(e=>!isNaN(Date.parse(e)),{message:`Invalid datetime string`});break;case`object`:n=e.properties?$(e.properties):X(U(),Ri());break;default:n=Ri()}let r=e.array?J(n):n;t[e.name]=e.required?r:r.optional()}),Y(t)},Ja=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 Y({path:$(t).optional(),query:$(n).optional(),body:$(r).optional(),headers:$(i).optional()})},Ya=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:Ca};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Xa=t=>{if(t.operationType===`refresh_token`)return{enabled:!1};if(e(t.compositeIdentifiers)){let e=t.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=i(e)?[{targetFieldKey:e.targetFieldKey,remote:`id`,components:[{name:e.targetFieldKey,alias:e.alias}]}]:void 0;return{enabled:!0,version:d,fields:n}}let n=[];for(let e of t.compositeIdentifiers?.fields??[]){let r=e.components.map(e=>{let n=t.fieldConfigs?.find(t=>t.targetFieldKey===e);return{name:e,alias:n?.alias}});n.push({targetFieldKey:e.targetFieldKey,remote:e.remote,components:r})}return{enabled:t.compositeIdentifiers.enabled,version:t.compositeIdentifiers.version,fields:n.length>0?n:void 0}},Za=t=>{if(!e(t.scheduledJobs))return t.scheduledJobs},Qa=(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{}},$a=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return;let r=e.authentication?.[t]?.[n]?.refreshAuthentication?.operation;if(i(r))return{operation:r,params:{}}},eo=(e,t,n)=>{if(e.authentication?.[t]?.[n]?.authorization.type!==`oauth2`)return!1;let r=$a(e,t,n);return i(r)},to=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenExpiresIn},no=(e,t,n)=>{let r=e.authentication?.[t]?.[n]?.authorization;if(r?.type===`oauth2`)return r?.tokenRefreshExpiresIn},ro=e=>{try{let t=[],n=C(e),r=Pa.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=io(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}]}}},io=(t,n)=>{let r=n.split(`
|
|
30
|
+
`),a=0,o=-1,s=0;for(let n=0;n<r.length;n++){let c=r[n],l=c.match(/^(\s*)/)?.[1]?.length||0,u=c.replace(`- `,``).trim();if(u.startsWith(`#`)||u===``||l<=o)continue;let d=i(t[a])?`${String(t[a])}`:``;if(e(d))return s+1;if(isNaN(Number(d))){if(u.startsWith(`${d}:`)){if(a===t.length-1)return n+1;o=l,s=n,a++}}else{let e=parseInt(d,10),t=-1;for(let i=n;i<r.length;i++){let o=r[i],c=o.trim();if(c.startsWith(`-`)&&t++,t===e){a++,s=n,n--;break}else n++}}}return s+1};var ao=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}`}},oo=class extends ao{constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},so=class extends ao{constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},co=class extends ao{constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},lo=class extends ao{constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const uo=(e,t)=>{let n=Object.keys(e.authentication??{}).map(t=>({type:`custom`,label:e.authentication?.[t].production?.label||`Custom`,key:t})),r=Object.values(e?.operations??{}).map(e=>({id:e.id,description:e.description.replace(/\b\w/g,e=>e.toUpperCase()),label:e.label.replace(/\b\w/g,e=>e.toUpperCase()),schema_type:e.schemaType,tags:e.tags,authentication:n,operation_details:t?.includes(`operation_details`)?e:void 0}));return{version:e.version,name:e.description,key:e.key,icon:e.assets?.icon,description:e.description,authentication:n,actions:r}},fo=(e,t)=>e.map(e=>uo(e,t)),po=`stackone://internal//`,mo=`${po}refresh_token`,ho=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=m.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===p.MAP_FIELDS?{[p.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},go=({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}),_o=t=>{let n=t.operation?.compositeIdentifiers,r={...t.inputs??{}};if(!n?.enabled||e(r))return t;let i=n.fields?.reduce((e,t)=>(t.components.forEach(t=>{t.alias&&(e[t.name]=t.alias)}),e),{}),a={version:n.version??d,aliases:i};return vo(r,a,t.logger),{...t,inputs:r}},vo=(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`))wo(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)vo(e,t,n);else typeof i==`object`&&i&&vo(i,t,n)}},yo=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=h(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}},bo=(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]})},xo=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},So=(e,t,n,r,i)=>{n.every(xo)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},Co=(e,t,n)=>{e instanceof f&&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})},wo=(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}=yo(o,t,r,i);bo(n,t,s,a),So(n,t,s,c,a)}catch(e){Co(e,t,i)}},To=`remote_`,Eo=t=>{let n=t.operation?.compositeIdentifiers;if(!n?.enabled)return t;let r=`data`,i=t.outputs?.[r];if(e(i))return t;let a=Array.isArray(i)?i.map(e=>Do(e,n)):Do(i,n);return{...t,outputs:{...t.outputs??{},[r]:a}}},Do=(e,t)=>{let r=Oo(e,t),i=Io(r);return{...e,...n(i)?i:{}}},Oo=(e,t)=>{let n=t.version??d,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=g(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${To}${t.remote}`]=e[t.remote])}),{...e,...r}},ko=e=>e===`id`||/.+_id(s)?$/.test(e),Ao=e=>Array.isArray(e)&&e.every(e=>r(e)&&e.length>0),jo=(e,t)=>v(e)||t.startsWith(To),Mo=(e,t)=>{try{return g({key:e,value:t},{version:d})}catch{return t}},No=(e,t,n)=>{let i=t.map(t=>r(t)&&t.length>0&&!v(t)?Mo(e,t):t);n[e]=i,n[`${To}${e}`]=t},Po=(e,t,n)=>{if(jo(t,e))return;let r=g({key:e,value:t},{version:d});n[e]=r,n[`remote_${e}`]=t},Fo=(e,t,n)=>{Ao(t)?No(e,t,n):r(t)&&t.length>0&&Po(e,t,n)},Io=e=>{if(Array.isArray(e))return e.map(e=>Io(e));if(!n(e))return e;let t={...e};for(let[r,i]of Object.entries(e))(n(i)||Array.isArray(i)&&i.length>0&&n(i[0]))&&(t[r]=Io(i)),ko(r)&&Fo(r,i,t);return t},Lo=(e,n)=>{let r=Number(e.inputs?.page_size),a=i(e.inputs?.page_size)&&t(r)&&!Number.isNaN(r)?r:e.operation?.cursor?.pageSize??n;return a},Ro=(t,r,a,o)=>{let s=e(t)?void 0:t.data,c=Object.keys(a).length+1,l=y({cursor:o,ignoreStepIndex:c});if(!n(t)||e(s)||(s?.length??0)<=r)return{result:t,next:i(o)&&!l?b(o):null};let u=o?.remote?.[c]?.pageNumber??1,d=(u-1)*r,f=d+r,p=s.slice(d,f),m=s.length>f||!l,h=x({cursor:o,stepIndex:c,pageNumber:u+1});return{result:{...t,data:p},next:m?b(h):null}},zo=async({block:e,buildStepFunction:t=m.build,virtualPaginateResultFn:n=Ro,encodeResultCompositeIds:r=Eo,decodeInputCompositeIds:i=_o})=>{let a=i(e),o=await Go({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},Bo=(e,t)=>e.condition?!T(e.condition,t):!1,Vo=(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??{}},Ho=(e,t,n,r,i)=>{let a=qo({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},Uo=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 qo({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return qo({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=Vo(o,r,t),u=await c({block:r,params:l});if(u.successful===!1)return Ho(r,e,u,o,i);let d=r.operation?.cursor.enabled?x({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return qo({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},Wo=(e,t,r,a,o)=>{let s=!r.hasFatalError,c=s?e.operation?.responses.success.statusCode??200:r.errorStatusCode??500,l=i(o)&&n(o.result)?{next:o.next,...o.result}:a;return{...t,outputs:l,response:{successful:s,statusCode:c,message:s?void 0:e.operation?.responses?.errors?.[c]?.description??ee?.[c]??`Error while processing the request`}}},Go=async({block:e,buildStepFunction:t=m.build,virtualPaginateResultFn:n=Ro})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=Lo(e,Ca),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await Uo(t,e,r,i,s,c);let l=e.operation?.result?Ko(e.operation.result,i):void 0,u=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return Wo(e,i,s,l,u)},Ko=(e,t)=>n(e)?te(e,t):T(e,t),qo=({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}}}),Jo=async({operationId:t,account:n,connector:i,pathParams:a={},queryParams:o={},body:s={},headers:c={},logger:l,getHttpClient:u,parseConnector:d=Fa,parseOperationInputsFn:f=qa,createBlockContextFn:p=go,createBlockFn:m=ne,runStepOperationFn:h=zo})=>{let g=n.authConfigKey,_=n.environment??`production`,v=n.secureId,y=n.projectSecureId,b=n.credentials,x=p({category:`action`,connectorKey:n.providerKey,connectorVersion:n.providerVersion,authConfigKey:g,environment:_,accountSecureId:v,projectSecureId:y}),ee;try{ee=r(i)?d(i):i}catch{throw new oo(x,`Error while parsing connector`)}let S=ue(i,t);if(e(S))throw new so(x,`No matching operation found`);x.operationType=S.operationType,x.schema=S.schema?.key;let C=Yo(o,x),w;try{w=f(S,{path:a,query:o,body:s,headers:c})}catch{throw new co(x,`Error while parsing operation inputs`)}let T=await m({connector:ee,inputs:w,context:x,operation:S,credentials:b,nextCursor:C,logger:l,getHttpClient:u});return await h({block:T})},Yo=(e,t)=>{let n=e?.next,r=i(n)&&t.operationType===`list`?_(n):void 0;if(r===null)throw new lo(t,`Invalid cursor.`);return r},Xo=async({account:t,connector:n,category:i,path:a,method:o=`get`,queryParams:s={},body:c,headers:l,logger:u,getHttpClient:d,parseConnector:f=Fa,getOperationFromUrlFn:p=se,getOperationForRefreshAuthenticationFn:m=$a,parseOperationInputsFn:h=qa,createBlockContextFn:g=go,createBlockFn:_=ne,runStepOperationFn:v=zo})=>{let y=t.authConfigKey,b=t.environment??`production`,x=t.secureId,ee=t.projectSecureId,S=t.credentials,C=g({category:i,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:y,environment:b,accountSecureId:x,projectSecureId:ee}),w;try{w=r(n)?f(n):n}catch{throw new oo(C,`Error while parsing connector`)}let T=Qo(a)?m(w,y,b):p(w,a,o);if(e(T))throw new so(C,`No matching operation found`);C.operationType=T.operation.operationType,C.schema=T.operation.schema?.key;let te=Zo(s,C),re;try{re=h(T.operation,{query:s,body:c,headers:l,path:T.params})}catch{throw new co(C,`Error while parsing operation inputs`)}let ie=await _({connector:w,inputs:re,context:C,operation:T.operation,credentials:S,nextCursor:te,logger:u,getHttpClient:d});return await v({block:ie})},Zo=(e,t)=>{let n=e?.next,r=i(n)&&t.operationType===`list`?_(n):void 0;if(r===null)throw new lo(t,`Invalid cursor.`);return r},Qo=e=>e===mo,$o=(e,t,n)=>e.authentication?.[t]?.[n]?.testOperations,es=async({account:t,connector:n,logger:a,getHttpClient:o,parseConnector:s=Fa,getTestOperationsFn:c=$o,createBlockContextFn:l=go,createBlockFn:u=ne,runStepOperationFn:d=zo})=>{let f=t.authConfigKey,p=t.environment??`production`,m=t.secureId,h=t.projectSecureId,g=t.credentials,_=l({category:`internal`,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:f,environment:p,accountSecureId:m,projectSecureId:h}),v;try{v=r(n)?s(n):n}catch{throw new oo(_,`Error while parsing connector`)}let y=c(v,f,p);if(e(y)||y.length===0)return!0;_.operationType=`test`;for(let t of y){let n=await u({connector:v,inputs:void 0,context:_,operation:t.operation,credentials:g,nextCursor:void 0,logger:a,getHttpClient:o}),r=i(t.condition)?w(t.condition,n):!0;if(!r)continue;let s=await d({block:n});if((e(s?.response?.successful)||!s.response.successful)&&t.required)return a?.error({code:`TestOperationFailed`,message:`Test operation "${t.operation.id}" failed with error: ${s?.response?.message}`}),!1}return!0};export{ao as ConnectSDKError,mo as REFRESH_TOKEN_OPERATION_PATH,uo as buildActionsMetaFromConfig,ne as createBlock,ho as executeStepFunction,fo as getActionsMetaFromConfigs,se as getOperationFromUrl,no as getRefreshTokenExpiresIn,to as getTokenExpiresIn,re as loadConnector,qa as parseOperationInputs,Fa as parseYamlConnector,Jo as runConnectorAction,Xo as runConnectorOperation,zo as runStepOperation,es as runTestOperations,eo as supportsRefreshAuthentication,ro as validateYamlConnector};
|