@versori/run 0.3.0-veta.2 → 0.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +6 -9
- package/esm/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +11 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +103 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/esm/src/context/AsyncWorkflow.js +1 -1
- package/esm/src/context/Context.d.ts +7 -6
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -13
- package/esm/src/context/ContextProvider.d.ts +1 -3
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +3 -6
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -14
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +0 -3
- package/esm/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +21 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +122 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.d.ts +16 -24
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +5 -4
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +3 -2
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +17 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +8 -2
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +4 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +3 -2
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +17 -4
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +33 -3
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +5 -1
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.js +3 -9
- package/esm/src/services/createConnectRpcClient.d.ts +16 -0
- package/esm/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/esm/src/services/createConnectRpcClient.js +63 -0
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +5 -8
- package/script/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +11 -2
- package/script/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +126 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/script/src/context/AsyncWorkflow.js +1 -1
- package/script/src/context/Context.d.ts +7 -6
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -13
- package/script/src/context/ContextProvider.d.ts +1 -3
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +3 -6
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -14
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +0 -3
- package/script/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +21 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +129 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.d.ts +16 -24
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +5 -4
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +3 -2
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +17 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +8 -2
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +4 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +3 -2
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +17 -4
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +33 -3
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +5 -1
- package/script/src/issues/Issues.js +1 -1
- package/script/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValue.js +3 -9
- package/script/src/services/createConnectRpcClient.d.ts +16 -0
- package/script/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/script/src/services/createConnectRpcClient.js +66 -0
- package/esm/src/context/WorkflowClient.d.ts +0 -29
- package/esm/src/context/WorkflowClient.d.ts.map +0 -1
- package/esm/src/context/WorkflowClient.js +0 -95
- package/esm/src/dsl/http/versori/activation.d.ts +0 -13
- package/esm/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/activation.js +0 -65
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -25
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -90
- package/esm/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/platformapi.js +0 -148
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -196
- package/script/src/context/WorkflowClient.d.ts +0 -29
- package/script/src/context/WorkflowClient.d.ts.map +0 -1
- package/script/src/context/WorkflowClient.js +0 -99
- package/script/src/dsl/http/versori/activation.d.ts +0 -13
- package/script/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/script/src/dsl/http/versori/activation.js +0 -69
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -23
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -28
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -94
- package/script/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/script/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/script/src/dsl/http/versori/platformapi.js +0 -152
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -200
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
import { Logger } from '../../observability/mod.js';
|
|
2
2
|
export type WorkflowMsgMetadata = {
|
|
3
3
|
parentWorkflowId?: string;
|
|
4
|
-
executionId
|
|
5
|
-
activationId
|
|
4
|
+
executionId?: string;
|
|
5
|
+
activationId?: string;
|
|
6
6
|
userId?: string;
|
|
7
7
|
};
|
|
8
8
|
export type Workflows = {
|
|
9
|
-
workflows:
|
|
9
|
+
workflows: WorkflowMsg[];
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
12
|
-
id
|
|
13
|
-
projectId
|
|
14
|
-
environmentId
|
|
11
|
+
export type WorkflowMsg = {
|
|
12
|
+
id?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
environmentId?: string;
|
|
15
15
|
group: string;
|
|
16
|
-
payload
|
|
16
|
+
payload?: string;
|
|
17
17
|
output?: string;
|
|
18
18
|
status?: 'available' | 'locked' | 'completed' | 'failed';
|
|
19
|
-
attempt
|
|
20
|
-
maxAttempts?: number;
|
|
21
|
-
timeout: string;
|
|
22
|
-
createdAt: string;
|
|
23
|
-
metadata: WorkflowMsgMetadata;
|
|
24
|
-
};
|
|
25
|
-
export type SubmitWorkflow = {
|
|
26
|
-
group: string;
|
|
27
|
-
payload: string;
|
|
19
|
+
attempt?: number;
|
|
28
20
|
maxAttempts?: number;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
timeout?: string;
|
|
22
|
+
createdAt?: string;
|
|
23
|
+
metadata?: WorkflowMsgMetadata;
|
|
32
24
|
};
|
|
33
25
|
export type CompleteWorkflowRequest = {
|
|
34
26
|
id: string;
|
|
@@ -47,14 +39,14 @@ export type RescheduleWorkflowRequest = {
|
|
|
47
39
|
after: string;
|
|
48
40
|
};
|
|
49
41
|
export type SubmitWorkflowsRequest = {
|
|
50
|
-
workflows:
|
|
42
|
+
workflows: WorkflowMsg[];
|
|
51
43
|
};
|
|
52
44
|
export interface QueueAPI {
|
|
53
45
|
complete(request: CompleteWorkflowRequest): Promise<void>;
|
|
54
46
|
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
55
47
|
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
56
48
|
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
57
|
-
|
|
49
|
+
poll(workflowId: string): Promise<WorkflowMsg>;
|
|
58
50
|
}
|
|
59
51
|
export declare class QueueImpl implements QueueAPI {
|
|
60
52
|
private baseUrl;
|
|
@@ -67,7 +59,7 @@ export declare class QueueImpl implements QueueAPI {
|
|
|
67
59
|
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
68
60
|
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
69
61
|
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
70
|
-
|
|
62
|
+
poll(workflowId: string): Promise<WorkflowMsg>;
|
|
71
63
|
}
|
|
72
64
|
export declare class MockQueue implements QueueAPI {
|
|
73
65
|
constructor();
|
|
@@ -75,6 +67,6 @@ export declare class MockQueue implements QueueAPI {
|
|
|
75
67
|
submit(_request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
76
68
|
fetchWorkflows(_request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
77
69
|
reschedule(_request: RescheduleWorkflowRequest): Promise<void>;
|
|
78
|
-
|
|
70
|
+
poll(_workflowId: string): Promise<WorkflowMsg>;
|
|
79
71
|
}
|
|
80
72
|
//# sourceMappingURL=Queue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MockQueue = exports.QueueImpl = void 0;
|
|
4
|
-
const constants_js_1 = require("../../
|
|
4
|
+
const constants_js_1 = require("../../internal/constants.js");
|
|
5
5
|
const mod_js_1 = require("../../mod.js");
|
|
6
6
|
class QueueImpl {
|
|
7
7
|
constructor(baseUrl, projectId, environmentId, log) {
|
|
@@ -60,7 +60,7 @@ class QueueImpl {
|
|
|
60
60
|
output: request.output,
|
|
61
61
|
status: request.status,
|
|
62
62
|
});
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error('Failed to complete workflow');
|
|
64
64
|
}
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -133,7 +133,8 @@ class QueueImpl {
|
|
|
133
133
|
}
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
async
|
|
136
|
+
async poll(workflowId) {
|
|
137
|
+
// this endpoint returns a 404 if the workflow is not completed
|
|
137
138
|
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
138
139
|
method: 'GET',
|
|
139
140
|
});
|
|
@@ -161,7 +162,7 @@ class MockQueue {
|
|
|
161
162
|
reschedule(_request) {
|
|
162
163
|
throw new Error('Method not implemented.');
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
poll(_workflowId) {
|
|
165
166
|
throw new Error('Method not implemented.');
|
|
166
167
|
}
|
|
167
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAGA,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/durable/compilers/catch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -13,6 +13,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
13
13
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
14
14
|
span.setAttribute('execution.id', ctx.executionId);
|
|
15
15
|
span.setAttribute('task.type', 'catch');
|
|
16
|
+
span.setAttribute('type', 'task');
|
|
16
17
|
if (error instanceof Error) {
|
|
17
18
|
span.recordException(error);
|
|
18
19
|
span.setAttribute('error.message', error.message);
|
|
@@ -26,7 +27,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
26
27
|
annotations: {
|
|
27
28
|
'error': error.message,
|
|
28
29
|
'stack': error.stack || '',
|
|
29
|
-
'workflowId': ctx.options.
|
|
30
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
30
31
|
'',
|
|
31
32
|
'executionId': ctx.executionId,
|
|
32
33
|
},
|
|
@@ -42,7 +43,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
42
43
|
annotations: {
|
|
43
44
|
'error': error.message || '',
|
|
44
45
|
'stack': error.stack || '',
|
|
45
|
-
'workflowId': ctx.options.
|
|
46
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
46
47
|
'',
|
|
47
48
|
'executionId': ctx.executionId,
|
|
48
49
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAmG9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -5,7 +5,6 @@ exports.compileDurableWorkflow = compileDurableWorkflow;
|
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
6
|
const DurableTrigger_js_1 = require("../../../dsl/triggers/DurableTrigger.js");
|
|
7
7
|
const constants_js_1 = require("../../../internal/constants.js");
|
|
8
|
-
const mod_js_1 = require("../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js");
|
|
9
8
|
function compileDurableWorkflow(ctx, trigger, signal) {
|
|
10
9
|
return new rxjs_1.Observable((subscriber) => {
|
|
11
10
|
function cleanup() {
|
|
@@ -40,9 +39,24 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
40
39
|
continue;
|
|
41
40
|
}
|
|
42
41
|
for (const wf of wfs.workflows) {
|
|
42
|
+
if (wf.id &&
|
|
43
|
+
wf.attempt !== undefined &&
|
|
44
|
+
trigger.options.maxAttempts &&
|
|
45
|
+
wf.attempt > trigger.options.maxAttempts) {
|
|
46
|
+
ctx.log.error('Workflow exceeded max attempts failing', {
|
|
47
|
+
workflowId: wf.id,
|
|
48
|
+
attempts: wf.attempt,
|
|
49
|
+
});
|
|
50
|
+
await ctx.queueProvider.complete({
|
|
51
|
+
id: wf.id,
|
|
52
|
+
output: wf.output,
|
|
53
|
+
status: 'failed',
|
|
54
|
+
});
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
43
57
|
const data = JSON.parse(atob(wf.payload ?? '{}'));
|
|
44
58
|
let activation;
|
|
45
|
-
|
|
59
|
+
if (wf.metadata?.activationId) {
|
|
46
60
|
const { data } = await ctx.platformApi.getActivation({
|
|
47
61
|
path: {
|
|
48
62
|
activation_id: wf.metadata.activationId,
|
|
@@ -53,23 +67,9 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
53
67
|
});
|
|
54
68
|
activation = data;
|
|
55
69
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
61
|
-
workflow: wf,
|
|
62
|
-
onSuccess: (completedContext) => {
|
|
63
|
-
// locked status means we own the workflow and it's not completed yet
|
|
64
|
-
if (wf.status !== 'locked') {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
ctx.queueProvider.complete({
|
|
68
|
-
id: wf.id,
|
|
69
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
70
|
-
status: 'completed',
|
|
71
|
-
});
|
|
72
|
-
},
|
|
70
|
+
const newContext = ctx.contextProvider.create(data, {
|
|
71
|
+
activation: activation,
|
|
72
|
+
workflowId: wf.id,
|
|
73
73
|
});
|
|
74
74
|
consecutiveErrors = 0;
|
|
75
75
|
subscriber.next(newContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAwCnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -3,19 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fnCompiler = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
6
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
6
7
|
function compileFn(compilerCtx, task) {
|
|
7
8
|
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
8
9
|
complete: () => compilerCtx.log.debug('fn.complete')
|
|
9
10
|
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
10
11
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
11
12
|
span.setAttribute('task.id', task.id);
|
|
13
|
+
span.setAttribute('type', 'task');
|
|
14
|
+
span.setAttribute('task.type', 'fn');
|
|
12
15
|
span.setAttribute('execution.id', ctx.executionId);
|
|
13
|
-
|
|
16
|
+
try {
|
|
17
|
+
let result;
|
|
18
|
+
if (typeof ctx.idx === 'number') {
|
|
19
|
+
result = ctx.withData(await task._fn(ctx, ctx.idx));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
result = ctx.withData(await task._fn(ctx));
|
|
23
|
+
}
|
|
24
|
+
if (supervisor_js_1.enabled) {
|
|
25
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
14
30
|
span.end();
|
|
15
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
16
31
|
}
|
|
17
|
-
span.end();
|
|
18
|
-
return ctx.withData(await task._fn(ctx));
|
|
19
32
|
});
|
|
20
33
|
}));
|
|
21
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAOA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAwFnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.httpCompiler = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
7
6
|
const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
|
|
8
7
|
const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
|
|
8
|
+
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
9
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
9
10
|
function compileHttp(compilerCtx, task) {
|
|
10
11
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
11
12
|
let fetchFactory;
|
|
@@ -39,10 +40,15 @@ function compileHttp(compilerCtx, task) {
|
|
|
39
40
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
40
41
|
span.setAttribute('task.id', task.id);
|
|
41
42
|
span.setAttribute('task.type', 'http');
|
|
43
|
+
span.setAttribute('type', 'task');
|
|
42
44
|
span.setAttribute('execution.id', ctx.executionId);
|
|
43
45
|
span.setAttribute('connection.name', task.opts.connection);
|
|
44
46
|
try {
|
|
45
|
-
|
|
47
|
+
let result = await http(ctx);
|
|
48
|
+
if (supervisor_js_1.enabled) {
|
|
49
|
+
span.setAttribute('http.response.body', JSON.stringify(result.data));
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
46
52
|
}
|
|
47
53
|
catch (error) {
|
|
48
54
|
if (error instanceof Error) {
|
|
@@ -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":"AAKA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scheduleCompiler = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
|
-
const constants_js_1 = require("../../../dsl/http/versori/constants.js");
|
|
6
5
|
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
6
|
+
const constants_js_1 = require("../../../internal/constants.js");
|
|
7
7
|
function compileSchedule(ctx, trigger, signal) {
|
|
8
8
|
return new rxjs_1.Observable((subscriber) => {
|
|
9
9
|
// Add HTTP endpoint for manual triggering
|
|
@@ -94,6 +94,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
94
94
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
95
95
|
span.setAttribute('task.id', trigger.id);
|
|
96
96
|
span.setAttribute('task.type', 'schedule');
|
|
97
|
+
span.setAttribute('type', 'task');
|
|
97
98
|
span.setAttribute('schedule', trigger.schedule);
|
|
98
99
|
span.setAttribute('project.id', projectId);
|
|
99
100
|
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":"
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AAcA,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"}
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.webhookCompiler = void 0;
|
|
7
7
|
const cors_1 = __importDefault(require("cors"));
|
|
8
8
|
const express_1 = __importDefault(require("express"));
|
|
9
|
+
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
9
10
|
const promises_1 = require("node:stream/promises");
|
|
10
11
|
const rxjs_1 = require("rxjs");
|
|
11
12
|
const webhookmiddleware_js_1 = require("../../../dsl/http/versori/webhookmiddleware.js");
|
|
12
13
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
13
14
|
const constants_js_1 = require("../../../internal/constants.js");
|
|
14
|
-
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
15
15
|
const xml2jsDefaults = {
|
|
16
16
|
explicitArray: false,
|
|
17
17
|
normalize: false,
|
|
@@ -125,6 +125,7 @@ exports.webhookCompiler = {
|
|
|
125
125
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
126
126
|
span.setAttribute('task.id', trigger.id);
|
|
127
127
|
span.setAttribute('task.type', 'webhook');
|
|
128
|
+
span.setAttribute('task.type', 'fn');
|
|
128
129
|
const staticActivation = res.locals.activation;
|
|
129
130
|
const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
130
131
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
@@ -161,6 +162,7 @@ exports.webhookCompiler = {
|
|
|
161
162
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
162
163
|
span.setAttribute('task.id', trigger.id);
|
|
163
164
|
span.setAttribute('task.type', 'webhook');
|
|
165
|
+
span.setAttribute('type', 'task');
|
|
164
166
|
span.setAttribute('user.id', req.params.userId);
|
|
165
167
|
const userId = req.params.userId;
|
|
166
168
|
const activation = res.locals.activation;
|
|
@@ -216,6 +218,7 @@ exports.webhookCompiler = {
|
|
|
216
218
|
}), async (req, res) => {
|
|
217
219
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
218
220
|
span.setAttribute('task.id', trigger.id);
|
|
221
|
+
span.setAttribute('type', 'task');
|
|
219
222
|
span.setAttribute('task.type', 'webhook');
|
|
220
223
|
span.setAttribute('activation.id', req.params.activationId);
|
|
221
224
|
const activation = res.locals.activation;
|
|
@@ -2,6 +2,7 @@ import { Tracer } from '@opentelemetry/api';
|
|
|
2
2
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
3
3
|
import { Router } from 'express';
|
|
4
4
|
import { Observable, Subscription } from 'rxjs';
|
|
5
|
+
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
5
6
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
6
7
|
import { ConfigReader, CronProvider } from '../../dsl/http/types.js';
|
|
7
8
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
@@ -9,7 +10,6 @@ import { IssueAPI } from '../../issues/Issues.js';
|
|
|
9
10
|
import { ContextImpl, ContextOperatorFunction } from '../../mod.js';
|
|
10
11
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
11
12
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
12
|
-
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
13
13
|
export type MemoryInterpreterOptions = {
|
|
14
14
|
logger?: Logger;
|
|
15
15
|
compiler?: ObservableCompiler;
|
|
@@ -24,6 +24,11 @@ type Registration = {
|
|
|
24
24
|
sigintListener: () => void;
|
|
25
25
|
subscription?: Subscription;
|
|
26
26
|
};
|
|
27
|
+
type WebhookRegistry = Map<string, {
|
|
28
|
+
method: string;
|
|
29
|
+
path: string;
|
|
30
|
+
options: any;
|
|
31
|
+
}>;
|
|
27
32
|
export declare class MemoryInterpreter {
|
|
28
33
|
private readonly log;
|
|
29
34
|
private readonly compiler;
|
|
@@ -31,6 +36,7 @@ export declare class MemoryInterpreter {
|
|
|
31
36
|
private readonly webhookRouter;
|
|
32
37
|
private readonly cronRouter;
|
|
33
38
|
private cronRegistry;
|
|
39
|
+
private webhookRegistry;
|
|
34
40
|
private readonly cnxFactory;
|
|
35
41
|
private readonly cronProvider;
|
|
36
42
|
private readonly tracer;
|
|
@@ -42,7 +48,7 @@ export declare class MemoryInterpreter {
|
|
|
42
48
|
private cronServer?;
|
|
43
49
|
private shutdownServer?;
|
|
44
50
|
private isShuttingDown;
|
|
45
|
-
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);
|
|
51
|
+
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);
|
|
46
52
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
47
53
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
48
54
|
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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"}
|
|
@@ -10,31 +10,32 @@ const resources_1 = require("@opentelemetry/resources");
|
|
|
10
10
|
const sdk_node_1 = require("@opentelemetry/sdk-node");
|
|
11
11
|
const express_1 = __importDefault(require("express"));
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
|
+
const DirectConnectionFactory_js_1 = require("../../connection/DirectConnectionFactory.js");
|
|
13
14
|
const ContextProvider_js_1 = require("../../context/ContextProvider.js");
|
|
14
15
|
const default_js_1 = require("../../dsl/http/default.js");
|
|
15
16
|
const configloader_js_1 = require("../../dsl/http/versori/configloader.js");
|
|
16
|
-
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
17
17
|
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
18
18
|
const Workflow_js_1 = require("../../dsl/Workflow.js");
|
|
19
|
+
const constants_js_1 = require("../../internal/constants.js");
|
|
20
|
+
const supervisor_js_1 = require("../../internal/supervisor.js");
|
|
19
21
|
const Issues_js_1 = require("../../issues/Issues.js");
|
|
20
22
|
const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
|
|
21
23
|
const NatsKeyValueProvider_js_1 = require("../../kv/nats/NatsKeyValueProvider.js");
|
|
22
24
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
23
|
-
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
24
25
|
const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
|
|
25
|
-
const
|
|
26
|
-
function getKVProvider(
|
|
27
|
-
if (
|
|
26
|
+
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
27
|
+
function getKVProvider() {
|
|
28
|
+
if (supervisor_js_1.enabled) {
|
|
28
29
|
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
29
30
|
}
|
|
30
31
|
return NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv();
|
|
31
32
|
}
|
|
32
|
-
function getRoundTripperFactory(log
|
|
33
|
+
function getRoundTripperFactory(log) {
|
|
33
34
|
log.info('Running with default round tripper factory');
|
|
34
35
|
return new default_js_1.DefaultRoundTripperFactory();
|
|
35
36
|
}
|
|
36
37
|
class MemoryInterpreter {
|
|
37
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
38
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
38
39
|
Object.defineProperty(this, "log", {
|
|
39
40
|
enumerable: true,
|
|
40
41
|
configurable: true,
|
|
@@ -71,6 +72,12 @@ class MemoryInterpreter {
|
|
|
71
72
|
writable: true,
|
|
72
73
|
value: cronRegistry
|
|
73
74
|
});
|
|
75
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: webhookRegistry
|
|
80
|
+
});
|
|
74
81
|
Object.defineProperty(this, "cnxFactory", {
|
|
75
82
|
enumerable: true,
|
|
76
83
|
configurable: true,
|
|
@@ -155,7 +162,6 @@ class MemoryInterpreter {
|
|
|
155
162
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
156
163
|
let otelSDK;
|
|
157
164
|
const configReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
|
|
158
|
-
const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
159
165
|
await waitForReady(log);
|
|
160
166
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
161
167
|
const resource = (0, resources_1.resourceFromAttributes)({
|
|
@@ -177,23 +183,29 @@ class MemoryInterpreter {
|
|
|
177
183
|
log.info('Starting OpenTelemetry SDK');
|
|
178
184
|
otelSDK.start();
|
|
179
185
|
}
|
|
186
|
+
else if (supervisor_js_1.enabled) {
|
|
187
|
+
otelSDK = new sdk_node_1.NodeSDK({
|
|
188
|
+
traceExporter: new supervisor_js_1.Fake(),
|
|
189
|
+
serviceName: serviceName,
|
|
190
|
+
resource: resource,
|
|
191
|
+
});
|
|
192
|
+
log.info('Starting Testing OpenTelemetry SDK');
|
|
193
|
+
otelSDK.start();
|
|
194
|
+
}
|
|
180
195
|
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
181
|
-
const roundTripperFactory = getRoundTripperFactory(log
|
|
182
|
-
skipVersoriCredentials: options.skipVersoriCredentials,
|
|
183
|
-
runLocal: runLocal,
|
|
184
|
-
});
|
|
196
|
+
const roundTripperFactory = getRoundTripperFactory(log);
|
|
185
197
|
const issuesProvider = new Issues_js_1.IssueImpl(log);
|
|
186
198
|
if (options.contextProvider) {
|
|
187
199
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
188
200
|
// initialised.
|
|
189
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log), cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
201
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log), cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
190
202
|
}
|
|
191
|
-
const kvp = await getKVProvider(
|
|
203
|
+
const kvp = await getKVProvider();
|
|
192
204
|
const platformApi = PlatformApi_js_1.PlatformApiImpl.fromEnv();
|
|
193
205
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
194
206
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
195
207
|
const ctxProvider = new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials(), platformApi, organisationId, environmentId, issuesProvider);
|
|
196
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log), cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
208
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), new Map(), DirectConnectionFactory_js_1.DirectConnectionFactory.fromEnv(log), cronapi_js_1.CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
197
209
|
}
|
|
198
210
|
register(workflow, options) {
|
|
199
211
|
const localAbortController = new AbortController();
|
|
@@ -212,6 +224,7 @@ class MemoryInterpreter {
|
|
|
212
224
|
cnxFactory: this.cnxFactory,
|
|
213
225
|
platformApi: PlatformApi_js_1.PlatformApiImpl.fromEnv(),
|
|
214
226
|
webhookRouter: this.webhookRouter,
|
|
227
|
+
webhookRegistry: this.webhookRegistry,
|
|
215
228
|
cronRouter: this.cronRouter,
|
|
216
229
|
cronRegistry: this.cronRegistry,
|
|
217
230
|
configReader: this.cfgReader,
|
|
@@ -233,8 +246,8 @@ class MemoryInterpreter {
|
|
|
233
246
|
return registration;
|
|
234
247
|
}
|
|
235
248
|
async start() {
|
|
236
|
-
const port = Deno.env.get(
|
|
237
|
-
const cronPort = Deno.env.get(
|
|
249
|
+
const port = Deno.env.get(constants_js_1.envPort) || 3000;
|
|
250
|
+
const cronPort = Deno.env.get(constants_js_1.envCronPort) || 3001;
|
|
238
251
|
const webhookApp = (0, express_1.default)();
|
|
239
252
|
const cronApp = (0, express_1.default)();
|
|
240
253
|
cronApp.use(express_1.default.json());
|
|
@@ -258,6 +271,12 @@ class MemoryInterpreter {
|
|
|
258
271
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
259
272
|
error: err instanceof Error ? err.toString() : err,
|
|
260
273
|
});
|
|
274
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
275
|
+
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
276
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
277
|
+
span.setAttribute('result', 'fail');
|
|
278
|
+
span.end();
|
|
279
|
+
});
|
|
261
280
|
try {
|
|
262
281
|
ctx.options.onError?.(ctx.withData(err));
|
|
263
282
|
}
|
|
@@ -277,6 +296,11 @@ class MemoryInterpreter {
|
|
|
277
296
|
durationMs,
|
|
278
297
|
data: ctx.data,
|
|
279
298
|
});
|
|
299
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
300
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
301
|
+
span.setAttribute('result', 'pass');
|
|
302
|
+
span.end();
|
|
303
|
+
});
|
|
280
304
|
try {
|
|
281
305
|
ctx.options.onSuccess?.(ctx);
|
|
282
306
|
}
|
|
@@ -313,6 +337,9 @@ class MemoryInterpreter {
|
|
|
313
337
|
});
|
|
314
338
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
315
339
|
}
|
|
340
|
+
// register with suopervisor
|
|
341
|
+
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
342
|
+
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
316
343
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
317
344
|
this.log.info(`Express server listening on port ${port}`);
|
|
318
345
|
});
|
|
@@ -332,6 +359,7 @@ class MemoryInterpreter {
|
|
|
332
359
|
if (this.cronServer) {
|
|
333
360
|
this.cronServer.close();
|
|
334
361
|
}
|
|
362
|
+
this.otelSDK?.shutdown();
|
|
335
363
|
// Remove all signal listeners
|
|
336
364
|
for (const registration of this.registeredWorkflows) {
|
|
337
365
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -384,7 +412,7 @@ class MemoryInterpreter {
|
|
|
384
412
|
}
|
|
385
413
|
exports.MemoryInterpreter = MemoryInterpreter;
|
|
386
414
|
async function waitForReady(log) {
|
|
387
|
-
const readyCheckUrl = Deno.env.get(
|
|
415
|
+
const readyCheckUrl = Deno.env.get(constants_js_1.envReadyCheckURL);
|
|
388
416
|
if (!readyCheckUrl) {
|
|
389
417
|
return Promise.resolve();
|
|
390
418
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Tracer } from '@opentelemetry/api';
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
import { Observable, OperatorFunction } from 'rxjs';
|
|
4
|
+
import { ConnectionFactory } from '../../connection/types.js';
|
|
4
5
|
import { ContextImpl } from '../../context/Context.js';
|
|
5
6
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
6
7
|
import { ConfigReader } from '../../dsl/http/types.js';
|
|
@@ -10,7 +11,6 @@ import { IssueAPI } from '../../issues/Issues.js';
|
|
|
10
11
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
11
12
|
import { PlatformApi } from '../../services/platform/PlatformApi.js';
|
|
12
13
|
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
13
|
-
import { ConnectionFactory } from '../../connection/types.js';
|
|
14
14
|
export type CompilerContext = {
|
|
15
15
|
compiler: ObservableCompiler;
|
|
16
16
|
log: Logger;
|
|
@@ -23,6 +23,11 @@ export type CompilerContext = {
|
|
|
23
23
|
issueProvider: IssueAPI;
|
|
24
24
|
configReader: ConfigReader;
|
|
25
25
|
cronRegistry: Map<string, string>;
|
|
26
|
+
webhookRegistry: Map<string, {
|
|
27
|
+
method: string;
|
|
28
|
+
path: string;
|
|
29
|
+
options: any;
|
|
30
|
+
}>;
|
|
26
31
|
organisationId: string;
|
|
27
32
|
};
|
|
28
33
|
export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: CompilerContext, task: T) => OperatorFunction<In, Out>;
|