@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
|
@@ -16,6 +16,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.MemoryInterpreter = 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");
|
|
@@ -28,18 +30,50 @@ const configloader_js_1 = require("../../dsl/http/versori/configloader.js");
|
|
|
28
30
|
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
29
31
|
const Workflow_js_1 = require("../../dsl/Workflow.js");
|
|
30
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 NatsKeyValueProvider_js_1 = require("../../kv/nats/NatsKeyValueProvider.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
|
-
function getKVProvider(
|
|
38
|
-
if (
|
|
41
|
+
function getKVProvider() {
|
|
42
|
+
if (supervisor_js_1.enabled) {
|
|
39
43
|
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
40
44
|
}
|
|
41
45
|
return NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv();
|
|
42
46
|
}
|
|
47
|
+
function getCredentialsProvider(d) {
|
|
48
|
+
return {
|
|
49
|
+
async getRaw(name, _activationId) {
|
|
50
|
+
const response = await d['credentials'].get({ id: name, organisationId: '' });
|
|
51
|
+
if (!response.credential) {
|
|
52
|
+
throw new Error(`Failed to get credential: ${name}`);
|
|
53
|
+
}
|
|
54
|
+
const rawData = (0, protobuf_1.create)(mod_js_1.credentialv1alpha1.CredentialDataRawSchema, response.credential.data);
|
|
55
|
+
return rawData.raw;
|
|
56
|
+
},
|
|
57
|
+
async getAccessToken(name, forceRefresh, _activationId) {
|
|
58
|
+
const response = await d['tokens'].getToken({ credentialId: name, forceRefresh: forceRefresh || false });
|
|
59
|
+
if (!response.token) {
|
|
60
|
+
throw new Error(`Failed to get token for credential: ${name}`);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
accessToken: response.token.accessToken,
|
|
64
|
+
tokenType: response.token.tokenType,
|
|
65
|
+
expiry: response.token.expiry ? new Date((0, wkt_1.timestampMs)(response.token.expiry)) : undefined,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
async getOAuth1Metadata(name, _activationId) {
|
|
69
|
+
const response = await d['oauth1'].getAuthorizationMetadata({ credentialId: name });
|
|
70
|
+
if (!response) {
|
|
71
|
+
throw new Error(`Failed to get OAuth1 metadata for credential: ${name}`);
|
|
72
|
+
}
|
|
73
|
+
return response;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
43
77
|
/**
|
|
44
78
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
45
79
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -62,7 +96,7 @@ function getKVProvider(runLocal) {
|
|
|
62
96
|
* ```
|
|
63
97
|
*/
|
|
64
98
|
class MemoryInterpreter {
|
|
65
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
99
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
66
100
|
Object.defineProperty(this, "log", {
|
|
67
101
|
enumerable: true,
|
|
68
102
|
configurable: true,
|
|
@@ -99,6 +133,12 @@ class MemoryInterpreter {
|
|
|
99
133
|
writable: true,
|
|
100
134
|
value: cronRegistry
|
|
101
135
|
});
|
|
136
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: webhookRegistry
|
|
141
|
+
});
|
|
102
142
|
Object.defineProperty(this, "cnxFactory", {
|
|
103
143
|
enumerable: true,
|
|
104
144
|
configurable: true,
|
|
@@ -183,7 +223,6 @@ class MemoryInterpreter {
|
|
|
183
223
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
184
224
|
let otelSDK;
|
|
185
225
|
const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
|
|
186
|
-
const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
187
226
|
await waitForReady(log);
|
|
188
227
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
189
228
|
const resource = (0, resources_1.resourceFromAttributes)({
|
|
@@ -205,20 +244,30 @@ class MemoryInterpreter {
|
|
|
205
244
|
log.info('Starting OpenTelemetry SDK');
|
|
206
245
|
otelSDK.start();
|
|
207
246
|
}
|
|
247
|
+
else if (supervisor_js_1.enabled) {
|
|
248
|
+
otelSDK = new sdk_node_1.NodeSDK({
|
|
249
|
+
traceExporter: new supervisor_js_1.Fake(),
|
|
250
|
+
serviceName: serviceName,
|
|
251
|
+
resource: resource,
|
|
252
|
+
});
|
|
253
|
+
log.info('Starting Testing OpenTelemetry SDK');
|
|
254
|
+
otelSDK.start();
|
|
255
|
+
}
|
|
208
256
|
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
209
|
-
const
|
|
257
|
+
const cnxFactory = DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log);
|
|
258
|
+
const credentialsProvider = getCredentialsProvider(cnxFactory);
|
|
210
259
|
const issuesProvider = new Issues_js_1.IssueImpl(log);
|
|
211
260
|
if (options.contextProvider) {
|
|
212
261
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
213
262
|
// initialised.
|
|
214
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(),
|
|
263
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), cnxFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
215
264
|
}
|
|
216
|
-
const kvp = await getKVProvider(
|
|
265
|
+
const kvp = await getKVProvider();
|
|
217
266
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
218
267
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
219
268
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
220
|
-
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp,
|
|
221
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(),
|
|
269
|
+
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, credentialsProvider, platformApi, organisationId, environmentId, issuesProvider);
|
|
270
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), cnxFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
222
271
|
}
|
|
223
272
|
register(workflow, options) {
|
|
224
273
|
const localAbortController = new AbortController();
|
|
@@ -237,6 +286,7 @@ class MemoryInterpreter {
|
|
|
237
286
|
cnxFactory: this.cnxFactory,
|
|
238
287
|
platformApi: PlatformApi_js_1.PlatformApiImpl.fromEnv(),
|
|
239
288
|
webhookRouter: this.webhookRouter,
|
|
289
|
+
webhookRegistry: this.webhookRegistry,
|
|
240
290
|
cronRouter: this.cronRouter,
|
|
241
291
|
cronRegistry: this.cronRegistry,
|
|
242
292
|
configReader: this.cfgReader,
|
|
@@ -257,9 +307,9 @@ class MemoryInterpreter {
|
|
|
257
307
|
this.registeredWorkflows.push(registration);
|
|
258
308
|
return registration;
|
|
259
309
|
}
|
|
260
|
-
start() {
|
|
261
|
-
const port = Deno.env.get(
|
|
262
|
-
const cronPort = Deno.env.get(
|
|
310
|
+
async start() {
|
|
311
|
+
const port = Deno.env.get(constants_js_1.envPort) || 3000;
|
|
312
|
+
const cronPort = Deno.env.get(constants_js_1.envCronPort) || 3001;
|
|
263
313
|
const webhookApp = (0, express_1.default)();
|
|
264
314
|
const cronApp = (0, express_1.default)();
|
|
265
315
|
cronApp.use(express_1.default.json());
|
|
@@ -283,6 +333,12 @@ class MemoryInterpreter {
|
|
|
283
333
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
284
334
|
error: err instanceof Error ? err.toString() : err,
|
|
285
335
|
});
|
|
336
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
337
|
+
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
338
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
339
|
+
span.setAttribute('result', 'fail');
|
|
340
|
+
span.end();
|
|
341
|
+
});
|
|
286
342
|
try {
|
|
287
343
|
ctx.options.onError?.(ctx.withData(err));
|
|
288
344
|
}
|
|
@@ -302,6 +358,11 @@ class MemoryInterpreter {
|
|
|
302
358
|
durationMs,
|
|
303
359
|
data: ctx.data,
|
|
304
360
|
});
|
|
361
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
362
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
363
|
+
span.setAttribute('result', 'pass');
|
|
364
|
+
span.end();
|
|
365
|
+
});
|
|
305
366
|
try {
|
|
306
367
|
ctx.options.onSuccess?.(ctx);
|
|
307
368
|
}
|
|
@@ -338,6 +399,9 @@ class MemoryInterpreter {
|
|
|
338
399
|
});
|
|
339
400
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
340
401
|
}
|
|
402
|
+
// register with suopervisor
|
|
403
|
+
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
404
|
+
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
341
405
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
342
406
|
this.log.info(`Express server listening on port ${port}`);
|
|
343
407
|
});
|
|
@@ -357,6 +421,7 @@ class MemoryInterpreter {
|
|
|
357
421
|
if (this.cronServer) {
|
|
358
422
|
this.cronServer.close();
|
|
359
423
|
}
|
|
424
|
+
this.otelSDK?.shutdown();
|
|
360
425
|
// Remove all signal listeners
|
|
361
426
|
for (const registration of this.registeredWorkflows) {
|
|
362
427
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -410,7 +475,7 @@ class MemoryInterpreter {
|
|
|
410
475
|
}
|
|
411
476
|
exports.MemoryInterpreter = MemoryInterpreter;
|
|
412
477
|
async function waitForReady(log) {
|
|
413
|
-
const readyCheckUrl = Deno.env.get(
|
|
478
|
+
const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
|
|
414
479
|
if (!readyCheckUrl) {
|
|
415
480
|
return Promise.resolve();
|
|
416
481
|
}
|
|
@@ -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';
|
|
@@ -10,7 +11,6 @@ import { IssueAPI } from '../../issues/Issues.js';
|
|
|
10
11
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
11
12
|
import { PlatformApi } from '../../services/platform/PlatformApi.js';
|
|
12
13
|
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
13
|
-
import { ConnectionFactory } from '../../connection/types.js';
|
|
14
14
|
export type CompilerContext = {
|
|
15
15
|
compiler: ObservableCompiler;
|
|
16
16
|
log: Logger;
|
|
@@ -23,6 +23,11 @@ export type CompilerContext = {
|
|
|
23
23
|
issueProvider: IssueAPI;
|
|
24
24
|
configReader: ConfigReader;
|
|
25
25
|
cronRegistry: Map<string, string>;
|
|
26
|
+
webhookRegistry: Map<string, {
|
|
27
|
+
method: string;
|
|
28
|
+
path: string;
|
|
29
|
+
options: any;
|
|
30
|
+
}>;
|
|
26
31
|
organisationId: string;
|
|
27
32
|
};
|
|
28
33
|
export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: CompilerContext, task: T) => OperatorFunction<In, Out>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/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;
|
|
1
|
+
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/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,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,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,wBAAwB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AASrE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI9F,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,QAAQ,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAC7E,cAAc,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,CACrF,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,CAAC,KACN,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAE/B,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,gBAAgB,CAAgD;;IAgBxE,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI,EACzC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,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,eAAe,EACpB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/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/memory/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAmFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -24,6 +24,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
24
24
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
25
25
|
span.setAttribute('execution.id', ctx.executionId);
|
|
26
26
|
span.setAttribute('task.type', 'catch');
|
|
27
|
+
span.setAttribute('type', 'task');
|
|
27
28
|
if (error instanceof Error) {
|
|
28
29
|
span.recordException(error);
|
|
29
30
|
span.setAttribute('error.message', error.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA2CnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.fnCompiler = void 0;
|
|
16
4
|
const rxjs_1 = require("rxjs");
|
|
17
5
|
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
6
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
18
7
|
function compileFn(compilerCtx, task) {
|
|
19
8
|
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
20
9
|
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
21
10
|
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
22
11
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
23
12
|
span.setAttribute('task.id', task.id);
|
|
13
|
+
span.setAttribute('type', 'task');
|
|
14
|
+
span.setAttribute('task.type', 'fn');
|
|
24
15
|
span.setAttribute('execution.id', ctx.executionId);
|
|
25
|
-
|
|
16
|
+
try {
|
|
17
|
+
let result;
|
|
18
|
+
const spanContext = span.spanContext();
|
|
19
|
+
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
20
|
+
if (typeof ctx.idx === 'number') {
|
|
21
|
+
result = ctx.withData(await task._fn(ctxWithLogger, ctx.idx));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
result = ctx.withData(await task._fn(ctxWithLogger));
|
|
25
|
+
}
|
|
26
|
+
if (supervisor_js_1.enabled) {
|
|
27
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
26
32
|
span.end();
|
|
27
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
28
33
|
}
|
|
29
|
-
span.end();
|
|
30
|
-
return ctx.withData(await task._fn(ctx));
|
|
31
34
|
});
|
|
32
35
|
}));
|
|
33
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/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"}
|
|
@@ -16,17 +16,31 @@ exports.httpCompiler = void 0;
|
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
17
|
const operators_1 = require("rxjs/operators");
|
|
18
18
|
const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
|
|
19
|
+
const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
|
|
19
20
|
const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
|
|
20
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 newCtx = 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(newCtx.data));
|
|
89
|
+
}
|
|
90
|
+
return newCtx;
|
|
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/memory/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyI7C,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
|
|
@@ -99,6 +99,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
99
99
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
100
100
|
span.setAttribute('task.id', trigger.id);
|
|
101
101
|
span.setAttribute('task.type', 'schedule');
|
|
102
|
+
span.setAttribute('type', 'task');
|
|
102
103
|
span.setAttribute('schedule', trigger.schedule);
|
|
103
104
|
span.setAttribute('project.id', projectId);
|
|
104
105
|
span.setAttribute('environment.id', environmentId);
|
|
@@ -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":"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,CA4TxE,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,
|
|
@@ -123,6 +123,7 @@ exports.webhookCompiler = {
|
|
|
123
123
|
ctx.webhookRouter.use((0, cors_1.default)(corsOptions));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
126
127
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
127
128
|
ctx.webhookRouter[method](`/${trigger.id}`, (0, webhookmiddleware_js_1.createStaticWebhookMiddleware)({
|
|
128
129
|
id: trigger.id,
|
|
@@ -137,8 +138,12 @@ 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 }));
|
|
146
|
+
executionCtx.log.info("stack", { stack: new Error().stack });
|
|
142
147
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
143
148
|
try {
|
|
144
149
|
subscriber.next(executionCtx);
|
|
@@ -173,6 +178,7 @@ exports.webhookCompiler = {
|
|
|
173
178
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
174
179
|
span.setAttribute('task.id', trigger.id);
|
|
175
180
|
span.setAttribute('task.type', 'webhook');
|
|
181
|
+
span.setAttribute('type', 'task');
|
|
176
182
|
span.setAttribute('user.id', req.params.userId);
|
|
177
183
|
const userId = req.params.userId;
|
|
178
184
|
// Right now we only support a user having one activation
|
|
@@ -189,7 +195,9 @@ exports.webhookCompiler = {
|
|
|
189
195
|
span.end();
|
|
190
196
|
return;
|
|
191
197
|
}
|
|
192
|
-
|
|
198
|
+
let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
199
|
+
const spanContext = span.spanContext();
|
|
200
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
193
201
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
194
202
|
const errors = [];
|
|
195
203
|
try {
|
|
@@ -229,6 +237,7 @@ exports.webhookCompiler = {
|
|
|
229
237
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
230
238
|
span.setAttribute('task.id', trigger.id);
|
|
231
239
|
span.setAttribute('task.type', 'webhook');
|
|
240
|
+
span.setAttribute('type', 'task');
|
|
232
241
|
span.setAttribute('activation.id', req.params.activationId);
|
|
233
242
|
const activation = res.locals.activation;
|
|
234
243
|
const activationId = activation?.id ?? req.params.activationId;
|
|
@@ -243,7 +252,9 @@ exports.webhookCompiler = {
|
|
|
243
252
|
span.end();
|
|
244
253
|
return;
|
|
245
254
|
}
|
|
246
|
-
|
|
255
|
+
let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
256
|
+
const spanContext = span.spanContext();
|
|
257
|
+
activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
247
258
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
248
259
|
try {
|
|
249
260
|
subscriber.next(activationCtx);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MockIssues = exports.IssueImpl = void 0;
|
|
16
16
|
const node_crypto_1 = require("node:crypto");
|
|
17
|
-
const constants_js_1 = require("../
|
|
17
|
+
const constants_js_1 = require("../internal/constants.js");
|
|
18
18
|
class IssueImpl {
|
|
19
19
|
constructor(log) {
|
|
20
20
|
Object.defineProperty(this, "baseUrl", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6CvF,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa,oBAAqB,YAAW,gBAAgB,EAAE,eAAe;IAEtE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALzB,OAAO;WAQM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,OAAO,CAAC,oBAAoB,CAAC;IA0BhC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI/C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -16,8 +16,8 @@ exports.NatsKeyValueProvider = void 0;
|
|
|
16
16
|
const mod_js_1 = require("../../../deps/jsr.io/@nats-io/jetstream/3.2.0/src/mod.js");
|
|
17
17
|
const mod_js_2 = require("../../../deps/jsr.io/@nats-io/kv/3.2.0/src/mod.js");
|
|
18
18
|
const mod_js_3 = require("../../../deps/jsr.io/@nats-io/transport-deno/3.2.0/src/mod.js");
|
|
19
|
-
const isKVOptionsExecution_js_1 = require("../isKVOptionsExecution.js");
|
|
20
19
|
const NatsKeyValue_js_1 = require("./NatsKeyValue.js");
|
|
20
|
+
const isKVOptionsExecution_js_1 = require("../isKVOptionsExecution.js");
|
|
21
21
|
function getOptionsFromEnv() {
|
|
22
22
|
const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
23
23
|
return {
|
|
@@ -175,7 +175,7 @@ class NatsKeyValueProvider {
|
|
|
175
175
|
const activationSuffix = options.activationId ? `.${options.activationId}` : '';
|
|
176
176
|
switch (options.scope) {
|
|
177
177
|
case ':organization:':
|
|
178
|
-
return `${this.opts.organizationId}`;
|
|
178
|
+
return `${this.opts.organizationId}${activationSuffix}`;
|
|
179
179
|
case ':project:':
|
|
180
180
|
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}${activationSuffix}`;
|
|
181
181
|
case ':execution:':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAmCvF,MAAM,MAAM,0BAA0B,GAAG;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF,qBAAa,mBAAoB,YAAW,gBAAgB,EAAE,eAAe;IAErE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJzB,OAAO;WAOM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAC/C,OAAO,CAAC,mBAAmB,CAAC;IAY/B,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI9C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SDKKeyValueProvider = void 0;
|
|
16
|
-
const KvOperationsService_js_1 = require("../../dsl/http/versori/kvapi/services/KvOperationsService.js");
|
|
17
16
|
const StoresService_js_1 = require("../../dsl/http/versori/kvapi/services/StoresService.js");
|
|
18
|
-
const
|
|
17
|
+
const KvOperationsService_js_1 = require("../../dsl/http/versori/kvapi/services/KvOperationsService.js");
|
|
19
18
|
const SDKKeyValue_js_1 = require("./SDKKeyValue.js");
|
|
19
|
+
const isKVOptionsExecution_js_1 = require("../isKVOptionsExecution.js");
|
|
20
20
|
function getOptionsFromEnv() {
|
|
21
21
|
return {
|
|
22
22
|
organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
|
|
@@ -148,7 +148,7 @@ class SDKKeyValueProvider {
|
|
|
148
148
|
const activationSuffix = options.activationId ? `/${options.activationId}` : '';
|
|
149
149
|
switch (options.scope) {
|
|
150
150
|
case ':organization:':
|
|
151
|
-
return `${this.opts.organizationId}`;
|
|
151
|
+
return `${this.opts.organizationId}${activationSuffix}`;
|
|
152
152
|
case ':project:':
|
|
153
153
|
return `${this.opts.organizationId}/${this.opts.projectId}/${this.opts.environment}${activationSuffix}`;
|
|
154
154
|
case ':execution:':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqM/C;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAOjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsB9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAGlC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
-
export type { Uint8Array_ };
|
|
3
|
-
export declare const padding: number;
|
|
4
|
-
export declare const alphabet: Record<Base64Alphabet, Uint8Array>;
|
|
5
|
-
export declare const rAlphabet: Record<Base64Alphabet, Uint8Array>;
|
|
6
|
-
/**
|
|
7
|
-
* Options for encoding and decoding base64 strings.
|
|
8
|
-
*/
|
|
9
|
-
export interface Base64Options {
|
|
10
|
-
/** The base64 alphabet. Defaults to "base64" */
|
|
11
|
-
alphabet?: Base64Alphabet;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The base64 alphabets.
|
|
15
|
-
*/
|
|
16
|
-
export type Base64Alphabet = "base64" | "base64url";
|
|
17
|
-
/**
|
|
18
|
-
* Calculate the output size needed to encode a given input size for
|
|
19
|
-
* {@linkcode encodeIntoBase64}.
|
|
20
|
-
*
|
|
21
|
-
* @param originalSize The size of the input buffer.
|
|
22
|
-
* @returns The size of the output buffer.
|
|
23
|
-
*
|
|
24
|
-
* @example Basic Usage
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { assertEquals } from "@std/assert";
|
|
27
|
-
* import { calcSizeBase64 } from "@std/encoding/unstable-base64";
|
|
28
|
-
*
|
|
29
|
-
* assertEquals(calcSizeBase64(1), 4);
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function calcSizeBase64(originalSize: number): number;
|
|
33
|
-
export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
|
34
|
-
export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
|
35
|
-
//# sourceMappingURL=_common64.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_common64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common64.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,eAAO,MAAM,OAAO,QAAoB,CAAC;AACzC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAKvD,CAAC;AACF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAGxD,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CA4BR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAmDR"}
|