cliodot 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +178 -0
  7. package/dist/CommercialAppClient.d.ts.map +1 -0
  8. package/dist/CommercialAppClient.js +576 -0
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +23 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -0
  18. package/dist/IdentityAppClient.js +197 -0
  19. package/dist/MemoryAppClient.d.ts +28 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -0
  21. package/dist/MemoryAppClient.js +149 -0
  22. package/dist/MemoryClient.d.ts +8 -0
  23. package/dist/MemoryClient.d.ts.map +1 -0
  24. package/dist/MemoryClient.js +20 -0
  25. package/dist/OAuthAppClient.d.ts +1 -0
  26. package/dist/OAuthAppClient.d.ts.map +1 -1
  27. package/dist/OAuthAppClient.js +269 -1
  28. package/dist/ProviderServicesClient.d.ts +24 -0
  29. package/dist/ProviderServicesClient.d.ts.map +1 -0
  30. package/dist/ProviderServicesClient.js +158 -0
  31. package/dist/Surface.d.ts +2 -0
  32. package/dist/Surface.d.ts.map +1 -1
  33. package/dist/Surface.js +255 -1
  34. package/dist/ValidatorBuilder.js +24 -1
  35. package/dist/Webhooks.d.ts +20 -0
  36. package/dist/Webhooks.d.ts.map +1 -0
  37. package/dist/Webhooks.js +61 -0
  38. package/dist/WorkflowBuilder.js +279 -1
  39. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  40. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  41. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  42. package/dist/__tests__/Events.test.js +191 -1
  43. package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
  44. package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
  45. package/dist/__tests__/IdentityAppClient.test.js +232 -0
  46. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  47. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  48. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  49. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  50. package/dist/__tests__/Surface.test.js +150 -1
  51. package/dist/__tests__/errors.test.js +54 -1
  52. package/dist/__tests__/function.test.js +58 -1
  53. package/dist/__tests__/helpers.d.ts +5 -0
  54. package/dist/__tests__/helpers.d.ts.map +1 -0
  55. package/dist/__tests__/helpers.js +10 -0
  56. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  57. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  58. package/dist/__tests__/localhost-lookup.test.js +26 -0
  59. package/dist/__tests__/parse-api-error.test.js +26 -1
  60. package/dist/__tests__/runner.test.js +156 -1
  61. package/dist/connectors/builtin.js +354 -1
  62. package/dist/connectors/registry.js +300 -1
  63. package/dist/decorators/build.js +105 -1
  64. package/dist/decorators/connector.js +56 -1
  65. package/dist/decorators/index.js +34 -1
  66. package/dist/decorators/metadata.js +338 -1
  67. package/dist/decorators/steps.js +220 -1
  68. package/dist/decorators/workflow.js +52 -1
  69. package/dist/errors.js +76 -1
  70. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  71. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  73. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  74. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  75. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  76. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  77. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  78. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  79. package/dist/http/cliodot-request.d.ts +35 -0
  80. package/dist/http/cliodot-request.d.ts.map +1 -0
  81. package/dist/http/cliodot-request.js +105 -0
  82. package/dist/http/cliodot-result.d.ts +40 -0
  83. package/dist/http/cliodot-result.d.ts.map +1 -0
  84. package/dist/http/cliodot-result.js +139 -0
  85. package/dist/http/create-client.d.ts +3 -0
  86. package/dist/http/create-client.d.ts.map +1 -0
  87. package/dist/http/create-client.js +14 -0
  88. package/dist/http/events-instance-id.d.ts +11 -0
  89. package/dist/http/events-instance-id.d.ts.map +1 -0
  90. package/dist/http/events-instance-id.js +86 -0
  91. package/dist/http/localhost-lookup.d.ts +12 -0
  92. package/dist/http/localhost-lookup.d.ts.map +1 -0
  93. package/dist/http/localhost-lookup.js +67 -0
  94. package/dist/http/parse-api-error.js +56 -1
  95. package/dist/http/sanitize-execution-headers.js +79 -1
  96. package/dist/identity-offline-verify.d.ts +6 -0
  97. package/dist/identity-offline-verify.d.ts.map +1 -0
  98. package/dist/identity-offline-verify.js +174 -0
  99. package/dist/identity-token-cache.d.ts +6 -0
  100. package/dist/identity-token-cache.d.ts.map +1 -0
  101. package/dist/identity-token-cache.js +51 -0
  102. package/dist/index.d.ts +10 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +108 -1
  105. package/dist/runner/ProcessorEngine.js +1311 -1
  106. package/dist/runner/connector.executor.js +1786 -1
  107. package/dist/runner/utilities/math.executor.js +153 -1
  108. package/dist/runner/utilities/random.executor.js +151 -1
  109. package/dist/runner/utilities/string.executor.js +825 -1
  110. package/dist/template.js +127 -1
  111. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  112. package/dist/transformers/WorkflowTransformer.js +189 -1
  113. package/dist/types/auth-app.api.d.ts +2 -0
  114. package/dist/types/auth-app.api.d.ts.map +1 -1
  115. package/dist/types/auth-app.api.js +2 -1
  116. package/dist/types/builtin.js +2 -1
  117. package/dist/types/client.api.js +2 -1
  118. package/dist/types/commercial-app.api.d.ts +963 -0
  119. package/dist/types/commercial-app.api.d.ts.map +1 -0
  120. package/dist/types/commercial-app.api.js +2 -0
  121. package/dist/types/connector.js +2 -1
  122. package/dist/types/context.js +2 -1
  123. package/dist/types/event-app.api.d.ts +8 -0
  124. package/dist/types/event-app.api.d.ts.map +1 -1
  125. package/dist/types/event-app.api.js +2 -1
  126. package/dist/types/function.js +2 -1
  127. package/dist/types/identity-app.api.d.ts +99 -0
  128. package/dist/types/identity-app.api.d.ts.map +1 -0
  129. package/dist/types/identity-app.api.js +2 -0
  130. package/dist/types/index.js +23 -1
  131. package/dist/types/memory-app.api.d.ts +140 -0
  132. package/dist/types/memory-app.api.d.ts.map +1 -0
  133. package/dist/types/memory-app.api.js +2 -0
  134. package/dist/types/oauth-app.api.d.ts +2 -0
  135. package/dist/types/oauth-app.api.d.ts.map +1 -1
  136. package/dist/types/oauth-app.api.js +105 -1
  137. package/dist/types/provider-services.api.d.ts +98 -0
  138. package/dist/types/provider-services.api.d.ts.map +1 -0
  139. package/dist/types/provider-services.api.js +2 -0
  140. package/dist/types/validator.js +2 -1
  141. package/dist/types/webhook-app.api.d.ts +2 -0
  142. package/dist/types/webhook-app.api.d.ts.map +1 -0
  143. package/dist/types/webhook-app.api.js +2 -0
  144. package/dist/types/workflow.js +33 -1
  145. package/dist/validators/validators.js +478 -1
  146. package/dist/variable.js +37 -1
  147. package/package.json +3 -2
@@ -1 +1,54 @@
1
- 'use strict';function _0x5d44(_0x9a4ef0,_0x531e29){_0x9a4ef0=_0x9a4ef0-0x150;const _0x34b5f9=_0x34b5();let _0x5d449c=_0x34b5f9[_0x9a4ef0];if(_0x5d44['hQLRnE']===undefined){var _0x2aee4a=function(_0x5b927e){const _0x5c409d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1e0e92='',_0x43723b='';for(let _0x2cd144=0x0,_0xb35d0a,_0x29f03d,_0x32e02d=0x0;_0x29f03d=_0x5b927e['charAt'](_0x32e02d++);~_0x29f03d&&(_0xb35d0a=_0x2cd144%0x4?_0xb35d0a*0x40+_0x29f03d:_0x29f03d,_0x2cd144++%0x4)?_0x1e0e92+=String['fromCharCode'](0xff&_0xb35d0a>>(-0x2*_0x2cd144&0x6)):0x0){_0x29f03d=_0x5c409d['indexOf'](_0x29f03d);}for(let _0x59d738=0x0,_0x320552=_0x1e0e92['length'];_0x59d738<_0x320552;_0x59d738++){_0x43723b+='%'+('00'+_0x1e0e92['charCodeAt'](_0x59d738)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x43723b);};_0x5d44['aurhVi']=_0x2aee4a,_0x5d44['WpDKug']={},_0x5d44['hQLRnE']=!![];}const _0x1dd10b=_0x34b5f9[0x0],_0x4b3297=_0x9a4ef0+_0x1dd10b,_0x45e475=_0x5d44['WpDKug'][_0x4b3297];return!_0x45e475?(_0x5d449c=_0x5d44['aurhVi'](_0x5d449c),_0x5d44['WpDKug'][_0x4b3297]=_0x5d449c):_0x5d449c=_0x45e475,_0x5d449c;}const _0x16314c=_0x5d44;(function(_0xa4996d,_0x4a01ac){const _0x42438d=_0x5d44,_0x49239d=_0xa4996d();while(!![]){try{const _0x3cdbff=-parseInt(_0x42438d(0x159))/0x1*(-parseInt(_0x42438d(0x16e))/0x2)+parseInt(_0x42438d(0x152))/0x3+-parseInt(_0x42438d(0x153))/0x4*(-parseInt(_0x42438d(0x15a))/0x5)+-parseInt(_0x42438d(0x16d))/0x6*(parseInt(_0x42438d(0x150))/0x7)+parseInt(_0x42438d(0x15f))/0x8*(parseInt(_0x42438d(0x160))/0x9)+-parseInt(_0x42438d(0x15e))/0xa+parseInt(_0x42438d(0x162))/0xb;if(_0x3cdbff===_0x4a01ac)break;else _0x49239d['push'](_0x49239d['shift']());}catch(_0x128938){_0x49239d['push'](_0x49239d['shift']());}}}(_0x34b5,0x79072));Object[_0x16314c(0x173)](exports,_0x16314c(0x156),{'value':!![]});function _0x34b5(){const _0x1c28f4=['Dg9czuLUC3rHBMnLt2y','zgf0yq','mZy4mKLqAxvNAW','mJqYndK1AK1Mq3Ds','l3yXl3n1yNnJCMLIzs94','BwvZC2fNzq','CgfYC2u','mJyXotCXmeXjBxHAsW','oe5rueHQvG','mta1ndG5rev2sef3','BM90','ndqXmZm4n2XRv0HkCa','rvzftLrFu1vcu0nssujfuL9ot1rFrK9vtKq','tM9Wzq','Dg9fCxvHBa','zgvSzxrL','lI4VzxjYB3jZ','Dw53CMfWCYbHEgLVCY1SAwTLihjLC3bVBNnLig9WDgLVBIbPzIbWyxnZzwqGDg8Gy29UC3rYDwn0B3i','Dg9iyxzLuhjVCgvYDhK','tM90iezVDw5K','C3rHDhvZ','uMvXDwvZDcbMywLSzwqGD2L0AcbZDgf0DxmGy29Kzsa0mdq','nJy1nhrgBvDoDW','mZzNB1zmDeG','uMvXDwvZDcbMywLSzwq','AgvHzgvYCW','CMvZCg9UC2u','u3vIC2nYAxb0Aw9Uig5VDcbMB3vUza','zgvMAw5LuhjVCgvYDhK','nda4muLqyNLMtW','yxbWBgLJyxrPB24VANnVBG','mJyYotyWnxfTvgfTDG','ngPpBvzhwq','Dg9czq','q2XPB2rVDefWAuvYCM9Y','x19LC01VzhvSzq'];_0x34b5=function(){return _0x1c28f4;};return _0x34b5();}const errors_1=require(_0x16314c(0x167));describe(_0x16314c(0x155),()=>{const _0x3bbc64=_0x16314c;it('exposes\x20only\x20API\x20body\x20on\x20response/data\x20from\x20axios\x20errors',()=>{const _0x522f59=_0x5d44,_0x1e0e92={'ok':![],'error':_0x522f59(0x172),'code':'EVENT_SUBSCRIBER_NOT_FOUND'},_0x43723b=(0x0,errors_1['cliodotApiErrorFromAxios'])({'message':_0x522f59(0x16c),'response':{'status':0x194,'statusText':_0x522f59(0x16a),'headers':{'content-type':_0x522f59(0x151)},'config':{'url':_0x522f59(0x15b),'method':_0x522f59(0x166)},'request':{},'data':_0x1e0e92}},_0x522f59(0x16f));expect(_0x43723b)[_0x522f59(0x157)](errors_1[_0x522f59(0x155)]),expect(_0x43723b['status'])[_0x522f59(0x154)](0x194),expect(_0x43723b[_0x522f59(0x15c)])['toBe'](_0x522f59(0x172)),expect(_0x43723b['code'])[_0x522f59(0x154)](_0x522f59(0x163)),expect(_0x43723b[_0x522f59(0x171)])['toEqual'](_0x1e0e92),expect(_0x43723b[_0x522f59(0x158)])[_0x522f59(0x165)](_0x1e0e92),expect(_0x43723b['response'])['not'][_0x522f59(0x169)]('config'),expect(_0x43723b[_0x522f59(0x171)])[_0x522f59(0x161)][_0x522f59(0x169)](_0x522f59(0x170)),expect(_0x43723b[_0x522f59(0x171)])['not']['toHaveProperty']('request'),expect(JSON[_0x522f59(0x15d)](JSON['stringify'](_0x43723b)))[_0x522f59(0x165)]({'name':'CliodotApiError','message':'Subscription\x20not\x20found','status':0x194,'code':_0x522f59(0x163),'data':_0x1e0e92,'response':_0x1e0e92});}),it(_0x3bbc64(0x168),()=>{const _0x59b7a1=_0x3bbc64,_0x2cd144={'ok':![],'error':_0x59b7a1(0x164),'code':'X'},_0xb35d0a=new errors_1[(_0x59b7a1(0x155))](_0x59b7a1(0x164),{'response':{'status':0x190,'headers':{},'config':{},'data':_0x2cd144}});expect(_0xb35d0a['response'])[_0x59b7a1(0x165)](_0x2cd144),expect(_0xb35d0a[_0x59b7a1(0x158)])[_0x59b7a1(0x165)](_0x2cd144),expect(_0xb35d0a[_0x59b7a1(0x16b)])[_0x59b7a1(0x154)](0x190);});});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const errors_1 = require("../errors");
4
+ describe("CliodotApiError", () => {
5
+ it("exposes only API body on response/data from axios errors", () => {
6
+ const body = {
7
+ ok: false,
8
+ error: "Subscription not found",
9
+ code: "EVENT_SUBSCRIBER_NOT_FOUND",
10
+ };
11
+ const err = (0, errors_1.cliodotApiErrorFromAxios)({
12
+ message: "Request failed with status code 404",
13
+ response: {
14
+ status: 404,
15
+ statusText: "Not Found",
16
+ headers: { "content-type": "application/json" },
17
+ config: { url: "/v1/subscribe/x", method: "delete" },
18
+ request: {},
19
+ data: body,
20
+ },
21
+ }, "Request failed");
22
+ expect(err).toBeInstanceOf(errors_1.CliodotApiError);
23
+ expect(err.status).toBe(404);
24
+ expect(err.message).toBe("Subscription not found");
25
+ expect(err.code).toBe("EVENT_SUBSCRIBER_NOT_FOUND");
26
+ expect(err.response).toEqual(body);
27
+ expect(err.data).toEqual(body);
28
+ expect(err.response).not.toHaveProperty("config");
29
+ expect(err.response).not.toHaveProperty("headers");
30
+ expect(err.response).not.toHaveProperty("request");
31
+ expect(JSON.parse(JSON.stringify(err))).toEqual({
32
+ name: "CliodotApiError",
33
+ message: "Subscription not found",
34
+ status: 404,
35
+ code: "EVENT_SUBSCRIBER_NOT_FOUND",
36
+ data: body,
37
+ response: body,
38
+ });
39
+ });
40
+ it("unwraps axios-like response option if passed to constructor", () => {
41
+ const body = { ok: false, error: "Nope", code: "X" };
42
+ const err = new errors_1.CliodotApiError("Nope", {
43
+ response: {
44
+ status: 400,
45
+ headers: {},
46
+ config: {},
47
+ data: body,
48
+ },
49
+ });
50
+ expect(err.response).toEqual(body);
51
+ expect(err.data).toEqual(body);
52
+ expect(err.status).toBe(400);
53
+ });
54
+ });
@@ -1 +1,58 @@
1
- 'use strict';const _0x15d128=_0x975e;(function(_0x3ac67d,_0x27e926){const _0x306ccc=_0x975e,_0x2ded6e=_0x3ac67d();while(!![]){try{const _0x236964=-parseInt(_0x306ccc(0x103))/0x1*(parseInt(_0x306ccc(0x100))/0x2)+-parseInt(_0x306ccc(0x106))/0x3+parseInt(_0x306ccc(0xe1))/0x4*(-parseInt(_0x306ccc(0xfb))/0x5)+parseInt(_0x306ccc(0xd7))/0x6+-parseInt(_0x306ccc(0x10a))/0x7+-parseInt(_0x306ccc(0x104))/0x8+-parseInt(_0x306ccc(0xdb))/0x9*(-parseInt(_0x306ccc(0xf6))/0xa);if(_0x236964===_0x27e926)break;else _0x2ded6e['push'](_0x2ded6e['shift']());}catch(_0x1decdd){_0x2ded6e['push'](_0x2ded6e['shift']());}}}(_0x381b,0xa7d7b));Object['defineProperty'](exports,_0x15d128(0xec),{'value':!![]});const index_1=require(_0x15d128(0xf7));describe(_0x15d128(0xd6),()=>{const _0x521ae8=_0x15d128;beforeEach(()=>{const _0x48411e=_0x975e;index_1['flosync'][_0x48411e(0xf4)]({'connectors':{}});}),it(_0x521ae8(0xdc),async()=>{const _0x3f784e=_0x521ae8,_0x3e331d=index_1[_0x3f784e(0xfa)][_0x3f784e(0xe8)](_0x3f784e(0xfd))[_0x3f784e(0xe6)]({'amount':_0x3f784e(0xdd),'currency':_0x3f784e(0xfe)})[_0x3f784e(0x102)](_0x3f784e(0xe0),_0x43f364=>_0x43f364[_0x3f784e(0xf1)]({'amount':'{{\x20args.amount\x20}}','currency':_0x3f784e(0xed)}))[_0x3f784e(0x102)]('format',_0x57a9ef=>_0x57a9ef[_0x3f784e(0xe9)]({'valid':_0x3f784e(0x105),'amount':_0x3f784e(0xeb)}))[_0x3f784e(0x101)](_0x3f784e(0xe3))[_0x3f784e(0xda)]();index_1[_0x3f784e(0xfa)][_0x3f784e(0xde)](_0x3e331d);const _0x55bd5c=await index_1[_0x3f784e(0xfa)][_0x3f784e(0xe5)](_0x3f784e(0xfd),{'amount':0x64,'currency':_0x3f784e(0xea)});expect(_0x55bd5c)[_0x3f784e(0xd8)](),expect(_0x55bd5c[_0x3f784e(0x108)])[_0x3f784e(0xe7)](!![]),expect(_0x55bd5c[_0x3f784e(0xff)])[_0x3f784e(0xe7)](0x64);}),it(_0x521ae8(0x107),async()=>{const _0x56db23=_0x521ae8,_0x546907=index_1[_0x56db23(0xfa)][_0x56db23(0xe8)](_0x56db23(0xfd))[_0x56db23(0xe6)]({'amount':'number','currency':_0x56db23(0xfe)})[_0x56db23(0x102)](_0x56db23(0xe3),_0x35614e=>_0x35614e['transform']({'valid':'true','amount':'{{\x20args.amount\x20}}','currency':_0x56db23(0xed)}))[_0x56db23(0x101)](_0x56db23(0xe3))[_0x56db23(0xda)]();index_1[_0x56db23(0xfa)][_0x56db23(0xde)](_0x546907);const _0x1575f1=index_1[_0x56db23(0xfa)]['workflow'](_0x56db23(0x109))['http'](_0x56db23(0xd5),_0x56db23(0xf8))[_0x56db23(0x102)](_0x56db23(0xe0),_0x2c70ab=>_0x2c70ab[_0x56db23(0xe4)](_0x56db23(0xfd),{'amount':_0x56db23(0xf9),'currency':_0x56db23(0xe2)}))[_0x56db23(0x102)](_0x56db23(0xfc),_0x375eb0=>_0x375eb0[_0x56db23(0xee)](_0x56db23(0xdf),{'body':_0x56db23(0xd9)}))[_0x56db23(0xda)]();index_1['flosync'][_0x56db23(0xf3)](_0x1575f1);const _0x537115=await index_1[_0x56db23(0xfa)][_0x56db23(0xf5)](_0x56db23(0x109),{'body':{'amount':0x32,'currency':_0x56db23(0xf2)}});expect(_0x537115[_0x56db23(0xef)])[_0x56db23(0xe7)](0xc8),expect(_0x537115[_0x56db23(0xf0)][_0x56db23(0x108)])[_0x56db23(0xd8)](),expect(_0x537115['body'][_0x56db23(0x108)])['toBeTruthy'](),expect(Number(_0x537115[_0x56db23(0xf0)][_0x56db23(0xff)]))[_0x56db23(0xe7)](0x32);});});function _0x975e(_0x4dda79,_0x5da116){_0x4dda79=_0x4dda79-0xd5;const _0x381b9e=_0x381b();let _0x975e1a=_0x381b9e[_0x4dda79];if(_0x975e['HDQudX']===undefined){var _0x5730b3=function(_0x3f32af){const _0x1b4e4d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3e331d='',_0x55bd5c='';for(let _0x43f364=0x0,_0x57a9ef,_0x546907,_0x1575f1=0x0;_0x546907=_0x3f32af['charAt'](_0x1575f1++);~_0x546907&&(_0x57a9ef=_0x43f364%0x4?_0x57a9ef*0x40+_0x546907:_0x546907,_0x43f364++%0x4)?_0x3e331d+=String['fromCharCode'](0xff&_0x57a9ef>>(-0x2*_0x43f364&0x6)):0x0){_0x546907=_0x1b4e4d['indexOf'](_0x546907);}for(let _0x537115=0x0,_0x35614e=_0x3e331d['length'];_0x537115<_0x35614e;_0x537115++){_0x55bd5c+='%'+('00'+_0x3e331d['charCodeAt'](_0x537115)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x55bd5c);};_0x975e['WqLvRH']=_0x5730b3,_0x975e['aDvOGO']={},_0x975e['HDQudX']=!![];}const _0x866d58=_0x381b9e[0x0],_0x5a681d=_0x4dda79+_0x866d58,_0x1ffe19=_0x975e['aDvOGO'][_0x5a681d];return!_0x1ffe19?(_0x975e1a=_0x975e['WqLvRH'](_0x975e1a),_0x975e['aDvOGO'][_0x5a681d]=_0x975e1a):_0x975e1a=_0x1ffe19,_0x975e1a;}function _0x381b(){const _0x123556=['DMfSAwrHDguTCgf5BwvUDa','C3rYAw5N','yw1VDw50','mtb6vMrgAeq','B3v0Chv0rNjVBq','C3rLCa','mJi1mdqXC2vVzezx','mtyWodi5nLv2yunWra','E3SGC3rLCfjLC3vSDhmUDMfSAwrHDguUDMfSAwqGFx0','mtGYmZq4mxHWBgXrzq','DxnLCYbMDw5JDgLVBIbPBIb3B3jRzMXVDYb2AweGy2fSBcbZDgvW','DMfSAwq','Cgf5BwvUDc1MBg93','ndq2nJy1mvfeuMrcBW','ue9tva','rNvUy3rPB25cDwLSzgvY','odeWmduXmeX1rvrIvq','Dg9czurLzMLUzwq','E3SGC3rLCfjLC3vSDhmUDMfSAwrHDguGFx0','yNvPBgq','nJnJAujeAe0','y3jLyxrLCYbHBMqGCNvUCYbHigz1BMn0Aw9UihDPDgGGDhjHBNnMB3jTigfUzcbVDxrWDxrgCM9T','BNvTyMvY','CMvNAxn0zxjgDw5JDgLVBG','ANnVBG','DMfSAwrHDgu','mZG1nJr3zMjPuxq','E3SGDhjPz2DLCI5IB2r5lMn1CNjLBMn5ih19','zM9YBwf0','y2fSBa','CNvUrNvUy3rPB24','Aw5WDxq','Dg9czq','zNvUy3rPB24','DhjHBNnMB3jT','vvne','E3SGyxjNCY5HBw91BNqGFx0','x19LC01VzhvSzq','E3SGyxjNCY5JDxjYzw5JEsb9Fq','CMvZCg9UzgvY','C3rHDhvZq29Kzq','yM9KEq','DMfSAwrHDg9Y','tKDo','CMvNAxn0zxi','y29UzMLNDxjL','CNvU','mZq4ntq1mhPYuKvWEq','lI4VAw5KzxG','l3bHEq','E3SGDhjPz2DLCI5IB2r5lMfTB3vUDcb9Fq','zMXVC3LUyW','mJC1Du5lCwfq','CMvZCg9Uza'];_0x381b=function(){return _0x123556;};return _0x381b();}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("../index");
4
+ describe("FunctionBuilder", () => {
5
+ beforeEach(() => {
6
+ index_1.flosync.configure({ connectors: {} });
7
+ });
8
+ it("creates and runs a function with transform and outputFrom", async () => {
9
+ const validatePayment = index_1.flosync
10
+ .function("validate-payment")
11
+ .input({ amount: "number", currency: "string" })
12
+ .step("validate", (s) => s.validator({ amount: "{{ args.amount }}", currency: "{{ args.currency }}" }))
13
+ .step("format", (s) => s.transform({
14
+ valid: "{{ stepResults.validate.valid }}",
15
+ amount: "{{ args.amount }}",
16
+ }))
17
+ .outputFrom("format")
18
+ .build();
19
+ index_1.flosync.registerFunction(validatePayment);
20
+ const result = await index_1.flosync.runFunction("validate-payment", {
21
+ amount: 100,
22
+ currency: "USD",
23
+ });
24
+ expect(result).toBeDefined();
25
+ expect(result.valid).toBe(true);
26
+ expect(result.amount).toBe(100);
27
+ });
28
+ it("uses function in workflow via call step", async () => {
29
+ const validatePayment = index_1.flosync
30
+ .function("validate-payment")
31
+ .input({ amount: "number", currency: "string" })
32
+ .step("format", (s) => s.transform({
33
+ valid: "true",
34
+ amount: "{{ args.amount }}",
35
+ currency: "{{ args.currency }}",
36
+ }))
37
+ .outputFrom("format")
38
+ .build();
39
+ index_1.flosync.registerFunction(validatePayment);
40
+ const w = index_1.flosync
41
+ .workflow("payment-flow")
42
+ .http("POST", "/pay")
43
+ .step("validate", (s) => s.call("validate-payment", {
44
+ amount: "{{ trigger.body.amount }}",
45
+ currency: "{{ trigger.body.currency }}",
46
+ }))
47
+ .step("respond", (s) => s.responder("json", { body: "{{ stepResults.validate }}" }))
48
+ .build();
49
+ index_1.flosync.register(w);
50
+ const result = await index_1.flosync.run("payment-flow", {
51
+ body: { amount: 50, currency: "NGN" },
52
+ });
53
+ expect(result.statusCode).toBe(200);
54
+ expect(result.body.valid).toBeDefined();
55
+ expect(result.body.valid).toBeTruthy();
56
+ expect(Number(result.body.amount)).toBe(50);
57
+ });
58
+ });
@@ -0,0 +1,5 @@
1
+ import { type CliodotMethodResult } from "../http/cliodot-result";
2
+ export declare function assertOk<T extends object>(result: CliodotMethodResult<T>): asserts result is Extract<CliodotMethodResult<T>, {
3
+ ok: true;
4
+ }>;
5
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAKjE"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertOk = assertOk;
4
+ const cliodot_result_1 = require("../http/cliodot-result");
5
+ function assertOk(result) {
6
+ expect((0, cliodot_result_1.isCliodotOk)(result)).toBe(true);
7
+ if ((0, cliodot_result_1.isCliodotFail)(result)) {
8
+ throw new Error(`${result.error.code}: ${result.error.message}`);
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=localhost-lookup.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localhost-lookup.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/localhost-lookup.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const localhost_lookup_1 = require("../http/localhost-lookup");
4
+ describe("localhostAwareLookup", () => {
5
+ it("treats localhost and *.localhost as loopback", () => {
6
+ expect((0, localhost_lookup_1.isLoopbackHostname)("localhost")).toBe(true);
7
+ expect((0, localhost_lookup_1.isLoopbackHostname)("flash.localhost")).toBe(true);
8
+ expect((0, localhost_lookup_1.isLoopbackHostname)("FLASH.LOCALHOST")).toBe(true);
9
+ expect((0, localhost_lookup_1.isLoopbackHostname)("api.example.com")).toBe(false);
10
+ });
11
+ it("resolves *.localhost to 127.0.0.1 without DNS", (done) => {
12
+ (0, localhost_lookup_1.localhostAwareLookup)("flash.localhost", {}, (err, address, family) => {
13
+ expect(err).toBeNull();
14
+ expect(address).toBe("127.0.0.1");
15
+ expect(family).toBe(4);
16
+ done();
17
+ });
18
+ });
19
+ it("supports all:true lookups", (done) => {
20
+ (0, localhost_lookup_1.localhostAwareLookup)("flash.localhost", { all: true }, (err, address) => {
21
+ expect(err).toBeNull();
22
+ expect(address).toEqual([{ address: "127.0.0.1", family: 4 }]);
23
+ done();
24
+ });
25
+ });
26
+ });
@@ -1 +1,26 @@
1
- 'use strict';const _0x21a56b=_0x43f2;(function(_0x7bdd65,_0xbb3206){const _0xc8a908=_0x43f2,_0x5396eb=_0x7bdd65();while(!![]){try{const _0x5d264=parseInt(_0xc8a908(0x1de))/0x1+parseInt(_0xc8a908(0x1da))/0x2+-parseInt(_0xc8a908(0x1e0))/0x3+parseInt(_0xc8a908(0x1e7))/0x4+-parseInt(_0xc8a908(0x1dd))/0x5*(-parseInt(_0xc8a908(0x1d3))/0x6)+-parseInt(_0xc8a908(0x1e3))/0x7+-parseInt(_0xc8a908(0x1e6))/0x8;if(_0x5d264===_0xbb3206)break;else _0x5396eb['push'](_0x5396eb['shift']());}catch(_0x2e4072){_0x5396eb['push'](_0x5396eb['shift']());}}}(_0x1e5a,0x517bf));Object[_0x21a56b(0x1db)](exports,_0x21a56b(0x1e4),{'value':!![]});const parse_api_error_1=require(_0x21a56b(0x1d9));function _0x43f2(_0x5b8669,_0x242a16){_0x5b8669=_0x5b8669-0x1d3;const _0x1e5ac6=_0x1e5a();let _0x43f2bc=_0x1e5ac6[_0x5b8669];if(_0x43f2['YieEEY']===undefined){var _0x301b06=function(_0x4dbb8e){const _0x48950f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xef2adf='',_0x4aa4ce='';for(let _0x18c6ec=0x0,_0x4219d3,_0x448ef3,_0x24d8a9=0x0;_0x448ef3=_0x4dbb8e['charAt'](_0x24d8a9++);~_0x448ef3&&(_0x4219d3=_0x18c6ec%0x4?_0x4219d3*0x40+_0x448ef3:_0x448ef3,_0x18c6ec++%0x4)?_0xef2adf+=String['fromCharCode'](0xff&_0x4219d3>>(-0x2*_0x18c6ec&0x6)):0x0){_0x448ef3=_0x48950f['indexOf'](_0x448ef3);}for(let _0x5f3ec6=0x0,_0x4d91b3=_0xef2adf['length'];_0x5f3ec6<_0x4d91b3;_0x5f3ec6++){_0x4aa4ce+='%'+('00'+_0xef2adf['charCodeAt'](_0x5f3ec6)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4aa4ce);};_0x43f2['fIteJv']=_0x301b06,_0x43f2['YAtMof']={},_0x43f2['YieEEY']=!![];}const _0x558a8b=_0x1e5ac6[0x0],_0x27df5b=_0x5b8669+_0x558a8b,_0x2457c2=_0x43f2['YAtMof'][_0x27df5b];return!_0x2457c2?(_0x43f2bc=_0x43f2['fIteJv'](_0x43f2bc),_0x43f2['YAtMof'][_0x27df5b]=_0x43f2bc):_0x43f2bc=_0x2457c2,_0x43f2bc;}function _0x1e5a(){const _0x4f20fc=['CgfYC2vbCgLfCNjVCK1LC3nHz2u','CgfYC2vbCgLfCNjVCG','t0fvveHFrvHdsefor0vFq09erv9jtLzbteLe','CgfYC2vbCgLfCNjVCLn0yxr1CW','lI4VAhr0Cc9WyxjZzs1HCgKTzxjYB3i','ntG0mZCWr1bsz3rR','zgvMAw5LuhjVCgvYDhK','Dg9czq','mtm1wu5bEg1q','mJu3nZC5BLzLyLft','CgfYC2vbCgLfCNjVCKnVzgu','ndu1mZC5whfvwM1M','sw52ywXPzcbVCIbLEhbPCMvKigv4y2HHBMDLignVzgu','CMvHzhmGC3rYAw5NigvYCM9YigzPzwXK','ndq0ode2nejsrgDWqq','x19LC01VzhvSzq','tM8GCMvMCMvZAcb0B2TLBIbHDMfPBgfIBguGzM9YihrOAxmGy29UBMvJDgLVBG','ndeWndG0mfb4BLHura','mJy2mZiYog1ty1zPqW','oti5nJrttMTcDNm','t0fvveHFufjpvKLervjFrvjst1i'];_0x1e5a=function(){return _0x4f20fc;};return _0x1e5a();}describe(_0x21a56b(0x1d6),()=>{const _0x3127ff=_0x21a56b;it('prefers\x20top-level\x20message\x20over\x20nested\x20error\x20object',()=>{const _0x318ed2=_0x43f2,_0xef2adf={'message':_0x318ed2(0x1e5),'status':![],'statusCode':0x1a6,'data':null,'error':{'statusCode':0x1a6,'code':'OAUTH_PROVIDER_ERROR'}};expect((0x0,parse_api_error_1[_0x318ed2(0x1d5)])(_0xef2adf))[_0x318ed2(0x1dc)]('No\x20refresh\x20token\x20available\x20for\x20this\x20connection'),expect((0x0,parse_api_error_1[_0x318ed2(0x1df)])(_0xef2adf))[_0x318ed2(0x1dc)](_0x318ed2(0x1d4)),expect((0x0,parse_api_error_1[_0x318ed2(0x1d8)])(_0xef2adf))[_0x318ed2(0x1dc)](0x1a6);}),it(_0x3127ff(0x1e2),()=>{const _0x20f04d=_0x3127ff,_0x4aa4ce={'ok':![],'error':_0x20f04d(0x1e1),'code':_0x20f04d(0x1d7)};expect((0x0,parse_api_error_1[_0x20f04d(0x1d5)])(_0x4aa4ce))[_0x20f04d(0x1dc)](_0x20f04d(0x1e1)),expect((0x0,parse_api_error_1[_0x20f04d(0x1df)])(_0x4aa4ce))['toBe'](_0x20f04d(0x1d7));});});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const parse_api_error_1 = require("../http/parse-api-error");
4
+ describe("parseApiError", () => {
5
+ it("prefers top-level message over nested error object", () => {
6
+ const data = {
7
+ message: "No refresh token available for this connection",
8
+ status: false,
9
+ statusCode: 422,
10
+ data: null,
11
+ error: { statusCode: 422, code: "OAUTH_PROVIDER_ERROR" },
12
+ };
13
+ expect((0, parse_api_error_1.parseApiErrorMessage)(data)).toBe("No refresh token available for this connection");
14
+ expect((0, parse_api_error_1.parseApiErrorCode)(data)).toBe("OAUTH_PROVIDER_ERROR");
15
+ expect((0, parse_api_error_1.parseApiErrorStatus)(data)).toBe(422);
16
+ });
17
+ it("reads string error field", () => {
18
+ const data = {
19
+ ok: false,
20
+ error: "Invalid or expired exchange code",
21
+ code: "OAUTH_EXCHANGE_CODE_INVALID",
22
+ };
23
+ expect((0, parse_api_error_1.parseApiErrorMessage)(data)).toBe("Invalid or expired exchange code");
24
+ expect((0, parse_api_error_1.parseApiErrorCode)(data)).toBe("OAUTH_EXCHANGE_CODE_INVALID");
25
+ });
26
+ });
@@ -1 +1,156 @@
1
- 'use strict';const _0x3bef7d=_0x318a;(function(_0x2940c1,_0x2d840c){const _0x26dcdc=_0x318a,_0x58977c=_0x2940c1();while(!![]){try{const _0x246ac9=parseInt(_0x26dcdc(0x84))/0x1+parseInt(_0x26dcdc(0x92))/0x2*(parseInt(_0x26dcdc(0xce))/0x3)+-parseInt(_0x26dcdc(0x8b))/0x4+-parseInt(_0x26dcdc(0xcb))/0x5+-parseInt(_0x26dcdc(0x8e))/0x6+parseInt(_0x26dcdc(0xa5))/0x7*(parseInt(_0x26dcdc(0xc4))/0x8)+parseInt(_0x26dcdc(0xc9))/0x9;if(_0x246ac9===_0x2d840c)break;else _0x58977c['push'](_0x58977c['shift']());}catch(_0x45d075){_0x58977c['push'](_0x58977c['shift']());}}}(_0x1b75,0xcd59d));function _0x318a(_0x28f687,_0x393d57){_0x28f687=_0x28f687-0x7c;const _0x1b7541=_0x1b75();let _0x318a12=_0x1b7541[_0x28f687];if(_0x318a['fPHFUI']===undefined){var _0x27a8a9=function(_0x3296a1){const _0xcb1c7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x30ac9d='',_0x9e123='';for(let _0x7233a6=0x0,_0x52398e,_0x701d53,_0x54c8f1=0x0;_0x701d53=_0x3296a1['charAt'](_0x54c8f1++);~_0x701d53&&(_0x52398e=_0x7233a6%0x4?_0x52398e*0x40+_0x701d53:_0x701d53,_0x7233a6++%0x4)?_0x30ac9d+=String['fromCharCode'](0xff&_0x52398e>>(-0x2*_0x7233a6&0x6)):0x0){_0x701d53=_0xcb1c7['indexOf'](_0x701d53);}for(let _0x4cae04=0x0,_0x58d9df=_0x30ac9d['length'];_0x4cae04<_0x58d9df;_0x4cae04++){_0x9e123+='%'+('00'+_0x30ac9d['charCodeAt'](_0x4cae04)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x9e123);};_0x318a['OtGDic']=_0x27a8a9,_0x318a['CCzNtZ']={},_0x318a['fPHFUI']=!![];}const _0x5c5f85=_0x1b7541[0x0],_0x4538c2=_0x28f687+_0x5c5f85,_0x8064d2=_0x318a['CCzNtZ'][_0x4538c2];return!_0x8064d2?(_0x318a12=_0x318a['OtGDic'](_0x318a12),_0x318a['CCzNtZ'][_0x4538c2]=_0x318a12):_0x318a12=_0x8064d2,_0x318a12;}Object[_0x3bef7d(0x7f)](exports,_0x3bef7d(0xa6),{'value':!![]});const index_1=require(_0x3bef7d(0xbc));describe(_0x3bef7d(0xb1),()=>{const _0x521548=_0x3bef7d;beforeEach(()=>{const _0x4a704e=_0x318a;index_1[_0x4a704e(0x7e)]['configure']({'connectors':{}});}),it(_0x521548(0xbd),async()=>{const _0x361dbc=_0x521548,_0x30ac9d=index_1[_0x361dbc(0x7e)][_0x361dbc(0x7d)](_0x361dbc(0x81))['http']('POST',_0x361dbc(0xb8))['step'](_0x361dbc(0xc6),_0x7233a6=>_0x7233a6['validator']({'amount':_0x361dbc(0xc7),'currency':'{{\x20trigger.body.currency\x20}}'}))[_0x361dbc(0xc3)](_0x361dbc(0xcf),_0x52398e=>_0x52398e[_0x361dbc(0xd6)]('json',{'statusCode':0xc8,'body':_0x361dbc(0xcc)}))[_0x361dbc(0xc8)]();index_1[_0x361dbc(0x7e)]['register'](_0x30ac9d);const _0x9e123=await index_1[_0x361dbc(0x7e)][_0x361dbc(0xb6)](_0x361dbc(0x81),{'body':{'amount':0x64,'currency':'USD'}});expect(_0x9e123[_0x361dbc(0xa1)])[_0x361dbc(0x88)](0xc8),expect(_0x9e123[_0x361dbc(0xb9)])[_0x361dbc(0xac)](),expect(_0x9e123[_0x361dbc(0xb9)][_0x361dbc(0xd5)])[_0x361dbc(0x88)](!![]);}),it(_0x521548(0x9a),async()=>{const _0x564fa6=_0x521548,_0x701d53=index_1[_0x564fa6(0x7e)][_0x564fa6(0x7d)](_0x564fa6(0xa9))[_0x564fa6(0xbb)]('POST',_0x564fa6(0x98))['step']('check',_0x58d9df=>_0x58d9df[_0x564fa6(0xd0)](_0x564fa6(0x80))[_0x564fa6(0xd1)]('ok')[_0x564fa6(0xb7)](_0x564fa6(0xa0)))[_0x564fa6(0xc3)]('ok',_0x37709d=>_0x37709d['responder'](_0x564fa6(0xc0),{'statusCode':0xc8,'body':{'status':'ok'}}))[_0x564fa6(0xc3)]('fail',_0x30f4c6=>_0x30f4c6[_0x564fa6(0xd6)](_0x564fa6(0xc0),{'statusCode':0x190,'body':{'status':_0x564fa6(0xa0)}}))[_0x564fa6(0xc8)]();index_1[_0x564fa6(0x7e)][_0x564fa6(0xcd)](_0x701d53);const _0x54c8f1=await index_1[_0x564fa6(0x7e)][_0x564fa6(0xb6)](_0x564fa6(0xa9),{'body':{'amount':0xa}});expect(_0x54c8f1['statusCode'])['toBe'](0xc8),expect(_0x54c8f1[_0x564fa6(0xb9)])[_0x564fa6(0x9f)]({'status':'ok'});const _0x4cae04=await index_1['flosync']['run'](_0x564fa6(0xa9),{'body':{'amount':0x0}});expect(_0x4cae04['statusCode'])['toBe'](0x190),expect(_0x4cae04[_0x564fa6(0xb9)])[_0x564fa6(0x9f)]({'status':_0x564fa6(0xa0)});}),it(_0x521548(0xb0),async()=>{const _0x13ae18=_0x521548,_0x3309dd=index_1[_0x13ae18(0x7e)][_0x13ae18(0x7d)](_0x13ae18(0x9d))[_0x13ae18(0xbb)](_0x13ae18(0x95),_0x13ae18(0x85))[_0x13ae18(0xc3)](_0x13ae18(0x8c),_0x2b06e0=>_0x2b06e0[_0x13ae18(0x8c)]({'doubled':_0x13ae18(0xb5),'upper':'{{\x20uppercase(trigger.body.name)\x20}}'}))[_0x13ae18(0xc3)](_0x13ae18(0xcf),_0x698331=>_0x698331['responder']('json',{'body':_0x13ae18(0xd3)}))['build']();index_1[_0x13ae18(0x7e)][_0x13ae18(0xcd)](_0x3309dd);const _0x28ba09=await index_1[_0x13ae18(0x7e)][_0x13ae18(0xb6)](_0x13ae18(0x9d),{'body':{'value':0x5,'name':_0x13ae18(0xc2)}});expect(_0x28ba09['statusCode'])['toBe'](0xc8),expect(_0x28ba09[_0x13ae18(0xb9)])['toBeDefined'](),expect(_0x28ba09[_0x13ae18(0xb9)][_0x13ae18(0xc5)])['toBe'](0xa),expect(_0x28ba09['body'][_0x13ae18(0x8a)])[_0x13ae18(0x88)](_0x13ae18(0xd2));}),it('validator\x20fails\x20and\x20triggers\x20else\x20branch',async()=>{const _0x2887fc=_0x521548,_0x3a64b9=index_1[_0x2887fc(0x7e)][_0x2887fc(0x7d)]('validator-else')[_0x2887fc(0xbb)](_0x2887fc(0x95),'/v')[_0x2887fc(0xc3)](_0x2887fc(0xc6),_0x4d8331=>_0x4d8331[_0x2887fc(0x9b)]({'amount':_0x2887fc(0xc7)})[_0x2887fc(0xd1)](_0x2887fc(0xaa))[_0x2887fc(0xb7)](_0x2887fc(0x93)))[_0x2887fc(0xc3)](_0x2887fc(0xaa),_0x36e6f1=>_0x36e6f1[_0x2887fc(0xd6)](_0x2887fc(0xc0),{'statusCode':0xc8,'body':{'saved':!![]}}))[_0x2887fc(0xc3)]('error',_0x4408ec=>_0x4408ec[_0x2887fc(0xd6)]('json',{'statusCode':0x190,'body':{'error':_0x2887fc(0xa7)}}))[_0x2887fc(0xc8)]();index_1[_0x2887fc(0x7e)][_0x2887fc(0xcd)](_0x3a64b9);const _0x3823b2=await index_1['flosync'][_0x2887fc(0xb6)](_0x2887fc(0x89),{'body':{}});expect(_0x3823b2[_0x2887fc(0xa1)])[_0x2887fc(0x88)](0x190),expect(_0x3823b2[_0x2887fc(0xb9)]['error'])['toBe'](_0x2887fc(0xa7));}),it('accepts\x20plain\x20object\x20as\x20trigger\x20body\x20(no\x20body\x20key)',async()=>{const _0x40579e=_0x521548,_0x5c0ef2=index_1[_0x40579e(0x7e)][_0x40579e(0x7d)]('plain-body')[_0x40579e(0xbb)](_0x40579e(0x95),'/plain')['step'](_0x40579e(0xcf),_0x28f150=>_0x28f150[_0x40579e(0xd6)](_0x40579e(0xc0),{'body':{'received':_0x40579e(0xc7)}}))[_0x40579e(0xc8)]();index_1[_0x40579e(0x7e)]['register'](_0x5c0ef2);const _0x380c64=await index_1[_0x40579e(0x7e)][_0x40579e(0xb6)](_0x40579e(0xa3),{'amount':0x2a});expect(_0x380c64['statusCode'])[_0x40579e(0x88)](0xc8),expect(Number(_0x380c64['body']['received']))['toBe'](0x2a);}),it(_0x521548(0x99),async()=>{const _0x3c83e4=_0x521548,_0x419a25=index_1[_0x3c83e4(0x7e)][_0x3c83e4(0x7d)](_0x3c83e4(0x96))[_0x3c83e4(0xbb)]('POST','/users/:id')[_0x3c83e4(0xc3)]('respond',_0x514e1d=>_0x514e1d[_0x3c83e4(0xd6)](_0x3c83e4(0xc0),{'body':{'bodyAmount':_0x3c83e4(0xc7),'headerX':_0x3c83e4(0xab),'pathId':_0x3c83e4(0xa4),'queryPage':'{{\x20query.page\x20}}','varOverride':'{{\x20vars.override\x20}}'}}))['build']();index_1[_0x3c83e4(0x7e)][_0x3c83e4(0xcd)](_0x419a25);const _0x3cc57e=await index_1[_0x3c83e4(0x7e)][_0x3c83e4(0xb6)](_0x3c83e4(0x96),{'body':{'amount':0xa},'headers':{'x-request-id':_0x3c83e4(0x94)},'pathParams':{'id':_0x3c83e4(0x8d)},'query':{'page':0x2},'vars':{'override':_0x3c83e4(0xb3)}});expect(_0x3cc57e[_0x3c83e4(0xa1)])['toBe'](0xc8),expect(Number(_0x3cc57e[_0x3c83e4(0xb9)][_0x3c83e4(0x90)]))[_0x3c83e4(0x88)](0xa),expect(_0x3cc57e[_0x3c83e4(0xb9)][_0x3c83e4(0x9e)])[_0x3c83e4(0x88)](_0x3c83e4(0x94)),expect(_0x3cc57e[_0x3c83e4(0xb9)][_0x3c83e4(0x97)])[_0x3c83e4(0x88)](_0x3c83e4(0x8d)),expect(Number(_0x3cc57e['body'][_0x3c83e4(0x82)]))[_0x3c83e4(0x88)](0x2),expect(_0x3cc57e[_0x3c83e4(0xb9)][_0x3c83e4(0x7c)])[_0x3c83e4(0x88)](_0x3c83e4(0xb3));}),it(_0x521548(0x86),async()=>{const _0x4910fd=_0x521548,_0x7ab6a9=index_1[_0x4910fd(0x7e)]['workflow'](_0x4910fd(0xa8))[_0x4910fd(0xbb)](_0x4910fd(0x95),_0x4910fd(0xb8))[_0x4910fd(0xc3)](_0x4910fd(0xcf),_0x2722c6=>_0x2722c6[_0x4910fd(0xd6)](_0x4910fd(0xc0),{'body':{'viaBody':_0x4910fd(0xae),'viaTrigger':_0x4910fd(0xad)}}))['build']();index_1['flosync'][_0x4910fd(0xcd)](_0x7ab6a9);const _0xde408c=await index_1[_0x4910fd(0x7e)][_0x4910fd(0xb6)](_0x4910fd(0xa8),{'body':{'account':_0x4910fd(0x87),'email':'user@example.com'}});expect(_0xde408c['statusCode'])[_0x4910fd(0x88)](0xc8),expect(_0xde408c[_0x4910fd(0xb9)]['viaBody'])['toBe']('acct-1'),expect(_0xde408c[_0x4910fd(0xb9)][_0x4910fd(0xaf)])[_0x4910fd(0x88)](_0x4910fd(0xba));}),it(_0x521548(0x91),async()=>{const _0x3ae27c=_0x521548,_0x24cf54=index_1['flosync'][_0x3ae27c(0x7d)]('manual-flow')[_0x3ae27c(0xc3)](_0x3ae27c(0xcf),_0x5ca5e6=>_0x5ca5e6[_0x3ae27c(0xd6)]('json',{'body':{'received':_0x3ae27c(0xbf)}}))[_0x3ae27c(0xc8)]();index_1['flosync'][_0x3ae27c(0xcd)](_0x24cf54);const _0x12c463=await index_1[_0x3ae27c(0x7e)][_0x3ae27c(0xb6)](_0x3ae27c(0xc1),{'body':{'amount':0x63}});expect(_0x12c463['statusCode'])[_0x3ae27c(0x88)](0xc8),expect(Number(_0x12c463[_0x3ae27c(0xb9)][_0x3ae27c(0xb4)]))['toBe'](0x63);}),it(_0x521548(0x9c),async()=>{const _0x1b727e=_0x521548,_0x1d7334=index_1[_0x1b727e(0x7e)][_0x1b727e(0x7d)](_0x1b727e(0xca))[_0x1b727e(0xd4)]('0\x20*\x20*\x20*\x20*',_0x1b727e(0xb2))[_0x1b727e(0xc3)](_0x1b727e(0xcf),_0x2663cc=>_0x2663cc[_0x1b727e(0xd6)]('json',{'body':{'ok':!![]}}))[_0x1b727e(0xc8)]();expect(_0x1d7334[_0x1b727e(0x83)][_0x1b727e(0xa2)])[_0x1b727e(0x88)]('job'),expect(_0x1d7334['trigger'][_0x1b727e(0x8f)])[_0x1b727e(0x88)](_0x1b727e(0xbe)),expect(_0x1d7334[_0x1b727e(0x83)]['timezone'])[_0x1b727e(0x88)](_0x1b727e(0xb2)),index_1['flosync']['register'](_0x1d7334);const _0x3757a7=await index_1[_0x1b727e(0x7e)]['run'](_0x1b727e(0xca),{});expect(_0x3757a7[_0x1b727e(0xa1)])[_0x1b727e(0x88)](0xc8),expect(_0x3757a7[_0x1b727e(0xb9)]['ok'])['toBe'](!![]);});});function _0x1b75(){const _0x38a609=['CMvJzwL2zwq','E3SGDhjPz2DLCI5IB2r5lNzHBhvLicOGmIb9Fq','CNvU','zwXZzq','l3rLC3q','yM9KEq','DxnLCKbLEgfTCgXLlMnVBq','Ahr0Ca','lI4VAw5KzxG','CNvUCYbHihnPBxbSzsb3B3jRzMXVDYb3AxrOihzHBgLKyxrVCIbHBMqGCMvZCg9UzgvY','mcaQicOGkIaQ','E3SGyM9KEs5HBw91BNqGFx0','ANnVBG','BwfUDwfSlwzSB3C','AgvSBg8','C3rLCa','offougX0qW','zg91yMXLza','DMfSAwrHDgu','E3SGDhjPz2DLCI5IB2r5lMfTB3vUDcb9Fq','yNvPBgq','ndK5nJyWmKDnr3rpuG','AM9IlwzSB3C','mZG5odeWnuT6wuf6CG','E3SGC3rLCfjLC3vSDhmUDMfSAwrHDguGFx0','CMvNAxn0zxi','m01XwhfQzq','CMvZCg9Uza','y29UzgL0Aw9U','DgHLBG','sevmte8','E3SGC3rLCfjLC3vSDhmUDhjHBNnMB3jTih19','AM9I','DMfSAwq','CMvZCg9UzgvY','DMfYt3zLCNjPzgu','D29YA2zSB3C','zMXVC3LUyW','zgvMAw5LuhjVCgvYDhK','E3SGDhjPz2DLCI5IB2r5lMfTB3vUDca+idaGFx0','DgvZDc1MBg93','CxvLCNLqywDL','DhjPz2DLCG','mtyWndCYnxzLtMritG','l3rYyw5ZzM9YBq','C3vWCg9YDhmGE3SGyM9KEs54ih19igfUzcb7EYb0CMLNz2vYlNGGFx0GzM9YigjVzhKGzMLLBgrZ','ywnJDc0X','Dg9czq','DMfSAwrHDg9YlwvSC2u','DxbWzxi','mti2mdy4ngXzDvHAtq','DhjHBNnMB3jT','DxnLCI00nty','nZCYodK2mgD2s1LIsa','y3jVBG','yM9KEufTB3vUDa','CNvUCYb3B3jRzMXVDYb3AxrOB3v0igH0DhaGDhjPz2DLCIaOBwfUDwfSkq','mte5otG2nMjRvKTNvq','zxjYB3i','CMvXlteYmW','ue9tva','zNvSBc1WyxLSB2fK','Cgf0AeLK','l2nVBMq','CgfZC2vZigHLywrLCNmSihbHDgHqyxjHBxmSihbHCMfTCYWGCxvLCNKSihzHCNmGDg8GDgvTCgXHDguGy29UDgv4Da','CNvUCYb3B3jRzMXVDYb3AxrOignVBMrPDgLVBIb0AgvUl2vSC2u','DMfSAwrHDg9Y','yNvPBgrZihDVCMTMBg93ihDPDgGGAM9IihrYAwDNzxi','DhjHBNnMB3jTlwzSB3C','AgvHzgvYwa','Dg9fCxvHBa','zMfPBa','C3rHDhvZq29Kzq','DhLWzq','CgXHAw4TyM9KEq','E3SGCgf0AfbHCMfTCY5Pzcb9Fq','mZi0otyZmuH5sgPNzG','x19LC01VzhvSzq','vMfSAwrHDgLVBIbMywLSzwq','yM9KEs10CMLNz2vYlwfJy2vZCW','y29Uzc1MBg93','C2f2zq','E3SGAgvHzgvYC1SNEc1Yzxf1zxn0lwLKj10GFx0','Dg9czurLzMLUzwq','E3SGDhjPz2DLCI5LBwfPBcb9Fq','E3SGyM9KEs5Hy2nVDw50ih19','DMLHvhjPz2DLCG','CNvUCYb3B3jRzMXVDYb3AxrOihrYyw5ZzM9YBsbZDgvW','uhjVy2vZC29Yrw5NAw5L','vvrd','zNjVBs1WyxLSB2fK'];_0x1b75=function(){return _0x38a609;};return _0x1b75();}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("../index");
4
+ describe("ProcessorEngine", () => {
5
+ beforeEach(() => {
6
+ index_1.flosync.configure({ connectors: {} });
7
+ });
8
+ it("runs a simple workflow with validator and responder", async () => {
9
+ const w = index_1.flosync
10
+ .workflow("test-flow")
11
+ .http("POST", "/test")
12
+ .step("validate", (s) => s.validator({ amount: "{{ trigger.body.amount }}", currency: "{{ trigger.body.currency }}" }))
13
+ .step("respond", (s) => s.responder("json", { statusCode: 200, body: "{{ stepResults.validate }}" }))
14
+ .build();
15
+ index_1.flosync.register(w);
16
+ const result = await index_1.flosync.run("test-flow", {
17
+ body: { amount: 100, currency: "USD" },
18
+ });
19
+ expect(result.statusCode).toBe(200);
20
+ expect(result.body).toBeDefined();
21
+ expect(result.body.valid).toBe(true);
22
+ });
23
+ it("runs workflow with condition then/else", async () => {
24
+ const w = index_1.flosync
25
+ .workflow("cond-flow")
26
+ .http("POST", "/cond")
27
+ .step("check", (s) => s.condition("{{ trigger.body.amount > 0 }}").then("ok").else("fail"))
28
+ .step("ok", (s) => s.responder("json", { statusCode: 200, body: { status: "ok" } }))
29
+ .step("fail", (s) => s.responder("json", { statusCode: 400, body: { status: "fail" } }))
30
+ .build();
31
+ index_1.flosync.register(w);
32
+ const okResult = await index_1.flosync.run("cond-flow", { body: { amount: 10 } });
33
+ expect(okResult.statusCode).toBe(200);
34
+ expect(okResult.body).toEqual({ status: "ok" });
35
+ const failResult = await index_1.flosync.run("cond-flow", { body: { amount: 0 } });
36
+ expect(failResult.statusCode).toBe(400);
37
+ expect(failResult.body).toEqual({ status: "fail" });
38
+ });
39
+ it("runs workflow with transform step", async () => {
40
+ const w = index_1.flosync
41
+ .workflow("transform-flow")
42
+ .http("POST", "/transform")
43
+ .step("transform", (s) => s.transform({
44
+ doubled: "{{ trigger.body.value * 2 }}",
45
+ upper: "{{ uppercase(trigger.body.name) }}",
46
+ }))
47
+ .step("respond", (s) => s.responder("json", { body: "{{ stepResults.transform }}" }))
48
+ .build();
49
+ index_1.flosync.register(w);
50
+ const result = await index_1.flosync.run("transform-flow", {
51
+ body: { value: 5, name: "hello" },
52
+ });
53
+ expect(result.statusCode).toBe(200);
54
+ expect(result.body).toBeDefined();
55
+ expect(result.body.doubled).toBe(10);
56
+ expect(result.body.upper).toBe("HELLO");
57
+ });
58
+ it("validator fails and triggers else branch", async () => {
59
+ const w = index_1.flosync
60
+ .workflow("validator-else")
61
+ .http("POST", "/v")
62
+ .step("validate", (s) => s.validator({ amount: "{{ trigger.body.amount }}" })
63
+ .then("save")
64
+ .else("error"))
65
+ .step("save", (s) => s.responder("json", { statusCode: 200, body: { saved: true } }))
66
+ .step("error", (s) => s.responder("json", { statusCode: 400, body: { error: "Validation failed" } }))
67
+ .build();
68
+ index_1.flosync.register(w);
69
+ const result = await index_1.flosync.run("validator-else", { body: {} });
70
+ expect(result.statusCode).toBe(400);
71
+ expect(result.body.error).toBe("Validation failed");
72
+ });
73
+ it("accepts plain object as trigger body (no body key)", async () => {
74
+ const w = index_1.flosync
75
+ .workflow("plain-body")
76
+ .http("POST", "/plain")
77
+ .step("respond", (s) => s.responder("json", { body: { received: "{{ trigger.body.amount }}" } }))
78
+ .build();
79
+ index_1.flosync.register(w);
80
+ const result = await index_1.flosync.run("plain-body", { amount: 42 });
81
+ expect(result.statusCode).toBe(200);
82
+ expect(Number(result.body.received)).toBe(42);
83
+ });
84
+ it("passes headers, pathParams, params, query, vars to template context", async () => {
85
+ const w = index_1.flosync
86
+ .workflow("full-payload")
87
+ .http("POST", "/users/:id")
88
+ .step("respond", (s) => s.responder("json", {
89
+ body: {
90
+ bodyAmount: "{{ trigger.body.amount }}",
91
+ headerX: "{{ headers['x-request-id'] }}",
92
+ pathId: "{{ pathParams.id }}",
93
+ queryPage: "{{ query.page }}",
94
+ varOverride: "{{ vars.override }}",
95
+ },
96
+ }))
97
+ .build();
98
+ index_1.flosync.register(w);
99
+ const result = await index_1.flosync.run("full-payload", {
100
+ body: { amount: 10 },
101
+ headers: { "x-request-id": "req-123" },
102
+ pathParams: { id: "user-456" },
103
+ query: { page: 2 },
104
+ vars: { override: "from-payload" },
105
+ });
106
+ expect(result.statusCode).toBe(200);
107
+ expect(Number(result.body.bodyAmount)).toBe(10);
108
+ expect(result.body.headerX).toBe("req-123");
109
+ expect(result.body.pathId).toBe("user-456");
110
+ expect(Number(result.body.queryPage)).toBe(2);
111
+ expect(result.body.varOverride).toBe("from-payload");
112
+ });
113
+ it("supports {{ body.x }} and {{ trigger.x }} for body fields", async () => {
114
+ const w = index_1.flosync
115
+ .workflow("body-trigger-access")
116
+ .http("POST", "/test")
117
+ .step("respond", (s) => s.responder("json", {
118
+ body: {
119
+ viaBody: "{{ body.account }}",
120
+ viaTrigger: "{{ trigger.email }}",
121
+ },
122
+ }))
123
+ .build();
124
+ index_1.flosync.register(w);
125
+ const result = await index_1.flosync.run("body-trigger-access", {
126
+ body: { account: "acct-1", email: "user@example.com" },
127
+ });
128
+ expect(result.statusCode).toBe(200);
129
+ expect(result.body.viaBody).toBe("acct-1");
130
+ expect(result.body.viaTrigger).toBe("user@example.com");
131
+ });
132
+ it("runs workflow without http trigger (manual)", async () => {
133
+ const w = index_1.flosync
134
+ .workflow("manual-flow")
135
+ .step("respond", (s) => s.responder("json", { body: { received: "{{ body.amount }}" } }))
136
+ .build();
137
+ index_1.flosync.register(w);
138
+ const result = await index_1.flosync.run("manual-flow", { body: { amount: 99 } });
139
+ expect(result.statusCode).toBe(200);
140
+ expect(Number(result.body.received)).toBe(99);
141
+ });
142
+ it("builds workflow with job trigger", async () => {
143
+ const w = index_1.flosync
144
+ .workflow("job-flow")
145
+ .job("0 * * * *", "UTC")
146
+ .step("respond", (s) => s.responder("json", { body: { ok: true } }))
147
+ .build();
148
+ expect(w.trigger.type).toBe("job");
149
+ expect(w.trigger.cron).toBe("0 * * * *");
150
+ expect(w.trigger.timezone).toBe("UTC");
151
+ index_1.flosync.register(w);
152
+ const result = await index_1.flosync.run("job-flow", {});
153
+ expect(result.statusCode).toBe(200);
154
+ expect(result.body.ok).toBe(true);
155
+ });
156
+ });