@versori/run 0.5.0 → 0.5.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/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
|
@@ -167,7 +167,7 @@ export class MemoryInterpreter {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
static async newInstance(options = {}) {
|
|
170
|
-
const log = options.logger || new ConsoleLogger(
|
|
170
|
+
const log = options.logger || new ConsoleLogger();
|
|
171
171
|
const compiler = options.compiler || new ObservableCompiler();
|
|
172
172
|
const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
|
|
173
173
|
const environmentID = Deno.env.get(envVarEnvId) || 'development';
|
|
@@ -223,7 +223,10 @@ export class MemoryInterpreter {
|
|
|
223
223
|
if (!(workflow instanceof WorkflowImpl)) {
|
|
224
224
|
throw new Error('workflow is not an instance of WorkflowImpl');
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
const triggerName = 'id' in workflow.trigger && typeof workflow.trigger.id === 'string'
|
|
227
|
+
? workflow.trigger.id
|
|
228
|
+
: workflow.trigger.constructor.name;
|
|
229
|
+
this.log.info('MemoryInterpreter.register', { workflow, triggerName });
|
|
227
230
|
const compilerContext = {
|
|
228
231
|
compiler: this.compiler,
|
|
229
232
|
log: this.log,
|
|
@@ -241,11 +244,12 @@ export class MemoryInterpreter {
|
|
|
241
244
|
const trigger$ = this.compiler.compileTrigger(compilerContext, workflow.trigger, combinedSignal);
|
|
242
245
|
const task$ = this.compiler.compileTask(compilerContext, workflow.task);
|
|
243
246
|
const registration = {
|
|
247
|
+
triggerName,
|
|
244
248
|
trigger$,
|
|
245
249
|
task$,
|
|
246
250
|
localAbortController,
|
|
247
251
|
sigintListener: () => {
|
|
248
|
-
this.log.info('Received SIGINT, shutting down workflow');
|
|
252
|
+
this.log.info('Received SIGINT, shutting down workflow', { triggerName });
|
|
249
253
|
localAbortController.abort();
|
|
250
254
|
},
|
|
251
255
|
};
|
|
@@ -273,16 +277,22 @@ export class MemoryInterpreter {
|
|
|
273
277
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
274
278
|
registration.subscription = registration.trigger$
|
|
275
279
|
.pipe(tap((ctx) => {
|
|
276
|
-
ctx.log.info('MemoryInterpreter.executionStarted', {
|
|
280
|
+
ctx.log.info('MemoryInterpreter.executionStarted', {
|
|
281
|
+
triggerName: registration.triggerName,
|
|
282
|
+
});
|
|
277
283
|
}), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
|
|
278
284
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
285
|
+
triggerName: registration.triggerName,
|
|
279
286
|
error: err instanceof Error ? err.toString() : err,
|
|
280
287
|
});
|
|
281
288
|
try {
|
|
282
289
|
ctx.options.onError?.(ctx.withData(err));
|
|
283
290
|
}
|
|
284
291
|
catch (err) {
|
|
285
|
-
ctx.log.error('MemoryInterpreter.onError Error: failed to call onError handler', {
|
|
292
|
+
ctx.log.error('MemoryInterpreter.onError Error: failed to call onError handler', {
|
|
293
|
+
triggerName: registration.triggerName,
|
|
294
|
+
error: err instanceof Error ? err.toString() : err,
|
|
295
|
+
});
|
|
286
296
|
ctx.options.onError?.(ctx.withData({
|
|
287
297
|
message: 'Internal server error',
|
|
288
298
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -294,13 +304,17 @@ export class MemoryInterpreter {
|
|
|
294
304
|
next: (ctx) => {
|
|
295
305
|
const durationMs = Date.now() - ctx.startTime.getTime();
|
|
296
306
|
ctx.log.info('MemoryInterpreter.executionCompleted', {
|
|
307
|
+
triggerName: registration.triggerName,
|
|
297
308
|
durationMs,
|
|
298
309
|
});
|
|
299
310
|
try {
|
|
300
311
|
ctx.options.onSuccess?.(ctx);
|
|
301
312
|
}
|
|
302
313
|
catch (err) {
|
|
303
|
-
ctx.log.error('MemoryInterpreter.onSuccessError: failed to call onSuccess handler', {
|
|
314
|
+
ctx.log.error('MemoryInterpreter.onSuccessError: failed to call onSuccess handler', {
|
|
315
|
+
triggerName: registration.triggerName,
|
|
316
|
+
error: err instanceof Error ? err.toString() : err,
|
|
317
|
+
});
|
|
304
318
|
ctx.options.onSuccess?.(ctx.withData({
|
|
305
319
|
message: 'Internal server error',
|
|
306
320
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -310,12 +324,15 @@ export class MemoryInterpreter {
|
|
|
310
324
|
},
|
|
311
325
|
error: (err) => {
|
|
312
326
|
this.log.error('MemoryInterpreter.error', {
|
|
327
|
+
triggerName: registration.triggerName,
|
|
313
328
|
error: err instanceof Error ? err.toString() : err,
|
|
314
329
|
});
|
|
315
330
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
316
331
|
},
|
|
317
332
|
complete: () => {
|
|
318
|
-
this.log.info('MemoryInterpreter.workflowCompleted'
|
|
333
|
+
this.log.info('MemoryInterpreter.workflowCompleted', {
|
|
334
|
+
triggerName: registration.triggerName,
|
|
335
|
+
});
|
|
319
336
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
320
337
|
},
|
|
321
338
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAiCnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -19,12 +19,15 @@ function compileFn(compilerCtx, task) {
|
|
|
19
19
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
20
20
|
span.setAttribute('task.id', task.id);
|
|
21
21
|
span.setAttribute('execution.id', ctx.executionId);
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
if (typeof ctx.idx === 'number') {
|
|
24
|
+
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
25
|
+
}
|
|
26
|
+
return ctx.withData(await task._fn(ctx));
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
23
29
|
span.end();
|
|
24
|
-
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
25
30
|
}
|
|
26
|
-
span.end();
|
|
27
|
-
return ctx.withData(await task._fn(ctx));
|
|
28
31
|
});
|
|
29
32
|
}));
|
|
30
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyI7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA0SxE,CAAC"}
|
|
@@ -96,12 +96,13 @@ export const webhookCompiler = {
|
|
|
96
96
|
},
|
|
97
97
|
request: req,
|
|
98
98
|
});
|
|
99
|
+
const routeMiddleware = [];
|
|
99
100
|
if (!trigger.options.request?.rawBody) {
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
routeMiddleware.push(express.json({ limit: '50mb', type: ['application/json', '*/*+json'] }));
|
|
102
|
+
routeMiddleware.push(xmlparser(xml2jsDefaults));
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
104
|
-
|
|
105
|
+
routeMiddleware.push(express.raw({ type: '*/*', limit: '50mb' }));
|
|
105
106
|
}
|
|
106
107
|
return new Observable((subscriber) => {
|
|
107
108
|
if (!ctx.webhookRouter) {
|
|
@@ -118,7 +119,7 @@ export const webhookCompiler = {
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
121
|
-
ctx.webhookRouter[method](`/${trigger.id}`, createStaticWebhookMiddleware({
|
|
122
|
+
ctx.webhookRouter[method](`/${trigger.id}`, ...routeMiddleware, createStaticWebhookMiddleware({
|
|
122
123
|
id: trigger.id,
|
|
123
124
|
organisationId: ctx.organisationId,
|
|
124
125
|
environmentId: Deno.env.get(envVarEnvId) ?? '',
|
|
@@ -154,7 +155,7 @@ export const webhookCompiler = {
|
|
|
154
155
|
});
|
|
155
156
|
});
|
|
156
157
|
// this endpoint will trigger the workflow for each activation given by the external user ID
|
|
157
|
-
ctx.webhookRouter[method](`/${trigger.id}/users/:userId`, createUserIdDynamicWebhookMiddleware({
|
|
158
|
+
ctx.webhookRouter[method](`/${trigger.id}/users/:userId`, ...routeMiddleware, createUserIdDynamicWebhookMiddleware({
|
|
158
159
|
id: trigger.id,
|
|
159
160
|
connName: trigger.options.connection,
|
|
160
161
|
organisationId: ctx.organisationId,
|
|
@@ -210,7 +211,7 @@ export const webhookCompiler = {
|
|
|
210
211
|
});
|
|
211
212
|
});
|
|
212
213
|
// this endpoint will trigger the workflow only for the activation given by its ID
|
|
213
|
-
ctx.webhookRouter[method](`/${trigger.id}/activations/:activationId`, createActIdDynamicWebhookMiddleware({
|
|
214
|
+
ctx.webhookRouter[method](`/${trigger.id}/activations/:activationId`, ...routeMiddleware, createActIdDynamicWebhookMiddleware({
|
|
214
215
|
id: trigger.id,
|
|
215
216
|
organisationId: ctx.organisationId,
|
|
216
217
|
environmentId: Deno.env.get(envVarEnvId) ?? '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/interpreter/mod.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/interpreter/mod.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Context } from '../../context/Context.js';
|
|
2
|
+
/**
|
|
3
|
+
* ExecutionError wraps errors that occur during durable workflow execution, providing access to the context at the
|
|
4
|
+
* time of the error. This is used with the {@link VanillaInterpreter}.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare class ExecutionError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* The workflow context at the time the error occurred.
|
|
10
|
+
*/
|
|
11
|
+
ctx: Context<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new ExecutionError.
|
|
14
|
+
*
|
|
15
|
+
* @param ctx The workflow context at the time of the error.
|
|
16
|
+
* @param message The error message.
|
|
17
|
+
* @param opts Optional error options.
|
|
18
|
+
*/
|
|
19
|
+
constructor(ctx: Context<any>, message: string, opts?: ErrorOptions);
|
|
20
|
+
toJSON(): {
|
|
21
|
+
name: string;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ExecutionError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionError.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/ExecutionError.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACrC;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAElB;;;;;;OAMG;gBACS,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;IAOnE,MAAM;;;;CAMT"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* ExecutionError wraps errors that occur during durable workflow execution, providing access to the context at the
|
|
15
|
+
* time of the error. This is used with the {@link VanillaInterpreter}.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export class ExecutionError extends Error {
|
|
19
|
+
/**
|
|
20
|
+
* Create a new ExecutionError.
|
|
21
|
+
*
|
|
22
|
+
* @param ctx The workflow context at the time of the error.
|
|
23
|
+
* @param message The error message.
|
|
24
|
+
* @param opts Optional error options.
|
|
25
|
+
*/
|
|
26
|
+
constructor(ctx, message, opts) {
|
|
27
|
+
super(message, opts);
|
|
28
|
+
/**
|
|
29
|
+
* The workflow context at the time the error occurred.
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(this, "ctx", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
this.name = 'ExecutionError';
|
|
38
|
+
this.ctx = ctx;
|
|
39
|
+
}
|
|
40
|
+
toJSON() {
|
|
41
|
+
return {
|
|
42
|
+
name: this.name,
|
|
43
|
+
message: this.message,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { Activation } from '../../services/platform/mod.js';
|
|
3
|
+
import { Router } from 'express';
|
|
4
|
+
import { Observable, OperatorFunction } from 'rxjs';
|
|
5
|
+
import { ConnectionFactory } from '../../connection/types.js';
|
|
6
|
+
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
7
|
+
import { VanillaContext } from '../../context/VanillaContext.js';
|
|
8
|
+
import { ConfigReader } from '../../dsl/http/types.js';
|
|
9
|
+
import { Task } from '../../dsl/Task.js';
|
|
10
|
+
import { Trigger } from '../../dsl/Trigger.js';
|
|
11
|
+
import { Logger } from '../../observability/logging/Logger.js';
|
|
12
|
+
import { QueueAPI } from '../durable/Queue.js';
|
|
13
|
+
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
14
|
+
export type VanillaCompilerContext = {
|
|
15
|
+
compiler: ObservableCompiler;
|
|
16
|
+
log: Logger;
|
|
17
|
+
tracer: Tracer;
|
|
18
|
+
contextProvider: ContextProvider;
|
|
19
|
+
cnxFactory: ConnectionFactory;
|
|
20
|
+
queueProvider: QueueAPI;
|
|
21
|
+
webhookRouter: Router;
|
|
22
|
+
cronRouter: Router;
|
|
23
|
+
configReader: ConfigReader;
|
|
24
|
+
cronRegistry: Map<string, string>;
|
|
25
|
+
organisationId: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const VanillaActivation: Activation;
|
|
28
|
+
export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: VanillaCompilerContext, task: T) => OperatorFunction<In, Out>;
|
|
29
|
+
export declare class ObservableCompiler {
|
|
30
|
+
private taskCompilers;
|
|
31
|
+
private triggerCompilers;
|
|
32
|
+
constructor();
|
|
33
|
+
compileTask<In = any, Out = any, Index = void>(ctx: VanillaCompilerContext, task: Task<In, Out>): ContextOperatorFunction<In, Out, Index>;
|
|
34
|
+
compileTrigger<Out = any, T extends Trigger<Out> = Trigger<Out>>(ctx: VanillaCompilerContext, trigger: T, signal: AbortSignal): Observable<VanillaContext<Out, void>>;
|
|
35
|
+
registerTask<In, Out, T extends Task<In, Out>>(compiler: TaskCompiler<In, Out, T>): void;
|
|
36
|
+
registerTrigger<Out, T extends Trigger<Out>>(compiler: TriggerCompiler<Out, T>): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ObservableCompiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9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OAAO,CAAC,gBAAgB,CAAgD;;IAkBxE,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI,EACzC,GAAG,EAAE,sBAAsB,EAC3B,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,GACpB,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC;IAe1C,cAAc,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAC3D,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAexC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { TaskType } from '../../dsl/Task.js';
|
|
14
|
+
import { TriggerType } from '../../dsl/Trigger.js';
|
|
15
|
+
import { backgroundCompiler } from './compilers/background.js';
|
|
16
|
+
import { catchCompiler } from './compilers/catch.js';
|
|
17
|
+
import { chainCompiler } from './compilers/chain.js';
|
|
18
|
+
import { durableWorkflowCompiler } from './compilers/durableworkflow.js';
|
|
19
|
+
import { fnCompiler } from './compilers/fn.js';
|
|
20
|
+
import { httpCompiler } from './compilers/http.js';
|
|
21
|
+
import { parallelCompiler } from './compilers/parallel.js';
|
|
22
|
+
import { scheduleCompiler } from './compilers/schedule.js';
|
|
23
|
+
import { serialCompiler } from './compilers/serial.js';
|
|
24
|
+
import { unpackCompiler } from './compilers/unpack.js';
|
|
25
|
+
import { webhookCompiler } from './compilers/webhook.js';
|
|
26
|
+
export const VanillaActivation = {
|
|
27
|
+
id: 'vanilla-webhook-activation',
|
|
28
|
+
user: {
|
|
29
|
+
id: 'vanilla-user-id',
|
|
30
|
+
externalId: 'vanilla-user-external-id',
|
|
31
|
+
displayName: 'Vanilla User',
|
|
32
|
+
organisationId: 'vanilla-org-id',
|
|
33
|
+
createdAt: new Date().toISOString(),
|
|
34
|
+
updatedAt: new Date().toISOString(),
|
|
35
|
+
},
|
|
36
|
+
connections: [],
|
|
37
|
+
dynamicVariables: {},
|
|
38
|
+
environment: undefined,
|
|
39
|
+
};
|
|
40
|
+
export class ObservableCompiler {
|
|
41
|
+
constructor() {
|
|
42
|
+
Object.defineProperty(this, "taskCompilers", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: new Map()
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "triggerCompilers", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: new Map()
|
|
53
|
+
});
|
|
54
|
+
// Register all available compilers
|
|
55
|
+
this.registerTask(parallelCompiler);
|
|
56
|
+
this.registerTask(serialCompiler);
|
|
57
|
+
this.registerTask(catchCompiler);
|
|
58
|
+
this.registerTask(chainCompiler);
|
|
59
|
+
this.registerTask(fnCompiler);
|
|
60
|
+
this.registerTask(backgroundCompiler);
|
|
61
|
+
this.registerTask(unpackCompiler);
|
|
62
|
+
this.registerTask(httpCompiler);
|
|
63
|
+
this.registerTrigger(scheduleCompiler);
|
|
64
|
+
this.registerTrigger(webhookCompiler);
|
|
65
|
+
this.registerTrigger(durableWorkflowCompiler);
|
|
66
|
+
}
|
|
67
|
+
compileTask(ctx, task) {
|
|
68
|
+
const compiler = this.taskCompilers.get(task[TaskType]);
|
|
69
|
+
if (!compiler) {
|
|
70
|
+
throw new Error(`No compiler registered for task type: ${task[TaskType]}`);
|
|
71
|
+
}
|
|
72
|
+
if (!(task instanceof compiler.ctor)) {
|
|
73
|
+
throw new Error(`Task type mismatch: expected ${compiler.ctor.name}, got ${task.constructor.name}`);
|
|
74
|
+
}
|
|
75
|
+
return compiler.compile(ctx, task);
|
|
76
|
+
}
|
|
77
|
+
compileTrigger(ctx, trigger, signal) {
|
|
78
|
+
const compiler = this.triggerCompilers.get(trigger[TriggerType]);
|
|
79
|
+
if (!compiler) {
|
|
80
|
+
throw new Error(`No compiler registered for trigger type: ${trigger[TriggerType]}`);
|
|
81
|
+
}
|
|
82
|
+
if (!(trigger instanceof compiler.ctor)) {
|
|
83
|
+
throw new Error(`Trigger type mismatch: expected ${compiler.ctor.name}, got ${trigger.constructor.name}`);
|
|
84
|
+
}
|
|
85
|
+
return compiler.compile(ctx, trigger, signal);
|
|
86
|
+
}
|
|
87
|
+
registerTask(compiler) {
|
|
88
|
+
const task = new compiler.ctor();
|
|
89
|
+
this.taskCompilers.set(task[TaskType], compiler);
|
|
90
|
+
}
|
|
91
|
+
registerTrigger(compiler) {
|
|
92
|
+
const trigger = new compiler.ctor();
|
|
93
|
+
this.triggerCompilers.set(trigger[TriggerType], compiler);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
3
|
+
import { Router } from 'express';
|
|
4
|
+
import { Observable, Subscription } from 'rxjs';
|
|
5
|
+
import { DefaultConnectionFactory } from '../../connection/VanillaConnectionFactory.js';
|
|
6
|
+
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
7
|
+
import { VanillaContext, VanillaContextProvider } from '../../context/VanillaContext.js';
|
|
8
|
+
import { ConfigReader, CronProvider } from '../../dsl/http/types.js';
|
|
9
|
+
import { Workflow } from '../../dsl/Workflow.js';
|
|
10
|
+
import { Logger } from '../../observability/logging/Logger.js';
|
|
11
|
+
import { QueueAPI } from '../durable/Queue.js';
|
|
12
|
+
import { ContextOperatorFunction } from './compilers/types.js';
|
|
13
|
+
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
14
|
+
/**
|
|
15
|
+
* VanillaInterpreterOptions
|
|
16
|
+
* configures the behavior of the {@link VanillaInterpreter}.
|
|
17
|
+
*/
|
|
18
|
+
export type VanillaInterpreterOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Custom logger instance. Defaults to ConsoleLogger.
|
|
21
|
+
*/
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
/**
|
|
24
|
+
* Custom compiler for workflow execution. Advanced use only.
|
|
25
|
+
*/
|
|
26
|
+
compiler?: ObservableCompiler;
|
|
27
|
+
/**
|
|
28
|
+
* Custom context provider. Advanced use only.
|
|
29
|
+
*/
|
|
30
|
+
contextProvider?: VanillaContextProvider;
|
|
31
|
+
/**
|
|
32
|
+
* Abort signal to cancel workflow execution.
|
|
33
|
+
*/
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* Skip loading Versori credentials. Useful for local development.
|
|
37
|
+
*/
|
|
38
|
+
skipVersoriCredentials?: boolean;
|
|
39
|
+
};
|
|
40
|
+
type Registration = {
|
|
41
|
+
triggerName: string;
|
|
42
|
+
trigger$: Observable<VanillaContext<any, void>>;
|
|
43
|
+
task$: ContextOperatorFunction<any, any, any>;
|
|
44
|
+
localAbortController: AbortController;
|
|
45
|
+
sigintListener: () => void;
|
|
46
|
+
subscription?: Subscription;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* VanillaInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
50
|
+
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
51
|
+
* programmatically.
|
|
52
|
+
*
|
|
53
|
+
* Unlike {@link DurableInterpreter}, this interpreter is incapable of using connections. Therefore, all fetch requests will need
|
|
54
|
+
* to use fully qualified URLs and authentication must be handled manually within the workflow.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { VanillaInterpreter, workflow, fn } from '@versori/run';
|
|
59
|
+
*
|
|
60
|
+
* const processJob = workflow('process-job', { maxAttempts: 3 })
|
|
61
|
+
* .then(fn('task', async (ctx) => {
|
|
62
|
+
* ctx.log.info('Processing job', { data: ctx.data });
|
|
63
|
+
* // ... long-running process
|
|
64
|
+
* }));
|
|
65
|
+
*
|
|
66
|
+
* const interpreter = new VanillaInterpreter();
|
|
67
|
+
* interpreter.register(processJob);
|
|
68
|
+
* await interpreter.start();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare class VanillaInterpreter {
|
|
72
|
+
private readonly log;
|
|
73
|
+
private readonly compiler;
|
|
74
|
+
private readonly contextProvider;
|
|
75
|
+
private readonly webhookRouter;
|
|
76
|
+
private readonly cronRouter;
|
|
77
|
+
private readonly cronRegistry;
|
|
78
|
+
private readonly cnxFetchFactory;
|
|
79
|
+
private readonly cronProvider;
|
|
80
|
+
private readonly tracer;
|
|
81
|
+
private readonly cfgReader;
|
|
82
|
+
private readonly queueProvider;
|
|
83
|
+
private readonly otelSDK?;
|
|
84
|
+
private registeredWorkflows;
|
|
85
|
+
private webhookServer?;
|
|
86
|
+
private cronServer?;
|
|
87
|
+
private shutdownServer?;
|
|
88
|
+
private isShuttingDown;
|
|
89
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFetchFactory: DefaultConnectionFactory, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
90
|
+
static newInstance(options?: VanillaInterpreterOptions): Promise<VanillaInterpreter>;
|
|
91
|
+
register<O>(workflow: Workflow<O>, options?: VanillaInterpreterOptions): Registration;
|
|
92
|
+
start(): Promise<void>;
|
|
93
|
+
stop(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=VanillaInterpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VanillaInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/VanillaInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAarE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAA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