@pogodisco/zephyr 1.3.18 → 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,12 +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
- type WorkflowBuilderStatic<Reg extends ActionRegistry, Input, Context, Steps extends StepDef<Reg, any, any>[] = [], Results = {}, Output = undefined> = WorkflowBuilder<Reg, Input, Context, Steps, Results, Output>;
82
81
  export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown, Context = unknown, Steps extends StepDef<Reg, any, any>[] = [], Results = {}, Output = undefined> {
83
82
  private name;
84
83
  private steps;
@@ -105,14 +104,14 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
105
104
  as<NewType>(): WorkflowBuilder<Reg, Input, Context, Steps, Steps extends [...infer Rest, infer Last] ? Last extends StepDef<Reg, infer ID, any> ? Simplify<Omit<Results, ID> & {
106
105
  [K in ID]: NewType;
107
106
  }> : Results : Results, Output>;
108
- parallel<Branches extends readonly WorkflowBuilderStatic<Reg, Input, Context, any, any>[]>(...branches: {
109
- [K in keyof Branches]: (builder: WorkflowBuilderStatic<Reg, Input, Context, [], Results>) => Branches[K];
110
- }): WorkflowBuilder<Reg, Input, Context, MergeBranchSteps<Branches, Steps>, Results & MergeBranchResults<Branches>>;
111
- join<ID extends string = string, ActionName extends keyof Reg & string = any, ResolveOut extends ResolvedStepInput = ResolvedStepInput, BranchResults = {}>(id: ID, action: ActionName, resolve?: (ctx: {
107
+ parallel<Branches extends readonly WorkflowBuilder<Reg, Input, Context, any, any>[]>(...branches: {
108
+ [K in keyof Branches]: (builder: WorkflowBuilder<Reg, Input, Context, [], Results>) => Branches[K];
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: {
112
111
  input: Input;
113
- results: Results & BranchResults;
112
+ results: Results;
114
113
  context: Context;
115
- } & 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>;
116
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: {
117
116
  input: Input;
118
117
  results: Results;
@@ -121,10 +120,7 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
121
120
  input: Input;
122
121
  results: Results;
123
122
  context: Context;
124
- }) => WorkflowInput<WF>, options?: StepOptions<Input, Results, Context>): WorkflowBuilder<Reg, Input, Context, [
125
- ...Steps,
126
- ...WF["steps"]
127
- ], Results & {
123
+ }) => WorkflowInput<WF>, options?: StepOptions<Input, Results, Context>): WorkflowBuilder<Reg, Input, Context, Steps, Results & {
128
124
  [K in Prefix]: SubflowResult<WorkflowResults<WF>, WorkflowOutput<WF>>;
129
125
  }>;
130
126
  when(predicate: (ctx: {
@@ -503,6 +503,9 @@
503
503
  //
504
504
  //
505
505
  //
506
+ /* ------------------------------------------------ */
507
+ /* FLUENT WORKFLOW BUILDER */
508
+ /* ------------------------------------------------ */
506
509
  export class WorkflowBuilder {
507
510
  clearPendingWhen() {
508
511
  this.pendingWhen = undefined;
@@ -549,7 +552,6 @@ export class WorkflowBuilder {
549
552
  });
550
553
  this.frontier = branchEnds;
551
554
  this.clearPendingWhen();
552
- // TypeScript now knows the returned WorkflowBuilder's Results = parent & branch results
553
555
  return this;
554
556
  }
555
557
  /* ------------------------------------------------ */
@@ -641,6 +643,14 @@ export class WorkflowBuilder {
641
643
  /* ------------------------------------------------ */
642
644
  /* WORKFLOW CREATOR */
643
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
+ // }
644
654
  export function createWorkflow() {
645
655
  return function workflow(name) {
646
656
  return new WorkflowBuilder(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pogodisco/zephyr",
3
- "version": "1.3.18",
3
+ "version": "1.3.19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },