@stackone/core 3.2.0 → 3.4.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("mime-types");u=__toESM(u);let d=require("saml"),f=require("uuid"),p=require("node:crypto"),m=require("jose"),h=require("form-data");h=__toESM(h);const g=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=g.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},_={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=>_[e.toLowerCase()]??null,isValidCategory=e=>!!_[e.toLowerCase()],v=(0,o.encodeToBase64)(`so1!`),y=RegExp(`(?<!\\\\):`,`g`),b=RegExp(`(?<!\\\\),`,`g`);var x=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends x{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!(0,o.isMissing)(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!(0,o.isMissing)(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(b).forEach(e=>{let[n,i]=e.split(y),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=>`${v}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(v))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(v)[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(v),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if((0,o.isMissing)(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=(0,s.safeEvaluate)(`{{${n.result.trim()}}}`,t);if(!(0,o.isMissing)(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!(0,o.isMissing)(n))for(let e of n.rules){let n=(0,s.safeEvaluate)(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,(0,s.safeEvaluate)(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},S={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>S[e],isValidEnumRef=e=>e in S,C=[`preview`,`beta`,`ga`,`deprecated`,`internal`],w=[`sync`,`async`],T=(0,o.zStrictObject)({r:o.z.record(o.z.string(),(0,o.zStrictObject)({n:o.z.number().optional().nullable(),c:o.z.string().optional().nullable(),p:o.z.number().optional().nullable()})),v:o.z.number(),t:o.z.number()}),E=(0,o.zStrictObject)({remote:o.z.record(o.z.string(),(0,o.zStrictObject)({pageNumber:o.z.number().optional(),providerPageCursor:o.z.string().optional(),position:o.z.number().optional()})),version:o.z.number(),timestamp:o.z.number()}),minifyCursor=e=>(0,o.encodeToBase64)(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if((0,o.isString)(e)){let t=(0,o.decodeFromBase64)(e),n=JSON.parse(t);return expandCursorObject(T.parse(n))}else return E.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:i,...a}=n,{timestamp:s,...c}=r;return(0,o.getContentHash)(a)===(0,o.getContentHash)(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>(0,o.isMissing)(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return((0,o.isMissing)(t)||r!==t.toString())&&(n=n&&(0,o.isMissing)(i.pageNumber)&&(0,o.isMissing)(i.position)&&(0,o.isMissing)(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},s=(0,o.isMissing)(n)&&(0,o.isMissing)(r)&&(0,o.isMissing)(i);return(0,o.isMissing)(e)?{remote:s?{}:{[t]:a},version:2,timestamp:Date.now()}:s?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof x;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}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 D={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`,Internal:`INTERNAL`},O={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},k={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},A={APIKey:`API_KEY`,SessionToken:`SESSION_TOKEN`,UserSession:`USER_SESSION`,Cookie:`COOKIE`,Webhook:`WEBHOOK`,Signature:`SIGNATURE`},browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},j=o.z.object({startUrl:o.z.string().url(),systemPrompt:o.z.string().optional(),viewport:(0,o.zStrictObject)({width:o.z.number().int().positive(),height:o.z.number().int().positive()}).optional(),locale:o.z.string().optional(),budgets:(0,o.zStrictObject)({maxDurationMs:o.z.number().int().positive(),maxSteps:o.z.number().int().positive()}),auth:(0,o.zStrictObject)({sensitiveKeys:o.z.array(o.z.string().min(1)).optional(),requiresSession:o.z.boolean().optional(),allowedDomains:o.z.array(o.z.string().min(1)).optional()}).optional()}),M=o.z.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},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}},N=(0,o.zStrictObject)({lambdaName:o.z.string(),region:o.z.string().optional(),endpoint:o.z.string().optional(),invocationType:o.z.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:o.z.string().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:o.z.string().optional()}),P=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),executedVersion:o.z.string().optional()}).optional(),F=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||F.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,I=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;try{let n=(0,s.evaluate)(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||(0,s.safeEvaluate)(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,c=typeof o==`string`&&!F.test(o),l=t?.qualifier,u=typeof l==`string`&&!hasExpressionMarker(l),d={...t?(0,s.safeEvaluateRecord)(i===void 0?t:{...t,args:a},e):{},...c?{dataKey:o}:{},...u?{qualifier:l}:{}},f;try{f=N.parse(d)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:p,region:m,endpoint:h,invocationType:g,qualifier:_,args:v,dataKey:y}=f,b;try{b=await n({lambdaName:p,payload:buildPayloadFromArgs(v),region:m,endpoint:h,invocationType:g,qualifier:_,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(b.functionError){let t=typeof b.payload==`object`&&b.payload!==null&&`errorMessage`in b.payload&&typeof b.payload.errorMessage==`string`?b.payload.errorMessage:`Lambda function error: ${b.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:b.functionError}],output:{statusCode:b.statusCode,message:t,data:b.payload,raw:b}}}return{block:e,successful:!0,output:{data:y?I(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},L=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),R=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional()}),z=o.z.discriminatedUnion(`strategy`,[L,R]),B=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:z.optional()}),V=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),H=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),U=(0,o.zStrictObject)({type:o.z.literal(`oauth2`),authorizationUrl:o.z.string().optional(),authorizationParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenUrl:o.z.string().optional(),tokenParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenExpiresIn:o.z.number().optional(),tokenRefreshExpiresIn:o.z.number().optional(),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0),scopes:o.z.string().optional(),scopeDelimiter:o.z.string().optional(),customHeaders:o.z.record(o.z.string(),o.z.string()).optional(),pkce:o.z.boolean().optional(),additionalTokenFields:o.z.record(o.z.string(),o.z.string().optional()).optional(),issuer:o.z.string().optional()}),W=o.z.discriminatedUnion(`type`,[B,V,H,U]),G=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),K=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:W.optional(),responseMode:o.z.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:o.z.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:o.z.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:(0,o.zStrictObject)({dataKey:o.z.string().optional(),fileNameKey:o.z.string().optional(),contentTypeKey:o.z.string().optional(),contentIsBase64:o.z.boolean().optional().default(!1),urlKey:o.z.string().optional(),forwardAuth:o.z.boolean().optional().default(!1)}).optional(),maxRedirects:o.z.number().optional().default(5),followRedirects:o.z.boolean().optional().default(!0),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),q=(0,o.zStrictObject)({data:o.z.union([o.z.string(),o.z.instanceof(Buffer)]).optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),headers:o.z.record(o.z.string(),o.z.string()).optional(),contentDisposition:o.z.string().optional(),fileMetadata:(0,o.zStrictObject)({contentType:o.z.string().optional(),contentLength:o.z.number().optional(),fileName:o.z.string().optional(),lastModified:o.z.string().optional(),etag:o.z.string().optional()}).optional(),finalUrl:o.z.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,authorization:f,args:p,responseMode:m,responseType:h,encoding:g,response:_,maxRedirects:v,followRedirects:y}=K.parse(a),b=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,x=p?(0,c.parseRequestParameters)(p):{query:{},body:{},headers:{}},S=(0,c.createAuthorizationHeaders)((0,o.notMissing)(f)?f:W.parse(b)),C={...x?.headers??{},...S},w=e.connector?.rateLimit,T=e.connector?.concurrency,E=w!==void 0||T!==void 0?{rateLimit:w,concurrency:T}:void 0;if(m===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,maxRedirects:y?v:0,requestConfig:E});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,responseType:h,encoding:g,response:_,maxRedirects:y?v:0,requestConfig:E,authHeaders:S})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:s,authHeaders:c}=e,l=n.data;if(r.urlKey){let e=extractValueByPath(l,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?c:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:s}),o=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:o,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(l,r.dataKey);if((0,o.isMissing)(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let s=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:s,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if((0,o.isMissing)(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=(0,o.isString)(e[`content-type`])?e[`content-type`]:void 0,n=(0,o.isString)(e[`content-length`])?e[`content-length`]:void 0,r=(0,o.isString)(e[`content-disposition`])?e[`content-disposition`]:void 0,i=(0,o.isString)(e[`last-modified`])?e[`last-modified`]:void 0,a=(0,o.isString)(e.etag)?e.etag:void 0,s=n?parseInt(n,10):void 0,c=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(s)?void 0:s,fileName:c,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return u.default.extension(t)||void 0},J=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()}),Y=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}=J.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}},X=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),ee=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=X.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)}}},te=__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=ne(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=ne(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},{}),ne=__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}=re(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`),re=__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}},ie=(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(()=>ie).array().optional(),requiredScopes:o.z.string().array().optional()}),Z=o.z.object({fields:ie.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),ae=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}=Z.parse(t),o=buildExpressionContext(e),c=(0,s.evaluate)(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!c)return{block:e,successful:!0};let l=Object.keys(a??{})?.reduce((e,t)=>(e[t]=(0,s.evaluate)(a?.[t],o),e),{}),u;if(Array.isArray(c))u=c.map(e=>{let t=Q(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=Q(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=Q(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=Q(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Q(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=Q(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},oe=__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`),Q=__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=oe(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 se(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},se=__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=se(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=>d.Saml20.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let p={api_key:i},m={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:p,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+(0,f.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("mime-types");u=__toESM(u);let d=require("saml"),f=require("uuid"),p=require("node:crypto"),m=require("jose"),h=require("form-data");h=__toESM(h);const g=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=g.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},_={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=>_[e.toLowerCase()]??null,isValidCategory=e=>!!_[e.toLowerCase()],v=(0,o.encodeToBase64)(`so1!`),y=RegExp(`(?<!\\\\):`,`g`),b=RegExp(`(?<!\\\\),`,`g`);var x=class CoreError extends Error{constructor({category:e,name:t,type:n,context:r,message:i}){super(i),this.name=t??`CoreError`,this.type=n,this.category=e,this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,CoreError)}toString(){let e=this.message?`: ${this.message}`:``;return`${this.category}-${this.name} [${this.type}]${e}`}},BaseCompositeIdError=class extends x{constructor(e,t,n){super({category:`CompositeId`,name:t??`BaseCompositeIdError`,type:e,message:n})}},CompositeIdMissingHeaderError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_HEADER_ERROR`,`CompositeIdMissingHeaderError`,e??`Invalid compositeId, missing header`)}},CompositeIdMissingBodyError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_MISSING_BODY_ERROR`,`CompositeIdMissingBodyError`,e??`Invalid compositeId, missing body`)}},CompositeIdUnknownIdentifierError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR`,`CompositeIdUnknownIdentifierError`,e??`Invalid compositeId, unknown identifier`)}},CompositeIdUnsupportedVersionError=class extends BaseCompositeIdError{constructor(e){super(`COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR`,`CompositeIdUnsupportedVersionError`,e??`Invalid compositeId, unsupported version`)}};const isSingleIdentifier=e=>!(0,o.isMissing)(e)&&`value`in e&&e.value!==void 0,isMultipleIdentifier=e=>!(0,o.isMissing)(e)&&`identifiers`in e&&e.identifiers!==void 0,encodeCompositeId=(e,t={version:1})=>{if(t.version===1)return encodeIdV1(getComposedIdV1(e,t.aliases));throw new CompositeIdUnsupportedVersionError(`Cannot generate ID, unsupported version number: ${t.version}`)},decodeCompositeId=(e,t={version:1})=>{let n=decodeId(e,t),r={};return n&&n.split(b).forEach(e=>{let[n,i]=e.split(y),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=>`${v}${(0,o.encodeToBase64)(e)}`,decodeIdV1=e=>{if(!e.startsWith(v))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let t=e.split(v)[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(v),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if((0,o.isMissing)(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=(0,s.safeEvaluate)(`{{${n.result.trim()}}}`,t);if(!(0,o.isMissing)(r)){if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}if(typeof r==`number`||typeof r==`bigint`||typeof r==`boolean`)return String(r)}},evaluateEventRouter=(e,t)=>{let n=e.events?.router;if(!(0,o.isMissing)(n))for(let e of n.rules){let n=(0,s.safeEvaluate)(`{{${e.when.trim()}}}`,t);if(n!==null&&n!==!1&&n!==void 0){let n=e.then.input?Object.fromEntries(Object.entries(e.then.input).map(([e,n])=>[e,(0,s.safeEvaluate)(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},S={employment_status:[`active`,`inactive`,`terminated`,`pending`,`leave`],employment_type:[`full_time`,`part_time`,`contractor`,`intern`,`temporary`],gender:[`male`,`female`,`non_binary`,`other`,`prefer_not_to_say`],marital_status:[`single`,`married`,`divorced`,`widowed`,`domestic_partnership`]},getInputEnumValues=e=>S[e],isValidEnumRef=e=>e in S,C=[`preview`,`beta`,`ga`,`deprecated`,`internal`],w=[`sync`,`async`],T=(0,o.zStrictObject)({r:o.z.record(o.z.string(),(0,o.zStrictObject)({n:o.z.number().optional().nullable(),c:o.z.string().optional().nullable(),p:o.z.number().optional().nullable()})),v:o.z.number(),t:o.z.number()}),E=(0,o.zStrictObject)({remote:o.z.record(o.z.string(),(0,o.zStrictObject)({pageNumber:o.z.number().optional(),providerPageCursor:o.z.string().optional(),position:o.z.number().optional()})),version:o.z.number(),timestamp:o.z.number()}),minifyCursor=e=>(0,o.encodeToBase64)(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if((0,o.isString)(e)){let t=(0,o.decodeFromBase64)(e),n=JSON.parse(t);return expandCursorObject(T.parse(n))}else return E.parse(e),e}catch{return null}},expandCursorObject=e=>{let{r:t,v:n,t:r}=e;return{remote:Object.fromEntries(Object.entries(t).map(([e,{n:t,c:n,p:r}])=>[e,{pageNumber:t,providerPageCursor:n,position:r}])),version:n,timestamp:r}},areCursorsEqual=(e,t)=>{let n=typeof e==`string`?expandCursor(e):e,r=typeof t==`string`?expandCursor(t):t;if(n===null||r===null)return n===r;let{timestamp:i,...a}=n,{timestamp:s,...c}=r;return(0,o.getContentHash)(a)===(0,o.getContentHash)(c)},isCursorEmpty=({cursor:e,ignoreStepIndex:t})=>(0,o.isMissing)(e)?!0:Object.keys(e?.remote??{}).reduce((n,r)=>{let i=e?.remote?.[r];return((0,o.isMissing)(t)||r!==t.toString())&&(n=n&&(0,o.isMissing)(i.pageNumber)&&(0,o.isMissing)(i.position)&&(0,o.isMissing)(i.providerPageCursor)),n},!0),updateCursor=({cursor:e,stepIndex:t,pageNumber:n,providerPageCursor:r,position:i})=>{let a={pageNumber:n??void 0,providerPageCursor:r??void 0,position:i??void 0},s=(0,o.isMissing)(n)&&(0,o.isMissing)(r)&&(0,o.isMissing)(i);return(0,o.isMissing)(e)?{remote:s?{}:{[t]:a},version:2,timestamp:Date.now()}:s?(delete e.remote[t],e):{...e,remote:{...e.remote,[t]:a}}},isCoreError=e=>e instanceof x;function stripPaginationParams(e,t){let n=getPaginationKeys(t);if(n.length===0)return e;let r=getIteratorLocation(t);if(!r)return e;let i=e[r];if(!i||typeof i!=`object`)return e;let a={...i};for(let e of n)delete a[e];return{...e,[r]:a}}function getPaginationKeys(e){switch(e.type){case`cursor`:return[e.iterator.key];case`offset`:{let t=e;return[t.iterator.offsetKey,t.iterator.limitKey]}case`page`:{let t=e,n=[t.iterator.pageKey];return t.iterator.pageSizeKey&&n.push(t.iterator.pageSizeKey),n}default:return[]}}function getIteratorLocation(e){if(`iterator`in e&&typeof e.iterator==`object`&&e.iterator!==null)return e.iterator.in}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 D={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`,Internal:`INTERNAL`},O={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},k={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},A={APIKey:`API_KEY`,SessionToken:`SESSION_TOKEN`,UserSession:`USER_SESSION`,Cookie:`COOKIE`,Webhook:`WEBHOOK`,Signature:`SIGNATURE`},browserUseStepFunction=async()=>{throw Error(`browser_use step function cannot be executed synchronously — actions using this step must have executionMode: "async" so they are dispatched to the Temporal workflow runtime`)},j=o.z.object({startUrl:o.z.string().url(),systemPrompt:o.z.string().optional(),viewport:(0,o.zStrictObject)({width:o.z.number().int().positive(),height:o.z.number().int().positive()}).optional(),locale:o.z.string().optional(),budgets:(0,o.zStrictObject)({maxDurationMs:o.z.number().int().positive(),maxSteps:o.z.number().int().positive()}),auth:(0,o.zStrictObject)({sensitiveKeys:o.z.array(o.z.string().min(1)).optional(),requiresSession:o.z.boolean().optional(),allowedDomains:o.z.array(o.z.string().min(1)).optional()}).optional()}),M=o.z.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},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}},N=(0,o.zStrictObject)({lambdaName:o.z.string(),region:o.z.string().optional(),endpoint:o.z.string().optional(),invocationType:o.z.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:o.z.string().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),condition:o.z.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:o.z.string().optional()}),P=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),executedVersion:o.z.string().optional()}).optional(),F=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>(0,s.isExpression)(e)||F.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>(0,s.isExpression)(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,I=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;try{let n=(0,s.evaluate)(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||(0,s.safeEvaluate)(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,c=typeof o==`string`&&!F.test(o),l=t?.qualifier,u=typeof l==`string`&&!hasExpressionMarker(l),d={...t?(0,s.safeEvaluateRecord)(i===void 0?t:{...t,args:a},e):{},...c?{dataKey:o}:{},...u?{qualifier:l}:{}},f;try{f=N.parse(d)}catch(t){return buildStepErrorOutput(t,e)}let{lambdaName:p,region:m,endpoint:h,invocationType:g,qualifier:_,args:v,dataKey:y}=f,b;try{b=await n({lambdaName:p,payload:buildPayloadFromArgs(v),region:m,endpoint:h,invocationType:g,qualifier:_,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}if(b.functionError){let t=typeof b.payload==`object`&&b.payload!==null&&`errorMessage`in b.payload&&typeof b.payload.errorMessage==`string`?b.payload.errorMessage:`Lambda function error: ${b.functionError}`;return{block:e,successful:!1,errors:[{message:t,kind:`lambda_function_error`,functionError:b.functionError}],output:{statusCode:b.statusCode,message:t,data:b.payload,raw:b}}}return{block:e,successful:!0,output:{data:y?I(b.payload,y):b.payload,raw:b,statusCode:b.statusCode,executedVersion:b.executedVersion}}},L=(0,o.zStrictObject)({strategy:o.z.literal(`aws4`),service:o.z.string(),region:o.z.string().optional()}),R=(0,o.zStrictObject)({strategy:o.z.literal(`hmac`),algorithm:o.z.enum([`sha256`,`sha512`]).optional(),headerName:o.z.string().optional(),prefix:o.z.string().optional()}),z=o.z.discriminatedUnion(`strategy`,[L,R]),B=(0,o.zStrictObject)({type:o.z.literal(`none`),signing:z.optional()}),V=(0,o.zStrictObject)({type:o.z.literal(`basic`),username:o.z.string().optional(),password:o.z.string().optional(),encoding:o.z.string().optional()}),H=(0,o.zStrictObject)({type:o.z.literal(`bearer`),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0)}),U=(0,o.zStrictObject)({type:o.z.literal(`oauth2`),authorizationUrl:o.z.string().optional(),authorizationParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenUrl:o.z.string().optional(),tokenParams:o.z.record(o.z.string(),o.z.string()).optional(),tokenExpiresIn:o.z.number().optional(),tokenRefreshExpiresIn:o.z.number().optional(),token:o.z.string(),includeBearer:o.z.boolean().optional().default(!0),scopes:o.z.string().optional(),scopeDelimiter:o.z.string().optional(),customHeaders:o.z.record(o.z.string(),o.z.string()).optional(),pkce:o.z.boolean().optional(),additionalTokenFields:o.z.record(o.z.string(),o.z.string().optional()).optional(),issuer:o.z.string().optional(),tokenResponse:(0,o.zStrictObject)({acceptTokenTypes:o.z.array(o.z.string()).optional()}).optional()}),W=o.z.discriminatedUnion(`type`,[B,V,H,U]),G=(0,o.zStrictObject)({certs:o.z.string().array().optional(),keys:o.z.string().array().optional()}).optional(),K=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).optional().default(`get`),authorization:W.optional(),responseMode:o.z.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:o.z.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:o.z.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:(0,o.zStrictObject)({dataKey:o.z.string().optional(),fileNameKey:o.z.string().optional(),contentTypeKey:o.z.string().optional(),contentIsBase64:o.z.boolean().optional().default(!1),urlKey:o.z.string().optional(),forwardAuth:o.z.boolean().optional().default(!1)}).optional(),maxRedirects:o.z.number().optional().default(5),followRedirects:o.z.boolean().optional().default(!0),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),q=(0,o.zStrictObject)({data:o.z.union([o.z.string(),o.z.instanceof(Buffer)]).optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional(),headers:o.z.record(o.z.string(),o.z.string()).optional(),contentDisposition:o.z.string().optional(),fileMetadata:(0,o.zStrictObject)({contentType:o.z.string().optional(),contentLength:o.z.number().optional(),fileName:o.z.string().optional(),lastModified:o.z.string().optional(),etag:o.z.string().optional()}).optional(),finalUrl:o.z.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?(0,s.safeEvaluateRecord)({...t,args:r},e):{},a={...i,customErrors:t?.customErrors},{baseUrl:l,url:u,method:d,authorization:f,args:p,responseMode:m,responseType:h,encoding:g,response:_,maxRedirects:v,followRedirects:y}=K.parse(a),b=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,x=p?(0,c.parseRequestParameters)(p):{query:{},body:{},headers:{}},S=(0,c.createAuthorizationHeaders)((0,o.notMissing)(f)?f:W.parse(b)),C={...x?.headers??{},...S},w=e.connector?.rateLimit,T=e.connector?.concurrency,E=w!==void 0||T!==void 0?{rateLimit:w,concurrency:T}:void 0;if(m===`stream`)return performStreamDownload({block:e,httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,maxRedirects:y?v:0,requestConfig:E});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:l??``,url:u,method:d,headers:C,queryParams:x?.query,body:x?.body,responseType:h,encoding:g,response:_,maxRedirects:y?v:0,requestConfig:E,authHeaders:S})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:s,authHeaders:c}=e,l=n.data;if(r.urlKey){let e=extractValueByPath(l,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?c:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:s}),o=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:o,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(l,r.dataKey);if((0,o.isMissing)(e))throw Error(`No file content found at path: ${r.dataKey}`);let t;if(typeof e==`string`)t=r.contentIsBase64?i===`base64`?e:i===`none`?Buffer.from(e,`base64`):Buffer.from(e,`base64`).toString(i===`raw`?`binary`:i):encodeFileData(e,i);else if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=encodeFileData(e,i);else throw Error(`Unexpected file content type at path: ${r.dataKey}`);let a={};if(r.fileNameKey){let e=extractValueByPath(l,r.fileNameKey);typeof e==`string`&&(a.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(l,r.contentTypeKey);typeof e==`string`&&(a.contentType=e)}let s=buildContentDisposition(a);return{data:t,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:s,fileMetadata:a}}throw Error(`JSON response handling requires either urlKey or dataKey to be specified`)},extractValueByPath=(e,t)=>{let n=(t.startsWith(`$.`)?t.slice(2):t).split(`.`),r=e;for(let e of n){if((0,o.isMissing)(r)||typeof r!=`object`)return;r=r[e]}return r},encodeFileData=(e,t)=>{if(t===`none`)return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`string`?Buffer.from(e):Buffer.from(JSON.stringify(e));if(t===`raw`)return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Buffer.from(e).toString(`binary`):JSON.stringify(e);if(typeof e==`string`)return t===`base64`?Buffer.from(e).toString(`base64`):e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=Buffer.from(e);switch(t){case`base64`:return n.toString(`base64`);case`utf8`:return n.toString(`utf8`);default:return n.toString(`binary`)}}return JSON.stringify(e)},extractFileMetadata=e=>{let t=(0,o.isString)(e[`content-type`])?e[`content-type`]:void 0,n=(0,o.isString)(e[`content-length`])?e[`content-length`]:void 0,r=(0,o.isString)(e[`content-disposition`])?e[`content-disposition`]:void 0,i=(0,o.isString)(e[`last-modified`])?e[`last-modified`]:void 0,a=(0,o.isString)(e.etag)?e.etag:void 0,s=n?parseInt(n,10):void 0,c=extractFileName(r);return{contentType:t,contentLength:Number.isNaN(s)?void 0:s,fileName:c,lastModified:i,etag:a}},extractFileName=e=>{if(!e)return;let t=e.match(/filename\*=(?:UTF-8''|utf-8'')([^;\s]+)/i);if(t&&t[1])try{return decodeURIComponent(t[1])}catch{}let n=e.match(/filename=["']([^"']+)["']/);if(n&&n[1])return n[1];let r=e.match(/filename=([^;\s]+)/);if(r&&r[1])return r[1]},buildContentDisposition=e=>{let{fileName:t,contentType:n}=e,r=`attachment`;if(t)r=`attachment; filename="${t}"; filename*=UTF-8''${encodeURIComponent(t).replace(/['()]/g,escape)}`;else if(n){let e=getExtensionFromContentType(n);e&&(r=`attachment; filename="download.${e}"`)}return r},getExtensionFromContentType=e=>{let t=e.split(`;`)[0].trim().toLowerCase();return u.default.extension(t)||void 0},J=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()}),Y=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}=J.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}},X=o.z.object({stepsDataToGroup:o.z.array(o.z.string()),isSingleRecord:o.z.boolean().optional()}),ee=o.z.object({data:o.z.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=X.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)}}},te=__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=ne(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=ne(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},{}),ne=__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}=re(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`),re=__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}},ie=(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(()=>ie).array().optional(),requiredScopes:o.z.string().array().optional()}),Z=o.z.object({fields:ie.array(),dataSource:o.z.string(),externalSources:o.z.record(o.z.string(),o.z.string()).optional()}),ae=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}=Z.parse(t),o=buildExpressionContext(e),c=(0,s.evaluate)(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!c)return{block:e,successful:!0};let l=Object.keys(a??{})?.reduce((e,t)=>(e[t]=(0,s.evaluate)(a?.[t],o),e),{}),u;if(Array.isArray(c))u=c.map(e=>{let t=Q(r,{...e,external:l},o);return n.push(...t?.errors||[]),t?.record});else{let e=Q(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=Q(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=Q(e.properties,t,i);return(0,o.notMissing)(n?.errors)&&r.push(...n.errors),n?.record}).filter(Boolean);{let n=Q(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=Q(e.properties,i,r);return(0,o.notMissing)(a?.errors)&&n.push(...a.errors),a?.record},oe=__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`),Q=__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=oe(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 se(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},se=__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=se(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=>d.Saml20.create(e),sleepFn:u=e=>new Promise(t=>setTimeout(t,e))})=>{let p={api_key:i},m={cert:e,key:generatePrivateKey(t),issuer:n,lifetimeInSeconds:r,audiences:s,attributes:p,nameIdentifier:a,nameIdentifierFormat:c,recipient:o,sessionIndex:`_`+(0,f.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-----`)},ce=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()}),le=(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(),$=__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&&$(d),p=t?.response?.dataKey,m=p&&$(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}=ce.parse(g),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],D=E?.authorization,O=E?.certificates,k=O?(0,c.buildHttpsAgent)(O):void 0,A=W.parse(D),j=w?(0,c.parseRequestParameters)(w):{query:{},body:{},headers:{}},M=(0,c.createAuthorizationHeaders)(A),N={...j?.headers??{},...M},P=e.connector?.rateLimit,F=e.connector?.concurrency,I=P!==void 0||F!==void 0?{rateLimit:P,concurrency:F}:void 0,L=(0,o.notMissing)(T)?{[T.objectKey]:await 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=[],G=[],K=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?ue(t.data,b.dataKey):t.data;let r=R?U?.slice(0,K):U?.slice(q,q+K);K-=r.length,q+=r.length,G.push(t),H=H.concat(r),V=t?.status,z=de({result:t,response:b}),X=(0,o.notMissing)(x.condition)?(0,s.safeEvaluate)(x.condition,t.data)===!0:!0,!R&&r.length===U.length&&K===0&&(q=0,B=z),Y=!X||(0,o.isMissing)(z)&&H.length<a}while((R||(0,o.notMissing)(z))&&X&&H.length<a&&U?.length>0);return{block:e,successful:!0,output:{data:me(H,b),raw:G,statusCode:V,next:Y?void 0:B,position:Y?void 0:q}}},ue=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)($(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),de=__name(({result:e,response:t})=>{if((0,o.isMissing)(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?fe(e.headers,r):pe(e.data,r)},`resolveNextIterator`),fe=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`)return null;if($(t)){let n=(0,s.safeEvaluate)(t,e);return typeof n==`string`&&n!==``||typeof n==`number`?n:null}let n=t.toLowerCase(),[,r]=Object.entries(e).find(([e])=>e?.toLowerCase()===n)??[];if(Array.isArray(r)){let e=r.find(e=>typeof e==`string`&&e!==``||typeof e==`number`);return typeof e==`string`||typeof e==`number`?e:null}return typeof r==`string`&&r!==``||typeof r==`number`?r:null},`resolveFromHeaders`),pe=__name((e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return null;let n=(0,s.safeEvaluate)($(t)?t:`$.${t}`,e);return(0,o.isMissing)(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),me=__name((e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),he=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:W.optional(),certificates:G,saml:(0,o.zStrictObject)({objectKey:o.z.string(),key:o.z.string(),clientId:o.z.string(),cert:o.z.unknown().optional(),issuer:o.z.string().optional(),lifetime:o.z.number().optional(),nameId:o.z.string().optional(),audience:o.z.string().optional(),nameIdentifierFormat:o.z.string().optional(),tokenEndpoint:o.z.string().optional()}).optional(),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),spread:o.z.boolean().optional(),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),ge=(0,o.zStrictObject)({data:o.z.unknown().optional(),raw:o.z.unknown().optional(),statusCode:o.z.number(),message:o.z.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=c.RequestClientFactory.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||(0,s.evaluate)(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?.response?.dataKey,l=a&&isJexlExpression(a),u=t?(0,s.safeEvaluateRecord)({...t,args:i},e):{},d={...u,customErrors:t?.customErrors,response:l?{...u?.response??{},dataKey:a}:u?.response},{baseUrl:f,url:p,method:m,response:h,authorization:g,certificates:_,customErrors:v,args:y,saml:b}=he.parse(d),x=u?.authentication?.[e.context.authenticationType]?.[e.context.environment],S=x?.authorization,C=_??x?.certificates,w=C?(0,c.buildHttpsAgent)(C):void 0,T=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},E=(0,o.notMissing)(g)?g:W.parse(S),D=(0,c.createAuthorizationHeaders)(E),O={...T?.headers??{},...D},k=e.connector?.rateLimit,A=e.connector?.concurrency,j=k!==void 0||A!==void 0?{rateLimit:k,concurrency:A}:void 0,M=(0,o.notMissing)(b)?{[b.objectKey]:await generateSamlAssertion({key:b.key,clientId:b.clientId,cert:b.cert,issuer:b.issuer,lifetime:b.lifetime,audience:b.audience,nameId:b.nameId,nameIdentifierFormat:b.nameIdentifierFormat,tokenEndpoint:b.tokenEndpoint})}:{},N=Array.isArray(T?.body)?T?.body:{...T?.body,...M};if(E.type===`none`&&E.signing?.strategy){let t=E.signing,n=e.credentials??{};try{let e=(0,c.getSigningStrategy)(t.strategy);if(!e)throw Error(`Signing strategy "${t.strategy}" is not registered`);let r=e({method:m,url:`${f}${p}`,headers:O,query:T?.query??{},body:N},n,t);Object.assign(O,r)}catch(t){return buildStepErrorOutput(t,e)}}let P;try{P=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:T?.query,method:m,headers:O,body:N,customErrorConfigs:v,requestConfig:j,httpsAgent:w,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:_e(h?.dataKey?resolveDataKey(P.data,h.dataKey):P.data,h),raw:P,statusCode:P?.status,message:P?.message}}},resolveDataKey=(e,t)=>{if((0,o.isMissing)(e)||typeof e!=`object`||!e)return e;let n=(0,s.safeEvaluate)(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},_e=__name((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),ve=o.z.union([o.z.string(),o.z.number()]),ye=(0,o.zStrictObject)({algorithm:o.z.literal(`RS256`),privateKey:o.z.string(),claims:o.z.record(o.z.string(),ve)}),be=(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,p.createHash)(`sha256`).update(t).digest(`base64`)}`},xe=/^now$/,Se=/^now\+(?<amount>\d+)(?<unit>[smh])$/,Ce=`{publicKeyFingerprint}`,we={s:1,m:60,h:3600},Te=new Set([`iat`,`exp`,`nbf`]),resolveClaimValue=(e,t,{now:n,publicKeyFingerprint:r})=>{if(typeof t==`number`)return t;let i=t.includes(Ce)?t.split(Ce).join(r):t;if(!Te.has(e))return i;if(xe.test(i))return n;let a=i.match(Se);return a?.groups?n+Number(a.groups.amount)*we[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}=ye.parse(n),o=(0,p.createPrivateKey)(i),c=computePublicKeyFingerprint((0,p.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 h=await new m.SignJWT(u).setProtectedHeader({alg:r}).sign(o);return{block:{...e},successful:!0,output:{token:h,expiresIn:f-d,publicKeyFingerprint:c}}}catch(t){return buildStepErrorOutput(t,e)}},Ee=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()}),De=(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}=Ee.parse(d),E=u?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,D=b?(0,c.parseRequestParameters)(b):{query:{},body:{},headers:{}},O=(0,c.createAuthorizationHeaders)((0,o.notMissing)(v)?v:W.parse(E)),k={...D?.headers??{},...O},A=e.connector?.rateLimit,j=e.connector?.concurrency,M={...(A!==void 0||j!==void 0)&&{rateLimit:A,concurrency:j},soapOperation:x,namespaces:S,envelope:C,soapAction:w,soapContext:T?{username:e.credentials?.username,password:e.credentials?.password}:void 0},N=_?.token??null,P=null,F=null,I=[],L=[],R=[],z=a,B=_?.position??0,V=!0,H;do{V?V=!1:B=0,N!==null&&(g.in===`query`?D.query[g.key]=N.toString():g.in===`body`&&(D.body[g.key]=N));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${f}${p}`,queryParams:D?.query,method:m,headers:k,body:D?.body,customErrorConfigs:y,requestConfig:M,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}P=N,L=h?.dataKey?t.data[h?.dataKey]:t.data,Array.isArray(L)||(L=L?[L]:[]);let r=L?.slice(B,B+z);z-=r.length,B+=r.length,R.push(t),I=I.concat(r),F=t?.status,N=resolveNextIterator({result:t,response:h}),r.length===L.length&&z===0&&(B=0,P=N),H=(0,o.isMissing)(N)&&I.length<a}while((0,o.notMissing)(N)&&I.length<a&&L?.length>0);return{block:e,successful:!0,output:{data:Oe(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},Oe=__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`),ke=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods),authorization:W.optional(),envelope:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.unknown())]).optional(),namespaces:o.z.strictObject({namespaceIdentifier:o.z.string(),namespace:o.z.string()}).array().optional(),soapOperation:o.z.string().optional(),soapAction:o.z.string().optional(),useSoapContext:o.z.boolean().optional().default(!0),response:(0,o.zStrictObject)({collection:o.z.boolean().optional(),indexField:o.z.string().optional(),dataKey:o.z.string().optional()}).optional(),customErrors:c.CUSTOM_ERROR_CONFIG_SCHEMA.array().optional(),args:(0,o.zStrictObject)({name:o.z.string(),value:o.z.unknown(),in:o.z.enum(c.RequestParameterLocations),condition:o.z.string().optional(),arrayFormat:o.z.enum(c.QueryArrayFormats).optional()}).array().optional()}),Ae=(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}=ke.parse(l),S=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,C=g?(0,c.parseRequestParameters)(g):{query:{},body:{},headers:{}},w=(0,c.createAuthorizationHeaders)((0,o.notMissing)(m)?m:W.parse(S)),T={...C?.headers??{},...w},E=e.connector?.rateLimit,D=e.connector?.concurrency,O={...(E!==void 0||D!==void 0)&&{rateLimit:E,concurrency:D},soapOperation:_,namespaces:v,envelope:y,soapAction:b,soapContext:x?{username:e.credentials?.username,password:e.credentials?.password}:void 0},k;try{k=await n.performRequest({httpClient:e.httpClient,url:`${u}${d}`,queryParams:C?.query,method:f,headers:T,body:C?.body,customErrorConfigs:h,requestConfig:O,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:je(p?.dataKey?k.data[p?.dataKey]:k.data,p),raw:k,statusCode:k?.status,message:k?.message}}},je=__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`),Me=o.z.object({values:o.z.string().or(o.z.record(o.z.string(),o.z.unknown())).or(o.z.array(o.z.unknown()))}),Ne=o.z.object({data:o.z.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Me.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,Pe=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(()=>Pe).array().optional(),requiredScopes:o.z.string().array().optional()}),Fe=o.z.object({fields:Pe.array().optional(),dataSource:o.z.string()}),Ie=o.z.object({data:o.z.unknown()});let Le=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(Le).includes(e),Re=__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=>ze(e,t)):ze(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),ze=__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}=Fe.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}},Be=(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)`)}),Ve=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:W.optional(),binaryContent:Be.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)`)}),He=(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}=Ve.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?(0,c.parseRequestParameters)(h):{query:{},body:{},headers:{}},y=(0,c.createAuthorizationHeaders)((0,o.notMissing)(p)?p:W.parse(_)),b=Buffer.from(m.content,`base64`),x={"content-type":m.contentType??`application/octet-stream`,...v?.headers??{},...y},S=e.connector?.rateLimit,C=e.connector?.concurrency,w=S!==void 0||C!==void 0?{rateLimit:S,concurrency:C}:void 0,T;try{T=await e.httpClient.request({url:`${l??``}${u}`,method:d,headers:x,queryParams:v?.query,payload:b,requestConfig:w})}catch(t){let n=t;return{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let E=(0,c.translateCustomError)(T,g,e.credentials);return(0,c.isFailedStatusCode)(E?.status)?{block:e,successful:!1,errors:[(0,c.serializeHttpResponseError)(new c.HttpResponseError(E,E.message))],output:{statusCode:E.status,message:E.message}}:{block:e,successful:!0,output:{data:Ue(f?.dataKey?E.data[f?.dataKey]:E.data,f),raw:E,statusCode:E?.status,message:E?.message}}},Ue=__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`),We=(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")`)}),Ge=o.z.object({baseUrl:o.z.string().optional(),url:o.z.string(),method:o.z.enum(c.HttpMethods).default(`post`),authorization:W.optional(),file:We.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)`)}),Ke=(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:g,file:_,additionalFields:v,args:y,customErrors:b}=Ge.parse(u),x=l?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,S=y?(0,c.parseRequestParameters)(y):{query:{},body:{},headers:{}},C=(0,c.createAuthorizationHeaders)((0,o.notMissing)(g)?g:W.parse(x)),w=new h.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 qe=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 Je={typecast:{v1:{fn:Re},v2:{fn:typecastStepFunction,inputSchema:Fe,outputSchema:Ie}},map_fields:{v1:{fn:te},v2:{fn:mapFieldsStepFunction,inputSchema:Z,outputSchema:ae}},request:{v1:{fn:requestStepFunction,inputSchema:he,outputSchema:ge}},group_data:{v1:{fn:groupDataStepFunction,inputSchema:X,outputSchema:ee}},paginated_request:{v1:{fn:paginatedRequestStepFunction,inputSchema:ce,outputSchema:le}},soap_request:{v1:{fn:soapRequestStepFunction,inputSchema:ke,outputSchema:Ae}},soap_paginated_request:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:Ee,outputSchema:De}},static_values:{v1:{fn:staticValuesStepFunction,inputSchema:Me,outputSchema:Ne}},upload_file:{v1:{fn:uploadFileStepFunction,inputSchema:Ge,outputSchema:Ke}},upload_binary:{v1:{fn:uploadBinaryStepFunction,inputSchema:Ve,outputSchema:He}},download_file:{v1:{fn:downloadFileStepFunction,inputSchema:K,outputSchema:q}},emit_event:{v1:{fn:emitEventStepFunction,inputSchema:J,outputSchema:Y}},browser_use:{v1:{fn:browserUseStepFunction,inputSchema:j,outputSchema:M}},code_execution_lambda:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:N,outputSchema:P}},sign_jwt:{v1:{fn:signJwtStepFunction,inputSchema:ye,outputSchema:be}}},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},Ye={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Je}){let i=r?.[e]?.[`v${t}`];if(!i)throw Error(`Unknown step function: ${e} v${t}`);return n?{...i,fn:stepFunctionEnhancedWithSchemasValidation(i,e)}:i}},isForeachStep=e=>`iterator`in e&&typeof e.iterator==`string`;exports.AUTHORIZATION_SCHEMA=W,exports.AuthType=A,exports.BROWSER_USE_INPUT_PARAMS=j,exports.BROWSER_USE_OUTPUT=M,exports.COMPOSITE_ID_LATEST_VERSION=1,exports.CoreError=x,exports.ExecutionModes=w,exports.INPUT_ENUM_REGISTRY=S,exports.ReleaseStages=C,exports.SourceType=D,exports.StepFunctionName=qe,exports.StepFunctionsFactory=Ye,exports.StepFunctionsRegistry=Je,exports.StreamType=k,exports.TransportType=O,exports.areCursorsEqual=areCursorsEqual,exports.buildExpressionContext=buildExpressionContext,exports.decodeCompositeId=decodeCompositeId,exports.encodeCompositeId=encodeCompositeId,exports.evaluateEventRouter=evaluateEventRouter,exports.evaluateExternalAccountIdExtractor=evaluateExternalAccountIdExtractor,exports.expandCursor=expandCursor,exports.getCategoryDetails=getCategoryDetails,exports.getInputEnumValues=getInputEnumValues,exports.getIteratorLocation=getIteratorLocation,exports.getPaginationKeys=getPaginationKeys,exports.isCompositeId=isCompositeId,exports.isCoreError=isCoreError,exports.isCursorEmpty=isCursorEmpty,exports.isForeachStep=isForeachStep,exports.isValidCategory=isValidCategory,exports.isValidEnumRef=isValidEnumRef,exports.minifyCursor=minifyCursor,exports.stripIncrementalParams=stripIncrementalParams,exports.stripPaginationParams=stripPaginationParams,exports.updateCursor=updateCursor;
package/dist/index.d.cts CHANGED
@@ -1898,6 +1898,9 @@ declare const stepFunctions: {
1898
1898
  pkce: ZodOptional<ZodBoolean>;
1899
1899
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
1900
1900
  issuer: ZodOptional<ZodString>;
1901
+ tokenResponse: ZodOptional<ZodObject<{
1902
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
1903
+ }, $strict>>;
1901
1904
  }, $strict>]>>;
1902
1905
  certificates: ZodOptional<ZodObject<{
1903
1906
  certs: ZodOptional<ZodArray<ZodString>>;
@@ -2102,6 +2105,9 @@ declare const stepFunctions: {
2102
2105
  pkce: ZodOptional<ZodBoolean>;
2103
2106
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2104
2107
  issuer: ZodOptional<ZodString>;
2108
+ tokenResponse: ZodOptional<ZodObject<{
2109
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2110
+ }, $strict>>;
2105
2111
  }, $strict>]>>;
2106
2112
  envelope: ZodOptional<ZodUnion<readonly [ZodString, ZodRecord<ZodString, ZodUnknown>]>>;
2107
2113
  namespaces: ZodOptional<ZodArray<ZodObject<{
@@ -2303,6 +2309,9 @@ declare const stepFunctions: {
2303
2309
  pkce: ZodOptional<ZodBoolean>;
2304
2310
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2305
2311
  issuer: ZodOptional<ZodString>;
2312
+ tokenResponse: ZodOptional<ZodObject<{
2313
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2314
+ }, $strict>>;
2306
2315
  }, $strict>]>>;
2307
2316
  file: ZodObject<{
2308
2317
  fieldName: ZodString;
@@ -2406,6 +2415,9 @@ declare const stepFunctions: {
2406
2415
  pkce: ZodOptional<ZodBoolean>;
2407
2416
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2408
2417
  issuer: ZodOptional<ZodString>;
2418
+ tokenResponse: ZodOptional<ZodObject<{
2419
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2420
+ }, $strict>>;
2409
2421
  }, $strict>]>>;
2410
2422
  binaryContent: ZodObject<{
2411
2423
  content: ZodString;
@@ -2501,6 +2513,9 @@ declare const stepFunctions: {
2501
2513
  pkce: ZodOptional<ZodBoolean>;
2502
2514
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2503
2515
  issuer: ZodOptional<ZodString>;
2516
+ tokenResponse: ZodOptional<ZodObject<{
2517
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2518
+ }, $strict>>;
2504
2519
  }, $strict>]>>;
2505
2520
  responseMode: ZodDefault<ZodOptional<ZodEnum<{
2506
2521
  buffer: "buffer";
@@ -2858,9 +2873,10 @@ type InputRules = {
2858
2873
  max?: number;
2859
2874
  errorMessage?: string;
2860
2875
  };
2876
+ type InputType = 'string' | 'number' | 'boolean' | 'datetime_string' | 'object' | 'enum';
2861
2877
  type Input = {
2862
2878
  name: string;
2863
- type: 'string' | 'number' | 'boolean' | 'datetime_string' | 'object' | 'enum';
2879
+ type?: InputType;
2864
2880
  required: boolean;
2865
2881
  description: string;
2866
2882
  in: InputLocation;
@@ -2868,6 +2884,15 @@ type Input = {
2868
2884
  properties?: Omit<Input, 'in'>[];
2869
2885
  oneOf?: EnumOneOf;
2870
2886
  rules?: InputRules;
2887
+ variants?: InputVariant[];
2888
+ };
2889
+ type InputVariant = {
2890
+ type: InputType;
2891
+ description?: string;
2892
+ array?: boolean;
2893
+ properties?: Omit<Input, 'in'>[];
2894
+ oneOf?: EnumOneOf;
2895
+ rules?: InputRules;
2871
2896
  };
2872
2897
  type RequiredIfCondition = {
2873
2898
  field: string;
@@ -3463,6 +3488,9 @@ declare const AUTHORIZATION_SCHEMA: z.ZodDiscriminatedUnion<[z.ZodObject<{
3463
3488
  pkce: z.ZodOptional<z.ZodBoolean>;
3464
3489
  additionalTokenFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
3465
3490
  issuer: z.ZodOptional<z.ZodString>;
3491
+ tokenResponse: z.ZodOptional<z.ZodObject<{
3492
+ acceptTokenTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3493
+ }, z.core.$strict>>;
3466
3494
  }, z.core.$strict>]>;
3467
3495
  //#endregion
3468
3496
  //#region src/steps/typeguards.d.ts
@@ -3484,4 +3512,4 @@ type Account = {
3484
3512
  originOwnerName?: string;
3485
3513
  };
3486
3514
  //#endregion
3487
- 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 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 IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, SourceType, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, StreamType, type SupportConfig, type SyncParams, type TestActionConfig, 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 };
3515
+ 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 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 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
@@ -1897,6 +1897,9 @@ declare const stepFunctions: {
1897
1897
  pkce: ZodOptional<ZodBoolean>;
1898
1898
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
1899
1899
  issuer: ZodOptional<ZodString>;
1900
+ tokenResponse: ZodOptional<ZodObject<{
1901
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
1902
+ }, $strict>>;
1900
1903
  }, $strict>]>>;
1901
1904
  certificates: ZodOptional<ZodObject<{
1902
1905
  certs: ZodOptional<ZodArray<ZodString>>;
@@ -2101,6 +2104,9 @@ declare const stepFunctions: {
2101
2104
  pkce: ZodOptional<ZodBoolean>;
2102
2105
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2103
2106
  issuer: ZodOptional<ZodString>;
2107
+ tokenResponse: ZodOptional<ZodObject<{
2108
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2109
+ }, $strict>>;
2104
2110
  }, $strict>]>>;
2105
2111
  envelope: ZodOptional<ZodUnion<readonly [ZodString, ZodRecord<ZodString, ZodUnknown>]>>;
2106
2112
  namespaces: ZodOptional<ZodArray<ZodObject<{
@@ -2302,6 +2308,9 @@ declare const stepFunctions: {
2302
2308
  pkce: ZodOptional<ZodBoolean>;
2303
2309
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2304
2310
  issuer: ZodOptional<ZodString>;
2311
+ tokenResponse: ZodOptional<ZodObject<{
2312
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2313
+ }, $strict>>;
2305
2314
  }, $strict>]>>;
2306
2315
  file: ZodObject<{
2307
2316
  fieldName: ZodString;
@@ -2405,6 +2414,9 @@ declare const stepFunctions: {
2405
2414
  pkce: ZodOptional<ZodBoolean>;
2406
2415
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2407
2416
  issuer: ZodOptional<ZodString>;
2417
+ tokenResponse: ZodOptional<ZodObject<{
2418
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2419
+ }, $strict>>;
2408
2420
  }, $strict>]>>;
2409
2421
  binaryContent: ZodObject<{
2410
2422
  content: ZodString;
@@ -2500,6 +2512,9 @@ declare const stepFunctions: {
2500
2512
  pkce: ZodOptional<ZodBoolean>;
2501
2513
  additionalTokenFields: ZodOptional<ZodRecord<ZodString, ZodOptional<ZodString>>>;
2502
2514
  issuer: ZodOptional<ZodString>;
2515
+ tokenResponse: ZodOptional<ZodObject<{
2516
+ acceptTokenTypes: ZodOptional<ZodArray<ZodString>>;
2517
+ }, $strict>>;
2503
2518
  }, $strict>]>>;
2504
2519
  responseMode: ZodDefault<ZodOptional<ZodEnum<{
2505
2520
  buffer: "buffer";
@@ -2857,9 +2872,10 @@ type InputRules = {
2857
2872
  max?: number;
2858
2873
  errorMessage?: string;
2859
2874
  };
2875
+ type InputType = 'string' | 'number' | 'boolean' | 'datetime_string' | 'object' | 'enum';
2860
2876
  type Input = {
2861
2877
  name: string;
2862
- type: 'string' | 'number' | 'boolean' | 'datetime_string' | 'object' | 'enum';
2878
+ type?: InputType;
2863
2879
  required: boolean;
2864
2880
  description: string;
2865
2881
  in: InputLocation;
@@ -2867,6 +2883,15 @@ type Input = {
2867
2883
  properties?: Omit<Input, 'in'>[];
2868
2884
  oneOf?: EnumOneOf;
2869
2885
  rules?: InputRules;
2886
+ variants?: InputVariant[];
2887
+ };
2888
+ type InputVariant = {
2889
+ type: InputType;
2890
+ description?: string;
2891
+ array?: boolean;
2892
+ properties?: Omit<Input, 'in'>[];
2893
+ oneOf?: EnumOneOf;
2894
+ rules?: InputRules;
2870
2895
  };
2871
2896
  type RequiredIfCondition = {
2872
2897
  field: string;
@@ -3462,6 +3487,9 @@ declare const AUTHORIZATION_SCHEMA: z.ZodDiscriminatedUnion<[z.ZodObject<{
3462
3487
  pkce: z.ZodOptional<z.ZodBoolean>;
3463
3488
  additionalTokenFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
3464
3489
  issuer: z.ZodOptional<z.ZodString>;
3490
+ tokenResponse: z.ZodOptional<z.ZodObject<{
3491
+ acceptTokenTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
3492
+ }, z.core.$strict>>;
3465
3493
  }, z.core.$strict>]>;
3466
3494
  //#endregion
3467
3495
  //#region src/steps/typeguards.d.ts
@@ -3483,4 +3511,4 @@ type Account = {
3483
3511
  originOwnerName?: string;
3484
3512
  };
3485
3513
  //#endregion
3486
- 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 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 IntermediateStepSnapshot, type IteratorLocation, type MatchedEventAction, type OffsetPaginationConfig, type PagePaginationConfig, type PaginationConfig, type ReleaseStage, ReleaseStages, type Schema, type SchemaField, type ScopeDefinition, type Settings, type SimpleStep, type Source, SourceType, type Step, type StepFunction, type StepFunctionMeta, StepFunctionName, type StepFunctionOutput, type StepFunctionParams, StepFunctionsFactory, stepFunctions as StepFunctionsRegistry, type StepsSnapshots, type StreamOutputData, StreamType, type SupportConfig, type SyncParams, type TestActionConfig, 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 };
3514
+ 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 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 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 A,safeParseToNumber as j,safeParseToString as M,z as N,zStrictObject as P}from"@stackone/utils";import{evaluate as F,isExpression as I,isValidExpression as L,safeEvaluate as R,safeEvaluateRecord as z}from"@stackone/expressions";import{CUSTOM_ERROR_CONFIG_SCHEMA as B,HttpMethods as V,HttpResponseError as H,QueryArrayFormats as U,RequestClientFactory as ee,RequestParameterLocations as W,buildHttpsAgent as te,createAuthorizationHeaders as G,getSigningStrategy as K,isFailedStatusCode as q,parseRequestParameters as J,serializeHttpResponseError as Y,translateCustomError as X}from"@stackone/transport";import{InvokeCommand as Z,LambdaClient as ne}from"@aws-sdk/client-lambda";import re from"mime-types";import{Saml20 as ie}from"saml";import{v4 as ae}from"uuid";import{createHash as oe,createPrivateKey as se,createPublicKey as ce}from"node:crypto";import{SignJWT as le}from"jose";import ue from"form-data";const de=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=de.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},fe={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=>fe[e.toLowerCase()]??null,isValidCategory=e=>!!fe[e.toLowerCase()],pe=n(`so1!`),me=RegExp(`(?<!\\\\):`,`g`),he=RegExp(`(?<!\\\\),`,`g`),ge=1;var _e=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 _e{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(he).forEach(e=>{let[n,i]=e.split(me),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=>`${pe}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(pe))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(pe)[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(pe),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(T(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=R(`{{${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=R(`{{${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,R(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},ve={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=>ve[e],isValidEnumRef=e=>e in ve,ye=[`preview`,`beta`,`ga`,`deprecated`,`internal`],be=[`sync`,`async`],xe=P({r:N.record(N.string(),P({n:N.number().optional().nullable(),c:N.string().optional().nullable(),p:N.number().optional().nullable()})),v:N.number(),t:N.number()}),Se=P({remote:N.record(N.string(),P({pageNumber:N.number().optional(),providerPageCursor:N.string().optional(),position:N.number().optional()})),version:N.number(),timestamp:N.number()}),minifyCursor=e=>n(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if(D(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(xe.parse(r))}else return Se.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 _e;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 Ce={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`,Internal:`INTERNAL`},we={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},Te={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},Ee={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`)},De=N.object({startUrl:N.string().url(),systemPrompt:N.string().optional(),viewport:P({width:N.number().int().positive(),height:N.number().int().positive()}).optional(),locale:N.string().optional(),budgets:P({maxDurationMs:N.number().int().positive(),maxSteps:N.number().int().positive()}),auth:P({sensitiveKeys:N.array(N.string().min(1)).optional(),requiresSession:N.boolean().optional(),allowedDomains:N.array(N.string().min(1)).optional()}).optional()}),Oe=N.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},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 H){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[Y(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:[Y(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:[Y(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[Y(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 ne(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 Z({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}},ke=P({lambdaName:N.string(),region:N.string().optional(),endpoint:N.string().optional(),invocationType:N.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:N.string().optional(),args:P({name:N.string(),value:N.unknown(),condition:N.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:N.string().optional()}),Ae=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),executedVersion:N.string().optional()}).optional(),je=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>I(e)||je.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>I(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,Me=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;try{let n=F(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||R(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!je.test(o),c=t?.qualifier,l=typeof c==`string`&&!hasExpressionMarker(c),u={...t?z(i===void 0?t:{...t,args:a},e):{},...s?{dataKey:o}:{},...l?{qualifier:c}:{}},d;try{d=ke.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?Me(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Ne=P({strategy:N.literal(`aws4`),service:N.string(),region:N.string().optional()}),Pe=P({strategy:N.literal(`hmac`),algorithm:N.enum([`sha256`,`sha512`]).optional(),headerName:N.string().optional(),prefix:N.string().optional()}),Fe=N.discriminatedUnion(`strategy`,[Ne,Pe]),Ie=P({type:N.literal(`none`),signing:Fe.optional()}),Le=P({type:N.literal(`basic`),username:N.string().optional(),password:N.string().optional(),encoding:N.string().optional()}),Re=P({type:N.literal(`bearer`),token:N.string(),includeBearer:N.boolean().optional().default(!0)}),ze=P({type:N.literal(`oauth2`),authorizationUrl:N.string().optional(),authorizationParams:N.record(N.string(),N.string()).optional(),tokenUrl:N.string().optional(),tokenParams:N.record(N.string(),N.string()).optional(),tokenExpiresIn:N.number().optional(),tokenRefreshExpiresIn:N.number().optional(),token:N.string(),includeBearer:N.boolean().optional().default(!0),scopes:N.string().optional(),scopeDelimiter:N.string().optional(),customHeaders:N.record(N.string(),N.string()).optional(),pkce:N.boolean().optional(),additionalTokenFields:N.record(N.string(),N.string().optional()).optional(),issuer:N.string().optional()}),Q=N.discriminatedUnion(`type`,[Ie,Le,Re,ze]),Be=P({certs:N.string().array().optional(),keys:N.string().array().optional()}).optional(),Ve=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V).optional().default(`get`),authorization:Q.optional(),responseMode:N.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:N.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:N.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:P({dataKey:N.string().optional(),fileNameKey:N.string().optional(),contentTypeKey:N.string().optional(),contentIsBase64:N.boolean().optional().default(!1),urlKey:N.string().optional(),forwardAuth:N.boolean().optional().default(!1)}).optional(),maxRedirects:N.number().optional().default(5),followRedirects:N.boolean().optional().default(!0),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),He=P({data:N.union([N.string(),N.instanceof(Buffer)]).optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),headers:N.record(N.string(),N.string()).optional(),contentDisposition:N.string().optional(),fileMetadata:P({contentType:N.string().optional(),contentLength:N.number().optional(),fileName:N.string().optional(),lastModified:N.string().optional(),etag:N.string().optional()}).optional(),finalUrl:N.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?z({...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}=Ve.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?J(u):{query:{},body:{},headers:{}},y=G(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});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,responseType:f,encoding:p,response:m,maxRedirects:g?h:0,requestConfig:C,authHeaders:y})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:o,authHeaders:s}=e,c=n.data;if(r.urlKey){let e=extractValueByPath(c,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?s:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:o}),l=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:l,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(c,r.dataKey);if(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)}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 re.extension(t)||void 0},Ue=N.object({event:N.object({eventType:N.string(),eventId:N.coerce.string().optional(),eventDate:N.coerce.string().optional(),data:N.unknown().optional()}).optional()}),We=N.record(N.string(),N.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?z(t,e):{},{event:r}=Ue.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}},Ge=N.object({stepsDataToGroup:N.array(N.string()),isSingleRecord:N.boolean().optional()}),Ke=N.object({data:N.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=Ge.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)}}},qe=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=Je(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Je(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},{}),Je=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}=Ye(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`),Ye=e((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=F(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return 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}},Xe=P({targetFieldKey:N.string(),alias:N.string().optional(),expression:N.string().optional(),values:N.unknown().optional(),type:N.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:N.boolean().default(!1),custom:N.boolean().default(!1),hidden:N.boolean().default(!1),enumMapper:P({matcher:N.string().or(P({matchExpression:N.string(),value:N.string()}).array())}).optional(),properties:N.lazy(()=>Xe).array().optional(),requiredScopes:N.string().array().optional()}),Ze=N.object({fields:Xe.array(),dataSource:N.string(),externalSources:N.record(N.string(),N.string()).optional()}),Qe=N.object({data:N.unknown()}),mergeSourceWithState=(e,t)=>E(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=Ze.parse(t),o=buildExpressionContext(e),s=F(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!s)return{block:e,successful:!0};let c=Object.keys(a??{})?.reduce((e,t)=>(e[t]=F(a?.[t],o),e),{}),l;if(Array.isArray(s))l=s.map(e=>{let t=$(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=F(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},$e=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=$e(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(L(e))try{return F(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return et(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},et=e((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=F(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=et(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(F(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=>ie.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:`_`+ae()},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 A,safeParseToNumber as j,safeParseToString as M,z as N,zStrictObject as P}from"@stackone/utils";import{evaluate as F,isExpression as I,isValidExpression as L,safeEvaluate as R,safeEvaluateRecord as z}from"@stackone/expressions";import{CUSTOM_ERROR_CONFIG_SCHEMA as B,HttpMethods as V,HttpResponseError as H,QueryArrayFormats as U,RequestClientFactory as ee,RequestParameterLocations as W,buildHttpsAgent as te,createAuthorizationHeaders as G,getSigningStrategy as K,isFailedStatusCode as q,parseRequestParameters as J,serializeHttpResponseError as Y,translateCustomError as X}from"@stackone/transport";import{InvokeCommand as Z,LambdaClient as ne}from"@aws-sdk/client-lambda";import re from"mime-types";import{Saml20 as ie}from"saml";import{v4 as ae}from"uuid";import{createHash as oe,createPrivateKey as se,createPublicKey as ce}from"node:crypto";import{SignJWT as le}from"jose";import ue from"form-data";const de=[`context`,`inputs`,`steps`,`intermediateSteps`,`iterator`,`result`],buildExpressionContext=(e,t={})=>{let n=t.includeCredentials??e.context?.flowType===`refresh_authentication`,r=de.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{});return n&&`credentials`in e&&(r.credentials=e.credentials),r},fe={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=>fe[e.toLowerCase()]??null,isValidCategory=e=>!!fe[e.toLowerCase()],pe=n(`so1!`),me=RegExp(`(?<!\\\\):`,`g`),he=RegExp(`(?<!\\\\),`,`g`),ge=1;var _e=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 _e{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(he).forEach(e=>{let[n,i]=e.split(me),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=>`${pe}${n(e)}`,decodeIdV1=e=>{if(!e.startsWith(pe))throw new CompositeIdMissingHeaderError(`Trying to decode an ID without the header: ${e}`);let n=e.split(pe)[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(pe),evaluateExternalAccountIdExtractor=(e,t)=>{let n=e.events?.externalAccountIdExtractor;if(T(n)||typeof n.result!=`string`||n.result.trim().length===0)return;let r=R(`{{${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=R(`{{${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,R(`{{${String(n).trim()}}}`,t)])):void 0;return{action:e.then.action,input:n}}}},ve={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=>ve[e],isValidEnumRef=e=>e in ve,ye=[`preview`,`beta`,`ga`,`deprecated`,`internal`],be=[`sync`,`async`],xe=P({r:N.record(N.string(),P({n:N.number().optional().nullable(),c:N.string().optional().nullable(),p:N.number().optional().nullable()})),v:N.number(),t:N.number()}),Se=P({remote:N.record(N.string(),P({pageNumber:N.number().optional(),providerPageCursor:N.string().optional(),position:N.number().optional()})),version:N.number(),timestamp:N.number()}),minifyCursor=e=>n(JSON.stringify(minifyCursorObject(e))),minifyCursorObject=e=>{let{remote:t,version:n,timestamp:r}=e;return{r:Object.fromEntries(Object.entries(t).map(([e,{pageNumber:t,providerPageCursor:n,position:r}])=>[e,{n:t,c:n,p:r}])),v:n,t:r}},expandCursor=e=>{try{if(D(e)){let n=t(e),r=JSON.parse(n);return expandCursorObject(xe.parse(r))}else return Se.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 _e;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 Ce={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`,Internal:`INTERNAL`},we={HTTP:`HTTP`,MCP:`MCP`,ActionRPC:`ACTION_RPC`,WebSocket:`WEBSOCKET`},Te={HTTP:`HTTP`,WebSocket:`WEBSOCKET`,SSE:`SSE`},Ee={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`)},De=N.object({startUrl:N.string().url(),systemPrompt:N.string().optional(),viewport:P({width:N.number().int().positive(),height:N.number().int().positive()}).optional(),locale:N.string().optional(),budgets:P({maxDurationMs:N.number().int().positive(),maxSteps:N.number().int().positive()}),auth:P({sensitiveKeys:N.array(N.string().min(1)).optional(),requiresSession:N.boolean().optional(),allowedDomains:N.array(N.string().min(1)).optional()}).optional()}),Oe=N.unknown(),sanitizeRaw=e=>{let t={};return e.status!=null&&(t.status=e.status),e.data!==void 0&&(t.data=e.data),e.headers!=null&&(t.headers=e.headers),e.requestUrl!=null&&(t.requestUrl=e.requestUrl),e.message!=null&&(t.message=e.message),t},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 H){let n=e.message,r=decodeResponseBody(e.response);return{block:t,successful:!1,errors:[Y(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:[Y(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:[Y(e)],output:{statusCode:500,message:e.message}}:{block:t,successful:!1,errors:[Y(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 ne(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 Z({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}},ke=P({lambdaName:N.string(),region:N.string().optional(),endpoint:N.string().optional(),invocationType:N.enum([`RequestResponse`,`Event`,`DryRun`]).optional(),qualifier:N.string().optional(),args:P({name:N.string(),value:N.unknown(),condition:N.string().optional()}).array().optional().describe(`Key/value pairs combined into the JSON payload sent to the Lambda function`),dataKey:N.string().optional()}),Ae=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),executedVersion:N.string().optional()}).optional(),je=/\${[^}]+}/,isJsonPathLike=e=>{let t=e.trimStart();return t.startsWith(`$.`)||t.startsWith(`$[`)},hasExpressionMarker=e=>I(e)||je.test(e)||isJsonPathLike(e),buildDataKeyExpression=e=>I(e)||e.trimStart().startsWith(`$`)?e:`$.${e}`,Me=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;try{let n=F(buildDataKeyExpression(t),e);if(n!==void 0)return n}catch{}return e[t]},`resolveDataKey`),buildPayloadFromArgs=e=>{if(!(!e||e.length===0))return e.reduce((e,t)=>(e[t.name]=t.value,e),{})},codeExecutionLambdaStepFunction=async({block:e,params:t},n=invokeLambda)=>{let r=t?.args,i=Array.isArray(r)?r:void 0,isPlainObject=e=>typeof e==`object`&&!!e,a=i?i.filter(t=>{if(!isPlainObject(t))return!0;let n=t.condition;return typeof n!=`string`||R(n,e)===!0}).map(e=>isPlainObject(e)?{...e,condition:void 0}:e):void 0,o=t?.dataKey,s=typeof o==`string`&&!je.test(o),c=t?.qualifier,l=typeof c==`string`&&!hasExpressionMarker(c),u={...t?z(i===void 0?t:{...t,args:a},e):{},...s?{dataKey:o}:{},...l?{qualifier:c}:{}},d;try{d=ke.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?Me(y.payload,v):y.payload,raw:y,statusCode:y.statusCode,executedVersion:y.executedVersion}}},Ne=P({strategy:N.literal(`aws4`),service:N.string(),region:N.string().optional()}),Pe=P({strategy:N.literal(`hmac`),algorithm:N.enum([`sha256`,`sha512`]).optional(),headerName:N.string().optional(),prefix:N.string().optional()}),Fe=N.discriminatedUnion(`strategy`,[Ne,Pe]),Ie=P({type:N.literal(`none`),signing:Fe.optional()}),Le=P({type:N.literal(`basic`),username:N.string().optional(),password:N.string().optional(),encoding:N.string().optional()}),Re=P({type:N.literal(`bearer`),token:N.string(),includeBearer:N.boolean().optional().default(!0)}),ze=P({type:N.literal(`oauth2`),authorizationUrl:N.string().optional(),authorizationParams:N.record(N.string(),N.string()).optional(),tokenUrl:N.string().optional(),tokenParams:N.record(N.string(),N.string()).optional(),tokenExpiresIn:N.number().optional(),tokenRefreshExpiresIn:N.number().optional(),token:N.string(),includeBearer:N.boolean().optional().default(!0),scopes:N.string().optional(),scopeDelimiter:N.string().optional(),customHeaders:N.record(N.string(),N.string()).optional(),pkce:N.boolean().optional(),additionalTokenFields:N.record(N.string(),N.string().optional()).optional(),issuer:N.string().optional(),tokenResponse:P({acceptTokenTypes:N.array(N.string()).optional()}).optional()}),Q=N.discriminatedUnion(`type`,[Ie,Le,Re,ze]),Be=P({certs:N.string().array().optional(),keys:N.string().array().optional()}).optional(),Ve=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V).optional().default(`get`),authorization:Q.optional(),responseMode:N.enum([`buffer`,`stream`]).optional().default(`buffer`),responseType:N.enum([`arraybuffer`,`blob`,`text`,`json`]).optional().default(`arraybuffer`),encoding:N.enum([`base64`,`utf8`,`binary`,`raw`,`none`]).optional().default(`base64`),response:P({dataKey:N.string().optional(),fileNameKey:N.string().optional(),contentTypeKey:N.string().optional(),contentIsBase64:N.boolean().optional().default(!1),urlKey:N.string().optional(),forwardAuth:N.boolean().optional().default(!1)}).optional(),maxRedirects:N.number().optional().default(5),followRedirects:N.boolean().optional().default(!0),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),He=P({data:N.union([N.string(),N.instanceof(Buffer)]).optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),headers:N.record(N.string(),N.string()).optional(),contentDisposition:N.string().optional(),fileMetadata:P({contentType:N.string().optional(),contentLength:N.number().optional(),fileName:N.string().optional(),lastModified:N.string().optional(),etag:N.string().optional()}).optional(),finalUrl:N.string().optional()}).optional(),downloadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?z({...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}=Ve.parse(a),_=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=u?J(u):{query:{},body:{},headers:{}},y=G(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});try{return{block:e,successful:!0,output:await performDownload({httpClient:e.httpClient,baseUrl:o??``,url:s,method:c,headers:b,queryParams:v?.query,body:v?.body,responseType:f,encoding:p,response:m,maxRedirects:g?h:0,requestConfig:C,authHeaders:y})}}catch(t){return buildStepErrorOutput(t,e)}},performStreamDownload=async e=>{let{block:t,httpClient:n,baseUrl:r,url:i,method:a,headers:o,queryParams:s,body:c,maxRedirects:l,requestConfig:u}=e,d=`${r}${i}`;if(!d.startsWith(`http://`)&&!d.startsWith(`https://`))throw Error(`Invalid URL: "${d}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);if(!n.requestStream)throw Error(`HTTP client does not support streaming. Either implement requestStream method or use responseMode: "buffer".`);try{let e=await n.requestStream({url:d,method:a,headers:o,queryParams:s,payload:c,maxRedirects:l,requestConfig:u}),r=extractFileMetadata(e.headers),i=buildContentDisposition(r);return{block:t,successful:!0,streamOutput:{stream:e.stream,headers:e.headers,contentDisposition:i,fileMetadata:r}}}catch(e){return buildStepErrorOutput(e,t)}},performDownload=async e=>{let{httpClient:t,baseUrl:n,url:r,method:i,headers:a,queryParams:o,body:s,responseType:c,encoding:l,response:u,maxRedirects:d,requestConfig:f,authHeaders:p}=e,m=`${n}${r}`;if(!m.startsWith(`http://`)&&!m.startsWith(`https://`))throw Error(`Invalid URL: "${m}". URL must be absolute (start with http:// or https://). Either provide a baseUrl or ensure url is a complete URL.`);let h=u?.urlKey||u?.dataKey?`json`:c,g=await t.request({url:m,method:i,headers:a,queryParams:o,payload:s,responseType:h===`json`?void 0:h,maxRedirects:d,requestConfig:f});if(u?.urlKey||u?.dataKey)return handleJsonResponse({httpClient:t,result:g,response:u,encoding:l,maxRedirects:d,requestConfig:f,authHeaders:p});let _=encodeFileData(g.data,l),v=extractFileMetadata(g.headers),y=buildContentDisposition(v);return{data:_,raw:g,statusCode:g?.status,message:g?.message,headers:g.headers,contentDisposition:y,fileMetadata:v,finalUrl:g?.requestUrl}},handleJsonResponse=async e=>{let{httpClient:t,result:n,response:r,encoding:i,maxRedirects:a,requestConfig:o,authHeaders:s}=e,c=n.data;if(r.urlKey){let e=extractValueByPath(c,r.urlKey);if(typeof e==`string`){let n=await t.request({url:e,method:`get`,headers:r.forwardAuth?s:{},responseType:`arraybuffer`,maxRedirects:a,requestConfig:o}),l=encodeFileData(n.data,i),u=extractFileMetadata(n.headers);if(r.fileNameKey){let e=extractValueByPath(c,r.fileNameKey);typeof e==`string`&&(u.fileName=e)}if(r.contentTypeKey){let e=extractValueByPath(c,r.contentTypeKey);typeof e==`string`&&(u.contentType=e)}let d=buildContentDisposition(u);return{data:l,raw:n,statusCode:n?.status,message:n?.message,headers:n.headers,contentDisposition:d,fileMetadata:u,finalUrl:e}}}if(r.dataKey){let e=extractValueByPath(c,r.dataKey);if(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)}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 re.extension(t)||void 0},Ue=N.object({event:N.object({eventType:N.string(),eventId:N.coerce.string().optional(),eventDate:N.coerce.string().optional(),data:N.unknown().optional()}).optional()}),We=N.record(N.string(),N.unknown()),emitEventStepFunction=async({block:e,params:t})=>{let n=t?z(t,e):{},{event:r}=Ue.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}},Ge=N.object({stepsDataToGroup:N.array(N.string()),isSingleRecord:N.boolean().optional()}),Ke=N.object({data:N.unknown()}),groupDataStepFunction=async({block:e,params:t})=>{let{stepsDataToGroup:n,isSingleRecord:r}=Ge.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)}}},qe=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=Je(e,t,extractSingleRecordBlockStepData(r,o,a),i);return n.push(...s.errors||[]),s.record})}else{let o=Je(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},{}),Je=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}=Ye(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`),Ye=e((e,t,n)=>{let{expression:r,targetFieldKey:i}=n;if(!r)return{error:{message:`Expression is empty`,id:t,targetField:i}};let a;try{a=F(r,e)}catch{return{error:{message:`Invalid expression`,id:t,targetField:i}}}return a===void 0?{error:{message:`Expression returned no value`,id:t,targetField:i}}:{value:a}},`extractFieldValue`),getEnumMatcher=e=>{switch(e){case`country_alpha2code_by_alpha2code`:return 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}},Xe=P({targetFieldKey:N.string(),alias:N.string().optional(),expression:N.string().optional(),values:N.unknown().optional(),type:N.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:N.boolean().default(!1),custom:N.boolean().default(!1),hidden:N.boolean().default(!1),enumMapper:P({matcher:N.string().or(P({matchExpression:N.string(),value:N.string()}).array())}).optional(),properties:N.lazy(()=>Xe).array().optional(),requiredScopes:N.string().array().optional()}),Ze=N.object({fields:Xe.array(),dataSource:N.string(),externalSources:N.record(N.string(),N.string()).optional()}),Qe=N.object({data:N.unknown()}),mergeSourceWithState=(e,t)=>E(e)?{...t,...e}:e,mapFieldsStepFunction=async({block:e,params:t})=>{let n=[],{fields:r,dataSource:i,externalSources:a}=Ze.parse(t),o=buildExpressionContext(e),s=F(i,o);if(!r||!i||e?.debug?.custom_mappings===`disabled`||!s)return{block:e,successful:!0};let c=Object.keys(a??{})?.reduce((e,t)=>(e[t]=F(a?.[t],o),e),{}),l;if(Array.isArray(s))l=s.map(e=>{let t=$(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=F(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},$e=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=$e(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(L(e))try{return F(e,t)}catch{return e}return e}if(Array.isArray(e))return e.map(e=>evaluateExpressionsInObject(e,t));if(typeof e==`object`){let n={...e};for(let[e,r]of Object.entries(n))n[e]=evaluateExpressionsInObject(r,t);return n}return e},extractFieldValue=(e,t,n)=>{switch(n.type){case`string`:case`number`:case`boolean`:case`datetime_string`:return et(n,t,e);case`enum`:return evaluateEnumValue(n,t,e);default:return{error:{message:`Invalid type`,id:t,targetField:n.targetFieldKey}}}},et=e((e,t,n)=>{if(!e.expression)return{error:{message:`Expression is empty`,id:t,targetField:e.targetFieldKey}};let r;try{r=F(e.expression,n)}catch{return{error:{message:`Invalid expression`,id:t,targetField:e.targetFieldKey}}}return r===void 0?{error:{message:`Expression returned no value`,id:t,targetField:e.targetFieldKey}}:{value:r}},`evaluateValue`),evaluateEnumValue=(e,t,n)=>{let r=et(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(F(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=>ie.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:`_`+ae()},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-----`)},tt=N.object({baseUrl:N.string(),url:N.string(),method:N.enum(V),saml:P({objectKey:N.string(),key:N.string(),clientId:N.string(),cert:N.unknown().optional(),issuer:N.string().optional(),lifetime:N.number().optional(),nameId:N.string().optional(),audience:N.string().optional(),nameIdentifierFormat:N.string().optional(),tokenEndpoint:N.string().optional()}).optional(),response:P({indexField:N.string().optional(),dataKey:N.string().optional(),nextKey:N.string().optional(),nextKeyIn:N.enum([`data`,`headers`]).optional()}).optional(),iterator:P({key:N.string(),in:N.enum(W),condition:N.string().optional(),mode:N.enum([`cursor`,`offset`]).optional()}),cursor:P({token:N.string().optional().nullable(),position:N.number().optional().nullable()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),nt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),next:N.string().optional().nullable(),position:N.number().optional()}).optional(),rt=e(e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},`isJexlExpression`),paginatedRequestStepFunction=async({block:e,params:t})=>{let n=ee.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||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,s=t?z({...t,args:o},e):{},c=t?.response?.nextKey,l=c&&rt(c),u=t?.response?.dataKey,d=u&&rt(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}=tt.parse(p),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment],w=C?.authorization,D=C?.certificates,k=D?te(D):void 0,A=Q.parse(w),j=x?J(x):{query:{},body:{},headers:{}},M=G(A),N={...j?.headers??{},...M},P=e.connector?.rateLimit,I=e.connector?.concurrency,L=P!==void 0||I!==void 0?{rateLimit:P,concurrency:I}:void 0,B=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})}:{},V=v.mode===`offset`,H=y?.token??null,U=null,W=null,K=[],q=[],Y=[],X=a,Z=y?.position??0,ne=!0,re=!0,ie=!0;do{ne?ne=!1:V||(Z=0),H===null?V&&(v.in===`query`?j.query[v.key]=Z.toString():v.in===`body`&&(Array.isArray(j.body)||(j.body[v.key]=Z))):v.in===`query`?E(H)?Object.entries(H).forEach(([e,t])=>{j.query[`${v.key}[${e}]`]=t?.toString()??``}):j.query[v.key]=H.toString():v.in===`body`&&(Array.isArray(j.body)||(j.body[v.key]=H));let t;try{t=await n.performRequest({httpClient:e.httpClient,url:`${m}${h}`,queryParams:{...j?.query},method:g,headers:{...N},body:Array.isArray(j?.body)?j.body:{...j?.body,...B},customErrorConfigs:b,requestConfig:L,httpsAgent:k,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}U=H,q=_?.dataKey?it(t.data,_.dataKey):t.data;let r=V?q?.slice(0,X):q?.slice(Z,Z+X);X-=r.length,Z+=r.length,Y.push(t),K=K.concat(r),W=t?.status,H=at({result:t,response:_}),ie=O(v.condition)?R(v.condition,t.data)===!0:!0,!V&&r.length===q.length&&X===0&&(Z=0,U=H),re=!ie||T(H)&&K.length<a}while((V||O(H))&&ie&&K.length<a&&q?.length>0);return{block:e,successful:!0,output:{data:ct(K,_),raw:Y,statusCode:W,next:re?void 0:U,position:re?void 0:Z}}},it=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;let n=R(rt(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},`resolveDataKey`),at=e(({result:e,response:t})=>{if(T(t?.nextKey))return null;let n=t?.nextKeyIn??`data`,r=t?.nextKey;return n===`headers`?ot(e.headers,r):st(e.data,r)},`resolveNextIterator`),ot=e((e,t)=>{if(T(e)||typeof e!=`object`)return null;if(rt(t)){let n=R(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`),st=e((e,t)=>{if(T(e)||typeof e!=`object`||!e)return null;let n=R(rt(t)?t:`$.${t}`,e);return T(n)?null:typeof n==`string`||typeof n==`number`||typeof n==`object`?n:null},`resolveFromData`),ct=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`),lt=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V),authorization:Q.optional(),certificates:Be,saml:P({objectKey:N.string(),key:N.string(),clientId:N.string(),cert:N.unknown().optional(),issuer:N.string().optional(),lifetime:N.number().optional(),nameId:N.string().optional(),audience:N.string().optional(),nameIdentifierFormat:N.string().optional(),tokenEndpoint:N.string().optional()}).optional(),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),ut=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),isJexlExpression=e=>{let t=e.trim();return t.startsWith(`{{`)&&t.endsWith(`}}`)},requestStepFunction=async({block:e,params:t})=>{let n=ee.build();if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?.response?.dataKey,o=a&&isJexlExpression(a),s=t?z({...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:_}=lt.parse(c),v=s?.authentication?.[e.context.authenticationType]?.[e.context.environment],y=v?.authorization,b=m??v?.certificates,x=b?te(b):void 0,S=g?J(g):{query:{},body:{},headers:{}},C=O(p)?p:Q.parse(y),w=G(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,A=O(_)?{[_.objectKey]:await generateSamlAssertion({key:_.key,clientId:_.clientId,cert:_.cert,issuer:_.issuer,lifetime:_.lifetime,audience:_.audience,nameId:_.nameId,nameIdentifierFormat:_.nameIdentifierFormat,tokenEndpoint:_.tokenEndpoint})}:{},j=Array.isArray(S?.body)?S?.body:{...S?.body,...A};if(C.type===`none`&&C.signing?.strategy){let t=C.signing,n=e.credentials??{};try{let e=K(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:j},n,t);Object.assign(T,r)}catch(t){return buildStepErrorOutput(t,e)}}let M;try{M=await n.performRequest({httpClient:e.httpClient,url:`${l}${u}`,queryParams:S?.query,method:d,headers:T,body:j,customErrorConfigs:h,requestConfig:k,httpsAgent:x,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}return{block:e,successful:!0,output:{data:dt(f?.dataKey?resolveDataKey(M.data,f.dataKey):M.data,f),raw:M,statusCode:M?.status,message:M?.message}}},resolveDataKey=(e,t)=>{if(T(e)||typeof e!=`object`||!e)return e;let n=R(isJexlExpression(t)?t:`$.${t}`,e);return n===void 0?e[t]:n},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`),ft=N.union([N.string(),N.number()]),pt=P({algorithm:N.literal(`RS256`),privateKey:N.string(),claims:N.record(N.string(),ft)}),mt=P({token:N.string(),expiresIn:N.number(),publicKeyFingerprint:N.string()}),computePublicKeyFingerprint=e=>{let t=e.export({format:`der`,type:`spki`});return`SHA256:${oe(`sha256`).update(t).digest(`base64`)}`},ht=/^now$/,gt=/^now\+(?<amount>\d+)(?<unit>[smh])$/,_t=`{publicKeyFingerprint}`,vt={s:1,m:60,h:3600},yt=new Set([`iat`,`exp`,`nbf`]),resolveClaimValue=(e,t,{now:n,publicKeyFingerprint:r})=>{if(typeof t==`number`)return t;let i=t.includes(_t)?t.split(_t).join(r):t;if(!yt.has(e))return i;if(ht.test(i))return n;let a=i.match(gt);return a?.groups?n+Number(a.groups.amount)*vt[a.groups.unit]:i},signJwtStepFunction=async({block:e,params:t})=>{try{let n=t?z(t,e):void 0,{algorithm:r,privateKey:i,claims:a}=pt.parse(n),o=se(i),s=computePublicKeyFingerprint(ce(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 le(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)}},bt=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V),authorization:N.discriminatedUnion(`type`,[P({type:N.literal(`none`)}),P({type:N.literal(`basic`),username:N.string().optional(),password:N.string().optional(),encoding:N.string().optional()}),P({type:N.literal(`bearer`),token:N.string(),includeBearer:N.boolean().optional().default(!0)}),P({type:N.literal(`oauth2`),token:N.string(),includeBearer:N.boolean().optional().default(!0)})]).optional(),envelope:N.union([N.string(),N.record(N.string(),N.unknown())]).optional(),namespaces:N.strictObject({namespaceIdentifier:N.string(),namespace:N.string()}).array().optional(),soapOperation:N.string().optional(),soapAction:N.string().optional(),useSoapContext:N.boolean().optional().default(!0),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional(),nextKey:N.string().optional(),nextKeyIn:N.enum([`data`,`headers`]).optional()}).optional(),iterator:P({key:N.string(),in:N.enum(W)}),cursor:P({token:N.string().optional().nullable(),position:N.number().optional().nullable()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),xt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional(),next:N.string().optional().nullable(),position:N.number().optional()}).optional(),soapPaginatedRequestStepFunction=async({block:e,params:t})=>{let n=ee.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=Number(e.inputs?.page_size),a=Number.isNaN(i)?25:i,o=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,s=t?z({...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}=bt.parse(c),C=s?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,w=_?J(_):{query:{},body:{},headers:{}},E=G(O(h)?h:Q.parse(C)),D={...w?.headers??{},...E},k=e.connector?.rateLimit,A=e.connector?.concurrency,j={...(k!==void 0||A!==void 0)&&{rateLimit:k,concurrency:A},soapOperation:v,namespaces:y,envelope:b,soapAction:x,soapContext:S?{username:e.credentials?.username,password:e.credentials?.password}:void 0},M=m?.token??null,N=null,P=null,I=[],L=[],R=[],B=a,V=m?.position??0,H=!0,U;do{H?H=!1:V=0,M!==null&&(p.in===`query`?w.query[p.key]=M.toString():p.in===`body`&&(w.body[p.key]=M));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:j,credentials:e.credentials})}catch(t){return buildStepErrorOutput(t,e)}N=M,L=f?.dataKey?t.data[f?.dataKey]:t.data,Array.isArray(L)||(L=L?[L]:[]);let r=L?.slice(V,V+B);B-=r.length,V+=r.length,R.push(t),I=I.concat(r),P=t?.status,M=resolveNextIterator({result:t,response:f}),r.length===L.length&&B===0&&(V=0,N=M),U=T(M)&&I.length<a}while(O(M)&&I.length<a&&L?.length>0);return{block:e,successful:!0,output:{data:St(I,f),raw:R,statusCode:P,next:U?void 0:N,position:U?void 0:V}}},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},St=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`),Ct=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V),authorization:Q.optional(),envelope:N.union([N.string(),N.record(N.string(),N.unknown())]).optional(),namespaces:N.strictObject({namespaceIdentifier:N.string(),namespace:N.string()}).array().optional(),soapOperation:N.string().optional(),soapAction:N.string().optional(),useSoapContext:N.boolean().optional().default(!0),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional()}),wt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),soapRequestStepFunction=async({block:e,params:t})=>{let n=ee.build(`soap`);if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:r}=t,i=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=t?z({...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}=Ct.parse(o),y=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,b=p?J(p):{query:{},body:{},headers:{}},x=G(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:Tt(u?.dataKey?E.data[u?.dataKey]:E.data,u),raw:E,statusCode:E?.status,message:E?.message}}},Tt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Et=N.object({values:N.string().or(N.record(N.string(),N.unknown())).or(N.array(N.unknown()))}),Dt=N.object({data:N.unknown()}),staticValuesStepFunction=async({block:e,params:t})=>{let{values:n}=Et.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)?R(e,t):E(e)?z(e,t):e,Ot=N.object({targetFieldKey:N.string(),type:N.enum([`string`,`number`,`boolean`,`datetime_string`,`enum`,`object`]),array:N.boolean().default(!1),custom:N.boolean().default(!1),hidden:N.boolean().default(!1),properties:N.lazy(()=>Ot).array().optional(),requiredScopes:N.string().array().optional()}),kt=N.object({fields:Ot.array().optional(),dataSource:N.string()}),At=N.object({data:N.unknown()});let jt=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 M({value:e});case`number`:return j({value:e});case`boolean`:return k({value:e});case`datetime_string`:return A({value:e,format:n});default:return e}},isFieldSupportedType=e=>Object.values(jt).includes(e),Mt=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=>Nt(e,t)):Nt(e.result,t),{block:{...e,result:n},successful:!0}},`typecastStepFunction`),Nt=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}=kt.parse(t),i=F(r,buildExpressionContext(e));if(!n||e?.debug?.custom_mappings===`disabled`)return{block:e,successful:!0};let a;return a=Array.isArray(i)?i.map(e=>mapSingleRecord(e,n)):mapSingleRecord(i,n),{block:{...e},successful:!0,output:{data:a}}},handleObjectField=(e,t)=>!e.properties||!t?t:Array.isArray(t)?t.map(t=>typeof t==`object`&&t?mapSingleRecord(t,e.properties):t):typeof t==`object`&&t?mapSingleRecord(t,e.properties):t,mapSingleRecord=(e,t)=>{let n={...e};return t.forEach(t=>{let{targetFieldKey:r,type:i,array:a}=t;i===`object`?!t.custom&&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}},Pt=P({content:N.string().describe(`The file content as base64 encoded string`),contentType:N.string().optional().describe(`The MIME type for the binary content (defaults to application/octet-stream)`)}),Ft=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V).default(`post`),authorization:Q.optional(),binaryContent:Pt.describe(`Raw binary content for octet-stream uploads`),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),It=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),uploadBinaryStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n}=t,r=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,i=t?z({...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}=Ft.parse(a),m=i?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,h=f?J(f):{query:{},body:{},headers:{}},g=G(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:[Y(t)],output:{statusCode:n?.response?.status??500,message:n?.response?.message}}}let C=X(S,p,e.credentials);return q(C?.status)?{block:e,successful:!1,errors:[Y(new H(C,C.message))],output:{statusCode:C.status,message:C.message}}:{block:e,successful:!0,output:{data:Lt(l?.dataKey?C.data[l?.dataKey]:C.data,l),raw:C,statusCode:C?.status,message:C?.message}}},Lt=e((e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce((e,n)=>{let r=t.indexField;return r&&n[r]&&(e[n[r]]=n),e},{});if(!t?.collection&&t?.indexField){let n=t.indexField;return n&&e[n]?{[e[n]]:e}:e}return e},`indexResponseData`),Rt=P({fieldName:N.string().describe(`The form field name for the file`),content:N.string().describe(`The file content as base64 encoded string`),filename:N.string().describe(`The filename to use in the upload`),contentType:N.string().optional().describe(`The MIME type of the file (e.g., "image/png", "application/pdf")`)}),zt=N.object({baseUrl:N.string().optional(),url:N.string(),method:N.enum(V).default(`post`),authorization:Q.optional(),file:Rt.describe(`The file to upload`),additionalFields:P({name:N.string(),value:N.unknown(),condition:N.string().optional(),contentType:N.string().optional().describe(`The MIME type for this form field (e.g., "application/json")`)}).array().optional().describe(`Additional form fields to include in the multipart request`),response:P({collection:N.boolean().optional(),indexField:N.string().optional(),dataKey:N.string().optional()}).optional(),customErrors:B.array().optional(),args:P({name:N.string(),value:N.unknown(),in:N.enum(W),spread:N.boolean().optional(),condition:N.string().optional(),arrayFormat:N.enum(U).optional()}).array().optional().describe(`Additional request parameters (query params, headers)`)}),Bt=P({data:N.unknown().optional(),raw:N.unknown().optional(),statusCode:N.number(),message:N.string().optional()}).optional(),uploadFileStepFunction=async({block:e,params:t})=>{if(!e.httpClient)throw Error(`HTTP client is not configured`);let{args:n,additionalFields:r}=t,i=n?n.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,a=r?r.filter(t=>!t.condition||F(t.condition,e)===!0).map(e=>({...e,condition:void 0})):void 0,o=t?z({...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}=zt.parse(s),_=o?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,v=h?J(h):{query:{},body:{},headers:{}},y=G(O(f)?f:Q.parse(_)),b=new ue;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=X(E,g,e.credentials);return q(D?.status)?buildStepErrorOutput(new H(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 Vt=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 Ht={typecast:{v1:{fn:Mt},v2:{fn:typecastStepFunction,inputSchema:kt,outputSchema:At}},map_fields:{v1:{fn:qe},v2:{fn:mapFieldsStepFunction,inputSchema:Ze,outputSchema:Qe}},request:{v1:{fn:requestStepFunction,inputSchema:lt,outputSchema:ut}},group_data:{v1:{fn:groupDataStepFunction,inputSchema:Ge,outputSchema:Ke}},paginated_request:{v1:{fn:paginatedRequestStepFunction,inputSchema:tt,outputSchema:nt}},soap_request:{v1:{fn:soapRequestStepFunction,inputSchema:Ct,outputSchema:wt}},soap_paginated_request:{v1:{fn:soapPaginatedRequestStepFunction,inputSchema:bt,outputSchema:xt}},static_values:{v1:{fn:staticValuesStepFunction,inputSchema:Et,outputSchema:Dt}},upload_file:{v1:{fn:uploadFileStepFunction,inputSchema:zt,outputSchema:Bt}},upload_binary:{v1:{fn:uploadBinaryStepFunction,inputSchema:Ft,outputSchema:It}},download_file:{v1:{fn:downloadFileStepFunction,inputSchema:Ve,outputSchema:He}},emit_event:{v1:{fn:emitEventStepFunction,inputSchema:Ue,outputSchema:We}},browser_use:{v1:{fn:browserUseStepFunction,inputSchema:De,outputSchema:Oe}},code_execution_lambda:{v1:{fn:codeExecutionLambdaStepFunction,inputSchema:ke,outputSchema:Ae}},sign_jwt:{v1:{fn:signJwtStepFunction,inputSchema:pt,outputSchema:mt}}},formatZodIssues=(e,t,n)=>e instanceof N.ZodError?e.issues.map(e=>({...e,kind:t,functionName:n})):[{kind:t,functionName:n,message:e?.message??`unknown error`}],stepFunctionEnhancedWithSchemasValidation=(e,t)=>async({block:n,params:r})=>{try{e.inputSchema&&e.inputSchema.parse(r)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`input_schema_validation`,t)}}let i=await e.fn({block:n,params:r});try{e.outputSchema&&e.outputSchema.parse(i.output)}catch(e){return{block:n,successful:!1,errors:formatZodIssues(e,`output_schema_validation`,t)}}return i},Ut={build({functionName:e,version:t=`1`,validateSchemas:n=!1,stepFunctionsList:r=Ht}){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,Ee as AuthType,De as BROWSER_USE_INPUT_PARAMS,Oe as BROWSER_USE_OUTPUT,ge as COMPOSITE_ID_LATEST_VERSION,_e as CoreError,be as ExecutionModes,ve as INPUT_ENUM_REGISTRY,ye as ReleaseStages,Ce as SourceType,Vt as StepFunctionName,Ut as StepFunctionsFactory,Ht as StepFunctionsRegistry,Te as StreamType,we 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.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",