cliodot 1.2.2 → 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.
Files changed (147) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +178 -0
  7. package/dist/CommercialAppClient.d.ts.map +1 -0
  8. package/dist/CommercialAppClient.js +576 -0
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +23 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -0
  18. package/dist/IdentityAppClient.js +197 -0
  19. package/dist/MemoryAppClient.d.ts +28 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -0
  21. package/dist/MemoryAppClient.js +149 -0
  22. package/dist/MemoryClient.d.ts +8 -0
  23. package/dist/MemoryClient.d.ts.map +1 -0
  24. package/dist/MemoryClient.js +20 -0
  25. package/dist/OAuthAppClient.d.ts +1 -0
  26. package/dist/OAuthAppClient.d.ts.map +1 -1
  27. package/dist/OAuthAppClient.js +269 -1
  28. package/dist/ProviderServicesClient.d.ts +24 -0
  29. package/dist/ProviderServicesClient.d.ts.map +1 -0
  30. package/dist/ProviderServicesClient.js +158 -0
  31. package/dist/Surface.d.ts +2 -0
  32. package/dist/Surface.d.ts.map +1 -1
  33. package/dist/Surface.js +255 -1
  34. package/dist/ValidatorBuilder.js +24 -1
  35. package/dist/Webhooks.d.ts +20 -0
  36. package/dist/Webhooks.d.ts.map +1 -0
  37. package/dist/Webhooks.js +61 -0
  38. package/dist/WorkflowBuilder.js +279 -1
  39. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  40. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  41. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  42. package/dist/__tests__/Events.test.js +191 -1
  43. package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
  44. package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
  45. package/dist/__tests__/IdentityAppClient.test.js +232 -0
  46. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  47. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  48. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  49. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  50. package/dist/__tests__/Surface.test.js +150 -1
  51. package/dist/__tests__/errors.test.js +54 -1
  52. package/dist/__tests__/function.test.js +58 -1
  53. package/dist/__tests__/helpers.d.ts +5 -0
  54. package/dist/__tests__/helpers.d.ts.map +1 -0
  55. package/dist/__tests__/helpers.js +10 -0
  56. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  57. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  58. package/dist/__tests__/localhost-lookup.test.js +26 -0
  59. package/dist/__tests__/parse-api-error.test.js +26 -1
  60. package/dist/__tests__/runner.test.js +156 -1
  61. package/dist/connectors/builtin.js +354 -1
  62. package/dist/connectors/registry.js +300 -1
  63. package/dist/decorators/build.js +105 -1
  64. package/dist/decorators/connector.js +56 -1
  65. package/dist/decorators/index.js +34 -1
  66. package/dist/decorators/metadata.js +338 -1
  67. package/dist/decorators/steps.js +220 -1
  68. package/dist/decorators/workflow.js +52 -1
  69. package/dist/errors.js +76 -1
  70. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  71. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  73. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  74. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  75. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  76. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  77. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  78. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  79. package/dist/http/cliodot-request.d.ts +35 -0
  80. package/dist/http/cliodot-request.d.ts.map +1 -0
  81. package/dist/http/cliodot-request.js +105 -0
  82. package/dist/http/cliodot-result.d.ts +40 -0
  83. package/dist/http/cliodot-result.d.ts.map +1 -0
  84. package/dist/http/cliodot-result.js +139 -0
  85. package/dist/http/create-client.d.ts +3 -0
  86. package/dist/http/create-client.d.ts.map +1 -0
  87. package/dist/http/create-client.js +14 -0
  88. package/dist/http/events-instance-id.d.ts +11 -0
  89. package/dist/http/events-instance-id.d.ts.map +1 -0
  90. package/dist/http/events-instance-id.js +86 -0
  91. package/dist/http/localhost-lookup.d.ts +12 -0
  92. package/dist/http/localhost-lookup.d.ts.map +1 -0
  93. package/dist/http/localhost-lookup.js +67 -0
  94. package/dist/http/parse-api-error.js +56 -1
  95. package/dist/http/sanitize-execution-headers.js +79 -1
  96. package/dist/identity-offline-verify.d.ts +6 -0
  97. package/dist/identity-offline-verify.d.ts.map +1 -0
  98. package/dist/identity-offline-verify.js +174 -0
  99. package/dist/identity-token-cache.d.ts +6 -0
  100. package/dist/identity-token-cache.d.ts.map +1 -0
  101. package/dist/identity-token-cache.js +51 -0
  102. package/dist/index.d.ts +10 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +108 -1
  105. package/dist/runner/ProcessorEngine.js +1311 -1
  106. package/dist/runner/connector.executor.js +1786 -1
  107. package/dist/runner/utilities/math.executor.js +153 -1
  108. package/dist/runner/utilities/random.executor.js +151 -1
  109. package/dist/runner/utilities/string.executor.js +825 -1
  110. package/dist/template.js +127 -1
  111. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  112. package/dist/transformers/WorkflowTransformer.js +189 -1
  113. package/dist/types/auth-app.api.d.ts +2 -0
  114. package/dist/types/auth-app.api.d.ts.map +1 -1
  115. package/dist/types/auth-app.api.js +2 -1
  116. package/dist/types/builtin.js +2 -1
  117. package/dist/types/client.api.js +2 -1
  118. package/dist/types/commercial-app.api.d.ts +963 -0
  119. package/dist/types/commercial-app.api.d.ts.map +1 -0
  120. package/dist/types/commercial-app.api.js +2 -0
  121. package/dist/types/connector.js +2 -1
  122. package/dist/types/context.js +2 -1
  123. package/dist/types/event-app.api.d.ts +8 -0
  124. package/dist/types/event-app.api.d.ts.map +1 -1
  125. package/dist/types/event-app.api.js +2 -1
  126. package/dist/types/function.js +2 -1
  127. package/dist/types/identity-app.api.d.ts +99 -0
  128. package/dist/types/identity-app.api.d.ts.map +1 -0
  129. package/dist/types/identity-app.api.js +2 -0
  130. package/dist/types/index.js +23 -1
  131. package/dist/types/memory-app.api.d.ts +140 -0
  132. package/dist/types/memory-app.api.d.ts.map +1 -0
  133. package/dist/types/memory-app.api.js +2 -0
  134. package/dist/types/oauth-app.api.d.ts +2 -0
  135. package/dist/types/oauth-app.api.d.ts.map +1 -1
  136. package/dist/types/oauth-app.api.js +105 -1
  137. package/dist/types/provider-services.api.d.ts +98 -0
  138. package/dist/types/provider-services.api.d.ts.map +1 -0
  139. package/dist/types/provider-services.api.js +2 -0
  140. package/dist/types/validator.js +2 -1
  141. package/dist/types/webhook-app.api.d.ts +2 -0
  142. package/dist/types/webhook-app.api.d.ts.map +1 -0
  143. package/dist/types/webhook-app.api.js +2 -0
  144. package/dist/types/workflow.js +33 -1
  145. package/dist/validators/validators.js +478 -1
  146. package/dist/variable.js +37 -1
  147. package/package.json +3 -2
@@ -1 +1,1311 @@
1
- 'use strict';const _0x38f9f9=_0x227f;(function(_0x2c6cd3,_0x506c74){const _0x4336f2=_0x227f,_0xd118c9=_0x2c6cd3();while(!![]){try{const _0x1c5825=-parseInt(_0x4336f2(0x1f4))/0x1+-parseInt(_0x4336f2(0x1c5))/0x2*(parseInt(_0x4336f2(0x238))/0x3)+parseInt(_0x4336f2(0x21f))/0x4+parseInt(_0x4336f2(0x1fe))/0x5*(parseInt(_0x4336f2(0x1e8))/0x6)+-parseInt(_0x4336f2(0x23c))/0x7+-parseInt(_0x4336f2(0x21b))/0x8+parseInt(_0x4336f2(0x1ee))/0x9;if(_0x1c5825===_0x506c74)break;else _0xd118c9['push'](_0xd118c9['shift']());}catch(_0x37b307){_0xd118c9['push'](_0xd118c9['shift']());}}}(_0x165a,0xd151e));function _0x227f(_0xdc4d06,_0x451495){_0xdc4d06=_0xdc4d06-0x193;const _0x165a7b=_0x165a();let _0x227f90=_0x165a7b[_0xdc4d06];if(_0x227f['PScHsu']===undefined){var _0x158edc=function(_0x59b2c4){const _0x416c92='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x8b23c='',_0x472f36='';for(let _0x314471=0x0,_0x54d6c8,_0x53e3d3,_0x3e5872=0x0;_0x53e3d3=_0x59b2c4['charAt'](_0x3e5872++);~_0x53e3d3&&(_0x54d6c8=_0x314471%0x4?_0x54d6c8*0x40+_0x53e3d3:_0x53e3d3,_0x314471++%0x4)?_0x8b23c+=String['fromCharCode'](0xff&_0x54d6c8>>(-0x2*_0x314471&0x6)):0x0){_0x53e3d3=_0x416c92['indexOf'](_0x53e3d3);}for(let _0x3928ab=0x0,_0x107b85=_0x8b23c['length'];_0x3928ab<_0x107b85;_0x3928ab++){_0x472f36+='%'+('00'+_0x8b23c['charCodeAt'](_0x3928ab)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x472f36);};_0x227f['qyXtUi']=_0x158edc,_0x227f['vAzSTt']={},_0x227f['PScHsu']=!![];}const _0x3abdb0=_0x165a7b[0x0],_0x326726=_0xdc4d06+_0x3abdb0,_0x37847b=_0x227f['vAzSTt'][_0x326726];return!_0x37847b?(_0x227f90=_0x227f['qyXtUi'](_0x227f90),_0x227f['vAzSTt'][_0x326726]=_0x227f90):_0x227f90=_0x37847b,_0x227f90;}Object[_0x38f9f9(0x21e)](exports,_0x38f9f9(0x1ae),{'value':!![]}),exports[_0x38f9f9(0x1e3)]=void 0x0;const template_1=require(_0x38f9f9(0x1cf));function resolveTemplateOrExpression(value,_0x8b23c){const _0x22d01f=_0x38f9f9;if(typeof value!==_0x22d01f(0x22c))return Promise['resolve'](value);const _0x472f36=value[_0x22d01f(0x25e)]();if(_0x472f36[_0x22d01f(0x24f)]('{{')&&_0x472f36[_0x22d01f(0x1b9)]('}}')){const _0x314471=_0x472f36['slice'](0x2,-0x2)[_0x22d01f(0x25e)]();return(0x0,template_1[_0x22d01f(0x210)])(_0x314471,_0x8b23c);}return(0x0,template_1[_0x22d01f(0x25a)])(value,_0x8b23c);}async function renderBodyRecursive(_0x54d6c8,_0x53e3d3){const _0x1da573=_0x38f9f9;if(_0x54d6c8==null)return _0x54d6c8;if(typeof _0x54d6c8===_0x1da573(0x22c)&&_0x54d6c8['includes']('{{')){const _0x3e5872=await(0x0,template_1['renderTemplate'])(_0x54d6c8,_0x53e3d3);if(typeof _0x3e5872===_0x1da573(0x22c)&&_0x3e5872[_0x1da573(0x24f)]('{')&&_0x3e5872[_0x1da573(0x1b9)]('}'))try{return JSON['parse'](_0x3e5872);}catch{return _0x3e5872;}if(typeof _0x3e5872===_0x1da573(0x22c)&&_0x3e5872[_0x1da573(0x24f)]('[')&&_0x3e5872[_0x1da573(0x1b9)](']'))try{return JSON[_0x1da573(0x206)](_0x3e5872);}catch{return _0x3e5872;}return _0x3e5872;}if(Array[_0x1da573(0x1da)](_0x54d6c8))return Promise['all'](_0x54d6c8[_0x1da573(0x235)](_0x3928ab=>renderBodyRecursive(_0x3928ab,_0x53e3d3)));if(typeof _0x54d6c8===_0x1da573(0x208)){const _0x107b85={};for(const _0x2598e9 of Object[_0x1da573(0x203)](_0x54d6c8)){_0x107b85[_0x2598e9]=await renderBodyRecursive(_0x54d6c8[_0x2598e9],_0x53e3d3);}return _0x107b85;}return _0x54d6c8;}const connector_executor_1=require(_0x38f9f9(0x20c)),validators_1=require('../validators/validators'),builtin_1=require(_0x38f9f9(0x200)),workflow_1=require(_0x38f9f9(0x1f2));function parseHttpErrorResponseData(_0x4d1e74){const _0x493062=_0x38f9f9;if(_0x4d1e74===undefined||_0x4d1e74===null)return _0x4d1e74;if(typeof _0x4d1e74===_0x493062(0x208))return _0x4d1e74;if(typeof _0x4d1e74===_0x493062(0x22c)){const _0x3e555d=_0x4d1e74[_0x493062(0x25e)]();if(_0x3e555d['startsWith']('{')&&_0x3e555d[_0x493062(0x1b9)]('}')||_0x3e555d['startsWith']('[')&&_0x3e555d['endsWith'](']'))try{return JSON[_0x493062(0x206)](_0x3e555d);}catch{return _0x4d1e74;}return _0x4d1e74;}return _0x4d1e74;}function buildHttpStepFailurePayload(_0x129415){const _0x349175=_0x38f9f9,_0x4295a8=_0x129415?.[_0x349175(0x1ca)],_0x21b21d=_0x129415?.[_0x349175(0x25b)]!==undefined?_0x129415[_0x349175(0x25b)]:_0x4295a8&&typeof _0x4295a8===_0x349175(0x208)&&_0x349175(0x25b)in _0x4295a8&&('config'in _0x4295a8||_0x349175(0x20e)in _0x4295a8||'statusText'in _0x4295a8)?_0x4295a8[_0x349175(0x25b)]:_0x4295a8,_0x94ab3=parseHttpErrorResponseData(_0x21b21d),_0x10c6d2=_0x129415?.[_0x349175(0x1e0)]||String(_0x129415),_0x4033c9={'ok':![],'message':_0x10c6d2},_0xa82006=typeof _0x129415?.['status']==='number'?_0x129415[_0x349175(0x1b5)]:_0x4295a8&&typeof _0x4295a8[_0x349175(0x1b5)]===_0x349175(0x1f1)?_0x4295a8['status']:undefined;typeof _0xa82006===_0x349175(0x1f1)&&(_0x4033c9[_0x349175(0x1b5)]=_0xa82006);_0x94ab3!==undefined&&(_0x4033c9[_0x349175(0x25b)]=_0x94ab3);if(_0x94ab3&&typeof _0x94ab3===_0x349175(0x208)&&_0x94ab3!==null&&typeof _0x94ab3[_0x349175(0x1e0)]===_0x349175(0x22c))_0x4033c9[_0x349175(0x24e)]=_0x94ab3['message'];else{if(typeof _0x94ab3===_0x349175(0x22c)&&_0x94ab3)_0x4033c9[_0x349175(0x24e)]=_0x94ab3;else _0x94ab3&&typeof _0x94ab3===_0x349175(0x208)&&_0x94ab3!==null&&typeof _0x94ab3['error']===_0x349175(0x22c)?_0x4033c9['error']=_0x94ab3['error']:_0x4033c9[_0x349175(0x24e)]=_0x10c6d2;}return _0x4033c9;}function warnConnectorResponseShape(_0x54ec31,_0x406b4a,_0x4a9e18,_0xe6ef5f){const _0x19f754=_0x38f9f9,_0x1287a9=_0xe6ef5f?.[_0x19f754(0x1f3)];Array[_0x19f754(0x1da)](_0x1287a9)&&_0x1287a9[_0x19f754(0x240)]&&console['warn'](_0x19f754(0x1bf)+_0x54ec31+_0x19f754(0x253)+_0x406b4a+_0x19f754(0x1b0)+_0x4a9e18+_0x19f754(0x25c)+_0x1287a9[_0x19f754(0x1a9)](';\x20'));}class ProcessorEngine{constructor(_0x533f2e={}){const _0x441b5f=_0x38f9f9;this[_0x441b5f(0x1fc)]=_0x533f2e[_0x441b5f(0x1fc)]||new Map(),this[_0x441b5f(0x193)]=_0x533f2e[_0x441b5f(0x193)]||new Map(),this[_0x441b5f(0x1a6)]=_0x533f2e[_0x441b5f(0x1a6)]||new Map(),this[_0x441b5f(0x257)]=_0x533f2e[_0x441b5f(0x257)]||{},this[_0x441b5f(0x216)]=_0x533f2e[_0x441b5f(0x216)]||null;}[_0x38f9f9(0x259)](_0x452df1){const _0x41464e=_0x38f9f9,_0x39de5c={'json.responder':builtin_1[_0x41464e(0x212)],'http.responder':builtin_1['httpResponderConnector'],'raw.responder':builtin_1[_0x41464e(0x20f)],'redirect.responder':builtin_1['redirectResponderConnector'],'empty.responder':builtin_1['emptyResponderConnector'],'condition.logic':builtin_1['conditionLogicConnector'],'mongodb.system':builtin_1[_0x41464e(0x1f8)],'mysql.system':builtin_1['mysqlConnector'],'postgres.system':builtin_1[_0x41464e(0x1a2)],'redis.system':builtin_1['redisConnector'],'bearer.system':builtin_1[_0x41464e(0x223)],'api_key.system':builtin_1[_0x41464e(0x1d4)],'basic.system':builtin_1[_0x41464e(0x202)],'custom_header.system':builtin_1['customHeaderAuthConnector'],'utility.date_time':builtin_1[_0x41464e(0x234)],'utility.string':builtin_1[_0x41464e(0x252)],'utility.random':builtin_1[_0x41464e(0x225)],'utility.math':builtin_1['mathUtilityConnector'],'utility.compare':builtin_1[_0x41464e(0x1cd)],'utility.geo':builtin_1[_0x41464e(0x1ed)],'base64.encryption':builtin_1[_0x41464e(0x25f)],'hash.encryption':builtin_1[_0x41464e(0x1d0)],'aes.encryption':builtin_1['aesEncryptionConnector'],'rsa.encryption':builtin_1[_0x41464e(0x1f5)],'hmac.encryption':builtin_1[_0x41464e(0x207)],'password.encryption':builtin_1[_0x41464e(0x1c9)]};return _0x39de5c[_0x452df1]??this[_0x41464e(0x1fc)][_0x41464e(0x19c)](_0x452df1);}async[_0x38f9f9(0x19b)](_0x5076ae,_0x5407db){const _0x337825=_0x38f9f9,_0x1457ff=_0x5407db!=null&&String(_0x5407db)[_0x337825(0x25e)]()!=='',_0x745c75=_0x1457ff?String(_0x5407db)[_0x337825(0x25e)]():'',_0x135473=_0x1457ff?_0x5076ae+_0x337825(0x24d)+_0x745c75:_0x5076ae;let _0x39d3c0=this['connectors'][_0x337825(0x19c)](_0x135473);if(_0x39d3c0)return _0x39d3c0;if(!_0x1457ff){_0x39d3c0=this[_0x337825(0x259)](_0x5076ae);if(_0x39d3c0)return _0x39d3c0;}if(this[_0x337825(0x216)]?.[_0x337825(0x1fc)]?.[_0x337825(0x19c)])try{_0x39d3c0=await this[_0x337825(0x216)]['connectors']['get'](_0x5076ae,_0x1457ff?{'version':_0x745c75}:undefined);if(_0x39d3c0)this[_0x337825(0x1fc)][_0x337825(0x19d)](_0x135473,_0x39d3c0);}catch{_0x39d3c0=null;}return _0x39d3c0;}async[_0x38f9f9(0x196)](_0x1587c4,_0x2824fc={}){const _0x55d9a2=_0x38f9f9,_0x22155a=this[_0x55d9a2(0x249)](_0x2824fc),_0x43a10c=_0x2824fc?.[_0x55d9a2(0x20e)]||{};delete _0x43a10c[_0x55d9a2(0x236)];const _0x1065ee=_0x2824fc?.[_0x55d9a2(0x21d)]??_0x2824fc?.['path_params']??{},_0x533197=_0x2824fc?.[_0x55d9a2(0x222)]??{},_0x4c5008=_0x2824fc?.[_0x55d9a2(0x1e9)]??{},_0x276a39=_0x22155a?.[_0x55d9a2(0x25b)]??{},_0x296766=_0x1587c4[_0x55d9a2(0x239)]||{},_0x7b2818=_0x2824fc?.[_0x55d9a2(0x239)]??{},_0x5e1f5b=_0x2824fc?.[_0x55d9a2(0x1dc)]??_0x2824fc?.['env_vars']??_0x2824fc?.[_0x55d9a2(0x1f6)]??{},_0x3d1c44={'workflow':_0x1587c4,'trigger':_0x22155a,'body':_0x276a39,'bracket':_0x276a39,'brackets':_0x276a39,'callStack':_0x2824fc?.[_0x55d9a2(0x1d6)]??_0x2824fc?.[_0x55d9a2(0x1cc)]??[],'stepResults':{},'stepErrors':{},'vars':{..._0x296766,..._0x7b2818},'headers':_0x43a10c,'params':{..._0x4c5008,..._0x533197},'pathParams':_0x1065ee,'query':_0x4c5008,'tenantId':_0x1587c4['tenant_id'],'env':_0x5e1f5b,'connectorConfig':this['connectorConfig']},_0x582c90=_0x1587c4['steps']||[],_0x22cd7a=0x3e8;let _0x39dc99=0x0;const _0x4f30fc=new Map();_0x582c90[_0x55d9a2(0x244)](_0x15c36a=>{const _0x4c5bf0=_0x55d9a2;if(_0x15c36a['input_from'])_0x4f30fc[_0x4c5bf0(0x19d)](_0x15c36a[_0x4c5bf0(0x213)],_0x15c36a['id']);});const _0x2f07a7=_0x5d1c1f=>{const _0x515af6=_0x55d9a2,_0x5a301d=_0x4f30fc[_0x515af6(0x19c)](_0x5d1c1f['id']);if(_0x5a301d){const _0x5519ea=_0x582c90['findIndex'](_0x1f6f30=>_0x1f6f30['id']===_0x5a301d);if(_0x5519ea>=0x0)return _0x5519ea;}return-0x1;},_0x4da39b=_0xffd719=>{const _0x283075=_0x55d9a2,_0x24668f=_0xffd719['else']||_0xffd719[_0x283075(0x1e5)];if(_0x24668f){const _0x20b220=_0x582c90[_0x283075(0x1dd)](_0x1e3d49=>_0x1e3d49['id']===_0x24668f);if(_0x20b220>=0x0)return _0x15d88c=_0x20b220,!![];}return![];},_0x5646bc=_0x38588f=>{const _0x107ad1=_0x55d9a2,_0x4caba1=_0x38588f[_0x107ad1(0x246)];if(_0x4caba1){const _0x5a7b91=_0x582c90[_0x107ad1(0x1dd)](_0x15872f=>_0x15872f['id']===_0x4caba1);if(_0x5a7b91>=0x0)return _0x15d88c=_0x5a7b91,!![];}return![];},_0x1b21f4=_0x78198a=>{const _0x2b07fd=_0x55d9a2;if(_0x78198a===null||_0x78198a===undefined)return!![];if(typeof _0x78198a==='object'&&(_0x78198a['ok']===![]||_0x78198a[_0x2b07fd(0x220)]===![]))return!![];return![];};let _0x15d88c=_0x582c90[_0x55d9a2(0x1dd)](_0x2505b7=>!_0x2505b7['input_from']);if(_0x15d88c<0x0)_0x15d88c=0x0;const _0x16668f=()=>({..._0x3d1c44[_0x55d9a2(0x201)],'stepResults':_0x3d1c44[_0x55d9a2(0x201)],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'body':_0x3d1c44[_0x55d9a2(0x233)],'vars':_0x3d1c44[_0x55d9a2(0x239)],'headers':_0x3d1c44['headers'],'params':_0x3d1c44[_0x55d9a2(0x222)],'pathParams':_0x3d1c44[_0x55d9a2(0x21d)],'query':_0x3d1c44[_0x55d9a2(0x1e9)],'env':_0x3d1c44['env']});while(_0x15d88c>=0x0&&_0x15d88c<_0x582c90['length']){if(++_0x39dc99>_0x22cd7a)throw new Error('max\x20steps\x20exceeded');const _0x180d7a=_0x582c90[_0x15d88c],_0x471df7=_0x16668f();try{if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType'][_0x55d9a2(0x24b)]){const _0x413f86=_0x180d7a;let _0x99d456=!![];if(_0x413f86[_0x55d9a2(0x1ab)])try{_0x99d456=await(0x0,template_1[_0x55d9a2(0x210)])(_0x413f86['when'],{..._0x471df7,'error':_0x3d1c44[_0x55d9a2(0x245)]});}catch{_0x99d456=![];}if(_0x99d456){const _0x144b46=_0x413f86['responder']+_0x55d9a2(0x1b7),_0x376b00=_0x144b46===_0x55d9a2(0x247)?builtin_1[_0x55d9a2(0x212)]:this[_0x55d9a2(0x259)](_0x144b46);if(!_0x376b00)throw new Error('Responder\x20not\x20found:\x20'+_0x144b46);const _0x2ce297=_0x413f86['config']||{};let _0x39226c=_0x2ce297[_0x55d9a2(0x1eb)]??0xc8;typeof _0x39226c===_0x55d9a2(0x22c)&&_0x39226c[_0x55d9a2(0x229)]('{{')&&(_0x39226c=Number(await(0x0,template_1[_0x55d9a2(0x25a)])(_0x39226c,_0x3d1c44))||0xc8);const _0x299a81={'statusCode':_0x39226c};if(_0x2ce297[_0x55d9a2(0x20e)]){_0x299a81[_0x55d9a2(0x20e)]={};for(const [_0x4f7157,_0x38365d]of Object[_0x55d9a2(0x1f0)](_0x2ce297[_0x55d9a2(0x20e)])){_0x299a81['headers'][_0x4f7157]=typeof _0x38365d===_0x55d9a2(0x22c)&&_0x38365d[_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x38365d,_0x3d1c44):_0x38365d;}}_0x2ce297[_0x55d9a2(0x233)]!==undefined&&(_0x299a81[_0x55d9a2(0x233)]=await renderBodyRecursive(_0x2ce297[_0x55d9a2(0x233)],_0x3d1c44));const _0x5c3401=await(0x0,connector_executor_1['executeConnectorAction'])(_0x376b00,_0x55d9a2(0x1c8),_0x299a81,_0x3d1c44);if(_0x5c3401?.['terminate']){const _0x124cb3=_0x2824fc?.['debug']===!![]||String(_0x3d1c44[_0x55d9a2(0x20e)]?.[_0x55d9a2(0x1c6)])===_0x55d9a2(0x1ce)||String(_0x2824fc?.[_0x55d9a2(0x1e9)]?.[_0x55d9a2(0x248)])===_0x55d9a2(0x1ce);return _0x124cb3&&_0x5c3401[_0x55d9a2(0x233)]&&typeof _0x5c3401[_0x55d9a2(0x233)]==='object'&&(_0x5c3401[_0x55d9a2(0x233)][_0x55d9a2(0x1b4)]={'stepResults':_0x3d1c44['stepResults']}),_0x5c3401;}}const _0xa9efcb=_0x2f07a7(_0x180d7a);_0x15d88c=_0xa9efcb>=0x0?_0xa9efcb:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)]['VALIDATOR']){const _0x5b80a6=_0x180d7a;let _0x51b6d5={};_0x5b80a6[_0x55d9a2(0x213)]?_0x51b6d5=_0x3d1c44[_0x55d9a2(0x201)][_0x5b80a6[_0x55d9a2(0x213)]]?.[_0x55d9a2(0x224)]??_0x3d1c44['stepResults'][_0x5b80a6[_0x55d9a2(0x213)]]??{}:_0x51b6d5=_0x3d1c44[_0x55d9a2(0x1ad)]?.[_0x55d9a2(0x25b)]??_0x3d1c44[_0x55d9a2(0x1ad)]??{};const _0x19fab7={..._0x3d1c44['stepResults'],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'body':_0x3d1c44['body'],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x178336=await Promise[_0x55d9a2(0x1c1)]((_0x5b80a6['validationGroups']||[])[_0x55d9a2(0x235)](async _0x3a1d9d=>{const _0x46132b=_0x55d9a2,_0x4ce161=await Promise[_0x46132b(0x1c1)]((_0x3a1d9d['fields']||[])[_0x46132b(0x235)](_0x566997=>(0x0,template_1[_0x46132b(0x25a)])(_0x566997,_0x19fab7))),_0x139ce3=(_0x3a1d9d[_0x46132b(0x1a5)]||[])['map'](_0x52b475=>{const _0x12aa5b=_0x46132b,_0xa7b312=_0x52b475[_0x12aa5b(0x22d)](/\{\{|\}\}/g,'')['trim']()[_0x12aa5b(0x232)]('.');return _0xa7b312['length']>0x0?_0xa7b312[_0xa7b312[_0x12aa5b(0x240)]-0x1]:_0x52b475;}),_0xddebe1=await Promise[_0x46132b(0x1c1)]((_0x3a1d9d[_0x46132b(0x1af)]||[])[_0x46132b(0x235)](async _0x312f09=>{const _0x1b9d8e=_0x46132b,_0x356083={};for(const [_0x1424a2,_0x27c38b]of Object[_0x1b9d8e(0x1f0)](_0x312f09[_0x1b9d8e(0x1ea)]||{})){typeof _0x27c38b===_0x1b9d8e(0x22c)&&(String(_0x27c38b)[_0x1b9d8e(0x229)]('{{')||String(_0x27c38b)['includes']('${'))?_0x356083[_0x1424a2]=await(0x0,template_1[_0x1b9d8e(0x25a)])(String(_0x27c38b),_0x19fab7):_0x356083[_0x1424a2]=_0x27c38b;}return{'name':_0x312f09[_0x1b9d8e(0x195)],'config':_0x356083};}));return{'fields':_0x4ce161,'fieldNames':_0x139ce3,'validators':_0xddebe1};})),_0x439792={};let _0x71e454=!![];const _0xc3e04c=(_0x388437,_0x4bf17e)=>{const _0x113a3a=_0x55d9a2;if(!_0x4bf17e[_0x113a3a(0x240)])return;const _0x57f3e6=_0x439792[_0x388437]??[];_0x439792[_0x388437]=[...new Set([..._0x57f3e6,..._0x4bf17e])];};for(const _0xb4acb5 of _0x178336){const {fields:fields=[],fieldNames:fieldNames=[],validators:validators=[]}=_0xb4acb5;if(fields[_0x55d9a2(0x240)]===0x0||validators[_0x55d9a2(0x240)]===0x0)continue;for(let _0x6fbeb6=0x0;_0x6fbeb6<fields[_0x55d9a2(0x240)];_0x6fbeb6++){const _0x555f2d=fields[_0x6fbeb6],_0x52ac36=fieldNames&&fieldNames[_0x6fbeb6]||_0x55d9a2(0x194)+_0x6fbeb6,_0x20f0b2=validators['map'](_0x13188a=>({'validator':_0x13188a['name'],'options':_0x13188a[_0x55d9a2(0x1ea)]||{}})),{valid:_0x533ba9,failures:_0xd80673}=(0x0,validators_1[_0x55d9a2(0x19e)])(_0x20f0b2,_0x555f2d,{'stepId':_0x180d7a['id'],'fieldName':_0x52ac36});!_0x533ba9&&(_0x71e454=![],_0xc3e04c(_0x52ac36,_0xd80673[_0x55d9a2(0x235)](_0x45b1ee=>_0x45b1ee[_0x55d9a2(0x1e0)])));}}const _0x39e1f0={'valid':_0x71e454,'ok':_0x71e454,'statusCode':_0x71e454?0xc8:0x190,'errors':Object[_0x55d9a2(0x203)](_0x439792)[_0x55d9a2(0x240)]>0x0?_0x439792:undefined,'result':_0x71e454?{'valid':!![]}:{'valid':![],'error':_0x55d9a2(0x1d2),'message':_0x55d9a2(0x1be)}};_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x39e1f0;if(!_0x71e454){if(_0x4da39b(_0x180d7a))continue;const _0x3816bd=_0x2f07a7(_0x180d7a);_0x15d88c=_0x3816bd>=0x0?_0x3816bd:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x4f06bd=_0x2f07a7(_0x180d7a);_0x15d88c=_0x4f06bd>=0x0?_0x4f06bd:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x255)]){const _0x53a778=_0x180d7a;let _0x10c8ec=![];const _0x56dc2f=_0x53a778[_0x55d9a2(0x218)]||'jexl';if(_0x56dc2f===_0x55d9a2(0x22e)&&_0x53a778['if']){let _0x462b05=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x53a778['if'],_0x471df7);if(typeof _0x462b05===_0x55d9a2(0x22c))_0x462b05=_0x462b05[_0x55d9a2(0x25e)]();if(!_0x462b05)_0x462b05=_0x55d9a2(0x197);try{_0x10c8ec=Boolean(await(0x0,template_1[_0x55d9a2(0x210)])(String(_0x462b05),_0x471df7));}catch{_0x10c8ec=![];}}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x10c8ec;let _0x280c85=-0x1;_0x10c8ec?_0x280c85=_0x53a778['then']?_0x582c90[_0x55d9a2(0x1dd)](_0x213243=>_0x213243['id']===_0x53a778[_0x55d9a2(0x246)]):_0x2f07a7(_0x180d7a):_0x280c85=_0x53a778['else']?_0x582c90[_0x55d9a2(0x1dd)](_0x3cc1e6=>_0x3cc1e6['id']===_0x53a778[_0x55d9a2(0x256)]):_0x2f07a7(_0x180d7a);_0x15d88c=_0x280c85>=0x0?_0x280c85:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType']['TRANSFORM']){const _0x5c2d4d=_0x180d7a;if(_0x5c2d4d[_0x55d9a2(0x1c4)]){const _0x51c7cc={};for(const _0x136069 of Object[_0x55d9a2(0x203)](_0x5c2d4d[_0x55d9a2(0x1c4)])){_0x51c7cc[_0x136069]=await resolveTemplateOrExpression(_0x5c2d4d[_0x55d9a2(0x1c4)][_0x136069],_0x471df7);}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x51c7cc;}else{if(_0x5c2d4d[_0x55d9a2(0x1a3)]){let _0x1c093a={};if(_0x5c2d4d[_0x55d9a2(0x213)])_0x1c093a=_0x3d1c44['stepResults'][_0x5c2d4d[_0x55d9a2(0x213)]]??{};else _0x1c093a=_0x3d1c44['trigger']?.[_0x55d9a2(0x25b)]??{};const _0x26ba01=JSON[_0x55d9a2(0x206)](JSON[_0x55d9a2(0x199)](_0x1c093a));for(const _0x235a89 of _0x5c2d4d[_0x55d9a2(0x1a3)]){if(_0x235a89[_0x55d9a2(0x1d5)]===_0x55d9a2(0x235)&&_0x235a89[_0x55d9a2(0x1c4)])for(const _0x5b3228 of Object['keys'](_0x235a89[_0x55d9a2(0x1c4)])){_0x26ba01[_0x5b3228]=await resolveTemplateOrExpression(_0x235a89[_0x55d9a2(0x1c4)][_0x5b3228],_0x471df7);}}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x26ba01;}else _0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={};}const _0x48d4c0=_0x2f07a7(_0x180d7a);_0x15d88c=_0x48d4c0>=0x0?_0x48d4c0:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x198)]){const _0x7a50ee=_0x180d7a,_0x9ac62b=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x7a50ee[_0x55d9a2(0x1e0)],_0x471df7);_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={'logged':_0x9ac62b};const _0x527fd8=_0x2f07a7(_0x180d7a);_0x15d88c=_0x527fd8>=0x0?_0x527fd8:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType'][_0x55d9a2(0x237)]){const _0x311cde=_0x180d7a;await new Promise(_0x32fcbe=>setTimeout(_0x32fcbe,_0x311cde['ms']||0x0)),_0x3d1c44['stepResults'][_0x180d7a['id']]={'delayed':_0x311cde['ms']};const _0x3f98de=_0x2f07a7(_0x180d7a);_0x15d88c=_0x3f98de>=0x0?_0x3f98de:-0x1;continue;}if(_0x180d7a['type']===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x1c3)]){const _0x580d99=_0x180d7a,_0x210cca=_0x580d99[_0x55d9a2(0x213)]?_0x3d1c44[_0x55d9a2(0x201)][_0x580d99[_0x55d9a2(0x213)]]?.[_0x55d9a2(0x224)]??_0x3d1c44[_0x55d9a2(0x201)][_0x580d99[_0x55d9a2(0x213)]]?.['output']??_0x3d1c44[_0x55d9a2(0x201)][_0x580d99['input_from']]??{}:_0x3d1c44['trigger']?.[_0x55d9a2(0x25b)]??_0x3d1c44[_0x55d9a2(0x1ad)]??{},_0x2bd2e6={'input':_0x210cca,'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)],'headers':_0x3d1c44[_0x55d9a2(0x20e)],'params':_0x3d1c44['params'],'pathParams':_0x3d1c44[_0x55d9a2(0x21d)],'query':_0x3d1c44[_0x55d9a2(0x1e9)],'body':_0x3d1c44['body'],'env':_0x3d1c44[_0x55d9a2(0x1f6)]};let _0x229f2f=null;if(_0x580d99[_0x55d9a2(0x23f)]){const _0x3c8726=Object[_0x55d9a2(0x1d8)](async function(){})['constructor'],_0x52b902=new _0x3c8726(_0x55d9a2(0x228),_0x55d9a2(0x22f),_0x580d99['source']);_0x229f2f=await _0x52b902(_0x2bd2e6,{});}else{if(_0x580d99[_0x55d9a2(0x1b3)])throw new Error(_0x55d9a2(0x1c7));else throw new Error(_0x55d9a2(0x1db));}if(_0x229f2f&&typeof _0x229f2f===_0x55d9a2(0x208)&&_0x229f2f[_0x55d9a2(0x209)]&&typeof _0x229f2f[_0x55d9a2(0x209)]===_0x55d9a2(0x208))for(const _0x52caa0 of Object[_0x55d9a2(0x203)](_0x229f2f[_0x55d9a2(0x209)])){_0x3d1c44[_0x55d9a2(0x239)][_0x52caa0]=_0x229f2f[_0x55d9a2(0x209)][_0x52caa0];}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={'result':_0x229f2f?.[_0x55d9a2(0x1e6)]??_0x229f2f};const _0x3aa733=_0x2f07a7(_0x180d7a);_0x15d88c=_0x3aa733>=0x0?_0x3aa733:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===_0x55d9a2(0x215)||_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)]['CUSTOM']){const _0x2559f5=_0x180d7a,_0x35b526=_0x2559f5[_0x55d9a2(0x213)]?_0x3d1c44['stepResults'][_0x2559f5[_0x55d9a2(0x213)]]?.[_0x55d9a2(0x224)]??_0x3d1c44[_0x55d9a2(0x201)][_0x2559f5[_0x55d9a2(0x213)]]?.['output']??_0x3d1c44[_0x55d9a2(0x201)][_0x2559f5['input_from']]??{}:_0x3d1c44[_0x55d9a2(0x1ad)]?.['data']??_0x3d1c44[_0x55d9a2(0x1ad)]??{},_0x333362={'input':_0x35b526,'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44['stepResults'],'vars':_0x3d1c44[_0x55d9a2(0x239)],'headers':_0x3d1c44[_0x55d9a2(0x20e)],'params':_0x3d1c44[_0x55d9a2(0x222)],'pathParams':_0x3d1c44[_0x55d9a2(0x21d)],'query':_0x3d1c44['query'],'body':_0x3d1c44[_0x55d9a2(0x233)],'env':_0x3d1c44['env']};let _0xa9f932=null;const _0x187ad3=_0x2559f5[_0x55d9a2(0x227)]||_0x2559f5[_0x55d9a2(0x23f)];if(_0x187ad3){const _0x227dbc=Object['getPrototypeOf'](async function(){})[_0x55d9a2(0x204)],_0xe04047=new _0x227dbc(_0x55d9a2(0x228),_0x55d9a2(0x22f),_0x187ad3);_0xa9f932=await _0xe04047(_0x333362,{});}if(_0xa9f932&&typeof _0xa9f932===_0x55d9a2(0x208)&&_0xa9f932['setVars']&&typeof _0xa9f932['setVars']===_0x55d9a2(0x208))for(const _0xbc1f41 of Object[_0x55d9a2(0x203)](_0xa9f932[_0x55d9a2(0x209)])){_0x3d1c44[_0x55d9a2(0x239)][_0xbc1f41]=_0xa9f932[_0x55d9a2(0x209)][_0xbc1f41];}_0x3d1c44['stepResults'][_0x180d7a['id']]=_0xa9f932?.[_0x55d9a2(0x1e6)]??_0xa9f932??{};if(_0x1b21f4(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']])){if(_0x4da39b(_0x180d7a))continue;const _0x267881=_0x2f07a7(_0x180d7a);_0x15d88c=_0x267881>=0x0?_0x267881:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x4f9c23=_0x2f07a7(_0x180d7a);_0x15d88c=_0x4f9c23>=0x0?_0x4f9c23:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x1b1)]){const _0x294a0e=_0x180d7a,_0x2e6db4=await this[_0x55d9a2(0x19b)](_0x294a0e['connector_id'],_0x294a0e[_0x55d9a2(0x1e4)]);if(!_0x2e6db4)throw new Error(_0x55d9a2(0x1ff)+_0x294a0e[_0x55d9a2(0x21a)]);if(_0x294a0e[_0x55d9a2(0x239)]&&typeof _0x294a0e['vars']===_0x55d9a2(0x208)&&!Array[_0x55d9a2(0x1da)](_0x294a0e[_0x55d9a2(0x239)])){const _0x20429c={..._0x3d1c44[_0x55d9a2(0x239)]};for(const [_0x487a31,_0x10021c]of Object['entries'](_0x294a0e[_0x55d9a2(0x239)])){_0x20429c[_0x487a31]=typeof _0x10021c===_0x55d9a2(0x22c)&&_0x10021c[_0x55d9a2(0x229)]('{{')?await(0x0,template_1['renderTemplate'])(_0x10021c,_0x3d1c44):_0x10021c;}_0x3d1c44[_0x55d9a2(0x239)]=_0x20429c;}let _0x1ff617=_0x294a0e[_0x55d9a2(0x233)]||{};if(typeof _0x1ff617===_0x55d9a2(0x208))_0x1ff617=JSON[_0x55d9a2(0x206)](await(0x0,template_1[_0x55d9a2(0x25a)])(JSON['stringify'](_0x1ff617),_0x3d1c44));else{if(typeof _0x1ff617===_0x55d9a2(0x22c))_0x1ff617=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x1ff617,_0x3d1c44);}const _0x5b7730={};for(const _0x3b819c of Object['keys'](_0x294a0e['pathParams']||{})){_0x5b7730[_0x3b819c]=typeof _0x294a0e[_0x55d9a2(0x21d)][_0x3b819c]===_0x55d9a2(0x22c)&&_0x294a0e['pathParams'][_0x3b819c][_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x294a0e[_0x55d9a2(0x21d)][_0x3b819c],_0x3d1c44):_0x294a0e['pathParams'][_0x3b819c];}const _0x1d0811={};for(const _0x5a9fbd of Object['keys'](_0x294a0e[_0x55d9a2(0x222)]||{})){_0x1d0811[_0x5a9fbd]=typeof _0x294a0e[_0x55d9a2(0x222)][_0x5a9fbd]===_0x55d9a2(0x22c)&&_0x294a0e[_0x55d9a2(0x222)][_0x5a9fbd][_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x294a0e[_0x55d9a2(0x222)][_0x5a9fbd],_0x3d1c44):_0x294a0e[_0x55d9a2(0x222)][_0x5a9fbd];}const _0x1b73fd={},_0x5a9d82=_0x294a0e[_0x55d9a2(0x20e)];if(_0x5a9d82){if(typeof _0x5a9d82===_0x55d9a2(0x208)&&!Array['isArray'](_0x5a9d82))for(const [_0x17e418,value]of Object[_0x55d9a2(0x1f0)](_0x5a9d82)){_0x1b73fd[_0x17e418]=typeof value===_0x55d9a2(0x22c)&&value[_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(value,_0x3d1c44):value;}else{if(Array[_0x55d9a2(0x1da)](_0x5a9d82))for(const _0x4da583 of _0x5a9d82){_0x4da583?.['key']&&_0x4da583?.[_0x55d9a2(0x1de)]!==undefined&&(_0x1b73fd[_0x4da583['key']]=typeof _0x4da583['value']===_0x55d9a2(0x22c)&&_0x4da583[_0x55d9a2(0x1de)][_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x4da583[_0x55d9a2(0x1de)],_0x3d1c44):_0x4da583['value']);}}}const _0xc91d9a={'params':_0x1d0811,'pathParams':_0x5b7730,'body':_0x1ff617};if(Object[_0x55d9a2(0x203)](_0x1b73fd)[_0x55d9a2(0x240)]>0x0)_0xc91d9a[_0x55d9a2(0x20e)]=_0x1b73fd;if(_0x294a0e[_0x55d9a2(0x20b)]!=null)_0xc91d9a[_0x55d9a2(0x20b)]=_0x294a0e['timeout'];if(_0x294a0e['files'])_0xc91d9a[_0x55d9a2(0x217)]=_0x294a0e['files'];const _0x3b1b08=await(0x0,connector_executor_1['executeConnectorAction'])(_0x2e6db4,_0x294a0e['action'],_0xc91d9a,_0x3d1c44);if(_0x3b1b08?.['terminate'])return _0x3b1b08;warnConnectorResponseShape(_0x180d7a['id'],_0x294a0e['connector_id'],_0x294a0e['action'],_0x3b1b08);const _0x3390a0=_0x3b1b08;_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x3390a0?.[_0x55d9a2(0x241)]??_0x3390a0?.[_0x55d9a2(0x25d)]??null;if(typeof _0x180d7a[_0x55d9a2(0x227)]===_0x55d9a2(0x22c)&&_0x180d7a[_0x55d9a2(0x227)][_0x55d9a2(0x25e)]()[_0x55d9a2(0x240)]>0x0){const _0x39a265=_0x180d7a[_0x55d9a2(0x227)],_0x463285=Object[_0x55d9a2(0x1d8)](async function(){})[_0x55d9a2(0x204)],_0x2427e5=new _0x463285(_0x55d9a2(0x228),_0x55d9a2(0x22f),_0x39a265),_0x59cab3={'input':_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x389bc2=await _0x2427e5(_0x59cab3,{});if(_0x389bc2&&typeof _0x389bc2===_0x55d9a2(0x208)&&_0x389bc2['setVars']&&typeof _0x389bc2[_0x55d9a2(0x209)]===_0x55d9a2(0x208)){for(const _0x3a707f of Object[_0x55d9a2(0x203)](_0x389bc2[_0x55d9a2(0x209)]))_0x3d1c44[_0x55d9a2(0x239)][_0x3a707f]=_0x389bc2['setVars'][_0x3a707f];}if(_0x389bc2&&typeof _0x389bc2===_0x55d9a2(0x208)&&Object[_0x55d9a2(0x211)][_0x55d9a2(0x1b8)]['call'](_0x389bc2,_0x55d9a2(0x1e6)))_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x389bc2[_0x55d9a2(0x1e6)];else _0x389bc2!==undefined&&typeof _0x389bc2!==_0x55d9a2(0x208)&&(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x389bc2);}if(_0x1b21f4(_0x3d1c44['stepResults'][_0x180d7a['id']])){if(_0x4da39b(_0x180d7a))continue;const _0x537c10=_0x2f07a7(_0x180d7a);_0x15d88c=_0x537c10>=0x0?_0x537c10:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x157fc4=_0x2f07a7(_0x180d7a);_0x15d88c=_0x157fc4>=0x0?_0x157fc4:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType'][_0x55d9a2(0x1cb)]){const _0x590123=_0x180d7a,_0xa1bd1e=await this[_0x55d9a2(0x19b)](_0x590123[_0x55d9a2(0x21a)],_0x590123[_0x55d9a2(0x1e4)]);if(!_0xa1bd1e)throw new Error(_0x55d9a2(0x1ff)+_0x590123[_0x55d9a2(0x21a)]);let _0x278cd8=_0x590123['body']||{};if(typeof _0x278cd8===_0x55d9a2(0x208))_0x278cd8=JSON[_0x55d9a2(0x206)](await(0x0,template_1['renderTemplate'])(JSON[_0x55d9a2(0x199)](_0x278cd8),_0x3d1c44));else{if(typeof _0x278cd8==='string')_0x278cd8=await(0x0,template_1['renderTemplate'])(_0x278cd8,_0x3d1c44);}const _0x45d486=await(0x0,connector_executor_1[_0x55d9a2(0x1bd)])(_0xa1bd1e,_0x590123[_0x55d9a2(0x1d5)],{'body':_0x278cd8,..._0x278cd8},_0x3d1c44);if(_0x45d486?.['terminate'])return _0x45d486;const _0x393e0e=_0x45d486;_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x393e0e?.[_0x55d9a2(0x241)]??_0x393e0e??_0x45d486;if(typeof _0x180d7a[_0x55d9a2(0x227)]===_0x55d9a2(0x22c)&&_0x180d7a['post_source'][_0x55d9a2(0x25e)]()[_0x55d9a2(0x240)]>0x0){const _0x469401=_0x180d7a[_0x55d9a2(0x227)],_0x12e0fb=Object[_0x55d9a2(0x1d8)](async function(){})[_0x55d9a2(0x204)],_0x3cea71=new _0x12e0fb('ctx','platform',_0x469401),_0x22eb3f={'input':_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0xe16efb=await _0x3cea71(_0x22eb3f,{});if(_0xe16efb&&typeof _0xe16efb===_0x55d9a2(0x208)&&_0xe16efb['setVars']&&typeof _0xe16efb[_0x55d9a2(0x209)]==='object'){for(const _0x401c26 of Object[_0x55d9a2(0x203)](_0xe16efb[_0x55d9a2(0x209)]))_0x3d1c44['vars'][_0x401c26]=_0xe16efb['setVars'][_0x401c26];}if(_0xe16efb&&typeof _0xe16efb===_0x55d9a2(0x208)&&Object[_0x55d9a2(0x211)][_0x55d9a2(0x1b8)]['call'](_0xe16efb,_0x55d9a2(0x1e6)))_0x3d1c44['stepResults'][_0x180d7a['id']]=_0xe16efb['out'];else _0xe16efb!==undefined&&typeof _0xe16efb!==_0x55d9a2(0x208)&&(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0xe16efb);}if(_0x1b21f4(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']])){if(_0x4da39b(_0x180d7a))continue;const _0x329e43=_0x2f07a7(_0x180d7a);_0x15d88c=_0x329e43>=0x0?_0x329e43:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x5bb3b3=_0x2f07a7(_0x180d7a);_0x15d88c=_0x5bb3b3>=0x0?_0x5bb3b3:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x1ac)]){const _0x3bb21c=_0x180d7a,_0x555377=await this[_0x55d9a2(0x19b)](_0x3bb21c['connector_id'],_0x3bb21c[_0x55d9a2(0x1e4)]);if(!_0x555377)throw new Error(_0x55d9a2(0x1ff)+_0x3bb21c[_0x55d9a2(0x21a)]);let _0x156ae4=_0x3bb21c[_0x55d9a2(0x233)]||_0x3bb21c[_0x55d9a2(0x222)]||{};if(typeof _0x156ae4===_0x55d9a2(0x208))_0x156ae4=JSON[_0x55d9a2(0x206)](await(0x0,template_1[_0x55d9a2(0x25a)])(JSON[_0x55d9a2(0x199)](_0x156ae4),_0x3d1c44));else{if(typeof _0x156ae4===_0x55d9a2(0x22c))_0x156ae4=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x156ae4,_0x3d1c44);}const _0x593544=await(0x0,connector_executor_1[_0x55d9a2(0x1bd)])(_0x555377,_0x3bb21c['action'],{'body':_0x156ae4,..._0x156ae4},_0x3d1c44);if(_0x593544?.[_0x55d9a2(0x1c2)])return _0x593544;warnConnectorResponseShape(_0x180d7a['id'],_0x3bb21c[_0x55d9a2(0x21a)],_0x3bb21c[_0x55d9a2(0x1d5)],_0x593544);const _0x16b4e1=_0x593544;_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x16b4e1?.[_0x55d9a2(0x241)]??_0x16b4e1?.[_0x55d9a2(0x25d)]??null;if(typeof _0x180d7a['post_source']===_0x55d9a2(0x22c)&&_0x180d7a[_0x55d9a2(0x227)][_0x55d9a2(0x25e)]()[_0x55d9a2(0x240)]>0x0){const _0x8435a6=_0x180d7a['post_source'],_0x6366c=Object['getPrototypeOf'](async function(){})[_0x55d9a2(0x204)],_0x3beec0=new _0x6366c('ctx',_0x55d9a2(0x22f),_0x8435a6),_0x121af4={'input':_0x3d1c44['stepResults'][_0x180d7a['id']],'trigger':_0x3d1c44['trigger'],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x599cc4=await _0x3beec0(_0x121af4,{});if(_0x599cc4&&typeof _0x599cc4==='object'&&_0x599cc4[_0x55d9a2(0x209)]&&typeof _0x599cc4[_0x55d9a2(0x209)]==='object'){for(const _0x1315be of Object[_0x55d9a2(0x203)](_0x599cc4[_0x55d9a2(0x209)]))_0x3d1c44[_0x55d9a2(0x239)][_0x1315be]=_0x599cc4['setVars'][_0x1315be];}if(_0x599cc4&&typeof _0x599cc4===_0x55d9a2(0x208)&&Object['prototype'][_0x55d9a2(0x1b8)][_0x55d9a2(0x260)](_0x599cc4,_0x55d9a2(0x1e6)))_0x3d1c44['stepResults'][_0x180d7a['id']]=_0x599cc4[_0x55d9a2(0x1e6)];else _0x599cc4!==undefined&&typeof _0x599cc4!==_0x55d9a2(0x208)&&(_0x3d1c44['stepResults'][_0x180d7a['id']]=_0x599cc4);}if(_0x5646bc(_0x180d7a))continue;const _0x4874dc=_0x2f07a7(_0x180d7a);_0x15d88c=_0x4874dc>=0x0?_0x4874dc:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType']['DB']){const _0x2b8524=_0x180d7a,_0x954601=await this[_0x55d9a2(0x19b)](_0x2b8524[_0x55d9a2(0x21a)],_0x2b8524[_0x55d9a2(0x1e4)]);if(!_0x954601)throw new Error('connector\x20not\x20found:\x20'+_0x2b8524[_0x55d9a2(0x21a)]);let _0x27a3b4=_0x2b8524[_0x55d9a2(0x233)]||{};if(typeof _0x27a3b4===_0x55d9a2(0x208))_0x27a3b4=JSON[_0x55d9a2(0x206)](await(0x0,template_1[_0x55d9a2(0x25a)])(JSON['stringify'](_0x27a3b4),_0x3d1c44));else{if(typeof _0x27a3b4==='string')_0x27a3b4=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x27a3b4,_0x3d1c44);}const _0x1abf30={..._0x27a3b4};if(_0x2b8524[_0x55d9a2(0x219)])_0x1abf30[_0x55d9a2(0x219)]=_0x2b8524[_0x55d9a2(0x219)];if(_0x2b8524[_0x55d9a2(0x1d1)])_0x1abf30[_0x55d9a2(0x1d1)]=_0x2b8524['database'];const _0x189397=await(0x0,connector_executor_1['executeConnectorAction'])(_0x954601,_0x2b8524[_0x55d9a2(0x1d5)],_0x1abf30,_0x3d1c44);if(_0x189397?.['terminate'])return _0x189397;warnConnectorResponseShape(_0x180d7a['id'],_0x2b8524['connector_id'],_0x2b8524['action'],_0x189397);const _0x31192d=_0x189397;_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x31192d?.[_0x55d9a2(0x241)]??_0x31192d?.[_0x55d9a2(0x25d)]??null;if(typeof _0x180d7a[_0x55d9a2(0x227)]==='string'&&_0x180d7a[_0x55d9a2(0x227)]['trim']()['length']>0x0){const _0x3afd84=_0x180d7a[_0x55d9a2(0x227)],_0x4353a0=Object['getPrototypeOf'](async function(){})[_0x55d9a2(0x204)],_0xdd998a=new _0x4353a0('ctx','platform',_0x3afd84),_0x4120ed={'input':_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x3743fb=await _0xdd998a(_0x4120ed,{});if(_0x3743fb&&typeof _0x3743fb==='object'&&_0x3743fb['setVars']&&typeof _0x3743fb[_0x55d9a2(0x209)]===_0x55d9a2(0x208)){for(const _0x303ed9 of Object[_0x55d9a2(0x203)](_0x3743fb[_0x55d9a2(0x209)]))_0x3d1c44['vars'][_0x303ed9]=_0x3743fb[_0x55d9a2(0x209)][_0x303ed9];}if(_0x3743fb&&typeof _0x3743fb===_0x55d9a2(0x208)&&Object[_0x55d9a2(0x211)][_0x55d9a2(0x1b8)][_0x55d9a2(0x260)](_0x3743fb,'out'))_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x3743fb['out'];else _0x3743fb!==undefined&&typeof _0x3743fb!==_0x55d9a2(0x208)&&(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x3743fb);}if(_0x5646bc(_0x180d7a))continue;const _0xfb9a4f=_0x2f07a7(_0x180d7a);_0x15d88c=_0xfb9a4f>=0x0?_0xfb9a4f:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType'][_0x55d9a2(0x1d3)]){const _0x2ef279=_0x180d7a,_0x2c089e=_0x2ef279[_0x55d9a2(0x20a)]||_0x2ef279[_0x55d9a2(0x254)];if(!_0x2c089e)throw new Error(_0x55d9a2(0x1c0));const _0x2fa951={};for(const _0x3b326c of Object[_0x55d9a2(0x203)](_0x2ef279[_0x55d9a2(0x24a)]||{})){const _0x15ad0c=_0x2ef279[_0x55d9a2(0x24a)][_0x3b326c];_0x2fa951[_0x3b326c]=typeof _0x15ad0c===_0x55d9a2(0x22c)&&_0x15ad0c[_0x55d9a2(0x229)]('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x15ad0c,_0x3d1c44):_0x15ad0c;}const _0x4c5973=this[_0x55d9a2(0x1a6)][_0x55d9a2(0x19c)](_0x2c089e);let _0x24619e;if(_0x4c5973)_0x24619e=await this['runFunction'](_0x4c5973,_0x2fa951,_0x3d1c44);else{if(this[_0x55d9a2(0x216)]?.[_0x55d9a2(0x1a6)]?.[_0x55d9a2(0x1bc)])try{const _0x3a71fb=await this[_0x55d9a2(0x216)]['functions'][_0x55d9a2(0x1bc)](_0x2c089e,_0x2fa951);_0x24619e={'ok':!![],'data':_0x3a71fb};}catch(_0x411d80){_0x24619e={'ok':![],'error':_0x411d80?.[_0x55d9a2(0x1e0)]||'Remote\x20function\x20failed'};}else throw new Error('Function\x20not\x20found:\x20'+_0x2c089e);}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x24619e['ok']?_0x24619e['data']??_0x24619e[_0x55d9a2(0x201)]??{}:{'error':_0x24619e[_0x55d9a2(0x24e)],'ok':![]};if(typeof _0x180d7a['post_source']===_0x55d9a2(0x22c)&&_0x180d7a[_0x55d9a2(0x227)]['trim']()[_0x55d9a2(0x240)]>0x0){const _0x3f4d08=_0x180d7a['post_source'],_0x32c4dd=Object[_0x55d9a2(0x1d8)](async function(){})['constructor'],_0x39c8c6=new _0x32c4dd('ctx',_0x55d9a2(0x22f),_0x3f4d08),_0x21965c={'input':_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x3adf14=await _0x39c8c6(_0x21965c,{});if(_0x3adf14&&typeof _0x3adf14===_0x55d9a2(0x208)&&_0x3adf14[_0x55d9a2(0x209)]&&typeof _0x3adf14[_0x55d9a2(0x209)]===_0x55d9a2(0x208)){for(const _0x1de82c of Object['keys'](_0x3adf14[_0x55d9a2(0x209)]))_0x3d1c44['vars'][_0x1de82c]=_0x3adf14['setVars'][_0x1de82c];}if(_0x3adf14&&typeof _0x3adf14===_0x55d9a2(0x208)&&Object['prototype'][_0x55d9a2(0x1b8)]['call'](_0x3adf14,_0x55d9a2(0x1e6)))_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x3adf14[_0x55d9a2(0x1e6)];else _0x3adf14!==undefined&&typeof _0x3adf14!==_0x55d9a2(0x208)&&(_0x3d1c44['stepResults'][_0x180d7a['id']]=_0x3adf14);}if(_0x1b21f4(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']])){if(_0x4da39b(_0x180d7a))continue;const _0x2f919d=_0x2f07a7(_0x180d7a);_0x15d88c=_0x2f919d>=0x0?_0x2f919d:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x1f1f84=_0x2f07a7(_0x180d7a);_0x15d88c=_0x1f1f84>=0x0?_0x1f1f84:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x1a7)]){const _0x22293c=_0x180d7a,_0x5e35d7=_0x22293c[_0x55d9a2(0x1a8)];let _0x421f1d=_0x22293c[_0x55d9a2(0x1a0)]||_0x22293c[_0x55d9a2(0x21c)];typeof _0x421f1d===_0x55d9a2(0x22c)&&_0x421f1d[_0x55d9a2(0x229)]('{{')&&(_0x421f1d=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x421f1d,_0x3d1c44));_0x421f1d=_0x421f1d?String(_0x421f1d)[_0x55d9a2(0x25e)]():'';const _0x34d5c6=(_0x22293c[_0x55d9a2(0x19f)]||_0x22293c[_0x55d9a2(0x221)]||_0x55d9a2(0x22b))['toUpperCase']();if(!_0x5e35d7&&!_0x421f1d)throw new Error(_0x55d9a2(0x1b2));const _0x55f30b=_0x22293c[_0x55d9a2(0x261)]||_0x22293c[_0x55d9a2(0x23e)]||'trigger',_0x113a51=_0x22293c[_0x55d9a2(0x1d9)]===!![];let _0x38dc20=_0x22293c[_0x55d9a2(0x1f9)]||{};typeof _0x38dc20==='object'&&(_0x38dc20=JSON[_0x55d9a2(0x206)](await(0x0,template_1[_0x55d9a2(0x25a)])(JSON[_0x55d9a2(0x199)](_0x38dc20),_0x3d1c44)));const _0x5f55f0=_0x22293c['execution_headers']||_0x22293c['executionHeaders'],_0x254b2d=_0x5f55f0&&typeof _0x5f55f0===_0x55d9a2(0x208)?Object[_0x55d9a2(0x23a)](await Promise['all'](Object[_0x55d9a2(0x1f0)](_0x5f55f0)[_0x55d9a2(0x235)](async([_0x43cdfe,_0x819380])=>[_0x43cdfe,typeof _0x819380===_0x55d9a2(0x22c)&&_0x819380['includes']('{{')?await(0x0,template_1[_0x55d9a2(0x25a)])(_0x819380,_0x3d1c44):_0x819380]))):{},_0x4e9eba=_0x38dc20?.[_0x55d9a2(0x25b)]??_0x38dc20?.[_0x55d9a2(0x233)]??_0x38dc20??{},_0xd8360e=_0x321265=>{const _0x42058b=_0x55d9a2,_0x216e65=String(_0x321265||'')[_0x42058b(0x25e)]();if(!_0x216e65)return _0x216e65;return _0x216e65['startsWith']('/')?_0x216e65:'/'+_0x216e65;},_0x1656ae=_0x5e35d7||_0x421f1d||'call',_0x34b77f=[..._0x3d1c44['callStack']||[],{'kind':_0x55d9a2(0x251),'workflowId':_0x1656ae,'stepId':_0x180d7a['id']}];if(_0x34b77f[_0x55d9a2(0x1bb)](_0xdf44e3=>_0xdf44e3?.[_0x55d9a2(0x1d7)]==='workflow')[_0x55d9a2(0x240)]>0xf)throw new Error('call_workflow\x20nesting\x20depth\x20exceeded');if(!_0x113a51){let _0x2f7d7f=undefined;if(_0x5e35d7){_0x2f7d7f=this['workflows'][_0x55d9a2(0x19c)](_0x5e35d7);if(!_0x2f7d7f)for(const _0x43620b of this[_0x55d9a2(0x193)][_0x55d9a2(0x242)]()){const _0x543c67=_0x43620b;if(_0x543c67[_0x55d9a2(0x1fd)]===_0x5e35d7||_0x543c67['__rawId']===_0x5e35d7||_0x543c67[_0x55d9a2(0x195)]===_0x5e35d7){_0x2f7d7f=_0x543c67;break;}}}if(!_0x2f7d7f&&_0x421f1d)for(const _0x452418 of this[_0x55d9a2(0x193)]['values']()){const _0x10216f=_0x452418,_0x122372=_0x10216f[_0x55d9a2(0x1ad)],_0x49bf74=_0x122372?.['webhook_url'],_0x423905=(_0x122372?.[_0x55d9a2(0x221)]??_0x55d9a2(0x22b))['toUpperCase']();if(_0x49bf74&&_0xd8360e(_0x49bf74)===_0xd8360e(_0x421f1d)&&_0x423905===_0x34d5c6){_0x2f7d7f=_0x10216f;break;}}if(_0x2f7d7f){const _0x4ef7ab=await this[_0x55d9a2(0x196)](_0x2f7d7f,{'body':_0x4e9eba,'data':_0x4e9eba,'headers':{..._0x3d1c44[_0x55d9a2(0x20e)],..._0x254b2d},'pathParams':_0x3d1c44['pathParams'],'query':_0x3d1c44[_0x55d9a2(0x1e9)],'vars':{..._0x3d1c44['vars']},'envVars':_0x3d1c44[_0x55d9a2(0x1f6)],'callStack':_0x34b77f});_0x4ef7ab&&_0x4ef7ab[_0x55d9a2(0x1c2)]?_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={'terminated':!![],..._0x4ef7ab}:_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x4ef7ab?.[_0x55d9a2(0x233)]??_0x4ef7ab;}else{if(!this[_0x55d9a2(0x216)]?.[_0x55d9a2(0x193)]?.['run'])throw new Error(_0x55d9a2(0x1a1));}}if(_0x113a51||!_0x3d1c44['stepResults'][_0x180d7a['id']]){if(!this[_0x55d9a2(0x216)]?.['workflows']?.[_0x55d9a2(0x205)])throw new Error(_0x55d9a2(0x1e1));let _0x32e6d9;if(_0x421f1d){const _0x31250b={'body':_0x4e9eba,'environment':_0x22293c['environment']};_0x254b2d&&Object['keys'](_0x254b2d)['length']>0x0&&(_0x31250b['executionHeaders']=_0x254b2d),_0x32e6d9=await this['client'][_0x55d9a2(0x193)][_0x55d9a2(0x258)](_0x421f1d,_0x34d5c6,_0x31250b);}else{const _0x2063d9=_0x38dc20&&typeof _0x38dc20===_0x55d9a2(0x208)&&!Array[_0x55d9a2(0x1da)](_0x38dc20)&&(_0x55d9a2(0x25b)in _0x38dc20||'body'in _0x38dc20)?_0x38dc20:{'body':_0x4e9eba,'data':_0x4e9eba};_0x32e6d9=await this['client'][_0x55d9a2(0x193)][_0x55d9a2(0x205)](_0x5e35d7,_0x55f30b,{'payload':_0x2063d9,'environment':_0x22293c[_0x55d9a2(0x1fb)],'executionHeaders':_0x254b2d&&Object[_0x55d9a2(0x203)](_0x254b2d)[_0x55d9a2(0x240)]>0x0?_0x254b2d:undefined});}const _0x91266f=_0x32e6d9?.[_0x55d9a2(0x233)]??_0x32e6d9?.[_0x55d9a2(0x25b)]??_0x32e6d9;_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x91266f;}if(typeof _0x180d7a['post_source']===_0x55d9a2(0x22c)&&_0x180d7a[_0x55d9a2(0x227)][_0x55d9a2(0x25e)]()[_0x55d9a2(0x240)]>0x0){const _0x4c4c09=_0x180d7a[_0x55d9a2(0x227)],_0x1458bc=Object[_0x55d9a2(0x1d8)](async function(){})[_0x55d9a2(0x204)],_0x31497d=new _0x1458bc(_0x55d9a2(0x228),_0x55d9a2(0x22f),_0x4c4c09),_0x2a2e40={'input':_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']],'trigger':_0x3d1c44[_0x55d9a2(0x1ad)],'steps':_0x3d1c44[_0x55d9a2(0x201)],'vars':_0x3d1c44[_0x55d9a2(0x239)]},_0x1583f2=await _0x31497d(_0x2a2e40,{});if(_0x1583f2&&typeof _0x1583f2==='object'&&_0x1583f2['setVars']&&typeof _0x1583f2[_0x55d9a2(0x209)]===_0x55d9a2(0x208)){for(const _0xebfb49 of Object[_0x55d9a2(0x203)](_0x1583f2['setVars']))_0x3d1c44[_0x55d9a2(0x239)][_0xebfb49]=_0x1583f2[_0x55d9a2(0x209)][_0xebfb49];}if(_0x1583f2&&typeof _0x1583f2===_0x55d9a2(0x208)&&Object[_0x55d9a2(0x211)][_0x55d9a2(0x1b8)][_0x55d9a2(0x260)](_0x1583f2,'out'))_0x3d1c44['stepResults'][_0x180d7a['id']]=_0x1583f2[_0x55d9a2(0x1e6)];else _0x1583f2!==undefined&&typeof _0x1583f2!==_0x55d9a2(0x208)&&(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x1583f2);}if(_0x1b21f4(_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']])){if(_0x4da39b(_0x180d7a))continue;const _0x5a0799=_0x2f07a7(_0x180d7a);_0x15d88c=_0x5a0799>=0x0?_0x5a0799:-0x1;continue;}if(_0x5646bc(_0x180d7a))continue;const _0x2cf746=_0x2f07a7(_0x180d7a);_0x15d88c=_0x2cf746>=0x0?_0x2cf746:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType'][_0x55d9a2(0x1f7)]){const _0xa12eac=_0x180d7a,_0x3969a3=_0xa12eac['over'];if(!_0x3969a3)throw new Error(_0x55d9a2(0x19a));const _0x23a25c=await(0x0,template_1[_0x55d9a2(0x210)])(_0x3969a3,_0x471df7);let _0x4d5850=[];if(Array[_0x55d9a2(0x1da)](_0x23a25c))_0x4d5850=_0x23a25c;else{if(_0x23a25c&&typeof _0x23a25c==='object'&&typeof _0x23a25c[Symbol['iterator']]===_0x55d9a2(0x1a4))_0x4d5850=Array['from'](_0x23a25c);else{if(_0x23a25c&&typeof _0x23a25c===_0x55d9a2(0x208))_0x4d5850=Object[_0x55d9a2(0x1f0)](_0x23a25c);else throw new Error(_0x55d9a2(0x20d));}}const _0x2ded07=_0xa12eac['max_iterations']??0x3e8;if(_0x4d5850[_0x55d9a2(0x240)]>_0x2ded07)throw new Error(_0x55d9a2(0x231)+_0x2ded07+')');const _0x3e03de=_0xa12eac['as']??_0x55d9a2(0x1df),_0x380d38=_0xa12eac[_0x55d9a2(0x1aa)]??'index',_0x4a5910=_0xa12eac[_0x55d9a2(0x23d)]||[],_0x18da0e=[];for(let _0x39c5d4=0x0;_0x39c5d4<_0x4d5850[_0x55d9a2(0x240)];_0x39c5d4++){const _0x1f2417=_0x4d5850[_0x39c5d4],_0x5a82db={..._0x471df7,'vars':{..._0x3d1c44[_0x55d9a2(0x239)],[_0x3e03de]:_0x1f2417,[_0x380d38]:_0x39c5d4},[_0x3e03de]:_0x1f2417,[_0x380d38]:_0x39c5d4};let _0x2b9f1b=null;for(const _0x5e934c of _0x4a5910){if(_0x5e934c[_0x55d9a2(0x1ba)]===workflow_1[_0x55d9a2(0x1e7)][_0x55d9a2(0x1fa)]&&_0x5e934c[_0x55d9a2(0x1c4)]){const _0x312507={};for(const _0x20a00e of Object['keys'](_0x5e934c[_0x55d9a2(0x1c4)])){_0x312507[_0x20a00e]=await resolveTemplateOrExpression(_0x5e934c[_0x55d9a2(0x1c4)][_0x20a00e],_0x5a82db);}_0x3d1c44[_0x55d9a2(0x201)][_0x5e934c['id']]=_0x312507,_0x2b9f1b=_0x312507;}else{if(_0x5e934c[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType']['LOG']){const _0x4150dc=await(0x0,template_1[_0x55d9a2(0x25a)])(_0x5e934c[_0x55d9a2(0x1e0)],_0x5a82db);_0x3d1c44[_0x55d9a2(0x201)][_0x5e934c['id']]={'logged':_0x4150dc};}}}_0x18da0e[_0x55d9a2(0x214)]({'index':_0x39c5d4,'item':_0x1f2417,'result':_0x2b9f1b});}_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={'iterations':_0x18da0e[_0x55d9a2(0x240)],'results':_0x18da0e};const _0x52884a=_0x2f07a7(_0x180d7a);_0x15d88c=_0x52884a>=0x0?_0x52884a:-0x1;continue;}if(_0x180d7a[_0x55d9a2(0x1ba)]===workflow_1['WorkflowStepType']['NOTIFY']){_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]={'notified':_0x180d7a[_0x55d9a2(0x22a)]};const _0xe483e5=_0x2f07a7(_0x180d7a);_0x15d88c=_0xe483e5>=0x0?_0xe483e5:-0x1;continue;}const _0xd53d36=_0x2f07a7(_0x180d7a);_0x15d88c=_0xd53d36>=0x0?_0xd53d36:-0x1;}catch(_0x47e236){const _0x132aad=buildHttpStepFailurePayload(_0x47e236);_0x3d1c44[_0x55d9a2(0x201)][_0x180d7a['id']]=_0x132aad,_0x3d1c44[_0x55d9a2(0x245)][_0x180d7a['id']]=_0x132aad;if(_0x4da39b(_0x180d7a))continue;const _0x3193f9=_0x2f07a7(_0x180d7a);if(_0x3193f9>=0x0){_0x15d88c=_0x3193f9;continue;}throw _0x47e236;}}return{'statusCode':0xc8,'body':_0x3d1c44[_0x55d9a2(0x201)]};}async[_0x38f9f9(0x230)](_0x52c960,_0x3df253,_0x579778){const _0x1a50af=_0x38f9f9,_0xc74e38=_0x52c960['steps']||[],_0x140826={'workflow':_0x579778?.[_0x1a50af(0x251)]||{},'trigger':_0x579778?.[_0x1a50af(0x1ad)]||{},'body':_0x579778?.[_0x1a50af(0x233)]??_0x3df253,'bracket':_0x3df253,'brackets':_0x3df253,'callStack':_0x579778?.[_0x1a50af(0x1d6)]||[],'stepResults':{},'stepErrors':{},'vars':{..._0x579778?.[_0x1a50af(0x239)]||{},..._0x52c960[_0x1a50af(0x239)]||{}},'headers':_0x579778?.[_0x1a50af(0x20e)]||{},'params':_0x579778?.[_0x1a50af(0x222)]||{},'pathParams':_0x579778?.['pathParams']||{},'query':_0x579778?.['query']||{},'tenantId':_0x579778?.[_0x1a50af(0x1e2)],'env':_0x579778?.[_0x1a50af(0x1f6)]||{},'connectorConfig':_0x579778?.[_0x1a50af(0x257)]||this['connectorConfig']},_0x5ad332=()=>({..._0x140826[_0x1a50af(0x201)],'stepResults':_0x140826[_0x1a50af(0x201)],'args':_0x3df253,'trigger':_0x140826['trigger'],'body':_0x140826[_0x1a50af(0x233)],'vars':_0x140826[_0x1a50af(0x239)],'headers':_0x140826[_0x1a50af(0x20e)],'params':_0x140826[_0x1a50af(0x222)],'pathParams':_0x140826[_0x1a50af(0x21d)],'query':_0x140826[_0x1a50af(0x1e9)],'env':_0x140826[_0x1a50af(0x1f6)]});for(let _0x33d3c1=0x0;_0x33d3c1<_0xc74e38[_0x1a50af(0x240)];_0x33d3c1++){const _0x27fd1e=_0xc74e38[_0x33d3c1],_0x5a3220=_0x5ad332();if(_0x27fd1e['type']===_0x1a50af(0x1b6)||_0x27fd1e[_0x1a50af(0x1ba)]===workflow_1['WorkflowStepType'][_0x1a50af(0x24b)]){const _0x324928=builtin_1[_0x1a50af(0x212)],_0x1c1fa0=_0x27fd1e[_0x1a50af(0x1ea)]||{},_0x28110a={'statusCode':_0x1c1fa0[_0x1a50af(0x1eb)]??0xc8,'body':_0x1c1fa0[_0x1a50af(0x233)]};_0x28110a[_0x1a50af(0x233)]=await renderBodyRecursive(_0x28110a[_0x1a50af(0x233)],_0x5a3220);const _0x375d43=await(0x0,connector_executor_1['executeConnectorAction'])(_0x324928,'json.respond',_0x28110a,_0x140826);if(_0x375d43?.[_0x1a50af(0x1c2)]){const _0x5e1ff7=_0x3df253?.['debug']===!![]||String(_0x140826['headers']?.[_0x1a50af(0x1c6)])===_0x1a50af(0x1ce);return _0x5e1ff7&&_0x375d43[_0x1a50af(0x233)]&&typeof _0x375d43[_0x1a50af(0x233)]===_0x1a50af(0x208)&&(_0x375d43[_0x1a50af(0x233)][_0x1a50af(0x1b4)]={'stepResults':_0x140826[_0x1a50af(0x201)]}),{'ok':!![],'data':_0x375d43[_0x1a50af(0x233)],'stepResults':_0x140826['stepResults']};}}if(_0x27fd1e[_0x1a50af(0x1ba)]===_0x1a50af(0x226)||_0x27fd1e[_0x1a50af(0x1ba)]===workflow_1[_0x1a50af(0x1e7)][_0x1a50af(0x243)]){const _0x20daf9=_0x27fd1e,_0x305a4e=_0x3df253,_0x67688={..._0x140826['stepResults'],'args':_0x3df253,'body':_0x140826[_0x1a50af(0x233)],'vars':_0x140826[_0x1a50af(0x239)]},_0xa2c934=await Promise[_0x1a50af(0x1c1)]((_0x20daf9[_0x1a50af(0x250)]||[])[_0x1a50af(0x235)](async _0x31e61e=>{const _0x12a54d=_0x1a50af,_0x2bc70a=await Promise[_0x12a54d(0x1c1)]((_0x31e61e[_0x12a54d(0x1a5)]||[])[_0x12a54d(0x235)](_0x2289e5=>(0x0,template_1['renderTemplate'])(_0x2289e5,_0x67688))),_0xf696d7=(_0x31e61e[_0x12a54d(0x1a5)]||[])[_0x12a54d(0x235)](_0x425ab0=>{const _0x1d2cd6=_0x12a54d,_0x17f766=_0x425ab0[_0x1d2cd6(0x22d)](/\{\{|\}\}/g,'')[_0x1d2cd6(0x25e)]()[_0x1d2cd6(0x232)]('.');return _0x17f766[_0x1d2cd6(0x240)]>0x0?_0x17f766[_0x17f766[_0x1d2cd6(0x240)]-0x1]:_0x425ab0;}),_0x276d0d=(_0x31e61e[_0x12a54d(0x1af)]||[])['map'](_0x524ab5=>({'name':_0x524ab5[_0x12a54d(0x195)],'config':_0x524ab5[_0x12a54d(0x1ea)]||{}}));return{'fields':_0x2bc70a,'fieldNames':_0xf696d7,'validators':_0x276d0d};})),_0x1c4b74={};let _0x2e7ba9=!![];const _0x36dc45=(_0x11b8b8,_0x10e79)=>{const _0x3cd760=_0x1a50af;if(!_0x10e79[_0x3cd760(0x240)])return;const _0x456a84=_0x1c4b74[_0x11b8b8]??[];_0x1c4b74[_0x11b8b8]=[...new Set([..._0x456a84,..._0x10e79])];};for(const _0x38de55 of _0xa2c934){const {fields:fields=[],fieldNames:fieldNames=[],validators:validators=[]}=_0x38de55;if(fields[_0x1a50af(0x240)]===0x0||validators[_0x1a50af(0x240)]===0x0)continue;for(let _0x1196a6=0x0;_0x1196a6<fields[_0x1a50af(0x240)];_0x1196a6++){const _0x3e1827=fields[_0x1196a6],_0x3bce04=fieldNames&&fieldNames[_0x1196a6]||_0x1a50af(0x194)+_0x1196a6,_0x136074=validators[_0x1a50af(0x235)](_0x5e2245=>({'validator':_0x5e2245[_0x1a50af(0x195)],'options':_0x5e2245[_0x1a50af(0x1ea)]||{}})),{valid:_0x2539eb,failures:_0x360854}=(0x0,validators_1[_0x1a50af(0x19e)])(_0x136074,_0x3e1827,{'stepId':_0x27fd1e['id'],'fieldName':_0x3bce04});!_0x2539eb&&(_0x2e7ba9=![],_0x36dc45(_0x3bce04,_0x360854['map'](_0x52417a=>_0x52417a[_0x1a50af(0x1e0)])));}}_0x140826[_0x1a50af(0x201)][_0x27fd1e['id']]={'valid':_0x2e7ba9,'ok':_0x2e7ba9,'statusCode':_0x2e7ba9?0xc8:0x190,'errors':Object[_0x1a50af(0x203)](_0x1c4b74)[_0x1a50af(0x240)]>0x0?_0x1c4b74:undefined,'result':_0x2e7ba9?{'valid':!![]}:{'valid':![]}};}if(_0x27fd1e['type']===_0x1a50af(0x24c)||_0x27fd1e[_0x1a50af(0x1ba)]===workflow_1[_0x1a50af(0x1e7)][_0x1a50af(0x1fa)]){const _0x2315a6=_0x27fd1e;if(_0x2315a6['mapping']){const _0x3c1ccd={};for(const _0x47512c of Object[_0x1a50af(0x203)](_0x2315a6[_0x1a50af(0x1c4)])){_0x3c1ccd[_0x47512c]=await resolveTemplateOrExpression(_0x2315a6[_0x1a50af(0x1c4)][_0x47512c],_0x5a3220);}_0x140826[_0x1a50af(0x201)][_0x27fd1e['id']]=_0x3c1ccd;}}if(_0x27fd1e[_0x1a50af(0x1ba)]===_0x1a50af(0x1ef)||_0x27fd1e[_0x1a50af(0x1ba)]===workflow_1[_0x1a50af(0x1e7)][_0x1a50af(0x1b1)]){const _0x376ce6=_0x27fd1e,_0xdc37d5=await this[_0x1a50af(0x19b)](_0x376ce6[_0x1a50af(0x21a)],_0x376ce6[_0x1a50af(0x1e4)]);if(!_0xdc37d5)throw new Error(_0x1a50af(0x1ff)+_0x376ce6['connector_id']);if(_0x376ce6[_0x1a50af(0x239)]&&typeof _0x376ce6[_0x1a50af(0x239)]===_0x1a50af(0x208)&&!Array[_0x1a50af(0x1da)](_0x376ce6[_0x1a50af(0x239)])){const _0x206275={..._0x140826['vars']};for(const [_0x474f32,_0x409ec5]of Object[_0x1a50af(0x1f0)](_0x376ce6[_0x1a50af(0x239)])){_0x206275[_0x474f32]=typeof _0x409ec5===_0x1a50af(0x22c)&&_0x409ec5[_0x1a50af(0x229)]('{{')?await(0x0,template_1['renderTemplate'])(_0x409ec5,_0x140826):_0x409ec5;}_0x140826[_0x1a50af(0x239)]=_0x206275;}let _0x4ff6c5=_0x376ce6['body']||{};if(typeof _0x4ff6c5===_0x1a50af(0x208))_0x4ff6c5=JSON['parse'](await(0x0,template_1['renderTemplate'])(JSON[_0x1a50af(0x199)](_0x4ff6c5),_0x140826));else{if(typeof _0x4ff6c5===_0x1a50af(0x22c))_0x4ff6c5=await(0x0,template_1[_0x1a50af(0x25a)])(_0x4ff6c5,_0x140826);}const _0x3e4baa={};for(const _0xb8daa4 of Object[_0x1a50af(0x203)](_0x376ce6['pathParams']||{})){_0x3e4baa[_0xb8daa4]=typeof _0x376ce6[_0x1a50af(0x21d)][_0xb8daa4]===_0x1a50af(0x22c)&&_0x376ce6['pathParams'][_0xb8daa4]['includes']('{{')?await(0x0,template_1[_0x1a50af(0x25a)])(_0x376ce6[_0x1a50af(0x21d)][_0xb8daa4],_0x140826):_0x376ce6['pathParams'][_0xb8daa4];}const _0x19c5d4={};for(const _0xed6581 of Object['keys'](_0x376ce6['params']||{})){_0x19c5d4[_0xed6581]=typeof _0x376ce6[_0x1a50af(0x222)][_0xed6581]===_0x1a50af(0x22c)&&_0x376ce6[_0x1a50af(0x222)][_0xed6581][_0x1a50af(0x229)]('{{')?await(0x0,template_1[_0x1a50af(0x25a)])(_0x376ce6[_0x1a50af(0x222)][_0xed6581],_0x140826):_0x376ce6[_0x1a50af(0x222)][_0xed6581];}const _0x415d4a={},_0x4de715=_0x376ce6[_0x1a50af(0x20e)];if(_0x4de715){if(typeof _0x4de715==='object'&&!Array[_0x1a50af(0x1da)](_0x4de715))for(const [_0x131141,value]of Object['entries'](_0x4de715)){_0x415d4a[_0x131141]=typeof value===_0x1a50af(0x22c)&&value[_0x1a50af(0x229)]('{{')?await(0x0,template_1[_0x1a50af(0x25a)])(value,_0x140826):value;}else{if(Array[_0x1a50af(0x1da)](_0x4de715))for(const _0x17b52f of _0x4de715){_0x17b52f?.[_0x1a50af(0x1ec)]&&_0x17b52f?.[_0x1a50af(0x1de)]!==undefined&&(_0x415d4a[_0x17b52f[_0x1a50af(0x1ec)]]=typeof _0x17b52f[_0x1a50af(0x1de)]===_0x1a50af(0x22c)&&_0x17b52f['value'][_0x1a50af(0x229)]('{{')?await(0x0,template_1[_0x1a50af(0x25a)])(_0x17b52f[_0x1a50af(0x1de)],_0x140826):_0x17b52f[_0x1a50af(0x1de)]);}}}const _0xe3a76={'params':_0x19c5d4,'pathParams':_0x3e4baa,'body':_0x4ff6c5};if(Object[_0x1a50af(0x203)](_0x415d4a)[_0x1a50af(0x240)]>0x0)_0xe3a76[_0x1a50af(0x20e)]=_0x415d4a;if(_0x376ce6[_0x1a50af(0x20b)]!=null)_0xe3a76[_0x1a50af(0x20b)]=_0x376ce6[_0x1a50af(0x20b)];if(_0x376ce6['files'])_0xe3a76[_0x1a50af(0x217)]=_0x376ce6[_0x1a50af(0x217)];const _0x1d979c=await(0x0,connector_executor_1[_0x1a50af(0x1bd)])(_0xdc37d5,_0x376ce6['action'],_0xe3a76,_0x140826);if(_0x1d979c?.[_0x1a50af(0x1c2)])return{'ok':!![],'data':_0x1d979c[_0x1a50af(0x233)],'stepResults':_0x140826[_0x1a50af(0x201)]};warnConnectorResponseShape(_0x27fd1e['id'],_0x376ce6[_0x1a50af(0x21a)],_0x376ce6['action'],_0x1d979c),_0x140826['stepResults'][_0x27fd1e['id']]=_0x1d979c?.[_0x1a50af(0x241)]??_0x1d979c?.[_0x1a50af(0x25d)]??null;}if(_0x27fd1e[_0x1a50af(0x1ba)]==='db'||_0x27fd1e['type']===workflow_1[_0x1a50af(0x1e7)]['DB']){const _0x1b6d4c=_0x27fd1e,_0x53976f=await this['getConnectorOrFetch'](_0x1b6d4c['connector_id'],_0x1b6d4c[_0x1a50af(0x1e4)]);if(!_0x53976f)throw new Error(_0x1a50af(0x1ff)+_0x1b6d4c[_0x1a50af(0x21a)]);let _0x12e03b=_0x1b6d4c['body']||{};if(typeof _0x12e03b===_0x1a50af(0x208))_0x12e03b=JSON[_0x1a50af(0x206)](await(0x0,template_1[_0x1a50af(0x25a)])(JSON['stringify'](_0x12e03b),_0x5a3220));const _0x187f54=await(0x0,connector_executor_1[_0x1a50af(0x1bd)])(_0x53976f,_0x1b6d4c['action'],{..._0x12e03b},_0x140826);if(_0x187f54?.[_0x1a50af(0x1c2)])return{'ok':!![],'data':_0x187f54['body'],'stepResults':_0x140826[_0x1a50af(0x201)]};warnConnectorResponseShape(_0x27fd1e['id'],_0x1b6d4c[_0x1a50af(0x21a)],_0x1b6d4c[_0x1a50af(0x1d5)],_0x187f54),_0x140826[_0x1a50af(0x201)][_0x27fd1e['id']]=_0x187f54?.['mapped']??_0x187f54?.[_0x1a50af(0x25d)]??null;}}const _0x110521=_0x52c960[_0x1a50af(0x23b)],_0xe76bd0=_0x110521?_0x140826[_0x1a50af(0x201)][_0x110521]:((()=>{const _0x3ebf72=_0x1a50af,_0x542913=_0xc74e38[_0xc74e38[_0x3ebf72(0x240)]-0x1];return _0x542913?_0x140826['stepResults'][_0x542913['id']]:_0x140826[_0x3ebf72(0x201)];})());return{'ok':!![],'data':_0xe76bd0,'stepResults':_0x140826[_0x1a50af(0x201)]};}['normalizeTrigger'](_0x43d202){const _0x44e2fb=_0x38f9f9;if(!_0x43d202||typeof _0x43d202!==_0x44e2fb(0x208))return _0x43d202;if(Array[_0x44e2fb(0x1da)](_0x43d202))return{'data':_0x43d202,'body':_0x43d202};const _0x481373=_0x43d202[_0x44e2fb(0x1ad)]??_0x43d202,_0x329e95=_0x481373[_0x44e2fb(0x25b)]??_0x481373[_0x44e2fb(0x233)]??_0x43d202[_0x44e2fb(0x25b)]??_0x43d202[_0x44e2fb(0x233)]??_0x43d202,_0x4a01fb=typeof _0x329e95===_0x44e2fb(0x208)&&_0x329e95!==null?_0x329e95:{};return{..._0x4a01fb,..._0x481373,'data':_0x329e95,'body':_0x329e95};}}exports[_0x38f9f9(0x1e3)]=ProcessorEngine;function _0x165a(){const _0x2ba66e=['zNjVBuvUDhjPzxm','B3v0Chv0x2zYB20','ndu2odC1m2ffy2vhBW','C3rLChm','DhjPz2DLCKLK','C291CMnL','BgvUz3rO','BwfWCgvK','DMfSDwvZ','vKfmsurbve9s','zM9YrwfJAa','C3rLCevYCM9YCW','DgHLBG','ANnVBI5YzxnWB25Kzxi','zgvIDwC','BM9YBwfSAxPLvhjPz2DLCG','yxjNCW','uKvtue9orevs','DhjHBNnMB3jT','oJPFx3zFxZO','zxjYB3i','C3rHCNrZv2L0Aa','DMfSAwrHDgLVBKDYB3vWCW','D29YA2zSB3C','C3rYAw5NvxrPBgL0EunVBM5Ly3rVCG','iIaO','zNvUy3rPB25FC2X1zW','q09oreLusu9o','zwXZzq','y29UBMvJDg9Yq29UzMLN','CNvUqNLxzwjOB29R','z2v0q29UBMvJDg9Y','CMvUzgvYvgvTCgXHDgu','zgf0yq','ktOG','CMf3','DhjPBq','yMfZzty0rw5JCNLWDgLVBKnVBM5Ly3rVCG','y2fSBa','DhjPz2DLCL9Pza','D29YA2zSB3DZ','zMLLBgrF','BMfTzq','CNvUv29YA2zSB3C','zMfSC2u','te9h','C3rYAw5NAwz5','tg9VCcbZDgvWihjLCxvPCMvZicDVDMvYjYbLEhbYzxnZAw9U','z2v0q29UBMvJDg9Yt3jgzxrJAa','z2v0','C2v0','yxbWBhLwywXPzgf0Aw9UC0nVBgXLy3rbBgW','D2vIAg9VA19TzxrOB2q','D2vIAg9VA19WyxrO','y2fSBf93B3jRzMXVDZOGD29YA2zSB3CGBM90igzVDw5KigXVy2fSBhKGyw5KiezSB3n5BMndBgLLBNqGAxmGBM90ignVBMzPz3vYzwqUifjLz2LZDgvYihrOzsbJAgLSzcb3B3jRzMXVDYbVCIbZzxqGCMvTB3rLoIb0CNvLihDPDgGGyxbPs2v5l2fWAvnLy3jLDc4','Cg9ZDgDYzxndB25Uzwn0B3i','B3bLCMf0Aw9UCW','zNvUy3rPB24','zMLLBgrZ','zNvUy3rPB25Z','q0fmtf9xt1jlrKXpvW','D29YA2zSB3DFAwq','AM9PBG','Aw5KzxHFyxm','D2HLBG','ru5duLLqveLptG','DhjPz2DLCG','x19LC01VzhvSzq','DMfSAwrHDg9YCW','imk3ia','qvbjx0nbteW','y2fSBf93B3jRzMXVDYbZDgvWig1PC3nPBMCGD29YA2zSB3DFAwqGyw5KihDLyMHVB2TFCgf0Aa','Bw9KDwXLx3jLzG','x2rLyNvN','C3rHDhvZ','CMvZCg9UzgvY','lNjLC3bVBMrLCG','AgfZt3DUuhjVCgvYDhK','zw5KC1DPDgG','DhLWzq','zMLSDgvY','Aw52B2TL','zxHLy3v0zunVBM5Ly3rVCKfJDgLVBG','t25Lig9Yig1VCMuGDMfSAwrHDgLVBIbLCNjVCNmGB2nJDxjYzwq','w0zSB3n5BMnDihn0zxaGiG','zNvUy3rPB24GC3rLCcbTAxnZAw5Nigz1BMn0Aw9Ux2LKig9Yigz1BMn0Aw9Ux3nSDwC','ywXS','DgvYBwLUyxrL','q09erq','BwfWCgLUzW','mZe0mhLTAfH6vq','Ec1MBg9ZEw5JlwrLyNvN','Bw9KDwXLx3jLzIbPCYbUB3qGC3vWCg9YDgvKigLUigXVy2fSignVzguGC3rLChm','ANnVBI5YzxnWB25K','CgfZC3DVCMrfBMnYExb0Aw9Uq29UBMvJDg9Y','CMvZCg9UC2u','qvvusevoveLdqvrjt04','y2fSBf9ZDgfJAW','y29TCgfYzvv0AwXPDhLdB25Uzwn0B3i','Dhj1zq','lI4VDgvTCgXHDgu','AgfZAevUy3j5ChrPB25dB25Uzwn0B3i','zgf0ywjHC2u','vMfSAwrHDgLVBIbMywLSzwq','rLvoq1rjt04','yxbPs2v5qxv0AenVBM5Ly3rVCG','ywn0Aw9U','y2fSBfn0ywnR','A2LUza','z2v0uhjVDg90ExbLt2y','CMvTB3rL','AxnbCNjHEq','y29KzsbZDgvWig11C3qGAgf2zsbLAxrOzxiGC291CMnLig9Yig1VzhvSzv9Yzwy','zw52vMfYCW','zMLUzeLUzgv4','DMfSDwu','AxrLBq','BwvZC2fNzq','q2XPzw50ihjLCxvPCMvKigzVCIbYzw1VDguGy2fSBf93B3jRzMXVDY4Gq29UzMLNDxjLigfWAuTLEsbHBMqGyxbPu2vJCMv0lG','DgvUyw50swq','uhjVy2vZC29Yrw5NAw5L','y29UBMvJDg9Yx3zLCNnPB24','B25FzxjYB3i','B3v0','v29YA2zSB3DtDgvWvhLWzq','ota4mZrXswzbBNq','CxvLCNK','y29UzMLN','C3rHDhvZq29Kzq','A2v5','z2vVvxrPBgL0EunVBM5Ly3rVCG','mZqXmti1nZrnzfbmANm','yxbPx2nHBgW','zw50CMLLCW','BNvTyMvY','lI4VDhLWzxmVD29YA2zSB3C','CMvZCg9UC2vxyxjUAw5NCW','mte3ndaXohfjqvfPCq','CNnHrw5JCNLWDgLVBKnVBM5Ly3rVCG','zw52','te9pua','Bw9Uz29KyKnVBM5Ly3rVCG','Cgf5Bg9Hza','vfjbtLngt1jn','zw52AxjVBM1LBNq','y29UBMvJDg9YCW','x2LK','mty1BeDLzeTv','y29UBMvJDg9Yig5VDcbMB3vUzdOG','lI4Vy29UBMvJDg9YCY9IDwLSDgLU','C3rLCfjLC3vSDhm','yMfZAwnbDxrOq29UBMvJDg9Y','A2v5CW','y29UC3rYDwn0B3i','CNvU','CgfYC2u','Ag1Hy0vUy3j5ChrPB25dB25Uzwn0B3i','B2jQzwn0','C2v0vMfYCW','zNvUy3rPB25FAwq','DgLTzw91Da','lI9JB25Uzwn0B3iUzxHLy3v0B3i','tg9VCcaNB3zLCICGBxvZDcbLDMfSDwf0zsb0BYbHCNjHEsbVCIbPDgvYywjSzq','AgvHzgvYCW','CMf3uMvZCg9UzgvYq29UBMvJDg9Y','zxzHBhvHDgvfEhbYzxnZAw9U','ChjVDg90ExbL','ANnVBLjLC3bVBMrLCKnVBM5Ly3rVCG','Aw5WDxrFzNjVBq','ChvZAa','y3vZDg9T','y2XPzw50','zMLSzxm','Bw9Kzq','y29UBMvJDgLVBL9Pza','y29UBMvJDg9Yx2LK','mtG5otu1mKHfwKfHtW','D2vIAg9VA1bHDgG','Cgf0AfbHCMfTCW','zgvMAw5LuhjVCgvYDhK','mJiYnti4wxjLBvzU','DMfSAwq','D2vIAg9VA01LDgHVza','CgfYyw1Z','yMvHCMvYqxv0AenVBM5Ly3rVCG','CMvZDwX0','CMfUzg9TvxrPBgL0EunVBM5Ly3rVCG','DMfSAwrHDg9Y','Cg9ZDf9ZB3vYy2u','y3r4','Aw5JBhvKzxm','y2HHBM5LBa','ue9tva','C3rYAw5N','CMvWBgfJzq','AMv4Ba','CgXHDgzVCM0','CNvUrNvUy3rPB24','tg9VCcbLEgnLzwrZig1HEcbPDgvYyxrPB25ZicG','C3bSAxq','yM9KEq','zgf0zvrPBwvvDgLSAxr5q29UBMvJDg9Y','BwfW','Ag9ZDa','revmqvK','mJCYmw14AMLnuq','DMfYCW'];_0x165a=function(){return _0x2ba66e;};return _0x165a();}
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;