@stackone/core 3.11.0 → 3.13.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 CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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("node:stream"),d=require("mime-types");d=__toESM(d);let f=require("saml"),p=require("uuid"),m=require("node:crypto"),h=require("jose"),g=require("form-data");g=__toESM(g);const _=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=_.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},v={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=>v[e.toLowerCase()]??null,isValidCategory=e=>!!v[e.toLowerCase()],y=(0,o.encodeToBase64)(`so1!`),b=RegExp(`(?<!\\\\):`,`g`),x=RegExp(`(?<!\\\\),`,`g`);var S=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 S{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(x).forEach(e=>{let[n,i]=e.split(b),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=>`${y}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(y))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(y)[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(y),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}}}},C={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=>C[e],isValidEnumRef=e=>e in C,w=[`preview`,`beta`,`ga`,`deprecated`,`internal`],T=[`auth`,`downstream-change`,`bug-fix`,`new-actions`],E=[`sync`,`async`],D=(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()}),O=(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(D.parse(n))}else return O.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 S;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}function stripIncrementalParams(e,t){if(!t)return e;let{key:n,in:r}=t.iterator,i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};return delete a[n],{...e,[r]:a}}const k={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Discode:`DISCODE`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,API:`API`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,Application:`APPLICATION`,DataSync:`DATA_SYNC`,DataSyncV2:`DATA_SYNC_V2`,Internal:`INTERNAL`},A={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},j={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},M={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`)},N=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(),allowedDomains:o.z.array(o.z.string().min(1)).optional()}).optional()}),P=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},isSerializedBuffer=e=>typeof e==`object`&&!!e&&e.type===`Buffer`&&Array.isArray(e.data),decodeBinaryBody=e=>{let t;if(Buffer.isBuffer(e)?t=e.toString(`utf8`):e instanceof ArrayBuffer?t=new TextDecoder().decode(new Uint8Array(e)):ArrayBuffer.isView(e)?t=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):isSerializedBuffer(e)&&(t=Buffer.from(e.data).toString(`utf8`)),t===void 0)return e;try{return JSON.parse(t)}catch{return t}},decodeResponseBody=e=>({...e,data:decodeBinaryBody(e.data)}),isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractTopLevelMessage=e=>{if(typeof e.message==`string`&&e.message.trim().length>0)return e.message},extractNestedErrorMessage=e=>{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`&&e.error.length>0)return e.error;if(typeof e.error_description==`string`&&e.error_description.length>0)return e.error_description},extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractTopLevelMessage(n);if(e!=null)return e}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractNestedErrorMessage(n);if(e!=null)return e}if(Array.isArray(n)&&n.length>0){let e=n[0];if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=extractTopLevelMessage(t)??extractNestedErrorMessage(t);if(n!=null)return n}}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof c.HttpResponseError){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:r?.status??500,message:extractErrorMessage(r,n),data:r?.data,raw:sanitizeRaw(r)}}}if(isHttpLikeError(e)){let n=decodeResponseBody(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}},F=(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()}),I=(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(),L=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||L.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,R=__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`&&!L.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=F.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?R(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},z=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),B=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha1`,`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional(),dateFormat:o.z.enum([`iso8601`,`rfc2822`]).optional(),includeHost:o.z.boolean().optional(),includeBodyHash:o.z.boolean().optional(),outputFormat:o.z.enum([`header`,`basic`]).optional(),username:o.z.string().optional()}),V=o.z.discriminatedUnion(`strategy`,[z,B]),H=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:V.optional()}),U=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),W=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),G=(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(),tokenResponse:(0,o.zStrictObject)({acceptTokenTypes:o.z.array(o.z.string()).optional(),accessToken:o.z.string().min(1).optional(),refreshToken:o.z.string().min(1).optional()}).optional()}),K=o.z.discriminatedUnion(`type`,[H,U,W,G]),q=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),J=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:K.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(),contentType: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()}),Y=(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.union([o.z.string(),o.z.array(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}=J.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:K.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,response:_,responseType:h,authHeaders:S});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:s,queryParams:c,body:l,maxRedirects:d,requestConfig:f,response:p,responseType:m,authHeaders:h}=e,g=`${r}${i}`;if(!g.startsWith(`http://`)&&!g.startsWith(`https://`))throw Error(`Invalid URL: "${g}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if((0,o.notMissing)(p?.dataKey)||(0,o.notMissing)(p?.urlKey))try{let e=await performDownload({httpClient:n,baseUrl:r,url:i,method:a,headers:s,queryParams:c,body:l,responseType:m??`arraybuffer`,encoding:`none`,response:p,maxRedirects:d,requestConfig:f,authHeaders:h??{}}),g=Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data),_={...e.fileMetadata,contentLength:g.length};return{block:t,successful:!0,streamOutput:{stream:u.Readable.from(g),headers:(0,o.notMissing)(_.contentType)?{"content-type":_.contentType}:{},contentDisposition:e.contentDisposition,fileMetadata:_}}}catch(e){return buildStepErrorOutput(e,t)}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:g,method:a,headers:s,queryParams:c,payload:l,maxRedirects:d,requestConfig:f}),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}),u=encodeFileData(n.data,i),d=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(d.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(d.contentType=e)}(0,o.isMissing)(d.contentType)&&(0,o.notMissing)(r.contentType)&&(d.contentType=r.contentType);let f=buildContentDisposition(d);return{data:u,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:f,fileMetadata:d,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)}(0,o.isMissing)(a.contentType)&&(0,o.notMissing)(r.contentType)&&(a.contentType=r.contentType);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`);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 d.default.extension(t)||void 0},X=o.z.object({event:o.z.object({eventType:o.z.string(),eventId:o.z.coerce.string().optional(),eventDate:o.z.coerce.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}=X.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventId:r.eventId,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}},te=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),ne=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=te.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)}}},re=__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=ie(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=ie(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},{}),ie=__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}=ae(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`),ae=__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}},oe=(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(()=>oe).array().optional(),requiredScopes:o.z.string().array().optional()}),se=o.z.object({fields:oe.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),ce=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}=se.parse(t),o=buildExpressionContext(e,{includeCredentials:!0}),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=Z(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=Z(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=Z(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=Z(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Z(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=Z(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},le=__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`),Z=__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=le(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 ue(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},ue=__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=ue(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}}},generateSamlAssertion=async({cert:e,key:t,issuer:n,lifetime:r,clientId:i,nameId:a,tokenEndpoint:o,audience:s,nameIdentifierFormat:c,createSamlFn:l=e=>f.Saml20.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let d={api_key:i},m={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:d,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+(0,p.v4)()},h=Buffer.from(l(m)).toString(`base64`);return await u(1e3),h},generatePrivateKey=e=>{let t=Buffer.from(e,`base64`).toString(`utf-8`).split(`###`);if(t.length!==2)throw Error(`Invalid private key`);let n=t[0];return Buffer.from(`-----BEGIN PRIVATE KEY-----
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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("node:stream"),d=require("mime-types");d=__toESM(d);let f=require("saml"),p=require("uuid"),m=require("node:crypto"),h=require("jose"),g=require("form-data");g=__toESM(g);const _=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=_.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},v={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=>v[e.toLowerCase()]??null,isValidCategory=e=>!!v[e.toLowerCase()],y=(0,o.encodeToBase64)(`so1!`),b=RegExp(`(?<!\\\\):`,`g`),x=RegExp(`(?<!\\\\),`,`g`);var S=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 S{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(x).forEach(e=>{let[n,i]=e.split(b),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=>`${y}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(y))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(y)[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(y),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}}}},C={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=>C[e],isValidEnumRef=e=>e in C,w=[`preview`,`beta`,`ga`,`deprecated`,`internal`],T=[`auth`,`downstream-change`,`bug-fix`,`new-actions`],E=[`sync`,`async`],D=(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()}),O=(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(D.parse(n))}else return O.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 S;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}function stripIncrementalParams(e,t){if(!t)return e;let{key:n,in:r}=t.iterator,i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};return delete a[n],{...e,[r]:a}}const k={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Discode:`DISCODE`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,API:`API`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,MCP:`MCP`,Application:`APPLICATION`,DataSync:`DATA_SYNC`,DataSyncV2:`DATA_SYNC_V2`,Internal:`INTERNAL`},A={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},j={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},M={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`)},N=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(),allowedDomains:o.z.array(o.z.string().min(1)).optional()}).optional()}),P=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},isSerializedBuffer=e=>typeof e==`object`&&!!e&&e.type===`Buffer`&&Array.isArray(e.data),decodeBinaryBody=e=>{let t;if(Buffer.isBuffer(e)?t=e.toString(`utf8`):e instanceof ArrayBuffer?t=new TextDecoder().decode(new Uint8Array(e)):ArrayBuffer.isView(e)?t=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):isSerializedBuffer(e)&&(t=Buffer.from(e.data).toString(`utf8`)),t===void 0)return e;try{return JSON.parse(t)}catch{return t}},decodeResponseBody=e=>({...e,data:decodeBinaryBody(e.data)}),isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractTopLevelMessage=e=>{if(typeof e.message==`string`&&e.message.trim().length>0)return e.message},extractNestedErrorMessage=e=>{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`&&e.error.length>0)return e.error;if(typeof e.error_description==`string`&&e.error_description.length>0)return e.error_description},extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractTopLevelMessage(n);if(e!=null)return e}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractNestedErrorMessage(n);if(e!=null)return e}if(Array.isArray(n)&&n.length>0){let e=n[0];if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=extractTopLevelMessage(t)??extractNestedErrorMessage(t);if(n!=null)return n}}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof c.HttpResponseError){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[(0,c.serializeHttpResponseError)(e)],output:{statusCode:r?.status??500,message:extractErrorMessage(r,n),data:r?.data,raw:sanitizeRaw(r)}}}if(isHttpLikeError(e)){let n=decodeResponseBody(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}},F=(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()}),I=(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(),L=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||L.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,R=__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`&&!L.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=F.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?R(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},z=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),B=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha1`,`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional(),dateFormat:o.z.enum([`iso8601`,`rfc2822`]).optional(),includeHost:o.z.boolean().optional(),includeBodyHash:o.z.boolean().optional(),outputFormat:o.z.enum([`header`,`basic`]).optional(),username:o.z.string().optional()}),V=o.z.discriminatedUnion(`strategy`,[z,B]),H=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:V.optional()}),U=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),W=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),G=(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(),tokenResponse:(0,o.zStrictObject)({acceptTokenTypes:o.z.array(o.z.string()).optional(),accessToken:o.z.string().min(1).optional(),refreshToken:o.z.string().min(1).optional()}).optional()}),K=o.z.discriminatedUnion(`type`,[H,U,W,G]),q=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),J=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:K.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(),contentType: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()}),Y=(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.union([o.z.string(),o.z.array(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}=J.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:K.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,response:_,responseType:h,authHeaders:S});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:s,queryParams:c,body:l,maxRedirects:d,requestConfig:f,response:p,responseType:m,authHeaders:h}=e,g=`${r}${i}`;if(!g.startsWith(`http://`)&&!g.startsWith(`https://`))throw Error(`Invalid URL: "${g}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if((0,o.notMissing)(p?.dataKey)||(0,o.notMissing)(p?.urlKey))try{let e=await performDownload({httpClient:n,baseUrl:r,url:i,method:a,headers:s,queryParams:c,body:l,responseType:m??`arraybuffer`,encoding:`none`,response:p,maxRedirects:d,requestConfig:f,authHeaders:h??{}}),g=Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data),_={...e.fileMetadata,contentLength:g.length};return{block:t,successful:!0,streamOutput:{stream:u.Readable.from(g),headers:(0,o.notMissing)(_.contentType)?{"content-type":_.contentType}:{},contentDisposition:e.contentDisposition,fileMetadata:_}}}catch(e){return buildStepErrorOutput(e,t)}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:g,method:a,headers:s,queryParams:c,payload:l,maxRedirects:d,requestConfig:f}),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}),u=encodeFileData(n.data,i),d=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(d.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(d.contentType=e)}(0,o.isMissing)(d.contentType)&&(0,o.notMissing)(r.contentType)&&(d.contentType=r.contentType);let f=buildContentDisposition(d);return{data:u,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:f,fileMetadata:d,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)}(0,o.isMissing)(a.contentType)&&(0,o.notMissing)(r.contentType)&&(a.contentType=r.contentType);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`);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 d.default.extension(t)||void 0},X=o.z.object({event:o.z.object({eventType:o.z.string(),eventId:o.z.coerce.string().optional(),eventDate:o.z.coerce.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}=X.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventId:r.eventId,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}},te=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),ne=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=te.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)}}},re=__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=ie(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=ie(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},{}),ie=__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}=ae(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`),ae=__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}},oe=(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(()=>oe).array().optional(),requiredScopes:o.z.string().array().optional()}),se=o.z.object({fields:oe.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),ce=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}=se.parse(t),o=buildExpressionContext(e,{includeCredentials:!0}),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=Z(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=Z(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=Z(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=Z(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Z(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=Z(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},le=__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`),Z=__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=le(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 ue(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},ue=__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=ue(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}}},generateSamlAssertion=async({cert:e,key:t,issuer:n,lifetime:r,clientId:i,nameId:a,tokenEndpoint:o,audience:s,nameIdentifierFormat:c,createSamlFn:l=e=>f.Saml20.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let d={api_key:i},m={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:d,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+(0,p.v4)()},h=Buffer.from(l(m)).toString(`base64`);return await u(1e3),h},generatePrivateKey=e=>{let t=Buffer.from(e,`base64`).toString(`utf-8`).split(`###`);if(t.length!==2)throw Error(`Invalid private key`);let n=t[0];return Buffer.from(`-----BEGIN PRIVATE KEY-----
2
2
  ${n}
3
3
  -----END PRIVATE KEY-----`)},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([`data`,`headers`]).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(),Q=__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&&Q(d),p=t?.response?.dataKey,m=p&&Q(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=K.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 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=[],W=[],G=a,q=S?.position??0,J=!0,Y=!0,X=!0;do{J?J=!1:R||(q=0),z===null?R&&(x.in===`query`?j.query[x.key]=q.toString():x.in===`body`&&(Array.isArray(j.body)||(j.body[x.key]=q))):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?pe(t.data,b.dataKey):t.data;let r=R?U?.slice(0,G):U?.slice(q,q+G);G-=r.length,q+=r.length,W.push(t),H=H.concat(r),V=t?.status,z=me({result:t,response:b}),X=(0,o.notMissing)(x.condition)?(0,s.safeEvaluate)(x.condition,t.data)===!0:!0;let i=q>=(U?.length??0),c=(0,o.notMissing)(b?.nextKey);!R&&r.length===U.length&&G===0&&(q=0,B=z),Y=R||!c?!X||(0,o.isMissing)(z)&&H.length<a:i&&((0,o.isMissing)(z)||!X)}while((R||(0,o.notMissing)(z))&&X&&H.length<a&&U?.length>0);return{block:e,successful:!0,output:{data:_e(H,b),raw:W,statusCode:V,next:Y?void 0:B,position:Y?void 0:q}}},pe=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(Q(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),me=__name(({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?he(e.headers,r):ge(e.data,r)},`resolveNextIterator`),he=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;if(Q(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`),ge=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=(0,s.safeEvaluate)(Q(t)?t:`$.${t}`,e);return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),_e=__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`),ve=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:K.optional(),certificates:q,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()}),ye=(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}=ve.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:K.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 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:be(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},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`),xe=o.z.union([o.z.string(),o.z.number()]),Se=(0,o.zStrictObject)({algorithm:o.z.literal(`RS256`),privateKey:o.z.string(),claims:o.z.record(o.z.string(),xe)}),Ce=(0,o.zStrictObject)({token:o.z.string(),expiresIn:o.z.number(),publicKeyFingerprint:o.z.string()}),computePublicKeyFingerprint=e=>{let t=e.export({format:`der`,type:`spki`});return`SHA256:${(0,m.createHash)(`sha256`).update(t).digest(`base64`)}`},we=/^now$/,Te=/^now\+(?<amount>\d+)(?<unit>[smh])$/,Ee=`{publicKeyFingerprint}`,De={s:1,m:60,h:3600},Oe=new Set([`iat`,`exp`,`nbf`]),resolveClaimValue=(e,t,{now:n,publicKeyFingerprint:r})=>{if(typeof t==`number`)return t;let i=t.includes(Ee)?t.split(Ee).join(r):t;if(!Oe.has(e))return i;if(we.test(i))return n;let a=i.match(Te);return a?.groups?n+Number(a.groups.amount)*De[a.groups.unit]:i},signJwtStepFunction=async({block:e,params:t})=>{try{let n=t?(0,s.safeEvaluateRecord)(t,e):void 0,{algorithm:r,privateKey:i,claims:a}=Se.parse(n),o=(0,m.createPrivateKey)(i),c=computePublicKeyFingerprint((0,m.createPublicKey)(o)),l=Math.floor(Date.now()/1e3),u={};for(let[e,t]of Object.entries(a))u[e]=resolveClaimValue(e,t,{now:l,publicKeyFingerprint:c});let{iat:d,exp:f}=u;if(typeof d!=`number`||typeof f!=`number`)throw Error(`signJwt requires numeric 'iat' and 'exp' claims (use 'now' / 'now+<N>s|m|h' tokens, or pass numbers directly)`);if(f<=d)throw Error(`signJwt requires 'exp' to be greater than 'iat'`);let p=await new h.SignJWT(u).setProtectedHeader({alg:r}).sign(o);return{block:{...e},successful:!0,output:{token:p,expiresIn:f-d,publicKeyFingerprint:c}}}catch(t){return buildStepErrorOutput(t,e)}},ke=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([`data`,`headers`]).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()}),Ae=(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(),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}=ke.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:K.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:je(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},je=__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`),Me=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:K.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()}),Ne=(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}=Me.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:K.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:Pe(p?.dataKey?k.data[p?.dataKey]:k.data,p),raw:k,statusCode:k?.status,message:k?.message}}},Pe=__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`),Fe=o.z.object({values:o.z.string().or(o.z.record(o.z.string(),o.z.unknown())).or(o.z.array(o.z.unknown()))}),Ie=o.z.object({data:o.z.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Fe.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,Le=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(()=>Le).array().optional(),requiredScopes:o.z.string().array().optional()}),$=o.z.object({fields:Le.array().optional(),dataSource:o.z.string()}),Re=o.z.object({data:o.z.unknown()});let ze=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`string`:return(0,o.safeParseToString)({value:e});case`number`:return(0,o.safeParseToNumber)({value:e});case`boolean`:return(0,o.safeParseToBoolean)({value:e});case`datetime_string`:return(0,o.safeParseToDateTimeString)({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(ze).includes(e),Be=__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=>Ve(e,t)):Ve(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),Ve=__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}=$.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}},He=(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)`)}),Ue=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:K.optional(),binaryContent:He.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)`)}),We=(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}=Ue.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:K.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:Ge(f?.dataKey?E.data[f?.dataKey]:E.data,f),raw:E,statusCode:E?.status,message:E?.message}}},Ge=__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`),Ke=(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")`)}),qe=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:K.optional(),file:Ke.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)`)}),Je=(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:d,url:f,method:p,response:m,authorization:h,file:_,additionalFields:v,args:y,customErrors:b}=qe.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)(h)?h:K.parse(x)),w=new g.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:`${d??``}${f}`,method:p,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(m?.dataKey?j.data[m?.dataKey]:j.data,m),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 Ye=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.SIGN_JWT=`sign_jwt`,e}({});const Xe={typecast:{v1:{fn:Be},v2:{fn:typecastStepFunction,inputSchema:$,outputSchema:Re}},map_fields:{v1:{fn:re},v2:{fn:mapFieldsStepFunction,inputSchema:se,outputSchema:ce}},request:{v1:{fn:requestStepFunction,inputSchema:ve,outputSchema:ye}},group_data:{v1:{fn:groupDataStepFunction,inputSchema:te,outputSchema:ne}},paginated_request:{v1:{fn:paginatedRequestStepFunction,inputSchema:de,outputSchema:fe}},soap_request:{v1:{fn:soapRequestStepFunction,inputSchema:Me,outputSchema:Ne}},soap_paginated_request:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:ke,outputSchema:Ae}},static_values:{v1:{fn:staticValuesStepFunction,inputSchema:Fe,outputSchema:Ie}},upload_file:{v1:{fn:uploadFileStepFunction,inputSchema:qe,outputSchema:Je}},upload_binary:{v1:{fn:uploadBinaryStepFunction,inputSchema:Ue,outputSchema:We}},download_file:{v1:{fn:downloadFileStepFunction,inputSchema:J,outputSchema:Y}},emit_event:{v1:{fn:emitEventStepFunction,inputSchema:X,outputSchema:ee}},browser_use:{v1:{fn:browserUseStepFunction,inputSchema:N,outputSchema:P}},code_execution_lambda:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:F,outputSchema:I}},sign_jwt:{v1:{fn:signJwtStepFunction,inputSchema:Se,outputSchema:Ce}}},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},Ze={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Xe}){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=K,exports.AuthType=M,exports.BROWSER_USE_INPUT_PARAMS=N,exports.BROWSER_USE_OUTPUT=P,exports.COMPOSITE_ID_LATEST_VERSION=1,exports.ChangelogLabels=T,exports.CoreError=S,exports.ExecutionModes=E,exports.INPUT_ENUM_REGISTRY=C,exports.ReleaseStages=w,exports.SourceType=k,exports.StepFunctionName=Ye,exports.StepFunctionsFactory=Ze,exports.StepFunctionsRegistry=Xe,exports.StreamType=j,exports.TransportType=A,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.stripIncrementalParams=stripIncrementalParams,exports.stripPaginationParams=stripPaginationParams,exports.updateCursor=updateCursor;
package/dist/index.d.cts CHANGED
@@ -2941,6 +2941,14 @@ type Assets = {
2941
2941
  icon: string;
2942
2942
  };
2943
2943
  type ActionType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom' | 'refresh_token' | 'test' | 'event' | 'unknown';
2944
+ type Effect = 'read' | 'write' | 'delete' | 'search' | 'execute';
2945
+ type ActionAnnotations = {
2946
+ title?: string;
2947
+ readOnlyHint?: boolean;
2948
+ destructiveHint?: boolean;
2949
+ idempotentHint?: boolean;
2950
+ openWorldHint?: boolean;
2951
+ };
2944
2952
  type InputLocation = 'body' | 'query' | 'path' | 'headers';
2945
2953
  type EnumOneOf = {
2946
2954
  values: string[];
@@ -3019,6 +3027,8 @@ type Action = {
3019
3027
  endpoint?: string;
3020
3028
  resources?: string;
3021
3029
  actionType: ActionType;
3030
+ effects?: Effect[];
3031
+ annotations?: ActionAnnotations;
3022
3032
  executionMode?: ExecutionMode;
3023
3033
  tags?: string[];
3024
3034
  releaseStage?: ReleaseStage;
@@ -3230,6 +3240,7 @@ declare const SourceType: {
3230
3240
  readonly Scheduler: "SCHEDULER";
3231
3241
  readonly Webhook: "WEBHOOK";
3232
3242
  readonly Agent: "AGENT";
3243
+ readonly MCP: "MCP";
3233
3244
  readonly Application: "APPLICATION";
3234
3245
  readonly DataSync: "DATA_SYNC";
3235
3246
  readonly DataSyncV2: "DATA_SYNC_V2";
@@ -3632,4 +3643,4 @@ type Account = {
3632
3643
  originOwnerName?: string;
3633
3644
  };
3634
3645
  //#endregion
3635
- 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 BaseIncrementalConfig, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type Changelog, type ChangelogLabel, ChangelogLabels, type Checkpoint, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DeltaTokenIncrementalConfig, 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 IncrementalConfig, type Input, type InputFormat, type InputLocation, type InputRules, type InputType, type InputVariant, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type OnConditionError, 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, type TimeFilterIncrementalConfig, 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, stripIncrementalParams, stripPaginationParams, updateCursor };
3646
+ export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionAnnotations, 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 BaseIncrementalConfig, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type Changelog, type ChangelogLabel, ChangelogLabels, type Checkpoint, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DeltaTokenIncrementalConfig, type DocumentationReference, type Effect, 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 IncrementalConfig, type Input, type InputFormat, type InputLocation, type InputRules, type InputType, type InputVariant, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type OnConditionError, 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, type TimeFilterIncrementalConfig, 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, stripIncrementalParams, stripPaginationParams, updateCursor };
package/dist/index.d.mts CHANGED
@@ -2940,6 +2940,14 @@ type Assets = {
2940
2940
  icon: string;
2941
2941
  };
2942
2942
  type ActionType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom' | 'refresh_token' | 'test' | 'event' | 'unknown';
2943
+ type Effect = 'read' | 'write' | 'delete' | 'search' | 'execute';
2944
+ type ActionAnnotations = {
2945
+ title?: string;
2946
+ readOnlyHint?: boolean;
2947
+ destructiveHint?: boolean;
2948
+ idempotentHint?: boolean;
2949
+ openWorldHint?: boolean;
2950
+ };
2943
2951
  type InputLocation = 'body' | 'query' | 'path' | 'headers';
2944
2952
  type EnumOneOf = {
2945
2953
  values: string[];
@@ -3018,6 +3026,8 @@ type Action = {
3018
3026
  endpoint?: string;
3019
3027
  resources?: string;
3020
3028
  actionType: ActionType;
3029
+ effects?: Effect[];
3030
+ annotations?: ActionAnnotations;
3021
3031
  executionMode?: ExecutionMode;
3022
3032
  tags?: string[];
3023
3033
  releaseStage?: ReleaseStage;
@@ -3229,6 +3239,7 @@ declare const SourceType: {
3229
3239
  readonly Scheduler: "SCHEDULER";
3230
3240
  readonly Webhook: "WEBHOOK";
3231
3241
  readonly Agent: "AGENT";
3242
+ readonly MCP: "MCP";
3232
3243
  readonly Application: "APPLICATION";
3233
3244
  readonly DataSync: "DATA_SYNC";
3234
3245
  readonly DataSyncV2: "DATA_SYNC_V2";
@@ -3631,4 +3642,4 @@ type Account = {
3631
3642
  originOwnerName?: string;
3632
3643
  };
3633
3644
  //#endregion
3634
- 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 BaseIncrementalConfig, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type Changelog, type ChangelogLabel, ChangelogLabels, type Checkpoint, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DeltaTokenIncrementalConfig, 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 IncrementalConfig, type Input, type InputFormat, type InputLocation, type InputRules, type InputType, type InputVariant, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type OnConditionError, 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, type TimeFilterIncrementalConfig, 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, stripIncrementalParams, stripPaginationParams, updateCursor };
3645
+ export { AUTHORIZATION_SCHEMA, type Account, type Action, type ActionAnnotations, 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 BaseIncrementalConfig, type BasePaginationConfig, type Block, type BlockContext, type BlockIndexedRecord, COMPOSITE_ID_LATEST_VERSION, type Category, type Changelog, type ChangelogLabel, ChangelogLabels, type Checkpoint, type CompositeIdentifier, type CompositeIdentifierConfig, type CompositeIdentifierConnectorConfig, type Connector, type ConnectorDocumentation, type ConnectorEvents, CoreError, type Cursor, type CursorPaginationConfig, type DataSyncConfig, type DefenderMetadata, type DefenderSettings, type DeltaTokenIncrementalConfig, type DocumentationReference, type Effect, 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 IncrementalConfig, type Input, type InputFormat, type InputLocation, type InputRules, type InputType, type InputVariant, type IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type OnConditionError, 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, type TimeFilterIncrementalConfig, 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, stripIncrementalParams, stripPaginationParams, updateCursor };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{t as e}from"./chunk-BhWHdk3m.mjs";import{decodeFromBase64 as t,encodeToBase64 as n,getContentHash as r,getCountryAlpha2CodeByAlpha2Code as i,getCountryAlpha2CodeByAlpha3Code as a,getCountryAlpha2CodeByCitizenship as o,getCountryAlpha2CodeByCountryCode as s,getCountryAlpha2CodeByCountryName as c,getCountryAlpha3CodeByAlpha2Code as l,getCountryAlpha3CodeByAlpha3Code as u,getCountryAlpha3CodeByCountryCode as d,getCountryAlpha3CodeByCountryName as f,getCountryCodeByAlpha2Code as p,getCountryCodeByAlpha3Code as m,getCountryCodeByCountryCode as h,getCountryCodeByCountryName as g,getCountryNameByAlpha2Code as _,getCountryNameByAlpha3Code as v,getCountryNameByCountryCode as y,getCountryNameByCountryName as b,getCountrySubDivisionCodeBySubDivisionName as x,getCountrySubDivisionNameBySubDivisionCode as S,getCountrySubDivisionsByAlpha2Code as C,getDocumentFileFormatFromExtension as w,isMissing as T,isObject as E,isString as D,notMissing as O,safeParseToBoolean as k,safeParseToDateTimeString as ee,safeParseToNumber as A,safeParseToString as j,z as M,zStrictObject as N}from"@stackone/utils";import{evaluate as P,isExpression as F,isValidExpression as I,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 te,RequestParameterLocations as U,buildHttpsAgent as ne,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 re}from"@aws-sdk/client-lambda";import{Readable as ie}from"node:stream";import Z from"mime-types";import{Saml20 as ae}from"saml";import{v4 as oe}from"uuid";import{createHash as se,createPrivateKey as ce,createPublicKey as le}from"node:crypto";import{SignJWT as ue}from"jose";import de from"form-data";const fe=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=fe.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},pe={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=>pe[e.toLowerCase()]??null,isValidCategory=e=>!!pe[e.toLowerCase()],me=n(`so1!`),he=RegExp(`(?<!\\\\):`,`g`),ge=RegExp(`(?<!\\\\),`,`g`),_e=1;var ve=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 ve{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=>!T(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!T(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(ge).forEach(e=>{let[n,i]=e.split(he),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=>`${me}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(me))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(me)[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=>T(e)?!1:e.startsWith(me),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(T(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=L(`{{${n.result.trim()}}}`,t);if(!T(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(!T(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}}}},ye={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=>ye[e],isValidEnumRef=e=>e in ye,be=[`preview`,`beta`,`ga`,`deprecated`,`internal`],xe=[`auth`,`downstream-change`,`bug-fix`,`new-actions`],Se=[`sync`,`async`],Ce=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()}),we=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(D(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(Ce.parse(r))}else return we.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,i=typeof t==`string`?expandCursor(t):t;if(n===null||i===null)return n===i;let{timestamp:a,...o}=n,{timestamp:s,...c}=i;return r(o)===r(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>T(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return(T(t)||r!==t.toString())&&(n=n&&T(i.pageNumber)&&T(i.position)&&T(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=T(n)&&T(r)&&T(i);return T(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 ve;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}function stripIncrementalParams(e,t){if(!t)return e;let{key:n,in:r}=t.iterator,i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};return delete a[n],{...e,[r]:a}}const Te={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Discode:`DISCODE`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,API:`API`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,Application:`APPLICATION`,DataSync:`DATA_SYNC`,DataSyncV2:`DATA_SYNC_V2`,Internal:`INTERNAL`},Ee={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},De={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},Oe={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`)},ke=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(),allowedDomains:M.array(M.string().min(1)).optional()}).optional()}),Ae=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},isSerializedBuffer=e=>typeof e==`object`&&!!e&&e.type===`Buffer`&&Array.isArray(e.data),decodeBinaryBody=e=>{let t;if(Buffer.isBuffer(e)?t=e.toString(`utf8`):e instanceof ArrayBuffer?t=new TextDecoder().decode(new Uint8Array(e)):ArrayBuffer.isView(e)?t=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):isSerializedBuffer(e)&&(t=Buffer.from(e.data).toString(`utf8`)),t===void 0)return e;try{return JSON.parse(t)}catch{return t}},decodeResponseBody=e=>({...e,data:decodeBinaryBody(e.data)}),isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractTopLevelMessage=e=>{if(typeof e.message==`string`&&e.message.trim().length>0)return e.message},extractNestedErrorMessage=e=>{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`&&e.error.length>0)return e.error;if(typeof e.error_description==`string`&&e.error_description.length>0)return e.error_description},extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractTopLevelMessage(n);if(e!=null)return e}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractNestedErrorMessage(n);if(e!=null)return e}if(Array.isArray(n)&&n.length>0){let e=n[0];if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=extractTopLevelMessage(t)??extractNestedErrorMessage(t);if(n!=null)return n}}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof V){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[J(e)],output:{statusCode:r?.status??500,message:extractErrorMessage(r,n),data:r?.data,raw:sanitizeRaw(r)}}}if(isHttpLikeError(e)){let n=decodeResponseBody(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 re(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}},je=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()}),Me=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),executedVersion:M.string().optional()}).optional(),Ne=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>F(e)||Ne.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>F(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,Pe=e((e,t)=>{if(T(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`||L(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!Ne.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=je.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?Pe(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Fe=N({strategy:M.literal(`aws4`),service:M.string(),region:M.string().optional()}),Ie=N({strategy:M.literal(`hmac`),algorithm:M.enum([`sha1`,`sha256`,`sha512`]).optional(),headerName:M.string().optional(),prefix:M.string().optional(),dateFormat:M.enum([`iso8601`,`rfc2822`]).optional(),includeHost:M.boolean().optional(),includeBodyHash:M.boolean().optional(),outputFormat:M.enum([`header`,`basic`]).optional(),username:M.string().optional()}),Le=M.discriminatedUnion(`strategy`,[Fe,Ie]),Re=N({type:M.literal(`none`),signing:Le.optional()}),ze=N({type:M.literal(`basic`),username:M.string().optional(),password:M.string().optional(),encoding:M.string().optional()}),Be=N({type:M.literal(`bearer`),token:M.string(),includeBearer:M.boolean().optional().default(!0)}),Ve=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(),tokenResponse:N({acceptTokenTypes:M.array(M.string()).optional(),accessToken:M.string().min(1).optional(),refreshToken:M.string().min(1).optional()}).optional()}),Q=M.discriminatedUnion(`type`,[Re,ze,Be,Ve]),He=N({certs:M.string().array().optional(),keys:M.string().array().optional()}).optional(),Ue=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B).optional().default(`get`),authorization:Q.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(),contentType: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:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),We=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.union([M.string(),M.array(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?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}=Ue.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?q(u):{query:{},body:{},headers:{}},y=W(O(l)?l:Q.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,response:m,responseType:f,authHeaders:y});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,response:d,responseType:f,authHeaders:p}=e,m=`${r}${i}`;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.`);if(O(d?.dataKey)||O(d?.urlKey))try{let e=await performDownload({httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,responseType:f??`arraybuffer`,encoding:`none`,response:d,maxRedirects:l,requestConfig:u,authHeaders:p??{}}),m=Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data),h={...e.fileMetadata,contentLength:m.length};return{block:t,successful:!0,streamOutput:{stream:ie.from(m),headers:O(h.contentType)?{"content-type":h.contentType}:{},contentDisposition:e.contentDisposition,fileMetadata:h}}}catch(e){return buildStepErrorOutput(e,t)}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:m,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)}T(u.contentType)&&O(r.contentType)&&(u.contentType=r.contentType);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(T(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)}T(a.contentType)&&O(r.contentType)&&(a.contentType=r.contentType);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(T(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`);default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=D(e[`content-type`])?e[`content-type`]:void 0,n=D(e[`content-length`])?e[`content-length`]:void 0,r=D(e[`content-disposition`])?e[`content-disposition`]:void 0,i=D(e[`last-modified`])?e[`last-modified`]:void 0,a=D(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 Z.extension(t)||void 0},Ge=M.object({event:M.object({eventType:M.string(),eventId:M.coerce.string().optional(),eventDate:M.coerce.string().optional(),data:M.unknown().optional()}).optional()}),Ke=M.record(M.string(),M.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?R(t,e):{},{event:r}=Ge.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventId:r.eventId,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}},qe=M.object({stepsDataToGroup:M.array(M.string()),isSingleRecord:M.boolean().optional()}),Je=M.object({data:M.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=qe.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]={...O(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},Ye=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=Xe(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Xe(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},{}),Xe=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}=Ze(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`),Ze=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 i;case`country_alpha3code_by_alpha3code`:return u;case`country_code_by_country_code`:return h;case`country_name_by_country_name`:return b;case`country_name_by_alpha3code`:return v;case`country_name_by_alpha2code`:return _;case`country_name_by_country_code`:return y;case`country_alpha3code_by_alpha2code`:return l;case`country_alpha3code_by_country_name`:return f;case`country_alpha3code_by_country_code`:return d;case`country_alpha2code_by_alpha3code`:return a;case`country_alpha2code_by_country_name`:return c;case`country_alpha2code_by_country_code`:return s;case`country_code_by_alpha2code`:return p;case`country_code_by_alpha3code`:return m;case`country_code_by_country_name`:return g;case`country_subdivisions_by_alpha2code`:return C;case`country_subdivision_code_by_subdivision_name`:return x;case`country_alpha2code_by_citizenship`:return o;case`country_subdivision_name_by_subdivision_code`:return S;case`document_file_format_from_extension`:return w;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()}),$e=M.object({fields:Qe.array(),dataSource:M.string(),externalSources:M.record(M.string(),M.string()).optional()}),et=M.object({data:M.unknown()}),mergeSourceWithState=(e,t)=>E(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=$e.parse(t),o=buildExpressionContext(e,{includeCredentials:!0}),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=$(r,{...e,external:c},o);return n.push(...t?.errors||[]),t?.record});else{let e=$(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=$(e.properties,a,r);return O(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=$(e.properties,t,i);return O(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=$(e.properties,t,i);return O(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=O(e.values)?e.values:t,a=$(e.properties,i,r);return O(a?.errors)&&n.push(...a.errors),a?.record},tt=e((e,t,n,r,i)=>{if(!T(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`),$=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=tt(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(I(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 nt(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},nt=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=nt(e,t,n),i=O(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(D(a)){let n=getEnumMatcher(a);return O(n)?{value:{value:(O(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}}},generateSamlAssertion=async({cert:e,key:t,issuer:n,lifetime:r,clientId:i,nameId:a,tokenEndpoint:o,audience:s,nameIdentifierFormat:c,createSamlFn:l=e=>ae.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let d={api_key:i},f={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:d,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+oe()},p=Buffer.from(l(f)).toString(`base64`);return await u(1e3),p},generatePrivateKey=e=>{let t=Buffer.from(e,`base64`).toString(`utf-8`).split(`###`);if(t.length!==2)throw Error(`Invalid private key`);let n=t[0];return Buffer.from(`-----BEGIN PRIVATE KEY-----
1
+ import{t as e}from"./chunk-BhWHdk3m.mjs";import{decodeFromBase64 as t,encodeToBase64 as n,getContentHash as r,getCountryAlpha2CodeByAlpha2Code as i,getCountryAlpha2CodeByAlpha3Code as a,getCountryAlpha2CodeByCitizenship as o,getCountryAlpha2CodeByCountryCode as s,getCountryAlpha2CodeByCountryName as c,getCountryAlpha3CodeByAlpha2Code as l,getCountryAlpha3CodeByAlpha3Code as u,getCountryAlpha3CodeByCountryCode as d,getCountryAlpha3CodeByCountryName as f,getCountryCodeByAlpha2Code as p,getCountryCodeByAlpha3Code as m,getCountryCodeByCountryCode as h,getCountryCodeByCountryName as g,getCountryNameByAlpha2Code as _,getCountryNameByAlpha3Code as v,getCountryNameByCountryCode as y,getCountryNameByCountryName as b,getCountrySubDivisionCodeBySubDivisionName as x,getCountrySubDivisionNameBySubDivisionCode as S,getCountrySubDivisionsByAlpha2Code as C,getDocumentFileFormatFromExtension as w,isMissing as T,isObject as E,isString as D,notMissing as O,safeParseToBoolean as k,safeParseToDateTimeString as ee,safeParseToNumber as A,safeParseToString as j,z as M,zStrictObject as N}from"@stackone/utils";import{evaluate as P,isExpression as F,isValidExpression as I,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 te,RequestParameterLocations as U,buildHttpsAgent as ne,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 re}from"@aws-sdk/client-lambda";import{Readable as ie}from"node:stream";import Z from"mime-types";import{Saml20 as ae}from"saml";import{v4 as oe}from"uuid";import{createHash as se,createPrivateKey as ce,createPublicKey as le}from"node:crypto";import{SignJWT as ue}from"jose";import de from"form-data";const fe=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=fe.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},pe={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=>pe[e.toLowerCase()]??null,isValidCategory=e=>!!pe[e.toLowerCase()],me=n(`so1!`),he=RegExp(`(?<!\\\\):`,`g`),ge=RegExp(`(?<!\\\\),`,`g`),_e=1;var ve=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 ve{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=>!T(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!T(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(ge).forEach(e=>{let[n,i]=e.split(he),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=>`${me}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(me))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(me)[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=>T(e)?!1:e.startsWith(me),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(T(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=L(`{{${n.result.trim()}}}`,t);if(!T(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(!T(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}}}},ye={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=>ye[e],isValidEnumRef=e=>e in ye,be=[`preview`,`beta`,`ga`,`deprecated`,`internal`],xe=[`auth`,`downstream-change`,`bug-fix`,`new-actions`],Se=[`sync`,`async`],Ce=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()}),we=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(D(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(Ce.parse(r))}else return we.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,i=typeof t==`string`?expandCursor(t):t;if(n===null||i===null)return n===i;let{timestamp:a,...o}=n,{timestamp:s,...c}=i;return r(o)===r(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>T(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return(T(t)||r!==t.toString())&&(n=n&&T(i.pageNumber)&&T(i.position)&&T(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=T(n)&&T(r)&&T(i);return T(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 ve;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}function stripIncrementalParams(e,t){if(!t)return e;let{key:n,in:r}=t.iterator,i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};return delete a[n],{...e,[r]:a}}const Te={RequestTester:`REQUEST_TESTER`,ActionTester:`ACTION_TESTER`,Discode:`DISCODE`,Dashboard:`DASHBOARD`,Playground:`PLAYGROUND`,SDK:`SDK`,API:`API`,Scheduler:`SCHEDULER`,Webhook:`WEBHOOK`,Agent:`AGENT`,MCP:`MCP`,Application:`APPLICATION`,DataSync:`DATA_SYNC`,DataSyncV2:`DATA_SYNC_V2`,Internal:`INTERNAL`},Ee={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},De={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},Oe={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`)},ke=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(),allowedDomains:M.array(M.string().min(1)).optional()}).optional()}),Ae=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},isSerializedBuffer=e=>typeof e==`object`&&!!e&&e.type===`Buffer`&&Array.isArray(e.data),decodeBinaryBody=e=>{let t;if(Buffer.isBuffer(e)?t=e.toString(`utf8`):e instanceof ArrayBuffer?t=new TextDecoder().decode(new Uint8Array(e)):ArrayBuffer.isView(e)?t=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):isSerializedBuffer(e)&&(t=Buffer.from(e.data).toString(`utf8`)),t===void 0)return e;try{return JSON.parse(t)}catch{return t}},decodeResponseBody=e=>({...e,data:decodeBinaryBody(e.data)}),isHttpLikeError=e=>typeof e==`object`&&!!e&&`response`in e&&e.response!=null&&typeof e.response==`object`,extractTopLevelMessage=e=>{if(typeof e.message==`string`&&e.message.trim().length>0)return e.message},extractNestedErrorMessage=e=>{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`&&e.error.length>0)return e.error;if(typeof e.error_description==`string`&&e.error_description.length>0)return e.error_description},extractErrorMessage=(e,t)=>{let n=e.data;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractTopLevelMessage(n);if(e!=null)return e}if(typeof e.message==`string`&&e.message.length>0)return e.message;if(typeof n==`object`&&n&&!Array.isArray(n)){let e=extractNestedErrorMessage(n);if(e!=null)return e}if(Array.isArray(n)&&n.length>0){let e=n[0];if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=extractTopLevelMessage(t)??extractNestedErrorMessage(t);if(n!=null)return n}}return typeof n==`string`&&n.length>0?n:t},buildStepErrorOutput=(e,t)=>{if(e instanceof V){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[J(e)],output:{statusCode:r?.status??500,message:extractErrorMessage(r,n),data:r?.data,raw:sanitizeRaw(r)}}}if(isHttpLikeError(e)){let n=decodeResponseBody(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 re(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}},je=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()}),Me=N({data:M.unknown().optional(),raw:M.unknown().optional(),statusCode:M.number(),message:M.string().optional(),executedVersion:M.string().optional()}).optional(),Ne=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>F(e)||Ne.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>F(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,Pe=e((e,t)=>{if(T(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`||L(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!Ne.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=je.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?Pe(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Fe=N({strategy:M.literal(`aws4`),service:M.string(),region:M.string().optional()}),Ie=N({strategy:M.literal(`hmac`),algorithm:M.enum([`sha1`,`sha256`,`sha512`]).optional(),headerName:M.string().optional(),prefix:M.string().optional(),dateFormat:M.enum([`iso8601`,`rfc2822`]).optional(),includeHost:M.boolean().optional(),includeBodyHash:M.boolean().optional(),outputFormat:M.enum([`header`,`basic`]).optional(),username:M.string().optional()}),Le=M.discriminatedUnion(`strategy`,[Fe,Ie]),Re=N({type:M.literal(`none`),signing:Le.optional()}),ze=N({type:M.literal(`basic`),username:M.string().optional(),password:M.string().optional(),encoding:M.string().optional()}),Be=N({type:M.literal(`bearer`),token:M.string(),includeBearer:M.boolean().optional().default(!0)}),Ve=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(),tokenResponse:N({acceptTokenTypes:M.array(M.string()).optional(),accessToken:M.string().min(1).optional(),refreshToken:M.string().min(1).optional()}).optional()}),Q=M.discriminatedUnion(`type`,[Re,ze,Be,Ve]),He=N({certs:M.string().array().optional(),keys:M.string().array().optional()}).optional(),Ue=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B).optional().default(`get`),authorization:Q.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(),contentType: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:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),We=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.union([M.string(),M.array(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?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}=Ue.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?q(u):{query:{},body:{},headers:{}},y=W(O(l)?l:Q.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,response:m,responseType:f,authHeaders:y});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,response:d,responseType:f,authHeaders:p}=e,m=`${r}${i}`;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.`);if(O(d?.dataKey)||O(d?.urlKey))try{let e=await performDownload({httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,responseType:f??`arraybuffer`,encoding:`none`,response:d,maxRedirects:l,requestConfig:u,authHeaders:p??{}}),m=Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data),h={...e.fileMetadata,contentLength:m.length};return{block:t,successful:!0,streamOutput:{stream:ie.from(m),headers:O(h.contentType)?{"content-type":h.contentType}:{},contentDisposition:e.contentDisposition,fileMetadata:h}}}catch(e){return buildStepErrorOutput(e,t)}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:m,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)}T(u.contentType)&&O(r.contentType)&&(u.contentType=r.contentType);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(T(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)}T(a.contentType)&&O(r.contentType)&&(a.contentType=r.contentType);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(T(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`);default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=D(e[`content-type`])?e[`content-type`]:void 0,n=D(e[`content-length`])?e[`content-length`]:void 0,r=D(e[`content-disposition`])?e[`content-disposition`]:void 0,i=D(e[`last-modified`])?e[`last-modified`]:void 0,a=D(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 Z.extension(t)||void 0},Ge=M.object({event:M.object({eventType:M.string(),eventId:M.coerce.string().optional(),eventDate:M.coerce.string().optional(),data:M.unknown().optional()}).optional()}),Ke=M.record(M.string(),M.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?R(t,e):{},{event:r}=Ge.parse(n);if(r&&e.emitEvent)try{await e.emitEvent({eventType:r.eventType,eventId:r.eventId,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}},qe=M.object({stepsDataToGroup:M.array(M.string()),isSingleRecord:M.boolean().optional()}),Je=M.object({data:M.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=qe.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]={...O(t[e])?t[e]:{},[n]:{...i[e]}}}),t):t},{});return{block:{...e},successful:!0,output:{data:r?i:Object.values(i)}}},Ye=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=Xe(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Xe(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},{}),Xe=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}=Ze(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`),Ze=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 i;case`country_alpha3code_by_alpha3code`:return u;case`country_code_by_country_code`:return h;case`country_name_by_country_name`:return b;case`country_name_by_alpha3code`:return v;case`country_name_by_alpha2code`:return _;case`country_name_by_country_code`:return y;case`country_alpha3code_by_alpha2code`:return l;case`country_alpha3code_by_country_name`:return f;case`country_alpha3code_by_country_code`:return d;case`country_alpha2code_by_alpha3code`:return a;case`country_alpha2code_by_country_name`:return c;case`country_alpha2code_by_country_code`:return s;case`country_code_by_alpha2code`:return p;case`country_code_by_alpha3code`:return m;case`country_code_by_country_name`:return g;case`country_subdivisions_by_alpha2code`:return C;case`country_subdivision_code_by_subdivision_name`:return x;case`country_alpha2code_by_citizenship`:return o;case`country_subdivision_name_by_subdivision_code`:return S;case`document_file_format_from_extension`:return w;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()}),$e=M.object({fields:Qe.array(),dataSource:M.string(),externalSources:M.record(M.string(),M.string()).optional()}),et=M.object({data:M.unknown()}),mergeSourceWithState=(e,t)=>E(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=$e.parse(t),o=buildExpressionContext(e,{includeCredentials:!0}),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=$(r,{...e,external:c},o);return n.push(...t?.errors||[]),t?.record});else{let e=$(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=$(e.properties,a,r);return O(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=$(e.properties,t,i);return O(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=$(e.properties,t,i);return O(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=O(e.values)?e.values:t,a=$(e.properties,i,r);return O(a?.errors)&&n.push(...a.errors),a?.record},tt=e((e,t,n,r,i)=>{if(!T(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`),$=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=tt(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(I(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 nt(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},nt=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=nt(e,t,n),i=O(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(D(a)){let n=getEnumMatcher(a);return O(n)?{value:{value:(O(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}}},generateSamlAssertion=async({cert:e,key:t,issuer:n,lifetime:r,clientId:i,nameId:a,tokenEndpoint:o,audience:s,nameIdentifierFormat:c,createSamlFn:l=e=>ae.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let d={api_key:i},f={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:d,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+oe()},p=Buffer.from(l(f)).toString(`base64`);return await u(1e3),p},generatePrivateKey=e=>{let t=Buffer.from(e,`base64`).toString(`utf-8`).split(`###`);if(t.length!==2)throw Error(`Invalid private key`);let n=t[0];return Buffer.from(`-----BEGIN PRIVATE KEY-----
2
2
  ${n}
3
3
  -----END PRIVATE KEY-----`)},rt=M.object({baseUrl:M.string(),url:M.string(),method:M.enum(B),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(U),condition:M.string().optional(),mode:M.enum([`cursor`,`offset`]).optional()}),cursor:N({token:M.string().optional().nullable(),position:M.number().optional().nullable()}).optional(),customErrors:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),it=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(),at=e(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=te.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,o=r?r.filter(t=>!t.condition||P(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,s=t?R({...t,args:o},e):{},c=t?.response?.nextKey,l=c&&at(c),u=t?.response?.dataKey,d=u&&at(u),f={...s?.response??{},...l?{nextKey:c}:{},...d?{dataKey:u}:{}},p={...s,customErrors:t?.customErrors,iterator:{...s?.iterator??{},condition:t?.iterator?.condition},response:l||d?f:s?.response},{baseUrl:m,url:h,method:g,response:_,iterator:v,cursor:y,customErrors:b,args:x,saml:S}=rt.parse(p),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment],w=C?.authorization,D=C?.certificates,k=D?ne(D):void 0,ee=Q.parse(w),A=x?q(x):{query:{},body:{},headers:{}},j=W(ee),M={...A?.headers??{},...j},N=e.connector?.rateLimit,F=e.connector?.concurrency,I=N!==void 0||F!==void 0?{rateLimit:N,concurrency:F}:void 0,z=O(S)?{[S.objectKey]:await generateSamlAssertion({key:S.key,clientId:S.clientId,cert:S.cert,issuer:S.issuer,lifetime:S.lifetime,audience:S.audience,nameId:S.nameId,nameIdentifierFormat:S.nameIdentifierFormat,tokenEndpoint:S.tokenEndpoint})}:{},B=v.mode===`offset`,V=y?.token??null,H=null,U=null,G=[],K=[],J=[],Y=a,X=y?.position??0,re=!0,ie=!0,Z=!0;do{re?re=!1:B||(X=0),V===null?B&&(v.in===`query`?A.query[v.key]=X.toString():v.in===`body`&&(Array.isArray(A.body)||(A.body[v.key]=X))):v.in===`query`?E(V)?Object.entries(V).forEach(([e,t])=>{A.query[`${v.key}[${e}]`]=t?.toString()??``}):A.query[v.key]=V.toString():v.in===`body`&&(Array.isArray(A.body)||(A.body[v.key]=V));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${m}${h}`,queryParams:{...A?.query},method:g,headers:{...M},body:Array.isArray(A?.body)?A.body:{...A?.body,...z},customErrorConfigs:b,requestConfig:I,httpsAgent:k,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}H=V,K=_?.dataKey?ot(t.data,_.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=st({result:t,response:_}),Z=O(v.condition)?L(v.condition,t.data)===!0:!0;let i=X>=(K?.length??0),o=O(_?.nextKey);!B&&r.length===K.length&&Y===0&&(X=0,H=V),ie=B||!o?!Z||T(V)&&G.length<a:i&&(T(V)||!Z)}while((B||O(V))&&Z&&G.length<a&&K?.length>0);return{block:e,successful:!0,output:{data:ut(G,_),raw:J,statusCode:U,next:ie?void 0:H,position:ie?void 0:X}}},ot=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;let n=L(at(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),st=e(({result:e,response:t})=>{if(T(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?ct(e.headers,r):lt(e.data,r)},`resolveNextIterator`),ct=e((e,t)=>{if(T(e)||typeof e!=`object`)return null;if(at(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`),lt=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return null;let n=L(at(t)?t:`$.${t}`,e);return T(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),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(B),authorization:Q.optional(),certificates:He,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:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),ft=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=te.build();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?.response?.dataKey,o=a&&isJexlExpression(a),s=t?R({...t,args:i},e):{},c={...s,customErrors:t?.customErrors,response:o?{...s?.response??{},dataKey:a}:s?.response},{baseUrl:l,url:u,method:d,response:f,authorization:p,certificates:m,customErrors:h,args:g,saml:_}=dt.parse(c),v=s?.authentication?.[e.context.authenticationType]?.[e.context.environment],y=v?.authorization,b=m??v?.certificates,x=b?ne(b):void 0,S=g?q(g):{query:{},body:{},headers:{}},C=O(p)?p:Q.parse(y),w=W(C),T={...S?.headers??{},...w},E=e.connector?.rateLimit,D=e.connector?.concurrency,k=E!==void 0||D!==void 0?{rateLimit:E,concurrency:D}:void 0,ee=O(_)?{[_.objectKey]:await generateSamlAssertion({key:_.key,clientId:_.clientId,cert:_.cert,issuer:_.issuer,lifetime:_.lifetime,audience:_.audience,nameId:_.nameId,nameIdentifierFormat:_.nameIdentifierFormat,tokenEndpoint:_.tokenEndpoint})}:{},A=Array.isArray(S?.body)?S?.body:{...S?.body,...ee};if(C.type===`none`&&C.signing?.strategy){let t=C.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:d,url:`${l}${u}`,headers:T,query:S?.query??{},body:A},n,t);Object.assign(T,r)}catch(t){return buildStepErrorOutput(t,e)}}let j;try{j=await n.performRequest({httpClient:e.httpClient,url:`${l}${u}`,queryParams:S?.query,method:d,headers:T,body:A,customErrorConfigs:h,requestConfig:k,httpsAgent:x,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:pt(f?.dataKey?resolveDataKey(j.data,f.dataKey):j.data,f),raw:j,statusCode:j?.status,message:j?.message}}},resolveDataKey=(e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;let n=L(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},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.union([M.string(),M.number()]),ht=N({algorithm:M.literal(`RS256`),privateKey:M.string(),claims:M.record(M.string(),mt)}),gt=N({token:M.string(),expiresIn:M.number(),publicKeyFingerprint:M.string()}),computePublicKeyFingerprint=e=>{let t=e.export({format:`der`,type:`spki`});return`SHA256:${se(`sha256`).update(t).digest(`base64`)}`},_t=/^now$/,vt=/^now\+(?<amount>\d+)(?<unit>[smh])$/,yt=`{publicKeyFingerprint}`,bt={s:1,m:60,h:3600},xt=new Set([`iat`,`exp`,`nbf`]),resolveClaimValue=(e,t,{now:n,publicKeyFingerprint:r})=>{if(typeof t==`number`)return t;let i=t.includes(yt)?t.split(yt).join(r):t;if(!xt.has(e))return i;if(_t.test(i))return n;let a=i.match(vt);return a?.groups?n+Number(a.groups.amount)*bt[a.groups.unit]:i},signJwtStepFunction=async({block:e,params:t})=>{try{let n=t?R(t,e):void 0,{algorithm:r,privateKey:i,claims:a}=ht.parse(n),o=ce(i),s=computePublicKeyFingerprint(le(o)),c=Math.floor(Date.now()/1e3),l={};for(let[e,t]of Object.entries(a))l[e]=resolveClaimValue(e,t,{now:c,publicKeyFingerprint:s});let{iat:u,exp:d}=l;if(typeof u!=`number`||typeof d!=`number`)throw Error(`signJwt requires numeric 'iat' and 'exp' claims (use 'now' / 'now+<N>s|m|h' tokens, or pass numbers directly)`);if(d<=u)throw Error(`signJwt requires 'exp' to be greater than 'iat'`);let f=await new ue(l).setProtectedHeader({alg:r}).sign(o);return{block:{...e},successful:!0,output:{token:f,expiresIn:d-u,publicKeyFingerprint:s}}}catch(t){return buildStepErrorOutput(t,e)}},St=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B),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(U)}),cursor:N({token:M.string().optional().nullable(),position:M.number().optional().nullable()}).optional(),customErrors:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),Ct=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=te.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?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}=St.parse(c),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,w=_?q(_):{query:{},body:{},headers:{}},E=W(O(h)?h:Q.parse(C)),D={...w?.headers??{},...E},k=e.connector?.rateLimit,ee=e.connector?.concurrency,A={...(k!==void 0||ee!==void 0)&&{rateLimit:k,concurrency:ee},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,F=[],I=[],L=[],z=a,B=m?.position??0,V=!0,H;do{V?V=!1:B=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:A,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(B,B+z);z-=r.length,B+=r.length,L.push(t),F=F.concat(r),N=t?.status,j=resolveNextIterator({result:t,response:f}),r.length===I.length&&z===0&&(B=0,M=j),H=T(j)&&F.length<a}while(O(j)&&F.length<a&&I?.length>0);return{block:e,successful:!0,output:{data:wt(F,f),raw:L,statusCode:N,next:H?void 0:M,position:H?void 0:B}}},resolveNextIterator=({result:e,response:t})=>{if(T(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(T(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(T(e)||typeof e!=`object`||!e)return null;let n=e[t];return T(n)?null:typeof n==`string`||typeof n==`number`?n:null},wt=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=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B),authorization:Q.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:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional()}),Et=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=te.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?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}=Tt.parse(o),y=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,b=p?q(p):{query:{},body:{},headers:{}},x=W(O(d)?d:Q.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:Dt(u?.dataKey?E.data[u?.dataKey]:E.data,u),raw:E,statusCode:E?.status,message:E?.message}}},Dt=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`),Ot=M.object({values:M.string().or(M.record(M.string(),M.unknown())).or(M.array(M.unknown()))}),kt=M.object({data:M.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Ot.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)=>D(e)?L(e,t):E(e)?R(e,t):e,At=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(()=>At).array().optional(),requiredScopes:M.string().array().optional()}),jt=M.object({fields:At.array().optional(),dataSource:M.string()}),Mt=M.object({data:M.unknown()});let Nt=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(T(e))return null;switch(t){case`string`:return j({value:e});case`number`:return A({value:e});case`boolean`:return k({value:e});case`datetime_string`:return ee({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(Nt).includes(e),Pt=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=>Ft(e,t)):Ft(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),Ft=e((e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i}=t;isFieldSupportedType(i)&&(!t.custom&&O(n[r])?n[r]=typecast({value:e[r],type:i}):n.unified_custom_fields&&O(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}=jt.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&&O(n[r])?n[r]=handleObjectField(t,e[r]):n.unified_custom_fields&&O(n.unified_custom_fields?.[r])&&(n.unified_custom_fields[r]=handleObjectField(t,e.unified_custom_fields?.[r])):isFieldSupportedType(i)&&(!t.custom&&O(n[r])?(!a||!Array.isArray(n[r]))&&(n[r]=typecast({value:e[r],type:i})):n.unified_custom_fields&&O(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}},It=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)`)}),Lt=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B).default(`post`),authorization:Q.optional(),binaryContent:It.describe(`Raw binary content for octet-stream uploads`),response:N({collection:M.boolean().optional(),indexField:M.string().optional(),dataKey:M.string().optional()}).optional(),customErrors:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Rt=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?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}=Lt.parse(a),m=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,h=f?q(f):{query:{},body:{},headers:{}},g=W(O(u)?u:Q.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:zt(l?.dataKey?C.data[l?.dataKey]:C.data,l),raw:C,statusCode:C?.status,message:C?.message}}},zt=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`),Bt=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")`)}),Vt=M.object({baseUrl:M.string().optional(),url:M.string(),method:M.enum(B).default(`post`),authorization:Q.optional(),file:Bt.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:z.array().optional(),args:N({name:M.string(),value:M.unknown(),in:M.enum(U),spread:M.boolean().optional(),condition:M.string().optional(),arrayFormat:M.enum(H).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Ht=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?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}=Vt.parse(s),_=o?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?q(h):{query:{},body:{},headers:{}},y=W(O(f)?f:Q.parse(_)),b=new de;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 Ut=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.SIGN_JWT=`sign_jwt`,e}({});const Wt={typecast:{v1:{fn:Pt},v2:{fn:typecastStepFunction,inputSchema:jt,outputSchema:Mt}},map_fields:{v1:{fn:Ye},v2:{fn:mapFieldsStepFunction,inputSchema:$e,outputSchema:et}},request:{v1:{fn:requestStepFunction,inputSchema:dt,outputSchema:ft}},group_data:{v1:{fn:groupDataStepFunction,inputSchema:qe,outputSchema:Je}},paginated_request:{v1:{fn:paginatedRequestStepFunction,inputSchema:rt,outputSchema:it}},soap_request:{v1:{fn:soapRequestStepFunction,inputSchema:Tt,outputSchema:Et}},soap_paginated_request:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:St,outputSchema:Ct}},static_values:{v1:{fn:staticValuesStepFunction,inputSchema:Ot,outputSchema:kt}},upload_file:{v1:{fn:uploadFileStepFunction,inputSchema:Vt,outputSchema:Ht}},upload_binary:{v1:{fn:uploadBinaryStepFunction,inputSchema:Lt,outputSchema:Rt}},download_file:{v1:{fn:downloadFileStepFunction,inputSchema:Ue,outputSchema:We}},emit_event:{v1:{fn:emitEventStepFunction,inputSchema:Ge,outputSchema:Ke}},browser_use:{v1:{fn:browserUseStepFunction,inputSchema:ke,outputSchema:Ae}},code_execution_lambda:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:je,outputSchema:Me}},sign_jwt:{v1:{fn:signJwtStepFunction,inputSchema:ht,outputSchema:gt}}},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},Gt={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Wt}){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{Q as AUTHORIZATION_SCHEMA,Oe as AuthType,ke as BROWSER_USE_INPUT_PARAMS,Ae as BROWSER_USE_OUTPUT,_e as COMPOSITE_ID_LATEST_VERSION,xe as ChangelogLabels,ve as CoreError,Se as ExecutionModes,ye as INPUT_ENUM_REGISTRY,be as ReleaseStages,Te as SourceType,Ut as StepFunctionName,Gt as StepFunctionsFactory,Wt as StepFunctionsRegistry,De as StreamType,Ee as TransportType,areCursorsEqual,buildExpressionContext,decodeCompositeId,encodeCompositeId,evaluateEventRouter,evaluateExternalAccountIdExtractor,expandCursor,getCategoryDetails,getInputEnumValues,getIteratorLocation,getPaginationKeys,isCompositeId,isCoreError,isCursorEmpty,isForeachStep,isValidCategory,isValidEnumRef,minifyCursor,stripIncrementalParams,stripPaginationParams,updateCursor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "3.11.0",
3
+ "version": "3.13.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",