@pogodisco/zephyr 1.3.6 → 1.3.7

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/index.d.ts CHANGED
@@ -6,6 +6,5 @@ export * from "./workflow-module.js";
6
6
  export * from "./utils.js";
7
7
  export * from "./types.js";
8
8
  export * from "./utils.js";
9
- export * from "./node/index.js";
10
9
  export * from "./session.js";
11
10
  export { useMetrics, useLog } from "./observer.js";
package/dist/index.js CHANGED
@@ -6,6 +6,5 @@ export * from "./workflow-module.js";
6
6
  export * from "./utils.js";
7
7
  export * from "./types.js";
8
8
  export * from "./utils.js";
9
- export * from "./node/index.js";
10
9
  export * from "./session.js";
11
10
  export { useMetrics, useLog } from "./observer.js";
@@ -1,4 +1,10 @@
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;
2
8
  type NormalizedCall = {
3
9
  kind: "none";
4
10
  } | {
@@ -72,17 +78,17 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
72
78
  input: Input;
73
79
  results: Results;
74
80
  context: Context;
75
- } & CallHelpers<Reg, ActionName>) => ResolveOut, dependsOn?: string[], options?: {}): WorkflowBuilder<Reg, Input, Context, [
81
+ } & CallHelpers<Reg, ActionName>) => ResolveOut, dependsOn?: string[], options?: {}): StepBuilderResult<WorkflowBuilder<Reg, Input, Context, [
76
82
  ...Steps,
77
83
  StepDef<Reg, ID, ActionName>
78
84
  ], Results & {
79
85
  [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>;
80
- }>;
86
+ }, Output>, ID, StepResultFromResolve<Reg, ActionName, ResolveOut>>;
81
87
  seq<ID extends string, ActionName extends keyof Reg & string, ResolveOut extends ResolvedStepInput = ResolvedStepInput>(id: ID, action: ActionName, resolve?: (ctx: {
82
88
  input: Input;
83
89
  results: Results;
84
90
  context: Context;
85
- } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, undefined>;
91
+ } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): StepBuilderResult<WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, Output>, ID, StepResultFromResolve<Reg, ActionName, ResolveOut>>;
86
92
  parallel<Branches extends WorkflowBuilder<Reg, Input, Context, any, any>[]>(...branches: {
87
93
  [K in keyof Branches]: (builder: WorkflowBuilder<Reg, Input, Context, [], Results>) => Branches[K];
88
94
  }): WorkflowBuilder<Reg, Input, Context, [
@@ -93,7 +99,7 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
93
99
  input: Input;
94
100
  results: Results;
95
101
  context: Context;
96
- } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, undefined>;
102
+ } & CallHelpers<Reg, ActionName>) => ResolveOut, options?: {}): StepBuilderResult<WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut>; }, Output>, ID, StepResultFromResolve<Reg, ActionName, ResolveOut>>;
97
103
  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: {
98
104
  input: Input;
99
105
  results: Results;
@@ -376,6 +376,47 @@ export class WorkflowBuilder {
376
376
  /* ------------------------------------------------ */
377
377
  /* Base Step */
378
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 & { [K in ID]: StepResultFromResolve<Reg, ActionName, ResolveOut> }
401
+ // > {
402
+ // const deps = dependsOn ?? [...this.frontier];
403
+ //
404
+ // this.steps.push({
405
+ // id,
406
+ // action,
407
+ // resolve: resolve ?? (() => ({ kind: "none" })),
408
+ // dependsOn: deps,
409
+ // });
410
+ //
411
+ // this.frontier = [id];
412
+ //
413
+ // // with Override
414
+ //
415
+ // return this as any;
416
+ // }
417
+ /* ------------------------------------------------ */
418
+ /* Base Step */
419
+ /* ------------------------------------------------ */
379
420
  step(id, action, resolve, dependsOn, options) {
380
421
  const deps = dependsOn ?? [...this.frontier];
381
422
  this.steps.push({
@@ -385,7 +426,13 @@ export class WorkflowBuilder {
385
426
  dependsOn: deps,
386
427
  });
387
428
  this.frontier = [id];
388
- return this;
429
+ // with Override
430
+ const next = this;
431
+ next.as = () => {
432
+ return next;
433
+ };
434
+ return next;
435
+ // return this as any;
389
436
  }
390
437
  /* ------------------------------------------------ */
391
438
  /* Sequential shortcut */
@@ -418,60 +465,6 @@ export class WorkflowBuilder {
418
465
  /* ------------------------------------------------ */
419
466
  /* Subflow */
420
467
  /* ------------------------------------------------ */
421
- // subflow<
422
- // Prefix extends string,
423
- // SubInput,
424
- // SubResults,
425
- // SubSteps extends StepDef<Reg, any, any>[],
426
- // SubOutput,
427
- // >(
428
- // prefix: Prefix,
429
- // workflow: WorkflowDef<Reg, SubInput, SubResults, SubSteps, SubOutput>,
430
- // resolveInput?: (ctx: {
431
- // input: Input;
432
- // results: Results;
433
- // context: Context;
434
- // }) => SubInput,
435
- // options?: { loop?: boolean },
436
- // ): WorkflowBuilder<
437
- // Reg,
438
- // Input,
439
- // Context,
440
- // [...Steps, ...SubSteps],
441
- // Results & { [K in Prefix]: SubflowResult<SubResults, SubOutput> }
442
- // > {
443
- // const idMap = new Map<string, string>();
444
- //
445
- // workflow.steps.forEach((step) => {
446
- // idMap.set(step.id, `${prefix}.${step.id}`);
447
- // });
448
- //
449
- // workflow.steps.forEach((step) => {
450
- // const newStep: StepDef<Reg, any, any> = {
451
- // ...step,
452
- // id: idMap.get(step.id)!,
453
- // dependsOn: step.dependsOn.map((d) => idMap.get(d)!),
454
- // resolve: (ctx: any) => {
455
- // const subInput = resolveInput ? resolveInput(ctx) : undefined;
456
- // return step.resolve({
457
- // input: subInput,
458
- // results: ctx.results,
459
- // context: ctx.context,
460
- // });
461
- // },
462
- // ...(options ? { loop: options.loop ?? step.loop } : {}),
463
- // };
464
- //
465
- // if (workflow.entrySteps.find((e) => e.id === step.id)) {
466
- // newStep.dependsOn = [...this.frontier];
467
- // }
468
- //
469
- // this.steps.push(newStep);
470
- // });
471
- //
472
- // this.frontier = workflow.endSteps.map((e) => idMap.get(e.id)!);
473
- // return this as any;
474
- // }
475
468
  subflow(prefix, workflow, resolveInput, options) {
476
469
  const idMap = new Map();
477
470
  workflow.steps.forEach((step) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pogodisco/zephyr",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },