@prometheus-ags/entity-graph-core 3.0.4 → 3.1.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/CHANGELOG.md +30 -0
- package/README.md +248 -0
- package/dist/chunk-BE3BMRKF.mjs +938 -0
- package/dist/chunk-BE3BMRKF.mjs.map +1 -0
- package/dist/devtools.cjs +2561 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +531 -0
- package/dist/devtools.d.ts +531 -0
- package/dist/devtools.mjs +2019 -0
- package/dist/devtools.mjs.map +1 -0
- package/dist/graph-ClW3HD8B.d.cts +990 -0
- package/dist/graph-ClW3HD8B.d.ts +990 -0
- package/dist/index.cjs +572 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -1059
- package/dist/index.d.ts +131 -1059
- package/dist/index.mjs +127 -910
- package/dist/index.mjs.map +1 -1
- package/fixtures/devtools/README.md +37 -0
- package/fixtures/devtools/entity-inspection-v1.json +304 -0
- package/fixtures/devtools/time-travel-v1.json +110 -0
- package/package.json +25 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,76 +1,7 @@
|
|
|
1
|
+
import { S as SortSpec, F as FilterSpec, E as EntityType, G as GraphStore$1, a as EntityId, b as SyncOrigin, Q as QueryKey, u as useGraphStore, c as EntitySnapshot, d as EntitySyncMetadata, g as graphStore } from './graph-ClW3HD8B.js';
|
|
2
|
+
export { C as CompletenessMode, e as EMPTY_ENTITY_STATE, f as EMPTY_IDS, h as EMPTY_LIST_STATE, i as EMPTY_SYNC_METADATA, j as EntityError, k as EntityErrorOptions, l as EntityState, m as FetchedEntityBatch, n as FetchedListProjection, o as FetchedListTarget, p as FilterClause, q as FilterGroup, r as FilterOperator, s as GraphState, I as IngestFetchedListOptions, L as ListResultMeta, t as ListState, v as SortClause, w as SortDirection, T as TerminalError, x as TransientError, V as ViewDescriptor, y as createGraphStore, z as flattenClauses, A as hasCustomPredicates, B as toEntityError, D as toGraphQLVariables, H as toRestParams, J as toSQLClauses } from './graph-ClW3HD8B.js';
|
|
1
3
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
2
4
|
|
|
3
|
-
/**
|
|
4
|
-
* Typed errors used throughout 2.0 to drive retry policy and consumer
|
|
5
|
-
* UI decisions.
|
|
6
|
-
*
|
|
7
|
-
* Why two classes (not a discriminator field):
|
|
8
|
-
* - `instanceof` checks are zero-cost at runtime and survive bundler
|
|
9
|
-
* minification of property names.
|
|
10
|
-
* - Consumers can write `if (error instanceof TerminalError) renderInline()`
|
|
11
|
-
* without importing a type-narrowing helper.
|
|
12
|
-
* - The engine's retry policy is one `instanceof TransientError` check.
|
|
13
|
-
*
|
|
14
|
-
* 4xx → `TerminalError` (no retry — the request is structurally wrong:
|
|
15
|
-
* unauthorized, not-found, schema mismatch, validation failure).
|
|
16
|
-
*
|
|
17
|
-
* 5xx + network failures → `TransientError` (engine retries with
|
|
18
|
-
* exponential backoff up to `maxRetries`).
|
|
19
|
-
*
|
|
20
|
-
* Custom transports can throw either class. The default REST helper
|
|
21
|
-
* (`makeRestTransport`) maps HTTP status codes to the appropriate
|
|
22
|
-
* class automatically.
|
|
23
|
-
*
|
|
24
|
-
* Both classes preserve the original error via the standard
|
|
25
|
-
* `cause` option so stack traces survive the boundary.
|
|
26
|
-
*/
|
|
27
|
-
interface EntityErrorOptions {
|
|
28
|
-
/** HTTP status if the underlying transport was HTTP. */
|
|
29
|
-
status?: number;
|
|
30
|
-
/** Original thrown value (`Error`, `Response`, anything). */
|
|
31
|
-
cause?: unknown;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Permanent failure — do not retry. The request will not succeed by
|
|
35
|
-
* trying again with the same inputs.
|
|
36
|
-
*
|
|
37
|
-
* Typical sources: HTTP 4xx, missing tables, validation errors,
|
|
38
|
-
* permission denied, schema mismatches.
|
|
39
|
-
*/
|
|
40
|
-
declare class TerminalError extends Error {
|
|
41
|
-
readonly kind: "terminal";
|
|
42
|
-
readonly status?: number;
|
|
43
|
-
constructor(message: string, opts?: EntityErrorOptions);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Temporary failure — safe to retry. The engine will retry with
|
|
47
|
-
* exponential backoff up to the configured `maxRetries`.
|
|
48
|
-
*
|
|
49
|
-
* Typical sources: HTTP 5xx, network timeouts, fetch rejections,
|
|
50
|
-
* dropped sockets.
|
|
51
|
-
*/
|
|
52
|
-
declare class TransientError extends Error {
|
|
53
|
-
readonly kind: "transient";
|
|
54
|
-
readonly status?: number;
|
|
55
|
-
constructor(message: string, opts?: EntityErrorOptions);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Union of every typed error the library raises. Use on consumer-side
|
|
59
|
-
* `error` props when both classes are possible.
|
|
60
|
-
*/
|
|
61
|
-
type EntityError = TerminalError | TransientError;
|
|
62
|
-
/**
|
|
63
|
-
* Convert an unknown thrown value into a typed entity error.
|
|
64
|
-
*
|
|
65
|
-
* - Already-typed errors pass through.
|
|
66
|
-
* - HTTP-status-bearing errors become Terminal (4xx) or Transient (5xx).
|
|
67
|
-
* - `AbortError` / `DOMException` "AbortError" → Terminal (caller
|
|
68
|
-
* cancelled; not worth retrying).
|
|
69
|
-
* - Everything else → Transient (assume retryable; better than
|
|
70
|
-
* accidentally permanently failing on a one-off network blip).
|
|
71
|
-
*/
|
|
72
|
-
declare function toEntityError(err: unknown): EntityError;
|
|
73
|
-
|
|
74
5
|
/**
|
|
75
6
|
* Compiles a {@link FilterSpec} into a Prisma `where` object (plain JSON-serializable shape).
|
|
76
7
|
*
|
|
@@ -87,922 +18,6 @@ declare function toPrismaWhere(filter: FilterSpec): Record<string, unknown>;
|
|
|
87
18
|
*/
|
|
88
19
|
declare function toPrismaOrderBy(sort: SortSpec): Record<string, string>[];
|
|
89
20
|
|
|
90
|
-
/**
|
|
91
|
-
* Transport-agnostic comparison operators. Same spec can compile to REST, SQL, GraphQL, or local JS (`evaluator`).
|
|
92
|
-
* `custom` opts out of automatic serialization — use for predicates only the client can evaluate.
|
|
93
|
-
*/
|
|
94
|
-
type FilterOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "contains" | "startsWith" | "endsWith" | "isNull" | "isNotNull" | "between" | "arrayContains" | "arrayOverlaps" | "matches" | "custom";
|
|
95
|
-
/** Atomic filter: field path, operator, optional value, and optional JS predicate for `custom`. */
|
|
96
|
-
interface FilterClause {
|
|
97
|
-
field: string;
|
|
98
|
-
op: FilterOperator;
|
|
99
|
-
value?: unknown;
|
|
100
|
-
predicate?: (fieldValue: unknown, entity: Record<string, unknown>) => boolean;
|
|
101
|
-
}
|
|
102
|
-
type FilterLogic = "and" | "or";
|
|
103
|
-
/** Nested boolean group so you can express `(A AND B) OR C` without losing structure when compiling to backends. */
|
|
104
|
-
interface FilterGroup {
|
|
105
|
-
logic: FilterLogic;
|
|
106
|
-
clauses: Array<FilterClause | FilterGroup>;
|
|
107
|
-
}
|
|
108
|
-
/** Top-level filter: flat AND list of clauses, or a recursive `FilterGroup`. */
|
|
109
|
-
type FilterSpec = FilterGroup | FilterClause[];
|
|
110
|
-
type SortDirection = "asc" | "desc";
|
|
111
|
-
/** Single sort key with optional null ordering and custom comparator for local sort parity with remote semantics. */
|
|
112
|
-
interface SortClause {
|
|
113
|
-
field: string;
|
|
114
|
-
direction: SortDirection;
|
|
115
|
-
nulls?: "first" | "last";
|
|
116
|
-
comparator?: (a: unknown, b: unknown) => number;
|
|
117
|
-
}
|
|
118
|
-
/** Ordered multi-key sort (stable application in `compareEntities`). */
|
|
119
|
-
type SortSpec = SortClause[];
|
|
120
|
-
/**
|
|
121
|
-
* Everything `useEntityView` needs to describe a virtualized collection: filters, sorts, and simple multi-field search.
|
|
122
|
-
* One descriptor can drive local evaluation, remote query compilation, or hybrid mode.
|
|
123
|
-
*/
|
|
124
|
-
interface ViewDescriptor {
|
|
125
|
-
filter?: FilterSpec;
|
|
126
|
-
sort?: SortSpec;
|
|
127
|
-
search?: {
|
|
128
|
-
query: string;
|
|
129
|
-
fields: string[];
|
|
130
|
-
minChars?: number;
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* How complete local graph data is relative to the view: **local** (all in memory), **remote** (server must filter/sort), **hybrid** (show local fast + remote reconcile).
|
|
135
|
-
*/
|
|
136
|
-
type CompletenessMode = "local" | "remote" | "hybrid";
|
|
137
|
-
/**
|
|
138
|
-
* Compile a view to flat REST query params (`sort`, `q`, and `field[op]=value` keys). Skips `custom` clauses — those cannot be expressed as strings.
|
|
139
|
-
*/
|
|
140
|
-
declare function toRestParams(view: ViewDescriptor): Record<string, string>;
|
|
141
|
-
/**
|
|
142
|
-
* Compile a view to parameterized SQL fragments for server-side filtering/sorting. Unknown ops become `TRUE` — validate or restrict ops at the edge.
|
|
143
|
-
*/
|
|
144
|
-
declare function toSQLClauses(view: ViewDescriptor): {
|
|
145
|
-
where: string;
|
|
146
|
-
orderBy: string;
|
|
147
|
-
params: unknown[];
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Produce a GraphQL-variable-shaped object from a view (Hasura/Postgraphile-style `_op` maps). Intended as a starting point — wire to your actual schema.
|
|
151
|
-
*/
|
|
152
|
-
declare function toGraphQLVariables(view: ViewDescriptor): {
|
|
153
|
-
where?: Record<string, unknown>;
|
|
154
|
-
orderBy?: Array<Record<string, unknown>>;
|
|
155
|
-
search?: string;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Normalize nested `FilterGroup` trees to a flat clause list for compilers that only understand atomic predicates.
|
|
160
|
-
*/
|
|
161
|
-
declare function flattenClauses(filter: FilterSpec): FilterClause[];
|
|
162
|
-
/** True if any clause requires client-side `predicate` logic — forces local/hybrid evaluation paths that cannot be pushed to generic REST/SQL. */
|
|
163
|
-
declare function hasCustomPredicates(filter: FilterSpec): boolean;
|
|
164
|
-
|
|
165
|
-
/** Logical entity kind (e.g. `"Post"`). Used to partition the normalized graph. */
|
|
166
|
-
type EntityType = string;
|
|
167
|
-
/** Primary key for an entity within its `type`. Lists and relations reference this, not row copies. */
|
|
168
|
-
type EntityId = string;
|
|
169
|
-
/** Stable string key for a list query (often `JSON.stringify`-shaped). Lists store IDs only under this key. */
|
|
170
|
-
type QueryKey = string;
|
|
171
|
-
/** Provenance of the latest known entity state. */
|
|
172
|
-
type SyncOrigin = "server" | "client" | "optimistic";
|
|
173
|
-
/** Optional sync-facing metadata kept outside canonical entity payloads. */
|
|
174
|
-
interface EntitySyncMetadata {
|
|
175
|
-
synced: boolean;
|
|
176
|
-
origin: SyncOrigin;
|
|
177
|
-
updatedAt: number | null;
|
|
178
|
-
}
|
|
179
|
-
/** Snapshot shape returned by sync-aware reads and graph-native query helpers. */
|
|
180
|
-
type EntitySnapshot<T extends object> = T & {
|
|
181
|
-
$synced: boolean;
|
|
182
|
-
$origin: SyncOrigin;
|
|
183
|
-
$updatedAt: number | null;
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Fetch/cache metadata for a single entity instance (`type:id`).
|
|
187
|
-
* Separates transport concerns from canonical `entities` data so hooks can show spinners and stale-while-revalidate without mutating server-shaped fields.
|
|
188
|
-
*/
|
|
189
|
-
interface EntityState {
|
|
190
|
-
isFetching: boolean;
|
|
191
|
-
lastFetched: number | null;
|
|
192
|
-
error: string | null;
|
|
193
|
-
stale: boolean;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Ordered **IDs** for a list query plus pagination metadata — never embedded entity payloads.
|
|
197
|
-
* Cross-view reactivity depends on this: when `entities[type][id]` updates, every list containing that id re-resolves rows from the graph.
|
|
198
|
-
*/
|
|
199
|
-
interface ListState {
|
|
200
|
-
ids: EntityId[];
|
|
201
|
-
total: number | null;
|
|
202
|
-
nextCursor: string | null;
|
|
203
|
-
prevCursor: string | null;
|
|
204
|
-
hasNextPage: boolean;
|
|
205
|
-
hasPrevPage: boolean;
|
|
206
|
-
isFetching: boolean;
|
|
207
|
-
isFetchingMore: boolean;
|
|
208
|
-
error: string | null;
|
|
209
|
-
/**
|
|
210
|
-
* Typed error instance for 2.0 hooks (`useEntities`, `useEntityQuery`).
|
|
211
|
-
* Carries `TerminalError` / `TransientError` so consumers can
|
|
212
|
-
* `instanceof`-check the failure mode without parsing the string in
|
|
213
|
-
* `error`. Both fields are written together by `setListError`; the
|
|
214
|
-
* string `error` field remains for back-compat with 1.x consumers.
|
|
215
|
-
*/
|
|
216
|
-
lastError: EntityError | null;
|
|
217
|
-
lastFetched: number | null;
|
|
218
|
-
stale: boolean;
|
|
219
|
-
currentPage: number | null;
|
|
220
|
-
pageSize: number | null;
|
|
221
|
-
}
|
|
222
|
-
/** Pagination and lifecycle metadata accepted by successful list writes. */
|
|
223
|
-
type ListResultMeta = Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>;
|
|
224
|
-
/** One list projection updated as part of an atomic fetched-list ingestion. */
|
|
225
|
-
interface FetchedListTarget {
|
|
226
|
-
key: QueryKey;
|
|
227
|
-
mode?: "replace" | "append";
|
|
228
|
-
meta?: ListResultMeta;
|
|
229
|
-
/** Override list membership when the transport derives ids separately. */
|
|
230
|
-
ids?: EntityId[];
|
|
231
|
-
}
|
|
232
|
-
/** Additional normalized entity rows committed with the primary fetched list. */
|
|
233
|
-
interface FetchedEntityBatch {
|
|
234
|
-
type: EntityType;
|
|
235
|
-
entries: Array<{
|
|
236
|
-
id: EntityId;
|
|
237
|
-
data: Record<string, unknown>;
|
|
238
|
-
}>;
|
|
239
|
-
}
|
|
240
|
-
/** Incrementally project fetched rows into an existing view-backed list. */
|
|
241
|
-
interface FetchedListProjection {
|
|
242
|
-
key: QueryKey;
|
|
243
|
-
view: ViewDescriptor;
|
|
244
|
-
/** Complete the projection's fetch lifecycle without replacing its ids. */
|
|
245
|
-
completeFetch?: boolean;
|
|
246
|
-
}
|
|
247
|
-
/** Additional graph projections completed by one fetched-list response. */
|
|
248
|
-
interface IngestFetchedListOptions {
|
|
249
|
-
lists?: FetchedListTarget[];
|
|
250
|
-
/** Side-descriptor rows that must commit or fail with the primary batch. */
|
|
251
|
-
sideBatches?: FetchedEntityBatch[];
|
|
252
|
-
/** View-backed lists that receive matching fetched ids in the same publication. */
|
|
253
|
-
projections?: FetchedListProjection[];
|
|
254
|
-
/** List fetch flags to clear without replacing their existing ids or metadata. */
|
|
255
|
-
finishListFetches?: QueryKey[];
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Stable fallbacks for missing `lists[key]` / `entityStates[key]` slots.
|
|
259
|
-
* Inline `?? { ... }` defaults allocate new objects every `getSnapshot` call and trigger React 19
|
|
260
|
-
* “getSnapshot should be cached” / maximum update depth errors with `useSyncExternalStore`.
|
|
261
|
-
*/
|
|
262
|
-
declare const EMPTY_IDS: EntityId[];
|
|
263
|
-
declare const EMPTY_ENTITY_STATE: EntityState;
|
|
264
|
-
declare const EMPTY_SYNC_METADATA: EntitySyncMetadata;
|
|
265
|
-
declare const EMPTY_LIST_STATE: ListState;
|
|
266
|
-
/**
|
|
267
|
-
* Canonical Zustand store: **entities** (server truth), **patches** (UI-only overlay), **lists** (id order + list meta), and **entityStates** (per-entity fetch state).
|
|
268
|
-
* Framework bindings subscribe to the vanilla store; stores, adapters, and
|
|
269
|
-
* engines can read it synchronously through `graphStore.getState()`.
|
|
270
|
-
*/
|
|
271
|
-
interface GraphState {
|
|
272
|
-
/** Normalized server-confirmed records. Mutate only via upsert/replace/remove — not from components. */
|
|
273
|
-
entities: Record<EntityType, Record<EntityId, Record<string, unknown>>>;
|
|
274
|
-
/** Local-only fields merged at read time (`readEntity` / hooks). Never send patches to the server. */
|
|
275
|
-
patches: Record<EntityType, Record<EntityId, Record<string, unknown>>>;
|
|
276
|
-
/** Per-entity fetch lifecycle keyed as `${type}:${id}`. */
|
|
277
|
-
entityStates: Record<string, EntityState>;
|
|
278
|
-
/** Optional sync/provenance state layered beside the canonical entity payload. */
|
|
279
|
-
syncMetadata: Record<string, EntitySyncMetadata>;
|
|
280
|
-
/** List slots keyed by serialized query keys. Values hold id arrays and pagination — not entity clones. */
|
|
281
|
-
lists: Record<QueryKey, ListState>;
|
|
282
|
-
/**
|
|
283
|
-
* Shallow-merge `data` into the canonical entity. Use when the API returns partial updates or normalized fragments.
|
|
284
|
-
* @param type - Entity kind
|
|
285
|
-
* @param id - Entity id
|
|
286
|
-
* @param data - Fields to merge into existing canonical data
|
|
287
|
-
*/
|
|
288
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
289
|
-
/**
|
|
290
|
-
* Batch upsert for list endpoints — avoids N separate writes when hydrating many rows at once.
|
|
291
|
-
* @param type - Entity kind
|
|
292
|
-
* @param entries - Pairs of id + partial/full payloads to merge
|
|
293
|
-
*/
|
|
294
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
295
|
-
id: EntityId;
|
|
296
|
-
data: Record<string, unknown>;
|
|
297
|
-
}>) => void;
|
|
298
|
-
/**
|
|
299
|
-
* Merge one fetched page, mark every row fetched, and update its list
|
|
300
|
-
* projections in one Zustand publication.
|
|
301
|
-
*/
|
|
302
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
303
|
-
id: EntityId;
|
|
304
|
-
data: Record<string, unknown>;
|
|
305
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
306
|
-
/**
|
|
307
|
-
* Replace the canonical entity entirely (no merge). Use when the server returns a full snapshot and partial merge would leave stale keys behind.
|
|
308
|
-
*/
|
|
309
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
310
|
-
/** Remove canonical entity, its patches, and its entityState. Does not remove the id from lists — use `removeIdFromAllLists` if needed. */
|
|
311
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
312
|
-
/**
|
|
313
|
-
* Merge UI-only fields into `patches` so every subscriber sees selection, expansion, optimistic toggles, etc., without forking canonical data.
|
|
314
|
-
*/
|
|
315
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
316
|
-
/** Remove specific patch keys; other patch keys remain. */
|
|
317
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
318
|
-
/** Drop all patches for an entity (e.g. after successful mutation when server data is authoritative). */
|
|
319
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
320
|
-
/** Reflect in-flight GET for a single entity (deduped fetches in the engine still flip this once per logical request). */
|
|
321
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
322
|
-
/** Persist terminal fetch failure message and clear fetching — hooks surface `error` while leaving prior data if any. */
|
|
323
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
324
|
-
/** Mark entity successfully loaded; clears error, fetching, stale, and updates `lastFetched`. */
|
|
325
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
326
|
-
/** Drive background revalidation: when true, hooks refetch while still showing cached `readEntity` data. */
|
|
327
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
328
|
-
/** Merge sync metadata for one entity without polluting canonical server fields. */
|
|
329
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
330
|
-
/** Clear sync metadata for one entity. */
|
|
331
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
332
|
-
/**
|
|
333
|
-
* Replace list ids and merge pagination meta after a primary list fetch (not load-more).
|
|
334
|
-
* Resets fetching flags and clears list error on success path (engine calls this after normalize).
|
|
335
|
-
*/
|
|
336
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
337
|
-
/** Append unique ids (e.g. infinite scroll) while merging meta; dedupes id order. */
|
|
338
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
339
|
-
/** Prepend ids (e.g. “new item at top”) with optional meta merge. */
|
|
340
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
341
|
-
/** After deletes, keep every list consistent by removing an id everywhere it appears and decrementing `total` when tracked. */
|
|
342
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
343
|
-
/**
|
|
344
|
-
* Insert or move an id in one list. If the id already exists, it is removed first then re-inserted at `position`.
|
|
345
|
-
* @param position - `"start"`, `"end"`, or numeric index
|
|
346
|
-
*/
|
|
347
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
348
|
-
/** Initial or full list fetch in progress (not page-2+). */
|
|
349
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
350
|
-
/** Pagination / “load more” in progress for the same list key. */
|
|
351
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
352
|
-
/**
|
|
353
|
-
* Record list fetch failure; clears both fetching flags.
|
|
354
|
-
* The optional `typed` argument is the typed `EntityError` instance
|
|
355
|
-
* (used by 2.0 hooks); when omitted only the string `error` field is
|
|
356
|
-
* populated (back-compat with 1.x callers).
|
|
357
|
-
*/
|
|
358
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
359
|
-
/** Mark a list query stale so hooks can refetch without discarding current ids (stale-while-revalidate). */
|
|
360
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
361
|
-
/**
|
|
362
|
-
* Mark one or all entities of a type stale for subscriber-driven refetch. Does not delete data.
|
|
363
|
-
* @param id - Omit to stale every entity of `type`
|
|
364
|
-
*/
|
|
365
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
366
|
-
/**
|
|
367
|
-
* Mark lists stale by key prefix or custom predicate so the next access triggers background refresh without dropping ids immediately.
|
|
368
|
-
*/
|
|
369
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
370
|
-
/** Convenience: stale all entities of a type and lists whose keys start with `type`. */
|
|
371
|
-
invalidateType: (type: EntityType) => void;
|
|
372
|
-
/**
|
|
373
|
-
* Single read path: `{ ...entities[type][id], ...patches[type][id] }` or null if no canonical row exists.
|
|
374
|
-
* @returns Merged view suitable for rendering; not a deep clone
|
|
375
|
-
*/
|
|
376
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
377
|
-
/**
|
|
378
|
-
* Sync-aware read path: canonical entity + patches + virtual sync metadata (`$synced`, `$origin`, `$updatedAt`).
|
|
379
|
-
*/
|
|
380
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
381
|
-
}
|
|
382
|
-
/** Creates an isolated, framework-neutral entity graph store. */
|
|
383
|
-
declare function createGraphStore(): Omit<Omit<zustand_vanilla.StoreApi<GraphState>, "subscribe"> & {
|
|
384
|
-
subscribe: {
|
|
385
|
-
(listener: (selectedState: GraphState, previousSelectedState: GraphState) => void): () => void;
|
|
386
|
-
<U>(selector: (state: GraphState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
387
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
388
|
-
fireImmediately?: boolean;
|
|
389
|
-
} | undefined): () => void;
|
|
390
|
-
};
|
|
391
|
-
}, "setState"> & {
|
|
392
|
-
setState(nextStateOrUpdater: GraphState | Partial<GraphState> | ((state: {
|
|
393
|
-
entities: {
|
|
394
|
-
[x: string]: {
|
|
395
|
-
[x: string]: {
|
|
396
|
-
[x: string]: unknown;
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
patches: {
|
|
401
|
-
[x: string]: {
|
|
402
|
-
[x: string]: {
|
|
403
|
-
[x: string]: unknown;
|
|
404
|
-
};
|
|
405
|
-
};
|
|
406
|
-
};
|
|
407
|
-
entityStates: {
|
|
408
|
-
[x: string]: {
|
|
409
|
-
isFetching: boolean;
|
|
410
|
-
lastFetched: number | null;
|
|
411
|
-
error: string | null;
|
|
412
|
-
stale: boolean;
|
|
413
|
-
};
|
|
414
|
-
};
|
|
415
|
-
syncMetadata: {
|
|
416
|
-
[x: string]: {
|
|
417
|
-
synced: boolean;
|
|
418
|
-
origin: SyncOrigin;
|
|
419
|
-
updatedAt: number | null;
|
|
420
|
-
};
|
|
421
|
-
};
|
|
422
|
-
lists: {
|
|
423
|
-
[x: string]: {
|
|
424
|
-
ids: string[];
|
|
425
|
-
total: number | null;
|
|
426
|
-
nextCursor: string | null;
|
|
427
|
-
prevCursor: string | null;
|
|
428
|
-
hasNextPage: boolean;
|
|
429
|
-
hasPrevPage: boolean;
|
|
430
|
-
isFetching: boolean;
|
|
431
|
-
isFetchingMore: boolean;
|
|
432
|
-
error: string | null;
|
|
433
|
-
lastError: {
|
|
434
|
-
kind: "terminal";
|
|
435
|
-
status?: number | undefined;
|
|
436
|
-
name: string;
|
|
437
|
-
message: string;
|
|
438
|
-
stack?: string | undefined;
|
|
439
|
-
cause?: unknown;
|
|
440
|
-
} | {
|
|
441
|
-
kind: "transient";
|
|
442
|
-
status?: number | undefined;
|
|
443
|
-
name: string;
|
|
444
|
-
message: string;
|
|
445
|
-
stack?: string | undefined;
|
|
446
|
-
cause?: unknown;
|
|
447
|
-
} | null;
|
|
448
|
-
lastFetched: number | null;
|
|
449
|
-
stale: boolean;
|
|
450
|
-
currentPage: number | null;
|
|
451
|
-
pageSize: number | null;
|
|
452
|
-
};
|
|
453
|
-
};
|
|
454
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
455
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
456
|
-
id: EntityId;
|
|
457
|
-
data: Record<string, unknown>;
|
|
458
|
-
}>) => void;
|
|
459
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
460
|
-
id: EntityId;
|
|
461
|
-
data: Record<string, unknown>;
|
|
462
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
463
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
464
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
465
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
466
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
467
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
468
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
469
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
470
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
471
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
472
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
473
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
474
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
475
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
476
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
477
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
478
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
479
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
480
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
481
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
482
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
483
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
484
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
485
|
-
invalidateType: (type: EntityType) => void;
|
|
486
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
487
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
488
|
-
}) => void), shouldReplace?: false): void;
|
|
489
|
-
setState(nextStateOrUpdater: GraphState | ((state: {
|
|
490
|
-
entities: {
|
|
491
|
-
[x: string]: {
|
|
492
|
-
[x: string]: {
|
|
493
|
-
[x: string]: unknown;
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
|
-
};
|
|
497
|
-
patches: {
|
|
498
|
-
[x: string]: {
|
|
499
|
-
[x: string]: {
|
|
500
|
-
[x: string]: unknown;
|
|
501
|
-
};
|
|
502
|
-
};
|
|
503
|
-
};
|
|
504
|
-
entityStates: {
|
|
505
|
-
[x: string]: {
|
|
506
|
-
isFetching: boolean;
|
|
507
|
-
lastFetched: number | null;
|
|
508
|
-
error: string | null;
|
|
509
|
-
stale: boolean;
|
|
510
|
-
};
|
|
511
|
-
};
|
|
512
|
-
syncMetadata: {
|
|
513
|
-
[x: string]: {
|
|
514
|
-
synced: boolean;
|
|
515
|
-
origin: SyncOrigin;
|
|
516
|
-
updatedAt: number | null;
|
|
517
|
-
};
|
|
518
|
-
};
|
|
519
|
-
lists: {
|
|
520
|
-
[x: string]: {
|
|
521
|
-
ids: string[];
|
|
522
|
-
total: number | null;
|
|
523
|
-
nextCursor: string | null;
|
|
524
|
-
prevCursor: string | null;
|
|
525
|
-
hasNextPage: boolean;
|
|
526
|
-
hasPrevPage: boolean;
|
|
527
|
-
isFetching: boolean;
|
|
528
|
-
isFetchingMore: boolean;
|
|
529
|
-
error: string | null;
|
|
530
|
-
lastError: {
|
|
531
|
-
kind: "terminal";
|
|
532
|
-
status?: number | undefined;
|
|
533
|
-
name: string;
|
|
534
|
-
message: string;
|
|
535
|
-
stack?: string | undefined;
|
|
536
|
-
cause?: unknown;
|
|
537
|
-
} | {
|
|
538
|
-
kind: "transient";
|
|
539
|
-
status?: number | undefined;
|
|
540
|
-
name: string;
|
|
541
|
-
message: string;
|
|
542
|
-
stack?: string | undefined;
|
|
543
|
-
cause?: unknown;
|
|
544
|
-
} | null;
|
|
545
|
-
lastFetched: number | null;
|
|
546
|
-
stale: boolean;
|
|
547
|
-
currentPage: number | null;
|
|
548
|
-
pageSize: number | null;
|
|
549
|
-
};
|
|
550
|
-
};
|
|
551
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
552
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
553
|
-
id: EntityId;
|
|
554
|
-
data: Record<string, unknown>;
|
|
555
|
-
}>) => void;
|
|
556
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
557
|
-
id: EntityId;
|
|
558
|
-
data: Record<string, unknown>;
|
|
559
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
560
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
561
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
562
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
563
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
564
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
565
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
566
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
567
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
568
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
569
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
570
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
571
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
572
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
573
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
574
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
575
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
576
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
577
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
578
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
579
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
580
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
581
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
582
|
-
invalidateType: (type: EntityType) => void;
|
|
583
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
584
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
585
|
-
}) => void), shouldReplace: true): void;
|
|
586
|
-
};
|
|
587
|
-
/**
|
|
588
|
-
* Default process-wide entity graph store. Framework bindings subscribe to
|
|
589
|
-
* this vanilla store; non-React consumers use its `getState`, `setState`, and
|
|
590
|
-
* `subscribe` methods directly.
|
|
591
|
-
*/
|
|
592
|
-
declare const graphStore: Omit<Omit<zustand_vanilla.StoreApi<GraphState>, "subscribe"> & {
|
|
593
|
-
subscribe: {
|
|
594
|
-
(listener: (selectedState: GraphState, previousSelectedState: GraphState) => void): () => void;
|
|
595
|
-
<U>(selector: (state: GraphState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
596
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
597
|
-
fireImmediately?: boolean;
|
|
598
|
-
} | undefined): () => void;
|
|
599
|
-
};
|
|
600
|
-
}, "setState"> & {
|
|
601
|
-
setState(nextStateOrUpdater: GraphState | Partial<GraphState> | ((state: {
|
|
602
|
-
entities: {
|
|
603
|
-
[x: string]: {
|
|
604
|
-
[x: string]: {
|
|
605
|
-
[x: string]: unknown;
|
|
606
|
-
};
|
|
607
|
-
};
|
|
608
|
-
};
|
|
609
|
-
patches: {
|
|
610
|
-
[x: string]: {
|
|
611
|
-
[x: string]: {
|
|
612
|
-
[x: string]: unknown;
|
|
613
|
-
};
|
|
614
|
-
};
|
|
615
|
-
};
|
|
616
|
-
entityStates: {
|
|
617
|
-
[x: string]: {
|
|
618
|
-
isFetching: boolean;
|
|
619
|
-
lastFetched: number | null;
|
|
620
|
-
error: string | null;
|
|
621
|
-
stale: boolean;
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
syncMetadata: {
|
|
625
|
-
[x: string]: {
|
|
626
|
-
synced: boolean;
|
|
627
|
-
origin: SyncOrigin;
|
|
628
|
-
updatedAt: number | null;
|
|
629
|
-
};
|
|
630
|
-
};
|
|
631
|
-
lists: {
|
|
632
|
-
[x: string]: {
|
|
633
|
-
ids: string[];
|
|
634
|
-
total: number | null;
|
|
635
|
-
nextCursor: string | null;
|
|
636
|
-
prevCursor: string | null;
|
|
637
|
-
hasNextPage: boolean;
|
|
638
|
-
hasPrevPage: boolean;
|
|
639
|
-
isFetching: boolean;
|
|
640
|
-
isFetchingMore: boolean;
|
|
641
|
-
error: string | null;
|
|
642
|
-
lastError: {
|
|
643
|
-
kind: "terminal";
|
|
644
|
-
status?: number | undefined;
|
|
645
|
-
name: string;
|
|
646
|
-
message: string;
|
|
647
|
-
stack?: string | undefined;
|
|
648
|
-
cause?: unknown;
|
|
649
|
-
} | {
|
|
650
|
-
kind: "transient";
|
|
651
|
-
status?: number | undefined;
|
|
652
|
-
name: string;
|
|
653
|
-
message: string;
|
|
654
|
-
stack?: string | undefined;
|
|
655
|
-
cause?: unknown;
|
|
656
|
-
} | null;
|
|
657
|
-
lastFetched: number | null;
|
|
658
|
-
stale: boolean;
|
|
659
|
-
currentPage: number | null;
|
|
660
|
-
pageSize: number | null;
|
|
661
|
-
};
|
|
662
|
-
};
|
|
663
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
664
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
665
|
-
id: EntityId;
|
|
666
|
-
data: Record<string, unknown>;
|
|
667
|
-
}>) => void;
|
|
668
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
669
|
-
id: EntityId;
|
|
670
|
-
data: Record<string, unknown>;
|
|
671
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
672
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
673
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
674
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
675
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
676
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
677
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
678
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
679
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
680
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
681
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
682
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
683
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
684
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
685
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
686
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
687
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
688
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
689
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
690
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
691
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
692
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
693
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
694
|
-
invalidateType: (type: EntityType) => void;
|
|
695
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
696
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
697
|
-
}) => void), shouldReplace?: false): void;
|
|
698
|
-
setState(nextStateOrUpdater: GraphState | ((state: {
|
|
699
|
-
entities: {
|
|
700
|
-
[x: string]: {
|
|
701
|
-
[x: string]: {
|
|
702
|
-
[x: string]: unknown;
|
|
703
|
-
};
|
|
704
|
-
};
|
|
705
|
-
};
|
|
706
|
-
patches: {
|
|
707
|
-
[x: string]: {
|
|
708
|
-
[x: string]: {
|
|
709
|
-
[x: string]: unknown;
|
|
710
|
-
};
|
|
711
|
-
};
|
|
712
|
-
};
|
|
713
|
-
entityStates: {
|
|
714
|
-
[x: string]: {
|
|
715
|
-
isFetching: boolean;
|
|
716
|
-
lastFetched: number | null;
|
|
717
|
-
error: string | null;
|
|
718
|
-
stale: boolean;
|
|
719
|
-
};
|
|
720
|
-
};
|
|
721
|
-
syncMetadata: {
|
|
722
|
-
[x: string]: {
|
|
723
|
-
synced: boolean;
|
|
724
|
-
origin: SyncOrigin;
|
|
725
|
-
updatedAt: number | null;
|
|
726
|
-
};
|
|
727
|
-
};
|
|
728
|
-
lists: {
|
|
729
|
-
[x: string]: {
|
|
730
|
-
ids: string[];
|
|
731
|
-
total: number | null;
|
|
732
|
-
nextCursor: string | null;
|
|
733
|
-
prevCursor: string | null;
|
|
734
|
-
hasNextPage: boolean;
|
|
735
|
-
hasPrevPage: boolean;
|
|
736
|
-
isFetching: boolean;
|
|
737
|
-
isFetchingMore: boolean;
|
|
738
|
-
error: string | null;
|
|
739
|
-
lastError: {
|
|
740
|
-
kind: "terminal";
|
|
741
|
-
status?: number | undefined;
|
|
742
|
-
name: string;
|
|
743
|
-
message: string;
|
|
744
|
-
stack?: string | undefined;
|
|
745
|
-
cause?: unknown;
|
|
746
|
-
} | {
|
|
747
|
-
kind: "transient";
|
|
748
|
-
status?: number | undefined;
|
|
749
|
-
name: string;
|
|
750
|
-
message: string;
|
|
751
|
-
stack?: string | undefined;
|
|
752
|
-
cause?: unknown;
|
|
753
|
-
} | null;
|
|
754
|
-
lastFetched: number | null;
|
|
755
|
-
stale: boolean;
|
|
756
|
-
currentPage: number | null;
|
|
757
|
-
pageSize: number | null;
|
|
758
|
-
};
|
|
759
|
-
};
|
|
760
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
761
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
762
|
-
id: EntityId;
|
|
763
|
-
data: Record<string, unknown>;
|
|
764
|
-
}>) => void;
|
|
765
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
766
|
-
id: EntityId;
|
|
767
|
-
data: Record<string, unknown>;
|
|
768
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
769
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
770
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
771
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
772
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
773
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
774
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
775
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
776
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
777
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
778
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
779
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
780
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
781
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
782
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
783
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
784
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
785
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
786
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
787
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
788
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
789
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
790
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
791
|
-
invalidateType: (type: EntityType) => void;
|
|
792
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
793
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
794
|
-
}) => void), shouldReplace: true): void;
|
|
795
|
-
};
|
|
796
|
-
type GraphStore$1 = ReturnType<typeof createGraphStore>;
|
|
797
|
-
/**
|
|
798
|
-
* @deprecated Import `graphStore` from core, or `useGraphStore` from the React
|
|
799
|
-
* binding. This StoreApi-shaped alias remains for non-React 2.x migrations.
|
|
800
|
-
*/
|
|
801
|
-
declare const useGraphStore: Omit<Omit<zustand_vanilla.StoreApi<GraphState>, "subscribe"> & {
|
|
802
|
-
subscribe: {
|
|
803
|
-
(listener: (selectedState: GraphState, previousSelectedState: GraphState) => void): () => void;
|
|
804
|
-
<U>(selector: (state: GraphState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
805
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
806
|
-
fireImmediately?: boolean;
|
|
807
|
-
} | undefined): () => void;
|
|
808
|
-
};
|
|
809
|
-
}, "setState"> & {
|
|
810
|
-
setState(nextStateOrUpdater: GraphState | Partial<GraphState> | ((state: {
|
|
811
|
-
entities: {
|
|
812
|
-
[x: string]: {
|
|
813
|
-
[x: string]: {
|
|
814
|
-
[x: string]: unknown;
|
|
815
|
-
};
|
|
816
|
-
};
|
|
817
|
-
};
|
|
818
|
-
patches: {
|
|
819
|
-
[x: string]: {
|
|
820
|
-
[x: string]: {
|
|
821
|
-
[x: string]: unknown;
|
|
822
|
-
};
|
|
823
|
-
};
|
|
824
|
-
};
|
|
825
|
-
entityStates: {
|
|
826
|
-
[x: string]: {
|
|
827
|
-
isFetching: boolean;
|
|
828
|
-
lastFetched: number | null;
|
|
829
|
-
error: string | null;
|
|
830
|
-
stale: boolean;
|
|
831
|
-
};
|
|
832
|
-
};
|
|
833
|
-
syncMetadata: {
|
|
834
|
-
[x: string]: {
|
|
835
|
-
synced: boolean;
|
|
836
|
-
origin: SyncOrigin;
|
|
837
|
-
updatedAt: number | null;
|
|
838
|
-
};
|
|
839
|
-
};
|
|
840
|
-
lists: {
|
|
841
|
-
[x: string]: {
|
|
842
|
-
ids: string[];
|
|
843
|
-
total: number | null;
|
|
844
|
-
nextCursor: string | null;
|
|
845
|
-
prevCursor: string | null;
|
|
846
|
-
hasNextPage: boolean;
|
|
847
|
-
hasPrevPage: boolean;
|
|
848
|
-
isFetching: boolean;
|
|
849
|
-
isFetchingMore: boolean;
|
|
850
|
-
error: string | null;
|
|
851
|
-
lastError: {
|
|
852
|
-
kind: "terminal";
|
|
853
|
-
status?: number | undefined;
|
|
854
|
-
name: string;
|
|
855
|
-
message: string;
|
|
856
|
-
stack?: string | undefined;
|
|
857
|
-
cause?: unknown;
|
|
858
|
-
} | {
|
|
859
|
-
kind: "transient";
|
|
860
|
-
status?: number | undefined;
|
|
861
|
-
name: string;
|
|
862
|
-
message: string;
|
|
863
|
-
stack?: string | undefined;
|
|
864
|
-
cause?: unknown;
|
|
865
|
-
} | null;
|
|
866
|
-
lastFetched: number | null;
|
|
867
|
-
stale: boolean;
|
|
868
|
-
currentPage: number | null;
|
|
869
|
-
pageSize: number | null;
|
|
870
|
-
};
|
|
871
|
-
};
|
|
872
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
873
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
874
|
-
id: EntityId;
|
|
875
|
-
data: Record<string, unknown>;
|
|
876
|
-
}>) => void;
|
|
877
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
878
|
-
id: EntityId;
|
|
879
|
-
data: Record<string, unknown>;
|
|
880
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
881
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
882
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
883
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
884
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
885
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
886
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
887
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
888
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
889
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
890
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
891
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
892
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
893
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
894
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
895
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
896
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
897
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
898
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
899
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
900
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
901
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
902
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
903
|
-
invalidateType: (type: EntityType) => void;
|
|
904
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
905
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
906
|
-
}) => void), shouldReplace?: false): void;
|
|
907
|
-
setState(nextStateOrUpdater: GraphState | ((state: {
|
|
908
|
-
entities: {
|
|
909
|
-
[x: string]: {
|
|
910
|
-
[x: string]: {
|
|
911
|
-
[x: string]: unknown;
|
|
912
|
-
};
|
|
913
|
-
};
|
|
914
|
-
};
|
|
915
|
-
patches: {
|
|
916
|
-
[x: string]: {
|
|
917
|
-
[x: string]: {
|
|
918
|
-
[x: string]: unknown;
|
|
919
|
-
};
|
|
920
|
-
};
|
|
921
|
-
};
|
|
922
|
-
entityStates: {
|
|
923
|
-
[x: string]: {
|
|
924
|
-
isFetching: boolean;
|
|
925
|
-
lastFetched: number | null;
|
|
926
|
-
error: string | null;
|
|
927
|
-
stale: boolean;
|
|
928
|
-
};
|
|
929
|
-
};
|
|
930
|
-
syncMetadata: {
|
|
931
|
-
[x: string]: {
|
|
932
|
-
synced: boolean;
|
|
933
|
-
origin: SyncOrigin;
|
|
934
|
-
updatedAt: number | null;
|
|
935
|
-
};
|
|
936
|
-
};
|
|
937
|
-
lists: {
|
|
938
|
-
[x: string]: {
|
|
939
|
-
ids: string[];
|
|
940
|
-
total: number | null;
|
|
941
|
-
nextCursor: string | null;
|
|
942
|
-
prevCursor: string | null;
|
|
943
|
-
hasNextPage: boolean;
|
|
944
|
-
hasPrevPage: boolean;
|
|
945
|
-
isFetching: boolean;
|
|
946
|
-
isFetchingMore: boolean;
|
|
947
|
-
error: string | null;
|
|
948
|
-
lastError: {
|
|
949
|
-
kind: "terminal";
|
|
950
|
-
status?: number | undefined;
|
|
951
|
-
name: string;
|
|
952
|
-
message: string;
|
|
953
|
-
stack?: string | undefined;
|
|
954
|
-
cause?: unknown;
|
|
955
|
-
} | {
|
|
956
|
-
kind: "transient";
|
|
957
|
-
status?: number | undefined;
|
|
958
|
-
name: string;
|
|
959
|
-
message: string;
|
|
960
|
-
stack?: string | undefined;
|
|
961
|
-
cause?: unknown;
|
|
962
|
-
} | null;
|
|
963
|
-
lastFetched: number | null;
|
|
964
|
-
stale: boolean;
|
|
965
|
-
currentPage: number | null;
|
|
966
|
-
pageSize: number | null;
|
|
967
|
-
};
|
|
968
|
-
};
|
|
969
|
-
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
970
|
-
upsertEntities: (type: EntityType, entries: Array<{
|
|
971
|
-
id: EntityId;
|
|
972
|
-
data: Record<string, unknown>;
|
|
973
|
-
}>) => void;
|
|
974
|
-
ingestFetchedList: (type: EntityType, entries: Array<{
|
|
975
|
-
id: EntityId;
|
|
976
|
-
data: Record<string, unknown>;
|
|
977
|
-
}>, options?: IngestFetchedListOptions) => void;
|
|
978
|
-
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => void;
|
|
979
|
-
removeEntity: (type: EntityType, id: EntityId) => void;
|
|
980
|
-
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => void;
|
|
981
|
-
unpatchEntity: (type: EntityType, id: EntityId, keys: string[]) => void;
|
|
982
|
-
clearPatch: (type: EntityType, id: EntityId) => void;
|
|
983
|
-
setEntityFetching: (type: EntityType, id: EntityId, fetching: boolean) => void;
|
|
984
|
-
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
985
|
-
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
986
|
-
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
987
|
-
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
988
|
-
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
989
|
-
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
990
|
-
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
991
|
-
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
992
|
-
removeIdFromAllLists: (type: EntityType, id: EntityId) => void;
|
|
993
|
-
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => void;
|
|
994
|
-
setListFetching: (key: QueryKey, fetching: boolean) => void;
|
|
995
|
-
setListFetchingMore: (key: QueryKey, fetchingMore: boolean) => void;
|
|
996
|
-
setListError: (key: QueryKey, error: string | null, typed?: EntityError | null) => void;
|
|
997
|
-
setListStale: (key: QueryKey, stale: boolean) => void;
|
|
998
|
-
invalidateEntity: (type: EntityType, id?: EntityId) => void;
|
|
999
|
-
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
1000
|
-
invalidateType: (type: EntityType) => void;
|
|
1001
|
-
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
1002
|
-
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
1003
|
-
}) => void), shouldReplace: true): void;
|
|
1004
|
-
};
|
|
1005
|
-
|
|
1006
21
|
/**
|
|
1007
22
|
* 2.0 transport contract.
|
|
1008
23
|
*
|
|
@@ -1162,6 +177,77 @@ declare function __resetEntityTransports(): void;
|
|
|
1162
177
|
*/
|
|
1163
178
|
declare function getRegisteredEntityTypes(): EntityType[];
|
|
1164
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Active-graph resolution for imperative (non-hook) access.
|
|
182
|
+
*
|
|
183
|
+
* `GraphStoreProvider` scopes the React *hook* surface, but imperative callers —
|
|
184
|
+
* Zustand store actions, module-level helpers, mutation callbacks — have no
|
|
185
|
+
* React context to read. Before this module they had no way to reach a scoped
|
|
186
|
+
* graph at all, so a mounted provider silently failed to isolate them.
|
|
187
|
+
*
|
|
188
|
+
* Two independent mechanisms, both opt-in, both falling back to the package
|
|
189
|
+
* singleton so existing consumers are unaffected:
|
|
190
|
+
*
|
|
191
|
+
* 1. `setActiveGraphStore(store)` — a module-level active store. Correct in the
|
|
192
|
+
* browser, where there is exactly one application tree. `GraphStoreProvider`
|
|
193
|
+
* sets it on mount and restores the previous value on unmount.
|
|
194
|
+
*
|
|
195
|
+
* 2. `runWithGraphStore(store, fn)` — an `AsyncLocalStorage` scope. Required on
|
|
196
|
+
* the server, where concurrent requests interleave and a module-level value
|
|
197
|
+
* would leak across them.
|
|
198
|
+
*
|
|
199
|
+
* ALS takes precedence: if a request scope is active it always wins over the
|
|
200
|
+
* module-level value, because a server render must never observe another
|
|
201
|
+
* request's graph.
|
|
202
|
+
*
|
|
203
|
+
* ## Why `node:async_hooks` is loaded lazily
|
|
204
|
+
*
|
|
205
|
+
* This package is bundled for the browser as well as Node. A static
|
|
206
|
+
* `import "node:async_hooks"` would break browser builds and pull a polyfill
|
|
207
|
+
* into client bundles. The import is therefore attempted once, at first use of
|
|
208
|
+
* `runWithGraphStore`, and failure degrades to the module-level mechanism
|
|
209
|
+
* rather than throwing.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Initialise request scoping on runtimes without a synchronous `require`.
|
|
214
|
+
*
|
|
215
|
+
* Under **pure ESM** there is no `require`, so the synchronous path above cannot
|
|
216
|
+
* load `node:async_hooks` and `runWithGraphStore` would silently degrade to the
|
|
217
|
+
* module-level store — which does NOT isolate concurrent requests. An ESM server
|
|
218
|
+
* must therefore `await prepareGraphStoreScope()` once during startup, before
|
|
219
|
+
* serving traffic.
|
|
220
|
+
*
|
|
221
|
+
* Safe to call anywhere: it resolves to `false` in the browser and is idempotent.
|
|
222
|
+
*/
|
|
223
|
+
declare function prepareGraphStoreScope(): Promise<boolean>;
|
|
224
|
+
/**
|
|
225
|
+
* Set the process/tab-wide active graph.
|
|
226
|
+
*
|
|
227
|
+
* Returns a restore function; callers MUST invoke it on teardown so a nested or
|
|
228
|
+
* remounted provider does not strand a stale store. Passing `null` clears it.
|
|
229
|
+
*/
|
|
230
|
+
declare function setActiveGraphStore(store: GraphStore$1 | null): () => void;
|
|
231
|
+
/**
|
|
232
|
+
* Run `fn` with `store` as the active graph for this async context.
|
|
233
|
+
*
|
|
234
|
+
* This is the server-side entry point: an SSR host wraps each request so that
|
|
235
|
+
* concurrent renders never share entity state. When the runtime has no
|
|
236
|
+
* `AsyncLocalStorage`, `fn` still runs — under the module-level store — rather
|
|
237
|
+
* than failing, so isomorphic code does not need a branch.
|
|
238
|
+
*/
|
|
239
|
+
declare function runWithGraphStore<R>(store: GraphStore$1, fn: () => R): R;
|
|
240
|
+
/**
|
|
241
|
+
* The graph imperative access should target right now.
|
|
242
|
+
*
|
|
243
|
+
* Precedence: request scope (ALS) → module-level active store → `fallback`.
|
|
244
|
+
* `fallback` is the package singleton, supplied by the caller to avoid a
|
|
245
|
+
* circular import with `graph.ts`.
|
|
246
|
+
*/
|
|
247
|
+
declare function resolveActiveGraphStore(fallback: GraphStore$1): GraphStore$1;
|
|
248
|
+
/** Test seam: drop all active-store state. */
|
|
249
|
+
declare function __resetActiveGraphStore(): void;
|
|
250
|
+
|
|
1165
251
|
/**
|
|
1166
252
|
* `makeRestTransport` — built-in helper for the most common case: a
|
|
1167
253
|
* Supabase / PostgREST backend reached through a `SupabaseClient`-like
|
|
@@ -1710,6 +796,37 @@ declare function replayActionWithRetry(action: GraphActionRecord, policy: Resolv
|
|
|
1710
796
|
error: unknown;
|
|
1711
797
|
}>;
|
|
1712
798
|
|
|
799
|
+
/** Deprecated in-process event shape retained by the package root. */
|
|
800
|
+
type LegacyDevtoolsEvent = {
|
|
801
|
+
kind: "upsert";
|
|
802
|
+
type: string;
|
|
803
|
+
id: string;
|
|
804
|
+
data: Record<string, unknown>;
|
|
805
|
+
at: string;
|
|
806
|
+
} | {
|
|
807
|
+
kind: "patch";
|
|
808
|
+
type: string;
|
|
809
|
+
id: string;
|
|
810
|
+
patch: Record<string, unknown>;
|
|
811
|
+
at: string;
|
|
812
|
+
} | {
|
|
813
|
+
kind: "unpatch";
|
|
814
|
+
type: string;
|
|
815
|
+
id: string;
|
|
816
|
+
keys: string[];
|
|
817
|
+
at: string;
|
|
818
|
+
} | {
|
|
819
|
+
kind: "clearPatch";
|
|
820
|
+
type: string;
|
|
821
|
+
id: string;
|
|
822
|
+
at: string;
|
|
823
|
+
} | {
|
|
824
|
+
kind: "list";
|
|
825
|
+
key: string;
|
|
826
|
+
idCount: number;
|
|
827
|
+
at: string;
|
|
828
|
+
};
|
|
829
|
+
|
|
1713
830
|
/**
|
|
1714
831
|
* Process-wide defaults for stale times, retries, and background revalidation.
|
|
1715
832
|
* Keeps hook signatures small: `useEntity` / `useEntityList` merge these with per-query overrides.
|
|
@@ -1809,47 +926,15 @@ declare function unregisterSubscriber(key: string, token: symbol, store?: GraphS
|
|
|
1809
926
|
* Subscribe to ref-count changes for `registerSubscriber` / `unregisterSubscriber`.
|
|
1810
927
|
* Used by `useGraphDevTools` so subscriber totals update without graph mutations.
|
|
1811
928
|
*/
|
|
1812
|
-
declare function subscribeSubscriberStats(onChange: () => void): () => boolean;
|
|
929
|
+
declare function subscribeSubscriberStats(onChange: () => void, store?: GraphStore$1): () => boolean;
|
|
1813
930
|
/** Total active entity subscriber tokens across all keys (sum of ref-counts). */
|
|
1814
931
|
declare function getActiveSubscriberCount(store?: GraphStore$1): number;
|
|
1815
932
|
/**
|
|
1816
933
|
* Discriminated union of devtools events.
|
|
1817
934
|
*
|
|
1818
|
-
*
|
|
1819
|
-
* - `unpatch` and `list` are forward-compatible kinds reserved for future
|
|
1820
|
-
* instrumentation (W5+ event bus / W6+ panel). Consumers MUST handle them
|
|
1821
|
-
* in exhaustive `switch`/`if` chains today, even though no op-site emits
|
|
1822
|
-
* them in this change.
|
|
935
|
+
* New inspection surfaces should use the versioned `./devtools` subpath.
|
|
1823
936
|
*/
|
|
1824
|
-
type DevtoolsEvent =
|
|
1825
|
-
kind: "upsert";
|
|
1826
|
-
type: EntityType;
|
|
1827
|
-
id: EntityId;
|
|
1828
|
-
data: Record<string, unknown>;
|
|
1829
|
-
at: string;
|
|
1830
|
-
} | {
|
|
1831
|
-
kind: "patch";
|
|
1832
|
-
type: EntityType;
|
|
1833
|
-
id: EntityId;
|
|
1834
|
-
patch: Record<string, unknown>;
|
|
1835
|
-
at: string;
|
|
1836
|
-
} | {
|
|
1837
|
-
kind: "unpatch";
|
|
1838
|
-
type: EntityType;
|
|
1839
|
-
id: EntityId;
|
|
1840
|
-
keys: string[];
|
|
1841
|
-
at: string;
|
|
1842
|
-
} | {
|
|
1843
|
-
kind: "clearPatch";
|
|
1844
|
-
type: EntityType;
|
|
1845
|
-
id: EntityId;
|
|
1846
|
-
at: string;
|
|
1847
|
-
} | {
|
|
1848
|
-
kind: "list";
|
|
1849
|
-
key: string;
|
|
1850
|
-
idCount: number;
|
|
1851
|
-
at: string;
|
|
1852
|
-
};
|
|
937
|
+
type DevtoolsEvent = LegacyDevtoolsEvent;
|
|
1853
938
|
type DevtoolsListener = (event: DevtoolsEvent) => void;
|
|
1854
939
|
/**
|
|
1855
940
|
* Subscribe to the devtools event stream.
|
|
@@ -1943,67 +1028,54 @@ declare function createDevtoolsEventBus(opts?: DevtoolsEventBusOptions): Devtool
|
|
|
1943
1028
|
* Throws if `name` is already registered and active.
|
|
1944
1029
|
*/
|
|
1945
1030
|
declare function registerStore(bus: DevtoolsEventBus, source: DevtoolsSourceFn, name: string): () => void;
|
|
1946
|
-
/** Returns
|
|
1947
|
-
declare function getRegisteredStores(): ReadonlyArray<RegisteredStore>;
|
|
1031
|
+
/** Returns registered stores for one bus, or every bus for legacy callers. */
|
|
1032
|
+
declare function getRegisteredStores(bus?: DevtoolsEventBus): ReadonlyArray<RegisteredStore>;
|
|
1948
1033
|
|
|
1949
1034
|
/**
|
|
1950
|
-
*
|
|
1035
|
+
* Deprecated root time-travel compatibility facade.
|
|
1951
1036
|
*
|
|
1952
|
-
*
|
|
1953
|
-
*
|
|
1954
|
-
*
|
|
1955
|
-
*
|
|
1956
|
-
* Model:
|
|
1957
|
-
* - `recordGraphSnapshot()` captures the canonical graph data (entities, patches,
|
|
1958
|
-
* entityStates, syncMetadata, lists) into a bounded ring (default 50).
|
|
1959
|
-
* - `restoreGraphSnapshot(index)` writes a captured snapshot back into the live
|
|
1960
|
-
* Zustand store — the graph (and every subscriber/view) reverts to that state.
|
|
1961
|
-
* - `getTimeTravelState()` exposes the ring + current cursor for the devtools UI.
|
|
1962
|
-
*
|
|
1963
|
-
* Snapshots are deep-cloned on capture and on restore so restoring never aliases
|
|
1964
|
-
* ring contents into the live store (a later mutation must not corrupt history).
|
|
1965
|
-
*
|
|
1966
|
-
* This is debug-time machinery: it is intended to run behind the EntityExplorer,
|
|
1967
|
-
* not in production data paths.
|
|
1037
|
+
* Snapshot data, cursors, retention, rewind state, and listeners are owned by
|
|
1038
|
+
* the optional per-store DevTools controller. This root module imports only a
|
|
1039
|
+
* lightweight delegate bridge, so normal package imports do not pull the
|
|
1040
|
+
* optional controller/protocol implementation into the root bundle.
|
|
1968
1041
|
*/
|
|
1969
1042
|
|
|
1970
1043
|
type GraphSlice = Pick<ReturnType<typeof graphStore.getState>, "entities" | "patches" | "entityStates" | "syncMetadata" | "lists">;
|
|
1971
1044
|
interface TimeTravelSnapshot {
|
|
1972
|
-
/** Monotonic
|
|
1045
|
+
/** Monotonic controller cursor for the captured state. */
|
|
1973
1046
|
seq: number;
|
|
1974
1047
|
/** Capture timestamp (ms). */
|
|
1975
1048
|
at: number;
|
|
1976
|
-
/** Optional label
|
|
1049
|
+
/** Optional compatibility label. */
|
|
1977
1050
|
label?: string;
|
|
1051
|
+
/** Snapshot payloads are controller-private and no longer exposed at root. */
|
|
1978
1052
|
data: GraphSlice;
|
|
1979
1053
|
}
|
|
1980
1054
|
interface TimeTravelState {
|
|
1981
1055
|
snapshots: ReadonlyArray<Omit<TimeTravelSnapshot, "data">>;
|
|
1982
|
-
/**
|
|
1056
|
+
/** Compatibility ring index currently restored, or null when live. */
|
|
1983
1057
|
cursor: number | null;
|
|
1984
1058
|
capacity: number;
|
|
1985
1059
|
}
|
|
1986
|
-
/**
|
|
1060
|
+
/** @deprecated Attach `@prometheus-ags/entity-graph-core/devtools` and configure its controller. */
|
|
1987
1061
|
declare function configureTimeTravel(opts: {
|
|
1988
1062
|
capacity?: number;
|
|
1989
|
-
}): void;
|
|
1990
|
-
/** Capture the current live graph state into the ring. Returns the snapshot seq. */
|
|
1991
|
-
declare function recordGraphSnapshot(label?: string, storeApi?: GraphStore$1): number;
|
|
1063
|
+
}, storeApi?: GraphStore$1): void;
|
|
1992
1064
|
/**
|
|
1993
|
-
*
|
|
1994
|
-
*
|
|
1995
|
-
* captured slice, so all subscribers re-render at that historical state.
|
|
1996
|
-
* Returns true if restored.
|
|
1065
|
+
* @deprecated Use the attached controller's automatic snapshot history.
|
|
1066
|
+
* Returns `-1` when the optional controller is not attached to `storeApi`.
|
|
1997
1067
|
*/
|
|
1068
|
+
declare function recordGraphSnapshot(label?: string, storeApi?: GraphStore$1): number;
|
|
1069
|
+
/** @deprecated Use `controller.rewind(cursor)` from the explicit `./devtools` entry. */
|
|
1998
1070
|
declare function restoreGraphSnapshot(index: number, storeApi?: GraphStore$1): boolean;
|
|
1999
|
-
/**
|
|
1071
|
+
/** @deprecated Use `controller.rewind(cursor)` from the explicit `./devtools` entry. */
|
|
2000
1072
|
declare function restoreGraphSnapshotBySeq(seq: number, storeApi?: GraphStore$1): boolean;
|
|
2001
|
-
/**
|
|
1073
|
+
/** @deprecated Resolve retained cursors through the explicit per-store controller. */
|
|
2002
1074
|
declare function stepTimeTravel(delta: number, storeApi?: GraphStore$1): boolean;
|
|
2003
|
-
/**
|
|
2004
|
-
declare function getTimeTravelState(): TimeTravelState;
|
|
2005
|
-
/** Subscribe to
|
|
2006
|
-
declare function subscribeTimeTravel(cb: () => void): () => void;
|
|
1075
|
+
/** @deprecated Use `controller.getSnapshotHistoryStatus()` and controller events. */
|
|
1076
|
+
declare function getTimeTravelState(storeApi?: GraphStore$1): TimeTravelState;
|
|
1077
|
+
/** @deprecated Subscribe to the explicit per-store controller. */
|
|
1078
|
+
declare function subscribeTimeTravel(cb: () => void, storeApi?: GraphStore$1): () => void;
|
|
2007
1079
|
|
|
2008
1080
|
/**
|
|
2009
1081
|
* Evaluate `FilterSpec` against one in-memory entity — mirrors remote semantics as closely as plain JS allows.
|
|
@@ -3308,4 +2380,4 @@ declare function getFacetedMinMaxValues<TData>(rowModel: RowModel<TData>, column
|
|
|
3308
2380
|
*/
|
|
3309
2381
|
declare function getFacetedRowModel<TData>(preFilteredRowModel: RowModel<TData>, columnId: string, allFilteredRowModel: RowModel<TData>): RowModel<TData>;
|
|
3310
2382
|
|
|
3311
|
-
export { type AccessorFn, type AdapterStatus, type AgUiStateDeltaEvent, type AgUiStateMapping, type AgUiStateSnapshotEvent, type AggregationFn, type ApplyAgUiOptions, type BelongsToRelation, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeEvent, type ChangeOp, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnDef, type ColumnFiltersState, type ColumnMeta, type ColumnOrderState, type ColumnPinningState, type ColumnSizingInfoState, type ColumnSizingState, type ColumnVisibilityState, type
|
|
2383
|
+
export { type AccessorFn, type AdapterStatus, type AgUiStateDeltaEvent, type AgUiStateMapping, type AgUiStateSnapshotEvent, type AggregationFn, type ApplyAgUiOptions, type BelongsToRelation, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeEvent, type ChangeOp, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnDef, type ColumnFiltersState, type ColumnMeta, type ColumnOrderState, type ColumnPinningState, type ColumnSizingInfoState, type ColumnSizingState, type ColumnVisibilityState, type CreateFlintAdapterOptions, type CreatePGlitePersistenceAdapterOptions, type CreateTauriSqlPersistenceAdapterOptions, type DevtoolsEvent, type DevtoolsEventBus, type DevtoolsEventBusOptions, type DevtoolsSourceFn, type ElectricAdapterOptions, type ElectricTableConfig, type EngineOptions, type EntityChange, EntityId, type EntityJsonSchemaConfig, type EntityQueryOptions, type EntitySchema, EntitySnapshot, EntitySyncMetadata, type EntityTransport, EntityType, type ExpandedState, type FilterFn, FilterSpec, type FlintCheckpointStore, type FlintClientLike, type FlintEntityEvent, type FlintEntityQuery, type FlintEntityRecord, type GetEntityJsonSchemaOptions, type GraphActionEvent, type GraphActionOptions, type GraphActionRecord$1 as GraphActionRecord, type GraphEffectEvent, type GraphEffectHandle, type GraphEffectOptions, type GraphIncludeMap, type GraphIncludeRelation, type GraphPersistenceAdapter, type GraphQueryOptions, type GraphSnapshotExportOptions, type GraphSnapshotPayload, type GraphSnapshotWithSchemasOptions, GraphStore$1 as GraphStore, type GraphSyncStatus, type GraphToolContext, type GraphTransaction, type GroupingState, type HasManyRelation, type Header, type HeaderContext, type HeaderGroup, type HeaderRenderer, IncrementalView, type IncrementalViewOptions, type JsonPatchOp, type JsonSchemaObject, type ListFetchParams, type ListQuery, type ListQueryOptions, type ListResponse, type ListResult, type LocalFirstGraphRuntime, type LoroModuleLoader, type MakeRestTransportOptions, type ManagerOptions, type ManyToManyRelation, type MergeContext, type MergeStrategy, type PGlitePersistenceClient, type PaginationState, type ColumnDef as PureColumnDef, type ColumnMeta as PureColumnMeta, QueryKey, type RealtimeAdapter, RealtimeManager, type RegisterEntityFromSqlOptions, type RegisteredStore, type RelationDescriptor, type ReplayRetryPolicy, type Row, type RowModel, type RowSelectionState, type SchemaGraphToolContext, SortSpec, type SortingFn, type SortingState, type StartLocalFirstGraphOptions, type SubscriptionConfig, type SupabaseAdapterOptions, type SupabaseLike, type SupabaseQueryBuilderLike, type SurrealCheckpointStore, type SurrealLike, type SurrealLiveAction, type SurrealLiveAdapterOptions, type SurrealTableConfig, type SyncAdapter, SyncOrigin, type TableInstance, type TableOptions, type TableState, type TauriSqlClient, type TenantClaim, type TenantScopedAdapterOptions, type TenantScopedTableConfig, type TimeTravelSnapshot, type TimeTravelState, type UnsubscribeFn, type Updater, type ViewMode, type WebSocketAdapterOptions, __resetActiveGraphStore, __resetEntityTransports, __resetStoreRegistry, applyAgUiDelta, applyAgUiSnapshot, applyJsonPatch, applyView, attachGlobalListeners, buildTenantWhere, cascadeInvalidation, checkCompleteness, collectDirtyPaths, compareEntities, configureEngine, configureTimeTravel, createConvexAdapter, createDevtoolsEventBus, createElectricAdapter, createFlintAdapter, createGraphAction, createGraphEffect, createGraphQLSubscriptionAdapter, createGraphTool, createGraphTransaction, createLoroMergeStrategy, createPGlitePersistenceAdapter, createRow, createSchemaGraphTool, createSupabaseRealtimeAdapter, createSurrealLiveAdapter, createTauriSqlPersistenceAdapter, createTenantScopedElectricAdapter, createWebSocketAdapter, dedupe, escapeHtml, exportGraphSnapshot, exportGraphSnapshotWithSchemas, fetchEntity, fetchList, findInsertionIndex, getActiveSubscriberCount, getCoreRowModel, getRealtimeManager as getElectricRealtimeManager, getEngineOptions, getEntityJsonSchema, getEntityTransport, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGraphSyncStatus, getGroupedRowModel, getMergeStrategy, getPaginatedRowModel, getRealtimeManager, getRegisteredEntityTypes, getRegisteredStores, getSchema, getSelectedRowModel, getSortedRowModel, getTimeTravelState, getValueAtPath, graphStore, graphSyncStatusStore, hasMergeStrategy, humanizeFieldName, hydrateGraphFromStorage, inferSchemaFieldType, lwwStrategy, makeRestTransport, matchesFilter, matchesSearch, parseCreateTable, persistGraphToStorage, prepareGraphStoreScope, publishFlintMutation, queryOnce, readRelations, recordGraphSnapshot, registerEntityFromSql, registerEntityJsonSchema, registerEntityTransport, registerMergeStrategy, registerRuntimeSchema, registerSchema, registerStore, registerSubscriber, registryKey, renderMarkdownToHtml, replayActionWithRetry, resetRealtimeManager, resolveActiveGraphStore, restoreGraphSnapshot, restoreGraphSnapshotBySeq, runWithGraphStore, selectGraph, serializeKey, setActiveGraphStore, setDefaultMergeStrategy, setValueAtPath, sqlTypeToJsonSchema, startGarbageCollector, startLocalFirstGraph, stepTimeTravel, stopGarbageCollector, subscribeDevtoolsEvent, subscribeSubscriberStats, subscribeTimeTravel, toPrismaOrderBy, toPrismaWhere, unregisterSubscriber, useGraphStore };
|