@pogodisco/zephyr 1.2.5 → 1.2.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/workflow-module.d.ts +13 -2
- package/dist/workflow-module.js +59 -0
- package/package.json +1 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { ActionRegistry } from "./types.js";
|
|
2
|
-
import { createWorkflow } from "./workflow-composer.js";
|
|
2
|
+
import { createWorkflow, WorkflowDef } from "./workflow-composer.js";
|
|
3
3
|
export declare function workflowModule<Reg extends ActionRegistry, Context extends Record<string, any>, Flows extends Record<string, any>>(registry: Reg, context: Context, factory: (wf: ReturnType<typeof createWorkflow<Reg, Context>>) => Flows): {
|
|
4
4
|
wf: <Input = unknown>(name: string) => import("./workflow-composer.js").WorkflowBuilder<Reg, Input, Context, [], {}, undefined>;
|
|
5
5
|
} & Flows & {
|
|
6
|
-
extend<Extra extends Record<string, any>>(overrides:
|
|
6
|
+
extend<Extra extends Record<string, any>>(overrides: Extra): Flows & Extra;
|
|
7
7
|
};
|
|
8
|
+
type AnyWorkflow = WorkflowDef<any, any, any, any, any>;
|
|
9
|
+
type ModuleShape = Record<string, AnyWorkflow>;
|
|
10
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
11
|
+
type UnionToIntersectionOrEmpty<U> = [U] extends [never] ? {} : UnionToIntersection<U>;
|
|
12
|
+
export declare function createModule<Reg extends ActionRegistry, Context extends Record<string, any>, Use extends ModuleShape[] = [], Deps extends ModuleShape = UnionToIntersectionOrEmpty<Use[number]> & ModuleShape, Own extends ModuleShape = {}>({ registry, context, use, define, }: {
|
|
13
|
+
registry: Reg;
|
|
14
|
+
context: Context;
|
|
15
|
+
use?: [...Use];
|
|
16
|
+
define: (wf: ReturnType<typeof createWorkflow<Reg, Context>>, deps: Deps) => Own;
|
|
17
|
+
}): Deps & Own;
|
|
18
|
+
export {};
|
package/dist/workflow-module.js
CHANGED
|
@@ -35,3 +35,62 @@ export function workflowModule(registry, context, factory) {
|
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
export function createModule({ registry, context, use, define, }) {
|
|
39
|
+
const wf = createWorkflow(registry, context);
|
|
40
|
+
const deps = (use ? Object.assign({}, ...use) : {});
|
|
41
|
+
const own = define(wf, deps);
|
|
42
|
+
return {
|
|
43
|
+
...deps,
|
|
44
|
+
...own,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// type MergeFlows<T extends any[]> = T extends [infer F, ...infer R]
|
|
48
|
+
// ? F extends { flows: infer Fl }
|
|
49
|
+
// ? MergeFlows<R> & Fl
|
|
50
|
+
// : MergeFlows<R>
|
|
51
|
+
// : {};
|
|
52
|
+
//
|
|
53
|
+
// type Module<
|
|
54
|
+
// Reg extends ActionRegistry,
|
|
55
|
+
// Context extends Record<string, any>,
|
|
56
|
+
// Flows,
|
|
57
|
+
// > = {
|
|
58
|
+
// wf: ReturnType<typeof createWorkflow<Reg, Context>>;
|
|
59
|
+
// flows: Flows;
|
|
60
|
+
// };
|
|
61
|
+
//
|
|
62
|
+
// export function createModule<
|
|
63
|
+
// Reg extends ActionRegistry,
|
|
64
|
+
// Context extends Record<string, any>,
|
|
65
|
+
// Flows extends Record<string, any>,
|
|
66
|
+
// UseModules extends Module<any, any, any>[] = [],
|
|
67
|
+
// >({
|
|
68
|
+
// registry,
|
|
69
|
+
// context,
|
|
70
|
+
// use = [] as unknown as UseModules,
|
|
71
|
+
// define,
|
|
72
|
+
// }: {
|
|
73
|
+
// registry: Reg;
|
|
74
|
+
// context: Context;
|
|
75
|
+
// use?: UseModules;
|
|
76
|
+
// define?: (
|
|
77
|
+
// wf: ReturnType<typeof createWorkflow<Reg, Context>>,
|
|
78
|
+
// deps: MergeFlows<UseModules>,
|
|
79
|
+
// ) => Flows;
|
|
80
|
+
// }) {
|
|
81
|
+
// const wf = createWorkflow(registry, context);
|
|
82
|
+
//
|
|
83
|
+
// const inherited = Object.assign({}, ...use.map((m) => m.flows));
|
|
84
|
+
// const own = define ? define(wf, inherited as MergeFlows<UseModules>) : {};
|
|
85
|
+
//
|
|
86
|
+
// const flows = {
|
|
87
|
+
// ...inherited,
|
|
88
|
+
// ...own,
|
|
89
|
+
// };
|
|
90
|
+
//
|
|
91
|
+
// return {
|
|
92
|
+
// wf,
|
|
93
|
+
// flows,
|
|
94
|
+
// ...flows,
|
|
95
|
+
// } as Module<Reg, Context, typeof flows>;
|
|
96
|
+
// }
|