cliodot 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +2 -0
- package/dist/AuthAppClient.d.ts +1 -0
- package/dist/AuthAppClient.d.ts.map +1 -1
- package/dist/AuthAppClient.js +199 -1
- package/dist/CommercialAppClient.d.ts +50 -9
- package/dist/CommercialAppClient.d.ts.map +1 -1
- package/dist/CommercialAppClient.js +576 -1
- package/dist/ConnectorBuilder.js +104 -1
- package/dist/Events.d.ts +2 -0
- package/dist/Events.d.ts.map +1 -1
- package/dist/Events.js +325 -1
- package/dist/Flosync.js +296 -1
- package/dist/FlosyncClient.js +429 -1
- package/dist/FunctionBuilder.js +65 -1
- package/dist/IdentityAppClient.d.ts +1 -0
- package/dist/IdentityAppClient.d.ts.map +1 -1
- package/dist/IdentityAppClient.js +197 -1
- package/dist/MemoryAppClient.d.ts +1 -0
- package/dist/MemoryAppClient.d.ts.map +1 -1
- package/dist/MemoryAppClient.js +149 -1
- package/dist/MemoryClient.js +20 -1
- package/dist/OAuthAppClient.d.ts +1 -0
- package/dist/OAuthAppClient.d.ts.map +1 -1
- package/dist/OAuthAppClient.js +269 -1
- package/dist/ProviderServicesClient.d.ts +24 -0
- package/dist/ProviderServicesClient.d.ts.map +1 -0
- package/dist/ProviderServicesClient.js +158 -0
- package/dist/Surface.d.ts +2 -0
- package/dist/Surface.d.ts.map +1 -1
- package/dist/Surface.js +255 -1
- package/dist/ValidatorBuilder.js +24 -1
- package/dist/Webhooks.js +61 -1
- package/dist/WorkflowBuilder.js +279 -1
- package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
- package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/CommercialAppClient.test.js +217 -0
- package/dist/__tests__/Events.test.js +191 -1
- package/dist/__tests__/IdentityAppClient.test.js +232 -1
- package/dist/__tests__/OAuthAppClient.test.js +300 -1
- package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
- package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
- package/dist/__tests__/ProviderServicesClient.test.js +131 -0
- package/dist/__tests__/Surface.test.js +150 -1
- package/dist/__tests__/errors.test.js +54 -1
- package/dist/__tests__/function.test.js +58 -1
- package/dist/__tests__/helpers.d.ts +5 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/__tests__/helpers.js +10 -0
- package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
- package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
- package/dist/__tests__/localhost-lookup.test.js +26 -0
- package/dist/__tests__/parse-api-error.test.js +26 -1
- package/dist/__tests__/runner.test.js +156 -1
- package/dist/connectors/builtin.js +354 -1
- package/dist/connectors/registry.js +300 -1
- package/dist/decorators/build.js +105 -1
- package/dist/decorators/connector.js +56 -1
- package/dist/decorators/index.js +34 -1
- package/dist/decorators/metadata.js +338 -1
- package/dist/decorators/steps.js +220 -1
- package/dist/decorators/workflow.js +52 -1
- package/dist/errors.js +76 -1
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-result.test.js +57 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
- package/dist/http/__tests__/events-instance-id.test.js +45 -0
- package/dist/http/cliodot-request.d.ts +35 -0
- package/dist/http/cliodot-request.d.ts.map +1 -0
- package/dist/http/cliodot-request.js +105 -0
- package/dist/http/cliodot-result.d.ts +40 -0
- package/dist/http/cliodot-result.d.ts.map +1 -0
- package/dist/http/cliodot-result.js +139 -0
- package/dist/http/create-client.d.ts +3 -0
- package/dist/http/create-client.d.ts.map +1 -0
- package/dist/http/create-client.js +14 -0
- package/dist/http/events-instance-id.d.ts +11 -0
- package/dist/http/events-instance-id.d.ts.map +1 -0
- package/dist/http/events-instance-id.js +86 -0
- package/dist/http/localhost-lookup.d.ts +12 -0
- package/dist/http/localhost-lookup.d.ts.map +1 -0
- package/dist/http/localhost-lookup.js +67 -0
- package/dist/http/parse-api-error.js +56 -1
- package/dist/http/sanitize-execution-headers.js +79 -1
- package/dist/identity-offline-verify.js +174 -1
- package/dist/identity-token-cache.js +51 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -1
- package/dist/runner/ProcessorEngine.js +1311 -1
- package/dist/runner/connector.executor.js +1786 -1
- package/dist/runner/utilities/math.executor.js +153 -1
- package/dist/runner/utilities/random.executor.js +151 -1
- package/dist/runner/utilities/string.executor.js +825 -1
- package/dist/template.js +127 -1
- package/dist/transformers/StepsToNodesTransformer.js +214 -1
- package/dist/transformers/WorkflowTransformer.js +189 -1
- package/dist/types/auth-app.api.d.ts +2 -0
- package/dist/types/auth-app.api.d.ts.map +1 -1
- package/dist/types/auth-app.api.js +2 -1
- package/dist/types/builtin.js +2 -1
- package/dist/types/client.api.js +2 -1
- package/dist/types/commercial-app.api.d.ts +407 -11
- package/dist/types/commercial-app.api.d.ts.map +1 -1
- package/dist/types/commercial-app.api.js +2 -1
- package/dist/types/connector.js +2 -1
- package/dist/types/context.js +2 -1
- package/dist/types/event-app.api.d.ts +8 -0
- package/dist/types/event-app.api.d.ts.map +1 -1
- package/dist/types/event-app.api.js +2 -1
- package/dist/types/function.js +2 -1
- package/dist/types/identity-app.api.d.ts +2 -0
- package/dist/types/identity-app.api.d.ts.map +1 -1
- package/dist/types/identity-app.api.js +2 -1
- package/dist/types/index.js +23 -1
- package/dist/types/memory-app.api.d.ts +2 -0
- package/dist/types/memory-app.api.d.ts.map +1 -1
- package/dist/types/memory-app.api.js +2 -1
- package/dist/types/oauth-app.api.d.ts +2 -0
- package/dist/types/oauth-app.api.d.ts.map +1 -1
- package/dist/types/oauth-app.api.js +105 -1
- package/dist/types/provider-services.api.d.ts +98 -0
- package/dist/types/provider-services.api.d.ts.map +1 -0
- package/dist/types/provider-services.api.js +2 -0
- package/dist/types/validator.js +2 -1
- package/dist/types/webhook-app.api.js +2 -1
- package/dist/types/workflow.js +33 -1
- package/dist/validators/validators.js +478 -1
- package/dist/variable.js +37 -1
- package/package.json +3 -2
package/dist/Flosync.js
CHANGED
|
@@ -1 +1,296 @@
|
|
|
1
|
-
'use strict';const _0x237eda=_0x5949;(function(_0x4406f5,_0x41c7ee){const _0x24b95f=_0x5949,_0x5b1dac=_0x4406f5();while(!![]){try{const _0x227251=-parseInt(_0x24b95f(0xe3))/0x1*(-parseInt(_0x24b95f(0xc1))/0x2)+parseInt(_0x24b95f(0xfc))/0x3*(parseInt(_0x24b95f(0x113))/0x4)+parseInt(_0x24b95f(0xcb))/0x5*(parseInt(_0x24b95f(0xe1))/0x6)+parseInt(_0x24b95f(0xc7))/0x7*(parseInt(_0x24b95f(0x110))/0x8)+-parseInt(_0x24b95f(0x115))/0x9+-parseInt(_0x24b95f(0xff))/0xa*(parseInt(_0x24b95f(0x112))/0xb)+-parseInt(_0x24b95f(0xfb))/0xc;if(_0x227251===_0x41c7ee)break;else _0x5b1dac['push'](_0x5b1dac['shift']());}catch(_0x175346){_0x5b1dac['push'](_0x5b1dac['shift']());}}}(_0x4458,0xb788a));Object[_0x237eda(0x102)](exports,_0x237eda(0xd8),{'value':!![]}),exports[_0x237eda(0xfe)]=exports[_0x237eda(0xdc)]=void 0x0;const WorkflowBuilder_1=require(_0x237eda(0x105)),FunctionBuilder_1=require(_0x237eda(0x103)),ProcessorEngine_1=require(_0x237eda(0xe0)),builtin_1=require(_0x237eda(0x11b)),FlosyncClient_1=require('./FlosyncClient'),build_1=require(_0x237eda(0x118)),registry_1=require(_0x237eda(0xd6)),sanitize_execution_headers_1=require('./http/sanitize-execution-headers');function _0x5949(_0xc0e652,_0x2928dd){_0xc0e652=_0xc0e652-0xb9;const _0x44582e=_0x4458();let _0x594963=_0x44582e[_0xc0e652];if(_0x5949['YgJvzd']===undefined){var _0x30cff6=function(_0x171aab){const _0x7211ad='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4e06ba='',_0x3482b9='';for(let _0x136609=0x0,_0x564dde,_0x31a65e,_0x3f9671=0x0;_0x31a65e=_0x171aab['charAt'](_0x3f9671++);~_0x31a65e&&(_0x564dde=_0x136609%0x4?_0x564dde*0x40+_0x31a65e:_0x31a65e,_0x136609++%0x4)?_0x4e06ba+=String['fromCharCode'](0xff&_0x564dde>>(-0x2*_0x136609&0x6)):0x0){_0x31a65e=_0x7211ad['indexOf'](_0x31a65e);}for(let _0xe2e8bf=0x0,_0x5548ae=_0x4e06ba['length'];_0xe2e8bf<_0x5548ae;_0xe2e8bf++){_0x3482b9+='%'+('00'+_0x4e06ba['charCodeAt'](_0xe2e8bf)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3482b9);};_0x5949['TitVMl']=_0x30cff6,_0x5949['KOokcP']={},_0x5949['YgJvzd']=!![];}const _0x4674b4=_0x44582e[0x0],_0x25795d=_0xc0e652+_0x4674b4,_0x2d8b7b=_0x5949['KOokcP'][_0x25795d];return!_0x2d8b7b?(_0x594963=_0x5949['TitVMl'](_0x594963),_0x5949['KOokcP'][_0x25795d]=_0x594963):_0x594963=_0x2d8b7b,_0x594963;}function _0x4458(){const _0x3ffdc3=['CMf3','zw52x3zHCNm','BgvUz3rO','zxjYB3i','C2v0','ChvZAez1BMn0Aw9U','y29UBMvJDg9YCW','C2fUAxrPEMvfEgvJDxrPB25izwfKzxjZ','Aw5JBhvKzxm','mZjVC2nKCee','yxbPu2vJCMv0','mJmWnZKXr0jfzNDp','ntGYntKYnevdtMLmCW','yMfZzvvYBa','otu3nJe1m2zxt0TJwa','rMXVC3LUy0nSAwvUDa','AxnuExbLzenVBM5Ly3rVCKrLzG','lI9KzwnVCMf0B3jZl2j1AwXK','CNvU','DhjPz2DLCKLK','lI9JB25Uzwn0B3jZl2j1AwX0Aw4','rMXVC3LUy0nSAwvUDcbUB3qGy29UzMLNDxjLzc4Gu2v0igfWAuTLEsbHBMqGyxbPu2vJCMv0igzVCIbYzw1VDguGCNvUlG','y2XPB2rVDa','zMLSDgvY','v29YA2zSB3DcDwLSzgvY','x2LK','y2XPzw50','D29YA2zSB3DZqNLoyw1L','CNvUqNLjza','q29UBMvJDg9Yia','CNvUrNvUy3rPB24','zw52vMfYCW','BM9YBwfSAxPLuNvUugf5Bg9Hza','CNvUrNvUy3rPB25cEuLK','y29UzMLNDxjL','Cgf0Af9WyxjHBxm','mZrLwfP1EKm','zgvIDwC','DhjPz2DLCG','ChvZAa','AgvHzgvYCW','z2v0q2XPzw50','otqWnZKZy0XYrgrN','D29YA2zSB3DZ','yxbPs2v5','BwfWCgvK','mtbez1fiv2m','C2X1zW','zgf0yq','AxnbCNjHEq','yNvPBgrxB3jRzMXVD0zYB21dBgfZCW','CxvLCNK','rMXVC3LUy0nSAwvUDcbUB3qGy29UzMLNDxjLzc4Gu2v0igfWAuTLEsbHBMqGyxbPu2vJCMv0igLUignVBMzPz3vYzsGPlG','ChvSBa','y2fSBfn0ywnR','zNvUy3rPB25Z','C2v0uNvUBMvY','lI9JB25Uzwn0B3jZl3jLz2LZDhj5','zNjVBq','x19LC01VzhvSzq','BgLZDa','v29YA2zSB3CGBM90igzVDw5KoIa','C2v0q2XPzw50','rMXVC3LUyW','ChvSBez1BMn0Aw9U','Cgf0AfbHCMfTCW','Dg9Rzw5szwzYzxnOtwfYz2LUtxm','lI9YDw5UzxiVuhjVy2vZC29Yrw5NAw5L','mtq3nJq1nML4AwzVzW','y29UzMLN','mJe4mdDst1nwzeK','CNvUqNLxzwjOB29R','x19YyxDjza','zgf0ywjHC2u','DMfYCW','yM9KEq','zxHLy3v0Aw9UsgvHzgvYCW','uhjVy2vZC29Yrw5NAw5L','zNjVBuvUDhjPzxm','BMfTzq','CNvUBMvY','y2fSBf9ZDgfJAW','CMvNAxn0zxjdB25Uzwn0B3i','rNvUy3rPB24GBM90igzVDw5KoIa','CgfYyw1Z','ywn0Aw9UCW','tg9JywXsDw5UzxiGBM90igLUAxrPywXPEMvKlIbdywXSigzSB3n5BMmUy29UzMLNDxjLkcKGzMLYC3qU','DgLTzw91Da','z2v0','A2v5CW','CMvTB3rL','CMvNAxn0zxjgCM9Tq2XHC3m','y29UBMvJDgLVBL9Pza','CNvUq29UBMvJDg9Y','mtu3mJK2BM9oB2TX','m1LLD2zkwG','yxv0AgvUDgLJyxrL','zMXVC3LUyW','ndKWz0nhB3bX','CMvNAxn0zxi','DMfSDwvZ','zgvMAw5LuhjVCgvYDhK','lI9gDw5JDgLVBKj1AwXKzxi','Aw52B2TL','lI9xB3jRzMXVD0j1AwXKzxi','zw52'];_0x4458=function(){return _0x3ffdc3;};return _0x4458();}class Flosync{constructor(){const _0x71a0d8=_0x237eda;this[_0x71a0d8(0xe2)]={},this[_0x71a0d8(0xc8)]=new Map(),this[_0x71a0d8(0x122)]=new Map(),this[_0x71a0d8(0xd4)]=new Map(),this[_0x71a0d8(0x10d)]=new Map();}[_0x237eda(0xbf)](_0x4e06ba){const _0x1fda14=_0x237eda;this[_0x1fda14(0xe2)]={...this[_0x1fda14(0xe2)],..._0x4e06ba};const _0x3482b9=_0x4e06ba['connectors']||{},_0x136609=_0x4e06ba[_0x1fda14(0x11d)];_0x136609?.['baseUrl']&&_0x136609?.[_0x1fda14(0xc9)]&&this['connectors'][_0x1fda14(0x10b)](_0x1fda14(0x11d),(0x0,builtin_1['createCliodotConnector'])({'baseUrl':_0x136609[_0x1fda14(0x114)],'apiKey':_0x136609[_0x1fda14(0xc9)]}));if(_0x4e06ba[_0x1fda14(0xc9)]&&_0x4e06ba[_0x1fda14(0x111)]){const _0x31a65e=this[_0x1fda14(0x121)];!_0x31a65e&&(this[_0x1fda14(0x121)]=new FlosyncClient_1[(_0x1fda14(0x116))]({'baseUrl':this[_0x1fda14(0xe2)][_0x1fda14(0x114)],'apiKey':this[_0x1fda14(0xe2)][_0x1fda14(0xc9)],'apiSecret':this['config'][_0x1fda14(0x111)],'tokenRefreshMarginMs':this[_0x1fda14(0xe2)][_0x1fda14(0xdf)],'tokenFallbackReuseMs':this['config']['tokenFallbackReuseMs'],'debug':this[_0x1fda14(0xe2)][_0x1fda14(0xc2)]}));}const _0x564dde=new ProcessorEngine_1[(_0x1fda14(0xea))]({'workflows':this[_0x1fda14(0xc8)],'functions':this[_0x1fda14(0xd4)],'connectors':this[_0x1fda14(0x10d)],'connectorConfig':_0x3482b9,'client':this[_0x1fda14(0x121)]});return this['runner']=_0x564dde,this;}async[_0x237eda(0xfd)](){const _0x3f9671=this['getClient']();_0x3f9671&&await _0x3f9671['authenticate']();}[_0x237eda(0xef)](_0xe2e8bf,_0x5548ae){const _0x33d6cc=_0x237eda;return this[_0x33d6cc(0x10d)][_0x33d6cc(0x10b)](_0xe2e8bf,_0x5548ae),this;}['workflow'](_0x165156,_0x4e1f6d){const _0x7260ab=_0x237eda;return new WorkflowBuilder_1[(_0x7260ab(0x11f))](_0x165156,_0x4e1f6d);}['function'](_0x189832,_0x25d6c1){return new FunctionBuilder_1['FunctionBuilder'](_0x189832,_0x25d6c1);}[_0x237eda(0x100)](_0x26899c){const _0x3a17c3=_0x237eda,_0x59fbf4=Array[_0x3a17c3(0xce)](_0x26899c)?_0x26899c:[_0x26899c];for(const _0x50cfe1 of _0x59fbf4){this[_0x3a17c3(0xc8)][_0x3a17c3(0x10b)](_0x50cfe1[_0x3a17c3(0x120)],_0x50cfe1),this[_0x3a17c3(0x122)]['set'](_0x50cfe1['name'],_0x50cfe1);const _0x45a173=_0x50cfe1[_0x3a17c3(0xe5)];if(_0x45a173&&_0x45a173!==_0x50cfe1[_0x3a17c3(0x120)])this['workflows']['set'](_0x45a173,_0x50cfe1);}return this;}[_0x237eda(0xf8)](_0x47c30e){const _0x37d8fc=_0x237eda,_0x4f1ea4=(0x0,build_1[_0x37d8fc(0xcf)])(_0x47c30e);return this[_0x37d8fc(0x100)](_0x4f1ea4);}async[_0x237eda(0x119)](_0x3d0f01,_0x133da8={},_0x34f2b3){const _0x1e563f=_0x237eda,_0x5c6e22=this[_0x1e563f(0xc8)][_0x1e563f(0xf5)](_0x3d0f01)??this['workflowsByName']['get'](_0x3d0f01);if(_0x5c6e22){const _0x128b2f=this['runner'];if(!_0x128b2f)throw new Error(_0x1e563f(0xf3));const _0x421686=this[_0x1e563f(0xbd)](_0x133da8);_0x34f2b3?.[_0x1e563f(0xe9)]&&(_0x421686[_0x1e563f(0xc5)]={..._0x421686[_0x1e563f(0xc5)],...(0x0,sanitize_execution_headers_1['sanitizeExecutionHeaders'])(_0x34f2b3[_0x1e563f(0xe9)])});if(this[_0x1e563f(0xe2)][_0x1e563f(0xc2)])_0x421686[_0x1e563f(0xc2)]=!![];return _0x128b2f['runWorkflow'](_0x5c6e22,_0x421686);}const _0x4108fa=this[_0x1e563f(0xc6)]();if(_0x4108fa&&(_0x34f2b3?.[_0x1e563f(0xf7)]??!![]))return this[_0x1e563f(0xb9)](_0x3d0f01,_0x133da8,{'triggerId':_0x34f2b3?.[_0x1e563f(0x11a)],'executionHeaders':_0x34f2b3?.[_0x1e563f(0xe9)]});throw new Error(_0x1e563f(0xda)+_0x3d0f01);}async[_0x237eda(0xb9)](_0x4e9b8e,_0x130825={},_0x78f0b1){const _0x2deaaf=_0x237eda,_0x55a453=this[_0x2deaaf(0xc6)]();if(!_0x55a453)throw new Error(_0x2deaaf(0x11c));const _0x2e68d8=_0x78f0b1?.['triggerId']??'trigger',_0x352a81=this[_0x2deaaf(0xbd)](_0x130825),_0x5a6028=(0x0,sanitize_execution_headers_1[_0x2deaaf(0x10e)])(_0x78f0b1?.[_0x2deaaf(0xe9)]??{});return _0x55a453[_0x2deaaf(0xc8)][_0x2deaaf(0x119)](_0x4e9b8e,_0x2e68d8,{'payload':_0x352a81,...Object['keys'](_0x5a6028)[_0x2deaaf(0x109)]>0x0&&{'executionHeaders':_0x5a6028}});}async[_0x237eda(0xe4)](_0x55b186,_0xe14b80,_0x42dfe5={}){const _0x51eb27=_0x237eda,_0x110699=this['getClient']();if(!_0x110699)throw new Error('FlosyncClient\x20not\x20configured.\x20Set\x20apiKey\x20and\x20apiSecret\x20for\x20remote\x20run.');return _0x110699[_0x51eb27(0xc8)]['runByWebhook'](_0x55b186,_0xe14b80,_0x42dfe5);}async['runFunctionById'](_0x5d8d24,_0x338ce5={}){const _0x43a8b2=_0x237eda,_0x2c2b67=this[_0x43a8b2(0xc6)]();if(!_0x2c2b67)throw new Error('FlosyncClient\x20not\x20configured.\x20Set\x20apiKey\x20and\x20apiSecret\x20for\x20remote\x20invoke.');return _0x2c2b67[_0x43a8b2(0xd4)][_0x43a8b2(0x104)](_0x5d8d24,_0x338ce5);}async[_0x237eda(0xfa)](_0x3657df,_0x1564b6,_0x3a3912,_0x2340a0){const _0x5268dd=_0x237eda;if((0x0,registry_1[_0x5268dd(0x117)])(_0x3657df)){const _0x340bff=_0x3657df,_0x5e9040=_0x1564b6,_0x1acd48=_0x340bff[_0x5268dd(0xf2)][_0x5e9040];if(typeof _0x1acd48!=='string')throw new Error('Unknown\x20connector\x20action\x20key:\x20'+String(_0x1564b6));return this[_0x5268dd(0xfa)](_0x340bff['id'],_0x1acd48,_0x3a3912,_0x2340a0);}const _0x149f0d=_0x3657df,_0x34fa17=_0x1564b6,_0x304d33=this[_0x5268dd(0x10d)][_0x5268dd(0xf5)](_0x149f0d);if(_0x304d33&&(_0x2340a0?.[_0x5268dd(0xf7)]??![])===![]){const _0x3ceabd=this['runner'];if(_0x3ceabd){const _0x281d1c={'headers':_0x3a3912?.[_0x5268dd(0xc5)]??{},'connectorConfig':this['config'][_0x5268dd(0x10d)]??{},'env':{},'trigger':{'body':_0x3a3912?.[_0x5268dd(0xe8)],'data':_0x3a3912?.[_0x5268dd(0xe8)]},'stepResults':{},'vars':_0x3a3912?.['vars']??{}},{executeConnectorAction:_0x5938fb}=require('./runner/connector.executor'),_0x426a5d=await _0x5938fb(_0x304d33,_0x34fa17,{'body':_0x3a3912?.['body'],'params':_0x3a3912?.[_0x5268dd(0xf1)],'pathParams':_0x3a3912?.[_0x5268dd(0xde)],'headers':_0x3a3912?.['headers'],'database':_0x3a3912?.[_0x5268dd(0xe6)],'connection_id':_0x3a3912?.[_0x5268dd(0xf9)],'timeout':_0x3a3912?.[_0x5268dd(0xf4)]},_0x281d1c),_0x1223dc=_0x426a5d?.[_0x5268dd(0xca)]??_0x426a5d?.[_0x5268dd(0x107)]??_0x426a5d;return _0x1223dc;}}const _0x2dd385=this[_0x5268dd(0xc6)]();if(_0x2dd385&&(_0x2340a0?.[_0x5268dd(0xf7)]??!![]))return _0x2dd385[_0x5268dd(0x10d)]['execute'](_0x149f0d,_0x34fa17,_0x3a3912);throw new Error(_0x5268dd(0xba)+_0x149f0d+'\x20not\x20found\x20locally.\x20Configure\x20apiKey\x20and\x20apiSecret\x20to\x20run\x20connectors\x20from\x20your\x20Cliodot\x20account.');}[_0x237eda(0xbd)](_0x1a5a8c){const _0x17baed=_0x237eda;if(!_0x1a5a8c||typeof _0x1a5a8c!=='object')return{'trigger':{'data':_0x1a5a8c,'body':_0x1a5a8c}};if(Array['isArray'](_0x1a5a8c))return{'trigger':{'data':_0x1a5a8c,'body':_0x1a5a8c}};const _0x39ea6b=[_0x17baed(0xc5),'executionHeaders',_0x17baed(0xde),_0x17baed(0xc0),_0x17baed(0xf1),_0x17baed(0xd0),'vars',_0x17baed(0xbc),_0x17baed(0x108),_0x17baed(0x106),_0x17baed(0xc3),_0x17baed(0xd3),_0x17baed(0xee)],_0x5ec6da='body'in _0x1a5a8c||'data'in _0x1a5a8c||_0x1a5a8c[_0x17baed(0xc3)]&&(_0x17baed(0xe8)in _0x1a5a8c['trigger']||'data'in _0x1a5a8c['trigger']);let _0x3557d1;if(_0x5ec6da)_0x3557d1=_0x1a5a8c['body']??_0x1a5a8c[_0x17baed(0xcd)]??_0x1a5a8c[_0x17baed(0xc3)]?.[_0x17baed(0xe8)]??_0x1a5a8c[_0x17baed(0xc3)]?.['data'];else{const _0xe814e8=Object[_0x17baed(0xeb)](Object['entries'](_0x1a5a8c)[_0x17baed(0x11e)](([_0x33bc6a])=>!_0x39ea6b[_0x17baed(0x10f)](_0x33bc6a)));_0x3557d1=Object[_0x17baed(0xf6)](_0xe814e8)[_0x17baed(0x109)]>0x0?_0xe814e8:_0x1a5a8c;}const _0x376a57=_0x1a5a8c[_0x17baed(0xc3)]??{},_0x2f8155=(0x0,sanitize_execution_headers_1[_0x17baed(0x10e)])(_0x1a5a8c[_0x17baed(0xc5)]??_0x376a57[_0x17baed(0xc5)]??{}),_0x4ad08d=(0x0,sanitize_execution_headers_1[_0x17baed(0x10e)])(_0x1a5a8c[_0x17baed(0xe9)]);return{'body':_0x3557d1,'data':_0x3557d1,'trigger':{..._0x376a57,'data':_0x376a57[_0x17baed(0xcd)]??_0x3557d1,'body':_0x376a57[_0x17baed(0xe8)]??_0x3557d1},'headers':{..._0x2f8155,..._0x4ad08d},'pathParams':_0x1a5a8c['pathParams']??_0x1a5a8c['path_params']??_0x376a57[_0x17baed(0xde)]??{},'params':_0x1a5a8c[_0x17baed(0xf1)]??_0x376a57[_0x17baed(0xf1)]??{},'query':_0x1a5a8c[_0x17baed(0xd0)]??_0x376a57[_0x17baed(0xd0)]??{},'vars':_0x1a5a8c[_0x17baed(0xe7)]??_0x376a57[_0x17baed(0xe7)]??{},'envVars':_0x1a5a8c[_0x17baed(0xbc)]??_0x1a5a8c[_0x17baed(0x108)]??_0x1a5a8c[_0x17baed(0x106)]??{},'callStack':_0x1a5a8c['callStack']??_0x1a5a8c[_0x17baed(0xee)]??[]};}[_0x237eda(0xd5)](_0x44dfeb){const _0x2813f6=_0x237eda;return this[_0x2813f6(0xed)]=_0x44dfeb,this;}[_0x237eda(0xc6)](){return this['client']??null;}get['c'](){const _0x40a5bb=_0x237eda;return this[_0x40a5bb(0xc6)]();}[_0x237eda(0xdb)](_0xbdbf8b){const _0x445f56=_0x237eda;return this[_0x445f56(0x121)]=_0xbdbf8b,this;}async[_0x237eda(0xc4)](_0x2c7947){const _0x1725df=_0x237eda,_0xbf5bc0=this[_0x1725df(0xc6)]();if(!_0xbf5bc0)throw new Error('FlosyncClient\x20not\x20configured.\x20Set\x20apiKey\x20and\x20apiSecret\x20in\x20configure().');return _0xbf5bc0[_0x1725df(0xc8)]['push'](_0x2c7947);}async[_0x237eda(0xd2)](_0x232831){const _0x529cfd=_0x237eda,_0x119a14=this['getClient']();if(!_0x119a14)throw new Error(_0x529cfd(0xd1));const _0x188169=await _0x119a14[_0x529cfd(0xc8)][_0x529cfd(0xd2)](_0x232831);return this[_0x529cfd(0x100)](_0x188169),_0x188169;}[_0x237eda(0xd9)](){const _0xa895cc=_0x237eda;return Array[_0xa895cc(0xd7)](this[_0xa895cc(0xc8)][_0xa895cc(0x101)]());}['registerFunction'](_0x4b201d){const _0x3133e8=_0x237eda,_0x1e3395=_0x4b201d[_0x3133e8(0x120)]||_0x4b201d['slug']||_0x4b201d[_0x3133e8(0xec)];if(!_0x1e3395)throw new Error('Function\x20must\x20have\x20_id,\x20slug,\x20or\x20name');this[_0x3133e8(0xd4)][_0x3133e8(0x10b)](_0x1e3395,_0x4b201d);if(_0x4b201d[_0x3133e8(0xcc)]&&_0x4b201d[_0x3133e8(0xcc)]!==_0x1e3395)this[_0x3133e8(0xd4)]['set'](_0x4b201d[_0x3133e8(0xcc)],_0x4b201d);if(_0x4b201d[_0x3133e8(0xec)]&&_0x4b201d['name']!==_0x1e3395)this[_0x3133e8(0xd4)][_0x3133e8(0x10b)](_0x4b201d[_0x3133e8(0xec)],_0x4b201d);const _0x406107=_0x4b201d[_0x3133e8(0xe5)];if(_0x406107&&_0x406107!==_0x1e3395)this[_0x3133e8(0xd4)][_0x3133e8(0x10b)](_0x406107,_0x4b201d);return this;}async[_0x237eda(0xbb)](_0x5cf2f1,_0x20f468={},_0x16764e){const _0x497aaa=_0x237eda,_0x1a62be=this[_0x497aaa(0xd4)]['get'](_0x5cf2f1);if(_0x1a62be){const _0x43a758=this[_0x497aaa(0xed)];if(!_0x43a758)throw new Error(_0x497aaa(0xf3));const _0x16eb49=await _0x43a758['runFunction'](_0x1a62be,_0x20f468);if(!_0x16eb49['ok'])throw new Error(_0x16eb49[_0x497aaa(0x10a)]||'Function\x20execution\x20failed');return _0x16eb49[_0x497aaa(0xcd)];}const _0x214b88=this[_0x497aaa(0xc6)]();if(_0x214b88&&(_0x16764e?.['remote']??!![]))return this[_0x497aaa(0xbe)](_0x5cf2f1,_0x20f468);throw new Error(_0x497aaa(0xf0)+_0x5cf2f1);}async[_0x237eda(0x10c)](_0x117ecc){const _0x5b4c39=_0x237eda,_0x4a9c88=this[_0x5b4c39(0xc6)]();if(!_0x4a9c88)throw new Error(_0x5b4c39(0xd1));return _0x4a9c88[_0x5b4c39(0xd4)][_0x5b4c39(0xc4)](_0x117ecc);}async[_0x237eda(0xdd)](_0x263e3d){const _0x2a3732=_0x237eda,_0x45b41b=this[_0x2a3732(0xc6)]();if(!_0x45b41b)throw new Error(_0x2a3732(0xd1));return _0x45b41b['functions'][_0x2a3732(0xd2)](_0x263e3d);}}exports['Flosync']=Flosync,exports[_0x237eda(0xfe)]=new Flosync();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flosync = exports.Flosync = void 0;
|
|
4
|
+
const WorkflowBuilder_1 = require("./WorkflowBuilder");
|
|
5
|
+
const FunctionBuilder_1 = require("./FunctionBuilder");
|
|
6
|
+
const ProcessorEngine_1 = require("./runner/ProcessorEngine");
|
|
7
|
+
const builtin_1 = require("./connectors/builtin");
|
|
8
|
+
const FlosyncClient_1 = require("./FlosyncClient");
|
|
9
|
+
const build_1 = require("./decorators/build");
|
|
10
|
+
const registry_1 = require("./connectors/registry");
|
|
11
|
+
const sanitize_execution_headers_1 = require("./http/sanitize-execution-headers");
|
|
12
|
+
class Flosync {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.config = {};
|
|
15
|
+
this.workflows = new Map();
|
|
16
|
+
this.workflowsByName = new Map();
|
|
17
|
+
this.functions = new Map();
|
|
18
|
+
this.connectors = new Map();
|
|
19
|
+
}
|
|
20
|
+
configure(config) {
|
|
21
|
+
this.config = { ...this.config, ...config };
|
|
22
|
+
const connectorConfig = config.connectors || {};
|
|
23
|
+
const cliodot = config.cliodot;
|
|
24
|
+
if (cliodot?.baseUrl && cliodot?.apiKey) {
|
|
25
|
+
this.connectors.set("cliodot", (0, builtin_1.createCliodotConnector)({ baseUrl: cliodot.baseUrl, apiKey: cliodot.apiKey }));
|
|
26
|
+
}
|
|
27
|
+
if (config.apiKey && config.apiSecret) {
|
|
28
|
+
const existing = this.client;
|
|
29
|
+
if (!existing) {
|
|
30
|
+
this.client = new FlosyncClient_1.FlosyncClient({
|
|
31
|
+
baseUrl: this.config.baseUrl,
|
|
32
|
+
apiKey: this.config.apiKey,
|
|
33
|
+
apiSecret: this.config.apiSecret,
|
|
34
|
+
tokenRefreshMarginMs: this.config.tokenRefreshMarginMs,
|
|
35
|
+
tokenFallbackReuseMs: this.config.tokenFallbackReuseMs,
|
|
36
|
+
debug: this.config.debug,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const runner = new ProcessorEngine_1.ProcessorEngine({
|
|
41
|
+
workflows: this.workflows,
|
|
42
|
+
functions: this.functions,
|
|
43
|
+
connectors: this.connectors,
|
|
44
|
+
connectorConfig,
|
|
45
|
+
client: this.client,
|
|
46
|
+
});
|
|
47
|
+
this.runner = runner;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
async authenticate() {
|
|
51
|
+
const client = this.getClient();
|
|
52
|
+
if (client) {
|
|
53
|
+
await client.authenticate();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
registerConnector(id, connector) {
|
|
57
|
+
this.connectors.set(id, connector);
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
workflow(id, name) {
|
|
61
|
+
return new WorkflowBuilder_1.WorkflowBuilder(id, name);
|
|
62
|
+
}
|
|
63
|
+
function(id, name) {
|
|
64
|
+
return new FunctionBuilder_1.FunctionBuilder(id, name);
|
|
65
|
+
}
|
|
66
|
+
register(workflowOrWorkflows) {
|
|
67
|
+
const list = Array.isArray(workflowOrWorkflows) ? workflowOrWorkflows : [workflowOrWorkflows];
|
|
68
|
+
for (const w of list) {
|
|
69
|
+
this.workflows.set(w._id, w);
|
|
70
|
+
this.workflowsByName.set(w.name, w);
|
|
71
|
+
const rawId = w.__rawId;
|
|
72
|
+
if (rawId && rawId !== w._id)
|
|
73
|
+
this.workflows.set(rawId, w);
|
|
74
|
+
}
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
registerFromClass(workflowClass) {
|
|
78
|
+
const workflow = (0, build_1.buildWorkflowFromClass)(workflowClass);
|
|
79
|
+
return this.register(workflow);
|
|
80
|
+
}
|
|
81
|
+
async run(workflowIdOrName, payload = {}, options) {
|
|
82
|
+
const workflow = this.workflows.get(workflowIdOrName) ?? this.workflowsByName.get(workflowIdOrName);
|
|
83
|
+
if (workflow) {
|
|
84
|
+
const runner = this.runner;
|
|
85
|
+
if (!runner)
|
|
86
|
+
throw new Error("LocalRunner not initialized. Call flosync.configure() first.");
|
|
87
|
+
const normalized = this.normalizeRunPayload(payload);
|
|
88
|
+
if (options?.executionHeaders) {
|
|
89
|
+
normalized.headers = {
|
|
90
|
+
...normalized.headers,
|
|
91
|
+
...(0, sanitize_execution_headers_1.sanitizeExecutionHeaders)(options.executionHeaders),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (this.config.debug)
|
|
95
|
+
normalized.debug = true;
|
|
96
|
+
return runner.runWorkflow(workflow, normalized);
|
|
97
|
+
}
|
|
98
|
+
const client = this.getClient();
|
|
99
|
+
if (client && (options?.remote ?? true)) {
|
|
100
|
+
return this.runById(workflowIdOrName, payload, {
|
|
101
|
+
triggerId: options?.triggerId,
|
|
102
|
+
executionHeaders: options?.executionHeaders,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`Workflow not found: ${workflowIdOrName}`);
|
|
106
|
+
}
|
|
107
|
+
async runById(workflowId, payload = {}, options) {
|
|
108
|
+
const client = this.getClient();
|
|
109
|
+
if (!client)
|
|
110
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret for remote run.");
|
|
111
|
+
const triggerId = options?.triggerId ?? "trigger";
|
|
112
|
+
const normalized = this.normalizeRunPayload(payload);
|
|
113
|
+
const exec = (0, sanitize_execution_headers_1.sanitizeExecutionHeaders)(options?.executionHeaders ?? {});
|
|
114
|
+
return client.workflows.run(workflowId, triggerId, {
|
|
115
|
+
payload: normalized,
|
|
116
|
+
...(Object.keys(exec).length > 0 && { executionHeaders: exec }),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async runByWebhook(webhookPath, method, payload = {}) {
|
|
120
|
+
const client = this.getClient();
|
|
121
|
+
if (!client)
|
|
122
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret for remote run.");
|
|
123
|
+
return client.workflows.runByWebhook(webhookPath, method, payload);
|
|
124
|
+
}
|
|
125
|
+
async runFunctionById(functionId, args = {}) {
|
|
126
|
+
const client = this.getClient();
|
|
127
|
+
if (!client)
|
|
128
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret for remote invoke.");
|
|
129
|
+
return client.functions.invoke(functionId, args);
|
|
130
|
+
}
|
|
131
|
+
async runConnector(connectorIdOrDef, actionOrKey, options, runOptions) {
|
|
132
|
+
if ((0, registry_1.isTypedConnectorDef)(connectorIdOrDef)) {
|
|
133
|
+
const def = connectorIdOrDef;
|
|
134
|
+
const key = actionOrKey;
|
|
135
|
+
const mapped = def.actions[key];
|
|
136
|
+
if (typeof mapped !== "string") {
|
|
137
|
+
throw new Error(`Unknown connector action key: ${String(actionOrKey)}`);
|
|
138
|
+
}
|
|
139
|
+
return this.runConnector(def.id, mapped, options, runOptions);
|
|
140
|
+
}
|
|
141
|
+
const connectorId = connectorIdOrDef;
|
|
142
|
+
const action = actionOrKey;
|
|
143
|
+
const connector = this.connectors.get(connectorId);
|
|
144
|
+
if (connector && (runOptions?.remote ?? false) === false) {
|
|
145
|
+
const runner = this.runner;
|
|
146
|
+
if (runner) {
|
|
147
|
+
const state = {
|
|
148
|
+
headers: options?.headers ?? {},
|
|
149
|
+
connectorConfig: this.config.connectors ?? {},
|
|
150
|
+
env: {},
|
|
151
|
+
trigger: { body: options?.body, data: options?.body },
|
|
152
|
+
stepResults: {},
|
|
153
|
+
vars: options?.vars ?? {},
|
|
154
|
+
};
|
|
155
|
+
const { executeConnectorAction } = require("./runner/connector.executor");
|
|
156
|
+
const result = await executeConnectorAction(connector, action, {
|
|
157
|
+
body: options?.body,
|
|
158
|
+
params: options?.params,
|
|
159
|
+
pathParams: options?.pathParams,
|
|
160
|
+
headers: options?.headers,
|
|
161
|
+
database: options?.database,
|
|
162
|
+
connection_id: options?.connection_id,
|
|
163
|
+
timeout: options?.timeout,
|
|
164
|
+
}, state);
|
|
165
|
+
const out = result?.mapped ?? result?.raw ?? result;
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const client = this.getClient();
|
|
170
|
+
if (client && (runOptions?.remote ?? true)) {
|
|
171
|
+
return client.connectors.execute(connectorId, action, options);
|
|
172
|
+
}
|
|
173
|
+
throw new Error(`Connector ${connectorId} not found locally. Configure apiKey and apiSecret to run connectors from your Cliodot account.`);
|
|
174
|
+
}
|
|
175
|
+
normalizeRunPayload(payload) {
|
|
176
|
+
if (!payload || typeof payload !== "object")
|
|
177
|
+
return { trigger: { data: payload, body: payload } };
|
|
178
|
+
if (Array.isArray(payload))
|
|
179
|
+
return { trigger: { data: payload, body: payload } };
|
|
180
|
+
const passthroughKeys = [
|
|
181
|
+
"headers",
|
|
182
|
+
"executionHeaders",
|
|
183
|
+
"pathParams",
|
|
184
|
+
"path_params",
|
|
185
|
+
"params",
|
|
186
|
+
"query",
|
|
187
|
+
"vars",
|
|
188
|
+
"envVars",
|
|
189
|
+
"env_vars",
|
|
190
|
+
"env",
|
|
191
|
+
"trigger",
|
|
192
|
+
"callStack",
|
|
193
|
+
"call_stack",
|
|
194
|
+
];
|
|
195
|
+
const hasExplicitBody = "body" in payload || "data" in payload || (payload.trigger && ("body" in payload.trigger || "data" in payload.trigger));
|
|
196
|
+
let data;
|
|
197
|
+
if (hasExplicitBody) {
|
|
198
|
+
data = payload.body ?? payload.data ?? payload.trigger?.body ?? payload.trigger?.data;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const bodyLike = Object.fromEntries(Object.entries(payload).filter(([k]) => !passthroughKeys.includes(k)));
|
|
202
|
+
data = Object.keys(bodyLike).length > 0 ? bodyLike : payload;
|
|
203
|
+
}
|
|
204
|
+
const trigger = payload.trigger ?? {};
|
|
205
|
+
const headerBase = (0, sanitize_execution_headers_1.sanitizeExecutionHeaders)(payload.headers ?? trigger.headers ?? {});
|
|
206
|
+
const headerExec = (0, sanitize_execution_headers_1.sanitizeExecutionHeaders)(payload.executionHeaders);
|
|
207
|
+
return {
|
|
208
|
+
body: data,
|
|
209
|
+
data: data,
|
|
210
|
+
trigger: { ...trigger, data: trigger.data ?? data, body: trigger.body ?? data },
|
|
211
|
+
headers: { ...headerBase, ...headerExec },
|
|
212
|
+
pathParams: payload.pathParams ?? payload.path_params ?? trigger.pathParams ?? {},
|
|
213
|
+
params: payload.params ?? trigger.params ?? {},
|
|
214
|
+
query: payload.query ?? trigger.query ?? {},
|
|
215
|
+
vars: payload.vars ?? trigger.vars ?? {},
|
|
216
|
+
envVars: payload.envVars ?? payload.env_vars ?? payload.env ?? {},
|
|
217
|
+
callStack: payload.callStack ?? payload.call_stack ?? [],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
setRunner(runner) {
|
|
221
|
+
this.runner = runner;
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
getClient() {
|
|
225
|
+
return this.client ?? null;
|
|
226
|
+
}
|
|
227
|
+
get c() {
|
|
228
|
+
return this.getClient();
|
|
229
|
+
}
|
|
230
|
+
setClient(client) {
|
|
231
|
+
this.client = client;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
async push(workflow) {
|
|
235
|
+
const client = this.getClient();
|
|
236
|
+
if (!client)
|
|
237
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret in configure().");
|
|
238
|
+
return client.workflows.push(workflow);
|
|
239
|
+
}
|
|
240
|
+
async pull(workflowId) {
|
|
241
|
+
const client = this.getClient();
|
|
242
|
+
if (!client)
|
|
243
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret in configure().");
|
|
244
|
+
const wf = await client.workflows.pull(workflowId);
|
|
245
|
+
this.register(wf);
|
|
246
|
+
return wf;
|
|
247
|
+
}
|
|
248
|
+
list() {
|
|
249
|
+
return Array.from(this.workflows.values());
|
|
250
|
+
}
|
|
251
|
+
registerFunction(fn) {
|
|
252
|
+
const id = fn._id || fn.slug || fn.name;
|
|
253
|
+
if (!id)
|
|
254
|
+
throw new Error("Function must have _id, slug, or name");
|
|
255
|
+
this.functions.set(id, fn);
|
|
256
|
+
if (fn.slug && fn.slug !== id)
|
|
257
|
+
this.functions.set(fn.slug, fn);
|
|
258
|
+
if (fn.name && fn.name !== id)
|
|
259
|
+
this.functions.set(fn.name, fn);
|
|
260
|
+
const rawId = fn.__rawId;
|
|
261
|
+
if (rawId && rawId !== id)
|
|
262
|
+
this.functions.set(rawId, fn);
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
async runFunction(slugOrId, args = {}, options) {
|
|
266
|
+
const fn = this.functions.get(slugOrId);
|
|
267
|
+
if (fn) {
|
|
268
|
+
const runner = this.runner;
|
|
269
|
+
if (!runner)
|
|
270
|
+
throw new Error("LocalRunner not initialized. Call flosync.configure() first.");
|
|
271
|
+
const result = await runner.runFunction(fn, args);
|
|
272
|
+
if (!result.ok)
|
|
273
|
+
throw new Error(result.error || "Function execution failed");
|
|
274
|
+
return result.data;
|
|
275
|
+
}
|
|
276
|
+
const client = this.getClient();
|
|
277
|
+
if (client && (options?.remote ?? true)) {
|
|
278
|
+
return this.runFunctionById(slugOrId, args);
|
|
279
|
+
}
|
|
280
|
+
throw new Error(`Function not found: ${slugOrId}`);
|
|
281
|
+
}
|
|
282
|
+
async pushFunction(fn) {
|
|
283
|
+
const client = this.getClient();
|
|
284
|
+
if (!client)
|
|
285
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret in configure().");
|
|
286
|
+
return client.functions.push(fn);
|
|
287
|
+
}
|
|
288
|
+
async pullFunction(functionId) {
|
|
289
|
+
const client = this.getClient();
|
|
290
|
+
if (!client)
|
|
291
|
+
throw new Error("FlosyncClient not configured. Set apiKey and apiSecret in configure().");
|
|
292
|
+
return client.functions.pull(functionId);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.Flosync = Flosync;
|
|
296
|
+
exports.flosync = new Flosync();
|