@versori/run 0.4.4 → 0.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +2 -2
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +1 -1
- package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +120 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/esm/src/context/Context.d.ts +1 -0
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -0
- package/esm/src/context/ContextProvider.d.ts +1 -1
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +1 -1
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/types.d.ts +2 -0
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -15
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/InternalAuth.d.ts +0 -1
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +1 -14
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +25 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +156 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +79 -27
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +1 -1
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +1 -0
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +19 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +40 -7
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +14 -4
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +1 -0
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +19 -16
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +39 -6
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +15 -4
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +2 -2
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +143 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/script/src/context/Context.d.ts +1 -0
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -0
- package/script/src/context/ContextProvider.d.ts +1 -1
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +1 -1
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/types.d.ts +2 -0
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -15
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/InternalAuth.d.ts +0 -1
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -13
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +25 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +163 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +84 -32
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +1 -1
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +1 -0
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +19 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +40 -7
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +14 -4
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +1 -0
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +19 -16
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +39 -6
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +15 -4
- package/script/src/issues/Issues.js +1 -1
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/dsl/http/default.d.ts +0 -26
- package/esm/src/dsl/http/default.d.ts.map +0 -1
- package/esm/src/dsl/http/default.js +0 -56
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -32
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -37
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -102
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -208
- package/esm/src/internal/cli.d.ts +0 -2
- package/esm/src/internal/cli.d.ts.map +0 -1
- package/esm/src/internal/cli.js +0 -32
- package/script/src/dsl/http/default.d.ts +0 -26
- package/script/src/dsl/http/default.d.ts.map +0 -1
- package/script/src/dsl/http/default.js +0 -60
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -35
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -40
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -106
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -212
- package/script/src/internal/cli.d.ts +0 -2
- package/script/src/internal/cli.d.ts.map +0 -1
- package/script/src/internal/cli.js +0 -35
|
@@ -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';
|
|
@@ -18,26 +20,53 @@ import express from 'express';
|
|
|
18
20
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
21
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
20
22
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
21
|
-
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
22
23
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
|
-
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
24
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
25
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
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';
|
|
26
28
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
27
29
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
28
30
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
29
31
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
32
|
+
import { credentialv1alpha1 } from '../../services/credentials/mod.js';
|
|
30
33
|
import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
|
|
31
34
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
32
|
-
function getKVProvider(
|
|
33
|
-
if (
|
|
35
|
+
function getKVProvider() {
|
|
36
|
+
if (supervisorEnabled) {
|
|
34
37
|
return Promise.resolve(new MemoryKeyValueProvider());
|
|
35
38
|
}
|
|
36
39
|
return NatsKeyValueProvider.fromEnv();
|
|
37
40
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
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
|
+
};
|
|
41
70
|
}
|
|
42
71
|
/**
|
|
43
72
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
@@ -61,7 +90,7 @@ function getRoundTripperFactory(log) {
|
|
|
61
90
|
* ```
|
|
62
91
|
*/
|
|
63
92
|
export class MemoryInterpreter {
|
|
64
|
-
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) {
|
|
65
94
|
Object.defineProperty(this, "log", {
|
|
66
95
|
enumerable: true,
|
|
67
96
|
configurable: true,
|
|
@@ -98,6 +127,12 @@ export class MemoryInterpreter {
|
|
|
98
127
|
writable: true,
|
|
99
128
|
value: cronRegistry
|
|
100
129
|
});
|
|
130
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: webhookRegistry
|
|
135
|
+
});
|
|
101
136
|
Object.defineProperty(this, "cnxFactory", {
|
|
102
137
|
enumerable: true,
|
|
103
138
|
configurable: true,
|
|
@@ -182,7 +217,6 @@ export class MemoryInterpreter {
|
|
|
182
217
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
183
218
|
let otelSDK;
|
|
184
219
|
const configReader = VersoriConfigReader.fromEnv(log);
|
|
185
|
-
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
186
220
|
await waitForReady(log);
|
|
187
221
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
188
222
|
const resource = resourceFromAttributes({
|
|
@@ -204,20 +238,30 @@ export class MemoryInterpreter {
|
|
|
204
238
|
log.info('Starting OpenTelemetry SDK');
|
|
205
239
|
otelSDK.start();
|
|
206
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
|
+
}
|
|
207
250
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
208
|
-
const
|
|
251
|
+
const cnxFactory = DirectConnectionFactory.fromEnv(log);
|
|
252
|
+
const credentialsProvider = getCredentialsProvider(cnxFactory);
|
|
209
253
|
const issuesProvider = new IssueImpl(log);
|
|
210
254
|
if (options.contextProvider) {
|
|
211
255
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
212
256
|
// initialised.
|
|
213
|
-
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);
|
|
214
258
|
}
|
|
215
|
-
const kvp = await getKVProvider(
|
|
259
|
+
const kvp = await getKVProvider();
|
|
216
260
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
217
261
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
218
262
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
219
|
-
const ctxProvider = new ContextProviderImpl(log, kvp,
|
|
220
|
-
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);
|
|
221
265
|
}
|
|
222
266
|
register(workflow, options) {
|
|
223
267
|
const localAbortController = new AbortController();
|
|
@@ -236,6 +280,7 @@ export class MemoryInterpreter {
|
|
|
236
280
|
cnxFactory: this.cnxFactory,
|
|
237
281
|
platformApi: PlatformApiImpl.fromEnv(),
|
|
238
282
|
webhookRouter: this.webhookRouter,
|
|
283
|
+
webhookRegistry: this.webhookRegistry,
|
|
239
284
|
cronRouter: this.cronRouter,
|
|
240
285
|
cronRegistry: this.cronRegistry,
|
|
241
286
|
configReader: this.cfgReader,
|
|
@@ -256,9 +301,9 @@ export class MemoryInterpreter {
|
|
|
256
301
|
this.registeredWorkflows.push(registration);
|
|
257
302
|
return registration;
|
|
258
303
|
}
|
|
259
|
-
start() {
|
|
260
|
-
const port = Deno.env.get(
|
|
261
|
-
const cronPort = Deno.env.get(
|
|
304
|
+
async start() {
|
|
305
|
+
const port = Deno.env.get(envPort) || 3000;
|
|
306
|
+
const cronPort = Deno.env.get(envCronPort) || 3001;
|
|
262
307
|
const webhookApp = express();
|
|
263
308
|
const cronApp = express();
|
|
264
309
|
cronApp.use(express.json());
|
|
@@ -282,6 +327,12 @@ export class MemoryInterpreter {
|
|
|
282
327
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
283
328
|
error: err instanceof Error ? err.toString() : err,
|
|
284
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
|
+
});
|
|
285
336
|
try {
|
|
286
337
|
ctx.options.onError?.(ctx.withData(err));
|
|
287
338
|
}
|
|
@@ -301,6 +352,11 @@ export class MemoryInterpreter {
|
|
|
301
352
|
durationMs,
|
|
302
353
|
data: ctx.data,
|
|
303
354
|
});
|
|
355
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
356
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
357
|
+
span.setAttribute('result', 'pass');
|
|
358
|
+
span.end();
|
|
359
|
+
});
|
|
304
360
|
try {
|
|
305
361
|
ctx.options.onSuccess?.(ctx);
|
|
306
362
|
}
|
|
@@ -337,6 +393,9 @@ export class MemoryInterpreter {
|
|
|
337
393
|
});
|
|
338
394
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
339
395
|
}
|
|
396
|
+
// register with suopervisor
|
|
397
|
+
await registerCrons(this.cronRegistry);
|
|
398
|
+
await registerWebhooks(this.webhookRegistry);
|
|
340
399
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
341
400
|
this.log.info(`Express server listening on port ${port}`);
|
|
342
401
|
});
|
|
@@ -356,6 +415,7 @@ export class MemoryInterpreter {
|
|
|
356
415
|
if (this.cronServer) {
|
|
357
416
|
this.cronServer.close();
|
|
358
417
|
}
|
|
418
|
+
this.otelSDK?.shutdown();
|
|
359
419
|
// Remove all signal listeners
|
|
360
420
|
for (const registration of this.registeredWorkflows) {
|
|
361
421
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -408,7 +468,7 @@ export class MemoryInterpreter {
|
|
|
408
468
|
}
|
|
409
469
|
}
|
|
410
470
|
async function waitForReady(log) {
|
|
411
|
-
const readyCheckUrl = Deno.env.get(
|
|
471
|
+
const readyCheckUrl = Deno.env.get(envReadyCheckURL);
|
|
412
472
|
if (!readyCheckUrl) {
|
|
413
473
|
return Promise.resolve();
|
|
414
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":"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"}
|
|
@@ -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":"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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectConnectionFactory.d.ts","sourceRoot":"","sources":["../../../src/src/connection/DirectConnectionFactory.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"DirectConnectionFactory.d.ts","sourceRoot":"","sources":["../../../src/src/connection/DirectConnectionFactory.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;GAOG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAKzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAR3B,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA4B;IACtE,OAAO,CAAC,QAAQ,CAAC,+BAA+B,CAA2B;gBAGtD,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,MAAM,CAAC,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,EAChE,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,YAAY,CAAC,EAC5C,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,EACpD,MAAM,EAAE,MAAM;IAkBnC,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAI5C,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IAIjD,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB;CAuB1D"}
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DirectConnectionFactory = void 0;
|
|
16
16
|
const connect_node_1 = require("@connectrpc/connect-node");
|
|
17
|
-
const
|
|
17
|
+
const constants_js_1 = require("../internal/constants.js");
|
|
18
18
|
const createConnectRpcClient_js_1 = require("../services/createConnectRpcClient.js");
|
|
19
|
+
const mod_js_1 = require("../services/credentials/mod.js");
|
|
19
20
|
const HttpClientFactory_js_1 = require("./internal/HttpClientFactory.js");
|
|
20
21
|
const InboundConnectionFactory_js_1 = require("./internal/InboundConnectionFactory.js");
|
|
21
22
|
const OutboundConnectionFactory_js_1 = require("./internal/OutboundConnectionFactory.js");
|
|
22
|
-
const constants_js_1 = require("../internal/constants.js");
|
|
23
23
|
/**
|
|
24
24
|
* DirectConnectionFactory is used by actual {@link FetchFactory} and {@link ExpressHandlers} implementations to build a
|
|
25
25
|
* fetchers and handlers for a given connection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialHolder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/CredentialHolder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CredentialHolder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/CredentialHolder.ts"],"names":[],"mappings":"AAcA,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;GAEG;AACH,qBAAa,gBAAgB,CAAC,CAAC;;gBAQvB,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAOlD,GAAG,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IA0B/C,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;CAgClC"}
|
|
@@ -47,7 +47,7 @@ class CredentialHolder {
|
|
|
47
47
|
this.refresh();
|
|
48
48
|
return __classPrivateFieldGet(this, _CredentialHolder_value, "f");
|
|
49
49
|
}
|
|
50
|
-
// if this.refresh returns a rejected promise we are stuck with it until a restart.
|
|
50
|
+
// if this.refresh returns a rejected promise we are stuck with it until a restart.
|
|
51
51
|
// the try/catch bellow just keeps on trying to refresh the token if this.#value is rejected.
|
|
52
52
|
//
|
|
53
53
|
// We might have to change this because if credentials has an issue we might just make that issue worse by pamming more requests
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FetchLike, OutboundMiddleware } from '../types.js';
|
|
2
|
-
|
|
2
|
+
export type FetchConnection = {
|
|
3
|
+
name: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* FetchBuilder is used to build a fetch function which can be composed by multiple middlewares for
|
|
5
9
|
* modifying the request/response and makes the implementation of {@link ConnectionFetchFactory}
|
|
@@ -8,8 +12,11 @@ import { Connection } from '../../services/platform/mod.js';
|
|
|
8
12
|
export declare class FetchBuilder {
|
|
9
13
|
#private;
|
|
10
14
|
middlewares: OutboundMiddleware[];
|
|
11
|
-
constructor(fetch: FetchLike, cnx:
|
|
15
|
+
constructor(fetch: FetchLike, cnx: FetchConnection);
|
|
12
16
|
use(fn: OutboundMiddleware): void;
|
|
13
17
|
build(): FetchLike;
|
|
18
|
+
buildSupervisedFetch(): FetchLike;
|
|
19
|
+
private supervisedFetch;
|
|
20
|
+
private wrapWithTracing;
|
|
14
21
|
}
|
|
15
22
|
//# sourceMappingURL=FetchBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/FetchBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FetchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/FetchBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED;;;;GAIG;AACH,qBAAa,YAAY;;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;gBAMtB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe;IAalD,GAAG,CAAC,EAAE,EAAE,kBAAkB;IAI1B,KAAK,IAAI,SAAS;IAalB,oBAAoB,IAAI,SAAS;IAOjC,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,eAAe;CAyE1B"}
|