@versori/run 0.1.0-alpha.9 → 0.2.0-alpha.1
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/esm/_dnt.shims.d.ts +1 -5
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -5
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +6 -7
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -12
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -2
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -8
- package/esm/src/context/Context.d.ts +14 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +16 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +2 -3
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +5 -6
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +3 -4
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +5 -6
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +76 -7
- package/esm/src/interpreter/memory/compilers/schedule.js +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +132 -25
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +7 -8
- package/package.json +3 -6
- package/script/_dnt.shims.d.ts +1 -5
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +2 -7
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +9 -33
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -35
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -25
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -31
- package/script/src/context/Context.d.ts +14 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +16 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +2 -26
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +5 -29
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +3 -27
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +5 -29
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +76 -30
- package/script/src/interpreter/memory/compilers/schedule.js +1 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +135 -25
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +7 -31
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.LoadConfigFromFile = LoadConfigFromFile;
|
|
27
|
-
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
4
|
const constants_js_1 = require("./constants.js");
|
|
29
5
|
/**
|
|
30
6
|
* Loads the Versori SDK configuration from a JSON file.
|
|
@@ -37,10 +13,10 @@ const constants_js_1 = require("./constants.js");
|
|
|
37
13
|
*/
|
|
38
14
|
function LoadConfigFromFile() {
|
|
39
15
|
// Get the config file name from the environment variable
|
|
40
|
-
const configFileName =
|
|
16
|
+
const configFileName = Deno.env.get(constants_js_1.envVarConfigFile);
|
|
41
17
|
if (!configFileName) {
|
|
42
18
|
throw new Error(`Environment variable ${constants_js_1.envVarConfigFile} is not set`);
|
|
43
19
|
}
|
|
44
|
-
const cfg = JSON.parse(
|
|
20
|
+
const cfg = JSON.parse(Deno.readTextFileSync(configFileName));
|
|
45
21
|
return cfg;
|
|
46
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IA2BpB,QAAQ;CAsBjB"}
|
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.InternalAuth = void 0;
|
|
27
|
-
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
4
|
const constants_js_1 = require("./constants.js");
|
|
29
5
|
class InternalAuth {
|
|
30
6
|
constructor() {
|
|
@@ -58,13 +34,13 @@ class InternalAuth {
|
|
|
58
34
|
writable: true,
|
|
59
35
|
value: void 0
|
|
60
36
|
});
|
|
61
|
-
this.clientId =
|
|
62
|
-
this.clientSecret =
|
|
63
|
-
this.tokenEndpoint =
|
|
37
|
+
this.clientId = Deno.env.get(constants_js_1.envVarClientId) || '';
|
|
38
|
+
this.clientSecret = Deno.env.get(constants_js_1.envVarClientSecret) || '';
|
|
39
|
+
this.tokenEndpoint = Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
|
|
64
40
|
this.accessToken = '';
|
|
65
41
|
this.expiresAt = 0;
|
|
66
|
-
if (
|
|
67
|
-
this.accessToken =
|
|
42
|
+
if (Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
43
|
+
this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
68
44
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
69
45
|
console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
|
|
70
46
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIzE,qBAAa,iBAAkB,YAAW,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAe;gBAG/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;IAQjB,MAAM,CAAC,OAAO,IAAI,iBAAiB;IAY7B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAiBnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAmBzD,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmBpE,uBAAuB,CACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmB5B,eAAe,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAkBjD"}
|
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.PlatformAPIClient = void 0;
|
|
27
|
-
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
4
|
const constants_js_1 = require("./constants.js");
|
|
29
5
|
const internalauth_js_1 = require("./internalauth.js");
|
|
30
6
|
class PlatformAPIClient {
|
|
@@ -59,9 +35,9 @@ class PlatformAPIClient {
|
|
|
59
35
|
this.internalAuth = new internalauth_js_1.InternalAuth();
|
|
60
36
|
}
|
|
61
37
|
static fromEnv() {
|
|
62
|
-
const baseUrl =
|
|
63
|
-
const orgId =
|
|
64
|
-
const envId =
|
|
38
|
+
const baseUrl = Deno.env.get(constants_js_1.envVarPlatformApiBaseURL);
|
|
39
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId);
|
|
40
|
+
const envId = Deno.env.get(constants_js_1.envVarEnvId);
|
|
65
41
|
if (!baseUrl || !orgId || !envId) {
|
|
66
42
|
throw new Error('Missing required environment variables');
|
|
67
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AASlE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE,OAAO,CAAC,WAAW,CAA0B;IAE7C,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;gBAGE,WAAW,EAAE,uBAAuB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM;IAQlB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,0BAA0B;IA0B3D,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,aAAa;IAsBf,MAAM,CACR,QAAQ,EAAE,MAAM,EAChB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IA4B9B,aAAa,CACf,YAAY,EAAE,MAAM,EACpB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA4CtC,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa;YAUP,aAAa;YAoDb,gBAAgB;YAmChB,kBAAkB;YAiClB,aAAa;CAkD9B"}
|
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.VersoriRoundTripperFactory = void 0;
|
|
27
|
-
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
4
|
const configloader_js_1 = require("./configloader.js");
|
|
29
5
|
const mod_js_1 = require("./credentials/mod.js");
|
|
30
6
|
const platformapi_js_1 = require("./platformapi.js");
|
|
@@ -85,10 +61,10 @@ class VersoriRoundTripperFactory {
|
|
|
85
61
|
this.log = logger;
|
|
86
62
|
}
|
|
87
63
|
static fromEnv(logger) {
|
|
88
|
-
const credsBaseURL =
|
|
89
|
-
const platformApiBaseURL =
|
|
90
|
-
const orgId =
|
|
91
|
-
const envId =
|
|
64
|
+
const credsBaseURL = Deno.env.get(constants_js_1.envVarCredsBaseURL);
|
|
65
|
+
const platformApiBaseURL = Deno.env.get(constants_js_1.envVarPlatformApiBaseURL);
|
|
66
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId);
|
|
67
|
+
const envId = Deno.env.get(constants_js_1.envVarEnvId);
|
|
92
68
|
if (!orgId || !envId || !platformApiBaseURL || !credsBaseURL) {
|
|
93
69
|
const missingVars = [];
|
|
94
70
|
if (!orgId)
|
|
@@ -101,7 +77,7 @@ class VersoriRoundTripperFactory {
|
|
|
101
77
|
missingVars.push(constants_js_1.envVarCredsBaseURL);
|
|
102
78
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
103
79
|
}
|
|
104
|
-
const pAPIClient = new platformapi_js_1.PlatformAPIClient(platformApiBaseURL, orgId, envId
|
|
80
|
+
const pAPIClient = new platformapi_js_1.PlatformAPIClient(platformApiBaseURL, orgId, envId);
|
|
105
81
|
const tokenClient = new mod_js_1.VersoriCredentialClient(credsBaseURL);
|
|
106
82
|
const log = logger || new mod_js_2.ConsoleLogger('debug');
|
|
107
83
|
return new VersoriRoundTripperFactory(tokenClient, pAPIClient, log);
|
|
@@ -33,7 +33,7 @@ export declare class HttpContextImpl<D, PageParams> extends ContextImpl<D> imple
|
|
|
33
33
|
pageParams?: PageParams;
|
|
34
34
|
private dynamicFetcher?;
|
|
35
35
|
private staticFetcher?;
|
|
36
|
-
constructor(ctx:
|
|
36
|
+
constructor(ctx: ContextImpl<D, any>, connectionVars: Record<string, any>, staticFetcher?: typeof globalThis.fetch, dynamicFetcher?: DynamicFetcher, pageParams?: PageParams);
|
|
37
37
|
get fetch(): typeof globalThis.fetch;
|
|
38
38
|
nextPage(nextParams: PageParams): Promise<void>;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-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AG,CAAC,EACxB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,aAAa,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,EACvC,cAAc,CAAC,EAAE,cAAc,EAC/B,UAAU,CAAC,EAAE,UAAU;IAkB3B,IAAI,KAAK,IAAI,OAAO,UAAU,CAAC,KAAK,CAGnC;IAEK,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxD;AAED,wBAAgB,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,UAAU,GAAG,OAAO,EAC1D,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EACtC,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GACzC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAEf"}
|
|
@@ -66,7 +66,7 @@ class HttpContextImpl extends Context_js_1.ContextImpl {
|
|
|
66
66
|
constructor(ctx, connectionVars, staticFetcher, dynamicFetcher, pageParams) {
|
|
67
67
|
// We need to cast ctx to InternalContext to access kvp
|
|
68
68
|
const internalCtx = ctx;
|
|
69
|
-
super(ctx.log, internalCtx.kvp, ctx.executionId, ctx.startTime, ctx.data, ctx.
|
|
69
|
+
super(ctx.log, internalCtx.kvp, ctx.executionId, ctx.startTime, ctx.data, ctx.options);
|
|
70
70
|
Object.defineProperty(this, "connectionVariables", {
|
|
71
71
|
enumerable: true,
|
|
72
72
|
configurable: true,
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
+
import { Context } from '../../context/Context.js';
|
|
1
2
|
import { Taskable } from '../Task.js';
|
|
2
3
|
import { Trigger, TriggerType } from '../Trigger.js';
|
|
3
4
|
import { Workflow } from '../Workflow.js';
|
|
4
5
|
export type WebhookData = Record<string, never>;
|
|
6
|
+
export type WebhookCorsOptions = boolean | {
|
|
7
|
+
origin: string;
|
|
8
|
+
methods: string[];
|
|
9
|
+
allowedHeaders: string[];
|
|
10
|
+
exposedHeaders: string[];
|
|
11
|
+
credentials: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type WebhookResponseOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Mode determines how the response is sent to the client. The response can be customized by
|
|
16
|
+
* the `onSuccess` and `onError` functions, which have sensible defaults for each mode.
|
|
17
|
+
*
|
|
18
|
+
* - `sync`: The response is sent at the end of the workflow.
|
|
19
|
+
* - `async`: The response is sent immediately after the trigger is activated.
|
|
20
|
+
*
|
|
21
|
+
* @default 'sync'
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'sync' | 'async';
|
|
24
|
+
/**
|
|
25
|
+
* Function that returns a response for a successful trigger activation.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to a 202 Accepted response for 'async' mode, and a 200 OK response for 'sync' mode.
|
|
28
|
+
*
|
|
29
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
30
|
+
* @returns A response to send to the client.
|
|
31
|
+
*/
|
|
32
|
+
onSuccess?: <T>(ctx: Context<T>) => Response;
|
|
33
|
+
/**
|
|
34
|
+
* Function that returns a response for a failed trigger activation.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to a 500 Internal Server Error response for both modes.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
39
|
+
* @returns A response to send to the client.
|
|
40
|
+
*/
|
|
41
|
+
onError?: <T>(ctx: Context<T>) => Response;
|
|
42
|
+
};
|
|
43
|
+
export type WebhookOptions = {
|
|
44
|
+
cors?: WebhookCorsOptions;
|
|
45
|
+
response?: WebhookResponseOptions;
|
|
46
|
+
};
|
|
5
47
|
export declare class WebhookTrigger implements Trigger<WebhookData> {
|
|
6
48
|
id: string;
|
|
49
|
+
options: WebhookOptions;
|
|
7
50
|
[TriggerType]: string;
|
|
8
|
-
constructor(id: string);
|
|
51
|
+
constructor(id: string, options?: WebhookOptions);
|
|
9
52
|
then<OO>(task: Taskable<WebhookData, OO>): Workflow<OO>;
|
|
10
|
-
catch<OO>(error: any): Workflow<OO>;
|
|
11
53
|
}
|
|
12
|
-
export declare function webhook(id: string):
|
|
54
|
+
export declare function webhook(id: string, options?: WebhookOptions): Trigger<WebhookData>;
|
|
13
55
|
//# sourceMappingURL=WebhookTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACjC;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;IAE7C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;CAC9C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACrC,CAAA;AAED,qBAAa,cAAe,YAAW,OAAO,CAAC,WAAW,CAAC;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;IAExB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAa;gBAEtB,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAKpD,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;CAG1D;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAElF"}
|
|
@@ -7,13 +7,19 @@ const ensureTask_js_1 = require("../ensureTask.js");
|
|
|
7
7
|
const Trigger_js_1 = require("../Trigger.js");
|
|
8
8
|
const Workflow_js_1 = require("../Workflow.js");
|
|
9
9
|
class WebhookTrigger {
|
|
10
|
-
constructor(id) {
|
|
10
|
+
constructor(id, options = {}) {
|
|
11
11
|
Object.defineProperty(this, "id", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
configurable: true,
|
|
14
14
|
writable: true,
|
|
15
15
|
value: void 0
|
|
16
16
|
});
|
|
17
|
+
Object.defineProperty(this, "options", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
17
23
|
Object.defineProperty(this, _a, {
|
|
18
24
|
enumerable: true,
|
|
19
25
|
configurable: true,
|
|
@@ -21,16 +27,14 @@ class WebhookTrigger {
|
|
|
21
27
|
value: 'webhook'
|
|
22
28
|
});
|
|
23
29
|
this.id = id;
|
|
30
|
+
this.options = options;
|
|
24
31
|
}
|
|
25
32
|
then(task) {
|
|
26
33
|
return new Workflow_js_1.WorkflowImpl(this, (0, ensureTask_js_1.ensureTask)(task));
|
|
27
34
|
}
|
|
28
|
-
catch(error) {
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
35
|
}
|
|
32
36
|
exports.WebhookTrigger = WebhookTrigger;
|
|
33
37
|
_a = Trigger_js_1.TriggerType;
|
|
34
|
-
function webhook(id) {
|
|
35
|
-
return new WebhookTrigger(id);
|
|
38
|
+
function webhook(id, options) {
|
|
39
|
+
return new WebhookTrigger(id, options);
|
|
36
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable, Subscription } from 'rxjs';
|
|
3
3
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
4
4
|
import { ConnectionProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
5
5
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
@@ -18,6 +18,7 @@ type Registration = {
|
|
|
18
18
|
task$: ContextOperatorFunction<any, any, any>;
|
|
19
19
|
localAbortController: AbortController;
|
|
20
20
|
sigintListener: () => void;
|
|
21
|
+
subscription?: Subscription;
|
|
21
22
|
};
|
|
22
23
|
export declare class MemoryInterpreter {
|
|
23
24
|
private readonly log;
|
|
@@ -27,10 +28,14 @@ export declare class MemoryInterpreter {
|
|
|
27
28
|
private readonly router;
|
|
28
29
|
private readonly connectionProvider;
|
|
29
30
|
private registeredWorkflows;
|
|
31
|
+
private server?;
|
|
32
|
+
private shutdownServer?;
|
|
33
|
+
private isShuttingDown;
|
|
30
34
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, router: Router, connectionProvider: ConnectionProvider);
|
|
31
35
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
32
36
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
33
37
|
start(): Promise<void>;
|
|
38
|
+
stop(): Promise<void>;
|
|
34
39
|
}
|
|
35
40
|
export {};
|
|
36
41
|
//# sourceMappingURL=MemoryInterpreter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAA+B,UAAU,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAI/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAmB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,wBAAwB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7C,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,EAAE,eAAe,CAAC;IACtC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAA;AAED,qBAAa,iBAAiB;IAOtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAXvC,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB;WAS9C,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoC5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IA6C/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiHtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.MemoryInterpreter = void 0;
|
|
30
|
-
const dntShim = __importStar(require("../../../_dnt.shims.js"));
|
|
31
7
|
const express_1 = __importDefault(require("express"));
|
|
32
8
|
const rxjs_1 = require("rxjs");
|
|
33
9
|
const ContextProvider_js_1 = require("../../context/ContextProvider.js");
|
|
@@ -83,6 +59,29 @@ class MemoryInterpreter {
|
|
|
83
59
|
writable: true,
|
|
84
60
|
value: []
|
|
85
61
|
});
|
|
62
|
+
Object.defineProperty(this, "server", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "shutdownServer", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: void 0
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "isShuttingDown", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: false
|
|
79
|
+
});
|
|
80
|
+
if (typeof this.log === 'undefined') {
|
|
81
|
+
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
82
|
+
// error message back to the user to let them know they should use the new way.
|
|
83
|
+
throw new Error('MemoryInterpreter should not be instantiated directly. Use MemoryInterpreter.newInstance() instead.');
|
|
84
|
+
}
|
|
86
85
|
}
|
|
87
86
|
static async newInstance(options = {}) {
|
|
88
87
|
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
@@ -132,7 +131,7 @@ class MemoryInterpreter {
|
|
|
132
131
|
return registration;
|
|
133
132
|
}
|
|
134
133
|
async start() {
|
|
135
|
-
const port =
|
|
134
|
+
const port = Deno.env.get('PORT') || 3000;
|
|
136
135
|
const app = (0, express_1.default)();
|
|
137
136
|
app.use(express_1.default.json()); // Add JSON body parser middleware
|
|
138
137
|
// Add health check route
|
|
@@ -143,12 +142,13 @@ class MemoryInterpreter {
|
|
|
143
142
|
app.use(this.router);
|
|
144
143
|
// Start all registered workflows
|
|
145
144
|
for (const registration of this.registeredWorkflows) {
|
|
146
|
-
|
|
147
|
-
registration.trigger$
|
|
145
|
+
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
146
|
+
registration.subscription = registration.trigger$
|
|
148
147
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
149
148
|
ctx.log.info('MemoryInterpreter.executionStarted', { data: ctx.data });
|
|
150
149
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((error) => {
|
|
151
150
|
ctx.log.error('MemoryInterpreter.executionError', { error });
|
|
151
|
+
ctx.options.onError?.(ctx.withData(error));
|
|
152
152
|
return rxjs_1.EMPTY;
|
|
153
153
|
}))))
|
|
154
154
|
.subscribe({
|
|
@@ -158,21 +158,67 @@ class MemoryInterpreter {
|
|
|
158
158
|
durationMs,
|
|
159
159
|
data: ctx.data,
|
|
160
160
|
});
|
|
161
|
+
ctx.options.onSuccess?.(ctx);
|
|
161
162
|
this.contextProvider.destroy(ctx);
|
|
162
163
|
},
|
|
163
164
|
error: (err) => {
|
|
164
165
|
this.log.error('MemoryInterpreter.error', { error: err });
|
|
165
|
-
|
|
166
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
166
167
|
},
|
|
167
168
|
complete: () => {
|
|
168
169
|
this.log.info('MemoryInterpreter.workflowCompleted');
|
|
169
|
-
|
|
170
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
170
171
|
},
|
|
171
172
|
});
|
|
173
|
+
registration.subscription.add(() => {
|
|
174
|
+
registration.subscription = undefined;
|
|
175
|
+
});
|
|
172
176
|
}
|
|
173
|
-
app.listen(port, () => {
|
|
177
|
+
this.server = app.listen(port, () => {
|
|
174
178
|
this.log.info(`Express server listening on http://localhost:${port}`);
|
|
175
179
|
});
|
|
180
|
+
this.shutdownServer = () => {
|
|
181
|
+
if (this.isShuttingDown) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.isShuttingDown = true;
|
|
185
|
+
this.log.info('Shutting down server');
|
|
186
|
+
// Close the server
|
|
187
|
+
if (this.server) {
|
|
188
|
+
this.server.close();
|
|
189
|
+
}
|
|
190
|
+
// Remove all signal listeners
|
|
191
|
+
for (const registration of this.registeredWorkflows) {
|
|
192
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
193
|
+
// Unsubscribe from all observables
|
|
194
|
+
if (registration.subscription) {
|
|
195
|
+
registration.subscription.unsubscribe();
|
|
196
|
+
}
|
|
197
|
+
// Abort all controllers
|
|
198
|
+
registration.localAbortController.abort();
|
|
199
|
+
}
|
|
200
|
+
// Remove the server shutdown listener
|
|
201
|
+
if (this.shutdownServer) {
|
|
202
|
+
Deno.removeSignalListener('SIGINT', this.shutdownServer);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
206
|
+
return new Promise((resolve) => {
|
|
207
|
+
if (this.server) {
|
|
208
|
+
this.server.on('close', () => {
|
|
209
|
+
this.log.info('Server closed');
|
|
210
|
+
resolve();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
resolve();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async stop() {
|
|
219
|
+
if (this.shutdownServer) {
|
|
220
|
+
this.shutdownServer();
|
|
221
|
+
}
|
|
176
222
|
}
|
|
177
223
|
}
|
|
178
224
|
exports.MemoryInterpreter = MemoryInterpreter;
|
|
@@ -33,7 +33,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
activations.forEach((activation) => {
|
|
36
|
-
const executionCtx = ctx.contextProvider.create({}, activation);
|
|
36
|
+
const executionCtx = ctx.contextProvider.create({}, { activation });
|
|
37
37
|
executionCtx.log.info('no activations found, continuing');
|
|
38
38
|
try {
|
|
39
39
|
subscriber.next(executionCtx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA+LxE,CAAC"}
|