@directive-run/core 1.1.2 → 1.4.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-DDUARSUH.cjs +7 -0
- package/dist/chunk-DDUARSUH.cjs.map +1 -0
- package/dist/chunk-E2WETPLH.js +3 -0
- package/dist/chunk-E2WETPLH.js.map +1 -0
- package/dist/chunk-FK7BD7XT.js +7 -0
- package/dist/chunk-FK7BD7XT.js.map +1 -0
- package/dist/chunk-LFMRWCIG.js +16 -0
- package/dist/chunk-LFMRWCIG.js.map +1 -0
- package/dist/chunk-TUS5WDVE.cjs +3 -0
- package/dist/chunk-TUS5WDVE.cjs.map +1 -0
- package/dist/chunk-VSHSYVSY.cjs +16 -0
- package/dist/chunk-VSHSYVSY.cjs.map +1 -0
- package/dist/{helpers-mM-gApmO.d.cts → helpers-BUY1lYCX.d.cts} +1 -1
- package/dist/{helpers-BLtqbSnA.d.ts → helpers-D6LcRum7.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +307 -8
- package/dist/index.d.ts +307 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.cts +42 -4
- package/dist/internals.d.ts +42 -4
- package/dist/internals.js +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/{plugins-2i_wXhw1.d.cts → plugins-Dy1C8GtT.d.cts} +182 -2
- package/dist/{plugins-2i_wXhw1.d.ts → plugins-Dy1C8GtT.d.ts} +182 -2
- package/dist/system-2THXJBFM.cjs +2 -0
- package/dist/{system-GTVD42IW.cjs.map → system-2THXJBFM.cjs.map} +1 -1
- package/dist/system-JIO36ALC.js +2 -0
- package/dist/{system-RSS5FWVO.js.map → system-JIO36ALC.js.map} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +37 -2
- package/dist/testing.d.ts +37 -2
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2CAU4M66.cjs +0 -3
- package/dist/chunk-2CAU4M66.cjs.map +0 -1
- package/dist/chunk-7K4NABPI.js +0 -16
- package/dist/chunk-7K4NABPI.js.map +0 -1
- package/dist/chunk-EUWV4Y5C.js +0 -3
- package/dist/chunk-EUWV4Y5C.js.map +0 -1
- package/dist/chunk-GMFH2Z6C.cjs +0 -16
- package/dist/chunk-GMFH2Z6C.cjs.map +0 -1
- package/dist/chunk-KKHSUZA5.cjs +0 -2
- package/dist/chunk-KKHSUZA5.cjs.map +0 -1
- package/dist/chunk-LN4YQDLL.js +0 -2
- package/dist/chunk-LN4YQDLL.js.map +0 -1
- package/dist/system-GTVD42IW.cjs +0 -2
- package/dist/system-RSS5FWVO.js +0 -2
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ResolverStatus, o as Requirement, P as Plugin, Z as System,
|
|
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 { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ConstraintBindMode, aa as ResolverStatus, o as Requirement, P as Plugin, Z as System, ab as FactChange, w as FactsSnapshot, ac as ReconcileResult, Y as Snapshot, q as DirectiveError, ad as RecoveryStrategy, a2 as TraceEntry, ae as ErrorSource, n as ErrorBoundaryConfig, af as RetryLaterConfig, H as HistoryAPI, x as HistoryOption, _ as SystemConfig } from './plugins-Dy1C8GtT.js';
|
|
2
|
+
export { ag as BatchItemResult, ah as BatchResolveResults, ai as ConstraintsControl, aj as CrossModuleConstraintDef, g as CrossModuleConstraintsDef, ak as CrossModuleDerivationFn, e as CrossModuleDerivationsDef, al as CrossModuleEffectDef, f as CrossModuleEffectsDef, am as CrossModuleFactsWithSelf, an as DerivationKeys, ao as DerivationReturnType, ap as DerivationsControl, aq as DerivationsSchema, ar as DeriveAccessor, as as DispatchEventsFromSchema, r as DistributableSnapshot, s as DistributableSnapshotOptions, at as EffectCleanup, au as EffectsControl, av as EventPayloadSchema, aw as EventsAccessor, ax as EventsAccessorFromSchema, ay as EventsDef, az as EventsSchema, aA as FactKeys, aB as FactReturnType, aC as FlexibleEventHandler, aD as HistoryConfig, aE as InferEventPayloadFromSchema, aF as InferRequirementPayloadFromSchema, aG as InferSchema, aH as MutableNamespacedFacts, aI as NamespacedDerivations, aJ as NamespacedEventsAccessor, aK as NamespacedFacts, aL as ObservableKeys, aM as RequirementExplanation, aN as RequirementOutput, aO as RequirementPayloadSchema, aP as RequirementsSchema, aQ as ResolverContext, aR as ResolversControl, aS as SnapshotMeta, aT as SystemEvent, aU as TraceConfig, aV as TypedConstraintDef, b as TypedConstraintsDef, T as TypedDerivationsDef, a as TypedEventsDef, aW as TypedResolverContext, aX as TypedResolverDef, c as TypedResolversDef, aY as UnionEvents } from './plugins-Dy1C8GtT.js';
|
|
3
|
+
import { b as DerivationsDef, c as DerivedValues } from './helpers-D6LcRum7.js';
|
|
4
|
+
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-D6LcRum7.js';
|
|
5
5
|
export { g as safeStringify } from './utils-BnQajqPu.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -705,6 +705,28 @@ interface ResolversManager<_S extends Schema> {
|
|
|
705
705
|
*/
|
|
706
706
|
destroy(): void;
|
|
707
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
|
|
710
|
+
*
|
|
711
|
+
* The engine wires this lookup into the resolvers manager so that a resolver
|
|
712
|
+
* dispatched from a constraint with `bind: 'auto'` can re-evaluate the
|
|
713
|
+
* constraint's `when()` predicate live on every fact write.
|
|
714
|
+
*
|
|
715
|
+
* Returns `null` (or the lookup itself returns `undefined`) when the source
|
|
716
|
+
* constraint is unknown, async, or has `bind: 'none'` — in which case
|
|
717
|
+
* binding is a no-op and the resolver behaves exactly as before.
|
|
718
|
+
*
|
|
719
|
+
* @internal
|
|
720
|
+
*/
|
|
721
|
+
interface ConstraintBindingInfo<S extends Schema> {
|
|
722
|
+
/** The constraint's `bind` mode (effective; async predicates are forced to `'none'`). */
|
|
723
|
+
mode: ConstraintBindMode;
|
|
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;
|
|
729
|
+
}
|
|
708
730
|
/**
|
|
709
731
|
* Configuration options accepted by {@link createResolversManager}.
|
|
710
732
|
*
|
|
@@ -717,6 +739,15 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
717
739
|
facts: Facts<S>;
|
|
718
740
|
/** Underlying fact store used for `batch()` coalescing of mutations. */
|
|
719
741
|
store: FactsStore<S>;
|
|
742
|
+
/**
|
|
743
|
+
* Look up binding info for a source constraint id (RFC-1).
|
|
744
|
+
*
|
|
745
|
+
* Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
|
|
746
|
+
* returns the constraint's effective bind mode + a synchronous `when()`
|
|
747
|
+
* reference. Return `undefined` if the constraint is unknown or binding
|
|
748
|
+
* does not apply.
|
|
749
|
+
*/
|
|
750
|
+
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo<S> | undefined;
|
|
720
751
|
/** Called when a resolver begins execution. */
|
|
721
752
|
onStart?: (resolver: string, req: RequirementWithId) => void;
|
|
722
753
|
/** Called when a resolver completes successfully, with the wall-clock duration in ms. */
|
|
@@ -729,6 +760,13 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
729
760
|
onCancel?: (resolver: string, req: RequirementWithId) => void;
|
|
730
761
|
/** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
|
|
731
762
|
onResolutionComplete?: () => void;
|
|
763
|
+
/**
|
|
764
|
+
* Called when a resolver invokes `ctx.requeue()` for one of its owning
|
|
765
|
+
* requirements. The engine uses this to drop the requirement from its
|
|
766
|
+
* `previousRequirements` set so the next reconcile diff treats it as a
|
|
767
|
+
* fresh addition and re-dispatches the resolver.
|
|
768
|
+
*/
|
|
769
|
+
onRequeue?: (requirementId: string) => void;
|
|
732
770
|
}
|
|
733
771
|
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
734
772
|
|
package/dist/internals.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,z as createEngine,t as createErrorBoundaryManager,w as createFacts,v as createFactsProxy,u as createFactsStore,i as createHistoryManager,x as createPluginManager,d as createResolverFactory,y as createResolversManager,s as createRetryLaterManager}from'./chunk-
|
|
1
|
+
export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,z as createEngine,t as createErrorBoundaryManager,w as createFacts,v as createFactsProxy,u as createFactsStore,i as createHistoryManager,x as createPluginManager,d as createResolverFactory,y as createResolversManager,s as createRetryLaterManager}from'./chunk-E2WETPLH.js';export{g as getCurrentDeps,h as isTracking,k as trackAccess,i as withTracking,j as withoutTracking}from'./chunk-FK7BD7XT.js';export{l as safeStringify}from'./chunk-4CMO5OVZ.js';//# sourceMappingURL=internals.js.map
|
|
2
2
|
//# sourceMappingURL=internals.js.map
|
package/dist/plugins/index.d.cts
CHANGED
package/dist/plugins/index.d.ts
CHANGED
|
@@ -268,6 +268,39 @@ type RequirementsSchema = Record<string, RequirementPayloadSchema>;
|
|
|
268
268
|
* - No requirements: `null` or `[]`
|
|
269
269
|
*/
|
|
270
270
|
type RequirementOutput$1<R extends Requirement = Requirement> = R | R[] | null;
|
|
271
|
+
/**
|
|
272
|
+
* Resolver-to-constraint binding mode (RFC-1: Resolver Constraint-Binding).
|
|
273
|
+
*
|
|
274
|
+
* Controls whether fact writes from a resolver are *bound* to the constraint
|
|
275
|
+
* that triggered them. When the binding is `'auto'`, every write performed by
|
|
276
|
+
* the resolver re-evaluates the constraint's `when()` predicate against the
|
|
277
|
+
* latest facts; if `when()` no longer holds, the write is dropped, the
|
|
278
|
+
* resolver's {@link AbortController} is aborted, and `ctx.signal.aborted`
|
|
279
|
+
* becomes `true` so the resolver can early-exit on its next checkpoint.
|
|
280
|
+
*
|
|
281
|
+
* Binding is **one-shot per resolver invocation**: once `when()` flips to
|
|
282
|
+
* `false`, the binding stays deactivated even if `when()` would later flip
|
|
283
|
+
* back to `true` mid-resolver. This prevents a resolver from "resurrecting"
|
|
284
|
+
* a stale intent after the user has moved past it.
|
|
285
|
+
*
|
|
286
|
+
* - `'none'` (default): Current behavior. Every fact write succeeds.
|
|
287
|
+
* - `'auto'`: Writes are gated by the constraint's `when()` predicate. The
|
|
288
|
+
* predicate **must be synchronous** for `bind: 'auto'`; async constraints
|
|
289
|
+
* cannot be bound (their `when()` cannot be re-evaluated cheaply on every
|
|
290
|
+
* set).
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* constraints: {
|
|
295
|
+
* leaveParty: {
|
|
296
|
+
* when: (f) => f.status === 'mutating',
|
|
297
|
+
* require: { type: 'EXECUTE_ACTION' },
|
|
298
|
+
* bind: 'auto', // resolver tail won't clobber `status = 'left'`
|
|
299
|
+
* },
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ConstraintBindMode = "none" | "auto";
|
|
271
304
|
/** Constraint definition */
|
|
272
305
|
interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
273
306
|
/** Priority for ordering (higher runs first) */
|
|
@@ -286,6 +319,22 @@ interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
|
286
319
|
require: RequirementOutput$1<R> | ((facts: Facts<S>) => RequirementOutput$1<R>);
|
|
287
320
|
/** Timeout for async constraints (ms) */
|
|
288
321
|
timeout?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
324
|
+
*
|
|
325
|
+
* When `'auto'`, fact writes from the resolver triggered by this
|
|
326
|
+
* constraint are dropped (and the resolver is aborted) once `when()`
|
|
327
|
+
* flips to false. Defaults to `'none'` (current behavior preserved).
|
|
328
|
+
*
|
|
329
|
+
* **Forbidden on async constraints** (`async: true`): the binding
|
|
330
|
+
* checker re-evaluates `when()` synchronously on every fact write,
|
|
331
|
+
* which is incompatible with async predicates. Setting `bind: 'auto'`
|
|
332
|
+
* on an async constraint logs a dev-mode warning and is treated as
|
|
333
|
+
* `'none'`.
|
|
334
|
+
*
|
|
335
|
+
* @see {@link ConstraintBindMode}
|
|
336
|
+
*/
|
|
337
|
+
bind?: ConstraintBindMode;
|
|
289
338
|
/**
|
|
290
339
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
291
340
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -438,6 +487,28 @@ type EventsDef<S extends Schema> = Record<string, FlexibleEventHandler<S>>;
|
|
|
438
487
|
* Resolver Types - Type definitions for resolvers
|
|
439
488
|
*/
|
|
440
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Jitter strategy applied to the computed retry delay.
|
|
492
|
+
*
|
|
493
|
+
* Jitter spreads synchronized retries across a fleet of clients to
|
|
494
|
+
* prevent thundering-herd against shared services (e.g. Rekor, ACME,
|
|
495
|
+
* upstream APIs) when a regional outage causes every retry pass to
|
|
496
|
+
* wake at the same multiple of the initial delay.
|
|
497
|
+
*
|
|
498
|
+
* - `"none"` (default): no jitter; delay is exactly the computed value.
|
|
499
|
+
* - `"full"`: delay is uniformly distributed in `[0, computedDelay]`.
|
|
500
|
+
* AWS-style "full jitter" — best for thundering-herd protection
|
|
501
|
+
* against shared services at fleet scale.
|
|
502
|
+
* - `"equal"`: delay is `computedDelay/2 + uniform[0, computedDelay/2]`.
|
|
503
|
+
* Bounds the worst-case wait while still spreading retries.
|
|
504
|
+
* - `{ maxMs: number }`: adds `uniform[0, maxMs]` to the computed delay.
|
|
505
|
+
* Useful when bounded jitter is desired regardless of attempt number.
|
|
506
|
+
*
|
|
507
|
+
* Reference: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
508
|
+
*/
|
|
509
|
+
type JitterStrategy = "none" | "full" | "equal" | {
|
|
510
|
+
maxMs: number;
|
|
511
|
+
};
|
|
441
512
|
/** Retry policy configuration */
|
|
442
513
|
interface RetryPolicy {
|
|
443
514
|
/** Maximum number of attempts */
|
|
@@ -448,6 +519,17 @@ interface RetryPolicy {
|
|
|
448
519
|
initialDelay?: number;
|
|
449
520
|
/** Maximum delay in ms */
|
|
450
521
|
maxDelay?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Jitter strategy applied to the computed delay before each retry.
|
|
524
|
+
* Defaults to `"none"`. See {@link JitterStrategy} for options.
|
|
525
|
+
*
|
|
526
|
+
* Jitter is applied AFTER `maxDelay` clamping for `"full"` and `"equal"`
|
|
527
|
+
* strategies (so the jittered range respects `maxDelay`). For
|
|
528
|
+
* `{ maxMs }`, the additive jitter can push the final delay above
|
|
529
|
+
* `maxDelay` by up to `maxMs` — this is intentional, since `maxMs` is
|
|
530
|
+
* the operator's explicit upper bound on the jitter spread.
|
|
531
|
+
*/
|
|
532
|
+
jitter?: JitterStrategy;
|
|
451
533
|
/**
|
|
452
534
|
* Optional predicate to decide whether to retry after an error.
|
|
453
535
|
* Return `true` to retry, `false` to stop immediately.
|
|
@@ -491,6 +573,44 @@ interface ResolverContext<S extends Schema = Schema> {
|
|
|
491
573
|
readonly signal: AbortSignal;
|
|
492
574
|
/** Returns a read-only snapshot of the current facts state, useful for before/after comparisons inside resolvers. */
|
|
493
575
|
readonly snapshot: () => FactsSnapshot<S>;
|
|
576
|
+
/**
|
|
577
|
+
* Mark this resolver's owning requirement(s) as eligible for re-evaluation
|
|
578
|
+
* in the next reconciliation pass — even if the constraint that produced
|
|
579
|
+
* them re-emits the same requirement ID.
|
|
580
|
+
*
|
|
581
|
+
* **Default behavior (no requeue):** When a resolver writes facts that
|
|
582
|
+
* cause its owning constraint's `when` to re-evaluate to true with the
|
|
583
|
+
* same requirement ID, Directive's diff logic recognizes the requirement
|
|
584
|
+
* as unchanged and does NOT re-fire the resolver. This is intentional:
|
|
585
|
+
* it prevents accidental infinite loops from resolvers that mutate facts
|
|
586
|
+
* read by their own constraint.
|
|
587
|
+
*
|
|
588
|
+
* **When to use `requeue()`:** Explicit chained pipelines where the
|
|
589
|
+
* resolver knowingly wants to be re-invoked with its updated facts (e.g.
|
|
590
|
+
* a multi-step state machine where each step writes the next pendingAction
|
|
591
|
+
* and requires the constraint to re-fire). Calling `requeue()` opts out of
|
|
592
|
+
* the suppression for *this* invocation only — the next reconcile will
|
|
593
|
+
* treat the still-emitted requirement as freshly added.
|
|
594
|
+
*
|
|
595
|
+
* **When NOT to use it:** Most resolvers. Prefer separate constraints
|
|
596
|
+
* keyed on different `when` predicates, or split mutation kinds so each
|
|
597
|
+
* step produces a distinct requirement ID.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* resolve: async (req, ctx) => {
|
|
602
|
+
* if (ctx.facts.pendingAction?.kind === "first") {
|
|
603
|
+
* await doFirst();
|
|
604
|
+
* ctx.facts.pendingAction = { kind: "second" };
|
|
605
|
+
* ctx.requeue(); // re-fire the same constraint with updated state
|
|
606
|
+
* return;
|
|
607
|
+
* }
|
|
608
|
+
* await doSecond();
|
|
609
|
+
* ctx.facts.status = "done";
|
|
610
|
+
* }
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
readonly requeue: () => void;
|
|
494
614
|
}
|
|
495
615
|
/** Single resolver definition (untyped - use TypedResolversDef for type safety) */
|
|
496
616
|
interface ResolverDef<S extends Schema, R extends Requirement = Requirement> {
|
|
@@ -1222,11 +1342,35 @@ declare function isNamespacedSystem(system: AnySystem): boolean;
|
|
|
1222
1342
|
*/
|
|
1223
1343
|
|
|
1224
1344
|
/** Lifecycle hooks for modules */
|
|
1225
|
-
interface ModuleHooks<
|
|
1345
|
+
interface ModuleHooks<M extends ModuleSchema> {
|
|
1226
1346
|
onInit?: (system: System<any>) => void;
|
|
1227
1347
|
onStart?: (system: System<any>) => void;
|
|
1228
1348
|
onStop?: (system: System<any>) => void;
|
|
1229
1349
|
onError?: (error: DirectiveError, context: unknown) => void;
|
|
1350
|
+
/**
|
|
1351
|
+
* Called when a resolver owned by this module throws after all retries
|
|
1352
|
+
* have been exhausted. The hook fires *after* the engine's internal error
|
|
1353
|
+
* handling (error boundary, plugin notification, retry decision) so it is
|
|
1354
|
+
* a side-channel observer — not a recovery mechanism.
|
|
1355
|
+
*
|
|
1356
|
+
* Use it to forward resolver failures into module-local error sinks
|
|
1357
|
+
* (logging, telemetry, user-facing toast machines) without coupling those
|
|
1358
|
+
* sinks to the engine's plugin system.
|
|
1359
|
+
*
|
|
1360
|
+
* **Failure isolation:** Errors thrown from inside `onResolverError` are
|
|
1361
|
+
* caught by the engine and logged via `console.error`; they do not abort
|
|
1362
|
+
* the engine or other modules' hooks.
|
|
1363
|
+
*
|
|
1364
|
+
* @param error - The error the resolver threw (already normalized to `Error`).
|
|
1365
|
+
* @param requirement - The requirement object that the failing resolver was handling.
|
|
1366
|
+
* @param ctx - Hook context, including a typed snapshot of this module's facts.
|
|
1367
|
+
*/
|
|
1368
|
+
onResolverError?: (error: Error, requirement: {
|
|
1369
|
+
type: string;
|
|
1370
|
+
[key: string]: unknown;
|
|
1371
|
+
}, ctx: {
|
|
1372
|
+
facts: Facts<M["facts"]>;
|
|
1373
|
+
}) => void;
|
|
1230
1374
|
}
|
|
1231
1375
|
/** Helper to get derivations schema, defaulting to empty */
|
|
1232
1376
|
type GetDerivationsSchema<M extends ModuleSchema> = M["derivations"] extends DerivationsSchema ? M["derivations"] : Record<string, never>;
|
|
@@ -1285,6 +1429,11 @@ interface TypedConstraintDef<M extends ModuleSchema> {
|
|
|
1285
1429
|
require: RequirementOutput<InferRequirements<M>> | ((facts: Facts<M["facts"]>) => RequirementOutput<InferRequirements<M>>);
|
|
1286
1430
|
/** Timeout for async constraints (ms) */
|
|
1287
1431
|
timeout?: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1434
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1435
|
+
*/
|
|
1436
|
+
bind?: ConstraintBindMode;
|
|
1288
1437
|
/**
|
|
1289
1438
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1290
1439
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1325,6 +1474,11 @@ interface CrossModuleConstraintDef<M extends ModuleSchema, Deps extends CrossMod
|
|
|
1325
1474
|
require: RequirementOutput<InferRequirements<M>> | ((facts: CrossModuleFactsWithSelf<M, Deps>) => RequirementOutput<InferRequirements<M>>);
|
|
1326
1475
|
/** Timeout for async constraints (ms) */
|
|
1327
1476
|
timeout?: number;
|
|
1477
|
+
/**
|
|
1478
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1479
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1480
|
+
*/
|
|
1481
|
+
bind?: ConstraintBindMode;
|
|
1328
1482
|
/**
|
|
1329
1483
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1330
1484
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1390,6 +1544,32 @@ interface TypedResolverContext<M extends ModuleSchema> {
|
|
|
1390
1544
|
readonly signal: AbortSignal;
|
|
1391
1545
|
/** Returns a read-only snapshot of the current facts state, useful for before/after comparisons inside resolvers. */
|
|
1392
1546
|
readonly snapshot: () => FactsSnapshot<M["facts"]>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Mark this resolver's owning requirement(s) as eligible for re-evaluation
|
|
1549
|
+
* in the next reconciliation pass — even if the constraint that produced
|
|
1550
|
+
* them re-emits the same requirement ID.
|
|
1551
|
+
*
|
|
1552
|
+
* See {@link ResolverContext.requeue} for full semantics and guidance on
|
|
1553
|
+
* when (and when not) to use this. The default behavior — silently
|
|
1554
|
+
* suppressing same-constraint re-fires — is intentional and prevents
|
|
1555
|
+
* accidental loops; `requeue()` is the explicit opt-in for chained
|
|
1556
|
+
* pipelines.
|
|
1557
|
+
*
|
|
1558
|
+
* @example
|
|
1559
|
+
* ```typescript
|
|
1560
|
+
* resolve: async (req, ctx) => {
|
|
1561
|
+
* if (ctx.facts.pendingAction?.kind === "first") {
|
|
1562
|
+
* await doFirst();
|
|
1563
|
+
* ctx.facts.pendingAction = { kind: "second" };
|
|
1564
|
+
* ctx.requeue();
|
|
1565
|
+
* return;
|
|
1566
|
+
* }
|
|
1567
|
+
* await doSecond();
|
|
1568
|
+
* ctx.facts.status = "done";
|
|
1569
|
+
* }
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
readonly requeue: () => void;
|
|
1393
1573
|
}
|
|
1394
1574
|
/**
|
|
1395
1575
|
* Helper to extract a specific requirement type from the schema.
|
|
@@ -2463,4 +2643,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
|
|
|
2463
2643
|
onTraceComplete?: (entry: TraceEntry) => void;
|
|
2464
2644
|
}
|
|
2465
2645
|
|
|
2466
|
-
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type
|
|
2646
|
+
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type ConstraintBindMode as a9, type FactKeys as aA, type FactReturnType as aB, type FlexibleEventHandler as aC, type HistoryConfig as aD, type InferEventPayloadFromSchema as aE, type InferRequirementPayloadFromSchema as aF, type InferSchema as aG, type MutableNamespacedFacts as aH, type NamespacedDerivations as aI, type NamespacedEventsAccessor as aJ, type NamespacedFacts as aK, type ObservableKeys as aL, type RequirementExplanation as aM, type RequirementOutput as aN, type RequirementPayloadSchema$1 as aO, type RequirementsSchema as aP, type ResolverContext as aQ, type ResolversControl as aR, type SnapshotMeta as aS, type SystemEvent as aT, type TraceConfig as aU, type TypedConstraintDef as aV, type TypedResolverContext as aW, type TypedResolverDef as aX, type UnionEvents as aY, type RequirementOutput$1 as aZ, type ResolverStatus as aa, type FactChange as ab, type ReconcileResult as ac, type RecoveryStrategy as ad, type ErrorSource as ae, type RetryLaterConfig as af, type BatchItemResult as ag, type BatchResolveResults as ah, type ConstraintsControl as ai, type CrossModuleConstraintDef as aj, type CrossModuleDerivationFn as ak, type CrossModuleEffectDef as al, type CrossModuleFactsWithSelf as am, type DerivationKeys as an, type DerivationReturnType as ao, type DerivationsControl as ap, type DerivationsSchema as aq, type DeriveAccessor as ar, type DispatchEventsFromSchema as as, type EffectCleanup as at, type EffectsControl as au, type EventPayloadSchema as av, type EventsAccessor as aw, type EventsAccessorFromSchema as ax, type EventsDef as ay, type EventsSchema as az, type TypedConstraintsDef as b, type TypedResolversDef as c, type ModuleHooks as d, type CrossModuleDerivationsDef as e, type CrossModuleEffectsDef as f, type CrossModuleConstraintsDef as g, type ModuleDef as h, type CreateSystemOptionsSingle as i, type SingleModuleSystem as j, type ModulesMap as k, type CreateSystemOptionsNamed as l, type TraceOption as m, type ErrorBoundaryConfig as n, type Requirement as o, type RequirementKeyFn as p, DirectiveError as q, type DistributableSnapshot as r, type DistributableSnapshotOptions as s, type DynamicConstraintDef as t, type DynamicEffectDef as u, type DynamicResolverDef as v, type FactsSnapshot as w, type HistoryOption as x, type HistoryState as y, type InferEvents as z };
|
|
@@ -268,6 +268,39 @@ type RequirementsSchema = Record<string, RequirementPayloadSchema>;
|
|
|
268
268
|
* - No requirements: `null` or `[]`
|
|
269
269
|
*/
|
|
270
270
|
type RequirementOutput$1<R extends Requirement = Requirement> = R | R[] | null;
|
|
271
|
+
/**
|
|
272
|
+
* Resolver-to-constraint binding mode (RFC-1: Resolver Constraint-Binding).
|
|
273
|
+
*
|
|
274
|
+
* Controls whether fact writes from a resolver are *bound* to the constraint
|
|
275
|
+
* that triggered them. When the binding is `'auto'`, every write performed by
|
|
276
|
+
* the resolver re-evaluates the constraint's `when()` predicate against the
|
|
277
|
+
* latest facts; if `when()` no longer holds, the write is dropped, the
|
|
278
|
+
* resolver's {@link AbortController} is aborted, and `ctx.signal.aborted`
|
|
279
|
+
* becomes `true` so the resolver can early-exit on its next checkpoint.
|
|
280
|
+
*
|
|
281
|
+
* Binding is **one-shot per resolver invocation**: once `when()` flips to
|
|
282
|
+
* `false`, the binding stays deactivated even if `when()` would later flip
|
|
283
|
+
* back to `true` mid-resolver. This prevents a resolver from "resurrecting"
|
|
284
|
+
* a stale intent after the user has moved past it.
|
|
285
|
+
*
|
|
286
|
+
* - `'none'` (default): Current behavior. Every fact write succeeds.
|
|
287
|
+
* - `'auto'`: Writes are gated by the constraint's `when()` predicate. The
|
|
288
|
+
* predicate **must be synchronous** for `bind: 'auto'`; async constraints
|
|
289
|
+
* cannot be bound (their `when()` cannot be re-evaluated cheaply on every
|
|
290
|
+
* set).
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* constraints: {
|
|
295
|
+
* leaveParty: {
|
|
296
|
+
* when: (f) => f.status === 'mutating',
|
|
297
|
+
* require: { type: 'EXECUTE_ACTION' },
|
|
298
|
+
* bind: 'auto', // resolver tail won't clobber `status = 'left'`
|
|
299
|
+
* },
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ConstraintBindMode = "none" | "auto";
|
|
271
304
|
/** Constraint definition */
|
|
272
305
|
interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
273
306
|
/** Priority for ordering (higher runs first) */
|
|
@@ -286,6 +319,22 @@ interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
|
286
319
|
require: RequirementOutput$1<R> | ((facts: Facts<S>) => RequirementOutput$1<R>);
|
|
287
320
|
/** Timeout for async constraints (ms) */
|
|
288
321
|
timeout?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
324
|
+
*
|
|
325
|
+
* When `'auto'`, fact writes from the resolver triggered by this
|
|
326
|
+
* constraint are dropped (and the resolver is aborted) once `when()`
|
|
327
|
+
* flips to false. Defaults to `'none'` (current behavior preserved).
|
|
328
|
+
*
|
|
329
|
+
* **Forbidden on async constraints** (`async: true`): the binding
|
|
330
|
+
* checker re-evaluates `when()` synchronously on every fact write,
|
|
331
|
+
* which is incompatible with async predicates. Setting `bind: 'auto'`
|
|
332
|
+
* on an async constraint logs a dev-mode warning and is treated as
|
|
333
|
+
* `'none'`.
|
|
334
|
+
*
|
|
335
|
+
* @see {@link ConstraintBindMode}
|
|
336
|
+
*/
|
|
337
|
+
bind?: ConstraintBindMode;
|
|
289
338
|
/**
|
|
290
339
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
291
340
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -438,6 +487,28 @@ type EventsDef<S extends Schema> = Record<string, FlexibleEventHandler<S>>;
|
|
|
438
487
|
* Resolver Types - Type definitions for resolvers
|
|
439
488
|
*/
|
|
440
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Jitter strategy applied to the computed retry delay.
|
|
492
|
+
*
|
|
493
|
+
* Jitter spreads synchronized retries across a fleet of clients to
|
|
494
|
+
* prevent thundering-herd against shared services (e.g. Rekor, ACME,
|
|
495
|
+
* upstream APIs) when a regional outage causes every retry pass to
|
|
496
|
+
* wake at the same multiple of the initial delay.
|
|
497
|
+
*
|
|
498
|
+
* - `"none"` (default): no jitter; delay is exactly the computed value.
|
|
499
|
+
* - `"full"`: delay is uniformly distributed in `[0, computedDelay]`.
|
|
500
|
+
* AWS-style "full jitter" — best for thundering-herd protection
|
|
501
|
+
* against shared services at fleet scale.
|
|
502
|
+
* - `"equal"`: delay is `computedDelay/2 + uniform[0, computedDelay/2]`.
|
|
503
|
+
* Bounds the worst-case wait while still spreading retries.
|
|
504
|
+
* - `{ maxMs: number }`: adds `uniform[0, maxMs]` to the computed delay.
|
|
505
|
+
* Useful when bounded jitter is desired regardless of attempt number.
|
|
506
|
+
*
|
|
507
|
+
* Reference: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
508
|
+
*/
|
|
509
|
+
type JitterStrategy = "none" | "full" | "equal" | {
|
|
510
|
+
maxMs: number;
|
|
511
|
+
};
|
|
441
512
|
/** Retry policy configuration */
|
|
442
513
|
interface RetryPolicy {
|
|
443
514
|
/** Maximum number of attempts */
|
|
@@ -448,6 +519,17 @@ interface RetryPolicy {
|
|
|
448
519
|
initialDelay?: number;
|
|
449
520
|
/** Maximum delay in ms */
|
|
450
521
|
maxDelay?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Jitter strategy applied to the computed delay before each retry.
|
|
524
|
+
* Defaults to `"none"`. See {@link JitterStrategy} for options.
|
|
525
|
+
*
|
|
526
|
+
* Jitter is applied AFTER `maxDelay` clamping for `"full"` and `"equal"`
|
|
527
|
+
* strategies (so the jittered range respects `maxDelay`). For
|
|
528
|
+
* `{ maxMs }`, the additive jitter can push the final delay above
|
|
529
|
+
* `maxDelay` by up to `maxMs` — this is intentional, since `maxMs` is
|
|
530
|
+
* the operator's explicit upper bound on the jitter spread.
|
|
531
|
+
*/
|
|
532
|
+
jitter?: JitterStrategy;
|
|
451
533
|
/**
|
|
452
534
|
* Optional predicate to decide whether to retry after an error.
|
|
453
535
|
* Return `true` to retry, `false` to stop immediately.
|
|
@@ -491,6 +573,44 @@ interface ResolverContext<S extends Schema = Schema> {
|
|
|
491
573
|
readonly signal: AbortSignal;
|
|
492
574
|
/** Returns a read-only snapshot of the current facts state, useful for before/after comparisons inside resolvers. */
|
|
493
575
|
readonly snapshot: () => FactsSnapshot<S>;
|
|
576
|
+
/**
|
|
577
|
+
* Mark this resolver's owning requirement(s) as eligible for re-evaluation
|
|
578
|
+
* in the next reconciliation pass — even if the constraint that produced
|
|
579
|
+
* them re-emits the same requirement ID.
|
|
580
|
+
*
|
|
581
|
+
* **Default behavior (no requeue):** When a resolver writes facts that
|
|
582
|
+
* cause its owning constraint's `when` to re-evaluate to true with the
|
|
583
|
+
* same requirement ID, Directive's diff logic recognizes the requirement
|
|
584
|
+
* as unchanged and does NOT re-fire the resolver. This is intentional:
|
|
585
|
+
* it prevents accidental infinite loops from resolvers that mutate facts
|
|
586
|
+
* read by their own constraint.
|
|
587
|
+
*
|
|
588
|
+
* **When to use `requeue()`:** Explicit chained pipelines where the
|
|
589
|
+
* resolver knowingly wants to be re-invoked with its updated facts (e.g.
|
|
590
|
+
* a multi-step state machine where each step writes the next pendingAction
|
|
591
|
+
* and requires the constraint to re-fire). Calling `requeue()` opts out of
|
|
592
|
+
* the suppression for *this* invocation only — the next reconcile will
|
|
593
|
+
* treat the still-emitted requirement as freshly added.
|
|
594
|
+
*
|
|
595
|
+
* **When NOT to use it:** Most resolvers. Prefer separate constraints
|
|
596
|
+
* keyed on different `when` predicates, or split mutation kinds so each
|
|
597
|
+
* step produces a distinct requirement ID.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* resolve: async (req, ctx) => {
|
|
602
|
+
* if (ctx.facts.pendingAction?.kind === "first") {
|
|
603
|
+
* await doFirst();
|
|
604
|
+
* ctx.facts.pendingAction = { kind: "second" };
|
|
605
|
+
* ctx.requeue(); // re-fire the same constraint with updated state
|
|
606
|
+
* return;
|
|
607
|
+
* }
|
|
608
|
+
* await doSecond();
|
|
609
|
+
* ctx.facts.status = "done";
|
|
610
|
+
* }
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
readonly requeue: () => void;
|
|
494
614
|
}
|
|
495
615
|
/** Single resolver definition (untyped - use TypedResolversDef for type safety) */
|
|
496
616
|
interface ResolverDef<S extends Schema, R extends Requirement = Requirement> {
|
|
@@ -1222,11 +1342,35 @@ declare function isNamespacedSystem(system: AnySystem): boolean;
|
|
|
1222
1342
|
*/
|
|
1223
1343
|
|
|
1224
1344
|
/** Lifecycle hooks for modules */
|
|
1225
|
-
interface ModuleHooks<
|
|
1345
|
+
interface ModuleHooks<M extends ModuleSchema> {
|
|
1226
1346
|
onInit?: (system: System<any>) => void;
|
|
1227
1347
|
onStart?: (system: System<any>) => void;
|
|
1228
1348
|
onStop?: (system: System<any>) => void;
|
|
1229
1349
|
onError?: (error: DirectiveError, context: unknown) => void;
|
|
1350
|
+
/**
|
|
1351
|
+
* Called when a resolver owned by this module throws after all retries
|
|
1352
|
+
* have been exhausted. The hook fires *after* the engine's internal error
|
|
1353
|
+
* handling (error boundary, plugin notification, retry decision) so it is
|
|
1354
|
+
* a side-channel observer — not a recovery mechanism.
|
|
1355
|
+
*
|
|
1356
|
+
* Use it to forward resolver failures into module-local error sinks
|
|
1357
|
+
* (logging, telemetry, user-facing toast machines) without coupling those
|
|
1358
|
+
* sinks to the engine's plugin system.
|
|
1359
|
+
*
|
|
1360
|
+
* **Failure isolation:** Errors thrown from inside `onResolverError` are
|
|
1361
|
+
* caught by the engine and logged via `console.error`; they do not abort
|
|
1362
|
+
* the engine or other modules' hooks.
|
|
1363
|
+
*
|
|
1364
|
+
* @param error - The error the resolver threw (already normalized to `Error`).
|
|
1365
|
+
* @param requirement - The requirement object that the failing resolver was handling.
|
|
1366
|
+
* @param ctx - Hook context, including a typed snapshot of this module's facts.
|
|
1367
|
+
*/
|
|
1368
|
+
onResolverError?: (error: Error, requirement: {
|
|
1369
|
+
type: string;
|
|
1370
|
+
[key: string]: unknown;
|
|
1371
|
+
}, ctx: {
|
|
1372
|
+
facts: Facts<M["facts"]>;
|
|
1373
|
+
}) => void;
|
|
1230
1374
|
}
|
|
1231
1375
|
/** Helper to get derivations schema, defaulting to empty */
|
|
1232
1376
|
type GetDerivationsSchema<M extends ModuleSchema> = M["derivations"] extends DerivationsSchema ? M["derivations"] : Record<string, never>;
|
|
@@ -1285,6 +1429,11 @@ interface TypedConstraintDef<M extends ModuleSchema> {
|
|
|
1285
1429
|
require: RequirementOutput<InferRequirements<M>> | ((facts: Facts<M["facts"]>) => RequirementOutput<InferRequirements<M>>);
|
|
1286
1430
|
/** Timeout for async constraints (ms) */
|
|
1287
1431
|
timeout?: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1434
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1435
|
+
*/
|
|
1436
|
+
bind?: ConstraintBindMode;
|
|
1288
1437
|
/**
|
|
1289
1438
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1290
1439
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1325,6 +1474,11 @@ interface CrossModuleConstraintDef<M extends ModuleSchema, Deps extends CrossMod
|
|
|
1325
1474
|
require: RequirementOutput<InferRequirements<M>> | ((facts: CrossModuleFactsWithSelf<M, Deps>) => RequirementOutput<InferRequirements<M>>);
|
|
1326
1475
|
/** Timeout for async constraints (ms) */
|
|
1327
1476
|
timeout?: number;
|
|
1477
|
+
/**
|
|
1478
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1479
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1480
|
+
*/
|
|
1481
|
+
bind?: ConstraintBindMode;
|
|
1328
1482
|
/**
|
|
1329
1483
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1330
1484
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1390,6 +1544,32 @@ interface TypedResolverContext<M extends ModuleSchema> {
|
|
|
1390
1544
|
readonly signal: AbortSignal;
|
|
1391
1545
|
/** Returns a read-only snapshot of the current facts state, useful for before/after comparisons inside resolvers. */
|
|
1392
1546
|
readonly snapshot: () => FactsSnapshot<M["facts"]>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Mark this resolver's owning requirement(s) as eligible for re-evaluation
|
|
1549
|
+
* in the next reconciliation pass — even if the constraint that produced
|
|
1550
|
+
* them re-emits the same requirement ID.
|
|
1551
|
+
*
|
|
1552
|
+
* See {@link ResolverContext.requeue} for full semantics and guidance on
|
|
1553
|
+
* when (and when not) to use this. The default behavior — silently
|
|
1554
|
+
* suppressing same-constraint re-fires — is intentional and prevents
|
|
1555
|
+
* accidental loops; `requeue()` is the explicit opt-in for chained
|
|
1556
|
+
* pipelines.
|
|
1557
|
+
*
|
|
1558
|
+
* @example
|
|
1559
|
+
* ```typescript
|
|
1560
|
+
* resolve: async (req, ctx) => {
|
|
1561
|
+
* if (ctx.facts.pendingAction?.kind === "first") {
|
|
1562
|
+
* await doFirst();
|
|
1563
|
+
* ctx.facts.pendingAction = { kind: "second" };
|
|
1564
|
+
* ctx.requeue();
|
|
1565
|
+
* return;
|
|
1566
|
+
* }
|
|
1567
|
+
* await doSecond();
|
|
1568
|
+
* ctx.facts.status = "done";
|
|
1569
|
+
* }
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
readonly requeue: () => void;
|
|
1393
1573
|
}
|
|
1394
1574
|
/**
|
|
1395
1575
|
* Helper to extract a specific requirement type from the schema.
|
|
@@ -2463,4 +2643,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
|
|
|
2463
2643
|
onTraceComplete?: (entry: TraceEntry) => void;
|
|
2464
2644
|
}
|
|
2465
2645
|
|
|
2466
|
-
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type
|
|
2646
|
+
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type ConstraintBindMode as a9, type FactKeys as aA, type FactReturnType as aB, type FlexibleEventHandler as aC, type HistoryConfig as aD, type InferEventPayloadFromSchema as aE, type InferRequirementPayloadFromSchema as aF, type InferSchema as aG, type MutableNamespacedFacts as aH, type NamespacedDerivations as aI, type NamespacedEventsAccessor as aJ, type NamespacedFacts as aK, type ObservableKeys as aL, type RequirementExplanation as aM, type RequirementOutput as aN, type RequirementPayloadSchema$1 as aO, type RequirementsSchema as aP, type ResolverContext as aQ, type ResolversControl as aR, type SnapshotMeta as aS, type SystemEvent as aT, type TraceConfig as aU, type TypedConstraintDef as aV, type TypedResolverContext as aW, type TypedResolverDef as aX, type UnionEvents as aY, type RequirementOutput$1 as aZ, type ResolverStatus as aa, type FactChange as ab, type ReconcileResult as ac, type RecoveryStrategy as ad, type ErrorSource as ae, type RetryLaterConfig as af, type BatchItemResult as ag, type BatchResolveResults as ah, type ConstraintsControl as ai, type CrossModuleConstraintDef as aj, type CrossModuleDerivationFn as ak, type CrossModuleEffectDef as al, type CrossModuleFactsWithSelf as am, type DerivationKeys as an, type DerivationReturnType as ao, type DerivationsControl as ap, type DerivationsSchema as aq, type DeriveAccessor as ar, type DispatchEventsFromSchema as as, type EffectCleanup as at, type EffectsControl as au, type EventPayloadSchema as av, type EventsAccessor as aw, type EventsAccessorFromSchema as ax, type EventsDef as ay, type EventsSchema as az, type TypedConstraintsDef as b, type TypedResolversDef as c, type ModuleHooks as d, type CrossModuleDerivationsDef as e, type CrossModuleEffectsDef as f, type CrossModuleConstraintsDef as g, type ModuleDef as h, type CreateSystemOptionsSingle as i, type SingleModuleSystem as j, type ModulesMap as k, type CreateSystemOptionsNamed as l, type TraceOption as m, type ErrorBoundaryConfig as n, type Requirement as o, type RequirementKeyFn as p, DirectiveError as q, type DistributableSnapshot as r, type DistributableSnapshotOptions as s, type DynamicConstraintDef as t, type DynamicEffectDef as u, type DynamicResolverDef as v, type FactsSnapshot as w, type HistoryOption as x, type HistoryState as y, type InferEvents as z };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkVSHSYVSY_cjs=require('./chunk-VSHSYVSY.cjs');require('./chunk-TUS5WDVE.cjs'),require('./chunk-DDUARSUH.cjs'),require('./chunk-BEJ6ICA7.cjs');Object.defineProperty(exports,"createSystem",{enumerable:true,get:function(){return chunkVSHSYVSY_cjs.a}});//# sourceMappingURL=system-2THXJBFM.cjs.map
|
|
2
|
+
//# sourceMappingURL=system-2THXJBFM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-2THXJBFM.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-JIO36ALC.js"}
|