@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
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* As of the Change Date, in accordance with the Business Source License,
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
|
+
import { create } from '@bufbuild/protobuf';
|
|
14
|
+
import { timestampMs } from '@bufbuild/protobuf/wkt';
|
|
13
15
|
import opentelemetry from '@opentelemetry/api';
|
|
14
16
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
15
17
|
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
@@ -21,19 +23,51 @@ import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
|
21
23
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
22
24
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
23
25
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
24
|
-
import { envVarEnvId, envVarEnvironmentName,
|
|
26
|
+
import { envCronPort, envPort, envReadyCheckURL, envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../internal/constants.js';
|
|
27
|
+
import { Fake, registerCrons, registerWebhooks, enabled as supervisorEnabled } from '../../internal/supervisor.js';
|
|
25
28
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
26
29
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
27
30
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
28
31
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
32
|
+
import { credentialv1alpha1 } from '../../services/credentials/mod.js';
|
|
29
33
|
import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
|
|
30
34
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
31
|
-
function getKVProvider(
|
|
32
|
-
if (
|
|
35
|
+
function getKVProvider() {
|
|
36
|
+
if (supervisorEnabled) {
|
|
33
37
|
return Promise.resolve(new MemoryKeyValueProvider());
|
|
34
38
|
}
|
|
35
39
|
return NatsKeyValueProvider.fromEnv();
|
|
36
40
|
}
|
|
41
|
+
function getCredentialsProvider(d) {
|
|
42
|
+
return {
|
|
43
|
+
async getRaw(name, _activationId) {
|
|
44
|
+
const response = await d['credentials'].get({ id: name, organisationId: '' });
|
|
45
|
+
if (!response.credential) {
|
|
46
|
+
throw new Error(`Failed to get credential: ${name}`);
|
|
47
|
+
}
|
|
48
|
+
const rawData = create(credentialv1alpha1.CredentialDataRawSchema, response.credential.data);
|
|
49
|
+
return rawData.raw;
|
|
50
|
+
},
|
|
51
|
+
async getAccessToken(name, forceRefresh, _activationId) {
|
|
52
|
+
const response = await d['tokens'].getToken({ credentialId: name, forceRefresh: forceRefresh || false });
|
|
53
|
+
if (!response.token) {
|
|
54
|
+
throw new Error(`Failed to get token for credential: ${name}`);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
accessToken: response.token.accessToken,
|
|
58
|
+
tokenType: response.token.tokenType,
|
|
59
|
+
expiry: response.token.expiry ? new Date(timestampMs(response.token.expiry)) : undefined,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
async getOAuth1Metadata(name, _activationId) {
|
|
63
|
+
const response = await d['oauth1'].getAuthorizationMetadata({ credentialId: name });
|
|
64
|
+
if (!response) {
|
|
65
|
+
throw new Error(`Failed to get OAuth1 metadata for credential: ${name}`);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
37
71
|
/**
|
|
38
72
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
39
73
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -56,7 +90,7 @@ function getKVProvider(runLocal) {
|
|
|
56
90
|
* ```
|
|
57
91
|
*/
|
|
58
92
|
export class MemoryInterpreter {
|
|
59
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
93
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
60
94
|
Object.defineProperty(this, "log", {
|
|
61
95
|
enumerable: true,
|
|
62
96
|
configurable: true,
|
|
@@ -93,6 +127,12 @@ export class MemoryInterpreter {
|
|
|
93
127
|
writable: true,
|
|
94
128
|
value: cronRegistry
|
|
95
129
|
});
|
|
130
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: webhookRegistry
|
|
135
|
+
});
|
|
96
136
|
Object.defineProperty(this, "cnxFactory", {
|
|
97
137
|
enumerable: true,
|
|
98
138
|
configurable: true,
|
|
@@ -177,7 +217,6 @@ export class MemoryInterpreter {
|
|
|
177
217
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
178
218
|
let otelSDK;
|
|
179
219
|
const configReader = VersoriConfigReader.fromEnv(log);
|
|
180
|
-
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
181
220
|
await waitForReady(log);
|
|
182
221
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
183
222
|
const resource = resourceFromAttributes({
|
|
@@ -199,20 +238,30 @@ export class MemoryInterpreter {
|
|
|
199
238
|
log.info('Starting OpenTelemetry SDK');
|
|
200
239
|
otelSDK.start();
|
|
201
240
|
}
|
|
241
|
+
else if (supervisorEnabled) {
|
|
242
|
+
otelSDK = new NodeSDK({
|
|
243
|
+
traceExporter: new Fake(),
|
|
244
|
+
serviceName: serviceName,
|
|
245
|
+
resource: resource,
|
|
246
|
+
});
|
|
247
|
+
log.info('Starting Testing OpenTelemetry SDK');
|
|
248
|
+
otelSDK.start();
|
|
249
|
+
}
|
|
202
250
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
203
|
-
const
|
|
251
|
+
const cnxFactory = DirectConnectionFactory.fromEnv(log);
|
|
252
|
+
const credentialsProvider = getCredentialsProvider(cnxFactory);
|
|
204
253
|
const issuesProvider = new IssueImpl(log);
|
|
205
254
|
if (options.contextProvider) {
|
|
206
255
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
207
256
|
// initialised.
|
|
208
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(),
|
|
257
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), new Map(), cnxFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
209
258
|
}
|
|
210
|
-
const kvp = await getKVProvider(
|
|
259
|
+
const kvp = await getKVProvider();
|
|
211
260
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
212
261
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
213
262
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
214
|
-
const ctxProvider = new ContextProviderImpl(log, kvp,
|
|
215
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(),
|
|
263
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, credentialsProvider, platformApi, organisationId, environmentId, issuesProvider);
|
|
264
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), new Map(), cnxFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
216
265
|
}
|
|
217
266
|
register(workflow, options) {
|
|
218
267
|
const localAbortController = new AbortController();
|
|
@@ -231,6 +280,7 @@ export class MemoryInterpreter {
|
|
|
231
280
|
cnxFactory: this.cnxFactory,
|
|
232
281
|
platformApi: PlatformApiImpl.fromEnv(),
|
|
233
282
|
webhookRouter: this.webhookRouter,
|
|
283
|
+
webhookRegistry: this.webhookRegistry,
|
|
234
284
|
cronRouter: this.cronRouter,
|
|
235
285
|
cronRegistry: this.cronRegistry,
|
|
236
286
|
configReader: this.cfgReader,
|
|
@@ -251,9 +301,9 @@ export class MemoryInterpreter {
|
|
|
251
301
|
this.registeredWorkflows.push(registration);
|
|
252
302
|
return registration;
|
|
253
303
|
}
|
|
254
|
-
start() {
|
|
255
|
-
const port = Deno.env.get(
|
|
256
|
-
const cronPort = Deno.env.get(
|
|
304
|
+
async start() {
|
|
305
|
+
const port = Deno.env.get(envPort) || 3000;
|
|
306
|
+
const cronPort = Deno.env.get(envCronPort) || 3001;
|
|
257
307
|
const webhookApp = express();
|
|
258
308
|
const cronApp = express();
|
|
259
309
|
cronApp.use(express.json());
|
|
@@ -277,6 +327,12 @@ export class MemoryInterpreter {
|
|
|
277
327
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
278
328
|
error: err instanceof Error ? err.toString() : err,
|
|
279
329
|
});
|
|
330
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
331
|
+
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
332
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
333
|
+
span.setAttribute('result', 'fail');
|
|
334
|
+
span.end();
|
|
335
|
+
});
|
|
280
336
|
try {
|
|
281
337
|
ctx.options.onError?.(ctx.withData(err));
|
|
282
338
|
}
|
|
@@ -296,6 +352,11 @@ export class MemoryInterpreter {
|
|
|
296
352
|
durationMs,
|
|
297
353
|
data: ctx.data,
|
|
298
354
|
});
|
|
355
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
356
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
357
|
+
span.setAttribute('result', 'pass');
|
|
358
|
+
span.end();
|
|
359
|
+
});
|
|
299
360
|
try {
|
|
300
361
|
ctx.options.onSuccess?.(ctx);
|
|
301
362
|
}
|
|
@@ -332,6 +393,9 @@ export class MemoryInterpreter {
|
|
|
332
393
|
});
|
|
333
394
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
334
395
|
}
|
|
396
|
+
// register with suopervisor
|
|
397
|
+
await registerCrons(this.cronRegistry);
|
|
398
|
+
await registerWebhooks(this.webhookRegistry);
|
|
335
399
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
336
400
|
this.log.info(`Express server listening on port ${port}`);
|
|
337
401
|
});
|
|
@@ -351,6 +415,7 @@ export class MemoryInterpreter {
|
|
|
351
415
|
if (this.cronServer) {
|
|
352
416
|
this.cronServer.close();
|
|
353
417
|
}
|
|
418
|
+
this.otelSDK?.shutdown();
|
|
354
419
|
// Remove all signal listeners
|
|
355
420
|
for (const registration of this.registeredWorkflows) {
|
|
356
421
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -403,7 +468,7 @@ export class MemoryInterpreter {
|
|
|
403
468
|
}
|
|
404
469
|
}
|
|
405
470
|
async function waitForReady(log) {
|
|
406
|
-
const readyCheckUrl = Deno.env.get(
|
|
471
|
+
const readyCheckUrl = Deno.env.get(envReadyCheckURL);
|
|
407
472
|
if (!readyCheckUrl) {
|
|
408
473
|
return Promise.resolve();
|
|
409
474
|
}
|
|
@@ -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"}
|
|
@@ -21,6 +21,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
21
21
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
22
22
|
span.setAttribute('execution.id', ctx.executionId);
|
|
23
23
|
span.setAttribute('task.type', 'catch');
|
|
24
|
+
span.setAttribute('type', 'task');
|
|
24
25
|
if (error instanceof Error) {
|
|
25
26
|
span.recordException(error);
|
|
26
27
|
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,30 +1,33 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
-
*
|
|
4
|
-
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
-
* included in the LICENSE file at the root of this repository.
|
|
6
|
-
*
|
|
7
|
-
* Change Date: 2029-01-01
|
|
8
|
-
* Change License: Apache License, Version 2.0
|
|
9
|
-
*
|
|
10
|
-
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
-
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
-
*/
|
|
13
1
|
import { mergeMap, tap } from 'rxjs';
|
|
14
2
|
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
3
|
+
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
15
4
|
function compileFn(compilerCtx, task) {
|
|
16
5
|
return (src) => src.pipe(tap({
|
|
17
6
|
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
18
7
|
}), mergeMap(async (ctx) => {
|
|
19
8
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
20
9
|
span.setAttribute('task.id', task.id);
|
|
10
|
+
span.setAttribute('type', 'task');
|
|
11
|
+
span.setAttribute('task.type', 'fn');
|
|
21
12
|
span.setAttribute('execution.id', ctx.executionId);
|
|
22
|
-
|
|
13
|
+
try {
|
|
14
|
+
let result;
|
|
15
|
+
const spanContext = span.spanContext();
|
|
16
|
+
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
17
|
+
if (typeof ctx.idx === 'number') {
|
|
18
|
+
result = ctx.withData(await task._fn(ctxWithLogger, ctx.idx));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
result = ctx.withData(await task._fn(ctxWithLogger));
|
|
22
|
+
}
|
|
23
|
+
if (supervisorEnabled) {
|
|
24
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
23
29
|
span.end();
|
|
24
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
25
30
|
}
|
|
26
|
-
span.end();
|
|
27
|
-
return ctx.withData(await task._fn(ctx));
|
|
28
31
|
});
|
|
29
32
|
}));
|
|
30
33
|
}
|
|
@@ -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"}
|
|
@@ -13,17 +13,31 @@
|
|
|
13
13
|
import { mergeMap } from 'rxjs';
|
|
14
14
|
import { tap } from 'rxjs/operators';
|
|
15
15
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
16
|
+
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
16
17
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
17
18
|
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
19
|
+
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
18
20
|
function compileHttp(compilerCtx, task) {
|
|
19
21
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
20
22
|
let fetchFactory;
|
|
21
23
|
if (!cnxMap) {
|
|
22
|
-
compilerCtx.log.
|
|
23
|
-
|
|
24
|
+
compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
|
|
25
|
+
if (supervisorEnabled) {
|
|
26
|
+
// missing connection map and we are in supervised mode, so we use the fake fetcher
|
|
27
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// missing connection map and not in supervised mode, so we use global fetch
|
|
31
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
else if (cnxMap.dynamic) {
|
|
26
|
-
|
|
35
|
+
if (cnxMap.mockWithAI) {
|
|
36
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
40
|
+
}
|
|
27
41
|
}
|
|
28
42
|
else {
|
|
29
43
|
fetchFactory = compilerCtx.platformApi.getConnection({
|
|
@@ -33,8 +47,21 @@ function compileHttp(compilerCtx, task) {
|
|
|
33
47
|
},
|
|
34
48
|
throwOnError: true,
|
|
35
49
|
})
|
|
36
|
-
.then(({ data }) =>
|
|
37
|
-
.
|
|
50
|
+
.then(({ data }) => {
|
|
51
|
+
if (cnxMap.mockWithAI) {
|
|
52
|
+
// use the fake fetcher that calls the supervisor to generate a mock reponse
|
|
53
|
+
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
|
|
54
|
+
}
|
|
55
|
+
return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
|
|
56
|
+
.then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
|
|
60
|
+
if (supervisorEnabled) {
|
|
61
|
+
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
|
|
62
|
+
}
|
|
63
|
+
throw err;
|
|
64
|
+
});
|
|
38
65
|
}
|
|
39
66
|
async function http(ctx) {
|
|
40
67
|
const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
|
|
@@ -48,10 +75,16 @@ function compileHttp(compilerCtx, task) {
|
|
|
48
75
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
49
76
|
span.setAttribute('task.id', task.id);
|
|
50
77
|
span.setAttribute('task.type', 'http');
|
|
78
|
+
span.setAttribute('type', 'task');
|
|
51
79
|
span.setAttribute('execution.id', ctx.executionId);
|
|
52
80
|
span.setAttribute('connection.name', task.opts.connection);
|
|
81
|
+
const spanContext = span.spanContext();
|
|
53
82
|
try {
|
|
54
|
-
|
|
83
|
+
const newCtx = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
84
|
+
if (supervisorEnabled) {
|
|
85
|
+
span.setAttribute('response.body', JSON.stringify(newCtx.data));
|
|
86
|
+
}
|
|
87
|
+
return newCtx;
|
|
55
88
|
}
|
|
56
89
|
catch (error) {
|
|
57
90
|
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"}
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { Observable } from 'rxjs';
|
|
14
|
-
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../dsl/http/versori/constants.js';
|
|
15
14
|
import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
|
|
15
|
+
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../internal/constants.js';
|
|
16
16
|
function compileSchedule(ctx, trigger, signal) {
|
|
17
17
|
return new Observable((subscriber) => {
|
|
18
18
|
// Add HTTP endpoint for manual triggering
|
|
@@ -96,6 +96,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
96
96
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
97
97
|
span.setAttribute('task.id', trigger.id);
|
|
98
98
|
span.setAttribute('task.type', 'schedule');
|
|
99
|
+
span.setAttribute('type', 'task');
|
|
99
100
|
span.setAttribute('schedule', trigger.schedule);
|
|
100
101
|
span.setAttribute('project.id', projectId);
|
|
101
102
|
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"}
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import cors from 'cors';
|
|
14
14
|
import express from 'express';
|
|
15
|
+
import xmlparser from 'express-xml-bodyparser';
|
|
15
16
|
import { pipeline } from 'node:stream/promises';
|
|
16
17
|
import { Observable } from 'rxjs';
|
|
17
18
|
import { createActIdDynamicWebhookMiddleware, createStaticWebhookMiddleware, createUserIdDynamicWebhookMiddleware, } from '../../../dsl/http/versori/webhookmiddleware.js';
|
|
18
19
|
import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
|
|
19
20
|
import { envVarEnvId } from '../../../internal/constants.js';
|
|
20
|
-
import xmlparser from 'express-xml-bodyparser';
|
|
21
21
|
const xml2jsDefaults = {
|
|
22
22
|
explicitArray: false,
|
|
23
23
|
normalize: false,
|
|
@@ -117,6 +117,7 @@ export const webhookCompiler = {
|
|
|
117
117
|
ctx.webhookRouter.use(cors(corsOptions));
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
120
121
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
121
122
|
ctx.webhookRouter[method](`/${trigger.id}`, createStaticWebhookMiddleware({
|
|
122
123
|
id: trigger.id,
|
|
@@ -131,8 +132,12 @@ export const webhookCompiler = {
|
|
|
131
132
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
132
133
|
span.setAttribute('task.id', trigger.id);
|
|
133
134
|
span.setAttribute('task.type', 'webhook');
|
|
135
|
+
span.setAttribute('type', 'task');
|
|
134
136
|
const staticActivation = res.locals.activation;
|
|
135
|
-
|
|
137
|
+
let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
138
|
+
const spanContext = span.spanContext();
|
|
139
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
140
|
+
executionCtx.log.info("stack", { stack: new Error().stack });
|
|
136
141
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
137
142
|
try {
|
|
138
143
|
subscriber.next(executionCtx);
|
|
@@ -167,6 +172,7 @@ export const webhookCompiler = {
|
|
|
167
172
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
168
173
|
span.setAttribute('task.id', trigger.id);
|
|
169
174
|
span.setAttribute('task.type', 'webhook');
|
|
175
|
+
span.setAttribute('type', 'task');
|
|
170
176
|
span.setAttribute('user.id', req.params.userId);
|
|
171
177
|
const userId = req.params.userId;
|
|
172
178
|
// Right now we only support a user having one activation
|
|
@@ -183,7 +189,9 @@ export const webhookCompiler = {
|
|
|
183
189
|
span.end();
|
|
184
190
|
return;
|
|
185
191
|
}
|
|
186
|
-
|
|
192
|
+
let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
193
|
+
const spanContext = span.spanContext();
|
|
194
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
187
195
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
188
196
|
const errors = [];
|
|
189
197
|
try {
|
|
@@ -223,6 +231,7 @@ export const webhookCompiler = {
|
|
|
223
231
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
224
232
|
span.setAttribute('task.id', trigger.id);
|
|
225
233
|
span.setAttribute('task.type', 'webhook');
|
|
234
|
+
span.setAttribute('type', 'task');
|
|
226
235
|
span.setAttribute('activation.id', req.params.activationId);
|
|
227
236
|
const activation = res.locals.activation;
|
|
228
237
|
const activationId = activation?.id ?? req.params.activationId;
|
|
@@ -237,7 +246,9 @@ export const webhookCompiler = {
|
|
|
237
246
|
span.end();
|
|
238
247
|
return;
|
|
239
248
|
}
|
|
240
|
-
|
|
249
|
+
let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
250
|
+
const spanContext = span.spanContext();
|
|
251
|
+
activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
241
252
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
242
253
|
try {
|
|
243
254
|
subscriber.next(activationCtx);
|
package/esm/src/issues/Issues.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { createHash } from 'node:crypto';
|
|
14
|
-
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../
|
|
14
|
+
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../internal/constants.js';
|
|
15
15
|
export class IssueImpl {
|
|
16
16
|
constructor(log) {
|
|
17
17
|
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"}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
import { JetStreamApiCodes, JetStreamApiError } from '../../../deps/jsr.io/@nats-io/jetstream/3.2.0/src/mod.js';
|
|
14
14
|
import { Kvm } from '../../../deps/jsr.io/@nats-io/kv/3.2.0/src/mod.js';
|
|
15
15
|
import { connect, credsAuthenticator } from '../../../deps/jsr.io/@nats-io/transport-deno/3.2.0/src/mod.js';
|
|
16
|
-
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
17
16
|
import { NatsKeyValue } from './NatsKeyValue.js';
|
|
17
|
+
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
18
18
|
function getOptionsFromEnv() {
|
|
19
19
|
const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
20
20
|
return {
|
|
@@ -172,7 +172,7 @@ export class NatsKeyValueProvider {
|
|
|
172
172
|
const activationSuffix = options.activationId ? `.${options.activationId}` : '';
|
|
173
173
|
switch (options.scope) {
|
|
174
174
|
case ':organization:':
|
|
175
|
-
return `${this.opts.organizationId}`;
|
|
175
|
+
return `${this.opts.organizationId}${activationSuffix}`;
|
|
176
176
|
case ':project:':
|
|
177
177
|
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}${activationSuffix}`;
|
|
178
178
|
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"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* As of the Change Date, in accordance with the Business Source License,
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
|
-
import { KvOperationsService } from '../../dsl/http/versori/kvapi/services/KvOperationsService.js';
|
|
14
13
|
import { StoresService } from '../../dsl/http/versori/kvapi/services/StoresService.js';
|
|
15
|
-
import {
|
|
14
|
+
import { KvOperationsService } from '../../dsl/http/versori/kvapi/services/KvOperationsService.js';
|
|
16
15
|
import { SDKKeyValue } from './SDKKeyValue.js';
|
|
16
|
+
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
17
17
|
function getOptionsFromEnv() {
|
|
18
18
|
return {
|
|
19
19
|
organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
|
|
@@ -145,7 +145,7 @@ export class SDKKeyValueProvider {
|
|
|
145
145
|
const activationSuffix = options.activationId ? `/${options.activationId}` : '';
|
|
146
146
|
switch (options.scope) {
|
|
147
147
|
case ':organization:':
|
|
148
|
-
return `${this.opts.organizationId}`;
|
|
148
|
+
return `${this.opts.organizationId}${activationSuffix}`;
|
|
149
149
|
case ':project:':
|
|
150
150
|
return `${this.opts.organizationId}/${this.opts.projectId}/${this.opts.environment}${activationSuffix}`;
|
|
151
151
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versori/run",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.1",
|
|
4
4
|
"description": "Versori Run",
|
|
5
5
|
"homepage": "https://github.com/versori/versori-run#readme",
|
|
6
6
|
"repository": {
|
|
@@ -27,9 +27,11 @@
|
|
|
27
27
|
"@connectrpc/connect": "^2.0.4",
|
|
28
28
|
"@connectrpc/connect-node": "^2.0.4",
|
|
29
29
|
"@opentelemetry/api": "^1.9.0",
|
|
30
|
+
"@opentelemetry/core": "^2.1.0",
|
|
30
31
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.200.0",
|
|
31
32
|
"@opentelemetry/resources": "^2.0.0",
|
|
32
33
|
"@opentelemetry/sdk-node": "^0.200.0",
|
|
34
|
+
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
33
35
|
"cors": "^2.8.5",
|
|
34
36
|
"express": "^4.21.2",
|
|
35
37
|
"express-xml-bodyparser": "^0.3.0",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Client } from '@connectrpc/connect';
|
|
2
2
|
import { RequestHandler } from 'express';
|
|
3
|
-
import { CredentialsProvider } from '../credentials/CredentialsProvider.js';
|
|
4
3
|
import { Logger } from '../observability/mod.js';
|
|
5
4
|
import { credentialv1alpha1, oauth1v1, tokensv1 } from '../services/credentials/mod.js';
|
|
6
5
|
import { Connection } from '../services/platform/mod.js';
|
|
@@ -16,16 +15,15 @@ import { ConnectionFactory, FetchLike } from './types.js';
|
|
|
16
15
|
*/
|
|
17
16
|
export declare class DirectConnectionFactory implements ConnectionFactory {
|
|
18
17
|
private readonly httpClientFactory;
|
|
19
|
-
readonly credentials
|
|
20
|
-
readonly tokens
|
|
21
|
-
readonly oauth1
|
|
18
|
+
private readonly credentials;
|
|
19
|
+
private readonly tokens;
|
|
20
|
+
private readonly oauth1;
|
|
22
21
|
private readonly logger;
|
|
23
22
|
private readonly outboundConnectionFactory;
|
|
24
23
|
private readonly expressInboundConnectionFactory;
|
|
25
24
|
constructor(httpClientFactory: HttpClientFactory, credentials: Client<typeof credentialv1alpha1.CredentialService>, tokens: Client<typeof tokensv1.TokenService>, oauth1: Client<typeof oauth1v1.AuthorizationService>, logger: Logger);
|
|
26
25
|
fetcher(cnx: Connection): Promise<FetchLike>;
|
|
27
26
|
handler(cnx: Connection): Promise<RequestHandler>;
|
|
28
|
-
getCredentialsProvider(): CredentialsProvider;
|
|
29
27
|
static fromEnv(logger: Logger): DirectConnectionFactory;
|
|
30
28
|
}
|
|
31
29
|
//# sourceMappingURL=DirectConnectionFactory.d.ts.map
|