@versori/run 0.4.5 → 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 +3 -5
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +0 -5
- 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 +80 -15
- 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 +79 -14
- 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/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +2 -2
- package/esm/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValueProvider.js +3 -3
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts +3 -5
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +0 -5
- 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 +85 -20
- 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 -13
- 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/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +2 -2
- package/script/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValueProvider.js +3 -3
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +0 -35
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.js +0 -113
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +0 -40
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.js +0 -82
- package/esm/src/connection/CredentialsProvider.d.ts +0 -17
- package/esm/src/connection/CredentialsProvider.d.ts.map +0 -1
- package/esm/src/connection/CredentialsProvider.js +0 -63
- package/esm/src/credentials/CredentialsProvider.d.ts +0 -49
- package/esm/src/credentials/CredentialsProvider.d.ts.map +0 -1
- package/esm/src/credentials/CredentialsProvider.js +0 -102
- 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/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/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +0 -35
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.js +0 -119
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -16
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -3
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +0 -40
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.js +0 -86
- package/script/src/connection/CredentialsProvider.d.ts +0 -17
- package/script/src/connection/CredentialsProvider.d.ts.map +0 -1
- package/script/src/connection/CredentialsProvider.js +0 -67
- package/script/src/credentials/CredentialsProvider.d.ts +0 -49
- package/script/src/credentials/CredentialsProvider.d.ts.map +0 -1
- package/script/src/credentials/CredentialsProvider.js +0 -106
- 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/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,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");
|
|
@@ -25,22 +27,54 @@ 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
29
|
const configloader_js_1 = require("../../dsl/http/versori/configloader.js");
|
|
28
|
-
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
29
30
|
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
30
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");
|
|
31
34
|
const Issues_js_1 = require("../../issues/Issues.js");
|
|
32
35
|
const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
|
|
33
36
|
const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
|
|
34
37
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
38
|
+
const mod_js_1 = require("../../services/credentials/mod.js");
|
|
35
39
|
const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
|
|
36
40
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
37
41
|
const Queue_js_1 = require("./Queue.js");
|
|
38
|
-
function getKVProvider(
|
|
39
|
-
if (
|
|
42
|
+
function getKVProvider() {
|
|
43
|
+
if (supervisor_js_1.enabled) {
|
|
40
44
|
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
41
45
|
}
|
|
42
46
|
return SDKKeyValueProvider_js_1.SDKKeyValueProvider.fromEnv();
|
|
43
47
|
}
|
|
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
|
+
};
|
|
77
|
+
}
|
|
44
78
|
/**
|
|
45
79
|
* DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
46
80
|
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
@@ -66,7 +100,7 @@ function getKVProvider(runLocal) {
|
|
|
66
100
|
* ```
|
|
67
101
|
*/
|
|
68
102
|
class DurableInterpreter {
|
|
69
|
-
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) {
|
|
70
104
|
Object.defineProperty(this, "log", {
|
|
71
105
|
enumerable: true,
|
|
72
106
|
configurable: true,
|
|
@@ -103,6 +137,12 @@ class DurableInterpreter {
|
|
|
103
137
|
writable: true,
|
|
104
138
|
value: cronRegistry
|
|
105
139
|
});
|
|
140
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: webhookRegistry
|
|
145
|
+
});
|
|
106
146
|
Object.defineProperty(this, "platformApi", {
|
|
107
147
|
enumerable: true,
|
|
108
148
|
configurable: true,
|
|
@@ -201,7 +241,6 @@ class DurableInterpreter {
|
|
|
201
241
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
202
242
|
let otelSDK;
|
|
203
243
|
const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
|
|
204
|
-
const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
205
244
|
await waitForReady(log);
|
|
206
245
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
207
246
|
const resource = (0, resources_1.resourceFromAttributes)({
|
|
@@ -223,21 +262,31 @@ class DurableInterpreter {
|
|
|
223
262
|
log.info('Starting OpenTelemetry SDK');
|
|
224
263
|
otelSDK.start();
|
|
225
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
|
+
}
|
|
226
274
|
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
275
|
+
const cnxFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
|
|
276
|
+
const credentialsProvider = getCredentialsProvider(cnxFactory);
|
|
227
277
|
const queueProvider = await Queue_js_1.QueueImpl.fromEnv(log);
|
|
228
|
-
const connectionFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
|
|
229
278
|
const issuesProvider = new Issues_js_1.IssueImpl(log);
|
|
230
279
|
if (options.contextProvider) {
|
|
231
280
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
232
281
|
// initialised.
|
|
233
|
-
return new DurableInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(),
|
|
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);
|
|
234
283
|
}
|
|
235
|
-
const kvp = await getKVProvider(
|
|
284
|
+
const kvp = await getKVProvider();
|
|
236
285
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
237
286
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
238
287
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
239
|
-
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp,
|
|
240
|
-
return new DurableInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), PlatformApi_js_1.PlatformApiImpl.fromEnv(),
|
|
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);
|
|
241
290
|
}
|
|
242
291
|
register(workflow, options) {
|
|
243
292
|
const localAbortController = new AbortController();
|
|
@@ -254,6 +303,7 @@ class DurableInterpreter {
|
|
|
254
303
|
tracer: this.tracer,
|
|
255
304
|
contextProvider: this.contextProvider,
|
|
256
305
|
webhookRouter: this.webhookRouter,
|
|
306
|
+
webhookRegistry: this.webhookRegistry,
|
|
257
307
|
queueProvider: this.queueProvider,
|
|
258
308
|
cronRouter: this.cronRouter,
|
|
259
309
|
cronRegistry: this.cronRegistry,
|
|
@@ -277,9 +327,9 @@ class DurableInterpreter {
|
|
|
277
327
|
this.registeredWorkflows.push(registration);
|
|
278
328
|
return registration;
|
|
279
329
|
}
|
|
280
|
-
start() {
|
|
281
|
-
const port = Deno.env.get(
|
|
282
|
-
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;
|
|
283
333
|
const webhookApp = (0, express_1.default)();
|
|
284
334
|
const cronApp = (0, express_1.default)();
|
|
285
335
|
cronApp.use(express_1.default.json());
|
|
@@ -303,11 +353,17 @@ class DurableInterpreter {
|
|
|
303
353
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
304
354
|
error: err instanceof Error ? err.toString() : err,
|
|
305
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
|
+
});
|
|
306
362
|
try {
|
|
307
363
|
ctx.options.onError?.(ctx.withData(err));
|
|
308
364
|
}
|
|
309
365
|
catch (err) {
|
|
310
|
-
ctx.log.error('DurableInterpreter.
|
|
366
|
+
ctx.log.error('DurableInterpreter.onError Error: failed to call onError handler', { error: err instanceof Error ? err.toString() : err });
|
|
311
367
|
ctx.options.onError?.(ctx.withData({
|
|
312
368
|
message: 'Internal server error',
|
|
313
369
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -322,6 +378,11 @@ class DurableInterpreter {
|
|
|
322
378
|
durationMs,
|
|
323
379
|
data: ctx.data,
|
|
324
380
|
});
|
|
381
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
382
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
383
|
+
span.setAttribute('result', 'pass');
|
|
384
|
+
span.end();
|
|
385
|
+
});
|
|
325
386
|
try {
|
|
326
387
|
ctx.options.onSuccess?.(ctx);
|
|
327
388
|
}
|
|
@@ -369,6 +430,9 @@ class DurableInterpreter {
|
|
|
369
430
|
});
|
|
370
431
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
371
432
|
}
|
|
433
|
+
// register with supervisor
|
|
434
|
+
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
435
|
+
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
372
436
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
373
437
|
this.log.info(`Express server listening on port ${port}`);
|
|
374
438
|
});
|
|
@@ -388,6 +452,7 @@ class DurableInterpreter {
|
|
|
388
452
|
if (this.cronServer) {
|
|
389
453
|
this.cronServer.close();
|
|
390
454
|
}
|
|
455
|
+
this.otelSDK?.shutdown();
|
|
391
456
|
// Remove all signal listeners
|
|
392
457
|
for (const registration of this.registeredWorkflows) {
|
|
393
458
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -441,7 +506,7 @@ class DurableInterpreter {
|
|
|
441
506
|
}
|
|
442
507
|
exports.DurableInterpreter = DurableInterpreter;
|
|
443
508
|
async function waitForReady(log) {
|
|
444
|
-
const readyCheckUrl = Deno.env.get(
|
|
509
|
+
const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
|
|
445
510
|
if (!readyCheckUrl) {
|
|
446
511
|
return Promise.resolve();
|
|
447
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,kCAAkC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM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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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA0CnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -15,19 +15,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.fnCompiler = void 0;
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
17
|
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
18
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
18
19
|
function compileFn(compilerCtx, task) {
|
|
19
20
|
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
20
21
|
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
21
22
|
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
22
23
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
23
24
|
span.setAttribute('task.id', task.id);
|
|
25
|
+
span.setAttribute('type', 'task');
|
|
26
|
+
span.setAttribute('task.type', 'fn');
|
|
24
27
|
span.setAttribute('execution.id', ctx.executionId);
|
|
25
|
-
|
|
28
|
+
try {
|
|
29
|
+
const spanContext = span.spanContext();
|
|
30
|
+
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
31
|
+
let result;
|
|
32
|
+
if (typeof ctx.idx === 'number') {
|
|
33
|
+
result = ctx.withData(await task._fn(ctxWithLogger, ctx.idx));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result = ctx.withData(await task._fn(ctxWithLogger));
|
|
37
|
+
}
|
|
38
|
+
if (supervisor_js_1.enabled) {
|
|
39
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
26
44
|
span.end();
|
|
27
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
28
45
|
}
|
|
29
|
-
span.end();
|
|
30
|
-
return ctx.withData(await task._fn(ctx));
|
|
31
46
|
});
|
|
32
47
|
}));
|
|
33
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAuHnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -15,18 +15,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.httpCompiler = void 0;
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
17
|
const operators_1 = require("rxjs/operators");
|
|
18
|
-
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
19
18
|
const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
|
|
19
|
+
const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
|
|
20
20
|
const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
|
|
21
|
+
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
22
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
21
23
|
function compileHttp(compilerCtx, task) {
|
|
22
24
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
23
25
|
let fetchFactory;
|
|
24
26
|
if (!cnxMap) {
|
|
25
|
-
compilerCtx.log.
|
|
26
|
-
|
|
27
|
+
compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
|
|
28
|
+
if (supervisor_js_1.enabled) {
|
|
29
|
+
// missing connection map and we are in supervised mode, so we use the fake fetcher
|
|
30
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// missing connection map and not in supervised mode, so we use global fetch
|
|
34
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
else if (cnxMap.dynamic) {
|
|
29
|
-
|
|
38
|
+
if (cnxMap.mockWithAI) {
|
|
39
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
43
|
+
}
|
|
30
44
|
}
|
|
31
45
|
else {
|
|
32
46
|
fetchFactory = compilerCtx.platformApi.getConnection({
|
|
@@ -36,8 +50,21 @@ function compileHttp(compilerCtx, task) {
|
|
|
36
50
|
},
|
|
37
51
|
throwOnError: true,
|
|
38
52
|
})
|
|
39
|
-
.then(({ data }) =>
|
|
40
|
-
.
|
|
53
|
+
.then(({ data }) => {
|
|
54
|
+
if (cnxMap.mockWithAI) {
|
|
55
|
+
// use the fake fetcher that calls the supervisor to generate a mock reponse
|
|
56
|
+
return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
|
|
57
|
+
}
|
|
58
|
+
return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
|
|
59
|
+
.then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
|
|
60
|
+
})
|
|
61
|
+
.catch((err) => {
|
|
62
|
+
compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
|
|
63
|
+
if (supervisor_js_1.enabled) {
|
|
64
|
+
return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
|
|
65
|
+
}
|
|
66
|
+
throw err;
|
|
67
|
+
});
|
|
41
68
|
}
|
|
42
69
|
async function http(ctx) {
|
|
43
70
|
const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
|
|
@@ -51,10 +78,16 @@ function compileHttp(compilerCtx, task) {
|
|
|
51
78
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
52
79
|
span.setAttribute('task.id', task.id);
|
|
53
80
|
span.setAttribute('task.type', 'http');
|
|
81
|
+
span.setAttribute('type', 'task');
|
|
54
82
|
span.setAttribute('execution.id', ctx.executionId);
|
|
55
83
|
span.setAttribute('connection.name', task.opts.connection);
|
|
84
|
+
const spanContext = span.spanContext();
|
|
56
85
|
try {
|
|
57
|
-
|
|
86
|
+
const result = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
87
|
+
if (supervisor_js_1.enabled) {
|
|
88
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
58
91
|
}
|
|
59
92
|
catch (error) {
|
|
60
93
|
if (error instanceof Error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.scheduleCompiler = void 0;
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
|
-
const constants_js_1 = require("../../../dsl/http/versori/constants.js");
|
|
18
17
|
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
18
|
+
const constants_js_1 = require("../../../internal/constants.js");
|
|
19
19
|
function compileSchedule(ctx, trigger, signal) {
|
|
20
20
|
return new rxjs_1.Observable((subscriber) => {
|
|
21
21
|
// Add HTTP endpoint for manual triggering
|
|
@@ -106,6 +106,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
106
106
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
107
107
|
span.setAttribute('task.id', trigger.id);
|
|
108
108
|
span.setAttribute('task.type', 'schedule');
|
|
109
|
+
span.setAttribute('type', 'task');
|
|
109
110
|
span.setAttribute('schedule', trigger.schedule);
|
|
110
111
|
span.setAttribute('project.id', projectId);
|
|
111
112
|
span.setAttribute('environment.id', environmentId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAwTxE,CAAC"}
|
|
@@ -18,12 +18,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.webhookCompiler = void 0;
|
|
19
19
|
const cors_1 = __importDefault(require("cors"));
|
|
20
20
|
const express_1 = __importDefault(require("express"));
|
|
21
|
+
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
21
22
|
const promises_1 = require("node:stream/promises");
|
|
22
23
|
const rxjs_1 = require("rxjs");
|
|
23
24
|
const webhookmiddleware_js_1 = require("../../../dsl/http/versori/webhookmiddleware.js");
|
|
24
25
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
25
26
|
const constants_js_1 = require("../../../internal/constants.js");
|
|
26
|
-
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
27
27
|
const xml2jsDefaults = {
|
|
28
28
|
explicitArray: false,
|
|
29
29
|
normalize: false,
|
|
@@ -109,6 +109,7 @@ exports.webhookCompiler = {
|
|
|
109
109
|
else {
|
|
110
110
|
ctx.webhookRouter.use(express_1.default.raw({ type: '*/*', limit: '50mb' }));
|
|
111
111
|
}
|
|
112
|
+
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
112
113
|
return new rxjs_1.Observable((subscriber) => {
|
|
113
114
|
if (!ctx.webhookRouter) {
|
|
114
115
|
throw new Error('Router not available in compiler context');
|
|
@@ -137,8 +138,11 @@ exports.webhookCompiler = {
|
|
|
137
138
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
138
139
|
span.setAttribute('task.id', trigger.id);
|
|
139
140
|
span.setAttribute('task.type', 'webhook');
|
|
141
|
+
span.setAttribute('type', 'task');
|
|
140
142
|
const staticActivation = res.locals.activation;
|
|
141
|
-
|
|
143
|
+
let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
144
|
+
const spanContext = span.spanContext();
|
|
145
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
142
146
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
143
147
|
try {
|
|
144
148
|
subscriber.next(executionCtx);
|
|
@@ -173,6 +177,7 @@ exports.webhookCompiler = {
|
|
|
173
177
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
174
178
|
span.setAttribute('task.id', trigger.id);
|
|
175
179
|
span.setAttribute('task.type', 'webhook');
|
|
180
|
+
span.setAttribute('type', 'task');
|
|
176
181
|
span.setAttribute('user.id', req.params.userId);
|
|
177
182
|
const userId = req.params.userId;
|
|
178
183
|
const activation = res.locals.activation;
|
|
@@ -189,7 +194,9 @@ exports.webhookCompiler = {
|
|
|
189
194
|
span.end();
|
|
190
195
|
return;
|
|
191
196
|
}
|
|
192
|
-
|
|
197
|
+
let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
198
|
+
const spanContext = span.spanContext();
|
|
199
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
193
200
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
194
201
|
const errors = [];
|
|
195
202
|
try {
|
|
@@ -228,6 +235,7 @@ exports.webhookCompiler = {
|
|
|
228
235
|
}), async (req, res) => {
|
|
229
236
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
230
237
|
span.setAttribute('task.id', trigger.id);
|
|
238
|
+
span.setAttribute('type', 'task');
|
|
231
239
|
span.setAttribute('task.type', 'webhook');
|
|
232
240
|
span.setAttribute('activation.id', req.params.activationId);
|
|
233
241
|
const activation = res.locals.activation;
|
|
@@ -243,7 +251,9 @@ exports.webhookCompiler = {
|
|
|
243
251
|
span.end();
|
|
244
252
|
return;
|
|
245
253
|
}
|
|
246
|
-
|
|
254
|
+
let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
255
|
+
const spanContext = span.spanContext();
|
|
256
|
+
activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
247
257
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
248
258
|
try {
|
|
249
259
|
subscriber.next(activationCtx);
|
|
@@ -43,6 +43,11 @@ type Registration = {
|
|
|
43
43
|
sigintListener: () => void;
|
|
44
44
|
subscription?: Subscription;
|
|
45
45
|
};
|
|
46
|
+
type WebhookRegistry = Map<string, {
|
|
47
|
+
method: string;
|
|
48
|
+
path: string;
|
|
49
|
+
options: any;
|
|
50
|
+
}>;
|
|
46
51
|
/**
|
|
47
52
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
48
53
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -71,6 +76,7 @@ export declare class MemoryInterpreter {
|
|
|
71
76
|
private readonly webhookRouter;
|
|
72
77
|
private readonly cronRouter;
|
|
73
78
|
private cronRegistry;
|
|
79
|
+
private webhookRegistry;
|
|
74
80
|
private readonly cnxFactory;
|
|
75
81
|
private readonly cronProvider;
|
|
76
82
|
private readonly tracer;
|
|
@@ -82,7 +88,7 @@ export declare class MemoryInterpreter {
|
|
|
82
88
|
private cronServer?;
|
|
83
89
|
private shutdownServer?;
|
|
84
90
|
private isShuttingDown;
|
|
85
|
-
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
91
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
86
92
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
87
93
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
88
94
|
start(): Promise<void>;
|
|
@@ -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":"AAeA,OAAsB,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB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