@pogodisco/zephyr 1.3.8 → 1.3.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/dist/utils.d.ts +7 -0
- package/dist/utils.js +6 -0
- package/dist/workflow-composer.js +0 -41
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ActionRegistry } from "./types.js";
|
|
2
|
+
import { WorkflowDef } from "./workflow-composer.js";
|
|
1
3
|
type AnyFn = (...args: any[]) => any;
|
|
2
4
|
/**
|
|
3
5
|
* For generic actions - preserves the generic parameter
|
|
@@ -7,4 +9,9 @@ export declare function genericAction<F extends AnyFn>(fn: F): <T>() => ((...arg
|
|
|
7
9
|
* For fixed actions
|
|
8
10
|
*/
|
|
9
11
|
export declare function fixedAction<F extends AnyFn>(fn: F): () => ((...args: Parameters<F>) => ReturnType<F>);
|
|
12
|
+
export declare function createRunner<Reg extends ActionRegistry>(registry: Reg): <W extends WorkflowDef<Reg, any, any, any, any>>(workflow: W, input: W extends WorkflowDef<Reg, infer I, any, any, any> ? I : never, observers?: any[]) => Promise<{
|
|
13
|
+
output: W extends WorkflowDef<Reg, any, any, any, infer O> ? O : never;
|
|
14
|
+
results: W extends WorkflowDef<Reg, any, infer R, any, any> ? R : never;
|
|
15
|
+
extras: Record<string, any>;
|
|
16
|
+
}>;
|
|
10
17
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { executeWorkflow } from "./workflow-executor.js";
|
|
1
2
|
/**
|
|
2
3
|
* For generic actions - preserves the generic parameter
|
|
3
4
|
*/
|
|
@@ -15,3 +16,8 @@ export function fixedAction(fn) {
|
|
|
15
16
|
return fn;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
export function createRunner(registry) {
|
|
20
|
+
return async (workflow, input, observers) => {
|
|
21
|
+
return executeWorkflow(workflow, registry, input, observers ?? []);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -373,47 +373,6 @@ export class WorkflowBuilder {
|
|
|
373
373
|
this.steps = [];
|
|
374
374
|
this.frontier = [];
|
|
375
375
|
}
|
|
376
|
-
/* ------------------------------------------------ */
|
|
377
|
-
/* Base Step */
|
|
378
|
-
/* ------------------------------------------------ */
|
|
379
|
-
// step<
|
|
380
|
-
// ID extends string,
|
|
381
|
-
// ActionName extends keyof Reg & string,
|
|
382
|
-
// ResolveOut extends ResolvedStepInput = ResolvedStepInput,
|
|
383
|
-
// >(
|
|
384
|
-
// id: ID,
|
|
385
|
-
// action: ActionName,
|
|
386
|
-
// resolve?: (
|
|
387
|
-
// ctx: {
|
|
388
|
-
// input: Input;
|
|
389
|
-
// results: Results;
|
|
390
|
-
// context: Context;
|
|
391
|
-
// } & CallHelpers<Reg, ActionName>,
|
|
392
|
-
// ) => ResolveOut,
|
|
393
|
-
// dependsOn?: string[],
|
|
394
|
-
// options?: {},
|
|
395
|
-
// ): WorkflowBuilder<
|
|
396
|
-
// Reg,
|
|
397
|
-
// Input,
|
|
398
|
-
// Context,
|
|
399
|
-
// [...Steps, StepDef<Reg, ID, ActionName>],
|
|
400
|
-
// Results & {
|
|
401
|
-
// [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>;
|
|
402
|
-
// }
|
|
403
|
-
// > {
|
|
404
|
-
// const deps = dependsOn ?? [...this.frontier];
|
|
405
|
-
//
|
|
406
|
-
// this.steps.push({
|
|
407
|
-
// id,
|
|
408
|
-
// action,
|
|
409
|
-
// resolve: resolve ?? (() => ({ kind: "none" })),
|
|
410
|
-
// dependsOn: deps,
|
|
411
|
-
// });
|
|
412
|
-
//
|
|
413
|
-
// this.frontier = [id];
|
|
414
|
-
//
|
|
415
|
-
// return this as any;
|
|
416
|
-
// }
|
|
417
376
|
step(id, action, resolve, dependsOn, options) {
|
|
418
377
|
const deps = dependsOn ?? [...this.frontier];
|
|
419
378
|
this.steps.push({
|