@versori/run 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/src/connection/VanillaConnectionFactory.d.ts +16 -0
- package/esm/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
- package/esm/src/connection/VanillaConnectionFactory.js +35 -0
- package/esm/src/context/ActivationImpl.d.ts +2 -1
- package/esm/src/context/ActivationImpl.d.ts.map +1 -1
- package/esm/src/context/Context.d.ts +2 -1
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.d.ts +8 -8
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +1 -1
- package/esm/src/context/VanillaContext.d.ts +63 -0
- package/esm/src/context/VanillaContext.d.ts.map +1 -0
- package/esm/src/context/VanillaContext.js +313 -0
- package/esm/src/context/WorkflowClient.d.ts +2 -2
- package/esm/src/context/WorkflowClient.d.ts.map +1 -1
- package/esm/src/dsl/http/mod.d.ts +1 -1
- package/esm/src/dsl/http/mod.d.ts.map +1 -1
- package/esm/src/dsl/http/types.d.ts +20 -134
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +3 -0
- 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/tasks/HttpTask.d.ts +4 -4
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +24 -7
- package/esm/src/interpreter/durable/Queue.d.ts +1 -1
- package/esm/src/interpreter/durable/Queue.js +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +2 -1
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +7 -4
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +7 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +3 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +24 -7
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +7 -4
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +7 -6
- package/esm/src/interpreter/mod.d.ts +1 -0
- package/esm/src/interpreter/mod.d.ts.map +1 -1
- package/esm/src/interpreter/mod.js +1 -0
- package/esm/src/interpreter/vanilla/ExecutionError.d.ts +25 -0
- package/esm/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/ExecutionError.js +46 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.js +95 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +96 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.js +435 -0
- package/esm/src/interpreter/vanilla/compilers/background.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/background.js +34 -0
- package/esm/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/catch.js +75 -0
- package/esm/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
- package/esm/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/chain.js +21 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +91 -0
- package/esm/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/fn.js +37 -0
- package/esm/src/interpreter/vanilla/compilers/http.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/http.js +54 -0
- package/esm/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
- package/esm/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/mod.js +13 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.js +31 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.js +76 -0
- package/esm/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/serial.js +28 -0
- package/esm/src/interpreter/vanilla/compilers/types.d.ts +15 -0
- package/esm/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/types.js +13 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.js +34 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.js +261 -0
- package/esm/src/interpreter/vanilla/mod.d.ts +3 -0
- package/esm/src/interpreter/vanilla/mod.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/mod.js +14 -0
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/esm/src/observability/logging/ConsoleLogger.d.ts +1 -1
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/observability/logging/ConsoleLogger.js +11 -1
- package/esm/src/services/platform/generated/core/pathSerializer.gen.d.ts +2 -2
- package/package.json +1 -1
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -1
- package/script/src/connection/VanillaConnectionFactory.d.ts +16 -0
- package/script/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
- package/script/src/connection/VanillaConnectionFactory.js +40 -0
- package/script/src/context/ActivationImpl.d.ts +2 -1
- package/script/src/context/ActivationImpl.d.ts.map +1 -1
- package/script/src/context/Context.d.ts +2 -1
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/ContextProvider.d.ts +8 -8
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +1 -1
- package/script/src/context/VanillaContext.d.ts +63 -0
- package/script/src/context/VanillaContext.d.ts.map +1 -0
- package/script/src/context/VanillaContext.js +319 -0
- package/script/src/context/WorkflowClient.d.ts +2 -2
- package/script/src/context/WorkflowClient.d.ts.map +1 -1
- package/script/src/dsl/http/mod.d.ts +1 -1
- package/script/src/dsl/http/mod.d.ts.map +1 -1
- package/script/src/dsl/http/types.d.ts +20 -134
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +3 -0
- 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/tasks/HttpTask.d.ts +4 -4
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +24 -7
- package/script/src/interpreter/durable/Queue.d.ts +1 -1
- package/script/src/interpreter/durable/Queue.js +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +2 -1
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +7 -4
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +7 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +3 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +24 -7
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +7 -4
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +7 -6
- package/script/src/interpreter/mod.d.ts +1 -0
- package/script/src/interpreter/mod.d.ts.map +1 -1
- package/script/src/interpreter/mod.js +2 -1
- package/script/src/interpreter/vanilla/ExecutionError.d.ts +25 -0
- package/script/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/ExecutionError.js +50 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.js +99 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +96 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.js +442 -0
- package/script/src/interpreter/vanilla/compilers/background.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/background.js +37 -0
- package/script/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/catch.js +78 -0
- package/script/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
- package/script/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/chain.js +24 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.js +95 -0
- package/script/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/fn.js +40 -0
- package/script/src/interpreter/vanilla/compilers/http.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/http.js +57 -0
- package/script/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
- package/script/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/mod.js +14 -0
- package/script/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/parallel.js +34 -0
- package/script/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/schedule.js +79 -0
- package/script/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/serial.js +31 -0
- package/script/src/interpreter/vanilla/compilers/types.d.ts +15 -0
- package/script/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/types.js +14 -0
- package/script/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/unpack.js +37 -0
- package/script/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/webhook.js +267 -0
- package/script/src/interpreter/vanilla/mod.d.ts +3 -0
- package/script/src/interpreter/vanilla/mod.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/mod.js +30 -0
- package/script/src/issues/Issues.d.ts.map +1 -1
- package/script/src/observability/logging/ConsoleLogger.d.ts +1 -1
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/script/src/observability/logging/ConsoleLogger.js +11 -1
- package/script/src/services/platform/generated/core/pathSerializer.gen.d.ts +2 -2
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import opentelemetry from '@opentelemetry/api';
|
|
14
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
15
|
+
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
16
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
17
|
+
import express from 'express';
|
|
18
|
+
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
|
+
import { DefaultConnectionFactory } from '../../connection/VanillaConnectionFactory.js';
|
|
20
|
+
import { VanillaContextProvider } from '../../context/VanillaContext.js';
|
|
21
|
+
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
22
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
23
|
+
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
24
|
+
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
25
|
+
import { IssueImpl } from '../../issues/Issues.js';
|
|
26
|
+
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
27
|
+
import { SDKKeyValueProvider } from '../../kv/sdk/SDKKeyValueProvider.js';
|
|
28
|
+
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
29
|
+
import { QueueImpl } from '../durable/Queue.js';
|
|
30
|
+
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
31
|
+
function getKVProvider(runLocal) {
|
|
32
|
+
if (runLocal) {
|
|
33
|
+
return Promise.resolve(new MemoryKeyValueProvider());
|
|
34
|
+
}
|
|
35
|
+
return SDKKeyValueProvider.fromEnv();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* VanillaInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
39
|
+
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
40
|
+
* programmatically.
|
|
41
|
+
*
|
|
42
|
+
* Unlike {@link DurableInterpreter}, this interpreter is incapable of using connections. Therefore, all fetch requests will need
|
|
43
|
+
* to use fully qualified URLs and authentication must be handled manually within the workflow.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { VanillaInterpreter, workflow, fn } from '@versori/run';
|
|
48
|
+
*
|
|
49
|
+
* const processJob = workflow('process-job', { maxAttempts: 3 })
|
|
50
|
+
* .then(fn('task', async (ctx) => {
|
|
51
|
+
* ctx.log.info('Processing job', { data: ctx.data });
|
|
52
|
+
* // ... long-running process
|
|
53
|
+
* }));
|
|
54
|
+
*
|
|
55
|
+
* const interpreter = new VanillaInterpreter();
|
|
56
|
+
* interpreter.register(processJob);
|
|
57
|
+
* await interpreter.start();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export class VanillaInterpreter {
|
|
61
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFetchFactory, cronProvider, tracer, cfgReader, queueProvider, otelSDK) {
|
|
62
|
+
Object.defineProperty(this, "log", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: log
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "compiler", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: compiler
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "contextProvider", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: contextProvider
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "webhookRouter", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: webhookRouter
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "cronRouter", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: cronRouter
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(this, "cronRegistry", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: cronRegistry
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "cnxFetchFactory", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: cnxFetchFactory
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(this, "cronProvider", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: cronProvider
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "tracer", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: tracer
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "cfgReader", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: cfgReader
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(this, "queueProvider", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
configurable: true,
|
|
125
|
+
writable: true,
|
|
126
|
+
value: queueProvider
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(this, "otelSDK", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: otelSDK
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(this, "registeredWorkflows", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: true,
|
|
138
|
+
value: []
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(this, "webhookServer", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: void 0
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(this, "cronServer", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true,
|
|
149
|
+
writable: true,
|
|
150
|
+
value: void 0
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(this, "shutdownServer", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: void 0
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(this, "isShuttingDown", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: false
|
|
163
|
+
});
|
|
164
|
+
if (typeof this.log === 'undefined') {
|
|
165
|
+
throw new Error('VanillaInterpreter should not be instantiated directly. Use VanillaInterpreter.newInstance() instead.');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
static async newInstance(options = {}) {
|
|
169
|
+
const log = options.logger || new ConsoleLogger();
|
|
170
|
+
const compiler = options.compiler || new ObservableCompiler();
|
|
171
|
+
const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
|
|
172
|
+
const environmentID = Deno.env.get(envVarEnvId) || 'development';
|
|
173
|
+
const version = Deno.env.get(envVarVersion) || '1.0.0';
|
|
174
|
+
const environment = Deno.env.get(envVarEnvironmentName) || 'development';
|
|
175
|
+
const orgId = Deno.env.get(envVarOrgId) || 'development';
|
|
176
|
+
const orgSlug = Deno.env.get(envVarOrgSlug) || 'development';
|
|
177
|
+
const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
|
|
178
|
+
let otelSDK;
|
|
179
|
+
const configReader = VersoriConfigReader.fromEnv(log);
|
|
180
|
+
const runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
181
|
+
await waitForReady(log);
|
|
182
|
+
// Do NOT change these attributes, they are used by the API to filter on
|
|
183
|
+
const resource = resourceFromAttributes({
|
|
184
|
+
'service.id': serviceName,
|
|
185
|
+
'service.environment': environment,
|
|
186
|
+
'service.environment_id': environmentID,
|
|
187
|
+
'service.version': version,
|
|
188
|
+
'service.organisation_id': orgId,
|
|
189
|
+
'service.organisation_slug': orgSlug,
|
|
190
|
+
});
|
|
191
|
+
if (otelTracesURL && serviceName) {
|
|
192
|
+
otelSDK = new NodeSDK({
|
|
193
|
+
traceExporter: new OTLPTraceExporter({
|
|
194
|
+
url: otelTracesURL,
|
|
195
|
+
}),
|
|
196
|
+
serviceName: serviceName,
|
|
197
|
+
resource: resource,
|
|
198
|
+
});
|
|
199
|
+
log.info('Starting OpenTelemetry SDK');
|
|
200
|
+
otelSDK.start();
|
|
201
|
+
}
|
|
202
|
+
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
203
|
+
const queueProvider = await QueueImpl.fromEnv(log);
|
|
204
|
+
const connectionFactory = new DefaultConnectionFactory();
|
|
205
|
+
const issuesProvider = new IssueImpl(log);
|
|
206
|
+
if (options.contextProvider) {
|
|
207
|
+
return new VanillaInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
208
|
+
}
|
|
209
|
+
const kvp = await getKVProvider(runLocal);
|
|
210
|
+
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
211
|
+
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
212
|
+
const ctxProvider = new VanillaContextProvider(log, kvp, organisationId, environmentId, issuesProvider);
|
|
213
|
+
return new VanillaInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
214
|
+
}
|
|
215
|
+
register(workflow, options) {
|
|
216
|
+
const localAbortController = new AbortController();
|
|
217
|
+
const combinedSignal = options?.signal
|
|
218
|
+
? AbortSignal.any([localAbortController.signal, options.signal])
|
|
219
|
+
: localAbortController.signal;
|
|
220
|
+
if (!(workflow instanceof WorkflowImpl)) {
|
|
221
|
+
throw new Error('workflow is not an instance of WorkflowImpl');
|
|
222
|
+
}
|
|
223
|
+
const compilerContext = {
|
|
224
|
+
compiler: this.compiler,
|
|
225
|
+
log: this.log,
|
|
226
|
+
tracer: this.tracer,
|
|
227
|
+
contextProvider: this.contextProvider,
|
|
228
|
+
webhookRouter: this.webhookRouter,
|
|
229
|
+
queueProvider: this.queueProvider,
|
|
230
|
+
cronRouter: this.cronRouter,
|
|
231
|
+
cronRegistry: this.cronRegistry,
|
|
232
|
+
configReader: this.cfgReader,
|
|
233
|
+
cnxFactory: this.cnxFetchFactory,
|
|
234
|
+
organisationId: Deno.env.get(envVarOrgId) || 'development',
|
|
235
|
+
};
|
|
236
|
+
const trigger$ = this.compiler.compileTrigger(compilerContext, workflow.trigger, combinedSignal);
|
|
237
|
+
const task$ = this.compiler.compileTask(compilerContext, workflow.task);
|
|
238
|
+
const triggerName = 'id' in workflow.trigger && typeof workflow.trigger.id === 'string'
|
|
239
|
+
? workflow.trigger.id
|
|
240
|
+
: workflow.trigger.constructor.name;
|
|
241
|
+
const registration = {
|
|
242
|
+
triggerName,
|
|
243
|
+
trigger$,
|
|
244
|
+
task$,
|
|
245
|
+
localAbortController,
|
|
246
|
+
sigintListener: () => {
|
|
247
|
+
this.log.info('Received SIGINT, shutting down workflow', { triggerName });
|
|
248
|
+
localAbortController.abort();
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
this.registeredWorkflows.push(registration);
|
|
252
|
+
return registration;
|
|
253
|
+
}
|
|
254
|
+
start() {
|
|
255
|
+
const port = Deno.env.get('PORT') || 3000;
|
|
256
|
+
const cronPort = Deno.env.get('CRON_PORT') || 3001;
|
|
257
|
+
const webhookApp = express();
|
|
258
|
+
const cronApp = express();
|
|
259
|
+
cronApp.use(express.json());
|
|
260
|
+
this.webhookRouter.get('/health', (_req, res) => {
|
|
261
|
+
res.json({ status: 'healthy' });
|
|
262
|
+
});
|
|
263
|
+
this.cronRouter.get('/health', (_req, res) => {
|
|
264
|
+
res.json({ status: 'healthy' });
|
|
265
|
+
});
|
|
266
|
+
webhookApp.use(this.webhookRouter);
|
|
267
|
+
cronApp.use(this.cronRouter);
|
|
268
|
+
for (const registration of this.registeredWorkflows) {
|
|
269
|
+
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
270
|
+
registration.subscription = registration.trigger$
|
|
271
|
+
.pipe(tap((ctx) => {
|
|
272
|
+
ctx.log.info('VanillaInterpreter.executionStarted', {
|
|
273
|
+
triggerName: registration.triggerName,
|
|
274
|
+
data: ctx.data,
|
|
275
|
+
});
|
|
276
|
+
}), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
|
|
277
|
+
ctx.log.error('VanillaInterpreter.executionError', {
|
|
278
|
+
triggerName: registration.triggerName,
|
|
279
|
+
error: err instanceof Error ? err.toString() : err,
|
|
280
|
+
});
|
|
281
|
+
try {
|
|
282
|
+
ctx.options.onError?.(ctx.withData(err));
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
ctx.log.error('VanillaInterpreter.onErrorError: failed to call onError handler', {
|
|
286
|
+
triggerName: registration.triggerName,
|
|
287
|
+
error: err instanceof Error ? err.toString() : err,
|
|
288
|
+
});
|
|
289
|
+
ctx.options.onError?.(ctx.withData({
|
|
290
|
+
message: 'Internal server error',
|
|
291
|
+
error: err instanceof Error ? err.toString() : err,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
return EMPTY;
|
|
295
|
+
}))))
|
|
296
|
+
.subscribe({
|
|
297
|
+
next: (ctx) => {
|
|
298
|
+
const durationMs = Date.now() - ctx.startTime.getTime();
|
|
299
|
+
ctx.log.info('VanillaInterpreter.executionCompleted', {
|
|
300
|
+
triggerName: registration.triggerName,
|
|
301
|
+
durationMs,
|
|
302
|
+
});
|
|
303
|
+
try {
|
|
304
|
+
ctx.options.onSuccess?.(ctx);
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
ctx.log.error('VanillaInterpreter.onSuccessError: failed to call onSuccess handler', {
|
|
308
|
+
triggerName: registration.triggerName,
|
|
309
|
+
error: err instanceof Error ? err.toString() : err,
|
|
310
|
+
});
|
|
311
|
+
ctx.options.onSuccess?.(ctx.withData({
|
|
312
|
+
message: 'Internal server error',
|
|
313
|
+
error: err instanceof Error ? err.toString() : err,
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
this.contextProvider.destroy(ctx);
|
|
317
|
+
},
|
|
318
|
+
error: (err) => {
|
|
319
|
+
this.log.error('VanillaInterpreter.error', {
|
|
320
|
+
triggerName: registration.triggerName,
|
|
321
|
+
error: err instanceof Error ? err.toString() : err,
|
|
322
|
+
});
|
|
323
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
324
|
+
},
|
|
325
|
+
complete: () => {
|
|
326
|
+
this.log.info('VanillaInterpreter.workflowCompleted', {
|
|
327
|
+
triggerName: registration.triggerName,
|
|
328
|
+
});
|
|
329
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
registration.subscription.add(() => {
|
|
333
|
+
registration.subscription = undefined;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
this.cronProvider.updateCrons(this.cronRegistry);
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
this.log.error('VanillaInterpreter.updateCronsError', {
|
|
341
|
+
error: err instanceof Error ? err.toString() : err,
|
|
342
|
+
});
|
|
343
|
+
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
344
|
+
}
|
|
345
|
+
this.webhookServer = webhookApp.listen(port, () => {
|
|
346
|
+
this.log.info(`Express server listening on port ${port}`);
|
|
347
|
+
});
|
|
348
|
+
this.cronServer = cronApp.listen(cronPort, () => {
|
|
349
|
+
this.log.info(`Cron server listening on port ${cronPort}`);
|
|
350
|
+
});
|
|
351
|
+
this.shutdownServer = () => {
|
|
352
|
+
if (this.isShuttingDown) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
this.isShuttingDown = true;
|
|
356
|
+
this.log.info('Shutting down server');
|
|
357
|
+
if (this.webhookServer) {
|
|
358
|
+
this.webhookServer.close();
|
|
359
|
+
}
|
|
360
|
+
if (this.cronServer) {
|
|
361
|
+
this.cronServer.close();
|
|
362
|
+
}
|
|
363
|
+
for (const registration of this.registeredWorkflows) {
|
|
364
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
365
|
+
if (registration.subscription) {
|
|
366
|
+
registration.subscription.unsubscribe();
|
|
367
|
+
}
|
|
368
|
+
registration.localAbortController.abort();
|
|
369
|
+
}
|
|
370
|
+
if (this.shutdownServer) {
|
|
371
|
+
Deno.removeSignalListener('SIGINT', this.shutdownServer);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
375
|
+
return new Promise((resolve) => {
|
|
376
|
+
let serversClosed = 0;
|
|
377
|
+
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
378
|
+
const checkResolve = () => {
|
|
379
|
+
serversClosed++;
|
|
380
|
+
if (serversClosed === totalServers) {
|
|
381
|
+
this.log.info('All servers closed');
|
|
382
|
+
resolve();
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
if (this.webhookServer) {
|
|
386
|
+
this.webhookServer.on('close', () => {
|
|
387
|
+
this.log.info('Webhook server closed');
|
|
388
|
+
checkResolve();
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
if (this.cronServer) {
|
|
392
|
+
this.cronServer.on('close', () => {
|
|
393
|
+
this.log.info('Cron server closed');
|
|
394
|
+
checkResolve();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (!this.webhookServer && !this.cronServer) {
|
|
398
|
+
resolve();
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
stop() {
|
|
403
|
+
this.otelSDK?.shutdown();
|
|
404
|
+
if (this.shutdownServer) {
|
|
405
|
+
this.shutdownServer();
|
|
406
|
+
}
|
|
407
|
+
return Promise.resolve();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async function waitForReady(log) {
|
|
411
|
+
const readyCheckUrl = Deno.env.get('READY_CHECK_URL');
|
|
412
|
+
if (!readyCheckUrl) {
|
|
413
|
+
return Promise.resolve();
|
|
414
|
+
}
|
|
415
|
+
const maxAttempts = 40;
|
|
416
|
+
const delay = 500;
|
|
417
|
+
log.info('VanillaInterpreter.waitForReady: waiting for network to be ready', { readyCheckUrl });
|
|
418
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
419
|
+
try {
|
|
420
|
+
const response = await fetch(readyCheckUrl);
|
|
421
|
+
if (response.ok) {
|
|
422
|
+
log.info('VanillaInterpreter.waitForReady: network is ready');
|
|
423
|
+
return Promise.resolve();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
catch (err) {
|
|
427
|
+
log.error('VanillaInterpreter.waitForReadyError', {
|
|
428
|
+
error: err instanceof Error ? err.toString() : err,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
log.info('VanillaInterpreter.waitForReady: retrying...', { attempt: i });
|
|
432
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
433
|
+
}
|
|
434
|
+
throw new Error(`Network is not ready after ${maxAttempts * (delay / 1000)} seconds`);
|
|
435
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/background.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA2CnE,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/E,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import { asyncScheduler, catchError, connect, EMPTY, ignoreElements, map, merge, mergeMap, of, subscribeOn, tap, } from 'rxjs';
|
|
14
|
+
import { BackgroundTask } from '../../../dsl/tasks/BackgroundTask.js';
|
|
15
|
+
function compileBackground(ctx, task) {
|
|
16
|
+
const base = ctx.compiler.compileTask(ctx, task._base);
|
|
17
|
+
return (src) => src.pipe(connect((shared$) => merge(shared$.pipe(mergeMap((ctx) => base(of(ctx)).pipe(subscribeOn(asyncScheduler), tap({
|
|
18
|
+
next: (ctx) => ctx.log.debug('Background task emitted a value', {
|
|
19
|
+
data: ctx.data,
|
|
20
|
+
}),
|
|
21
|
+
complete: () => ctx.log.debug('Background task completed'),
|
|
22
|
+
}), catchError((error) => {
|
|
23
|
+
ctx.log.error('Error in background task', {
|
|
24
|
+
error,
|
|
25
|
+
inputData: ctx.data,
|
|
26
|
+
executionId: ctx.executionId,
|
|
27
|
+
});
|
|
28
|
+
return EMPTY;
|
|
29
|
+
}), ignoreElements()))), shared$.pipe(map((ctx) => ctx.withData(void 0))))));
|
|
30
|
+
}
|
|
31
|
+
export const backgroundCompiler = {
|
|
32
|
+
ctor: BackgroundTask,
|
|
33
|
+
compile: compileBackground,
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/catch.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAwFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import { catchError, mergeMap, of } from 'rxjs';
|
|
14
|
+
import { CatchTask } from '../../../dsl/tasks/CatchTask.js';
|
|
15
|
+
import { ExecutionError } from '../ExecutionError.js';
|
|
16
|
+
function compileCatch(compilerCtx, task) {
|
|
17
|
+
const baseOperator = compilerCtx.compiler.compileTask(compilerCtx, task._base);
|
|
18
|
+
const errorOperator = compilerCtx.compiler.compileTask(compilerCtx, task._errorHandler);
|
|
19
|
+
return (src) => {
|
|
20
|
+
return src.pipe(mergeMap((ctx) => {
|
|
21
|
+
return baseOperator(of(ctx)).pipe(catchError((error) => {
|
|
22
|
+
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
23
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
24
|
+
span.setAttribute('task.type', 'catch');
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
span.recordException(error);
|
|
27
|
+
span.setAttribute('error.message', error.message);
|
|
28
|
+
span.setAttribute('error.stack', error.stack ?? '');
|
|
29
|
+
span.end();
|
|
30
|
+
ctx.log.error('execution has encountered an error', {
|
|
31
|
+
error: error.message,
|
|
32
|
+
stack: error.stack,
|
|
33
|
+
});
|
|
34
|
+
// TODO: Do we want to submit issues for the VanillaInterpreter or not?
|
|
35
|
+
// compilerCtx.issueProvider.submitIssue({
|
|
36
|
+
// annotations: {
|
|
37
|
+
// 'error': error.message,
|
|
38
|
+
// 'stack': error.stack || '',
|
|
39
|
+
// 'workflowId': ctx.options.workflowId || ctx.workflowId || '',
|
|
40
|
+
// 'executionId': ctx.executionId,
|
|
41
|
+
// 'activationId': ctx.activation.id,
|
|
42
|
+
// 'activationExternalId': ctx.activation?.user.externalId,
|
|
43
|
+
// },
|
|
44
|
+
// reason: 'error',
|
|
45
|
+
// severity: 'high',
|
|
46
|
+
// });
|
|
47
|
+
return errorOperator(of(ctx.withData(new ExecutionError(ctx, error.message, { cause: error }))));
|
|
48
|
+
}
|
|
49
|
+
ctx.log.error('execution has encountered an error', {
|
|
50
|
+
error: error,
|
|
51
|
+
});
|
|
52
|
+
// compilerCtx.issueProvider.submitIssue({
|
|
53
|
+
// annotations: {
|
|
54
|
+
// 'error': error.message,
|
|
55
|
+
// 'stack': error.stack || '',
|
|
56
|
+
// 'workflowId': ctx.options.workflowId || ctx.workflowId || '',
|
|
57
|
+
// 'executionId': ctx.executionId,
|
|
58
|
+
// 'activationId': ctx.activation.id,
|
|
59
|
+
// 'activationExternalId': ctx.activation?.user.externalId,
|
|
60
|
+
// },
|
|
61
|
+
// reason: 'error',
|
|
62
|
+
// severity: 'low',
|
|
63
|
+
// });
|
|
64
|
+
span.setAttribute('error', `${error}`);
|
|
65
|
+
span.end();
|
|
66
|
+
return errorOperator(of(ctx.withData(new ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export const catchCompiler = {
|
|
73
|
+
ctor: CatchTask,
|
|
74
|
+
compile: compileCatch,
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/chain.ts"],"names":[],"mappings":"AAgBA,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAanE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAGrD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import { ChainTask } from '../../../dsl/tasks/ChainTask.js';
|
|
14
|
+
function compileChain(ctx, task) {
|
|
15
|
+
const operators = task.tasks.map((t) => ctx.compiler.compileTask(ctx, t));
|
|
16
|
+
return (src) => operators.reduce((acc, curr) => curr(acc), src);
|
|
17
|
+
}
|
|
18
|
+
export const chainCompiler = {
|
|
19
|
+
ctor: ChainTask,
|
|
20
|
+
compile: compileChain,
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DurableWorkflowData, DurableWorkflowTrigger } from '../../../dsl/triggers/DurableTrigger.js';
|
|
3
|
+
import { VanillaCompilerContext } from '../ObservableCompiler.js';
|
|
4
|
+
import { TriggerCompiler } from './mod.js';
|
|
5
|
+
import { VanillaContext } from '../../../context/VanillaContext.js';
|
|
6
|
+
export declare function compileDurableWorkflow(ctx: VanillaCompilerContext, trigger: DurableWorkflowTrigger, signal: AbortSignal): Observable<VanillaContext<DurableWorkflowData>>;
|
|
7
|
+
export declare const durableWorkflowCompiler: TriggerCompiler<DurableWorkflowData, DurableWorkflowTrigger>;
|
|
8
|
+
//# sourceMappingURL=durableworkflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/durableworkflow.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAuFjD;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAI5F,CAAC"}
|