@directive-run/core 1.17.2 → 1.18.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.d.cts +1 -1
- package/dist/adapter-utils.d.ts +1 -1
- package/dist/chunk-3LBPXJO2.cjs +3 -0
- package/dist/chunk-3LBPXJO2.cjs.map +1 -0
- package/dist/chunk-4QCKAJCX.cjs +2 -0
- package/dist/chunk-4QCKAJCX.cjs.map +1 -0
- package/dist/chunk-NPKUAG3Q.js +3 -0
- package/dist/chunk-NPKUAG3Q.js.map +1 -0
- package/dist/{chunk-F5JPF4YX.js → chunk-SGTWS4S2.js} +3 -3
- package/dist/chunk-SGTWS4S2.js.map +1 -0
- package/dist/chunk-WKCMOU2F.js +2 -0
- package/dist/chunk-WKCMOU2F.js.map +1 -0
- package/dist/{chunk-SUCLMJSZ.cjs → chunk-YYBU4TCO.cjs} +3 -3
- package/dist/chunk-YYBU4TCO.cjs.map +1 -0
- package/dist/{index-D_oNDe4l.d.cts → index-DW5awWlo.d.ts} +25 -2
- package/dist/{index-c5wGodzh.d.ts → index-uuMlmmrP.d.cts} +25 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -6
- package/dist/index.d.ts +21 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.cts +204 -5
- package/dist/internals.d.ts +204 -5
- package/dist/internals.js +1 -1
- package/dist/plugins/index.cjs +2 -2
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/{plugins-BpNMkJRw.d.ts → plugins-xpm4B7Nt.d.cts} +550 -1
- package/dist/{plugins-BpNMkJRw.d.cts → plugins-xpm4B7Nt.d.ts} +550 -1
- package/dist/{predicate-BinuVL33.d.ts → predicate-CMGFjIeu.d.cts} +2 -2
- package/dist/{predicate-DN1MnDbi.d.cts → predicate-fpUoy77T.d.ts} +2 -2
- package/dist/system-6D4C5QZL.cjs +2 -0
- package/dist/{system-RHSYFDOB.cjs.map → system-6D4C5QZL.cjs.map} +1 -1
- package/dist/system-ATW7RUEU.js +2 -0
- package/dist/{system-MMCZKPI2.js.map → system-ATW7RUEU.js.map} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +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-4MTC4BSK.cjs +0 -2
- package/dist/chunk-4MTC4BSK.cjs.map +0 -1
- package/dist/chunk-F5JPF4YX.js.map +0 -1
- package/dist/chunk-Q5UTBMX2.cjs +0 -3
- package/dist/chunk-Q5UTBMX2.cjs.map +0 -1
- package/dist/chunk-RWJV7QLM.js +0 -3
- package/dist/chunk-RWJV7QLM.js.map +0 -1
- package/dist/chunk-SUCLMJSZ.cjs.map +0 -1
- package/dist/chunk-YYFRZJO2.js +0 -2
- package/dist/chunk-YYFRZJO2.js.map +0 -1
- package/dist/system-MMCZKPI2.js +0 -2
- package/dist/system-RHSYFDOB.cjs +0 -2
package/dist/internals.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk3LBPXJO2_cjs=require('./chunk-3LBPXJO2.cjs'),chunkRWFKUNF7_cjs=require('./chunk-RWFKUNF7.cjs'),chunkJGPPJV5P_cjs=require('./chunk-JGPPJV5P.cjs'),chunk4MNQDXH7_cjs=require('./chunk-4MNQDXH7.cjs');Object.defineProperty(exports,"createConstraintFactory",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.c}});Object.defineProperty(exports,"createConstraintsManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.p}});Object.defineProperty(exports,"createDerivationsManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.q}});Object.defineProperty(exports,"createDisabledHistory",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.j}});Object.defineProperty(exports,"createEffectsManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.r}});Object.defineProperty(exports,"createEngine",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.A}});Object.defineProperty(exports,"createErrorBoundaryManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.t}});Object.defineProperty(exports,"createFacts",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.w}});Object.defineProperty(exports,"createFactsProxy",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.v}});Object.defineProperty(exports,"createFactsStore",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.u}});Object.defineProperty(exports,"createHistoryManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.i}});Object.defineProperty(exports,"createPluginManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.x}});Object.defineProperty(exports,"createResolverFactory",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.d}});Object.defineProperty(exports,"createResolversManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.y}});Object.defineProperty(exports,"createRetryLaterManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.s}});Object.defineProperty(exports,"createSourcesManager",{enumerable:true,get:function(){return chunk3LBPXJO2_cjs.z}});Object.defineProperty(exports,"dangerousRegex",{enumerable:true,get:function(){return chunkRWFKUNF7_cjs.m}});Object.defineProperty(exports,"getCurrentDeps",{enumerable:true,get:function(){return chunkJGPPJV5P_cjs.f}});Object.defineProperty(exports,"isTracking",{enumerable:true,get:function(){return chunkJGPPJV5P_cjs.g}});Object.defineProperty(exports,"trackAccess",{enumerable:true,get:function(){return chunkJGPPJV5P_cjs.j}});Object.defineProperty(exports,"withTracking",{enumerable:true,get:function(){return chunkJGPPJV5P_cjs.h}});Object.defineProperty(exports,"withoutTracking",{enumerable:true,get:function(){return chunkJGPPJV5P_cjs.i}});Object.defineProperty(exports,"hashObject",{enumerable:true,get:function(){return chunk4MNQDXH7_cjs.h}});Object.defineProperty(exports,"isPrototypeSafe",{enumerable:true,get:function(){return chunk4MNQDXH7_cjs.f}});Object.defineProperty(exports,"safeStringify",{enumerable:true,get:function(){return chunk4MNQDXH7_cjs.o}});Object.defineProperty(exports,"stableStringify",{enumerable:true,get:function(){return chunk4MNQDXH7_cjs.e}});//# 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 {
|
|
4
|
-
export {
|
|
1
|
+
import { ah as Schema, aA as FactsStore, a as Facts, D as DefinitionMeta, E as EffectsDef, u as ConstraintsDef, s as RequirementKeyFn, R as RequirementWithId, aB as ConstraintState, F as FactPredicate, C as ClauseResult, af as ResolversDef, aC as ResolverStatus, r as Requirement, ak as SourceDef, P as Plugin, ao as System, aD as FactChange, O as FactsSnapshot, aE as ReconcileResult, aj as Snapshot, x as DirectiveError, aF as RecoveryStrategy, av as TraceEntry, aG as ErrorSource, q as ErrorBoundaryConfig, aH as RetryLaterConfig, Q as HistoryAPI, U as HistoryOption, ap as SystemConfig } from './plugins-xpm4B7Nt.cjs';
|
|
2
|
+
export { aI as BatchItemResult, aJ as BatchResolveResults, aK as ConstraintsControl, v as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aL as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, w as CrossModuleEffectDef, i as CrossModuleEffectsDef, aM as CrossModuleFactsWithSelf, aN as DerivationKeys, aO as DerivationReturnType, aP as DerivationsControl, aQ as DerivationsSchema, aR as DeriveAccessor, aS as DispatchEventsFromSchema, y as DistributableSnapshot, z as DistributableSnapshotOptions, aT as EffectCleanup, aU as EffectsControl, aV as EventPayloadSchema, aW as EventsAccessor, aX as EventsAccessorFromSchema, K as EventsDef, aY as EventsSchema, aZ as FactKeys, a_ as FactReturnType, a$ as FlexibleEventHandler, b0 as HistoryConfig, b1 as InferEventPayloadFromSchema, b2 as InferRequirementPayloadFromSchema, b3 as InferSchema, b4 as MutableNamespacedFacts, b5 as NamespacedDerivations, b6 as NamespacedEventsAccessor, b7 as NamespacedFacts, b8 as ObservableKeys, b9 as RequirementExplanation, ba as RequirementOutput, bb as RequirementPayloadSchema, bc as RequirementsSchema, bd as ResolverContext, be as ResolversControl, bf as SnapshotMeta, bg as SystemEvent, bh as TraceConfig, aw as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, b as TypedEventsDef, bi as TypedResolverContext, ax as TypedResolverDef, e as TypedResolversDef, bj as UnionEvents } from './plugins-xpm4B7Nt.cjs';
|
|
3
|
+
import { b as DerivationsDef, y as DerivedValues } from './predicate-CMGFjIeu.cjs';
|
|
4
|
+
export { z as DerivationState, T as TypedConstraint, A as TypedResolver, B as createConstraintFactory, C as createResolverFactory, E as dangerousRegex } from './predicate-CMGFjIeu.cjs';
|
|
5
5
|
export { h as hashObject, g as isPrototypeSafe, j as safeStringify, k as stableStringify } from './utils-BZBBwS5A.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -810,6 +810,201 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
810
810
|
*/
|
|
811
811
|
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
812
812
|
|
|
813
|
+
/**
|
|
814
|
+
* Sources Manager — lifecycle owner for typed external event sources.
|
|
815
|
+
*
|
|
816
|
+
* Sources attach at {@link System.start} and tear down at {@link System.stop}.
|
|
817
|
+
* The manager supports the full start → stop → start → stop re-entry cycle:
|
|
818
|
+
* each `attachAll` re-arms the manager, each `cleanupAll` is idempotent until
|
|
819
|
+
* the next `attachAll`. Failures inside attach or unsubscribe are isolated so
|
|
820
|
+
* a single misbehaving source cannot prevent other sources (or the system
|
|
821
|
+
* itself) from completing their lifecycle.
|
|
822
|
+
*
|
|
823
|
+
* The manager also supports {@link SourcesManager.registerDefinitions} for
|
|
824
|
+
* dynamic module registration via {@link System.registerModule}: sources
|
|
825
|
+
* declared on a module registered AFTER the system has started attach
|
|
826
|
+
* immediately; sources declared before the next `start` queue up and attach
|
|
827
|
+
* with the rest.
|
|
828
|
+
*
|
|
829
|
+
* The manager invokes per-source lifecycle callbacks (`onAttach`,
|
|
830
|
+
* `onPublish`, `onDetach`, `onError`) so the engine can emit accurate plugin
|
|
831
|
+
* observation events — including correct per-source attribution even when
|
|
832
|
+
* two sources publish the same event name.
|
|
833
|
+
*
|
|
834
|
+
* See {@link SourceDef} for the primitive's full semantics + rationale.
|
|
835
|
+
*/
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Engine-side dispatcher invoked when a source publishes an event. The
|
|
839
|
+
* manager wraps each source's publish callback in a closure that closes
|
|
840
|
+
* over the source id + moduleId so the engine cannot mis-attribute
|
|
841
|
+
* publishes (a naive "look up the source by event name" approach fails
|
|
842
|
+
* when multiple sources publish the same event).
|
|
843
|
+
*
|
|
844
|
+
* Returns a {@link SourceDispatchResult} indicating whether the engine
|
|
845
|
+
* accepted the publish. The manager uses the result to gate counter bumps
|
|
846
|
+
* + `onPublish` plugin emission: an accepted publish bumps `publishCount`
|
|
847
|
+
* and fires `onPublish`; a rejected publish bumps `dropCount` /
|
|
848
|
+
* `lastDropReason` and stays out of the plugin hook (otherwise observers
|
|
849
|
+
* would see "publish happened" for events the engine swallowed).
|
|
850
|
+
*/
|
|
851
|
+
type SourceDispatch = (sourceId: string, moduleId: string, eventName: string, payload: unknown) => SourceDispatchResult;
|
|
852
|
+
/**
|
|
853
|
+
* Outcome of a single source publish handed back to the manager. `"accepted"`
|
|
854
|
+
* means the engine dispatched into the event handler chain. Rejection
|
|
855
|
+
* reasons name the specific drop path so per-source telemetry can attribute
|
|
856
|
+
* the drop precisely:
|
|
857
|
+
*
|
|
858
|
+
* - `"post-destroy"` — publish arrived after `system.destroy()`.
|
|
859
|
+
* - `"post-stop"` — publish arrived between `system.stop()` and the next
|
|
860
|
+
* `system.start()`.
|
|
861
|
+
* - `"blocked-event-name"` — event name was `__proto__` / `constructor` /
|
|
862
|
+
* `prototype` (BLOCKED_PROPS guard, parity with `system.dispatch`).
|
|
863
|
+
* - `"invalid-event-name"` — event name was non-string or empty string.
|
|
864
|
+
*/
|
|
865
|
+
type SourceDispatchResult = {
|
|
866
|
+
accepted: true;
|
|
867
|
+
} | {
|
|
868
|
+
accepted: false;
|
|
869
|
+
reason: "post-destroy" | "post-stop" | "blocked-event-name" | "invalid-event-name" | "coalesced";
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* Per-source lifecycle callbacks the engine wires into the plugin manager.
|
|
873
|
+
* All are optional — manager-only consumers can omit them. The manager
|
|
874
|
+
* GUARANTEES:
|
|
875
|
+
*
|
|
876
|
+
* - `onAttach(id, moduleId)` runs ONLY when `attach()` returned a function
|
|
877
|
+
* (i.e. the source successfully attached). Sources that threw or returned
|
|
878
|
+
* non-functions invoke `onError` instead.
|
|
879
|
+
* - `onPublish(id, moduleId, eventName)` runs BEFORE the engine's dispatch,
|
|
880
|
+
* per publish call, with correct per-source attribution.
|
|
881
|
+
* - `onDetach(id, moduleId)` runs BEFORE the source's unsubscribe is called
|
|
882
|
+
* so observers see the detach intent before any teardown side effects.
|
|
883
|
+
* (If unsubscribe throws, `onError` fires afterward.)
|
|
884
|
+
* - `onError(id, moduleId, phase, error)` runs on attach OR cleanup failures.
|
|
885
|
+
* Always logged via `console.error` regardless of whether this callback
|
|
886
|
+
* is supplied.
|
|
887
|
+
*/
|
|
888
|
+
interface SourcesManagerCallbacks {
|
|
889
|
+
readonly onAttach?: (id: string, moduleId: string) => void;
|
|
890
|
+
readonly onPublish?: (id: string, moduleId: string, eventName: string) => void;
|
|
891
|
+
readonly onDetach?: (id: string, moduleId: string) => void;
|
|
892
|
+
readonly onError?: (id: string, moduleId: string, phase: "attach" | "cleanup" | "runtime", error: Error) => void;
|
|
893
|
+
}
|
|
894
|
+
interface SourcesManager {
|
|
895
|
+
registerDefinitions(moduleId: string, definitions: Record<string, SourceDef>): void;
|
|
896
|
+
/**
|
|
897
|
+
* Attach every registered source against the supplied dispatcher. Runs at
|
|
898
|
+
* `system.start()`. On a re-start, this re-arms the manager: the previous
|
|
899
|
+
* cycle's `attached` array is dropped and every source attaches afresh.
|
|
900
|
+
*
|
|
901
|
+
* The manager wraps each source's publish callback with a closure that
|
|
902
|
+
* forwards to `dispatch(sourceId, moduleId, eventName, payload)`. Sources
|
|
903
|
+
* that successfully attach also trigger the `onAttach` callback; failures
|
|
904
|
+
* trigger `onError`.
|
|
905
|
+
*/
|
|
906
|
+
attachAll(dispatch: SourceDispatch): void;
|
|
907
|
+
/**
|
|
908
|
+
* Invoke every recorded unsubscribe, in reverse-registration order. Runs at
|
|
909
|
+
* `system.stop()`. Idempotent within a single attach cycle — calling twice
|
|
910
|
+
* is a no-op on the second call. The flag clears at the next `attachAll`.
|
|
911
|
+
*
|
|
912
|
+
* `onDetach` fires BEFORE each unsubscribe runs. `onError` fires AFTER if
|
|
913
|
+
* the unsubscribe throws.
|
|
914
|
+
*
|
|
915
|
+
* Sync variant kept for back-compat: async unsubscribes are kicked off
|
|
916
|
+
* (the Promise is captured but not awaited). Use {@link cleanupAllAsync}
|
|
917
|
+
* when you need to await the actual transport teardown (e.g. Supabase
|
|
918
|
+
* `channel.unsubscribe()` returns a Promise that must complete before
|
|
919
|
+
* the broker drops the subscription).
|
|
920
|
+
*/
|
|
921
|
+
cleanupAll(): void;
|
|
922
|
+
/**
|
|
923
|
+
* RFC 0009: async-aware cleanup. Awaits each source's unsubscribe in
|
|
924
|
+
* reverse-registration order. Errors are caught + reported as
|
|
925
|
+
* `phase: "cleanup"` so a single failing unsubscribe cannot block the
|
|
926
|
+
* rest of the teardown.
|
|
927
|
+
*
|
|
928
|
+
* The host runtime calls this from `System.stopAsync()` /
|
|
929
|
+
* `System.destroyAsync()`. For sync `system.stop()` callers, the sync
|
|
930
|
+
* `cleanupAll` is still used (Promises from async unsubscribes are
|
|
931
|
+
* fire-and-forget).
|
|
932
|
+
*/
|
|
933
|
+
cleanupAllAsync(): Promise<void>;
|
|
934
|
+
/**
|
|
935
|
+
* RFC 0009: signal eviction to every source whose definition declares
|
|
936
|
+
* `onEvict`. Runs in registration order so sources with downstream
|
|
937
|
+
* dependencies close in the right order. Errors are caught + reported
|
|
938
|
+
* as `phase: "runtime"`. After `evictAll`, the host runtime calls
|
|
939
|
+
* `cleanupAllAsync`.
|
|
940
|
+
*/
|
|
941
|
+
evictAll(): Promise<void>;
|
|
942
|
+
/** Number of sources currently attached. Used by `system.inspect()`. */
|
|
943
|
+
attachedCount(): number;
|
|
944
|
+
/**
|
|
945
|
+
* List the declared source definitions for `system.inspect()`. Returns
|
|
946
|
+
* `{ id, moduleId, meta, attached, publishCount, lastPublishAt,
|
|
947
|
+
* dropCount, lastDropReason, lastDropAt, errorCount, lastError,
|
|
948
|
+
* attachedAt, detachedAt }` rows in registration order. Mirrors how
|
|
949
|
+
* effects are surfaced, with per-source telemetry an operator can read
|
|
950
|
+
* without registering a custom plugin.
|
|
951
|
+
*/
|
|
952
|
+
listDefinitions(): SourceInspectionRow[];
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Public per-source telemetry row returned by
|
|
956
|
+
* `SourcesManager.listDefinitions()` and surfaced unchanged on
|
|
957
|
+
* `SystemInspection.sources[i]`. Exported so consumers can name the type
|
|
958
|
+
* when writing helpers over the inspect output.
|
|
959
|
+
*/
|
|
960
|
+
interface SourceInspectionRow {
|
|
961
|
+
id: string;
|
|
962
|
+
moduleId: string;
|
|
963
|
+
meta?: unknown;
|
|
964
|
+
attached: boolean;
|
|
965
|
+
publishCount: number;
|
|
966
|
+
lastPublishAt: number | null;
|
|
967
|
+
/**
|
|
968
|
+
* Publishes the engine's dispatch guard rejected OR the manager
|
|
969
|
+
* coalesced this cycle. Operators monitor this to spot misconfigured
|
|
970
|
+
* sources (wrong event names) and to verify the coalesce strategy is
|
|
971
|
+
* actually debouncing the high-frequency sources it was meant to.
|
|
972
|
+
*/
|
|
973
|
+
dropCount: number;
|
|
974
|
+
/**
|
|
975
|
+
* Reason for the most recent rejected publish, or `null`.
|
|
976
|
+
* - `"post-destroy"` / `"post-stop"` — leaked transport
|
|
977
|
+
* - `"blocked-event-name"` / `"invalid-event-name"` — guard probe
|
|
978
|
+
* - `"coalesced"` — manager debounced a same-event-name publish
|
|
979
|
+
* ahead of the microtask flush (only when `SourceDef.coalesce`
|
|
980
|
+
* is `"lastWriteWins"`)
|
|
981
|
+
*/
|
|
982
|
+
lastDropReason: "post-destroy" | "post-stop" | "blocked-event-name" | "invalid-event-name" | "coalesced" | null;
|
|
983
|
+
/** Wall-clock ms of the most recent rejected publish, or `null`. */
|
|
984
|
+
lastDropAt: number | null;
|
|
985
|
+
errorCount: number;
|
|
986
|
+
lastError: SourceLastError | null;
|
|
987
|
+
attachedAt: number | null;
|
|
988
|
+
detachedAt: number | null;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* The most recent attach or cleanup error a source has recorded this cycle.
|
|
992
|
+
* `message` is truncated to a fixed length so a source that throws with a
|
|
993
|
+
* payload-embedded message does not write unbounded data into inspect
|
|
994
|
+
* output (and downstream into the audit ledger).
|
|
995
|
+
*/
|
|
996
|
+
interface SourceLastError {
|
|
997
|
+
phase: "attach" | "cleanup" | "runtime";
|
|
998
|
+
message: string;
|
|
999
|
+
at: number;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Create a sources manager bound to a (mutable) catalogue of source
|
|
1003
|
+
* definitions. The catalogue grows when modules are registered dynamically;
|
|
1004
|
+
* the static modules at `createSystem` time seed it via the engine.
|
|
1005
|
+
*/
|
|
1006
|
+
declare function createSourcesManager(initialDefinitions?: Record<string, SourceDef>, initialModuleIds?: Record<string, string>, callbacks?: SourcesManagerCallbacks): SourcesManager;
|
|
1007
|
+
|
|
813
1008
|
/**
|
|
814
1009
|
* Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
|
|
815
1010
|
*
|
|
@@ -884,6 +1079,10 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
884
1079
|
}): void;
|
|
885
1080
|
emitEffectRun(id: string): void;
|
|
886
1081
|
emitEffectError(id: string, error: unknown): void;
|
|
1082
|
+
emitSourceAttach(id: string, moduleId: string): void;
|
|
1083
|
+
emitSourcePublish(id: string, moduleId: string, eventName: string): void;
|
|
1084
|
+
emitSourceDetach(id: string, moduleId: string): void;
|
|
1085
|
+
emitSourceError(id: string, moduleId: string, phase: "attach" | "cleanup" | "runtime", error: unknown): void;
|
|
887
1086
|
emitSnapshot(snapshot: Snapshot): void;
|
|
888
1087
|
emitHistoryNavigate(from: number, to: number): void;
|
|
889
1088
|
emitError(error: DirectiveError): void;
|
|
@@ -1249,4 +1448,4 @@ declare function withoutTracking<T>(fn: () => T): T;
|
|
|
1249
1448
|
*/
|
|
1250
1449
|
declare function trackAccess(key: string): void;
|
|
1251
1450
|
|
|
1252
|
-
export { ConstraintState, ConstraintsDef, DerivationsDef, DerivedValues, EffectsDef, ErrorSource, FactChange, FactsStore, type InflightInfo, type PendingRetry, ReconcileResult, RecoveryStrategy, RequirementKeyFn, ResolverStatus, ResolversDef, RetryLaterConfig, createConstraintsManager, createDerivationsManager, createDisabledHistory, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createHistoryManager, createPluginManager, createResolversManager, createRetryLaterManager, getCurrentDeps, isTracking, trackAccess, withTracking, withoutTracking };
|
|
1451
|
+
export { ConstraintState, ConstraintsDef, DerivationsDef, DerivedValues, EffectsDef, ErrorSource, FactChange, FactsStore, type InflightInfo, type PendingRetry, ReconcileResult, RecoveryStrategy, RequirementKeyFn, ResolverStatus, ResolversDef, RetryLaterConfig, type SourceDispatch, type SourceDispatchResult, type SourceInspectionRow, type SourceLastError, type SourcesManager, type SourcesManagerCallbacks, createConstraintsManager, createDerivationsManager, createDisabledHistory, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createHistoryManager, createPluginManager, createResolversManager, createRetryLaterManager, createSourcesManager, getCurrentDeps, isTracking, trackAccess, withTracking, withoutTracking };
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { ah as Schema, aA as FactsStore, a as Facts, D as DefinitionMeta, E as EffectsDef, u as ConstraintsDef, s as RequirementKeyFn, R as RequirementWithId, aB as ConstraintState, F as FactPredicate, C as ClauseResult, af as ResolversDef, aC as ResolverStatus, r as Requirement, ak as SourceDef, P as Plugin, ao as System, aD as FactChange, O as FactsSnapshot, aE as ReconcileResult, aj as Snapshot, x as DirectiveError, aF as RecoveryStrategy, av as TraceEntry, aG as ErrorSource, q as ErrorBoundaryConfig, aH as RetryLaterConfig, Q as HistoryAPI, U as HistoryOption, ap as SystemConfig } from './plugins-xpm4B7Nt.js';
|
|
2
|
+
export { aI as BatchItemResult, aJ as BatchResolveResults, aK as ConstraintsControl, v as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aL as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, w as CrossModuleEffectDef, i as CrossModuleEffectsDef, aM as CrossModuleFactsWithSelf, aN as DerivationKeys, aO as DerivationReturnType, aP as DerivationsControl, aQ as DerivationsSchema, aR as DeriveAccessor, aS as DispatchEventsFromSchema, y as DistributableSnapshot, z as DistributableSnapshotOptions, aT as EffectCleanup, aU as EffectsControl, aV as EventPayloadSchema, aW as EventsAccessor, aX as EventsAccessorFromSchema, K as EventsDef, aY as EventsSchema, aZ as FactKeys, a_ as FactReturnType, a$ as FlexibleEventHandler, b0 as HistoryConfig, b1 as InferEventPayloadFromSchema, b2 as InferRequirementPayloadFromSchema, b3 as InferSchema, b4 as MutableNamespacedFacts, b5 as NamespacedDerivations, b6 as NamespacedEventsAccessor, b7 as NamespacedFacts, b8 as ObservableKeys, b9 as RequirementExplanation, ba as RequirementOutput, bb as RequirementPayloadSchema, bc as RequirementsSchema, bd as ResolverContext, be as ResolversControl, bf as SnapshotMeta, bg as SystemEvent, bh as TraceConfig, aw as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, b as TypedEventsDef, bi as TypedResolverContext, ax as TypedResolverDef, e as TypedResolversDef, bj as UnionEvents } from './plugins-xpm4B7Nt.js';
|
|
3
|
+
import { b as DerivationsDef, y as DerivedValues } from './predicate-fpUoy77T.js';
|
|
4
|
+
export { z as DerivationState, T as TypedConstraint, A as TypedResolver, B as createConstraintFactory, C as createResolverFactory, E as dangerousRegex } from './predicate-fpUoy77T.js';
|
|
5
5
|
export { h as hashObject, g as isPrototypeSafe, j as safeStringify, k as stableStringify } from './utils-BZBBwS5A.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -810,6 +810,201 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
810
810
|
*/
|
|
811
811
|
declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
|
|
812
812
|
|
|
813
|
+
/**
|
|
814
|
+
* Sources Manager — lifecycle owner for typed external event sources.
|
|
815
|
+
*
|
|
816
|
+
* Sources attach at {@link System.start} and tear down at {@link System.stop}.
|
|
817
|
+
* The manager supports the full start → stop → start → stop re-entry cycle:
|
|
818
|
+
* each `attachAll` re-arms the manager, each `cleanupAll` is idempotent until
|
|
819
|
+
* the next `attachAll`. Failures inside attach or unsubscribe are isolated so
|
|
820
|
+
* a single misbehaving source cannot prevent other sources (or the system
|
|
821
|
+
* itself) from completing their lifecycle.
|
|
822
|
+
*
|
|
823
|
+
* The manager also supports {@link SourcesManager.registerDefinitions} for
|
|
824
|
+
* dynamic module registration via {@link System.registerModule}: sources
|
|
825
|
+
* declared on a module registered AFTER the system has started attach
|
|
826
|
+
* immediately; sources declared before the next `start` queue up and attach
|
|
827
|
+
* with the rest.
|
|
828
|
+
*
|
|
829
|
+
* The manager invokes per-source lifecycle callbacks (`onAttach`,
|
|
830
|
+
* `onPublish`, `onDetach`, `onError`) so the engine can emit accurate plugin
|
|
831
|
+
* observation events — including correct per-source attribution even when
|
|
832
|
+
* two sources publish the same event name.
|
|
833
|
+
*
|
|
834
|
+
* See {@link SourceDef} for the primitive's full semantics + rationale.
|
|
835
|
+
*/
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Engine-side dispatcher invoked when a source publishes an event. The
|
|
839
|
+
* manager wraps each source's publish callback in a closure that closes
|
|
840
|
+
* over the source id + moduleId so the engine cannot mis-attribute
|
|
841
|
+
* publishes (a naive "look up the source by event name" approach fails
|
|
842
|
+
* when multiple sources publish the same event).
|
|
843
|
+
*
|
|
844
|
+
* Returns a {@link SourceDispatchResult} indicating whether the engine
|
|
845
|
+
* accepted the publish. The manager uses the result to gate counter bumps
|
|
846
|
+
* + `onPublish` plugin emission: an accepted publish bumps `publishCount`
|
|
847
|
+
* and fires `onPublish`; a rejected publish bumps `dropCount` /
|
|
848
|
+
* `lastDropReason` and stays out of the plugin hook (otherwise observers
|
|
849
|
+
* would see "publish happened" for events the engine swallowed).
|
|
850
|
+
*/
|
|
851
|
+
type SourceDispatch = (sourceId: string, moduleId: string, eventName: string, payload: unknown) => SourceDispatchResult;
|
|
852
|
+
/**
|
|
853
|
+
* Outcome of a single source publish handed back to the manager. `"accepted"`
|
|
854
|
+
* means the engine dispatched into the event handler chain. Rejection
|
|
855
|
+
* reasons name the specific drop path so per-source telemetry can attribute
|
|
856
|
+
* the drop precisely:
|
|
857
|
+
*
|
|
858
|
+
* - `"post-destroy"` — publish arrived after `system.destroy()`.
|
|
859
|
+
* - `"post-stop"` — publish arrived between `system.stop()` and the next
|
|
860
|
+
* `system.start()`.
|
|
861
|
+
* - `"blocked-event-name"` — event name was `__proto__` / `constructor` /
|
|
862
|
+
* `prototype` (BLOCKED_PROPS guard, parity with `system.dispatch`).
|
|
863
|
+
* - `"invalid-event-name"` — event name was non-string or empty string.
|
|
864
|
+
*/
|
|
865
|
+
type SourceDispatchResult = {
|
|
866
|
+
accepted: true;
|
|
867
|
+
} | {
|
|
868
|
+
accepted: false;
|
|
869
|
+
reason: "post-destroy" | "post-stop" | "blocked-event-name" | "invalid-event-name" | "coalesced";
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* Per-source lifecycle callbacks the engine wires into the plugin manager.
|
|
873
|
+
* All are optional — manager-only consumers can omit them. The manager
|
|
874
|
+
* GUARANTEES:
|
|
875
|
+
*
|
|
876
|
+
* - `onAttach(id, moduleId)` runs ONLY when `attach()` returned a function
|
|
877
|
+
* (i.e. the source successfully attached). Sources that threw or returned
|
|
878
|
+
* non-functions invoke `onError` instead.
|
|
879
|
+
* - `onPublish(id, moduleId, eventName)` runs BEFORE the engine's dispatch,
|
|
880
|
+
* per publish call, with correct per-source attribution.
|
|
881
|
+
* - `onDetach(id, moduleId)` runs BEFORE the source's unsubscribe is called
|
|
882
|
+
* so observers see the detach intent before any teardown side effects.
|
|
883
|
+
* (If unsubscribe throws, `onError` fires afterward.)
|
|
884
|
+
* - `onError(id, moduleId, phase, error)` runs on attach OR cleanup failures.
|
|
885
|
+
* Always logged via `console.error` regardless of whether this callback
|
|
886
|
+
* is supplied.
|
|
887
|
+
*/
|
|
888
|
+
interface SourcesManagerCallbacks {
|
|
889
|
+
readonly onAttach?: (id: string, moduleId: string) => void;
|
|
890
|
+
readonly onPublish?: (id: string, moduleId: string, eventName: string) => void;
|
|
891
|
+
readonly onDetach?: (id: string, moduleId: string) => void;
|
|
892
|
+
readonly onError?: (id: string, moduleId: string, phase: "attach" | "cleanup" | "runtime", error: Error) => void;
|
|
893
|
+
}
|
|
894
|
+
interface SourcesManager {
|
|
895
|
+
registerDefinitions(moduleId: string, definitions: Record<string, SourceDef>): void;
|
|
896
|
+
/**
|
|
897
|
+
* Attach every registered source against the supplied dispatcher. Runs at
|
|
898
|
+
* `system.start()`. On a re-start, this re-arms the manager: the previous
|
|
899
|
+
* cycle's `attached` array is dropped and every source attaches afresh.
|
|
900
|
+
*
|
|
901
|
+
* The manager wraps each source's publish callback with a closure that
|
|
902
|
+
* forwards to `dispatch(sourceId, moduleId, eventName, payload)`. Sources
|
|
903
|
+
* that successfully attach also trigger the `onAttach` callback; failures
|
|
904
|
+
* trigger `onError`.
|
|
905
|
+
*/
|
|
906
|
+
attachAll(dispatch: SourceDispatch): void;
|
|
907
|
+
/**
|
|
908
|
+
* Invoke every recorded unsubscribe, in reverse-registration order. Runs at
|
|
909
|
+
* `system.stop()`. Idempotent within a single attach cycle — calling twice
|
|
910
|
+
* is a no-op on the second call. The flag clears at the next `attachAll`.
|
|
911
|
+
*
|
|
912
|
+
* `onDetach` fires BEFORE each unsubscribe runs. `onError` fires AFTER if
|
|
913
|
+
* the unsubscribe throws.
|
|
914
|
+
*
|
|
915
|
+
* Sync variant kept for back-compat: async unsubscribes are kicked off
|
|
916
|
+
* (the Promise is captured but not awaited). Use {@link cleanupAllAsync}
|
|
917
|
+
* when you need to await the actual transport teardown (e.g. Supabase
|
|
918
|
+
* `channel.unsubscribe()` returns a Promise that must complete before
|
|
919
|
+
* the broker drops the subscription).
|
|
920
|
+
*/
|
|
921
|
+
cleanupAll(): void;
|
|
922
|
+
/**
|
|
923
|
+
* RFC 0009: async-aware cleanup. Awaits each source's unsubscribe in
|
|
924
|
+
* reverse-registration order. Errors are caught + reported as
|
|
925
|
+
* `phase: "cleanup"` so a single failing unsubscribe cannot block the
|
|
926
|
+
* rest of the teardown.
|
|
927
|
+
*
|
|
928
|
+
* The host runtime calls this from `System.stopAsync()` /
|
|
929
|
+
* `System.destroyAsync()`. For sync `system.stop()` callers, the sync
|
|
930
|
+
* `cleanupAll` is still used (Promises from async unsubscribes are
|
|
931
|
+
* fire-and-forget).
|
|
932
|
+
*/
|
|
933
|
+
cleanupAllAsync(): Promise<void>;
|
|
934
|
+
/**
|
|
935
|
+
* RFC 0009: signal eviction to every source whose definition declares
|
|
936
|
+
* `onEvict`. Runs in registration order so sources with downstream
|
|
937
|
+
* dependencies close in the right order. Errors are caught + reported
|
|
938
|
+
* as `phase: "runtime"`. After `evictAll`, the host runtime calls
|
|
939
|
+
* `cleanupAllAsync`.
|
|
940
|
+
*/
|
|
941
|
+
evictAll(): Promise<void>;
|
|
942
|
+
/** Number of sources currently attached. Used by `system.inspect()`. */
|
|
943
|
+
attachedCount(): number;
|
|
944
|
+
/**
|
|
945
|
+
* List the declared source definitions for `system.inspect()`. Returns
|
|
946
|
+
* `{ id, moduleId, meta, attached, publishCount, lastPublishAt,
|
|
947
|
+
* dropCount, lastDropReason, lastDropAt, errorCount, lastError,
|
|
948
|
+
* attachedAt, detachedAt }` rows in registration order. Mirrors how
|
|
949
|
+
* effects are surfaced, with per-source telemetry an operator can read
|
|
950
|
+
* without registering a custom plugin.
|
|
951
|
+
*/
|
|
952
|
+
listDefinitions(): SourceInspectionRow[];
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Public per-source telemetry row returned by
|
|
956
|
+
* `SourcesManager.listDefinitions()` and surfaced unchanged on
|
|
957
|
+
* `SystemInspection.sources[i]`. Exported so consumers can name the type
|
|
958
|
+
* when writing helpers over the inspect output.
|
|
959
|
+
*/
|
|
960
|
+
interface SourceInspectionRow {
|
|
961
|
+
id: string;
|
|
962
|
+
moduleId: string;
|
|
963
|
+
meta?: unknown;
|
|
964
|
+
attached: boolean;
|
|
965
|
+
publishCount: number;
|
|
966
|
+
lastPublishAt: number | null;
|
|
967
|
+
/**
|
|
968
|
+
* Publishes the engine's dispatch guard rejected OR the manager
|
|
969
|
+
* coalesced this cycle. Operators monitor this to spot misconfigured
|
|
970
|
+
* sources (wrong event names) and to verify the coalesce strategy is
|
|
971
|
+
* actually debouncing the high-frequency sources it was meant to.
|
|
972
|
+
*/
|
|
973
|
+
dropCount: number;
|
|
974
|
+
/**
|
|
975
|
+
* Reason for the most recent rejected publish, or `null`.
|
|
976
|
+
* - `"post-destroy"` / `"post-stop"` — leaked transport
|
|
977
|
+
* - `"blocked-event-name"` / `"invalid-event-name"` — guard probe
|
|
978
|
+
* - `"coalesced"` — manager debounced a same-event-name publish
|
|
979
|
+
* ahead of the microtask flush (only when `SourceDef.coalesce`
|
|
980
|
+
* is `"lastWriteWins"`)
|
|
981
|
+
*/
|
|
982
|
+
lastDropReason: "post-destroy" | "post-stop" | "blocked-event-name" | "invalid-event-name" | "coalesced" | null;
|
|
983
|
+
/** Wall-clock ms of the most recent rejected publish, or `null`. */
|
|
984
|
+
lastDropAt: number | null;
|
|
985
|
+
errorCount: number;
|
|
986
|
+
lastError: SourceLastError | null;
|
|
987
|
+
attachedAt: number | null;
|
|
988
|
+
detachedAt: number | null;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* The most recent attach or cleanup error a source has recorded this cycle.
|
|
992
|
+
* `message` is truncated to a fixed length so a source that throws with a
|
|
993
|
+
* payload-embedded message does not write unbounded data into inspect
|
|
994
|
+
* output (and downstream into the audit ledger).
|
|
995
|
+
*/
|
|
996
|
+
interface SourceLastError {
|
|
997
|
+
phase: "attach" | "cleanup" | "runtime";
|
|
998
|
+
message: string;
|
|
999
|
+
at: number;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Create a sources manager bound to a (mutable) catalogue of source
|
|
1003
|
+
* definitions. The catalogue grows when modules are registered dynamically;
|
|
1004
|
+
* the static modules at `createSystem` time seed it via the engine.
|
|
1005
|
+
*/
|
|
1006
|
+
declare function createSourcesManager(initialDefinitions?: Record<string, SourceDef>, initialModuleIds?: Record<string, string>, callbacks?: SourcesManagerCallbacks): SourcesManager;
|
|
1007
|
+
|
|
813
1008
|
/**
|
|
814
1009
|
* Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
|
|
815
1010
|
*
|
|
@@ -884,6 +1079,10 @@ interface PluginManager<_S extends Schema = any> {
|
|
|
884
1079
|
}): void;
|
|
885
1080
|
emitEffectRun(id: string): void;
|
|
886
1081
|
emitEffectError(id: string, error: unknown): void;
|
|
1082
|
+
emitSourceAttach(id: string, moduleId: string): void;
|
|
1083
|
+
emitSourcePublish(id: string, moduleId: string, eventName: string): void;
|
|
1084
|
+
emitSourceDetach(id: string, moduleId: string): void;
|
|
1085
|
+
emitSourceError(id: string, moduleId: string, phase: "attach" | "cleanup" | "runtime", error: unknown): void;
|
|
887
1086
|
emitSnapshot(snapshot: Snapshot): void;
|
|
888
1087
|
emitHistoryNavigate(from: number, to: number): void;
|
|
889
1088
|
emitError(error: DirectiveError): void;
|
|
@@ -1249,4 +1448,4 @@ declare function withoutTracking<T>(fn: () => T): T;
|
|
|
1249
1448
|
*/
|
|
1250
1449
|
declare function trackAccess(key: string): void;
|
|
1251
1450
|
|
|
1252
|
-
export { ConstraintState, ConstraintsDef, DerivationsDef, DerivedValues, EffectsDef, ErrorSource, FactChange, FactsStore, type InflightInfo, type PendingRetry, ReconcileResult, RecoveryStrategy, RequirementKeyFn, ResolverStatus, ResolversDef, RetryLaterConfig, createConstraintsManager, createDerivationsManager, createDisabledHistory, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createHistoryManager, createPluginManager, createResolversManager, createRetryLaterManager, getCurrentDeps, isTracking, trackAccess, withTracking, withoutTracking };
|
|
1451
|
+
export { ConstraintState, ConstraintsDef, DerivationsDef, DerivedValues, EffectsDef, ErrorSource, FactChange, FactsStore, type InflightInfo, type PendingRetry, ReconcileResult, RecoveryStrategy, RequirementKeyFn, ResolverStatus, ResolversDef, RetryLaterConfig, type SourceDispatch, type SourceDispatchResult, type SourceInspectionRow, type SourceLastError, type SourcesManager, type SourcesManagerCallbacks, createConstraintsManager, createDerivationsManager, createDisabledHistory, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createHistoryManager, createPluginManager, createResolversManager, createRetryLaterManager, createSourcesManager, getCurrentDeps, isTracking, trackAccess, withTracking, withoutTracking };
|
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,
|
|
1
|
+
export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,A 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,z as createSourcesManager}from'./chunk-NPKUAG3Q.js';export{m as dangerousRegex}from'./chunk-O4GQEV4G.js';export{f as getCurrentDeps,g as isTracking,j as trackAccess,h as withTracking,i as withoutTracking}from'./chunk-3ETCZLAY.js';export{h as hashObject,f as isPrototypeSafe,o as safeStringify,e as stableStringify}from'./chunk-PXRV64PA.js';//# sourceMappingURL=internals.js.map
|
|
2
2
|
//# sourceMappingURL=internals.js.map
|