@directive-run/core 0.1.1 → 0.3.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,5 +1,5 @@
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 ErrorSource, X as RetryLaterConfig, Y as TimeTravelAPI, Z as SystemConfig } from './plugins-CcwEXXMS.cjs';
2
- export { _ as AnySystem, $ as BatchItemResult, a0 as BatchResolveResults, a1 as CircuitBreakerConfig, a2 as CircuitBreakerState, a3 as CrossModuleConstraintDef, a4 as CrossModuleDerivationFn, a5 as CrossModuleEffectDef, a6 as CrossModuleFactsWithSelf, a7 as DerivationKeys, a8 as DerivationReturnType, a9 as DeriveAccessor, aa as DispatchEventsFromSchema, ab as DistributableSnapshot, ac as DistributableSnapshotOptions, ad as EffectCleanup, ae as EventPayloadSchema, af as EventsAccessor, ag as EventsAccessorFromSchema, ah as EventsDef, ai as EventsSchema, aj as FactKeys, ak as FactReturnType, al as FlexibleEventHandler, am as InferDerivations, an as InferEventPayloadFromSchema, ao as InferEvents, ap as InferRequirementPayloadFromSchema, aq as InferRequirementTypes, ar as InferSchema, as as InferSchemaType, at as InferSelectorState, au as MutableNamespacedFacts, av as NamespacedDerivations, aw as NamespacedEventsAccessor, ax as NamespacedFacts, ay as ObservableKeys, az as RequirementExplanation, aA as RequirementPayloadSchema, aB as RequirementsSchema, aC as SnapshotMeta, aD as SystemEvent, aE as SystemInspection, aF as SystemMode, aG as SystemSnapshot, aH as TimeTravelState, aI as TypedResolverContext, aJ as TypedResolverDef, aK as UnionEvents, aL as isNamespacedSystem, aM as isSingleModuleSystem } from './plugins-CcwEXXMS.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, 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-DZljh9NJ.cjs';
2
+ export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as CircuitBreakerConfig, a3 as CircuitBreakerState, a4 as CrossModuleConstraintDef, a5 as CrossModuleDerivationFn, a6 as CrossModuleEffectDef, a7 as CrossModuleFactsWithSelf, a8 as DerivationKeys, a9 as DerivationReturnType, aa as DeriveAccessor, ab as DispatchEventsFromSchema, ac as DistributableSnapshot, ad as DistributableSnapshotOptions, ae as EffectCleanup, af as EventPayloadSchema, ag as EventsAccessor, ah as EventsAccessorFromSchema, ai as EventsDef, aj as EventsSchema, ak as FactKeys, al as FactReturnType, am as FlexibleEventHandler, an as InferDerivations, ao as InferEventPayloadFromSchema, ap as InferEvents, aq as InferRequirementPayloadFromSchema, ar as InferRequirementTypes, as as InferSchema, at as InferSchemaType, au as InferSelectorState, av as MutableNamespacedFacts, aw as NamespacedDerivations, ax as NamespacedEventsAccessor, ay as NamespacedFacts, az as ObservableKeys, aA as RequirementExplanation, aB as RequirementPayloadSchema, aC as RequirementsSchema, aD as SnapshotMeta, aE as SystemEvent, aF as SystemInspection, aG as SystemMode, aH as SystemSnapshot, aI as TimeTravelState, aJ as TypedResolverContext, aK as TypedResolverDef, aL as UnionEvents, aM as isNamespacedSystem, aN as isSingleModuleSystem } from './plugins-DZljh9NJ.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
4
  export { DirectiveModuleStructure, ReduxSliceConfig, XStateMachineConfig, ZustandStoreConfig, analyzeReduxSlice, analyzeXStateMachine, analyzeZustandStore, generateMigrationChecklist, generateModuleCode } from './migration.cjs';
5
5
 
@@ -13,28 +13,13 @@ interface TrackingContext {
13
13
  track(key: string): void;
14
14
  getDependencies(): Set<string>;
15
15
  }
16
- /**
17
- * Legacy derivation definition function signature.
18
- * Used internally by the engine.
19
- *
20
- * @deprecated For typed derivations, use TypedDerivationsDef from module.ts
21
- */
16
+ /** Derivation definition function signature. */
22
17
  interface DerivationDef<S extends Schema, T, D extends DerivationsDef<S>> {
23
18
  (facts: Facts<S>, derive: DerivedValues<S, D>): T;
24
19
  }
25
- /**
26
- * Legacy map of derivation definitions.
27
- * Used internally by the engine.
28
- *
29
- * @deprecated For typed derivations, use TypedDerivationsDef from module.ts
30
- */
20
+ /** Map of derivation definitions. */
31
21
  type DerivationsDef<S extends Schema> = Record<string, DerivationDef<S, unknown, DerivationsDef<S>>>;
32
- /**
33
- * Legacy computed derived values.
34
- * Used internally by the engine.
35
- *
36
- * @deprecated For typed derivations, use InferDerivations from schema.ts
37
- */
22
+ /** Computed derived values. */
38
23
  type DerivedValues<S extends Schema, D extends DerivationsDef<S>> = {
39
24
  readonly [K in keyof D]: ReturnType<D[K]>;
40
25
  };
@@ -364,21 +349,6 @@ declare const t: {
364
349
  nonNull(): ChainableSchemaType<T> & /*elided*/ any;
365
350
  hasKeys(...keys: string[]): ChainableSchemaType<T> & /*elided*/ any;
366
351
  };
367
- /**
368
- * Create an any-typed schema (bypasses all validation).
369
- *
370
- * @deprecated Use specific types (`t.string()`, `t.object()`, `t.union()`) for type safety.
371
- * This bypasses all runtime validation.
372
- *
373
- * @example
374
- * ```typescript
375
- * // Use when type is complex or external
376
- * schema: {
377
- * externalApiResponse: t.any<ExternalAPIResponse>(),
378
- * }
379
- * ```
380
- */
381
- any<T>(): ExtendedSchemaType<T>;
382
352
  /**
383
353
  * Create an enum schema type for string literal unions.
384
354
  *
@@ -623,6 +593,8 @@ interface ModuleConfig<M extends ModuleSchema> {
623
593
  constraints?: TypedConstraintsDef<M>;
624
594
  resolvers?: TypedResolversDef<M>;
625
595
  hooks?: ModuleHooks<M>;
596
+ /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
597
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
626
598
  }
627
599
  /**
628
600
  * Module configuration with cross-module dependencies for type-safe access
@@ -692,6 +664,8 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
692
664
  /** Resolvers. Uses flat access (`ctx.facts.myFact`) to keep async mutations scoped to own module. */
693
665
  resolvers?: TypedResolversDef<M>;
694
666
  hooks?: ModuleHooks<M>;
667
+ /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
668
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
695
669
  }
696
670
  /**
697
671
  * Create a module definition with full type inference.
@@ -1457,7 +1431,7 @@ interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>
1457
1431
  facts: Facts<S>;
1458
1432
  store: FactsStore<S>;
1459
1433
  /** Callback when a derivation is computed */
1460
- onCompute?: (id: string, value: unknown, deps: string[]) => void;
1434
+ onCompute?: (id: string, value: unknown, oldValue: unknown, deps: string[]) => void;
1461
1435
  /** Callback when a derivation is invalidated */
1462
1436
  onInvalidate?: (id: string) => void;
1463
1437
  /** Callback when a derivation errors */
@@ -1538,8 +1512,8 @@ interface CreateEffectsOptions<S extends Schema> {
1538
1512
  definitions: EffectsDef<S>;
1539
1513
  facts: Facts<S>;
1540
1514
  store: FactsStore<S>;
1541
- /** Callback when an effect runs */
1542
- onRun?: (id: string) => void;
1515
+ /** Callback when an effect runs (deps = the fact keys that triggered it) */
1516
+ onRun?: (id: string, deps: string[]) => void;
1543
1517
  /** Callback when an effect errors */
1544
1518
  onError?: (id: string, error: unknown) => void;
1545
1519
  }
@@ -1581,8 +1555,12 @@ interface ConstraintsManager<_S extends Schema> {
1581
1555
  enable(id: string): void;
1582
1556
  /** Invalidate constraints that depend on the given fact key */
1583
1557
  invalidate(factKey: string): void;
1558
+ /** Get the tracked dependencies for a constraint */
1559
+ getDependencies(id: string): Set<string> | undefined;
1584
1560
  /** Mark a constraint's resolver as completed (for `after` ordering) */
1585
1561
  markResolved(constraintId: string): void;
1562
+ /** Check if a constraint is currently disabled */
1563
+ isDisabled(id: string): boolean;
1586
1564
  /** Check if a constraint has been resolved (for `after` ordering) */
1587
1565
  isResolved(constraintId: string): boolean;
1588
1566
  /** Register new constraint definitions (for dynamic module registration) */
@@ -1728,6 +1706,7 @@ interface PluginManager<_S extends Schema = any> {
1728
1706
  emitTimeTravel(from: number, to: number): void;
1729
1707
  emitError(error: DirectiveError): void;
1730
1708
  emitErrorRecovery(error: DirectiveError, strategy: RecoveryStrategy): void;
1709
+ emitRunComplete(run: RunChangelogEntry): void;
1731
1710
  }
1732
1711
  /**
1733
1712
  * Create a manager that broadcasts lifecycle events to registered plugins.
@@ -2013,4 +1992,4 @@ declare const Backoff: {
2013
1992
  readonly Exponential: "exponential";
2014
1993
  };
2015
1994
 
2016
- 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, 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 };
1995
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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 ErrorSource, X as RetryLaterConfig, Y as TimeTravelAPI, Z as SystemConfig } from './plugins-CcwEXXMS.js';
2
- export { _ as AnySystem, $ as BatchItemResult, a0 as BatchResolveResults, a1 as CircuitBreakerConfig, a2 as CircuitBreakerState, a3 as CrossModuleConstraintDef, a4 as CrossModuleDerivationFn, a5 as CrossModuleEffectDef, a6 as CrossModuleFactsWithSelf, a7 as DerivationKeys, a8 as DerivationReturnType, a9 as DeriveAccessor, aa as DispatchEventsFromSchema, ab as DistributableSnapshot, ac as DistributableSnapshotOptions, ad as EffectCleanup, ae as EventPayloadSchema, af as EventsAccessor, ag as EventsAccessorFromSchema, ah as EventsDef, ai as EventsSchema, aj as FactKeys, ak as FactReturnType, al as FlexibleEventHandler, am as InferDerivations, an as InferEventPayloadFromSchema, ao as InferEvents, ap as InferRequirementPayloadFromSchema, aq as InferRequirementTypes, ar as InferSchema, as as InferSchemaType, at as InferSelectorState, au as MutableNamespacedFacts, av as NamespacedDerivations, aw as NamespacedEventsAccessor, ax as NamespacedFacts, ay as ObservableKeys, az as RequirementExplanation, aA as RequirementPayloadSchema, aB as RequirementsSchema, aC as SnapshotMeta, aD as SystemEvent, aE as SystemInspection, aF as SystemMode, aG as SystemSnapshot, aH as TimeTravelState, aI as TypedResolverContext, aJ as TypedResolverDef, aK as UnionEvents, aL as isNamespacedSystem, aM as isSingleModuleSystem } from './plugins-CcwEXXMS.js';
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-DZljh9NJ.js';
2
+ export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as CircuitBreakerConfig, a3 as CircuitBreakerState, a4 as CrossModuleConstraintDef, a5 as CrossModuleDerivationFn, a6 as CrossModuleEffectDef, a7 as CrossModuleFactsWithSelf, a8 as DerivationKeys, a9 as DerivationReturnType, aa as DeriveAccessor, ab as DispatchEventsFromSchema, ac as DistributableSnapshot, ad as DistributableSnapshotOptions, ae as EffectCleanup, af as EventPayloadSchema, ag as EventsAccessor, ah as EventsAccessorFromSchema, ai as EventsDef, aj as EventsSchema, ak as FactKeys, al as FactReturnType, am as FlexibleEventHandler, an as InferDerivations, ao as InferEventPayloadFromSchema, ap as InferEvents, aq as InferRequirementPayloadFromSchema, ar as InferRequirementTypes, as as InferSchema, at as InferSchemaType, au as InferSelectorState, av as MutableNamespacedFacts, aw as NamespacedDerivations, ax as NamespacedEventsAccessor, ay as NamespacedFacts, az as ObservableKeys, aA as RequirementExplanation, aB as RequirementPayloadSchema, aC as RequirementsSchema, aD as SnapshotMeta, aE as SystemEvent, aF as SystemInspection, aG as SystemMode, aH as SystemSnapshot, aI as TimeTravelState, aJ as TypedResolverContext, aK as TypedResolverDef, aL as UnionEvents, aM as isNamespacedSystem, aN as isSingleModuleSystem } from './plugins-DZljh9NJ.js';
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.js';
4
4
  export { DirectiveModuleStructure, ReduxSliceConfig, XStateMachineConfig, ZustandStoreConfig, analyzeReduxSlice, analyzeXStateMachine, analyzeZustandStore, generateMigrationChecklist, generateModuleCode } from './migration.js';
5
5
 
@@ -13,28 +13,13 @@ interface TrackingContext {
13
13
  track(key: string): void;
14
14
  getDependencies(): Set<string>;
15
15
  }
16
- /**
17
- * Legacy derivation definition function signature.
18
- * Used internally by the engine.
19
- *
20
- * @deprecated For typed derivations, use TypedDerivationsDef from module.ts
21
- */
16
+ /** Derivation definition function signature. */
22
17
  interface DerivationDef<S extends Schema, T, D extends DerivationsDef<S>> {
23
18
  (facts: Facts<S>, derive: DerivedValues<S, D>): T;
24
19
  }
25
- /**
26
- * Legacy map of derivation definitions.
27
- * Used internally by the engine.
28
- *
29
- * @deprecated For typed derivations, use TypedDerivationsDef from module.ts
30
- */
20
+ /** Map of derivation definitions. */
31
21
  type DerivationsDef<S extends Schema> = Record<string, DerivationDef<S, unknown, DerivationsDef<S>>>;
32
- /**
33
- * Legacy computed derived values.
34
- * Used internally by the engine.
35
- *
36
- * @deprecated For typed derivations, use InferDerivations from schema.ts
37
- */
22
+ /** Computed derived values. */
38
23
  type DerivedValues<S extends Schema, D extends DerivationsDef<S>> = {
39
24
  readonly [K in keyof D]: ReturnType<D[K]>;
40
25
  };
@@ -364,21 +349,6 @@ declare const t: {
364
349
  nonNull(): ChainableSchemaType<T> & /*elided*/ any;
365
350
  hasKeys(...keys: string[]): ChainableSchemaType<T> & /*elided*/ any;
366
351
  };
367
- /**
368
- * Create an any-typed schema (bypasses all validation).
369
- *
370
- * @deprecated Use specific types (`t.string()`, `t.object()`, `t.union()`) for type safety.
371
- * This bypasses all runtime validation.
372
- *
373
- * @example
374
- * ```typescript
375
- * // Use when type is complex or external
376
- * schema: {
377
- * externalApiResponse: t.any<ExternalAPIResponse>(),
378
- * }
379
- * ```
380
- */
381
- any<T>(): ExtendedSchemaType<T>;
382
352
  /**
383
353
  * Create an enum schema type for string literal unions.
384
354
  *
@@ -623,6 +593,8 @@ interface ModuleConfig<M extends ModuleSchema> {
623
593
  constraints?: TypedConstraintsDef<M>;
624
594
  resolvers?: TypedResolversDef<M>;
625
595
  hooks?: ModuleHooks<M>;
596
+ /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
597
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
626
598
  }
627
599
  /**
628
600
  * Module configuration with cross-module dependencies for type-safe access
@@ -692,6 +664,8 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
692
664
  /** Resolvers. Uses flat access (`ctx.facts.myFact`) to keep async mutations scoped to own module. */
693
665
  resolvers?: TypedResolversDef<M>;
694
666
  hooks?: ModuleHooks<M>;
667
+ /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
668
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
695
669
  }
696
670
  /**
697
671
  * Create a module definition with full type inference.
@@ -1457,7 +1431,7 @@ interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>
1457
1431
  facts: Facts<S>;
1458
1432
  store: FactsStore<S>;
1459
1433
  /** Callback when a derivation is computed */
1460
- onCompute?: (id: string, value: unknown, deps: string[]) => void;
1434
+ onCompute?: (id: string, value: unknown, oldValue: unknown, deps: string[]) => void;
1461
1435
  /** Callback when a derivation is invalidated */
1462
1436
  onInvalidate?: (id: string) => void;
1463
1437
  /** Callback when a derivation errors */
@@ -1538,8 +1512,8 @@ interface CreateEffectsOptions<S extends Schema> {
1538
1512
  definitions: EffectsDef<S>;
1539
1513
  facts: Facts<S>;
1540
1514
  store: FactsStore<S>;
1541
- /** Callback when an effect runs */
1542
- onRun?: (id: string) => void;
1515
+ /** Callback when an effect runs (deps = the fact keys that triggered it) */
1516
+ onRun?: (id: string, deps: string[]) => void;
1543
1517
  /** Callback when an effect errors */
1544
1518
  onError?: (id: string, error: unknown) => void;
1545
1519
  }
@@ -1581,8 +1555,12 @@ interface ConstraintsManager<_S extends Schema> {
1581
1555
  enable(id: string): void;
1582
1556
  /** Invalidate constraints that depend on the given fact key */
1583
1557
  invalidate(factKey: string): void;
1558
+ /** Get the tracked dependencies for a constraint */
1559
+ getDependencies(id: string): Set<string> | undefined;
1584
1560
  /** Mark a constraint's resolver as completed (for `after` ordering) */
1585
1561
  markResolved(constraintId: string): void;
1562
+ /** Check if a constraint is currently disabled */
1563
+ isDisabled(id: string): boolean;
1586
1564
  /** Check if a constraint has been resolved (for `after` ordering) */
1587
1565
  isResolved(constraintId: string): boolean;
1588
1566
  /** Register new constraint definitions (for dynamic module registration) */
@@ -1728,6 +1706,7 @@ interface PluginManager<_S extends Schema = any> {
1728
1706
  emitTimeTravel(from: number, to: number): void;
1729
1707
  emitError(error: DirectiveError): void;
1730
1708
  emitErrorRecovery(error: DirectiveError, strategy: RecoveryStrategy): void;
1709
+ emitRunComplete(run: RunChangelogEntry): void;
1731
1710
  }
1732
1711
  /**
1733
1712
  * Create a manager that broadcasts lifecycle events to registered plugins.
@@ -2013,4 +1992,4 @@ declare const Backoff: {
2013
1992
  readonly Exponential: "exponential";
2014
1993
  };
2015
1994
 
2016
- 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, 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 };
1995
+ 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 };