@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,9 +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
|
-
import { sendTaskStartEvent } from '../../../internal/supervisor.js';
|
|
17
16
|
function compileSchedule(ctx, trigger, signal) {
|
|
18
17
|
return new Observable((subscriber) => {
|
|
19
18
|
// Add HTTP endpoint for manual triggering
|
|
@@ -26,43 +25,8 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
26
25
|
const orgId = Deno.env.get(envVarOrgId) || 'example-org';
|
|
27
26
|
const client = ctx.platformApi;
|
|
28
27
|
ctx.cronRegistry.set(trigger.id, trigger.schedule);
|
|
29
|
-
async function handleSchedule(
|
|
28
|
+
async function handleSchedule(_req, res, span) {
|
|
30
29
|
try {
|
|
31
|
-
// run for a single activation
|
|
32
|
-
const activationId = req.params.activationId;
|
|
33
|
-
if (activationId) {
|
|
34
|
-
const { data: activation } = await client.getActivation({
|
|
35
|
-
path: {
|
|
36
|
-
organisation_id: ctx.organisationId,
|
|
37
|
-
environment_id: environmentId,
|
|
38
|
-
activation_id: activationId,
|
|
39
|
-
},
|
|
40
|
-
throwOnError: false,
|
|
41
|
-
});
|
|
42
|
-
if (!activation) {
|
|
43
|
-
res.status(412).json({
|
|
44
|
-
status: 'error',
|
|
45
|
-
message: `No activation found for ID: ${activationId}`,
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const executionCtx = ctx.contextProvider.create(activation, {}, { workflowId: trigger.id });
|
|
50
|
-
span.setAttribute('execution.id', executionCtx.executionId);
|
|
51
|
-
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
52
|
-
try {
|
|
53
|
-
ctx.log.info(`Running schedule ${trigger.id} for activation ${activationId}`);
|
|
54
|
-
subscriber.next(executionCtx);
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
executionCtx.log.error('execution error inside schedule', { error });
|
|
58
|
-
}
|
|
59
|
-
res.status(200).json({
|
|
60
|
-
status: 'triggered',
|
|
61
|
-
executionId: executionCtx.executionId,
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
// run for static activation only
|
|
66
30
|
if (trigger.activationPredicate === undefined) {
|
|
67
31
|
const { data: activation } = await client.listActivations({
|
|
68
32
|
path: {
|
|
@@ -81,9 +45,8 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
81
45
|
});
|
|
82
46
|
return;
|
|
83
47
|
}
|
|
84
|
-
const executionCtx = ctx.contextProvider.create(activation[0], {}
|
|
48
|
+
const executionCtx = ctx.contextProvider.create(activation[0], {});
|
|
85
49
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
86
|
-
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
87
50
|
try {
|
|
88
51
|
subscriber.next(executionCtx);
|
|
89
52
|
}
|
|
@@ -96,7 +59,6 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
96
59
|
});
|
|
97
60
|
return;
|
|
98
61
|
}
|
|
99
|
-
// run for all activations
|
|
100
62
|
const { data: activations } = await client.listActivations({
|
|
101
63
|
path: {
|
|
102
64
|
organisation_id: ctx.organisationId,
|
|
@@ -115,9 +77,8 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
115
77
|
return;
|
|
116
78
|
}
|
|
117
79
|
activations.forEach((activation) => {
|
|
118
|
-
const executionCtx = ctx.contextProvider.create(activation, {}
|
|
80
|
+
const executionCtx = ctx.contextProvider.create(activation, {});
|
|
119
81
|
try {
|
|
120
|
-
ctx.log.info(`Running schedule ${trigger.id} for activation ${activation.id}`);
|
|
121
82
|
subscriber.next(executionCtx);
|
|
122
83
|
}
|
|
123
84
|
catch (error) {
|
|
@@ -135,29 +96,11 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
135
96
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
136
97
|
span.setAttribute('task.id', trigger.id);
|
|
137
98
|
span.setAttribute('task.type', 'schedule');
|
|
138
|
-
span.setAttribute('type', 'task');
|
|
139
|
-
span.setAttribute('schedule', trigger.schedule);
|
|
140
|
-
span.setAttribute('project.id', projectId);
|
|
141
|
-
span.setAttribute('environment.id', environmentId);
|
|
142
|
-
span.setAttribute('environment.name', environmentName);
|
|
143
|
-
span.setAttribute('org.id', orgId);
|
|
144
|
-
span.setAttribute('workflow.id', trigger.id);
|
|
145
|
-
await handleSchedule(req, res, span);
|
|
146
|
-
span.end();
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
ctx.cronRouter.post(`/cron/${trigger.id}/activations/:activationId`, async (req, res) => {
|
|
150
|
-
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
151
|
-
span.setAttribute('task.id', trigger.id);
|
|
152
|
-
span.setAttribute('activation.id', req.params.activationId);
|
|
153
|
-
span.setAttribute('task.type', 'schedule');
|
|
154
|
-
span.setAttribute('type', 'task');
|
|
155
99
|
span.setAttribute('schedule', trigger.schedule);
|
|
156
100
|
span.setAttribute('project.id', projectId);
|
|
157
101
|
span.setAttribute('environment.id', environmentId);
|
|
158
102
|
span.setAttribute('environment.name', environmentName);
|
|
159
103
|
span.setAttribute('org.id', orgId);
|
|
160
|
-
span.setAttribute('workflow.id', trigger.id);
|
|
161
104
|
await handleSchedule(req, res, span);
|
|
162
105
|
span.end();
|
|
163
106
|
});
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,CA0SxE,CAAC"}
|
|
@@ -18,7 +18,6 @@ import { Observable } from 'rxjs';
|
|
|
18
18
|
import { createActIdDynamicWebhookMiddleware, createStaticWebhookMiddleware, createUserIdDynamicWebhookMiddleware, } from '../../../dsl/http/versori/webhookmiddleware.js';
|
|
19
19
|
import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
|
|
20
20
|
import { envVarEnvId } from '../../../internal/constants.js';
|
|
21
|
-
import { sendTaskStartEvent } from '../../../internal/supervisor.js';
|
|
22
21
|
const xml2jsDefaults = {
|
|
23
22
|
explicitArray: false,
|
|
24
23
|
normalize: false,
|
|
@@ -85,7 +84,6 @@ export const webhookCompiler = {
|
|
|
85
84
|
onError = trigger.options.response.onError;
|
|
86
85
|
}
|
|
87
86
|
const ctxOptionsFn = (req, res) => ({
|
|
88
|
-
workflowId: trigger.id,
|
|
89
87
|
onSuccess: (ctx) => {
|
|
90
88
|
if (isSync) {
|
|
91
89
|
sendResponse(res, onSuccess(ctx));
|
|
@@ -106,7 +104,6 @@ export const webhookCompiler = {
|
|
|
106
104
|
else {
|
|
107
105
|
routeMiddleware.push(express.raw({ type: '*/*', limit: '50mb' }));
|
|
108
106
|
}
|
|
109
|
-
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
110
107
|
return new Observable((subscriber) => {
|
|
111
108
|
if (!ctx.webhookRouter) {
|
|
112
109
|
throw new Error('Router not available in compiler context');
|
|
@@ -132,13 +129,12 @@ export const webhookCompiler = {
|
|
|
132
129
|
cfgReader: ctx.configReader,
|
|
133
130
|
log: ctx.log,
|
|
134
131
|
}), async (req, res) => {
|
|
135
|
-
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`,
|
|
132
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
136
133
|
span.setAttribute('task.id', trigger.id);
|
|
137
134
|
span.setAttribute('task.type', 'webhook');
|
|
138
135
|
const staticActivation = res.locals.activation;
|
|
139
136
|
const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
140
137
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
141
|
-
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
142
138
|
try {
|
|
143
139
|
subscriber.next(executionCtx);
|
|
144
140
|
if (isAsync) {
|
|
@@ -169,7 +165,7 @@ export const webhookCompiler = {
|
|
|
169
165
|
cfgReader: ctx.configReader,
|
|
170
166
|
log: ctx.log,
|
|
171
167
|
}), async (req, res) => {
|
|
172
|
-
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`,
|
|
168
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
173
169
|
span.setAttribute('task.id', trigger.id);
|
|
174
170
|
span.setAttribute('task.type', 'webhook');
|
|
175
171
|
span.setAttribute('user.id', req.params.userId);
|
|
@@ -190,7 +186,6 @@ export const webhookCompiler = {
|
|
|
190
186
|
}
|
|
191
187
|
const executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
192
188
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
193
|
-
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
194
189
|
const errors = [];
|
|
195
190
|
try {
|
|
196
191
|
subscriber.next(executionCtx);
|
|
@@ -226,7 +221,7 @@ export const webhookCompiler = {
|
|
|
226
221
|
cfgReader: ctx.configReader,
|
|
227
222
|
log: ctx.log,
|
|
228
223
|
}), async (req, res) => {
|
|
229
|
-
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`,
|
|
224
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
230
225
|
span.setAttribute('task.id', trigger.id);
|
|
231
226
|
span.setAttribute('task.type', 'webhook');
|
|
232
227
|
span.setAttribute('activation.id', req.params.activationId);
|
|
@@ -245,7 +240,6 @@ export const webhookCompiler = {
|
|
|
245
240
|
}
|
|
246
241
|
const activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
247
242
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
248
|
-
await sendTaskStartEvent(trigger.id, activationCtx, span);
|
|
249
243
|
try {
|
|
250
244
|
subscriber.next(activationCtx);
|
|
251
245
|
if (isAsync) {
|
|
@@ -86,7 +86,6 @@ export declare class VanillaInterpreter {
|
|
|
86
86
|
private cronServer?;
|
|
87
87
|
private shutdownServer?;
|
|
88
88
|
private isShuttingDown;
|
|
89
|
-
private wfRegistration;
|
|
90
89
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFetchFactory: DefaultConnectionFactory, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
91
90
|
static newInstance(options?: VanillaInterpreterOptions): Promise<VanillaInterpreter>;
|
|
92
91
|
register<O>(workflow: Workflow<O>, options?: VanillaInterpreterOptions): Registration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VanillaInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/VanillaInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAarE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAA0B,MAAM,yBAAyB,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,WAAW,E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,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,eAAe,EAAE,wBAAwB,EACzC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WASzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6F9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAsDtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoMtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -19,8 +19,7 @@ import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
|
19
19
|
import { DefaultConnectionFactory } from '../../connection/VanillaConnectionFactory.js';
|
|
20
20
|
import { VanillaContextProvider } from '../../context/VanillaContext.js';
|
|
21
21
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
22
|
-
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../
|
|
23
|
-
import { Fake, registerWorkflow, signalReady, enabled as supervisorEnabled } from '../../internal/supervisor.js';
|
|
22
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
23
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
24
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
26
25
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
@@ -29,8 +28,8 @@ import { SDKKeyValueProvider } from '../../kv/sdk/SDKKeyValueProvider.js';
|
|
|
29
28
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
30
29
|
import { QueueImpl } from '../durable/Queue.js';
|
|
31
30
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
32
|
-
function getKVProvider() {
|
|
33
|
-
if (
|
|
31
|
+
function getKVProvider(runLocal) {
|
|
32
|
+
if (runLocal) {
|
|
34
33
|
return Promise.resolve(new MemoryKeyValueProvider());
|
|
35
34
|
}
|
|
36
35
|
return SDKKeyValueProvider.fromEnv();
|
|
@@ -162,13 +161,6 @@ export class VanillaInterpreter {
|
|
|
162
161
|
writable: true,
|
|
163
162
|
value: false
|
|
164
163
|
});
|
|
165
|
-
// Workflow registration promises only used when supervisor is enabled
|
|
166
|
-
Object.defineProperty(this, "wfRegistration", {
|
|
167
|
-
enumerable: true,
|
|
168
|
-
configurable: true,
|
|
169
|
-
writable: true,
|
|
170
|
-
value: []
|
|
171
|
-
});
|
|
172
164
|
if (typeof this.log === 'undefined') {
|
|
173
165
|
throw new Error('VanillaInterpreter should not be instantiated directly. Use VanillaInterpreter.newInstance() instead.');
|
|
174
166
|
}
|
|
@@ -185,6 +177,7 @@ export class VanillaInterpreter {
|
|
|
185
177
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
186
178
|
let otelSDK;
|
|
187
179
|
const configReader = VersoriConfigReader.fromEnv(log);
|
|
180
|
+
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
188
181
|
await waitForReady(log);
|
|
189
182
|
// Do NOT change these attributes, they are used by the API to filter on
|
|
190
183
|
const resource = resourceFromAttributes({
|
|
@@ -206,15 +199,6 @@ export class VanillaInterpreter {
|
|
|
206
199
|
log.info('Starting OpenTelemetry SDK');
|
|
207
200
|
otelSDK.start();
|
|
208
201
|
}
|
|
209
|
-
else if (supervisorEnabled) {
|
|
210
|
-
otelSDK = new NodeSDK({
|
|
211
|
-
traceExporter: new Fake(),
|
|
212
|
-
serviceName: serviceName,
|
|
213
|
-
resource: resource,
|
|
214
|
-
});
|
|
215
|
-
log.info('Starting Testing OpenTelemetry SDK');
|
|
216
|
-
otelSDK.start();
|
|
217
|
-
}
|
|
218
202
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
219
203
|
const queueProvider = await QueueImpl.fromEnv(log);
|
|
220
204
|
const connectionFactory = new DefaultConnectionFactory();
|
|
@@ -222,7 +206,7 @@ export class VanillaInterpreter {
|
|
|
222
206
|
if (options.contextProvider) {
|
|
223
207
|
return new VanillaInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
224
208
|
}
|
|
225
|
-
const kvp = await getKVProvider();
|
|
209
|
+
const kvp = await getKVProvider(runLocal);
|
|
226
210
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
227
211
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
228
212
|
const ctxProvider = new VanillaContextProvider(log, kvp, organisationId, environmentId, issuesProvider, queueProvider);
|
|
@@ -265,12 +249,9 @@ export class VanillaInterpreter {
|
|
|
265
249
|
},
|
|
266
250
|
};
|
|
267
251
|
this.registeredWorkflows.push(registration);
|
|
268
|
-
if (supervisorEnabled) {
|
|
269
|
-
this.wfRegistration.push(registerWorkflow(workflow));
|
|
270
|
-
}
|
|
271
252
|
return registration;
|
|
272
253
|
}
|
|
273
|
-
|
|
254
|
+
start() {
|
|
274
255
|
const port = Deno.env.get('PORT') || 3000;
|
|
275
256
|
const cronPort = Deno.env.get('CRON_PORT') || 3001;
|
|
276
257
|
const webhookApp = express();
|
|
@@ -379,7 +360,6 @@ export class VanillaInterpreter {
|
|
|
379
360
|
if (this.cronServer) {
|
|
380
361
|
this.cronServer.close();
|
|
381
362
|
}
|
|
382
|
-
this.otelSDK?.shutdown();
|
|
383
363
|
for (const registration of this.registeredWorkflows) {
|
|
384
364
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
385
365
|
if (registration.subscription) {
|
|
@@ -392,10 +372,6 @@ export class VanillaInterpreter {
|
|
|
392
372
|
}
|
|
393
373
|
};
|
|
394
374
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
395
|
-
if (supervisorEnabled) {
|
|
396
|
-
await Promise.all(this.wfRegistration);
|
|
397
|
-
await signalReady();
|
|
398
|
-
}
|
|
399
375
|
return new Promise((resolve) => {
|
|
400
376
|
let serversClosed = 0;
|
|
401
377
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/durableworkflow.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/durableworkflow.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CA+HjD;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAI5F,CAAC"}
|
|
@@ -14,6 +14,7 @@ import { ulid } from '../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js';
|
|
|
14
14
|
import { Observable } from 'rxjs';
|
|
15
15
|
import { DurableWorkflowTrigger, } from '../../../dsl/triggers/DurableTrigger.js';
|
|
16
16
|
import { VanillaActivation } from '../ObservableCompiler.js';
|
|
17
|
+
import { extractTraceContext } from '../../../observability/tracePropagation.js';
|
|
17
18
|
export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
18
19
|
return new Observable((subscriber) => {
|
|
19
20
|
function cleanup() {
|
|
@@ -40,17 +41,26 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
43
|
for (const wf of wfs.workflows) {
|
|
43
|
-
|
|
44
|
+
// If the metadata carries a traceparent, extractTraceContext returns a
|
|
45
|
+
// context with the remote span as parent; otherwise it returns the
|
|
46
|
+
// current active context, which causes startActiveSpan to create a new
|
|
47
|
+
// root span (new trace). Either way the SDK does the right thing.
|
|
48
|
+
const parentCtx = extractTraceContext(wf.metadata);
|
|
49
|
+
await ctx.tracer.startActiveSpan(`durableworkflow-${trigger.id}`, {}, parentCtx, (span) => {
|
|
44
50
|
span.setAttribute('task.id', trigger.id);
|
|
45
51
|
span.setAttribute('task.type', 'durableworkflow');
|
|
46
52
|
span.setAttribute('execution.id', wf.metadata?.executionId ?? '');
|
|
47
53
|
if (wf.metadata?.activationId) {
|
|
48
54
|
span.setAttribute('activation.id', wf.metadata.activationId);
|
|
49
55
|
}
|
|
56
|
+
if (wf.metadata?.traceparent) {
|
|
57
|
+
span.setAttribute('trace.continuation', true);
|
|
58
|
+
}
|
|
50
59
|
try {
|
|
51
60
|
const payload = wf.payload ? atob(wf.payload) : '{}';
|
|
52
61
|
const data = JSON.parse(payload);
|
|
53
|
-
const newContext = ctx.contextProvider
|
|
62
|
+
const newContext = ctx.contextProvider
|
|
63
|
+
.createWithExecutionId(VanillaActivation, data, wf.metadata?.executionId ?? ulid().toString(), {
|
|
54
64
|
workflow: wf,
|
|
55
65
|
onSuccess: (completedContext) => {
|
|
56
66
|
const opts = completedContext.options;
|
|
@@ -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 { Observable } from 'rxjs';
|
|
14
|
-
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../
|
|
14
|
+
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../dsl/http/versori/constants.js';
|
|
15
15
|
import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
|
|
16
16
|
import { VanillaActivation } from '../ObservableCompiler.js';
|
|
17
17
|
function compileSchedule(ctx, trigger, signal) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAWjD,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC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AC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,GAAG,CAAS;gBAER,GAAG,EAAE,MAAM;IA2BjB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QACtC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YAWX,MAAM;CA2DvB;AAED,qBAAa,UAAW,YAAW,QAAQ;IACvC,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACnC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAG5B"}
|
package/esm/src/issues/Issues.js
CHANGED
|
@@ -11,8 +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 '../
|
|
15
|
-
import { enabled as supervisorEnabled } from '../internal/supervisor.js';
|
|
14
|
+
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../dsl/http/versori/constants.js';
|
|
16
15
|
export class IssueImpl {
|
|
17
16
|
constructor(log) {
|
|
18
17
|
Object.defineProperty(this, "baseUrl", {
|
|
@@ -108,10 +107,6 @@ export class IssueImpl {
|
|
|
108
107
|
issue.annotations['environmentId'] = this.environmentId;
|
|
109
108
|
issue.annotations['organisationId'] = this.organisationId;
|
|
110
109
|
try {
|
|
111
|
-
if (supervisorEnabled) {
|
|
112
|
-
this.log.info('Issue to be submitted', { issue: issue });
|
|
113
|
-
return Promise.resolve(null);
|
|
114
|
-
}
|
|
115
110
|
const response = await fetch(`${this.baseUrl}/v1/issues/submit`, {
|
|
116
111
|
method: 'POST',
|
|
117
112
|
headers: {
|
package/esm/src/kv/KeyValue.d.ts
CHANGED
|
@@ -67,10 +67,13 @@ export interface KeyValue {
|
|
|
67
67
|
* KeyValueScope determines the visibility and lifetime of key-value data.
|
|
68
68
|
*
|
|
69
69
|
* - `:execution:` - Data scoped to a single workflow execution (deleted after execution completes).
|
|
70
|
-
* - `:project:` -
|
|
70
|
+
* - `:project:` - Contrary to the name this scopes the KV to the current activation, not the project.
|
|
71
|
+
* - `:workspace:` - Data scoped to the true project (shared across all activations within the project).
|
|
71
72
|
* - `:organization:` - Data scoped to the organization (shared across all projects).
|
|
73
|
+
* - `:user:` - Data scoped to the current user based on the external_id of the activation.
|
|
74
|
+
*
|
|
72
75
|
*/
|
|
73
|
-
export type KeyValueScope = ':execution:' | ':project:' | ':organization:';
|
|
76
|
+
export type KeyValueScope = ':execution:' | ':project:' | ':workspace:' | ':organization:' | ':user:';
|
|
74
77
|
/**
|
|
75
78
|
* KVOptionsExecution specifies options for opening an execution-scoped KV store.
|
|
76
79
|
*/
|
|
@@ -79,7 +82,7 @@ export type KVOptionsExecution = {
|
|
|
79
82
|
executionId: string;
|
|
80
83
|
};
|
|
81
84
|
/**
|
|
82
|
-
* KVOptionsNotExecution specifies options for opening project or
|
|
85
|
+
* KVOptionsNotExecution specifies options for opening project, workspace, organization, or user-scoped KV stores.
|
|
83
86
|
*/
|
|
84
87
|
export type KVOptionsNotExecution = {
|
|
85
88
|
scope: Exclude<KeyValueScope, ':execution:'>;
|
|
@@ -89,6 +92,7 @@ export type KVOptionsNotExecution = {
|
|
|
89
92
|
*/
|
|
90
93
|
export type KVOptions = (KVOptionsExecution | KVOptionsNotExecution) & {
|
|
91
94
|
activationId?: string;
|
|
95
|
+
externalUserId?: string;
|
|
92
96
|
};
|
|
93
97
|
/**
|
|
94
98
|
* DestroyOptions configures which KV store to destroy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyValue.d.ts","sourceRoot":"","sources":["../../../src/src/kv/KeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpG,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC7B,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC5B,YAAY,EAAE,CAAC,CAAC;IAChB,eAAe,CAAC,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF,KAAK,mBAAmB,CAAC,CAAC,IAAI;IAC1B,eAAe,EAAE,IAAI,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAClB,sBAAsB,CAAC,CAAC,CAAC,GACzB,qBAAqB,CAAC,CAAC,CAAC,GACxB,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAE7B;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB;;;;;;;;OAQG;IACH,GAAG,CAAC,CAAC,GAAG,GAAG,EACP,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,GAC3D,OAAO,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,GAAG,GAAG,EACP,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,OA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jD;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,WAAW,GAAG,aAAa,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAEtG;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,kBAAkB,GAAG,qBAAqB,CAAC,GAAG;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;;;OAKG;IACH,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IAEjC;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable hex fingerprint of an external user id for KV path segments.
|
|
3
|
+
* Output is `[0-9a-f]{64}` so it satisfies backends that only allow `[a-zA-Z0-9_-]+` per segment.
|
|
4
|
+
*/
|
|
5
|
+
export declare function fingerprintExternalUserId(externalUserId: string): string;
|
|
6
|
+
//# sourceMappingURL=fingerprintExternalUserId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprintExternalUserId.d.ts","sourceRoot":"","sources":["../../../src/src/kv/fingerprintExternalUserId.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { createHash } from 'node:crypto';
|
|
14
|
+
/**
|
|
15
|
+
* Stable hex fingerprint of an external user id for KV path segments.
|
|
16
|
+
* Output is `[0-9a-f]{64}` so it satisfies backends that only allow `[a-zA-Z0-9_-]+` per segment.
|
|
17
|
+
*/
|
|
18
|
+
export function fingerprintExternalUserId(externalUserId) {
|
|
19
|
+
return createHash('sha256').update(externalUserId, 'utf8').digest('hex');
|
|
20
|
+
}
|
|
@@ -2,8 +2,12 @@ import { DestroyOptions, KeyValue, KeyValueProvider, KVOptions } from '../KeyVal
|
|
|
2
2
|
export declare class MemoryKeyValueProvider implements KeyValueProvider {
|
|
3
3
|
private executionKv;
|
|
4
4
|
private projectKv;
|
|
5
|
+
private workspaceKv;
|
|
6
|
+
private organizationKv;
|
|
7
|
+
private userKv;
|
|
5
8
|
kv(options: KVOptions): KeyValue;
|
|
6
9
|
destroy(options: DestroyOptions): Promise<void>;
|
|
7
10
|
private getExecutionKv;
|
|
11
|
+
private getUserKv;
|
|
8
12
|
}
|
|
9
13
|
//# sourceMappingURL=MemoryKeyValueProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/memory/MemoryKeyValueProvider.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGvF,qBAAa,sBAAuB,YAAW,gBAAgB;IAC3D,OAAO,CAAC,WAAW,CAAoC;
|
|
1
|
+
{"version":3,"file":"MemoryKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/memory/MemoryKeyValueProvider.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGvF,qBAAa,sBAAuB,YAAW,gBAAgB;IAC3D,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,MAAM,CAAoC;IAElD,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAyBhC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC/C,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,SAAS;CAUpB"}
|
|
@@ -25,6 +25,24 @@ export class MemoryKeyValueProvider {
|
|
|
25
25
|
writable: true,
|
|
26
26
|
value: new MemoryKeyValue()
|
|
27
27
|
});
|
|
28
|
+
Object.defineProperty(this, "workspaceKv", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: new MemoryKeyValue()
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "organizationKv", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: new MemoryKeyValue()
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "userKv", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: new Map()
|
|
45
|
+
});
|
|
28
46
|
}
|
|
29
47
|
kv(options) {
|
|
30
48
|
switch (options.scope) {
|
|
@@ -35,6 +53,15 @@ export class MemoryKeyValueProvider {
|
|
|
35
53
|
return this.getExecutionKv(options.executionId);
|
|
36
54
|
case ':project:':
|
|
37
55
|
return this.projectKv;
|
|
56
|
+
case ':workspace:':
|
|
57
|
+
return this.workspaceKv;
|
|
58
|
+
case ':organization:':
|
|
59
|
+
return this.organizationKv;
|
|
60
|
+
case ':user:':
|
|
61
|
+
if (typeof options.externalUserId === 'undefined') {
|
|
62
|
+
throw new Error('externalUserId is required when scope is :user:');
|
|
63
|
+
}
|
|
64
|
+
return this.getUserKv(options.externalUserId);
|
|
38
65
|
default:
|
|
39
66
|
throw new Error(`Unsupported scope: ${options.scope}`);
|
|
40
67
|
}
|
|
@@ -47,6 +74,21 @@ export class MemoryKeyValueProvider {
|
|
|
47
74
|
}
|
|
48
75
|
this.executionKv.delete(options.executionId);
|
|
49
76
|
return Promise.resolve();
|
|
77
|
+
case ':project:':
|
|
78
|
+
this.projectKv = new MemoryKeyValue();
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
case ':workspace:':
|
|
81
|
+
this.workspaceKv = new MemoryKeyValue();
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
case ':organization:':
|
|
84
|
+
this.organizationKv = new MemoryKeyValue();
|
|
85
|
+
return Promise.resolve();
|
|
86
|
+
case ':user:':
|
|
87
|
+
if (typeof options.externalUserId === 'undefined') {
|
|
88
|
+
throw new Error('externalUserId is required when scope is :user:');
|
|
89
|
+
}
|
|
90
|
+
this.userKv.delete(options.externalUserId);
|
|
91
|
+
return Promise.resolve();
|
|
50
92
|
default:
|
|
51
93
|
return Promise.resolve();
|
|
52
94
|
}
|
|
@@ -59,4 +101,12 @@ export class MemoryKeyValueProvider {
|
|
|
59
101
|
}
|
|
60
102
|
return kv;
|
|
61
103
|
}
|
|
104
|
+
getUserKv(externalUserId) {
|
|
105
|
+
let kv = this.userKv.get(externalUserId);
|
|
106
|
+
if (!kv) {
|
|
107
|
+
kv = new MemoryKeyValue();
|
|
108
|
+
this.userKv.set(externalUserId, kv);
|
|
109
|
+
}
|
|
110
|
+
return kv;
|
|
111
|
+
}
|
|
62
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AAGxH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA4CvF,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa,oBAAqB,YAAW,gBAAgB,EAAE,eAAe;IAEtE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALzB,OAAO;WAQM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,OAAO,CAAC,oBAAoB,CAAC;IA0BhC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI/C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAyB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAsBxB"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { JetStreamApiCodes, JetStreamApiError } from '../../../deps/jsr.io/@nats-io/jetstream/3.3.1/src/mod.js';
|
|
14
14
|
import { Kvm } from '../../../deps/jsr.io/@nats-io/kv/3.3.1/src/mod.js';
|
|
15
15
|
import { connect, credsAuthenticator } from '../../../deps/jsr.io/@nats-io/transport-deno/3.3.1/src/mod.js';
|
|
16
|
+
import { fingerprintExternalUserId } from '../fingerprintExternalUserId.js';
|
|
16
17
|
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
17
18
|
import { NatsKeyValue } from './NatsKeyValue.js';
|
|
18
19
|
function getOptionsFromEnv() {
|
|
@@ -125,6 +126,10 @@ export class NatsKeyValueProvider {
|
|
|
125
126
|
return new NatsKeyValue(this.kvOrgScope, this.subjectPrefix(options));
|
|
126
127
|
case ':project:':
|
|
127
128
|
return new NatsKeyValue(this.kvProjectScope, this.subjectPrefix(options));
|
|
129
|
+
case ':workspace:':
|
|
130
|
+
return new NatsKeyValue(this.kvProjectScope, this.subjectPrefix(options));
|
|
131
|
+
case ':user:':
|
|
132
|
+
return new NatsKeyValue(this.kvProjectScope, this.subjectPrefix(options));
|
|
128
133
|
case ':execution:':
|
|
129
134
|
if (!isKVOptionsExecution(options)) {
|
|
130
135
|
throw new Error('invalid KV options, executionId is required for :execution: scope');
|
|
@@ -175,8 +180,17 @@ export class NatsKeyValueProvider {
|
|
|
175
180
|
return `${this.opts.organizationId}`;
|
|
176
181
|
case ':project:':
|
|
177
182
|
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}${activationSuffix}`;
|
|
183
|
+
case ':workspace:':
|
|
184
|
+
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}`;
|
|
185
|
+
case ':user:':
|
|
186
|
+
if (typeof options.externalUserId === 'undefined') {
|
|
187
|
+
throw new Error('externalUserId is required when scope is :user:');
|
|
188
|
+
}
|
|
189
|
+
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}.${fingerprintExternalUserId(options.externalUserId)}`;
|
|
178
190
|
case ':execution:':
|
|
179
191
|
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}.${options.executionId}${activationSuffix}`;
|
|
192
|
+
default:
|
|
193
|
+
throw new Error(`Unsupported scope for subjectPrefix: ${options.scope}`);
|
|
180
194
|
}
|
|
181
195
|
}
|
|
182
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkCvF,MAAM,MAAM,0BAA0B,GAAG;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF,qBAAa,mBAAoB,YAAW,gBAAgB,EAAE,eAAe;IAErE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJzB,OAAO;WAOM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAC/C,OAAO,CAAC,mBAAmB,CAAC;IAY/B,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI9C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAyB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAoBxB"}
|