@pogodisco/zephyr 1.3.17 → 1.3.19

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.
@@ -73,11 +73,11 @@ type StepOptions<Input, Results, Context> = {
73
73
  label?: string;
74
74
  meta?: Record<string, any>;
75
75
  };
76
+ type MergeBranchResults<Branches extends readonly any[], Acc> = Branches extends readonly [infer Head, ...infer Tail] ? MergeBranchResults<Tail, Acc & (Head extends WorkflowBuilder<any, any, any, any, infer R> ? R : {})> : Acc;
76
77
  type MergeBranchSteps<Branches extends readonly any[], Acc extends any[]> = Branches extends readonly [infer Head, ...infer Tail] ? MergeBranchSteps<Tail, [
77
78
  ...Acc,
78
79
  ...(Head extends WorkflowBuilder<any, any, any, infer S, any> ? S : [])
79
80
  ]> : Acc;
80
- type MergeBranchResults<Branches extends readonly WorkflowBuilder<any, any, any, any, any>[]> = Simplify<Branches extends readonly [infer Head, ...infer Tail] ? Head extends WorkflowBuilder<any, any, any, any, infer R> ? Tail extends readonly WorkflowBuilder<any, any, any, any, any>[] ? R & MergeBranchResults<Tail> : R : MergeBranchResults<Tail & WorkflowBuilder<any, any, any, any, any>[]> : {}>;
81
81
  export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown, Context = unknown, Steps extends StepDef<Reg, any, any>[] = [], Results = {}, Output = undefined> {
82
82
  private name;
83
83
  private steps;
@@ -106,12 +106,12 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
106
106
  }> : Results : Results, Output>;
107
107
  parallel<Branches extends readonly WorkflowBuilder<Reg, Input, Context, any, any>[]>(...branches: {
108
108
  [K in keyof Branches]: (builder: WorkflowBuilder<Reg, Input, Context, [], Results>) => Branches[K];
109
- }): WorkflowBuilder<Reg, Input, Context, MergeBranchSteps<Branches, Steps>, Results & MergeBranchResults<Branches>>;
110
- join<ID extends string = string, ActionName extends keyof Reg & string = any, ResolveOut extends ResolvedStepInput = ResolvedStepInput, BranchResults = {}>(id: ID, action: ActionName, resolve?: (ctx: {
109
+ }): WorkflowBuilder<Reg, Input, Context, MergeBranchSteps<Branches, Steps>, Simplify<MergeBranchResults<Branches, Results>>>;
110
+ join<ID extends string = string, ActionName extends keyof Reg & string = any, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
111
111
  input: Input;
112
- results: Results & BranchResults;
112
+ results: Results;
113
113
  context: Context;
114
- } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: StepOptions<Input, Results & BranchResults, Context>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K_1 in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; } extends infer T ? { [K in keyof T]: T[K]; } : never, undefined>;
114
+ } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: StepOptions<Input, Results, Context>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K_1 in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; } extends infer T ? { [K in keyof T]: T[K]; } : never, undefined>;
115
115
  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: {
116
116
  input: Input;
117
117
  results: Results;
@@ -120,10 +120,7 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
120
120
  input: Input;
121
121
  results: Results;
122
122
  context: Context;
123
- }) => WorkflowInput<WF>, options?: StepOptions<Input, Results, Context>): WorkflowBuilder<Reg, Input, Context, [
124
- ...Steps,
125
- ...WF["steps"]
126
- ], Results & {
123
+ }) => WorkflowInput<WF>, options?: StepOptions<Input, Results, Context>): WorkflowBuilder<Reg, Input, Context, Steps, Results & {
127
124
  [K in Prefix]: SubflowResult<WorkflowResults<WF>, WorkflowOutput<WF>>;
128
125
  }>;
129
126
  when(predicate: (ctx: {
@@ -552,7 +552,6 @@ export class WorkflowBuilder {
552
552
  });
553
553
  this.frontier = branchEnds;
554
554
  this.clearPendingWhen();
555
- // TypeScript now knows the returned WorkflowBuilder's Results = parent & branch results
556
555
  return this;
557
556
  }
558
557
  /* ------------------------------------------------ */
@@ -644,6 +643,14 @@ export class WorkflowBuilder {
644
643
  /* ------------------------------------------------ */
645
644
  /* WORKFLOW CREATOR */
646
645
  /* ------------------------------------------------ */
646
+ // export function createWorkflow<
647
+ // Reg extends ActionRegistry,
648
+ // Context extends Record<string, any> = {},
649
+ // >(registry: Reg, context?: Context) {
650
+ // return function workflow<Input = unknown>(name: string) {
651
+ // return new WorkflowBuilder<Reg, Input, Context>(name);
652
+ // };
653
+ // }
647
654
  export function createWorkflow() {
648
655
  return function workflow(name) {
649
656
  return new WorkflowBuilder(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pogodisco/zephyr",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },