@directive-run/core 1.4.0 → 1.6.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/adapter-utils.cjs +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/{chunk-FK7BD7XT.js → chunk-EH2Q754B.js} +3 -3
- package/dist/chunk-EH2Q754B.js.map +1 -0
- package/dist/chunk-EOLY64E6.cjs +3 -0
- package/dist/chunk-EOLY64E6.cjs.map +1 -0
- package/dist/chunk-K3KVGWLP.cjs +3 -0
- package/dist/chunk-K3KVGWLP.cjs.map +1 -0
- package/dist/chunk-OVNPYGYJ.js +3 -0
- package/dist/chunk-OVNPYGYJ.js.map +1 -0
- package/dist/chunk-QOK7CHOW.js +16 -0
- package/dist/chunk-QOK7CHOW.js.map +1 -0
- package/dist/{chunk-DDUARSUH.cjs → chunk-S3CFYDIB.cjs} +3 -3
- package/dist/chunk-S3CFYDIB.cjs.map +1 -0
- package/dist/chunk-T4ZO4IYL.cjs +16 -0
- package/dist/chunk-T4ZO4IYL.cjs.map +1 -0
- package/dist/chunk-T6IJUWYR.js +3 -0
- package/dist/chunk-T6IJUWYR.js.map +1 -0
- package/dist/{helpers-BUY1lYCX.d.cts → helpers-BwAThjnJ.d.ts} +12 -2
- package/dist/{helpers-D6LcRum7.d.ts → helpers-CG27mEGG.d.cts} +12 -2
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +413 -5
- package/dist/index.d.ts +413 -5
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.cts +86 -40
- package/dist/internals.d.ts +86 -40
- package/dist/internals.js +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +11 -8
- package/dist/plugins/index.d.ts +11 -8
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/{plugins-Dy1C8GtT.d.cts → plugins-DvrsPhzx.d.cts} +471 -68
- package/dist/{plugins-Dy1C8GtT.d.ts → plugins-DvrsPhzx.d.ts} +471 -68
- package/dist/system-5BSCMT63.cjs +2 -0
- package/dist/{system-2THXJBFM.cjs.map → system-5BSCMT63.cjs.map} +1 -1
- package/dist/system-DMJ6XEJ7.js +2 -0
- package/dist/{system-JIO36ALC.js.map → system-DMJ6XEJ7.js.map} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/worker.cjs +1 -1
- 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 +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4CMO5OVZ.js +0 -3
- package/dist/chunk-4CMO5OVZ.js.map +0 -1
- package/dist/chunk-BEJ6ICA7.cjs +0 -3
- package/dist/chunk-BEJ6ICA7.cjs.map +0 -1
- package/dist/chunk-DDUARSUH.cjs.map +0 -1
- package/dist/chunk-E2WETPLH.js +0 -3
- package/dist/chunk-E2WETPLH.js.map +0 -1
- package/dist/chunk-FK7BD7XT.js.map +0 -1
- package/dist/chunk-LFMRWCIG.js +0 -16
- package/dist/chunk-LFMRWCIG.js.map +0 -1
- package/dist/chunk-TUS5WDVE.cjs +0 -3
- package/dist/chunk-TUS5WDVE.cjs.map +0 -1
- package/dist/chunk-VSHSYVSY.cjs +0 -16
- package/dist/chunk-VSHSYVSY.cjs.map +0 -1
- package/dist/system-2THXJBFM.cjs +0 -2
- package/dist/system-JIO36ALC.js +0 -2
package/dist/internals.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkK3KVGWLP_cjs=require('./chunk-K3KVGWLP.cjs'),chunkS3CFYDIB_cjs=require('./chunk-S3CFYDIB.cjs'),chunkEOLY64E6_cjs=require('./chunk-EOLY64E6.cjs');Object.defineProperty(exports,"createConstraintFactory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.q}});Object.defineProperty(exports,"createConstraintsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.D}});Object.defineProperty(exports,"createDerivationsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.E}});Object.defineProperty(exports,"createDisabledHistory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.x}});Object.defineProperty(exports,"createEffectsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.F}});Object.defineProperty(exports,"createEngine",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.N}});Object.defineProperty(exports,"createErrorBoundaryManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.H}});Object.defineProperty(exports,"createFacts",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.K}});Object.defineProperty(exports,"createFactsProxy",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.J}});Object.defineProperty(exports,"createFactsStore",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.I}});Object.defineProperty(exports,"createHistoryManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.w}});Object.defineProperty(exports,"createPluginManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.L}});Object.defineProperty(exports,"createResolverFactory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.r}});Object.defineProperty(exports,"createResolversManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.M}});Object.defineProperty(exports,"createRetryLaterManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.G}});Object.defineProperty(exports,"getCurrentDeps",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.g}});Object.defineProperty(exports,"isTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.h}});Object.defineProperty(exports,"trackAccess",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.k}});Object.defineProperty(exports,"withTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.i}});Object.defineProperty(exports,"withoutTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.j}});Object.defineProperty(exports,"safeStringify",{enumerable:true,get:function(){return chunkEOLY64E6_cjs.n}});//# sourceMappingURL=internals.cjs.map
|
|
2
2
|
//# sourceMappingURL=internals.cjs.map
|
package/dist/internals.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { b as DerivationsDef, c as DerivedValues } from './helpers-
|
|
4
|
-
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-
|
|
1
|
+
import { a8 as Schema, ai as FactsStore, b as Facts, D as DefinitionMeta, E as EffectsDef, aj as ConstraintsDef, t as RequirementKeyFn, R as RequirementWithId, ak as ConstraintState, a as FactPredicate, C as ClauseResult, al as ResolversDef, am as ResolverStatus, s as Requirement, p as Plugin, aa as System, an as FactChange, G as FactsSnapshot, ao as ReconcileResult, a9 as Snapshot, u as DirectiveError, ap as RecoveryStrategy, af as TraceEntry, aq as ErrorSource, r as ErrorBoundaryConfig, ar as RetryLaterConfig, H as HistoryAPI, I as HistoryOption, ab as SystemConfig } from './plugins-DvrsPhzx.cjs';
|
|
2
|
+
export { as as BatchItemResult, at as BatchResolveResults, au as ConstraintsControl, av as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aw as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, ax as CrossModuleEffectDef, i as CrossModuleEffectsDef, ay as CrossModuleFactsWithSelf, az as DerivationKeys, aA as DerivationReturnType, aB as DerivationsControl, aC as DerivationsSchema, aD as DeriveAccessor, aE as DispatchEventsFromSchema, v as DistributableSnapshot, w as DistributableSnapshotOptions, aF as EffectCleanup, aG as EffectsControl, aH as EventPayloadSchema, aI as EventsAccessor, aJ as EventsAccessorFromSchema, aK as EventsDef, aL as EventsSchema, aM as FactKeys, aN as FactReturnType, aO as FlexibleEventHandler, aP as HistoryConfig, aQ as InferEventPayloadFromSchema, aR as InferRequirementPayloadFromSchema, aS as InferSchema, aT as MutableNamespacedFacts, aU as NamespacedDerivations, aV as NamespacedEventsAccessor, aW as NamespacedFacts, aX as ObservableKeys, aY as RequirementExplanation, aZ as RequirementOutput, a_ as RequirementPayloadSchema, a$ as RequirementsSchema, b0 as ResolverContext, b1 as ResolversControl, b2 as SnapshotMeta, b3 as SystemEvent, b4 as TraceConfig, b5 as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, c as TypedEventsDef, b6 as TypedResolverContext, b7 as TypedResolverDef, e as TypedResolversDef, b8 as UnionEvents } from './plugins-DvrsPhzx.cjs';
|
|
3
|
+
import { b as DerivationsDef, c as DerivedValues } from './helpers-CG27mEGG.cjs';
|
|
4
|
+
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-CG27mEGG.cjs';
|
|
5
5
|
export { g as safeStringify } from './utils-BnQajqPu.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -369,16 +369,6 @@ interface CreateEffectsOptions<S extends Schema> {
|
|
|
369
369
|
*/
|
|
370
370
|
declare function createEffectsManager<S extends Schema>(options: CreateEffectsOptions<S>): EffectsManager<S>;
|
|
371
371
|
|
|
372
|
-
/**
|
|
373
|
-
* Constraints - Rules that produce requirements when conditions aren't met
|
|
374
|
-
*
|
|
375
|
-
* Features:
|
|
376
|
-
* - Sync and async constraint evaluation
|
|
377
|
-
* - Priority ordering (higher runs first)
|
|
378
|
-
* - Timeout handling for async constraints
|
|
379
|
-
* - Error isolation
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
372
|
/**
|
|
383
373
|
* Manager returned by {@link createConstraintsManager} that evaluates
|
|
384
374
|
* constraint rules against the current facts and produces unmet
|
|
@@ -512,6 +502,19 @@ interface ConstraintsManager<_S extends Schema> {
|
|
|
512
502
|
* @param requirementType - The requirement type string to remove.
|
|
513
503
|
*/
|
|
514
504
|
removeRequirementKey(requirementType: string): void;
|
|
505
|
+
/**
|
|
506
|
+
* Return the original {@link FactPredicate} spec a constraint was declared
|
|
507
|
+
* with — present only when the constraint's `when` was provided as data.
|
|
508
|
+
* Used by `system.inspect()` / `system.explain()` and devtools to render
|
|
509
|
+
* the clause structure.
|
|
510
|
+
*/
|
|
511
|
+
getWhenSpec(id: string): FactPredicate<Record<string, unknown>> | undefined;
|
|
512
|
+
/**
|
|
513
|
+
* Evaluate a data-form `when` and return the per-clause breakdown
|
|
514
|
+
* (which clauses passed, which failed, against what fact values).
|
|
515
|
+
* Returns `undefined` for constraints whose `when` is a function.
|
|
516
|
+
*/
|
|
517
|
+
explainWhen(id: string): ClauseResult[] | undefined;
|
|
515
518
|
}
|
|
516
519
|
/**
|
|
517
520
|
* Configuration options accepted by {@link createConstraintsManager}.
|
|
@@ -610,8 +613,16 @@ interface ResolversManager<_S extends Schema> {
|
|
|
610
613
|
* for batch processing instead of being resolved immediately.
|
|
611
614
|
*
|
|
612
615
|
* @param req - The requirement (with a stable identity ID) to resolve.
|
|
616
|
+
* @param options.factsBaseline - Optional pre-dispatch facts snapshot
|
|
617
|
+
* shared by every resolver dispatched in the same reconcile tick. Used
|
|
618
|
+
* by RFC-1 constraint-binding to seed each resolver's `expected` map
|
|
619
|
+
* from a value that pre-dates any sibling resolver's writes, preventing
|
|
620
|
+
* the sibling-clobber gap where resolver 2 silently overwrites
|
|
621
|
+
* resolver 1's owned write.
|
|
613
622
|
*/
|
|
614
|
-
resolve(req: RequirementWithId
|
|
623
|
+
resolve(req: RequirementWithId, options?: {
|
|
624
|
+
factsBaseline?: Readonly<Record<string, unknown>>;
|
|
625
|
+
}): void;
|
|
615
626
|
/**
|
|
616
627
|
* Cancel an in-flight or batch-queued resolver by requirement ID.
|
|
617
628
|
*
|
|
@@ -622,6 +633,20 @@ interface ResolversManager<_S extends Schema> {
|
|
|
622
633
|
* @param requirementId - The unique requirement ID to cancel.
|
|
623
634
|
*/
|
|
624
635
|
cancel(requirementId: string): void;
|
|
636
|
+
/**
|
|
637
|
+
* Untrack an in-flight resolver by requirement ID **without** aborting it
|
|
638
|
+
* (RFC-0003 resolver constraint-binding).
|
|
639
|
+
*
|
|
640
|
+
* @remarks
|
|
641
|
+
* Used for bound resolvers whose triggering requirement was removed: the
|
|
642
|
+
* resolver runs to completion (its data writes land; the binding still
|
|
643
|
+
* guards owned facts) but it no longer occupies the `inflight` slot, so the
|
|
644
|
+
* same requirement re-dispatches cleanly if it returns. A no-op if the
|
|
645
|
+
* requirement is not in-flight.
|
|
646
|
+
*
|
|
647
|
+
* @param requirementId - The unique requirement ID to detach.
|
|
648
|
+
*/
|
|
649
|
+
detach(requirementId: string): void;
|
|
625
650
|
/**
|
|
626
651
|
* Cancel every in-flight resolver and flush all pending batch queues.
|
|
627
652
|
*/
|
|
@@ -709,23 +734,18 @@ interface ResolversManager<_S extends Schema> {
|
|
|
709
734
|
* Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
|
|
710
735
|
*
|
|
711
736
|
* The engine wires this lookup into the resolvers manager so that a resolver
|
|
712
|
-
* dispatched from a constraint with
|
|
713
|
-
*
|
|
737
|
+
* dispatched from a constraint with an `owns` field knows which facts it
|
|
738
|
+
* *owns* — writes to those are clobber-checked (see {@link createBoundFacts}).
|
|
714
739
|
*
|
|
715
|
-
* Returns `null`
|
|
716
|
-
*
|
|
717
|
-
*
|
|
740
|
+
* Returns `undefined`/`null` when the source constraint is unknown or has no
|
|
741
|
+
* `owns` field — in which case binding is a no-op and the resolver behaves
|
|
742
|
+
* exactly as before.
|
|
718
743
|
*
|
|
719
744
|
* @internal
|
|
720
745
|
*/
|
|
721
|
-
interface ConstraintBindingInfo
|
|
722
|
-
/**
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* The constraint's `when()` predicate, narrowed to a sync signature.
|
|
726
|
-
* Only populated when `mode === 'auto'` and the constraint is sync.
|
|
727
|
-
*/
|
|
728
|
-
when: ((facts: Facts<S>) => boolean) | null;
|
|
746
|
+
interface ConstraintBindingInfo {
|
|
747
|
+
/** Fact keys the triggering resolver owns; writes to these are clobber-checked. */
|
|
748
|
+
readonly fields: readonly string[];
|
|
729
749
|
}
|
|
730
750
|
/**
|
|
731
751
|
* Configuration options accepted by {@link createResolversManager}.
|
|
@@ -743,11 +763,10 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
743
763
|
* Look up binding info for a source constraint id (RFC-1).
|
|
744
764
|
*
|
|
745
765
|
* Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
|
|
746
|
-
* returns the constraint's
|
|
747
|
-
*
|
|
748
|
-
* does not apply.
|
|
766
|
+
* returns the constraint's owned fact keys. Return `undefined` if the
|
|
767
|
+
* constraint is unknown or has no `owns` field.
|
|
749
768
|
*/
|
|
750
|
-
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo
|
|
769
|
+
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo | undefined;
|
|
751
770
|
/** Called when a resolver begins execution. */
|
|
752
771
|
onStart?: (resolver: string, req: RequirementWithId) => void;
|
|
753
772
|
/** Called when a resolver completes successfully, with the wall-clock duration in ms. */
|
|
@@ -758,6 +777,19 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
758
777
|
onRetry?: (resolver: string, req: RequirementWithId, attempt: number) => void;
|
|
759
778
|
/** Called when a resolver is canceled via {@link ResolversManager.cancel | cancel}. */
|
|
760
779
|
onCancel?: (resolver: string, req: RequirementWithId) => void;
|
|
780
|
+
/**
|
|
781
|
+
* Called when a bound resolver's owned-fact write is dropped because the
|
|
782
|
+
* fact was changed by something outside the resolver (RFC-0003 clobber).
|
|
783
|
+
* Fires once per dropped write; the resolver's `AbortController` is also
|
|
784
|
+
* aborted in the same step. Wired to plugins for observability.
|
|
785
|
+
*/
|
|
786
|
+
onClobber?: (resolver: string, req: RequirementWithId, fact: string, expected: unknown, actual: unknown) => void;
|
|
787
|
+
/**
|
|
788
|
+
* Called once when a single resolver instance exceeds the per-instance
|
|
789
|
+
* clobber-event cap. `dropped` is the number of per-clobber events
|
|
790
|
+
* suppressed. Rate-limits clobber-event amplification (RFC-0003).
|
|
791
|
+
*/
|
|
792
|
+
onClobberSuppressed?: (resolver: string, req: RequirementWithId, dropped: number) => void;
|
|
761
793
|
/** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
|
|
762
794
|
onResolutionComplete?: () => void;
|
|
763
795
|
/**
|
|
@@ -768,16 +800,15 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
768
800
|
*/
|
|
769
801
|
onRequeue?: (requirementId: string) => void;
|
|
770
802
|
}
|
|
771
|
-
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
772
|
-
|
|
773
803
|
/**
|
|
774
|
-
*
|
|
804
|
+
* Creates a resolver manager that tracks active resolver instances and
|
|
805
|
+
* coordinates their lifecycle (start / complete / error / cancel) against
|
|
806
|
+
* the engine's requirement graph.
|
|
775
807
|
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
* - Multiple plugins can be composed
|
|
779
|
-
* - Plugins execute in registration order
|
|
808
|
+
* @param options - resolver definitions, facts reference, and event hooks
|
|
809
|
+
* @returns the manager handle used by the engine to drive resolver invocations
|
|
780
810
|
*/
|
|
811
|
+
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
781
812
|
|
|
782
813
|
/**
|
|
783
814
|
* Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
|
|
@@ -826,7 +857,7 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
826
857
|
emitDerivationInvalidate(id: string): void;
|
|
827
858
|
emitReconcileStart(snapshot: FactsSnapshot<any>): void;
|
|
828
859
|
emitReconcileEnd(result: ReconcileResult): void;
|
|
829
|
-
emitConstraintEvaluate(id: string, active: boolean): void;
|
|
860
|
+
emitConstraintEvaluate(id: string, active: boolean, whenExplain?: ClauseResult[]): void;
|
|
830
861
|
emitConstraintError(id: string, error: unknown): void;
|
|
831
862
|
emitRequirementCreated(req: RequirementWithId): void;
|
|
832
863
|
emitRequirementMet(req: RequirementWithId, byResolver: string): void;
|
|
@@ -836,6 +867,21 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
836
867
|
emitResolverError(resolver: string, req: RequirementWithId, error: unknown): void;
|
|
837
868
|
emitResolverRetry(resolver: string, req: RequirementWithId, attempt: number): void;
|
|
838
869
|
emitResolverCancel(resolver: string, req: RequirementWithId): void;
|
|
870
|
+
emitResolverWriteRejected(event: {
|
|
871
|
+
kind: "rejection";
|
|
872
|
+
resolver: string;
|
|
873
|
+
req: RequirementWithId;
|
|
874
|
+
reason: "clobbered";
|
|
875
|
+
fact: string;
|
|
876
|
+
expected: unknown;
|
|
877
|
+
actual: unknown;
|
|
878
|
+
} | {
|
|
879
|
+
kind: "summary";
|
|
880
|
+
resolver: string;
|
|
881
|
+
req: RequirementWithId;
|
|
882
|
+
reason: "clobbered";
|
|
883
|
+
dropped: number;
|
|
884
|
+
}): void;
|
|
839
885
|
emitEffectRun(id: string): void;
|
|
840
886
|
emitEffectError(id: string, error: unknown): void;
|
|
841
887
|
emitSnapshot(snapshot: Snapshot): void;
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { b as DerivationsDef, c as DerivedValues } from './helpers-
|
|
4
|
-
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-
|
|
1
|
+
import { a8 as Schema, ai as FactsStore, b as Facts, D as DefinitionMeta, E as EffectsDef, aj as ConstraintsDef, t as RequirementKeyFn, R as RequirementWithId, ak as ConstraintState, a as FactPredicate, C as ClauseResult, al as ResolversDef, am as ResolverStatus, s as Requirement, p as Plugin, aa as System, an as FactChange, G as FactsSnapshot, ao as ReconcileResult, a9 as Snapshot, u as DirectiveError, ap as RecoveryStrategy, af as TraceEntry, aq as ErrorSource, r as ErrorBoundaryConfig, ar as RetryLaterConfig, H as HistoryAPI, I as HistoryOption, ab as SystemConfig } from './plugins-DvrsPhzx.js';
|
|
2
|
+
export { as as BatchItemResult, at as BatchResolveResults, au as ConstraintsControl, av as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aw as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, ax as CrossModuleEffectDef, i as CrossModuleEffectsDef, ay as CrossModuleFactsWithSelf, az as DerivationKeys, aA as DerivationReturnType, aB as DerivationsControl, aC as DerivationsSchema, aD as DeriveAccessor, aE as DispatchEventsFromSchema, v as DistributableSnapshot, w as DistributableSnapshotOptions, aF as EffectCleanup, aG as EffectsControl, aH as EventPayloadSchema, aI as EventsAccessor, aJ as EventsAccessorFromSchema, aK as EventsDef, aL as EventsSchema, aM as FactKeys, aN as FactReturnType, aO as FlexibleEventHandler, aP as HistoryConfig, aQ as InferEventPayloadFromSchema, aR as InferRequirementPayloadFromSchema, aS as InferSchema, aT as MutableNamespacedFacts, aU as NamespacedDerivations, aV as NamespacedEventsAccessor, aW as NamespacedFacts, aX as ObservableKeys, aY as RequirementExplanation, aZ as RequirementOutput, a_ as RequirementPayloadSchema, a$ as RequirementsSchema, b0 as ResolverContext, b1 as ResolversControl, b2 as SnapshotMeta, b3 as SystemEvent, b4 as TraceConfig, b5 as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, c as TypedEventsDef, b6 as TypedResolverContext, b7 as TypedResolverDef, e as TypedResolversDef, b8 as UnionEvents } from './plugins-DvrsPhzx.js';
|
|
3
|
+
import { b as DerivationsDef, c as DerivedValues } from './helpers-BwAThjnJ.js';
|
|
4
|
+
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-BwAThjnJ.js';
|
|
5
5
|
export { g as safeStringify } from './utils-BnQajqPu.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -369,16 +369,6 @@ interface CreateEffectsOptions<S extends Schema> {
|
|
|
369
369
|
*/
|
|
370
370
|
declare function createEffectsManager<S extends Schema>(options: CreateEffectsOptions<S>): EffectsManager<S>;
|
|
371
371
|
|
|
372
|
-
/**
|
|
373
|
-
* Constraints - Rules that produce requirements when conditions aren't met
|
|
374
|
-
*
|
|
375
|
-
* Features:
|
|
376
|
-
* - Sync and async constraint evaluation
|
|
377
|
-
* - Priority ordering (higher runs first)
|
|
378
|
-
* - Timeout handling for async constraints
|
|
379
|
-
* - Error isolation
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
372
|
/**
|
|
383
373
|
* Manager returned by {@link createConstraintsManager} that evaluates
|
|
384
374
|
* constraint rules against the current facts and produces unmet
|
|
@@ -512,6 +502,19 @@ interface ConstraintsManager<_S extends Schema> {
|
|
|
512
502
|
* @param requirementType - The requirement type string to remove.
|
|
513
503
|
*/
|
|
514
504
|
removeRequirementKey(requirementType: string): void;
|
|
505
|
+
/**
|
|
506
|
+
* Return the original {@link FactPredicate} spec a constraint was declared
|
|
507
|
+
* with — present only when the constraint's `when` was provided as data.
|
|
508
|
+
* Used by `system.inspect()` / `system.explain()` and devtools to render
|
|
509
|
+
* the clause structure.
|
|
510
|
+
*/
|
|
511
|
+
getWhenSpec(id: string): FactPredicate<Record<string, unknown>> | undefined;
|
|
512
|
+
/**
|
|
513
|
+
* Evaluate a data-form `when` and return the per-clause breakdown
|
|
514
|
+
* (which clauses passed, which failed, against what fact values).
|
|
515
|
+
* Returns `undefined` for constraints whose `when` is a function.
|
|
516
|
+
*/
|
|
517
|
+
explainWhen(id: string): ClauseResult[] | undefined;
|
|
515
518
|
}
|
|
516
519
|
/**
|
|
517
520
|
* Configuration options accepted by {@link createConstraintsManager}.
|
|
@@ -610,8 +613,16 @@ interface ResolversManager<_S extends Schema> {
|
|
|
610
613
|
* for batch processing instead of being resolved immediately.
|
|
611
614
|
*
|
|
612
615
|
* @param req - The requirement (with a stable identity ID) to resolve.
|
|
616
|
+
* @param options.factsBaseline - Optional pre-dispatch facts snapshot
|
|
617
|
+
* shared by every resolver dispatched in the same reconcile tick. Used
|
|
618
|
+
* by RFC-1 constraint-binding to seed each resolver's `expected` map
|
|
619
|
+
* from a value that pre-dates any sibling resolver's writes, preventing
|
|
620
|
+
* the sibling-clobber gap where resolver 2 silently overwrites
|
|
621
|
+
* resolver 1's owned write.
|
|
613
622
|
*/
|
|
614
|
-
resolve(req: RequirementWithId
|
|
623
|
+
resolve(req: RequirementWithId, options?: {
|
|
624
|
+
factsBaseline?: Readonly<Record<string, unknown>>;
|
|
625
|
+
}): void;
|
|
615
626
|
/**
|
|
616
627
|
* Cancel an in-flight or batch-queued resolver by requirement ID.
|
|
617
628
|
*
|
|
@@ -622,6 +633,20 @@ interface ResolversManager<_S extends Schema> {
|
|
|
622
633
|
* @param requirementId - The unique requirement ID to cancel.
|
|
623
634
|
*/
|
|
624
635
|
cancel(requirementId: string): void;
|
|
636
|
+
/**
|
|
637
|
+
* Untrack an in-flight resolver by requirement ID **without** aborting it
|
|
638
|
+
* (RFC-0003 resolver constraint-binding).
|
|
639
|
+
*
|
|
640
|
+
* @remarks
|
|
641
|
+
* Used for bound resolvers whose triggering requirement was removed: the
|
|
642
|
+
* resolver runs to completion (its data writes land; the binding still
|
|
643
|
+
* guards owned facts) but it no longer occupies the `inflight` slot, so the
|
|
644
|
+
* same requirement re-dispatches cleanly if it returns. A no-op if the
|
|
645
|
+
* requirement is not in-flight.
|
|
646
|
+
*
|
|
647
|
+
* @param requirementId - The unique requirement ID to detach.
|
|
648
|
+
*/
|
|
649
|
+
detach(requirementId: string): void;
|
|
625
650
|
/**
|
|
626
651
|
* Cancel every in-flight resolver and flush all pending batch queues.
|
|
627
652
|
*/
|
|
@@ -709,23 +734,18 @@ interface ResolversManager<_S extends Schema> {
|
|
|
709
734
|
* Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
|
|
710
735
|
*
|
|
711
736
|
* The engine wires this lookup into the resolvers manager so that a resolver
|
|
712
|
-
* dispatched from a constraint with
|
|
713
|
-
*
|
|
737
|
+
* dispatched from a constraint with an `owns` field knows which facts it
|
|
738
|
+
* *owns* — writes to those are clobber-checked (see {@link createBoundFacts}).
|
|
714
739
|
*
|
|
715
|
-
* Returns `null`
|
|
716
|
-
*
|
|
717
|
-
*
|
|
740
|
+
* Returns `undefined`/`null` when the source constraint is unknown or has no
|
|
741
|
+
* `owns` field — in which case binding is a no-op and the resolver behaves
|
|
742
|
+
* exactly as before.
|
|
718
743
|
*
|
|
719
744
|
* @internal
|
|
720
745
|
*/
|
|
721
|
-
interface ConstraintBindingInfo
|
|
722
|
-
/**
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* The constraint's `when()` predicate, narrowed to a sync signature.
|
|
726
|
-
* Only populated when `mode === 'auto'` and the constraint is sync.
|
|
727
|
-
*/
|
|
728
|
-
when: ((facts: Facts<S>) => boolean) | null;
|
|
746
|
+
interface ConstraintBindingInfo {
|
|
747
|
+
/** Fact keys the triggering resolver owns; writes to these are clobber-checked. */
|
|
748
|
+
readonly fields: readonly string[];
|
|
729
749
|
}
|
|
730
750
|
/**
|
|
731
751
|
* Configuration options accepted by {@link createResolversManager}.
|
|
@@ -743,11 +763,10 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
743
763
|
* Look up binding info for a source constraint id (RFC-1).
|
|
744
764
|
*
|
|
745
765
|
* Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
|
|
746
|
-
* returns the constraint's
|
|
747
|
-
*
|
|
748
|
-
* does not apply.
|
|
766
|
+
* returns the constraint's owned fact keys. Return `undefined` if the
|
|
767
|
+
* constraint is unknown or has no `owns` field.
|
|
749
768
|
*/
|
|
750
|
-
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo
|
|
769
|
+
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo | undefined;
|
|
751
770
|
/** Called when a resolver begins execution. */
|
|
752
771
|
onStart?: (resolver: string, req: RequirementWithId) => void;
|
|
753
772
|
/** Called when a resolver completes successfully, with the wall-clock duration in ms. */
|
|
@@ -758,6 +777,19 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
758
777
|
onRetry?: (resolver: string, req: RequirementWithId, attempt: number) => void;
|
|
759
778
|
/** Called when a resolver is canceled via {@link ResolversManager.cancel | cancel}. */
|
|
760
779
|
onCancel?: (resolver: string, req: RequirementWithId) => void;
|
|
780
|
+
/**
|
|
781
|
+
* Called when a bound resolver's owned-fact write is dropped because the
|
|
782
|
+
* fact was changed by something outside the resolver (RFC-0003 clobber).
|
|
783
|
+
* Fires once per dropped write; the resolver's `AbortController` is also
|
|
784
|
+
* aborted in the same step. Wired to plugins for observability.
|
|
785
|
+
*/
|
|
786
|
+
onClobber?: (resolver: string, req: RequirementWithId, fact: string, expected: unknown, actual: unknown) => void;
|
|
787
|
+
/**
|
|
788
|
+
* Called once when a single resolver instance exceeds the per-instance
|
|
789
|
+
* clobber-event cap. `dropped` is the number of per-clobber events
|
|
790
|
+
* suppressed. Rate-limits clobber-event amplification (RFC-0003).
|
|
791
|
+
*/
|
|
792
|
+
onClobberSuppressed?: (resolver: string, req: RequirementWithId, dropped: number) => void;
|
|
761
793
|
/** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
|
|
762
794
|
onResolutionComplete?: () => void;
|
|
763
795
|
/**
|
|
@@ -768,16 +800,15 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
768
800
|
*/
|
|
769
801
|
onRequeue?: (requirementId: string) => void;
|
|
770
802
|
}
|
|
771
|
-
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
772
|
-
|
|
773
803
|
/**
|
|
774
|
-
*
|
|
804
|
+
* Creates a resolver manager that tracks active resolver instances and
|
|
805
|
+
* coordinates their lifecycle (start / complete / error / cancel) against
|
|
806
|
+
* the engine's requirement graph.
|
|
775
807
|
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
* - Multiple plugins can be composed
|
|
779
|
-
* - Plugins execute in registration order
|
|
808
|
+
* @param options - resolver definitions, facts reference, and event hooks
|
|
809
|
+
* @returns the manager handle used by the engine to drive resolver invocations
|
|
780
810
|
*/
|
|
811
|
+
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
781
812
|
|
|
782
813
|
/**
|
|
783
814
|
* Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
|
|
@@ -826,7 +857,7 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
826
857
|
emitDerivationInvalidate(id: string): void;
|
|
827
858
|
emitReconcileStart(snapshot: FactsSnapshot<any>): void;
|
|
828
859
|
emitReconcileEnd(result: ReconcileResult): void;
|
|
829
|
-
emitConstraintEvaluate(id: string, active: boolean): void;
|
|
860
|
+
emitConstraintEvaluate(id: string, active: boolean, whenExplain?: ClauseResult[]): void;
|
|
830
861
|
emitConstraintError(id: string, error: unknown): void;
|
|
831
862
|
emitRequirementCreated(req: RequirementWithId): void;
|
|
832
863
|
emitRequirementMet(req: RequirementWithId, byResolver: string): void;
|
|
@@ -836,6 +867,21 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
836
867
|
emitResolverError(resolver: string, req: RequirementWithId, error: unknown): void;
|
|
837
868
|
emitResolverRetry(resolver: string, req: RequirementWithId, attempt: number): void;
|
|
838
869
|
emitResolverCancel(resolver: string, req: RequirementWithId): void;
|
|
870
|
+
emitResolverWriteRejected(event: {
|
|
871
|
+
kind: "rejection";
|
|
872
|
+
resolver: string;
|
|
873
|
+
req: RequirementWithId;
|
|
874
|
+
reason: "clobbered";
|
|
875
|
+
fact: string;
|
|
876
|
+
expected: unknown;
|
|
877
|
+
actual: unknown;
|
|
878
|
+
} | {
|
|
879
|
+
kind: "summary";
|
|
880
|
+
resolver: string;
|
|
881
|
+
req: RequirementWithId;
|
|
882
|
+
reason: "clobbered";
|
|
883
|
+
dropped: number;
|
|
884
|
+
}): void;
|
|
839
885
|
emitEffectRun(id: string): void;
|
|
840
886
|
emitEffectError(id: string, error: unknown): void;
|
|
841
887
|
emitSnapshot(snapshot: Snapshot): void;
|
package/dist/internals.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{q as createConstraintFactory,D as createConstraintsManager,E as createDerivationsManager,x as createDisabledHistory,F as createEffectsManager,N as createEngine,H as createErrorBoundaryManager,K as createFacts,J as createFactsProxy,I as createFactsStore,w as createHistoryManager,L as createPluginManager,r as createResolverFactory,M as createResolversManager,G as createRetryLaterManager}from'./chunk-OVNPYGYJ.js';export{g as getCurrentDeps,h as isTracking,k as trackAccess,i as withTracking,j as withoutTracking}from'./chunk-EH2Q754B.js';export{n as safeStringify}from'./chunk-T6IJUWYR.js';//# sourceMappingURL=internals.js.map
|
|
2
2
|
//# sourceMappingURL=internals.js.map
|