@versori/run 0.6.0-alpha.1 → 0.6.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/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.js +2 -2
- package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +1 -1
- package/esm/src/connection/internal/FetchBuilder.d.ts +2 -9
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +3 -124
- package/esm/src/context/Context.d.ts +0 -5
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -6
- package/esm/src/context/VanillaContext.d.ts.map +1 -1
- package/esm/src/context/VanillaContext.js +3 -0
- package/esm/src/context/WorkflowClient.d.ts +1 -0
- package/esm/src/context/WorkflowClient.d.ts.map +1 -1
- package/esm/src/context/WorkflowClient.js +3 -0
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +0 -2
- package/esm/src/dsl/http/types.d.ts +0 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/constants.d.ts +21 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/constants.js +38 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts +3 -2
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +15 -14
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +1 -3
- package/esm/src/internal/constants.d.ts +0 -3
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +0 -3
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +2 -9
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +13 -57
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +1 -6
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.d.ts +3 -0
- package/esm/src/interpreter/durable/Queue.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 -3
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +21 -6
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +6 -29
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +11 -45
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +3 -4
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +0 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +1 -8
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +12 -56
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +1 -6
- 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 +0 -5
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +18 -29
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +10 -44
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +4 -61
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +3 -9
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +0 -1
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/vanilla/VanillaInterpreter.js +6 -30
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +12 -2
- package/esm/src/interpreter/vanilla/compilers/schedule.js +1 -1
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/esm/src/issues/Issues.js +1 -6
- package/esm/src/kv/KeyValue.d.ts +7 -3
- package/esm/src/kv/KeyValue.d.ts.map +1 -1
- package/esm/src/kv/fingerprintExternalUserId.d.ts +6 -0
- package/esm/src/kv/fingerprintExternalUserId.d.ts.map +1 -0
- package/esm/src/kv/fingerprintExternalUserId.js +20 -0
- package/esm/src/kv/memory/MemoryKeyValueProvider.d.ts +4 -0
- package/esm/src/kv/memory/MemoryKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/memory/MemoryKeyValueProvider.js +50 -0
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +14 -0
- package/esm/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValueProvider.js +12 -0
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/observability/mod.d.ts +1 -0
- package/esm/src/observability/mod.d.ts.map +1 -1
- package/esm/src/observability/mod.js +1 -0
- package/esm/src/observability/tracePropagation.d.ts +23 -0
- package/esm/src/observability/tracePropagation.d.ts.map +1 -0
- package/esm/src/observability/tracePropagation.js +39 -0
- package/package.json +1 -3
- package/script/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.js +2 -2
- package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/script/src/connection/internal/CredentialHolder.js +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts +2 -9
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +3 -147
- package/script/src/context/Context.d.ts +0 -5
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -6
- package/script/src/context/VanillaContext.d.ts.map +1 -1
- package/script/src/context/VanillaContext.js +3 -0
- package/script/src/context/WorkflowClient.d.ts +1 -0
- package/script/src/context/WorkflowClient.d.ts.map +1 -1
- package/script/src/context/WorkflowClient.js +3 -0
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +0 -2
- package/script/src/dsl/http/types.d.ts +0 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/constants.d.ts +21 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -0
- package/script/src/dsl/http/versori/constants.js +41 -0
- package/script/src/dsl/http/versori/cronapi.d.ts +3 -2
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +15 -14
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +1 -3
- package/script/src/internal/constants.d.ts +0 -3
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +1 -4
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +2 -9
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +18 -62
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +1 -6
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.d.ts +3 -0
- package/script/src/interpreter/durable/Queue.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 -3
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +21 -6
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +5 -28
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +11 -45
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +3 -4
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +0 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +1 -8
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +11 -55
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +1 -6
- 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 +0 -5
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +17 -28
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +10 -44
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +4 -61
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +3 -9
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +0 -1
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/vanilla/VanillaInterpreter.js +6 -30
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/vanilla/compilers/durableworkflow.js +12 -2
- package/script/src/interpreter/vanilla/compilers/schedule.js +1 -1
- package/script/src/issues/Issues.d.ts.map +1 -1
- package/script/src/issues/Issues.js +1 -6
- package/script/src/kv/KeyValue.d.ts +7 -3
- package/script/src/kv/KeyValue.d.ts.map +1 -1
- package/script/src/kv/fingerprintExternalUserId.d.ts +6 -0
- package/script/src/kv/fingerprintExternalUserId.d.ts.map +1 -0
- package/script/src/kv/fingerprintExternalUserId.js +23 -0
- package/script/src/kv/memory/MemoryKeyValueProvider.d.ts +4 -0
- package/script/src/kv/memory/MemoryKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/memory/MemoryKeyValueProvider.js +50 -0
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +14 -0
- package/script/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValueProvider.js +12 -0
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/script/src/observability/mod.d.ts +1 -0
- package/script/src/observability/mod.d.ts.map +1 -1
- package/script/src/observability/mod.js +1 -0
- package/script/src/observability/tracePropagation.d.ts +23 -0
- package/script/src/observability/tracePropagation.d.ts.map +1 -0
- package/script/src/observability/tracePropagation.js +46 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.9/colors.d.ts.map +0 -1
- package/esm/src/internal/supervisor.d.ts +0 -23
- package/esm/src/internal/supervisor.d.ts.map +0 -1
- package/esm/src/internal/supervisor.js +0 -267
- package/script/deps/jsr.io/@std/fmt/1.0.9/colors.d.ts.map +0 -1
- package/script/src/internal/supervisor.d.ts +0 -23
- package/script/src/internal/supervisor.d.ts.map +0 -1
- package/script/src/internal/supervisor.js +0 -275
- /package/esm/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.9 → 1.0.10}/colors.d.ts +0 -0
|
@@ -11,32 +11,19 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { mergeMap } from 'rxjs';
|
|
14
|
+
import { tap } from 'rxjs/operators';
|
|
15
|
+
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
14
16
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
15
|
-
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
16
17
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
17
|
-
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
18
|
-
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
19
18
|
function compileHttp(compilerCtx, task) {
|
|
20
19
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
21
20
|
let fetchFactory;
|
|
22
21
|
if (!cnxMap) {
|
|
23
|
-
compilerCtx.log.
|
|
24
|
-
|
|
25
|
-
// missing connection map and we are in supervised mode, so we use the fake fetcher
|
|
26
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// missing connection map and not in supervised mode, so we use global fetch
|
|
30
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
|
|
31
|
-
}
|
|
22
|
+
compilerCtx.log.error(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
|
|
23
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
|
|
32
24
|
}
|
|
33
25
|
else if (cnxMap.dynamic) {
|
|
34
|
-
|
|
35
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
39
|
-
}
|
|
26
|
+
fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
40
27
|
}
|
|
41
28
|
else {
|
|
42
29
|
fetchFactory = compilerCtx.platformApi.getConnection({
|
|
@@ -46,21 +33,8 @@ function compileHttp(compilerCtx, task) {
|
|
|
46
33
|
},
|
|
47
34
|
throwOnError: true,
|
|
48
35
|
})
|
|
49
|
-
.then(({ data }) =>
|
|
50
|
-
|
|
51
|
-
// use the fake fetcher that calls the supervisor to generate a mock reponse
|
|
52
|
-
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
|
|
53
|
-
}
|
|
54
|
-
return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
|
|
55
|
-
.then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
|
|
56
|
-
})
|
|
57
|
-
.catch((err) => {
|
|
58
|
-
compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
|
|
59
|
-
if (supervisorEnabled) {
|
|
60
|
-
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
|
|
61
|
-
}
|
|
62
|
-
throw err;
|
|
63
|
-
});
|
|
36
|
+
.then(({ data }) => Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? '']))
|
|
37
|
+
.then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
|
|
64
38
|
}
|
|
65
39
|
async function http(ctx) {
|
|
66
40
|
const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
|
|
@@ -68,27 +42,19 @@ function compileHttp(compilerCtx, task) {
|
|
|
68
42
|
const result = await task.fn(httpContext);
|
|
69
43
|
return ctx.withData(result);
|
|
70
44
|
}
|
|
71
|
-
return (src) => src.pipe(
|
|
45
|
+
return (src) => src.pipe(tap({
|
|
46
|
+
complete: () => compilerCtx.log.debug('http.complete'),
|
|
47
|
+
}), mergeMap((ctx) => {
|
|
72
48
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
73
|
-
await sendTaskStartEvent(task.id, ctx, span);
|
|
74
49
|
span.setAttribute('task.id', task.id);
|
|
75
50
|
span.setAttribute('task.type', 'http');
|
|
76
|
-
span.setAttribute('type', 'task');
|
|
77
51
|
span.setAttribute('execution.id', ctx.executionId);
|
|
78
52
|
span.setAttribute('connection.name', task.opts.connection);
|
|
79
|
-
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
80
|
-
const spanContext = span.spanContext();
|
|
81
53
|
try {
|
|
82
|
-
|
|
83
|
-
if (supervisorEnabled) {
|
|
84
|
-
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
85
|
-
}
|
|
86
|
-
span.setAttribute('status', 'pass');
|
|
87
|
-
return result;
|
|
54
|
+
return await http(ctx);
|
|
88
55
|
}
|
|
89
56
|
catch (error) {
|
|
90
57
|
if (error instanceof Error) {
|
|
91
|
-
span.setAttribute('status', 'fail');
|
|
92
58
|
span.recordException(error);
|
|
93
59
|
}
|
|
94
60
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkJ7C,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';
|
|
14
15
|
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
|
|
@@ -52,7 +52,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
52
52
|
});
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const executionCtx = ctx.contextProvider.create(activation[0], {}
|
|
55
|
+
const executionCtx = ctx.contextProvider.create(activation[0], {});
|
|
56
56
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
57
57
|
try {
|
|
58
58
|
subscriber.next(executionCtx);
|
|
@@ -84,7 +84,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
activations.forEach((activation) => {
|
|
87
|
-
const executionCtx = ctx.contextProvider.create(activation, {}
|
|
87
|
+
const executionCtx = ctx.contextProvider.create(activation, {});
|
|
88
88
|
try {
|
|
89
89
|
subscriber.next(executionCtx);
|
|
90
90
|
}
|
|
@@ -103,7 +103,6 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
103
103
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
104
104
|
span.setAttribute('task.id', trigger.id);
|
|
105
105
|
span.setAttribute('task.type', 'schedule');
|
|
106
|
-
span.setAttribute('type', 'task');
|
|
107
106
|
span.setAttribute('schedule', trigger.schedule);
|
|
108
107
|
span.setAttribute('project.id', projectId);
|
|
109
108
|
span.setAttribute('environment.id', environmentId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"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,
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAySxE,CAAC"}
|
|
@@ -84,7 +84,6 @@ export const webhookCompiler = {
|
|
|
84
84
|
onError = trigger.options.response.onError;
|
|
85
85
|
}
|
|
86
86
|
const ctxOptionsFn = (req, res) => ({
|
|
87
|
-
workflowId: trigger.id,
|
|
88
87
|
onSuccess: (ctx) => {
|
|
89
88
|
if (isSync) {
|
|
90
89
|
sendResponse(res, onSuccess(ctx));
|
|
@@ -105,7 +104,6 @@ export const webhookCompiler = {
|
|
|
105
104
|
else {
|
|
106
105
|
routeMiddleware.push(express.raw({ type: '*/*', limit: '50mb' }));
|
|
107
106
|
}
|
|
108
|
-
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
109
107
|
return new Observable((subscriber) => {
|
|
110
108
|
if (!ctx.webhookRouter) {
|
|
111
109
|
throw new Error('Router not available in compiler context');
|
|
@@ -44,11 +44,6 @@ type Registration = {
|
|
|
44
44
|
sigintListener: () => void;
|
|
45
45
|
subscription?: Subscription;
|
|
46
46
|
};
|
|
47
|
-
type WebhookRegistry = Map<string, {
|
|
48
|
-
method: string;
|
|
49
|
-
path: string;
|
|
50
|
-
options: any;
|
|
51
|
-
}>;
|
|
52
47
|
/**
|
|
53
48
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
54
49
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -77,7 +72,6 @@ export declare class MemoryInterpreter {
|
|
|
77
72
|
private readonly webhookRouter;
|
|
78
73
|
private readonly cronRouter;
|
|
79
74
|
private cronRegistry;
|
|
80
|
-
private webhookRegistry;
|
|
81
75
|
private readonly cnxFactory;
|
|
82
76
|
private readonly cronProvider;
|
|
83
77
|
private readonly tracer;
|
|
@@ -89,8 +83,7 @@ export declare class MemoryInterpreter {
|
|
|
89
83
|
private cronServer?;
|
|
90
84
|
private shutdownServer?;
|
|
91
85
|
private isShuttingDown;
|
|
92
|
-
|
|
93
|
-
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
86
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
94
87
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
95
88
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
96
89
|
start(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,16 +22,15 @@ import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
|
22
22
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
23
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
24
24
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
25
|
-
import {
|
|
26
|
-
import { Fake, registerWorkflow, signalReady, enabled as supervisorEnabled } from '../../internal/supervisor.js';
|
|
25
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../internal/constants.js';
|
|
27
26
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
28
27
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
29
28
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
30
29
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
31
30
|
import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
|
|
32
31
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
33
|
-
function getKVProvider() {
|
|
34
|
-
if (
|
|
32
|
+
function getKVProvider(runLocal) {
|
|
33
|
+
if (runLocal) {
|
|
35
34
|
return Promise.resolve(new MemoryKeyValueProvider());
|
|
36
35
|
}
|
|
37
36
|
return NatsKeyValueProvider.fromEnv();
|
|
@@ -58,7 +57,7 @@ function getKVProvider() {
|
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
59
|
export class MemoryInterpreter {
|
|
61
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry,
|
|
60
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
62
61
|
Object.defineProperty(this, "log", {
|
|
63
62
|
enumerable: true,
|
|
64
63
|
configurable: true,
|
|
@@ -95,12 +94,6 @@ export class MemoryInterpreter {
|
|
|
95
94
|
writable: true,
|
|
96
95
|
value: cronRegistry
|
|
97
96
|
});
|
|
98
|
-
Object.defineProperty(this, "webhookRegistry", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: webhookRegistry
|
|
103
|
-
});
|
|
104
97
|
Object.defineProperty(this, "cnxFactory", {
|
|
105
98
|
enumerable: true,
|
|
106
99
|
configurable: true,
|
|
@@ -167,13 +160,6 @@ export class MemoryInterpreter {
|
|
|
167
160
|
writable: true,
|
|
168
161
|
value: false
|
|
169
162
|
});
|
|
170
|
-
// Workflow registration promises only used when supervisor is enabled
|
|
171
|
-
Object.defineProperty(this, "wfRegistration", {
|
|
172
|
-
enumerable: true,
|
|
173
|
-
configurable: true,
|
|
174
|
-
writable: true,
|
|
175
|
-
value: []
|
|
176
|
-
});
|
|
177
163
|
if (typeof this.log === 'undefined') {
|
|
178
164
|
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
179
165
|
// error message back to the user to let them know they should use the new way.
|
|
@@ -192,6 +178,7 @@ export class MemoryInterpreter {
|
|
|
192
178
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
193
179
|
let otelSDK;
|
|
194
180
|
const configReader = VersoriConfigReader.fromEnv(log);
|
|
181
|
+
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
195
182
|
await waitForReady(log);
|
|
196
183
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
197
184
|
const resource = resourceFromAttributes({
|
|
@@ -213,29 +200,20 @@ export class MemoryInterpreter {
|
|
|
213
200
|
log.info('Starting OpenTelemetry SDK');
|
|
214
201
|
otelSDK.start();
|
|
215
202
|
}
|
|
216
|
-
else if (supervisorEnabled) {
|
|
217
|
-
otelSDK = new NodeSDK({
|
|
218
|
-
traceExporter: new Fake(),
|
|
219
|
-
serviceName: serviceName,
|
|
220
|
-
resource: resource,
|
|
221
|
-
});
|
|
222
|
-
log.info('Starting Testing OpenTelemetry SDK');
|
|
223
|
-
otelSDK.start();
|
|
224
|
-
}
|
|
225
203
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
226
204
|
const connectionFactory = DirectConnectionFactory.fromEnv(log);
|
|
227
205
|
const issuesProvider = new IssueImpl(log);
|
|
228
206
|
if (options.contextProvider) {
|
|
229
207
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
230
208
|
// initialised.
|
|
231
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(),
|
|
209
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
232
210
|
}
|
|
233
|
-
const kvp = await getKVProvider();
|
|
211
|
+
const kvp = await getKVProvider(runLocal);
|
|
234
212
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
235
213
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
236
214
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
237
215
|
const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
|
|
238
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(),
|
|
216
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
239
217
|
}
|
|
240
218
|
register(workflow, options) {
|
|
241
219
|
const localAbortController = new AbortController();
|
|
@@ -257,7 +235,6 @@ export class MemoryInterpreter {
|
|
|
257
235
|
cnxFactory: this.cnxFactory,
|
|
258
236
|
platformApi: PlatformApiImpl.fromEnv(),
|
|
259
237
|
webhookRouter: this.webhookRouter,
|
|
260
|
-
webhookRegistry: this.webhookRegistry,
|
|
261
238
|
cronRouter: this.cronRouter,
|
|
262
239
|
cronRegistry: this.cronRegistry,
|
|
263
240
|
configReader: this.cfgReader,
|
|
@@ -277,14 +254,11 @@ export class MemoryInterpreter {
|
|
|
277
254
|
},
|
|
278
255
|
};
|
|
279
256
|
this.registeredWorkflows.push(registration);
|
|
280
|
-
if (supervisorEnabled) {
|
|
281
|
-
this.wfRegistration.push(registerWorkflow(workflow));
|
|
282
|
-
}
|
|
283
257
|
return registration;
|
|
284
258
|
}
|
|
285
|
-
|
|
286
|
-
const port = Deno.env.get(
|
|
287
|
-
const cronPort = Deno.env.get(
|
|
259
|
+
start() {
|
|
260
|
+
const port = Deno.env.get('PORT') || 3000;
|
|
261
|
+
const cronPort = Deno.env.get('CRON_PORT') || 3001;
|
|
288
262
|
const webhookApp = express();
|
|
289
263
|
const cronApp = express();
|
|
290
264
|
cronApp.use(express.json());
|
|
@@ -311,13 +285,6 @@ export class MemoryInterpreter {
|
|
|
311
285
|
triggerName: registration.triggerName,
|
|
312
286
|
error: err instanceof Error ? err.toString() : err,
|
|
313
287
|
});
|
|
314
|
-
this.tracer.startActiveSpan('done', (span) => {
|
|
315
|
-
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
316
|
-
span.setAttribute('execution.id', ctx.executionId);
|
|
317
|
-
span.setAttribute('result', 'fail');
|
|
318
|
-
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
319
|
-
span.end();
|
|
320
|
-
});
|
|
321
288
|
try {
|
|
322
289
|
ctx.options.onError?.(ctx.withData(err));
|
|
323
290
|
}
|
|
@@ -340,12 +307,6 @@ export class MemoryInterpreter {
|
|
|
340
307
|
triggerName: registration.triggerName,
|
|
341
308
|
durationMs,
|
|
342
309
|
});
|
|
343
|
-
this.tracer.startActiveSpan('done', (span) => {
|
|
344
|
-
span.setAttribute('execution.id', ctx.executionId);
|
|
345
|
-
span.setAttribute('result', 'pass');
|
|
346
|
-
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
347
|
-
span.end();
|
|
348
|
-
});
|
|
349
310
|
try {
|
|
350
311
|
ctx.options.onSuccess?.(ctx);
|
|
351
312
|
}
|
|
@@ -407,7 +368,6 @@ export class MemoryInterpreter {
|
|
|
407
368
|
if (this.cronServer) {
|
|
408
369
|
this.cronServer.close();
|
|
409
370
|
}
|
|
410
|
-
this.otelSDK?.shutdown();
|
|
411
371
|
// Remove all signal listeners
|
|
412
372
|
for (const registration of this.registeredWorkflows) {
|
|
413
373
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -424,10 +384,6 @@ export class MemoryInterpreter {
|
|
|
424
384
|
}
|
|
425
385
|
};
|
|
426
386
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
427
|
-
if (supervisorEnabled) {
|
|
428
|
-
await Promise.all(this.wfRegistration);
|
|
429
|
-
await signalReady();
|
|
430
|
-
}
|
|
431
387
|
return new Promise((resolve) => {
|
|
432
388
|
let serversClosed = 0;
|
|
433
389
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -464,7 +420,7 @@ export class MemoryInterpreter {
|
|
|
464
420
|
}
|
|
465
421
|
}
|
|
466
422
|
async function waitForReady(log) {
|
|
467
|
-
const readyCheckUrl = Deno.env.get(
|
|
423
|
+
const readyCheckUrl = Deno.env.get('READY_CHECK_URL');
|
|
468
424
|
if (!readyCheckUrl) {
|
|
469
425
|
return Promise.resolve();
|
|
470
426
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import { ContextImpl } from '../../context/Context.js';
|
|
6
5
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
7
6
|
import { ConfigReader } from '../../dsl/http/types.js';
|
|
@@ -11,6 +10,7 @@ import { IssueAPI } from '../../issues/Issues.js';
|
|
|
11
10
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
12
11
|
import { PlatformApi } from '../../services/platform/PlatformApi.js';
|
|
13
12
|
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,11 +23,6 @@ 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
|
-
}>;
|
|
31
26
|
organisationId: string;
|
|
32
27
|
};
|
|
33
28
|
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;AAEpD,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;AAG9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,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,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;AAsFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -19,13 +19,9 @@ function compileCatch(compilerCtx, task) {
|
|
|
19
19
|
return (src) => src.pipe(mergeMap((ctx) => {
|
|
20
20
|
return baseOperator(of(ctx)).pipe(catchError((error) => {
|
|
21
21
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
22
|
-
// TODO: do we even want this here? Can't be async in here I believe
|
|
23
|
-
// await sendTaskStartEvent(task.id, span);
|
|
24
22
|
span.setAttribute('execution.id', ctx.executionId);
|
|
25
23
|
span.setAttribute('task.type', 'catch');
|
|
26
|
-
span.setAttribute('type', 'task');
|
|
27
24
|
if (error instanceof Error) {
|
|
28
|
-
span.setAttribute('status', 'fail');
|
|
29
25
|
span.recordException(error);
|
|
30
26
|
span.setAttribute('error.message', error.message);
|
|
31
27
|
span.setAttribute('error.stack', error.stack ?? '');
|
|
@@ -63,7 +59,6 @@ function compileCatch(compilerCtx, task) {
|
|
|
63
59
|
ctx.log.error('execution has encountered an error', {
|
|
64
60
|
error: error,
|
|
65
61
|
});
|
|
66
|
-
span.setAttribute('status', 'fail');
|
|
67
62
|
span.setAttribute('error', `${error}`);
|
|
68
63
|
span.end();
|
|
69
64
|
return errorOperator(of(ctx.withData(new ExecutionError(ctx, `${error}`, { cause: error }), { recoveredFromCatch: true })));
|
|
@@ -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;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAiCnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -1,40 +1,29 @@
|
|
|
1
|
-
|
|
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
|
+
import { mergeMap, tap } from 'rxjs';
|
|
2
14
|
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
3
|
-
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
4
15
|
function compileFn(compilerCtx, task) {
|
|
5
|
-
return (src) => src.pipe(
|
|
16
|
+
return (src) => src.pipe(tap({
|
|
17
|
+
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
18
|
+
}), mergeMap(async (ctx) => {
|
|
6
19
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
7
|
-
ctx = await sendTaskStartEvent(task.id, ctx, span);
|
|
8
20
|
span.setAttribute('task.id', task.id);
|
|
9
|
-
span.setAttribute('type', 'task');
|
|
10
|
-
span.setAttribute('task.type', 'fn');
|
|
11
21
|
span.setAttribute('execution.id', ctx.executionId);
|
|
12
|
-
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
13
22
|
try {
|
|
14
|
-
let result;
|
|
15
|
-
const spanContext = span.spanContext();
|
|
16
|
-
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
17
23
|
if (typeof ctx.idx === 'number') {
|
|
18
|
-
|
|
24
|
+
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
result = ctx.withData(await task._fn(ctxWithLogger));
|
|
22
|
-
}
|
|
23
|
-
if (supervisorEnabled) {
|
|
24
|
-
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
25
|
-
}
|
|
26
|
-
span.setAttribute('status', 'pass');
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
if (error instanceof Error) {
|
|
31
|
-
span.setAttribute('status', 'fail');
|
|
32
|
-
span.recordException(error);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
span.recordException(new Error(String(error)));
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
26
|
+
return ctx.withData(await task._fn(ctx));
|
|
38
27
|
}
|
|
39
28
|
finally {
|
|
40
29
|
span.end();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAqFnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -11,32 +11,19 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { mergeMap } from 'rxjs';
|
|
14
|
+
import { tap } from 'rxjs/operators';
|
|
14
15
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
15
|
-
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
16
16
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
17
17
|
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
18
|
-
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
19
18
|
function compileHttp(compilerCtx, task) {
|
|
20
19
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
21
20
|
let fetchFactory;
|
|
22
21
|
if (!cnxMap) {
|
|
23
|
-
compilerCtx.log.
|
|
24
|
-
|
|
25
|
-
// missing connection map and we are in supervised mode, so we use the fake fetcher
|
|
26
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// missing connection map and not in supervised mode, so we use global fetch
|
|
30
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
|
|
31
|
-
}
|
|
22
|
+
compilerCtx.log.error(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
|
|
23
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
|
|
32
24
|
}
|
|
33
25
|
else if (cnxMap.dynamic) {
|
|
34
|
-
|
|
35
|
-
fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
39
|
-
}
|
|
26
|
+
fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
40
27
|
}
|
|
41
28
|
else {
|
|
42
29
|
fetchFactory = compilerCtx.platformApi.getConnection({
|
|
@@ -46,21 +33,8 @@ function compileHttp(compilerCtx, task) {
|
|
|
46
33
|
},
|
|
47
34
|
throwOnError: true,
|
|
48
35
|
})
|
|
49
|
-
.then(({ data }) =>
|
|
50
|
-
|
|
51
|
-
// use the fake fetcher that calls the supervisor to generate a mock reponse
|
|
52
|
-
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
|
|
53
|
-
}
|
|
54
|
-
return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
|
|
55
|
-
.then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
|
|
56
|
-
})
|
|
57
|
-
.catch((err) => {
|
|
58
|
-
compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
|
|
59
|
-
if (supervisorEnabled) {
|
|
60
|
-
return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
|
|
61
|
-
}
|
|
62
|
-
throw err;
|
|
63
|
-
});
|
|
36
|
+
.then(({ data }) => Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? '']))
|
|
37
|
+
.then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
|
|
64
38
|
}
|
|
65
39
|
async function http(ctx) {
|
|
66
40
|
const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
|
|
@@ -68,27 +42,19 @@ function compileHttp(compilerCtx, task) {
|
|
|
68
42
|
const result = await task.fn(httpContext);
|
|
69
43
|
return ctx.withData(result);
|
|
70
44
|
}
|
|
71
|
-
return (src) => src.pipe(
|
|
45
|
+
return (src) => src.pipe(tap({
|
|
46
|
+
complete: () => compilerCtx.log.debug('http.complete'),
|
|
47
|
+
}), mergeMap((ctx) => {
|
|
72
48
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
73
|
-
ctx = await sendTaskStartEvent(task.id, ctx, span);
|
|
74
49
|
span.setAttribute('task.id', task.id);
|
|
75
50
|
span.setAttribute('task.type', 'http');
|
|
76
|
-
span.setAttribute('type', 'task');
|
|
77
51
|
span.setAttribute('execution.id', ctx.executionId);
|
|
78
52
|
span.setAttribute('connection.name', task.opts.connection);
|
|
79
|
-
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
80
|
-
const spanContext = span.spanContext();
|
|
81
53
|
try {
|
|
82
|
-
|
|
83
|
-
if (supervisorEnabled) {
|
|
84
|
-
span.setAttribute('response.body', JSON.stringify(newCtx.data));
|
|
85
|
-
}
|
|
86
|
-
span.setAttribute('status', 'pass');
|
|
87
|
-
return newCtx;
|
|
54
|
+
return await http(ctx);
|
|
88
55
|
}
|
|
89
56
|
catch (error) {
|
|
90
57
|
if (error instanceof Error) {
|
|
91
|
-
span.setAttribute('status', 'fail');
|
|
92
58
|
span.recordException(error);
|
|
93
59
|
}
|
|
94
60
|
else {
|
|
@@ -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":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyI7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|