@stackone/core 2.63.0 → 2.65.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.cjs +1 -1
- package/dist/index.d.cts +97 -22
- package/dist/index.d.mts +97 -22
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0}),n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__copyProps=(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},__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let o=require(`@stackone/utils`),s=require(`@stackone/expressions`),c=require(`@stackone/transport`),l=require(`@aws-sdk/client-lambda`),u=require(`mime-types`);u=__toESM(u);let d=require(`form-data`);d=__toESM(d);const f=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=f.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},p={hris:{title:`HRIS`,key:`hris`,description:`Human Resource Information System`},crm:{title:`CRM`,key:`crm`,description:`Customer Relationship Management`},ats:{title:`ATS`,key:`ats`,description:`Applicant Tracking System`},lms:{title:`LMS`,key:`lms`,description:`Learning Management System`},marketing:{title:`Marketing`,key:`marketing`,description:`Marketing`},filestorage:{title:`File Storage`,key:`filestorage`,description:`File Storage`},iam:{title:`IAM`,key:`iam`,description:`Identity and Access Management`},internal:{title:`Internal`,key:`internal`,description:`Category for internal actions`},action:{title:`Action`,key:`action`,description:`Action`}},getCategoryDetails=e=>p[e.toLowerCase()]??null,isValidCategory=e=>!!p[e.toLowerCase()],m=`so1!`,h=(0,o.encodeToBase64)(`so1!`),g=`:`,_=`,`,v=RegExp(`(?<!\\\\):`,`g`),y=RegExp(`(?<!\\\\),`,`g`),b=1;var x=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends x{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!(0,o.isMissing)(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!(0,o.isMissing)(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(y).forEach(e=>{let[n,i]=e.split(v),a=getOriginalKey(n,t.aliases??{});r[a]=unescapeValue(i)}),r},getComposedIdV1=(e,t={})=>{if(isSingleIdentifier(e))return getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!0});if(isMultipleIdentifier(e))return e.identifiers.map(e=>getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!1})).join(`,`);throw new CompositeIdUnknownIdentifierError},getSingleIdentifierString=({identifier:e,compositeIdAliases:t,isSoleIdentifier:n})=>[n?`id`:t[e.key]||e.key,escapeValue(e.value)].filter(Boolean).join(`:`),getOriginalKey=(e,t)=>Object.keys(t).find(n=>t[n]===e)??e,decodeId=(e,t)=>{if(t.version===1)return decodeIdV1(e);throw new CompositeIdUnsupportedVersionError(`Cannot decode ID, unsupported version number: ${t.version}`)},encodeIdV1=e=>`${h}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(h))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(h)[1];if(!t)throw new CompositeIdMissingBodyError(`Trying to decode an ID without a body: ${e}`);return(0,o.decodeFromBase64)(t)},escapeValue=e=>[`,`,`:`].reduce((e,t)=>e.replace(t,`\\`+t),e),unescapeValue=e=>[`,`,`:`].reduce((e,t)=>{let n=`\\`+t;return e.replace(RegExp(`\\\\`+n,`g`),t)},e),isCompositeId=e=>(0,o.isMissing)(e)?!1:e.startsWith(h),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if((0,o.isMissing)(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=(0,s.safeEvaluate)(`{{${n.result.trim()}}}`,t);if(!(0,o.isMissing)(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!(0,o.isMissing)(n))for(let e of n.rules){let n=(0,s.safeEvaluate)(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,(0,s.safeEvaluate)(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},S={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>S[e],isValidEnumRef=e=>e in S,C=[`preview`,`beta`,`ga`,`deprecated`,`internal`],w=[`sync`,`async`],T=(0,o.zStrictObject)({r:o.z.record(o.z.string(),(0,o.zStrictObject)({n:o.z.number().optional().nullable(),c:o.z.string().optional().nullable(),p:o.z.number().optional().nullable()})),v:o.z.number(),t:o.z.number()}),E=(0,o.zStrictObject)({remote:o.z.record(o.z.string(),(0,o.zStrictObject)({pageNumber:o.z.number().optional(),providerPageCursor:o.z.string().optional(),position:o.z.number().optional()})),version:o.z.number(),timestamp:o.z.number()}),minifyCursor=e=>(0,o.encodeToBase64)(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if((0,o.isString)(e)){let t=(0,o.decodeFromBase64)(e),n=JSON.parse(t);return expandCursorObject(T.parse(n))}else return E.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:i,...a}=n,{timestamp:s,...c}=r;return(0,o.getContentHash)(a)===(0,o.getContentHash)(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>(0,o.isMissing)(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return((0,o.isMissing)(t)||r!==t.toString())&&(n=n&&(0,o.isMissing)(i.pageNumber)&&(0,o.isMissing)(i.position)&&(0,o.isMissing)(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},s=(0,o.isMissing)(n)&&(0,o.isMissing)(r)&&(0,o.isMissing)(i);return(0,o.isMissing)(e)?{remote:s?{}:{[t]:a},version:2,timestamp:Date.now()}:s?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof x;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}const browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},D=o.z.object({startUrl:o.z.string().url(),systemPrompt:o.z.string().optional(),viewport:(0,o.zStrictObject)({width:o.z.number().int().positive(),height:o.z.number().int().positive()}).optional(),locale:o.z.string().optional(),budgets:(0,o.zStrictObject)({maxDurationMs:o.z.number().int().positive(),maxSteps:o.z.number().int().positive()}),auth:(0,o.zStrictObject)({sensitiveKeys:o.z.array(o.z.string().min(1)).optional(),requiresSession:o.z.boolean().optional()}).optional()}),O=o.z.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(typeof e.message==`string`&&e.message.trim().length>0)return e.message}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(e.error!=null&&typeof e.error==`object`&&!Array.isArray(e.error)&&typeof e.error.message==`string`)return e.error.message;if(typeof e.error==`string`)return e.error;if(typeof e.error_description==`string`)return e.error_description}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof c.HttpResponseError){let n=e.message;return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:e.response?.status??500,message:extractErrorMessage(e.response,n),data:e.response?.data,raw:sanitizeRaw(e.response)}}}if(isHttpLikeError(e)){let n=e.response,r=e instanceof Error?e.message:`HTTP error: ${n.status??500}`;return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:n.status??500,message:extractErrorMessage(n,r),data:n.data,raw:sanitizeRaw(n)}}}return e instanceof Error?{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:500,message:String(e)}}},isAwsCredentials=e=>!!e&&typeof e.accessKeyId==`string`&&typeof e.secretAccessKey==`string`,buildLambdaClientConfig=({region:e,endpoint:t,credentials:n})=>({region:e,...t?{endpoint:t}:{},...isAwsCredentials(n)?{credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,sessionToken:typeof n.sessionToken==`string`?n.sessionToken:void 0}}:t?{credentials:{accessKeyId:`local`,secretAccessKey:`local`}}:{}}),defaultClientFactory=e=>new l.LambdaClient(e),invokeLambda=async({lambdaName:e,payload:t,region:n,endpoint:r,invocationType:i=`RequestResponse`,qualifier:a,credentials:o,clientFactory:s=defaultClientFactory})=>{let c=s(buildLambdaClientConfig({region:n,endpoint:r,credentials:o})),u=new l.InvokeCommand({FunctionName:e,InvocationType:i,Qualifier:a,Payload:t?Buffer.from(JSON.stringify(t)):void 0}),d=await c.send(u),f=d.Payload?Buffer.from(d.Payload).toString(`utf-8`):``,p;if(f.length===0)p=void 0;else try{p=JSON.parse(f)}catch{p=f}return{statusCode:d.StatusCode??200,payload:p,functionError:d.FunctionError,executedVersion:d.ExecutedVersion}},k=(0,o.zStrictObject)({lambdaName:o.z.string(),region:o.z.string().optional(),endpoint:o.z.string().optional(),invocationType:o.z.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:o.z.string().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:o.z.string().optional()}),A=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),executedVersion:o.z.string().optional()}).optional(),j=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||j.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,M=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;try{let n=(0,s.evaluate)(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||(0,s.safeEvaluate)(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,c=typeof o==`string`&&!j.test(o),l=t?.qualifier,u=typeof l==`string`&&!hasExpressionMarker(l),d={...t?(0,s.safeEvaluateRecord)(i===void 0?t:{...t,args:a},e):{},...c?{dataKey:o}:{},...u?{qualifier:l}:{}},f;try{f=k.parse(d)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:p,region:m,endpoint:h,invocationType:g,qualifier:_,args:v,dataKey:y}=f,b;try{b=await n({lambdaName:p,payload:buildPayloadFromArgs(v),region:m,endpoint:h,invocationType:g,qualifier:_,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(b.functionError){let t=typeof b.payload==`object`&&b.payload!==null&&`errorMessage`in b.payload&&typeof b.payload.errorMessage==`string`?b.payload.errorMessage:`Lambda function error: ${b.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:b.functionError}],output:{statusCode:b.statusCode,message:t,data:b.payload,raw:b}}}return{block:e,successful:!0,output:{data:y?M(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},N=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),P=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional()}),F=o.z.discriminatedUnion(`strategy`,[N,P]),I=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:F.optional()}),L=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),R=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),z=(0,o.zStrictObject)({type:o.z.literal(`oauth2`),authorizationUrl:o.z.string().optional(),authorizationParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenUrl:o.z.string().optional(),tokenParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenExpiresIn:o.z.number().optional(),tokenRefreshExpiresIn:o.z.number().optional(),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0),scopes:o.z.string().optional(),scopeDelimiter:o.z.string().optional(),customHeaders:o.z.record(o.z.string(),o.z.string()).optional(),pkce:o.z.boolean().optional(),additionalTokenFields:o.z.record(o.z.string(),o.z.string().optional()).optional(),issuer:o.z.string().optional()}),B=o.z.discriminatedUnion(`type`,[I,L,R,z]),V=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),H=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:B.optional(),responseMode:o.z.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:o.z.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:o.z.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:(0,o.zStrictObject)({dataKey:o.z.string().optional(),fileNameKey:o.z.string().optional(),contentTypeKey:o.z.string().optional(),contentIsBase64:o.z.boolean().optional().default(!1),urlKey:o.z.string().optional(),forwardAuth:o.z.boolean().optional().default(!1)}).optional(),maxRedirects:o.z.number().optional().default(5),followRedirects:o.z.boolean().optional().default(!0),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),U=(0,o.zStrictObject)({data:o.z.union([o.z.string(),o.z.instanceof(Buffer)]).optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),headers:o.z.record(o.z.string(),o.z.string()).optional(),contentDisposition:o.z.string().optional(),fileMetadata:(0,o.zStrictObject)({contentType:o.z.string().optional(),contentLength:o.z.number().optional(),fileName:o.z.string().optional(),lastModified:o.z.string().optional(),etag:o.z.string().optional()}).optional(),finalUrl:o.z.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,authorization:f,args:p,responseMode:m,responseType:h,encoding:g,response:_,maxRedirects:v,followRedirects:y}=H.parse(a),b=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,x=p?(0,c.parseRequestParameters)(p):{query:{},body:{},headers:{}},S=(0,c.createAuthorizationHeaders)((0,o.notMissing)(f)?f:B.parse(b)),C={...x?.headers??{},...S},w=e.connector?.rateLimit,T=e.connector?.concurrency,E=w!==void 0||T!==void 0?{rateLimit:w,concurrency:T}:void 0;if(m===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,maxRedirects:y?v:0,requestConfig:E});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,responseType:h,encoding:g,response:_,maxRedirects:y?v:0,requestConfig:E,authHeaders:S})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:s,authHeaders:c}=e,l=n.data;if(r.urlKey){let e=extractValueByPath(l,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?c:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:s}),o=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:o,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(l,r.dataKey);if((0,o.isMissing)(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let s=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:s,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if((0,o.isMissing)(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);case`binary`:default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=(0,o.isString)(e[`content-type`])?e[`content-type`]:void 0,n=(0,o.isString)(e[`content-length`])?e[`content-length`]:void 0,r=(0,o.isString)(e[`content-disposition`])?e[`content-disposition`]:void 0,i=(0,o.isString)(e[`last-modified`])?e[`last-modified`]:void 0,a=(0,o.isString)(e.etag)?e.etag:void 0,s=n?parseInt(n,10):void 0,c=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(s)?void 0:s,fileName:c,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return u.default.extension(t)||void 0},W=o.z.object({event:o.z.object({eventType:o.z.string(),eventDate:o.z.string().optional(),data:o.z.unknown().optional()}).optional()}),ee=o.z.record(o.z.string(),o.z.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?(0,s.safeEvaluateRecord)(t,e):{},{event:r}=W.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventDate:r.eventDate,data:r.data})}catch(t){throw e.logger?.error({code:`EmitEventError`,message:`emitEvent callback failed: ${t.message}`}),t}else r&&!e.emitEvent&&e.logger?.warning({message:`emit_event step executed but no emitEvent callback provided on the block`});let{event:i,...a}=n;return{block:{...e},successful:!0,output:a}},G=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),K=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=G.parse(t),i=n.reduce((t,n)=>{let i=e.steps?.[n]?.output?.data;return i?r?{...t,[n]:{...i}}:(Object.keys(i).forEach(e=>{t[e]={...(0,o.notMissing)(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},q=__name(async({block:e})=>{let t=e?.fieldConfigs,n=[],r=e.steps;if(!t||e?.debug?.custom_mappings===`disabled`||!r)return{block:e,successful:!0};let i=buildExpressionContext(e),a;if(Array.isArray(e.result)){let o=e.result.length;a=e.result.map((e,a)=>{let s=J(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=J(e.result,t,r,i);a=o.record,n.push(...o.errors||[])}return{block:{...e,result:a},successful:!0,errors:Object.keys(n).length>0?n:void 0}},`mapFieldsStepFunction`),extractSingleRecordBlockStepData=(e,t,n)=>Object.entries(e).reduce((e,[r,i])=>{let a=i?.output?.data;return Array.isArray(a)&&a.length===t?e[r]={output:{data:a[n]}}:e[r]=i,e},{}),J=__name((e,t,n,r)=>{if(!e||!n)return{record:e};let i={...r,unified:{...e},...typeof n==`object`?n:{}},a={},o=[],s={...e};for(let n of t){let{error:t,value:r}=Y(i,e.id,n);if(t){o.push(t);continue}n.custom?a[n.targetFieldKey]=r:s[n.targetFieldKey]=r}return{record:{...s,unified_custom_fields:Object.keys(a).length>0?a:void 0},errors:o.length>0?o:void 0}},`mapSingleRecord`),Y=__name((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=(0,s.evaluate)(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return o.getCountryAlpha2CodeByAlpha2Code;case`country_alpha3code_by_alpha3code`:return o.getCountryAlpha3CodeByAlpha3Code;case`country_code_by_country_code`:return o.getCountryCodeByCountryCode;case`country_name_by_country_name`:return o.getCountryNameByCountryName;case`country_name_by_alpha3code`:return o.getCountryNameByAlpha3Code;case`country_name_by_alpha2code`:return o.getCountryNameByAlpha2Code;case`country_name_by_country_code`:return o.getCountryNameByCountryCode;case`country_alpha3code_by_alpha2code`:return o.getCountryAlpha3CodeByAlpha2Code;case`country_alpha3code_by_country_name`:return o.getCountryAlpha3CodeByCountryName;case`country_alpha3code_by_country_code`:return o.getCountryAlpha3CodeByCountryCode;case`country_alpha2code_by_alpha3code`:return o.getCountryAlpha2CodeByAlpha3Code;case`country_alpha2code_by_country_name`:return o.getCountryAlpha2CodeByCountryName;case`country_alpha2code_by_country_code`:return o.getCountryAlpha2CodeByCountryCode;case`country_code_by_alpha2code`:return o.getCountryCodeByAlpha2Code;case`country_code_by_alpha3code`:return o.getCountryCodeByAlpha3Code;case`country_code_by_country_name`:return o.getCountryCodeByCountryName;case`country_subdivisions_by_alpha2code`:return o.getCountrySubDivisionsByAlpha2Code;case`country_subdivision_code_by_subdivision_name`:return o.getCountrySubDivisionCodeBySubDivisionName;case`country_alpha2code_by_citizenship`:return o.getCountryAlpha2CodeByCitizenship;case`country_subdivision_name_by_subdivision_code`:return o.getCountrySubDivisionNameBySubDivisionCode;case`document_file_format_from_extension`:return o.getDocumentFileFormatFromExtension;default:return}},te=(0,o.zStrictObject)({targetFieldKey:o.z.string(),alias:o.z.string().optional(),expression:o.z.string().optional(),values:o.z.unknown().optional(),type:o.z.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:o.z.boolean().default(!1),custom:o.z.boolean().default(!1),hidden:o.z.boolean().default(!1),enumMapper:(0,o.zStrictObject)({matcher:o.z.string().or((0,o.zStrictObject)({matchExpression:o.z.string(),value:o.z.string()}).array())}).optional(),properties:o.z.lazy(()=>te).array().optional(),requiredScopes:o.z.string().array().optional()}),ne=o.z.object({fields:te.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),re=o.z.object({data:o.z.unknown()}),mergeSourceWithState=(e,t)=>(0,o.isObject)(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=ne.parse(t),o=buildExpressionContext(e),c=(0,s.evaluate)(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!c)return{block:e,successful:!0};let l=Object.keys(a??{})?.reduce((e,t)=>(e[t]=(0,s.evaluate)(a?.[t],o),e),{}),u;if(Array.isArray(c))u=c.map(e=>{let t=X(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=X(r,{...c,external:l},o);u=e?.record,n.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:u},errors:Object.keys(n).length>0?n:void 0}},handleObjectArrayFromValues=(e,t,n,r)=>{if(Array.isArray(e.values))return e.values.map(i=>{let a=evaluateExpressionsInObject(i,t),s=X(e.properties,a,r);return(0,o.notMissing)(s?.errors)&&n.push(...s.errors),s?.record}).filter(Boolean)},handleObjectArrayFromExpression=(e,t,n,r,i)=>{if(e.expression)try{let t=(0,s.evaluate)(e.expression,n);if(Array.isArray(t))return t.map(t=>{let n=X(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=X(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}}catch{r.push({message:`Invalid expression`,id:t?.id,targetField:e.targetFieldKey});return}},handleSingleObject=(e,t,n,r)=>{let i=(0,o.notMissing)(e.values)?e.values:t,a=X(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},ie=__name((e,t,n,r,i)=>{if(!(0,o.isMissing)(e.properties))return e.array&&Array.isArray(e.values)?handleObjectArrayFromValues(e,n,r,i):e.array&&e.expression?handleObjectArrayFromExpression(e,t,n,r,i):handleSingleObject(e,t,r,i)},`handleObjectField`),X=__name((e,t,n)=>{if(!t)return;let r=mergeSourceWithState(t,n),i={},a=[],o={};for(let s of e){let e;if(s.type===`object`){if(e=ie(s,t,r,a,n),e===void 0)continue}else{let{error:n,value:i}=extractFieldValue(r,t?.id,s);if(e=i,n){a.push(n);continue}}s.custom?i[s.targetFieldKey]=e:o[s.targetFieldKey]=e}let s=Object.keys(i).length>0?{unified_custom_fields:i}:{};return{record:{...o,...s},errors:a.length>0?a:void 0}},`mapSingleRecord`),evaluateExpressionsInObject=(e,t)=>{if(e==null)return e;if(typeof e==`string`){if((0,s.isValidExpression)(e))try{return(0,s.evaluate)(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return ae(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},ae=__name((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=(0,s.evaluate)(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=ae(e,t,n),i=(0,o.notMissing)(r.value)?r.value:null;if(e.enumMapper===void 0)return{error:{message:`Enum mapper was not defined`,id:t,targetField:e.targetFieldKey}};let a=e.enumMapper.matcher;if((0,o.isString)(a)){let n=getEnumMatcher(a);return(0,o.notMissing)(n)?{value:{value:((0,o.notMissing)(i)?n(i):null)??`unmapped_value`,source_value:i}}:{error:{message:`The built-in matcher "${a}" is not supported`,id:t,targetField:e.targetFieldKey}}}for(let e of a){let{matchExpression:t,value:r}=e;if((0,s.evaluate)(t,n)===!0)return{value:{value:r,source_value:i}}}return{value:{value:`unmapped_value`,source_value:i}}},oe=[`data`,`headers`],se=o.z.object({baseUrl:o.z.string(),url:o.z.string(),method:o.z.enum(c.HttpMethods),saml:(0,o.zStrictObject)({objectKey:o.z.string(),key:o.z.string(),clientId:o.z.string(),cert:o.z.unknown().optional(),issuer:o.z.string().optional(),lifetime:o.z.number().optional(),nameId:o.z.string().optional(),audience:o.z.string().optional(),nameIdentifierFormat:o.z.string().optional(),tokenEndpoint:o.z.string().optional()}).optional(),response:(0,o.zStrictObject)({indexField:o.z.string().optional(),dataKey:o.z.string().optional(),nextKey:o.z.string().optional(),nextKeyIn:o.z.enum(oe).optional()}).optional(),iterator:(0,o.zStrictObject)({key:o.z.string(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),mode:o.z.enum([`cursor`,`offset`]).optional()}),cursor:(0,o.zStrictObject)({token:o.z.string().optional().nullable(),position:o.z.number().optional().nullable()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),ce=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),next:o.z.string().optional().nullable(),position:o.z.number().optional()}).optional(),le=25,Z=__name(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,l=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,u=t?(0,s.safeEvaluateRecord)({...t,args:l},e):{},d=t?.response?.nextKey,f=d&&Z(d),p=t?.response?.dataKey,m=p&&Z(p),h={...u?.response??{},...f?{nextKey:d}:{},...m?{dataKey:p}:{}},g={...u,customErrors:t?.customErrors,iterator:{...u?.iterator??{},condition:t?.iterator?.condition},response:f||m?h:u?.response},{baseUrl:_,url:v,method:y,response:b,iterator:x,cursor:S,customErrors:C,args:w,saml:T}=se.parse(g),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],D=E?.authorization,O=E?.certificates,k=O?(0,c.buildHttpsAgent)(O):void 0,A=B.parse(D),j=w?(0,c.parseRequestParameters)(w):{query:{},body:{},headers:{}},M=(0,c.createAuthorizationHeaders)(A),N={...j?.headers??{},...M},P=e.connector?.rateLimit,F=e.connector?.concurrency,I=P!==void 0||F!==void 0?{rateLimit:P,concurrency:F}:void 0,L=(0,o.notMissing)(T)?{[T.objectKey]:await(0,o.generateSamlAssertion)({key:T.key,clientId:T.clientId,cert:T.cert,issuer:T.issuer,lifetime:T.lifetime,audience:T.audience,nameId:T.nameId,nameIdentifierFormat:T.nameIdentifierFormat,tokenEndpoint:T.tokenEndpoint})}:{},R=x.mode===`offset`,z=S?.token??null,V=null,H=null,U=[],W=[],ee=[],G=a,K=S?.position??0,q=!0,J=!0,Y=!0;do{q?q=!1:R||(K=0),z===null?R&&(x.in===`query`?j.query[x.key]=K.toString():x.in===`body`&&(Array.isArray(j.body)||(j.body[x.key]=K))):x.in===`query`?(0,o.isObject)(z)?Object.entries(z).forEach(([e,t])=>{j.query[`${x.key}[${e}]`]=t?.toString()??``}):j.query[x.key]=z.toString():x.in===`body`&&(Array.isArray(j.body)||(j.body[x.key]=z));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${_}${v}`,queryParams:{...j?.query},method:y,headers:{...N},body:Array.isArray(j?.body)?j.body:{...j?.body,...L},customErrorConfigs:C,requestConfig:I,httpsAgent:k,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}V=z,W=b?.dataKey?ue(t.data,b.dataKey):t.data;let r=R?W?.slice(0,G):W?.slice(K,K+G);G-=r.length,K+=r.length,ee.push(t),U=U.concat(r),H=t?.status,z=de({result:t,response:b}),Y=(0,o.notMissing)(x.condition)?(0,s.safeEvaluate)(x.condition,t.data)===!0:!0,!R&&r.length===W.length&&G===0&&(K=0,V=z),J=!Y||(0,o.isMissing)(z)&&U.length<a}while((R||(0,o.notMissing)(z))&&Y&&U.length<a&&W?.length>0);return{block:e,successful:!0,output:{data:me(U,b),raw:ee,statusCode:H,next:J?void 0:V,position:J?void 0:K}}},ue=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(Z(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),de=__name(({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?fe(e.headers,r):pe(e.data,r)},`resolveNextIterator`),fe=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;if(Z(t)){let n=(0,s.safeEvaluate)(t,e);return typeof n==`string`&&n!==``||typeof n==`number`?n:null}let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},`resolveFromHeaders`),pe=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=(0,s.safeEvaluate)(Z(t)?t:`$.${t}`,e);return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),me=__name((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),he=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:B.optional(),certificates:V,saml:(0,o.zStrictObject)({objectKey:o.z.string(),key:o.z.string(),clientId:o.z.string(),cert:o.z.unknown().optional(),issuer:o.z.string().optional(),lifetime:o.z.number().optional(),nameId:o.z.string().optional(),audience:o.z.string().optional(),nameIdentifierFormat:o.z.string().optional(),tokenEndpoint:o.z.string().optional()}).optional(),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),ge=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?.response?.dataKey,l=a&&isJexlExpression(a),u=t?(0,s.safeEvaluateRecord)({...t,args:i},e):{},d={...u,customErrors:t?.customErrors,response:l?{...u?.response??{},dataKey:a}:u?.response},{baseUrl:f,url:p,method:m,response:h,authorization:g,certificates:_,customErrors:v,args:y,saml:b}=he.parse(d),x=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],S=x?.authorization,C=_??x?.certificates,w=C?(0,c.buildHttpsAgent)(C):void 0,T=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},E=(0,o.notMissing)(g)?g:B.parse(S),D=(0,c.createAuthorizationHeaders)(E),O={...T?.headers??{},...D},k=e.connector?.rateLimit,A=e.connector?.concurrency,j=k!==void 0||A!==void 0?{rateLimit:k,concurrency:A}:void 0,M=(0,o.notMissing)(b)?{[b.objectKey]:await(0,o.generateSamlAssertion)({key:b.key,clientId:b.clientId,cert:b.cert,issuer:b.issuer,lifetime:b.lifetime,audience:b.audience,nameId:b.nameId,nameIdentifierFormat:b.nameIdentifierFormat,tokenEndpoint:b.tokenEndpoint})}:{},N=Array.isArray(T?.body)?T?.body:{...T?.body,...M};if(E.type===`none`&&E.signing?.strategy){let t=E.signing,n=e.credentials??{};try{let e=(0,c.getSigningStrategy)(t.strategy);if(!e)throw Error(`Signing strategy "${t.strategy}" is not registered`);let r=e({method:m,url:`${f}${p}`,headers:O,query:T?.query??{},body:N},n,t);Object.assign(O,r)}catch(t){return buildStepErrorOutput(t,e)}}let P;try{P=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:T?.query,method:m,headers:O,body:N,customErrorConfigs:v,requestConfig:j,httpsAgent:w,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:_e(h?.dataKey?resolveDataKey(P.data,h.dataKey):P.data,h),raw:P,statusCode:P?.status,message:P?.message}}},resolveDataKey=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},_e=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),ve=[`data`,`headers`],ye=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:o.z.discriminatedUnion(`type`,[(0,o.zStrictObject)({type:o.z.literal(`none`)}),(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),(0,o.zStrictObject)({type:o.z.literal(`oauth2`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)})]).optional(),envelope:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.unknown())]).optional(),namespaces:o.z.strictObject({namespaceIdentifier:o.z.string(),namespace:o.z.string()}).array().optional(),soapOperation:o.z.string().optional(),soapAction:o.z.string().optional(),useSoapContext:o.z.boolean().optional().default(!0),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional(),nextKey:o.z.string().optional(),nextKeyIn:o.z.enum(ve).optional()}).optional(),iterator:(0,o.zStrictObject)({key:o.z.string(),in:o.z.enum(c.RequestParameterLocations)}),cursor:(0,o.zStrictObject)({token:o.z.string().optional().nullable(),position:o.z.number().optional().nullable()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),be=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),next:o.z.string().optional().nullable(),position:o.z.number().optional()}).optional(),xe=25,soapPaginatedRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,l=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,u=t?(0,s.safeEvaluateRecord)({...t,args:l},e):{},d={...u,customErrors:t?.customErrors},{baseUrl:f,url:p,method:m,response:h,iterator:g,cursor:_,authorization:v,customErrors:y,args:b,soapOperation:x,namespaces:S,envelope:C,soapAction:w,useSoapContext:T}=ye.parse(d),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,D=b?(0,c.parseRequestParameters)(b):{query:{},body:{},headers:{}},O=(0,c.createAuthorizationHeaders)((0,o.notMissing)(v)?v:B.parse(E)),k={...D?.headers??{},...O},A=e.connector?.rateLimit,j=e.connector?.concurrency,M={...(A!==void 0||j!==void 0)&&{rateLimit:A,concurrency:j},soapOperation:x,namespaces:S,envelope:C,soapAction:w,soapContext:T?{username:e.credentials?.username,password:e.credentials?.password}:void 0},N=_?.token??null,P=null,F=null,I=[],L=[],R=[],z=a,V=_?.position??0,H=!0,U;do{H?H=!1:V=0,N!==null&&(g.in===`query`?D.query[g.key]=N.toString():g.in===`body`&&(D.body[g.key]=N));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:D?.query,method:m,headers:k,body:D?.body,customErrorConfigs:y,requestConfig:M,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}P=N,L=h?.dataKey?t.data[h?.dataKey]:t.data,Array.isArray(L)||(L=L?[L]:[]);let r=L?.slice(V,V+z);z-=r.length,V+=r.length,R.push(t),I=I.concat(r),F=t?.status,N=resolveNextIterator({result:t,response:h}),r.length===L.length&&z===0&&(V=0,P=N),U=(0,o.isMissing)(N)&&I.length<a}while((0,o.notMissing)(N)&&I.length<a&&L?.length>0);return{block:e,successful:!0,output:{data:Se(I,h),raw:R,statusCode:F,next:U?void 0:P,position:U?void 0:V}}},resolveNextIterator=({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?resolveFromHeaders(e.headers,r):resolveFromData(e.data,r)},resolveFromHeaders=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},resolveFromData=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=e[t];return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`?n:null},Se=__name((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Ce=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:B.optional(),envelope:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.unknown())]).optional(),namespaces:o.z.strictObject({namespaceIdentifier:o.z.string(),namespace:o.z.string()}).array().optional(),soapOperation:o.z.string().optional(),soapAction:o.z.string().optional(),useSoapContext:o.z.boolean().optional().default(!0),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),we=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),soapRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?(0,s.safeEvaluateRecord)({...t,args:i},e):{},l={...a,customErrors:t?.customErrors},{baseUrl:u,url:d,method:f,response:p,authorization:m,customErrors:h,args:g,soapOperation:_,namespaces:v,envelope:y,soapAction:b,useSoapContext:x}=Ce.parse(l),S=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,C=g?(0,c.parseRequestParameters)(g):{query:{},body:{},headers:{}},w=(0,c.createAuthorizationHeaders)((0,o.notMissing)(m)?m:B.parse(S)),T={...C?.headers??{},...w},E=e.connector?.rateLimit,D=e.connector?.concurrency,O={...(E!==void 0||D!==void 0)&&{rateLimit:E,concurrency:D},soapOperation:_,namespaces:v,envelope:y,soapAction:b,soapContext:x?{username:e.credentials?.username,password:e.credentials?.password}:void 0},k;try{k=await n.performRequest({httpClient:e.httpClient,url:`${u}${d}`,queryParams:C?.query,method:f,headers:T,body:C?.body,customErrorConfigs:h,requestConfig:O,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:Te(p?.dataKey?k.data[p?.dataKey]:k.data,p),raw:k,statusCode:k?.status,message:k?.message}}},Te=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Ee=o.z.object({values:o.z.string().or(o.z.record(o.z.string(),o.z.unknown())).or(o.z.array(o.z.unknown()))}),De=o.z.object({data:o.z.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Ee.parse(t),r=Array.isArray(n)?n.map(t=>evaluateValue(t,e)):evaluateValue(n,e);return{block:{...e},successful:!0,output:{data:r}}},evaluateValue=(e,t)=>(0,o.isString)(e)?(0,s.safeEvaluate)(e,t):(0,o.isObject)(e)?(0,s.safeEvaluateRecord)(e,t):e,Oe=o.z.object({targetFieldKey:o.z.string(),type:o.z.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:o.z.boolean().default(!1),custom:o.z.boolean().default(!1),hidden:o.z.boolean().default(!1),properties:o.z.lazy(()=>Oe).array().optional(),requiredScopes:o.z.string().array().optional()}),ke=o.z.object({fields:Oe.array().optional(),dataSource:o.z.string()}),Ae=o.z.object({data:o.z.unknown()});let Q=function(e){return e.String=`string`,e.Number=`number`,e.Boolean=`boolean`,e.DateTimeString=`datetime_string`,e}({});const typecast=({value:e,type:t,format:n})=>{if((0,o.isMissing)(e))return null;switch(t){case Q.String:return(0,o.safeParseToString)({value:e});case Q.Number:return(0,o.safeParseToNumber)({value:e});case Q.Boolean:return(0,o.safeParseToBoolean)({value:e});case Q.DateTimeString:return(0,o.safeParseToDateTimeString)({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(Q).includes(e),je=__name(async({block:e})=>{let t=e?.fieldConfigs;if(!t||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let n;return n=Array.isArray(e.result)?e.result.map(e=>Me(e,t)):Me(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),Me=__name((e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i}=t;isFieldSupportedType(i)&&(!t.custom&&(0,o.notMissing)(n[r])?n[r]=typecast({value:e[r],type:i}):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},`mapSingleRecord`),typecastStepFunction=async({block:e,params:t})=>{let{fields:n,dataSource:r}=ke.parse(t),i=(0,s.evaluate)(r,buildExpressionContext(e));if(!n||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let a;return a=Array.isArray(i)?i.map(e=>mapSingleRecord(e,n)):mapSingleRecord(i,n),{block:{...e},successful:!0,output:{data:a}}},handleObjectField=(e,t)=>!e.properties||!t?t:Array.isArray(t)?t.map(t=>typeof t==`object`&&t?mapSingleRecord(t,e.properties):t):typeof t==`object`&&t?mapSingleRecord(t,e.properties):t,mapSingleRecord=(e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i,array:a}=t;i===`object`?!t.custom&&(0,o.notMissing)(n[r])?n[r]=handleObjectField(t,e[r]):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=handleObjectField(t,e.unified_custom_fields?.[r])):isFieldSupportedType(i)&&(!t.custom&&(0,o.notMissing)(n[r])?(!a||!Array.isArray(n[r]))&&(n[r]=typecast({value:e[r],type:i})):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(!a||!Array.isArray(n.unified_custom_fields[r]))&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},Ne=(0,o.zStrictObject)({content:o.z.string().describe(`The file content as base64 encoded string`),contentType:o.z.string().optional().describe(`The MIME type for the binary content (defaults to application/octet-stream)`)}),Pe=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:B.optional(),binaryContent:Ne.describe(`Raw binary content for octet-stream uploads`),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Fe=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),uploadBinaryStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,response:f,authorization:p,binaryContent:m,args:h,customErrors:g}=Pe.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?(0,c.parseRequestParameters)(h):{query:{},body:{},headers:{}},y=(0,c.createAuthorizationHeaders)((0,o.notMissing)(p)?p:B.parse(_)),b=Buffer.from(m.content,`base64`),x={"content-type":m.contentType??`application/octet-stream`,...v?.headers??{},...y},S=e.connector?.rateLimit,C=e.connector?.concurrency,w=S!==void 0||C!==void 0?{rateLimit:S,concurrency:C}:void 0,T;try{T=await e.httpClient.request({url:`${l??``}${u}`,method:d,headers:x,queryParams:v?.query,payload:b,requestConfig:w})}catch(t){let n=t;return{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let E=(0,c.translateCustomError)(T,g,e.credentials);return(0,c.isFailedStatusCode)(E?.status)?{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(new c.HttpResponseError(E,E.message))],output:{statusCode:E.status,message:E.message}}:{block:e,successful:!0,output:{data:Ie(f?.dataKey?E.data[f?.dataKey]:E.data,f),raw:E,statusCode:E?.status,message:E?.message}}},Ie=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Le=(0,o.zStrictObject)({fieldName:o.z.string().describe(`The form field name for the file`),content:o.z.string().describe(`The file content as base64 encoded string`),filename:o.z.string().describe(`The filename to use in the upload`),contentType:o.z.string().optional().describe(`The MIME type of the file (e.g., "image/png", "application/pdf")`)}),Re=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:B.optional(),file:Le.describe(`The file to upload`),additionalFields:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional(),contentType:o.z.string().optional().describe(`The MIME type for this form field (e.g., "application/json")`)}).array().optional().describe(`Additional form fields to include in the multipart request`),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),ze=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),uploadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n,additionalFields:r}=t,i=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,l=t?(0,s.safeEvaluateRecord)({...t,args:i,additionalFields:a},e):{},u={...l,customErrors:t?.customErrors},{baseUrl:f,url:p,method:m,response:h,authorization:g,file:_,additionalFields:v,args:y,customErrors:b}=Re.parse(u),x=l?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,S=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},C=(0,c.createAuthorizationHeaders)((0,o.notMissing)(g)?g:B.parse(x)),w=new d.default;if(v)for(let e of v){let t=typeof e.value==`object`?JSON.stringify(e.value):String(e.value);w.append(e.name,t,e.contentType?{contentType:e.contentType}:void 0)}let T=Buffer.from(_.content,`base64`);w.append(_.fieldName,T,{filename:_.filename,contentType:_.contentType});let E={...w.getHeaders(),...S?.headers??{},...C},D=e.connector?.rateLimit,O=e.connector?.concurrency,k=D!==void 0||O!==void 0?{rateLimit:D,concurrency:O}:void 0,A;try{A=await e.httpClient.request({url:`${f??``}${p}`,method:m,headers:E,queryParams:S?.query,payload:w,requestConfig:k})}catch(t){return buildStepErrorOutput(t,e)}let j=(0,c.translateCustomError)(A,b,e.credentials);return(0,c.isFailedStatusCode)(j?.status)?buildStepErrorOutput(new c.HttpResponseError(j,j.message),e):{block:e,successful:!0,output:{data:indexResponseData(h?.dataKey?j.data[h?.dataKey]:j.data,h),raw:j,statusCode:j?.status,message:j?.message}}},indexResponseData=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e};let $=function(e){return e.TYPECAST=`typecast`,e.MAP_FIELDS=`map_fields`,e.GROUP_DATA=`group_data`,e.REQUEST=`request`,e.PAGINATED_REQUEST=`paginated_request`,e.SOAP_REQUEST=`soap_request`,e.SOAP_PAGINATED_REQUEST=`soap_paginated_request`,e.STATIC_VALUES=`static_values`,e.UPLOAD_FILE=`upload_file`,e.UPLOAD_BINARY=`upload_binary`,e.DOWNLOAD_FILE=`download_file`,e.EMIT_EVENT=`emit_event`,e.BROWSER_USE=`browser_use`,e.CODE_EXECUTION_LAMBDA=`code_execution_lambda`,e}({});const Be={[$.TYPECAST]:{v1:{fn:je},v2:{fn:typecastStepFunction,inputSchema:ke,outputSchema:Ae}},[$.MAP_FIELDS]:{v1:{fn:q},v2:{fn:mapFieldsStepFunction,inputSchema:ne,outputSchema:re}},[$.REQUEST]:{v1:{fn:requestStepFunction,inputSchema:he,outputSchema:ge}},[$.GROUP_DATA]:{v1:{fn:groupDataStepFunction,inputSchema:G,outputSchema:K}},[$.PAGINATED_REQUEST]:{v1:{fn:paginatedRequestStepFunction,inputSchema:se,outputSchema:ce}},[$.SOAP_REQUEST]:{v1:{fn:soapRequestStepFunction,inputSchema:Ce,outputSchema:we}},[$.SOAP_PAGINATED_REQUEST]:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:ye,outputSchema:be}},[$.STATIC_VALUES]:{v1:{fn:staticValuesStepFunction,inputSchema:Ee,outputSchema:De}},[$.UPLOAD_FILE]:{v1:{fn:uploadFileStepFunction,inputSchema:Re,outputSchema:ze}},[$.UPLOAD_BINARY]:{v1:{fn:uploadBinaryStepFunction,inputSchema:Pe,outputSchema:Fe}},[$.DOWNLOAD_FILE]:{v1:{fn:downloadFileStepFunction,inputSchema:H,outputSchema:U}},[$.EMIT_EVENT]:{v1:{fn:emitEventStepFunction,inputSchema:W,outputSchema:ee}},[$.BROWSER_USE]:{v1:{fn:browserUseStepFunction,inputSchema:D,outputSchema:O}},[$.CODE_EXECUTION_LAMBDA]:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:k,outputSchema:A}}},formatZodIssues=(e,t,n)=>e instanceof o.z.ZodError?e.issues.map(e=>({...e,kind:t,functionName:n})):[{kind:t,functionName:n,message:e?.message??`unknown error`}],stepFunctionEnhancedWithSchemasValidation=(e,t)=>async({block:n,params:r})=>{try{e.inputSchema&&e.inputSchema.parse(r)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`input_schema_validation`,t)}}let i=await e.fn({block:n,params:r});try{e.outputSchema&&e.outputSchema.parse(i.output)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`output_schema_validation`,t)}}return i},Ve={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Be}){let i=r?.[e]?.[`v${t}`];if(!i)throw Error(`Unknown step function: ${e} v${t}`);return n?{...i,fn:stepFunctionEnhancedWithSchemasValidation(i,e)}:i}},isForeachStep=e=>`iterator`in e&&typeof e.iterator==`string`;exports.AUTHORIZATION_SCHEMA=B,exports.BROWSER_USE_INPUT_PARAMS=D,exports.BROWSER_USE_OUTPUT=O,exports.COMPOSITE_ID_LATEST_VERSION=1,exports.CoreError=x,exports.ExecutionModes=w,exports.INPUT_ENUM_REGISTRY=S,exports.ReleaseStages=C,exports.StepFunctionName=$,exports.StepFunctionsFactory=Ve,exports.StepFunctionsRegistry=Be,exports.areCursorsEqual=areCursorsEqual,exports.buildExpressionContext=buildExpressionContext,exports.decodeCompositeId=decodeCompositeId,exports.encodeCompositeId=encodeCompositeId,exports.evaluateEventRouter=evaluateEventRouter,exports.evaluateExternalAccountIdExtractor=evaluateExternalAccountIdExtractor,exports.expandCursor=expandCursor,exports.getCategoryDetails=getCategoryDetails,exports.getInputEnumValues=getInputEnumValues,exports.getIteratorLocation=getIteratorLocation,exports.getPaginationKeys=getPaginationKeys,exports.isCompositeId=isCompositeId,exports.isCoreError=isCoreError,exports.isCursorEmpty=isCursorEmpty,exports.isForeachStep=isForeachStep,exports.isValidCategory=isValidCategory,exports.isValidEnumRef=isValidEnumRef,exports.minifyCursor=minifyCursor,exports.stripPaginationParams=stripPaginationParams,exports.updateCursor=updateCursor;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0}),n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__copyProps=(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},__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let o=require(`@stackone/utils`),s=require(`@stackone/expressions`),c=require(`@stackone/transport`),l=require(`@aws-sdk/client-lambda`),u=require(`mime-types`);u=__toESM(u);let d=require(`form-data`);d=__toESM(d);const f=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=f.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},p={hris:{title:`HRIS`,key:`hris`,description:`Human Resource Information System`},crm:{title:`CRM`,key:`crm`,description:`Customer Relationship Management`},ats:{title:`ATS`,key:`ats`,description:`Applicant Tracking System`},lms:{title:`LMS`,key:`lms`,description:`Learning Management System`},marketing:{title:`Marketing`,key:`marketing`,description:`Marketing`},filestorage:{title:`File Storage`,key:`filestorage`,description:`File Storage`},iam:{title:`IAM`,key:`iam`,description:`Identity and Access Management`},internal:{title:`Internal`,key:`internal`,description:`Category for internal actions`},action:{title:`Action`,key:`action`,description:`Action`}},getCategoryDetails=e=>p[e.toLowerCase()]??null,isValidCategory=e=>!!p[e.toLowerCase()],m=`so1!`,h=(0,o.encodeToBase64)(`so1!`),g=`:`,_=`,`,v=RegExp(`(?<!\\\\):`,`g`),y=RegExp(`(?<!\\\\),`,`g`),b=1;var x=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends x{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!(0,o.isMissing)(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!(0,o.isMissing)(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(y).forEach(e=>{let[n,i]=e.split(v),a=getOriginalKey(n,t.aliases??{});r[a]=unescapeValue(i)}),r},getComposedIdV1=(e,t={})=>{if(isSingleIdentifier(e))return getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!0});if(isMultipleIdentifier(e))return e.identifiers.map(e=>getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!1})).join(`,`);throw new CompositeIdUnknownIdentifierError},getSingleIdentifierString=({identifier:e,compositeIdAliases:t,isSoleIdentifier:n})=>[n?`id`:t[e.key]||e.key,escapeValue(e.value)].filter(Boolean).join(`:`),getOriginalKey=(e,t)=>Object.keys(t).find(n=>t[n]===e)??e,decodeId=(e,t)=>{if(t.version===1)return decodeIdV1(e);throw new CompositeIdUnsupportedVersionError(`Cannot decode ID, unsupported version number: ${t.version}`)},encodeIdV1=e=>`${h}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(h))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(h)[1];if(!t)throw new CompositeIdMissingBodyError(`Trying to decode an ID without a body: ${e}`);return(0,o.decodeFromBase64)(t)},escapeValue=e=>[`,`,`:`].reduce((e,t)=>e.replace(t,`\\`+t),e),unescapeValue=e=>[`,`,`:`].reduce((e,t)=>{let n=`\\`+t;return e.replace(RegExp(`\\\\`+n,`g`),t)},e),isCompositeId=e=>(0,o.isMissing)(e)?!1:e.startsWith(h),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if((0,o.isMissing)(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=(0,s.safeEvaluate)(`{{${n.result.trim()}}}`,t);if(!(0,o.isMissing)(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!(0,o.isMissing)(n))for(let e of n.rules){let n=(0,s.safeEvaluate)(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,(0,s.safeEvaluate)(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},S={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>S[e],isValidEnumRef=e=>e in S,C=[`preview`,`beta`,`ga`,`deprecated`,`internal`],w=[`sync`,`async`],T=(0,o.zStrictObject)({r:o.z.record(o.z.string(),(0,o.zStrictObject)({n:o.z.number().optional().nullable(),c:o.z.string().optional().nullable(),p:o.z.number().optional().nullable()})),v:o.z.number(),t:o.z.number()}),E=(0,o.zStrictObject)({remote:o.z.record(o.z.string(),(0,o.zStrictObject)({pageNumber:o.z.number().optional(),providerPageCursor:o.z.string().optional(),position:o.z.number().optional()})),version:o.z.number(),timestamp:o.z.number()}),minifyCursor=e=>(0,o.encodeToBase64)(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if((0,o.isString)(e)){let t=(0,o.decodeFromBase64)(e),n=JSON.parse(t);return expandCursorObject(T.parse(n))}else return E.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:i,...a}=n,{timestamp:s,...c}=r;return(0,o.getContentHash)(a)===(0,o.getContentHash)(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>(0,o.isMissing)(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return((0,o.isMissing)(t)||r!==t.toString())&&(n=n&&(0,o.isMissing)(i.pageNumber)&&(0,o.isMissing)(i.position)&&(0,o.isMissing)(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},s=(0,o.isMissing)(n)&&(0,o.isMissing)(r)&&(0,o.isMissing)(i);return(0,o.isMissing)(e)?{remote:s?{}:{[t]:a},version:2,timestamp:Date.now()}:s?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof x;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}const D={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,Internal:`INTERNAL`},O={Http:`HTTP`,Mcp:`MCP`,ActionRpc:`ACTION_RPC`,WebSocket:`WEBSOCKET`},k={Http:`HTTP`,WebSocket:`WEBSOCKET`,Sse:`SSE`},A={ApiKey:`API_KEY`,SessionToken:`SESSION_TOKEN`,UserSession:`USER_SESSION`,Cookie:`COOKIE`,Webhook:`WEBHOOK`,Signature:`SIGNATURE`},browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},j=o.z.object({startUrl:o.z.string().url(),systemPrompt:o.z.string().optional(),viewport:(0,o.zStrictObject)({width:o.z.number().int().positive(),height:o.z.number().int().positive()}).optional(),locale:o.z.string().optional(),budgets:(0,o.zStrictObject)({maxDurationMs:o.z.number().int().positive(),maxSteps:o.z.number().int().positive()}),auth:(0,o.zStrictObject)({sensitiveKeys:o.z.array(o.z.string().min(1)).optional(),requiresSession:o.z.boolean().optional()}).optional()}),M=o.z.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(typeof e.message==`string`&&e.message.trim().length>0)return e.message}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(e.error!=null&&typeof e.error==`object`&&!Array.isArray(e.error)&&typeof e.error.message==`string`)return e.error.message;if(typeof e.error==`string`)return e.error;if(typeof e.error_description==`string`)return e.error_description}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof c.HttpResponseError){let n=e.message;return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:e.response?.status??500,message:extractErrorMessage(e.response,n),data:e.response?.data,raw:sanitizeRaw(e.response)}}}if(isHttpLikeError(e)){let n=e.response,r=e instanceof Error?e.message:`HTTP error: ${n.status??500}`;return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:n.status??500,message:extractErrorMessage(n,r),data:n.data,raw:sanitizeRaw(n)}}}return e instanceof Error?{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:500,message:String(e)}}},isAwsCredentials=e=>!!e&&typeof e.accessKeyId==`string`&&typeof e.secretAccessKey==`string`,buildLambdaClientConfig=({region:e,endpoint:t,credentials:n})=>({region:e,...t?{endpoint:t}:{},...isAwsCredentials(n)?{credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,sessionToken:typeof n.sessionToken==`string`?n.sessionToken:void 0}}:t?{credentials:{accessKeyId:`local`,secretAccessKey:`local`}}:{}}),defaultClientFactory=e=>new l.LambdaClient(e),invokeLambda=async({lambdaName:e,payload:t,region:n,endpoint:r,invocationType:i=`RequestResponse`,qualifier:a,credentials:o,clientFactory:s=defaultClientFactory})=>{let c=s(buildLambdaClientConfig({region:n,endpoint:r,credentials:o})),u=new l.InvokeCommand({FunctionName:e,InvocationType:i,Qualifier:a,Payload:t?Buffer.from(JSON.stringify(t)):void 0}),d=await c.send(u),f=d.Payload?Buffer.from(d.Payload).toString(`utf-8`):``,p;if(f.length===0)p=void 0;else try{p=JSON.parse(f)}catch{p=f}return{statusCode:d.StatusCode??200,payload:p,functionError:d.FunctionError,executedVersion:d.ExecutedVersion}},N=(0,o.zStrictObject)({lambdaName:o.z.string(),region:o.z.string().optional(),endpoint:o.z.string().optional(),invocationType:o.z.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:o.z.string().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:o.z.string().optional()}),P=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),executedVersion:o.z.string().optional()}).optional(),F=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||F.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,I=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;try{let n=(0,s.evaluate)(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||(0,s.safeEvaluate)(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,c=typeof o==`string`&&!F.test(o),l=t?.qualifier,u=typeof l==`string`&&!hasExpressionMarker(l),d={...t?(0,s.safeEvaluateRecord)(i===void 0?t:{...t,args:a},e):{},...c?{dataKey:o}:{},...u?{qualifier:l}:{}},f;try{f=N.parse(d)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:p,region:m,endpoint:h,invocationType:g,qualifier:_,args:v,dataKey:y}=f,b;try{b=await n({lambdaName:p,payload:buildPayloadFromArgs(v),region:m,endpoint:h,invocationType:g,qualifier:_,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(b.functionError){let t=typeof b.payload==`object`&&b.payload!==null&&`errorMessage`in b.payload&&typeof b.payload.errorMessage==`string`?b.payload.errorMessage:`Lambda function error: ${b.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:b.functionError}],output:{statusCode:b.statusCode,message:t,data:b.payload,raw:b}}}return{block:e,successful:!0,output:{data:y?I(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},L=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),R=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional()}),z=o.z.discriminatedUnion(`strategy`,[L,R]),B=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:z.optional()}),V=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),H=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),U=(0,o.zStrictObject)({type:o.z.literal(`oauth2`),authorizationUrl:o.z.string().optional(),authorizationParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenUrl:o.z.string().optional(),tokenParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenExpiresIn:o.z.number().optional(),tokenRefreshExpiresIn:o.z.number().optional(),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0),scopes:o.z.string().optional(),scopeDelimiter:o.z.string().optional(),customHeaders:o.z.record(o.z.string(),o.z.string()).optional(),pkce:o.z.boolean().optional(),additionalTokenFields:o.z.record(o.z.string(),o.z.string().optional()).optional(),issuer:o.z.string().optional()}),W=o.z.discriminatedUnion(`type`,[B,V,H,U]),ee=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),G=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:W.optional(),responseMode:o.z.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:o.z.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:o.z.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:(0,o.zStrictObject)({dataKey:o.z.string().optional(),fileNameKey:o.z.string().optional(),contentTypeKey:o.z.string().optional(),contentIsBase64:o.z.boolean().optional().default(!1),urlKey:o.z.string().optional(),forwardAuth:o.z.boolean().optional().default(!1)}).optional(),maxRedirects:o.z.number().optional().default(5),followRedirects:o.z.boolean().optional().default(!0),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),K=(0,o.zStrictObject)({data:o.z.union([o.z.string(),o.z.instanceof(Buffer)]).optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),headers:o.z.record(o.z.string(),o.z.string()).optional(),contentDisposition:o.z.string().optional(),fileMetadata:(0,o.zStrictObject)({contentType:o.z.string().optional(),contentLength:o.z.number().optional(),fileName:o.z.string().optional(),lastModified:o.z.string().optional(),etag:o.z.string().optional()}).optional(),finalUrl:o.z.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,authorization:f,args:p,responseMode:m,responseType:h,encoding:g,response:_,maxRedirects:v,followRedirects:y}=G.parse(a),b=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,x=p?(0,c.parseRequestParameters)(p):{query:{},body:{},headers:{}},S=(0,c.createAuthorizationHeaders)((0,o.notMissing)(f)?f:W.parse(b)),C={...x?.headers??{},...S},w=e.connector?.rateLimit,T=e.connector?.concurrency,E=w!==void 0||T!==void 0?{rateLimit:w,concurrency:T}:void 0;if(m===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,maxRedirects:y?v:0,requestConfig:E});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,responseType:h,encoding:g,response:_,maxRedirects:y?v:0,requestConfig:E,authHeaders:S})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:s,authHeaders:c}=e,l=n.data;if(r.urlKey){let e=extractValueByPath(l,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?c:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:s}),o=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:o,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(l,r.dataKey);if((0,o.isMissing)(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let s=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:s,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if((0,o.isMissing)(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);case`binary`:default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=(0,o.isString)(e[`content-type`])?e[`content-type`]:void 0,n=(0,o.isString)(e[`content-length`])?e[`content-length`]:void 0,r=(0,o.isString)(e[`content-disposition`])?e[`content-disposition`]:void 0,i=(0,o.isString)(e[`last-modified`])?e[`last-modified`]:void 0,a=(0,o.isString)(e.etag)?e.etag:void 0,s=n?parseInt(n,10):void 0,c=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(s)?void 0:s,fileName:c,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return u.default.extension(t)||void 0},q=o.z.object({event:o.z.object({eventType:o.z.string(),eventDate:o.z.string().optional(),data:o.z.unknown().optional()}).optional()}),J=o.z.record(o.z.string(),o.z.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?(0,s.safeEvaluateRecord)(t,e):{},{event:r}=q.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventDate:r.eventDate,data:r.data})}catch(t){throw e.logger?.error({code:`EmitEventError`,message:`emitEvent callback failed: ${t.message}`}),t}else r&&!e.emitEvent&&e.logger?.warning({message:`emit_event step executed but no emitEvent callback provided on the block`});let{event:i,...a}=n;return{block:{...e},successful:!0,output:a}},Y=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),te=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=Y.parse(t),i=n.reduce((t,n)=>{let i=e.steps?.[n]?.output?.data;return i?r?{...t,[n]:{...i}}:(Object.keys(i).forEach(e=>{t[e]={...(0,o.notMissing)(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},ne=__name(async({block:e})=>{let t=e?.fieldConfigs,n=[],r=e.steps;if(!t||e?.debug?.custom_mappings===`disabled`||!r)return{block:e,successful:!0};let i=buildExpressionContext(e),a;if(Array.isArray(e.result)){let o=e.result.length;a=e.result.map((e,a)=>{let s=re(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=re(e.result,t,r,i);a=o.record,n.push(...o.errors||[])}return{block:{...e,result:a},successful:!0,errors:Object.keys(n).length>0?n:void 0}},`mapFieldsStepFunction`),extractSingleRecordBlockStepData=(e,t,n)=>Object.entries(e).reduce((e,[r,i])=>{let a=i?.output?.data;return Array.isArray(a)&&a.length===t?e[r]={output:{data:a[n]}}:e[r]=i,e},{}),re=__name((e,t,n,r)=>{if(!e||!n)return{record:e};let i={...r,unified:{...e},...typeof n==`object`?n:{}},a={},o=[],s={...e};for(let n of t){let{error:t,value:r}=ie(i,e.id,n);if(t){o.push(t);continue}n.custom?a[n.targetFieldKey]=r:s[n.targetFieldKey]=r}return{record:{...s,unified_custom_fields:Object.keys(a).length>0?a:void 0},errors:o.length>0?o:void 0}},`mapSingleRecord`),ie=__name((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=(0,s.evaluate)(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return o.getCountryAlpha2CodeByAlpha2Code;case`country_alpha3code_by_alpha3code`:return o.getCountryAlpha3CodeByAlpha3Code;case`country_code_by_country_code`:return o.getCountryCodeByCountryCode;case`country_name_by_country_name`:return o.getCountryNameByCountryName;case`country_name_by_alpha3code`:return o.getCountryNameByAlpha3Code;case`country_name_by_alpha2code`:return o.getCountryNameByAlpha2Code;case`country_name_by_country_code`:return o.getCountryNameByCountryCode;case`country_alpha3code_by_alpha2code`:return o.getCountryAlpha3CodeByAlpha2Code;case`country_alpha3code_by_country_name`:return o.getCountryAlpha3CodeByCountryName;case`country_alpha3code_by_country_code`:return o.getCountryAlpha3CodeByCountryCode;case`country_alpha2code_by_alpha3code`:return o.getCountryAlpha2CodeByAlpha3Code;case`country_alpha2code_by_country_name`:return o.getCountryAlpha2CodeByCountryName;case`country_alpha2code_by_country_code`:return o.getCountryAlpha2CodeByCountryCode;case`country_code_by_alpha2code`:return o.getCountryCodeByAlpha2Code;case`country_code_by_alpha3code`:return o.getCountryCodeByAlpha3Code;case`country_code_by_country_name`:return o.getCountryCodeByCountryName;case`country_subdivisions_by_alpha2code`:return o.getCountrySubDivisionsByAlpha2Code;case`country_subdivision_code_by_subdivision_name`:return o.getCountrySubDivisionCodeBySubDivisionName;case`country_alpha2code_by_citizenship`:return o.getCountryAlpha2CodeByCitizenship;case`country_subdivision_name_by_subdivision_code`:return o.getCountrySubDivisionNameBySubDivisionCode;case`document_file_format_from_extension`:return o.getDocumentFileFormatFromExtension;default:return}},ae=(0,o.zStrictObject)({targetFieldKey:o.z.string(),alias:o.z.string().optional(),expression:o.z.string().optional(),values:o.z.unknown().optional(),type:o.z.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:o.z.boolean().default(!1),custom:o.z.boolean().default(!1),hidden:o.z.boolean().default(!1),enumMapper:(0,o.zStrictObject)({matcher:o.z.string().or((0,o.zStrictObject)({matchExpression:o.z.string(),value:o.z.string()}).array())}).optional(),properties:o.z.lazy(()=>ae).array().optional(),requiredScopes:o.z.string().array().optional()}),oe=o.z.object({fields:ae.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),se=o.z.object({data:o.z.unknown()}),mergeSourceWithState=(e,t)=>(0,o.isObject)(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=oe.parse(t),o=buildExpressionContext(e),c=(0,s.evaluate)(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!c)return{block:e,successful:!0};let l=Object.keys(a??{})?.reduce((e,t)=>(e[t]=(0,s.evaluate)(a?.[t],o),e),{}),u;if(Array.isArray(c))u=c.map(e=>{let t=X(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=X(r,{...c,external:l},o);u=e?.record,n.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:u},errors:Object.keys(n).length>0?n:void 0}},handleObjectArrayFromValues=(e,t,n,r)=>{if(Array.isArray(e.values))return e.values.map(i=>{let a=evaluateExpressionsInObject(i,t),s=X(e.properties,a,r);return(0,o.notMissing)(s?.errors)&&n.push(...s.errors),s?.record}).filter(Boolean)},handleObjectArrayFromExpression=(e,t,n,r,i)=>{if(e.expression)try{let t=(0,s.evaluate)(e.expression,n);if(Array.isArray(t))return t.map(t=>{let n=X(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=X(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}}catch{r.push({message:`Invalid expression`,id:t?.id,targetField:e.targetFieldKey});return}},handleSingleObject=(e,t,n,r)=>{let i=(0,o.notMissing)(e.values)?e.values:t,a=X(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},ce=__name((e,t,n,r,i)=>{if(!(0,o.isMissing)(e.properties))return e.array&&Array.isArray(e.values)?handleObjectArrayFromValues(e,n,r,i):e.array&&e.expression?handleObjectArrayFromExpression(e,t,n,r,i):handleSingleObject(e,t,r,i)},`handleObjectField`),X=__name((e,t,n)=>{if(!t)return;let r=mergeSourceWithState(t,n),i={},a=[],o={};for(let s of e){let e;if(s.type===`object`){if(e=ce(s,t,r,a,n),e===void 0)continue}else{let{error:n,value:i}=extractFieldValue(r,t?.id,s);if(e=i,n){a.push(n);continue}}s.custom?i[s.targetFieldKey]=e:o[s.targetFieldKey]=e}let s=Object.keys(i).length>0?{unified_custom_fields:i}:{};return{record:{...o,...s},errors:a.length>0?a:void 0}},`mapSingleRecord`),evaluateExpressionsInObject=(e,t)=>{if(e==null)return e;if(typeof e==`string`){if((0,s.isValidExpression)(e))try{return(0,s.evaluate)(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return le(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},le=__name((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=(0,s.evaluate)(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=le(e,t,n),i=(0,o.notMissing)(r.value)?r.value:null;if(e.enumMapper===void 0)return{error:{message:`Enum mapper was not defined`,id:t,targetField:e.targetFieldKey}};let a=e.enumMapper.matcher;if((0,o.isString)(a)){let n=getEnumMatcher(a);return(0,o.notMissing)(n)?{value:{value:((0,o.notMissing)(i)?n(i):null)??`unmapped_value`,source_value:i}}:{error:{message:`The built-in matcher "${a}" is not supported`,id:t,targetField:e.targetFieldKey}}}for(let e of a){let{matchExpression:t,value:r}=e;if((0,s.evaluate)(t,n)===!0)return{value:{value:r,source_value:i}}}return{value:{value:`unmapped_value`,source_value:i}}},ue=[`data`,`headers`],de=o.z.object({baseUrl:o.z.string(),url:o.z.string(),method:o.z.enum(c.HttpMethods),saml:(0,o.zStrictObject)({objectKey:o.z.string(),key:o.z.string(),clientId:o.z.string(),cert:o.z.unknown().optional(),issuer:o.z.string().optional(),lifetime:o.z.number().optional(),nameId:o.z.string().optional(),audience:o.z.string().optional(),nameIdentifierFormat:o.z.string().optional(),tokenEndpoint:o.z.string().optional()}).optional(),response:(0,o.zStrictObject)({indexField:o.z.string().optional(),dataKey:o.z.string().optional(),nextKey:o.z.string().optional(),nextKeyIn:o.z.enum(ue).optional()}).optional(),iterator:(0,o.zStrictObject)({key:o.z.string(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),mode:o.z.enum([`cursor`,`offset`]).optional()}),cursor:(0,o.zStrictObject)({token:o.z.string().optional().nullable(),position:o.z.number().optional().nullable()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),fe=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),next:o.z.string().optional().nullable(),position:o.z.number().optional()}).optional(),pe=25,Z=__name(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,l=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,u=t?(0,s.safeEvaluateRecord)({...t,args:l},e):{},d=t?.response?.nextKey,f=d&&Z(d),p=t?.response?.dataKey,m=p&&Z(p),h={...u?.response??{},...f?{nextKey:d}:{},...m?{dataKey:p}:{}},g={...u,customErrors:t?.customErrors,iterator:{...u?.iterator??{},condition:t?.iterator?.condition},response:f||m?h:u?.response},{baseUrl:_,url:v,method:y,response:b,iterator:x,cursor:S,customErrors:C,args:w,saml:T}=de.parse(g),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],D=E?.authorization,O=E?.certificates,k=O?(0,c.buildHttpsAgent)(O):void 0,A=W.parse(D),j=w?(0,c.parseRequestParameters)(w):{query:{},body:{},headers:{}},M=(0,c.createAuthorizationHeaders)(A),N={...j?.headers??{},...M},P=e.connector?.rateLimit,F=e.connector?.concurrency,I=P!==void 0||F!==void 0?{rateLimit:P,concurrency:F}:void 0,L=(0,o.notMissing)(T)?{[T.objectKey]:await(0,o.generateSamlAssertion)({key:T.key,clientId:T.clientId,cert:T.cert,issuer:T.issuer,lifetime:T.lifetime,audience:T.audience,nameId:T.nameId,nameIdentifierFormat:T.nameIdentifierFormat,tokenEndpoint:T.tokenEndpoint})}:{},R=x.mode===`offset`,z=S?.token??null,B=null,V=null,H=[],U=[],ee=[],G=a,K=S?.position??0,q=!0,J=!0,Y=!0;do{q?q=!1:R||(K=0),z===null?R&&(x.in===`query`?j.query[x.key]=K.toString():x.in===`body`&&(Array.isArray(j.body)||(j.body[x.key]=K))):x.in===`query`?(0,o.isObject)(z)?Object.entries(z).forEach(([e,t])=>{j.query[`${x.key}[${e}]`]=t?.toString()??``}):j.query[x.key]=z.toString():x.in===`body`&&(Array.isArray(j.body)||(j.body[x.key]=z));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${_}${v}`,queryParams:{...j?.query},method:y,headers:{...N},body:Array.isArray(j?.body)?j.body:{...j?.body,...L},customErrorConfigs:C,requestConfig:I,httpsAgent:k,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}B=z,U=b?.dataKey?me(t.data,b.dataKey):t.data;let r=R?U?.slice(0,G):U?.slice(K,K+G);G-=r.length,K+=r.length,ee.push(t),H=H.concat(r),V=t?.status,z=he({result:t,response:b}),Y=(0,o.notMissing)(x.condition)?(0,s.safeEvaluate)(x.condition,t.data)===!0:!0,!R&&r.length===U.length&&G===0&&(K=0,B=z),J=!Y||(0,o.isMissing)(z)&&H.length<a}while((R||(0,o.notMissing)(z))&&Y&&H.length<a&&U?.length>0);return{block:e,successful:!0,output:{data:ve(H,b),raw:ee,statusCode:V,next:J?void 0:B,position:J?void 0:K}}},me=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(Z(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),he=__name(({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?ge(e.headers,r):_e(e.data,r)},`resolveNextIterator`),ge=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;if(Z(t)){let n=(0,s.safeEvaluate)(t,e);return typeof n==`string`&&n!==``||typeof n==`number`?n:null}let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},`resolveFromHeaders`),_e=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=(0,s.safeEvaluate)(Z(t)?t:`$.${t}`,e);return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),ve=__name((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),ye=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:W.optional(),certificates:ee,saml:(0,o.zStrictObject)({objectKey:o.z.string(),key:o.z.string(),clientId:o.z.string(),cert:o.z.unknown().optional(),issuer:o.z.string().optional(),lifetime:o.z.number().optional(),nameId:o.z.string().optional(),audience:o.z.string().optional(),nameIdentifierFormat:o.z.string().optional(),tokenEndpoint:o.z.string().optional()}).optional(),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),be=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?.response?.dataKey,l=a&&isJexlExpression(a),u=t?(0,s.safeEvaluateRecord)({...t,args:i},e):{},d={...u,customErrors:t?.customErrors,response:l?{...u?.response??{},dataKey:a}:u?.response},{baseUrl:f,url:p,method:m,response:h,authorization:g,certificates:_,customErrors:v,args:y,saml:b}=ye.parse(d),x=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],S=x?.authorization,C=_??x?.certificates,w=C?(0,c.buildHttpsAgent)(C):void 0,T=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},E=(0,o.notMissing)(g)?g:W.parse(S),D=(0,c.createAuthorizationHeaders)(E),O={...T?.headers??{},...D},k=e.connector?.rateLimit,A=e.connector?.concurrency,j=k!==void 0||A!==void 0?{rateLimit:k,concurrency:A}:void 0,M=(0,o.notMissing)(b)?{[b.objectKey]:await(0,o.generateSamlAssertion)({key:b.key,clientId:b.clientId,cert:b.cert,issuer:b.issuer,lifetime:b.lifetime,audience:b.audience,nameId:b.nameId,nameIdentifierFormat:b.nameIdentifierFormat,tokenEndpoint:b.tokenEndpoint})}:{},N=Array.isArray(T?.body)?T?.body:{...T?.body,...M};if(E.type===`none`&&E.signing?.strategy){let t=E.signing,n=e.credentials??{};try{let e=(0,c.getSigningStrategy)(t.strategy);if(!e)throw Error(`Signing strategy "${t.strategy}" is not registered`);let r=e({method:m,url:`${f}${p}`,headers:O,query:T?.query??{},body:N},n,t);Object.assign(O,r)}catch(t){return buildStepErrorOutput(t,e)}}let P;try{P=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:T?.query,method:m,headers:O,body:N,customErrorConfigs:v,requestConfig:j,httpsAgent:w,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:xe(h?.dataKey?resolveDataKey(P.data,h.dataKey):P.data,h),raw:P,statusCode:P?.status,message:P?.message}}},resolveDataKey=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},xe=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Se=[`data`,`headers`],Ce=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:o.z.discriminatedUnion(`type`,[(0,o.zStrictObject)({type:o.z.literal(`none`)}),(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),(0,o.zStrictObject)({type:o.z.literal(`oauth2`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)})]).optional(),envelope:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.unknown())]).optional(),namespaces:o.z.strictObject({namespaceIdentifier:o.z.string(),namespace:o.z.string()}).array().optional(),soapOperation:o.z.string().optional(),soapAction:o.z.string().optional(),useSoapContext:o.z.boolean().optional().default(!0),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional(),nextKey:o.z.string().optional(),nextKeyIn:o.z.enum(Se).optional()}).optional(),iterator:(0,o.zStrictObject)({key:o.z.string(),in:o.z.enum(c.RequestParameterLocations)}),cursor:(0,o.zStrictObject)({token:o.z.string().optional().nullable(),position:o.z.number().optional().nullable()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),we=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),next:o.z.string().optional().nullable(),position:o.z.number().optional()}).optional(),Te=25,soapPaginatedRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,l=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,u=t?(0,s.safeEvaluateRecord)({...t,args:l},e):{},d={...u,customErrors:t?.customErrors},{baseUrl:f,url:p,method:m,response:h,iterator:g,cursor:_,authorization:v,customErrors:y,args:b,soapOperation:x,namespaces:S,envelope:C,soapAction:w,useSoapContext:T}=Ce.parse(d),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,D=b?(0,c.parseRequestParameters)(b):{query:{},body:{},headers:{}},O=(0,c.createAuthorizationHeaders)((0,o.notMissing)(v)?v:W.parse(E)),k={...D?.headers??{},...O},A=e.connector?.rateLimit,j=e.connector?.concurrency,M={...(A!==void 0||j!==void 0)&&{rateLimit:A,concurrency:j},soapOperation:x,namespaces:S,envelope:C,soapAction:w,soapContext:T?{username:e.credentials?.username,password:e.credentials?.password}:void 0},N=_?.token??null,P=null,F=null,I=[],L=[],R=[],z=a,B=_?.position??0,V=!0,H;do{V?V=!1:B=0,N!==null&&(g.in===`query`?D.query[g.key]=N.toString():g.in===`body`&&(D.body[g.key]=N));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:D?.query,method:m,headers:k,body:D?.body,customErrorConfigs:y,requestConfig:M,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}P=N,L=h?.dataKey?t.data[h?.dataKey]:t.data,Array.isArray(L)||(L=L?[L]:[]);let r=L?.slice(B,B+z);z-=r.length,B+=r.length,R.push(t),I=I.concat(r),F=t?.status,N=resolveNextIterator({result:t,response:h}),r.length===L.length&&z===0&&(B=0,P=N),H=(0,o.isMissing)(N)&&I.length<a}while((0,o.notMissing)(N)&&I.length<a&&L?.length>0);return{block:e,successful:!0,output:{data:Ee(I,h),raw:R,statusCode:F,next:H?void 0:P,position:H?void 0:B}}},resolveNextIterator=({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?resolveFromHeaders(e.headers,r):resolveFromData(e.data,r)},resolveFromHeaders=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},resolveFromData=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=e[t];return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`?n:null},Ee=__name((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),De=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:W.optional(),envelope:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.unknown())]).optional(),namespaces:o.z.strictObject({namespaceIdentifier:o.z.string(),namespace:o.z.string()}).array().optional(),soapOperation:o.z.string().optional(),soapAction:o.z.string().optional(),useSoapContext:o.z.boolean().optional().default(!0),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),Oe=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),soapRequestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?(0,s.safeEvaluateRecord)({...t,args:i},e):{},l={...a,customErrors:t?.customErrors},{baseUrl:u,url:d,method:f,response:p,authorization:m,customErrors:h,args:g,soapOperation:_,namespaces:v,envelope:y,soapAction:b,useSoapContext:x}=De.parse(l),S=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,C=g?(0,c.parseRequestParameters)(g):{query:{},body:{},headers:{}},w=(0,c.createAuthorizationHeaders)((0,o.notMissing)(m)?m:W.parse(S)),T={...C?.headers??{},...w},E=e.connector?.rateLimit,D=e.connector?.concurrency,O={...(E!==void 0||D!==void 0)&&{rateLimit:E,concurrency:D},soapOperation:_,namespaces:v,envelope:y,soapAction:b,soapContext:x?{username:e.credentials?.username,password:e.credentials?.password}:void 0},k;try{k=await n.performRequest({httpClient:e.httpClient,url:`${u}${d}`,queryParams:C?.query,method:f,headers:T,body:C?.body,customErrorConfigs:h,requestConfig:O,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:ke(p?.dataKey?k.data[p?.dataKey]:k.data,p),raw:k,statusCode:k?.status,message:k?.message}}},ke=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Ae=o.z.object({values:o.z.string().or(o.z.record(o.z.string(),o.z.unknown())).or(o.z.array(o.z.unknown()))}),je=o.z.object({data:o.z.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Ae.parse(t),r=Array.isArray(n)?n.map(t=>evaluateValue(t,e)):evaluateValue(n,e);return{block:{...e},successful:!0,output:{data:r}}},evaluateValue=(e,t)=>(0,o.isString)(e)?(0,s.safeEvaluate)(e,t):(0,o.isObject)(e)?(0,s.safeEvaluateRecord)(e,t):e,Me=o.z.object({targetFieldKey:o.z.string(),type:o.z.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:o.z.boolean().default(!1),custom:o.z.boolean().default(!1),hidden:o.z.boolean().default(!1),properties:o.z.lazy(()=>Me).array().optional(),requiredScopes:o.z.string().array().optional()}),Ne=o.z.object({fields:Me.array().optional(),dataSource:o.z.string()}),Pe=o.z.object({data:o.z.unknown()});let Q=function(e){return e.String=`string`,e.Number=`number`,e.Boolean=`boolean`,e.DateTimeString=`datetime_string`,e}({});const typecast=({value:e,type:t,format:n})=>{if((0,o.isMissing)(e))return null;switch(t){case Q.String:return(0,o.safeParseToString)({value:e});case Q.Number:return(0,o.safeParseToNumber)({value:e});case Q.Boolean:return(0,o.safeParseToBoolean)({value:e});case Q.DateTimeString:return(0,o.safeParseToDateTimeString)({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(Q).includes(e),Fe=__name(async({block:e})=>{let t=e?.fieldConfigs;if(!t||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let n;return n=Array.isArray(e.result)?e.result.map(e=>Ie(e,t)):Ie(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),Ie=__name((e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i}=t;isFieldSupportedType(i)&&(!t.custom&&(0,o.notMissing)(n[r])?n[r]=typecast({value:e[r],type:i}):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},`mapSingleRecord`),typecastStepFunction=async({block:e,params:t})=>{let{fields:n,dataSource:r}=Ne.parse(t),i=(0,s.evaluate)(r,buildExpressionContext(e));if(!n||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let a;return a=Array.isArray(i)?i.map(e=>mapSingleRecord(e,n)):mapSingleRecord(i,n),{block:{...e},successful:!0,output:{data:a}}},handleObjectField=(e,t)=>!e.properties||!t?t:Array.isArray(t)?t.map(t=>typeof t==`object`&&t?mapSingleRecord(t,e.properties):t):typeof t==`object`&&t?mapSingleRecord(t,e.properties):t,mapSingleRecord=(e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i,array:a}=t;i===`object`?!t.custom&&(0,o.notMissing)(n[r])?n[r]=handleObjectField(t,e[r]):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=handleObjectField(t,e.unified_custom_fields?.[r])):isFieldSupportedType(i)&&(!t.custom&&(0,o.notMissing)(n[r])?(!a||!Array.isArray(n[r]))&&(n[r]=typecast({value:e[r],type:i})):n.unified_custom_fields&&(0,o.notMissing)(n.unified_custom_fields?.[r])&&(!a||!Array.isArray(n.unified_custom_fields[r]))&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},Le=(0,o.zStrictObject)({content:o.z.string().describe(`The file content as base64 encoded string`),contentType:o.z.string().optional().describe(`The MIME type for the binary content (defaults to application/octet-stream)`)}),Re=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:W.optional(),binaryContent:Le.describe(`Raw binary content for octet-stream uploads`),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),ze=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),uploadBinaryStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,response:f,authorization:p,binaryContent:m,args:h,customErrors:g}=Re.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?(0,c.parseRequestParameters)(h):{query:{},body:{},headers:{}},y=(0,c.createAuthorizationHeaders)((0,o.notMissing)(p)?p:W.parse(_)),b=Buffer.from(m.content,`base64`),x={"content-type":m.contentType??`application/octet-stream`,...v?.headers??{},...y},S=e.connector?.rateLimit,C=e.connector?.concurrency,w=S!==void 0||C!==void 0?{rateLimit:S,concurrency:C}:void 0,T;try{T=await e.httpClient.request({url:`${l??``}${u}`,method:d,headers:x,queryParams:v?.query,payload:b,requestConfig:w})}catch(t){let n=t;return{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let E=(0,c.translateCustomError)(T,g,e.credentials);return(0,c.isFailedStatusCode)(E?.status)?{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(new c.HttpResponseError(E,E.message))],output:{statusCode:E.status,message:E.message}}:{block:e,successful:!0,output:{data:Be(f?.dataKey?E.data[f?.dataKey]:E.data,f),raw:E,statusCode:E?.status,message:E?.message}}},Be=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Ve=(0,o.zStrictObject)({fieldName:o.z.string().describe(`The form field name for the file`),content:o.z.string().describe(`The file content as base64 encoded string`),filename:o.z.string().describe(`The filename to use in the upload`),contentType:o.z.string().optional().describe(`The MIME type of the file (e.g., "image/png", "application/pdf")`)}),He=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:W.optional(),file:Ve.describe(`The file to upload`),additionalFields:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional(),contentType:o.z.string().optional().describe(`The MIME type for this form field (e.g., "application/json")`)}).array().optional().describe(`Additional form fields to include in the multipart request`),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Ue=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),uploadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n,additionalFields:r}=t,i=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,l=t?(0,s.safeEvaluateRecord)({...t,args:i,additionalFields:a},e):{},u={...l,customErrors:t?.customErrors},{baseUrl:f,url:p,method:m,response:h,authorization:g,file:_,additionalFields:v,args:y,customErrors:b}=He.parse(u),x=l?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,S=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},C=(0,c.createAuthorizationHeaders)((0,o.notMissing)(g)?g:W.parse(x)),w=new d.default;if(v)for(let e of v){let t=typeof e.value==`object`?JSON.stringify(e.value):String(e.value);w.append(e.name,t,e.contentType?{contentType:e.contentType}:void 0)}let T=Buffer.from(_.content,`base64`);w.append(_.fieldName,T,{filename:_.filename,contentType:_.contentType});let E={...w.getHeaders(),...S?.headers??{},...C},D=e.connector?.rateLimit,O=e.connector?.concurrency,k=D!==void 0||O!==void 0?{rateLimit:D,concurrency:O}:void 0,A;try{A=await e.httpClient.request({url:`${f??``}${p}`,method:m,headers:E,queryParams:S?.query,payload:w,requestConfig:k})}catch(t){return buildStepErrorOutput(t,e)}let j=(0,c.translateCustomError)(A,b,e.credentials);return(0,c.isFailedStatusCode)(j?.status)?buildStepErrorOutput(new c.HttpResponseError(j,j.message),e):{block:e,successful:!0,output:{data:indexResponseData(h?.dataKey?j.data[h?.dataKey]:j.data,h),raw:j,statusCode:j?.status,message:j?.message}}},indexResponseData=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e};let $=function(e){return e.TYPECAST=`typecast`,e.MAP_FIELDS=`map_fields`,e.GROUP_DATA=`group_data`,e.REQUEST=`request`,e.PAGINATED_REQUEST=`paginated_request`,e.SOAP_REQUEST=`soap_request`,e.SOAP_PAGINATED_REQUEST=`soap_paginated_request`,e.STATIC_VALUES=`static_values`,e.UPLOAD_FILE=`upload_file`,e.UPLOAD_BINARY=`upload_binary`,e.DOWNLOAD_FILE=`download_file`,e.EMIT_EVENT=`emit_event`,e.BROWSER_USE=`browser_use`,e.CODE_EXECUTION_LAMBDA=`code_execution_lambda`,e}({});const We={[$.TYPECAST]:{v1:{fn:Fe},v2:{fn:typecastStepFunction,inputSchema:Ne,outputSchema:Pe}},[$.MAP_FIELDS]:{v1:{fn:ne},v2:{fn:mapFieldsStepFunction,inputSchema:oe,outputSchema:se}},[$.REQUEST]:{v1:{fn:requestStepFunction,inputSchema:ye,outputSchema:be}},[$.GROUP_DATA]:{v1:{fn:groupDataStepFunction,inputSchema:Y,outputSchema:te}},[$.PAGINATED_REQUEST]:{v1:{fn:paginatedRequestStepFunction,inputSchema:de,outputSchema:fe}},[$.SOAP_REQUEST]:{v1:{fn:soapRequestStepFunction,inputSchema:De,outputSchema:Oe}},[$.SOAP_PAGINATED_REQUEST]:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:Ce,outputSchema:we}},[$.STATIC_VALUES]:{v1:{fn:staticValuesStepFunction,inputSchema:Ae,outputSchema:je}},[$.UPLOAD_FILE]:{v1:{fn:uploadFileStepFunction,inputSchema:He,outputSchema:Ue}},[$.UPLOAD_BINARY]:{v1:{fn:uploadBinaryStepFunction,inputSchema:Re,outputSchema:ze}},[$.DOWNLOAD_FILE]:{v1:{fn:downloadFileStepFunction,inputSchema:G,outputSchema:K}},[$.EMIT_EVENT]:{v1:{fn:emitEventStepFunction,inputSchema:q,outputSchema:J}},[$.BROWSER_USE]:{v1:{fn:browserUseStepFunction,inputSchema:j,outputSchema:M}},[$.CODE_EXECUTION_LAMBDA]:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:N,outputSchema:P}}},formatZodIssues=(e,t,n)=>e instanceof o.z.ZodError?e.issues.map(e=>({...e,kind:t,functionName:n})):[{kind:t,functionName:n,message:e?.message??`unknown error`}],stepFunctionEnhancedWithSchemasValidation=(e,t)=>async({block:n,params:r})=>{try{e.inputSchema&&e.inputSchema.parse(r)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`input_schema_validation`,t)}}let i=await e.fn({block:n,params:r});try{e.outputSchema&&e.outputSchema.parse(i.output)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`output_schema_validation`,t)}}return i},Ge={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=We}){let i=r?.[e]?.[`v${t}`];if(!i)throw Error(`Unknown step function: ${e} v${t}`);return n?{...i,fn:stepFunctionEnhancedWithSchemasValidation(i,e)}:i}},isForeachStep=e=>`iterator`in e&&typeof e.iterator==`string`;exports.AUTHORIZATION_SCHEMA=W,exports.AuthType=A,exports.BROWSER_USE_INPUT_PARAMS=j,exports.BROWSER_USE_OUTPUT=M,exports.COMPOSITE_ID_LATEST_VERSION=1,exports.CoreError=x,exports.ExecutionModes=w,exports.INPUT_ENUM_REGISTRY=S,exports.ReleaseStages=C,exports.SourceType=D,exports.StepFunctionName=$,exports.StepFunctionsFactory=Ge,exports.StepFunctionsRegistry=We,exports.StreamType=k,exports.TransportType=O,exports.areCursorsEqual=areCursorsEqual,exports.buildExpressionContext=buildExpressionContext,exports.decodeCompositeId=decodeCompositeId,exports.encodeCompositeId=encodeCompositeId,exports.evaluateEventRouter=evaluateEventRouter,exports.evaluateExternalAccountIdExtractor=evaluateExternalAccountIdExtractor,exports.expandCursor=expandCursor,exports.getCategoryDetails=getCategoryDetails,exports.getInputEnumValues=getInputEnumValues,exports.getIteratorLocation=getIteratorLocation,exports.getPaginationKeys=getPaginationKeys,exports.isCompositeId=isCompositeId,exports.isCoreError=isCoreError,exports.isCursorEmpty=isCursorEmpty,exports.isForeachStep=isForeachStep,exports.isValidCategory=isValidCategory,exports.isValidEnumRef=isValidEnumRef,exports.minifyCursor=minifyCursor,exports.stripPaginationParams=stripPaginationParams,exports.updateCursor=updateCursor;
|
package/dist/index.d.cts
CHANGED
|
@@ -393,22 +393,9 @@ type DefenderContext = {
|
|
|
393
393
|
[key: string]: unknown;
|
|
394
394
|
};
|
|
395
395
|
type ActionInput = {
|
|
396
|
+
actionRunId: string;
|
|
396
397
|
actionId?: string;
|
|
397
398
|
mode: string;
|
|
398
|
-
url?: string;
|
|
399
|
-
pathParams?: unknown;
|
|
400
|
-
queryParams?: unknown;
|
|
401
|
-
body?: unknown;
|
|
402
|
-
headers?: Record<string, string>;
|
|
403
|
-
sourceId?: string;
|
|
404
|
-
sourceType?: string;
|
|
405
|
-
sourceValue?: string;
|
|
406
|
-
isBackground?: boolean;
|
|
407
|
-
startTime?: Date;
|
|
408
|
-
};
|
|
409
|
-
type ActionResult = {
|
|
410
|
-
actionRunId: string;
|
|
411
|
-
actionId: string;
|
|
412
399
|
connectorKey: string;
|
|
413
400
|
connectorVersion: string;
|
|
414
401
|
connectorOwner?: string;
|
|
@@ -420,12 +407,29 @@ type ActionResult = {
|
|
|
420
407
|
accountSecureId: string;
|
|
421
408
|
originOwnerId?: string;
|
|
422
409
|
originOwnerName?: string;
|
|
410
|
+
authType?: AuthType;
|
|
411
|
+
authId?: string;
|
|
412
|
+
sourceType?: SourceType | string;
|
|
413
|
+
userAgent?: string;
|
|
414
|
+
ipAddress?: string;
|
|
415
|
+
sessionId?: string;
|
|
416
|
+
agentId?: string;
|
|
417
|
+
transportType?: TransportType;
|
|
418
|
+
streamType?: StreamType;
|
|
419
|
+
isBackground?: boolean;
|
|
420
|
+
pathParams?: unknown;
|
|
421
|
+
queryParams?: unknown;
|
|
422
|
+
body?: unknown;
|
|
423
|
+
headers?: Record<string, string>;
|
|
423
424
|
httpMethod?: string;
|
|
424
425
|
url?: string;
|
|
425
426
|
path?: string;
|
|
426
427
|
resource?: string;
|
|
427
428
|
subResource?: string;
|
|
428
429
|
childResource?: string;
|
|
430
|
+
startTime?: Date;
|
|
431
|
+
};
|
|
432
|
+
type ActionResult = {
|
|
429
433
|
success?: boolean;
|
|
430
434
|
statusCode?: number;
|
|
431
435
|
message?: string;
|
|
@@ -480,9 +484,12 @@ type UnifiedInput = {
|
|
|
480
484
|
resource?: string;
|
|
481
485
|
subResource?: string;
|
|
482
486
|
childResource?: string;
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
487
|
+
authType?: AuthType;
|
|
488
|
+
authId?: string;
|
|
489
|
+
sourceType?: SourceType | string;
|
|
490
|
+
userAgent?: string;
|
|
491
|
+
ipAddress?: string;
|
|
492
|
+
transportType?: TransportType;
|
|
486
493
|
isBackground?: boolean;
|
|
487
494
|
startTime?: Date;
|
|
488
495
|
};
|
|
@@ -727,9 +734,17 @@ type ActionLog = ILog & {
|
|
|
727
734
|
originOwnerName?: string;
|
|
728
735
|
httpMethod?: string;
|
|
729
736
|
url?: string;
|
|
730
|
-
sourceType?: string;
|
|
737
|
+
sourceType?: SourceType | string;
|
|
731
738
|
sourceId?: string;
|
|
732
739
|
sourceValue?: string;
|
|
740
|
+
authType?: AuthType;
|
|
741
|
+
authId?: string;
|
|
742
|
+
userAgent?: string;
|
|
743
|
+
ipAddress?: string;
|
|
744
|
+
sessionId?: string;
|
|
745
|
+
agentId?: string;
|
|
746
|
+
transportType?: TransportType;
|
|
747
|
+
streamType?: StreamType;
|
|
733
748
|
isBackground?: boolean;
|
|
734
749
|
success?: boolean;
|
|
735
750
|
statusCode?: number;
|
|
@@ -772,8 +787,16 @@ type UnifiedLog = ILog & {
|
|
|
772
787
|
service?: string;
|
|
773
788
|
action?: string;
|
|
774
789
|
sourceId?: string;
|
|
775
|
-
sourceType?: string;
|
|
790
|
+
sourceType?: SourceType | string;
|
|
776
791
|
sourceValue?: string;
|
|
792
|
+
authType?: AuthType;
|
|
793
|
+
authId?: string;
|
|
794
|
+
userAgent?: string;
|
|
795
|
+
ipAddress?: string;
|
|
796
|
+
sessionId?: string;
|
|
797
|
+
agentId?: string;
|
|
798
|
+
transportType?: TransportType;
|
|
799
|
+
streamType?: StreamType;
|
|
777
800
|
isBackground?: boolean;
|
|
778
801
|
originOwnerId?: string;
|
|
779
802
|
originOwnerName?: string;
|
|
@@ -2272,8 +2295,50 @@ type DefenderSettings = {
|
|
|
2272
2295
|
};
|
|
2273
2296
|
//#endregion
|
|
2274
2297
|
//#region src/source/types.d.ts
|
|
2298
|
+
declare const SourceType: {
|
|
2299
|
+
readonly RequestTester: "REQUEST_TESTER";
|
|
2300
|
+
readonly ActionTester: "ACTION_TESTER";
|
|
2301
|
+
readonly Dashboard: "DASHBOARD";
|
|
2302
|
+
readonly Playground: "PLAYGROUND";
|
|
2303
|
+
readonly SDK: "SDK";
|
|
2304
|
+
readonly Scheduler: "SCHEDULER";
|
|
2305
|
+
readonly Webhook: "WEBHOOK";
|
|
2306
|
+
readonly Agent: "AGENT";
|
|
2307
|
+
readonly Internal: "INTERNAL";
|
|
2308
|
+
};
|
|
2309
|
+
type SourceType = (typeof SourceType)[keyof typeof SourceType];
|
|
2310
|
+
declare const TransportType: {
|
|
2311
|
+
readonly Http: "HTTP";
|
|
2312
|
+
readonly Mcp: "MCP";
|
|
2313
|
+
readonly ActionRpc: "ACTION_RPC";
|
|
2314
|
+
readonly WebSocket: "WEBSOCKET";
|
|
2315
|
+
};
|
|
2316
|
+
type TransportType = (typeof TransportType)[keyof typeof TransportType];
|
|
2317
|
+
declare const StreamType: {
|
|
2318
|
+
readonly Http: "HTTP";
|
|
2319
|
+
readonly WebSocket: "WEBSOCKET";
|
|
2320
|
+
readonly Sse: "SSE";
|
|
2321
|
+
};
|
|
2322
|
+
type StreamType = (typeof StreamType)[keyof typeof StreamType] | null;
|
|
2323
|
+
declare const AuthType: {
|
|
2324
|
+
readonly ApiKey: "API_KEY";
|
|
2325
|
+
readonly SessionToken: "SESSION_TOKEN";
|
|
2326
|
+
readonly UserSession: "USER_SESSION";
|
|
2327
|
+
readonly Cookie: "COOKIE";
|
|
2328
|
+
readonly Webhook: "WEBHOOK";
|
|
2329
|
+
readonly Signature: "SIGNATURE";
|
|
2330
|
+
};
|
|
2331
|
+
type AuthType = (typeof AuthType)[keyof typeof AuthType];
|
|
2275
2332
|
type Source = {
|
|
2276
|
-
sourceType?: string;
|
|
2333
|
+
sourceType?: SourceType | string;
|
|
2334
|
+
userAgent?: string;
|
|
2335
|
+
ipAddress?: string;
|
|
2336
|
+
sessionId?: string;
|
|
2337
|
+
agentId?: string;
|
|
2338
|
+
transportType?: TransportType;
|
|
2339
|
+
streamType?: StreamType;
|
|
2340
|
+
authType?: AuthType;
|
|
2341
|
+
authId?: string;
|
|
2277
2342
|
sourceId?: string;
|
|
2278
2343
|
sourceValue?: string;
|
|
2279
2344
|
};
|
|
@@ -2331,8 +2396,18 @@ type BlockContext = {
|
|
|
2331
2396
|
actionRunId?: string;
|
|
2332
2397
|
originOwnerId?: string;
|
|
2333
2398
|
originOwnerName?: string;
|
|
2334
|
-
|
|
2399
|
+
sourceType?: SourceType | string;
|
|
2400
|
+
authType?: AuthType;
|
|
2401
|
+
authId?: string;
|
|
2402
|
+
sessionId?: string;
|
|
2403
|
+
agentId?: string;
|
|
2404
|
+
userAgent?: string;
|
|
2405
|
+
ipAddress?: string;
|
|
2406
|
+
transportType?: TransportType;
|
|
2407
|
+
streamType?: StreamType;
|
|
2335
2408
|
flowType?: FlowType;
|
|
2409
|
+
sourceId?: string;
|
|
2410
|
+
sourceValue?: string;
|
|
2336
2411
|
service: string;
|
|
2337
2412
|
resource: string;
|
|
2338
2413
|
subResource?: string;
|
|
@@ -2587,4 +2662,4 @@ type Account = {
|
|
|
2587
2662
|
originOwnerName?: string;
|
|
2588
2663
|
};
|
|
2589
2664
|
//#endregion
|
|
2590
|
-
export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionExample, type ActionResponse, type ActionType, type ActionValidationRule, type Assets, type Authentication, type AuthenticationConfig, type AuthenticationField, type AuthenticationGuides, type AuthenticationNotice, BROWSER_USE_INPUT_PARAMS, BROWSER_USE_OUTPUT, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DocumentationReference, type EnumOneOf, type EventRouter, type EventRouterRule, type EventToEmit, type ExecutionMode, ExecutionModes, type ExpressionContextOptions, type FieldConfig, type FlowType, type ForeachStep, type Guide, type GuideImage, type GuideSection, type GuideStep, INPUT_ENUM_REGISTRY, type Input, type InputFormat, type InputLocation, type InputRules, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, type SupportConfig, type SyncParams, type TestActionConfig, type WebhookSetup, type WebhookSetupPhase, type WebhookSetupPhaseKind, areCursorsEqual, buildExpressionContext, decodeCompositeId, encodeCompositeId, evaluateEventRouter, evaluateExternalAccountIdExtractor, expandCursor, getCategoryDetails, getInputEnumValues, getIteratorLocation, getPaginationKeys, isCompositeId, isCoreError, isCursorEmpty, isForeachStep, isValidCategory, isValidEnumRef, minifyCursor, stripPaginationParams, updateCursor };
|
|
2665
|
+
export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionExample, type ActionResponse, type ActionType, type ActionValidationRule, type Assets, AuthType, type Authentication, type AuthenticationConfig, type AuthenticationField, type AuthenticationGuides, type AuthenticationNotice, BROWSER_USE_INPUT_PARAMS, BROWSER_USE_OUTPUT, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DocumentationReference, type EnumOneOf, type EventRouter, type EventRouterRule, type EventToEmit, type ExecutionMode, ExecutionModes, type ExpressionContextOptions, type FieldConfig, type FlowType, type ForeachStep, type Guide, type GuideImage, type GuideSection, type GuideStep, INPUT_ENUM_REGISTRY, type Input, type InputFormat, type InputLocation, type InputRules, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, SourceType, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, StreamType, type SupportConfig, type SyncParams, type TestActionConfig, TransportType, type WebhookSetup, type WebhookSetupPhase, type WebhookSetupPhaseKind, areCursorsEqual, buildExpressionContext, decodeCompositeId, encodeCompositeId, evaluateEventRouter, evaluateExternalAccountIdExtractor, expandCursor, getCategoryDetails, getInputEnumValues, getIteratorLocation, getPaginationKeys, isCompositeId, isCoreError, isCursorEmpty, isForeachStep, isValidCategory, isValidEnumRef, minifyCursor, stripPaginationParams, updateCursor };
|
package/dist/index.d.mts
CHANGED
|
@@ -392,22 +392,9 @@ type DefenderContext = {
|
|
|
392
392
|
[key: string]: unknown;
|
|
393
393
|
};
|
|
394
394
|
type ActionInput = {
|
|
395
|
+
actionRunId: string;
|
|
395
396
|
actionId?: string;
|
|
396
397
|
mode: string;
|
|
397
|
-
url?: string;
|
|
398
|
-
pathParams?: unknown;
|
|
399
|
-
queryParams?: unknown;
|
|
400
|
-
body?: unknown;
|
|
401
|
-
headers?: Record<string, string>;
|
|
402
|
-
sourceId?: string;
|
|
403
|
-
sourceType?: string;
|
|
404
|
-
sourceValue?: string;
|
|
405
|
-
isBackground?: boolean;
|
|
406
|
-
startTime?: Date;
|
|
407
|
-
};
|
|
408
|
-
type ActionResult = {
|
|
409
|
-
actionRunId: string;
|
|
410
|
-
actionId: string;
|
|
411
398
|
connectorKey: string;
|
|
412
399
|
connectorVersion: string;
|
|
413
400
|
connectorOwner?: string;
|
|
@@ -419,12 +406,29 @@ type ActionResult = {
|
|
|
419
406
|
accountSecureId: string;
|
|
420
407
|
originOwnerId?: string;
|
|
421
408
|
originOwnerName?: string;
|
|
409
|
+
authType?: AuthType;
|
|
410
|
+
authId?: string;
|
|
411
|
+
sourceType?: SourceType | string;
|
|
412
|
+
userAgent?: string;
|
|
413
|
+
ipAddress?: string;
|
|
414
|
+
sessionId?: string;
|
|
415
|
+
agentId?: string;
|
|
416
|
+
transportType?: TransportType;
|
|
417
|
+
streamType?: StreamType;
|
|
418
|
+
isBackground?: boolean;
|
|
419
|
+
pathParams?: unknown;
|
|
420
|
+
queryParams?: unknown;
|
|
421
|
+
body?: unknown;
|
|
422
|
+
headers?: Record<string, string>;
|
|
422
423
|
httpMethod?: string;
|
|
423
424
|
url?: string;
|
|
424
425
|
path?: string;
|
|
425
426
|
resource?: string;
|
|
426
427
|
subResource?: string;
|
|
427
428
|
childResource?: string;
|
|
429
|
+
startTime?: Date;
|
|
430
|
+
};
|
|
431
|
+
type ActionResult = {
|
|
428
432
|
success?: boolean;
|
|
429
433
|
statusCode?: number;
|
|
430
434
|
message?: string;
|
|
@@ -479,9 +483,12 @@ type UnifiedInput = {
|
|
|
479
483
|
resource?: string;
|
|
480
484
|
subResource?: string;
|
|
481
485
|
childResource?: string;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
486
|
+
authType?: AuthType;
|
|
487
|
+
authId?: string;
|
|
488
|
+
sourceType?: SourceType | string;
|
|
489
|
+
userAgent?: string;
|
|
490
|
+
ipAddress?: string;
|
|
491
|
+
transportType?: TransportType;
|
|
485
492
|
isBackground?: boolean;
|
|
486
493
|
startTime?: Date;
|
|
487
494
|
};
|
|
@@ -726,9 +733,17 @@ type ActionLog = ILog & {
|
|
|
726
733
|
originOwnerName?: string;
|
|
727
734
|
httpMethod?: string;
|
|
728
735
|
url?: string;
|
|
729
|
-
sourceType?: string;
|
|
736
|
+
sourceType?: SourceType | string;
|
|
730
737
|
sourceId?: string;
|
|
731
738
|
sourceValue?: string;
|
|
739
|
+
authType?: AuthType;
|
|
740
|
+
authId?: string;
|
|
741
|
+
userAgent?: string;
|
|
742
|
+
ipAddress?: string;
|
|
743
|
+
sessionId?: string;
|
|
744
|
+
agentId?: string;
|
|
745
|
+
transportType?: TransportType;
|
|
746
|
+
streamType?: StreamType;
|
|
732
747
|
isBackground?: boolean;
|
|
733
748
|
success?: boolean;
|
|
734
749
|
statusCode?: number;
|
|
@@ -771,8 +786,16 @@ type UnifiedLog = ILog & {
|
|
|
771
786
|
service?: string;
|
|
772
787
|
action?: string;
|
|
773
788
|
sourceId?: string;
|
|
774
|
-
sourceType?: string;
|
|
789
|
+
sourceType?: SourceType | string;
|
|
775
790
|
sourceValue?: string;
|
|
791
|
+
authType?: AuthType;
|
|
792
|
+
authId?: string;
|
|
793
|
+
userAgent?: string;
|
|
794
|
+
ipAddress?: string;
|
|
795
|
+
sessionId?: string;
|
|
796
|
+
agentId?: string;
|
|
797
|
+
transportType?: TransportType;
|
|
798
|
+
streamType?: StreamType;
|
|
776
799
|
isBackground?: boolean;
|
|
777
800
|
originOwnerId?: string;
|
|
778
801
|
originOwnerName?: string;
|
|
@@ -2271,8 +2294,50 @@ type DefenderSettings = {
|
|
|
2271
2294
|
};
|
|
2272
2295
|
//#endregion
|
|
2273
2296
|
//#region src/source/types.d.ts
|
|
2297
|
+
declare const SourceType: {
|
|
2298
|
+
readonly RequestTester: "REQUEST_TESTER";
|
|
2299
|
+
readonly ActionTester: "ACTION_TESTER";
|
|
2300
|
+
readonly Dashboard: "DASHBOARD";
|
|
2301
|
+
readonly Playground: "PLAYGROUND";
|
|
2302
|
+
readonly SDK: "SDK";
|
|
2303
|
+
readonly Scheduler: "SCHEDULER";
|
|
2304
|
+
readonly Webhook: "WEBHOOK";
|
|
2305
|
+
readonly Agent: "AGENT";
|
|
2306
|
+
readonly Internal: "INTERNAL";
|
|
2307
|
+
};
|
|
2308
|
+
type SourceType = (typeof SourceType)[keyof typeof SourceType];
|
|
2309
|
+
declare const TransportType: {
|
|
2310
|
+
readonly Http: "HTTP";
|
|
2311
|
+
readonly Mcp: "MCP";
|
|
2312
|
+
readonly ActionRpc: "ACTION_RPC";
|
|
2313
|
+
readonly WebSocket: "WEBSOCKET";
|
|
2314
|
+
};
|
|
2315
|
+
type TransportType = (typeof TransportType)[keyof typeof TransportType];
|
|
2316
|
+
declare const StreamType: {
|
|
2317
|
+
readonly Http: "HTTP";
|
|
2318
|
+
readonly WebSocket: "WEBSOCKET";
|
|
2319
|
+
readonly Sse: "SSE";
|
|
2320
|
+
};
|
|
2321
|
+
type StreamType = (typeof StreamType)[keyof typeof StreamType] | null;
|
|
2322
|
+
declare const AuthType: {
|
|
2323
|
+
readonly ApiKey: "API_KEY";
|
|
2324
|
+
readonly SessionToken: "SESSION_TOKEN";
|
|
2325
|
+
readonly UserSession: "USER_SESSION";
|
|
2326
|
+
readonly Cookie: "COOKIE";
|
|
2327
|
+
readonly Webhook: "WEBHOOK";
|
|
2328
|
+
readonly Signature: "SIGNATURE";
|
|
2329
|
+
};
|
|
2330
|
+
type AuthType = (typeof AuthType)[keyof typeof AuthType];
|
|
2274
2331
|
type Source = {
|
|
2275
|
-
sourceType?: string;
|
|
2332
|
+
sourceType?: SourceType | string;
|
|
2333
|
+
userAgent?: string;
|
|
2334
|
+
ipAddress?: string;
|
|
2335
|
+
sessionId?: string;
|
|
2336
|
+
agentId?: string;
|
|
2337
|
+
transportType?: TransportType;
|
|
2338
|
+
streamType?: StreamType;
|
|
2339
|
+
authType?: AuthType;
|
|
2340
|
+
authId?: string;
|
|
2276
2341
|
sourceId?: string;
|
|
2277
2342
|
sourceValue?: string;
|
|
2278
2343
|
};
|
|
@@ -2330,8 +2395,18 @@ type BlockContext = {
|
|
|
2330
2395
|
actionRunId?: string;
|
|
2331
2396
|
originOwnerId?: string;
|
|
2332
2397
|
originOwnerName?: string;
|
|
2333
|
-
|
|
2398
|
+
sourceType?: SourceType | string;
|
|
2399
|
+
authType?: AuthType;
|
|
2400
|
+
authId?: string;
|
|
2401
|
+
sessionId?: string;
|
|
2402
|
+
agentId?: string;
|
|
2403
|
+
userAgent?: string;
|
|
2404
|
+
ipAddress?: string;
|
|
2405
|
+
transportType?: TransportType;
|
|
2406
|
+
streamType?: StreamType;
|
|
2334
2407
|
flowType?: FlowType;
|
|
2408
|
+
sourceId?: string;
|
|
2409
|
+
sourceValue?: string;
|
|
2335
2410
|
service: string;
|
|
2336
2411
|
resource: string;
|
|
2337
2412
|
subResource?: string;
|
|
@@ -2586,4 +2661,4 @@ type Account = {
|
|
|
2586
2661
|
originOwnerName?: string;
|
|
2587
2662
|
};
|
|
2588
2663
|
//#endregion
|
|
2589
|
-
export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionExample, type ActionResponse, type ActionType, type ActionValidationRule, type Assets, type Authentication, type AuthenticationConfig, type AuthenticationField, type AuthenticationGuides, type AuthenticationNotice, BROWSER_USE_INPUT_PARAMS, BROWSER_USE_OUTPUT, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DocumentationReference, type EnumOneOf, type EventRouter, type EventRouterRule, type EventToEmit, type ExecutionMode, ExecutionModes, type ExpressionContextOptions, type FieldConfig, type FlowType, type ForeachStep, type Guide, type GuideImage, type GuideSection, type GuideStep, INPUT_ENUM_REGISTRY, type Input, type InputFormat, type InputLocation, type InputRules, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, type SupportConfig, type SyncParams, type TestActionConfig, type WebhookSetup, type WebhookSetupPhase, type WebhookSetupPhaseKind, areCursorsEqual, buildExpressionContext, decodeCompositeId, encodeCompositeId, evaluateEventRouter, evaluateExternalAccountIdExtractor, expandCursor, getCategoryDetails, getInputEnumValues, getIteratorLocation, getPaginationKeys, isCompositeId, isCoreError, isCursorEmpty, isForeachStep, isValidCategory, isValidEnumRef, minifyCursor, stripPaginationParams, updateCursor };
|
|
2664
|
+
export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionExample, type ActionResponse, type ActionType, type ActionValidationRule, type Assets, AuthType, type Authentication, type AuthenticationConfig, type AuthenticationField, type AuthenticationGuides, type AuthenticationNotice, BROWSER_USE_INPUT_PARAMS, BROWSER_USE_OUTPUT, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DocumentationReference, type EnumOneOf, type EventRouter, type EventRouterRule, type EventToEmit, type ExecutionMode, ExecutionModes, type ExpressionContextOptions, type FieldConfig, type FlowType, type ForeachStep, type Guide, type GuideImage, type GuideSection, type GuideStep, INPUT_ENUM_REGISTRY, type Input, type InputFormat, type InputLocation, type InputRules, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, SourceType, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, StreamType, type SupportConfig, type SyncParams, type TestActionConfig, TransportType, type WebhookSetup, type WebhookSetupPhase, type WebhookSetupPhaseKind, areCursorsEqual, buildExpressionContext, decodeCompositeId, encodeCompositeId, evaluateEventRouter, evaluateExternalAccountIdExtractor, expandCursor, getCategoryDetails, getInputEnumValues, getIteratorLocation, getPaginationKeys, isCompositeId, isCoreError, isCursorEmpty, isForeachStep, isValidCategory, isValidEnumRef, minifyCursor, stripPaginationParams, updateCursor };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-Cfxk5zVN.mjs";import{decodeFromBase64 as t,encodeToBase64 as n,generateSamlAssertion as r,getContentHash as i,getCountryAlpha2CodeByAlpha2Code as a,getCountryAlpha2CodeByAlpha3Code as o,getCountryAlpha2CodeByCitizenship as s,getCountryAlpha2CodeByCountryCode as c,getCountryAlpha2CodeByCountryName as l,getCountryAlpha3CodeByAlpha2Code as u,getCountryAlpha3CodeByAlpha3Code as d,getCountryAlpha3CodeByCountryCode as f,getCountryAlpha3CodeByCountryName as p,getCountryCodeByAlpha2Code as m,getCountryCodeByAlpha3Code as h,getCountryCodeByCountryCode as g,getCountryCodeByCountryName as _,getCountryNameByAlpha2Code as v,getCountryNameByAlpha3Code as y,getCountryNameByCountryCode as b,getCountryNameByCountryName as x,getCountrySubDivisionCodeBySubDivisionName as S,getCountrySubDivisionNameBySubDivisionCode as C,getCountrySubDivisionsByAlpha2Code as w,getDocumentFileFormatFromExtension as T,isMissing as E,isObject as D,isString as O,notMissing as k,safeParseToBoolean as A,safeParseToDateTimeString as ee,safeParseToNumber as j,safeParseToString as M,z as N,zStrictObject as P}from"@stackone/utils";import{evaluate as F,isExpression as I,isValidExpression as te,safeEvaluate as L,safeEvaluateRecord as R}from"@stackone/expressions";import{CUSTOM_ERROR_CONFIG_SCHEMA as z,HttpMethods as B,HttpResponseError as V,QueryArrayFormats as H,RequestClientFactory as ne,RequestParameterLocations as U,buildHttpsAgent as re,createAuthorizationHeaders as W,getSigningStrategy as G,isFailedStatusCode as K,parseRequestParameters as q,serializeHttpResponseError as J,translateCustomError as Y}from"@stackone/transport";import{InvokeCommand as X,LambdaClient as ie}from"@aws-sdk/client-lambda";import ae from"mime-types";import oe from"form-data";const se=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=se.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},ce={hris:{title:`HRIS`,key:`hris`,description:`Human Resource Information System`},crm:{title:`CRM`,key:`crm`,description:`Customer Relationship Management`},ats:{title:`ATS`,key:`ats`,description:`Applicant Tracking System`},lms:{title:`LMS`,key:`lms`,description:`Learning Management System`},marketing:{title:`Marketing`,key:`marketing`,description:`Marketing`},filestorage:{title:`File Storage`,key:`filestorage`,description:`File Storage`},iam:{title:`IAM`,key:`iam`,description:`Identity and Access Management`},internal:{title:`Internal`,key:`internal`,description:`Category for internal actions`},action:{title:`Action`,key:`action`,description:`Action`}},getCategoryDetails=e=>ce[e.toLowerCase()]??null,isValidCategory=e=>!!ce[e.toLowerCase()],le=n(`so1!`),ue=RegExp(`(?<!\\\\):`,`g`),de=RegExp(`(?<!\\\\),`,`g`),fe=1;var pe=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends pe{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!E(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!E(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(de).forEach(e=>{let[n,i]=e.split(ue),a=getOriginalKey(n,t.aliases??{});r[a]=unescapeValue(i)}),r},getComposedIdV1=(e,t={})=>{if(isSingleIdentifier(e))return getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!0});if(isMultipleIdentifier(e))return e.identifiers.map(e=>getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!1})).join(`,`);throw new CompositeIdUnknownIdentifierError},getSingleIdentifierString=({identifier:e,compositeIdAliases:t,isSoleIdentifier:n})=>[n?`id`:t[e.key]||e.key,escapeValue(e.value)].filter(Boolean).join(`:`),getOriginalKey=(e,t)=>Object.keys(t).find(n=>t[n]===e)??e,decodeId=(e,t)=>{if(t.version===1)return decodeIdV1(e);throw new CompositeIdUnsupportedVersionError(`Cannot decode ID, unsupported version number: ${t.version}`)},encodeIdV1=e=>`${le}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(le))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(le)[1];if(!n)throw new CompositeIdMissingBodyError(`Trying to decode an ID without a body: ${e}`);return t(n)},escapeValue=e=>[`,`,`:`].reduce((e,t)=>e.replace(t,`\\`+t),e),unescapeValue=e=>[`,`,`:`].reduce((e,t)=>{let n=`\\`+t;return e.replace(RegExp(`\\\\`+n,`g`),t)},e),isCompositeId=e=>E(e)?!1:e.startsWith(le),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(E(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=L(`{{${n.result.trim()}}}`,t);if(!E(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!E(n))for(let e of n.rules){let n=L(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,L(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},me={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>me[e],isValidEnumRef=e=>e in me,he=[`preview`,`beta`,`ga`,`deprecated`,`internal`],ge=[`sync`,`async`],_e=P({r:N.record(N.string(),P({n:N.number().optional().nullable(),c:N.string().optional().nullable(),p:N.number().optional().nullable()})),v:N.number(),t:N.number()}),ve=P({remote:N.record(N.string(),P({pageNumber:N.number().optional(),providerPageCursor:N.string().optional(),position:N.number().optional()})),version:N.number(),timestamp:N.number()}),minifyCursor=e=>n(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if(O(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(_e.parse(r))}else return ve.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:a,...o}=n,{timestamp:s,...c}=r;return i(o)===i(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>E(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return(E(t)||r!==t.toString())&&(n=n&&E(i.pageNumber)&&E(i.position)&&E(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},o=E(n)&&E(r)&&E(i);return E(e)?{remote:o?{}:{[t]:a},version:2,timestamp:Date.now()}:o?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof pe;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}const browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},ye=N.object({startUrl:N.string().url(),systemPrompt:N.string().optional(),viewport:P({width:N.number().int().positive(),height:N.number().int().positive()}).optional(),locale:N.string().optional(),budgets:P({maxDurationMs:N.number().int().positive(),maxSteps:N.number().int().positive()}),auth:P({sensitiveKeys:N.array(N.string().min(1)).optional(),requiresSession:N.boolean().optional()}).optional()}),be=N.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(typeof e.message==`string`&&e.message.trim().length>0)return e.message}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(e.error!=null&&typeof e.error==`object`&&!Array.isArray(e.error)&&typeof e.error.message==`string`)return e.error.message;if(typeof e.error==`string`)return e.error;if(typeof e.error_description==`string`)return e.error_description}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof V){let n=e.message;return{block:t,successful:!1,errors:[J(e)],output:{statusCode:e.response?.status??500,message:extractErrorMessage(e.response,n),data:e.response?.data,raw:sanitizeRaw(e.response)}}}if(isHttpLikeError(e)){let n=e.response,r=e instanceof Error?e.message:`HTTP error: ${n.status??500}`;return{block:t,successful:!1,errors:[J(e)],output:{statusCode:n.status??500,message:extractErrorMessage(n,r),data:n.data,raw:sanitizeRaw(n)}}}return e instanceof Error?{block:t,successful:!1,errors:[J(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[J(e)],output:{statusCode:500,message:String(e)}}},isAwsCredentials=e=>!!e&&typeof e.accessKeyId==`string`&&typeof e.secretAccessKey==`string`,buildLambdaClientConfig=({region:e,endpoint:t,credentials:n})=>({region:e,...t?{endpoint:t}:{},...isAwsCredentials(n)?{credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,sessionToken:typeof n.sessionToken==`string`?n.sessionToken:void 0}}:t?{credentials:{accessKeyId:`local`,secretAccessKey:`local`}}:{}}),defaultClientFactory=e=>new ie(e),invokeLambda=async({lambdaName:e,payload:t,region:n,endpoint:r,invocationType:i=`RequestResponse`,qualifier:a,credentials:o,clientFactory:s=defaultClientFactory})=>{let c=s(buildLambdaClientConfig({region:n,endpoint:r,credentials:o})),l=new X({FunctionName:e,InvocationType:i,Qualifier:a,Payload:t?Buffer.from(JSON.stringify(t)):void 0}),u=await c.send(l),d=u.Payload?Buffer.from(u.Payload).toString(`utf-8`):``,f;if(d.length===0)f=void 0;else try{f=JSON.parse(d)}catch{f=d}return{statusCode:u.StatusCode??200,payload:f,functionError:u.FunctionError,executedVersion:u.ExecutedVersion}},xe=P({lambdaName:N.string(),region:N.string().optional(),endpoint:N.string().optional(),invocationType:N.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:N.string().optional(),args:P({name:N.string(),value:N.unknown(),condition:N.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:N.string().optional()}),Se=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),executedVersion:N.string().optional()}).optional(),Ce=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>I(e)||Ce.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>I(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,we=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;try{let n=F(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||L(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!Ce.test(o),c=t?.qualifier,l=typeof c==`string`&&!hasExpressionMarker(c),u={...t?R(i===void 0?t:{...t,args:a},e):{},...s?{dataKey:o}:{},...l?{qualifier:c}:{}},d;try{d=xe.parse(u)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:f,region:p,endpoint:m,invocationType:h,qualifier:g,args:_,dataKey:v}=d,y;try{y=await n({lambdaName:f,payload:buildPayloadFromArgs(_),region:p,endpoint:m,invocationType:h,qualifier:g,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(y.functionError){let t=typeof y.payload==`object`&&y.payload!==null&&`errorMessage`in y.payload&&typeof y.payload.errorMessage==`string`?y.payload.errorMessage:`Lambda function error: ${y.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:y.functionError}],output:{statusCode:y.statusCode,message:t,data:y.payload,raw:y}}}return{block:e,successful:!0,output:{data:v?we(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Te=P({strategy:N.literal(`aws4`),service:N.string(),region:N.string().optional()}),Ee=P({strategy:N.literal(`hmac`),algorithm:N.enum([`sha256`,`sha512`]).optional(),headerName:N.string().optional(),prefix:N.string().optional()}),De=N.discriminatedUnion(`strategy`,[Te,Ee]),Oe=P({type:N.literal(`none`),signing:De.optional()}),ke=P({type:N.literal(`basic`),username:N.string().optional(),password:N.string().optional(),encoding:N.string().optional()}),Ae=P({type:N.literal(`bearer`),token:N.string(),includeBearer:N.boolean().optional().default(!0)}),je=P({type:N.literal(`oauth2`),authorizationUrl:N.string().optional(),authorizationParams:N.record(N.string(),N.string()).optional(),tokenUrl:N.string().optional(),tokenParams:N.record(N.string(),N.string()).optional(),tokenExpiresIn:N.number().optional(),tokenRefreshExpiresIn:N.number().optional(),token:N.string(),includeBearer:N.boolean().optional().default(!0),scopes:N.string().optional(),scopeDelimiter:N.string().optional(),customHeaders:N.record(N.string(),N.string()).optional(),pkce:N.boolean().optional(),additionalTokenFields:N.record(N.string(),N.string().optional()).optional(),issuer:N.string().optional()}),Z=N.discriminatedUnion(`type`,[Oe,ke,Ae,je]),Me=P({certs:N.string().array().optional(),keys:N.string().array().optional()}).optional(),Ne=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B).optional().default(`get`),authorization:Z.optional(),responseMode:N.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:N.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:N.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:P({dataKey:N.string().optional(),fileNameKey:N.string().optional(),contentTypeKey:N.string().optional(),contentIsBase64:N.boolean().optional().default(!1),urlKey:N.string().optional(),forwardAuth:N.boolean().optional().default(!1)}).optional(),maxRedirects:N.number().optional().default(5),followRedirects:N.boolean().optional().default(!0),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional()}),Pe=P({data:N.union([N.string(),N.instanceof(Buffer)]).optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),headers:N.record(N.string(),N.string()).optional(),contentDisposition:N.string().optional(),fileMetadata:P({contentType:N.string().optional(),contentLength:N.number().optional(),fileName:N.string().optional(),lastModified:N.string().optional(),etag:N.string().optional()}).optional(),finalUrl:N.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?R({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:o,url:s,method:c,authorization:l,args:u,responseMode:d,responseType:f,encoding:p,response:m,maxRedirects:h,followRedirects:g}=Ne.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?q(u):{query:{},body:{},headers:{}},y=W(k(l)?l:Z.parse(_)),b={...v?.headers??{},...y},x=e.connector?.rateLimit,S=e.connector?.concurrency,C=x!==void 0||S!==void 0?{rateLimit:x,concurrency:S}:void 0;if(d===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,maxRedirects:g?h:0,requestConfig:C});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,responseType:f,encoding:p,response:m,maxRedirects:g?h:0,requestConfig:C,authHeaders:y})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:o,authHeaders:s}=e,c=n.data;if(r.urlKey){let e=extractValueByPath(c,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?s:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:o}),l=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:l,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(c,r.dataKey);if(E(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let o=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:o,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if(E(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);case`binary`:default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=O(e[`content-type`])?e[`content-type`]:void 0,n=O(e[`content-length`])?e[`content-length`]:void 0,r=O(e[`content-disposition`])?e[`content-disposition`]:void 0,i=O(e[`last-modified`])?e[`last-modified`]:void 0,a=O(e.etag)?e.etag:void 0,o=n?parseInt(n,10):void 0,s=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(o)?void 0:o,fileName:s,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return ae.extension(t)||void 0},Fe=N.object({event:N.object({eventType:N.string(),eventDate:N.string().optional(),data:N.unknown().optional()}).optional()}),Ie=N.record(N.string(),N.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?R(t,e):{},{event:r}=Fe.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventDate:r.eventDate,data:r.data})}catch(t){throw e.logger?.error({code:`EmitEventError`,message:`emitEvent callback failed: ${t.message}`}),t}else r&&!e.emitEvent&&e.logger?.warning({message:`emit_event step executed but no emitEvent callback provided on the block`});let{event:i,...a}=n;return{block:{...e},successful:!0,output:a}},Le=N.object({stepsDataToGroup:N.array(N.string()),isSingleRecord:N.boolean().optional()}),Re=N.object({data:N.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=Le.parse(t),i=n.reduce((t,n)=>{let i=e.steps?.[n]?.output?.data;return i?r?{...t,[n]:{...i}}:(Object.keys(i).forEach(e=>{t[e]={...k(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},ze=e(async({block:e})=>{let t=e?.fieldConfigs,n=[],r=e.steps;if(!t||e?.debug?.custom_mappings===`disabled`||!r)return{block:e,successful:!0};let i=buildExpressionContext(e),a;if(Array.isArray(e.result)){let o=e.result.length;a=e.result.map((e,a)=>{let s=Be(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Be(e.result,t,r,i);a=o.record,n.push(...o.errors||[])}return{block:{...e,result:a},successful:!0,errors:Object.keys(n).length>0?n:void 0}},`mapFieldsStepFunction`),extractSingleRecordBlockStepData=(e,t,n)=>Object.entries(e).reduce((e,[r,i])=>{let a=i?.output?.data;return Array.isArray(a)&&a.length===t?e[r]={output:{data:a[n]}}:e[r]=i,e},{}),Be=e((e,t,n,r)=>{if(!e||!n)return{record:e};let i={...r,unified:{...e},...typeof n==`object`?n:{}},a={},o=[],s={...e};for(let n of t){let{error:t,value:r}=Ve(i,e.id,n);if(t){o.push(t);continue}n.custom?a[n.targetFieldKey]=r:s[n.targetFieldKey]=r}return{record:{...s,unified_custom_fields:Object.keys(a).length>0?a:void 0},errors:o.length>0?o:void 0}},`mapSingleRecord`),Ve=e((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=F(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return a;case`country_alpha3code_by_alpha3code`:return d;case`country_code_by_country_code`:return g;case`country_name_by_country_name`:return x;case`country_name_by_alpha3code`:return y;case`country_name_by_alpha2code`:return v;case`country_name_by_country_code`:return b;case`country_alpha3code_by_alpha2code`:return u;case`country_alpha3code_by_country_name`:return p;case`country_alpha3code_by_country_code`:return f;case`country_alpha2code_by_alpha3code`:return o;case`country_alpha2code_by_country_name`:return l;case`country_alpha2code_by_country_code`:return c;case`country_code_by_alpha2code`:return m;case`country_code_by_alpha3code`:return h;case`country_code_by_country_name`:return _;case`country_subdivisions_by_alpha2code`:return w;case`country_subdivision_code_by_subdivision_name`:return S;case`country_alpha2code_by_citizenship`:return s;case`country_subdivision_name_by_subdivision_code`:return C;case`document_file_format_from_extension`:return T;default:return}},He=P({targetFieldKey:N.string(),alias:N.string().optional(),expression:N.string().optional(),values:N.unknown().optional(),type:N.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:N.boolean().default(!1),custom:N.boolean().default(!1),hidden:N.boolean().default(!1),enumMapper:P({matcher:N.string().or(P({matchExpression:N.string(),value:N.string()}).array())}).optional(),properties:N.lazy(()=>He).array().optional(),requiredScopes:N.string().array().optional()}),Ue=N.object({fields:He.array(),dataSource:N.string(),externalSources:N.record(N.string(),N.string()).optional()}),We=N.object({data:N.unknown()}),mergeSourceWithState=(e,t)=>D(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=Ue.parse(t),o=buildExpressionContext(e),s=F(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!s)return{block:e,successful:!0};let c=Object.keys(a??{})?.reduce((e,t)=>(e[t]=F(a?.[t],o),e),{}),l;if(Array.isArray(s))l=s.map(e=>{let t=Q(r,{...e,external:c},o);return n.push(...t?.errors||[]),t?.record});else{let e=Q(r,{...s,external:c},o);l=e?.record,n.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:l},errors:Object.keys(n).length>0?n:void 0}},handleObjectArrayFromValues=(e,t,n,r)=>{if(Array.isArray(e.values))return e.values.map(i=>{let a=evaluateExpressionsInObject(i,t),o=Q(e.properties,a,r);return k(o?.errors)&&n.push(...o.errors),o?.record}).filter(Boolean)},handleObjectArrayFromExpression=(e,t,n,r,i)=>{if(e.expression)try{let t=F(e.expression,n);if(Array.isArray(t))return t.map(t=>{let n=Q(e.properties,t,i);return k(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Q(e.properties,t,i);return k(n?.errors)&&r.push(...n.errors),n?.record}}catch{r.push({message:`Invalid expression`,id:t?.id,targetField:e.targetFieldKey});return}},handleSingleObject=(e,t,n,r)=>{let i=k(e.values)?e.values:t,a=Q(e.properties,i,r);return k(a?.errors)&&n.push(...a.errors),a?.record},Ge=e((e,t,n,r,i)=>{if(!E(e.properties))return e.array&&Array.isArray(e.values)?handleObjectArrayFromValues(e,n,r,i):e.array&&e.expression?handleObjectArrayFromExpression(e,t,n,r,i):handleSingleObject(e,t,r,i)},`handleObjectField`),Q=e((e,t,n)=>{if(!t)return;let r=mergeSourceWithState(t,n),i={},a=[],o={};for(let s of e){let e;if(s.type===`object`){if(e=Ge(s,t,r,a,n),e===void 0)continue}else{let{error:n,value:i}=extractFieldValue(r,t?.id,s);if(e=i,n){a.push(n);continue}}s.custom?i[s.targetFieldKey]=e:o[s.targetFieldKey]=e}let s=Object.keys(i).length>0?{unified_custom_fields:i}:{};return{record:{...o,...s},errors:a.length>0?a:void 0}},`mapSingleRecord`),evaluateExpressionsInObject=(e,t)=>{if(e==null)return e;if(typeof e==`string`){if(te(e))try{return F(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return Ke(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},Ke=e((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=F(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=Ke(e,t,n),i=k(r.value)?r.value:null;if(e.enumMapper===void 0)return{error:{message:`Enum mapper was not defined`,id:t,targetField:e.targetFieldKey}};let a=e.enumMapper.matcher;if(O(a)){let n=getEnumMatcher(a);return k(n)?{value:{value:(k(i)?n(i):null)??`unmapped_value`,source_value:i}}:{error:{message:`The built-in matcher "${a}" is not supported`,id:t,targetField:e.targetFieldKey}}}for(let e of a){let{matchExpression:t,value:r}=e;if(F(t,n)===!0)return{value:{value:r,source_value:i}}}return{value:{value:`unmapped_value`,source_value:i}}},qe=N.object({baseUrl:N.string(),url:N.string(),method:N.enum(B),saml:P({objectKey:N.string(),key:N.string(),clientId:N.string(),cert:N.unknown().optional(),issuer:N.string().optional(),lifetime:N.number().optional(),nameId:N.string().optional(),audience:N.string().optional(),nameIdentifierFormat:N.string().optional(),tokenEndpoint:N.string().optional()}).optional(),response:P({indexField:N.string().optional(),dataKey:N.string().optional(),nextKey:N.string().optional(),nextKeyIn:N.enum([`data`,`headers`]).optional()}).optional(),iterator:P({key:N.string(),in:N.enum(U),condition:N.string().optional(),mode:N.enum([`cursor`,`offset`]).optional()}),cursor:P({token:N.string().optional().nullable(),position:N.number().optional().nullable()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional()}),Je=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),next:N.string().optional().nullable(),position:N.number().optional()}).optional(),Ye=e(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=ne.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:i}=t,a=Number(e.inputs?.page_size),o=Number.isNaN(a)?25:a,s=i?i.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,c=t?R({...t,args:s},e):{},l=t?.response?.nextKey,u=l&&Ye(l),d=t?.response?.dataKey,f=d&&Ye(d),p={...c?.response??{},...u?{nextKey:l}:{},...f?{dataKey:d}:{}},m={...c,customErrors:t?.customErrors,iterator:{...c?.iterator??{},condition:t?.iterator?.condition},response:u||f?p:c?.response},{baseUrl:h,url:g,method:_,response:v,iterator:y,cursor:b,customErrors:x,args:S,saml:C}=qe.parse(m),w=c?.authentication?.[e.context.authenticationType]?.[e.context.environment],T=w?.authorization,O=w?.certificates,A=O?re(O):void 0,ee=Z.parse(T),j=S?q(S):{query:{},body:{},headers:{}},M=W(ee),N={...j?.headers??{},...M},P=e.connector?.rateLimit,I=e.connector?.concurrency,te=P!==void 0||I!==void 0?{rateLimit:P,concurrency:I}:void 0,z=k(C)?{[C.objectKey]:await r({key:C.key,clientId:C.clientId,cert:C.cert,issuer:C.issuer,lifetime:C.lifetime,audience:C.audience,nameId:C.nameId,nameIdentifierFormat:C.nameIdentifierFormat,tokenEndpoint:C.tokenEndpoint})}:{},B=y.mode===`offset`,V=b?.token??null,H=null,U=null,G=[],K=[],J=[],Y=o,X=b?.position??0,ie=!0,ae=!0,oe=!0;do{ie?ie=!1:B||(X=0),V===null?B&&(y.in===`query`?j.query[y.key]=X.toString():y.in===`body`&&(Array.isArray(j.body)||(j.body[y.key]=X))):y.in===`query`?D(V)?Object.entries(V).forEach(([e,t])=>{j.query[`${y.key}[${e}]`]=t?.toString()??``}):j.query[y.key]=V.toString():y.in===`body`&&(Array.isArray(j.body)||(j.body[y.key]=V));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${h}${g}`,queryParams:{...j?.query},method:_,headers:{...N},body:Array.isArray(j?.body)?j.body:{...j?.body,...z},customErrorConfigs:x,requestConfig:te,httpsAgent:A,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}H=V,K=v?.dataKey?Xe(t.data,v.dataKey):t.data;let r=B?K?.slice(0,Y):K?.slice(X,X+Y);Y-=r.length,X+=r.length,J.push(t),G=G.concat(r),U=t?.status,V=Ze({result:t,response:v}),oe=k(y.condition)?L(y.condition,t.data)===!0:!0,!B&&r.length===K.length&&Y===0&&(X=0,H=V),ae=!oe||E(V)&&G.length<o}while((B||k(V))&&oe&&G.length<o&&K?.length>0);return{block:e,successful:!0,output:{data:et(G,v),raw:J,statusCode:U,next:ae?void 0:H,position:ae?void 0:X}}},Xe=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;let n=L(Ye(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),Ze=e(({result:e,response:t})=>{if(E(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?Qe(e.headers,r):$e(e.data,r)},`resolveNextIterator`),Qe=e((e,t)=>{if(E(e)||typeof e!=`object`)return null;if(Ye(t)){let n=L(t,e);return typeof n==`string`&&n!==``||typeof n==`number`?n:null}let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},`resolveFromHeaders`),$e=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return null;let n=L(Ye(t)?t:`$.${t}`,e);return E(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),et=e((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),tt=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B),authorization:Z.optional(),certificates:Me,saml:P({objectKey:N.string(),key:N.string(),clientId:N.string(),cert:N.unknown().optional(),issuer:N.string().optional(),lifetime:N.number().optional(),nameId:N.string().optional(),audience:N.string().optional(),nameIdentifierFormat:N.string().optional(),tokenEndpoint:N.string().optional()}).optional(),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional()}),nt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=ne.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:i}=t,a=i?i.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,o=t?.response?.dataKey,s=o&&isJexlExpression(o),c=t?R({...t,args:a},e):{},l={...c,customErrors:t?.customErrors,response:s?{...c?.response??{},dataKey:o}:c?.response},{baseUrl:u,url:d,method:f,response:p,authorization:m,certificates:h,customErrors:g,args:_,saml:v}=tt.parse(l),y=c?.authentication?.[e.context.authenticationType]?.[e.context.environment],b=y?.authorization,x=h??y?.certificates,S=x?re(x):void 0,C=_?q(_):{query:{},body:{},headers:{}},w=k(m)?m:Z.parse(b),T=W(w),E={...C?.headers??{},...T},D=e.connector?.rateLimit,O=e.connector?.concurrency,A=D!==void 0||O!==void 0?{rateLimit:D,concurrency:O}:void 0,ee=k(v)?{[v.objectKey]:await r({key:v.key,clientId:v.clientId,cert:v.cert,issuer:v.issuer,lifetime:v.lifetime,audience:v.audience,nameId:v.nameId,nameIdentifierFormat:v.nameIdentifierFormat,tokenEndpoint:v.tokenEndpoint})}:{},j=Array.isArray(C?.body)?C?.body:{...C?.body,...ee};if(w.type===`none`&&w.signing?.strategy){let t=w.signing,n=e.credentials??{};try{let e=G(t.strategy);if(!e)throw Error(`Signing strategy "${t.strategy}" is not registered`);let r=e({method:f,url:`${u}${d}`,headers:E,query:C?.query??{},body:j},n,t);Object.assign(E,r)}catch(t){return buildStepErrorOutput(t,e)}}let M;try{M=await n.performRequest({httpClient:e.httpClient,url:`${u}${d}`,queryParams:C?.query,method:f,headers:E,body:j,customErrorConfigs:g,requestConfig:A,httpsAgent:S,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:rt(p?.dataKey?resolveDataKey(M.data,p.dataKey):M.data,p),raw:M,statusCode:M?.status,message:M?.message}}},resolveDataKey=(e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;let n=L(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},rt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),it=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B),authorization:N.discriminatedUnion(`type`,[P({type:N.literal(`none`)}),P({type:N.literal(`basic`),username:N.string().optional(),password:N.string().optional(),encoding:N.string().optional()}),P({type:N.literal(`bearer`),token:N.string(),includeBearer:N.boolean().optional().default(!0)}),P({type:N.literal(`oauth2`),token:N.string(),includeBearer:N.boolean().optional().default(!0)})]).optional(),envelope:N.union([N.string(),N.record(N.string(),N.unknown())]).optional(),namespaces:N.strictObject({namespaceIdentifier:N.string(),namespace:N.string()}).array().optional(),soapOperation:N.string().optional(),soapAction:N.string().optional(),useSoapContext:N.boolean().optional().default(!0),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional(),nextKey:N.string().optional(),nextKeyIn:N.enum([`data`,`headers`]).optional()}).optional(),iterator:P({key:N.string(),in:N.enum(U)}),cursor:P({token:N.string().optional().nullable(),position:N.number().optional().nullable()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional()}),at=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),next:N.string().optional().nullable(),position:N.number().optional()}).optional(),soapPaginatedRequestStepFunction=async({block:e,params:t})=>{let n=ne.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,o=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,s=t?R({...t,args:o},e):{},c={...s,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,response:f,iterator:p,cursor:m,authorization:h,customErrors:g,args:_,soapOperation:v,namespaces:y,envelope:b,soapAction:x,useSoapContext:S}=it.parse(c),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,w=_?q(_):{query:{},body:{},headers:{}},T=W(k(h)?h:Z.parse(C)),D={...w?.headers??{},...T},O=e.connector?.rateLimit,A=e.connector?.concurrency,ee={...(O!==void 0||A!==void 0)&&{rateLimit:O,concurrency:A},soapOperation:v,namespaces:y,envelope:b,soapAction:x,soapContext:S?{username:e.credentials?.username,password:e.credentials?.password}:void 0},j=m?.token??null,M=null,N=null,P=[],I=[],te=[],L=a,z=m?.position??0,B=!0,V;do{B?B=!1:z=0,j!==null&&(p.in===`query`?w.query[p.key]=j.toString():p.in===`body`&&(w.body[p.key]=j));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${l}${u}`,queryParams:w?.query,method:d,headers:D,body:w?.body,customErrorConfigs:g,requestConfig:ee,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}M=j,I=f?.dataKey?t.data[f?.dataKey]:t.data,Array.isArray(I)||(I=I?[I]:[]);let r=I?.slice(z,z+L);L-=r.length,z+=r.length,te.push(t),P=P.concat(r),N=t?.status,j=resolveNextIterator({result:t,response:f}),r.length===I.length&&L===0&&(z=0,M=j),V=E(j)&&P.length<a}while(k(j)&&P.length<a&&I?.length>0);return{block:e,successful:!0,output:{data:ot(P,f),raw:te,statusCode:N,next:V?void 0:M,position:V?void 0:z}}},resolveNextIterator=({result:e,response:t})=>{if(E(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?resolveFromHeaders(e.headers,r):resolveFromData(e.data,r)},resolveFromHeaders=(e,t)=>{if(E(e)||typeof e!=`object`)return null;let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},resolveFromData=(e,t)=>{if(E(e)||typeof e!=`object`||!e)return null;let n=e[t];return E(n)?null:typeof n==`string`||typeof n==`number`?n:null},ot=e((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),st=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B),authorization:Z.optional(),envelope:N.union([N.string(),N.record(N.string(),N.unknown())]).optional(),namespaces:N.strictObject({namespaceIdentifier:N.string(),namespace:N.string()}).array().optional(),soapOperation:N.string().optional(),soapAction:N.string().optional(),useSoapContext:N.boolean().optional().default(!0),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional()}),ct=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),soapRequestStepFunction=async({block:e,params:t})=>{let n=ne.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?R({...t,args:i},e):{},o={...a,customErrors:t?.customErrors},{baseUrl:s,url:c,method:l,response:u,authorization:d,customErrors:f,args:p,soapOperation:m,namespaces:h,envelope:g,soapAction:_,useSoapContext:v}=st.parse(o),y=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,b=p?q(p):{query:{},body:{},headers:{}},x=W(k(d)?d:Z.parse(y)),S={...b?.headers??{},...x},C=e.connector?.rateLimit,w=e.connector?.concurrency,T={...(C!==void 0||w!==void 0)&&{rateLimit:C,concurrency:w},soapOperation:m,namespaces:h,envelope:g,soapAction:_,soapContext:v?{username:e.credentials?.username,password:e.credentials?.password}:void 0},E;try{E=await n.performRequest({httpClient:e.httpClient,url:`${s}${c}`,queryParams:b?.query,method:l,headers:S,body:b?.body,customErrorConfigs:f,requestConfig:T,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:lt(u?.dataKey?E.data[u?.dataKey]:E.data,u),raw:E,statusCode:E?.status,message:E?.message}}},lt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),ut=N.object({values:N.string().or(N.record(N.string(),N.unknown())).or(N.array(N.unknown()))}),dt=N.object({data:N.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=ut.parse(t),r=Array.isArray(n)?n.map(t=>evaluateValue(t,e)):evaluateValue(n,e);return{block:{...e},successful:!0,output:{data:r}}},evaluateValue=(e,t)=>O(e)?L(e,t):D(e)?R(e,t):e,ft=N.object({targetFieldKey:N.string(),type:N.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:N.boolean().default(!1),custom:N.boolean().default(!1),hidden:N.boolean().default(!1),properties:N.lazy(()=>ft).array().optional(),requiredScopes:N.string().array().optional()}),pt=N.object({fields:ft.array().optional(),dataSource:N.string()}),mt=N.object({data:N.unknown()});let ht=function(e){return e.String=`string`,e.Number=`number`,e.Boolean=`boolean`,e.DateTimeString=`datetime_string`,e}({});const typecast=({value:e,type:t,format:n})=>{if(E(e))return null;switch(t){case ht.String:return M({value:e});case ht.Number:return j({value:e});case ht.Boolean:return A({value:e});case ht.DateTimeString:return ee({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(ht).includes(e),gt=e(async({block:e})=>{let t=e?.fieldConfigs;if(!t||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let n;return n=Array.isArray(e.result)?e.result.map(e=>_t(e,t)):_t(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),_t=e((e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i}=t;isFieldSupportedType(i)&&(!t.custom&&k(n[r])?n[r]=typecast({value:e[r],type:i}):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},`mapSingleRecord`),typecastStepFunction=async({block:e,params:t})=>{let{fields:n,dataSource:r}=pt.parse(t),i=F(r,buildExpressionContext(e));if(!n||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let a;return a=Array.isArray(i)?i.map(e=>mapSingleRecord(e,n)):mapSingleRecord(i,n),{block:{...e},successful:!0,output:{data:a}}},handleObjectField=(e,t)=>!e.properties||!t?t:Array.isArray(t)?t.map(t=>typeof t==`object`&&t?mapSingleRecord(t,e.properties):t):typeof t==`object`&&t?mapSingleRecord(t,e.properties):t,mapSingleRecord=(e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i,array:a}=t;i===`object`?!t.custom&&k(n[r])?n[r]=handleObjectField(t,e[r]):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=handleObjectField(t,e.unified_custom_fields?.[r])):isFieldSupportedType(i)&&(!t.custom&&k(n[r])?(!a||!Array.isArray(n[r]))&&(n[r]=typecast({value:e[r],type:i})):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(!a||!Array.isArray(n.unified_custom_fields[r]))&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},vt=P({content:N.string().describe(`The file content as base64 encoded string`),contentType:N.string().optional().describe(`The MIME type for the binary content (defaults to application/octet-stream)`)}),yt=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B).default(`post`),authorization:Z.optional(),binaryContent:vt.describe(`Raw binary content for octet-stream uploads`),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),bt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),uploadBinaryStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?R({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:o,url:s,method:c,response:l,authorization:u,binaryContent:d,args:f,customErrors:p}=yt.parse(a),m=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,h=f?q(f):{query:{},body:{},headers:{}},g=W(k(u)?u:Z.parse(m)),_=Buffer.from(d.content,`base64`),v={"content-type":d.contentType??`application/octet-stream`,...h?.headers??{},...g},y=e.connector?.rateLimit,b=e.connector?.concurrency,x=y!==void 0||b!==void 0?{rateLimit:y,concurrency:b}:void 0,S;try{S=await e.httpClient.request({url:`${o??``}${s}`,method:c,headers:v,queryParams:h?.query,payload:_,requestConfig:x})}catch(t){let n=t;return{block:e,successful:!1,errors:[J(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let C=Y(S,p,e.credentials);return K(C?.status)?{block:e,successful:!1,errors:[J(new V(C,C.message))],output:{statusCode:C.status,message:C.message}}:{block:e,successful:!0,output:{data:xt(l?.dataKey?C.data[l?.dataKey]:C.data,l),raw:C,statusCode:C?.status,message:C?.message}}},xt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),St=P({fieldName:N.string().describe(`The form field name for the file`),content:N.string().describe(`The file content as base64 encoded string`),filename:N.string().describe(`The filename to use in the upload`),contentType:N.string().optional().describe(`The MIME type of the file (e.g., "image/png", "application/pdf")`)}),Ct=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(B).default(`post`),authorization:Z.optional(),file:St.describe(`The file to upload`),additionalFields:P({name:N.string(),value:N.unknown(),condition:N.string().optional(),contentType:N.string().optional().describe(`The MIME type for this form field (e.g., "application/json")`)}).array().optional().describe(`Additional form fields to include in the multipart request`),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:z.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(U),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(H).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),wt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),uploadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n,additionalFields:r}=t,i=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,o=t?R({...t,args:i,additionalFields:a},e):{},s={...o,customErrors:t?.customErrors},{baseUrl:c,url:l,method:u,response:d,authorization:f,file:p,additionalFields:m,args:h,customErrors:g}=Ct.parse(s),_=o?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?q(h):{query:{},body:{},headers:{}},y=W(k(f)?f:Z.parse(_)),b=new oe;if(m)for(let e of m){let t=typeof e.value==`object`?JSON.stringify(e.value):String(e.value);b.append(e.name,t,e.contentType?{contentType:e.contentType}:void 0)}let x=Buffer.from(p.content,`base64`);b.append(p.fieldName,x,{filename:p.filename,contentType:p.contentType});let S={...b.getHeaders(),...v?.headers??{},...y},C=e.connector?.rateLimit,w=e.connector?.concurrency,T=C!==void 0||w!==void 0?{rateLimit:C,concurrency:w}:void 0,E;try{E=await e.httpClient.request({url:`${c??``}${l}`,method:u,headers:S,queryParams:v?.query,payload:b,requestConfig:T})}catch(t){return buildStepErrorOutput(t,e)}let D=Y(E,g,e.credentials);return K(D?.status)?buildStepErrorOutput(new V(D,D.message),e):{block:e,successful:!0,output:{data:indexResponseData(d?.dataKey?D.data[d?.dataKey]:D.data,d),raw:D,statusCode:D?.status,message:D?.message}}},indexResponseData=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e};let $=function(e){return e.TYPECAST=`typecast`,e.MAP_FIELDS=`map_fields`,e.GROUP_DATA=`group_data`,e.REQUEST=`request`,e.PAGINATED_REQUEST=`paginated_request`,e.SOAP_REQUEST=`soap_request`,e.SOAP_PAGINATED_REQUEST=`soap_paginated_request`,e.STATIC_VALUES=`static_values`,e.UPLOAD_FILE=`upload_file`,e.UPLOAD_BINARY=`upload_binary`,e.DOWNLOAD_FILE=`download_file`,e.EMIT_EVENT=`emit_event`,e.BROWSER_USE=`browser_use`,e.CODE_EXECUTION_LAMBDA=`code_execution_lambda`,e}({});const Tt={[$.TYPECAST]:{v1:{fn:gt},v2:{fn:typecastStepFunction,inputSchema:pt,outputSchema:mt}},[$.MAP_FIELDS]:{v1:{fn:ze},v2:{fn:mapFieldsStepFunction,inputSchema:Ue,outputSchema:We}},[$.REQUEST]:{v1:{fn:requestStepFunction,inputSchema:tt,outputSchema:nt}},[$.GROUP_DATA]:{v1:{fn:groupDataStepFunction,inputSchema:Le,outputSchema:Re}},[$.PAGINATED_REQUEST]:{v1:{fn:paginatedRequestStepFunction,inputSchema:qe,outputSchema:Je}},[$.SOAP_REQUEST]:{v1:{fn:soapRequestStepFunction,inputSchema:st,outputSchema:ct}},[$.SOAP_PAGINATED_REQUEST]:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:it,outputSchema:at}},[$.STATIC_VALUES]:{v1:{fn:staticValuesStepFunction,inputSchema:ut,outputSchema:dt}},[$.UPLOAD_FILE]:{v1:{fn:uploadFileStepFunction,inputSchema:Ct,outputSchema:wt}},[$.UPLOAD_BINARY]:{v1:{fn:uploadBinaryStepFunction,inputSchema:yt,outputSchema:bt}},[$.DOWNLOAD_FILE]:{v1:{fn:downloadFileStepFunction,inputSchema:Ne,outputSchema:Pe}},[$.EMIT_EVENT]:{v1:{fn:emitEventStepFunction,inputSchema:Fe,outputSchema:Ie}},[$.BROWSER_USE]:{v1:{fn:browserUseStepFunction,inputSchema:ye,outputSchema:be}},[$.CODE_EXECUTION_LAMBDA]:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:xe,outputSchema:Se}}},formatZodIssues=(e,t,n)=>e instanceof N.ZodError?e.issues.map(e=>({...e,kind:t,functionName:n})):[{kind:t,functionName:n,message:e?.message??`unknown error`}],stepFunctionEnhancedWithSchemasValidation=(e,t)=>async({block:n,params:r})=>{try{e.inputSchema&&e.inputSchema.parse(r)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`input_schema_validation`,t)}}let i=await e.fn({block:n,params:r});try{e.outputSchema&&e.outputSchema.parse(i.output)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`output_schema_validation`,t)}}return i},Et={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Tt}){let i=r?.[e]?.[`v${t}`];if(!i)throw Error(`Unknown step function: ${e} v${t}`);return n?{...i,fn:stepFunctionEnhancedWithSchemasValidation(i,e)}:i}},isForeachStep=e=>`iterator`in e&&typeof e.iterator==`string`;export{Z as AUTHORIZATION_SCHEMA,ye as BROWSER_USE_INPUT_PARAMS,be as BROWSER_USE_OUTPUT,fe as COMPOSITE_ID_LATEST_VERSION,pe as CoreError,ge as ExecutionModes,me as INPUT_ENUM_REGISTRY,he as ReleaseStages,$ as StepFunctionName,Et as StepFunctionsFactory,Tt as StepFunctionsRegistry,areCursorsEqual,buildExpressionContext,decodeCompositeId,encodeCompositeId,evaluateEventRouter,evaluateExternalAccountIdExtractor,expandCursor,getCategoryDetails,getInputEnumValues,getIteratorLocation,getPaginationKeys,isCompositeId,isCoreError,isCursorEmpty,isForeachStep,isValidCategory,isValidEnumRef,minifyCursor,stripPaginationParams,updateCursor};
|
|
1
|
+
import{t as e}from"./chunk-Cfxk5zVN.mjs";import{decodeFromBase64 as t,encodeToBase64 as n,generateSamlAssertion as r,getContentHash as i,getCountryAlpha2CodeByAlpha2Code as a,getCountryAlpha2CodeByAlpha3Code as o,getCountryAlpha2CodeByCitizenship as s,getCountryAlpha2CodeByCountryCode as c,getCountryAlpha2CodeByCountryName as l,getCountryAlpha3CodeByAlpha2Code as u,getCountryAlpha3CodeByAlpha3Code as d,getCountryAlpha3CodeByCountryCode as f,getCountryAlpha3CodeByCountryName as p,getCountryCodeByAlpha2Code as m,getCountryCodeByAlpha3Code as h,getCountryCodeByCountryCode as g,getCountryCodeByCountryName as _,getCountryNameByAlpha2Code as v,getCountryNameByAlpha3Code as y,getCountryNameByCountryCode as b,getCountryNameByCountryName as x,getCountrySubDivisionCodeBySubDivisionName as S,getCountrySubDivisionNameBySubDivisionCode as C,getCountrySubDivisionsByAlpha2Code as w,getDocumentFileFormatFromExtension as T,isMissing as E,isObject as D,isString as O,notMissing as k,safeParseToBoolean as ee,safeParseToDateTimeString as te,safeParseToNumber as A,safeParseToString as j,z as M,zStrictObject as N}from"@stackone/utils";import{evaluate as P,isExpression as F,isValidExpression as ne,safeEvaluate as I,safeEvaluateRecord as L}from"@stackone/expressions";import{CUSTOM_ERROR_CONFIG_SCHEMA as R,HttpMethods as z,HttpResponseError as B,QueryArrayFormats as V,RequestClientFactory as re,RequestParameterLocations as H,buildHttpsAgent as ie,createAuthorizationHeaders as U,getSigningStrategy as W,isFailedStatusCode as G,parseRequestParameters as K,serializeHttpResponseError as q,translateCustomError as J}from"@stackone/transport";import{InvokeCommand as Y,LambdaClient as ae}from"@aws-sdk/client-lambda";import oe from"mime-types";import se from"form-data";const ce=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=ce.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},le={hris:{title:`HRIS`,key:`hris`,description:`Human Resource Information System`},crm:{title:`CRM`,key:`crm`,description:`Customer Relationship Management`},ats:{title:`ATS`,key:`ats`,description:`Applicant Tracking System`},lms:{title:`LMS`,key:`lms`,description:`Learning Management System`},marketing:{title:`Marketing`,key:`marketing`,description:`Marketing`},filestorage:{title:`File Storage`,key:`filestorage`,description:`File Storage`},iam:{title:`IAM`,key:`iam`,description:`Identity and Access Management`},internal:{title:`Internal`,key:`internal`,description:`Category for internal actions`},action:{title:`Action`,key:`action`,description:`Action`}},getCategoryDetails=e=>le[e.toLowerCase()]??null,isValidCategory=e=>!!le[e.toLowerCase()],ue=n(`so1!`),de=RegExp(`(?<!\\\\):`,`g`),fe=RegExp(`(?<!\\\\),`,`g`),pe=1;var me=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends me{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!E(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!E(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(fe).forEach(e=>{let[n,i]=e.split(de),a=getOriginalKey(n,t.aliases??{});r[a]=unescapeValue(i)}),r},getComposedIdV1=(e,t={})=>{if(isSingleIdentifier(e))return getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!0});if(isMultipleIdentifier(e))return e.identifiers.map(e=>getSingleIdentifierString({identifier:e,compositeIdAliases:t,isSoleIdentifier:!1})).join(`,`);throw new CompositeIdUnknownIdentifierError},getSingleIdentifierString=({identifier:e,compositeIdAliases:t,isSoleIdentifier:n})=>[n?`id`:t[e.key]||e.key,escapeValue(e.value)].filter(Boolean).join(`:`),getOriginalKey=(e,t)=>Object.keys(t).find(n=>t[n]===e)??e,decodeId=(e,t)=>{if(t.version===1)return decodeIdV1(e);throw new CompositeIdUnsupportedVersionError(`Cannot decode ID, unsupported version number: ${t.version}`)},encodeIdV1=e=>`${ue}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(ue))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(ue)[1];if(!n)throw new CompositeIdMissingBodyError(`Trying to decode an ID without a body: ${e}`);return t(n)},escapeValue=e=>[`,`,`:`].reduce((e,t)=>e.replace(t,`\\`+t),e),unescapeValue=e=>[`,`,`:`].reduce((e,t)=>{let n=`\\`+t;return e.replace(RegExp(`\\\\`+n,`g`),t)},e),isCompositeId=e=>E(e)?!1:e.startsWith(ue),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(E(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=I(`{{${n.result.trim()}}}`,t);if(!E(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!E(n))for(let e of n.rules){let n=I(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,I(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},he={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>he[e],isValidEnumRef=e=>e in he,ge=[`preview`,`beta`,`ga`,`deprecated`,`internal`],_e=[`sync`,`async`],ve=N({r:M.record(M.string(),N({n:M.number().optional().nullable(),c:M.string().optional().nullable(),p:M.number().optional().nullable()})),v:M.number(),t:M.number()}),ye=N({remote:M.record(M.string(),N({pageNumber:M.number().optional(),providerPageCursor:M.string().optional(),position:M.number().optional()})),version:M.number(),timestamp:M.number()}),minifyCursor=e=>n(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if(O(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(ve.parse(r))}else return ye.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:a,...o}=n,{timestamp:s,...c}=r;return i(o)===i(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>E(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return(E(t)||r!==t.toString())&&(n=n&&E(i.pageNumber)&&E(i.position)&&E(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},o=E(n)&&E(r)&&E(i);return E(e)?{remote:o?{}:{[t]:a},version:2,timestamp:Date.now()}:o?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof me;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}const be={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,Internal:`INTERNAL`},xe={Http:`HTTP`,Mcp:`MCP`,ActionRpc:`ACTION_RPC`,WebSocket:`WEBSOCKET`},Se={Http:`HTTP`,WebSocket:`WEBSOCKET`,Sse:`SSE`},Ce={ApiKey:`API_KEY`,SessionToken:`SESSION_TOKEN`,UserSession:`USER_SESSION`,Cookie:`COOKIE`,Webhook:`WEBHOOK`,Signature:`SIGNATURE`},browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},we=M.object({startUrl:M.string().url(),systemPrompt:M.string().optional(),viewport:N({width:M.number().int().positive(),height:M.number().int().positive()}).optional(),locale:M.string().optional(),budgets:N({maxDurationMs:M.number().int().positive(),maxSteps:M.number().int().positive()}),auth:N({sensitiveKeys:M.array(M.string().min(1)).optional(),requiresSession:M.boolean().optional()}).optional()}),Te=M.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(typeof e.message==`string`&&e.message.trim().length>0)return e.message}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n;if(e.error!=null&&typeof e.error==`object`&&!Array.isArray(e.error)&&typeof e.error.message==`string`)return e.error.message;if(typeof e.error==`string`)return e.error;if(typeof e.error_description==`string`)return e.error_description}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof B){let n=e.message;return{block:t,successful:!1,errors:[q(e)],output:{statusCode:e.response?.status??500,message:extractErrorMessage(e.response,n),data:e.response?.data,raw:sanitizeRaw(e.response)}}}if(isHttpLikeError(e)){let n=e.response,r=e instanceof Error?e.message:`HTTP error: ${n.status??500}`;return{block:t,successful:!1,errors:[q(e)],output:{statusCode:n.status??500,message:extractErrorMessage(n,r),data:n.data,raw:sanitizeRaw(n)}}}return e instanceof Error?{block:t,successful:!1,errors:[q(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[q(e)],output:{statusCode:500,message:String(e)}}},isAwsCredentials=e=>!!e&&typeof e.accessKeyId==`string`&&typeof e.secretAccessKey==`string`,buildLambdaClientConfig=({region:e,endpoint:t,credentials:n})=>({region:e,...t?{endpoint:t}:{},...isAwsCredentials(n)?{credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,sessionToken:typeof n.sessionToken==`string`?n.sessionToken:void 0}}:t?{credentials:{accessKeyId:`local`,secretAccessKey:`local`}}:{}}),defaultClientFactory=e=>new ae(e),invokeLambda=async({lambdaName:e,payload:t,region:n,endpoint:r,invocationType:i=`RequestResponse`,qualifier:a,credentials:o,clientFactory:s=defaultClientFactory})=>{let c=s(buildLambdaClientConfig({region:n,endpoint:r,credentials:o})),l=new Y({FunctionName:e,InvocationType:i,Qualifier:a,Payload:t?Buffer.from(JSON.stringify(t)):void 0}),u=await c.send(l),d=u.Payload?Buffer.from(u.Payload).toString(`utf-8`):``,f;if(d.length===0)f=void 0;else try{f=JSON.parse(d)}catch{f=d}return{statusCode:u.StatusCode??200,payload:f,functionError:u.FunctionError,executedVersion:u.ExecutedVersion}},Ee=N({lambdaName:M.string(),region:M.string().optional(),endpoint:M.string().optional(),invocationType:M.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:M.string().optional(),args:N({name:M.string(),value:M.unknown(),condition:M.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:M.string().optional()}),De=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),executedVersion:M.string().optional()}).optional(),Oe=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>F(e)||Oe.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>F(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,ke=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;try{let n=P(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||I(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!Oe.test(o),c=t?.qualifier,l=typeof c==`string`&&!hasExpressionMarker(c),u={...t?L(i===void 0?t:{...t,args:a},e):{},...s?{dataKey:o}:{},...l?{qualifier:c}:{}},d;try{d=Ee.parse(u)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:f,region:p,endpoint:m,invocationType:h,qualifier:g,args:_,dataKey:v}=d,y;try{y=await n({lambdaName:f,payload:buildPayloadFromArgs(_),region:p,endpoint:m,invocationType:h,qualifier:g,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(y.functionError){let t=typeof y.payload==`object`&&y.payload!==null&&`errorMessage`in y.payload&&typeof y.payload.errorMessage==`string`?y.payload.errorMessage:`Lambda function error: ${y.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:y.functionError}],output:{statusCode:y.statusCode,message:t,data:y.payload,raw:y}}}return{block:e,successful:!0,output:{data:v?ke(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Ae=N({strategy:M.literal(`aws4`),service:M.string(),region:M.string().optional()}),je=N({strategy:M.literal(`hmac`),algorithm:M.enum([`sha256`,`sha512`]).optional(),headerName:M.string().optional(),prefix:M.string().optional()}),Me=M.discriminatedUnion(`strategy`,[Ae,je]),Ne=N({type:M.literal(`none`),signing:Me.optional()}),Pe=N({type:M.literal(`basic`),username:M.string().optional(),password:M.string().optional(),encoding:M.string().optional()}),Fe=N({type:M.literal(`bearer`),token:M.string(),includeBearer:M.boolean().optional().default(!0)}),Ie=N({type:M.literal(`oauth2`),authorizationUrl:M.string().optional(),authorizationParams:M.record(M.string(),M.string()).optional(),tokenUrl:M.string().optional(),tokenParams:M.record(M.string(),M.string()).optional(),tokenExpiresIn:M.number().optional(),tokenRefreshExpiresIn:M.number().optional(),token:M.string(),includeBearer:M.boolean().optional().default(!0),scopes:M.string().optional(),scopeDelimiter:M.string().optional(),customHeaders:M.record(M.string(),M.string()).optional(),pkce:M.boolean().optional(),additionalTokenFields:M.record(M.string(),M.string().optional()).optional(),issuer:M.string().optional()}),X=M.discriminatedUnion(`type`,[Ne,Pe,Fe,Ie]),Le=N({certs:M.string().array().optional(),keys:M.string().array().optional()}).optional(),Re=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z).optional().default(`get`),authorization:X.optional(),responseMode:M.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:M.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:M.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:N({dataKey:M.string().optional(),fileNameKey:M.string().optional(),contentTypeKey:M.string().optional(),contentIsBase64:M.boolean().optional().default(!1),urlKey:M.string().optional(),forwardAuth:M.boolean().optional().default(!1)}).optional(),maxRedirects:M.number().optional().default(5),followRedirects:M.boolean().optional().default(!0),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional()}),ze=N({data:M.union([M.string(),M.instanceof(Buffer)]).optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),headers:M.record(M.string(),M.string()).optional(),contentDisposition:M.string().optional(),fileMetadata:N({contentType:M.string().optional(),contentLength:M.number().optional(),fileName:M.string().optional(),lastModified:M.string().optional(),etag:M.string().optional()}).optional(),finalUrl:M.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?L({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:o,url:s,method:c,authorization:l,args:u,responseMode:d,responseType:f,encoding:p,response:m,maxRedirects:h,followRedirects:g}=Re.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?K(u):{query:{},body:{},headers:{}},y=U(k(l)?l:X.parse(_)),b={...v?.headers??{},...y},x=e.connector?.rateLimit,S=e.connector?.concurrency,C=x!==void 0||S!==void 0?{rateLimit:x,concurrency:S}:void 0;if(d===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,maxRedirects:g?h:0,requestConfig:C});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,responseType:f,encoding:p,response:m,maxRedirects:g?h:0,requestConfig:C,authHeaders:y})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:o,authHeaders:s}=e,c=n.data;if(r.urlKey){let e=extractValueByPath(c,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?s:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:o}),l=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:l,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(c,r.dataKey);if(E(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let o=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:o,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if(E(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);case`binary`:default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=O(e[`content-type`])?e[`content-type`]:void 0,n=O(e[`content-length`])?e[`content-length`]:void 0,r=O(e[`content-disposition`])?e[`content-disposition`]:void 0,i=O(e[`last-modified`])?e[`last-modified`]:void 0,a=O(e.etag)?e.etag:void 0,o=n?parseInt(n,10):void 0,s=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(o)?void 0:o,fileName:s,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return oe.extension(t)||void 0},Be=M.object({event:M.object({eventType:M.string(),eventDate:M.string().optional(),data:M.unknown().optional()}).optional()}),Ve=M.record(M.string(),M.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?L(t,e):{},{event:r}=Be.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventDate:r.eventDate,data:r.data})}catch(t){throw e.logger?.error({code:`EmitEventError`,message:`emitEvent callback failed: ${t.message}`}),t}else r&&!e.emitEvent&&e.logger?.warning({message:`emit_event step executed but no emitEvent callback provided on the block`});let{event:i,...a}=n;return{block:{...e},successful:!0,output:a}},He=M.object({stepsDataToGroup:M.array(M.string()),isSingleRecord:M.boolean().optional()}),Ue=M.object({data:M.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=He.parse(t),i=n.reduce((t,n)=>{let i=e.steps?.[n]?.output?.data;return i?r?{...t,[n]:{...i}}:(Object.keys(i).forEach(e=>{t[e]={...k(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},We=e(async({block:e})=>{let t=e?.fieldConfigs,n=[],r=e.steps;if(!t||e?.debug?.custom_mappings===`disabled`||!r)return{block:e,successful:!0};let i=buildExpressionContext(e),a;if(Array.isArray(e.result)){let o=e.result.length;a=e.result.map((e,a)=>{let s=Ge(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Ge(e.result,t,r,i);a=o.record,n.push(...o.errors||[])}return{block:{...e,result:a},successful:!0,errors:Object.keys(n).length>0?n:void 0}},`mapFieldsStepFunction`),extractSingleRecordBlockStepData=(e,t,n)=>Object.entries(e).reduce((e,[r,i])=>{let a=i?.output?.data;return Array.isArray(a)&&a.length===t?e[r]={output:{data:a[n]}}:e[r]=i,e},{}),Ge=e((e,t,n,r)=>{if(!e||!n)return{record:e};let i={...r,unified:{...e},...typeof n==`object`?n:{}},a={},o=[],s={...e};for(let n of t){let{error:t,value:r}=Ke(i,e.id,n);if(t){o.push(t);continue}n.custom?a[n.targetFieldKey]=r:s[n.targetFieldKey]=r}return{record:{...s,unified_custom_fields:Object.keys(a).length>0?a:void 0},errors:o.length>0?o:void 0}},`mapSingleRecord`),Ke=e((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=P(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return a;case`country_alpha3code_by_alpha3code`:return d;case`country_code_by_country_code`:return g;case`country_name_by_country_name`:return x;case`country_name_by_alpha3code`:return y;case`country_name_by_alpha2code`:return v;case`country_name_by_country_code`:return b;case`country_alpha3code_by_alpha2code`:return u;case`country_alpha3code_by_country_name`:return p;case`country_alpha3code_by_country_code`:return f;case`country_alpha2code_by_alpha3code`:return o;case`country_alpha2code_by_country_name`:return l;case`country_alpha2code_by_country_code`:return c;case`country_code_by_alpha2code`:return m;case`country_code_by_alpha3code`:return h;case`country_code_by_country_name`:return _;case`country_subdivisions_by_alpha2code`:return w;case`country_subdivision_code_by_subdivision_name`:return S;case`country_alpha2code_by_citizenship`:return s;case`country_subdivision_name_by_subdivision_code`:return C;case`document_file_format_from_extension`:return T;default:return}},qe=N({targetFieldKey:M.string(),alias:M.string().optional(),expression:M.string().optional(),values:M.unknown().optional(),type:M.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:M.boolean().default(!1),custom:M.boolean().default(!1),hidden:M.boolean().default(!1),enumMapper:N({matcher:M.string().or(N({matchExpression:M.string(),value:M.string()}).array())}).optional(),properties:M.lazy(()=>qe).array().optional(),requiredScopes:M.string().array().optional()}),Je=M.object({fields:qe.array(),dataSource:M.string(),externalSources:M.record(M.string(),M.string()).optional()}),Ye=M.object({data:M.unknown()}),mergeSourceWithState=(e,t)=>D(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=Je.parse(t),o=buildExpressionContext(e),s=P(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!s)return{block:e,successful:!0};let c=Object.keys(a??{})?.reduce((e,t)=>(e[t]=P(a?.[t],o),e),{}),l;if(Array.isArray(s))l=s.map(e=>{let t=Z(r,{...e,external:c},o);return n.push(...t?.errors||[]),t?.record});else{let e=Z(r,{...s,external:c},o);l=e?.record,n.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:l},errors:Object.keys(n).length>0?n:void 0}},handleObjectArrayFromValues=(e,t,n,r)=>{if(Array.isArray(e.values))return e.values.map(i=>{let a=evaluateExpressionsInObject(i,t),o=Z(e.properties,a,r);return k(o?.errors)&&n.push(...o.errors),o?.record}).filter(Boolean)},handleObjectArrayFromExpression=(e,t,n,r,i)=>{if(e.expression)try{let t=P(e.expression,n);if(Array.isArray(t))return t.map(t=>{let n=Z(e.properties,t,i);return k(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Z(e.properties,t,i);return k(n?.errors)&&r.push(...n.errors),n?.record}}catch{r.push({message:`Invalid expression`,id:t?.id,targetField:e.targetFieldKey});return}},handleSingleObject=(e,t,n,r)=>{let i=k(e.values)?e.values:t,a=Z(e.properties,i,r);return k(a?.errors)&&n.push(...a.errors),a?.record},Xe=e((e,t,n,r,i)=>{if(!E(e.properties))return e.array&&Array.isArray(e.values)?handleObjectArrayFromValues(e,n,r,i):e.array&&e.expression?handleObjectArrayFromExpression(e,t,n,r,i):handleSingleObject(e,t,r,i)},`handleObjectField`),Z=e((e,t,n)=>{if(!t)return;let r=mergeSourceWithState(t,n),i={},a=[],o={};for(let s of e){let e;if(s.type===`object`){if(e=Xe(s,t,r,a,n),e===void 0)continue}else{let{error:n,value:i}=extractFieldValue(r,t?.id,s);if(e=i,n){a.push(n);continue}}s.custom?i[s.targetFieldKey]=e:o[s.targetFieldKey]=e}let s=Object.keys(i).length>0?{unified_custom_fields:i}:{};return{record:{...o,...s},errors:a.length>0?a:void 0}},`mapSingleRecord`),evaluateExpressionsInObject=(e,t)=>{if(e==null)return e;if(typeof e==`string`){if(ne(e))try{return P(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return Ze(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},Ze=e((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=P(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=Ze(e,t,n),i=k(r.value)?r.value:null;if(e.enumMapper===void 0)return{error:{message:`Enum mapper was not defined`,id:t,targetField:e.targetFieldKey}};let a=e.enumMapper.matcher;if(O(a)){let n=getEnumMatcher(a);return k(n)?{value:{value:(k(i)?n(i):null)??`unmapped_value`,source_value:i}}:{error:{message:`The built-in matcher "${a}" is not supported`,id:t,targetField:e.targetFieldKey}}}for(let e of a){let{matchExpression:t,value:r}=e;if(P(t,n)===!0)return{value:{value:r,source_value:i}}}return{value:{value:`unmapped_value`,source_value:i}}},Qe=M.object({baseUrl:M.string(),url:M.string(),method:M.enum(z),saml:N({objectKey:M.string(),key:M.string(),clientId:M.string(),cert:M.unknown().optional(),issuer:M.string().optional(),lifetime:M.number().optional(),nameId:M.string().optional(),audience:M.string().optional(),nameIdentifierFormat:M.string().optional(),tokenEndpoint:M.string().optional()}).optional(),response:N({indexField:M.string().optional(),dataKey:M.string().optional(),nextKey:M.string().optional(),nextKeyIn:M.enum([`data`,`headers`]).optional()}).optional(),iterator:N({key:M.string(),in:M.enum(H),condition:M.string().optional(),mode:M.enum([`cursor`,`offset`]).optional()}),cursor:N({token:M.string().optional().nullable(),position:M.number().optional().nullable()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional()}),$e=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),next:M.string().optional().nullable(),position:M.number().optional()}).optional(),Q=e(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=re.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:i}=t,a=Number(e.inputs?.page_size),o=Number.isNaN(a)?25:a,s=i?i.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,c=t?L({...t,args:s},e):{},l=t?.response?.nextKey,u=l&&Q(l),d=t?.response?.dataKey,f=d&&Q(d),p={...c?.response??{},...u?{nextKey:l}:{},...f?{dataKey:d}:{}},m={...c,customErrors:t?.customErrors,iterator:{...c?.iterator??{},condition:t?.iterator?.condition},response:u||f?p:c?.response},{baseUrl:h,url:g,method:_,response:v,iterator:y,cursor:b,customErrors:x,args:S,saml:C}=Qe.parse(m),w=c?.authentication?.[e.context.authenticationType]?.[e.context.environment],T=w?.authorization,O=w?.certificates,ee=O?ie(O):void 0,te=X.parse(T),A=S?K(S):{query:{},body:{},headers:{}},j=U(te),M={...A?.headers??{},...j},N=e.connector?.rateLimit,F=e.connector?.concurrency,ne=N!==void 0||F!==void 0?{rateLimit:N,concurrency:F}:void 0,R=k(C)?{[C.objectKey]:await r({key:C.key,clientId:C.clientId,cert:C.cert,issuer:C.issuer,lifetime:C.lifetime,audience:C.audience,nameId:C.nameId,nameIdentifierFormat:C.nameIdentifierFormat,tokenEndpoint:C.tokenEndpoint})}:{},z=y.mode===`offset`,B=b?.token??null,V=null,H=null,W=[],G=[],q=[],J=o,Y=b?.position??0,ae=!0,oe=!0,se=!0;do{ae?ae=!1:z||(Y=0),B===null?z&&(y.in===`query`?A.query[y.key]=Y.toString():y.in===`body`&&(Array.isArray(A.body)||(A.body[y.key]=Y))):y.in===`query`?D(B)?Object.entries(B).forEach(([e,t])=>{A.query[`${y.key}[${e}]`]=t?.toString()??``}):A.query[y.key]=B.toString():y.in===`body`&&(Array.isArray(A.body)||(A.body[y.key]=B));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${h}${g}`,queryParams:{...A?.query},method:_,headers:{...M},body:Array.isArray(A?.body)?A.body:{...A?.body,...R},customErrorConfigs:x,requestConfig:ne,httpsAgent:ee,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}V=B,G=v?.dataKey?et(t.data,v.dataKey):t.data;let r=z?G?.slice(0,J):G?.slice(Y,Y+J);J-=r.length,Y+=r.length,q.push(t),W=W.concat(r),H=t?.status,B=tt({result:t,response:v}),se=k(y.condition)?I(y.condition,t.data)===!0:!0,!z&&r.length===G.length&&J===0&&(Y=0,V=B),oe=!se||E(B)&&W.length<o}while((z||k(B))&&se&&W.length<o&&G?.length>0);return{block:e,successful:!0,output:{data:it(W,v),raw:q,statusCode:H,next:oe?void 0:V,position:oe?void 0:Y}}},et=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;let n=I(Q(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),tt=e(({result:e,response:t})=>{if(E(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?nt(e.headers,r):rt(e.data,r)},`resolveNextIterator`),nt=e((e,t)=>{if(E(e)||typeof e!=`object`)return null;if(Q(t)){let n=I(t,e);return typeof n==`string`&&n!==``||typeof n==`number`?n:null}let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},`resolveFromHeaders`),rt=e((e,t)=>{if(E(e)||typeof e!=`object`||!e)return null;let n=I(Q(t)?t:`$.${t}`,e);return E(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),it=e((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),at=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z),authorization:X.optional(),certificates:Le,saml:N({objectKey:M.string(),key:M.string(),clientId:M.string(),cert:M.unknown().optional(),issuer:M.string().optional(),lifetime:M.number().optional(),nameId:M.string().optional(),audience:M.string().optional(),nameIdentifierFormat:M.string().optional(),tokenEndpoint:M.string().optional()}).optional(),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional()}),ot=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=re.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:i}=t,a=i?i.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,o=t?.response?.dataKey,s=o&&isJexlExpression(o),c=t?L({...t,args:a},e):{},l={...c,customErrors:t?.customErrors,response:s?{...c?.response??{},dataKey:o}:c?.response},{baseUrl:u,url:d,method:f,response:p,authorization:m,certificates:h,customErrors:g,args:_,saml:v}=at.parse(l),y=c?.authentication?.[e.context.authenticationType]?.[e.context.environment],b=y?.authorization,x=h??y?.certificates,S=x?ie(x):void 0,C=_?K(_):{query:{},body:{},headers:{}},w=k(m)?m:X.parse(b),T=U(w),E={...C?.headers??{},...T},D=e.connector?.rateLimit,O=e.connector?.concurrency,ee=D!==void 0||O!==void 0?{rateLimit:D,concurrency:O}:void 0,te=k(v)?{[v.objectKey]:await r({key:v.key,clientId:v.clientId,cert:v.cert,issuer:v.issuer,lifetime:v.lifetime,audience:v.audience,nameId:v.nameId,nameIdentifierFormat:v.nameIdentifierFormat,tokenEndpoint:v.tokenEndpoint})}:{},A=Array.isArray(C?.body)?C?.body:{...C?.body,...te};if(w.type===`none`&&w.signing?.strategy){let t=w.signing,n=e.credentials??{};try{let e=W(t.strategy);if(!e)throw Error(`Signing strategy "${t.strategy}" is not registered`);let r=e({method:f,url:`${u}${d}`,headers:E,query:C?.query??{},body:A},n,t);Object.assign(E,r)}catch(t){return buildStepErrorOutput(t,e)}}let j;try{j=await n.performRequest({httpClient:e.httpClient,url:`${u}${d}`,queryParams:C?.query,method:f,headers:E,body:A,customErrorConfigs:g,requestConfig:ee,httpsAgent:S,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:st(p?.dataKey?resolveDataKey(j.data,p.dataKey):j.data,p),raw:j,statusCode:j?.status,message:j?.message}}},resolveDataKey=(e,t)=>{if(E(e)||typeof e!=`object`||!e)return e;let n=I(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},st=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),ct=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z),authorization:M.discriminatedUnion(`type`,[N({type:M.literal(`none`)}),N({type:M.literal(`basic`),username:M.string().optional(),password:M.string().optional(),encoding:M.string().optional()}),N({type:M.literal(`bearer`),token:M.string(),includeBearer:M.boolean().optional().default(!0)}),N({type:M.literal(`oauth2`),token:M.string(),includeBearer:M.boolean().optional().default(!0)})]).optional(),envelope:M.union([M.string(),M.record(M.string(),M.unknown())]).optional(),namespaces:M.strictObject({namespaceIdentifier:M.string(),namespace:M.string()}).array().optional(),soapOperation:M.string().optional(),soapAction:M.string().optional(),useSoapContext:M.boolean().optional().default(!0),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional(),nextKey:M.string().optional(),nextKeyIn:M.enum([`data`,`headers`]).optional()}).optional(),iterator:N({key:M.string(),in:M.enum(H)}),cursor:N({token:M.string().optional().nullable(),position:M.number().optional().nullable()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional()}),lt=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),next:M.string().optional().nullable(),position:M.number().optional()}).optional(),soapPaginatedRequestStepFunction=async({block:e,params:t})=>{let n=re.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,o=r?r.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,s=t?L({...t,args:o},e):{},c={...s,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,response:f,iterator:p,cursor:m,authorization:h,customErrors:g,args:_,soapOperation:v,namespaces:y,envelope:b,soapAction:x,useSoapContext:S}=ct.parse(c),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,w=_?K(_):{query:{},body:{},headers:{}},T=U(k(h)?h:X.parse(C)),D={...w?.headers??{},...T},O=e.connector?.rateLimit,ee=e.connector?.concurrency,te={...(O!==void 0||ee!==void 0)&&{rateLimit:O,concurrency:ee},soapOperation:v,namespaces:y,envelope:b,soapAction:x,soapContext:S?{username:e.credentials?.username,password:e.credentials?.password}:void 0},A=m?.token??null,j=null,M=null,N=[],F=[],ne=[],I=a,R=m?.position??0,z=!0,B;do{z?z=!1:R=0,A!==null&&(p.in===`query`?w.query[p.key]=A.toString():p.in===`body`&&(w.body[p.key]=A));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${l}${u}`,queryParams:w?.query,method:d,headers:D,body:w?.body,customErrorConfigs:g,requestConfig:te,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}j=A,F=f?.dataKey?t.data[f?.dataKey]:t.data,Array.isArray(F)||(F=F?[F]:[]);let r=F?.slice(R,R+I);I-=r.length,R+=r.length,ne.push(t),N=N.concat(r),M=t?.status,A=resolveNextIterator({result:t,response:f}),r.length===F.length&&I===0&&(R=0,j=A),B=E(A)&&N.length<a}while(k(A)&&N.length<a&&F?.length>0);return{block:e,successful:!0,output:{data:ut(N,f),raw:ne,statusCode:M,next:B?void 0:j,position:B?void 0:R}}},resolveNextIterator=({result:e,response:t})=>{if(E(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?resolveFromHeaders(e.headers,r):resolveFromData(e.data,r)},resolveFromHeaders=(e,t)=>{if(E(e)||typeof e!=`object`)return null;let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},resolveFromData=(e,t)=>{if(E(e)||typeof e!=`object`||!e)return null;let n=e[t];return E(n)?null:typeof n==`string`||typeof n==`number`?n:null},ut=e((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),dt=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z),authorization:X.optional(),envelope:M.union([M.string(),M.record(M.string(),M.unknown())]).optional(),namespaces:M.strictObject({namespaceIdentifier:M.string(),namespace:M.string()}).array().optional(),soapOperation:M.string().optional(),soapAction:M.string().optional(),useSoapContext:M.boolean().optional().default(!0),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional()}),ft=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional()}).optional(),soapRequestStepFunction=async({block:e,params:t})=>{let n=re.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?L({...t,args:i},e):{},o={...a,customErrors:t?.customErrors},{baseUrl:s,url:c,method:l,response:u,authorization:d,customErrors:f,args:p,soapOperation:m,namespaces:h,envelope:g,soapAction:_,useSoapContext:v}=dt.parse(o),y=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,b=p?K(p):{query:{},body:{},headers:{}},x=U(k(d)?d:X.parse(y)),S={...b?.headers??{},...x},C=e.connector?.rateLimit,w=e.connector?.concurrency,T={...(C!==void 0||w!==void 0)&&{rateLimit:C,concurrency:w},soapOperation:m,namespaces:h,envelope:g,soapAction:_,soapContext:v?{username:e.credentials?.username,password:e.credentials?.password}:void 0},E;try{E=await n.performRequest({httpClient:e.httpClient,url:`${s}${c}`,queryParams:b?.query,method:l,headers:S,body:b?.body,customErrorConfigs:f,requestConfig:T,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:pt(u?.dataKey?E.data[u?.dataKey]:E.data,u),raw:E,statusCode:E?.status,message:E?.message}}},pt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),mt=M.object({values:M.string().or(M.record(M.string(),M.unknown())).or(M.array(M.unknown()))}),ht=M.object({data:M.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=mt.parse(t),r=Array.isArray(n)?n.map(t=>evaluateValue(t,e)):evaluateValue(n,e);return{block:{...e},successful:!0,output:{data:r}}},evaluateValue=(e,t)=>O(e)?I(e,t):D(e)?L(e,t):e,gt=M.object({targetFieldKey:M.string(),type:M.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:M.boolean().default(!1),custom:M.boolean().default(!1),hidden:M.boolean().default(!1),properties:M.lazy(()=>gt).array().optional(),requiredScopes:M.string().array().optional()}),_t=M.object({fields:gt.array().optional(),dataSource:M.string()}),vt=M.object({data:M.unknown()});let yt=function(e){return e.String=`string`,e.Number=`number`,e.Boolean=`boolean`,e.DateTimeString=`datetime_string`,e}({});const typecast=({value:e,type:t,format:n})=>{if(E(e))return null;switch(t){case yt.String:return j({value:e});case yt.Number:return A({value:e});case yt.Boolean:return ee({value:e});case yt.DateTimeString:return te({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(yt).includes(e),bt=e(async({block:e})=>{let t=e?.fieldConfigs;if(!t||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let n;return n=Array.isArray(e.result)?e.result.map(e=>xt(e,t)):xt(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),xt=e((e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i}=t;isFieldSupportedType(i)&&(!t.custom&&k(n[r])?n[r]=typecast({value:e[r],type:i}):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},`mapSingleRecord`),typecastStepFunction=async({block:e,params:t})=>{let{fields:n,dataSource:r}=_t.parse(t),i=P(r,buildExpressionContext(e));if(!n||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let a;return a=Array.isArray(i)?i.map(e=>mapSingleRecord(e,n)):mapSingleRecord(i,n),{block:{...e},successful:!0,output:{data:a}}},handleObjectField=(e,t)=>!e.properties||!t?t:Array.isArray(t)?t.map(t=>typeof t==`object`&&t?mapSingleRecord(t,e.properties):t):typeof t==`object`&&t?mapSingleRecord(t,e.properties):t,mapSingleRecord=(e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i,array:a}=t;i===`object`?!t.custom&&k(n[r])?n[r]=handleObjectField(t,e[r]):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=handleObjectField(t,e.unified_custom_fields?.[r])):isFieldSupportedType(i)&&(!t.custom&&k(n[r])?(!a||!Array.isArray(n[r]))&&(n[r]=typecast({value:e[r],type:i})):n.unified_custom_fields&&k(n.unified_custom_fields?.[r])&&(!a||!Array.isArray(n.unified_custom_fields[r]))&&(n.unified_custom_fields[r]=typecast({value:e.unified_custom_fields?.[r],type:i})))}),{...n}},St=N({content:M.string().describe(`The file content as base64 encoded string`),contentType:M.string().optional().describe(`The MIME type for the binary content (defaults to application/octet-stream)`)}),Ct=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z).default(`post`),authorization:X.optional(),binaryContent:St.describe(`Raw binary content for octet-stream uploads`),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),wt=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional()}).optional(),uploadBinaryStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?L({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:o,url:s,method:c,response:l,authorization:u,binaryContent:d,args:f,customErrors:p}=Ct.parse(a),m=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,h=f?K(f):{query:{},body:{},headers:{}},g=U(k(u)?u:X.parse(m)),_=Buffer.from(d.content,`base64`),v={"content-type":d.contentType??`application/octet-stream`,...h?.headers??{},...g},y=e.connector?.rateLimit,b=e.connector?.concurrency,x=y!==void 0||b!==void 0?{rateLimit:y,concurrency:b}:void 0,S;try{S=await e.httpClient.request({url:`${o??``}${s}`,method:c,headers:v,queryParams:h?.query,payload:_,requestConfig:x})}catch(t){let n=t;return{block:e,successful:!1,errors:[q(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let C=J(S,p,e.credentials);return G(C?.status)?{block:e,successful:!1,errors:[q(new B(C,C.message))],output:{statusCode:C.status,message:C.message}}:{block:e,successful:!0,output:{data:Tt(l?.dataKey?C.data[l?.dataKey]:C.data,l),raw:C,statusCode:C?.status,message:C?.message}}},Tt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Et=N({fieldName:M.string().describe(`The form field name for the file`),content:M.string().describe(`The file content as base64 encoded string`),filename:M.string().describe(`The filename to use in the upload`),contentType:M.string().optional().describe(`The MIME type of the file (e.g., "image/png", "application/pdf")`)}),Dt=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(z).default(`post`),authorization:X.optional(),file:Et.describe(`The file to upload`),additionalFields:N({name:M.string(),value:M.unknown(),condition:M.string().optional(),contentType:M.string().optional().describe(`The MIME type for this form field (e.g., "application/json")`)}).array().optional().describe(`Additional form fields to include in the multipart request`),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional()}).optional(),customErrors:R.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(H),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(V).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Ot=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional()}).optional(),uploadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n,additionalFields:r}=t,i=n?n.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=r?r.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,o=t?L({...t,args:i,additionalFields:a},e):{},s={...o,customErrors:t?.customErrors},{baseUrl:c,url:l,method:u,response:d,authorization:f,file:p,additionalFields:m,args:h,customErrors:g}=Dt.parse(s),_=o?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?K(h):{query:{},body:{},headers:{}},y=U(k(f)?f:X.parse(_)),b=new se;if(m)for(let e of m){let t=typeof e.value==`object`?JSON.stringify(e.value):String(e.value);b.append(e.name,t,e.contentType?{contentType:e.contentType}:void 0)}let x=Buffer.from(p.content,`base64`);b.append(p.fieldName,x,{filename:p.filename,contentType:p.contentType});let S={...b.getHeaders(),...v?.headers??{},...y},C=e.connector?.rateLimit,w=e.connector?.concurrency,T=C!==void 0||w!==void 0?{rateLimit:C,concurrency:w}:void 0,E;try{E=await e.httpClient.request({url:`${c??``}${l}`,method:u,headers:S,queryParams:v?.query,payload:b,requestConfig:T})}catch(t){return buildStepErrorOutput(t,e)}let D=J(E,g,e.credentials);return G(D?.status)?buildStepErrorOutput(new B(D,D.message),e):{block:e,successful:!0,output:{data:indexResponseData(d?.dataKey?D.data[d?.dataKey]:D.data,d),raw:D,statusCode:D?.status,message:D?.message}}},indexResponseData=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e};let $=function(e){return e.TYPECAST=`typecast`,e.MAP_FIELDS=`map_fields`,e.GROUP_DATA=`group_data`,e.REQUEST=`request`,e.PAGINATED_REQUEST=`paginated_request`,e.SOAP_REQUEST=`soap_request`,e.SOAP_PAGINATED_REQUEST=`soap_paginated_request`,e.STATIC_VALUES=`static_values`,e.UPLOAD_FILE=`upload_file`,e.UPLOAD_BINARY=`upload_binary`,e.DOWNLOAD_FILE=`download_file`,e.EMIT_EVENT=`emit_event`,e.BROWSER_USE=`browser_use`,e.CODE_EXECUTION_LAMBDA=`code_execution_lambda`,e}({});const kt={[$.TYPECAST]:{v1:{fn:bt},v2:{fn:typecastStepFunction,inputSchema:_t,outputSchema:vt}},[$.MAP_FIELDS]:{v1:{fn:We},v2:{fn:mapFieldsStepFunction,inputSchema:Je,outputSchema:Ye}},[$.REQUEST]:{v1:{fn:requestStepFunction,inputSchema:at,outputSchema:ot}},[$.GROUP_DATA]:{v1:{fn:groupDataStepFunction,inputSchema:He,outputSchema:Ue}},[$.PAGINATED_REQUEST]:{v1:{fn:paginatedRequestStepFunction,inputSchema:Qe,outputSchema:$e}},[$.SOAP_REQUEST]:{v1:{fn:soapRequestStepFunction,inputSchema:dt,outputSchema:ft}},[$.SOAP_PAGINATED_REQUEST]:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:ct,outputSchema:lt}},[$.STATIC_VALUES]:{v1:{fn:staticValuesStepFunction,inputSchema:mt,outputSchema:ht}},[$.UPLOAD_FILE]:{v1:{fn:uploadFileStepFunction,inputSchema:Dt,outputSchema:Ot}},[$.UPLOAD_BINARY]:{v1:{fn:uploadBinaryStepFunction,inputSchema:Ct,outputSchema:wt}},[$.DOWNLOAD_FILE]:{v1:{fn:downloadFileStepFunction,inputSchema:Re,outputSchema:ze}},[$.EMIT_EVENT]:{v1:{fn:emitEventStepFunction,inputSchema:Be,outputSchema:Ve}},[$.BROWSER_USE]:{v1:{fn:browserUseStepFunction,inputSchema:we,outputSchema:Te}},[$.CODE_EXECUTION_LAMBDA]:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:Ee,outputSchema:De}}},formatZodIssues=(e,t,n)=>e instanceof M.ZodError?e.issues.map(e=>({...e,kind:t,functionName:n})):[{kind:t,functionName:n,message:e?.message??`unknown error`}],stepFunctionEnhancedWithSchemasValidation=(e,t)=>async({block:n,params:r})=>{try{e.inputSchema&&e.inputSchema.parse(r)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`input_schema_validation`,t)}}let i=await e.fn({block:n,params:r});try{e.outputSchema&&e.outputSchema.parse(i.output)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`output_schema_validation`,t)}}return i},At={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=kt}){let i=r?.[e]?.[`v${t}`];if(!i)throw Error(`Unknown step function: ${e} v${t}`);return n?{...i,fn:stepFunctionEnhancedWithSchemasValidation(i,e)}:i}},isForeachStep=e=>`iterator`in e&&typeof e.iterator==`string`;export{X as AUTHORIZATION_SCHEMA,Ce as AuthType,we as BROWSER_USE_INPUT_PARAMS,Te as BROWSER_USE_OUTPUT,pe as COMPOSITE_ID_LATEST_VERSION,me as CoreError,_e as ExecutionModes,he as INPUT_ENUM_REGISTRY,ge as ReleaseStages,be as SourceType,$ as StepFunctionName,At as StepFunctionsFactory,kt as StepFunctionsRegistry,Se as StreamType,xe as TransportType,areCursorsEqual,buildExpressionContext,decodeCompositeId,encodeCompositeId,evaluateEventRouter,evaluateExternalAccountIdExtractor,expandCursor,getCategoryDetails,getInputEnumValues,getIteratorLocation,getPaginationKeys,isCompositeId,isCoreError,isCursorEmpty,isForeachStep,isValidCategory,isValidEnumRef,minifyCursor,stripPaginationParams,updateCursor};
|