@prometheus-ags/prometheus-entity-management 1.0.0 → 1.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 +21 -0
- package/README.md +31 -3
- package/dist/index.d.mts +162 -1
- package/dist/index.d.ts +162 -1
- package/dist/index.js +331 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +325 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [1.1.0] — 2026-04-05
|
|
9
|
+
|
|
10
|
+
Graph-runtime expansion release focused on TanStack DB comparison gaps without changing the library’s core React entity-graph architecture.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Graph runtime snapshot helpers: `queryOnce(...)` and `selectGraph(...)`.
|
|
15
|
+
- Nested graph projection support via graph-native `include` definitions.
|
|
16
|
+
- Explicit optimistic write primitives: `createGraphTransaction(...)` and `createGraphAction(...)`.
|
|
17
|
+
- Graph workflow/effect helper: `createGraphEffect(...)`.
|
|
18
|
+
- Per-entity sync/provenance metadata exposed through snapshot reads: `$synced`, `$origin`, `$updatedAt`.
|
|
19
|
+
- AI interoperability helpers: `createGraphTool(...)` and `exportGraphSnapshot(...)`.
|
|
20
|
+
- Vitest coverage for graph runtime querying, actions, rollback, effects, and AI helpers.
|
|
21
|
+
- New comparison documentation: `docs/tanstack-comparison.md`.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Core read paths now resolve sync-aware snapshots rather than base-entity-plus-patch merges alone.
|
|
26
|
+
- Optimistic mutation and CRUD flows now track sync metadata and restore it correctly on rollback.
|
|
27
|
+
- Top-level docs now describe the graph runtime surface and the library’s positioning relative to TanStack DB, Query, Table, AI, and Intent.
|
|
28
|
+
|
|
8
29
|
## [1.0.0] — 2026-04-04
|
|
9
30
|
|
|
10
31
|
Production-ready semantic version with CI, tests, documentation, and skills export verification.
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Update a post in one screen and every list row, detail panel, and badge that rea
|
|
|
9
9
|
| Doc | Purpose |
|
|
10
10
|
|-----|---------|
|
|
11
11
|
| [docs/tanstack-query-and-table.md](docs/tanstack-query-and-table.md) | How this library fits with TanStack Query and TanStack Table |
|
|
12
|
+
| [docs/tanstack-comparison.md](docs/tanstack-comparison.md) | Detailed comparison against TanStack DB, Query, Table, AI, and Intent |
|
|
12
13
|
| [docs/advanced.md](docs/advanced.md) | Engine, GC, Suspense, DevTools, SSR, testing |
|
|
13
14
|
| [RELEASING.md](RELEASING.md) | Versioning, `prepublishOnly`, npm publish |
|
|
14
15
|
| [CHANGELOG.md](CHANGELOG.md) | Release history |
|
|
@@ -20,10 +21,10 @@ Update a post in one screen and every list row, detail panel, and badge that rea
|
|
|
20
21
|
### 1. Install
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
|
|
24
|
+
pnpm add @prometheus-ags/prometheus-entity-management zustand immer
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
(`
|
|
27
|
+
(`npm install` works for consumers too; this repository itself is `pnpm`-only.)
|
|
27
28
|
|
|
28
29
|
### 2. Define an entity type
|
|
29
30
|
|
|
@@ -98,6 +99,21 @@ Data flows **up** into the graph; UI reads **down** through hooks (see [Architec
|
|
|
98
99
|
|
|
99
100
|
---
|
|
100
101
|
|
|
102
|
+
## New in v1.1
|
|
103
|
+
|
|
104
|
+
The graph runtime now exposes a focused set of non-hook helpers for loaders, workflows, and orchestration:
|
|
105
|
+
|
|
106
|
+
- `queryOnce(...)` / `selectGraph(...)` for one-shot graph snapshots without a live subscription
|
|
107
|
+
- nested `include` projections over normalized graph data
|
|
108
|
+
- `createGraphTransaction(...)` / `createGraphAction(...)` for explicit optimistic graph writes with rollback
|
|
109
|
+
- sync-aware snapshot metadata: `$synced`, `$origin`, `$updatedAt`
|
|
110
|
+
- `createGraphEffect(...)` for enter/update/exit reactions over graph query results
|
|
111
|
+
- `createGraphTool(...)` / `exportGraphSnapshot(...)` for AI interoperability without bundling an AI runtime
|
|
112
|
+
|
|
113
|
+
These additions are intentionally graph-native. They extend the entity graph for orchestration use cases without changing the core `Components → Hooks → Stores → APIs/Realtime` architecture.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
101
117
|
## Feature comparison
|
|
102
118
|
|
|
103
119
|
| Feature | `@prometheus-ags/prometheus-entity-management` | TanStack Query | Apollo Client | SWR |
|
|
@@ -147,6 +163,17 @@ Compare against peers only when measurement methodology matches (minified vs unm
|
|
|
147
163
|
| `dedupe` | Process-global in-flight promise deduplication helper. |
|
|
148
164
|
| `startGarbageCollector` / `stopGarbageCollector` | Periodic eviction of unsubscribed, stale entities (also started via `configureEngine`). |
|
|
149
165
|
|
|
166
|
+
### Graph runtime
|
|
167
|
+
|
|
168
|
+
| Export | Description |
|
|
169
|
+
|--------|-------------|
|
|
170
|
+
| `queryOnce` / `selectGraph` | One-shot graph snapshot queries with local filtering, sorting, and nested includes. |
|
|
171
|
+
| `createGraphTransaction` | Explicit graph write transaction with commit / rollback. |
|
|
172
|
+
| `createGraphAction` | Higher-level optimistic action wrapper around graph transactions. |
|
|
173
|
+
| `createGraphEffect` | Subscribe to graph query results with `onEnter`, `onUpdate`, and `onExit`. |
|
|
174
|
+
| `createGraphTool` | Typed graph-backed helper for AI or workflow integrations. |
|
|
175
|
+
| `exportGraphSnapshot` | Serialize graph data for prompts, exports, and non-React workflows. |
|
|
176
|
+
|
|
150
177
|
### Hooks (REST-oriented)
|
|
151
178
|
|
|
152
179
|
| Export | Description |
|
|
@@ -232,7 +259,7 @@ Compare against peers only when measurement methodology matches (minified vs unm
|
|
|
232
259
|
|
|
233
260
|
### Types (high level)
|
|
234
261
|
|
|
235
|
-
`GraphState`, `EntityState`, `ListState`, `EntityType`, `EntityId`, `EngineOptions`, `EntityQueryOptions`, `ListQueryOptions`, `ViewDescriptor`, `EntitySchema`, `RelationDescriptor`, realtime adapter types, GraphQL types, CRUD types, column meta types
|
|
262
|
+
`GraphState`, `EntityState`, `ListState`, `EntityType`, `EntityId`, `EntitySyncMetadata`, `EntitySnapshot`, `EngineOptions`, `EntityQueryOptions`, `ListQueryOptions`, `ViewDescriptor`, `EntitySchema`, `RelationDescriptor`, realtime adapter types, GraphQL types, CRUD types, and column meta types are all exported from the package entry.
|
|
236
263
|
|
|
237
264
|
---
|
|
238
265
|
|
|
@@ -475,6 +502,7 @@ pnpm run dev:next # http://localhost:3000
|
|
|
475
502
|
1. **`entities`** — Canonical server-shaped records per `(type, id)`.
|
|
476
503
|
2. **`patches`** — Local-only overlays (`_selected`, `_loading`, …) merged at read time.
|
|
477
504
|
3. **`lists`** — Ordered `ids[]`, pagination, and fetch flags — **not** duplicated row payloads.
|
|
505
|
+
4. **`syncMetadata`** — Per-entity sync/provenance state layered into snapshot reads as `$synced`, `$origin`, and `$updatedAt`.
|
|
478
506
|
|
|
479
507
|
### Engine (`src/engine.ts`)
|
|
480
508
|
|
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,20 @@ type EntityType = string;
|
|
|
11
11
|
type EntityId = string;
|
|
12
12
|
/** Stable string key for a list query (often `JSON.stringify`-shaped). Lists store IDs only under this key. */
|
|
13
13
|
type QueryKey = string;
|
|
14
|
+
/** Provenance of the latest known entity state. */
|
|
15
|
+
type SyncOrigin = "server" | "client" | "optimistic";
|
|
16
|
+
/** Optional sync-facing metadata kept outside canonical entity payloads. */
|
|
17
|
+
interface EntitySyncMetadata {
|
|
18
|
+
synced: boolean;
|
|
19
|
+
origin: SyncOrigin;
|
|
20
|
+
updatedAt: number | null;
|
|
21
|
+
}
|
|
22
|
+
/** Snapshot shape returned by sync-aware reads and graph-native query helpers. */
|
|
23
|
+
type EntitySnapshot<T extends Record<string, unknown>> = T & {
|
|
24
|
+
$synced: boolean;
|
|
25
|
+
$origin: SyncOrigin;
|
|
26
|
+
$updatedAt: number | null;
|
|
27
|
+
};
|
|
14
28
|
/**
|
|
15
29
|
* Fetch/cache metadata for a single entity instance (`type:id`).
|
|
16
30
|
* Separates transport concerns from canonical `entities` data so hooks can show spinners and stale-while-revalidate without mutating server-shaped fields.
|
|
@@ -51,6 +65,8 @@ interface GraphState {
|
|
|
51
65
|
patches: Record<EntityType, Record<EntityId, Record<string, unknown>>>;
|
|
52
66
|
/** Per-entity fetch lifecycle keyed as `${type}:${id}`. */
|
|
53
67
|
entityStates: Record<string, EntityState>;
|
|
68
|
+
/** Optional sync/provenance state layered beside the canonical entity payload. */
|
|
69
|
+
syncMetadata: Record<string, EntitySyncMetadata>;
|
|
54
70
|
/** List slots keyed by serialized query keys. Values hold id arrays and pagination — not entity clones. */
|
|
55
71
|
lists: Record<QueryKey, ListState>;
|
|
56
72
|
/**
|
|
@@ -91,6 +107,10 @@ interface GraphState {
|
|
|
91
107
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
92
108
|
/** Drive background revalidation: when true, hooks refetch while still showing cached `readEntity` data. */
|
|
93
109
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
110
|
+
/** Merge sync metadata for one entity without polluting canonical server fields. */
|
|
111
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
112
|
+
/** Clear sync metadata for one entity. */
|
|
113
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
94
114
|
/**
|
|
95
115
|
* Replace list ids and merge pagination meta after a primary list fetch (not load-more).
|
|
96
116
|
* Resets fetching flags and clears list error on success path (engine calls this after normalize).
|
|
@@ -131,6 +151,10 @@ interface GraphState {
|
|
|
131
151
|
* @returns Merged view suitable for rendering; not a deep clone
|
|
132
152
|
*/
|
|
133
153
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
154
|
+
/**
|
|
155
|
+
* Sync-aware read path: canonical entity + patches + virtual sync metadata (`$synced`, `$origin`, `$updatedAt`).
|
|
156
|
+
*/
|
|
157
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
134
158
|
}
|
|
135
159
|
/**
|
|
136
160
|
* Global entity graph store (Zustand + Immer). **Components should not subscribe directly** — use hooks so layering stays `Component → hook → store`.
|
|
@@ -168,6 +192,13 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
168
192
|
stale: boolean;
|
|
169
193
|
};
|
|
170
194
|
};
|
|
195
|
+
syncMetadata: {
|
|
196
|
+
[x: string]: {
|
|
197
|
+
synced: boolean;
|
|
198
|
+
origin: SyncOrigin;
|
|
199
|
+
updatedAt: number | null;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
171
202
|
lists: {
|
|
172
203
|
[x: string]: {
|
|
173
204
|
ids: string[];
|
|
@@ -199,6 +230,8 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
199
230
|
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
200
231
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
201
232
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
233
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
234
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
202
235
|
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
203
236
|
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
204
237
|
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
@@ -212,6 +245,7 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
212
245
|
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
213
246
|
invalidateType: (type: EntityType) => void;
|
|
214
247
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
248
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
215
249
|
}) => void), shouldReplace?: false): void;
|
|
216
250
|
setState(nextStateOrUpdater: GraphState | ((state: {
|
|
217
251
|
entities: {
|
|
@@ -236,6 +270,13 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
236
270
|
stale: boolean;
|
|
237
271
|
};
|
|
238
272
|
};
|
|
273
|
+
syncMetadata: {
|
|
274
|
+
[x: string]: {
|
|
275
|
+
synced: boolean;
|
|
276
|
+
origin: SyncOrigin;
|
|
277
|
+
updatedAt: number | null;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
239
280
|
lists: {
|
|
240
281
|
[x: string]: {
|
|
241
282
|
ids: string[];
|
|
@@ -267,6 +308,8 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
267
308
|
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
268
309
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
269
310
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
311
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
312
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
270
313
|
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
271
314
|
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
272
315
|
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
@@ -280,9 +323,127 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
280
323
|
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
281
324
|
invalidateType: (type: EntityType) => void;
|
|
282
325
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
326
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
283
327
|
}) => void), shouldReplace: true): void;
|
|
284
328
|
}>;
|
|
285
329
|
|
|
330
|
+
type GraphStore = ReturnType<typeof useGraphStore.getState>;
|
|
331
|
+
type GraphIncludeMap = Record<string, GraphIncludeRelation>;
|
|
332
|
+
type GraphIncludeRelation = {
|
|
333
|
+
type: EntityType;
|
|
334
|
+
via: {
|
|
335
|
+
kind: "field";
|
|
336
|
+
field: string;
|
|
337
|
+
};
|
|
338
|
+
include?: GraphIncludeMap;
|
|
339
|
+
} | {
|
|
340
|
+
type: EntityType;
|
|
341
|
+
via: {
|
|
342
|
+
kind: "array";
|
|
343
|
+
field: string;
|
|
344
|
+
};
|
|
345
|
+
include?: GraphIncludeMap;
|
|
346
|
+
} | {
|
|
347
|
+
type: EntityType;
|
|
348
|
+
via: {
|
|
349
|
+
kind: "list";
|
|
350
|
+
key: QueryKey | ((entity: Record<string, unknown>) => QueryKey | null | undefined);
|
|
351
|
+
};
|
|
352
|
+
include?: GraphIncludeMap;
|
|
353
|
+
} | {
|
|
354
|
+
type: EntityType;
|
|
355
|
+
via: {
|
|
356
|
+
kind: "resolver";
|
|
357
|
+
resolve: (entity: Record<string, unknown>, store: GraphStore) => EntityId | EntityId[] | null | undefined;
|
|
358
|
+
};
|
|
359
|
+
include?: GraphIncludeMap;
|
|
360
|
+
};
|
|
361
|
+
interface GraphQueryOptions<TEntity extends Record<string, unknown>> {
|
|
362
|
+
type: EntityType;
|
|
363
|
+
id?: EntityId;
|
|
364
|
+
ids?: EntityId[];
|
|
365
|
+
listKey?: QueryKey;
|
|
366
|
+
where?: (entity: EntitySnapshot<TEntity>) => boolean;
|
|
367
|
+
sort?: (a: EntitySnapshot<TEntity>, b: EntitySnapshot<TEntity>) => number;
|
|
368
|
+
include?: GraphIncludeMap;
|
|
369
|
+
select?: ((entity: Record<string, unknown>) => unknown) | string[];
|
|
370
|
+
}
|
|
371
|
+
type ProjectedRow = Record<string, unknown>;
|
|
372
|
+
declare function queryOnce<TEntity extends Record<string, unknown>>(opts: GraphQueryOptions<TEntity> & {
|
|
373
|
+
id: EntityId;
|
|
374
|
+
}): ProjectedRow | null;
|
|
375
|
+
declare function queryOnce<TEntity extends Record<string, unknown>>(opts: GraphQueryOptions<TEntity>): ProjectedRow[];
|
|
376
|
+
declare const selectGraph: typeof queryOnce;
|
|
377
|
+
|
|
378
|
+
interface GraphDataSnapshot {
|
|
379
|
+
entities: ReturnType<typeof useGraphStore.getState>["entities"];
|
|
380
|
+
patches: ReturnType<typeof useGraphStore.getState>["patches"];
|
|
381
|
+
entityStates: ReturnType<typeof useGraphStore.getState>["entityStates"];
|
|
382
|
+
syncMetadata: ReturnType<typeof useGraphStore.getState>["syncMetadata"];
|
|
383
|
+
lists: ReturnType<typeof useGraphStore.getState>["lists"];
|
|
384
|
+
}
|
|
385
|
+
interface GraphTransaction {
|
|
386
|
+
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => GraphTransaction;
|
|
387
|
+
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => GraphTransaction;
|
|
388
|
+
removeEntity: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
389
|
+
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => GraphTransaction;
|
|
390
|
+
clearPatch: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
391
|
+
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => GraphTransaction;
|
|
392
|
+
removeIdFromAllLists: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
393
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => GraphTransaction;
|
|
394
|
+
markEntityPending: (type: EntityType, id: EntityId, origin?: SyncOrigin) => GraphTransaction;
|
|
395
|
+
markEntitySynced: (type: EntityType, id: EntityId, origin?: SyncOrigin) => GraphTransaction;
|
|
396
|
+
commit: () => void;
|
|
397
|
+
rollback: () => void;
|
|
398
|
+
snapshot: () => GraphDataSnapshot;
|
|
399
|
+
}
|
|
400
|
+
interface GraphActionOptions<TInput, TResult> {
|
|
401
|
+
optimistic?: (tx: GraphTransaction, input: TInput) => void;
|
|
402
|
+
run: (tx: GraphTransaction, input: TInput) => Promise<TResult> | TResult;
|
|
403
|
+
onSuccess?: (result: TResult, input: TInput, tx: GraphTransaction) => void;
|
|
404
|
+
onError?: (error: Error, input: TInput) => void;
|
|
405
|
+
}
|
|
406
|
+
declare function createGraphTransaction(): GraphTransaction;
|
|
407
|
+
declare function createGraphAction<TInput, TResult>(opts: GraphActionOptions<TInput, TResult>): (input: TInput) => Promise<TResult>;
|
|
408
|
+
|
|
409
|
+
interface GraphEffectEvent<T> {
|
|
410
|
+
key: string;
|
|
411
|
+
value: T;
|
|
412
|
+
previousValue: T;
|
|
413
|
+
}
|
|
414
|
+
interface GraphEffectOptions<T> {
|
|
415
|
+
query: () => T[] | T | null;
|
|
416
|
+
getKey?: (value: T, index: number) => string;
|
|
417
|
+
skipInitial?: boolean;
|
|
418
|
+
isEqual?: (previousValue: T, nextValue: T) => boolean;
|
|
419
|
+
onEnter?: (event: {
|
|
420
|
+
key: string;
|
|
421
|
+
value: T;
|
|
422
|
+
}) => void;
|
|
423
|
+
onUpdate?: (event: GraphEffectEvent<T>) => void;
|
|
424
|
+
onExit?: (event: {
|
|
425
|
+
key: string;
|
|
426
|
+
previousValue: T;
|
|
427
|
+
}) => void;
|
|
428
|
+
}
|
|
429
|
+
interface GraphEffectHandle {
|
|
430
|
+
dispose: () => void;
|
|
431
|
+
}
|
|
432
|
+
declare function createGraphEffect<T>(opts: GraphEffectOptions<T>): GraphEffectHandle;
|
|
433
|
+
|
|
434
|
+
interface GraphSnapshotExportOptions {
|
|
435
|
+
scope: string;
|
|
436
|
+
data: unknown;
|
|
437
|
+
pretty?: boolean;
|
|
438
|
+
}
|
|
439
|
+
interface GraphToolContext {
|
|
440
|
+
store: ReturnType<typeof useGraphStore.getState>;
|
|
441
|
+
queryOnce: typeof queryOnce;
|
|
442
|
+
exportGraphSnapshot: typeof exportGraphSnapshot;
|
|
443
|
+
}
|
|
444
|
+
declare function exportGraphSnapshot(opts: GraphSnapshotExportOptions): string;
|
|
445
|
+
declare function createGraphTool<TInput, TResult>(handler: (input: TInput, ctx: GraphToolContext) => Promise<TResult> | TResult): (input: TInput) => TResult | Promise<TResult>;
|
|
446
|
+
|
|
286
447
|
/**
|
|
287
448
|
* Process-wide defaults for stale times, retries, and background revalidation.
|
|
288
449
|
* Keeps hook signatures small: `useEntity` / `useEntityList` merge these with per-query overrides.
|
|
@@ -2605,4 +2766,4 @@ declare const TableHead: React$1.ForwardRefExoticComponent<React$1.ThHTMLAttribu
|
|
|
2605
2766
|
declare const TableCell: React$1.ForwardRefExoticComponent<React$1.TdHTMLAttributes<HTMLTableCellElement> & React$1.RefAttributes<HTMLTableCellElement>>;
|
|
2606
2767
|
declare const TableCaption: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLTableCaptionElement> & React$1.RefAttributes<HTMLTableCaptionElement>>;
|
|
2607
2768
|
|
|
2608
|
-
export { type AccessorFn, ActionButtonRow, type ActionDef, ActionDropdown, type ActionItem, type ActivePresets, type AdapterStatus, type AggregationFn, type BatchActionDef, type BelongsToRelation, type CRUDMode, type CRUDOptions, type CRUDState, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnFilterType, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnPreset, ColumnPresetDialog, type ColumnPresetEntry, type ColumnSizingState, type ColumnVisibilityState, type CompletenessMode, DataTable, DataTableColumnHeader, DataTableFilter, DataTablePagination, DataTableToolbar, type DirtyFields, type ElectricAdapterOptions, ElectricSQLAdapter as ElectricSQLPresetAdapter, type ElectricSQLAdapterOptions as ElectricSQLPresetAdapterOptions, type ElectricTableConfig, EmptyState, type EmptyStateConfig, type EngineOptions, type EntityChange, type EntityColumnMeta, type EntityDescriptor, EntityDetailSheet, EntityFormSheet, type EntityId, EntityListView, type EntityListViewProps, type EntityQueryOptions, type EntitySchema, type EntityState, EntityTable, type EntityType, type ExpandedState, type FieldDescriptor, type FieldType, type FilterClause, type FilterFn, type FilterGroup, type FilterOperator, type FilterPreset, FilterPresetDialog, type FilterSpec, GQLClient, type GQLClientConfig, type GQLEntityOptions, type GQLError, type GQLListOptions, type GQLResponse, type GalleryColumns, GalleryView, type GraphState, type GroupingState, type HasManyRelation, type Header, type HeaderContext, type HeaderGroup, type HeaderRenderer, InlineCellEditor$1 as InlineCellEditor, InlineItemEditor, type ItemDescriptor, type ItemDescriptorBadge, type ItemDescriptorMeta, type ItemRenderContext, type ListFetchParams, type ListQueryOptions, type ListResponse, type ListState, ListView, type ManagerOptions, type ManyToManyRelation, MemoryAdapter, MultiSelectBar, type PaginationState, type PresetChangeEvent, type PresetChangeOperation, PresetPicker, type PresetStoreState, type UnsubscribeFn as PresetUnsubscribeFn, type PrismaEntityConfigOptions, type ColumnDef as PureColumnDef, type ColumnMeta as PureColumnMeta, InlineCellEditor as PureInlineCellEditor, type RealtimeAdapter, RealtimeManager, type RelationDescriptor, type RestAdapterOptions, RestApiAdapter, type Row, type RowModel, type RowSelectionState, SelectionContext, type SelectionStoreState, Sheet, type SortClause, type SortDirection, SortHeader, type SortSpec, type SortingFn, type SortingState, type SubscriptionConfig, type SupabaseAdapterOptions$1 as SupabaseAdapterOptions, SupabaseRealtimeAdapter as SupabasePresetAdapter, type SupabaseAdapterOptions as SupabasePresetAdapterOptions, type SyncAdapter, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableInstance, type TableOptions, type TablePresetSlice, TableRow, type TableState, type TableStorageAdapter, TableStorageProvider, type TableStorageProviderProps, type UnsubscribeFn$1 as UnsubscribeFn, type Updater, type UseEntityViewOptions, type UseEntityViewResult, type UseLocalFirstResult, type UseTablePresetsOptions, type UseTablePresetsResult, type ViewDescriptor, type ViewFetchParams, type ViewMode, ViewModeSwitcher, type WebSocketAdapterOptions, type ZustandAdapterOptions, ZustandPersistAdapter, actionsColumn$1 as actionsColumn, applyView, booleanColumn$1 as booleanColumn, cascadeInvalidation, checkCompleteness, compareEntities, configureEngine, createConvexAdapter, createElectricAdapter, createGQLClient, createGraphQLSubscriptionAdapter, createPresetStore, createPrismaEntityConfig, createRow, createSelectionStore, createSupabaseRealtimeAdapter, createWebSocketAdapter, dateColumn$1 as dateColumn, dedupe, deleteAction, editAction, enumColumn$1 as enumColumn, executeGQL, fetchEntity, fetchList, flattenClauses, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginatedRowModel, getRealtimeManager, getSchema, getSelectedRowModel, getSortedRowModel, hasCustomPredicates, matchesFilter, matchesSearch, normalizeGQLResponse, numberColumn$1 as numberColumn, prismaRelationsToSchema, actionsColumn as pureActionsColumn, booleanColumn as pureBooleanColumn, dateColumn as pureDateColumn, enumColumn as pureEnumColumn, numberColumn as pureNumberColumn, selectionColumn as pureSelectionColumn, textColumn as pureTextColumn, readRelations, registerSchema, resetRealtimeManager, selectionColumn$1 as selectionColumn, serializeKey, startGarbageCollector, stopGarbageCollector, textColumn$1 as textColumn, toGraphQLVariables, toPrismaInclude, toPrismaOrderBy, toPrismaWhere, toRestParams, toSQLClauses, useEntity, useEntityAugment, useEntityCRUD, useEntityList, useEntityMutation, useEntityView, useGQLEntity, useGQLList, useGQLMutation, useGQLSubscription, useGraphDevTools, useGraphStore, useLocalFirst, usePGliteQuery, useSelectionContext, useSelectionStore, useSuspenseEntity, useSuspenseEntityList, useTable, useTablePresets, useTableRealtimeMode, useTableStorageAdapter, viewAction };
|
|
2769
|
+
export { type AccessorFn, ActionButtonRow, type ActionDef, ActionDropdown, type ActionItem, type ActivePresets, type AdapterStatus, type AggregationFn, type BatchActionDef, type BelongsToRelation, type CRUDMode, type CRUDOptions, type CRUDState, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnFilterType, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnPreset, ColumnPresetDialog, type ColumnPresetEntry, type ColumnSizingState, type ColumnVisibilityState, type CompletenessMode, DataTable, DataTableColumnHeader, DataTableFilter, DataTablePagination, DataTableToolbar, type DirtyFields, type ElectricAdapterOptions, ElectricSQLAdapter as ElectricSQLPresetAdapter, type ElectricSQLAdapterOptions as ElectricSQLPresetAdapterOptions, type ElectricTableConfig, EmptyState, type EmptyStateConfig, type EngineOptions, type EntityChange, type EntityColumnMeta, type EntityDescriptor, EntityDetailSheet, EntityFormSheet, type EntityId, EntityListView, type EntityListViewProps, type EntityQueryOptions, type EntitySchema, type EntitySnapshot, type EntityState, type EntitySyncMetadata, EntityTable, type EntityType, type ExpandedState, type FieldDescriptor, type FieldType, type FilterClause, type FilterFn, type FilterGroup, type FilterOperator, type FilterPreset, FilterPresetDialog, type FilterSpec, GQLClient, type GQLClientConfig, type GQLEntityOptions, type GQLError, type GQLListOptions, type GQLResponse, type GalleryColumns, GalleryView, type GraphActionOptions, type GraphEffectEvent, type GraphEffectHandle, type GraphEffectOptions, type GraphIncludeMap, type GraphIncludeRelation, type GraphQueryOptions, type GraphSnapshotExportOptions, type GraphState, type GraphToolContext, type GraphTransaction, type GroupingState, type HasManyRelation, type Header, type HeaderContext, type HeaderGroup, type HeaderRenderer, InlineCellEditor$1 as InlineCellEditor, InlineItemEditor, type ItemDescriptor, type ItemDescriptorBadge, type ItemDescriptorMeta, type ItemRenderContext, type ListFetchParams, type ListQueryOptions, type ListResponse, type ListState, ListView, type ManagerOptions, type ManyToManyRelation, MemoryAdapter, MultiSelectBar, type PaginationState, type PresetChangeEvent, type PresetChangeOperation, PresetPicker, type PresetStoreState, type UnsubscribeFn as PresetUnsubscribeFn, type PrismaEntityConfigOptions, type ColumnDef as PureColumnDef, type ColumnMeta as PureColumnMeta, InlineCellEditor as PureInlineCellEditor, type QueryKey, type RealtimeAdapter, RealtimeManager, type RelationDescriptor, type RestAdapterOptions, RestApiAdapter, type Row, type RowModel, type RowSelectionState, SelectionContext, type SelectionStoreState, Sheet, type SortClause, type SortDirection, SortHeader, type SortSpec, type SortingFn, type SortingState, type SubscriptionConfig, type SupabaseAdapterOptions$1 as SupabaseAdapterOptions, SupabaseRealtimeAdapter as SupabasePresetAdapter, type SupabaseAdapterOptions as SupabasePresetAdapterOptions, type SyncAdapter, type SyncOrigin, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableInstance, type TableOptions, type TablePresetSlice, TableRow, type TableState, type TableStorageAdapter, TableStorageProvider, type TableStorageProviderProps, type UnsubscribeFn$1 as UnsubscribeFn, type Updater, type UseEntityViewOptions, type UseEntityViewResult, type UseLocalFirstResult, type UseTablePresetsOptions, type UseTablePresetsResult, type ViewDescriptor, type ViewFetchParams, type ViewMode, ViewModeSwitcher, type WebSocketAdapterOptions, type ZustandAdapterOptions, ZustandPersistAdapter, actionsColumn$1 as actionsColumn, applyView, booleanColumn$1 as booleanColumn, cascadeInvalidation, checkCompleteness, compareEntities, configureEngine, createConvexAdapter, createElectricAdapter, createGQLClient, createGraphAction, createGraphEffect, createGraphQLSubscriptionAdapter, createGraphTool, createGraphTransaction, createPresetStore, createPrismaEntityConfig, createRow, createSelectionStore, createSupabaseRealtimeAdapter, createWebSocketAdapter, dateColumn$1 as dateColumn, dedupe, deleteAction, editAction, enumColumn$1 as enumColumn, executeGQL, exportGraphSnapshot, fetchEntity, fetchList, flattenClauses, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginatedRowModel, getRealtimeManager, getSchema, getSelectedRowModel, getSortedRowModel, hasCustomPredicates, matchesFilter, matchesSearch, normalizeGQLResponse, numberColumn$1 as numberColumn, prismaRelationsToSchema, actionsColumn as pureActionsColumn, booleanColumn as pureBooleanColumn, dateColumn as pureDateColumn, enumColumn as pureEnumColumn, numberColumn as pureNumberColumn, selectionColumn as pureSelectionColumn, textColumn as pureTextColumn, queryOnce, readRelations, registerSchema, resetRealtimeManager, selectGraph, selectionColumn$1 as selectionColumn, serializeKey, startGarbageCollector, stopGarbageCollector, textColumn$1 as textColumn, toGraphQLVariables, toPrismaInclude, toPrismaOrderBy, toPrismaWhere, toRestParams, toSQLClauses, useEntity, useEntityAugment, useEntityCRUD, useEntityList, useEntityMutation, useEntityView, useGQLEntity, useGQLList, useGQLMutation, useGQLSubscription, useGraphDevTools, useGraphStore, useLocalFirst, usePGliteQuery, useSelectionContext, useSelectionStore, useSuspenseEntity, useSuspenseEntityList, useTable, useTablePresets, useTableRealtimeMode, useTableStorageAdapter, viewAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,20 @@ type EntityType = string;
|
|
|
11
11
|
type EntityId = string;
|
|
12
12
|
/** Stable string key for a list query (often `JSON.stringify`-shaped). Lists store IDs only under this key. */
|
|
13
13
|
type QueryKey = string;
|
|
14
|
+
/** Provenance of the latest known entity state. */
|
|
15
|
+
type SyncOrigin = "server" | "client" | "optimistic";
|
|
16
|
+
/** Optional sync-facing metadata kept outside canonical entity payloads. */
|
|
17
|
+
interface EntitySyncMetadata {
|
|
18
|
+
synced: boolean;
|
|
19
|
+
origin: SyncOrigin;
|
|
20
|
+
updatedAt: number | null;
|
|
21
|
+
}
|
|
22
|
+
/** Snapshot shape returned by sync-aware reads and graph-native query helpers. */
|
|
23
|
+
type EntitySnapshot<T extends Record<string, unknown>> = T & {
|
|
24
|
+
$synced: boolean;
|
|
25
|
+
$origin: SyncOrigin;
|
|
26
|
+
$updatedAt: number | null;
|
|
27
|
+
};
|
|
14
28
|
/**
|
|
15
29
|
* Fetch/cache metadata for a single entity instance (`type:id`).
|
|
16
30
|
* Separates transport concerns from canonical `entities` data so hooks can show spinners and stale-while-revalidate without mutating server-shaped fields.
|
|
@@ -51,6 +65,8 @@ interface GraphState {
|
|
|
51
65
|
patches: Record<EntityType, Record<EntityId, Record<string, unknown>>>;
|
|
52
66
|
/** Per-entity fetch lifecycle keyed as `${type}:${id}`. */
|
|
53
67
|
entityStates: Record<string, EntityState>;
|
|
68
|
+
/** Optional sync/provenance state layered beside the canonical entity payload. */
|
|
69
|
+
syncMetadata: Record<string, EntitySyncMetadata>;
|
|
54
70
|
/** List slots keyed by serialized query keys. Values hold id arrays and pagination — not entity clones. */
|
|
55
71
|
lists: Record<QueryKey, ListState>;
|
|
56
72
|
/**
|
|
@@ -91,6 +107,10 @@ interface GraphState {
|
|
|
91
107
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
92
108
|
/** Drive background revalidation: when true, hooks refetch while still showing cached `readEntity` data. */
|
|
93
109
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
110
|
+
/** Merge sync metadata for one entity without polluting canonical server fields. */
|
|
111
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
112
|
+
/** Clear sync metadata for one entity. */
|
|
113
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
94
114
|
/**
|
|
95
115
|
* Replace list ids and merge pagination meta after a primary list fetch (not load-more).
|
|
96
116
|
* Resets fetching flags and clears list error on success path (engine calls this after normalize).
|
|
@@ -131,6 +151,10 @@ interface GraphState {
|
|
|
131
151
|
* @returns Merged view suitable for rendering; not a deep clone
|
|
132
152
|
*/
|
|
133
153
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
154
|
+
/**
|
|
155
|
+
* Sync-aware read path: canonical entity + patches + virtual sync metadata (`$synced`, `$origin`, `$updatedAt`).
|
|
156
|
+
*/
|
|
157
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
134
158
|
}
|
|
135
159
|
/**
|
|
136
160
|
* Global entity graph store (Zustand + Immer). **Components should not subscribe directly** — use hooks so layering stays `Component → hook → store`.
|
|
@@ -168,6 +192,13 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
168
192
|
stale: boolean;
|
|
169
193
|
};
|
|
170
194
|
};
|
|
195
|
+
syncMetadata: {
|
|
196
|
+
[x: string]: {
|
|
197
|
+
synced: boolean;
|
|
198
|
+
origin: SyncOrigin;
|
|
199
|
+
updatedAt: number | null;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
171
202
|
lists: {
|
|
172
203
|
[x: string]: {
|
|
173
204
|
ids: string[];
|
|
@@ -199,6 +230,8 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
199
230
|
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
200
231
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
201
232
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
233
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
234
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
202
235
|
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
203
236
|
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
204
237
|
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
@@ -212,6 +245,7 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
212
245
|
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
213
246
|
invalidateType: (type: EntityType) => void;
|
|
214
247
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
248
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
215
249
|
}) => void), shouldReplace?: false): void;
|
|
216
250
|
setState(nextStateOrUpdater: GraphState | ((state: {
|
|
217
251
|
entities: {
|
|
@@ -236,6 +270,13 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
236
270
|
stale: boolean;
|
|
237
271
|
};
|
|
238
272
|
};
|
|
273
|
+
syncMetadata: {
|
|
274
|
+
[x: string]: {
|
|
275
|
+
synced: boolean;
|
|
276
|
+
origin: SyncOrigin;
|
|
277
|
+
updatedAt: number | null;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
239
280
|
lists: {
|
|
240
281
|
[x: string]: {
|
|
241
282
|
ids: string[];
|
|
@@ -267,6 +308,8 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
267
308
|
setEntityError: (type: EntityType, id: EntityId, error: string | null) => void;
|
|
268
309
|
setEntityFetched: (type: EntityType, id: EntityId) => void;
|
|
269
310
|
setEntityStale: (type: EntityType, id: EntityId, stale: boolean) => void;
|
|
311
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => void;
|
|
312
|
+
clearEntitySyncMetadata: (type: EntityType, id: EntityId) => void;
|
|
270
313
|
setListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
271
314
|
appendListResult: (key: QueryKey, ids: EntityId[], meta: Partial<Omit<ListState, "ids" | "isFetching" | "isFetchingMore" | "error" | "stale">>) => void;
|
|
272
315
|
prependListResult: (key: QueryKey, ids: EntityId[], meta?: Partial<ListState>) => void;
|
|
@@ -280,9 +323,127 @@ declare const useGraphStore: zustand.UseBoundStore<Omit<Omit<zustand.StoreApi<Gr
|
|
|
280
323
|
invalidateLists: (matcher: string | ((key: QueryKey) => boolean)) => void;
|
|
281
324
|
invalidateType: (type: EntityType) => void;
|
|
282
325
|
readEntity: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => T | null;
|
|
326
|
+
readEntitySnapshot: <T = Record<string, unknown>>(type: EntityType, id: EntityId) => EntitySnapshot<T & Record<string, unknown>> | null;
|
|
283
327
|
}) => void), shouldReplace: true): void;
|
|
284
328
|
}>;
|
|
285
329
|
|
|
330
|
+
type GraphStore = ReturnType<typeof useGraphStore.getState>;
|
|
331
|
+
type GraphIncludeMap = Record<string, GraphIncludeRelation>;
|
|
332
|
+
type GraphIncludeRelation = {
|
|
333
|
+
type: EntityType;
|
|
334
|
+
via: {
|
|
335
|
+
kind: "field";
|
|
336
|
+
field: string;
|
|
337
|
+
};
|
|
338
|
+
include?: GraphIncludeMap;
|
|
339
|
+
} | {
|
|
340
|
+
type: EntityType;
|
|
341
|
+
via: {
|
|
342
|
+
kind: "array";
|
|
343
|
+
field: string;
|
|
344
|
+
};
|
|
345
|
+
include?: GraphIncludeMap;
|
|
346
|
+
} | {
|
|
347
|
+
type: EntityType;
|
|
348
|
+
via: {
|
|
349
|
+
kind: "list";
|
|
350
|
+
key: QueryKey | ((entity: Record<string, unknown>) => QueryKey | null | undefined);
|
|
351
|
+
};
|
|
352
|
+
include?: GraphIncludeMap;
|
|
353
|
+
} | {
|
|
354
|
+
type: EntityType;
|
|
355
|
+
via: {
|
|
356
|
+
kind: "resolver";
|
|
357
|
+
resolve: (entity: Record<string, unknown>, store: GraphStore) => EntityId | EntityId[] | null | undefined;
|
|
358
|
+
};
|
|
359
|
+
include?: GraphIncludeMap;
|
|
360
|
+
};
|
|
361
|
+
interface GraphQueryOptions<TEntity extends Record<string, unknown>> {
|
|
362
|
+
type: EntityType;
|
|
363
|
+
id?: EntityId;
|
|
364
|
+
ids?: EntityId[];
|
|
365
|
+
listKey?: QueryKey;
|
|
366
|
+
where?: (entity: EntitySnapshot<TEntity>) => boolean;
|
|
367
|
+
sort?: (a: EntitySnapshot<TEntity>, b: EntitySnapshot<TEntity>) => number;
|
|
368
|
+
include?: GraphIncludeMap;
|
|
369
|
+
select?: ((entity: Record<string, unknown>) => unknown) | string[];
|
|
370
|
+
}
|
|
371
|
+
type ProjectedRow = Record<string, unknown>;
|
|
372
|
+
declare function queryOnce<TEntity extends Record<string, unknown>>(opts: GraphQueryOptions<TEntity> & {
|
|
373
|
+
id: EntityId;
|
|
374
|
+
}): ProjectedRow | null;
|
|
375
|
+
declare function queryOnce<TEntity extends Record<string, unknown>>(opts: GraphQueryOptions<TEntity>): ProjectedRow[];
|
|
376
|
+
declare const selectGraph: typeof queryOnce;
|
|
377
|
+
|
|
378
|
+
interface GraphDataSnapshot {
|
|
379
|
+
entities: ReturnType<typeof useGraphStore.getState>["entities"];
|
|
380
|
+
patches: ReturnType<typeof useGraphStore.getState>["patches"];
|
|
381
|
+
entityStates: ReturnType<typeof useGraphStore.getState>["entityStates"];
|
|
382
|
+
syncMetadata: ReturnType<typeof useGraphStore.getState>["syncMetadata"];
|
|
383
|
+
lists: ReturnType<typeof useGraphStore.getState>["lists"];
|
|
384
|
+
}
|
|
385
|
+
interface GraphTransaction {
|
|
386
|
+
upsertEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => GraphTransaction;
|
|
387
|
+
replaceEntity: (type: EntityType, id: EntityId, data: Record<string, unknown>) => GraphTransaction;
|
|
388
|
+
removeEntity: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
389
|
+
patchEntity: (type: EntityType, id: EntityId, patch: Record<string, unknown>) => GraphTransaction;
|
|
390
|
+
clearPatch: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
391
|
+
insertIdInList: (key: QueryKey, id: EntityId, position: "start" | "end" | number) => GraphTransaction;
|
|
392
|
+
removeIdFromAllLists: (type: EntityType, id: EntityId) => GraphTransaction;
|
|
393
|
+
setEntitySyncMetadata: (type: EntityType, id: EntityId, metadata: Partial<EntitySyncMetadata>) => GraphTransaction;
|
|
394
|
+
markEntityPending: (type: EntityType, id: EntityId, origin?: SyncOrigin) => GraphTransaction;
|
|
395
|
+
markEntitySynced: (type: EntityType, id: EntityId, origin?: SyncOrigin) => GraphTransaction;
|
|
396
|
+
commit: () => void;
|
|
397
|
+
rollback: () => void;
|
|
398
|
+
snapshot: () => GraphDataSnapshot;
|
|
399
|
+
}
|
|
400
|
+
interface GraphActionOptions<TInput, TResult> {
|
|
401
|
+
optimistic?: (tx: GraphTransaction, input: TInput) => void;
|
|
402
|
+
run: (tx: GraphTransaction, input: TInput) => Promise<TResult> | TResult;
|
|
403
|
+
onSuccess?: (result: TResult, input: TInput, tx: GraphTransaction) => void;
|
|
404
|
+
onError?: (error: Error, input: TInput) => void;
|
|
405
|
+
}
|
|
406
|
+
declare function createGraphTransaction(): GraphTransaction;
|
|
407
|
+
declare function createGraphAction<TInput, TResult>(opts: GraphActionOptions<TInput, TResult>): (input: TInput) => Promise<TResult>;
|
|
408
|
+
|
|
409
|
+
interface GraphEffectEvent<T> {
|
|
410
|
+
key: string;
|
|
411
|
+
value: T;
|
|
412
|
+
previousValue: T;
|
|
413
|
+
}
|
|
414
|
+
interface GraphEffectOptions<T> {
|
|
415
|
+
query: () => T[] | T | null;
|
|
416
|
+
getKey?: (value: T, index: number) => string;
|
|
417
|
+
skipInitial?: boolean;
|
|
418
|
+
isEqual?: (previousValue: T, nextValue: T) => boolean;
|
|
419
|
+
onEnter?: (event: {
|
|
420
|
+
key: string;
|
|
421
|
+
value: T;
|
|
422
|
+
}) => void;
|
|
423
|
+
onUpdate?: (event: GraphEffectEvent<T>) => void;
|
|
424
|
+
onExit?: (event: {
|
|
425
|
+
key: string;
|
|
426
|
+
previousValue: T;
|
|
427
|
+
}) => void;
|
|
428
|
+
}
|
|
429
|
+
interface GraphEffectHandle {
|
|
430
|
+
dispose: () => void;
|
|
431
|
+
}
|
|
432
|
+
declare function createGraphEffect<T>(opts: GraphEffectOptions<T>): GraphEffectHandle;
|
|
433
|
+
|
|
434
|
+
interface GraphSnapshotExportOptions {
|
|
435
|
+
scope: string;
|
|
436
|
+
data: unknown;
|
|
437
|
+
pretty?: boolean;
|
|
438
|
+
}
|
|
439
|
+
interface GraphToolContext {
|
|
440
|
+
store: ReturnType<typeof useGraphStore.getState>;
|
|
441
|
+
queryOnce: typeof queryOnce;
|
|
442
|
+
exportGraphSnapshot: typeof exportGraphSnapshot;
|
|
443
|
+
}
|
|
444
|
+
declare function exportGraphSnapshot(opts: GraphSnapshotExportOptions): string;
|
|
445
|
+
declare function createGraphTool<TInput, TResult>(handler: (input: TInput, ctx: GraphToolContext) => Promise<TResult> | TResult): (input: TInput) => TResult | Promise<TResult>;
|
|
446
|
+
|
|
286
447
|
/**
|
|
287
448
|
* Process-wide defaults for stale times, retries, and background revalidation.
|
|
288
449
|
* Keeps hook signatures small: `useEntity` / `useEntityList` merge these with per-query overrides.
|
|
@@ -2605,4 +2766,4 @@ declare const TableHead: React$1.ForwardRefExoticComponent<React$1.ThHTMLAttribu
|
|
|
2605
2766
|
declare const TableCell: React$1.ForwardRefExoticComponent<React$1.TdHTMLAttributes<HTMLTableCellElement> & React$1.RefAttributes<HTMLTableCellElement>>;
|
|
2606
2767
|
declare const TableCaption: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLTableCaptionElement> & React$1.RefAttributes<HTMLTableCaptionElement>>;
|
|
2607
2768
|
|
|
2608
|
-
export { type AccessorFn, ActionButtonRow, type ActionDef, ActionDropdown, type ActionItem, type ActivePresets, type AdapterStatus, type AggregationFn, type BatchActionDef, type BelongsToRelation, type CRUDMode, type CRUDOptions, type CRUDState, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnFilterType, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnPreset, ColumnPresetDialog, type ColumnPresetEntry, type ColumnSizingState, type ColumnVisibilityState, type CompletenessMode, DataTable, DataTableColumnHeader, DataTableFilter, DataTablePagination, DataTableToolbar, type DirtyFields, type ElectricAdapterOptions, ElectricSQLAdapter as ElectricSQLPresetAdapter, type ElectricSQLAdapterOptions as ElectricSQLPresetAdapterOptions, type ElectricTableConfig, EmptyState, type EmptyStateConfig, type EngineOptions, type EntityChange, type EntityColumnMeta, type EntityDescriptor, EntityDetailSheet, EntityFormSheet, type EntityId, EntityListView, type EntityListViewProps, type EntityQueryOptions, type EntitySchema, type EntityState, EntityTable, type EntityType, type ExpandedState, type FieldDescriptor, type FieldType, type FilterClause, type FilterFn, type FilterGroup, type FilterOperator, type FilterPreset, FilterPresetDialog, type FilterSpec, GQLClient, type GQLClientConfig, type GQLEntityOptions, type GQLError, type GQLListOptions, type GQLResponse, type GalleryColumns, GalleryView, type GraphState, type GroupingState, type HasManyRelation, type Header, type HeaderContext, type HeaderGroup, type HeaderRenderer, InlineCellEditor$1 as InlineCellEditor, InlineItemEditor, type ItemDescriptor, type ItemDescriptorBadge, type ItemDescriptorMeta, type ItemRenderContext, type ListFetchParams, type ListQueryOptions, type ListResponse, type ListState, ListView, type ManagerOptions, type ManyToManyRelation, MemoryAdapter, MultiSelectBar, type PaginationState, type PresetChangeEvent, type PresetChangeOperation, PresetPicker, type PresetStoreState, type UnsubscribeFn as PresetUnsubscribeFn, type PrismaEntityConfigOptions, type ColumnDef as PureColumnDef, type ColumnMeta as PureColumnMeta, InlineCellEditor as PureInlineCellEditor, type RealtimeAdapter, RealtimeManager, type RelationDescriptor, type RestAdapterOptions, RestApiAdapter, type Row, type RowModel, type RowSelectionState, SelectionContext, type SelectionStoreState, Sheet, type SortClause, type SortDirection, SortHeader, type SortSpec, type SortingFn, type SortingState, type SubscriptionConfig, type SupabaseAdapterOptions$1 as SupabaseAdapterOptions, SupabaseRealtimeAdapter as SupabasePresetAdapter, type SupabaseAdapterOptions as SupabasePresetAdapterOptions, type SyncAdapter, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableInstance, type TableOptions, type TablePresetSlice, TableRow, type TableState, type TableStorageAdapter, TableStorageProvider, type TableStorageProviderProps, type UnsubscribeFn$1 as UnsubscribeFn, type Updater, type UseEntityViewOptions, type UseEntityViewResult, type UseLocalFirstResult, type UseTablePresetsOptions, type UseTablePresetsResult, type ViewDescriptor, type ViewFetchParams, type ViewMode, ViewModeSwitcher, type WebSocketAdapterOptions, type ZustandAdapterOptions, ZustandPersistAdapter, actionsColumn$1 as actionsColumn, applyView, booleanColumn$1 as booleanColumn, cascadeInvalidation, checkCompleteness, compareEntities, configureEngine, createConvexAdapter, createElectricAdapter, createGQLClient, createGraphQLSubscriptionAdapter, createPresetStore, createPrismaEntityConfig, createRow, createSelectionStore, createSupabaseRealtimeAdapter, createWebSocketAdapter, dateColumn$1 as dateColumn, dedupe, deleteAction, editAction, enumColumn$1 as enumColumn, executeGQL, fetchEntity, fetchList, flattenClauses, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginatedRowModel, getRealtimeManager, getSchema, getSelectedRowModel, getSortedRowModel, hasCustomPredicates, matchesFilter, matchesSearch, normalizeGQLResponse, numberColumn$1 as numberColumn, prismaRelationsToSchema, actionsColumn as pureActionsColumn, booleanColumn as pureBooleanColumn, dateColumn as pureDateColumn, enumColumn as pureEnumColumn, numberColumn as pureNumberColumn, selectionColumn as pureSelectionColumn, textColumn as pureTextColumn, readRelations, registerSchema, resetRealtimeManager, selectionColumn$1 as selectionColumn, serializeKey, startGarbageCollector, stopGarbageCollector, textColumn$1 as textColumn, toGraphQLVariables, toPrismaInclude, toPrismaOrderBy, toPrismaWhere, toRestParams, toSQLClauses, useEntity, useEntityAugment, useEntityCRUD, useEntityList, useEntityMutation, useEntityView, useGQLEntity, useGQLList, useGQLMutation, useGQLSubscription, useGraphDevTools, useGraphStore, useLocalFirst, usePGliteQuery, useSelectionContext, useSelectionStore, useSuspenseEntity, useSuspenseEntityList, useTable, useTablePresets, useTableRealtimeMode, useTableStorageAdapter, viewAction };
|
|
2769
|
+
export { type AccessorFn, ActionButtonRow, type ActionDef, ActionDropdown, type ActionItem, type ActivePresets, type AdapterStatus, type AggregationFn, type BatchActionDef, type BelongsToRelation, type CRUDMode, type CRUDOptions, type CRUDState, type CascadeContext, type Cell, type CellContext, type CellRenderer, type ChangeOperation, type ChangeSet, type ChannelConfig, type Column, type ColumnFilterType, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnPreset, ColumnPresetDialog, type ColumnPresetEntry, type ColumnSizingState, type ColumnVisibilityState, type CompletenessMode, DataTable, DataTableColumnHeader, DataTableFilter, DataTablePagination, DataTableToolbar, type DirtyFields, type ElectricAdapterOptions, ElectricSQLAdapter as ElectricSQLPresetAdapter, type ElectricSQLAdapterOptions as ElectricSQLPresetAdapterOptions, type ElectricTableConfig, EmptyState, type EmptyStateConfig, type EngineOptions, type EntityChange, type EntityColumnMeta, type EntityDescriptor, EntityDetailSheet, EntityFormSheet, type EntityId, EntityListView, type EntityListViewProps, type EntityQueryOptions, type EntitySchema, type EntitySnapshot, type EntityState, type EntitySyncMetadata, EntityTable, type EntityType, type ExpandedState, type FieldDescriptor, type FieldType, type FilterClause, type FilterFn, type FilterGroup, type FilterOperator, type FilterPreset, FilterPresetDialog, type FilterSpec, GQLClient, type GQLClientConfig, type GQLEntityOptions, type GQLError, type GQLListOptions, type GQLResponse, type GalleryColumns, GalleryView, type GraphActionOptions, type GraphEffectEvent, type GraphEffectHandle, type GraphEffectOptions, type GraphIncludeMap, type GraphIncludeRelation, type GraphQueryOptions, type GraphSnapshotExportOptions, type GraphState, type GraphToolContext, type GraphTransaction, type GroupingState, type HasManyRelation, type Header, type HeaderContext, type HeaderGroup, type HeaderRenderer, InlineCellEditor$1 as InlineCellEditor, InlineItemEditor, type ItemDescriptor, type ItemDescriptorBadge, type ItemDescriptorMeta, type ItemRenderContext, type ListFetchParams, type ListQueryOptions, type ListResponse, type ListState, ListView, type ManagerOptions, type ManyToManyRelation, MemoryAdapter, MultiSelectBar, type PaginationState, type PresetChangeEvent, type PresetChangeOperation, PresetPicker, type PresetStoreState, type UnsubscribeFn as PresetUnsubscribeFn, type PrismaEntityConfigOptions, type ColumnDef as PureColumnDef, type ColumnMeta as PureColumnMeta, InlineCellEditor as PureInlineCellEditor, type QueryKey, type RealtimeAdapter, RealtimeManager, type RelationDescriptor, type RestAdapterOptions, RestApiAdapter, type Row, type RowModel, type RowSelectionState, SelectionContext, type SelectionStoreState, Sheet, type SortClause, type SortDirection, SortHeader, type SortSpec, type SortingFn, type SortingState, type SubscriptionConfig, type SupabaseAdapterOptions$1 as SupabaseAdapterOptions, SupabaseRealtimeAdapter as SupabasePresetAdapter, type SupabaseAdapterOptions as SupabasePresetAdapterOptions, type SyncAdapter, type SyncOrigin, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableInstance, type TableOptions, type TablePresetSlice, TableRow, type TableState, type TableStorageAdapter, TableStorageProvider, type TableStorageProviderProps, type UnsubscribeFn$1 as UnsubscribeFn, type Updater, type UseEntityViewOptions, type UseEntityViewResult, type UseLocalFirstResult, type UseTablePresetsOptions, type UseTablePresetsResult, type ViewDescriptor, type ViewFetchParams, type ViewMode, ViewModeSwitcher, type WebSocketAdapterOptions, type ZustandAdapterOptions, ZustandPersistAdapter, actionsColumn$1 as actionsColumn, applyView, booleanColumn$1 as booleanColumn, cascadeInvalidation, checkCompleteness, compareEntities, configureEngine, createConvexAdapter, createElectricAdapter, createGQLClient, createGraphAction, createGraphEffect, createGraphQLSubscriptionAdapter, createGraphTool, createGraphTransaction, createPresetStore, createPrismaEntityConfig, createRow, createSelectionStore, createSupabaseRealtimeAdapter, createWebSocketAdapter, dateColumn$1 as dateColumn, dedupe, deleteAction, editAction, enumColumn$1 as enumColumn, executeGQL, exportGraphSnapshot, fetchEntity, fetchList, flattenClauses, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginatedRowModel, getRealtimeManager, getSchema, getSelectedRowModel, getSortedRowModel, hasCustomPredicates, matchesFilter, matchesSearch, normalizeGQLResponse, numberColumn$1 as numberColumn, prismaRelationsToSchema, actionsColumn as pureActionsColumn, booleanColumn as pureBooleanColumn, dateColumn as pureDateColumn, enumColumn as pureEnumColumn, numberColumn as pureNumberColumn, selectionColumn as pureSelectionColumn, textColumn as pureTextColumn, queryOnce, readRelations, registerSchema, resetRealtimeManager, selectGraph, selectionColumn$1 as selectionColumn, serializeKey, startGarbageCollector, stopGarbageCollector, textColumn$1 as textColumn, toGraphQLVariables, toPrismaInclude, toPrismaOrderBy, toPrismaWhere, toRestParams, toSQLClauses, useEntity, useEntityAugment, useEntityCRUD, useEntityList, useEntityMutation, useEntityView, useGQLEntity, useGQLList, useGQLMutation, useGQLSubscription, useGraphDevTools, useGraphStore, useLocalFirst, usePGliteQuery, useSelectionContext, useSelectionStore, useSuspenseEntity, useSuspenseEntityList, useTable, useTablePresets, useTableRealtimeMode, useTableStorageAdapter, viewAction };
|