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,54 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 @@
|
|
|
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 @@
|
|
|
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
|
-
|
|
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
|
+
});
|