@directive-run/core 0.8.8 → 1.0.0

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.
Files changed (53) hide show
  1. package/dist/adapter-utils.d.cts +1 -1
  2. package/dist/adapter-utils.d.ts +1 -1
  3. package/dist/chunk-3H24Z7WM.cjs +16 -0
  4. package/dist/chunk-3H24Z7WM.cjs.map +1 -0
  5. package/dist/chunk-AUSBUCOL.cjs +3 -0
  6. package/dist/chunk-AUSBUCOL.cjs.map +1 -0
  7. package/dist/chunk-MPOV2REO.js +16 -0
  8. package/dist/chunk-MPOV2REO.js.map +1 -0
  9. package/dist/chunk-YWKFNZQV.js +3 -0
  10. package/dist/chunk-YWKFNZQV.js.map +1 -0
  11. package/dist/{helpers-50q7yhA9.d.ts → helpers-Bd_P3ZTY.d.ts} +54 -2
  12. package/dist/{helpers-B6SkcKCD.d.cts → helpers-CU3Il0tz.d.cts} +54 -2
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +16 -13
  16. package/dist/index.d.ts +16 -13
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/internals.cjs +1 -1
  20. package/dist/internals.d.cts +7 -38
  21. package/dist/internals.d.ts +7 -38
  22. package/dist/internals.js +1 -1
  23. package/dist/plugins/index.cjs +2 -2
  24. package/dist/plugins/index.cjs.map +1 -1
  25. package/dist/plugins/index.d.cts +1 -1
  26. package/dist/plugins/index.d.ts +1 -1
  27. package/dist/plugins/index.js +2 -2
  28. package/dist/plugins/index.js.map +1 -1
  29. package/dist/{plugins-Bg_oq2sO.d.cts → plugins-O-3VHejK.d.cts} +148 -6
  30. package/dist/{plugins-Bg_oq2sO.d.ts → plugins-O-3VHejK.d.ts} +148 -6
  31. package/dist/system-AGVKMAYF.js +2 -0
  32. package/dist/{system-3H5V4HJZ.js.map → system-AGVKMAYF.js.map} +1 -1
  33. package/dist/system-QQYBNE7A.cjs +2 -0
  34. package/dist/{system-IJKVTF3C.cjs.map → system-QQYBNE7A.cjs.map} +1 -1
  35. package/dist/testing.cjs +1 -1
  36. package/dist/testing.d.cts +1 -1
  37. package/dist/testing.d.ts +1 -1
  38. package/dist/testing.js +1 -1
  39. package/dist/worker.cjs +1 -1
  40. package/dist/worker.d.cts +1 -1
  41. package/dist/worker.d.ts +1 -1
  42. package/dist/worker.js +1 -1
  43. package/package.json +1 -1
  44. package/dist/chunk-CFSW3RP5.cjs +0 -16
  45. package/dist/chunk-CFSW3RP5.cjs.map +0 -1
  46. package/dist/chunk-ISYFVEHR.js +0 -3
  47. package/dist/chunk-ISYFVEHR.js.map +0 -1
  48. package/dist/chunk-L3SUAAPM.cjs +0 -3
  49. package/dist/chunk-L3SUAAPM.cjs.map +0 -1
  50. package/dist/chunk-LB6PNML4.js +0 -16
  51. package/dist/chunk-LB6PNML4.js.map +0 -1
  52. package/dist/system-3H5V4HJZ.js +0 -2
  53. package/dist/system-IJKVTF3C.cjs +0 -2
package/dist/index.d.cts CHANGED
@@ -1,17 +1,8 @@
1
- import { S as SchemaType, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-Bg_oq2sO.cjs';
2
- export { A as AnySystem, B as BatchConfig, D as DirectiveError, q as DistributableSnapshot, r as DistributableSnapshotOptions, s as DynamicConstraintDef, t as DynamicEffectDef, u as DynamicResolverDef, v as FactsSnapshot, H as HistoryAPI, w as HistoryOption, x as HistoryState, I as InferDerivations, y as InferEvents, z as InferFacts, G as InferRequirementTypes, J as InferRequirements, K as InferSchemaType, L as InferSelectorState, O as RetryPolicy, Q as Schema, U as Snapshot, V as System, W as SystemConfig, X as SystemInspection, Y as SystemMode, Z as SystemSnapshot, _ as TraceEntry, $ as isNamespacedSystem, a0 as isSingleModuleSystem } from './plugins-Bg_oq2sO.cjs';
3
- export { t as typedConstraint, a as typedResolver } from './helpers-B6SkcKCD.cjs';
1
+ import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-O-3VHejK.cjs';
2
+ export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as RetryPolicy, W as Schema, X as Snapshot, Y as System, Z as SystemConfig, _ as SystemInspection, $ as SystemMode, a0 as SystemSnapshot, a1 as TraceEntry, a2 as isNamespacedSystem, a3 as isSingleModuleSystem } from './plugins-O-3VHejK.cjs';
3
+ export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-CU3Il0tz.cjs';
4
4
  export { D as DistributableSnapshotLike, S as SignedSnapshot, a as SnapshotDiff, b as SnapshotDiffEntry, d as diffSnapshots, i as isSignedSnapshot, c as isSnapshotExpired, s as shallowEqual, e as signSnapshot, v as validateSnapshot, f as verifySnapshotSignature } from './utils-BnQajqPu.cjs';
5
5
 
6
- /**
7
- * Schema Type Builders
8
- *
9
- * Provides type-safe schema definitions with optional runtime validation.
10
- * Used to define fact types, derivation types, event payload types, etc.
11
- *
12
- * This module has no dependency on the facts store or tracking system.
13
- */
14
-
15
6
  /** Brand symbol for branded types */
16
7
  declare const Brand: unique symbol;
17
8
  /** Branded type - adds a unique brand to a base type */
@@ -30,6 +21,8 @@ interface ExtendedSchemaType<T> extends SchemaType<T> {
30
21
  }>;
31
22
  /** Mutable - set by array validators to indicate which element failed */
32
23
  _lastFailedIndex?: number;
24
+ /** Optional metadata for debugging and devtools (never read on hot path). */
25
+ readonly _meta?: DefinitionMeta;
33
26
  }
34
27
  /** Chainable schema type with all common methods */
35
28
  interface ChainableSchemaType<T> extends ExtendedSchemaType<T> {
@@ -40,6 +33,8 @@ interface ChainableSchemaType<T> extends ExtendedSchemaType<T> {
40
33
  refine(predicate: (value: T) => boolean, message: string): ChainableSchemaType<T>;
41
34
  nullable(): ChainableSchemaType<T | null>;
42
35
  optional(): ChainableSchemaType<T | undefined>;
36
+ /** Attach metadata for debugging and devtools. */
37
+ meta(meta: DefinitionMeta): ChainableSchemaType<T>;
43
38
  }
44
39
  /**
45
40
  * Schema type builders for defining fact types.
@@ -90,6 +85,7 @@ declare const t: {
90
85
  minLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
91
86
  maxLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
92
87
  pattern(regex: RegExp): ChainableSchemaType<T> & /*elided*/ any;
88
+ meta(m: DefinitionMeta): ChainableSchemaType<T> & /*elided*/ any;
93
89
  };
94
90
  /**
95
91
  * Create a number schema type with optional min/max constraints.
@@ -115,6 +111,7 @@ declare const t: {
115
111
  number(): ChainableSchemaType<number> & {
116
112
  min(n: number): ChainableSchemaType<number> & /*elided*/ any;
117
113
  max(n: number): ChainableSchemaType<number> & /*elided*/ any;
114
+ meta(m: DefinitionMeta): ChainableSchemaType<number> & /*elided*/ any;
118
115
  };
119
116
  /**
120
117
  * Create a boolean schema type.
@@ -139,6 +136,7 @@ declare const t: {
139
136
  nonEmpty(): ChainableSchemaType<T[]> & /*elided*/ any;
140
137
  maxLength(n: number): ChainableSchemaType<T[]> & /*elided*/ any;
141
138
  minLength(n: number): ChainableSchemaType<T[]> & /*elided*/ any;
139
+ meta(m: DefinitionMeta): ChainableSchemaType<T[]> & /*elided*/ any;
142
140
  _lastFailedIndex?: number;
143
141
  };
144
142
  /**
@@ -153,6 +151,7 @@ declare const t: {
153
151
  shape(schema: { [K in keyof T]?: SchemaType<T[K]>; }): ChainableSchemaType<T> & /*elided*/ any;
154
152
  nonNull(): ChainableSchemaType<T> & /*elided*/ any;
155
153
  hasKeys(...keys: string[]): ChainableSchemaType<T> & /*elided*/ any;
154
+ meta(m: DefinitionMeta): ChainableSchemaType<T> & /*elided*/ any;
156
155
  };
157
156
  /**
158
157
  * Create an enum schema type for string literal unions.
@@ -333,6 +332,8 @@ interface ModuleConfig<M extends ModuleSchema> {
333
332
  constraints?: TypedConstraintsDef<M>;
334
333
  resolvers?: TypedResolversDef<M>;
335
334
  hooks?: ModuleHooks<M>;
335
+ /** Optional metadata for debugging and devtools (never read on hot path). */
336
+ meta?: DefinitionMeta;
336
337
  /** History configuration — controls which events create snapshots for undo/redo. */
337
338
  history?: {
338
339
  /** Events that create history snapshots. Omit to snapshot all events. */
@@ -407,6 +408,8 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
407
408
  /** Resolvers. Uses flat access (`ctx.facts.myFact`) to keep async mutations scoped to own module. */
408
409
  resolvers?: TypedResolversDef<M>;
409
410
  hooks?: ModuleHooks<M>;
411
+ /** Optional metadata for debugging and devtools (never read on hot path). */
412
+ meta?: DefinitionMeta;
410
413
  /** History configuration — controls which events create snapshots for undo/redo. */
411
414
  history?: {
412
415
  /** Events that create history snapshots. Omit to snapshot all events. */
@@ -954,4 +957,4 @@ declare const Backoff: {
954
957
  readonly Exponential: "exponential";
955
958
  };
956
959
 
957
- export { Backoff, type Branded, type ChainableSchemaType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleDeps, ErrorBoundaryConfig, type ExtendedSchemaType, Facts, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaType, SingleModuleSystem, TraceOption, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, isRequirementType, req, t };
960
+ export { Backoff, type Branded, type ChainableSchemaType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleDeps, DefinitionMeta, ErrorBoundaryConfig, type ExtendedSchemaType, Facts, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaType, SingleModuleSystem, TraceOption, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, isRequirementType, req, t };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,8 @@
1
- import { S as SchemaType, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-Bg_oq2sO.js';
2
- export { A as AnySystem, B as BatchConfig, D as DirectiveError, q as DistributableSnapshot, r as DistributableSnapshotOptions, s as DynamicConstraintDef, t as DynamicEffectDef, u as DynamicResolverDef, v as FactsSnapshot, H as HistoryAPI, w as HistoryOption, x as HistoryState, I as InferDerivations, y as InferEvents, z as InferFacts, G as InferRequirementTypes, J as InferRequirements, K as InferSchemaType, L as InferSelectorState, O as RetryPolicy, Q as Schema, U as Snapshot, V as System, W as SystemConfig, X as SystemInspection, Y as SystemMode, Z as SystemSnapshot, _ as TraceEntry, $ as isNamespacedSystem, a0 as isSingleModuleSystem } from './plugins-Bg_oq2sO.js';
3
- export { t as typedConstraint, a as typedResolver } from './helpers-50q7yhA9.js';
1
+ import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-O-3VHejK.js';
2
+ export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as RetryPolicy, W as Schema, X as Snapshot, Y as System, Z as SystemConfig, _ as SystemInspection, $ as SystemMode, a0 as SystemSnapshot, a1 as TraceEntry, a2 as isNamespacedSystem, a3 as isSingleModuleSystem } from './plugins-O-3VHejK.js';
3
+ export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-Bd_P3ZTY.js';
4
4
  export { D as DistributableSnapshotLike, S as SignedSnapshot, a as SnapshotDiff, b as SnapshotDiffEntry, d as diffSnapshots, i as isSignedSnapshot, c as isSnapshotExpired, s as shallowEqual, e as signSnapshot, v as validateSnapshot, f as verifySnapshotSignature } from './utils-BnQajqPu.js';
5
5
 
6
- /**
7
- * Schema Type Builders
8
- *
9
- * Provides type-safe schema definitions with optional runtime validation.
10
- * Used to define fact types, derivation types, event payload types, etc.
11
- *
12
- * This module has no dependency on the facts store or tracking system.
13
- */
14
-
15
6
  /** Brand symbol for branded types */
16
7
  declare const Brand: unique symbol;
17
8
  /** Branded type - adds a unique brand to a base type */
@@ -30,6 +21,8 @@ interface ExtendedSchemaType<T> extends SchemaType<T> {
30
21
  }>;
31
22
  /** Mutable - set by array validators to indicate which element failed */
32
23
  _lastFailedIndex?: number;
24
+ /** Optional metadata for debugging and devtools (never read on hot path). */
25
+ readonly _meta?: DefinitionMeta;
33
26
  }
34
27
  /** Chainable schema type with all common methods */
35
28
  interface ChainableSchemaType<T> extends ExtendedSchemaType<T> {
@@ -40,6 +33,8 @@ interface ChainableSchemaType<T> extends ExtendedSchemaType<T> {
40
33
  refine(predicate: (value: T) => boolean, message: string): ChainableSchemaType<T>;
41
34
  nullable(): ChainableSchemaType<T | null>;
42
35
  optional(): ChainableSchemaType<T | undefined>;
36
+ /** Attach metadata for debugging and devtools. */
37
+ meta(meta: DefinitionMeta): ChainableSchemaType<T>;
43
38
  }
44
39
  /**
45
40
  * Schema type builders for defining fact types.
@@ -90,6 +85,7 @@ declare const t: {
90
85
  minLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
91
86
  maxLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
92
87
  pattern(regex: RegExp): ChainableSchemaType<T> & /*elided*/ any;
88
+ meta(m: DefinitionMeta): ChainableSchemaType<T> & /*elided*/ any;
93
89
  };
94
90
  /**
95
91
  * Create a number schema type with optional min/max constraints.
@@ -115,6 +111,7 @@ declare const t: {
115
111
  number(): ChainableSchemaType<number> & {
116
112
  min(n: number): ChainableSchemaType<number> & /*elided*/ any;
117
113
  max(n: number): ChainableSchemaType<number> & /*elided*/ any;
114
+ meta(m: DefinitionMeta): ChainableSchemaType<number> & /*elided*/ any;
118
115
  };
119
116
  /**
120
117
  * Create a boolean schema type.
@@ -139,6 +136,7 @@ declare const t: {
139
136
  nonEmpty(): ChainableSchemaType<T[]> & /*elided*/ any;
140
137
  maxLength(n: number): ChainableSchemaType<T[]> & /*elided*/ any;
141
138
  minLength(n: number): ChainableSchemaType<T[]> & /*elided*/ any;
139
+ meta(m: DefinitionMeta): ChainableSchemaType<T[]> & /*elided*/ any;
142
140
  _lastFailedIndex?: number;
143
141
  };
144
142
  /**
@@ -153,6 +151,7 @@ declare const t: {
153
151
  shape(schema: { [K in keyof T]?: SchemaType<T[K]>; }): ChainableSchemaType<T> & /*elided*/ any;
154
152
  nonNull(): ChainableSchemaType<T> & /*elided*/ any;
155
153
  hasKeys(...keys: string[]): ChainableSchemaType<T> & /*elided*/ any;
154
+ meta(m: DefinitionMeta): ChainableSchemaType<T> & /*elided*/ any;
156
155
  };
157
156
  /**
158
157
  * Create an enum schema type for string literal unions.
@@ -333,6 +332,8 @@ interface ModuleConfig<M extends ModuleSchema> {
333
332
  constraints?: TypedConstraintsDef<M>;
334
333
  resolvers?: TypedResolversDef<M>;
335
334
  hooks?: ModuleHooks<M>;
335
+ /** Optional metadata for debugging and devtools (never read on hot path). */
336
+ meta?: DefinitionMeta;
336
337
  /** History configuration — controls which events create snapshots for undo/redo. */
337
338
  history?: {
338
339
  /** Events that create history snapshots. Omit to snapshot all events. */
@@ -407,6 +408,8 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
407
408
  /** Resolvers. Uses flat access (`ctx.facts.myFact`) to keep async mutations scoped to own module. */
408
409
  resolvers?: TypedResolversDef<M>;
409
410
  hooks?: ModuleHooks<M>;
411
+ /** Optional metadata for debugging and devtools (never read on hot path). */
412
+ meta?: DefinitionMeta;
410
413
  /** History configuration — controls which events create snapshots for undo/redo. */
411
414
  history?: {
412
415
  /** Events that create history snapshots. Omit to snapshot all events. */
@@ -954,4 +957,4 @@ declare const Backoff: {
954
957
  readonly Exponential: "exponential";
955
958
  };
956
959
 
957
- export { Backoff, type Branded, type ChainableSchemaType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleDeps, ErrorBoundaryConfig, type ExtendedSchemaType, Facts, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaType, SingleModuleSystem, TraceOption, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, isRequirementType, req, t };
960
+ export { Backoff, type Branded, type ChainableSchemaType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleDeps, DefinitionMeta, ErrorBoundaryConfig, type ExtendedSchemaType, Facts, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaType, SingleModuleSystem, TraceOption, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, isRequirementType, req, t };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-LB6PNML4.js';export{a as createSystem}from'./chunk-LB6PNML4.js';export{a as DirectiveError,n as RequirementSet,m as forType,j as generateRequirementId,g as isNamespacedSystem,l as isRequirementType,f as isSingleModuleSystem,k as req,d as typedConstraint,e as typedResolver}from'./chunk-ISYFVEHR.js';import'./chunk-EFBBEXDA.js';export{h as diffSnapshots,i as isSignedSnapshot,f as isSnapshotExpired,d as shallowEqual,j as signSnapshot,g as validateSnapshot,k as verifySnapshotSignature}from'./chunk-4CMO5OVZ.js';function g(e=[],n,t,r,u,o){return {_type:void 0,_validators:e,_typeName:n,_default:t,_transform:r,_description:u,_refinements:o,validate(d){return g([...e,d],n,t,r,u,o)}}}function c(e,n,t,r,u,o){return {...g(e,n,t,r,u,o),default(i){return c(e,n,i,r,u,o)},transform(i){return c([],n,void 0,s=>{let l=r?r(s):s;return i(l)},u)},brand(){return c(e,`Branded<${n}>`,t,r,u,o)},describe(i){return c(e,n,t,r,i,o)},refine(i,a){let s=[...o??[],{predicate:i,message:a}];return c([...e,i],n,t,r,u,s)},nullable(){return c([i=>i===null||e.every(a=>a(i))],`${n} | null`,t,r,u)},optional(){return c([i=>i===void 0||e.every(a=>a(i))],`${n} | undefined`,t,r,u)}}}var $={string(){let e=(n,t,r,u,o)=>({...c(n,"string",t,r,u,o),minLength(i){return e([...n,a=>a.length>=i],t,r,u,o)},maxLength(i){return e([...n,a=>a.length<=i],t,r,u,o)},pattern(i){return e([...n,a=>i.test(a)],t,r,u,o)},default(i){return e(n,i,r,u,o)},describe(i){return e(n,t,r,i,o)},refine(i,a){let s=[...o??[],{predicate:i,message:a}];return e([...n,i],t,r,u,s)}});return e([n=>typeof n=="string"])},number(){let e=(n,t,r,u,o)=>({...c(n,"number",t,r,u,o),min(i){return e([...n,a=>a>=i],t,r,u,o)},max(i){return e([...n,a=>a<=i],t,r,u,o)},default(i){return e(n,i,r,u,o)},describe(i){return e(n,t,r,i,o)},refine(i,a){let s=[...o??[],{predicate:i,message:a}];return e([...n,i],t,r,u,s)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,t,r,u,o)=>{let d=c(n,"array",r,void 0,u),i=o??{value:-1};return {...d,get _lastFailedIndex(){return i.value},set _lastFailedIndex(s){i.value=s;},of(s){let l={value:-1};return e([...n,y=>{for(let p=0;p<y.length;p++){let S=y[p];if(!s._validators.every(M=>M(S)))return l.value=p,false}return true}],s,r,u,l)},nonEmpty(){return e([...n,s=>s.length>0],t,r,u,i)},maxLength(s){return e([...n,l=>l.length<=s],t,r,u,i)},minLength(s){return e([...n,l=>l.length>=s],t,r,u,i)},default(s){return e(n,t,s,u,i)},describe(s){return e(n,t,r,s,i)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,t,r)=>({...c(n,"object",t,void 0,r),shape(o){return e([...n,d=>{for(let[i,a]of Object.entries(o)){let s=d[i],l=a;if(l&&!l._validators.every(y=>y(s)))return false}return true}],t,r)},nonNull(){return e([...n,o=>o!=null],t,r)},hasKeys(...o){return e([...n,d=>o.every(i=>i in d)],t,r)},default(o){return e(n,o,r)},describe(o){return e(n,t,o)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([t=>typeof t=="string"&&n.has(t)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return g([t=>t===null?true:e._validators.every(r=>r(t))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return g([t=>t===void 0?true:e._validators.every(r=>r(t))],`${n} | undefined`)},union(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.union() called with no types - this will reject all values");let n=e.map(t=>t._typeName??"unknown");return c([t=>e.some(r=>r._validators.every(u=>u(t)))],n.join(" | "))},record(e){let n=e._typeName??"unknown";return c([t=>typeof t!="object"||t===null||Array.isArray(t)?false:Object.values(t).every(r=>e._validators.every(u=>u(r)))],`Record<string, ${n}>`)},tuple(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(t=>t._typeName??"unknown");return c([t=>!Array.isArray(t)||t.length!==e.length?false:e.every((r,u)=>r._validators.every(o=>o(t[u])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function W(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function f(e,n,t,r,u){for(let o of e)n.has(o)||console.warn(`[Directive] ${t} "${o}" not declared in ${r}`);for(let o of n)e.has(o)||console.warn(`[Directive] ${r}["${o}"] ${u}`);}function P(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let t=new Set(Object.keys(n));for(let r of e)t.has(r)||console.warn(`[Directive] history.snapshotEvents entry "${r}" not declared in schema.events. Available events: ${[...t].join(", ")||"(none)"}`);}function F(e,n){let t=new Set(Object.keys(n));for(let[r,u]of Object.entries(e)){let o=u;typeof o.requirement=="string"&&!t.has(o.requirement)&&console.warn(`[Directive] Resolver "${r}" references unknown requirement type "${o.requirement}". Available types: ${[...t].join(", ")||"(none)"}`);}}function U(e,n){W(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),f(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),f(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&P(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&F(n.resolvers,n.schema.requirements);}function T(e,n){process.env.NODE_ENV!=="production"&&U(e,n);let t="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,history:n.history,crossModuleDeps:t}}function z(e){return n=>T(n,e)}function h(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let a of e.listeners)a();}function t(a,s){let l=a.get(s);return l||(l=new Set,a.set(s,l)),l}function r(a){let s=e.pending.get(a)??new Set,l=e.inflight.get(a)??new Set,y=e.failed.get(a)??new Set,p=e.errors.get(a)??null;return {pending:s.size,inflight:l.size,failed:y.size,isLoading:s.size>0||l.size>0,hasError:y.size>0,lastError:p}}function u(){let a=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),s=new Map;for(let l of a)s.set(l,r(l));return s}function o(a){return e.listeners.add(a),()=>e.listeners.delete(a)}function d(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(a){let s=a.requirement.type;t(e.pending,s).add(a.id),e.failed.get(s)?.delete(a.id),n();},onResolverStart(a,s){let l=s.requirement.type;e.pending.get(l)?.delete(s.id),t(e.inflight,l).add(s.id),n();},onResolverComplete(a,s){let l=s.requirement.type;e.inflight.get(l)?.delete(s.id),e.pending.get(l)?.delete(s.id),n();},onResolverError(a,s,l){let y=s.requirement.type;e.inflight.get(y)?.delete(s.id),t(e.failed,y).add(s.id),e.errors.set(y,l instanceof Error?l:new Error(String(l))),n();},onResolverCancel(a,s){let l=s.requirement.type;e.pending.get(l)?.delete(s.id),e.inflight.get(l)?.delete(s.id),n();},onRequirementMet(a){let s=a.requirement.type;e.pending.get(s)?.delete(a.id),e.inflight.get(s)?.delete(a.id),n();}},getStatus:r,getAllStatus:u,subscribe:o,reset:d}}function L(e){return n=>e.getStatus(n)}function H(e){let n=h(),r=[...e.plugins??[],n.plugin];return {system:a({module:e.module,plugins:r,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}var Z={None:"none",Linear:"linear",Exponential:"exponential"};export{Z as Backoff,T as createModule,z as createModuleFactory,h as createRequirementStatusPlugin,L as createStatusHook,H as createSystemWithStatus,$ as t};//# sourceMappingURL=index.js.map
1
+ import {a}from'./chunk-MPOV2REO.js';export{a as createSystem}from'./chunk-MPOV2REO.js';export{b as DirectiveError,o as RequirementSet,n as forType,k as generateRequirementId,h as isNamespacedSystem,m as isRequirementType,g as isSingleModuleSystem,l as req,e as typedConstraint,f as typedResolver}from'./chunk-YWKFNZQV.js';import'./chunk-EFBBEXDA.js';export{h as diffSnapshots,i as isSignedSnapshot,f as isSnapshotExpired,d as shallowEqual,j as signSnapshot,g as validateSnapshot,k as verifySnapshotSignature}from'./chunk-4CMO5OVZ.js';function g(e=[],n,r,s,i,l,u){return {_type:void 0,_validators:e,_typeName:n,_default:r,_transform:s,_description:i,_refinements:l,_meta:u,validate(p){return g([...e,p],n,r,s,i,l,u)}}}function c(e,n,r,s,i,l,u){return {...g(e,n,r,s,i,l,u),default(t){return c(e,n,t,s,i,l,u)},transform(t){return c([],n,void 0,o=>{let d=s?s(o):o;return t(d)},i,void 0,u)},brand(){return c(e,`Branded<${n}>`,r,s,i,l,u)},describe(t){return c(e,n,r,s,t,l,u)},refine(t,a){let o=[...l??[],{predicate:t,message:a}];return c([...e,t],n,r,s,i,o,u)},nullable(){return c([t=>t===null||e.every(a=>a(t))],`${n} | null`,r,s,i,void 0,u)},optional(){return c([t=>t===void 0||e.every(a=>a(t))],`${n} | undefined`,r,s,i,void 0,u)},meta(t){return c(e,n,r,s,i,l,t)}}}var $={string(){let e=(n,r,s,i,l,u)=>({...c(n,"string",r,s,i,l,u),minLength(t){return e([...n,a=>a.length>=t],r,s,i,l,u)},maxLength(t){return e([...n,a=>a.length<=t],r,s,i,l,u)},pattern(t){return e([...n,a=>t.test(a)],r,s,i,l,u)},default(t){return e(n,t,s,i,l,u)},describe(t){return e(n,r,s,t,l,u)},refine(t,a){let o=[...l??[],{predicate:t,message:a}];return e([...n,t],r,s,i,o,u)},meta(t){return e(n,r,s,i,l,t)}});return e([n=>typeof n=="string"])},number(){let e=(n,r,s,i,l,u)=>({...c(n,"number",r,s,i,l,u),min(t){return e([...n,a=>a>=t],r,s,i,l,u)},max(t){return e([...n,a=>a<=t],r,s,i,l,u)},default(t){return e(n,t,s,i,l,u)},describe(t){return e(n,r,s,t,l,u)},refine(t,a){let o=[...l??[],{predicate:t,message:a}];return e([...n,t],r,s,i,o,u)},meta(t){return e(n,r,s,i,l,t)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,r,s,i,l,u)=>{let p=c(n,"array",s,void 0,i,void 0,u),t=l??{value:-1};return {...p,get _lastFailedIndex(){return t.value},set _lastFailedIndex(o){t.value=o;},of(o){let d={value:-1};return e([...n,y=>{for(let m=0;m<y.length;m++)if(!o._validators.every(S=>S(y[m])))return d.value=m,false;return true}],o,s,i,d,u)},nonEmpty(){return e([...n,o=>o.length>0],r,s,i,t,u)},maxLength(o){return e([...n,d=>d.length<=o],r,s,i,t,u)},minLength(o){return e([...n,d=>d.length>=o],r,s,i,t,u)},default(o){return e(n,r,o,i,t,u)},describe(o){return e(n,r,s,o,t,u)},meta(o){return e(n,r,s,i,t,o)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,r,s,i)=>({...c(n,"object",r,void 0,s,void 0,i),shape(u){return e([...n,p=>{for(let[t,a]of Object.entries(u)){let o=p[t],d=a;if(d&&!d._validators.every(y=>y(o)))return false}return true}],r,s,i)},nonNull(){return e([...n,u=>u!=null],r,s,i)},hasKeys(...u){return e([...n,p=>u.every(t=>t in p)],r,s,i)},default(u){return e(n,u,s,i)},describe(u){return e(n,r,u,i)},meta(u){return e(n,r,s,u)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([r=>typeof r=="string"&&n.has(r)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return g([r=>r===null?true:e._validators.every(s=>s(r))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return g([r=>r===void 0?true:e._validators.every(s=>s(r))],`${n} | undefined`)},union(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.union() called with no types - this will reject all values");let n=e.map(r=>r._typeName??"unknown");return c([r=>e.some(s=>s._validators.every(i=>i(r)))],n.join(" | "))},record(e){let n=e._typeName??"unknown";return c([r=>typeof r!="object"||r===null||Array.isArray(r)?false:Object.values(r).every(s=>e._validators.every(i=>i(s)))],`Record<string, ${n}>`)},tuple(...e){process.env.NODE_ENV!=="production"&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(r=>r._typeName??"unknown");return c([r=>!Array.isArray(r)||r.length!==e.length?false:e.every((s,i)=>s._validators.every(l=>l(r[i])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function W(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function f(e,n,r,s,i){for(let l of e)n.has(l)||console.warn(`[Directive] ${r} "${l}" not declared in ${s}`);for(let l of n)e.has(l)||console.warn(`[Directive] ${s}["${l}"] ${i}`);}function P(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let r=new Set(Object.keys(n));for(let s of e)r.has(s)||console.warn(`[Directive] history.snapshotEvents entry "${s}" not declared in schema.events. Available events: ${[...r].join(", ")||"(none)"}`);}function F(e,n){let r=new Set(Object.keys(n));for(let[s,i]of Object.entries(e)){let l=i;typeof l.requirement=="string"&&!r.has(l.requirement)&&console.warn(`[Directive] Resolver "${s}" references unknown requirement type "${l.requirement}". Available types: ${[...r].join(", ")||"(none)"}`);}}function U(e,n){W(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),f(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),f(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&P(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&F(n.resolvers,n.schema.requirements);}function M(e,n){process.env.NODE_ENV!=="production"&&U(e,n);let r="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,meta:n.meta,history:n.history,crossModuleDeps:r}}function z(e){return n=>M(n,e)}function T(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let t of e.listeners)t();}function r(t,a){let o=t.get(a);return o||(o=new Set,t.set(a,o)),o}function s(t){let a=e.pending.get(t)??new Set,o=e.inflight.get(t)??new Set,d=e.failed.get(t)??new Set,y=e.errors.get(t)??null;return {pending:a.size,inflight:o.size,failed:d.size,isLoading:a.size>0||o.size>0,hasError:d.size>0,lastError:y}}function i(){let t=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),a=new Map;for(let o of t)a.set(o,s(o));return a}function l(t){return e.listeners.add(t),()=>e.listeners.delete(t)}function u(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(t){let a=t.requirement.type;r(e.pending,a).add(t.id),e.failed.get(a)?.delete(t.id),n();},onResolverStart(t,a){let o=a.requirement.type;e.pending.get(o)?.delete(a.id),r(e.inflight,o).add(a.id),n();},onResolverComplete(t,a){let o=a.requirement.type;e.inflight.get(o)?.delete(a.id),e.pending.get(o)?.delete(a.id),n();},onResolverError(t,a,o){let d=a.requirement.type;e.inflight.get(d)?.delete(a.id),r(e.failed,d).add(a.id),e.errors.set(d,o instanceof Error?o:new Error(String(o))),n();},onResolverCancel(t,a){let o=a.requirement.type;e.pending.get(o)?.delete(a.id),e.inflight.get(o)?.delete(a.id),n();},onRequirementMet(t){let a=t.requirement.type;e.pending.get(a)?.delete(t.id),e.inflight.get(a)?.delete(t.id),n();}},getStatus:s,getAllStatus:i,subscribe:l,reset:u}}function L(e){return n=>e.getStatus(n)}function H(e){let n=T(),s=[...e.plugins??[],n.plugin];return {system:a({module:e.module,plugins:s,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}var Z={None:"none",Linear:"linear",Exponential:"exponential"};export{Z as Backoff,M as createModule,z as createModuleFactory,T as createRequirementStatusPlugin,L as createStatusHook,H as createSystemWithStatus,$ as t};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map