@versori/run 0.2.14 → 0.2.16
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/context/AsyncWorkflow.d.ts +14 -0
- package/esm/src/context/AsyncWorkflow.d.ts.map +1 -0
- package/esm/src/context/AsyncWorkflow.js +89 -0
- package/esm/src/context/Context.d.ts +13 -1
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +44 -4
- package/esm/src/context/ContextProvider.d.ts +3 -1
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +9 -2
- package/esm/src/dsl/http/versori/constants.d.ts +1 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.js +1 -0
- package/esm/src/dsl/tasks/HttpTask.d.ts +3 -0
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +3 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts +18 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
- package/esm/src/dsl/triggers/DurableTrigger.js +36 -0
- package/esm/src/dsl/triggers/mod.d.ts +1 -0
- package/esm/src/dsl/triggers/mod.d.ts.map +1 -1
- package/esm/src/dsl/triggers/mod.js +1 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
- package/esm/src/interpreter/durable/DurableInterpreter.js +433 -0
- package/esm/src/interpreter/durable/ExecutionError.d.ts +6 -0
- package/esm/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
- package/esm/src/interpreter/durable/ExecutionError.js +13 -0
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
- package/esm/src/interpreter/durable/ObservableCompiler.js +69 -0
- package/esm/src/interpreter/durable/Queue.d.ts +69 -0
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -0
- package/esm/src/interpreter/durable/Queue.js +149 -0
- package/esm/src/interpreter/durable/compilers/background.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/background.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/background.js +22 -0
- package/esm/src/interpreter/durable/compilers/catch.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/catch.js +36 -0
- package/esm/src/interpreter/durable/compilers/chain.d.ts +3 -0
- package/esm/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/chain.js +9 -0
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +69 -0
- package/esm/src/interpreter/durable/compilers/fn.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/fn.js +22 -0
- package/esm/src/interpreter/durable/compilers/http.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/http.js +44 -0
- package/esm/src/interpreter/durable/compilers/mod.d.ts +2 -0
- package/esm/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/mod.js +1 -0
- package/esm/src/interpreter/durable/compilers/parallel.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/parallel.js +19 -0
- package/esm/src/interpreter/durable/compilers/schedule.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/schedule.js +94 -0
- package/esm/src/interpreter/durable/compilers/serial.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/serial.js +16 -0
- package/esm/src/interpreter/durable/compilers/types.d.ts +15 -0
- package/esm/src/interpreter/durable/compilers/types.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/types.js +1 -0
- package/esm/src/interpreter/durable/compilers/unpack.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/unpack.js +22 -0
- package/esm/src/interpreter/durable/compilers/webhook.d.ts +4 -0
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
- package/esm/src/interpreter/durable/compilers/webhook.js +248 -0
- package/esm/src/interpreter/durable/mod.d.ts +5 -0
- package/esm/src/interpreter/durable/mod.d.ts.map +1 -0
- package/esm/src/interpreter/durable/mod.js +4 -0
- 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/package.json +1 -1
- package/script/src/context/AsyncWorkflow.d.ts +14 -0
- package/script/src/context/AsyncWorkflow.d.ts.map +1 -0
- package/script/src/context/AsyncWorkflow.js +93 -0
- package/script/src/context/Context.d.ts +13 -1
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +44 -4
- package/script/src/context/ContextProvider.d.ts +3 -1
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +9 -2
- package/script/src/dsl/http/versori/constants.d.ts +1 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.js +2 -1
- package/script/src/dsl/tasks/HttpTask.d.ts +3 -0
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +3 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts +18 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
- package/script/src/dsl/triggers/DurableTrigger.js +41 -0
- package/script/src/dsl/triggers/mod.d.ts +1 -0
- package/script/src/dsl/triggers/mod.d.ts.map +1 -1
- package/script/src/dsl/triggers/mod.js +3 -1
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
- package/script/src/interpreter/durable/DurableInterpreter.js +440 -0
- package/script/src/interpreter/durable/ExecutionError.d.ts +6 -0
- package/script/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
- package/script/src/interpreter/durable/ExecutionError.js +17 -0
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
- package/script/src/interpreter/durable/ObservableCompiler.js +73 -0
- package/script/src/interpreter/durable/Queue.d.ts +69 -0
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -0
- package/script/src/interpreter/durable/Queue.js +154 -0
- package/script/src/interpreter/durable/compilers/background.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/background.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/background.js +25 -0
- package/script/src/interpreter/durable/compilers/catch.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/catch.js +39 -0
- package/script/src/interpreter/durable/compilers/chain.d.ts +3 -0
- package/script/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/chain.js +12 -0
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/durableworkflow.js +73 -0
- package/script/src/interpreter/durable/compilers/fn.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/fn.js +25 -0
- package/script/src/interpreter/durable/compilers/http.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/http.js +47 -0
- package/script/src/interpreter/durable/compilers/mod.d.ts +2 -0
- package/script/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/mod.js +2 -0
- package/script/src/interpreter/durable/compilers/parallel.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/parallel.js +22 -0
- package/script/src/interpreter/durable/compilers/schedule.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/schedule.js +97 -0
- package/script/src/interpreter/durable/compilers/serial.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/serial.js +19 -0
- package/script/src/interpreter/durable/compilers/types.d.ts +15 -0
- package/script/src/interpreter/durable/compilers/types.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/types.js +2 -0
- package/script/src/interpreter/durable/compilers/unpack.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/unpack.js +25 -0
- package/script/src/interpreter/durable/compilers/webhook.d.ts +4 -0
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
- package/script/src/interpreter/durable/compilers/webhook.js +254 -0
- package/script/src/interpreter/durable/mod.d.ts +5 -0
- package/script/src/interpreter/durable/mod.d.ts.map +1 -0
- package/script/src/interpreter/durable/mod.js +20 -0
- 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 +14 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockQueue = exports.QueueImpl = void 0;
|
|
4
|
+
const mod_js_1 = require("../../mod.js");
|
|
5
|
+
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
6
|
+
class QueueImpl {
|
|
7
|
+
constructor(baseUrl, projectId, log) {
|
|
8
|
+
Object.defineProperty(this, "baseUrl", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "log", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "projectId", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
this.baseUrl = baseUrl;
|
|
27
|
+
this.log = log;
|
|
28
|
+
this.projectId = projectId;
|
|
29
|
+
}
|
|
30
|
+
static fromEnv(log) {
|
|
31
|
+
// TODO make these environment variables configurable in constants/ts
|
|
32
|
+
const baseUrl = Deno.env.get(constants_js_1.envVarWorkflowApiBaseURL);
|
|
33
|
+
const _log = log || new mod_js_1.ConsoleLogger('debug');
|
|
34
|
+
const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'default-project';
|
|
35
|
+
if (!baseUrl) {
|
|
36
|
+
throw new Error('Missing required environment variables');
|
|
37
|
+
}
|
|
38
|
+
return new QueueImpl(baseUrl, projectId, _log);
|
|
39
|
+
}
|
|
40
|
+
async complete(request) {
|
|
41
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/complete`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
id: request.id,
|
|
45
|
+
output: request.output,
|
|
46
|
+
status: request.status,
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
if (!resp.ok) {
|
|
50
|
+
this.log.error('Failed to complete workflow', {
|
|
51
|
+
id: request.id,
|
|
52
|
+
output: request.output,
|
|
53
|
+
status: request.status,
|
|
54
|
+
});
|
|
55
|
+
throw new Error('Failed to complete workflow');
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
async submit(request) {
|
|
60
|
+
// Ensure all workflows have the projectId set
|
|
61
|
+
const workflows = request.workflows.map((w) => ({
|
|
62
|
+
...w,
|
|
63
|
+
projectId: this.projectId || w.projectId,
|
|
64
|
+
}));
|
|
65
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/submit`, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
workflows: workflows,
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
if (!resp.ok) {
|
|
72
|
+
this.log.error('Failed to submit workflows', {
|
|
73
|
+
workflows: workflows,
|
|
74
|
+
});
|
|
75
|
+
throw new Error('Failed to submit workflows');
|
|
76
|
+
}
|
|
77
|
+
const result = (await resp.json());
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
async fetchWorkflows(request) {
|
|
81
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch`, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
ttl: request.ttl,
|
|
85
|
+
limit: request.limit,
|
|
86
|
+
group: request.group,
|
|
87
|
+
projectId: this.projectId || request.projectId,
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
if (!resp.ok) {
|
|
91
|
+
this.log.error('Failed to fetch workflows', {
|
|
92
|
+
ttl: request.ttl,
|
|
93
|
+
limit: request.limit,
|
|
94
|
+
group: request.group,
|
|
95
|
+
projectId: this.projectId || request.projectId,
|
|
96
|
+
});
|
|
97
|
+
throw new Error('Failed to fetch workflows');
|
|
98
|
+
}
|
|
99
|
+
if (resp.status === 204) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const result = (await resp.json());
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async reschedule(request) {
|
|
106
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/reschedule`, {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
body: JSON.stringify({
|
|
109
|
+
id: request.id,
|
|
110
|
+
after: request.after,
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
if (!resp.ok) {
|
|
114
|
+
this.log.error('Failed to reschedule workflow', {
|
|
115
|
+
id: request.id,
|
|
116
|
+
after: request.after,
|
|
117
|
+
});
|
|
118
|
+
throw new Error('Failed to reschedule workflow');
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
async poll(workflowId) {
|
|
123
|
+
// this endpoint returns a 404 if the workflow is not completed
|
|
124
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
125
|
+
method: 'GET',
|
|
126
|
+
});
|
|
127
|
+
if (!resp.ok) {
|
|
128
|
+
this.log.error('Failed to poll workflow', { workflowId });
|
|
129
|
+
throw new Error('Failed to poll workflow');
|
|
130
|
+
}
|
|
131
|
+
const result = (await resp.json());
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.QueueImpl = QueueImpl;
|
|
136
|
+
class MockQueue {
|
|
137
|
+
constructor() { }
|
|
138
|
+
complete(request) {
|
|
139
|
+
throw new Error('Method not implemented.');
|
|
140
|
+
}
|
|
141
|
+
submit(request) {
|
|
142
|
+
throw new Error('Method not implemented.');
|
|
143
|
+
}
|
|
144
|
+
fetchWorkflows(request) {
|
|
145
|
+
throw new Error('Method not implemented.');
|
|
146
|
+
}
|
|
147
|
+
reschedule(request) {
|
|
148
|
+
throw new Error('Method not implemented.');
|
|
149
|
+
}
|
|
150
|
+
poll(workflowId) {
|
|
151
|
+
throw new Error('Method not implemented.');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.MockQueue = MockQueue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/background.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA0CnE,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/E,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.backgroundCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const BackgroundTask_js_1 = require("../../../dsl/tasks/BackgroundTask.js");
|
|
6
|
+
function compileBackground(ctx, task) {
|
|
7
|
+
const base = ctx.compiler.compileTask(ctx, task._base);
|
|
8
|
+
return (src) => src.pipe((0, rxjs_1.connect)((shared$) => (0, rxjs_1.merge)(shared$.pipe((0, rxjs_1.mergeMap)((ctx) => base((0, rxjs_1.of)(ctx)).pipe((0, rxjs_1.subscribeOn)(rxjs_1.asyncScheduler), (0, rxjs_1.tap)({
|
|
9
|
+
next: (ctx) => ctx.log.debug('Background task emitted a value', {
|
|
10
|
+
data: ctx.data,
|
|
11
|
+
}),
|
|
12
|
+
complete: () => ctx.log.debug('Background task completed'),
|
|
13
|
+
}), (0, rxjs_1.catchError)((error) => {
|
|
14
|
+
ctx.log.error('Error in background task', {
|
|
15
|
+
error,
|
|
16
|
+
inputData: ctx.data,
|
|
17
|
+
executionId: ctx.executionId,
|
|
18
|
+
});
|
|
19
|
+
return rxjs_1.EMPTY;
|
|
20
|
+
}), (0, rxjs_1.ignoreElements)()))), shared$.pipe((0, rxjs_1.map)((ctx) => ctx.withData(void 0))))));
|
|
21
|
+
}
|
|
22
|
+
exports.backgroundCompiler = {
|
|
23
|
+
ctor: BackgroundTask_js_1.BackgroundTask,
|
|
24
|
+
compile: compileBackground,
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAmDnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.catchCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const CatchTask_js_1 = require("../../../dsl/tasks/CatchTask.js");
|
|
6
|
+
const ExecutionError_js_1 = require("../ExecutionError.js");
|
|
7
|
+
function compileCatch(compilerCtx, task) {
|
|
8
|
+
const baseOperator = compilerCtx.compiler.compileTask(compilerCtx, task._base);
|
|
9
|
+
const errorOperator = compilerCtx.compiler.compileTask(compilerCtx, task._errorHandler);
|
|
10
|
+
return (src) => src.pipe((0, rxjs_1.mergeMap)((ctx) => {
|
|
11
|
+
return baseOperator((0, rxjs_1.of)(ctx)).pipe((0, rxjs_1.catchError)((error) => {
|
|
12
|
+
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
13
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
14
|
+
span.setAttribute('task.type', 'catch');
|
|
15
|
+
if (error instanceof Error) {
|
|
16
|
+
span.recordException(error);
|
|
17
|
+
span.setAttribute('error.message', error.message);
|
|
18
|
+
span.setAttribute('error.stack', error.stack ?? '');
|
|
19
|
+
span.end();
|
|
20
|
+
ctx.log.error('execution has encountered an error', {
|
|
21
|
+
error: error.message,
|
|
22
|
+
stack: error.stack,
|
|
23
|
+
});
|
|
24
|
+
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, error.message, { cause: error }))));
|
|
25
|
+
}
|
|
26
|
+
ctx.log.error('execution has encountered an error', {
|
|
27
|
+
error: error,
|
|
28
|
+
});
|
|
29
|
+
span.setAttribute('error', `${error}`);
|
|
30
|
+
span.end();
|
|
31
|
+
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
32
|
+
});
|
|
33
|
+
}));
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
exports.catchCompiler = {
|
|
37
|
+
ctor: CatchTask_js_1.CatchTask,
|
|
38
|
+
compile: compileCatch,
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/chain.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAYnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAGrD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chainCompiler = void 0;
|
|
4
|
+
const ChainTask_js_1 = require("../../../dsl/tasks/ChainTask.js");
|
|
5
|
+
function compileChain(ctx, task) {
|
|
6
|
+
const operators = task.tasks.map((t) => ctx.compiler.compileTask(ctx, t));
|
|
7
|
+
return (src) => operators.reduce((acc, curr) => curr(acc), src);
|
|
8
|
+
}
|
|
9
|
+
exports.chainCompiler = {
|
|
10
|
+
ctor: ChainTask_js_1.ChainTask,
|
|
11
|
+
compile: compileChain,
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DurableCompilerContext } from '../mod.js';
|
|
3
|
+
import { ContextImpl } from '../../../mod.js';
|
|
4
|
+
import { DurableWorkflowData, DurableWorkflowTrigger } from '../../../dsl/triggers/DurableTrigger.js';
|
|
5
|
+
import { TriggerCompiler } from './mod.js';
|
|
6
|
+
export declare function compileDurableWorkflow(ctx: DurableCompilerContext, trigger: DurableWorkflowTrigger, signal: AbortSignal): Observable<ContextImpl<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/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;AAG3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CA8E9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAI5F,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.durableWorkflowCompiler = void 0;
|
|
4
|
+
exports.compileDurableWorkflow = compileDurableWorkflow;
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const DurableTrigger_js_1 = require("../../../dsl/triggers/DurableTrigger.js");
|
|
7
|
+
function compileDurableWorkflow(ctx, trigger, signal) {
|
|
8
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
9
|
+
function cleanup() {
|
|
10
|
+
ctx.log.debug('webhook trigger stopped');
|
|
11
|
+
subscriber.complete();
|
|
12
|
+
}
|
|
13
|
+
signal.addEventListener('abort', cleanup, { once: true });
|
|
14
|
+
(async () => {
|
|
15
|
+
while (true) {
|
|
16
|
+
if (signal.aborted) {
|
|
17
|
+
cleanup();
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// Right now the API itself will hang for a period of time if no workflows are available.
|
|
22
|
+
// so we don't need to add a delay here.
|
|
23
|
+
const wfs = await ctx.queueProvider.fetchWorkflows({
|
|
24
|
+
group: trigger.id,
|
|
25
|
+
ttl: trigger.options.ttl,
|
|
26
|
+
limit: trigger.options.limit,
|
|
27
|
+
});
|
|
28
|
+
if (!wfs) {
|
|
29
|
+
continue; // No workflows found, continue polling
|
|
30
|
+
}
|
|
31
|
+
for (const wf of wfs.workflows) {
|
|
32
|
+
if (wf.id && // this is for type safety
|
|
33
|
+
wf.attempt !== undefined &&
|
|
34
|
+
trigger.options.maxAttempts &&
|
|
35
|
+
wf.attempt > trigger.options.maxAttempts) {
|
|
36
|
+
ctx.log.error('Workflow exceeded max attempts failing', {
|
|
37
|
+
workflowId: wf.id,
|
|
38
|
+
attempts: wf.attempt,
|
|
39
|
+
});
|
|
40
|
+
await ctx.queueProvider.complete({
|
|
41
|
+
id: wf.id,
|
|
42
|
+
output: wf.output,
|
|
43
|
+
status: 'failed',
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const data = JSON.parse(atob(wf.payload ?? '{}'));
|
|
48
|
+
let activation;
|
|
49
|
+
if (wf.metadata?.activationId) {
|
|
50
|
+
activation = await ctx.connectionProvider.getActivation(wf.metadata.activationId);
|
|
51
|
+
}
|
|
52
|
+
const newContext = ctx.contextProvider.create(data, {
|
|
53
|
+
activation: activation,
|
|
54
|
+
workflowId: wf.id,
|
|
55
|
+
});
|
|
56
|
+
subscriber.next(newContext);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
ctx.log.error('Error fetching workflows', { error });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
return () => {
|
|
65
|
+
signal.removeEventListener('abort', cleanup);
|
|
66
|
+
ctx.log.debug('durable workflow cleanup');
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.durableWorkflowCompiler = {
|
|
71
|
+
ctor: DurableTrigger_js_1.DurableWorkflowTrigger,
|
|
72
|
+
compile: compileDurableWorkflow,
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fnCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
6
|
+
function compileFn(compilerCtx, task) {
|
|
7
|
+
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
8
|
+
complete: () => compilerCtx.log.debug('fn.complete')
|
|
9
|
+
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
10
|
+
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
11
|
+
span.setAttribute('task.id', task.id);
|
|
12
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
13
|
+
if (typeof ctx.idx === 'number') {
|
|
14
|
+
span.end();
|
|
15
|
+
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
16
|
+
}
|
|
17
|
+
span.end();
|
|
18
|
+
return ctx.withData(await task._fn(ctx));
|
|
19
|
+
});
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
exports.fnCompiler = {
|
|
23
|
+
ctor: FnTask_js_1.FnTask,
|
|
24
|
+
compile: compileFn,
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyDnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
7
|
+
function compileHttp(compilerCtx, task) {
|
|
8
|
+
const roundtripper = compilerCtx.roundTripperFactory.create(task.opts.connection);
|
|
9
|
+
const dynamicFetcher = compilerCtx.roundTripperFactory.createDynamic(task.opts.connection);
|
|
10
|
+
async function http(ctx) {
|
|
11
|
+
const _fetch = await roundtripper;
|
|
12
|
+
const _dynamicFetcher = await dynamicFetcher;
|
|
13
|
+
const httpContext = new HttpTask_js_1.HttpContextImpl(ctx, {}, _fetch, _dynamicFetcher);
|
|
14
|
+
const result = await task.fn(httpContext);
|
|
15
|
+
return ctx.withData(result);
|
|
16
|
+
}
|
|
17
|
+
return (src) => src.pipe((0, operators_1.tap)({
|
|
18
|
+
complete: () => compilerCtx.log.debug('http.complete'),
|
|
19
|
+
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
20
|
+
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
21
|
+
span.setAttribute('task.id', task.id);
|
|
22
|
+
span.setAttribute('task.type', 'http');
|
|
23
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
24
|
+
span.setAttribute('connection.name', task.opts.connection);
|
|
25
|
+
try {
|
|
26
|
+
let result = await http(ctx);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
span.recordException(error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
span.recordException(new Error(String(error)));
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
span.end();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
exports.httpCompiler = {
|
|
45
|
+
ctor: HttpTask_js_1.HttpTaskImpl,
|
|
46
|
+
compile: compileHttp,
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/parallel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAqCnE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGrF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parallelCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const ParallelTask_js_1 = require("../../../dsl/tasks/ParallelTask.js");
|
|
6
|
+
function compileParallel(ctx, task) {
|
|
7
|
+
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
8
|
+
const eachOperator = ctx.compiler.compileTask(ctx, task._each);
|
|
9
|
+
return (src) => src.pipe(baseOperator, (0, rxjs_1.mergeMap)((ctx) => {
|
|
10
|
+
return (0, rxjs_1.from)(ctx.data).pipe((0, rxjs_1.map)((data, idx) => ctx.withData(data).setIndex(idx)),
|
|
11
|
+
// Process items in parallel using mergeMap
|
|
12
|
+
(0, rxjs_1.mergeMap)((item) => eachOperator((0, rxjs_1.of)(item)).pipe((0, rxjs_1.map)((result) => result.setIndex(item.idx)))), (0, rxjs_1.toArray)(), (0, rxjs_1.map)((results) => {
|
|
13
|
+
// Sort by original index to maintain order
|
|
14
|
+
results.sort((a, b) => a.idx - b.idx);
|
|
15
|
+
return ctx.withData(results.map((r) => r.data));
|
|
16
|
+
}));
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
exports.parallelCompiler = {
|
|
20
|
+
ctor: ParallelTask_js_1.ParallelTask,
|
|
21
|
+
compile: compileParallel,
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA0H7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scheduleCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const constants_js_1 = require("../../../dsl/http/versori/constants.js");
|
|
6
|
+
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
7
|
+
function compileSchedule(ctx, trigger, signal) {
|
|
8
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
9
|
+
// Add HTTP endpoint for manual triggering
|
|
10
|
+
if (!ctx.cronRouter) {
|
|
11
|
+
throw new Error('Router not available in compiler context');
|
|
12
|
+
}
|
|
13
|
+
const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
14
|
+
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'example-environment';
|
|
15
|
+
const environmentName = Deno.env.get(constants_js_1.envVarEnvironmentName) || 'example-environment';
|
|
16
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId) || 'example-org';
|
|
17
|
+
const client = ctx.connectionProvider;
|
|
18
|
+
ctx.cronRegistry.set(trigger.id, trigger.schedule);
|
|
19
|
+
async function handleSchedule(req, res, span) {
|
|
20
|
+
try {
|
|
21
|
+
if (trigger.activationPredicate === undefined) {
|
|
22
|
+
const activation = await client.getStaticActivation();
|
|
23
|
+
const executionCtx = ctx.contextProvider.create({}, { activation });
|
|
24
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
25
|
+
try {
|
|
26
|
+
subscriber.next(executionCtx);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
30
|
+
}
|
|
31
|
+
res.status(200).json({
|
|
32
|
+
status: 'triggered',
|
|
33
|
+
executionId: executionCtx.executionId,
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const activations = await client.listActivations();
|
|
38
|
+
if (!activations || activations.length === 0) {
|
|
39
|
+
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
40
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
41
|
+
executionCtx.log.info('no activations found, continuing');
|
|
42
|
+
try {
|
|
43
|
+
subscriber.next(executionCtx);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
47
|
+
}
|
|
48
|
+
res.status(200).json({
|
|
49
|
+
status: 'triggered',
|
|
50
|
+
executionId: executionCtx.executionId,
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
activations.forEach((activation) => {
|
|
55
|
+
const executionCtx = ctx.contextProvider.create({}, { activation });
|
|
56
|
+
try {
|
|
57
|
+
subscriber.next(executionCtx);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
res.status(200).json({ status: 'triggered' });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
ctx.log.error('execution error inside schedule', { error });
|
|
67
|
+
res.status(500).json({ error: 'Failed to trigger schedule' });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ctx.cronRouter.post(`/cron/${trigger.id}`, async (req, res) => {
|
|
71
|
+
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
72
|
+
span.setAttribute('task.id', trigger.id);
|
|
73
|
+
span.setAttribute('task.type', 'schedule');
|
|
74
|
+
span.setAttribute('schedule', trigger.schedule);
|
|
75
|
+
span.setAttribute('project.id', projectId);
|
|
76
|
+
span.setAttribute('environment.id', environmentId);
|
|
77
|
+
span.setAttribute('environment.name', environmentName);
|
|
78
|
+
span.setAttribute('org.id', orgId);
|
|
79
|
+
await handleSchedule(req, res, span);
|
|
80
|
+
span.end();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
function cleanup() {
|
|
84
|
+
ctx.log.debug('scheduler trigger stopped');
|
|
85
|
+
subscriber.complete();
|
|
86
|
+
}
|
|
87
|
+
signal.addEventListener('abort', cleanup, { once: true });
|
|
88
|
+
return () => {
|
|
89
|
+
signal.removeEventListener('abort', cleanup);
|
|
90
|
+
ctx.log.debug('scheduler execution unsubscribed');
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.scheduleCompiler = {
|
|
95
|
+
ctor: ScheduleTrigger_js_1.ScheduleTrigger,
|
|
96
|
+
compile: compileSchedule,
|
|
97
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serial.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/serial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGjF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serialCompiler = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const SerialTask_js_1 = require("../../../dsl/tasks/SerialTask.js");
|
|
6
|
+
function compileSerial(ctx, task) {
|
|
7
|
+
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
8
|
+
const eachOperator = ctx.compiler.compileTask(ctx, task._each);
|
|
9
|
+
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
10
|
+
complete: () => ctx.log.debug('serial.complete'),
|
|
11
|
+
}), baseOperator, (0, rxjs_1.mergeMap)((ctx) => {
|
|
12
|
+
const tasks = ctx.data.map((d, idx) => eachOperator((0, rxjs_1.of)(ctx.withData(d).setIndex(idx))));
|
|
13
|
+
return (0, rxjs_1.concat)(...tasks).pipe((0, rxjs_1.map)((result) => result.data), (0, rxjs_1.toArray)(), (0, rxjs_1.map)((results) => ctx.withData(results)));
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
exports.serialCompiler = {
|
|
17
|
+
ctor: SerialTask_js_1.SerialTask,
|
|
18
|
+
compile: compileSerial,
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observable, OperatorFunction } from "rxjs";
|
|
2
|
+
import { ContextImpl } from '../../../context/Context.js';
|
|
3
|
+
import { Task } from "../../../dsl/Task.js";
|
|
4
|
+
import { Trigger } from '../../../dsl/Trigger.js';
|
|
5
|
+
import { DurableCompilerContext } from '../ObservableCompiler.js';
|
|
6
|
+
export interface TaskCompiler<In, Out, T extends Task<In, Out>> {
|
|
7
|
+
ctor: new (...args: any[]) => T;
|
|
8
|
+
compile: <Index = void>(ctx: DurableCompilerContext, task: T) => ContextOperatorFunction<In, Out, Index>;
|
|
9
|
+
}
|
|
10
|
+
export interface TriggerCompiler<Out, T extends Trigger<Out>> {
|
|
11
|
+
compile: (ctx: DurableCompilerContext, trigger: T, signal: AbortSignal) => Observable<ContextImpl<Out, void>>;
|
|
12
|
+
ctor: new (...args: any[]) => T;
|
|
13
|
+
}
|
|
14
|
+
export type ContextOperatorFunction<In, Out, Index = void> = OperatorFunction<ContextImpl<In, Index>, ContextImpl<Out, Index>>;
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|