@versori/run 0.4.4 → 0.5.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/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +2 -2
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +1 -1
- package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +120 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/esm/src/context/Context.d.ts +1 -0
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -0
- package/esm/src/context/ContextProvider.d.ts +1 -1
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +1 -1
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/types.d.ts +2 -0
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -15
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/InternalAuth.d.ts +0 -1
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +1 -14
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +25 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +156 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +79 -27
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +1 -1
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +1 -0
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +19 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +40 -7
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +14 -4
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +1 -0
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +19 -16
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +39 -6
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +15 -4
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +2 -2
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +143 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/script/src/context/Context.d.ts +1 -0
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -0
- package/script/src/context/ContextProvider.d.ts +1 -1
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +1 -1
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/types.d.ts +2 -0
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -15
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/InternalAuth.d.ts +0 -1
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -13
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +25 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +163 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +84 -32
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +1 -1
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +1 -0
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +19 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +40 -7
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +14 -4
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +1 -0
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +19 -16
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +39 -6
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +15 -4
- package/script/src/issues/Issues.js +1 -1
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/dsl/http/default.d.ts +0 -26
- package/esm/src/dsl/http/default.d.ts.map +0 -1
- package/esm/src/dsl/http/default.js +0 -56
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -32
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -37
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -102
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -208
- package/esm/src/internal/cli.d.ts +0 -2
- package/esm/src/internal/cli.d.ts.map +0 -1
- package/esm/src/internal/cli.js +0 -32
- package/script/src/dsl/http/default.d.ts +0 -26
- package/script/src/dsl/http/default.d.ts.map +0 -1
- package/script/src/dsl/http/default.js +0 -60
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -35
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -40
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -106
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -212
- package/script/src/internal/cli.d.ts +0 -2
- package/script/src/internal/cli.d.ts.map +0 -1
- package/script/src/internal/cli.js +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"AAoBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,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,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAsBrD"}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InternalAuth = void 0;
|
|
16
|
-
const cli_js_1 = require("./cli.js");
|
|
17
16
|
const constants_js_1 = require("./constants.js");
|
|
18
17
|
class InternalAuth {
|
|
19
18
|
constructor() {
|
|
@@ -35,12 +34,6 @@ class InternalAuth {
|
|
|
35
34
|
writable: true,
|
|
36
35
|
value: void 0
|
|
37
36
|
});
|
|
38
|
-
Object.defineProperty(this, "runLocal", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
37
|
Object.defineProperty(this, "accessToken", {
|
|
45
38
|
enumerable: true,
|
|
46
39
|
configurable: true,
|
|
@@ -58,18 +51,12 @@ class InternalAuth {
|
|
|
58
51
|
this.tokenEndpoint = Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
|
|
59
52
|
this.accessToken = '';
|
|
60
53
|
this.expiresAt = 0;
|
|
61
|
-
this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
62
54
|
if (Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
63
55
|
this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
64
56
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
65
57
|
console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
|
|
66
58
|
return;
|
|
67
59
|
}
|
|
68
|
-
if (this.runLocal) {
|
|
69
|
-
console.info('Running in local mode using cookie for authentication');
|
|
70
|
-
this.accessToken = (0, cli_js_1.getVersoriCookie)();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
60
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
74
61
|
const missingVars = [];
|
|
75
62
|
if (!this.clientId)
|
|
@@ -10,11 +10,13 @@ export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
|
|
|
10
10
|
export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
|
|
11
11
|
export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
|
|
12
12
|
export declare const envVarVersion = "RUN_SERVICE_VERSION";
|
|
13
|
+
export declare const envReadyCheckURL = "READY_CHECK_URL";
|
|
14
|
+
export declare const envPort = "PORT";
|
|
15
|
+
export declare const envCronPort = "CRON_PORT";
|
|
13
16
|
export declare const envVarConfigFile = "RUN_CONFIG_FILE";
|
|
14
17
|
export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
15
18
|
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
16
19
|
export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
|
|
17
20
|
export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
|
|
18
|
-
export declare const envVarLocalRun = "RUN_LOCAL";
|
|
19
21
|
export declare const cronPort = 3001;
|
|
20
22
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/src/internal/constants.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/src/internal/constants.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAA;AACjD,eAAO,MAAM,OAAO,SAAS,CAAC;AAC9B,eAAO,MAAM,WAAW,cAAc,CAAC;AAGvC,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAMxD,eAAO,MAAM,QAAQ,OAAO,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.cronPort = exports.
|
|
15
|
+
exports.cronPort = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envCronPort = exports.envPort = exports.envReadyCheckURL = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarSDKApiBaseURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
|
|
16
16
|
// This file contains constants used in the Versori DSL HTTP client.
|
|
17
17
|
exports.envVarOrgId = 'RUN_ORGANISATION_ID';
|
|
18
18
|
exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
|
|
@@ -26,6 +26,9 @@ exports.envVarSelfRefURL = 'RUN_SELF_REF_URL';
|
|
|
26
26
|
exports.envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
|
|
27
27
|
exports.envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
|
|
28
28
|
exports.envVarVersion = 'RUN_SERVICE_VERSION';
|
|
29
|
+
exports.envReadyCheckURL = 'READY_CHECK_URL';
|
|
30
|
+
exports.envPort = 'PORT';
|
|
31
|
+
exports.envCronPort = 'CRON_PORT';
|
|
29
32
|
// The following environment variables are used for the config file
|
|
30
33
|
exports.envVarConfigFile = 'RUN_CONFIG_FILE';
|
|
31
34
|
// The following environment variables are used for internal authentication
|
|
@@ -34,6 +37,6 @@ exports.envVarClientSecret = 'RUN_CLIENT_SECRET';
|
|
|
34
37
|
exports.envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
|
|
35
38
|
exports.envVarInternalToken = 'RUN_INTERNAL_TOKEN';
|
|
36
39
|
// The following are for running locally
|
|
37
|
-
|
|
40
|
+
// export const envVarLocalRun = 'RUN_LOCAL';
|
|
38
41
|
// please no changerino
|
|
39
42
|
exports.cronPort = 3001; // The port on which the cron API communicates with the service
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
2
|
+
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-node';
|
|
3
|
+
export declare const enabled: boolean;
|
|
4
|
+
type Webhooks = Map<string, {
|
|
5
|
+
method: string;
|
|
6
|
+
path: string;
|
|
7
|
+
options: any;
|
|
8
|
+
}>;
|
|
9
|
+
type Crons = Map<string, string>;
|
|
10
|
+
type MockConnection = {
|
|
11
|
+
name: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function registerWebhooks(webhooks: Webhooks): Promise<void>;
|
|
16
|
+
export declare function registerCrons(crons: Crons): Promise<void>;
|
|
17
|
+
export declare function mockAPIRequest(info: RequestInfo | URL, cnx?: MockConnection, options?: RequestInit): Promise<Response>;
|
|
18
|
+
export declare class Fake implements SpanExporter {
|
|
19
|
+
constructor();
|
|
20
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
21
|
+
shutdown(): Promise<void>;
|
|
22
|
+
forceFlush(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=supervisor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/src/internal/supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAA6D,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAO3E,eAAO,MAAM,OAAO,SAEjB,CAAA;AAyBH,KAAK,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAC5E,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjC,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxE;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/D;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoC5H;AAyBD,qBAAa,IAAK,YAAW,YAAY;;IAOrC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAmBnF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Fake = exports.enabled = void 0;
|
|
16
|
+
exports.registerWebhooks = registerWebhooks;
|
|
17
|
+
exports.registerCrons = registerCrons;
|
|
18
|
+
exports.mockAPIRequest = mockAPIRequest;
|
|
19
|
+
const core_1 = require("@opentelemetry/core");
|
|
20
|
+
const ConsoleLogger_js_1 = require("../observability/logging/ConsoleLogger.js");
|
|
21
|
+
const supervisorURL = function () {
|
|
22
|
+
return Deno.env.get('RUN_SUPERVISOR_URL') || '';
|
|
23
|
+
}();
|
|
24
|
+
exports.enabled = function () {
|
|
25
|
+
return Deno.env.get('RUN_SUPERVISOR_URL') ? true : false;
|
|
26
|
+
}();
|
|
27
|
+
const flows = function () {
|
|
28
|
+
try {
|
|
29
|
+
const _cwd = Deno.cwd();
|
|
30
|
+
const flowsFile = Deno.readTextFileSync(_cwd + '/versori-flow.json');
|
|
31
|
+
const flows = JSON.parse(flowsFile);
|
|
32
|
+
const nodes = {};
|
|
33
|
+
for (const node of flows.nodes) {
|
|
34
|
+
nodes[node.id] = {
|
|
35
|
+
description: node.data.description,
|
|
36
|
+
steps: node.data.steps,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return nodes;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
}();
|
|
45
|
+
const logger = new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
46
|
+
async function registerWebhooks(webhooks) {
|
|
47
|
+
if (!exports.enabled) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await fetch(`${supervisorURL}/register-webhooks`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
body: JSON.stringify(Object.fromEntries(webhooks)),
|
|
54
|
+
headers: {
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
logger.error('Failed to register webhooks with supervisor', { error: err });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function registerCrons(crons) {
|
|
64
|
+
if (!exports.enabled) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await fetch(`${supervisorURL}/register-schedulers`, {
|
|
69
|
+
method: "POST",
|
|
70
|
+
body: JSON.stringify(Object.fromEntries(crons)),
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
logger.error('Failed to register crons with supervisor', { error: err });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function mockAPIRequest(info, cnx, options) {
|
|
81
|
+
if (!exports.enabled) {
|
|
82
|
+
return new Response();
|
|
83
|
+
}
|
|
84
|
+
const mockRequest = {
|
|
85
|
+
url: info.toString(),
|
|
86
|
+
payload: options?.body || '',
|
|
87
|
+
method: options?.method || "GET",
|
|
88
|
+
headers: options?.headers,
|
|
89
|
+
connection: cnx?.name,
|
|
90
|
+
connectionId: cnx?.id,
|
|
91
|
+
};
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(`${supervisorURL}/ai/fake-fetch-call`, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: JSON.stringify(mockRequest),
|
|
96
|
+
headers: {
|
|
97
|
+
"Content-Type": "application/json",
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
logger.error('Failed to mock api request', { response });
|
|
102
|
+
return new Response();
|
|
103
|
+
}
|
|
104
|
+
const text = await response.text();
|
|
105
|
+
return new Response(text);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
logger.error('Failed to mock api request', { error: err });
|
|
109
|
+
return new Response();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function printableSpan(s) {
|
|
113
|
+
let span = {
|
|
114
|
+
name: s.name,
|
|
115
|
+
startTime: (0, core_1.hrTimeToTimeStamp)(s.startTime),
|
|
116
|
+
endTime: (0, core_1.hrTimeToTimeStamp)(s.endTime),
|
|
117
|
+
duration: (0, core_1.hrTimeToMilliseconds)(s.duration),
|
|
118
|
+
attributes: s.attributes,
|
|
119
|
+
status: s.status,
|
|
120
|
+
ended: s.ended,
|
|
121
|
+
events: s.events,
|
|
122
|
+
parentSpanContext: s.parentSpanContext,
|
|
123
|
+
spanContext: s.spanContext(),
|
|
124
|
+
};
|
|
125
|
+
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
126
|
+
if (nodeDetail) {
|
|
127
|
+
span.attributes['description'] = nodeDetail.description;
|
|
128
|
+
span.attributes['steps'] = nodeDetail.steps;
|
|
129
|
+
}
|
|
130
|
+
return span;
|
|
131
|
+
}
|
|
132
|
+
class Fake {
|
|
133
|
+
constructor() {
|
|
134
|
+
this.export = this.export.bind(this);
|
|
135
|
+
this.shutdown = this.shutdown.bind(this);
|
|
136
|
+
this.forceFlush = this.forceFlush.bind(this);
|
|
137
|
+
}
|
|
138
|
+
export(spans, resultCallback) {
|
|
139
|
+
const ss = spans.map(printableSpan);
|
|
140
|
+
try {
|
|
141
|
+
fetch(`${supervisorURL}/receive-spans`, {
|
|
142
|
+
method: "POST",
|
|
143
|
+
body: JSON.stringify({ spans: ss }),
|
|
144
|
+
headers: {
|
|
145
|
+
"Content-Type": "application/json",
|
|
146
|
+
},
|
|
147
|
+
}).catch((err) => {
|
|
148
|
+
logger.error('Failed to send spans to supervisor', { error: err });
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
logger.error('Failed to send spans to supervisor', { error: err });
|
|
153
|
+
}
|
|
154
|
+
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
155
|
+
}
|
|
156
|
+
shutdown() {
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
forceFlush() {
|
|
160
|
+
return Promise.resolve();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.Fake = Fake;
|
|
@@ -45,6 +45,11 @@ type Registration = {
|
|
|
45
45
|
sigintListener: () => void;
|
|
46
46
|
subscription?: Subscription;
|
|
47
47
|
};
|
|
48
|
+
type WebhookRegistry = Map<string, {
|
|
49
|
+
method: string;
|
|
50
|
+
path: string;
|
|
51
|
+
options: any;
|
|
52
|
+
}>;
|
|
48
53
|
/**
|
|
49
54
|
* DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
50
55
|
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
@@ -75,7 +80,8 @@ export declare class DurableInterpreter {
|
|
|
75
80
|
private readonly contextProvider;
|
|
76
81
|
private readonly webhookRouter;
|
|
77
82
|
private readonly cronRouter;
|
|
78
|
-
private
|
|
83
|
+
private cronRegistry;
|
|
84
|
+
private webhookRegistry;
|
|
79
85
|
private readonly platformApi;
|
|
80
86
|
private readonly cnxFetchFactory;
|
|
81
87
|
private readonly cronProvider;
|
|
@@ -89,7 +95,7 @@ export declare class DurableInterpreter {
|
|
|
89
95
|
private cronServer?;
|
|
90
96
|
private shutdownServer?;
|
|
91
97
|
private isShuttingDown;
|
|
92
|
-
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
98
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
93
99
|
static newInstance(options?: DurableInterpreterOptions): Promise<DurableInterpreter>;
|
|
94
100
|
register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration;
|
|
95
101
|
start(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"AAcA,OAAsB,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,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KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoH9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAqDhE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+N5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DurableInterpreter = void 0;
|
|
2
7
|
/*
|
|
3
8
|
* Copyright (c) 2025 Versori Group Inc
|
|
4
9
|
*
|
|
@@ -11,11 +16,8 @@
|
|
|
11
16
|
* As of the Change Date, in accordance with the Business Source License,
|
|
12
17
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
18
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DurableInterpreter = void 0;
|
|
19
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
20
|
+
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
19
21
|
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
20
22
|
const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
21
23
|
const resources_1 = require("@opentelemetry/resources");
|
|
@@ -24,32 +26,54 @@ const express_1 = __importDefault(require("express"));
|
|
|
24
26
|
const rxjs_1 = require("rxjs");
|
|
25
27
|
const DirectConnectionFactory_js_1 = require("../../connection/DirectConnectionFactory.js");
|
|
26
28
|
const ContextProvider_js_1 = require("../../context/ContextProvider.js");
|
|
27
|
-
const default_js_1 = require("../../dsl/http/default.js");
|
|
28
29
|
const configloader_js_1 = require("../../dsl/http/versori/configloader.js");
|
|
29
|
-
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
30
30
|
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
31
|
-
const proxyroundtripper_js_1 = require("../../dsl/http/versori/proxyroundtripper.js");
|
|
32
31
|
const Workflow_js_1 = require("../../dsl/Workflow.js");
|
|
32
|
+
const constants_js_1 = require("../../internal/constants.js");
|
|
33
|
+
const supervisor_js_1 = require("../../internal/supervisor.js");
|
|
33
34
|
const Issues_js_1 = require("../../issues/Issues.js");
|
|
34
35
|
const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
|
|
35
36
|
const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
|
|
36
37
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
38
|
+
const mod_js_1 = require("../../services/credentials/mod.js");
|
|
37
39
|
const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
|
|
38
40
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
39
41
|
const Queue_js_1 = require("./Queue.js");
|
|
40
|
-
function getKVProvider(
|
|
41
|
-
if (
|
|
42
|
+
function getKVProvider() {
|
|
43
|
+
if (supervisor_js_1.enabled) {
|
|
42
44
|
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
43
45
|
}
|
|
44
46
|
return SDKKeyValueProvider_js_1.SDKKeyValueProvider.fromEnv();
|
|
45
47
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
function getCredentialsProvider(d) {
|
|
49
|
+
return {
|
|
50
|
+
async getRaw(name, _activationId) {
|
|
51
|
+
const response = await d['credentials'].get({ id: name, organisationId: '' });
|
|
52
|
+
if (!response.credential) {
|
|
53
|
+
throw new Error(`Failed to get credential: ${name}`);
|
|
54
|
+
}
|
|
55
|
+
const rawData = (0, protobuf_1.create)(mod_js_1.credentialv1alpha1.CredentialDataRawSchema, response.credential.data);
|
|
56
|
+
return rawData.raw;
|
|
57
|
+
},
|
|
58
|
+
async getAccessToken(name, forceRefresh, _activationId) {
|
|
59
|
+
const response = await d['tokens'].getToken({ credentialId: name, forceRefresh: forceRefresh || false });
|
|
60
|
+
if (!response.token) {
|
|
61
|
+
throw new Error(`Failed to get token for credential: ${name}`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
accessToken: response.token.accessToken,
|
|
65
|
+
tokenType: response.token.tokenType,
|
|
66
|
+
expiry: response.token.expiry ? new Date((0, wkt_1.timestampMs)(response.token.expiry)) : undefined,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
async getOAuth1Metadata(name, _activationId) {
|
|
70
|
+
const response = await d['oauth1'].getAuthorizationMetadata({ credentialId: name });
|
|
71
|
+
if (!response) {
|
|
72
|
+
throw new Error(`Failed to get OAuth1 metadata for credential: ${name}`);
|
|
73
|
+
}
|
|
74
|
+
return response;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
53
77
|
}
|
|
54
78
|
/**
|
|
55
79
|
* DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
@@ -76,7 +100,7 @@ function getRoundTripperFactory(log, _tracer, opts) {
|
|
|
76
100
|
* ```
|
|
77
101
|
*/
|
|
78
102
|
class DurableInterpreter {
|
|
79
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
|
|
103
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, platformApi, cnxFetchFactory, cronProvider, tracer, issue, cfgReader, queueProvider, otelSDK) {
|
|
80
104
|
Object.defineProperty(this, "log", {
|
|
81
105
|
enumerable: true,
|
|
82
106
|
configurable: true,
|
|
@@ -113,6 +137,12 @@ class DurableInterpreter {
|
|
|
113
137
|
writable: true,
|
|
114
138
|
value: cronRegistry
|
|
115
139
|
});
|
|
140
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: webhookRegistry
|
|
145
|
+
});
|
|
116
146
|
Object.defineProperty(this, "platformApi", {
|
|
117
147
|
enumerable: true,
|
|
118
148
|
configurable: true,
|
|
@@ -211,7 +241,6 @@ class DurableInterpreter {
|
|
|
211
241
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
212
242
|
let otelSDK;
|
|
213
243
|
const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
|
|
214
|
-
const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
215
244
|
await waitForReady(log);
|
|
216
245
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
217
246
|
const resource = (0, resources_1.resourceFromAttributes)({
|
|
@@ -233,24 +262,31 @@ class DurableInterpreter {
|
|
|
233
262
|
log.info('Starting OpenTelemetry SDK');
|
|
234
263
|
otelSDK.start();
|
|
235
264
|
}
|
|
265
|
+
else if (supervisor_js_1.enabled) {
|
|
266
|
+
otelSDK = new sdk_node_1.NodeSDK({
|
|
267
|
+
traceExporter: new supervisor_js_1.Fake(),
|
|
268
|
+
serviceName: serviceName,
|
|
269
|
+
resource: resource,
|
|
270
|
+
});
|
|
271
|
+
log.info('Starting Testing OpenTelemetry SDK');
|
|
272
|
+
otelSDK.start();
|
|
273
|
+
}
|
|
236
274
|
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
runLocal: runLocal,
|
|
240
|
-
});
|
|
275
|
+
const cnxFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
|
|
276
|
+
const credentialsProvider = getCredentialsProvider(cnxFactory);
|
|
241
277
|
const queueProvider = await Queue_js_1.QueueImpl.fromEnv(log);
|
|
242
278
|
const issuesProvider = new Issues_js_1.IssueImpl(log);
|
|
243
279
|
if (options.contextProvider) {
|
|
244
280
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
245
281
|
// initialised.
|
|
246
|
-
return new DurableInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(),
|
|
282
|
+
return new DurableInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), cnxFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
247
283
|
}
|
|
248
|
-
const kvp = await getKVProvider(
|
|
284
|
+
const kvp = await getKVProvider();
|
|
249
285
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
250
286
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
251
287
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
252
|
-
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp,
|
|
253
|
-
return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(),
|
|
288
|
+
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, credentialsProvider, platformApi, organisationId, environmentId, issuesProvider);
|
|
289
|
+
return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(), cnxFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
254
290
|
}
|
|
255
291
|
register(workflow, options) {
|
|
256
292
|
const localAbortController = new AbortController();
|
|
@@ -267,6 +303,7 @@ class DurableInterpreter {
|
|
|
267
303
|
tracer: this.tracer,
|
|
268
304
|
contextProvider: this.contextProvider,
|
|
269
305
|
webhookRouter: this.webhookRouter,
|
|
306
|
+
webhookRegistry: this.webhookRegistry,
|
|
270
307
|
queueProvider: this.queueProvider,
|
|
271
308
|
cronRouter: this.cronRouter,
|
|
272
309
|
cronRegistry: this.cronRegistry,
|
|
@@ -290,9 +327,9 @@ class DurableInterpreter {
|
|
|
290
327
|
this.registeredWorkflows.push(registration);
|
|
291
328
|
return registration;
|
|
292
329
|
}
|
|
293
|
-
start() {
|
|
294
|
-
const port = Deno.env.get(
|
|
295
|
-
const cronPort = Deno.env.get(
|
|
330
|
+
async start() {
|
|
331
|
+
const port = Deno.env.get(constants_js_1.envPort) || 3000;
|
|
332
|
+
const cronPort = Deno.env.get(constants_js_1.envCronPort) || 3001;
|
|
296
333
|
const webhookApp = (0, express_1.default)();
|
|
297
334
|
const cronApp = (0, express_1.default)();
|
|
298
335
|
cronApp.use(express_1.default.json());
|
|
@@ -316,11 +353,17 @@ class DurableInterpreter {
|
|
|
316
353
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
317
354
|
error: err instanceof Error ? err.toString() : err,
|
|
318
355
|
});
|
|
356
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
357
|
+
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
358
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
359
|
+
span.setAttribute('result', 'fail');
|
|
360
|
+
span.end();
|
|
361
|
+
});
|
|
319
362
|
try {
|
|
320
363
|
ctx.options.onError?.(ctx.withData(err));
|
|
321
364
|
}
|
|
322
365
|
catch (err) {
|
|
323
|
-
ctx.log.error('DurableInterpreter.
|
|
366
|
+
ctx.log.error('DurableInterpreter.onError Error: failed to call onError handler', { error: err instanceof Error ? err.toString() : err });
|
|
324
367
|
ctx.options.onError?.(ctx.withData({
|
|
325
368
|
message: 'Internal server error',
|
|
326
369
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -335,6 +378,11 @@ class DurableInterpreter {
|
|
|
335
378
|
durationMs,
|
|
336
379
|
data: ctx.data,
|
|
337
380
|
});
|
|
381
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
382
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
383
|
+
span.setAttribute('result', 'pass');
|
|
384
|
+
span.end();
|
|
385
|
+
});
|
|
338
386
|
try {
|
|
339
387
|
ctx.options.onSuccess?.(ctx);
|
|
340
388
|
}
|
|
@@ -382,6 +430,9 @@ class DurableInterpreter {
|
|
|
382
430
|
});
|
|
383
431
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
384
432
|
}
|
|
433
|
+
// register with supervisor
|
|
434
|
+
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
435
|
+
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
385
436
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
386
437
|
this.log.info(`Express server listening on port ${port}`);
|
|
387
438
|
});
|
|
@@ -401,6 +452,7 @@ class DurableInterpreter {
|
|
|
401
452
|
if (this.cronServer) {
|
|
402
453
|
this.cronServer.close();
|
|
403
454
|
}
|
|
455
|
+
this.otelSDK?.shutdown();
|
|
404
456
|
// Remove all signal listeners
|
|
405
457
|
for (const registration of this.registeredWorkflows) {
|
|
406
458
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -454,7 +506,7 @@ class DurableInterpreter {
|
|
|
454
506
|
}
|
|
455
507
|
exports.DurableInterpreter = DurableInterpreter;
|
|
456
508
|
async function waitForReady(log) {
|
|
457
|
-
const readyCheckUrl = Deno.env.get(
|
|
509
|
+
const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
|
|
458
510
|
if (!readyCheckUrl) {
|
|
459
511
|
return Promise.resolve();
|
|
460
512
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Tracer } from '@opentelemetry/api';
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
import { Observable, OperatorFunction } from 'rxjs';
|
|
4
|
+
import { ConnectionFactory } from '../../connection/types.js';
|
|
4
5
|
import { ContextImpl } from '../../context/Context.js';
|
|
5
6
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
6
7
|
import { ConfigReader } from '../../dsl/http/types.js';
|
|
@@ -11,7 +12,6 @@ import { Logger } from '../../observability/logging/Logger.js';
|
|
|
11
12
|
import { PlatformApi } from '../../services/platform/mod.js';
|
|
12
13
|
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
13
14
|
import { QueueAPI } from './Queue.js';
|
|
14
|
-
import { ConnectionFactory } from '../../connection/types.js';
|
|
15
15
|
export type DurableCompilerContext = {
|
|
16
16
|
compiler: ObservableCompiler;
|
|
17
17
|
log: Logger;
|
|
@@ -22,6 +22,11 @@ export type DurableCompilerContext = {
|
|
|
22
22
|
queueProvider: QueueAPI;
|
|
23
23
|
issueProvider: IssueAPI;
|
|
24
24
|
webhookRouter: Router;
|
|
25
|
+
webhookRegistry: Map<string, {
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
options: any;
|
|
29
|
+
}>;
|
|
25
30
|
cronRouter: Router;
|
|
26
31
|
configReader: ConfigReader;
|
|
27
32
|
cronRegistry: Map<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,k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G,CAAC,GACpB,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC;IAe1C,cAAc,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAC3D,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAerC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MockQueue = exports.QueueImpl = void 0;
|
|
16
|
-
const constants_js_1 = require("../../
|
|
16
|
+
const constants_js_1 = require("../../internal/constants.js");
|
|
17
17
|
const mod_js_1 = require("../../mod.js");
|
|
18
18
|
class QueueImpl {
|
|
19
19
|
constructor(baseUrl, projectId, environmentId, log) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -25,6 +25,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
25
25
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
26
26
|
span.setAttribute('execution.id', ctx.executionId);
|
|
27
27
|
span.setAttribute('task.type', 'catch');
|
|
28
|
+
span.setAttribute('type', 'task');
|
|
28
29
|
if (error instanceof Error) {
|
|
29
30
|
span.recordException(error);
|
|
30
31
|
span.setAttribute('error.message', error.message);
|