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.
- package/LICENSE +201 -0
- package/README.md +81 -0
- package/dist/AuthAppClient.d.ts +1 -0
- package/dist/AuthAppClient.d.ts.map +1 -1
- package/dist/AuthAppClient.js +199 -1
- package/dist/CommercialAppClient.d.ts +178 -0
- package/dist/CommercialAppClient.d.ts.map +1 -0
- package/dist/CommercialAppClient.js +576 -0
- package/dist/ConnectorBuilder.js +104 -1
- package/dist/Events.d.ts +2 -0
- package/dist/Events.d.ts.map +1 -1
- package/dist/Events.js +325 -1
- package/dist/Flosync.js +296 -1
- package/dist/FlosyncClient.js +429 -1
- package/dist/FunctionBuilder.js +65 -1
- package/dist/IdentityAppClient.d.ts +23 -0
- package/dist/IdentityAppClient.d.ts.map +1 -0
- package/dist/IdentityAppClient.js +197 -0
- package/dist/MemoryAppClient.d.ts +28 -0
- package/dist/MemoryAppClient.d.ts.map +1 -0
- package/dist/MemoryAppClient.js +149 -0
- package/dist/MemoryClient.d.ts +8 -0
- package/dist/MemoryClient.d.ts.map +1 -0
- package/dist/MemoryClient.js +20 -0
- package/dist/OAuthAppClient.d.ts +1 -0
- package/dist/OAuthAppClient.d.ts.map +1 -1
- package/dist/OAuthAppClient.js +269 -1
- package/dist/ProviderServicesClient.d.ts +24 -0
- package/dist/ProviderServicesClient.d.ts.map +1 -0
- package/dist/ProviderServicesClient.js +158 -0
- package/dist/Surface.d.ts +2 -0
- package/dist/Surface.d.ts.map +1 -1
- package/dist/Surface.js +255 -1
- package/dist/ValidatorBuilder.js +24 -1
- package/dist/Webhooks.d.ts +20 -0
- package/dist/Webhooks.d.ts.map +1 -0
- package/dist/Webhooks.js +61 -0
- package/dist/WorkflowBuilder.js +279 -1
- package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
- package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/CommercialAppClient.test.js +217 -0
- package/dist/__tests__/Events.test.js +191 -1
- package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
- package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/IdentityAppClient.test.js +232 -0
- package/dist/__tests__/OAuthAppClient.test.js +300 -1
- package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
- package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
- package/dist/__tests__/ProviderServicesClient.test.js +131 -0
- package/dist/__tests__/Surface.test.js +150 -1
- package/dist/__tests__/errors.test.js +54 -1
- package/dist/__tests__/function.test.js +58 -1
- package/dist/__tests__/helpers.d.ts +5 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/__tests__/helpers.js +10 -0
- package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
- package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
- package/dist/__tests__/localhost-lookup.test.js +26 -0
- package/dist/__tests__/parse-api-error.test.js +26 -1
- package/dist/__tests__/runner.test.js +156 -1
- package/dist/connectors/builtin.js +354 -1
- package/dist/connectors/registry.js +300 -1
- package/dist/decorators/build.js +105 -1
- package/dist/decorators/connector.js +56 -1
- package/dist/decorators/index.js +34 -1
- package/dist/decorators/metadata.js +338 -1
- package/dist/decorators/steps.js +220 -1
- package/dist/decorators/workflow.js +52 -1
- package/dist/errors.js +76 -1
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-result.test.js +57 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
- package/dist/http/__tests__/events-instance-id.test.js +45 -0
- package/dist/http/cliodot-request.d.ts +35 -0
- package/dist/http/cliodot-request.d.ts.map +1 -0
- package/dist/http/cliodot-request.js +105 -0
- package/dist/http/cliodot-result.d.ts +40 -0
- package/dist/http/cliodot-result.d.ts.map +1 -0
- package/dist/http/cliodot-result.js +139 -0
- package/dist/http/create-client.d.ts +3 -0
- package/dist/http/create-client.d.ts.map +1 -0
- package/dist/http/create-client.js +14 -0
- package/dist/http/events-instance-id.d.ts +11 -0
- package/dist/http/events-instance-id.d.ts.map +1 -0
- package/dist/http/events-instance-id.js +86 -0
- package/dist/http/localhost-lookup.d.ts +12 -0
- package/dist/http/localhost-lookup.d.ts.map +1 -0
- package/dist/http/localhost-lookup.js +67 -0
- package/dist/http/parse-api-error.js +56 -1
- package/dist/http/sanitize-execution-headers.js +79 -1
- package/dist/identity-offline-verify.d.ts +6 -0
- package/dist/identity-offline-verify.d.ts.map +1 -0
- package/dist/identity-offline-verify.js +174 -0
- package/dist/identity-token-cache.d.ts +6 -0
- package/dist/identity-token-cache.d.ts.map +1 -0
- package/dist/identity-token-cache.js +51 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -1
- package/dist/runner/ProcessorEngine.js +1311 -1
- package/dist/runner/connector.executor.js +1786 -1
- package/dist/runner/utilities/math.executor.js +153 -1
- package/dist/runner/utilities/random.executor.js +151 -1
- package/dist/runner/utilities/string.executor.js +825 -1
- package/dist/template.js +127 -1
- package/dist/transformers/StepsToNodesTransformer.js +214 -1
- package/dist/transformers/WorkflowTransformer.js +189 -1
- package/dist/types/auth-app.api.d.ts +2 -0
- package/dist/types/auth-app.api.d.ts.map +1 -1
- package/dist/types/auth-app.api.js +2 -1
- package/dist/types/builtin.js +2 -1
- package/dist/types/client.api.js +2 -1
- package/dist/types/commercial-app.api.d.ts +963 -0
- package/dist/types/commercial-app.api.d.ts.map +1 -0
- package/dist/types/commercial-app.api.js +2 -0
- package/dist/types/connector.js +2 -1
- package/dist/types/context.js +2 -1
- package/dist/types/event-app.api.d.ts +8 -0
- package/dist/types/event-app.api.d.ts.map +1 -1
- package/dist/types/event-app.api.js +2 -1
- package/dist/types/function.js +2 -1
- package/dist/types/identity-app.api.d.ts +99 -0
- package/dist/types/identity-app.api.d.ts.map +1 -0
- package/dist/types/identity-app.api.js +2 -0
- package/dist/types/index.js +23 -1
- package/dist/types/memory-app.api.d.ts +140 -0
- package/dist/types/memory-app.api.d.ts.map +1 -0
- package/dist/types/memory-app.api.js +2 -0
- package/dist/types/oauth-app.api.d.ts +2 -0
- package/dist/types/oauth-app.api.d.ts.map +1 -1
- package/dist/types/oauth-app.api.js +105 -1
- package/dist/types/provider-services.api.d.ts +98 -0
- package/dist/types/provider-services.api.d.ts.map +1 -0
- package/dist/types/provider-services.api.js +2 -0
- package/dist/types/validator.js +2 -1
- package/dist/types/webhook-app.api.d.ts +2 -0
- package/dist/types/webhook-app.api.d.ts.map +1 -0
- package/dist/types/webhook-app.api.js +2 -0
- package/dist/types/workflow.js +33 -1
- package/dist/validators/validators.js +478 -1
- package/dist/variable.js +37 -1
- package/package.json +3 -2
|
@@ -1 +1,338 @@
|
|
|
1
|
-
'use strict';const _0x4b4114=_0x2b99;(function(_0x16b5b0,_0x1bc919){const _0x592144=_0x2b99,_0x19047e=_0x16b5b0();while(!![]){try{const _0x51533b=parseInt(_0x592144(0x143))/0x1+-parseInt(_0x592144(0x16b))/0x2*(-parseInt(_0x592144(0x144))/0x3)+parseInt(_0x592144(0x134))/0x4*(-parseInt(_0x592144(0x15d))/0x5)+parseInt(_0x592144(0x145))/0x6+parseInt(_0x592144(0x13a))/0x7*(parseInt(_0x592144(0x16a))/0x8)+-parseInt(_0x592144(0x148))/0x9+-parseInt(_0x592144(0x147))/0xa;if(_0x51533b===_0x1bc919)break;else _0x19047e['push'](_0x19047e['shift']());}catch(_0x2c2da4){_0x19047e['push'](_0x19047e['shift']());}}}(_0x3e42,0xda6dd));Object[_0x4b4114(0x149)](exports,_0x4b4114(0x16c),{'value':!![]}),exports[_0x4b4114(0x186)]=exports['WORKFLOW_META_KEY']=void 0x0,exports[_0x4b4114(0x135)]=getOrCreateWorkflowMeta,exports[_0x4b4114(0x177)]=getOrCreateConnectorMeta,exports[_0x4b4114(0x15e)]=sanitizeStepId,exports[_0x4b4114(0x14f)]=inferWorkflowIdFromClassName,exports['withThenElse']=withThenElse,exports[_0x4b4114(0x138)]=makeConnectorStep,exports[_0x4b4114(0x142)]=makeDbStep,exports[_0x4b4114(0x18a)]=makeValidatorStep,exports[_0x4b4114(0x13d)]=makeConditionStep,exports[_0x4b4114(0x18e)]=makeTransformStep,exports[_0x4b4114(0x158)]=makeResponderStep,exports['makeAuthStep']=makeAuthStep,exports['makeEncryptStep']=makeEncryptStep,exports[_0x4b4114(0x178)]=makeCodeStep,exports[_0x4b4114(0x184)]=makeCallStep,exports[_0x4b4114(0x170)]=makeCallWorkflowStep,exports['makeLoopStep']=makeLoopStep,exports[_0x4b4114(0x13c)]=makeLogStep,exports[_0x4b4114(0x154)]=makeDelayStep,exports['makeNotifyStep']=makeNotifyStep,exports[_0x4b4114(0x167)]=makeCustomStep;const workflow_1=require(_0x4b4114(0x146));exports['WORKFLOW_META_KEY']=Symbol[_0x4b4114(0x13b)]('cliodot:workflowMeta'),exports[_0x4b4114(0x186)]=Symbol[_0x4b4114(0x13b)](_0x4b4114(0x171));function getOrCreateWorkflowMeta(_0x412c55){const _0x46d731=_0x4b4114;return!_0x412c55[exports[_0x46d731(0x137)]]&&(_0x412c55[exports[_0x46d731(0x137)]]={'steps':[]}),_0x412c55[exports[_0x46d731(0x137)]];}function getOrCreateConnectorMeta(_0x32f299){const _0x17a2ed=_0x4b4114;return!_0x32f299[exports[_0x17a2ed(0x186)]]&&(_0x32f299[exports[_0x17a2ed(0x186)]]={'actions':[]}),_0x32f299[exports['CONNECTOR_META_KEY']];}function sanitizeStepId(_0x1c5db7){const _0xb87d67=_0x4b4114;return _0x1c5db7[_0xb87d67(0x131)](/[.\-\s]/g,'_');}function inferWorkflowIdFromClassName(_0x31f8ec){const _0xe5e818=_0x4b4114,_0x4c5260=_0x31f8ec[_0xe5e818(0x131)](/Workflow$/i,'')[_0xe5e818(0x131)](/_/g,'\x20')[_0xe5e818(0x151)](),_0x279699=_0x4c5260[_0xe5e818(0x131)](/([a-z0-9])([A-Z])/g,_0xe5e818(0x16e))[_0xe5e818(0x131)](/\s+/g,'-')[_0xe5e818(0x14a)]();return sanitizeStepId(_0x279699);}function _0x3e42(){const _0x42259f=['mtKZmdrWueDSrwW','mNzKt1jgDW','x19LC01VzhvSzq','yM9KEq','jdeTjdi','y2HPBgrFD29YA2zSB3DFBMfTzq','BwfRzunHBgXxB3jRzMXVD1n0zxa','y2XPB2rVDdPJB25Uzwn0B3jnzxrH','DMfSAwrHDg9YCW','Aw5JBhvKzxm','Aw5KzxHFyxm','CMvTB3rL','zMLSzxm','z2v0t3jdCMvHDgvdB25Uzwn0B3jnzxrH','BwfRzunVzgvtDgvW','q09erq','DgHLBG','BwfW','ru5duLLqveLptG','Bw9Uz29KyI5ZExn0zw0','D2vIAg9VA19WyxrO','ue9tva','Bw9Uz29KyG','D2vIAg9VA01LDgHVza','Bwv0Ag9K','zw52AxjVBM1LBNq','BwfRzunHBgXtDgvW','Cgf0AfbHCMfTCW','q09otKvdve9sx01fvefFs0vz','A2v5CW','AgvHzgvYCW','rLvoq1rjt04','BwfRzvzHBgLKyxrVCLn0zxa','zMLLBgrZ','AxrLBq','C3rHDhvZq29Kzq','BwfRzvrYyw5ZzM9YBvn0zxa','D29YA2zSB3DFBMfTzq','te9pua','BxLZCwWUC3LZDgvT','tK9usuzz','CMvWBgfJzq','BgvUz3rO','y29UzMLN','ntuXotaZmMrywLH1yq','z2v0t3jdCMvHDgvxB3jRzMXVD01LDge','DMfYCW','v09ss0zmt1DFtuvuqv9lrvK','BwfRzunVBM5Ly3rVCLn0zxa','Cgf0Aa','mtmZsvbLwgLs','zM9Y','BwfRzuXVz1n0zxa','BwfRzunVBMrPDgLVBLn0zxa','Aw5ZDgfSBgf0Aw9Ux2LK','Dg9vChbLCKnHC2u','q09oreLusu9o','AgfZ','BwfRzurIu3rLCa','mtC3nJq5nLrstvDjwa','mJCZmdqYm2Liy3PACq','otK5ntqYne9lBhLXtq','lI4VDhLWzxmVD29YA2zSB3C','ndG0mtq1menHBuTpCW','mtq3ntGYmdbSq3L2D2C','zgvMAw5LuhjVCgvYDhK','Dg9mB3DLCKnHC2u','uKvtue9orevs','zw50CMLLCW','v29YA2zSB3DtDgvWvhLWzq','D29YA2zSB3DFAwq','Aw5MzxjxB3jRzMXVD0LKrNjVBunSyxnZtMfTzq','vKfmsurbve9s','DhjPBq','y29UBMvJDgLVBL9Pza','Aw5WDxrFzNjVBq','BwfRzurLBgf5u3rLCa','D2vIAg9VA19TzxrOB2q','zxHLy3v0Aw9Ux2HLywrLCNm','CgfYyw1Z','BwfRzvjLC3bVBMrLCLn0zxa','zwXZzq','DhjPz2DLCL9Pza','zxHLy3v0Aw9UsgvHzgvYCW','D2vIAg9VA1bHDgG','nxfNA0LPAW','C2fUAxrPEMvtDgvWswq','q0fmtf9xt1jlrKXpvW','Bwf4x2L0zxjHDgLVBNm','zgf0ywjHC2u','Aw5KzxG','CMv0DxjU','AxnbCNjHEq','BMfTzq','DgLTzw91Da','BwfRzun1C3rVBvn0zxa','y29UBMvJDg9Yx3zLCNnPB24','DhjPz2DLCKLK'];_0x3e42=function(){return _0x42259f;};return _0x3e42();}function withThenElse(_0x5a766a,_0x4b313e,_0x3b6bde){const _0x158f49=_0x4b4114,_0x22637f=_0x4b313e?sanitizeStepId(_0x4b313e):undefined,_0x3df578=_0x3b6bde?sanitizeStepId(_0x3b6bde):undefined;if(_0x22637f)_0x5a766a[_0x158f49(0x17a)]=_0x22637f;if(_0x3df578)_0x5a766a[_0x158f49(0x159)]=_0x3df578;return _0x5a766a;}const CONNECTOR_STEP_RESERVED=new Set(['body',_0x4b4114(0x157),_0x4b4114(0x185),_0x4b4114(0x188),'vars',_0x4b4114(0x166),'files',_0x4b4114(0x13e),_0x4b4114(0x152),'database',_0x4b4114(0x168)]);function makeConnectorStep(_0x3162e1,_0x483b60,_0x499ace,_0x52d1a1={}){const _0x40524b=_0x4b4114,_0x5ae6fe=_0x52d1a1,_0x6952b3=_0x5ae6fe['body'],_0x231544=_0x5ae6fe[_0x40524b(0x157)],_0x7ba7a0=_0x5ae6fe['pathParams'],_0x5b6a9f=_0x5ae6fe[_0x40524b(0x188)],_0x104759=_0x5ae6fe[_0x40524b(0x136)],_0xae9beb=_0x5ae6fe[_0x40524b(0x166)],_0xf57498=_0x5ae6fe[_0x40524b(0x176)],_0x3ae580=_0x5ae6fe[_0x40524b(0x13e)],_0x2a064a=_0x5ae6fe[_0x40524b(0x152)],_0x344abd=_0x5ae6fe[_0x40524b(0x161)],_0x423b9f=_0x5ae6fe['connector_version'],_0x1d51e8={};for(const _0x2cb12c of Object[_0x40524b(0x187)](_0x5ae6fe)){if(!CONNECTOR_STEP_RESERVED[_0x40524b(0x141)](_0x2cb12c))_0x1d51e8[_0x2cb12c]=_0x5ae6fe[_0x2cb12c];}const _0x5845f3=_0x6952b3!==undefined?_0x6952b3:Object['keys'](_0x1d51e8)['length']>0x0?_0x1d51e8:undefined,_0x28274b={'id':_0x3162e1,'type':workflow_1['WorkflowStepType']['API_CALL'],'connector_id':_0x483b60,'action':_0x499ace};if(_0x231544!==undefined)_0x28274b[_0x40524b(0x157)]=_0x231544;if(_0x7ba7a0!==undefined)_0x28274b[_0x40524b(0x185)]=_0x7ba7a0;if(_0x5b6a9f!==undefined)_0x28274b[_0x40524b(0x188)]=_0x5b6a9f;if(_0x104759!==undefined)_0x28274b[_0x40524b(0x136)]=_0x104759;if(_0xae9beb!==undefined)_0x28274b[_0x40524b(0x166)]=_0xae9beb;if(_0xf57498!==undefined)_0x28274b[_0x40524b(0x176)]=_0xf57498;if(_0x3ae580!==undefined)_0x28274b['installation_id']=_0x3ae580;if(_0x2a064a!==undefined)_0x28274b[_0x40524b(0x152)]=_0x2a064a;if(_0x344abd!==undefined)_0x28274b[_0x40524b(0x161)]=_0x344abd;if(_0x423b9f!==undefined&&_0x423b9f!=='')_0x28274b[_0x40524b(0x168)]=String(_0x423b9f);if(_0x5845f3!==undefined)_0x28274b[_0x40524b(0x16d)]=_0x5845f3;return _0x28274b;}function makeDbStep(_0x28cb7c,_0x2796f3,_0x2cb931,_0x214496){const _0x30bd7b=_0x4b4114,_0x1780a6=_0x2796f3===_0x30bd7b(0x180)?_0x30bd7b(0x17d):_0x30bd7b(0x191),{connector_version:_0x35fd00,connection_id:_0x37f042,database:_0x1ca892,..._0xa80540}=_0x214496,_0x2e2267={'id':_0x28cb7c,'type':workflow_1[_0x30bd7b(0x14d)]['DB'],'connector_id':_0x1780a6,'action':_0x2cb931,'body':_0xa80540,'params':_0xa80540[_0x30bd7b(0x157)]};if(_0x37f042)_0x2e2267[_0x30bd7b(0x152)]=_0x37f042;if(_0x1ca892)_0x2e2267['database']=_0x1ca892;return _0x35fd00!=null&&String(_0x35fd00)[_0x30bd7b(0x151)]()!==''&&(_0x2e2267[_0x30bd7b(0x168)]=String(_0x35fd00)[_0x30bd7b(0x151)]()),_0x2e2267;}function makeValidatorStep(_0x163264,_0x4608a9){const _0x5b89f7=_0x4b4114;let _0x42f23;return Array[_0x5b89f7(0x164)](_0x4608a9)?_0x42f23=_0x4608a9:_0x42f23=[{'fields':Object['values'](_0x4608a9),'validators':Object[_0x5b89f7(0x14c)](_0x4608a9)['map'](()=>({'name':'required','config':{}}))}],{'id':_0x163264,'type':workflow_1[_0x5b89f7(0x14d)][_0x5b89f7(0x150)],'validationGroups':_0x42f23[_0x5b89f7(0x17b)](_0x543064=>({'fields':_0x543064[_0x5b89f7(0x18b)],'validators':_0x543064[_0x5b89f7(0x172)][_0x5b89f7(0x17b)](_0x40fa4b=>({'name':_0x40fa4b[_0x5b89f7(0x165)],'config':_0x40fa4b[_0x5b89f7(0x133)]??{}}))}))};}function makeConditionStep(_0x4e61e7,_0x3da85f){const _0x1cdacd=_0x4b4114;return{'id':_0x4e61e7,'type':workflow_1[_0x1cdacd(0x14d)][_0x1cdacd(0x140)],'mode':'jexl','if':_0x3da85f};}function makeTransformStep(_0x16a87e,_0x36b3f8){const _0x3c337c=_0x4b4114,_0x16a374=!Array['isArray'](_0x36b3f8);return{'id':_0x16a87e,'type':workflow_1[_0x3c337c(0x14d)]['TRANSFORM'],..._0x16a374?{'mapping':_0x36b3f8}:{'operations':_0x36b3f8}};}function makeResponderStep(_0x4b4f36,_0x3094c3,_0x1c9212){const _0x2f4570=_0x4b4114;return{'id':_0x4b4f36,'type':workflow_1[_0x2f4570(0x14d)][_0x2f4570(0x14b)],'responder':_0x3094c3,'config':{'statusCode':_0x1c9212[_0x2f4570(0x18d)]??0xc8,'headers':_0x1c9212[_0x2f4570(0x188)],'body':_0x1c9212[_0x2f4570(0x16d)],'contentType':_0x1c9212['contentType'],'location':_0x1c9212['location']}};}function makeAuthStep(_0x5af769,_0xc1b5ec,_0x25ac13,_0x295148){const _0x211cc7=_0x4b4114,{connector_version:_0x2e8eeb,..._0x2390ad}=_0x295148,_0x1690e1={'id':_0x5af769,'type':workflow_1['WorkflowStepType']['AUTHENTICATION'],'connector_id':_0xc1b5ec,'action':_0x25ac13,'params':_0x2390ad,'body':_0x2390ad};return _0x2e8eeb!=null&&String(_0x2e8eeb)[_0x211cc7(0x151)]()!==''&&(_0x1690e1[_0x211cc7(0x168)]=String(_0x2e8eeb)[_0x211cc7(0x151)]()),_0x1690e1;}function makeEncryptStep(_0x29bc2e,_0x376452,_0x21d37d,_0x3cb172){const _0x53c245=_0x4b4114,{connector_version:_0x4681b9,..._0x15ba23}=_0x3cb172,_0xa43ef3={'id':_0x29bc2e,'type':workflow_1[_0x53c245(0x14d)][_0x53c245(0x17c)],'connector_id':_0x376452,'action':_0x21d37d,'params':_0x15ba23,'body':_0x15ba23};return _0x4681b9!=null&&String(_0x4681b9)[_0x53c245(0x151)]()!==''&&(_0xa43ef3[_0x53c245(0x168)]=String(_0x4681b9)['trim']()),_0xa43ef3;}function makeCodeStep(_0x147b84,_0x4b403e,_0x2795a1,_0x4994db,_0x54b925){const _0x20b18f=_0x4b4114,_0x13e325=!_0x2795a1&&!_0x4b403e['includes'](_0x20b18f(0x163))&&!_0x4b403e[_0x20b18f(0x173)]('{{');return{'id':_0x147b84,'type':workflow_1['WorkflowStepType'][_0x20b18f(0x179)],..._0x13e325?{'module_ref':_0x4b403e,'fn':_0x2795a1||'execute','args':_0x4994db||{}}:{'source':_0x4b403e,'args':_0x4994db||{}},'input_from':_0x54b925?.[_0x20b18f(0x153)],'timeout':_0x54b925?.['timeout']??0x3e8};}function makeCallStep(_0xe00673,_0x5b8be3,_0x14f18c){const _0x17ff82=_0x4b4114;return{'id':_0xe00673,'type':workflow_1['WorkflowStepType'][_0x17ff82(0x189)],'function_id':_0x5b8be3,'function_slug':_0x5b8be3,'args':_0x14f18c};}function makeCallWorkflowStep(_0x729773,_0x1f6b4f,_0xe24eb1,_0x16346b){const _0x54cd50=_0x4b4114,_0x4bc455=_0xe24eb1??{},_0x33799e=_0x4bc455['trigger_id']??_0x4bc455[_0x54cd50(0x169)],_0x3a538d=_0x4bc455[_0x54cd50(0x183)],_0x219ea4=_0x4bc455[_0x54cd50(0x15b)]??_0x4bc455[_0x54cd50(0x156)],_0x2cae33=_0x4bc455[_0x54cd50(0x175)]===!![],_0x3e360f=_0x4bc455[_0x54cd50(0x16f)]??_0x4bc455[_0x54cd50(0x18f)],_0x71af01={..._0x4bc455};for(const _0x4be3fa of[_0x54cd50(0x15a),_0x54cd50(0x169),_0x54cd50(0x183),'executionHeaders',_0x54cd50(0x156),_0x54cd50(0x175),'child_workflow_name',_0x54cd50(0x18f),_0x54cd50(0x17e),_0x54cd50(0x15c),_0x54cd50(0x155),_0x54cd50(0x181)]){delete _0x71af01[_0x4be3fa];}const _0x198784=_0x4bc455[_0x54cd50(0x17e)]||_0x4bc455[_0x54cd50(0x15c)]?{'path':String(_0x4bc455['webhook_path']??_0x4bc455[_0x54cd50(0x15c)])['trim'](),'method':String(_0x4bc455[_0x54cd50(0x155)]??_0x4bc455[_0x54cd50(0x181)]??'POST')['toUpperCase']()}:undefined,_0xa7d632=_0x16346b?.['path']?{'path':_0x16346b['path'][_0x54cd50(0x151)](),'method':(_0x16346b['method']??_0x54cd50(0x17f))[_0x54cd50(0x13f)]()}:_0x198784,_0x38c7a0={'id':_0x729773,'type':workflow_1[_0x54cd50(0x14d)][_0x54cd50(0x15f)],'payload':Object[_0x54cd50(0x187)](_0x71af01)[_0x54cd50(0x132)]?_0x71af01:{}};if(_0x1f6b4f)_0x38c7a0[_0x54cd50(0x14e)]=_0x1f6b4f;_0xa7d632?.[_0x54cd50(0x139)]&&(_0x38c7a0[_0x54cd50(0x17e)]=_0xa7d632[_0x54cd50(0x139)],_0x38c7a0['webhook_method']=_0xa7d632[_0x54cd50(0x182)]);if(!_0x38c7a0[_0x54cd50(0x14e)]&&!_0x38c7a0[_0x54cd50(0x17e)])throw new Error('CallWorkflow\x20requires\x20a\x20workflow\x20group\x20id,\x20or\x20a\x20webhook\x20path,\x20or\x20both\x20in\x20payload');if(_0x33799e)_0x38c7a0['trigger_id']=_0x33799e;if(_0x3a538d)_0x38c7a0[_0x54cd50(0x183)]=_0x3a538d;if(_0x219ea4&&Object['keys'](_0x219ea4)['length']>0x0)_0x38c7a0['execution_headers']=_0x219ea4;if(_0x2cae33)_0x38c7a0[_0x54cd50(0x175)]=!![];if(_0x3e360f)_0x38c7a0[_0x54cd50(0x16f)]=_0x3e360f;return _0x38c7a0;}function makeLoopStep(_0x5e4072,_0x369858,_0x3077ea,_0x5c04ba){const _0x6049b3=_0x4b4114;return{'id':_0x5e4072,'type':workflow_1[_0x6049b3(0x14d)][_0x6049b3(0x190)],'over':_0x369858,'as':_0x5c04ba?.['as']??_0x6049b3(0x18c),'index_as':_0x5c04ba?.[_0x6049b3(0x174)]??_0x6049b3(0x162),'steps':_0x3077ea,'max_iterations':_0x5c04ba?.[_0x6049b3(0x160)]??0x3e8};}function makeLogStep(_0x2a4ae2,_0x2593c1){const _0x59ad2a=_0x4b4114;return{'id':_0x2a4ae2,'type':workflow_1[_0x59ad2a(0x14d)]['LOG'],'message':_0x2593c1};}function _0x2b99(_0x5eafb4,_0x378188){_0x5eafb4=_0x5eafb4-0x131;const _0x3e4299=_0x3e42();let _0x2b9970=_0x3e4299[_0x5eafb4];if(_0x2b99['afDMxB']===undefined){var _0x2938d8=function(_0x30429b){const _0x58203f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x412c55='',_0x32f299='';for(let _0x1c5db7=0x0,_0x31f8ec,_0x4c5260,_0x279699=0x0;_0x4c5260=_0x30429b['charAt'](_0x279699++);~_0x4c5260&&(_0x31f8ec=_0x1c5db7%0x4?_0x31f8ec*0x40+_0x4c5260:_0x4c5260,_0x1c5db7++%0x4)?_0x412c55+=String['fromCharCode'](0xff&_0x31f8ec>>(-0x2*_0x1c5db7&0x6)):0x0){_0x4c5260=_0x58203f['indexOf'](_0x4c5260);}for(let _0x5a766a=0x0,_0x4b313e=_0x412c55['length'];_0x5a766a<_0x4b313e;_0x5a766a++){_0x32f299+='%'+('00'+_0x412c55['charCodeAt'](_0x5a766a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x32f299);};_0x2b99['EhUhsP']=_0x2938d8,_0x2b99['XomGgV']={},_0x2b99['afDMxB']=!![];}const _0x2c79c0=_0x3e4299[0x0],_0x2799cb=_0x5eafb4+_0x2c79c0,_0x23d102=_0x2b99['XomGgV'][_0x2799cb];return!_0x23d102?(_0x2b9970=_0x2b99['EhUhsP'](_0x2b9970),_0x2b99['XomGgV'][_0x2799cb]=_0x2b9970):_0x2b9970=_0x23d102,_0x2b9970;}function makeDelayStep(_0x4ea6eb,_0x53d2b1){const _0x2cdad5=_0x4b4114;return{'id':_0x4ea6eb,'type':workflow_1[_0x2cdad5(0x14d)]['DELAY'],'ms':_0x53d2b1};}function makeNotifyStep(_0x2efe45,_0x1808ee,_0x21ac4c){const _0xe6d9c1=_0x4b4114;return{'id':_0x2efe45,'type':workflow_1[_0xe6d9c1(0x14d)][_0xe6d9c1(0x192)],'channel':_0x1808ee,'message':_0x21ac4c};}function makeCustomStep(_0x198c11){return{'id':_0x198c11,'type':workflow_1['WorkflowStepType']['CUSTOM']};}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONNECTOR_META_KEY = exports.WORKFLOW_META_KEY = void 0;
|
|
4
|
+
exports.getOrCreateWorkflowMeta = getOrCreateWorkflowMeta;
|
|
5
|
+
exports.getOrCreateConnectorMeta = getOrCreateConnectorMeta;
|
|
6
|
+
exports.sanitizeStepId = sanitizeStepId;
|
|
7
|
+
exports.inferWorkflowIdFromClassName = inferWorkflowIdFromClassName;
|
|
8
|
+
exports.withThenElse = withThenElse;
|
|
9
|
+
exports.makeConnectorStep = makeConnectorStep;
|
|
10
|
+
exports.makeDbStep = makeDbStep;
|
|
11
|
+
exports.makeValidatorStep = makeValidatorStep;
|
|
12
|
+
exports.makeConditionStep = makeConditionStep;
|
|
13
|
+
exports.makeTransformStep = makeTransformStep;
|
|
14
|
+
exports.makeResponderStep = makeResponderStep;
|
|
15
|
+
exports.makeAuthStep = makeAuthStep;
|
|
16
|
+
exports.makeEncryptStep = makeEncryptStep;
|
|
17
|
+
exports.makeCodeStep = makeCodeStep;
|
|
18
|
+
exports.makeCallStep = makeCallStep;
|
|
19
|
+
exports.makeCallWorkflowStep = makeCallWorkflowStep;
|
|
20
|
+
exports.makeLoopStep = makeLoopStep;
|
|
21
|
+
exports.makeLogStep = makeLogStep;
|
|
22
|
+
exports.makeDelayStep = makeDelayStep;
|
|
23
|
+
exports.makeNotifyStep = makeNotifyStep;
|
|
24
|
+
exports.makeCustomStep = makeCustomStep;
|
|
25
|
+
const workflow_1 = require("../types/workflow");
|
|
26
|
+
exports.WORKFLOW_META_KEY = Symbol.for("cliodot:workflowMeta");
|
|
27
|
+
exports.CONNECTOR_META_KEY = Symbol.for("cliodot:connectorMeta");
|
|
28
|
+
function getOrCreateWorkflowMeta(ctor) {
|
|
29
|
+
if (!ctor[exports.WORKFLOW_META_KEY]) {
|
|
30
|
+
ctor[exports.WORKFLOW_META_KEY] = { steps: [] };
|
|
31
|
+
}
|
|
32
|
+
return ctor[exports.WORKFLOW_META_KEY];
|
|
33
|
+
}
|
|
34
|
+
function getOrCreateConnectorMeta(ctor) {
|
|
35
|
+
if (!ctor[exports.CONNECTOR_META_KEY]) {
|
|
36
|
+
ctor[exports.CONNECTOR_META_KEY] = { actions: [] };
|
|
37
|
+
}
|
|
38
|
+
return ctor[exports.CONNECTOR_META_KEY];
|
|
39
|
+
}
|
|
40
|
+
function sanitizeStepId(id) {
|
|
41
|
+
return id.replace(/[.\-\s]/g, "_");
|
|
42
|
+
}
|
|
43
|
+
function inferWorkflowIdFromClassName(className) {
|
|
44
|
+
const raw = className.replace(/Workflow$/i, "").replace(/_/g, " ").trim();
|
|
45
|
+
const kebab = raw
|
|
46
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
47
|
+
.replace(/\s+/g, "-")
|
|
48
|
+
.toLowerCase();
|
|
49
|
+
return sanitizeStepId(kebab);
|
|
50
|
+
}
|
|
51
|
+
function withThenElse(step, thenId, elseId) {
|
|
52
|
+
const then = thenId ? sanitizeStepId(thenId) : undefined;
|
|
53
|
+
const elseStep = elseId ? sanitizeStepId(elseId) : undefined;
|
|
54
|
+
if (then)
|
|
55
|
+
step.then = then;
|
|
56
|
+
if (elseStep)
|
|
57
|
+
step.else = elseStep;
|
|
58
|
+
return step;
|
|
59
|
+
}
|
|
60
|
+
const CONNECTOR_STEP_RESERVED = new Set([
|
|
61
|
+
"body",
|
|
62
|
+
"params",
|
|
63
|
+
"pathParams",
|
|
64
|
+
"headers",
|
|
65
|
+
"vars",
|
|
66
|
+
"timeout",
|
|
67
|
+
"files",
|
|
68
|
+
"installation_id",
|
|
69
|
+
"connection_id",
|
|
70
|
+
"database",
|
|
71
|
+
"connector_version",
|
|
72
|
+
]);
|
|
73
|
+
function makeConnectorStep(id, connectorId, action, config = {}) {
|
|
74
|
+
const c = config;
|
|
75
|
+
const explicitBody = c.body;
|
|
76
|
+
const params = c.params;
|
|
77
|
+
const pathParams = c.pathParams;
|
|
78
|
+
const headers = c.headers;
|
|
79
|
+
const vars = c.vars;
|
|
80
|
+
const timeout = c.timeout;
|
|
81
|
+
const files = c.files;
|
|
82
|
+
const installation_id = c.installation_id;
|
|
83
|
+
const connection_id = c.connection_id;
|
|
84
|
+
const database = c.database;
|
|
85
|
+
const connector_version = c.connector_version;
|
|
86
|
+
const rest = {};
|
|
87
|
+
for (const k of Object.keys(c)) {
|
|
88
|
+
if (!CONNECTOR_STEP_RESERVED.has(k))
|
|
89
|
+
rest[k] = c[k];
|
|
90
|
+
}
|
|
91
|
+
const body = explicitBody !== undefined
|
|
92
|
+
? explicitBody
|
|
93
|
+
: Object.keys(rest).length > 0
|
|
94
|
+
? rest
|
|
95
|
+
: undefined;
|
|
96
|
+
const step = {
|
|
97
|
+
id,
|
|
98
|
+
type: workflow_1.WorkflowStepType.API_CALL,
|
|
99
|
+
connector_id: connectorId,
|
|
100
|
+
action,
|
|
101
|
+
};
|
|
102
|
+
if (params !== undefined)
|
|
103
|
+
step.params = params;
|
|
104
|
+
if (pathParams !== undefined)
|
|
105
|
+
step.pathParams = pathParams;
|
|
106
|
+
if (headers !== undefined)
|
|
107
|
+
step.headers = headers;
|
|
108
|
+
if (vars !== undefined)
|
|
109
|
+
step.vars = vars;
|
|
110
|
+
if (timeout !== undefined)
|
|
111
|
+
step.timeout = timeout;
|
|
112
|
+
if (files !== undefined)
|
|
113
|
+
step.files = files;
|
|
114
|
+
if (installation_id !== undefined)
|
|
115
|
+
step.installation_id = installation_id;
|
|
116
|
+
if (connection_id !== undefined)
|
|
117
|
+
step.connection_id = connection_id;
|
|
118
|
+
if (database !== undefined)
|
|
119
|
+
step.database = database;
|
|
120
|
+
if (connector_version !== undefined && connector_version !== "")
|
|
121
|
+
step.connector_version = String(connector_version);
|
|
122
|
+
if (body !== undefined)
|
|
123
|
+
step.body = body;
|
|
124
|
+
return step;
|
|
125
|
+
}
|
|
126
|
+
function makeDbStep(id, engine, action, config) {
|
|
127
|
+
const connectorId = engine === "mongodb" ? "mongodb.system" : "mysql.system";
|
|
128
|
+
const { connector_version: cvDb, connection_id, database, ...bodyPayload } = config;
|
|
129
|
+
const step = {
|
|
130
|
+
id,
|
|
131
|
+
type: workflow_1.WorkflowStepType.DB,
|
|
132
|
+
connector_id: connectorId,
|
|
133
|
+
action,
|
|
134
|
+
body: bodyPayload,
|
|
135
|
+
params: bodyPayload.params,
|
|
136
|
+
};
|
|
137
|
+
if (connection_id)
|
|
138
|
+
step.connection_id = connection_id;
|
|
139
|
+
if (database)
|
|
140
|
+
step.database = database;
|
|
141
|
+
if (cvDb != null && String(cvDb).trim() !== "") {
|
|
142
|
+
step.connector_version = String(cvDb).trim();
|
|
143
|
+
}
|
|
144
|
+
return step;
|
|
145
|
+
}
|
|
146
|
+
function makeValidatorStep(id, fieldsOrGroups) {
|
|
147
|
+
let validationGroups;
|
|
148
|
+
if (Array.isArray(fieldsOrGroups)) {
|
|
149
|
+
validationGroups = fieldsOrGroups;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
validationGroups = [
|
|
153
|
+
{
|
|
154
|
+
fields: Object.values(fieldsOrGroups),
|
|
155
|
+
validators: Object.entries(fieldsOrGroups).map(() => ({ name: "required", config: {} })),
|
|
156
|
+
},
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
id,
|
|
161
|
+
type: workflow_1.WorkflowStepType.VALIDATOR,
|
|
162
|
+
validationGroups: validationGroups.map((g) => ({
|
|
163
|
+
fields: g.fields,
|
|
164
|
+
validators: g.validators.map((v) => ({
|
|
165
|
+
name: v.name,
|
|
166
|
+
config: v.config ?? {},
|
|
167
|
+
})),
|
|
168
|
+
})),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function makeConditionStep(id, expr) {
|
|
172
|
+
return {
|
|
173
|
+
id,
|
|
174
|
+
type: workflow_1.WorkflowStepType.CONDITION,
|
|
175
|
+
mode: "jexl",
|
|
176
|
+
if: expr,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function makeTransformStep(id, mappingOrOperations) {
|
|
180
|
+
const isMapping = !Array.isArray(mappingOrOperations);
|
|
181
|
+
return {
|
|
182
|
+
id,
|
|
183
|
+
type: workflow_1.WorkflowStepType.TRANSFORM,
|
|
184
|
+
...(isMapping
|
|
185
|
+
? { mapping: mappingOrOperations }
|
|
186
|
+
: { operations: mappingOrOperations }),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function makeResponderStep(id, type, config) {
|
|
190
|
+
return {
|
|
191
|
+
id,
|
|
192
|
+
type: workflow_1.WorkflowStepType.RESPONDER,
|
|
193
|
+
responder: type,
|
|
194
|
+
config: {
|
|
195
|
+
statusCode: config.statusCode ?? 200,
|
|
196
|
+
headers: config.headers,
|
|
197
|
+
body: config.body,
|
|
198
|
+
contentType: config.contentType,
|
|
199
|
+
location: config.location,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function makeAuthStep(id, connectorId, action, config) {
|
|
204
|
+
const { connector_version: cvAuth, ...payload } = config;
|
|
205
|
+
const step = {
|
|
206
|
+
id,
|
|
207
|
+
type: workflow_1.WorkflowStepType.AUTHENTICATION,
|
|
208
|
+
connector_id: connectorId,
|
|
209
|
+
action,
|
|
210
|
+
params: payload,
|
|
211
|
+
body: payload,
|
|
212
|
+
};
|
|
213
|
+
if (cvAuth != null && String(cvAuth).trim() !== "") {
|
|
214
|
+
step.connector_version = String(cvAuth).trim();
|
|
215
|
+
}
|
|
216
|
+
return step;
|
|
217
|
+
}
|
|
218
|
+
function makeEncryptStep(id, connectorId, action, config) {
|
|
219
|
+
const { connector_version: cvEnc, ...payload } = config;
|
|
220
|
+
const step = {
|
|
221
|
+
id,
|
|
222
|
+
type: workflow_1.WorkflowStepType.ENCRYPTION,
|
|
223
|
+
connector_id: connectorId,
|
|
224
|
+
action,
|
|
225
|
+
params: payload,
|
|
226
|
+
body: payload,
|
|
227
|
+
};
|
|
228
|
+
if (cvEnc != null && String(cvEnc).trim() !== "") {
|
|
229
|
+
step.connector_version = String(cvEnc).trim();
|
|
230
|
+
}
|
|
231
|
+
return step;
|
|
232
|
+
}
|
|
233
|
+
function makeCodeStep(id, sourceOrModule, fn, args, config) {
|
|
234
|
+
const isModule = !fn && !sourceOrModule.includes("return") && !sourceOrModule.includes("{{");
|
|
235
|
+
return {
|
|
236
|
+
id,
|
|
237
|
+
type: workflow_1.WorkflowStepType.CODE,
|
|
238
|
+
...(isModule
|
|
239
|
+
? { module_ref: sourceOrModule, fn: fn || "execute", args: args || {} }
|
|
240
|
+
: { source: sourceOrModule, args: args || {} }),
|
|
241
|
+
input_from: config?.input_from,
|
|
242
|
+
timeout: config?.timeout ?? 1000,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function makeCallStep(id, functionSlugOrId, args) {
|
|
246
|
+
return {
|
|
247
|
+
id,
|
|
248
|
+
type: workflow_1.WorkflowStepType.FUNCTION,
|
|
249
|
+
function_id: functionSlugOrId,
|
|
250
|
+
function_slug: functionSlugOrId,
|
|
251
|
+
args,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function makeCallWorkflowStep(id, workflowId, payload, webhook) {
|
|
255
|
+
const raw = payload ?? {};
|
|
256
|
+
const trigger_id = (raw.trigger_id ?? raw.triggerId);
|
|
257
|
+
const environment = raw.environment;
|
|
258
|
+
const executionHeaders = (raw.executionHeaders ?? raw.execution_headers);
|
|
259
|
+
const remote = raw.remote === true;
|
|
260
|
+
const child_workflow_name = (raw.child_workflow_name ?? raw.workflow_name);
|
|
261
|
+
const rest = { ...raw };
|
|
262
|
+
for (const k of [
|
|
263
|
+
"trigger_id",
|
|
264
|
+
"triggerId",
|
|
265
|
+
"environment",
|
|
266
|
+
"executionHeaders",
|
|
267
|
+
"execution_headers",
|
|
268
|
+
"remote",
|
|
269
|
+
"child_workflow_name",
|
|
270
|
+
"workflow_name",
|
|
271
|
+
"webhook_path",
|
|
272
|
+
"webhookPath",
|
|
273
|
+
"webhook_method",
|
|
274
|
+
"webhookMethod",
|
|
275
|
+
]) {
|
|
276
|
+
delete rest[k];
|
|
277
|
+
}
|
|
278
|
+
const wFromRaw = raw.webhook_path || raw.webhookPath
|
|
279
|
+
? {
|
|
280
|
+
path: String(raw.webhook_path ?? raw.webhookPath).trim(),
|
|
281
|
+
method: String(raw.webhook_method ?? raw.webhookMethod ?? "POST").toUpperCase(),
|
|
282
|
+
}
|
|
283
|
+
: undefined;
|
|
284
|
+
const webhookResolved = webhook?.path
|
|
285
|
+
? { path: webhook.path.trim(), method: (webhook.method ?? "POST").toUpperCase() }
|
|
286
|
+
: wFromRaw;
|
|
287
|
+
const step = {
|
|
288
|
+
id,
|
|
289
|
+
type: workflow_1.WorkflowStepType.CALL_WORKFLOW,
|
|
290
|
+
payload: Object.keys(rest).length ? rest : {},
|
|
291
|
+
};
|
|
292
|
+
if (workflowId)
|
|
293
|
+
step.workflow_id = workflowId;
|
|
294
|
+
if (webhookResolved?.path) {
|
|
295
|
+
step.webhook_path = webhookResolved.path;
|
|
296
|
+
step.webhook_method = webhookResolved.method;
|
|
297
|
+
}
|
|
298
|
+
if (!step.workflow_id && !step.webhook_path) {
|
|
299
|
+
throw new Error("CallWorkflow requires a workflow group id, or a webhook path, or both in payload");
|
|
300
|
+
}
|
|
301
|
+
if (trigger_id)
|
|
302
|
+
step.trigger_id = trigger_id;
|
|
303
|
+
if (environment)
|
|
304
|
+
step.environment = environment;
|
|
305
|
+
if (executionHeaders && Object.keys(executionHeaders).length > 0)
|
|
306
|
+
step.execution_headers = executionHeaders;
|
|
307
|
+
if (remote)
|
|
308
|
+
step.remote = true;
|
|
309
|
+
if (child_workflow_name)
|
|
310
|
+
step.child_workflow_name = child_workflow_name;
|
|
311
|
+
return step;
|
|
312
|
+
}
|
|
313
|
+
function makeLoopStep(id, over, steps, config) {
|
|
314
|
+
return {
|
|
315
|
+
id,
|
|
316
|
+
type: workflow_1.WorkflowStepType.LOOP,
|
|
317
|
+
over,
|
|
318
|
+
as: config?.as ?? "item",
|
|
319
|
+
index_as: config?.index_as ?? "index",
|
|
320
|
+
steps,
|
|
321
|
+
max_iterations: config?.max_iterations ?? 1000,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function makeLogStep(id, message) {
|
|
325
|
+
return { id, type: workflow_1.WorkflowStepType.LOG, message };
|
|
326
|
+
}
|
|
327
|
+
function makeDelayStep(id, ms) {
|
|
328
|
+
return { id, type: workflow_1.WorkflowStepType.DELAY, ms };
|
|
329
|
+
}
|
|
330
|
+
function makeNotifyStep(id, channel, message) {
|
|
331
|
+
return { id, type: workflow_1.WorkflowStepType.NOTIFY, channel, message };
|
|
332
|
+
}
|
|
333
|
+
function makeCustomStep(id) {
|
|
334
|
+
return {
|
|
335
|
+
id,
|
|
336
|
+
type: workflow_1.WorkflowStepType.CUSTOM,
|
|
337
|
+
};
|
|
338
|
+
}
|
package/dist/decorators/steps.js
CHANGED
|
@@ -1 +1,220 @@
|
|
|
1
|
-
'use strict';const _0x35bd63=_0x14ec;(function(_0x54d94d,_0x6015d4){const _0x3c6838=_0x14ec,_0x384d56=_0x54d94d();while(!![]){try{const _0x451660=-parseInt(_0x3c6838(0x11f))/0x1+-parseInt(_0x3c6838(0xef))/0x2+-parseInt(_0x3c6838(0x100))/0x3+parseInt(_0x3c6838(0x120))/0x4*(-parseInt(_0x3c6838(0x115))/0x5)+parseInt(_0x3c6838(0xfc))/0x6+-parseInt(_0x3c6838(0x10f))/0x7+parseInt(_0x3c6838(0x10c))/0x8;if(_0x451660===_0x6015d4)break;else _0x384d56['push'](_0x384d56['shift']());}catch(_0x9efb65){_0x384d56['push'](_0x384d56['shift']());}}}(_0x1b62,0xc7c0e));Object[_0x35bd63(0xff)](exports,_0x35bd63(0x11c),{'value':!![]}),exports[_0x35bd63(0x110)]=Connector,exports['Util']=Util,exports['Db']=Db,exports[_0x35bd63(0x107)]=Validator,exports[_0x35bd63(0xfb)]=Condition,exports[_0x35bd63(0x10d)]=Transform,exports[_0x35bd63(0xf4)]=Auth,exports['Encrypt']=Encrypt,exports[_0x35bd63(0x10a)]=Responder,exports[_0x35bd63(0x102)]=Code,exports[_0x35bd63(0x109)]=Call,exports['CallWorkflow']=CallWorkflow,exports[_0x35bd63(0x11e)]=Loop,exports[_0x35bd63(0x10e)]=Log,exports[_0x35bd63(0xf5)]=Delay,exports[_0x35bd63(0xf3)]=Notify,exports['Step']=Step;const metadata_1=require('./metadata'),registry_1=require(_0x35bd63(0x111));function Connector(_0x2f66b4,_0x2a3a58,_0x4270d8,_0x22d96e={}){const _0x2bcac2=_0x4270d8??{};return function(target,_0xdf7283){const _0x3f8d4a=_0x14ec,_0x42d73a=(0x0,metadata_1[_0x3f8d4a(0x114)])(target['constructor']),_0x423b62=_0x22d96e['id']??_0xdf7283,_0x47689b=_0x22d96e[_0x3f8d4a(0x103)]??_0x42d73a[_0x3f8d4a(0x116)]['length'];let _0x1b7bb6,_0x172274;if((0x0,registry_1[_0x3f8d4a(0x112)])(_0x2f66b4)){_0x1b7bb6=_0x2f66b4['id'];const _0x343444=_0x2a3a58,_0x125324=_0x2f66b4[_0x3f8d4a(0xf0)][_0x343444];if(typeof _0x125324!==_0x3f8d4a(0xf6))throw new Error(_0x3f8d4a(0xf9)+_0x1b7bb6+':\x20'+String(_0x2a3a58));_0x172274=_0x125324;}else{if((0x0,registry_1['isCustomConnectorDef'])(_0x2f66b4)){_0x1b7bb6=_0x2f66b4['id'];const _0x21717c=_0x2a3a58,_0x524a9c=_0x2f66b4['actions'][_0x21717c];if(typeof _0x524a9c!==_0x3f8d4a(0xf6))throw new Error(_0x3f8d4a(0xf9)+_0x1b7bb6+':\x20'+String(_0x2a3a58));_0x172274=_0x524a9c;}else _0x1b7bb6=_0x2f66b4,_0x172274=_0x2a3a58;}const _0x2a3624=_0x143dae=>(0x0,metadata_1['makeConnectorStep'])(_0x143dae,_0x1b7bb6,_0x172274,_0x2bcac2);_0x42d73a[_0x3f8d4a(0x116)][_0x3f8d4a(0x11d)]({'stepId':_0x423b62,'methodKey':_0xdf7283,'orderKey':_0x47689b,'stage':_0x22d96e[_0x3f8d4a(0xf1)],'then':_0x22d96e[_0x3f8d4a(0x11b)],'else':_0x22d96e[_0x3f8d4a(0x121)],'factory':_0x2a3624});};}function Util(_0x22733b,_0x51e7ef,_0x1f5758={},_0x51b598={}){return Connector(_0x22733b,_0x51e7ef,_0x1f5758,_0x51b598);}function Db(_0x1117de,_0x286fed,_0xd92e26,_0x50bbbd={}){return function(target,_0x3b58f0){const _0x27e7d7=_0x14ec,_0x5858bc=(0x0,metadata_1['getOrCreateWorkflowMeta'])(target[_0x27e7d7(0x106)]),_0x824a5a=_0x50bbbd['id']??_0x3b58f0,_0x1f2c15=_0x50bbbd[_0x27e7d7(0x103)]??_0x5858bc[_0x27e7d7(0x116)]['length'],_0x1a31d1=_0x1a2437=>(0x0,metadata_1[_0x27e7d7(0x113)])(_0x1a2437,_0x1117de,_0x286fed,_0xd92e26);_0x5858bc[_0x27e7d7(0x116)][_0x27e7d7(0x11d)]({'stepId':_0x824a5a,'methodKey':_0x3b58f0,'orderKey':_0x1f2c15,'stage':_0x50bbbd[_0x27e7d7(0xf1)],'then':_0x50bbbd['then'],'else':_0x50bbbd[_0x27e7d7(0x121)],'factory':_0x1a31d1});};}function Validator(_0x176f2c,_0x41421b={}){return function(target,_0x120e61){const _0x27a7b6=_0x14ec,_0x63a2c8=(0x0,metadata_1[_0x27a7b6(0x114)])(target['constructor']),_0x2dd2ba=_0x41421b['id']??_0x120e61,_0x12a40c=_0x41421b[_0x27a7b6(0x103)]??_0x63a2c8[_0x27a7b6(0x116)]['length'],_0x21d389=_0x413e53=>(0x0,metadata_1['makeValidatorStep'])(_0x413e53,_0x176f2c);_0x63a2c8[_0x27a7b6(0x116)][_0x27a7b6(0x11d)]({'stepId':_0x2dd2ba,'methodKey':_0x120e61,'orderKey':_0x12a40c,'stage':_0x41421b[_0x27a7b6(0xf1)],'then':_0x41421b[_0x27a7b6(0x11b)],'else':_0x41421b[_0x27a7b6(0x121)],'factory':_0x21d389});};}function Condition(_0x3a9dc3,_0x588051={}){return function(target,_0x3744c3){const _0x57806b=_0x14ec,_0x521191=(0x0,metadata_1['getOrCreateWorkflowMeta'])(target[_0x57806b(0x106)]),_0xfceb22=_0x588051['id']??_0x3744c3,_0x20a85c=_0x588051[_0x57806b(0x103)]??_0x521191['steps'][_0x57806b(0x104)],_0xd9cd22=_0x3cb82e=>(0x0,metadata_1[_0x57806b(0x119)])(_0x3cb82e,_0x3a9dc3);_0x521191['steps'][_0x57806b(0x11d)]({'stepId':_0xfceb22,'methodKey':_0x3744c3,'orderKey':_0x20a85c,'stage':_0x588051['stage'],'then':_0x588051[_0x57806b(0x11b)],'else':_0x588051[_0x57806b(0x121)],'factory':_0xd9cd22});};}function _0x14ec(_0x11b320,_0x228766){_0x11b320=_0x11b320-0xef;const _0x1b620f=_0x1b62();let _0x14eccd=_0x1b620f[_0x11b320];if(_0x14ec['SqfirS']===undefined){var _0x3d948f=function(_0x422582){const _0x13bc6a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2f66b4='',_0x2a3a58='';for(let _0x4270d8=0x0,_0x22d96e,_0x2bcac2,_0xdf7283=0x0;_0x2bcac2=_0x422582['charAt'](_0xdf7283++);~_0x2bcac2&&(_0x22d96e=_0x4270d8%0x4?_0x22d96e*0x40+_0x2bcac2:_0x2bcac2,_0x4270d8++%0x4)?_0x2f66b4+=String['fromCharCode'](0xff&_0x22d96e>>(-0x2*_0x4270d8&0x6)):0x0){_0x2bcac2=_0x13bc6a['indexOf'](_0x2bcac2);}for(let _0x42d73a=0x0,_0x423b62=_0x2f66b4['length'];_0x42d73a<_0x423b62;_0x42d73a++){_0x2a3a58+='%'+('00'+_0x2f66b4['charCodeAt'](_0x42d73a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2a3a58);};_0x14ec['tddPsg']=_0x3d948f,_0x14ec['ImINcX']={},_0x14ec['SqfirS']=!![];}const _0x293897=_0x1b620f[0x0],_0x27bfb3=_0x11b320+_0x293897,_0x5105ab=_0x14ec['ImINcX'][_0x27bfb3];return!_0x5105ab?(_0x14eccd=_0x14ec['tddPsg'](_0x14eccd),_0x14ec['ImINcX'][_0x27bfb3]=_0x14eccd):_0x14eccd=_0x5105ab,_0x14eccd;}function Transform(_0x4ce7cb,_0xa6720e={}){return function(target,_0x2e71b2){const _0x508bd3=_0x14ec,_0x21dcaf=(0x0,metadata_1[_0x508bd3(0x114)])(target[_0x508bd3(0x106)]),_0x3fb1d9=_0xa6720e['id']??_0x2e71b2,_0x155fe8=_0xa6720e[_0x508bd3(0x103)]??_0x21dcaf['steps'][_0x508bd3(0x104)],_0xd491b9=_0x28a663=>(0x0,metadata_1['makeTransformStep'])(_0x28a663,_0x4ce7cb);_0x21dcaf['steps']['push']({'stepId':_0x3fb1d9,'methodKey':_0x2e71b2,'orderKey':_0x155fe8,'stage':_0xa6720e[_0x508bd3(0xf1)],'then':_0xa6720e[_0x508bd3(0x11b)],'else':_0xa6720e[_0x508bd3(0x121)],'factory':_0xd491b9});};}function Auth(_0x13607e,_0x3a46aa,_0x2082a7,_0x9aac5c={}){return function(target,_0x4da256){const _0x2cee4e=_0x14ec,_0xe9de37=(0x0,metadata_1[_0x2cee4e(0x114)])(target[_0x2cee4e(0x106)]),_0x5d5851=_0x9aac5c['id']??_0x4da256,_0x26bc74=_0x9aac5c[_0x2cee4e(0x103)]??_0xe9de37['steps'][_0x2cee4e(0x104)],_0x35c231=_0x2def8c=>(0x0,metadata_1['makeAuthStep'])(_0x2def8c,_0x13607e,_0x3a46aa,_0x2082a7);_0xe9de37[_0x2cee4e(0x116)][_0x2cee4e(0x11d)]({'stepId':_0x5d5851,'methodKey':_0x4da256,'orderKey':_0x26bc74,'stage':_0x9aac5c[_0x2cee4e(0xf1)],'then':_0x9aac5c['then'],'else':_0x9aac5c[_0x2cee4e(0x121)],'factory':_0x35c231});};}function Encrypt(_0x30aba2,_0x2e5fdf,_0x299d46,_0x2245ab={}){return function(target,_0x1520e1){const _0xf78de3=_0x14ec,_0x4d9cf1=(0x0,metadata_1[_0xf78de3(0x114)])(target[_0xf78de3(0x106)]),_0x3ddb05=_0x2245ab['id']??_0x1520e1,_0x2e8b75=_0x2245ab['order']??_0x4d9cf1[_0xf78de3(0x116)]['length'],_0x6757=_0x56c321=>(0x0,metadata_1[_0xf78de3(0x118)])(_0x56c321,_0x30aba2,_0x2e5fdf,_0x299d46);_0x4d9cf1['steps']['push']({'stepId':_0x3ddb05,'methodKey':_0x1520e1,'orderKey':_0x2e8b75,'stage':_0x2245ab[_0xf78de3(0xf1)],'then':_0x2245ab[_0xf78de3(0x11b)],'else':_0x2245ab[_0xf78de3(0x121)],'factory':_0x6757});};}function _0x1b62(){const _0x4fa1b1=['vhjHBNnMB3jT','tg9N','mJu1nZCWmM1jrMvIrG','q29UBMvJDg9Y','lI4Vy29UBMvJDg9YCY9YzwDPC3rYEq','AxnuExbLzenVBM5Ly3rVCKrLzG','BwfRzurIu3rLCa','z2v0t3jdCMvHDgvxB3jRzMXVD01LDge','mJqYntm3nuzgEevgEG','C3rLChm','D2vIAg9VA1bHDgG','BwfRzuvUy3j5ChrtDgvW','BwfRzunVBMrPDgLVBLn0zxa','Dg9vChbLCKnHC2u','DgHLBG','x19LC01VzhvSzq','ChvZAa','tg9VCa','ntKXnduZu0nptg9i','mtjlELvtCM0','zwXZzq','BwfRzu5VDgLMEvn0zxa','B2jQzwn0','mJy4mtGXmhv0BwPNyW','ywn0Aw9UCW','C3rHz2u','Cg9ZDa','tM90Awz5','qxv0Aa','rgvSyxK','C3rYAw5N','BwfRzunVzgvtDgvW','BwfRzunHBgXxB3jRzMXVD1n0zxa','vw5RBM93BIbHy3rPB24GA2v5ig9UignVBM5Ly3rVCIa','BwfRzunHBgXtDgvW','q29UzgL0Aw9U','mZeYoteZoercDeTmEq','BwfRzuXVz1n0zxa','BwfRzun1C3rVBvn0zxa','zgvMAw5LuhjVCgvYDhK','mJuWndqZsvfxD1fS','ue9tva','q29Kzq','B3jKzxi','BgvUz3rO','BwfRzuXVB3btDgvW','y29UC3rYDwn0B3i','vMfSAwrHDg9Y','D2vIAg9VA01LDgHVza','q2fSBa','uMvZCg9UzgvY','BwfRzurLBgf5u3rLCa','mZmWnJq5mZzvweDWwKG'];_0x1b62=function(){return _0x4fa1b1;};return _0x1b62();}function Responder(_0x5d1d67,_0x12a877,_0x3c2a03={}){return function(target,_0x7896a6){const _0x299bfd=_0x14ec,_0x14ec2b=(0x0,metadata_1[_0x299bfd(0x114)])(target[_0x299bfd(0x106)]),_0x170e7d=_0x3c2a03['id']??_0x7896a6,_0x44894b=_0x3c2a03[_0x299bfd(0x103)]??_0x14ec2b['steps'][_0x299bfd(0x104)],_0x36f9fc=_0x3c1740=>(0x0,metadata_1['makeResponderStep'])(_0x3c1740,_0x5d1d67,_0x12a877);_0x14ec2b[_0x299bfd(0x116)][_0x299bfd(0x11d)]({'stepId':_0x170e7d,'methodKey':_0x7896a6,'orderKey':_0x44894b,'stage':_0x3c2a03[_0x299bfd(0xf1)],'then':_0x3c2a03[_0x299bfd(0x11b)],'else':_0x3c2a03[_0x299bfd(0x121)],'factory':_0x36f9fc});};}function Code(_0x258d5a,_0x1c3dca,_0x13a87b,_0x48e47a,_0x49a51a={}){return function(target,_0x306f97){const _0x59fbdb=_0x14ec,_0x57abe1=(0x0,metadata_1[_0x59fbdb(0x114)])(target[_0x59fbdb(0x106)]),_0x5d3e33=_0x49a51a['id']??_0x306f97,_0x300718=_0x49a51a[_0x59fbdb(0x103)]??_0x57abe1['steps']['length'],_0x1a7d6d=_0x6de5ec=>(0x0,metadata_1[_0x59fbdb(0xf7)])(_0x6de5ec,_0x258d5a,_0x1c3dca,_0x13a87b,_0x48e47a);_0x57abe1[_0x59fbdb(0x116)][_0x59fbdb(0x11d)]({'stepId':_0x5d3e33,'methodKey':_0x306f97,'orderKey':_0x300718,'stage':_0x49a51a[_0x59fbdb(0xf1)],'then':_0x49a51a[_0x59fbdb(0x11b)],'else':_0x49a51a[_0x59fbdb(0x121)],'factory':_0x1a7d6d});};}function Call(_0x4e1b34,_0x31d458,_0x13c6cb={}){return function(target,_0x396c84){const _0x3010a5=_0x14ec,_0x474f48=(0x0,metadata_1[_0x3010a5(0x114)])(target[_0x3010a5(0x106)]),_0x3aed78=_0x13c6cb['id']??_0x396c84,_0x4f9272=_0x13c6cb[_0x3010a5(0x103)]??_0x474f48['steps'][_0x3010a5(0x104)],_0x441ad1=_0x588b20=>(0x0,metadata_1[_0x3010a5(0xfa)])(_0x588b20,_0x4e1b34,_0x31d458);_0x474f48[_0x3010a5(0x116)]['push']({'stepId':_0x3aed78,'methodKey':_0x396c84,'orderKey':_0x4f9272,'stage':_0x13c6cb[_0x3010a5(0xf1)],'then':_0x13c6cb['then'],'else':_0x13c6cb[_0x3010a5(0x121)],'factory':_0x441ad1});};}function CallWorkflow(_0x432287,_0x453d29,_0x382ca2={}){return function(target,_0x18c273){const _0x38f70d=_0x14ec,_0x4f9af1=(0x0,metadata_1['getOrCreateWorkflowMeta'])(target['constructor']),_0x3a7d95=_0x382ca2['id']??_0x18c273,_0x3d4c2a=_0x382ca2[_0x38f70d(0x103)]??_0x4f9af1[_0x38f70d(0x116)][_0x38f70d(0x104)];let _0x51798e='',_0x2473ea;typeof _0x432287===_0x38f70d(0x123)&&_0x432287!==null&&_0x38f70d(0x117)in _0x432287?_0x2473ea={'path':_0x432287[_0x38f70d(0x117)],'method':(_0x432287[_0x38f70d(0x108)]??_0x38f70d(0x101))[_0x38f70d(0x11a)]()}:_0x51798e=_0x432287;const _0x3836d3=_0x32a447=>(0x0,metadata_1[_0x38f70d(0xf8)])(_0x32a447,_0x51798e,_0x453d29,_0x2473ea);_0x4f9af1[_0x38f70d(0x116)][_0x38f70d(0x11d)]({'stepId':_0x3a7d95,'methodKey':_0x18c273,'orderKey':_0x3d4c2a,'stage':_0x382ca2[_0x38f70d(0xf1)],'then':_0x382ca2[_0x38f70d(0x11b)],'else':_0x382ca2[_0x38f70d(0x121)],'factory':_0x3836d3});};}function Loop(_0x349bf7,_0xbb9211,_0x35ab64,_0x784d04={}){return function(target,_0x450630){const _0x1a2297=_0x14ec,_0x186b07=(0x0,metadata_1[_0x1a2297(0x114)])(target['constructor']),_0x36cdb3=_0x784d04['id']??_0x450630,_0x22b465=_0x784d04[_0x1a2297(0x103)]??_0x186b07[_0x1a2297(0x116)]['length'],_0x46f54c=_0x3a2299=>(0x0,metadata_1[_0x1a2297(0x105)])(_0x3a2299,_0x349bf7,_0xbb9211,_0x35ab64);_0x186b07['steps'][_0x1a2297(0x11d)]({'stepId':_0x36cdb3,'methodKey':_0x450630,'orderKey':_0x22b465,'stage':_0x784d04['stage'],'then':_0x784d04['then'],'else':_0x784d04[_0x1a2297(0x121)],'factory':_0x46f54c});};}function Log(_0x38857b,_0x453c97={}){return function(target,_0x12e5ad){const _0x1adfa0=_0x14ec,_0x2efc8b=(0x0,metadata_1[_0x1adfa0(0x114)])(target[_0x1adfa0(0x106)]),_0x2cf8c4=_0x453c97['id']??_0x12e5ad,_0x575a4c=_0x453c97[_0x1adfa0(0x103)]??_0x2efc8b[_0x1adfa0(0x116)][_0x1adfa0(0x104)],_0x3b7752=_0x2de819=>(0x0,metadata_1[_0x1adfa0(0xfd)])(_0x2de819,_0x38857b);_0x2efc8b[_0x1adfa0(0x116)]['push']({'stepId':_0x2cf8c4,'methodKey':_0x12e5ad,'orderKey':_0x575a4c,'stage':_0x453c97[_0x1adfa0(0xf1)],'then':_0x453c97[_0x1adfa0(0x11b)],'else':_0x453c97[_0x1adfa0(0x121)],'factory':_0x3b7752});};}function Delay(_0xa30ce5,_0x27d49f={}){return function(target,_0x4ee2e5){const _0x497341=_0x14ec,_0x5a7baf=(0x0,metadata_1[_0x497341(0x114)])(target[_0x497341(0x106)]),_0x5f2ac1=_0x27d49f['id']??_0x4ee2e5,_0x3fed2e=_0x27d49f[_0x497341(0x103)]??_0x5a7baf['steps']['length'],_0x4846e=_0x2c9f28=>(0x0,metadata_1[_0x497341(0x10b)])(_0x2c9f28,_0xa30ce5);_0x5a7baf[_0x497341(0x116)]['push']({'stepId':_0x5f2ac1,'methodKey':_0x4ee2e5,'orderKey':_0x3fed2e,'stage':_0x27d49f['stage'],'then':_0x27d49f[_0x497341(0x11b)],'else':_0x27d49f[_0x497341(0x121)],'factory':_0x4846e});};}function Notify(_0x315c51,_0x196d2f,_0x2a6f91={}){return function(target,_0x53b318){const _0x7702d=_0x14ec,_0x457d1b=(0x0,metadata_1[_0x7702d(0x114)])(target[_0x7702d(0x106)]),_0x254c8f=_0x2a6f91['id']??_0x53b318,_0x47079e=_0x2a6f91[_0x7702d(0x103)]??_0x457d1b[_0x7702d(0x116)]['length'],_0x2dd62c=_0x56f212=>(0x0,metadata_1[_0x7702d(0x122)])(_0x56f212,_0x315c51,_0x196d2f);_0x457d1b[_0x7702d(0x116)][_0x7702d(0x11d)]({'stepId':_0x254c8f,'methodKey':_0x53b318,'orderKey':_0x47079e,'stage':_0x2a6f91['stage'],'then':_0x2a6f91[_0x7702d(0x11b)],'else':_0x2a6f91['else'],'factory':_0x2dd62c});};}function Step(_0xb5e276={}){return function(target,_0x2ad4dd){const _0x61bbed=_0x14ec,_0x2a66b2=(0x0,metadata_1['getOrCreateWorkflowMeta'])(target[_0x61bbed(0x106)]),_0x3ab0c0=_0xb5e276['id']??_0x2ad4dd,_0x204e29=_0xb5e276[_0x61bbed(0x103)]??_0x2a66b2[_0x61bbed(0x116)][_0x61bbed(0x104)],_0x5c7b0f=_0xb5e276[_0x61bbed(0xf1)]??_0x61bbed(0xf2),_0x51d223=_0x3a6b7b=>(0x0,metadata_1[_0x61bbed(0xfe)])(_0x3a6b7b);_0x2a66b2[_0x61bbed(0x116)][_0x61bbed(0x11d)]({'stepId':_0x3ab0c0,'methodKey':_0x2ad4dd,'orderKey':_0x204e29,'stage':_0x5c7b0f,'then':_0xb5e276[_0x61bbed(0x11b)],'else':_0xb5e276[_0x61bbed(0x121)],'factory':_0x51d223});};}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connector = Connector;
|
|
4
|
+
exports.Util = Util;
|
|
5
|
+
exports.Db = Db;
|
|
6
|
+
exports.Validator = Validator;
|
|
7
|
+
exports.Condition = Condition;
|
|
8
|
+
exports.Transform = Transform;
|
|
9
|
+
exports.Auth = Auth;
|
|
10
|
+
exports.Encrypt = Encrypt;
|
|
11
|
+
exports.Responder = Responder;
|
|
12
|
+
exports.Code = Code;
|
|
13
|
+
exports.Call = Call;
|
|
14
|
+
exports.CallWorkflow = CallWorkflow;
|
|
15
|
+
exports.Loop = Loop;
|
|
16
|
+
exports.Log = Log;
|
|
17
|
+
exports.Delay = Delay;
|
|
18
|
+
exports.Notify = Notify;
|
|
19
|
+
exports.Step = Step;
|
|
20
|
+
const metadata_1 = require("./metadata");
|
|
21
|
+
const registry_1 = require("../connectors/registry");
|
|
22
|
+
function Connector(connectorIdOrDef, actionOrKey, config, options = {}) {
|
|
23
|
+
const resolved = (config ?? {});
|
|
24
|
+
return function (target, propertyKey) {
|
|
25
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
26
|
+
const stepId = options.id ?? propertyKey;
|
|
27
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
28
|
+
let connectorId;
|
|
29
|
+
let action;
|
|
30
|
+
if ((0, registry_1.isTypedConnectorDef)(connectorIdOrDef)) {
|
|
31
|
+
connectorId = connectorIdOrDef.id;
|
|
32
|
+
const key = actionOrKey;
|
|
33
|
+
const mapped = connectorIdOrDef.actions[key];
|
|
34
|
+
if (typeof mapped !== "string") {
|
|
35
|
+
throw new Error(`Unknown action key on connector ${connectorId}: ${String(actionOrKey)}`);
|
|
36
|
+
}
|
|
37
|
+
action = mapped;
|
|
38
|
+
}
|
|
39
|
+
else if ((0, registry_1.isCustomConnectorDef)(connectorIdOrDef)) {
|
|
40
|
+
connectorId = connectorIdOrDef.id;
|
|
41
|
+
const key = actionOrKey;
|
|
42
|
+
const mapped = connectorIdOrDef.actions[key];
|
|
43
|
+
if (typeof mapped !== "string") {
|
|
44
|
+
throw new Error(`Unknown action key on connector ${connectorId}: ${String(actionOrKey)}`);
|
|
45
|
+
}
|
|
46
|
+
action = mapped;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
connectorId = connectorIdOrDef;
|
|
50
|
+
action = actionOrKey;
|
|
51
|
+
}
|
|
52
|
+
const factory = (id) => (0, metadata_1.makeConnectorStep)(id, connectorId, action, resolved);
|
|
53
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function Util(connectorId, action, config = {}, options = {}) {
|
|
57
|
+
return Connector(connectorId, action, config, options);
|
|
58
|
+
}
|
|
59
|
+
function Db(engine, action, config, options = {}) {
|
|
60
|
+
return function (target, propertyKey) {
|
|
61
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
62
|
+
const stepId = options.id ?? propertyKey;
|
|
63
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
64
|
+
const factory = (id) => (0, metadata_1.makeDbStep)(id, engine, action, config);
|
|
65
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function Validator(fieldsOrGroups, options = {}) {
|
|
69
|
+
return function (target, propertyKey) {
|
|
70
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
71
|
+
const stepId = options.id ?? propertyKey;
|
|
72
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
73
|
+
const factory = (id) => (0, metadata_1.makeValidatorStep)(id, fieldsOrGroups);
|
|
74
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function Condition(expr, options = {}) {
|
|
78
|
+
return function (target, propertyKey) {
|
|
79
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
80
|
+
const stepId = options.id ?? propertyKey;
|
|
81
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
82
|
+
const factory = (id) => (0, metadata_1.makeConditionStep)(id, expr);
|
|
83
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function Transform(mappingOrOperations, options = {}) {
|
|
87
|
+
return function (target, propertyKey) {
|
|
88
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
89
|
+
const stepId = options.id ?? propertyKey;
|
|
90
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
91
|
+
const factory = (id) => (0, metadata_1.makeTransformStep)(id, mappingOrOperations);
|
|
92
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function Auth(connectorId, action, config, options = {}) {
|
|
96
|
+
return function (target, propertyKey) {
|
|
97
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
98
|
+
const stepId = options.id ?? propertyKey;
|
|
99
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
100
|
+
const factory = (id) => (0, metadata_1.makeAuthStep)(id, connectorId, action, config);
|
|
101
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function Encrypt(connectorId, action, config, options = {}) {
|
|
105
|
+
return function (target, propertyKey) {
|
|
106
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
107
|
+
const stepId = options.id ?? propertyKey;
|
|
108
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
109
|
+
const factory = (id) => (0, metadata_1.makeEncryptStep)(id, connectorId, action, config);
|
|
110
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function Responder(type, config, options = {}) {
|
|
114
|
+
return function (target, propertyKey) {
|
|
115
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
116
|
+
const stepId = options.id ?? propertyKey;
|
|
117
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
118
|
+
const factory = (id) => (0, metadata_1.makeResponderStep)(id, type, config);
|
|
119
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function Code(sourceOrModule, fn, args, config, options = {}) {
|
|
123
|
+
return function (target, propertyKey) {
|
|
124
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
125
|
+
const stepId = options.id ?? propertyKey;
|
|
126
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
127
|
+
const factory = (id) => (0, metadata_1.makeCodeStep)(id, sourceOrModule, fn, args, config);
|
|
128
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function Call(functionSlugOrId, args, options = {}) {
|
|
132
|
+
return function (target, propertyKey) {
|
|
133
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
134
|
+
const stepId = options.id ?? propertyKey;
|
|
135
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
136
|
+
const factory = (id) => (0, metadata_1.makeCallStep)(id, functionSlugOrId, args);
|
|
137
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function CallWorkflow(pathOrGroupId, payload, options = {}) {
|
|
141
|
+
return function (target, propertyKey) {
|
|
142
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
143
|
+
const stepId = options.id ?? propertyKey;
|
|
144
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
145
|
+
let workflowId = "";
|
|
146
|
+
let webhook;
|
|
147
|
+
if (typeof pathOrGroupId === "object" && pathOrGroupId !== null && "webhookPath" in pathOrGroupId) {
|
|
148
|
+
webhook = {
|
|
149
|
+
path: pathOrGroupId.webhookPath,
|
|
150
|
+
method: (pathOrGroupId.webhookMethod ?? "POST").toUpperCase(),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
workflowId = pathOrGroupId;
|
|
155
|
+
}
|
|
156
|
+
const factory = (id) => (0, metadata_1.makeCallWorkflowStep)(id, workflowId, payload, webhook);
|
|
157
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function Loop(over, steps, config, options = {}) {
|
|
161
|
+
return function (target, propertyKey) {
|
|
162
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
163
|
+
const stepId = options.id ?? propertyKey;
|
|
164
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
165
|
+
const factory = (id) => (0, metadata_1.makeLoopStep)(id, over, steps, config);
|
|
166
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function Log(message, options = {}) {
|
|
170
|
+
return function (target, propertyKey) {
|
|
171
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
172
|
+
const stepId = options.id ?? propertyKey;
|
|
173
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
174
|
+
const factory = (id) => (0, metadata_1.makeLogStep)(id, message);
|
|
175
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function Delay(ms, options = {}) {
|
|
179
|
+
return function (target, propertyKey) {
|
|
180
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
181
|
+
const stepId = options.id ?? propertyKey;
|
|
182
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
183
|
+
const factory = (id) => (0, metadata_1.makeDelayStep)(id, ms);
|
|
184
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function Notify(channel, message, options = {}) {
|
|
188
|
+
return function (target, propertyKey) {
|
|
189
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
190
|
+
const stepId = options.id ?? propertyKey;
|
|
191
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
192
|
+
const factory = (id) => (0, metadata_1.makeNotifyStep)(id, channel, message);
|
|
193
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage: options.stage, then: options.then, else: options.else, factory });
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generic step decorator for custom user-defined logic.
|
|
198
|
+
*
|
|
199
|
+
* The method body is extracted at build time and executed as a code step.
|
|
200
|
+
* The method receives a typed `WorkflowContext` and should return a `StepOutput<T>`.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* @Step({ order: 0 })
|
|
205
|
+
* processData(ctx: WorkflowContext<{ todos: Todo[] }>): StepOutput<{ sorted: Todo[] }> {
|
|
206
|
+
* const sorted = [...ctx.input.todos].sort((a, b) => a.id - b.id);
|
|
207
|
+
* return { out: { sorted } };
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
function Step(options = {}) {
|
|
212
|
+
return function (target, propertyKey) {
|
|
213
|
+
const meta = (0, metadata_1.getOrCreateWorkflowMeta)(target.constructor);
|
|
214
|
+
const stepId = options.id ?? propertyKey;
|
|
215
|
+
const orderKey = options.order ?? meta.steps.length;
|
|
216
|
+
const stage = options.stage ?? "post";
|
|
217
|
+
const factory = (id) => (0, metadata_1.makeCustomStep)(id);
|
|
218
|
+
meta.steps.push({ stepId, methodKey: propertyKey, orderKey, stage, then: options.then, else: options.else, factory });
|
|
219
|
+
};
|
|
220
|
+
}
|