@directive-run/core 0.4.2 → 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/LICENSE +1 -1
- package/README.md +3 -2
- package/dist/adapter-utils.cjs +1 -1
- package/dist/adapter-utils.cjs.map +1 -1
- package/dist/adapter-utils.d.cts +1 -1
- package/dist/adapter-utils.d.ts +1 -1
- package/dist/adapter-utils.js +1 -1
- package/dist/adapter-utils.js.map +1 -1
- package/dist/index.cjs +8 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -139
- package/dist/index.d.ts +213 -139
- package/dist/index.js +8 -26
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/{plugins-cDWoL7A7.d.cts → plugins-Co2_xohI.d.cts} +177 -10
- package/dist/{plugins-cDWoL7A7.d.ts → plugins-Co2_xohI.d.ts} +177 -10
- package/dist/testing.cjs +8 -3
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +64 -2
- package/dist/testing.d.ts +64 -2
- package/dist/testing.js +8 -3
- package/dist/testing.js.map +1 -1
- package/dist/worker.cjs +8 -3
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +8 -3
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
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,
|
|
2
|
-
export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as
|
|
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.js';
|
|
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.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
|
-
export { DirectiveModuleStructure, ReduxSliceConfig, XStateMachineConfig, ZustandStoreConfig, analyzeReduxSlice, analyzeXStateMachine, analyzeZustandStore, generateMigrationChecklist, generateModuleCode } from './migration.js';
|
|
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>,
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
212
|
+
* Schema Type Builders
|
|
214
213
|
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
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 */
|
|
@@ -497,108 +494,6 @@ declare const t: {
|
|
|
497
494
|
*/
|
|
498
495
|
bigint(): ChainableSchemaType<bigint>;
|
|
499
496
|
};
|
|
500
|
-
/** Options for creating a facts store */
|
|
501
|
-
interface CreateFactsStoreOptions<S extends Schema> {
|
|
502
|
-
schema: S;
|
|
503
|
-
/** Validate values against schema (default: process.env.NODE_ENV !== 'production') */
|
|
504
|
-
validate?: boolean;
|
|
505
|
-
/** Throw on unknown schema keys (default: true in dev mode) */
|
|
506
|
-
strictKeys?: boolean;
|
|
507
|
-
/** Redact sensitive values in error messages */
|
|
508
|
-
redactErrors?: boolean;
|
|
509
|
-
/** Callback when facts change (for plugin hooks) */
|
|
510
|
-
onChange?: (key: string, value: unknown, prev: unknown) => void;
|
|
511
|
-
/** Callback for batch changes */
|
|
512
|
-
onBatch?: (changes: Array<{
|
|
513
|
-
key: string;
|
|
514
|
-
value: unknown;
|
|
515
|
-
prev: unknown;
|
|
516
|
-
type: "set" | "delete";
|
|
517
|
-
}>) => void;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Create a reactive facts store backed by a Map with schema validation,
|
|
521
|
-
* batched mutations, and granular key-level subscriptions.
|
|
522
|
-
*
|
|
523
|
-
* @remarks
|
|
524
|
-
* The store is the low-level primitive that powers the `facts` proxy.
|
|
525
|
-
* Most users should use {@link createFacts} or `createModule` instead.
|
|
526
|
-
*
|
|
527
|
-
* @param options - Store configuration including schema, validation settings, and change callbacks
|
|
528
|
-
* @returns A {@link FactsStore} with get/set/batch/subscribe methods and automatic schema validation
|
|
529
|
-
*
|
|
530
|
-
* @example
|
|
531
|
-
* ```ts
|
|
532
|
-
* const store = createFactsStore({
|
|
533
|
-
* schema: { count: t.number(), name: t.string() },
|
|
534
|
-
* });
|
|
535
|
-
*
|
|
536
|
-
* store.set("count", 1);
|
|
537
|
-
* store.get("count"); // 1
|
|
538
|
-
*
|
|
539
|
-
* store.batch(() => {
|
|
540
|
-
* store.set("count", 2);
|
|
541
|
-
* store.set("name", "hello");
|
|
542
|
-
* }); // listeners fire once after batch completes
|
|
543
|
-
* ```
|
|
544
|
-
*
|
|
545
|
-
* @internal
|
|
546
|
-
*/
|
|
547
|
-
declare function createFactsStore<S extends Schema>(options: CreateFactsStoreOptions<S>): FactsStore<S>;
|
|
548
|
-
/**
|
|
549
|
-
* Create a Proxy wrapper around a {@link FactsStore} for clean property-style
|
|
550
|
-
* access (`facts.phase`) with automatic dependency tracking.
|
|
551
|
-
*
|
|
552
|
-
* @remarks
|
|
553
|
-
* Reading a property calls `store.get()` (which tracks the access for
|
|
554
|
-
* auto-tracked derivations). Writing a property calls `store.set()` (which
|
|
555
|
-
* validates against the schema). The proxy also exposes `$store` for direct
|
|
556
|
-
* store access and `$snapshot()` for untracked reads.
|
|
557
|
-
*
|
|
558
|
-
* @param store - The underlying facts store to wrap
|
|
559
|
-
* @param schema - The schema definition used for `ownKeys` enumeration
|
|
560
|
-
* @returns A {@link Facts} proxy with property-style get/set and prototype pollution guards
|
|
561
|
-
*
|
|
562
|
-
* @example
|
|
563
|
-
* ```ts
|
|
564
|
-
* const store = createFactsStore({ schema: { phase: t.string() } });
|
|
565
|
-
* const facts = createFactsProxy(store, { phase: t.string() });
|
|
566
|
-
*
|
|
567
|
-
* facts.phase = "red";
|
|
568
|
-
* console.log(facts.phase); // "red"
|
|
569
|
-
* ```
|
|
570
|
-
*
|
|
571
|
-
* @internal
|
|
572
|
-
*/
|
|
573
|
-
declare function createFactsProxy<S extends Schema>(store: FactsStore<S>, schema: S): Facts<S>;
|
|
574
|
-
/**
|
|
575
|
-
* Convenience factory that creates both a {@link FactsStore} and its
|
|
576
|
-
* {@link createFactsProxy | proxy wrapper} in a single call.
|
|
577
|
-
*
|
|
578
|
-
* @remarks
|
|
579
|
-
* This is the recommended entry point when you need low-level store access
|
|
580
|
-
* outside of `createModule` / `createSystem`.
|
|
581
|
-
*
|
|
582
|
-
* @param options - Same options as {@link createFactsStore}
|
|
583
|
-
* @returns An object with `store` (the reactive Map-backed store) and `facts` (the Proxy accessor)
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* ```ts
|
|
587
|
-
* const { store, facts } = createFacts({
|
|
588
|
-
* schema: { phase: t.string<"red" | "green">() },
|
|
589
|
-
* });
|
|
590
|
-
*
|
|
591
|
-
* facts.phase = "red";
|
|
592
|
-
* console.log(facts.phase); // "red"
|
|
593
|
-
* store.subscribe(["phase"], () => console.log("phase changed"));
|
|
594
|
-
* ```
|
|
595
|
-
*
|
|
596
|
-
* @internal
|
|
597
|
-
*/
|
|
598
|
-
declare function createFacts<S extends Schema>(options: CreateFactsStoreOptions<S>): {
|
|
599
|
-
store: FactsStore<S>;
|
|
600
|
-
facts: Facts<S>;
|
|
601
|
-
};
|
|
602
497
|
|
|
603
498
|
/**
|
|
604
499
|
* Module - The declarative API for defining Directive modules
|
|
@@ -698,7 +593,7 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
|
|
|
698
593
|
* Create a module definition with full type inference.
|
|
699
594
|
*
|
|
700
595
|
* The consolidated schema provides:
|
|
701
|
-
* - Derivation composition (`
|
|
596
|
+
* - Derivation composition (`derived.otherDerivation` is typed)
|
|
702
597
|
* - Event dispatch (`system.dispatch({ type: "..." })` has autocomplete)
|
|
703
598
|
* - Resolver requirements (`req.payload` is typed based on requirement type)
|
|
704
599
|
*
|
|
@@ -732,9 +627,9 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
|
|
|
732
627
|
* },
|
|
733
628
|
* derive: {
|
|
734
629
|
* isRed: (facts) => facts.phase === "red",
|
|
735
|
-
* timeRemaining: (facts,
|
|
736
|
-
* //
|
|
737
|
-
* return
|
|
630
|
+
* timeRemaining: (facts, derived) => {
|
|
631
|
+
* // derived.isRed is typed as boolean!
|
|
632
|
+
* return derived.isRed ? 30 - facts.elapsed : 0;
|
|
738
633
|
* },
|
|
739
634
|
* },
|
|
740
635
|
* events: {
|
|
@@ -935,7 +830,7 @@ interface ModuleBuilder<M extends ModuleSchema = ModuleSchema> {
|
|
|
935
830
|
* Define derivation implementations for this module.
|
|
936
831
|
* Keys must match those declared in schema.derivations.
|
|
937
832
|
*/
|
|
938
|
-
derive<D extends Record<string, (facts: Facts<M["facts"]>,
|
|
833
|
+
derive<D extends Record<string, (facts: Facts<M["facts"]>, derived: DeriveAccessor<M>) => unknown>>(derivations: D): ModuleBuilder<M>;
|
|
939
834
|
/**
|
|
940
835
|
* Define event handler implementations for this module.
|
|
941
836
|
* Keys must match those declared in schema.events.
|
|
@@ -1450,20 +1345,6 @@ declare function createSystemWithStatus<M extends ModuleSchema>(options: CreateS
|
|
|
1450
1345
|
* - Requirement comparison and hashing
|
|
1451
1346
|
*/
|
|
1452
1347
|
|
|
1453
|
-
/**
|
|
1454
|
-
* Generate a stable identity string for a requirement.
|
|
1455
|
-
*
|
|
1456
|
-
* When no custom key function is provided, the ID is formed from the
|
|
1457
|
-
* requirement's `type` plus a deterministic JSON serialization of its
|
|
1458
|
-
* remaining properties. A custom {@link RequirementKeyFn} can override
|
|
1459
|
-
* this to control deduplication granularity.
|
|
1460
|
-
*
|
|
1461
|
-
* @param req - The requirement to generate an ID for.
|
|
1462
|
-
* @param keyFn - Optional custom key function that overrides the default identity logic.
|
|
1463
|
-
* @returns A stable string that uniquely identifies this requirement for deduplication.
|
|
1464
|
-
*
|
|
1465
|
-
* @public
|
|
1466
|
-
*/
|
|
1467
1348
|
declare function generateRequirementId(req: Requirement, keyFn?: RequirementKeyFn): string;
|
|
1468
1349
|
/**
|
|
1469
1350
|
* Create a typed requirement factory for a given requirement type string.
|
|
@@ -1639,6 +1520,120 @@ declare class RequirementSet {
|
|
|
1639
1520
|
};
|
|
1640
1521
|
}
|
|
1641
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
|
+
|
|
1642
1637
|
/**
|
|
1643
1638
|
* Derivations - Auto-tracked computed values with composition
|
|
1644
1639
|
*
|
|
@@ -1669,6 +1664,12 @@ interface DerivationsManager<S extends Schema, D extends DerivationsDef<S>> {
|
|
|
1669
1664
|
getDependencies(id: keyof D): Set<string>;
|
|
1670
1665
|
/** Register new derivation definitions (for dynamic module registration) */
|
|
1671
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;
|
|
1672
1673
|
}
|
|
1673
1674
|
/** Options for creating a derivations manager */
|
|
1674
1675
|
interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>> {
|
|
@@ -1792,6 +1793,26 @@ interface EffectsManager<_S extends Schema = Schema> {
|
|
|
1792
1793
|
* @param newDefs - New effect definitions to merge into the manager.
|
|
1793
1794
|
*/
|
|
1794
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>;
|
|
1795
1816
|
}
|
|
1796
1817
|
/**
|
|
1797
1818
|
* Configuration options accepted by {@link createEffectsManager}.
|
|
@@ -1963,6 +1984,30 @@ interface ConstraintsManager<_S extends Schema> {
|
|
|
1963
1984
|
* @param newDefs - New constraint definitions to merge into the manager.
|
|
1964
1985
|
*/
|
|
1965
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[]>;
|
|
1966
2011
|
}
|
|
1967
2012
|
/**
|
|
1968
2013
|
* Configuration options accepted by {@link createConstraintsManager}.
|
|
@@ -2124,6 +2169,31 @@ interface ResolversManager<_S extends Schema> {
|
|
|
2124
2169
|
* @param newDefs - New resolver definitions to merge into the manager.
|
|
2125
2170
|
*/
|
|
2126
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;
|
|
2127
2197
|
}
|
|
2128
2198
|
/**
|
|
2129
2199
|
* Configuration options accepted by {@link createResolversManager}.
|
|
@@ -2272,6 +2342,10 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
2272
2342
|
emitTimeTravel(from: number, to: number): void;
|
|
2273
2343
|
emitError(error: DirectiveError): void;
|
|
2274
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;
|
|
2275
2349
|
emitRunComplete(run: RunChangelogEntry): void;
|
|
2276
2350
|
}
|
|
2277
2351
|
/**
|
|
@@ -2640,4 +2714,4 @@ declare const Backoff: {
|
|
|
2640
2714
|
readonly Exponential: "exponential";
|
|
2641
2715
|
};
|
|
2642
2716
|
|
|
2643
|
-
export { Backoff, BatchConfig, type Branded, type ChainableSchemaType,
|
|
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 };
|