@pogodisco/zephyr 1.3.1 → 1.3.3

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/types.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { createWorkflow } from "./workflow-composer.js";
2
2
  export type Action<F extends (...args: any[]) => any = (...args: any[]) => any> = F;
3
- export interface ActionRegistry {
4
- [key: string]: Action;
5
- }
3
+ export type ActionRegistry = Record<string, (...args: any[]) => any>;
6
4
  export type MergeActionRegistries<A extends ActionRegistry, B extends ActionRegistry> = Omit<A, keyof B> & B;
7
5
  export type ExecutionFrame = {
8
6
  stepId: string;
@@ -13,8 +11,8 @@ export type ExecutionFrame = {
13
11
  output?: any;
14
12
  error?: any;
15
13
  };
16
- export type ActionParams<Reg extends ActionRegistry, K extends keyof Reg> = Parameters<Reg[K]>;
17
- export type ActionReturn<Reg extends ActionRegistry, K extends keyof Reg> = Awaited<ReturnType<Reg[K]>>;
14
+ export type ActionParams<Reg, K extends keyof Reg> = Reg[K] extends (...args: infer P) => any ? P : never;
15
+ export type ActionReturn<Reg, K extends keyof Reg> = Reg[K] extends (...args: any[]) => infer R ? Awaited<R> : never;
18
16
  export type WorkflowMiddleware<Reg extends ActionRegistry = any> = {
19
17
  (ctx: {
20
18
  stepId: string;
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  type AnyFn = (...args: any[]) => any;
2
2
  /**
3
- * For generic actions where you want to specify the return type
4
- * Just a type helper, does nothing at runtime
3
+ * For generic actions - preserves the generic parameter
5
4
  */
6
- export declare function genericAction<F extends AnyFn>(fn: F): <T = ReturnType<F>>() => ((...args: Parameters<F>) => T);
5
+ export declare function genericAction<F extends AnyFn>(fn: F): <T>() => ((...args: Parameters<F>) => ReturnType<F>);
7
6
  /**
8
- * For fixed actions - just returns the function
9
- * The type parameter T is for convenience when you want to override the return type
7
+ * For fixed actions
10
8
  */
11
- export declare function fixedAction<F extends AnyFn>(fn: F): <T = ReturnType<F>>() => ((...args: Parameters<F>) => T);
9
+ export declare function fixedAction<F extends AnyFn>(fn: F): () => ((...args: Parameters<F>) => ReturnType<F>);
12
10
  export {};
package/dist/utils.js CHANGED
@@ -40,16 +40,19 @@
40
40
  // }
41
41
  //
42
42
  /**
43
- * For generic actions where you want to specify the return type
44
- * Just a type helper, does nothing at runtime
43
+ * For generic actions - preserves the generic parameter
45
44
  */
46
45
  export function genericAction(fn) {
47
- return () => fn;
46
+ // Return a function that takes a type parameter and returns the typed function
47
+ return () => {
48
+ return fn;
49
+ };
48
50
  }
49
51
  /**
50
- * For fixed actions - just returns the function
51
- * The type parameter T is for convenience when you want to override the return type
52
+ * For fixed actions
52
53
  */
53
54
  export function fixedAction(fn) {
54
- return () => fn;
55
+ return () => {
56
+ return fn;
57
+ };
55
58
  }
@@ -49,7 +49,7 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
49
49
  input: Input;
50
50
  results: Results;
51
51
  context: Context;
52
- }) => ActionParams<Reg, ActionName>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: Awaited<ReturnType<Reg[ActionName]>>; }, undefined>;
52
+ }) => ActionParams<Reg, ActionName>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: ActionReturn<Reg, ActionName>; }, undefined>;
53
53
  parallel<Branches extends WorkflowBuilder<Reg, Input, Context, any, any>[]>(...branches: {
54
54
  [K in keyof Branches]: (builder: WorkflowBuilder<Reg, Input, Context, [], Results>) => Branches[K];
55
55
  }): WorkflowBuilder<Reg, Input, Context, [
@@ -62,7 +62,7 @@ export declare class WorkflowBuilder<Reg extends ActionRegistry, Input = unknown
62
62
  }) => undefined : (ctx: {
63
63
  input: Input;
64
64
  results: Results;
65
- }) => ActionParams<Reg, ActionName>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: Awaited<ReturnType<Reg[ActionName]>>; }, undefined>;
65
+ }) => ActionParams<Reg, ActionName>): WorkflowBuilder<Reg, Input, Context, [...Steps, StepDef<Reg, ID, ActionName>], Results & { [K in ID]: ActionReturn<Reg, ActionName>; }, undefined>;
66
66
  subflow<Prefix extends string, SubInput, SubResults, SubSteps extends StepDef<Reg, any, any>[], SubOutput>(prefix: Prefix, workflow: WorkflowDef<Reg, SubInput, SubResults, SubSteps, SubOutput>, resolveInput?: (ctx: {
67
67
  input: Input;
68
68
  results: Results;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pogodisco/zephyr",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },