@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":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,WAAW,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CA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EpB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOlF,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAehC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzD,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3D,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAoC9E,UAAU,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7D,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAevD;AAGD,qBAAa,SAAU,YAAW,QAAQ;;IAGtC,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG1D,MAAM,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IAG5D,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAG/E,UAAU,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9D,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAGlD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { envVarEnvId, envVarProjectId, envVarSDKApiBaseURL, } from '../../
|
|
1
|
+
import { envVarEnvId, envVarProjectId, envVarSDKApiBaseURL, } from '../../internal/constants.js';
|
|
2
2
|
import { ConsoleLogger } from '../../mod.js';
|
|
3
3
|
export class QueueImpl {
|
|
4
4
|
constructor(baseUrl, projectId, environmentId, log) {
|
|
@@ -57,7 +57,7 @@ export class QueueImpl {
|
|
|
57
57
|
output: request.output,
|
|
58
58
|
status: request.status,
|
|
59
59
|
});
|
|
60
|
-
throw new Error(
|
|
60
|
+
throw new Error('Failed to complete workflow');
|
|
61
61
|
}
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -130,7 +130,8 @@ export class QueueImpl {
|
|
|
130
130
|
}
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
async
|
|
133
|
+
async poll(workflowId) {
|
|
134
|
+
// this endpoint returns a 404 if the workflow is not completed
|
|
134
135
|
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
135
136
|
method: 'GET',
|
|
136
137
|
});
|
|
@@ -157,7 +158,7 @@ export class MockQueue {
|
|
|
157
158
|
reschedule(_request) {
|
|
158
159
|
throw new Error('Method not implemented.');
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
poll(_workflowId) {
|
|
161
162
|
throw new Error('Method not implemented.');
|
|
162
163
|
}
|
|
163
164
|
}
|
|
@@ -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"}
|
|
@@ -10,6 +10,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
10
10
|
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
11
11
|
span.setAttribute('execution.id', ctx.executionId);
|
|
12
12
|
span.setAttribute('task.type', 'catch');
|
|
13
|
+
span.setAttribute('type', 'task');
|
|
13
14
|
if (error instanceof Error) {
|
|
14
15
|
span.recordException(error);
|
|
15
16
|
span.setAttribute('error.message', error.message);
|
|
@@ -23,7 +24,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
23
24
|
annotations: {
|
|
24
25
|
'error': error.message,
|
|
25
26
|
'stack': error.stack || '',
|
|
26
|
-
'workflowId': ctx.options.
|
|
27
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
27
28
|
'',
|
|
28
29
|
'executionId': ctx.executionId,
|
|
29
30
|
},
|
|
@@ -39,7 +40,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
39
40
|
annotations: {
|
|
40
41
|
'error': error.message || '',
|
|
41
42
|
'stack': error.stack || '',
|
|
42
|
-
'workflowId': ctx.options.
|
|
43
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
43
44
|
'',
|
|
44
45
|
'executionId': ctx.executionId,
|
|
45
46
|
},
|
|
@@ -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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { DurableWorkflowTrigger, } from '../../../dsl/triggers/DurableTrigger.js';
|
|
3
3
|
import { envVarEnvId } from '../../../internal/constants.js';
|
|
4
|
-
import { ulid } from '../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js';
|
|
5
4
|
export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
6
5
|
return new Observable((subscriber) => {
|
|
7
6
|
function cleanup() {
|
|
@@ -36,9 +35,24 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
36
35
|
continue;
|
|
37
36
|
}
|
|
38
37
|
for (const wf of wfs.workflows) {
|
|
38
|
+
if (wf.id &&
|
|
39
|
+
wf.attempt !== undefined &&
|
|
40
|
+
trigger.options.maxAttempts &&
|
|
41
|
+
wf.attempt > trigger.options.maxAttempts) {
|
|
42
|
+
ctx.log.error('Workflow exceeded max attempts failing', {
|
|
43
|
+
workflowId: wf.id,
|
|
44
|
+
attempts: wf.attempt,
|
|
45
|
+
});
|
|
46
|
+
await ctx.queueProvider.complete({
|
|
47
|
+
id: wf.id,
|
|
48
|
+
output: wf.output,
|
|
49
|
+
status: 'failed',
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
39
53
|
const data = JSON.parse(atob(wf.payload ?? '{}'));
|
|
40
54
|
let activation;
|
|
41
|
-
|
|
55
|
+
if (wf.metadata?.activationId) {
|
|
42
56
|
const { data } = await ctx.platformApi.getActivation({
|
|
43
57
|
path: {
|
|
44
58
|
activation_id: wf.metadata.activationId,
|
|
@@ -49,23 +63,9 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
49
63
|
});
|
|
50
64
|
activation = data;
|
|
51
65
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? ulid().toString(), {
|
|
57
|
-
workflow: wf,
|
|
58
|
-
onSuccess: (completedContext) => {
|
|
59
|
-
// locked status means we own the workflow and it's not completed yet
|
|
60
|
-
if (wf.status !== 'locked') {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
ctx.queueProvider.complete({
|
|
64
|
-
id: wf.id,
|
|
65
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
66
|
-
status: 'completed',
|
|
67
|
-
});
|
|
68
|
-
},
|
|
66
|
+
const newContext = ctx.contextProvider.create(data, {
|
|
67
|
+
activation: activation,
|
|
68
|
+
workflowId: wf.id,
|
|
69
69
|
});
|
|
70
70
|
consecutiveErrors = 0;
|
|
71
71
|
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"}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { mergeMap, tap } from 'rxjs';
|
|
2
2
|
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
3
|
+
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
3
4
|
function compileFn(compilerCtx, task) {
|
|
4
5
|
return (src) => src.pipe(tap({
|
|
5
6
|
complete: () => compilerCtx.log.debug('fn.complete')
|
|
6
7
|
}), mergeMap(async (ctx) => {
|
|
7
8
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
8
9
|
span.setAttribute('task.id', task.id);
|
|
10
|
+
span.setAttribute('type', 'task');
|
|
11
|
+
span.setAttribute('task.type', 'fn');
|
|
9
12
|
span.setAttribute('execution.id', ctx.executionId);
|
|
10
|
-
|
|
13
|
+
try {
|
|
14
|
+
let result;
|
|
15
|
+
if (typeof ctx.idx === 'number') {
|
|
16
|
+
result = ctx.withData(await task._fn(ctx, ctx.idx));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
result = ctx.withData(await task._fn(ctx));
|
|
20
|
+
}
|
|
21
|
+
if (supervisorEnabled) {
|
|
22
|
+
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
11
27
|
span.end();
|
|
12
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
13
28
|
}
|
|
14
|
-
span.end();
|
|
15
|
-
return ctx.withData(await task._fn(ctx));
|
|
16
29
|
});
|
|
17
30
|
}));
|
|
18
31
|
}
|
|
@@ -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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { mergeMap } from 'rxjs';
|
|
2
2
|
import { tap } from 'rxjs/operators';
|
|
3
|
-
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
4
3
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
5
4
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
5
|
+
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
6
|
+
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
6
7
|
function compileHttp(compilerCtx, task) {
|
|
7
8
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
8
9
|
let fetchFactory;
|
|
@@ -36,10 +37,15 @@ function compileHttp(compilerCtx, task) {
|
|
|
36
37
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
37
38
|
span.setAttribute('task.id', task.id);
|
|
38
39
|
span.setAttribute('task.type', 'http');
|
|
40
|
+
span.setAttribute('type', 'task');
|
|
39
41
|
span.setAttribute('execution.id', ctx.executionId);
|
|
40
42
|
span.setAttribute('connection.name', task.opts.connection);
|
|
41
43
|
try {
|
|
42
|
-
|
|
44
|
+
let result = await http(ctx);
|
|
45
|
+
if (supervisorEnabled) {
|
|
46
|
+
span.setAttribute('http.response.body', JSON.stringify(result.data));
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
43
49
|
}
|
|
44
50
|
catch (error) {
|
|
45
51
|
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../dsl/http/versori/constants.js';
|
|
3
2
|
import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
|
|
3
|
+
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../internal/constants.js';
|
|
4
4
|
function compileSchedule(ctx, trigger, signal) {
|
|
5
5
|
return new Observable((subscriber) => {
|
|
6
6
|
// Add HTTP endpoint for manual triggering
|
|
@@ -91,6 +91,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
91
91
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
92
92
|
span.setAttribute('task.id', trigger.id);
|
|
93
93
|
span.setAttribute('task.type', 'schedule');
|
|
94
|
+
span.setAttribute('type', 'task');
|
|
94
95
|
span.setAttribute('schedule', trigger.schedule);
|
|
95
96
|
span.setAttribute('project.id', projectId);
|
|
96
97
|
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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import cors from 'cors';
|
|
2
2
|
import express from 'express';
|
|
3
|
+
import xmlparser from 'express-xml-bodyparser';
|
|
3
4
|
import { pipeline } from 'node:stream/promises';
|
|
4
5
|
import { Observable } from 'rxjs';
|
|
5
6
|
import { createActIdDynamicWebhookMiddleware, createStaticWebhookMiddleware, createUserIdDynamicWebhookMiddleware, } from '../../../dsl/http/versori/webhookmiddleware.js';
|
|
6
7
|
import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
|
|
7
8
|
import { envVarEnvId } from '../../../internal/constants.js';
|
|
8
|
-
import xmlparser from 'express-xml-bodyparser';
|
|
9
9
|
const xml2jsDefaults = {
|
|
10
10
|
explicitArray: false,
|
|
11
11
|
normalize: false,
|
|
@@ -119,6 +119,7 @@ export const webhookCompiler = {
|
|
|
119
119
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
120
120
|
span.setAttribute('task.id', trigger.id);
|
|
121
121
|
span.setAttribute('task.type', 'webhook');
|
|
122
|
+
span.setAttribute('task.type', 'fn');
|
|
122
123
|
const staticActivation = res.locals.activation;
|
|
123
124
|
const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
124
125
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
@@ -155,6 +156,7 @@ export const webhookCompiler = {
|
|
|
155
156
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
156
157
|
span.setAttribute('task.id', trigger.id);
|
|
157
158
|
span.setAttribute('task.type', 'webhook');
|
|
159
|
+
span.setAttribute('type', 'task');
|
|
158
160
|
span.setAttribute('user.id', req.params.userId);
|
|
159
161
|
const userId = req.params.userId;
|
|
160
162
|
const activation = res.locals.activation;
|
|
@@ -210,6 +212,7 @@ export const webhookCompiler = {
|
|
|
210
212
|
}), async (req, res) => {
|
|
211
213
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
212
214
|
span.setAttribute('task.id', trigger.id);
|
|
215
|
+
span.setAttribute('type', 'task');
|
|
213
216
|
span.setAttribute('task.type', 'webhook');
|
|
214
217
|
span.setAttribute('activation.id', req.params.activationId);
|
|
215
218
|
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/interpre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6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0G5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAoD/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkNtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO9B"}
|
|
@@ -4,31 +4,32 @@ import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
|
4
4
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
7
|
+
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
7
8
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
8
9
|
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
9
10
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
10
|
-
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
11
11
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
12
12
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
13
|
+
import { envCronPort, envPort, envReadyCheckURL, envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../internal/constants.js';
|
|
14
|
+
import { Fake, registerCrons, registerWebhooks, enabled as supervisorEnabled } from '../../internal/supervisor.js';
|
|
13
15
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
14
16
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
15
17
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
16
18
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
17
|
-
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
18
19
|
import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
|
|
19
|
-
import {
|
|
20
|
-
function getKVProvider(
|
|
21
|
-
if (
|
|
20
|
+
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
21
|
+
function getKVProvider() {
|
|
22
|
+
if (supervisorEnabled) {
|
|
22
23
|
return Promise.resolve(new MemoryKeyValueProvider());
|
|
23
24
|
}
|
|
24
25
|
return NatsKeyValueProvider.fromEnv();
|
|
25
26
|
}
|
|
26
|
-
function getRoundTripperFactory(log
|
|
27
|
+
function getRoundTripperFactory(log) {
|
|
27
28
|
log.info('Running with default round tripper factory');
|
|
28
29
|
return new DefaultRoundTripperFactory();
|
|
29
30
|
}
|
|
30
31
|
export class MemoryInterpreter {
|
|
31
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
32
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
|
|
32
33
|
Object.defineProperty(this, "log", {
|
|
33
34
|
enumerable: true,
|
|
34
35
|
configurable: true,
|
|
@@ -65,6 +66,12 @@ export class MemoryInterpreter {
|
|
|
65
66
|
writable: true,
|
|
66
67
|
value: cronRegistry
|
|
67
68
|
});
|
|
69
|
+
Object.defineProperty(this, "webhookRegistry", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: webhookRegistry
|
|
74
|
+
});
|
|
68
75
|
Object.defineProperty(this, "cnxFactory", {
|
|
69
76
|
enumerable: true,
|
|
70
77
|
configurable: true,
|
|
@@ -149,7 +156,6 @@ export class MemoryInterpreter {
|
|
|
149
156
|
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
150
157
|
let otelSDK;
|
|
151
158
|
const configReader = VersoriConfigReader.fromEnv(log);
|
|
152
|
-
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
153
159
|
await waitForReady(log);
|
|
154
160
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
155
161
|
const resource = resourceFromAttributes({
|
|
@@ -171,23 +177,29 @@ export class MemoryInterpreter {
|
|
|
171
177
|
log.info('Starting OpenTelemetry SDK');
|
|
172
178
|
otelSDK.start();
|
|
173
179
|
}
|
|
180
|
+
else if (supervisorEnabled) {
|
|
181
|
+
otelSDK = new NodeSDK({
|
|
182
|
+
traceExporter: new Fake(),
|
|
183
|
+
serviceName: serviceName,
|
|
184
|
+
resource: resource,
|
|
185
|
+
});
|
|
186
|
+
log.info('Starting Testing OpenTelemetry SDK');
|
|
187
|
+
otelSDK.start();
|
|
188
|
+
}
|
|
174
189
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
175
|
-
const roundTripperFactory = getRoundTripperFactory(log
|
|
176
|
-
skipVersoriCredentials: options.skipVersoriCredentials,
|
|
177
|
-
runLocal: runLocal,
|
|
178
|
-
});
|
|
190
|
+
const roundTripperFactory = getRoundTripperFactory(log);
|
|
179
191
|
const issuesProvider = new IssueImpl(log);
|
|
180
192
|
if (options.contextProvider) {
|
|
181
193
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
182
194
|
// initialised.
|
|
183
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
195
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
184
196
|
}
|
|
185
|
-
const kvp = await getKVProvider(
|
|
197
|
+
const kvp = await getKVProvider();
|
|
186
198
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
187
199
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
188
200
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
189
201
|
const ctxProvider = new ContextProviderImpl(log, kvp, roundTripperFactory.credentials(), platformApi, organisationId, environmentId, issuesProvider);
|
|
190
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
202
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
191
203
|
}
|
|
192
204
|
register(workflow, options) {
|
|
193
205
|
const localAbortController = new AbortController();
|
|
@@ -206,6 +218,7 @@ export class MemoryInterpreter {
|
|
|
206
218
|
cnxFactory: this.cnxFactory,
|
|
207
219
|
platformApi: PlatformApiImpl.fromEnv(),
|
|
208
220
|
webhookRouter: this.webhookRouter,
|
|
221
|
+
webhookRegistry: this.webhookRegistry,
|
|
209
222
|
cronRouter: this.cronRouter,
|
|
210
223
|
cronRegistry: this.cronRegistry,
|
|
211
224
|
configReader: this.cfgReader,
|
|
@@ -227,8 +240,8 @@ export class MemoryInterpreter {
|
|
|
227
240
|
return registration;
|
|
228
241
|
}
|
|
229
242
|
async start() {
|
|
230
|
-
const port = Deno.env.get(
|
|
231
|
-
const cronPort = Deno.env.get(
|
|
243
|
+
const port = Deno.env.get(envPort) || 3000;
|
|
244
|
+
const cronPort = Deno.env.get(envCronPort) || 3001;
|
|
232
245
|
const webhookApp = express();
|
|
233
246
|
const cronApp = express();
|
|
234
247
|
cronApp.use(express.json());
|
|
@@ -252,6 +265,12 @@ export class MemoryInterpreter {
|
|
|
252
265
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
253
266
|
error: err instanceof Error ? err.toString() : err,
|
|
254
267
|
});
|
|
268
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
269
|
+
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
270
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
271
|
+
span.setAttribute('result', 'fail');
|
|
272
|
+
span.end();
|
|
273
|
+
});
|
|
255
274
|
try {
|
|
256
275
|
ctx.options.onError?.(ctx.withData(err));
|
|
257
276
|
}
|
|
@@ -271,6 +290,11 @@ export class MemoryInterpreter {
|
|
|
271
290
|
durationMs,
|
|
272
291
|
data: ctx.data,
|
|
273
292
|
});
|
|
293
|
+
this.tracer.startActiveSpan('done', (span) => {
|
|
294
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
295
|
+
span.setAttribute('result', 'pass');
|
|
296
|
+
span.end();
|
|
297
|
+
});
|
|
274
298
|
try {
|
|
275
299
|
ctx.options.onSuccess?.(ctx);
|
|
276
300
|
}
|
|
@@ -307,6 +331,9 @@ export class MemoryInterpreter {
|
|
|
307
331
|
});
|
|
308
332
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
309
333
|
}
|
|
334
|
+
// register with suopervisor
|
|
335
|
+
await registerCrons(this.cronRegistry);
|
|
336
|
+
await registerWebhooks(this.webhookRegistry);
|
|
310
337
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
311
338
|
this.log.info(`Express server listening on port ${port}`);
|
|
312
339
|
});
|
|
@@ -326,6 +353,7 @@ export class MemoryInterpreter {
|
|
|
326
353
|
if (this.cronServer) {
|
|
327
354
|
this.cronServer.close();
|
|
328
355
|
}
|
|
356
|
+
this.otelSDK?.shutdown();
|
|
329
357
|
// Remove all signal listeners
|
|
330
358
|
for (const registration of this.registeredWorkflows) {
|
|
331
359
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
@@ -377,7 +405,7 @@ export class MemoryInterpreter {
|
|
|
377
405
|
}
|
|
378
406
|
}
|
|
379
407
|
async function waitForReady(log) {
|
|
380
|
-
const readyCheckUrl = Deno.env.get(
|
|
408
|
+
const readyCheckUrl = Deno.env.get(envReadyCheckURL);
|
|
381
409
|
if (!readyCheckUrl) {
|
|
382
410
|
return Promise.resolve();
|
|
383
411
|
}
|
|
@@ -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>;
|