@pogodisco/zephyr 1.3.7 → 1.3.8
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/workflow-composer.d.ts +9 -12
- package/dist/workflow-composer.js +10 -13
- package/package.json +1 -1
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { ActionParams, ActionRegistry, ActionReturn } from "./types.js";
|
|
2
|
-
type StepBuilderResult<WB, ID extends string, Default> = WB & {
|
|
3
|
-
as<Override>(): OverrideStepResult<WB, ID, Override>;
|
|
4
|
-
};
|
|
5
|
-
type OverrideStepResult<WB, ID extends string, Override> = WB extends WorkflowBuilder<infer Reg, infer Input, infer Context, infer Steps, infer Results, infer Output> ? WorkflowBuilder<Reg, Input, Context, Steps, Omit<Results, ID> & {
|
|
6
|
-
[K in ID]: Override;
|
|
7
|
-
}, Output> : never;
|
|
8
2
|
type NormalizedCall = {
|
|
9
3
|
kind: "none";
|
|
10
4
|
} | {
|
|
@@ -78,28 +72,31 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
|
|
|
78
72
|
input: Input;
|
|
79
73
|
results: Results;
|
|
80
74
|
context: Context;
|
|
81
|
-
} & CallHelpers<Reg, ActionName>) => ResolveOut, dependsOn?: string[], options?: {}):
|
|
75
|
+
} & CallHelpers<Reg, ActionName>) => ResolveOut, dependsOn?: string[], options?: {}): WorkflowBuilder<Reg, Input, Context, [
|
|
82
76
|
...Steps,
|
|
83
77
|
StepDef<Reg, ID, ActionName>
|
|
84
78
|
], Results & {
|
|
85
79
|
[K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>;
|
|
86
|
-
}
|
|
87
|
-
seq<ID extends string, ActionName extends keyof Reg & string, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
|
|
80
|
+
}>;
|
|
81
|
+
seq<ID extends string = string, ActionName extends keyof Reg & string = any, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
|
|
88
82
|
input: Input;
|
|
89
83
|
results: Results;
|
|
90
84
|
context: Context;
|
|
91
|
-
} & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}):
|
|
85
|
+
} & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, undefined>;
|
|
86
|
+
as<NewType>(): WorkflowBuilder<Reg, Input, Context, Steps, Steps extends [...infer Rest, infer Last] ? Last extends StepDef<Reg, infer ID, any> ? Omit<Results, ID> & {
|
|
87
|
+
[K in ID]: NewType;
|
|
88
|
+
} : Results : Results, Output>;
|
|
92
89
|
parallel<Branches extends WorkflowBuilder<Reg, Input, Context, any, any>[]>(...branches: {
|
|
93
90
|
[K in keyof Branches]: (builder: WorkflowBuilder<Reg, Input, Context, [], Results>) => Branches[K];
|
|
94
91
|
}): WorkflowBuilder<Reg, Input, Context, [
|
|
95
92
|
...Steps,
|
|
96
93
|
...(Branches[number] extends WorkflowBuilder<Reg, any, any, infer S, any> ? S : never)
|
|
97
94
|
], Results & (Branches[number] extends WorkflowBuilder<Reg, any, any, any, infer R> ? UnionToIntersection<R> : {})>;
|
|
98
|
-
join<ID extends string, ActionName extends keyof Reg & string, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
|
|
95
|
+
join<ID extends string = string, ActionName extends keyof Reg & string = any, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
|
|
99
96
|
input: Input;
|
|
100
97
|
results: Results;
|
|
101
98
|
context: Context;
|
|
102
|
-
} & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}):
|
|
99
|
+
} & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, undefined>;
|
|
103
100
|
subflow<Prefix extends string, SubSteps extends StepDef<Reg, any, any>[], WF extends WorkflowDef<Reg, any, any, SubSteps, any>>(prefix: Prefix, workflow: WF, resolveInput: WorkflowInput<WF> extends undefined ? ((ctx: {
|
|
104
101
|
input: Input;
|
|
105
102
|
results: Results;
|
|
@@ -397,7 +397,9 @@ export class WorkflowBuilder {
|
|
|
397
397
|
// Input,
|
|
398
398
|
// Context,
|
|
399
399
|
// [...Steps, StepDef<Reg, ID, ActionName>],
|
|
400
|
-
// Results & {
|
|
400
|
+
// Results & {
|
|
401
|
+
// [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>;
|
|
402
|
+
// }
|
|
401
403
|
// > {
|
|
402
404
|
// const deps = dependsOn ?? [...this.frontier];
|
|
403
405
|
//
|
|
@@ -410,13 +412,8 @@ export class WorkflowBuilder {
|
|
|
410
412
|
//
|
|
411
413
|
// this.frontier = [id];
|
|
412
414
|
//
|
|
413
|
-
// // with Override
|
|
414
|
-
//
|
|
415
415
|
// return this as any;
|
|
416
416
|
// }
|
|
417
|
-
/* ------------------------------------------------ */
|
|
418
|
-
/* Base Step */
|
|
419
|
-
/* ------------------------------------------------ */
|
|
420
417
|
step(id, action, resolve, dependsOn, options) {
|
|
421
418
|
const deps = dependsOn ?? [...this.frontier];
|
|
422
419
|
this.steps.push({
|
|
@@ -426,13 +423,7 @@ export class WorkflowBuilder {
|
|
|
426
423
|
dependsOn: deps,
|
|
427
424
|
});
|
|
428
425
|
this.frontier = [id];
|
|
429
|
-
|
|
430
|
-
const next = this;
|
|
431
|
-
next.as = () => {
|
|
432
|
-
return next;
|
|
433
|
-
};
|
|
434
|
-
return next;
|
|
435
|
-
// return this as any;
|
|
426
|
+
return this;
|
|
436
427
|
}
|
|
437
428
|
/* ------------------------------------------------ */
|
|
438
429
|
/* Sequential shortcut */
|
|
@@ -441,6 +432,12 @@ export class WorkflowBuilder {
|
|
|
441
432
|
return this.step(id, action, resolve, undefined, options);
|
|
442
433
|
}
|
|
443
434
|
/* ------------------------------------------------ */
|
|
435
|
+
/* Override the result of the last step */
|
|
436
|
+
/* ------------------------------------------------ */
|
|
437
|
+
as() {
|
|
438
|
+
return this;
|
|
439
|
+
}
|
|
440
|
+
/* ------------------------------------------------ */
|
|
444
441
|
/* Parallel branches */
|
|
445
442
|
/* ------------------------------------------------ */
|
|
446
443
|
parallel(...branches) {
|