@versori/run 0.7.0-alpha.3 → 0.7.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/VanillaConnectionFactory.d.ts +16 -0
- package/esm/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
- package/esm/src/connection/VanillaConnectionFactory.js +23 -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 +4 -2
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.d.ts +6 -6
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/VanillaContext.d.ts +60 -0
- package/esm/src/context/VanillaContext.d.ts.map +1 -0
- package/esm/src/context/VanillaContext.js +296 -0
- 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 +19 -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/tasks/HttpTask.d.ts +5 -5
- 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/memory/MemoryInterpreter.d.ts +2 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- 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 +27 -0
- package/esm/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/ExecutionError.js +48 -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/Queue.d.ts +72 -0
- package/esm/src/interpreter/vanilla/Queue.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/Queue.js +176 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.js +428 -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 +90 -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 +34 -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 +259 -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 +1 -18
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/package.json +1 -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 +28 -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 +4 -2
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/ContextProvider.d.ts +6 -6
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/VanillaContext.d.ts +60 -0
- package/script/src/context/VanillaContext.d.ts.map +1 -0
- package/script/src/context/VanillaContext.js +302 -0
- 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 +19 -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/tasks/HttpTask.d.ts +5 -5
- 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/memory/MemoryInterpreter.d.ts +2 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- 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 +27 -0
- package/script/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/ExecutionError.js +52 -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/Queue.d.ts +72 -0
- package/script/src/interpreter/vanilla/Queue.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/Queue.js +181 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.js +435 -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 +94 -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 +37 -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 +265 -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 +1 -18
- package/script/src/issues/Issues.d.ts.map +1 -1
|
@@ -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"}
|
|
@@ -38,7 +38,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.durable = void 0;
|
|
41
|
+
exports.vanilla = exports.durable = void 0;
|
|
42
42
|
/**
|
|
43
43
|
* The interpreter module provides the functionality for registering and executing workflows.
|
|
44
44
|
*
|
|
@@ -54,3 +54,4 @@ exports.durable = void 0;
|
|
|
54
54
|
*/
|
|
55
55
|
__exportStar(require("./memory/mod.js"), exports);
|
|
56
56
|
exports.durable = __importStar(require("./durable/mod.js"));
|
|
57
|
+
exports.vanilla = __importStar(require("./vanilla/mod.js"));
|
|
@@ -0,0 +1,27 @@
|
|
|
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 DurableInterpreter}.
|
|
5
|
+
*
|
|
6
|
+
* Note: When using the {@link MemoryInterpreter}, errors in `.catch()` handlers will be instances of the regular
|
|
7
|
+
* `ExecutionError` instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ExecutionError extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* The workflow context at the time the error occurred.
|
|
12
|
+
*/
|
|
13
|
+
ctx: Context<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new ExecutionError.
|
|
16
|
+
*
|
|
17
|
+
* @param ctx The workflow context at the time of the error.
|
|
18
|
+
* @param message The error message.
|
|
19
|
+
* @param opts Optional error options.
|
|
20
|
+
*/
|
|
21
|
+
constructor(ctx: Context<any>, message: string, opts?: ErrorOptions);
|
|
22
|
+
toJSON(): {
|
|
23
|
+
name: string;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# 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;;;;;;GAMG;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,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ExecutionError = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* ExecutionError wraps errors that occur during durable workflow execution, providing access to the context at the
|
|
18
|
+
* time of the error. This is used with the {@link DurableInterpreter}.
|
|
19
|
+
*
|
|
20
|
+
* Note: When using the {@link MemoryInterpreter}, errors in `.catch()` handlers will be instances of the regular
|
|
21
|
+
* `ExecutionError` instead.
|
|
22
|
+
*/
|
|
23
|
+
class ExecutionError extends Error {
|
|
24
|
+
/**
|
|
25
|
+
* Create a new ExecutionError.
|
|
26
|
+
*
|
|
27
|
+
* @param ctx The workflow context at the time of the error.
|
|
28
|
+
* @param message The error message.
|
|
29
|
+
* @param opts Optional error options.
|
|
30
|
+
*/
|
|
31
|
+
constructor(ctx, message, opts) {
|
|
32
|
+
super(message, opts);
|
|
33
|
+
/**
|
|
34
|
+
* The workflow context at the time the error occurred.
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(this, "ctx", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
this.name = 'ExecutionError';
|
|
43
|
+
this.ctx = ctx;
|
|
44
|
+
}
|
|
45
|
+
toJSON() {
|
|
46
|
+
return {
|
|
47
|
+
name: this.name,
|
|
48
|
+
message: this.message,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ExecutionError = ExecutionError;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { Observable, OperatorFunction } from 'rxjs';
|
|
4
|
+
import { ConfigReader } from '../../dsl/http/types.js';
|
|
5
|
+
import { Task } from '../../dsl/Task.js';
|
|
6
|
+
import { Trigger } from '../../dsl/Trigger.js';
|
|
7
|
+
import { Logger } from '../../observability/logging/Logger.js';
|
|
8
|
+
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
9
|
+
import { QueueAPI } from './Queue.js';
|
|
10
|
+
import { ConnectionFactory } from '../../connection/types.js';
|
|
11
|
+
import { VanillaContext } from '../../context/VanillaContext.js';
|
|
12
|
+
import { Activation } from '@versori/run/services/platform';
|
|
13
|
+
import { ContextProvider } from '../../context/ContextProvider.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,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAU/D,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,UA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,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,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ObservableCompiler = exports.VanillaActivation = void 0;
|
|
16
|
+
const Task_js_1 = require("../../dsl/Task.js");
|
|
17
|
+
const Trigger_js_1 = require("../../dsl/Trigger.js");
|
|
18
|
+
const background_js_1 = require("./compilers/background.js");
|
|
19
|
+
const catch_js_1 = require("./compilers/catch.js");
|
|
20
|
+
const chain_js_1 = require("./compilers/chain.js");
|
|
21
|
+
const durableworkflow_js_1 = require("./compilers/durableworkflow.js");
|
|
22
|
+
const fn_js_1 = require("./compilers/fn.js");
|
|
23
|
+
const http_js_1 = require("./compilers/http.js");
|
|
24
|
+
const parallel_js_1 = require("./compilers/parallel.js");
|
|
25
|
+
const schedule_js_1 = require("./compilers/schedule.js");
|
|
26
|
+
const serial_js_1 = require("./compilers/serial.js");
|
|
27
|
+
const unpack_js_1 = require("./compilers/unpack.js");
|
|
28
|
+
const webhook_js_1 = require("./compilers/webhook.js");
|
|
29
|
+
exports.VanillaActivation = {
|
|
30
|
+
id: 'vanilla-webhook-activation',
|
|
31
|
+
user: {
|
|
32
|
+
id: 'vanilla-user-id',
|
|
33
|
+
externalId: 'vanilla-user-external-id',
|
|
34
|
+
displayName: 'Vanilla User',
|
|
35
|
+
organisationId: 'vanilla-org-id',
|
|
36
|
+
createdAt: new Date().toISOString(),
|
|
37
|
+
updatedAt: new Date().toISOString(),
|
|
38
|
+
},
|
|
39
|
+
connections: [],
|
|
40
|
+
dynamicVariables: {},
|
|
41
|
+
environment: undefined,
|
|
42
|
+
};
|
|
43
|
+
class ObservableCompiler {
|
|
44
|
+
constructor() {
|
|
45
|
+
Object.defineProperty(this, "taskCompilers", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: new Map()
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(this, "triggerCompilers", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: new Map()
|
|
56
|
+
});
|
|
57
|
+
// Register all available compilers
|
|
58
|
+
this.registerTask(parallel_js_1.parallelCompiler);
|
|
59
|
+
this.registerTask(serial_js_1.serialCompiler);
|
|
60
|
+
this.registerTask(catch_js_1.catchCompiler);
|
|
61
|
+
this.registerTask(chain_js_1.chainCompiler);
|
|
62
|
+
this.registerTask(fn_js_1.fnCompiler);
|
|
63
|
+
this.registerTask(background_js_1.backgroundCompiler);
|
|
64
|
+
this.registerTask(unpack_js_1.unpackCompiler);
|
|
65
|
+
this.registerTask(http_js_1.httpCompiler);
|
|
66
|
+
this.registerTrigger(schedule_js_1.scheduleCompiler);
|
|
67
|
+
this.registerTrigger(webhook_js_1.webhookCompiler);
|
|
68
|
+
this.registerTrigger(durableworkflow_js_1.durableWorkflowCompiler);
|
|
69
|
+
}
|
|
70
|
+
compileTask(ctx, task) {
|
|
71
|
+
const compiler = this.taskCompilers.get(task[Task_js_1.TaskType]);
|
|
72
|
+
if (!compiler) {
|
|
73
|
+
throw new Error(`No compiler registered for task type: ${task[Task_js_1.TaskType]}`);
|
|
74
|
+
}
|
|
75
|
+
if (!(task instanceof compiler.ctor)) {
|
|
76
|
+
throw new Error(`Task type mismatch: expected ${compiler.ctor.name}, got ${task.constructor.name}`);
|
|
77
|
+
}
|
|
78
|
+
return compiler.compile(ctx, task);
|
|
79
|
+
}
|
|
80
|
+
compileTrigger(ctx, trigger, signal) {
|
|
81
|
+
const compiler = this.triggerCompilers.get(trigger[Trigger_js_1.TriggerType]);
|
|
82
|
+
if (!compiler) {
|
|
83
|
+
throw new Error(`No compiler registered for trigger type: ${trigger[Trigger_js_1.TriggerType]}`);
|
|
84
|
+
}
|
|
85
|
+
if (!(trigger instanceof compiler.ctor)) {
|
|
86
|
+
throw new Error(`Trigger type mismatch: expected ${compiler.ctor.name}, got ${trigger.constructor.name}`);
|
|
87
|
+
}
|
|
88
|
+
return compiler.compile(ctx, trigger, signal);
|
|
89
|
+
}
|
|
90
|
+
registerTask(compiler) {
|
|
91
|
+
const task = new compiler.ctor();
|
|
92
|
+
this.taskCompilers.set(task[Task_js_1.TaskType], compiler);
|
|
93
|
+
}
|
|
94
|
+
registerTrigger(compiler) {
|
|
95
|
+
const trigger = new compiler.ctor();
|
|
96
|
+
this.triggerCompilers.set(trigger[Trigger_js_1.TriggerType], compiler);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ObservableCompiler = ObservableCompiler;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Logger } from '../../observability/mod.js';
|
|
2
|
+
export type WorkflowMsgMetadata = {
|
|
3
|
+
parentWorkflowId?: string;
|
|
4
|
+
executionId?: string;
|
|
5
|
+
activationId?: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
};
|
|
8
|
+
export type Workflows = {
|
|
9
|
+
workflows: WorkflowMsg[];
|
|
10
|
+
};
|
|
11
|
+
export type WorkflowMsg = {
|
|
12
|
+
id?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
environmentId?: string;
|
|
15
|
+
group: string;
|
|
16
|
+
payload?: string;
|
|
17
|
+
output?: string;
|
|
18
|
+
status?: 'available' | 'locked' | 'completed' | 'failed';
|
|
19
|
+
attempt?: number;
|
|
20
|
+
maxAttempts?: number;
|
|
21
|
+
timeout?: string;
|
|
22
|
+
createdAt?: string;
|
|
23
|
+
metadata?: WorkflowMsgMetadata;
|
|
24
|
+
};
|
|
25
|
+
export type CompleteWorkflowRequest = {
|
|
26
|
+
id: string;
|
|
27
|
+
output?: string;
|
|
28
|
+
status: 'completed' | 'failed';
|
|
29
|
+
};
|
|
30
|
+
export type FetchWorkflowsRequest = {
|
|
31
|
+
ttl?: number;
|
|
32
|
+
limit?: number;
|
|
33
|
+
group: string;
|
|
34
|
+
projectId?: string;
|
|
35
|
+
environmentId?: string;
|
|
36
|
+
};
|
|
37
|
+
export type RescheduleWorkflowRequest = {
|
|
38
|
+
id: string;
|
|
39
|
+
after: string;
|
|
40
|
+
};
|
|
41
|
+
export type SubmitWorkflowsRequest = {
|
|
42
|
+
workflows: WorkflowMsg[];
|
|
43
|
+
};
|
|
44
|
+
export interface QueueAPI {
|
|
45
|
+
complete(request: CompleteWorkflowRequest): Promise<void>;
|
|
46
|
+
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
47
|
+
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
48
|
+
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
49
|
+
poll(workflowId: string): Promise<WorkflowMsg>;
|
|
50
|
+
}
|
|
51
|
+
export declare class QueueImpl implements QueueAPI {
|
|
52
|
+
private baseUrl;
|
|
53
|
+
private log;
|
|
54
|
+
private projectId;
|
|
55
|
+
private environmentId;
|
|
56
|
+
constructor(baseUrl: string, projectId: string, environmentId: string, log: Logger);
|
|
57
|
+
static fromEnv(log: Logger): QueueImpl;
|
|
58
|
+
complete(request: CompleteWorkflowRequest): Promise<void>;
|
|
59
|
+
submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
60
|
+
fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
61
|
+
reschedule(request: RescheduleWorkflowRequest): Promise<void>;
|
|
62
|
+
poll(workflowId: string): Promise<WorkflowMsg>;
|
|
63
|
+
}
|
|
64
|
+
export declare class MockQueue implements QueueAPI {
|
|
65
|
+
constructor();
|
|
66
|
+
complete(_request: CompleteWorkflowRequest): Promise<void>;
|
|
67
|
+
submit(_request: SubmitWorkflowsRequest): Promise<Workflows>;
|
|
68
|
+
fetchWorkflows(_request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
|
|
69
|
+
reschedule(_request: RescheduleWorkflowRequest): Promise<void>;
|
|
70
|
+
poll(_workflowId: string): Promise<WorkflowMsg>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=Queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/Queue.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,WAAW,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW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AAI,CAAC;IAG9D,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAGlD"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MockQueue = exports.QueueImpl = void 0;
|
|
16
|
+
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
17
|
+
const mod_js_1 = require("../../mod.js");
|
|
18
|
+
class QueueImpl {
|
|
19
|
+
constructor(baseUrl, projectId, environmentId, log) {
|
|
20
|
+
Object.defineProperty(this, "baseUrl", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "log", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "projectId", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "environmentId", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
this.baseUrl = baseUrl;
|
|
45
|
+
this.log = log;
|
|
46
|
+
this.projectId = projectId;
|
|
47
|
+
this.environmentId = environmentId;
|
|
48
|
+
}
|
|
49
|
+
static fromEnv(log) {
|
|
50
|
+
// TODO make these environment variables configurable in constants/ts
|
|
51
|
+
const baseUrl = Deno.env.get(constants_js_1.envVarSDKApiBaseURL);
|
|
52
|
+
const _log = log || new mod_js_1.ConsoleLogger('debug');
|
|
53
|
+
const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'default-project';
|
|
54
|
+
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'default-environment';
|
|
55
|
+
if (!baseUrl) {
|
|
56
|
+
throw new Error('Missing required environment variables');
|
|
57
|
+
}
|
|
58
|
+
return new QueueImpl(baseUrl, projectId, environmentId, _log);
|
|
59
|
+
}
|
|
60
|
+
async complete(request) {
|
|
61
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/complete`, {
|
|
62
|
+
method: 'POST',
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
id: request.id,
|
|
65
|
+
output: request.output,
|
|
66
|
+
status: request.status,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
if (!resp.ok) {
|
|
70
|
+
this.log.error('Failed to complete workflow', {
|
|
71
|
+
id: request.id,
|
|
72
|
+
output: request.output,
|
|
73
|
+
status: request.status,
|
|
74
|
+
});
|
|
75
|
+
throw new Error('Failed to complete workflow');
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
async submit(request) {
|
|
80
|
+
// Ensure all workflows have the projectId & environmentId set
|
|
81
|
+
const workflows = request.workflows.map((w) => ({
|
|
82
|
+
...w,
|
|
83
|
+
projectId: this.projectId || w.projectId,
|
|
84
|
+
environmentId: this.environmentId || w.environmentId,
|
|
85
|
+
}));
|
|
86
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/submit`, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
workflows: workflows,
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
if (!resp.ok) {
|
|
93
|
+
this.log.error('Failed to submit workflows', {
|
|
94
|
+
workflows: workflows,
|
|
95
|
+
});
|
|
96
|
+
throw new Error('Failed to submit workflows');
|
|
97
|
+
}
|
|
98
|
+
const result = (await resp.json());
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
async fetchWorkflows(request) {
|
|
102
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch`, {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
body: JSON.stringify({
|
|
105
|
+
ttl: request.ttl,
|
|
106
|
+
limit: request.limit,
|
|
107
|
+
group: request.group,
|
|
108
|
+
projectId: this.projectId || request.projectId,
|
|
109
|
+
environmentId: this.environmentId || request.environmentId,
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
if (!resp.ok) {
|
|
113
|
+
const errorText = (await resp.json());
|
|
114
|
+
this.log.error('Failed to fetch workflows', {
|
|
115
|
+
error: errorText.message,
|
|
116
|
+
ttl: request.ttl,
|
|
117
|
+
limit: request.limit,
|
|
118
|
+
group: request.group,
|
|
119
|
+
projectId: this.projectId || request.projectId,
|
|
120
|
+
});
|
|
121
|
+
throw new Error('failed to fetch workflows', {
|
|
122
|
+
cause: new Error(errorText.message),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (resp.status === 204) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const result = (await resp.json());
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
async reschedule(request) {
|
|
132
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/reschedule`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
body: JSON.stringify({
|
|
135
|
+
id: request.id,
|
|
136
|
+
after: request.after,
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
139
|
+
if (!resp.ok) {
|
|
140
|
+
this.log.error('Failed to reschedule workflow', {
|
|
141
|
+
id: request.id,
|
|
142
|
+
after: request.after,
|
|
143
|
+
});
|
|
144
|
+
throw new Error('Failed to reschedule workflow');
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
async poll(workflowId) {
|
|
149
|
+
// this endpoint returns a 404 if the workflow is not completed
|
|
150
|
+
const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
|
|
151
|
+
method: 'GET',
|
|
152
|
+
});
|
|
153
|
+
if (!resp.ok) {
|
|
154
|
+
this.log.error('Failed to poll workflow', { workflowId });
|
|
155
|
+
throw new Error('Failed to poll workflow');
|
|
156
|
+
}
|
|
157
|
+
const result = (await resp.json());
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.QueueImpl = QueueImpl;
|
|
162
|
+
// MockQueue can be used for testing. Right now it throws errors for all methods because it isn't used in tests yet.
|
|
163
|
+
class MockQueue {
|
|
164
|
+
constructor() { }
|
|
165
|
+
complete(_request) {
|
|
166
|
+
throw new Error('Method not implemented.');
|
|
167
|
+
}
|
|
168
|
+
submit(_request) {
|
|
169
|
+
throw new Error('Method not implemented.');
|
|
170
|
+
}
|
|
171
|
+
fetchWorkflows(_request) {
|
|
172
|
+
throw new Error('Method not implemented.');
|
|
173
|
+
}
|
|
174
|
+
reschedule(_request) {
|
|
175
|
+
throw new Error('Method not implemented.');
|
|
176
|
+
}
|
|
177
|
+
poll(_workflowId) {
|
|
178
|
+
throw new Error('Method not implemented.');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.MockQueue = MockQueue;
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { ConfigReader, CronProvider } from '../../dsl/http/types.js';
|
|
6
|
+
import { Workflow } from '../../dsl/Workflow.js';
|
|
7
|
+
import { Logger } from '../../observability/logging/Logger.js';
|
|
8
|
+
import { ContextOperatorFunction } from './compilers/types.js';
|
|
9
|
+
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
10
|
+
import { QueueAPI } from './Queue.js';
|
|
11
|
+
import { DefaultConnectionFactory } from '../../connection/VanillaConnectionFactory.js';
|
|
12
|
+
import { VanillaContext, VanillaContextProvider } from '../../context/VanillaContext.js';
|
|
13
|
+
import { ContextProvider } from '../../context/ContextProvider.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
|
+
trigger$: Observable<VanillaContext<any, void>>;
|
|
42
|
+
task$: ContextOperatorFunction<any, any, any>;
|
|
43
|
+
localAbortController: AbortController;
|
|
44
|
+
sigintListener: () => void;
|
|
45
|
+
subscription?: Subscription;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* VanillaInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
49
|
+
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
50
|
+
* programmatically.
|
|
51
|
+
*
|
|
52
|
+
* Unlike {@link DurableInterpreter}, this interpreter is incapable of using connections. Therefore, all fetch requests will need
|
|
53
|
+
* to use fully qualified URLs and authentication must be handled manually within the workflow.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { VanillaInterpreter, workflow, fn } from '@versori/run';
|
|
58
|
+
*
|
|
59
|
+
* const processJob = workflow('process-job', { maxAttempts: 3 })
|
|
60
|
+
* .then(fn('task', async (ctx) => {
|
|
61
|
+
* ctx.log.info('Processing job', { data: ctx.data });
|
|
62
|
+
* // ... long-running process
|
|
63
|
+
* }));
|
|
64
|
+
*
|
|
65
|
+
* const interpreter = new VanillaInterpreter();
|
|
66
|
+
* interpreter.register(processJob);
|
|
67
|
+
* await interpreter.start();
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare class VanillaInterpreter {
|
|
71
|
+
private readonly log;
|
|
72
|
+
private readonly compiler;
|
|
73
|
+
private readonly contextProvider;
|
|
74
|
+
private readonly webhookRouter;
|
|
75
|
+
private readonly cronRouter;
|
|
76
|
+
private readonly cronRegistry;
|
|
77
|
+
private readonly cnxFetchFactory;
|
|
78
|
+
private readonly cronProvider;
|
|
79
|
+
private readonly tracer;
|
|
80
|
+
private readonly cfgReader;
|
|
81
|
+
private readonly queueProvider;
|
|
82
|
+
private readonly otelSDK?;
|
|
83
|
+
private registeredWorkflows;
|
|
84
|
+
private webhookServer?;
|
|
85
|
+
private cronServer?;
|
|
86
|
+
private shutdownServer?;
|
|
87
|
+
private isShuttingDown;
|
|
88
|
+
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);
|
|
89
|
+
static newInstance(options?: VanillaInterpreterOptions): Promise<VanillaInterpreter>;
|
|
90
|
+
register<O>(workflow: Workflow<O>, options?: VanillaInterpreterOptions): Registration;
|
|
91
|
+
start(): Promise<void>;
|
|
92
|
+
stop(): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
95
|
+
//# 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,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,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAA0B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,k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