@pogodisco/zephyr 1.3.13 → 1.3.14
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/registry.d.ts +6 -5
- package/dist/registry.js +17 -4
- package/dist/workflow-module.d.ts +0 -4
- package/dist/workflow-module.js +1 -1
- package/package.json +1 -1
package/dist/registry.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ActionRegistry, MergeActionRegistries } from "./types.js";
|
|
2
|
-
export declare class ActionRegistryBuilder<R extends ActionRegistry = {}> {
|
|
2
|
+
export declare class ActionRegistryBuilder<R extends ActionRegistry = {}, Prefix extends string = ""> {
|
|
3
|
+
private prefix;
|
|
3
4
|
private registry;
|
|
4
|
-
constructor(initial?: R);
|
|
5
|
+
constructor(prefix: Prefix, initial?: R);
|
|
5
6
|
/**
|
|
6
7
|
* Accepts ANY function - sync or async, any parameter shape
|
|
7
8
|
* F captures the complete function signature for full type inference
|
|
8
9
|
*/
|
|
9
|
-
action<K extends string, F extends (...args: any[]) => any>(key: K, action: F): ActionRegistryBuilder<MergeActionRegistries<R, Record
|
|
10
|
-
extend<Other extends ActionRegistry>(other: ActionRegistryBuilder<Other> | Other): ActionRegistryBuilder<MergeActionRegistries<R, Other
|
|
10
|
+
action<K extends string, F extends (...args: any[]) => any>(key: K, action: F): ActionRegistryBuilder<MergeActionRegistries<R, Record<`${Prefix}${K}`, F>>, Prefix>;
|
|
11
|
+
extend<Other extends ActionRegistry>(other: ActionRegistryBuilder<Other, any> | Other): ActionRegistryBuilder<MergeActionRegistries<R, Other>, Prefix>;
|
|
11
12
|
build(): R;
|
|
12
13
|
}
|
|
13
|
-
export declare function createActionRegistry<R extends ActionRegistry = {}>(initial?: R): ActionRegistryBuilder<R>;
|
|
14
|
+
export declare function createActionRegistry<R extends ActionRegistry = {}, Prefix extends string = "">(prefix: Prefix, initial?: R): ActionRegistryBuilder<R, Prefix>;
|
package/dist/registry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class ActionRegistryBuilder {
|
|
2
|
-
constructor(initial) {
|
|
2
|
+
constructor(prefix, initial) {
|
|
3
|
+
this.prefix = prefix;
|
|
3
4
|
this.registry = {};
|
|
4
5
|
if (initial) {
|
|
5
6
|
this.registry = { ...initial };
|
|
@@ -10,12 +11,21 @@ export class ActionRegistryBuilder {
|
|
|
10
11
|
* F captures the complete function signature for full type inference
|
|
11
12
|
*/
|
|
12
13
|
action(key, action) {
|
|
13
|
-
this.
|
|
14
|
+
const fullKey = `${this.prefix}${key}`;
|
|
15
|
+
if (fullKey in this.registry) {
|
|
16
|
+
throw new Error(`Action "${fullKey}" already exists`);
|
|
17
|
+
}
|
|
18
|
+
this.registry[fullKey] = action;
|
|
14
19
|
return this;
|
|
15
20
|
}
|
|
16
21
|
// Extend with another registry (with override)
|
|
17
22
|
extend(other) {
|
|
18
23
|
const otherRegistry = other instanceof ActionRegistryBuilder ? other.build() : other;
|
|
24
|
+
for (const key in otherRegistry) {
|
|
25
|
+
if (key in this.registry) {
|
|
26
|
+
throw new Error(`Action collision detected "${key}"`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
Object.assign(this.registry, otherRegistry);
|
|
20
30
|
return this;
|
|
21
31
|
}
|
|
@@ -23,6 +33,9 @@ export class ActionRegistryBuilder {
|
|
|
23
33
|
return this.registry;
|
|
24
34
|
}
|
|
25
35
|
}
|
|
26
|
-
export function createActionRegistry(initial) {
|
|
27
|
-
|
|
36
|
+
export function createActionRegistry(prefix, initial) {
|
|
37
|
+
if (!prefix || typeof prefix !== "string" || prefix?.trim() === "") {
|
|
38
|
+
throw new Error(`Registry prefix is required`);
|
|
39
|
+
}
|
|
40
|
+
return new ActionRegistryBuilder(prefix, initial);
|
|
28
41
|
}
|
|
@@ -38,10 +38,6 @@ export type ModuleContext<Reg extends ActionRegistry, Context extends Record<str
|
|
|
38
38
|
context: Context;
|
|
39
39
|
}) => T) => T;
|
|
40
40
|
};
|
|
41
|
-
export declare function createModule<Reg extends ActionRegistry, Context extends Record<string, any>, Use extends ModuleMap<Reg>, Own extends ModuleShape>(config: {
|
|
42
|
-
use?: Use;
|
|
43
|
-
define: (ctx: ModuleContext<Reg, Context, Use>) => Own;
|
|
44
|
-
}): Module<Reg, Context, Own, Use>;
|
|
45
41
|
export declare function createModuleFactory<Reg extends ActionRegistry, Context extends Record<string, any>>(): <Use extends ModuleMap<Reg> = {}, Own extends ModuleShape = {}>(config: {
|
|
46
42
|
use?: Use;
|
|
47
43
|
define: (ctx: ModuleContext<Reg, Context, Use>) => Own;
|
package/dist/workflow-module.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createWorkflow } from "./workflow-composer.js";
|
|
2
2
|
import { executeWorkflow } from "./workflow-executor.js";
|
|
3
|
-
|
|
3
|
+
function createModule(config) {
|
|
4
4
|
const wf = createWorkflow();
|
|
5
5
|
const deps = (config.use ?? {});
|
|
6
6
|
const moduleCtx = {
|