@versori/run 0.0.1-alpha.0
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/_dnt.shims.d.ts +12 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +69 -0
- package/esm/context/Context.d.ts +23 -0
- package/esm/context/Context.d.ts.map +1 -0
- package/esm/context/Context.js +47 -0
- package/esm/context/ContextFunc.d.ts +5 -0
- package/esm/context/ContextFunc.d.ts.map +1 -0
- package/esm/context/ContextFunc.js +1 -0
- package/esm/context/ContextProvider.d.ts +11 -0
- package/esm/context/ContextProvider.d.ts.map +1 -0
- package/esm/context/ContextProvider.js +17 -0
- package/esm/dsl/Task.d.ts +36 -0
- package/esm/dsl/Task.d.ts.map +1 -0
- package/esm/dsl/Task.js +1 -0
- package/esm/dsl/Trigger.d.ts +8 -0
- package/esm/dsl/Trigger.d.ts.map +1 -0
- package/esm/dsl/Trigger.js +1 -0
- package/esm/dsl/Workflow.d.ts +14 -0
- package/esm/dsl/Workflow.d.ts.map +1 -0
- package/esm/dsl/Workflow.js +24 -0
- package/esm/dsl/ensureTask.d.ts +3 -0
- package/esm/dsl/ensureTask.d.ts.map +1 -0
- package/esm/dsl/ensureTask.js +7 -0
- package/esm/dsl/tasks/BackgroundTask.d.ts +12 -0
- package/esm/dsl/tasks/BackgroundTask.d.ts.map +1 -0
- package/esm/dsl/tasks/BackgroundTask.js +39 -0
- package/esm/dsl/tasks/CatchTask.d.ts +13 -0
- package/esm/dsl/tasks/CatchTask.d.ts.map +1 -0
- package/esm/dsl/tasks/CatchTask.js +46 -0
- package/esm/dsl/tasks/ChainTask.d.ts +12 -0
- package/esm/dsl/tasks/ChainTask.d.ts.map +1 -0
- package/esm/dsl/tasks/ChainTask.js +39 -0
- package/esm/dsl/tasks/FnTask.d.ts +15 -0
- package/esm/dsl/tasks/FnTask.d.ts.map +1 -0
- package/esm/dsl/tasks/FnTask.js +50 -0
- package/esm/dsl/tasks/HttpTask.d.ts +30 -0
- package/esm/dsl/tasks/HttpTask.d.ts.map +1 -0
- package/esm/dsl/tasks/HttpTask.js +57 -0
- package/esm/dsl/tasks/ParallelTask.d.ts +18 -0
- package/esm/dsl/tasks/ParallelTask.d.ts.map +1 -0
- package/esm/dsl/tasks/ParallelTask.js +52 -0
- package/esm/dsl/tasks/SerialTask.d.ts +18 -0
- package/esm/dsl/tasks/SerialTask.d.ts.map +1 -0
- package/esm/dsl/tasks/SerialTask.js +52 -0
- package/esm/dsl/tasks/UnpackTask.d.ts +15 -0
- package/esm/dsl/tasks/UnpackTask.d.ts.map +1 -0
- package/esm/dsl/tasks/UnpackTask.js +54 -0
- package/esm/dsl/triggers/ScheduleTrigger.d.ts +14 -0
- package/esm/dsl/triggers/ScheduleTrigger.d.ts.map +1 -0
- package/esm/dsl/triggers/ScheduleTrigger.js +38 -0
- package/esm/interpreter/memory/ExecutionError.d.ts +6 -0
- package/esm/interpreter/memory/ExecutionError.d.ts.map +1 -0
- package/esm/interpreter/memory/ExecutionError.js +13 -0
- package/esm/interpreter/memory/MemoryInterpreter.d.ts +18 -0
- package/esm/interpreter/memory/MemoryInterpreter.d.ts.map +1 -0
- package/esm/interpreter/memory/MemoryInterpreter.js +83 -0
- package/esm/interpreter/memory/ObservableCompiler.d.ts +23 -0
- package/esm/interpreter/memory/ObservableCompiler.d.ts.map +1 -0
- package/esm/interpreter/memory/ObservableCompiler.js +65 -0
- package/esm/interpreter/memory/compilers/background.d.ts +4 -0
- package/esm/interpreter/memory/compilers/background.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/background.js +20 -0
- package/esm/interpreter/memory/compilers/catch.d.ts +4 -0
- package/esm/interpreter/memory/compilers/catch.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/catch.js +19 -0
- package/esm/interpreter/memory/compilers/chain.d.ts +3 -0
- package/esm/interpreter/memory/compilers/chain.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/chain.js +9 -0
- package/esm/interpreter/memory/compilers/fn.d.ts +4 -0
- package/esm/interpreter/memory/compilers/fn.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/fn.js +16 -0
- package/esm/interpreter/memory/compilers/http.d.ts +4 -0
- package/esm/interpreter/memory/compilers/http.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/http.js +24 -0
- package/esm/interpreter/memory/compilers/parallel.d.ts +4 -0
- package/esm/interpreter/memory/compilers/parallel.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/parallel.js +19 -0
- package/esm/interpreter/memory/compilers/schedule.d.ts +4 -0
- package/esm/interpreter/memory/compilers/schedule.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/schedule.js +47 -0
- package/esm/interpreter/memory/compilers/serial.d.ts +4 -0
- package/esm/interpreter/memory/compilers/serial.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/serial.js +16 -0
- package/esm/interpreter/memory/compilers/types.d.ts +15 -0
- package/esm/interpreter/memory/compilers/types.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/types.js +1 -0
- package/esm/interpreter/memory/compilers/unpack.d.ts +4 -0
- package/esm/interpreter/memory/compilers/unpack.d.ts.map +1 -0
- package/esm/interpreter/memory/compilers/unpack.js +22 -0
- package/esm/mod.d.ts +5 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +4 -0
- package/esm/observability/logging/ConsoleLogger.d.ts +19 -0
- package/esm/observability/logging/ConsoleLogger.d.ts.map +1 -0
- package/esm/observability/logging/ConsoleLogger.js +85 -0
- package/esm/observability/logging/Logger.d.ts +12 -0
- package/esm/observability/logging/Logger.d.ts.map +1 -0
- package/esm/observability/logging/Logger.js +1 -0
- package/esm/package.json +3 -0
- package/package.json +34 -0
- package/script/_dnt.shims.d.ts +12 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +77 -0
- package/script/context/Context.d.ts +23 -0
- package/script/context/Context.d.ts.map +1 -0
- package/script/context/Context.js +51 -0
- package/script/context/ContextFunc.d.ts +5 -0
- package/script/context/ContextFunc.d.ts.map +1 -0
- package/script/context/ContextFunc.js +2 -0
- package/script/context/ContextProvider.d.ts +11 -0
- package/script/context/ContextProvider.d.ts.map +1 -0
- package/script/context/ContextProvider.js +21 -0
- package/script/dsl/Task.d.ts +36 -0
- package/script/dsl/Task.d.ts.map +1 -0
- package/script/dsl/Task.js +4 -0
- package/script/dsl/Trigger.d.ts +8 -0
- package/script/dsl/Trigger.d.ts.map +1 -0
- package/script/dsl/Trigger.js +4 -0
- package/script/dsl/Workflow.d.ts +14 -0
- package/script/dsl/Workflow.d.ts.map +1 -0
- package/script/dsl/Workflow.js +28 -0
- package/script/dsl/ensureTask.d.ts +3 -0
- package/script/dsl/ensureTask.d.ts.map +1 -0
- package/script/dsl/ensureTask.js +10 -0
- package/script/dsl/tasks/BackgroundTask.d.ts +12 -0
- package/script/dsl/tasks/BackgroundTask.d.ts.map +1 -0
- package/script/dsl/tasks/BackgroundTask.js +43 -0
- package/script/dsl/tasks/CatchTask.d.ts +13 -0
- package/script/dsl/tasks/CatchTask.d.ts.map +1 -0
- package/script/dsl/tasks/CatchTask.js +50 -0
- package/script/dsl/tasks/ChainTask.d.ts +12 -0
- package/script/dsl/tasks/ChainTask.d.ts.map +1 -0
- package/script/dsl/tasks/ChainTask.js +43 -0
- package/script/dsl/tasks/FnTask.d.ts +15 -0
- package/script/dsl/tasks/FnTask.d.ts.map +1 -0
- package/script/dsl/tasks/FnTask.js +55 -0
- package/script/dsl/tasks/HttpTask.d.ts +30 -0
- package/script/dsl/tasks/HttpTask.d.ts.map +1 -0
- package/script/dsl/tasks/HttpTask.js +62 -0
- package/script/dsl/tasks/ParallelTask.d.ts +18 -0
- package/script/dsl/tasks/ParallelTask.d.ts.map +1 -0
- package/script/dsl/tasks/ParallelTask.js +56 -0
- package/script/dsl/tasks/SerialTask.d.ts +18 -0
- package/script/dsl/tasks/SerialTask.d.ts.map +1 -0
- package/script/dsl/tasks/SerialTask.js +56 -0
- package/script/dsl/tasks/UnpackTask.d.ts +15 -0
- package/script/dsl/tasks/UnpackTask.d.ts.map +1 -0
- package/script/dsl/tasks/UnpackTask.js +58 -0
- package/script/dsl/triggers/ScheduleTrigger.d.ts +14 -0
- package/script/dsl/triggers/ScheduleTrigger.d.ts.map +1 -0
- package/script/dsl/triggers/ScheduleTrigger.js +43 -0
- package/script/interpreter/memory/ExecutionError.d.ts +6 -0
- package/script/interpreter/memory/ExecutionError.d.ts.map +1 -0
- package/script/interpreter/memory/ExecutionError.js +17 -0
- package/script/interpreter/memory/MemoryInterpreter.d.ts +18 -0
- package/script/interpreter/memory/MemoryInterpreter.d.ts.map +1 -0
- package/script/interpreter/memory/MemoryInterpreter.js +110 -0
- package/script/interpreter/memory/ObservableCompiler.d.ts +23 -0
- package/script/interpreter/memory/ObservableCompiler.d.ts.map +1 -0
- package/script/interpreter/memory/ObservableCompiler.js +69 -0
- package/script/interpreter/memory/compilers/background.d.ts +4 -0
- package/script/interpreter/memory/compilers/background.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/background.js +23 -0
- package/script/interpreter/memory/compilers/catch.d.ts +4 -0
- package/script/interpreter/memory/compilers/catch.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/catch.js +22 -0
- package/script/interpreter/memory/compilers/chain.d.ts +3 -0
- package/script/interpreter/memory/compilers/chain.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/chain.js +12 -0
- package/script/interpreter/memory/compilers/fn.d.ts +4 -0
- package/script/interpreter/memory/compilers/fn.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/fn.js +19 -0
- package/script/interpreter/memory/compilers/http.d.ts +4 -0
- package/script/interpreter/memory/compilers/http.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/http.js +27 -0
- package/script/interpreter/memory/compilers/parallel.d.ts +4 -0
- package/script/interpreter/memory/compilers/parallel.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/parallel.js +22 -0
- package/script/interpreter/memory/compilers/schedule.d.ts +4 -0
- package/script/interpreter/memory/compilers/schedule.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/schedule.js +50 -0
- package/script/interpreter/memory/compilers/serial.d.ts +4 -0
- package/script/interpreter/memory/compilers/serial.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/serial.js +19 -0
- package/script/interpreter/memory/compilers/types.d.ts +15 -0
- package/script/interpreter/memory/compilers/types.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/types.js +2 -0
- package/script/interpreter/memory/compilers/unpack.d.ts +4 -0
- package/script/interpreter/memory/compilers/unpack.d.ts.map +1 -0
- package/script/interpreter/memory/compilers/unpack.js +25 -0
- package/script/mod.d.ts +5 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +11 -0
- package/script/observability/logging/ConsoleLogger.d.ts +19 -0
- package/script/observability/logging/ConsoleLogger.d.ts.map +1 -0
- package/script/observability/logging/ConsoleLogger.js +112 -0
- package/script/observability/logging/Logger.d.ts +12 -0
- package/script/observability/logging/Logger.d.ts.map +1 -0
- package/script/observability/logging/Logger.js +2 -0
- package/script/package.json +3 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChainTask } from '../../../dsl/tasks/ChainTask.js';
|
|
2
|
+
function compileChain(ctx, task) {
|
|
3
|
+
const operators = task.tasks.map((t) => ctx.compiler.compileTask(ctx, t));
|
|
4
|
+
return (src) => operators.reduce((acc, curr) => curr(acc), src);
|
|
5
|
+
}
|
|
6
|
+
export const chainCompiler = {
|
|
7
|
+
ctor: ChainTask,
|
|
8
|
+
compile: compileChain,
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoBnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mergeMap, tap } from 'rxjs';
|
|
2
|
+
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
3
|
+
function compileFn(ctx, task) {
|
|
4
|
+
return (src) => src.pipe(tap({
|
|
5
|
+
complete: () => ctx.log.debug('fn.complete')
|
|
6
|
+
}), mergeMap(async (ctx) => {
|
|
7
|
+
if (typeof ctx.idx === 'number') {
|
|
8
|
+
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
9
|
+
}
|
|
10
|
+
return ctx.withData(await task._fn(ctx));
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
export const fnCompiler = {
|
|
14
|
+
ctor: FnTask,
|
|
15
|
+
compile: compileFn,
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mergeMap } from 'rxjs';
|
|
2
|
+
import { tap } from 'rxjs/operators';
|
|
3
|
+
import { HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
4
|
+
function compileHttp(ctx, task) {
|
|
5
|
+
return (src) => src.pipe(tap({
|
|
6
|
+
complete: () => ctx.log.debug('http.complete')
|
|
7
|
+
}), mergeMap(async (ctx) => {
|
|
8
|
+
const httpContext = {
|
|
9
|
+
...ctx,
|
|
10
|
+
fetch,
|
|
11
|
+
connectionVariables: {}, // TODO: Implement connection variables
|
|
12
|
+
pageParams: undefined,
|
|
13
|
+
nextPage: () => {
|
|
14
|
+
throw new Error('Pagination not yet implemented');
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const result = await task.fn(httpContext);
|
|
18
|
+
return ctx.withData(result);
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
export const httpCompiler = {
|
|
22
|
+
ctor: HttpTaskImpl,
|
|
23
|
+
compile: compileHttp,
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/parallel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA+BnE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGrF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { from, map, mergeMap, of, toArray } from 'rxjs';
|
|
2
|
+
import { ParallelTask } from '../../../dsl/tasks/ParallelTask.js';
|
|
3
|
+
function compileParallel(ctx, task) {
|
|
4
|
+
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
5
|
+
const eachOperator = ctx.compiler.compileTask(ctx, task._each);
|
|
6
|
+
return (src) => src.pipe(baseOperator, mergeMap((ctx) => {
|
|
7
|
+
return from(ctx.data).pipe(map((data, idx) => ctx.withData(data).setIndex(idx)),
|
|
8
|
+
// Process items in parallel using mergeMap
|
|
9
|
+
mergeMap((item) => eachOperator(of(item)).pipe(map((result) => result.setIndex(item.idx)))), toArray(), map((results) => {
|
|
10
|
+
// Sort by original index to maintain order
|
|
11
|
+
results.sort((a, b) => a.idx - b.idx);
|
|
12
|
+
return ctx.withData(results.map((r) => r.data));
|
|
13
|
+
}));
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
export const parallelCompiler = {
|
|
17
|
+
ctor: ParallelTask,
|
|
18
|
+
compile: compileParallel,
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../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;AAwD7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CronJob } from 'cron';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
|
|
4
|
+
function compileSchedule(ctx, trigger, signal) {
|
|
5
|
+
return new Observable((subscriber) => {
|
|
6
|
+
const job = CronJob.from({
|
|
7
|
+
cronTime: trigger.schedule,
|
|
8
|
+
onTick: () => {
|
|
9
|
+
const executionCtx = ctx.contextProvider.create({});
|
|
10
|
+
try {
|
|
11
|
+
subscriber.next(executionCtx);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
onComplete: () => {
|
|
18
|
+
if (subscriber.closed) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
ctx.log.debug('schedule execution completed');
|
|
22
|
+
subscriber.complete();
|
|
23
|
+
},
|
|
24
|
+
errorHandler: (error) => {
|
|
25
|
+
ctx.log.error('schedule execution error', { error });
|
|
26
|
+
subscriber.error(error);
|
|
27
|
+
},
|
|
28
|
+
start: true,
|
|
29
|
+
});
|
|
30
|
+
function cleanup() {
|
|
31
|
+
ctx.log.debug('schedule execution stopped');
|
|
32
|
+
job.stop();
|
|
33
|
+
}
|
|
34
|
+
signal.addEventListener('abort', cleanup, { once: true });
|
|
35
|
+
return () => {
|
|
36
|
+
signal.removeEventListener('abort', cleanup);
|
|
37
|
+
ctx.log.debug('schedule execution unsubscribed');
|
|
38
|
+
// call job.stop() directly rather than using cleanup since cleanup is called when the
|
|
39
|
+
// signal is aborted and we don't want duplicate logs when the unsubscription happens.
|
|
40
|
+
job.stop();
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export const scheduleCompiler = {
|
|
45
|
+
ctor: ScheduleTrigger,
|
|
46
|
+
compile: compileSchedule,
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serial.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/serial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGjF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { concat, map, mergeMap, of, toArray, tap } from 'rxjs';
|
|
2
|
+
import { SerialTask } from '../../../dsl/tasks/SerialTask.js';
|
|
3
|
+
function compileSerial(ctx, task) {
|
|
4
|
+
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
5
|
+
const eachOperator = ctx.compiler.compileTask(ctx, task._each);
|
|
6
|
+
return (src) => src.pipe(tap({
|
|
7
|
+
complete: () => ctx.log.debug('serial.complete')
|
|
8
|
+
}), baseOperator, mergeMap((ctx) => {
|
|
9
|
+
const tasks = ctx.data.map((d, idx) => eachOperator(of(ctx.withData(d).setIndex(idx))));
|
|
10
|
+
return concat(...tasks).pipe(map((result) => result.data), toArray(), map((results) => ctx.withData(results)));
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
export const serialCompiler = {
|
|
14
|
+
ctor: SerialTask,
|
|
15
|
+
compile: compileSerial,
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observable, OperatorFunction } from "rxjs";
|
|
2
|
+
import { ContextImpl } from '../../../context/Context.js';
|
|
3
|
+
import { Task } from "../../../dsl/Task.js";
|
|
4
|
+
import { Trigger } from '../../../dsl/Trigger.js';
|
|
5
|
+
import { CompilerContext } from '../ObservableCompiler.js';
|
|
6
|
+
export interface TaskCompiler<In, Out, T extends Task<In, Out>> {
|
|
7
|
+
ctor: new (...args: any[]) => T;
|
|
8
|
+
compile: <Index = void>(ctx: CompilerContext, task: T) => ContextOperatorFunction<In, Out, Index>;
|
|
9
|
+
}
|
|
10
|
+
export type TriggerCompiler<Out, T extends Trigger<Out>> = {
|
|
11
|
+
compile: (ctx: CompilerContext, trigger: T, signal: AbortSignal) => Observable<ContextImpl<Out, void>>;
|
|
12
|
+
ctor: new (...args: any[]) => T;
|
|
13
|
+
};
|
|
14
|
+
export type ContextOperatorFunction<In, Out, Index = void> = OperatorFunction<ContextImpl<In, Index>, ContextImpl<Out, Index>>;
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;IAC1D,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,KAAK,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;CACrG;AAED,MAAM,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,IAAI;IACvD,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACvG,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;CACnC,CAAA;AAED,MAAM,MAAM,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpack.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/memory/compilers/unpack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA6BnE,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { map, tap } from 'rxjs';
|
|
2
|
+
import { UnpackTask } from '../../../dsl/tasks/UnpackTask.js';
|
|
3
|
+
function ensureArray(data) {
|
|
4
|
+
if (Array.isArray(data)) {
|
|
5
|
+
return data;
|
|
6
|
+
}
|
|
7
|
+
return [data];
|
|
8
|
+
}
|
|
9
|
+
function compileUnpack(ctx, task) {
|
|
10
|
+
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
11
|
+
const mapper = task._mapper;
|
|
12
|
+
return (src) => src.pipe(tap({
|
|
13
|
+
complete: () => ctx.log.debug('unpack.complete')
|
|
14
|
+
}), baseOperator, map((ctx) => {
|
|
15
|
+
const result = mapper?.(ctx.data) ?? ctx.data;
|
|
16
|
+
return ctx.withData(ensureArray(result));
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
export const unpackCompiler = {
|
|
20
|
+
ctor: UnpackTask,
|
|
21
|
+
compile: compileUnpack,
|
|
22
|
+
};
|
package/esm/mod.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { schedule } from "./dsl/triggers/ScheduleTrigger.js";
|
|
2
|
+
export { http } from "./dsl/tasks/HttpTask.js";
|
|
3
|
+
export { fn } from "./dsl/tasks/FnTask.js";
|
|
4
|
+
export { MemoryInterpreter } from "./interpreter/memory/MemoryInterpreter.js";
|
|
5
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC"}
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as log from '@std/log';
|
|
2
|
+
import { Logger, LogLevel } from './Logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* ConsoleLogger implements Logger.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConsoleLogger implements Logger {
|
|
7
|
+
log: log.Logger;
|
|
8
|
+
level: LogLevel;
|
|
9
|
+
fields: Record<string, unknown>;
|
|
10
|
+
constructor(level: LogLevel, fields?: Record<string, unknown>);
|
|
11
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
12
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
13
|
+
error(message: string, fields?: Record<string, unknown>): void;
|
|
14
|
+
child(fields: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
}): ConsoleLogger;
|
|
17
|
+
setLevel(level: LogLevel): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ConsoleLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA+B/C;;GAEG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAOjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAGlC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as log from '@std/log';
|
|
2
|
+
log.setup({
|
|
3
|
+
handlers: {
|
|
4
|
+
default: new log.ConsoleHandler('DEBUG', {
|
|
5
|
+
formatter: (record) => {
|
|
6
|
+
// log.formatters.jsonFormatter bugs me:
|
|
7
|
+
// - time is in unix milliseconds
|
|
8
|
+
// - args are rendered as a nested object named `args`.
|
|
9
|
+
//
|
|
10
|
+
// This implementation uses ISO 8601 time and flattens the args object.
|
|
11
|
+
return JSON.stringify({
|
|
12
|
+
level: record.levelName,
|
|
13
|
+
time: record.datetime.toISOString(),
|
|
14
|
+
...(record.loggerName ? { name: record.loggerName } : {}),
|
|
15
|
+
msg: record.msg,
|
|
16
|
+
...(Array.isArray(record.args) ? record.args.reduce((acc, next) => ({
|
|
17
|
+
...acc,
|
|
18
|
+
...(typeof next === 'object' ? next : {}),
|
|
19
|
+
}), {}) : {})
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const levelMap = {
|
|
26
|
+
debug: log.getLevelByName('DEBUG'),
|
|
27
|
+
info: log.getLevelByName('INFO'),
|
|
28
|
+
error: log.getLevelByName('ERROR'),
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* ConsoleLogger implements Logger.
|
|
32
|
+
*/
|
|
33
|
+
export class ConsoleLogger {
|
|
34
|
+
constructor(level, fields = {}) {
|
|
35
|
+
Object.defineProperty(this, "log", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "level", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(this, "fields", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
this.log = log.getLogger();
|
|
54
|
+
this.level = level;
|
|
55
|
+
this.log.level = levelMap[level] ?? log.getLevelByName('INFO');
|
|
56
|
+
this.fields = fields;
|
|
57
|
+
}
|
|
58
|
+
debug(message, fields) {
|
|
59
|
+
this.log.debug(message, {
|
|
60
|
+
...this.fields,
|
|
61
|
+
...fields,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
info(message, fields) {
|
|
65
|
+
this.log.info(message, {
|
|
66
|
+
...this.fields,
|
|
67
|
+
...fields,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
error(message, fields) {
|
|
71
|
+
this.log.error(message, {
|
|
72
|
+
...this.fields,
|
|
73
|
+
...fields,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
child(fields) {
|
|
77
|
+
return new ConsoleLogger(this.level, {
|
|
78
|
+
...this.fields,
|
|
79
|
+
...fields,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
setLevel(level) {
|
|
83
|
+
this.log.level = levelMap[level] ?? log.getLevelByName('INFO');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'error';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
level: LogLevel;
|
|
4
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
5
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
6
|
+
error(message: string, fields?: Record<string, unknown>): void;
|
|
7
|
+
child(fields: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
}): Logger;
|
|
10
|
+
setLevel(level: LogLevel): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/observability/logging/Logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,QAAQ,CAAC;IAEhB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE/D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IAEjD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@versori/run",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Versori Run",
|
|
5
|
+
"homepage": "https://github.com/versori/versori-run#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/versori/versori-run.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/versori/versori-run/issues"
|
|
12
|
+
},
|
|
13
|
+
"main": "./script/mod.js",
|
|
14
|
+
"module": "./esm/mod.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./esm/mod.js",
|
|
18
|
+
"require": "./script/mod.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"private": false,
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@deno/shim-deno": "~0.18.0",
|
|
27
|
+
"@deno/shim-crypto": "~0.3.1",
|
|
28
|
+
"stream": "0.0.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.9.0"
|
|
32
|
+
},
|
|
33
|
+
"_generatedBy": "dnt@dev"
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
|
|
4
|
+
export { ReadableStream, TransformStream, WritableStream } from "stream";
|
|
5
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "ReadableStream" | "TransformStream" | "WritableStream" | "crypto" | "Deno"> & {
|
|
6
|
+
Deno: typeof Deno;
|
|
7
|
+
crypto: import("@deno/shim-crypto").Crypto;
|
|
8
|
+
ReadableStream: any;
|
|
9
|
+
TransformStream: any;
|
|
10
|
+
WritableStream: any;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErvB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AASzE,eAAO,MAAM,aAAa;;;;;;CAA2C,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dntGlobalThis = exports.WritableStream = exports.TransformStream = exports.ReadableStream = exports.crypto = exports.Deno = void 0;
|
|
4
|
+
const shim_deno_1 = require("@deno/shim-deno");
|
|
5
|
+
var shim_deno_2 = require("@deno/shim-deno");
|
|
6
|
+
Object.defineProperty(exports, "Deno", { enumerable: true, get: function () { return shim_deno_2.Deno; } });
|
|
7
|
+
const shim_crypto_1 = require("@deno/shim-crypto");
|
|
8
|
+
var shim_crypto_2 = require("@deno/shim-crypto");
|
|
9
|
+
Object.defineProperty(exports, "crypto", { enumerable: true, get: function () { return shim_crypto_2.crypto; } });
|
|
10
|
+
const stream_1 = require("stream");
|
|
11
|
+
var stream_2 = require("stream");
|
|
12
|
+
Object.defineProperty(exports, "ReadableStream", { enumerable: true, get: function () { return stream_2.ReadableStream; } });
|
|
13
|
+
Object.defineProperty(exports, "TransformStream", { enumerable: true, get: function () { return stream_2.TransformStream; } });
|
|
14
|
+
Object.defineProperty(exports, "WritableStream", { enumerable: true, get: function () { return stream_2.WritableStream; } });
|
|
15
|
+
const dntGlobals = {
|
|
16
|
+
Deno: shim_deno_1.Deno,
|
|
17
|
+
crypto: shim_crypto_1.crypto,
|
|
18
|
+
ReadableStream: stream_1.ReadableStream,
|
|
19
|
+
TransformStream: stream_1.TransformStream,
|
|
20
|
+
WritableStream: stream_1.WritableStream,
|
|
21
|
+
};
|
|
22
|
+
exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
23
|
+
function createMergeProxy(baseObj, extObj) {
|
|
24
|
+
return new Proxy(baseObj, {
|
|
25
|
+
get(_target, prop, _receiver) {
|
|
26
|
+
if (prop in extObj) {
|
|
27
|
+
return extObj[prop];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return baseObj[prop];
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
set(_target, prop, value) {
|
|
34
|
+
if (prop in extObj) {
|
|
35
|
+
delete extObj[prop];
|
|
36
|
+
}
|
|
37
|
+
baseObj[prop] = value;
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
deleteProperty(_target, prop) {
|
|
41
|
+
let success = false;
|
|
42
|
+
if (prop in extObj) {
|
|
43
|
+
delete extObj[prop];
|
|
44
|
+
success = true;
|
|
45
|
+
}
|
|
46
|
+
if (prop in baseObj) {
|
|
47
|
+
delete baseObj[prop];
|
|
48
|
+
success = true;
|
|
49
|
+
}
|
|
50
|
+
return success;
|
|
51
|
+
},
|
|
52
|
+
ownKeys(_target) {
|
|
53
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
54
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
55
|
+
const extKeysSet = new Set(extKeys);
|
|
56
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
57
|
+
},
|
|
58
|
+
defineProperty(_target, prop, desc) {
|
|
59
|
+
if (prop in extObj) {
|
|
60
|
+
delete extObj[prop];
|
|
61
|
+
}
|
|
62
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
63
|
+
return true;
|
|
64
|
+
},
|
|
65
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
66
|
+
if (prop in extObj) {
|
|
67
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
has(_target, prop) {
|
|
74
|
+
return prop in extObj || prop in baseObj;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Logger } from '../observability/logging/Logger.js';
|
|
2
|
+
export interface Context<D> {
|
|
3
|
+
log: Logger;
|
|
4
|
+
executionId: string;
|
|
5
|
+
startTime: Date;
|
|
6
|
+
data: D;
|
|
7
|
+
}
|
|
8
|
+
export interface InternalContext<D, Index = void> extends Context<D> {
|
|
9
|
+
withData<D2>(data: D2): InternalContext<D2, Index>;
|
|
10
|
+
setIndex(idx: number): InternalContext<D, number>;
|
|
11
|
+
idx: Index;
|
|
12
|
+
}
|
|
13
|
+
export declare class ContextImpl<D, Index = void> implements InternalContext<D, Index> {
|
|
14
|
+
log: Logger;
|
|
15
|
+
executionId: string;
|
|
16
|
+
startTime: Date;
|
|
17
|
+
data: D;
|
|
18
|
+
idx: Index;
|
|
19
|
+
constructor(log: Logger, executionId: string, startTime: Date, data: D);
|
|
20
|
+
setIndex(idx: number): InternalContext<D, number>;
|
|
21
|
+
withData<D2>(data: D2): InternalContext<D2, Index>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,MAAM,WAAW,OAAO,CAAC,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;CACX;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClD,GAAG,EAAE,KAAK,CAAC;CACd;AAED,qBAAa,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAE,YAAW,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IAER,GAAG,EAAE,KAAK,CAAC;gBAEC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAQtE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC;IAOjD,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC;CAGrD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextImpl = void 0;
|
|
4
|
+
class ContextImpl {
|
|
5
|
+
constructor(log, executionId, startTime, data) {
|
|
6
|
+
Object.defineProperty(this, "log", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "executionId", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "startTime", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "data", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "idx", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
this.log = log;
|
|
37
|
+
this.executionId = executionId;
|
|
38
|
+
this.startTime = startTime;
|
|
39
|
+
this.data = data;
|
|
40
|
+
this.idx = void 0;
|
|
41
|
+
}
|
|
42
|
+
setIndex(idx) {
|
|
43
|
+
const next = new ContextImpl(this.log, this.executionId, this.startTime, this.data);
|
|
44
|
+
next.idx = idx;
|
|
45
|
+
return next;
|
|
46
|
+
}
|
|
47
|
+
withData(data) {
|
|
48
|
+
return new ContextImpl(this.log, this.executionId, this.startTime, data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ContextImpl = ContextImpl;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from './Context.js';
|
|
2
|
+
export type ContextFunc<Input, Output, Index = void> = AsyncContextFunc<Input, Output, Index> | SyncContextFunc<Input, Output, Index>;
|
|
3
|
+
export type AsyncContextFunc<Input, Output, Index> = (ctx: Context<Input>, idx: Index) => Promise<Output>;
|
|
4
|
+
export type SyncContextFunc<Input, Output, Index> = (ctx: Context<Input>, idx: Index) => Output;
|
|
5
|
+
//# sourceMappingURL=ContextFunc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextFunc.d.ts","sourceRoot":"","sources":["../../src/context/ContextFunc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,IAC7C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GACtC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE1G,MAAM,MAAM,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Logger } from '../observability/logging/Logger.js';
|
|
2
|
+
import { InternalContext } from './Context.js';
|
|
3
|
+
export interface ContextProvider {
|
|
4
|
+
create<D>(data: D): InternalContext<D, void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class ContextProviderImpl implements ContextProvider {
|
|
7
|
+
log: Logger;
|
|
8
|
+
constructor(log: Logger);
|
|
9
|
+
create<D>(data: D): InternalContext<D, void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ContextProvider.d.ts.map
|