@directive-run/core 0.4.1 → 0.5.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { S as Schema, F as Facts, R as Requirement, a as RequirementOutput, b as RetryPolicy, B as BatchConfig, c as ResolverContext, d as SchemaType, e as FactsStore, M as ModuleSchema, T as TypedDerivationsDef, f as TypedEventsDef, E as EffectsDef, g as TypedConstraintsDef, h as TypedResolversDef, i as ModuleHooks, C as CrossModuleDeps, j as CrossModuleDerivationsDef, k as CrossModuleEffectsDef, l as CrossModuleConstraintsDef, m as ModuleDef, n as CreateSystemOptionsSingle, o as SingleModuleSystem, p as ModulesMap, q as CreateSystemOptionsNamed, N as NamespacedSystem, D as DerivationsSchema, r as TypedConstraintDef, s as RequirementOutput$1, I as InferRequirements, P as Plugin, t as DebugConfig, u as ErrorBoundaryConfig, v as InferFacts, w as ExtractSchema, x as RequirementWithId, y as RequirementKeyFn, z as ConstraintsDef, A as ConstraintState, G as ResolversDef, H as ResolverStatus, J as System, K as FactChange, L as FactsSnapshot, O as ReconcileResult, Q as Snapshot, U as DirectiveError, V as RecoveryStrategy, W as RunChangelogEntry, X as ErrorSource, Y as RetryLaterConfig, Z as TimeTravelAPI, _ as SystemConfig } from './plugins-cDWoL7A7.cjs';
2
- export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as CrossModuleConstraintDef, a3 as CrossModuleDerivationFn, a4 as CrossModuleEffectDef, a5 as CrossModuleFactsWithSelf, a6 as DerivationKeys, a7 as DerivationReturnType, a8 as DeriveAccessor, a9 as DispatchEventsFromSchema, aa as DistributableSnapshot, ab as DistributableSnapshotOptions, ac as EffectCleanup, ad as EventPayloadSchema, ae as EventsAccessor, af as EventsAccessorFromSchema, ag as EventsDef, ah as EventsSchema, ai as FactKeys, aj as FactReturnType, ak as FlexibleEventHandler, al as InferDerivations, am as InferEventPayloadFromSchema, an as InferEvents, ao as InferRequirementPayloadFromSchema, ap as InferRequirementTypes, aq as InferSchema, ar as InferSchemaType, as as InferSelectorState, at as MutableNamespacedFacts, au as NamespacedDerivations, av as NamespacedEventsAccessor, aw as NamespacedFacts, ax as ObservableKeys, ay as RequirementExplanation, az as RequirementPayloadSchema, aA as RequirementsSchema, aB as SnapshotMeta, aC as SystemEvent, aD as SystemInspection, aE as SystemMode, aF as SystemSnapshot, aG as TimeTravelState, aH as TypedResolverContext, aI as TypedResolverDef, aJ as UnionEvents, aK as isNamespacedSystem, aL as isSingleModuleSystem } from './plugins-cDWoL7A7.cjs';
1
+ import { S as Schema, F as Facts, R as Requirement, a as RequirementOutput, b as RetryPolicy, B as BatchConfig, c as ResolverContext, d as SchemaType, M as ModuleSchema, T as TypedDerivationsDef, e as TypedEventsDef, E as EffectsDef, f as TypedConstraintsDef, g as TypedResolversDef, h as ModuleHooks, C as CrossModuleDeps, i as CrossModuleDerivationsDef, j as CrossModuleEffectsDef, k as CrossModuleConstraintsDef, l as ModuleDef, m as CreateSystemOptionsSingle, n as SingleModuleSystem, o as ModulesMap, p as CreateSystemOptionsNamed, N as NamespacedSystem, D as DerivationsSchema, q as TypedConstraintDef, r as RequirementOutput$1, I as InferRequirements, P as Plugin, s as DebugConfig, t as ErrorBoundaryConfig, u as InferFacts, v as ExtractSchema, w as RequirementWithId, x as RequirementKeyFn, y as FactsStore, z as ConstraintsDef, A as ConstraintState, G as ResolversDef, H as ResolverStatus, J as System, K as FactChange, L as FactsSnapshot, O as ReconcileResult, Q as Snapshot, U as DirectiveError, V as RecoveryStrategy, W as RunChangelogEntry, X as ErrorSource, Y as RetryLaterConfig, Z as TimeTravelAPI, _ as SystemConfig } from './plugins-Co2_xohI.cjs';
2
+ export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as ConstraintsControl, a3 as CrossModuleConstraintDef, a4 as CrossModuleDerivationFn, a5 as CrossModuleEffectDef, a6 as CrossModuleFactsWithSelf, a7 as DerivationKeys, a8 as DerivationReturnType, a9 as DerivationsControl, aa as DeriveAccessor, ab as DispatchEventsFromSchema, ac as DistributableSnapshot, ad as DistributableSnapshotOptions, ae as EffectCleanup, af as EffectsControl, ag as EventPayloadSchema, ah as EventsAccessor, ai as EventsAccessorFromSchema, aj as EventsDef, ak as EventsSchema, al as FactKeys, am as FactReturnType, an as FlexibleEventHandler, ao as InferDerivations, ap as InferEventPayloadFromSchema, aq as InferEvents, ar as InferRequirementPayloadFromSchema, as as InferRequirementTypes, at as InferSchema, au as InferSchemaType, av as InferSelectorState, aw as MutableNamespacedFacts, ax as NamespacedDerivations, ay as NamespacedEventsAccessor, az as NamespacedFacts, aA as ObservableKeys, aB as RequirementExplanation, aC as RequirementPayloadSchema, aD as RequirementsSchema, aE as ResolversControl, aF as SnapshotMeta, aG as SystemEvent, aH as SystemInspection, aI as SystemMode, aJ as SystemSnapshot, aK as TimeTravelState, aL as TypedResolverContext, aM as TypedResolverDef, aN as UnionEvents, aO as isNamespacedSystem, aP as isSingleModuleSystem } from './plugins-Co2_xohI.cjs';
3
3
  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-4JrY5fk9.cjs';
4
- export { DirectiveModuleStructure, ReduxSliceConfig, XStateMachineConfig, ZustandStoreConfig, analyzeReduxSlice, analyzeXStateMachine, analyzeZustandStore, generateMigrationChecklist, generateModuleCode } from './migration.cjs';
5
4
 
6
5
  /**
7
6
  * Derivation Types - Type definitions for derivations
@@ -15,7 +14,7 @@ interface TrackingContext {
15
14
  }
16
15
  /** Derivation definition function signature. */
17
16
  interface DerivationDef<S extends Schema, T, D extends DerivationsDef<S>> {
18
- (facts: Facts<S>, derive: DerivedValues<S, D>): T;
17
+ (facts: Facts<S>, derived: DerivedValues<S, D>): T;
19
18
  }
20
19
  /** Map of derivation definitions. */
21
20
  type DerivationsDef<S extends Schema> = Record<string, DerivationDef<S, unknown, DerivationsDef<S>>>;
@@ -143,7 +142,7 @@ interface TypedResolver<S extends Schema, R extends Requirement = Requirement> {
143
142
  * @example
144
143
  * ```typescript
145
144
  * const schema = { count: t.number(), threshold: t.number() };
146
- * const factory = constraintFactory<typeof schema>();
145
+ * const factory = createConstraintFactory<typeof schema>();
147
146
  *
148
147
  * const maxCountConstraint = factory.create({
149
148
  * when: (facts) => facts.count > facts.threshold,
@@ -151,7 +150,7 @@ interface TypedResolver<S extends Schema, R extends Requirement = Requirement> {
151
150
  * });
152
151
  * ```
153
152
  */
154
- declare function constraintFactory<S extends Schema>(): {
153
+ declare function createConstraintFactory<S extends Schema>(): {
155
154
  /**
156
155
  * Create a typed constraint
157
156
  */
@@ -164,7 +163,7 @@ declare function constraintFactory<S extends Schema>(): {
164
163
  * @example
165
164
  * ```typescript
166
165
  * const schema = { user: t.object<User>() };
167
- * const factory = resolverFactory<typeof schema>();
166
+ * const factory = createResolverFactory<typeof schema>();
168
167
  *
169
168
  * const fetchUserResolver = factory.create<FetchUserReq>({
170
169
  * requirement: (req): req is FetchUserReq => req.type === "FETCH_USER",
@@ -174,7 +173,7 @@ declare function constraintFactory<S extends Schema>(): {
174
173
  * });
175
174
  * ```
176
175
  */
177
- declare function resolverFactory<S extends Schema>(): {
176
+ declare function createResolverFactory<S extends Schema>(): {
178
177
  /**
179
178
  * Create a typed resolver
180
179
  */
@@ -182,7 +181,7 @@ declare function resolverFactory<S extends Schema>(): {
182
181
  };
183
182
  /**
184
183
  * Type-safe constraint creator.
185
- * Simpler alternative to constraintFactory when you don't need a factory pattern.
184
+ * Simpler alternative to createConstraintFactory when you don't need a factory pattern.
186
185
  *
187
186
  * @example
188
187
  * ```typescript
@@ -195,7 +194,7 @@ declare function resolverFactory<S extends Schema>(): {
195
194
  declare function typedConstraint<S extends Schema, R extends Requirement = Requirement>(constraint: TypedConstraint<S, R>): TypedConstraint<S, R>;
196
195
  /**
197
196
  * Type-safe resolver creator.
198
- * Simpler alternative to resolverFactory when you don't need a factory pattern.
197
+ * Simpler alternative to createResolverFactory when you don't need a factory pattern.
199
198
  *
200
199
  * @example
201
200
  * ```typescript
@@ -210,14 +209,12 @@ declare function typedConstraint<S extends Schema, R extends Requirement = Requi
210
209
  declare function typedResolver<S extends Schema, R extends Requirement = Requirement>(resolver: TypedResolver<S, R>): TypedResolver<S, R>;
211
210
 
212
211
  /**
213
- * Facts Store - Proxy-based reactive state with auto-tracking
212
+ * Schema Type Builders
214
213
  *
215
- * Features:
216
- * - Proxy-based access (facts.phase instead of facts.get("phase"))
217
- * - Automatic dependency tracking via tracking context
218
- * - Batched updates with coalesced notifications
219
- * - Granular subscriptions by key
220
- * - Schema validation in development mode
214
+ * Provides type-safe schema definitions with optional runtime validation.
215
+ * Used to define fact types, derivation types, event payload types, etc.
216
+ *
217
+ * This module has no dependency on the facts store or tracking system.
221
218
  */
222
219
 
223
220
  /** Brand symbol for branded types */
@@ -346,12 +343,14 @@ declare const t: {
346
343
  _lastFailedIndex?: number;
347
344
  };
348
345
  /**
349
- * Create an object schema type.
346
+ * Create an object schema type for any complex value.
350
347
  * Can be used with or without shape validation:
351
348
  * - `t.object<User>()` - Type-only, no property validation
352
349
  * - `t.object<User>().shape({ name: t.string(), age: t.number() })` - With property validation
350
+ *
351
+ * For arrays, prefer `t.array<T>()` which adds `Array.isArray` validation.
353
352
  */
354
- object<T extends Record<string, unknown>>(): ChainableSchemaType<T> & {
353
+ object<T>(): ChainableSchemaType<T> & {
355
354
  shape(schema: { [K in keyof T]?: SchemaType<T[K]>; }): ChainableSchemaType<T> & /*elided*/ any;
356
355
  nonNull(): ChainableSchemaType<T> & /*elided*/ any;
357
356
  hasKeys(...keys: string[]): ChainableSchemaType<T> & /*elided*/ any;
@@ -495,108 +494,6 @@ declare const t: {
495
494
  */
496
495
  bigint(): ChainableSchemaType<bigint>;
497
496
  };
498
- /** Options for creating a facts store */
499
- interface CreateFactsStoreOptions<S extends Schema> {
500
- schema: S;
501
- /** Validate values against schema (default: process.env.NODE_ENV !== 'production') */
502
- validate?: boolean;
503
- /** Throw on unknown schema keys (default: true in dev mode) */
504
- strictKeys?: boolean;
505
- /** Redact sensitive values in error messages */
506
- redactErrors?: boolean;
507
- /** Callback when facts change (for plugin hooks) */
508
- onChange?: (key: string, value: unknown, prev: unknown) => void;
509
- /** Callback for batch changes */
510
- onBatch?: (changes: Array<{
511
- key: string;
512
- value: unknown;
513
- prev: unknown;
514
- type: "set" | "delete";
515
- }>) => void;
516
- }
517
- /**
518
- * Create a reactive facts store backed by a Map with schema validation,
519
- * batched mutations, and granular key-level subscriptions.
520
- *
521
- * @remarks
522
- * The store is the low-level primitive that powers the `facts` proxy.
523
- * Most users should use {@link createFacts} or `createModule` instead.
524
- *
525
- * @param options - Store configuration including schema, validation settings, and change callbacks
526
- * @returns A {@link FactsStore} with get/set/batch/subscribe methods and automatic schema validation
527
- *
528
- * @example
529
- * ```ts
530
- * const store = createFactsStore({
531
- * schema: { count: t.number(), name: t.string() },
532
- * });
533
- *
534
- * store.set("count", 1);
535
- * store.get("count"); // 1
536
- *
537
- * store.batch(() => {
538
- * store.set("count", 2);
539
- * store.set("name", "hello");
540
- * }); // listeners fire once after batch completes
541
- * ```
542
- *
543
- * @internal
544
- */
545
- declare function createFactsStore<S extends Schema>(options: CreateFactsStoreOptions<S>): FactsStore<S>;
546
- /**
547
- * Create a Proxy wrapper around a {@link FactsStore} for clean property-style
548
- * access (`facts.phase`) with automatic dependency tracking.
549
- *
550
- * @remarks
551
- * Reading a property calls `store.get()` (which tracks the access for
552
- * auto-tracked derivations). Writing a property calls `store.set()` (which
553
- * validates against the schema). The proxy also exposes `$store` for direct
554
- * store access and `$snapshot()` for untracked reads.
555
- *
556
- * @param store - The underlying facts store to wrap
557
- * @param schema - The schema definition used for `ownKeys` enumeration
558
- * @returns A {@link Facts} proxy with property-style get/set and prototype pollution guards
559
- *
560
- * @example
561
- * ```ts
562
- * const store = createFactsStore({ schema: { phase: t.string() } });
563
- * const facts = createFactsProxy(store, { phase: t.string() });
564
- *
565
- * facts.phase = "red";
566
- * console.log(facts.phase); // "red"
567
- * ```
568
- *
569
- * @internal
570
- */
571
- declare function createFactsProxy<S extends Schema>(store: FactsStore<S>, schema: S): Facts<S>;
572
- /**
573
- * Convenience factory that creates both a {@link FactsStore} and its
574
- * {@link createFactsProxy | proxy wrapper} in a single call.
575
- *
576
- * @remarks
577
- * This is the recommended entry point when you need low-level store access
578
- * outside of `createModule` / `createSystem`.
579
- *
580
- * @param options - Same options as {@link createFactsStore}
581
- * @returns An object with `store` (the reactive Map-backed store) and `facts` (the Proxy accessor)
582
- *
583
- * @example
584
- * ```ts
585
- * const { store, facts } = createFacts({
586
- * schema: { phase: t.string<"red" | "green">() },
587
- * });
588
- *
589
- * facts.phase = "red";
590
- * console.log(facts.phase); // "red"
591
- * store.subscribe(["phase"], () => console.log("phase changed"));
592
- * ```
593
- *
594
- * @internal
595
- */
596
- declare function createFacts<S extends Schema>(options: CreateFactsStoreOptions<S>): {
597
- store: FactsStore<S>;
598
- facts: Facts<S>;
599
- };
600
497
 
601
498
  /**
602
499
  * Module - The declarative API for defining Directive modules
@@ -696,7 +593,7 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
696
593
  * Create a module definition with full type inference.
697
594
  *
698
595
  * The consolidated schema provides:
699
- * - Derivation composition (`derive.otherDerivation` is typed)
596
+ * - Derivation composition (`derived.otherDerivation` is typed)
700
597
  * - Event dispatch (`system.dispatch({ type: "..." })` has autocomplete)
701
598
  * - Resolver requirements (`req.payload` is typed based on requirement type)
702
599
  *
@@ -730,9 +627,9 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
730
627
  * },
731
628
  * derive: {
732
629
  * isRed: (facts) => facts.phase === "red",
733
- * timeRemaining: (facts, derive) => {
734
- * // derive.isRed is typed as boolean!
735
- * return derive.isRed ? 30 - facts.elapsed : 0;
630
+ * timeRemaining: (facts, derived) => {
631
+ * // derived.isRed is typed as boolean!
632
+ * return derived.isRed ? 30 - facts.elapsed : 0;
736
633
  * },
737
634
  * },
738
635
  * events: {
@@ -933,7 +830,7 @@ interface ModuleBuilder<M extends ModuleSchema = ModuleSchema> {
933
830
  * Define derivation implementations for this module.
934
831
  * Keys must match those declared in schema.derivations.
935
832
  */
936
- derive<D extends Record<string, (facts: Facts<M["facts"]>, derive: DeriveAccessor<M>) => unknown>>(derivations: D): ModuleBuilder<M>;
833
+ derive<D extends Record<string, (facts: Facts<M["facts"]>, derived: DeriveAccessor<M>) => unknown>>(derivations: D): ModuleBuilder<M>;
937
834
  /**
938
835
  * Define event handler implementations for this module.
939
836
  * Keys must match those declared in schema.events.
@@ -1448,20 +1345,6 @@ declare function createSystemWithStatus<M extends ModuleSchema>(options: CreateS
1448
1345
  * - Requirement comparison and hashing
1449
1346
  */
1450
1347
 
1451
- /**
1452
- * Generate a stable identity string for a requirement.
1453
- *
1454
- * When no custom key function is provided, the ID is formed from the
1455
- * requirement's `type` plus a deterministic JSON serialization of its
1456
- * remaining properties. A custom {@link RequirementKeyFn} can override
1457
- * this to control deduplication granularity.
1458
- *
1459
- * @param req - The requirement to generate an ID for.
1460
- * @param keyFn - Optional custom key function that overrides the default identity logic.
1461
- * @returns A stable string that uniquely identifies this requirement for deduplication.
1462
- *
1463
- * @public
1464
- */
1465
1348
  declare function generateRequirementId(req: Requirement, keyFn?: RequirementKeyFn): string;
1466
1349
  /**
1467
1350
  * Create a typed requirement factory for a given requirement type string.
@@ -1637,6 +1520,120 @@ declare class RequirementSet {
1637
1520
  };
1638
1521
  }
1639
1522
 
1523
+ /**
1524
+ * Facts Store - Proxy-based reactive state with auto-tracking
1525
+ *
1526
+ * Features:
1527
+ * - Proxy-based access (facts.phase instead of facts.get("phase"))
1528
+ * - Automatic dependency tracking via tracking context
1529
+ * - Batched updates with coalesced notifications
1530
+ * - Granular subscriptions by key
1531
+ * - Schema validation in development mode
1532
+ */
1533
+
1534
+ /** Options for creating a facts store */
1535
+ interface CreateFactsStoreOptions<S extends Schema> {
1536
+ schema: S;
1537
+ /** Validate values against schema (default: process.env.NODE_ENV !== 'production') */
1538
+ validate?: boolean;
1539
+ /** Throw on unknown schema keys (default: true in dev mode) */
1540
+ strictKeys?: boolean;
1541
+ /** Redact sensitive values in error messages */
1542
+ redactErrors?: boolean;
1543
+ /** Callback when facts change (for plugin hooks) */
1544
+ onChange?: (key: string, value: unknown, prev: unknown) => void;
1545
+ /** Callback for batch changes */
1546
+ onBatch?: (changes: Array<{
1547
+ key: string;
1548
+ value: unknown;
1549
+ prev: unknown;
1550
+ type: "set" | "delete";
1551
+ }>) => void;
1552
+ }
1553
+ /**
1554
+ * Create a reactive facts store backed by a Map with schema validation,
1555
+ * batched mutations, and granular key-level subscriptions.
1556
+ *
1557
+ * @remarks
1558
+ * The store is the low-level primitive that powers the `facts` proxy.
1559
+ * Most users should use {@link createFacts} or `createModule` instead.
1560
+ *
1561
+ * @param options - Store configuration including schema, validation settings, and change callbacks
1562
+ * @returns A {@link FactsStore} with get/set/batch/subscribe methods and automatic schema validation
1563
+ *
1564
+ * @example
1565
+ * ```ts
1566
+ * const store = createFactsStore({
1567
+ * schema: { count: t.number(), name: t.string() },
1568
+ * });
1569
+ *
1570
+ * store.set("count", 1);
1571
+ * store.get("count"); // 1
1572
+ *
1573
+ * store.batch(() => {
1574
+ * store.set("count", 2);
1575
+ * store.set("name", "hello");
1576
+ * }); // listeners fire once after batch completes
1577
+ * ```
1578
+ *
1579
+ * @internal
1580
+ */
1581
+ declare function createFactsStore<S extends Schema>(options: CreateFactsStoreOptions<S>): FactsStore<S>;
1582
+ /**
1583
+ * Create a Proxy wrapper around a {@link FactsStore} for clean property-style
1584
+ * access (`facts.phase`) with automatic dependency tracking.
1585
+ *
1586
+ * @remarks
1587
+ * Reading a property calls `store.get()` (which tracks the access for
1588
+ * auto-tracked derivations). Writing a property calls `store.set()` (which
1589
+ * validates against the schema). The proxy also exposes `$store` for direct
1590
+ * store access and `$snapshot()` for untracked reads.
1591
+ *
1592
+ * @param store - The underlying facts store to wrap
1593
+ * @param schema - The schema definition used for `ownKeys` enumeration
1594
+ * @returns A {@link Facts} proxy with property-style get/set and prototype pollution guards
1595
+ *
1596
+ * @example
1597
+ * ```ts
1598
+ * const store = createFactsStore({ schema: { phase: t.string() } });
1599
+ * const facts = createFactsProxy(store, { phase: t.string() });
1600
+ *
1601
+ * facts.phase = "red";
1602
+ * console.log(facts.phase); // "red"
1603
+ * ```
1604
+ *
1605
+ * @internal
1606
+ */
1607
+ declare function createFactsProxy<S extends Schema>(store: FactsStore<S>, schema: S): Facts<S>;
1608
+ /**
1609
+ * Convenience factory that creates both a {@link FactsStore} and its
1610
+ * {@link createFactsProxy | proxy wrapper} in a single call.
1611
+ *
1612
+ * @remarks
1613
+ * This is the recommended entry point when you need low-level store access
1614
+ * outside of `createModule` / `createSystem`.
1615
+ *
1616
+ * @param options - Same options as {@link createFactsStore}
1617
+ * @returns An object with `store` (the reactive Map-backed store) and `facts` (the Proxy accessor)
1618
+ *
1619
+ * @example
1620
+ * ```ts
1621
+ * const { store, facts } = createFacts({
1622
+ * schema: { phase: t.string<"red" | "green">() },
1623
+ * });
1624
+ *
1625
+ * facts.phase = "red";
1626
+ * console.log(facts.phase); // "red"
1627
+ * store.subscribe(["phase"], () => console.log("phase changed"));
1628
+ * ```
1629
+ *
1630
+ * @internal
1631
+ */
1632
+ declare function createFacts<S extends Schema>(options: CreateFactsStoreOptions<S>): {
1633
+ store: FactsStore<S>;
1634
+ facts: Facts<S>;
1635
+ };
1636
+
1640
1637
  /**
1641
1638
  * Derivations - Auto-tracked computed values with composition
1642
1639
  *
@@ -1667,6 +1664,12 @@ interface DerivationsManager<S extends Schema, D extends DerivationsDef<S>> {
1667
1664
  getDependencies(id: keyof D): Set<string>;
1668
1665
  /** Register new derivation definitions (for dynamic module registration) */
1669
1666
  registerDefinitions(newDefs: DerivationsDef<S>): void;
1667
+ /** Override an existing derivation function */
1668
+ assignDefinition(id: string, fn: DerivationsDef<S>[keyof DerivationsDef<S>]): void;
1669
+ /** Remove a derivation and clean up its state */
1670
+ unregisterDefinition(id: string): void;
1671
+ /** Compute a derivation immediately (ignores cache) */
1672
+ callOne(id: string): unknown;
1670
1673
  }
1671
1674
  /** Options for creating a derivations manager */
1672
1675
  interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>> {
@@ -1790,6 +1793,26 @@ interface EffectsManager<_S extends Schema = Schema> {
1790
1793
  * @param newDefs - New effect definitions to merge into the manager.
1791
1794
  */
1792
1795
  registerDefinitions(newDefs: EffectsDef<Schema>): void;
1796
+ /**
1797
+ * Override an existing effect definition. Runs cleanup of the old effect first.
1798
+ *
1799
+ * @param id - The effect definition ID to override.
1800
+ * @param def - The new effect definition.
1801
+ * @throws If no effect with this ID exists.
1802
+ */
1803
+ assignDefinition(id: string, def: EffectsDef<Schema>[string]): void;
1804
+ /**
1805
+ * Remove an effect definition. Runs cleanup (try-catch) and removes from state.
1806
+ *
1807
+ * @param id - The effect definition ID to remove.
1808
+ */
1809
+ unregisterDefinition(id: string): void;
1810
+ /**
1811
+ * Execute an effect's `run()` function immediately.
1812
+ *
1813
+ * @param id - The effect definition ID.
1814
+ */
1815
+ callOne(id: string): Promise<void>;
1793
1816
  }
1794
1817
  /**
1795
1818
  * Configuration options accepted by {@link createEffectsManager}.
@@ -1961,6 +1984,30 @@ interface ConstraintsManager<_S extends Schema> {
1961
1984
  * @param newDefs - New constraint definitions to merge into the manager.
1962
1985
  */
1963
1986
  registerDefinitions(newDefs: ConstraintsDef<Schema>): void;
1987
+ /**
1988
+ * Override an existing constraint definition.
1989
+ * Stores the original in an internal map for inspection.
1990
+ *
1991
+ * @param id - The constraint definition ID to override.
1992
+ * @param def - The new constraint definition.
1993
+ * @throws If no constraint with this ID exists.
1994
+ */
1995
+ assignDefinition(id: string, def: ConstraintsDef<Schema>[string]): void;
1996
+ /**
1997
+ * Remove a constraint definition and all its internal state.
1998
+ *
1999
+ * @param id - The constraint definition ID to remove.
2000
+ */
2001
+ unregisterDefinition(id: string): void;
2002
+ /**
2003
+ * Evaluate a single constraint and emit its requirement if active.
2004
+ * Props are merged into the requirement object.
2005
+ *
2006
+ * @param id - The constraint definition ID.
2007
+ * @param props - Optional properties to merge into the requirement.
2008
+ * @returns The emitted requirements (if any).
2009
+ */
2010
+ callOne(id: string, props?: Record<string, unknown>): Promise<RequirementWithId[]>;
1964
2011
  }
1965
2012
  /**
1966
2013
  * Configuration options accepted by {@link createConstraintsManager}.
@@ -2122,6 +2169,31 @@ interface ResolversManager<_S extends Schema> {
2122
2169
  * @param newDefs - New resolver definitions to merge into the manager.
2123
2170
  */
2124
2171
  registerDefinitions(newDefs: ResolversDef<Schema>): void;
2172
+ /**
2173
+ * Override an existing resolver definition.
2174
+ *
2175
+ * @param id - The resolver definition ID to override.
2176
+ * @param def - The new resolver definition.
2177
+ * @throws If no resolver with this ID exists.
2178
+ */
2179
+ assignDefinition(id: string, def: ResolversDef<Schema>[string]): void;
2180
+ /**
2181
+ * Remove a resolver definition. Cancels any inflight resolution.
2182
+ *
2183
+ * @param id - The resolver definition ID to remove.
2184
+ */
2185
+ unregisterDefinition(id: string): void;
2186
+ /**
2187
+ * Execute a resolver with a given requirement object.
2188
+ *
2189
+ * @param id - The resolver definition ID.
2190
+ * @param requirement - The requirement to resolve.
2191
+ */
2192
+ callOne(id: string, requirement: Requirement): Promise<void>;
2193
+ /**
2194
+ * Clean up all internal state. Called on system destroy.
2195
+ */
2196
+ destroy(): void;
2125
2197
  }
2126
2198
  /**
2127
2199
  * Configuration options accepted by {@link createResolversManager}.
@@ -2270,6 +2342,10 @@ interface PluginManager<_S extends Schema = any> {
2270
2342
  emitTimeTravel(from: number, to: number): void;
2271
2343
  emitError(error: DirectiveError): void;
2272
2344
  emitErrorRecovery(error: DirectiveError, strategy: RecoveryStrategy): void;
2345
+ emitDefinitionRegister(type: string, id: string, def: unknown): void;
2346
+ emitDefinitionAssign(type: string, id: string, def: unknown, original: unknown): void;
2347
+ emitDefinitionUnregister(type: string, id: string): void;
2348
+ emitDefinitionCall(type: string, id: string, props?: unknown): void;
2273
2349
  emitRunComplete(run: RunChangelogEntry): void;
2274
2350
  }
2275
2351
  /**
@@ -2638,4 +2714,4 @@ declare const Backoff: {
2638
2714
  readonly Exponential: "exponential";
2639
2715
  };
2640
2716
 
2641
- export { Backoff, BatchConfig, type Branded, type ChainableSchemaType, type ConstraintBuilderComplete, type ConstraintBuilderStart, type ConstraintBuilderWithWhen, ConstraintState, ConstraintsDef, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef, CrossModuleDeps, CrossModuleDerivationsDef, CrossModuleEffectsDef, DebugConfig, type DerivationState, type DerivationsDef, DerivationsSchema, type DerivedValues, DirectiveError, EffectsDef, ErrorBoundaryConfig, ErrorSource, type ExtendedSchemaType, FactChange, Facts, FactsSnapshot, FactsStore, InferFacts, InferRequirements, type InflightInfo, type ModuleBuilder, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, type NamespacedSystemBuilder, type PendingRetry, Plugin, ReconcileResult, RecoveryStrategy, Requirement, RequirementKeyFn, RequirementOutput$1 as RequirementOutput, RequirementSet, type RequirementTypeStatus, RequirementWithId, ResolverContext, ResolverStatus, ResolversDef, RetryLaterConfig, RetryPolicy, RunChangelogEntry, Schema, SchemaType, SingleModuleSystem, type SingleModuleSystemBuilder, Snapshot, System, type SystemBuilderStart, SystemConfig, TimeTravelAPI, type TypedConstraint, TypedConstraintDef, TypedConstraintsDef, TypedDerivationsDef, TypedEventsDef, type TypedResolver, TypedResolversDef, type WhenBuilder, type WhenConstraint, constraint, constraintFactory, createConstraintsManager, createDerivationsManager, createDisabledTimeTravel, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createModule, createModuleFactory, createPluginManager, createRequirementStatusPlugin, createResolversManager, createRetryLaterManager, createStatusHook, createSystem, createSystemWithStatus, createTimeTravelManager, forType, generateRequirementId, getCurrentTracker, isRequirementType, isTracking, module$1 as module, req, resolverFactory, system, t, trackAccess, typedConstraint, typedResolver, when, withTracking, withoutTracking };
2717
+ export { Backoff, BatchConfig, type Branded, type ChainableSchemaType, ConstraintState, ConstraintsDef, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef, CrossModuleDeps, CrossModuleDerivationsDef, CrossModuleEffectsDef, DebugConfig, type DerivationState, type DerivationsDef, DerivationsSchema, type DerivedValues, DirectiveError, EffectsDef, ErrorBoundaryConfig, ErrorSource, type ExtendedSchemaType, FactChange, Facts, FactsSnapshot, FactsStore, InferFacts, InferRequirements, type InflightInfo, type ModuleBuilder, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, type PendingRetry, Plugin, ReconcileResult, RecoveryStrategy, Requirement, RequirementKeyFn, RequirementOutput$1 as RequirementOutput, RequirementSet, type RequirementTypeStatus, RequirementWithId, ResolverContext, ResolverStatus, ResolversDef, RetryLaterConfig, RetryPolicy, RunChangelogEntry, Schema, SchemaType, SingleModuleSystem, Snapshot, System, SystemConfig, TimeTravelAPI, type TypedConstraint, TypedConstraintDef, TypedConstraintsDef, TypedDerivationsDef, TypedEventsDef, type TypedResolver, TypedResolversDef, type WhenConstraint, constraint, createConstraintFactory, createConstraintsManager, createDerivationsManager, createDisabledTimeTravel, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createModule, createModuleFactory, createPluginManager, createRequirementStatusPlugin, createResolverFactory, createResolversManager, createRetryLaterManager, createStatusHook, createSystem, createSystemWithStatus, createTimeTravelManager, forType, generateRequirementId, getCurrentTracker, isRequirementType, isTracking, module$1 as module, req, system, t, trackAccess, typedConstraint, typedResolver, when, withTracking, withoutTracking };