@versori/run 0.2.0-alpha.7 → 0.2.0-alpha.9
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/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.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/dsl/http/types.d.ts +13 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/activation.d.ts +13 -0
- package/esm/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/activation.js +65 -0
- package/esm/src/dsl/http/versori/constants.d.ts +5 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.js +5 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts +10 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/cronapi.js +51 -0
- package/esm/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +38 -6
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +8 -5
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +4 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +24 -3
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +18 -23
- package/package.json +1 -1
- package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.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/dsl/http/types.d.ts +13 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/activation.d.ts +13 -0
- package/script/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/script/src/dsl/http/versori/activation.js +69 -0
- package/script/src/dsl/http/versori/constants.d.ts +5 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.js +6 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +10 -0
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -0
- package/script/src/dsl/http/versori/cronapi.js +55 -0
- package/script/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +38 -6
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +8 -5
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +4 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +24 -3
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +18 -23
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +0 -0
|
@@ -15,8 +15,9 @@ const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvi
|
|
|
15
15
|
const NatsKeyValueProvider_js_1 = require("../../kv/nats/NatsKeyValueProvider.js");
|
|
16
16
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
17
17
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
18
|
+
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
18
19
|
class MemoryInterpreter {
|
|
19
|
-
constructor(log, compiler, contextProvider, roundTripperFactory, router, connectionProvider) {
|
|
20
|
+
constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider) {
|
|
20
21
|
Object.defineProperty(this, "log", {
|
|
21
22
|
enumerable: true,
|
|
22
23
|
configurable: true,
|
|
@@ -47,12 +48,24 @@ class MemoryInterpreter {
|
|
|
47
48
|
writable: true,
|
|
48
49
|
value: router
|
|
49
50
|
});
|
|
51
|
+
Object.defineProperty(this, "cronRegistry", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: cronRegistry
|
|
56
|
+
});
|
|
50
57
|
Object.defineProperty(this, "connectionProvider", {
|
|
51
58
|
enumerable: true,
|
|
52
59
|
configurable: true,
|
|
53
60
|
writable: true,
|
|
54
61
|
value: connectionProvider
|
|
55
62
|
});
|
|
63
|
+
Object.defineProperty(this, "cronProvider", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: cronProvider
|
|
68
|
+
});
|
|
56
69
|
Object.defineProperty(this, "registeredWorkflows", {
|
|
57
70
|
enumerable: true,
|
|
58
71
|
configurable: true,
|
|
@@ -92,12 +105,12 @@ class MemoryInterpreter {
|
|
|
92
105
|
if (options.contextProvider) {
|
|
93
106
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
94
107
|
// initialised.
|
|
95
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express_1.default.Router(), platformapi_js_1.PlatformAPIClient.fromEnv());
|
|
108
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv());
|
|
96
109
|
}
|
|
97
110
|
const kvp = await (options.skipVersoriCredentials
|
|
98
111
|
? new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider()
|
|
99
112
|
: NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv());
|
|
100
|
-
return new MemoryInterpreter(log, compiler, new ContextProvider_js_1.ContextProviderImpl(log, kvp), roundTripperFactory, express_1.default.Router(), platformapi_js_1.PlatformAPIClient.fromEnv());
|
|
113
|
+
return new MemoryInterpreter(log, compiler, new ContextProvider_js_1.ContextProviderImpl(log, kvp), roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv());
|
|
101
114
|
}
|
|
102
115
|
register(workflow, options) {
|
|
103
116
|
const localAbortController = new AbortController();
|
|
@@ -114,6 +127,7 @@ class MemoryInterpreter {
|
|
|
114
127
|
contextProvider: this.contextProvider,
|
|
115
128
|
roundTripperFactory: this.roundTripperFactory,
|
|
116
129
|
router: this.router,
|
|
130
|
+
cronRegistry: this.cronRegistry,
|
|
117
131
|
connectionProvider: this.connectionProvider
|
|
118
132
|
};
|
|
119
133
|
const trigger$ = this.compiler.compileTrigger(compilerContext, workflow.trigger, combinedSignal);
|
|
@@ -192,6 +206,13 @@ class MemoryInterpreter {
|
|
|
192
206
|
registration.subscription = undefined;
|
|
193
207
|
});
|
|
194
208
|
}
|
|
209
|
+
try {
|
|
210
|
+
this.cronProvider.updateCrons(this.cronRegistry);
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
this.log.error('MemoryInterpreter.updateCronsError', { error: err instanceof Error ? err.toString() : err });
|
|
214
|
+
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
215
|
+
}
|
|
195
216
|
this.server = app.listen(port, () => {
|
|
196
217
|
this.log.info(`Express server listening on http://localhost:${port}`);
|
|
197
218
|
});
|
|
@@ -14,6 +14,7 @@ export type CompilerContext = {
|
|
|
14
14
|
roundTripperFactory: RoundTripperFactory;
|
|
15
15
|
connectionProvider: ConnectionProvider;
|
|
16
16
|
router: Router;
|
|
17
|
+
cronRegistry: Map<string, string>;
|
|
17
18
|
};
|
|
18
19
|
export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: CompilerContext, task: T) => OperatorFunction<In, Out>;
|
|
19
20
|
export declare class ObservableCompiler {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/ObservableCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAO/D,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAE,OAAO,EAAe,MAA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AG,EAAE,CAAC,CAAC;CAIjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAGA,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":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuF7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scheduleCompiler = void 0;
|
|
4
|
-
const cron_1 = require("cron");
|
|
5
4
|
const rxjs_1 = require("rxjs");
|
|
6
5
|
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
7
6
|
function compileSchedule(ctx, trigger, signal) {
|
|
8
7
|
return new rxjs_1.Observable((subscriber) => {
|
|
8
|
+
// Add HTTP endpoint for manual triggering
|
|
9
|
+
if (!ctx.router) {
|
|
10
|
+
throw new Error('Router not available in compiler context');
|
|
11
|
+
}
|
|
9
12
|
const client = ctx.connectionProvider;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
ctx.cronRegistry.set(trigger.id, trigger.schedule);
|
|
14
|
+
ctx.router.post(`/cron/${trigger.id}`, async (req, res) => {
|
|
15
|
+
try {
|
|
13
16
|
if (trigger.activationPredicate === undefined) {
|
|
14
17
|
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
15
18
|
try {
|
|
@@ -18,6 +21,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
18
21
|
catch (error) {
|
|
19
22
|
executionCtx.log.error('execution error inside schedule', { error });
|
|
20
23
|
}
|
|
24
|
+
res.status(200).json({ status: 'triggered', executionId: executionCtx.executionId });
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
const activations = await client.listActivations();
|
|
@@ -30,6 +34,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
30
34
|
catch (error) {
|
|
31
35
|
executionCtx.log.error('execution error inside schedule', { error });
|
|
32
36
|
}
|
|
37
|
+
res.status(200).json({ status: 'triggered', executionId: executionCtx.executionId });
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
40
|
activations.forEach((activation) => {
|
|
@@ -42,31 +47,21 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
42
47
|
executionCtx.log.error('execution error inside schedule', { error });
|
|
43
48
|
}
|
|
44
49
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
subscriber.complete();
|
|
52
|
-
},
|
|
53
|
-
errorHandler: (error) => {
|
|
54
|
-
ctx.log.error('schedule execution error', { error });
|
|
55
|
-
subscriber.error(error);
|
|
56
|
-
},
|
|
57
|
-
start: true,
|
|
50
|
+
res.status(200).json({ status: 'triggered' });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
54
|
+
res.status(500).json({ error: 'Failed to trigger schedule' });
|
|
55
|
+
}
|
|
58
56
|
});
|
|
59
57
|
function cleanup() {
|
|
60
|
-
ctx.log.debug('
|
|
61
|
-
|
|
58
|
+
ctx.log.debug('scheduler trigger stopped');
|
|
59
|
+
subscriber.complete();
|
|
62
60
|
}
|
|
63
61
|
signal.addEventListener('abort', cleanup, { once: true });
|
|
64
62
|
return () => {
|
|
65
63
|
signal.removeEventListener('abort', cleanup);
|
|
66
|
-
ctx.log.debug('
|
|
67
|
-
// call job.stop() directly rather than using cleanup since cleanup is called when the
|
|
68
|
-
// signal is aborted and we don't want duplicate logs when the unsubscription happens.
|
|
69
|
-
job.stop();
|
|
64
|
+
ctx.log.debug('scheduler execution unsubscribed');
|
|
70
65
|
};
|
|
71
66
|
});
|
|
72
67
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|