cliodot 1.2.3 → 1.2.4
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/LICENSE +201 -0
- package/README.md +2 -0
- package/dist/AuthAppClient.d.ts +1 -0
- package/dist/AuthAppClient.d.ts.map +1 -1
- package/dist/AuthAppClient.js +199 -1
- package/dist/CommercialAppClient.d.ts +50 -9
- package/dist/CommercialAppClient.d.ts.map +1 -1
- package/dist/CommercialAppClient.js +576 -1
- package/dist/ConnectorBuilder.js +104 -1
- package/dist/Events.d.ts +2 -0
- package/dist/Events.d.ts.map +1 -1
- package/dist/Events.js +325 -1
- package/dist/Flosync.js +296 -1
- package/dist/FlosyncClient.js +429 -1
- package/dist/FunctionBuilder.js +65 -1
- package/dist/IdentityAppClient.d.ts +1 -0
- package/dist/IdentityAppClient.d.ts.map +1 -1
- package/dist/IdentityAppClient.js +197 -1
- package/dist/MemoryAppClient.d.ts +1 -0
- package/dist/MemoryAppClient.d.ts.map +1 -1
- package/dist/MemoryAppClient.js +149 -1
- package/dist/MemoryClient.js +20 -1
- package/dist/OAuthAppClient.d.ts +1 -0
- package/dist/OAuthAppClient.d.ts.map +1 -1
- package/dist/OAuthAppClient.js +269 -1
- package/dist/ProviderServicesClient.d.ts +24 -0
- package/dist/ProviderServicesClient.d.ts.map +1 -0
- package/dist/ProviderServicesClient.js +158 -0
- package/dist/Surface.d.ts +2 -0
- package/dist/Surface.d.ts.map +1 -1
- package/dist/Surface.js +255 -1
- package/dist/ValidatorBuilder.js +24 -1
- package/dist/Webhooks.js +61 -1
- package/dist/WorkflowBuilder.js +279 -1
- package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
- package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/CommercialAppClient.test.js +217 -0
- package/dist/__tests__/Events.test.js +191 -1
- package/dist/__tests__/IdentityAppClient.test.js +232 -1
- package/dist/__tests__/OAuthAppClient.test.js +300 -1
- package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
- package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
- package/dist/__tests__/ProviderServicesClient.test.js +131 -0
- package/dist/__tests__/Surface.test.js +150 -1
- package/dist/__tests__/errors.test.js +54 -1
- package/dist/__tests__/function.test.js +58 -1
- package/dist/__tests__/helpers.d.ts +5 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/__tests__/helpers.js +10 -0
- package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
- package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
- package/dist/__tests__/localhost-lookup.test.js +26 -0
- package/dist/__tests__/parse-api-error.test.js +26 -1
- package/dist/__tests__/runner.test.js +156 -1
- package/dist/connectors/builtin.js +354 -1
- package/dist/connectors/registry.js +300 -1
- package/dist/decorators/build.js +105 -1
- package/dist/decorators/connector.js +56 -1
- package/dist/decorators/index.js +34 -1
- package/dist/decorators/metadata.js +338 -1
- package/dist/decorators/steps.js +220 -1
- package/dist/decorators/workflow.js +52 -1
- package/dist/errors.js +76 -1
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-result.test.js +57 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
- package/dist/http/__tests__/events-instance-id.test.js +45 -0
- package/dist/http/cliodot-request.d.ts +35 -0
- package/dist/http/cliodot-request.d.ts.map +1 -0
- package/dist/http/cliodot-request.js +105 -0
- package/dist/http/cliodot-result.d.ts +40 -0
- package/dist/http/cliodot-result.d.ts.map +1 -0
- package/dist/http/cliodot-result.js +139 -0
- package/dist/http/create-client.d.ts +3 -0
- package/dist/http/create-client.d.ts.map +1 -0
- package/dist/http/create-client.js +14 -0
- package/dist/http/events-instance-id.d.ts +11 -0
- package/dist/http/events-instance-id.d.ts.map +1 -0
- package/dist/http/events-instance-id.js +86 -0
- package/dist/http/localhost-lookup.d.ts +12 -0
- package/dist/http/localhost-lookup.d.ts.map +1 -0
- package/dist/http/localhost-lookup.js +67 -0
- package/dist/http/parse-api-error.js +56 -1
- package/dist/http/sanitize-execution-headers.js +79 -1
- package/dist/identity-offline-verify.js +174 -1
- package/dist/identity-token-cache.js +51 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -1
- package/dist/runner/ProcessorEngine.js +1311 -1
- package/dist/runner/connector.executor.js +1786 -1
- package/dist/runner/utilities/math.executor.js +153 -1
- package/dist/runner/utilities/random.executor.js +151 -1
- package/dist/runner/utilities/string.executor.js +825 -1
- package/dist/template.js +127 -1
- package/dist/transformers/StepsToNodesTransformer.js +214 -1
- package/dist/transformers/WorkflowTransformer.js +189 -1
- package/dist/types/auth-app.api.d.ts +2 -0
- package/dist/types/auth-app.api.d.ts.map +1 -1
- package/dist/types/auth-app.api.js +2 -1
- package/dist/types/builtin.js +2 -1
- package/dist/types/client.api.js +2 -1
- package/dist/types/commercial-app.api.d.ts +407 -11
- package/dist/types/commercial-app.api.d.ts.map +1 -1
- package/dist/types/commercial-app.api.js +2 -1
- package/dist/types/connector.js +2 -1
- package/dist/types/context.js +2 -1
- package/dist/types/event-app.api.d.ts +8 -0
- package/dist/types/event-app.api.d.ts.map +1 -1
- package/dist/types/event-app.api.js +2 -1
- package/dist/types/function.js +2 -1
- package/dist/types/identity-app.api.d.ts +2 -0
- package/dist/types/identity-app.api.d.ts.map +1 -1
- package/dist/types/identity-app.api.js +2 -1
- package/dist/types/index.js +23 -1
- package/dist/types/memory-app.api.d.ts +2 -0
- package/dist/types/memory-app.api.d.ts.map +1 -1
- package/dist/types/memory-app.api.js +2 -1
- package/dist/types/oauth-app.api.d.ts +2 -0
- package/dist/types/oauth-app.api.d.ts.map +1 -1
- package/dist/types/oauth-app.api.js +105 -1
- package/dist/types/provider-services.api.d.ts +98 -0
- package/dist/types/provider-services.api.d.ts.map +1 -0
- package/dist/types/provider-services.api.js +2 -0
- package/dist/types/validator.js +2 -1
- package/dist/types/webhook-app.api.js +2 -1
- package/dist/types/workflow.js +33 -1
- package/dist/validators/validators.js +478 -1
- package/dist/variable.js +37 -1
- package/package.json +3 -2
|
@@ -1 +1,1311 @@
|
|
|
1
|
-
'use strict';const _0x50b4ea=_0x5e10;(function(_0x1a7a32,_0x5e6c48){const _0x48f28c=_0x5e10,_0x1e2adf=_0x1a7a32();while(!![]){try{const _0x2ef0a1=-parseInt(_0x48f28c(0x18c))/0x1+parseInt(_0x48f28c(0x20f))/0x2+parseInt(_0x48f28c(0x24d))/0x3*(-parseInt(_0x48f28c(0x1bd))/0x4)+-parseInt(_0x48f28c(0x1c1))/0x5+parseInt(_0x48f28c(0x19d))/0x6+-parseInt(_0x48f28c(0x249))/0x7+-parseInt(_0x48f28c(0x23f))/0x8*(-parseInt(_0x48f28c(0x1e9))/0x9);if(_0x2ef0a1===_0x5e6c48)break;else _0x1e2adf['push'](_0x1e2adf['shift']());}catch(_0x3dd826){_0x1e2adf['push'](_0x1e2adf['shift']());}}}(_0x4d39,0xab7a0));function _0x5e10(_0x47c397,_0x26d0a4){_0x47c397=_0x47c397-0x188;const _0x4d3903=_0x4d39();let _0x5e100b=_0x4d3903[_0x47c397];if(_0x5e10['yWgNEo']===undefined){var _0x2d606e=function(_0x58cc55){const _0x51de7e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x276888='',_0xfb7d6f='';for(let _0x3dc31c=0x0,_0xeffdfb,_0x5f31ba,_0xac11d0=0x0;_0x5f31ba=_0x58cc55['charAt'](_0xac11d0++);~_0x5f31ba&&(_0xeffdfb=_0x3dc31c%0x4?_0xeffdfb*0x40+_0x5f31ba:_0x5f31ba,_0x3dc31c++%0x4)?_0x276888+=String['fromCharCode'](0xff&_0xeffdfb>>(-0x2*_0x3dc31c&0x6)):0x0){_0x5f31ba=_0x51de7e['indexOf'](_0x5f31ba);}for(let _0x14966c=0x0,_0x4fcba7=_0x276888['length'];_0x14966c<_0x4fcba7;_0x14966c++){_0xfb7d6f+='%'+('00'+_0x276888['charCodeAt'](_0x14966c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xfb7d6f);};_0x5e10['sxMWZy']=_0x2d606e,_0x5e10['XKQQRv']={},_0x5e10['yWgNEo']=!![];}const _0x5dd223=_0x4d3903[0x0],_0xdbba92=_0x47c397+_0x5dd223,_0x510983=_0x5e10['XKQQRv'][_0xdbba92];return!_0x510983?(_0x5e100b=_0x5e10['sxMWZy'](_0x5e100b),_0x5e10['XKQQRv'][_0xdbba92]=_0x5e100b):_0x5e100b=_0x510983,_0x5e100b;}Object[_0x50b4ea(0x230)](exports,_0x50b4ea(0x245),{'value':!![]}),exports['ProcessorEngine']=void 0x0;const template_1=require(_0x50b4ea(0x1be));function resolveTemplateOrExpression(value,_0x276888){const _0xb67b29=_0x50b4ea;if(typeof value!==_0xb67b29(0x241))return Promise[_0xb67b29(0x1c9)](value);const _0xfb7d6f=value[_0xb67b29(0x1c4)]();if(_0xfb7d6f[_0xb67b29(0x209)]('{{')&&_0xfb7d6f[_0xb67b29(0x22e)]('}}')){const _0x3dc31c=_0xfb7d6f[_0xb67b29(0x22f)](0x2,-0x2)[_0xb67b29(0x1c4)]();return(0x0,template_1[_0xb67b29(0x1fd)])(_0x3dc31c,_0x276888);}return(0x0,template_1[_0xb67b29(0x1f5)])(value,_0x276888);}async function renderBodyRecursive(_0xeffdfb,_0x5f31ba){const _0x57bce0=_0x50b4ea;if(_0xeffdfb==null)return _0xeffdfb;if(typeof _0xeffdfb===_0x57bce0(0x241)&&_0xeffdfb[_0x57bce0(0x1e5)]('{{')){const _0xac11d0=await(0x0,template_1['renderTemplate'])(_0xeffdfb,_0x5f31ba);if(typeof _0xac11d0===_0x57bce0(0x241)&&_0xac11d0['startsWith']('{')&&_0xac11d0['endsWith']('}'))try{return JSON[_0x57bce0(0x257)](_0xac11d0);}catch{return _0xac11d0;}if(typeof _0xac11d0===_0x57bce0(0x241)&&_0xac11d0[_0x57bce0(0x209)]('[')&&_0xac11d0[_0x57bce0(0x22e)](']'))try{return JSON[_0x57bce0(0x257)](_0xac11d0);}catch{return _0xac11d0;}return _0xac11d0;}if(Array[_0x57bce0(0x244)](_0xeffdfb))return Promise[_0x57bce0(0x1a7)](_0xeffdfb['map'](_0x14966c=>renderBodyRecursive(_0x14966c,_0x5f31ba)));if(typeof _0xeffdfb===_0x57bce0(0x1f6)){const _0x4fcba7={};for(const _0x1f51bb of Object[_0x57bce0(0x217)](_0xeffdfb)){_0x4fcba7[_0x1f51bb]=await renderBodyRecursive(_0xeffdfb[_0x1f51bb],_0x5f31ba);}return _0x4fcba7;}return _0xeffdfb;}const connector_executor_1=require(_0x50b4ea(0x1ca)),validators_1=require(_0x50b4ea(0x19b)),builtin_1=require(_0x50b4ea(0x1e1)),workflow_1=require(_0x50b4ea(0x1a2));function parseHttpErrorResponseData(_0x475701){const _0x759625=_0x50b4ea;if(_0x475701===undefined||_0x475701===null)return _0x475701;if(typeof _0x475701===_0x759625(0x1f6))return _0x475701;if(typeof _0x475701==='string'){const _0x815a35=_0x475701[_0x759625(0x1c4)]();if(_0x815a35['startsWith']('{')&&_0x815a35[_0x759625(0x22e)]('}')||_0x815a35[_0x759625(0x209)]('[')&&_0x815a35[_0x759625(0x22e)](']'))try{return JSON[_0x759625(0x257)](_0x815a35);}catch{return _0x475701;}return _0x475701;}return _0x475701;}function buildHttpStepFailurePayload(_0x317fce){const _0x540e0e=_0x50b4ea,_0x1690d4=_0x317fce?.[_0x540e0e(0x1e7)],_0x532607=_0x317fce?.['data']!==undefined?_0x317fce[_0x540e0e(0x1b2)]:_0x1690d4&&typeof _0x1690d4===_0x540e0e(0x1f6)&&_0x540e0e(0x1b2)in _0x1690d4&&(_0x540e0e(0x19e)in _0x1690d4||'headers'in _0x1690d4||_0x540e0e(0x222)in _0x1690d4)?_0x1690d4['data']:_0x1690d4,_0x1dac95=parseHttpErrorResponseData(_0x532607),_0x568357=_0x317fce?.['message']||String(_0x317fce),_0x2f88ed={'ok':![],'message':_0x568357},_0x3e7f53=typeof _0x317fce?.['status']===_0x540e0e(0x1e4)?_0x317fce[_0x540e0e(0x1b8)]:_0x1690d4&&typeof _0x1690d4[_0x540e0e(0x1b8)]===_0x540e0e(0x1e4)?_0x1690d4[_0x540e0e(0x1b8)]:undefined;typeof _0x3e7f53===_0x540e0e(0x1e4)&&(_0x2f88ed['status']=_0x3e7f53);_0x1dac95!==undefined&&(_0x2f88ed[_0x540e0e(0x1b2)]=_0x1dac95);if(_0x1dac95&&typeof _0x1dac95===_0x540e0e(0x1f6)&&_0x1dac95!==null&&typeof _0x1dac95[_0x540e0e(0x1dc)]==='string')_0x2f88ed[_0x540e0e(0x1b4)]=_0x1dac95[_0x540e0e(0x1dc)];else{if(typeof _0x1dac95===_0x540e0e(0x241)&&_0x1dac95)_0x2f88ed[_0x540e0e(0x1b4)]=_0x1dac95;else _0x1dac95&&typeof _0x1dac95==='object'&&_0x1dac95!==null&&typeof _0x1dac95[_0x540e0e(0x1b4)]===_0x540e0e(0x241)?_0x2f88ed[_0x540e0e(0x1b4)]=_0x1dac95['error']:_0x2f88ed['error']=_0x568357;}return _0x2f88ed;}function _0x4d39(){const _0x1c729f=['v29YA2zSB3DtDgvWvhLWzq','zxzHBhvHDgvfEhbYzxnZAw9U','B3zLCG','vMfSAwrHDgLVBIbMywLSzwq','AgfZAevUy3j5ChrPB25dB25Uzwn0B3i','zM9YrwfJAa','C3rYAw5NAwz5','y29UBMvJDg9Yx3zLCNnPB24','y2fSBf93B3jRzMXVDZOGD29YA2zSB3CGBM90igzVDw5KigXVy2fSBhKGyw5KiezSB3n5BMndBgLLBNqGAxmGBM90ignVBMzPz3vYzwqUifjLz2LZDgvYihrOzsbJAgLSzcb3B3jRzMXVDYbVCIbZzxqGCMvTB3rLoIb0CNvLihDPDgGGyxbPs2v5l2fWAvnLy3jLDc4','CMf3uMvZCg9UzgvYq29UBMvJDg9Y','zMLSzxm','z2v0','DgHLBG','C3rHCNrZv2L0Aa','uMvTB3rLigz1BMn0Aw9UigzHAwXLza','CMvTB3rL','x2rLyNvN','ywn0Aw9U','C2v0vMfYCW','mZa4ndCYwvDMBwrQ','zNjVBq','q09erq','AMv4Ba','yMvHCMvYqxv0AenVBM5Ly3rVCG','CgXHDgzVCM0','zNjVBuvUDhjPzxm','D29YA2zSB3DZ','A2v5CW','vfjbtLngt1jn','ywvZrw5JCNLWDgLVBKnVBM5Ly3rVCG','w0zSB3n5BMnDihn0zxaGiG','zw52','z2v0q29UBMvJDg9Y','y29TCgfYzvv0AwXPDhLdB25Uzwn0B3i','Cgf0AfbHCMfTCW','Cgf5Bg9Hza','zw50CMLLCW','zwXZzq','C3rHDhvZvgv4Da','C3rLChm','B3v0','Cg9ZDf9ZB3vYy2u','Ahr0CfjLC3bVBMrLCKnVBM5Ly3rVCG','B3bLCMf0Aw9UCW','revmqvK','C3rLCfjLC3vSDhm','zNvUy3rPB25Z','AM9PBG','AxrLCMf0B3i','tg9VCcaNB3zLCICGBxvZDcbLDMfSDwf0zsb0BYbHCNjHEsbVCIbPDgvYywjSzq','zw5KC1DPDgG','C2XPy2u','zgvMAw5LuhjVCgvYDhK','DMfSAwrHDg9Y','Ag1Hy0vUy3j5ChrPB25dB25Uzwn0B3i','C3bSAxq','zxHLy3v0Aw9UsgvHzgvYCW','ktOG','A2v5','B3v0Chv0x2zYB20','D2fYBG','ue9tva','CgfYyw1Z','zgvIDwC','DhjPz2DLCL9Pza','Dhj1zq','y3vZDg9T','otq3ndGWBMX3wwHe','CNvU','C3rYAw5N','BwfW','CMvKAxjLy3rszxnWB25KzxjdB25Uzwn0B3i','AxnbCNjHEq','x19LC01VzhvSzq','D2vIAg9VA19TzxrOB2q','te9pua','x19YyxDjza','mZu2mZqZnhrxrNbOtW','Bw9KDwXLx3jLzG','yxbPs2v5qxv0AenVBM5Ly3rVCG','vKfmsurbve9s','nJKWntDNwMzVyKi','oJPFx3zFxZO','CMvZCg9UzgvY','DMfSAwq','Bwf4ihn0zxbZigv4y2vLzgvK','yxbPx2nHBgW','y2fSBf9ZDgfJAW','DMfSDwu','yxjNCW','CNvUqNLxzwjOB29R','CgfYC2u','DMfSAwrHDg9YCW','z2v0q29UBMvJDg9Yt3jgzxrJAa','q0fmtf9xt1jlrKXpvW','Aw5KzxHFyxm','zw52x3zHCNm','Cgf0Af9WyxjHBxm','zgf0ywjHC2u','D29YA2zSB3DFAwq','Bw9Uz29KyKnVBM5Ly3rVCG','z2v0uhjVDg90ExbLt2y','y29UC3rYDwn0B3i','CMvZDwX0','CNnHrw5JCNLWDgLVBKnVBM5Ly3rVCG','yMfZzty0rw5JCNLWDgLVBKnVBM5Ly3rVCG','DgvUyw50x2LK','DhjHBNnMB3jT','mtaWmtK1nuTUtvDhza','y29UBMvJDg9Yq29UzMLN','yxbWBhLwywXPzgf0Aw9UC0nVBgXLy3rbBgW','uMvZCg9UzgvYig5VDcbMB3vUzdOG','zMLUzeLUzgv4','zgf0zvrPBwvvDgLSAxr5q29UBMvJDg9Y','q09oreLusu9o','zMLLBgrZ','ru5duLLqveLptG','y2HHBM5LBa','lNjLC3bVBMrLCG','y29UBMvJDg9Yig5VDcbMB3vUzdOG','DMfYCW','y3r4','zxHLy3v0zunVBM5Ly3rVCKfJDgLVBG','lI4VDMfSAwrHDg9YCY92ywXPzgf0B3jZ','q2XPzw50ihjLCxvPCMvKigzVCIbYzw1VDguGy2fSBf93B3jRzMXVDY4Gq29UzMLNDxjLigfWAuTLEsbHBMqGyxbPu2vJCMv0lG','mZK4mdyWngrHsxLuzW','y29UzMLN','CMvZCg9UC2vxyxjUAw5NCW','imk3ia','q1vtve9n','lI4VDhLWzxmVD29YA2zSB3C','y2fSBf93B3jRzMXVDYbZDgvWig1PC3nPBMCGD29YA2zSB3DFAwqGyw5KihDLyMHVB2TFCgf0Aa','zNvUy3rPB25FC2X1zW','iIaO','C3rYAw5NvxrPBgL0EunVBM5Ly3rVCG','ywXS','zNvUy3rPB25FAwq','rNvUy3rPB24GBM90igzVDw5KoIa','Ec1MBg9ZEw5JlwrLyNvN','qvbjx0nbteW','Bw9KDwXLx3jLzIbPCYbUB3qGC3vWCg9YDgvKigLUigXVy2fSignVzguGC3rLChm','Aw52B2TL','ANnVBI5YzxnWB25K','te9h','BxLZCwXdB25Uzwn0B3i','x2LK','zgf0yq','DhLWzq','zxjYB3i','zMLLBgrF','D2vIAg9VA1bHDgG','Ag9ZDa','C3rHDhvZ','CNvUrNvUy3rPB24','DgvYBwLUyxrL','y29UBMvJDg9YCW','C2v0','mta4yu1NyuTn','lI4VDgvTCgXHDgu','Aw5WDxrFzNjVBq','uKvtue9orevs','mte2nte4nur4Cg1PCW','D2vIAg9VA19WyxrO','zMfSC2u','DhjPBq','AgvHzgvYCW','tK9usuzz','AgfZt3DUuhjVCgvYDhK','y2fSBfn0ywnR','CMvZB2X2zq','lI9JB25Uzwn0B3iUzxHLy3v0B3i','B25FzxjYB3i','y29UBMvJDgLVBL9Pza','CMvKAxndB25Uzwn0B3i','D2HLBG','y29UBMvJDg9Yx2LK','D2vIAg9VA191CMW','DgLTzw91Da','B3v0Chv0','CMf3','t25Lig9Yig1VCMuGDMfSAwrHDgLVBIbLCNjVCNmGB2nJDxjYzwq','D29YA2zSB3C','CgfZC3DVCMrfBMnYExb0Aw9Uq29UBMvJDg9Y','BgvUz3rO','BM9YBwfSAxPLvhjPz2DLCG','Bw9Kzq','Cg9ZDgDYzxndB25Uzwn0B3i','C3rLCevYCM9YCW','BwvZC2fNzq','CxvLCNK','DhjPz2DLCG','A2LUza','Dg9vChbLCKnHC2u','lI4Vy29UBMvJDg9YCY9IDwLSDgLU','C3rHDhvZq29Kzq','ANnVBLjLC3bVBMrLCKnVBM5Ly3rVCG','BNvTyMvY','Aw5JBhvKzxm','BMfTzq','CMvZCg9UC2u','BwfWCgvK','mtCXyxzps0vy','tg9VCcbLEgnLzwrZig1HEcbPDgvYyxrPB25ZicG','C291CMnL','DgvUyw50swq','D2vIAg9VA01LDgHVza','DhjPz2DLCKLK','ChjVDg90ExbL','zw52AxjVBM1LBNq','yM9KEq','y2fSBa','DMfSAwrHDgLVBKDYB3vWCW','zNvUy3rPB24GC3rLCcbTAxnZAw5Nigz1BMn0Aw9Ux2LKig9Yigz1BMn0Aw9Ux3nSDwC','CMvUzgvYvgvTCgXHDgu','B2jQzwn0','CMvWBgfJzq','y2XPzw50','AxrLBq','BwfWCgLUzW','CMfUzg9TvxrPBgL0EunVBM5Ly3rVCG'];_0x4d39=function(){return _0x1c729f;};return _0x4d39();}function warnConnectorResponseShape(_0xe239b8,_0xc034cd,_0x261c70,_0x13a4ba){const _0x195460=_0x50b4ea,_0x304fb3=_0x13a4ba?.[_0x195460(0x19f)];Array[_0x195460(0x244)](_0x304fb3)&&_0x304fb3[_0x195460(0x1d7)]&&console[_0x195460(0x238)](_0x195460(0x21a)+_0xe239b8+_0x195460(0x1a5)+_0xc034cd+_0x195460(0x1a0)+_0x261c70+_0x195460(0x235)+_0x304fb3[_0x195460(0x22b)](';\x20'));}class ProcessorEngine{constructor(_0x42153f={}){const _0x3ace89=_0x50b4ea;this[_0x3ace89(0x1bb)]=_0x42153f[_0x3ace89(0x1bb)]||new Map(),this['workflows']=_0x42153f[_0x3ace89(0x216)]||new Map(),this[_0x3ace89(0x22a)]=_0x42153f[_0x3ace89(0x22a)]||new Map(),this[_0x3ace89(0x18d)]=_0x42153f[_0x3ace89(0x18d)]||{},this[_0x3ace89(0x1f8)]=_0x42153f[_0x3ace89(0x1f8)]||null;}[_0x50b4ea(0x21c)](_0x3e1e3e){const _0x50237d=_0x50b4ea,_0x37da0a={'json.responder':builtin_1[_0x50237d(0x1e3)],'http.responder':builtin_1[_0x50237d(0x226)],'raw.responder':builtin_1[_0x50237d(0x205)],'redirect.responder':builtin_1[_0x50237d(0x243)],'empty.responder':builtin_1['emptyResponderConnector'],'condition.logic':builtin_1['conditionLogicConnector'],'mongodb.system':builtin_1[_0x50237d(0x260)],'mysql.system':builtin_1[_0x50237d(0x1b0)],'postgres.system':builtin_1[_0x50237d(0x1da)],'redis.system':builtin_1[_0x50237d(0x1cd)],'bearer.system':builtin_1[_0x50237d(0x213)],'api_key.system':builtin_1[_0x50237d(0x24b)],'basic.system':builtin_1['basicAuthConnector'],'custom_header.system':builtin_1['customHeaderAuthConnector'],'utility.date_time':builtin_1[_0x50237d(0x191)],'utility.string':builtin_1[_0x50237d(0x1a6)],'utility.random':builtin_1[_0x50237d(0x1fb)],'utility.math':builtin_1['mathUtilityConnector'],'utility.compare':builtin_1[_0x50237d(0x21d)],'utility.geo':builtin_1['geoUtilityConnector'],'base64.encryption':builtin_1[_0x50237d(0x189)],'hash.encryption':builtin_1[_0x50237d(0x200)],'aes.encryption':builtin_1[_0x50237d(0x219)],'rsa.encryption':builtin_1[_0x50237d(0x188)],'hmac.encryption':builtin_1[_0x50237d(0x232)],'password.encryption':builtin_1[_0x50237d(0x1d6)]};return _0x37da0a[_0x3e1e3e]??this[_0x50237d(0x1bb)]['get'](_0x3e1e3e);}async['getConnectorOrFetch'](_0x39486b,_0x36cd15){const _0x16bae8=_0x50b4ea,_0x1804d0=_0x36cd15!=null&&String(_0x36cd15)[_0x16bae8(0x1c4)]()!=='',_0x338d12=_0x1804d0?String(_0x36cd15)['trim']():'',_0x272263=_0x1804d0?_0x39486b+_0x16bae8(0x24e)+_0x338d12:_0x39486b;let _0x5a0c54=this['connectors'][_0x16bae8(0x207)](_0x272263);if(_0x5a0c54)return _0x5a0c54;if(!_0x1804d0){_0x5a0c54=this['getConnector'](_0x39486b);if(_0x5a0c54)return _0x5a0c54;}if(this['client']?.[_0x16bae8(0x1bb)]?.[_0x16bae8(0x207)])try{_0x5a0c54=await this[_0x16bae8(0x1f8)][_0x16bae8(0x1bb)]['get'](_0x39486b,_0x1804d0?{'version':_0x338d12}:undefined);if(_0x5a0c54)this['connectors'][_0x16bae8(0x1bc)](_0x272263,_0x5a0c54);}catch{_0x5a0c54=null;}return _0x5a0c54;}async['runWorkflow'](_0xcecaad,_0x7429c1={}){const _0x225b79=_0x50b4ea,_0x4f6c10=this[_0x225b79(0x1d8)](_0x7429c1),_0x1f5dc6=_0x7429c1?.['headers']||{};delete _0x1f5dc6[_0x225b79(0x1b7)];const _0x16f821=_0x7429c1?.[_0x225b79(0x21e)]??_0x7429c1?.[_0x225b79(0x25d)]??{},_0x58e542=_0x7429c1?.['params']??{},_0x140494=_0x7429c1?.['query']??{},_0x262a73=_0x4f6c10?.[_0x225b79(0x1b2)]??{},_0x288031=_0xcecaad['vars']||{},_0xc324ae=_0x7429c1?.[_0x225b79(0x198)]??{},_0x5334d8=_0x7429c1?.['envVars']??_0x7429c1?.[_0x225b79(0x25c)]??_0x7429c1?.[_0x225b79(0x21b)]??{},_0x28b2d2={'workflow':_0xcecaad,'trigger':_0x4f6c10,'body':_0x262a73,'bracket':_0x262a73,'brackets':_0x262a73,'callStack':_0x7429c1?.['callStack']??_0x7429c1?.[_0x225b79(0x253)]??[],'stepResults':{},'stepErrors':{},'vars':{..._0x288031,..._0xc324ae},'headers':_0x1f5dc6,'params':{..._0x140494,..._0x58e542},'pathParams':_0x16f821,'query':_0x140494,'tenantId':_0xcecaad[_0x225b79(0x18a)],'env':_0x5334d8,'connectorConfig':this[_0x225b79(0x18d)]},_0xacf23c=_0xcecaad[_0x225b79(0x223)]||[],_0x12b516=0x3e8;let _0x4487d1=0x0;const _0x418dcf=new Map();_0xacf23c[_0x225b79(0x201)](_0x2b830b=>{const _0x3e2f1d=_0x225b79;if(_0x2b830b['input_from'])_0x418dcf[_0x3e2f1d(0x1bc)](_0x2b830b[_0x3e2f1d(0x1bf)],_0x2b830b['id']);});const _0x2db7d8=_0x435d13=>{const _0x9e9b84=_0x225b79,_0x1f2891=_0x418dcf['get'](_0x435d13['id']);if(_0x1f2891){const _0x475938=_0xacf23c[_0x9e9b84(0x190)](_0x549ab5=>_0x549ab5['id']===_0x1f2891);if(_0x475938>=0x0)return _0x475938;}return-0x1;},_0x449688=_0x30ee42=>{const _0x296355=_0x225b79,_0x39c895=_0x30ee42[_0x296355(0x221)]||_0x30ee42[_0x296355(0x1cb)];if(_0x39c895){const _0x6c8641=_0xacf23c[_0x296355(0x190)](_0xfde943=>_0xfde943['id']===_0x39c895);if(_0x6c8641>=0x0)return _0x1b48d6=_0x6c8641,!![];}return![];},_0x43d635=_0x5c21fb=>{const _0x31ef90=_0x225b79,_0x2f269f=_0x5c21fb[_0x31ef90(0x208)];if(_0x2f269f){const _0x5db7bb=_0xacf23c[_0x31ef90(0x190)](_0x4f0078=>_0x4f0078['id']===_0x2f269f);if(_0x5db7bb>=0x0)return _0x1b48d6=_0x5db7bb,!![];}return![];},_0x39633a=_0x2df1ce=>{const _0x148786=_0x225b79;if(_0x2df1ce===null||_0x2df1ce===undefined)return!![];if(typeof _0x2df1ce===_0x148786(0x1f6)&&(_0x2df1ce['ok']===![]||_0x2df1ce[_0x148786(0x250)]===![]))return!![];return![];};let _0x1b48d6=_0xacf23c['findIndex'](_0x79caf1=>!_0x79caf1[_0x225b79(0x1bf)]);if(_0x1b48d6<0x0)_0x1b48d6=0x0;const _0x3a6b8a=()=>({..._0x28b2d2[_0x225b79(0x229)],'stepResults':_0x28b2d2[_0x225b79(0x229)],'trigger':_0x28b2d2[_0x225b79(0x1de)],'body':_0x28b2d2[_0x225b79(0x1f1)],'vars':_0x28b2d2[_0x225b79(0x198)],'headers':_0x28b2d2[_0x225b79(0x1c5)],'params':_0x28b2d2[_0x225b79(0x23a)],'pathParams':_0x28b2d2['pathParams'],'query':_0x28b2d2['query'],'env':_0x28b2d2[_0x225b79(0x21b)]});while(_0x1b48d6>=0x0&&_0x1b48d6<_0xacf23c[_0x225b79(0x1d7)]){if(++_0x4487d1>_0x12b516)throw new Error(_0x225b79(0x251));const _0x1924cc=_0xacf23c[_0x1b48d6],_0x43f3a5=_0x3a6b8a();try{if(_0x1924cc['type']===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x1c0)]){const _0x996ee2=_0x1924cc;let _0x258273=!![];if(_0x996ee2[_0x225b79(0x1ce)])try{_0x258273=await(0x0,template_1[_0x225b79(0x1fd)])(_0x996ee2['when'],{..._0x43f3a5,'error':_0x28b2d2[_0x225b79(0x1db)]});}catch{_0x258273=![];}if(_0x258273){const _0x4f90a9=_0x996ee2[_0x225b79(0x24f)]+_0x225b79(0x196),_0x39abf2=_0x4f90a9==='json.responder'?builtin_1[_0x225b79(0x1e3)]:this['getConnector'](_0x4f90a9);if(!_0x39abf2)throw new Error(_0x225b79(0x18f)+_0x4f90a9);const _0x1d1b40=_0x996ee2[_0x225b79(0x19e)]||{};let _0x349100=_0x1d1b40[_0x225b79(0x1e2)]??0xc8;typeof _0x349100===_0x225b79(0x241)&&_0x349100[_0x225b79(0x1e5)]('{{')&&(_0x349100=Number(await(0x0,template_1['renderTemplate'])(_0x349100,_0x28b2d2))||0xc8);const _0x1921fb={'statusCode':_0x349100};if(_0x1d1b40['headers']){_0x1921fb['headers']={};for(const [_0x249443,_0xd04b89]of Object[_0x225b79(0x220)](_0x1d1b40[_0x225b79(0x1c5)])){_0x1921fb[_0x225b79(0x1c5)][_0x249443]=typeof _0xd04b89===_0x225b79(0x241)&&_0xd04b89['includes']('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0xd04b89,_0x28b2d2):_0xd04b89;}}_0x1d1b40[_0x225b79(0x1f1)]!==undefined&&(_0x1921fb[_0x225b79(0x1f1)]=await renderBodyRecursive(_0x1d1b40[_0x225b79(0x1f1)],_0x28b2d2));const _0x5ceb54=await(0x0,connector_executor_1[_0x225b79(0x19a)])(_0x39abf2,_0x225b79(0x1ae),_0x1921fb,_0x28b2d2);if(_0x5ceb54?.[_0x225b79(0x1ba)]){const _0x9e3ab8=_0x7429c1?.[_0x225b79(0x23b)]===!![]||String(_0x28b2d2[_0x225b79(0x1c5)]?.['x-flosync-debug'])==='true'||String(_0x7429c1?.['query']?.[_0x225b79(0x23b)])===_0x225b79(0x23d);return _0x9e3ab8&&_0x5ceb54[_0x225b79(0x1f1)]&&typeof _0x5ceb54['body']==='object'&&(_0x5ceb54['body']['_debug']={'stepResults':_0x28b2d2[_0x225b79(0x229)]}),_0x5ceb54;}}const _0x7df564=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x7df564>=0x0?_0x7df564:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)]['VALIDATOR']){const _0x487dba=_0x1924cc;let _0xc25fb={};_0x487dba['input_from']?_0xc25fb=_0x28b2d2[_0x225b79(0x229)][_0x487dba[_0x225b79(0x1bf)]]?.[_0x225b79(0x263)]??_0x28b2d2[_0x225b79(0x229)][_0x487dba[_0x225b79(0x1bf)]]??{}:_0xc25fb=_0x28b2d2[_0x225b79(0x1de)]?.[_0x225b79(0x1b2)]??_0x28b2d2['trigger']??{};const _0x9375d0={..._0x28b2d2[_0x225b79(0x229)],'trigger':_0x28b2d2['trigger'],'body':_0x28b2d2[_0x225b79(0x1f1)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0xd3aaa5=await Promise[_0x225b79(0x1a7)]((_0x487dba[_0x225b79(0x1f3)]||[])[_0x225b79(0x242)](async _0x1cad18=>{const _0x249ea4=_0x225b79,_0x335d77=await Promise[_0x249ea4(0x1a7)]((_0x1cad18[_0x249ea4(0x193)]||[])[_0x249ea4(0x242)](_0x2643ee=>(0x0,template_1[_0x249ea4(0x1f5)])(_0x2643ee,_0x9375d0))),_0x3ffcde=(_0x1cad18[_0x249ea4(0x193)]||[])[_0x249ea4(0x242)](_0xc2ebd6=>{const _0x5576b1=_0x249ea4,_0x14f544=_0xc2ebd6[_0x5576b1(0x1f7)](/\{\{|\}\}/g,'')[_0x5576b1(0x1c4)]()[_0x5576b1(0x233)]('.');return _0x14f544[_0x5576b1(0x1d7)]>0x0?_0x14f544[_0x14f544['length']-0x1]:_0xc2ebd6;}),_0xf2c623=await Promise[_0x249ea4(0x1a7)]((_0x1cad18[_0x249ea4(0x258)]||[])[_0x249ea4(0x242)](async _0x4be3b8=>{const _0x59a0d3=_0x249ea4,_0x2bd647={};for(const [_0x425975,_0x2e0381]of Object[_0x59a0d3(0x220)](_0x4be3b8[_0x59a0d3(0x19e)]||{})){typeof _0x2e0381==='string'&&(String(_0x2e0381)[_0x59a0d3(0x1e5)]('{{')||String(_0x2e0381)[_0x59a0d3(0x1e5)]('${'))?_0x2bd647[_0x425975]=await(0x0,template_1[_0x59a0d3(0x1f5)])(String(_0x2e0381),_0x9375d0):_0x2bd647[_0x425975]=_0x2e0381;}return{'name':_0x4be3b8['name'],'config':_0x2bd647};}));return{'fields':_0x335d77,'fieldNames':_0x3ffcde,'validators':_0xf2c623};})),_0x76df8a={};let _0x495507=!![];const _0x4f518b=(_0xb0aea1,_0x264637)=>{const _0x24f5e2=_0x225b79;if(!_0x264637[_0x24f5e2(0x1d7)])return;const _0x5d4523=_0x76df8a[_0xb0aea1]??[];_0x76df8a[_0xb0aea1]=[...new Set([..._0x5d4523,..._0x264637])];};for(const _0x545815 of _0xd3aaa5){const {fields:fields=[],fieldNames:fieldNames=[],validators:validators=[]}=_0x545815;if(fields['length']===0x0||validators[_0x225b79(0x1d7)]===0x0)continue;for(let _0x3dc0cf=0x0;_0x3dc0cf<fields['length'];_0x3dc0cf++){const _0x4a5440=fields[_0x3dc0cf],_0x3f2ea3=fieldNames&&fieldNames[_0x3dc0cf]||_0x225b79(0x1b5)+_0x3dc0cf,_0x22b824=validators[_0x225b79(0x242)](_0x28bcbb=>({'validator':_0x28bcbb[_0x225b79(0x1e6)],'options':_0x28bcbb['config']||{}})),{valid:_0x5af8a3,failures:_0x4c3f95}=(0x0,validators_1[_0x225b79(0x18e)])(_0x22b824,_0x4a5440,{'stepId':_0x1924cc['id'],'fieldName':_0x3f2ea3});!_0x5af8a3&&(_0x495507=![],_0x4f518b(_0x3f2ea3,_0x4c3f95[_0x225b79(0x242)](_0x3ecc8c=>_0x3ecc8c[_0x225b79(0x1dc)])));}}const _0x4dbdb2={'valid':_0x495507,'ok':_0x495507,'statusCode':_0x495507?0xc8:0x190,'errors':Object[_0x225b79(0x217)](_0x76df8a)['length']>0x0?_0x76df8a:undefined,'result':_0x495507?{'valid':!![]}:{'valid':![],'error':_0x225b79(0x1ff),'message':_0x225b79(0x1d4)}};_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x4dbdb2;if(!_0x495507){if(_0x449688(_0x1924cc))continue;const _0x5dc132=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x5dc132>=0x0?_0x5dc132:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x36723e=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x36723e>=0x0?_0x36723e:-0x1;continue;}if(_0x1924cc['type']===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x192)]){const _0x57f960=_0x1924cc;let _0x1c27c5=![];const _0x1fdad1=_0x57f960[_0x225b79(0x1d9)]||_0x225b79(0x212);if(_0x1fdad1===_0x225b79(0x212)&&_0x57f960['if']){let _0x45fe3b=await(0x0,template_1[_0x225b79(0x1f5)])(_0x57f960['if'],_0x43f3a5);if(typeof _0x45fe3b==='string')_0x45fe3b=_0x45fe3b[_0x225b79(0x1c4)]();if(!_0x45fe3b)_0x45fe3b=_0x225b79(0x1c3);try{_0x1c27c5=Boolean(await(0x0,template_1[_0x225b79(0x1fd)])(String(_0x45fe3b),_0x43f3a5));}catch{_0x1c27c5=![];}}_0x28b2d2['stepResults'][_0x1924cc['id']]=_0x1c27c5;let _0x34f8fd=-0x1;_0x1c27c5?_0x34f8fd=_0x57f960[_0x225b79(0x208)]?_0xacf23c['findIndex'](_0x3430b7=>_0x3430b7['id']===_0x57f960[_0x225b79(0x208)]):_0x2db7d8(_0x1924cc):_0x34f8fd=_0x57f960[_0x225b79(0x221)]?_0xacf23c[_0x225b79(0x190)](_0x71ffd2=>_0x71ffd2['id']===_0x57f960[_0x225b79(0x221)]):_0x2db7d8(_0x1924cc);_0x1b48d6=_0x34f8fd>=0x0?_0x34f8fd:-0x1;continue;}if(_0x1924cc['type']===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x218)]){const _0x4d3778=_0x1924cc;if(_0x4d3778[_0x225b79(0x1fa)]){const _0x3fd228={};for(const _0x4aeb03 of Object['keys'](_0x4d3778[_0x225b79(0x1fa)])){_0x3fd228[_0x4aeb03]=await resolveTemplateOrExpression(_0x4d3778[_0x225b79(0x1fa)][_0x4aeb03],_0x43f3a5);}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x3fd228;}else{if(_0x4d3778[_0x225b79(0x227)]){let _0x3601e6={};if(_0x4d3778[_0x225b79(0x1bf)])_0x3601e6=_0x28b2d2[_0x225b79(0x229)][_0x4d3778[_0x225b79(0x1bf)]]??{};else _0x3601e6=_0x28b2d2[_0x225b79(0x1de)]?.[_0x225b79(0x1b2)]??{};const _0x1b574c=JSON[_0x225b79(0x257)](JSON['stringify'](_0x3601e6));for(const _0x5553cd of _0x4d3778[_0x225b79(0x227)]){if(_0x5553cd[_0x225b79(0x20d)]==='map'&&_0x5553cd[_0x225b79(0x1fa)])for(const _0x293d5d of Object[_0x225b79(0x217)](_0x5553cd[_0x225b79(0x1fa)])){_0x1b574c[_0x293d5d]=await resolveTemplateOrExpression(_0x5553cd[_0x225b79(0x1fa)][_0x293d5d],_0x43f3a5);}}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x1b574c;}else _0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]={};}const _0x39eefe=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x39eefe>=0x0?_0x39eefe:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1['WorkflowStepType'][_0x225b79(0x1af)]){const _0x592325=_0x1924cc,_0x30f4c3=await(0x0,template_1[_0x225b79(0x1f5)])(_0x592325[_0x225b79(0x1dc)],_0x43f3a5);_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]={'logged':_0x30f4c3};const _0xe02504=_0x2db7d8(_0x1924cc);_0x1b48d6=_0xe02504>=0x0?_0xe02504:-0x1;continue;}if(_0x1924cc['type']===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x228)]){const _0x5634dd=_0x1924cc;await new Promise(_0x283ea9=>setTimeout(_0x283ea9,_0x5634dd['ms']||0x0)),_0x28b2d2['stepResults'][_0x1924cc['id']]={'delayed':_0x5634dd['ms']};const _0x38ea87=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x38ea87>=0x0?_0x38ea87:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x211)]){const _0x8e5e1c=_0x1924cc,_0x29e688=_0x8e5e1c[_0x225b79(0x1bf)]?_0x28b2d2[_0x225b79(0x229)][_0x8e5e1c[_0x225b79(0x1bf)]]?.[_0x225b79(0x263)]??_0x28b2d2[_0x225b79(0x229)][_0x8e5e1c[_0x225b79(0x1bf)]]?.[_0x225b79(0x1d2)]??_0x28b2d2[_0x225b79(0x229)][_0x8e5e1c[_0x225b79(0x1bf)]]??{}:_0x28b2d2[_0x225b79(0x1de)]?.['data']??_0x28b2d2['trigger']??{},_0x49593a={'input':_0x29e688,'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2['vars'],'headers':_0x28b2d2['headers'],'params':_0x28b2d2[_0x225b79(0x23a)],'pathParams':_0x28b2d2['pathParams'],'query':_0x28b2d2[_0x225b79(0x1dd)],'body':_0x28b2d2['body'],'env':_0x28b2d2['env']};let _0x3f4e51=null;if(_0x8e5e1c[_0x225b79(0x1eb)]){const _0x4c8eec=Object[_0x225b79(0x261)](async function(){})['constructor'],_0x36ab2c=new _0x4c8eec('ctx','platform',_0x8e5e1c[_0x225b79(0x1eb)]);_0x3f4e51=await _0x36ab2c(_0x49593a,{});}else{if(_0x8e5e1c[_0x225b79(0x24a)])throw new Error(_0x225b79(0x1ac));else throw new Error('code\x20step\x20must\x20have\x20either\x20source\x20or\x20module_ref');}if(_0x3f4e51&&typeof _0x3f4e51===_0x225b79(0x1f6)&&_0x3f4e51[_0x225b79(0x20e)]&&typeof _0x3f4e51[_0x225b79(0x20e)]===_0x225b79(0x1f6))for(const _0x4d7e18 of Object[_0x225b79(0x217)](_0x3f4e51[_0x225b79(0x20e)])){_0x28b2d2[_0x225b79(0x198)][_0x4d7e18]=_0x3f4e51[_0x225b79(0x20e)][_0x4d7e18];}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]={'result':_0x3f4e51?.[_0x225b79(0x224)]??_0x3f4e51};const _0xfd534a=_0x2db7d8(_0x1924cc);_0x1b48d6=_0xfd534a>=0x0?_0xfd534a:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===_0x225b79(0x23e)||_0x1924cc[_0x225b79(0x1b3)]===workflow_1['WorkflowStepType'][_0x225b79(0x1a1)]){const _0x45cf22=_0x1924cc,_0x13efd0=_0x45cf22[_0x225b79(0x1bf)]?_0x28b2d2[_0x225b79(0x229)][_0x45cf22[_0x225b79(0x1bf)]]?.[_0x225b79(0x263)]??_0x28b2d2[_0x225b79(0x229)][_0x45cf22[_0x225b79(0x1bf)]]?.['output']??_0x28b2d2[_0x225b79(0x229)][_0x45cf22[_0x225b79(0x1bf)]]??{}:_0x28b2d2[_0x225b79(0x1de)]?.[_0x225b79(0x1b2)]??_0x28b2d2[_0x225b79(0x1de)]??{},_0x1a137d={'input':_0x13efd0,'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2['stepResults'],'vars':_0x28b2d2['vars'],'headers':_0x28b2d2[_0x225b79(0x1c5)],'params':_0x28b2d2['params'],'pathParams':_0x28b2d2[_0x225b79(0x21e)],'query':_0x28b2d2[_0x225b79(0x1dd)],'body':_0x28b2d2['body'],'env':_0x28b2d2['env']};let _0x404d9b=null;const _0x14fe1a=_0x45cf22[_0x225b79(0x225)]||_0x45cf22[_0x225b79(0x1eb)];if(_0x14fe1a){const _0x3a1c8e=Object[_0x225b79(0x261)](async function(){})[_0x225b79(0x262)],_0x57182a=new _0x3a1c8e(_0x225b79(0x199),_0x225b79(0x214),_0x14fe1a);_0x404d9b=await _0x57182a(_0x1a137d,{});}if(_0x404d9b&&typeof _0x404d9b===_0x225b79(0x1f6)&&_0x404d9b['setVars']&&typeof _0x404d9b['setVars']===_0x225b79(0x1f6))for(const _0x1df59e of Object[_0x225b79(0x217)](_0x404d9b['setVars'])){_0x28b2d2[_0x225b79(0x198)][_0x1df59e]=_0x404d9b['setVars'][_0x1df59e];}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x404d9b?.[_0x225b79(0x224)]??_0x404d9b??{};if(_0x39633a(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']])){if(_0x449688(_0x1924cc))continue;const _0x21aa14=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x21aa14>=0x0?_0x21aa14:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x40543a=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x40543a>=0x0?_0x40543a:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1['WorkflowStepType'][_0x225b79(0x1ab)]){const _0x3a6f9c=_0x1924cc,_0x406829=await this[_0x225b79(0x259)](_0x3a6f9c[_0x225b79(0x1cf)],_0x3a6f9c[_0x225b79(0x203)]);if(!_0x406829)throw new Error(_0x225b79(0x197)+_0x3a6f9c['connector_id']);if(_0x3a6f9c[_0x225b79(0x198)]&&typeof _0x3a6f9c['vars']===_0x225b79(0x1f6)&&!Array[_0x225b79(0x244)](_0x3a6f9c[_0x225b79(0x198)])){const _0x2c3b2b={..._0x28b2d2[_0x225b79(0x198)]};for(const [_0x4a2721,_0x1eeea1]of Object[_0x225b79(0x220)](_0x3a6f9c[_0x225b79(0x198)])){_0x2c3b2b[_0x4a2721]=typeof _0x1eeea1===_0x225b79(0x241)&&_0x1eeea1[_0x225b79(0x1e5)]('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0x1eeea1,_0x28b2d2):_0x1eeea1;}_0x28b2d2['vars']=_0x2c3b2b;}let _0x4648d8=_0x3a6f9c[_0x225b79(0x1f1)]||{};if(typeof _0x4648d8===_0x225b79(0x1f6))_0x4648d8=JSON[_0x225b79(0x257)](await(0x0,template_1[_0x225b79(0x1f5)])(JSON['stringify'](_0x4648d8),_0x28b2d2));else{if(typeof _0x4648d8===_0x225b79(0x241))_0x4648d8=await(0x0,template_1['renderTemplate'])(_0x4648d8,_0x28b2d2);}const _0x272f25={};for(const _0x3c8508 of Object[_0x225b79(0x217)](_0x3a6f9c['pathParams']||{})){_0x272f25[_0x3c8508]=typeof _0x3a6f9c[_0x225b79(0x21e)][_0x3c8508]===_0x225b79(0x241)&&_0x3a6f9c[_0x225b79(0x21e)][_0x3c8508][_0x225b79(0x1e5)]('{{')?await(0x0,template_1['renderTemplate'])(_0x3a6f9c['pathParams'][_0x3c8508],_0x28b2d2):_0x3a6f9c[_0x225b79(0x21e)][_0x3c8508];}const _0x31dbe6={};for(const _0x8c3be5 of Object['keys'](_0x3a6f9c[_0x225b79(0x23a)]||{})){_0x31dbe6[_0x8c3be5]=typeof _0x3a6f9c[_0x225b79(0x23a)][_0x8c3be5]==='string'&&_0x3a6f9c['params'][_0x8c3be5]['includes']('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0x3a6f9c['params'][_0x8c3be5],_0x28b2d2):_0x3a6f9c['params'][_0x8c3be5];}const _0x26a302={},_0x237495=_0x3a6f9c[_0x225b79(0x1c5)];if(_0x237495){if(typeof _0x237495===_0x225b79(0x1f6)&&!Array[_0x225b79(0x244)](_0x237495))for(const [_0x246444,value]of Object[_0x225b79(0x220)](_0x237495)){_0x26a302[_0x246444]=typeof value==='string'&&value[_0x225b79(0x1e5)]('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(value,_0x28b2d2):value;}else{if(Array[_0x225b79(0x244)](_0x237495))for(const _0x548e1c of _0x237495){_0x548e1c?.['key']&&_0x548e1c?.[_0x225b79(0x254)]!==undefined&&(_0x26a302[_0x548e1c['key']]=typeof _0x548e1c[_0x225b79(0x254)]===_0x225b79(0x241)&&_0x548e1c['value'][_0x225b79(0x1e5)]('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0x548e1c[_0x225b79(0x254)],_0x28b2d2):_0x548e1c['value']);}}}const _0x18f369={'params':_0x31dbe6,'pathParams':_0x272f25,'body':_0x4648d8};if(Object[_0x225b79(0x217)](_0x26a302)[_0x225b79(0x1d7)]>0x0)_0x18f369[_0x225b79(0x1c5)]=_0x26a302;if(_0x3a6f9c[_0x225b79(0x1d1)]!=null)_0x18f369['timeout']=_0x3a6f9c[_0x225b79(0x1d1)];if(_0x3a6f9c['files'])_0x18f369['files']=_0x3a6f9c[_0x225b79(0x206)];const _0x1a2cec=await(0x0,connector_executor_1[_0x225b79(0x19a)])(_0x406829,_0x3a6f9c[_0x225b79(0x20d)],_0x18f369,_0x28b2d2);if(_0x1a2cec?.[_0x225b79(0x1ba)])return _0x1a2cec;warnConnectorResponseShape(_0x1924cc['id'],_0x3a6f9c[_0x225b79(0x1cf)],_0x3a6f9c[_0x225b79(0x20d)],_0x1a2cec);const _0x201e52=_0x1a2cec;_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x201e52?.['mapped']??_0x201e52?.[_0x225b79(0x1d3)]??null;if(typeof _0x1924cc[_0x225b79(0x225)]===_0x225b79(0x241)&&_0x1924cc[_0x225b79(0x225)][_0x225b79(0x1c4)]()['length']>0x0){const _0x39bff3=_0x1924cc['post_source'],_0x25f2e8=Object[_0x225b79(0x261)](async function(){})[_0x225b79(0x262)],_0x25ed60=new _0x25f2e8(_0x225b79(0x199),_0x225b79(0x214),_0x39bff3),_0xe02229={'input':_0x28b2d2['stepResults'][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x427e77=await _0x25ed60(_0xe02229,{});if(_0x427e77&&typeof _0x427e77===_0x225b79(0x1f6)&&_0x427e77['setVars']&&typeof _0x427e77[_0x225b79(0x20e)]===_0x225b79(0x1f6)){for(const _0x59ecb4 of Object[_0x225b79(0x217)](_0x427e77[_0x225b79(0x20e)]))_0x28b2d2[_0x225b79(0x198)][_0x59ecb4]=_0x427e77[_0x225b79(0x20e)][_0x59ecb4];}if(_0x427e77&&typeof _0x427e77===_0x225b79(0x1f6)&&Object[_0x225b79(0x1ef)]['hasOwnProperty'][_0x225b79(0x1f2)](_0x427e77,_0x225b79(0x224)))_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x427e77[_0x225b79(0x224)];else _0x427e77!==undefined&&typeof _0x427e77!==_0x225b79(0x1f6)&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x427e77);}if(_0x39633a(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']])){if(_0x449688(_0x1924cc))continue;const _0x29fbc9=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x29fbc9>=0x0?_0x29fbc9:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x38016e=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x38016e>=0x0?_0x38016e:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)]['AUTHENTICATION']){const _0x344883=_0x1924cc,_0x5d6632=await this[_0x225b79(0x259)](_0x344883[_0x225b79(0x1cf)],_0x344883['connector_version']);if(!_0x5d6632)throw new Error('connector\x20not\x20found:\x20'+_0x344883[_0x225b79(0x1cf)]);let _0x1c233e=_0x344883[_0x225b79(0x1f1)]||{};if(typeof _0x1c233e===_0x225b79(0x1f6))_0x1c233e=JSON[_0x225b79(0x257)](await(0x0,template_1[_0x225b79(0x1f5)])(JSON['stringify'](_0x1c233e),_0x28b2d2));else{if(typeof _0x1c233e===_0x225b79(0x241))_0x1c233e=await(0x0,template_1[_0x225b79(0x1f5)])(_0x1c233e,_0x28b2d2);}const _0x4d6187=await(0x0,connector_executor_1[_0x225b79(0x19a)])(_0x5d6632,_0x344883[_0x225b79(0x20d)],{'body':_0x1c233e,..._0x1c233e},_0x28b2d2);if(_0x4d6187?.[_0x225b79(0x1ba)])return _0x4d6187;const _0x3264ff=_0x4d6187;_0x28b2d2['stepResults'][_0x1924cc['id']]=_0x3264ff?.[_0x225b79(0x1e8)]??_0x3264ff??_0x4d6187;if(typeof _0x1924cc[_0x225b79(0x225)]===_0x225b79(0x241)&&_0x1924cc[_0x225b79(0x225)][_0x225b79(0x1c4)]()[_0x225b79(0x1d7)]>0x0){const _0x48bd72=_0x1924cc[_0x225b79(0x225)],_0x528685=Object['getPrototypeOf'](async function(){})['constructor'],_0x5f0e85=new _0x528685(_0x225b79(0x199),_0x225b79(0x214),_0x48bd72),_0x4d51c2={'input':_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x229990=await _0x5f0e85(_0x4d51c2,{});if(_0x229990&&typeof _0x229990===_0x225b79(0x1f6)&&_0x229990[_0x225b79(0x20e)]&&typeof _0x229990[_0x225b79(0x20e)]===_0x225b79(0x1f6)){for(const _0x1019f8 of Object['keys'](_0x229990[_0x225b79(0x20e)]))_0x28b2d2[_0x225b79(0x198)][_0x1019f8]=_0x229990['setVars'][_0x1019f8];}if(_0x229990&&typeof _0x229990===_0x225b79(0x1f6)&&Object[_0x225b79(0x1ef)]['hasOwnProperty'][_0x225b79(0x1f2)](_0x229990,_0x225b79(0x224)))_0x28b2d2['stepResults'][_0x1924cc['id']]=_0x229990['out'];else _0x229990!==undefined&&typeof _0x229990!=='object'&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x229990);}if(_0x39633a(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']])){if(_0x449688(_0x1924cc))continue;const _0x40115c=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x40115c>=0x0?_0x40115c:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x44ae67=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x44ae67>=0x0?_0x44ae67:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x194)]){const _0x35a293=_0x1924cc,_0x26403f=await this['getConnectorOrFetch'](_0x35a293['connector_id'],_0x35a293['connector_version']);if(!_0x26403f)throw new Error(_0x225b79(0x197)+_0x35a293[_0x225b79(0x1cf)]);let _0x32b9ed=_0x35a293[_0x225b79(0x1f1)]||_0x35a293[_0x225b79(0x23a)]||{};if(typeof _0x32b9ed===_0x225b79(0x1f6))_0x32b9ed=JSON[_0x225b79(0x257)](await(0x0,template_1[_0x225b79(0x1f5)])(JSON[_0x225b79(0x202)](_0x32b9ed),_0x28b2d2));else{if(typeof _0x32b9ed===_0x225b79(0x241))_0x32b9ed=await(0x0,template_1[_0x225b79(0x1f5)])(_0x32b9ed,_0x28b2d2);}const _0x514e51=await(0x0,connector_executor_1[_0x225b79(0x19a)])(_0x26403f,_0x35a293[_0x225b79(0x20d)],{'body':_0x32b9ed,..._0x32b9ed},_0x28b2d2);if(_0x514e51?.[_0x225b79(0x1ba)])return _0x514e51;warnConnectorResponseShape(_0x1924cc['id'],_0x35a293[_0x225b79(0x1cf)],_0x35a293[_0x225b79(0x20d)],_0x514e51);const _0x5880fb=_0x514e51;_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x5880fb?.[_0x225b79(0x1e8)]??_0x5880fb?.[_0x225b79(0x1d3)]??null;if(typeof _0x1924cc[_0x225b79(0x225)]==='string'&&_0x1924cc['post_source'][_0x225b79(0x1c4)]()[_0x225b79(0x1d7)]>0x0){const _0x1f8108=_0x1924cc['post_source'],_0x47bb06=Object[_0x225b79(0x261)](async function(){})[_0x225b79(0x262)],_0x30411c=new _0x47bb06(_0x225b79(0x199),_0x225b79(0x214),_0x1f8108),_0x161d21={'input':_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x395c49=await _0x30411c(_0x161d21,{});if(_0x395c49&&typeof _0x395c49==='object'&&_0x395c49[_0x225b79(0x20e)]&&typeof _0x395c49[_0x225b79(0x20e)]===_0x225b79(0x1f6)){for(const _0x279cc3 of Object['keys'](_0x395c49[_0x225b79(0x20e)]))_0x28b2d2['vars'][_0x279cc3]=_0x395c49[_0x225b79(0x20e)][_0x279cc3];}if(_0x395c49&&typeof _0x395c49===_0x225b79(0x1f6)&&Object['prototype'][_0x225b79(0x1c7)][_0x225b79(0x1f2)](_0x395c49,_0x225b79(0x224)))_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x395c49[_0x225b79(0x224)];else _0x395c49!==undefined&&typeof _0x395c49!==_0x225b79(0x1f6)&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x395c49);}if(_0x43d635(_0x1924cc))continue;const _0x125448=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x125448>=0x0?_0x125448:-0x1;continue;}if(_0x1924cc['type']===workflow_1[_0x225b79(0x1fc)]['DB']){const _0x2d3609=_0x1924cc,_0x27379c=await this[_0x225b79(0x259)](_0x2d3609[_0x225b79(0x1cf)],_0x2d3609[_0x225b79(0x203)]);if(!_0x27379c)throw new Error(_0x225b79(0x197)+_0x2d3609[_0x225b79(0x1cf)]);let _0x42f587=_0x2d3609['body']||{};if(typeof _0x42f587==='object')_0x42f587=JSON[_0x225b79(0x257)](await(0x0,template_1[_0x225b79(0x1f5)])(JSON['stringify'](_0x42f587),_0x28b2d2));else{if(typeof _0x42f587===_0x225b79(0x241))_0x42f587=await(0x0,template_1[_0x225b79(0x1f5)])(_0x42f587,_0x28b2d2);}const _0x3d7d27={..._0x42f587};if(_0x2d3609['connection_id'])_0x3d7d27[_0x225b79(0x1cc)]=_0x2d3609[_0x225b79(0x1cc)];if(_0x2d3609[_0x225b79(0x25e)])_0x3d7d27[_0x225b79(0x25e)]=_0x2d3609['database'];const _0x5485f7=await(0x0,connector_executor_1[_0x225b79(0x19a)])(_0x27379c,_0x2d3609[_0x225b79(0x20d)],_0x3d7d27,_0x28b2d2);if(_0x5485f7?.[_0x225b79(0x1ba)])return _0x5485f7;warnConnectorResponseShape(_0x1924cc['id'],_0x2d3609['connector_id'],_0x2d3609['action'],_0x5485f7);const _0xa18b0b=_0x5485f7;_0x28b2d2['stepResults'][_0x1924cc['id']]=_0xa18b0b?.[_0x225b79(0x1e8)]??_0xa18b0b?.[_0x225b79(0x1d3)]??null;if(typeof _0x1924cc[_0x225b79(0x225)]===_0x225b79(0x241)&&_0x1924cc[_0x225b79(0x225)][_0x225b79(0x1c4)]()[_0x225b79(0x1d7)]>0x0){const _0x1197d2=_0x1924cc[_0x225b79(0x225)],_0x1c3873=Object[_0x225b79(0x261)](async function(){})[_0x225b79(0x262)],_0x9a21e3=new _0x1c3873(_0x225b79(0x199),'platform',_0x1197d2),_0x42b001={'input':_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x33e187=await _0x9a21e3(_0x42b001,{});if(_0x33e187&&typeof _0x33e187==='object'&&_0x33e187['setVars']&&typeof _0x33e187['setVars']===_0x225b79(0x1f6)){for(const _0x383ba1 of Object[_0x225b79(0x217)](_0x33e187['setVars']))_0x28b2d2['vars'][_0x383ba1]=_0x33e187[_0x225b79(0x20e)][_0x383ba1];}if(_0x33e187&&typeof _0x33e187===_0x225b79(0x1f6)&&Object[_0x225b79(0x1ef)]['hasOwnProperty']['call'](_0x33e187,_0x225b79(0x224)))_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x33e187[_0x225b79(0x224)];else _0x33e187!==undefined&&typeof _0x33e187!==_0x225b79(0x1f6)&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x33e187);}if(_0x43d635(_0x1924cc))continue;const _0x5e7f66=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x5e7f66>=0x0?_0x5e7f66:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)]['FUNCTION']){const _0xa87102=_0x1924cc,_0x26056b=_0xa87102[_0x225b79(0x1a8)]||_0xa87102[_0x225b79(0x1a4)];if(!_0x26056b)throw new Error(_0x225b79(0x1f4));const _0xf87b2c={};for(const _0x25171a of Object[_0x225b79(0x217)](_0xa87102[_0x225b79(0x255)]||{})){const _0x3f38be=_0xa87102[_0x225b79(0x255)][_0x25171a];_0xf87b2c[_0x25171a]=typeof _0x3f38be===_0x225b79(0x241)&&_0x3f38be['includes']('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0x3f38be,_0x28b2d2):_0x3f38be;}const _0x5ab668=this[_0x225b79(0x22a)]['get'](_0x26056b);let _0x35b8d9;if(_0x5ab668)_0x35b8d9=await this[_0x225b79(0x1b9)](_0x5ab668,_0xf87b2c,_0x28b2d2);else{if(this[_0x225b79(0x1f8)]?.[_0x225b79(0x22a)]?.['invoke'])try{const _0x299ef8=await this[_0x225b79(0x1f8)][_0x225b79(0x22a)][_0x225b79(0x1ad)](_0x26056b,_0xf87b2c);_0x35b8d9={'ok':!![],'data':_0x299ef8};}catch(_0x634e15){_0x35b8d9={'ok':![],'error':_0x634e15?.[_0x225b79(0x1dc)]||_0x225b79(0x20a)};}else throw new Error(_0x225b79(0x1a9)+_0x26056b);}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x35b8d9['ok']?_0x35b8d9[_0x225b79(0x1b2)]??_0x35b8d9[_0x225b79(0x229)]??{}:{'error':_0x35b8d9[_0x225b79(0x1b4)],'ok':![]};if(typeof _0x1924cc['post_source']===_0x225b79(0x241)&&_0x1924cc['post_source'][_0x225b79(0x1c4)]()[_0x225b79(0x1d7)]>0x0){const _0x38f07c=_0x1924cc[_0x225b79(0x225)],_0x18b845=Object['getPrototypeOf'](async function(){})[_0x225b79(0x262)],_0x50253d=new _0x18b845(_0x225b79(0x199),_0x225b79(0x214),_0x38f07c),_0x4c4662={'input':_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2[_0x225b79(0x229)],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x3cfafb=await _0x50253d(_0x4c4662,{});if(_0x3cfafb&&typeof _0x3cfafb==='object'&&_0x3cfafb[_0x225b79(0x20e)]&&typeof _0x3cfafb[_0x225b79(0x20e)]===_0x225b79(0x1f6)){for(const _0x50b215 of Object[_0x225b79(0x217)](_0x3cfafb[_0x225b79(0x20e)]))_0x28b2d2['vars'][_0x50b215]=_0x3cfafb[_0x225b79(0x20e)][_0x50b215];}if(_0x3cfafb&&typeof _0x3cfafb===_0x225b79(0x1f6)&&Object[_0x225b79(0x1ef)][_0x225b79(0x1c7)][_0x225b79(0x1f2)](_0x3cfafb,_0x225b79(0x224)))_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x3cfafb[_0x225b79(0x224)];else _0x3cfafb!==undefined&&typeof _0x3cfafb!==_0x225b79(0x1f6)&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x3cfafb);}if(_0x39633a(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']])){if(_0x449688(_0x1924cc))continue;const _0x2f368c=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x2f368c>=0x0?_0x2f368c:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x223cd0=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x223cd0>=0x0?_0x223cd0:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1['WorkflowStepType'][_0x225b79(0x25a)]){const _0x59b389=_0x1924cc,_0x40b5c1=_0x59b389[_0x225b79(0x25f)];let _0x24ad68=_0x59b389[_0x225b79(0x1c2)]||_0x59b389[_0x225b79(0x1b6)];typeof _0x24ad68==='string'&&_0x24ad68['includes']('{{')&&(_0x24ad68=await(0x0,template_1[_0x225b79(0x1f5)])(_0x24ad68,_0x28b2d2));_0x24ad68=_0x24ad68?String(_0x24ad68)['trim']():'';const _0xc1f4cf=(_0x59b389[_0x225b79(0x246)]||_0x59b389[_0x225b79(0x1ed)]||_0x225b79(0x239))[_0x225b79(0x1e0)]();if(!_0x40b5c1&&!_0x24ad68)throw new Error(_0x225b79(0x1a3));const _0x322664=_0x59b389[_0x225b79(0x23c)]||_0x59b389[_0x225b79(0x1ee)]||_0x225b79(0x1de),_0x34bb05=_0x59b389[_0x225b79(0x20b)]===!![];let _0x23d910=_0x59b389[_0x225b79(0x21f)]||{};typeof _0x23d910===_0x225b79(0x1f6)&&(_0x23d910=JSON[_0x225b79(0x257)](await(0x0,template_1[_0x225b79(0x1f5)])(JSON[_0x225b79(0x202)](_0x23d910),_0x28b2d2)));const _0x287ea9=_0x59b389['execution_headers']||_0x59b389[_0x225b79(0x234)],_0x3749f0=_0x287ea9&&typeof _0x287ea9===_0x225b79(0x1f6)?Object[_0x225b79(0x215)](await Promise[_0x225b79(0x1a7)](Object[_0x225b79(0x220)](_0x287ea9)[_0x225b79(0x242)](async([_0x1d07dd,_0x31c66b])=>[_0x1d07dd,typeof _0x31c66b===_0x225b79(0x241)&&_0x31c66b[_0x225b79(0x1e5)]('{{')?await(0x0,template_1[_0x225b79(0x1f5)])(_0x31c66b,_0x28b2d2):_0x31c66b]))):{},_0x4509a8=_0x23d910?.[_0x225b79(0x1b2)]??_0x23d910?.[_0x225b79(0x1f1)]??_0x23d910??{},_0x5dd663=_0x43f57b=>{const _0x4fbe5e=_0x225b79,_0x11b516=String(_0x43f57b||'')[_0x4fbe5e(0x1c4)]();if(!_0x11b516)return _0x11b516;return _0x11b516[_0x4fbe5e(0x209)]('/')?_0x11b516:'/'+_0x11b516;},_0x598653=_0x40b5c1||_0x24ad68||_0x225b79(0x1f2),_0x424f73=[..._0x28b2d2['callStack']||[],{'kind':'workflow','workflowId':_0x598653,'stepId':_0x1924cc['id']}];if(_0x424f73['filter'](_0xbabd3d=>_0xbabd3d?.[_0x225b79(0x1df)]===_0x225b79(0x1d5))[_0x225b79(0x1d7)]>0xf)throw new Error('call_workflow\x20nesting\x20depth\x20exceeded');if(!_0x34bb05){let _0x5e1555=undefined;if(_0x40b5c1){_0x5e1555=this['workflows'][_0x225b79(0x207)](_0x40b5c1);if(!_0x5e1555)for(const _0x1c82b4 of this[_0x225b79(0x216)]['values']()){const _0x5e5586=_0x1c82b4;if(_0x5e5586[_0x225b79(0x1b1)]===_0x40b5c1||_0x5e5586[_0x225b79(0x248)]===_0x40b5c1||_0x5e5586[_0x225b79(0x1e6)]===_0x40b5c1){_0x5e1555=_0x5e5586;break;}}}if(!_0x5e1555&&_0x24ad68)for(const _0x15909b of this[_0x225b79(0x216)]['values']()){const _0x5a5903=_0x15909b,_0x29caff=_0x5a5903[_0x225b79(0x1de)],_0x185aa1=_0x29caff?.[_0x225b79(0x1d0)],_0xd372d9=(_0x29caff?.[_0x225b79(0x1ed)]??_0x225b79(0x239))['toUpperCase']();if(_0x185aa1&&_0x5dd663(_0x185aa1)===_0x5dd663(_0x24ad68)&&_0xd372d9===_0xc1f4cf){_0x5e1555=_0x5a5903;break;}}if(_0x5e1555){const _0x3768cd=await this['runWorkflow'](_0x5e1555,{'body':_0x4509a8,'data':_0x4509a8,'headers':{..._0x28b2d2[_0x225b79(0x1c5)],..._0x3749f0},'pathParams':_0x28b2d2['pathParams'],'query':_0x28b2d2[_0x225b79(0x1dd)],'vars':{..._0x28b2d2[_0x225b79(0x198)]},'envVars':_0x28b2d2['env'],'callStack':_0x424f73});_0x3768cd&&_0x3768cd[_0x225b79(0x1ba)]?_0x28b2d2['stepResults'][_0x1924cc['id']]={'terminated':!![],..._0x3768cd}:_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x3768cd?.[_0x225b79(0x1f1)]??_0x3768cd;}else{if(!this[_0x225b79(0x1f8)]?.[_0x225b79(0x216)]?.[_0x225b79(0x240)])throw new Error(_0x225b79(0x204));}}if(_0x34bb05||!_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]){if(!this[_0x225b79(0x1f8)]?.[_0x225b79(0x216)]?.[_0x225b79(0x240)])throw new Error(_0x225b79(0x19c));let _0x133958;if(_0x24ad68){const _0x5b5d53={'body':_0x4509a8,'environment':_0x59b389[_0x225b79(0x1f0)]};_0x3749f0&&Object[_0x225b79(0x217)](_0x3749f0)[_0x225b79(0x1d7)]>0x0&&(_0x5b5d53[_0x225b79(0x234)]=_0x3749f0),_0x133958=await this[_0x225b79(0x1f8)][_0x225b79(0x216)][_0x225b79(0x256)](_0x24ad68,_0xc1f4cf,_0x5b5d53);}else{const _0x538822=_0x23d910&&typeof _0x23d910==='object'&&!Array[_0x225b79(0x244)](_0x23d910)&&(_0x225b79(0x1b2)in _0x23d910||'body'in _0x23d910)?_0x23d910:{'body':_0x4509a8,'data':_0x4509a8};_0x133958=await this[_0x225b79(0x1f8)][_0x225b79(0x216)]['run'](_0x40b5c1,_0x322664,{'payload':_0x538822,'environment':_0x59b389[_0x225b79(0x1f0)],'executionHeaders':_0x3749f0&&Object['keys'](_0x3749f0)['length']>0x0?_0x3749f0:undefined});}const _0x374387=_0x133958?.[_0x225b79(0x1f1)]??_0x133958?.[_0x225b79(0x1b2)]??_0x133958;_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x374387;}if(typeof _0x1924cc[_0x225b79(0x225)]===_0x225b79(0x241)&&_0x1924cc[_0x225b79(0x225)][_0x225b79(0x1c4)]()[_0x225b79(0x1d7)]>0x0){const _0x206d71=_0x1924cc[_0x225b79(0x225)],_0x4711d0=Object['getPrototypeOf'](async function(){})[_0x225b79(0x262)],_0x3b7f26=new _0x4711d0(_0x225b79(0x199),_0x225b79(0x214),_0x206d71),_0x18961f={'input':_0x28b2d2['stepResults'][_0x1924cc['id']],'trigger':_0x28b2d2[_0x225b79(0x1de)],'steps':_0x28b2d2['stepResults'],'vars':_0x28b2d2[_0x225b79(0x198)]},_0x39a30c=await _0x3b7f26(_0x18961f,{});if(_0x39a30c&&typeof _0x39a30c===_0x225b79(0x1f6)&&_0x39a30c['setVars']&&typeof _0x39a30c['setVars']===_0x225b79(0x1f6)){for(const _0x39a57d of Object[_0x225b79(0x217)](_0x39a30c[_0x225b79(0x20e)]))_0x28b2d2['vars'][_0x39a57d]=_0x39a30c[_0x225b79(0x20e)][_0x39a57d];}if(_0x39a30c&&typeof _0x39a30c===_0x225b79(0x1f6)&&Object['prototype'][_0x225b79(0x1c7)]['call'](_0x39a30c,_0x225b79(0x224)))_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x39a30c[_0x225b79(0x224)];else _0x39a30c!==undefined&&typeof _0x39a30c!==_0x225b79(0x1f6)&&(_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]=_0x39a30c);}if(_0x39633a(_0x28b2d2['stepResults'][_0x1924cc['id']])){if(_0x449688(_0x1924cc))continue;const _0x3dd078=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x3dd078>=0x0?_0x3dd078:-0x1;continue;}if(_0x43d635(_0x1924cc))continue;const _0x202bbb=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x202bbb>=0x0?_0x202bbb:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x247)]){const _0x276718=_0x1924cc,_0x2f024e=_0x276718[_0x225b79(0x1fe)];if(!_0x2f024e)throw new Error('Loop\x20step\x20requires\x20\x27over\x27\x20expression');const _0x20526b=await(0x0,template_1[_0x225b79(0x1fd)])(_0x2f024e,_0x43f3a5);let _0x4aa395=[];if(Array[_0x225b79(0x244)](_0x20526b))_0x4aa395=_0x20526b;else{if(_0x20526b&&typeof _0x20526b===_0x225b79(0x1f6)&&typeof _0x20526b[Symbol[_0x225b79(0x22c)]]==='function')_0x4aa395=Array[_0x225b79(0x210)](_0x20526b);else{if(_0x20526b&&typeof _0x20526b==='object')_0x4aa395=Object[_0x225b79(0x220)](_0x20526b);else throw new Error(_0x225b79(0x22d));}}const _0x10acaf=_0x276718['max_iterations']??0x3e8;if(_0x4aa395[_0x225b79(0x1d7)]>_0x10acaf)throw new Error(_0x225b79(0x1ea)+_0x10acaf+')');const _0x12e085=_0x276718['as']??_0x225b79(0x1f9),_0x548b2c=_0x276718[_0x225b79(0x25b)]??'index',_0x3805be=_0x276718[_0x225b79(0x223)]||[],_0x291d56=[];for(let _0x83c0eb=0x0;_0x83c0eb<_0x4aa395['length'];_0x83c0eb++){const _0x4a69a5=_0x4aa395[_0x83c0eb],_0x1321bc={..._0x43f3a5,'vars':{..._0x28b2d2['vars'],[_0x12e085]:_0x4a69a5,[_0x548b2c]:_0x83c0eb},[_0x12e085]:_0x4a69a5,[_0x548b2c]:_0x83c0eb};let _0xfb114=null;for(const _0xebb48a of _0x3805be){if(_0xebb48a[_0x225b79(0x1b3)]===workflow_1['WorkflowStepType'][_0x225b79(0x218)]&&_0xebb48a['mapping']){const _0x36af4f={};for(const _0x532df3 of Object[_0x225b79(0x217)](_0xebb48a['mapping'])){_0x36af4f[_0x532df3]=await resolveTemplateOrExpression(_0xebb48a['mapping'][_0x532df3],_0x1321bc);}_0x28b2d2[_0x225b79(0x229)][_0xebb48a['id']]=_0x36af4f,_0xfb114=_0x36af4f;}else{if(_0xebb48a[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x1af)]){const _0x2f4ce3=await(0x0,template_1['renderTemplate'])(_0xebb48a[_0x225b79(0x1dc)],_0x1321bc);_0x28b2d2[_0x225b79(0x229)][_0xebb48a['id']]={'logged':_0x2f4ce3};}}}_0x291d56['push']({'index':_0x83c0eb,'item':_0x4a69a5,'result':_0xfb114});}_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]={'iterations':_0x291d56[_0x225b79(0x1d7)],'results':_0x291d56};const _0x42cacb=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x42cacb>=0x0?_0x42cacb:-0x1;continue;}if(_0x1924cc[_0x225b79(0x1b3)]===workflow_1[_0x225b79(0x1fc)][_0x225b79(0x1c6)]){_0x28b2d2[_0x225b79(0x229)][_0x1924cc['id']]={'notified':_0x1924cc[_0x225b79(0x195)]};const _0x1bae69=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x1bae69>=0x0?_0x1bae69:-0x1;continue;}const _0x4223cd=_0x2db7d8(_0x1924cc);_0x1b48d6=_0x4223cd>=0x0?_0x4223cd:-0x1;}catch(_0x58a9e7){const _0x46715e=buildHttpStepFailurePayload(_0x58a9e7);_0x28b2d2['stepResults'][_0x1924cc['id']]=_0x46715e,_0x28b2d2[_0x225b79(0x1db)][_0x1924cc['id']]=_0x46715e;if(_0x449688(_0x1924cc))continue;const _0x3086f9=_0x2db7d8(_0x1924cc);if(_0x3086f9>=0x0){_0x1b48d6=_0x3086f9;continue;}throw _0x58a9e7;}}return{'statusCode':0xc8,'body':_0x28b2d2[_0x225b79(0x229)]};}async[_0x50b4ea(0x1b9)](_0x28f10a,_0x145f96,_0x12a83a){const _0x420461=_0x50b4ea,_0x23d444=_0x28f10a['steps']||[],_0xf5073d={'workflow':_0x12a83a?.['workflow']||{},'trigger':_0x12a83a?.[_0x420461(0x1de)]||{},'body':_0x12a83a?.[_0x420461(0x1f1)]??_0x145f96,'bracket':_0x145f96,'brackets':_0x145f96,'callStack':_0x12a83a?.[_0x420461(0x1c8)]||[],'stepResults':{},'stepErrors':{},'vars':{..._0x12a83a?.[_0x420461(0x198)]||{},..._0x28f10a[_0x420461(0x198)]||{}},'headers':_0x12a83a?.[_0x420461(0x1c5)]||{},'params':_0x12a83a?.[_0x420461(0x23a)]||{},'pathParams':_0x12a83a?.[_0x420461(0x21e)]||{},'query':_0x12a83a?.[_0x420461(0x1dd)]||{},'tenantId':_0x12a83a?.[_0x420461(0x1ec)],'env':_0x12a83a?.[_0x420461(0x21b)]||{},'connectorConfig':_0x12a83a?.[_0x420461(0x18d)]||this[_0x420461(0x18d)]},_0x29cf1c=()=>({..._0xf5073d[_0x420461(0x229)],'stepResults':_0xf5073d['stepResults'],'args':_0x145f96,'trigger':_0xf5073d[_0x420461(0x1de)],'body':_0xf5073d[_0x420461(0x1f1)],'vars':_0xf5073d[_0x420461(0x198)],'headers':_0xf5073d[_0x420461(0x1c5)],'params':_0xf5073d[_0x420461(0x23a)],'pathParams':_0xf5073d[_0x420461(0x21e)],'query':_0xf5073d['query'],'env':_0xf5073d[_0x420461(0x21b)]});for(let _0x20d7be=0x0;_0x20d7be<_0x23d444[_0x420461(0x1d7)];_0x20d7be++){const _0x473409=_0x23d444[_0x20d7be],_0x465739=_0x29cf1c();if(_0x473409[_0x420461(0x1b3)]==='responder'||_0x473409[_0x420461(0x1b3)]===workflow_1[_0x420461(0x1fc)][_0x420461(0x1c0)]){const _0x6a417b=builtin_1[_0x420461(0x1e3)],_0x36e996=_0x473409['config']||{},_0x1a39aa={'statusCode':_0x36e996[_0x420461(0x1e2)]??0xc8,'body':_0x36e996[_0x420461(0x1f1)]};_0x1a39aa[_0x420461(0x1f1)]=await renderBodyRecursive(_0x1a39aa[_0x420461(0x1f1)],_0x465739);const _0x5386db=await(0x0,connector_executor_1[_0x420461(0x19a)])(_0x6a417b,_0x420461(0x1ae),_0x1a39aa,_0xf5073d);if(_0x5386db?.['terminate']){const _0x9fa2fc=_0x145f96?.[_0x420461(0x23b)]===!![]||String(_0xf5073d[_0x420461(0x1c5)]?.[_0x420461(0x1aa)])==='true';return _0x9fa2fc&&_0x5386db[_0x420461(0x1f1)]&&typeof _0x5386db['body']===_0x420461(0x1f6)&&(_0x5386db[_0x420461(0x1f1)][_0x420461(0x20c)]={'stepResults':_0xf5073d[_0x420461(0x229)]}),{'ok':!![],'data':_0x5386db[_0x420461(0x1f1)],'stepResults':_0xf5073d[_0x420461(0x229)]};}}if(_0x473409[_0x420461(0x1b3)]===_0x420461(0x231)||_0x473409[_0x420461(0x1b3)]===workflow_1['WorkflowStepType'][_0x420461(0x24c)]){const _0x325e92=_0x473409,_0x9bbb8e=_0x145f96,_0xc5b10a={..._0xf5073d[_0x420461(0x229)],'args':_0x145f96,'body':_0xf5073d[_0x420461(0x1f1)],'vars':_0xf5073d[_0x420461(0x198)]},_0x3d0415=await Promise['all']((_0x325e92[_0x420461(0x1f3)]||[])[_0x420461(0x242)](async _0x3ac14d=>{const _0x4324d7=_0x420461,_0x4aebfe=await Promise[_0x4324d7(0x1a7)]((_0x3ac14d[_0x4324d7(0x193)]||[])[_0x4324d7(0x242)](_0x58d341=>(0x0,template_1['renderTemplate'])(_0x58d341,_0xc5b10a))),_0x49b84f=(_0x3ac14d[_0x4324d7(0x193)]||[])[_0x4324d7(0x242)](_0x5e698f=>{const _0x59ae01=_0x4324d7,_0x40bd78=_0x5e698f['replace'](/\{\{|\}\}/g,'')[_0x59ae01(0x1c4)]()[_0x59ae01(0x233)]('.');return _0x40bd78[_0x59ae01(0x1d7)]>0x0?_0x40bd78[_0x40bd78[_0x59ae01(0x1d7)]-0x1]:_0x5e698f;}),_0x530aa4=(_0x3ac14d['validators']||[])[_0x4324d7(0x242)](_0x3f021f=>({'name':_0x3f021f[_0x4324d7(0x1e6)],'config':_0x3f021f[_0x4324d7(0x19e)]||{}}));return{'fields':_0x4aebfe,'fieldNames':_0x49b84f,'validators':_0x530aa4};})),_0x5b072b={};let _0x412e3d=!![];const _0x3d309e=(_0x47362e,_0x17ccb7)=>{if(!_0x17ccb7['length'])return;const _0x1fabed=_0x5b072b[_0x47362e]??[];_0x5b072b[_0x47362e]=[...new Set([..._0x1fabed,..._0x17ccb7])];};for(const _0x569e36 of _0x3d0415){const {fields:fields=[],fieldNames:fieldNames=[],validators:validators=[]}=_0x569e36;if(fields[_0x420461(0x1d7)]===0x0||validators[_0x420461(0x1d7)]===0x0)continue;for(let _0x28c7c6=0x0;_0x28c7c6<fields[_0x420461(0x1d7)];_0x28c7c6++){const _0x57fc7a=fields[_0x28c7c6],_0x34bb2c=fieldNames&&fieldNames[_0x28c7c6]||_0x420461(0x1b5)+_0x28c7c6,_0x1ce4fe=validators[_0x420461(0x242)](_0x376989=>({'validator':_0x376989['name'],'options':_0x376989[_0x420461(0x19e)]||{}})),{valid:_0x2bbe5d,failures:_0x3bbbc5}=(0x0,validators_1[_0x420461(0x18e)])(_0x1ce4fe,_0x57fc7a,{'stepId':_0x473409['id'],'fieldName':_0x34bb2c});!_0x2bbe5d&&(_0x412e3d=![],_0x3d309e(_0x34bb2c,_0x3bbbc5[_0x420461(0x242)](_0x374a67=>_0x374a67['message'])));}}_0xf5073d['stepResults'][_0x473409['id']]={'valid':_0x412e3d,'ok':_0x412e3d,'statusCode':_0x412e3d?0xc8:0x190,'errors':Object[_0x420461(0x217)](_0x5b072b)[_0x420461(0x1d7)]>0x0?_0x5b072b:undefined,'result':_0x412e3d?{'valid':!![]}:{'valid':![]}};}if(_0x473409[_0x420461(0x1b3)]===_0x420461(0x18b)||_0x473409['type']===workflow_1[_0x420461(0x1fc)][_0x420461(0x218)]){const _0x536d87=_0x473409;if(_0x536d87[_0x420461(0x1fa)]){const _0x3f7285={};for(const _0x4e4c2f of Object[_0x420461(0x217)](_0x536d87[_0x420461(0x1fa)])){_0x3f7285[_0x4e4c2f]=await resolveTemplateOrExpression(_0x536d87[_0x420461(0x1fa)][_0x4e4c2f],_0x465739);}_0xf5073d[_0x420461(0x229)][_0x473409['id']]=_0x3f7285;}}if(_0x473409['type']===_0x420461(0x252)||_0x473409[_0x420461(0x1b3)]===workflow_1[_0x420461(0x1fc)][_0x420461(0x1ab)]){const _0x363deb=_0x473409,_0x18c6cb=await this[_0x420461(0x259)](_0x363deb['connector_id'],_0x363deb['connector_version']);if(!_0x18c6cb)throw new Error(_0x420461(0x197)+_0x363deb[_0x420461(0x1cf)]);if(_0x363deb[_0x420461(0x198)]&&typeof _0x363deb[_0x420461(0x198)]==='object'&&!Array[_0x420461(0x244)](_0x363deb[_0x420461(0x198)])){const _0xf4de1={..._0xf5073d[_0x420461(0x198)]};for(const [_0x17b3d9,_0x20d604]of Object[_0x420461(0x220)](_0x363deb['vars'])){_0xf4de1[_0x17b3d9]=typeof _0x20d604===_0x420461(0x241)&&_0x20d604[_0x420461(0x1e5)]('{{')?await(0x0,template_1[_0x420461(0x1f5)])(_0x20d604,_0xf5073d):_0x20d604;}_0xf5073d['vars']=_0xf4de1;}let _0x199f7e=_0x363deb[_0x420461(0x1f1)]||{};if(typeof _0x199f7e==='object')_0x199f7e=JSON[_0x420461(0x257)](await(0x0,template_1[_0x420461(0x1f5)])(JSON[_0x420461(0x202)](_0x199f7e),_0xf5073d));else{if(typeof _0x199f7e===_0x420461(0x241))_0x199f7e=await(0x0,template_1[_0x420461(0x1f5)])(_0x199f7e,_0xf5073d);}const _0x153182={};for(const _0x13aef5 of Object[_0x420461(0x217)](_0x363deb[_0x420461(0x21e)]||{})){_0x153182[_0x13aef5]=typeof _0x363deb[_0x420461(0x21e)][_0x13aef5]===_0x420461(0x241)&&_0x363deb['pathParams'][_0x13aef5][_0x420461(0x1e5)]('{{')?await(0x0,template_1[_0x420461(0x1f5)])(_0x363deb[_0x420461(0x21e)][_0x13aef5],_0xf5073d):_0x363deb[_0x420461(0x21e)][_0x13aef5];}const _0xacf99d={};for(const _0x171be2 of Object[_0x420461(0x217)](_0x363deb[_0x420461(0x23a)]||{})){_0xacf99d[_0x171be2]=typeof _0x363deb[_0x420461(0x23a)][_0x171be2]===_0x420461(0x241)&&_0x363deb[_0x420461(0x23a)][_0x171be2][_0x420461(0x1e5)]('{{')?await(0x0,template_1[_0x420461(0x1f5)])(_0x363deb[_0x420461(0x23a)][_0x171be2],_0xf5073d):_0x363deb[_0x420461(0x23a)][_0x171be2];}const _0x23e7b8={},_0x56ebc5=_0x363deb[_0x420461(0x1c5)];if(_0x56ebc5){if(typeof _0x56ebc5===_0x420461(0x1f6)&&!Array[_0x420461(0x244)](_0x56ebc5))for(const [_0x423e75,value]of Object['entries'](_0x56ebc5)){_0x23e7b8[_0x423e75]=typeof value==='string'&&value[_0x420461(0x1e5)]('{{')?await(0x0,template_1['renderTemplate'])(value,_0xf5073d):value;}else{if(Array[_0x420461(0x244)](_0x56ebc5))for(const _0x3f0472 of _0x56ebc5){_0x3f0472?.[_0x420461(0x236)]&&_0x3f0472?.[_0x420461(0x254)]!==undefined&&(_0x23e7b8[_0x3f0472['key']]=typeof _0x3f0472[_0x420461(0x254)]===_0x420461(0x241)&&_0x3f0472['value'][_0x420461(0x1e5)]('{{')?await(0x0,template_1[_0x420461(0x1f5)])(_0x3f0472[_0x420461(0x254)],_0xf5073d):_0x3f0472[_0x420461(0x254)]);}}}const _0x378a77={'params':_0xacf99d,'pathParams':_0x153182,'body':_0x199f7e};if(Object[_0x420461(0x217)](_0x23e7b8)[_0x420461(0x1d7)]>0x0)_0x378a77[_0x420461(0x1c5)]=_0x23e7b8;if(_0x363deb[_0x420461(0x1d1)]!=null)_0x378a77[_0x420461(0x1d1)]=_0x363deb[_0x420461(0x1d1)];if(_0x363deb['files'])_0x378a77[_0x420461(0x206)]=_0x363deb[_0x420461(0x206)];const _0x50daa1=await(0x0,connector_executor_1[_0x420461(0x19a)])(_0x18c6cb,_0x363deb['action'],_0x378a77,_0xf5073d);if(_0x50daa1?.[_0x420461(0x1ba)])return{'ok':!![],'data':_0x50daa1[_0x420461(0x1f1)],'stepResults':_0xf5073d['stepResults']};warnConnectorResponseShape(_0x473409['id'],_0x363deb['connector_id'],_0x363deb['action'],_0x50daa1),_0xf5073d[_0x420461(0x229)][_0x473409['id']]=_0x50daa1?.[_0x420461(0x1e8)]??_0x50daa1?.[_0x420461(0x1d3)]??null;}if(_0x473409[_0x420461(0x1b3)]==='db'||_0x473409[_0x420461(0x1b3)]===workflow_1[_0x420461(0x1fc)]['DB']){const _0x5e94f9=_0x473409,_0x505797=await this[_0x420461(0x259)](_0x5e94f9[_0x420461(0x1cf)],_0x5e94f9[_0x420461(0x203)]);if(!_0x505797)throw new Error(_0x420461(0x197)+_0x5e94f9[_0x420461(0x1cf)]);let _0xc49e0c=_0x5e94f9[_0x420461(0x1f1)]||{};if(typeof _0xc49e0c===_0x420461(0x1f6))_0xc49e0c=JSON['parse'](await(0x0,template_1[_0x420461(0x1f5)])(JSON['stringify'](_0xc49e0c),_0x465739));const _0x25d792=await(0x0,connector_executor_1[_0x420461(0x19a)])(_0x505797,_0x5e94f9['action'],{..._0xc49e0c},_0xf5073d);if(_0x25d792?.[_0x420461(0x1ba)])return{'ok':!![],'data':_0x25d792[_0x420461(0x1f1)],'stepResults':_0xf5073d[_0x420461(0x229)]};warnConnectorResponseShape(_0x473409['id'],_0x5e94f9[_0x420461(0x1cf)],_0x5e94f9['action'],_0x25d792),_0xf5073d[_0x420461(0x229)][_0x473409['id']]=_0x25d792?.[_0x420461(0x1e8)]??_0x25d792?.[_0x420461(0x1d3)]??null;}}const _0x582070=_0x28f10a[_0x420461(0x237)],_0x216239=_0x582070?_0xf5073d[_0x420461(0x229)][_0x582070]:((()=>{const _0x4f94a2=_0x420461,_0x3d41e8=_0x23d444[_0x23d444[_0x4f94a2(0x1d7)]-0x1];return _0x3d41e8?_0xf5073d[_0x4f94a2(0x229)][_0x3d41e8['id']]:_0xf5073d[_0x4f94a2(0x229)];})());return{'ok':!![],'data':_0x216239,'stepResults':_0xf5073d[_0x420461(0x229)]};}['normalizeTrigger'](_0x3d3a94){const _0x50148a=_0x50b4ea;if(!_0x3d3a94||typeof _0x3d3a94!==_0x50148a(0x1f6))return _0x3d3a94;if(Array[_0x50148a(0x244)](_0x3d3a94))return{'data':_0x3d3a94,'body':_0x3d3a94};const _0x448c84=_0x3d3a94[_0x50148a(0x1de)]??_0x3d3a94,_0x19e864=_0x448c84['data']??_0x448c84[_0x50148a(0x1f1)]??_0x3d3a94[_0x50148a(0x1b2)]??_0x3d3a94[_0x50148a(0x1f1)]??_0x3d3a94,_0xd182ae=typeof _0x19e864===_0x50148a(0x1f6)&&_0x19e864!==null?_0x19e864:{};return{..._0xd182ae,..._0x448c84,'data':_0x19e864,'body':_0x19e864};}}exports['ProcessorEngine']=ProcessorEngine;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessorEngine = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
function resolveTemplateOrExpression(value, ctx) {
|
|
6
|
+
if (typeof value !== "string")
|
|
7
|
+
return Promise.resolve(value);
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
if (trimmed.startsWith("{{") && trimmed.endsWith("}}")) {
|
|
10
|
+
const expr = trimmed.slice(2, -2).trim();
|
|
11
|
+
return (0, template_1.evaluateExpression)(expr, ctx);
|
|
12
|
+
}
|
|
13
|
+
return (0, template_1.renderTemplate)(value, ctx);
|
|
14
|
+
}
|
|
15
|
+
async function renderBodyRecursive(val, ctx) {
|
|
16
|
+
if (val == null)
|
|
17
|
+
return val;
|
|
18
|
+
if (typeof val === "string" && val.includes("{{")) {
|
|
19
|
+
const rendered = await (0, template_1.renderTemplate)(val, ctx);
|
|
20
|
+
if (typeof rendered === "string" && rendered.startsWith("{") && rendered.endsWith("}")) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(rendered);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return rendered;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (typeof rendered === "string" && rendered.startsWith("[") && rendered.endsWith("]")) {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(rendered);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return rendered;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return rendered;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(val)) {
|
|
39
|
+
return Promise.all(val.map((v) => renderBodyRecursive(v, ctx)));
|
|
40
|
+
}
|
|
41
|
+
if (typeof val === "object") {
|
|
42
|
+
const out = {};
|
|
43
|
+
for (const k of Object.keys(val)) {
|
|
44
|
+
out[k] = await renderBodyRecursive(val[k], ctx);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
return val;
|
|
49
|
+
}
|
|
50
|
+
const connector_executor_1 = require("./connector.executor");
|
|
51
|
+
const validators_1 = require("../validators/validators");
|
|
52
|
+
const builtin_1 = require("../connectors/builtin");
|
|
53
|
+
const workflow_1 = require("../types/workflow");
|
|
54
|
+
function parseHttpErrorResponseData(data) {
|
|
55
|
+
if (data === undefined || data === null)
|
|
56
|
+
return data;
|
|
57
|
+
if (typeof data === "object")
|
|
58
|
+
return data;
|
|
59
|
+
if (typeof data === "string") {
|
|
60
|
+
const t = data.trim();
|
|
61
|
+
if ((t.startsWith("{") && t.endsWith("}")) || (t.startsWith("[") && t.endsWith("]"))) {
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(t);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
function buildHttpStepFailurePayload(err) {
|
|
74
|
+
const res = err?.response;
|
|
75
|
+
const body = err?.data !== undefined
|
|
76
|
+
? err.data
|
|
77
|
+
: res && typeof res === "object" && "data" in res && ("config" in res || "headers" in res || "statusText" in res)
|
|
78
|
+
? res.data
|
|
79
|
+
: res;
|
|
80
|
+
const parsed = parseHttpErrorResponseData(body);
|
|
81
|
+
const message = err?.message || String(err);
|
|
82
|
+
const out = {
|
|
83
|
+
ok: false,
|
|
84
|
+
message,
|
|
85
|
+
};
|
|
86
|
+
const status = typeof err?.status === "number"
|
|
87
|
+
? err.status
|
|
88
|
+
: res && typeof res.status === "number"
|
|
89
|
+
? res.status
|
|
90
|
+
: undefined;
|
|
91
|
+
if (typeof status === "number") {
|
|
92
|
+
out.status = status;
|
|
93
|
+
}
|
|
94
|
+
if (parsed !== undefined) {
|
|
95
|
+
out.data = parsed;
|
|
96
|
+
}
|
|
97
|
+
if (parsed && typeof parsed === "object" && parsed !== null && typeof parsed.message === "string") {
|
|
98
|
+
out.error = parsed.message;
|
|
99
|
+
}
|
|
100
|
+
else if (typeof parsed === "string" && parsed) {
|
|
101
|
+
out.error = parsed;
|
|
102
|
+
}
|
|
103
|
+
else if (parsed && typeof parsed === "object" && parsed !== null && typeof parsed.error === "string") {
|
|
104
|
+
out.error = parsed.error;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
out.error = message;
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
function warnConnectorResponseShape(stepId, connectorId, action, resp) {
|
|
112
|
+
const w = resp?.responseWarnings;
|
|
113
|
+
if (Array.isArray(w) && w.length) {
|
|
114
|
+
console.warn(`[Flosync] step "${stepId}" (${connectorId} · ${action}): ${w.join("; ")}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
class ProcessorEngine {
|
|
118
|
+
constructor(options = {}) {
|
|
119
|
+
this.connectors = options.connectors || new Map();
|
|
120
|
+
this.workflows = options.workflows || new Map();
|
|
121
|
+
this.functions = options.functions || new Map();
|
|
122
|
+
this.connectorConfig = options.connectorConfig || {};
|
|
123
|
+
this.client = options.client || null;
|
|
124
|
+
}
|
|
125
|
+
getConnector(id) {
|
|
126
|
+
const builtin = {
|
|
127
|
+
"json.responder": builtin_1.jsonResponderConnector,
|
|
128
|
+
"http.responder": builtin_1.httpResponderConnector,
|
|
129
|
+
"raw.responder": builtin_1.rawResponderConnector,
|
|
130
|
+
"redirect.responder": builtin_1.redirectResponderConnector,
|
|
131
|
+
"empty.responder": builtin_1.emptyResponderConnector,
|
|
132
|
+
"condition.logic": builtin_1.conditionLogicConnector,
|
|
133
|
+
"mongodb.system": builtin_1.mongodbConnector,
|
|
134
|
+
"mysql.system": builtin_1.mysqlConnector,
|
|
135
|
+
"postgres.system": builtin_1.postgresConnector,
|
|
136
|
+
"redis.system": builtin_1.redisConnector,
|
|
137
|
+
"bearer.system": builtin_1.bearerAuthConnector,
|
|
138
|
+
"api_key.system": builtin_1.apiKeyAuthConnector,
|
|
139
|
+
"basic.system": builtin_1.basicAuthConnector,
|
|
140
|
+
"custom_header.system": builtin_1.customHeaderAuthConnector,
|
|
141
|
+
"utility.date_time": builtin_1.dateTimeUtilityConnector,
|
|
142
|
+
"utility.string": builtin_1.stringUtilityConnector,
|
|
143
|
+
"utility.random": builtin_1.randomUtilityConnector,
|
|
144
|
+
"utility.math": builtin_1.mathUtilityConnector,
|
|
145
|
+
"utility.compare": builtin_1.compareUtilityConnector,
|
|
146
|
+
"utility.geo": builtin_1.geoUtilityConnector,
|
|
147
|
+
"base64.encryption": builtin_1.base64EncryptionConnector,
|
|
148
|
+
"hash.encryption": builtin_1.hashEncryptionConnector,
|
|
149
|
+
"aes.encryption": builtin_1.aesEncryptionConnector,
|
|
150
|
+
"rsa.encryption": builtin_1.rsaEncryptionConnector,
|
|
151
|
+
"hmac.encryption": builtin_1.hmacEncryptionConnector,
|
|
152
|
+
"password.encryption": builtin_1.passwordEncryptionConnector,
|
|
153
|
+
};
|
|
154
|
+
return builtin[id] ?? this.connectors.get(id);
|
|
155
|
+
}
|
|
156
|
+
async getConnectorOrFetch(id, connectorVersion) {
|
|
157
|
+
const hasVer = connectorVersion != null && String(connectorVersion).trim() !== "";
|
|
158
|
+
const v = hasVer ? String(connectorVersion).trim() : "";
|
|
159
|
+
const cacheKey = hasVer ? `${id}::__v__:${v}` : id;
|
|
160
|
+
let connector = this.connectors.get(cacheKey);
|
|
161
|
+
if (connector)
|
|
162
|
+
return connector;
|
|
163
|
+
if (!hasVer) {
|
|
164
|
+
connector = this.getConnector(id);
|
|
165
|
+
if (connector)
|
|
166
|
+
return connector;
|
|
167
|
+
}
|
|
168
|
+
if (this.client?.connectors?.get) {
|
|
169
|
+
try {
|
|
170
|
+
connector = await this.client.connectors.get(id, hasVer ? { version: v } : undefined);
|
|
171
|
+
if (connector)
|
|
172
|
+
this.connectors.set(cacheKey, connector);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
connector = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return connector;
|
|
179
|
+
}
|
|
180
|
+
async runWorkflow(workflow, triggerPayload = {}) {
|
|
181
|
+
const normalizedTrigger = this.normalizeTrigger(triggerPayload);
|
|
182
|
+
const headers = triggerPayload?.headers || {};
|
|
183
|
+
delete headers.host;
|
|
184
|
+
const pathParams = triggerPayload?.pathParams ?? triggerPayload?.path_params ?? {};
|
|
185
|
+
const params = triggerPayload?.params ?? {};
|
|
186
|
+
const query = triggerPayload?.query ?? {};
|
|
187
|
+
const inputData = normalizedTrigger?.data ?? {};
|
|
188
|
+
const workflowVars = workflow.vars || {};
|
|
189
|
+
const payloadVars = triggerPayload?.vars ?? {};
|
|
190
|
+
const payloadEnv = triggerPayload?.envVars ?? triggerPayload?.env_vars ?? triggerPayload?.env ?? {};
|
|
191
|
+
const state = {
|
|
192
|
+
workflow,
|
|
193
|
+
trigger: normalizedTrigger,
|
|
194
|
+
body: inputData,
|
|
195
|
+
bracket: inputData,
|
|
196
|
+
brackets: inputData,
|
|
197
|
+
callStack: triggerPayload?.callStack ?? triggerPayload?.call_stack ?? [],
|
|
198
|
+
stepResults: {},
|
|
199
|
+
stepErrors: {},
|
|
200
|
+
vars: { ...workflowVars, ...payloadVars },
|
|
201
|
+
headers,
|
|
202
|
+
params: { ...query, ...params },
|
|
203
|
+
pathParams,
|
|
204
|
+
query,
|
|
205
|
+
tenantId: workflow.tenant_id,
|
|
206
|
+
env: payloadEnv,
|
|
207
|
+
connectorConfig: this.connectorConfig,
|
|
208
|
+
};
|
|
209
|
+
const steps = workflow.steps || [];
|
|
210
|
+
const maxSteps = 1000;
|
|
211
|
+
let counter = 0;
|
|
212
|
+
const linearNext = new Map();
|
|
213
|
+
steps.forEach((step) => {
|
|
214
|
+
if (step.input_from)
|
|
215
|
+
linearNext.set(step.input_from, step.id);
|
|
216
|
+
});
|
|
217
|
+
const findNextStepIndex = (currentStep) => {
|
|
218
|
+
const nextStepId = linearNext.get(currentStep.id);
|
|
219
|
+
if (nextStepId) {
|
|
220
|
+
const idx = steps.findIndex((s) => s.id === nextStepId);
|
|
221
|
+
if (idx >= 0)
|
|
222
|
+
return idx;
|
|
223
|
+
}
|
|
224
|
+
return -1;
|
|
225
|
+
};
|
|
226
|
+
const checkAndJumpToErrorBranch = (step) => {
|
|
227
|
+
const errorBranchId = step.else || step.on_error;
|
|
228
|
+
if (errorBranchId) {
|
|
229
|
+
const idx = steps.findIndex((s) => s.id === errorBranchId);
|
|
230
|
+
if (idx >= 0) {
|
|
231
|
+
currentStepIndex = idx;
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
};
|
|
237
|
+
const checkAndJumpToSuccessBranch = (step) => {
|
|
238
|
+
const successBranchId = step.then;
|
|
239
|
+
if (successBranchId) {
|
|
240
|
+
const idx = steps.findIndex((s) => s.id === successBranchId);
|
|
241
|
+
if (idx >= 0) {
|
|
242
|
+
currentStepIndex = idx;
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
};
|
|
248
|
+
const isResultFailure = (result) => {
|
|
249
|
+
if (result === null || result === undefined)
|
|
250
|
+
return true;
|
|
251
|
+
if (typeof result === "object" && (result.ok === false || result.valid === false))
|
|
252
|
+
return true;
|
|
253
|
+
return false;
|
|
254
|
+
};
|
|
255
|
+
let currentStepIndex = steps.findIndex((s) => !s.input_from);
|
|
256
|
+
if (currentStepIndex < 0)
|
|
257
|
+
currentStepIndex = 0;
|
|
258
|
+
const templateState = () => ({
|
|
259
|
+
...state.stepResults,
|
|
260
|
+
stepResults: state.stepResults,
|
|
261
|
+
trigger: state.trigger,
|
|
262
|
+
body: state.body,
|
|
263
|
+
vars: state.vars,
|
|
264
|
+
headers: state.headers,
|
|
265
|
+
params: state.params,
|
|
266
|
+
pathParams: state.pathParams,
|
|
267
|
+
query: state.query,
|
|
268
|
+
env: state.env,
|
|
269
|
+
});
|
|
270
|
+
while (currentStepIndex >= 0 && currentStepIndex < steps.length) {
|
|
271
|
+
if (++counter > maxSteps)
|
|
272
|
+
throw new Error("max steps exceeded");
|
|
273
|
+
const step = steps[currentStepIndex];
|
|
274
|
+
const ctx = templateState();
|
|
275
|
+
try {
|
|
276
|
+
if (step.type === workflow_1.WorkflowStepType.RESPONDER) {
|
|
277
|
+
const respStep = step;
|
|
278
|
+
let shouldExecute = true;
|
|
279
|
+
if (respStep.when) {
|
|
280
|
+
try {
|
|
281
|
+
shouldExecute = await (0, template_1.evaluateExpression)(respStep.when, { ...ctx, error: state.stepErrors });
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
shouldExecute = false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (shouldExecute) {
|
|
288
|
+
const responderId = `${respStep.responder}.responder`;
|
|
289
|
+
const connector = responderId === "json.responder" ? builtin_1.jsonResponderConnector : this.getConnector(responderId);
|
|
290
|
+
if (!connector)
|
|
291
|
+
throw new Error(`Responder not found: ${responderId}`);
|
|
292
|
+
const config = respStep.config || {};
|
|
293
|
+
let statusCode = config.statusCode ?? 200;
|
|
294
|
+
if (typeof statusCode === "string" && statusCode.includes("{{")) {
|
|
295
|
+
statusCode = Number(await (0, template_1.renderTemplate)(statusCode, state)) || 200;
|
|
296
|
+
}
|
|
297
|
+
const options = { statusCode };
|
|
298
|
+
if (config.headers) {
|
|
299
|
+
options.headers = {};
|
|
300
|
+
for (const [k, v] of Object.entries(config.headers)) {
|
|
301
|
+
options.headers[k] = typeof v === "string" && v.includes("{{")
|
|
302
|
+
? await (0, template_1.renderTemplate)(v, state)
|
|
303
|
+
: v;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (config.body !== undefined) {
|
|
307
|
+
options.body = await renderBodyRecursive(config.body, state);
|
|
308
|
+
}
|
|
309
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, "json.respond", options, state);
|
|
310
|
+
if (resp?.terminate) {
|
|
311
|
+
const isDebug = triggerPayload?.debug === true || String(state.headers?.["x-flosync-debug"]) === "true" || String(triggerPayload?.query?.debug) === "true";
|
|
312
|
+
if (isDebug && resp.body && typeof resp.body === "object") {
|
|
313
|
+
resp.body._debug = { stepResults: state.stepResults };
|
|
314
|
+
}
|
|
315
|
+
return resp;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const nextIdx = findNextStepIndex(step);
|
|
319
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (step.type === workflow_1.WorkflowStepType.VALIDATOR) {
|
|
323
|
+
const valStep = step;
|
|
324
|
+
let inputData = {};
|
|
325
|
+
if (valStep.input_from) {
|
|
326
|
+
inputData = state.stepResults[valStep.input_from]?.result ?? state.stepResults[valStep.input_from] ?? {};
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
inputData = state.trigger?.data ?? state.trigger ?? {};
|
|
330
|
+
}
|
|
331
|
+
const templateStateForVal = { ...state.stepResults, trigger: state.trigger, body: state.body, vars: state.vars };
|
|
332
|
+
const resolvedGroups = await Promise.all((valStep.validationGroups || []).map(async (group) => {
|
|
333
|
+
const resolvedFields = await Promise.all((group.fields || []).map((expr) => (0, template_1.renderTemplate)(expr, templateStateForVal)));
|
|
334
|
+
const fieldNames = (group.fields || []).map((expr) => {
|
|
335
|
+
const parts = expr.replace(/\{\{|\}\}/g, "").trim().split(".");
|
|
336
|
+
return parts.length > 0 ? parts[parts.length - 1] : expr;
|
|
337
|
+
});
|
|
338
|
+
const resolvedValidators = await Promise.all((group.validators || []).map(async (v) => {
|
|
339
|
+
const cfg = {};
|
|
340
|
+
for (const [k, val] of Object.entries(v.config || {})) {
|
|
341
|
+
if (typeof val === "string" && (String(val).includes("{{") || String(val).includes("${"))) {
|
|
342
|
+
cfg[k] = await (0, template_1.renderTemplate)(String(val), templateStateForVal);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
cfg[k] = val;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return { name: v.name, config: cfg };
|
|
349
|
+
}));
|
|
350
|
+
return { fields: resolvedFields, fieldNames, validators: resolvedValidators };
|
|
351
|
+
}));
|
|
352
|
+
const errors = {};
|
|
353
|
+
let allValid = true;
|
|
354
|
+
const pushErrors = (fieldName, messages) => {
|
|
355
|
+
if (!messages.length)
|
|
356
|
+
return;
|
|
357
|
+
const prev = errors[fieldName] ?? [];
|
|
358
|
+
errors[fieldName] = [...new Set([...prev, ...messages])];
|
|
359
|
+
};
|
|
360
|
+
for (const group of resolvedGroups) {
|
|
361
|
+
const { fields = [], fieldNames = [], validators = [] } = group;
|
|
362
|
+
if (fields.length === 0 || validators.length === 0)
|
|
363
|
+
continue;
|
|
364
|
+
for (let i = 0; i < fields.length; i++) {
|
|
365
|
+
const val = fields[i];
|
|
366
|
+
const name = (fieldNames && fieldNames[i]) || `field_${i}`;
|
|
367
|
+
const validations = validators.map((v) => ({ validator: v.name, options: v.config || {} }));
|
|
368
|
+
const { valid, failures } = (0, validators_1.applyValidationsCollectAll)(validations, val, {
|
|
369
|
+
stepId: step.id,
|
|
370
|
+
fieldName: name,
|
|
371
|
+
});
|
|
372
|
+
if (!valid) {
|
|
373
|
+
allValid = false;
|
|
374
|
+
pushErrors(name, failures.map((f) => f.message));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const result = {
|
|
379
|
+
valid: allValid,
|
|
380
|
+
ok: allValid,
|
|
381
|
+
statusCode: allValid ? 200 : 400,
|
|
382
|
+
errors: Object.keys(errors).length > 0 ? errors : undefined,
|
|
383
|
+
result: allValid ? { valid: true } : { valid: false, error: "Validation failed", message: "One or more validation errors occurred" },
|
|
384
|
+
};
|
|
385
|
+
state.stepResults[step.id] = result;
|
|
386
|
+
if (!allValid) {
|
|
387
|
+
if (checkAndJumpToErrorBranch(step))
|
|
388
|
+
continue;
|
|
389
|
+
const nextIdx = findNextStepIndex(step);
|
|
390
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
394
|
+
continue;
|
|
395
|
+
const nextIdx = findNextStepIndex(step);
|
|
396
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (step.type === workflow_1.WorkflowStepType.CONDITION) {
|
|
400
|
+
const condStep = step;
|
|
401
|
+
let passBool = false;
|
|
402
|
+
const mode = condStep.mode || "jexl";
|
|
403
|
+
if (mode === "jexl" && condStep.if) {
|
|
404
|
+
let rendered = await (0, template_1.renderTemplate)(condStep.if, ctx);
|
|
405
|
+
if (typeof rendered === "string")
|
|
406
|
+
rendered = rendered.trim();
|
|
407
|
+
if (!rendered)
|
|
408
|
+
rendered = "false";
|
|
409
|
+
try {
|
|
410
|
+
passBool = Boolean(await (0, template_1.evaluateExpression)(String(rendered), ctx));
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
passBool = false;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
state.stepResults[step.id] = passBool;
|
|
417
|
+
let nextIdx = -1;
|
|
418
|
+
if (passBool) {
|
|
419
|
+
nextIdx = condStep.then ? steps.findIndex((s) => s.id === condStep.then) : findNextStepIndex(step);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
nextIdx = condStep.else ? steps.findIndex((s) => s.id === condStep.else) : findNextStepIndex(step);
|
|
423
|
+
}
|
|
424
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (step.type === workflow_1.WorkflowStepType.TRANSFORM) {
|
|
428
|
+
const transStep = step;
|
|
429
|
+
if (transStep.mapping) {
|
|
430
|
+
const out = {};
|
|
431
|
+
for (const k of Object.keys(transStep.mapping)) {
|
|
432
|
+
out[k] = await resolveTemplateOrExpression(transStep.mapping[k], ctx);
|
|
433
|
+
}
|
|
434
|
+
state.stepResults[step.id] = out;
|
|
435
|
+
}
|
|
436
|
+
else if (transStep.operations) {
|
|
437
|
+
let base = {};
|
|
438
|
+
if (transStep.input_from)
|
|
439
|
+
base = state.stepResults[transStep.input_from] ?? {};
|
|
440
|
+
else
|
|
441
|
+
base = state.trigger?.data ?? {};
|
|
442
|
+
const out = JSON.parse(JSON.stringify(base));
|
|
443
|
+
for (const op of transStep.operations) {
|
|
444
|
+
if (op.action === "map" && op.mapping) {
|
|
445
|
+
for (const key of Object.keys(op.mapping)) {
|
|
446
|
+
out[key] = await resolveTemplateOrExpression(op.mapping[key], ctx);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
state.stepResults[step.id] = out;
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
state.stepResults[step.id] = {};
|
|
454
|
+
}
|
|
455
|
+
const nextIdx = findNextStepIndex(step);
|
|
456
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (step.type === workflow_1.WorkflowStepType.LOG) {
|
|
460
|
+
const logStep = step;
|
|
461
|
+
const msg = await (0, template_1.renderTemplate)(logStep.message, ctx);
|
|
462
|
+
state.stepResults[step.id] = { logged: msg };
|
|
463
|
+
const nextIdx = findNextStepIndex(step);
|
|
464
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (step.type === workflow_1.WorkflowStepType.DELAY) {
|
|
468
|
+
const delayStep = step;
|
|
469
|
+
await new Promise((r) => setTimeout(r, delayStep.ms || 0));
|
|
470
|
+
state.stepResults[step.id] = { delayed: delayStep.ms };
|
|
471
|
+
const nextIdx = findNextStepIndex(step);
|
|
472
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (step.type === workflow_1.WorkflowStepType.CODE) {
|
|
476
|
+
const codeStep = step;
|
|
477
|
+
const input = codeStep.input_from
|
|
478
|
+
? state.stepResults[codeStep.input_from]?.result ??
|
|
479
|
+
state.stepResults[codeStep.input_from]?.output ??
|
|
480
|
+
state.stepResults[codeStep.input_from] ??
|
|
481
|
+
{}
|
|
482
|
+
: state.trigger?.data ?? state.trigger ?? {};
|
|
483
|
+
const ctxForCode = {
|
|
484
|
+
input,
|
|
485
|
+
trigger: state.trigger,
|
|
486
|
+
steps: state.stepResults,
|
|
487
|
+
vars: state.vars,
|
|
488
|
+
headers: state.headers,
|
|
489
|
+
params: state.params,
|
|
490
|
+
pathParams: state.pathParams,
|
|
491
|
+
query: state.query,
|
|
492
|
+
body: state.body,
|
|
493
|
+
env: state.env,
|
|
494
|
+
};
|
|
495
|
+
let result = null;
|
|
496
|
+
if (codeStep.source) {
|
|
497
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
498
|
+
const userFn = new AsyncFunction("ctx", "platform", codeStep.source);
|
|
499
|
+
result = await userFn(ctxForCode, {});
|
|
500
|
+
}
|
|
501
|
+
else if (codeStep.module_ref) {
|
|
502
|
+
throw new Error("module_ref is not supported in local code steps");
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
throw new Error("code step must have either source or module_ref");
|
|
506
|
+
}
|
|
507
|
+
if (result && typeof result === "object" && result.setVars && typeof result.setVars === "object") {
|
|
508
|
+
for (const k of Object.keys(result.setVars)) {
|
|
509
|
+
state.vars[k] = result.setVars[k];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
state.stepResults[step.id] = { result: result?.out ?? result };
|
|
513
|
+
const nextIdx = findNextStepIndex(step);
|
|
514
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
if (step.type === "custom" || step.type === workflow_1.WorkflowStepType.CUSTOM) {
|
|
518
|
+
const customStep = step;
|
|
519
|
+
const input = customStep.input_from
|
|
520
|
+
? state.stepResults[customStep.input_from]?.result ??
|
|
521
|
+
state.stepResults[customStep.input_from]?.output ??
|
|
522
|
+
state.stepResults[customStep.input_from] ??
|
|
523
|
+
{}
|
|
524
|
+
: state.trigger?.data ?? state.trigger ?? {};
|
|
525
|
+
const ctxForCustom = {
|
|
526
|
+
input,
|
|
527
|
+
trigger: state.trigger,
|
|
528
|
+
steps: state.stepResults,
|
|
529
|
+
vars: state.vars,
|
|
530
|
+
headers: state.headers,
|
|
531
|
+
params: state.params,
|
|
532
|
+
pathParams: state.pathParams,
|
|
533
|
+
query: state.query,
|
|
534
|
+
body: state.body,
|
|
535
|
+
env: state.env,
|
|
536
|
+
};
|
|
537
|
+
let result = null;
|
|
538
|
+
const source = customStep.post_source || customStep.source;
|
|
539
|
+
if (source) {
|
|
540
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
541
|
+
const userFn = new AsyncFunction("ctx", "platform", source);
|
|
542
|
+
result = await userFn(ctxForCustom, {});
|
|
543
|
+
}
|
|
544
|
+
if (result && typeof result === "object" && result.setVars && typeof result.setVars === "object") {
|
|
545
|
+
for (const k of Object.keys(result.setVars)) {
|
|
546
|
+
state.vars[k] = result.setVars[k];
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
state.stepResults[step.id] = result?.out ?? result ?? {};
|
|
550
|
+
if (isResultFailure(state.stepResults[step.id])) {
|
|
551
|
+
if (checkAndJumpToErrorBranch(step))
|
|
552
|
+
continue;
|
|
553
|
+
const nextIdx = findNextStepIndex(step);
|
|
554
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
558
|
+
continue;
|
|
559
|
+
const nextIdx = findNextStepIndex(step);
|
|
560
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (step.type === workflow_1.WorkflowStepType.API_CALL) {
|
|
564
|
+
const apiStep = step;
|
|
565
|
+
const connector = await this.getConnectorOrFetch(apiStep.connector_id, apiStep.connector_version);
|
|
566
|
+
if (!connector)
|
|
567
|
+
throw new Error("connector not found: " + apiStep.connector_id);
|
|
568
|
+
if (apiStep.vars && typeof apiStep.vars === "object" && !Array.isArray(apiStep.vars)) {
|
|
569
|
+
const merged = { ...state.vars };
|
|
570
|
+
for (const [k, v] of Object.entries(apiStep.vars)) {
|
|
571
|
+
merged[k] =
|
|
572
|
+
typeof v === "string" && v.includes("{{") ? await (0, template_1.renderTemplate)(v, state) : v;
|
|
573
|
+
}
|
|
574
|
+
state.vars = merged;
|
|
575
|
+
}
|
|
576
|
+
let body = apiStep.body || {};
|
|
577
|
+
if (typeof body === "object")
|
|
578
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), state));
|
|
579
|
+
else if (typeof body === "string")
|
|
580
|
+
body = await (0, template_1.renderTemplate)(body, state);
|
|
581
|
+
const pathParams = {};
|
|
582
|
+
for (const k of Object.keys(apiStep.pathParams || {})) {
|
|
583
|
+
pathParams[k] = typeof apiStep.pathParams[k] === "string" && apiStep.pathParams[k].includes("{{")
|
|
584
|
+
? await (0, template_1.renderTemplate)(apiStep.pathParams[k], state)
|
|
585
|
+
: apiStep.pathParams[k];
|
|
586
|
+
}
|
|
587
|
+
const params = {};
|
|
588
|
+
for (const k of Object.keys(apiStep.params || {})) {
|
|
589
|
+
params[k] = typeof apiStep.params[k] === "string" && apiStep.params[k].includes("{{")
|
|
590
|
+
? await (0, template_1.renderTemplate)(apiStep.params[k], state)
|
|
591
|
+
: apiStep.params[k];
|
|
592
|
+
}
|
|
593
|
+
const headers = {};
|
|
594
|
+
const stepHeaders = apiStep.headers;
|
|
595
|
+
if (stepHeaders) {
|
|
596
|
+
if (typeof stepHeaders === "object" && !Array.isArray(stepHeaders)) {
|
|
597
|
+
for (const [key, value] of Object.entries(stepHeaders)) {
|
|
598
|
+
headers[key] =
|
|
599
|
+
typeof value === "string" && value.includes("{{")
|
|
600
|
+
? await (0, template_1.renderTemplate)(value, state)
|
|
601
|
+
: value;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else if (Array.isArray(stepHeaders)) {
|
|
605
|
+
for (const h of stepHeaders) {
|
|
606
|
+
if (h?.key && h?.value !== undefined) {
|
|
607
|
+
headers[h.key] =
|
|
608
|
+
typeof h.value === "string" && h.value.includes("{{")
|
|
609
|
+
? await (0, template_1.renderTemplate)(h.value, state)
|
|
610
|
+
: h.value;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const execOpts = { params, pathParams, body };
|
|
616
|
+
if (Object.keys(headers).length > 0)
|
|
617
|
+
execOpts.headers = headers;
|
|
618
|
+
if (apiStep.timeout != null)
|
|
619
|
+
execOpts.timeout = apiStep.timeout;
|
|
620
|
+
if (apiStep.files)
|
|
621
|
+
execOpts.files = apiStep.files;
|
|
622
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, apiStep.action, execOpts, state);
|
|
623
|
+
if (resp?.terminate)
|
|
624
|
+
return resp;
|
|
625
|
+
warnConnectorResponseShape(step.id, apiStep.connector_id, apiStep.action, resp);
|
|
626
|
+
const normalResp = resp;
|
|
627
|
+
state.stepResults[step.id] = normalResp?.mapped ?? normalResp?.raw ?? null;
|
|
628
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
629
|
+
const postFnSource = step.post_source;
|
|
630
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
631
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
632
|
+
const postCtx = {
|
|
633
|
+
input: state.stepResults[step.id],
|
|
634
|
+
trigger: state.trigger,
|
|
635
|
+
steps: state.stepResults,
|
|
636
|
+
vars: state.vars,
|
|
637
|
+
};
|
|
638
|
+
const postRes = await userFn(postCtx, {});
|
|
639
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
640
|
+
for (const k of Object.keys(postRes.setVars))
|
|
641
|
+
state.vars[k] = postRes.setVars[k];
|
|
642
|
+
}
|
|
643
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
644
|
+
state.stepResults[step.id] = postRes.out;
|
|
645
|
+
}
|
|
646
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
647
|
+
state.stepResults[step.id] = postRes;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (isResultFailure(state.stepResults[step.id])) {
|
|
651
|
+
if (checkAndJumpToErrorBranch(step))
|
|
652
|
+
continue;
|
|
653
|
+
const nextIdx = findNextStepIndex(step);
|
|
654
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
658
|
+
continue;
|
|
659
|
+
const nextIdx = findNextStepIndex(step);
|
|
660
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (step.type === workflow_1.WorkflowStepType.AUTHENTICATION) {
|
|
664
|
+
const authStep = step;
|
|
665
|
+
const connector = await this.getConnectorOrFetch(authStep.connector_id, authStep.connector_version);
|
|
666
|
+
if (!connector)
|
|
667
|
+
throw new Error("connector not found: " + authStep.connector_id);
|
|
668
|
+
let body = authStep.body || {};
|
|
669
|
+
if (typeof body === "object")
|
|
670
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), state));
|
|
671
|
+
else if (typeof body === "string")
|
|
672
|
+
body = await (0, template_1.renderTemplate)(body, state);
|
|
673
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, authStep.action, { body, ...body }, state);
|
|
674
|
+
if (resp?.terminate)
|
|
675
|
+
return resp;
|
|
676
|
+
const authResult = resp;
|
|
677
|
+
state.stepResults[step.id] = authResult?.mapped ?? authResult ?? resp;
|
|
678
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
679
|
+
const postFnSource = step.post_source;
|
|
680
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
681
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
682
|
+
const postCtx = {
|
|
683
|
+
input: state.stepResults[step.id],
|
|
684
|
+
trigger: state.trigger,
|
|
685
|
+
steps: state.stepResults,
|
|
686
|
+
vars: state.vars,
|
|
687
|
+
};
|
|
688
|
+
const postRes = await userFn(postCtx, {});
|
|
689
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
690
|
+
for (const k of Object.keys(postRes.setVars))
|
|
691
|
+
state.vars[k] = postRes.setVars[k];
|
|
692
|
+
}
|
|
693
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
694
|
+
state.stepResults[step.id] = postRes.out;
|
|
695
|
+
}
|
|
696
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
697
|
+
state.stepResults[step.id] = postRes;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (isResultFailure(state.stepResults[step.id])) {
|
|
701
|
+
if (checkAndJumpToErrorBranch(step))
|
|
702
|
+
continue;
|
|
703
|
+
const nextIdx = findNextStepIndex(step);
|
|
704
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
708
|
+
continue;
|
|
709
|
+
const nextIdx = findNextStepIndex(step);
|
|
710
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (step.type === workflow_1.WorkflowStepType.ENCRYPTION) {
|
|
714
|
+
const encStep = step;
|
|
715
|
+
const connector = await this.getConnectorOrFetch(encStep.connector_id, encStep.connector_version);
|
|
716
|
+
if (!connector)
|
|
717
|
+
throw new Error("connector not found: " + encStep.connector_id);
|
|
718
|
+
let body = encStep.body || encStep.params || {};
|
|
719
|
+
if (typeof body === "object")
|
|
720
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), state));
|
|
721
|
+
else if (typeof body === "string")
|
|
722
|
+
body = await (0, template_1.renderTemplate)(body, state);
|
|
723
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, encStep.action, { body, ...body }, state);
|
|
724
|
+
if (resp?.terminate)
|
|
725
|
+
return resp;
|
|
726
|
+
warnConnectorResponseShape(step.id, encStep.connector_id, encStep.action, resp);
|
|
727
|
+
const normalResp = resp;
|
|
728
|
+
state.stepResults[step.id] = normalResp?.mapped ?? normalResp?.raw ?? null;
|
|
729
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
730
|
+
const postFnSource = step.post_source;
|
|
731
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
732
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
733
|
+
const postCtx = {
|
|
734
|
+
input: state.stepResults[step.id],
|
|
735
|
+
trigger: state.trigger,
|
|
736
|
+
steps: state.stepResults,
|
|
737
|
+
vars: state.vars,
|
|
738
|
+
};
|
|
739
|
+
const postRes = await userFn(postCtx, {});
|
|
740
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
741
|
+
for (const k of Object.keys(postRes.setVars))
|
|
742
|
+
state.vars[k] = postRes.setVars[k];
|
|
743
|
+
}
|
|
744
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
745
|
+
state.stepResults[step.id] = postRes.out;
|
|
746
|
+
}
|
|
747
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
748
|
+
state.stepResults[step.id] = postRes;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
752
|
+
continue;
|
|
753
|
+
const nextIdx = findNextStepIndex(step);
|
|
754
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
if (step.type === workflow_1.WorkflowStepType.DB) {
|
|
758
|
+
const dbStep = step;
|
|
759
|
+
const connector = await this.getConnectorOrFetch(dbStep.connector_id, dbStep.connector_version);
|
|
760
|
+
if (!connector)
|
|
761
|
+
throw new Error("connector not found: " + dbStep.connector_id);
|
|
762
|
+
let body = dbStep.body || {};
|
|
763
|
+
if (typeof body === "object")
|
|
764
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), state));
|
|
765
|
+
else if (typeof body === "string")
|
|
766
|
+
body = await (0, template_1.renderTemplate)(body, state);
|
|
767
|
+
const options = { ...body };
|
|
768
|
+
if (dbStep.connection_id)
|
|
769
|
+
options.connection_id = dbStep.connection_id;
|
|
770
|
+
if (dbStep.database)
|
|
771
|
+
options.database = dbStep.database;
|
|
772
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, dbStep.action, options, state);
|
|
773
|
+
if (resp?.terminate)
|
|
774
|
+
return resp;
|
|
775
|
+
warnConnectorResponseShape(step.id, dbStep.connector_id, dbStep.action, resp);
|
|
776
|
+
const normalResp = resp;
|
|
777
|
+
state.stepResults[step.id] = normalResp?.mapped ?? normalResp?.raw ?? null;
|
|
778
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
779
|
+
const postFnSource = step.post_source;
|
|
780
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
781
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
782
|
+
const postCtx = {
|
|
783
|
+
input: state.stepResults[step.id],
|
|
784
|
+
trigger: state.trigger,
|
|
785
|
+
steps: state.stepResults,
|
|
786
|
+
vars: state.vars,
|
|
787
|
+
};
|
|
788
|
+
const postRes = await userFn(postCtx, {});
|
|
789
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
790
|
+
for (const k of Object.keys(postRes.setVars))
|
|
791
|
+
state.vars[k] = postRes.setVars[k];
|
|
792
|
+
}
|
|
793
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
794
|
+
state.stepResults[step.id] = postRes.out;
|
|
795
|
+
}
|
|
796
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
797
|
+
state.stepResults[step.id] = postRes;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
801
|
+
continue;
|
|
802
|
+
const nextIdx = findNextStepIndex(step);
|
|
803
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (step.type === workflow_1.WorkflowStepType.FUNCTION) {
|
|
807
|
+
const fnStep = step;
|
|
808
|
+
const fnId = fnStep.function_id || fnStep.function_slug;
|
|
809
|
+
if (!fnId)
|
|
810
|
+
throw new Error("function step missing function_id or function_slug");
|
|
811
|
+
const args = {};
|
|
812
|
+
for (const k of Object.keys(fnStep.args || {})) {
|
|
813
|
+
const v = fnStep.args[k];
|
|
814
|
+
args[k] = typeof v === "string" && v.includes("{{") ? await (0, template_1.renderTemplate)(v, state) : v;
|
|
815
|
+
}
|
|
816
|
+
const fn = this.functions.get(fnId);
|
|
817
|
+
let fnResult;
|
|
818
|
+
if (fn) {
|
|
819
|
+
fnResult = await this.runFunction(fn, args, state);
|
|
820
|
+
}
|
|
821
|
+
else if (this.client?.functions?.invoke) {
|
|
822
|
+
try {
|
|
823
|
+
const data = await this.client.functions.invoke(fnId, args);
|
|
824
|
+
fnResult = { ok: true, data };
|
|
825
|
+
}
|
|
826
|
+
catch (e) {
|
|
827
|
+
fnResult = { ok: false, error: e?.message || "Remote function failed" };
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
throw new Error("Function not found: " + fnId);
|
|
832
|
+
}
|
|
833
|
+
state.stepResults[step.id] = fnResult.ok ? (fnResult.data ?? fnResult.stepResults ?? {}) : { error: fnResult.error, ok: false };
|
|
834
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
835
|
+
const postFnSource = step.post_source;
|
|
836
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
837
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
838
|
+
const postCtx = {
|
|
839
|
+
input: state.stepResults[step.id],
|
|
840
|
+
trigger: state.trigger,
|
|
841
|
+
steps: state.stepResults,
|
|
842
|
+
vars: state.vars,
|
|
843
|
+
};
|
|
844
|
+
const postRes = await userFn(postCtx, {});
|
|
845
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
846
|
+
for (const k of Object.keys(postRes.setVars))
|
|
847
|
+
state.vars[k] = postRes.setVars[k];
|
|
848
|
+
}
|
|
849
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
850
|
+
state.stepResults[step.id] = postRes.out;
|
|
851
|
+
}
|
|
852
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
853
|
+
state.stepResults[step.id] = postRes;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (isResultFailure(state.stepResults[step.id])) {
|
|
857
|
+
if (checkAndJumpToErrorBranch(step))
|
|
858
|
+
continue;
|
|
859
|
+
const nextIdx = findNextStepIndex(step);
|
|
860
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
864
|
+
continue;
|
|
865
|
+
const nextIdx = findNextStepIndex(step);
|
|
866
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if (step.type === workflow_1.WorkflowStepType.CALL_WORKFLOW) {
|
|
870
|
+
const wfStep = step;
|
|
871
|
+
const workflowId = wfStep.workflow_id;
|
|
872
|
+
let wPath = wfStep.webhook_path || wfStep.webhookPath;
|
|
873
|
+
if (typeof wPath === "string" && wPath.includes("{{")) {
|
|
874
|
+
wPath = await (0, template_1.renderTemplate)(wPath, state);
|
|
875
|
+
}
|
|
876
|
+
wPath = wPath ? String(wPath).trim() : "";
|
|
877
|
+
const wMethod = (wfStep.webhook_method || wfStep.webhookMethod || "POST").toUpperCase();
|
|
878
|
+
if (!workflowId && !wPath)
|
|
879
|
+
throw new Error("call_workflow step missing workflow_id and webhook_path");
|
|
880
|
+
const triggerId = wfStep.trigger_id || wfStep.triggerId || "trigger";
|
|
881
|
+
const forceRemote = wfStep.remote === true;
|
|
882
|
+
let payload = wfStep.payload || {};
|
|
883
|
+
if (typeof payload === "object") {
|
|
884
|
+
payload = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(payload), state));
|
|
885
|
+
}
|
|
886
|
+
const execHdrs = wfStep.execution_headers || wfStep.executionHeaders;
|
|
887
|
+
const extraHdr = execHdrs && typeof execHdrs === "object"
|
|
888
|
+
? Object.fromEntries(await Promise.all(Object.entries(execHdrs).map(async ([k, val]) => [
|
|
889
|
+
k,
|
|
890
|
+
typeof val === "string" && val.includes("{{") ? await (0, template_1.renderTemplate)(val, state) : val,
|
|
891
|
+
])))
|
|
892
|
+
: {};
|
|
893
|
+
const bodyData = payload?.data ?? payload?.body ?? payload ?? {};
|
|
894
|
+
const normPath = (p) => {
|
|
895
|
+
const s = String(p || "").trim();
|
|
896
|
+
if (!s)
|
|
897
|
+
return s;
|
|
898
|
+
return s.startsWith("/") ? s : `/${s}`;
|
|
899
|
+
};
|
|
900
|
+
const stackLabel = workflowId || wPath || "call";
|
|
901
|
+
const nextStack = [...(state.callStack || []), { kind: "workflow", workflowId: stackLabel, stepId: step.id }];
|
|
902
|
+
if (nextStack.filter((x) => x?.kind === "workflow").length > 15) {
|
|
903
|
+
throw new Error("call_workflow nesting depth exceeded");
|
|
904
|
+
}
|
|
905
|
+
if (!forceRemote) {
|
|
906
|
+
let local = undefined;
|
|
907
|
+
if (workflowId) {
|
|
908
|
+
local = this.workflows.get(workflowId);
|
|
909
|
+
if (!local) {
|
|
910
|
+
for (const w of this.workflows.values()) {
|
|
911
|
+
const ww = w;
|
|
912
|
+
if (ww._id === workflowId || ww.__rawId === workflowId || ww.name === workflowId) {
|
|
913
|
+
local = ww;
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (!local && wPath) {
|
|
920
|
+
for (const w of this.workflows.values()) {
|
|
921
|
+
const ww = w;
|
|
922
|
+
const tr = ww.trigger;
|
|
923
|
+
const url = tr?.webhook_url;
|
|
924
|
+
const m = (tr?.webhookMethod ?? "POST").toUpperCase();
|
|
925
|
+
if (url && normPath(url) === normPath(wPath) && m === wMethod) {
|
|
926
|
+
local = ww;
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (local) {
|
|
932
|
+
const sub = await this.runWorkflow(local, {
|
|
933
|
+
body: bodyData,
|
|
934
|
+
data: bodyData,
|
|
935
|
+
headers: { ...state.headers, ...extraHdr },
|
|
936
|
+
pathParams: state.pathParams,
|
|
937
|
+
query: state.query,
|
|
938
|
+
vars: { ...state.vars },
|
|
939
|
+
envVars: state.env,
|
|
940
|
+
callStack: nextStack,
|
|
941
|
+
});
|
|
942
|
+
if (sub && sub.terminate) {
|
|
943
|
+
state.stepResults[step.id] = { terminated: true, ...sub };
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
state.stepResults[step.id] = sub?.body ?? sub;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
else if (!this.client?.workflows?.run) {
|
|
950
|
+
throw new Error("call_workflow: workflow not found locally and FlosyncClient is not configured. Register the child workflow or set remote: true with apiKey/apiSecret.");
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (forceRemote || !state.stepResults[step.id]) {
|
|
954
|
+
if (!this.client?.workflows?.run) {
|
|
955
|
+
throw new Error("Client required for remote call_workflow. Configure apiKey and apiSecret.");
|
|
956
|
+
}
|
|
957
|
+
let result;
|
|
958
|
+
if (wPath) {
|
|
959
|
+
const wbPayload = {
|
|
960
|
+
body: bodyData,
|
|
961
|
+
environment: wfStep.environment,
|
|
962
|
+
};
|
|
963
|
+
if (extraHdr && Object.keys(extraHdr).length > 0) {
|
|
964
|
+
wbPayload.executionHeaders = extraHdr;
|
|
965
|
+
}
|
|
966
|
+
result = await this.client.workflows.runByWebhook(wPath, wMethod, wbPayload);
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
const normPayload = payload && typeof payload === "object" && !Array.isArray(payload) && ("data" in payload || "body" in payload)
|
|
970
|
+
? payload
|
|
971
|
+
: { body: bodyData, data: bodyData };
|
|
972
|
+
result = await this.client.workflows.run(workflowId, triggerId, {
|
|
973
|
+
payload: normPayload,
|
|
974
|
+
environment: wfStep.environment,
|
|
975
|
+
executionHeaders: extraHdr && Object.keys(extraHdr).length > 0 ? extraHdr : undefined,
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
const body = result?.body ?? result?.data ?? result;
|
|
979
|
+
state.stepResults[step.id] = body;
|
|
980
|
+
}
|
|
981
|
+
if (typeof step.post_source === "string" && step.post_source.trim().length > 0) {
|
|
982
|
+
const postFnSource = step.post_source;
|
|
983
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
984
|
+
const userFn = new AsyncFunction("ctx", "platform", postFnSource);
|
|
985
|
+
const postCtx = {
|
|
986
|
+
input: state.stepResults[step.id],
|
|
987
|
+
trigger: state.trigger,
|
|
988
|
+
steps: state.stepResults,
|
|
989
|
+
vars: state.vars,
|
|
990
|
+
};
|
|
991
|
+
const postRes = await userFn(postCtx, {});
|
|
992
|
+
if (postRes && typeof postRes === "object" && postRes.setVars && typeof postRes.setVars === "object") {
|
|
993
|
+
for (const k of Object.keys(postRes.setVars))
|
|
994
|
+
state.vars[k] = postRes.setVars[k];
|
|
995
|
+
}
|
|
996
|
+
if (postRes && typeof postRes === "object" && Object.prototype.hasOwnProperty.call(postRes, "out")) {
|
|
997
|
+
state.stepResults[step.id] = postRes.out;
|
|
998
|
+
}
|
|
999
|
+
else if (postRes !== undefined && typeof postRes !== "object") {
|
|
1000
|
+
state.stepResults[step.id] = postRes;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (isResultFailure(state.stepResults[step.id])) {
|
|
1004
|
+
if (checkAndJumpToErrorBranch(step))
|
|
1005
|
+
continue;
|
|
1006
|
+
const nextIdx = findNextStepIndex(step);
|
|
1007
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
if (checkAndJumpToSuccessBranch(step))
|
|
1011
|
+
continue;
|
|
1012
|
+
const nextIdx = findNextStepIndex(step);
|
|
1013
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
1014
|
+
continue;
|
|
1015
|
+
}
|
|
1016
|
+
if (step.type === workflow_1.WorkflowStepType.LOOP) {
|
|
1017
|
+
const loopStep = step;
|
|
1018
|
+
const overExpr = loopStep.over;
|
|
1019
|
+
if (!overExpr)
|
|
1020
|
+
throw new Error("Loop step requires 'over' expression");
|
|
1021
|
+
const iterableRaw = await (0, template_1.evaluateExpression)(overExpr, ctx);
|
|
1022
|
+
let iterable = [];
|
|
1023
|
+
if (Array.isArray(iterableRaw))
|
|
1024
|
+
iterable = iterableRaw;
|
|
1025
|
+
else if (iterableRaw && typeof iterableRaw === "object" && typeof iterableRaw[Symbol.iterator] === "function") {
|
|
1026
|
+
iterable = Array.from(iterableRaw);
|
|
1027
|
+
}
|
|
1028
|
+
else if (iterableRaw && typeof iterableRaw === "object") {
|
|
1029
|
+
iterable = Object.entries(iterableRaw);
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
throw new Error("Loop 'over' must evaluate to array or iterable");
|
|
1033
|
+
}
|
|
1034
|
+
const maxIter = loopStep.max_iterations ?? 1000;
|
|
1035
|
+
if (iterable.length > maxIter)
|
|
1036
|
+
throw new Error(`Loop exceeds max iterations (${maxIter})`);
|
|
1037
|
+
const as = loopStep.as ?? "item";
|
|
1038
|
+
const indexAs = loopStep.index_as ?? "index";
|
|
1039
|
+
const nestedSteps = loopStep.steps || [];
|
|
1040
|
+
const loopResults = [];
|
|
1041
|
+
for (let idx = 0; idx < iterable.length; idx++) {
|
|
1042
|
+
const item = iterable[idx];
|
|
1043
|
+
const loopCtx = {
|
|
1044
|
+
...ctx,
|
|
1045
|
+
vars: { ...state.vars, [as]: item, [indexAs]: idx },
|
|
1046
|
+
[as]: item,
|
|
1047
|
+
[indexAs]: idx,
|
|
1048
|
+
};
|
|
1049
|
+
let iterResult = null;
|
|
1050
|
+
for (const ns of nestedSteps) {
|
|
1051
|
+
if (ns.type === workflow_1.WorkflowStepType.TRANSFORM && ns.mapping) {
|
|
1052
|
+
const out = {};
|
|
1053
|
+
for (const k of Object.keys(ns.mapping)) {
|
|
1054
|
+
out[k] = await resolveTemplateOrExpression(ns.mapping[k], loopCtx);
|
|
1055
|
+
}
|
|
1056
|
+
state.stepResults[ns.id] = out;
|
|
1057
|
+
iterResult = out;
|
|
1058
|
+
}
|
|
1059
|
+
else if (ns.type === workflow_1.WorkflowStepType.LOG) {
|
|
1060
|
+
const msg = await (0, template_1.renderTemplate)(ns.message, loopCtx);
|
|
1061
|
+
state.stepResults[ns.id] = { logged: msg };
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
loopResults.push({ index: idx, item, result: iterResult });
|
|
1065
|
+
}
|
|
1066
|
+
state.stepResults[step.id] = { iterations: loopResults.length, results: loopResults };
|
|
1067
|
+
const nextIdx = findNextStepIndex(step);
|
|
1068
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
if (step.type === workflow_1.WorkflowStepType.NOTIFY) {
|
|
1072
|
+
state.stepResults[step.id] = { notified: step.channel };
|
|
1073
|
+
const nextIdx = findNextStepIndex(step);
|
|
1074
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
const nextIdx = findNextStepIndex(step);
|
|
1078
|
+
currentStepIndex = nextIdx >= 0 ? nextIdx : -1;
|
|
1079
|
+
}
|
|
1080
|
+
catch (err) {
|
|
1081
|
+
const fail = buildHttpStepFailurePayload(err);
|
|
1082
|
+
state.stepResults[step.id] = fail;
|
|
1083
|
+
state.stepErrors[step.id] = fail;
|
|
1084
|
+
if (checkAndJumpToErrorBranch(step))
|
|
1085
|
+
continue;
|
|
1086
|
+
const nextIdx = findNextStepIndex(step);
|
|
1087
|
+
if (nextIdx >= 0) {
|
|
1088
|
+
currentStepIndex = nextIdx;
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
throw err;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return { statusCode: 200, body: state.stepResults };
|
|
1095
|
+
}
|
|
1096
|
+
async runFunction(func, args, parentState) {
|
|
1097
|
+
const steps = func.steps || [];
|
|
1098
|
+
const state = {
|
|
1099
|
+
workflow: parentState?.workflow || {},
|
|
1100
|
+
trigger: parentState?.trigger || {},
|
|
1101
|
+
body: parentState?.body ?? args,
|
|
1102
|
+
bracket: args,
|
|
1103
|
+
brackets: args,
|
|
1104
|
+
callStack: parentState?.callStack || [],
|
|
1105
|
+
stepResults: {},
|
|
1106
|
+
stepErrors: {},
|
|
1107
|
+
vars: { ...(parentState?.vars || {}), ...(func.vars || {}) },
|
|
1108
|
+
headers: parentState?.headers || {},
|
|
1109
|
+
params: parentState?.params || {},
|
|
1110
|
+
pathParams: parentState?.pathParams || {},
|
|
1111
|
+
query: parentState?.query || {},
|
|
1112
|
+
tenantId: parentState?.tenantId,
|
|
1113
|
+
env: parentState?.env || {},
|
|
1114
|
+
connectorConfig: parentState?.connectorConfig || this.connectorConfig,
|
|
1115
|
+
};
|
|
1116
|
+
const templateState = () => ({
|
|
1117
|
+
...state.stepResults,
|
|
1118
|
+
stepResults: state.stepResults,
|
|
1119
|
+
args,
|
|
1120
|
+
trigger: state.trigger,
|
|
1121
|
+
body: state.body,
|
|
1122
|
+
vars: state.vars,
|
|
1123
|
+
headers: state.headers,
|
|
1124
|
+
params: state.params,
|
|
1125
|
+
pathParams: state.pathParams,
|
|
1126
|
+
query: state.query,
|
|
1127
|
+
env: state.env,
|
|
1128
|
+
});
|
|
1129
|
+
for (let i = 0; i < steps.length; i++) {
|
|
1130
|
+
const step = steps[i];
|
|
1131
|
+
const ctx = templateState();
|
|
1132
|
+
if (step.type === "responder" || step.type === workflow_1.WorkflowStepType.RESPONDER) {
|
|
1133
|
+
const connector = builtin_1.jsonResponderConnector;
|
|
1134
|
+
const config = step.config || {};
|
|
1135
|
+
const options = {
|
|
1136
|
+
statusCode: config.statusCode ?? 200,
|
|
1137
|
+
body: config.body,
|
|
1138
|
+
};
|
|
1139
|
+
options.body = await renderBodyRecursive(options.body, ctx);
|
|
1140
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, "json.respond", options, state);
|
|
1141
|
+
if (resp?.terminate) {
|
|
1142
|
+
const isDebug = args?.debug === true || String(state.headers?.["x-flosync-debug"]) === "true";
|
|
1143
|
+
if (isDebug && resp.body && typeof resp.body === "object") {
|
|
1144
|
+
resp.body._debug = { stepResults: state.stepResults };
|
|
1145
|
+
}
|
|
1146
|
+
return { ok: true, data: resp.body, stepResults: state.stepResults };
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (step.type === "validator" || step.type === workflow_1.WorkflowStepType.VALIDATOR) {
|
|
1150
|
+
const valStep = step;
|
|
1151
|
+
const inputData = args;
|
|
1152
|
+
const templateStateForVal = { ...state.stepResults, args, body: state.body, vars: state.vars };
|
|
1153
|
+
const resolvedGroups = await Promise.all((valStep.validationGroups || []).map(async (group) => {
|
|
1154
|
+
const resolvedFields = await Promise.all((group.fields || []).map((expr) => (0, template_1.renderTemplate)(expr, templateStateForVal)));
|
|
1155
|
+
const fieldNames = (group.fields || []).map((expr) => {
|
|
1156
|
+
const parts = expr.replace(/\{\{|\}\}/g, "").trim().split(".");
|
|
1157
|
+
return parts.length > 0 ? parts[parts.length - 1] : expr;
|
|
1158
|
+
});
|
|
1159
|
+
const resolvedValidators = (group.validators || []).map((v) => ({
|
|
1160
|
+
name: v.name,
|
|
1161
|
+
config: v.config || {},
|
|
1162
|
+
}));
|
|
1163
|
+
return { fields: resolvedFields, fieldNames, validators: resolvedValidators };
|
|
1164
|
+
}));
|
|
1165
|
+
const errors = {};
|
|
1166
|
+
let allValid = true;
|
|
1167
|
+
const pushErrors = (fieldName, messages) => {
|
|
1168
|
+
if (!messages.length)
|
|
1169
|
+
return;
|
|
1170
|
+
const prev = errors[fieldName] ?? [];
|
|
1171
|
+
errors[fieldName] = [...new Set([...prev, ...messages])];
|
|
1172
|
+
};
|
|
1173
|
+
for (const group of resolvedGroups) {
|
|
1174
|
+
const { fields = [], fieldNames = [], validators = [] } = group;
|
|
1175
|
+
if (fields.length === 0 || validators.length === 0)
|
|
1176
|
+
continue;
|
|
1177
|
+
for (let i = 0; i < fields.length; i++) {
|
|
1178
|
+
const val = fields[i];
|
|
1179
|
+
const name = (fieldNames && fieldNames[i]) || `field_${i}`;
|
|
1180
|
+
const validations = validators.map((v) => ({ validator: v.name, options: v.config || {} }));
|
|
1181
|
+
const { valid, failures } = (0, validators_1.applyValidationsCollectAll)(validations, val, {
|
|
1182
|
+
stepId: step.id,
|
|
1183
|
+
fieldName: name,
|
|
1184
|
+
});
|
|
1185
|
+
if (!valid) {
|
|
1186
|
+
allValid = false;
|
|
1187
|
+
pushErrors(name, failures.map((f) => f.message));
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
state.stepResults[step.id] = {
|
|
1192
|
+
valid: allValid,
|
|
1193
|
+
ok: allValid,
|
|
1194
|
+
statusCode: allValid ? 200 : 400,
|
|
1195
|
+
errors: Object.keys(errors).length > 0 ? errors : undefined,
|
|
1196
|
+
result: allValid ? { valid: true } : { valid: false },
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
if (step.type === "transform" || step.type === workflow_1.WorkflowStepType.TRANSFORM) {
|
|
1200
|
+
const transStep = step;
|
|
1201
|
+
if (transStep.mapping) {
|
|
1202
|
+
const out = {};
|
|
1203
|
+
for (const k of Object.keys(transStep.mapping)) {
|
|
1204
|
+
out[k] = await resolveTemplateOrExpression(transStep.mapping[k], ctx);
|
|
1205
|
+
}
|
|
1206
|
+
state.stepResults[step.id] = out;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if (step.type === "api_call" || step.type === workflow_1.WorkflowStepType.API_CALL) {
|
|
1210
|
+
const apiStep = step;
|
|
1211
|
+
const connector = await this.getConnectorOrFetch(apiStep.connector_id, apiStep.connector_version);
|
|
1212
|
+
if (!connector)
|
|
1213
|
+
throw new Error("connector not found: " + apiStep.connector_id);
|
|
1214
|
+
if (apiStep.vars && typeof apiStep.vars === "object" && !Array.isArray(apiStep.vars)) {
|
|
1215
|
+
const merged = { ...state.vars };
|
|
1216
|
+
for (const [k, v] of Object.entries(apiStep.vars)) {
|
|
1217
|
+
merged[k] =
|
|
1218
|
+
typeof v === "string" && v.includes("{{") ? await (0, template_1.renderTemplate)(v, state) : v;
|
|
1219
|
+
}
|
|
1220
|
+
state.vars = merged;
|
|
1221
|
+
}
|
|
1222
|
+
let body = apiStep.body || {};
|
|
1223
|
+
if (typeof body === "object")
|
|
1224
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), state));
|
|
1225
|
+
else if (typeof body === "string")
|
|
1226
|
+
body = await (0, template_1.renderTemplate)(body, state);
|
|
1227
|
+
const pathParams = {};
|
|
1228
|
+
for (const k of Object.keys(apiStep.pathParams || {})) {
|
|
1229
|
+
pathParams[k] =
|
|
1230
|
+
typeof apiStep.pathParams[k] === "string" && apiStep.pathParams[k].includes("{{")
|
|
1231
|
+
? await (0, template_1.renderTemplate)(apiStep.pathParams[k], state)
|
|
1232
|
+
: apiStep.pathParams[k];
|
|
1233
|
+
}
|
|
1234
|
+
const params = {};
|
|
1235
|
+
for (const k of Object.keys(apiStep.params || {})) {
|
|
1236
|
+
params[k] =
|
|
1237
|
+
typeof apiStep.params[k] === "string" && apiStep.params[k].includes("{{")
|
|
1238
|
+
? await (0, template_1.renderTemplate)(apiStep.params[k], state)
|
|
1239
|
+
: apiStep.params[k];
|
|
1240
|
+
}
|
|
1241
|
+
const headers = {};
|
|
1242
|
+
const stepHeaders = apiStep.headers;
|
|
1243
|
+
if (stepHeaders) {
|
|
1244
|
+
if (typeof stepHeaders === "object" && !Array.isArray(stepHeaders)) {
|
|
1245
|
+
for (const [key, value] of Object.entries(stepHeaders)) {
|
|
1246
|
+
headers[key] =
|
|
1247
|
+
typeof value === "string" && value.includes("{{")
|
|
1248
|
+
? await (0, template_1.renderTemplate)(value, state)
|
|
1249
|
+
: value;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
else if (Array.isArray(stepHeaders)) {
|
|
1253
|
+
for (const h of stepHeaders) {
|
|
1254
|
+
if (h?.key && h?.value !== undefined) {
|
|
1255
|
+
headers[h.key] =
|
|
1256
|
+
typeof h.value === "string" && h.value.includes("{{")
|
|
1257
|
+
? await (0, template_1.renderTemplate)(h.value, state)
|
|
1258
|
+
: h.value;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const execOpts = { params, pathParams, body };
|
|
1264
|
+
if (Object.keys(headers).length > 0)
|
|
1265
|
+
execOpts.headers = headers;
|
|
1266
|
+
if (apiStep.timeout != null)
|
|
1267
|
+
execOpts.timeout = apiStep.timeout;
|
|
1268
|
+
if (apiStep.files)
|
|
1269
|
+
execOpts.files = apiStep.files;
|
|
1270
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, apiStep.action, execOpts, state);
|
|
1271
|
+
if (resp?.terminate)
|
|
1272
|
+
return { ok: true, data: resp.body, stepResults: state.stepResults };
|
|
1273
|
+
warnConnectorResponseShape(step.id, apiStep.connector_id, apiStep.action, resp);
|
|
1274
|
+
state.stepResults[step.id] = resp?.mapped ?? resp?.raw ?? null;
|
|
1275
|
+
}
|
|
1276
|
+
if (step.type === "db" || step.type === workflow_1.WorkflowStepType.DB) {
|
|
1277
|
+
const dbStep = step;
|
|
1278
|
+
const connector = await this.getConnectorOrFetch(dbStep.connector_id, dbStep.connector_version);
|
|
1279
|
+
if (!connector)
|
|
1280
|
+
throw new Error("connector not found: " + dbStep.connector_id);
|
|
1281
|
+
let body = dbStep.body || {};
|
|
1282
|
+
if (typeof body === "object")
|
|
1283
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), ctx));
|
|
1284
|
+
const resp = await (0, connector_executor_1.executeConnectorAction)(connector, dbStep.action, { ...body }, state);
|
|
1285
|
+
if (resp?.terminate)
|
|
1286
|
+
return { ok: true, data: resp.body, stepResults: state.stepResults };
|
|
1287
|
+
warnConnectorResponseShape(step.id, dbStep.connector_id, dbStep.action, resp);
|
|
1288
|
+
state.stepResults[step.id] = resp?.mapped ?? resp?.raw ?? null;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
const outputFrom = func.output_from;
|
|
1292
|
+
const output = outputFrom
|
|
1293
|
+
? state.stepResults[outputFrom]
|
|
1294
|
+
: (() => {
|
|
1295
|
+
const lastStep = steps[steps.length - 1];
|
|
1296
|
+
return lastStep ? state.stepResults[lastStep.id] : state.stepResults;
|
|
1297
|
+
})();
|
|
1298
|
+
return { ok: true, data: output, stepResults: state.stepResults };
|
|
1299
|
+
}
|
|
1300
|
+
normalizeTrigger(payload) {
|
|
1301
|
+
if (!payload || typeof payload !== "object")
|
|
1302
|
+
return payload;
|
|
1303
|
+
if (Array.isArray(payload))
|
|
1304
|
+
return { data: payload, body: payload };
|
|
1305
|
+
const trigger = payload.trigger ?? payload;
|
|
1306
|
+
const data = trigger.data ?? trigger.body ?? payload.data ?? payload.body ?? payload;
|
|
1307
|
+
const bodyObj = typeof data === "object" && data !== null ? data : {};
|
|
1308
|
+
return { ...bodyObj, ...trigger, data, body: data };
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
exports.ProcessorEngine = ProcessorEngine;
|