@versori/run 0.1.0-alpha.11 → 0.1.0-alpha.13
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/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +28 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +328 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.js +32 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.js +50 -0
- package/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.js +8 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.js +4 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.js +488 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +96 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.js +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.js +72 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +54 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +44 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/esm/src/context/Context.d.ts +14 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +16 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +12 -1
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +32 -35
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +106 -32
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +1 -1
- package/package.json +2 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +31 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +333 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +20 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +5 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +3 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +35 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.js +53 -0
- package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.js +11 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.js +7 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.js +492 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +100 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.js +41 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.js +76 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +57 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +47 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/script/src/context/Context.d.ts +14 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +16 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +12 -1
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +32 -35
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +109 -32
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +3 -3
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextImpl = void 0;
|
|
4
4
|
class ContextImpl {
|
|
5
|
-
constructor(log, kvp, executionId, startTime, data,
|
|
5
|
+
constructor(log, kvp, executionId, startTime, data, options) {
|
|
6
6
|
Object.defineProperty(this, "log", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
configurable: true,
|
|
@@ -21,25 +21,25 @@ class ContextImpl {
|
|
|
21
21
|
writable: true,
|
|
22
22
|
value: void 0
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(this, "
|
|
24
|
+
Object.defineProperty(this, "data", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
configurable: true,
|
|
27
27
|
writable: true,
|
|
28
28
|
value: void 0
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(this, "
|
|
30
|
+
Object.defineProperty(this, "idx", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
configurable: true,
|
|
33
33
|
writable: true,
|
|
34
34
|
value: void 0
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(this, "
|
|
36
|
+
Object.defineProperty(this, "kvp", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
configurable: true,
|
|
39
39
|
writable: true,
|
|
40
40
|
value: void 0
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(this, "
|
|
42
|
+
Object.defineProperty(this, "options", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
configurable: true,
|
|
45
45
|
writable: true,
|
|
@@ -48,25 +48,31 @@ class ContextImpl {
|
|
|
48
48
|
this.log = log;
|
|
49
49
|
this.executionId = executionId;
|
|
50
50
|
this.startTime = startTime;
|
|
51
|
-
this.activation = activation;
|
|
52
51
|
this.data = data;
|
|
53
52
|
this.idx = void 0;
|
|
54
53
|
this.kvp = kvp;
|
|
54
|
+
this.options = options;
|
|
55
|
+
}
|
|
56
|
+
get activation() {
|
|
57
|
+
return this.options.activation;
|
|
55
58
|
}
|
|
56
59
|
setIndex(idx) {
|
|
57
|
-
const next = new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, this.data, this.
|
|
60
|
+
const next = new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, this.data, this.options);
|
|
58
61
|
next.idx = idx;
|
|
59
62
|
return next;
|
|
60
63
|
}
|
|
61
64
|
withActivation(activation) {
|
|
62
65
|
// Essentially makes activation immutable once set
|
|
63
66
|
if (this.activation) {
|
|
64
|
-
|
|
67
|
+
throw new Error('Activation is already set');
|
|
65
68
|
}
|
|
66
|
-
return new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, this.data,
|
|
69
|
+
return new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, this.data, {
|
|
70
|
+
...this.options,
|
|
71
|
+
activation,
|
|
72
|
+
});
|
|
67
73
|
}
|
|
68
74
|
withData(data) {
|
|
69
|
-
return new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, data, this.
|
|
75
|
+
return new ContextImpl(this.log, this.kvp, this.executionId, this.startTime, data, this.options);
|
|
70
76
|
}
|
|
71
77
|
openKv(scope = ':project:') {
|
|
72
78
|
if (scope === ':execution:') {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { KeyValueProvider } from '../kv/KeyValue.js';
|
|
2
2
|
import { Logger } from '../observability/logging/Logger.js';
|
|
3
|
-
import { Context, InternalContext } from './Context.js';
|
|
4
|
-
import { Activation } from '../dsl/http/types.js';
|
|
3
|
+
import { Context, ContextOptions, InternalContext } from './Context.js';
|
|
5
4
|
export interface ContextProvider {
|
|
6
|
-
create<D>(data: D,
|
|
5
|
+
create<D>(data: D, options?: ContextOptions): InternalContext<D, void>;
|
|
7
6
|
destroy(ctx: Context<any>): Promise<void>;
|
|
8
7
|
}
|
|
9
8
|
export declare class ContextProviderImpl implements ContextProvider {
|
|
10
9
|
log: Logger;
|
|
11
10
|
kvp: KeyValueProvider;
|
|
12
11
|
constructor(log: Logger, kvp: KeyValueProvider);
|
|
13
|
-
create<D>(data: D,
|
|
12
|
+
create<D>(data: D, options?: ContextOptions): InternalContext<D, void>;
|
|
14
13
|
destroy(ctx: Context<any>): Promise<void>;
|
|
15
14
|
}
|
|
16
15
|
//# sourceMappingURL=ContextProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAe,
|
|
1
|
+
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGrF,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,gBAAgB,CAAC;gBAEV,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB;IAK9C,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC;IAe1E,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
|
|
@@ -20,16 +20,16 @@ class ContextProviderImpl {
|
|
|
20
20
|
this.log = log;
|
|
21
21
|
this.kvp = kvp;
|
|
22
22
|
}
|
|
23
|
-
create(data,
|
|
23
|
+
create(data, options = {}) {
|
|
24
24
|
const executionId = (0, mod_js_1.ulid)();
|
|
25
25
|
let logger = this.log.child({ executionId });
|
|
26
|
-
if (activation) {
|
|
26
|
+
if (options.activation) {
|
|
27
27
|
logger = logger.child({
|
|
28
|
-
activationId: activation.id,
|
|
29
|
-
externalUserId: activation.user.externalId,
|
|
28
|
+
activationId: options.activation.id,
|
|
29
|
+
externalUserId: options.activation.user.externalId,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
return new Context_js_1.ContextImpl(logger, this.kvp, executionId, new Date(), data,
|
|
32
|
+
return new Context_js_1.ContextImpl(logger, this.kvp, executionId, new Date(), data, options);
|
|
33
33
|
}
|
|
34
34
|
destroy(ctx) {
|
|
35
35
|
return this.kvp.destroy({
|
|
@@ -4,7 +4,8 @@ export declare class PlatformAPIClient implements ConnectionProvider {
|
|
|
4
4
|
private orgId;
|
|
5
5
|
private envId;
|
|
6
6
|
private internalAuth;
|
|
7
|
-
|
|
7
|
+
private cache;
|
|
8
|
+
constructor(baseUrl: string, orgId: string, envId: string, cache?: Record<string, Connection>);
|
|
8
9
|
static fromEnv(): PlatformAPIClient;
|
|
9
10
|
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
10
11
|
getUserActivations(userId: string): Promise<Activation[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIzE,qBAAa,iBAAkB,YAAW,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAe;
|
|
1
|
+
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIzE,qBAAa,iBAAkB,YAAW,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,KAAK,CAA6B;gBAGtC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM;IAS1C,MAAM,CAAC,OAAO,IAAI,iBAAiB;IAY7B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAsBnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAmBzD,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmBpE,uBAAuB,CACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmB5B,eAAe,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAkBjD"}
|
|
@@ -4,7 +4,7 @@ exports.PlatformAPIClient = void 0;
|
|
|
4
4
|
const constants_js_1 = require("./constants.js");
|
|
5
5
|
const internalauth_js_1 = require("./internalauth.js");
|
|
6
6
|
class PlatformAPIClient {
|
|
7
|
-
constructor(baseUrl, orgId, envId) {
|
|
7
|
+
constructor(baseUrl, orgId, envId, cache = {}) {
|
|
8
8
|
Object.defineProperty(this, "baseUrl", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
configurable: true,
|
|
@@ -29,8 +29,15 @@ class PlatformAPIClient {
|
|
|
29
29
|
writable: true,
|
|
30
30
|
value: void 0
|
|
31
31
|
});
|
|
32
|
+
Object.defineProperty(this, "cache", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
32
38
|
this.baseUrl = baseUrl;
|
|
33
39
|
this.orgId = orgId;
|
|
40
|
+
this.cache = cache;
|
|
34
41
|
this.envId = envId;
|
|
35
42
|
this.internalAuth = new internalauth_js_1.InternalAuth();
|
|
36
43
|
}
|
|
@@ -44,6 +51,9 @@ class PlatformAPIClient {
|
|
|
44
51
|
return new PlatformAPIClient(baseUrl, orgId, envId);
|
|
45
52
|
}
|
|
46
53
|
async getStaticConnection(cnxId) {
|
|
54
|
+
if (this.cache[cnxId]) {
|
|
55
|
+
return this.cache[cnxId];
|
|
56
|
+
}
|
|
47
57
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
|
|
48
58
|
headers: {
|
|
49
59
|
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
@@ -53,6 +63,7 @@ class PlatformAPIClient {
|
|
|
53
63
|
return undefined;
|
|
54
64
|
}
|
|
55
65
|
const result = (await resp.json());
|
|
66
|
+
this.cache[cnxId] = result;
|
|
56
67
|
return result;
|
|
57
68
|
}
|
|
58
69
|
async getUserActivations(userId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AASlE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE,OAAO,CAAC,WAAW,CAA0B;IAE7C,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;gBAGE,WAAW,EAAE,uBAAuB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM;IAQlB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,0BAA0B;IA0B3D,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,aAAa;IAmBf,MAAM,CACR,QAAQ,EAAE,MAAM,EAChB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAuB9B,aAAa,CACf,YAAY,EAAE,MAAM,EACpB,EAAE,GAAE,OAAO,KAAwB,GACpC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA2DtC,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa;YAUP,aAAa;YAoDb,gBAAgB;YAmChB,kBAAkB;YAiClB,aAAa;CAkD9B"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VersoriRoundTripperFactory = void 0;
|
|
4
4
|
const configloader_js_1 = require("./configloader.js");
|
|
5
5
|
const mod_js_1 = require("./credentials/mod.js");
|
|
6
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
7
|
const platformapi_js_1 = require("./platformapi.js");
|
|
7
8
|
const mod_js_2 = require("../../../observability/mod.js");
|
|
8
9
|
const constants_js_1 = require("./constants.js");
|
|
@@ -85,12 +86,10 @@ class VersoriRoundTripperFactory {
|
|
|
85
86
|
// takes the info and modifies the url using changeBaseUrl if necessary
|
|
86
87
|
changeRequestInit(info, conn) {
|
|
87
88
|
if (typeof info === 'string') {
|
|
88
|
-
// should be this most of the time assuming we're using pathnames
|
|
89
89
|
return this.changeBaseUrl(info, conn);
|
|
90
90
|
}
|
|
91
91
|
else if (info instanceof URL) {
|
|
92
|
-
|
|
93
|
-
return newUrl;
|
|
92
|
+
return this.changeBaseUrl(info.toString(), conn);
|
|
94
93
|
}
|
|
95
94
|
else if (info instanceof Request) {
|
|
96
95
|
const url = this.changeBaseUrl(info.url, conn);
|
|
@@ -98,46 +97,44 @@ class VersoriRoundTripperFactory {
|
|
|
98
97
|
}
|
|
99
98
|
return info;
|
|
100
99
|
}
|
|
101
|
-
changeBaseUrl(
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return pathname;
|
|
100
|
+
changeBaseUrl(url, conn) {
|
|
101
|
+
const baseUrl = conn.baseUrl;
|
|
102
|
+
if (!baseUrl) {
|
|
103
|
+
return url;
|
|
106
104
|
}
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return
|
|
105
|
+
const urlObj = new URL(url);
|
|
106
|
+
const baseUrlObj = new URL(baseUrl);
|
|
107
|
+
urlObj.hostname = baseUrlObj.hostname;
|
|
108
|
+
this.log.debug('Changing base URL', {
|
|
109
|
+
originalUrl: url,
|
|
110
|
+
newUrl: urlObj.toString(),
|
|
111
|
+
});
|
|
112
|
+
return url.toString();
|
|
115
113
|
}
|
|
116
|
-
// TODO: Currently if the connection is edited, then the fetcher will not be updated.
|
|
117
114
|
async create(connName, fn = globalThis.fetch) {
|
|
118
115
|
const cnxId = this.getConnectionID(connName);
|
|
119
116
|
const conn = await this.platformAPIClient.getStaticConnection(cnxId);
|
|
120
117
|
if (!conn) {
|
|
121
118
|
return undefined;
|
|
122
119
|
}
|
|
123
|
-
const _fn = (input, init) => {
|
|
124
|
-
const _input = this.changeRequestInit(input, conn);
|
|
125
|
-
return fn(_input, init);
|
|
126
|
-
};
|
|
127
120
|
switch (conn.credentials[0].authSchemeConfig.type) {
|
|
128
121
|
case 'api-key':
|
|
129
|
-
return this.apiKeyFetcher(conn,
|
|
122
|
+
return this.apiKeyFetcher(conn, fn);
|
|
130
123
|
case 'basic-auth':
|
|
131
|
-
return this.basicAuthFetcher(conn,
|
|
124
|
+
return this.basicAuthFetcher(conn, fn);
|
|
132
125
|
case 'jwt-bearer':
|
|
133
|
-
return this.bearerTokenFetcher(conn,
|
|
126
|
+
return this.bearerTokenFetcher(conn, fn);
|
|
134
127
|
case 'oauth2':
|
|
135
|
-
return this.oauth2Fetcher(conn,
|
|
128
|
+
return this.oauth2Fetcher(conn, fn);
|
|
136
129
|
default:
|
|
137
130
|
return fn;
|
|
138
131
|
}
|
|
139
132
|
}
|
|
140
133
|
async createDynamic(templateName, fn = globalThis.fetch) {
|
|
134
|
+
const lruCacheOptions = {
|
|
135
|
+
max: 100,
|
|
136
|
+
};
|
|
137
|
+
const cache = new lru_cache_1.LRUCache(lruCacheOptions);
|
|
141
138
|
const template = this.getTemplateID(templateName);
|
|
142
139
|
if (!template) {
|
|
143
140
|
this.log.info('Template not found in config, could be a static connection', {
|
|
@@ -146,7 +143,16 @@ class VersoriRoundTripperFactory {
|
|
|
146
143
|
return undefined;
|
|
147
144
|
}
|
|
148
145
|
const _fn = async (activation, input, init) => {
|
|
149
|
-
|
|
146
|
+
let conn = undefined;
|
|
147
|
+
if (cache.has(activation.id)) {
|
|
148
|
+
conn = cache.get(activation.id);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
conn = await this.platformAPIClient.getActivationConnection(template, activation.id);
|
|
152
|
+
if (conn) {
|
|
153
|
+
cache.set(activation.id, conn);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
150
156
|
if (!conn) {
|
|
151
157
|
return this.defaultDynamic('Connection not found for user, using default fetch', {
|
|
152
158
|
templateName: templateName,
|
|
@@ -336,12 +342,3 @@ class VersoriRoundTripperFactory {
|
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
344
|
exports.VersoriRoundTripperFactory = VersoriRoundTripperFactory;
|
|
339
|
-
function isValidURL(url) {
|
|
340
|
-
try {
|
|
341
|
-
new URL(url);
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
catch (_) {
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
+
import { Context } from '../../context/Context.js';
|
|
1
2
|
import { Taskable } from '../Task.js';
|
|
2
3
|
import { Trigger, TriggerType } from '../Trigger.js';
|
|
3
4
|
import { Workflow } from '../Workflow.js';
|
|
4
5
|
export type WebhookData = Record<string, never>;
|
|
6
|
+
export type WebhookCorsOptions = boolean | {
|
|
7
|
+
origin: string;
|
|
8
|
+
methods: string[];
|
|
9
|
+
allowedHeaders: string[];
|
|
10
|
+
exposedHeaders: string[];
|
|
11
|
+
credentials: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type WebhookResponseOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Mode determines how the response is sent to the client. The response can be customized by
|
|
16
|
+
* the `onSuccess` and `onError` functions, which have sensible defaults for each mode.
|
|
17
|
+
*
|
|
18
|
+
* - `sync`: The response is sent at the end of the workflow.
|
|
19
|
+
* - `async`: The response is sent immediately after the trigger is activated.
|
|
20
|
+
*
|
|
21
|
+
* @default 'sync'
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'sync' | 'async';
|
|
24
|
+
/**
|
|
25
|
+
* Function that returns a response for a successful trigger activation.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to a 202 Accepted response for 'async' mode, and a 200 OK response for 'sync' mode.
|
|
28
|
+
*
|
|
29
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
30
|
+
* @returns A response to send to the client.
|
|
31
|
+
*/
|
|
32
|
+
onSuccess?: <T>(ctx: Context<T>) => Response;
|
|
33
|
+
/**
|
|
34
|
+
* Function that returns a response for a failed trigger activation.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to a 500 Internal Server Error response for both modes.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
39
|
+
* @returns A response to send to the client.
|
|
40
|
+
*/
|
|
41
|
+
onError?: <T>(ctx: Context<T>) => Response;
|
|
42
|
+
};
|
|
43
|
+
export type WebhookOptions = {
|
|
44
|
+
cors?: WebhookCorsOptions;
|
|
45
|
+
response?: WebhookResponseOptions;
|
|
46
|
+
};
|
|
5
47
|
export declare class WebhookTrigger implements Trigger<WebhookData> {
|
|
6
48
|
id: string;
|
|
49
|
+
options: WebhookOptions;
|
|
7
50
|
[TriggerType]: string;
|
|
8
|
-
constructor(id: string);
|
|
51
|
+
constructor(id: string, options?: WebhookOptions);
|
|
9
52
|
then<OO>(task: Taskable<WebhookData, OO>): Workflow<OO>;
|
|
10
|
-
catch<OO>(error: any): Workflow<OO>;
|
|
11
53
|
}
|
|
12
|
-
export declare function webhook(id: string):
|
|
54
|
+
export declare function webhook(id: string, options?: WebhookOptions): Trigger<WebhookData>;
|
|
13
55
|
//# sourceMappingURL=WebhookTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACjC;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;IAE7C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;CAC9C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACrC,CAAA;AAED,qBAAa,cAAe,YAAW,OAAO,CAAC,WAAW,CAAC;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;IAExB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAa;gBAEtB,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAKpD,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;CAG1D;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAElF"}
|
|
@@ -7,13 +7,19 @@ const ensureTask_js_1 = require("../ensureTask.js");
|
|
|
7
7
|
const Trigger_js_1 = require("../Trigger.js");
|
|
8
8
|
const Workflow_js_1 = require("../Workflow.js");
|
|
9
9
|
class WebhookTrigger {
|
|
10
|
-
constructor(id) {
|
|
10
|
+
constructor(id, options = {}) {
|
|
11
11
|
Object.defineProperty(this, "id", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
configurable: true,
|
|
14
14
|
writable: true,
|
|
15
15
|
value: void 0
|
|
16
16
|
});
|
|
17
|
+
Object.defineProperty(this, "options", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
17
23
|
Object.defineProperty(this, _a, {
|
|
18
24
|
enumerable: true,
|
|
19
25
|
configurable: true,
|
|
@@ -21,16 +27,14 @@ class WebhookTrigger {
|
|
|
21
27
|
value: 'webhook'
|
|
22
28
|
});
|
|
23
29
|
this.id = id;
|
|
30
|
+
this.options = options;
|
|
24
31
|
}
|
|
25
32
|
then(task) {
|
|
26
33
|
return new Workflow_js_1.WorkflowImpl(this, (0, ensureTask_js_1.ensureTask)(task));
|
|
27
34
|
}
|
|
28
|
-
catch(error) {
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
35
|
}
|
|
32
36
|
exports.WebhookTrigger = WebhookTrigger;
|
|
33
37
|
_a = Trigger_js_1.TriggerType;
|
|
34
|
-
function webhook(id) {
|
|
35
|
-
return new WebhookTrigger(id);
|
|
38
|
+
function webhook(id, options) {
|
|
39
|
+
return new WebhookTrigger(id, options);
|
|
36
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable, Subscription } from 'rxjs';
|
|
3
3
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
4
4
|
import { ConnectionProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
5
5
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
@@ -18,6 +18,7 @@ type Registration = {
|
|
|
18
18
|
task$: ContextOperatorFunction<any, any, any>;
|
|
19
19
|
localAbortController: AbortController;
|
|
20
20
|
sigintListener: () => void;
|
|
21
|
+
subscription?: Subscription;
|
|
21
22
|
};
|
|
22
23
|
export declare class MemoryInterpreter {
|
|
23
24
|
private readonly log;
|
|
@@ -27,10 +28,14 @@ export declare class MemoryInterpreter {
|
|
|
27
28
|
private readonly router;
|
|
28
29
|
private readonly connectionProvider;
|
|
29
30
|
private registeredWorkflows;
|
|
31
|
+
private server?;
|
|
32
|
+
private shutdownServer?;
|
|
33
|
+
private isShuttingDown;
|
|
30
34
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, router: Router, connectionProvider: ConnectionProvider);
|
|
31
35
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
32
36
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
33
37
|
start(): Promise<void>;
|
|
38
|
+
stop(): Promise<void>;
|
|
34
39
|
}
|
|
35
40
|
export {};
|
|
36
41
|
//# sourceMappingURL=MemoryInterpreter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAA+B,UAAU,EAAW,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAA+B,UAAU,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAI/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAmB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,wBAAwB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7C,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,EAAE,eAAe,CAAC;IACtC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAA;AAED,qBAAa,iBAAiB;IAOtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAXvC,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB;WAI9C,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoC5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IA6C/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiHtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
|
|
@@ -59,6 +59,24 @@ class MemoryInterpreter {
|
|
|
59
59
|
writable: true,
|
|
60
60
|
value: []
|
|
61
61
|
});
|
|
62
|
+
Object.defineProperty(this, "server", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "shutdownServer", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: void 0
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "isShuttingDown", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: false
|
|
79
|
+
});
|
|
62
80
|
}
|
|
63
81
|
static async newInstance(options = {}) {
|
|
64
82
|
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
@@ -84,9 +102,6 @@ class MemoryInterpreter {
|
|
|
84
102
|
if (!(workflow instanceof Workflow_js_1.WorkflowImpl)) {
|
|
85
103
|
throw new Error('workflow is not an instance of WorkflowImpl');
|
|
86
104
|
}
|
|
87
|
-
if (this.log === undefined) {
|
|
88
|
-
throw new Error('Logger is not set, you should initialise the MemoryInterpreter using `await newInstance()` instead');
|
|
89
|
-
}
|
|
90
105
|
this.log.info('MemoryInterpreter.register', { workflow });
|
|
91
106
|
const compilerContext = {
|
|
92
107
|
compiler: this.compiler,
|
|
@@ -123,11 +138,12 @@ class MemoryInterpreter {
|
|
|
123
138
|
// Start all registered workflows
|
|
124
139
|
for (const registration of this.registeredWorkflows) {
|
|
125
140
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
126
|
-
registration.trigger$
|
|
141
|
+
registration.subscription = registration.trigger$
|
|
127
142
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
128
143
|
ctx.log.info('MemoryInterpreter.executionStarted', { data: ctx.data });
|
|
129
144
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((error) => {
|
|
130
145
|
ctx.log.error('MemoryInterpreter.executionError', { error });
|
|
146
|
+
ctx.options.onError?.(ctx.withData(error));
|
|
131
147
|
return rxjs_1.EMPTY;
|
|
132
148
|
}))))
|
|
133
149
|
.subscribe({
|
|
@@ -137,6 +153,7 @@ class MemoryInterpreter {
|
|
|
137
153
|
durationMs,
|
|
138
154
|
data: ctx.data,
|
|
139
155
|
});
|
|
156
|
+
ctx.options.onSuccess?.(ctx);
|
|
140
157
|
this.contextProvider.destroy(ctx);
|
|
141
158
|
},
|
|
142
159
|
error: (err) => {
|
|
@@ -148,10 +165,55 @@ class MemoryInterpreter {
|
|
|
148
165
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
149
166
|
},
|
|
150
167
|
});
|
|
168
|
+
registration.subscription.add(() => {
|
|
169
|
+
registration.subscription = undefined;
|
|
170
|
+
});
|
|
151
171
|
}
|
|
152
|
-
app.listen(port, () => {
|
|
172
|
+
this.server = app.listen(port, () => {
|
|
153
173
|
this.log.info(`Express server listening on http://localhost:${port}`);
|
|
154
174
|
});
|
|
175
|
+
this.shutdownServer = () => {
|
|
176
|
+
if (this.isShuttingDown) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.isShuttingDown = true;
|
|
180
|
+
this.log.info('Shutting down server');
|
|
181
|
+
// Close the server
|
|
182
|
+
if (this.server) {
|
|
183
|
+
this.server.close();
|
|
184
|
+
}
|
|
185
|
+
// Remove all signal listeners
|
|
186
|
+
for (const registration of this.registeredWorkflows) {
|
|
187
|
+
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
188
|
+
// Unsubscribe from all observables
|
|
189
|
+
if (registration.subscription) {
|
|
190
|
+
registration.subscription.unsubscribe();
|
|
191
|
+
}
|
|
192
|
+
// Abort all controllers
|
|
193
|
+
registration.localAbortController.abort();
|
|
194
|
+
}
|
|
195
|
+
// Remove the server shutdown listener
|
|
196
|
+
if (this.shutdownServer) {
|
|
197
|
+
Deno.removeSignalListener('SIGINT', this.shutdownServer);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
201
|
+
return new Promise((resolve) => {
|
|
202
|
+
if (this.server) {
|
|
203
|
+
this.server.on('close', () => {
|
|
204
|
+
this.log.info('Server closed');
|
|
205
|
+
resolve();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
resolve();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async stop() {
|
|
214
|
+
if (this.shutdownServer) {
|
|
215
|
+
this.shutdownServer();
|
|
216
|
+
}
|
|
155
217
|
}
|
|
156
218
|
}
|
|
157
219
|
exports.MemoryInterpreter = MemoryInterpreter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8B7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA8KxE,CAAC"}
|