@prometheus-ags/entity-graph-core 3.0.0-alpha.0 → 3.0.0-rc.1
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 +39 -0
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/{index.js → index.cjs} +376 -291
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +458 -127
- package/dist/index.d.ts +458 -127
- package/dist/index.mjs +371 -289
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -9
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @prometheus-ags/entity-graph-core
|
|
2
|
+
|
|
3
|
+
## 3.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Preserve coalesced realtime update operations while merging repeated patches, so a burst does not degrade into a data-less upsert that the graph discards.
|
|
8
|
+
- Accept a public `LoroModuleLoader` callback in `createLoroMergeStrategy` so browser bundlers can include the optional `loro-crdt` peer without making it a core dependency.
|
|
9
|
+
|
|
10
|
+
## 3.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- v3.0.0 — Universal Platform Evolution
|
|
15
|
+
|
|
16
|
+
Evolves the React-only entity graph into a cross-platform, multi-framework,
|
|
17
|
+
AI-native, local-first ecosystem.
|
|
18
|
+
- **Monorepo split (breaking, but consumer-safe):** the framework-agnostic core
|
|
19
|
+
is extracted into `@prometheus-ags/entity-graph-core` (zero React). The
|
|
20
|
+
published `@prometheus-ags/prometheus-entity-management` package is the React
|
|
21
|
+
binding over the vanilla core. Existing React hook names remain available,
|
|
22
|
+
while core-only imperative consumers migrate from `useGraphStore.getState()`
|
|
23
|
+
to `graphStore.getState()`; the deprecated core alias remains through the
|
|
24
|
+
next-major removal window.
|
|
25
|
+
- **New framework bindings:** `entity-graph-svelte` (Svelte 5 runes),
|
|
26
|
+
`entity-graph-solid`, `entity-graph-web-components` (Lit 3), `entity-graph-alpine`,
|
|
27
|
+
`entity-graph-htmx` (Node SSE fragment server).
|
|
28
|
+
- **Peer sync:** `entity-graph-sync` with a pluggable SyncProvider — Yjs (default)
|
|
29
|
+
and Loro (reusing the 2.2.0 merge seam).
|
|
30
|
+
- **AI-native:** `entity-graph-a2a` plus `a2ui-react` with official A2UI
|
|
31
|
+
v0.9.1 rendering and default-deny graph actions; legacy
|
|
32
|
+
EntityChat/Copilot/Stream/Diff/Approval APIs live under `./ag-ui`.
|
|
33
|
+
- **Codegen contract:** `entity-graph-sdl` (schema → validated IR).
|
|
34
|
+
- **Native (published outside npm):** `entity-graph-cli` + `entity-graph-mcp`
|
|
35
|
+
(Rust, via crates.io), `entity-graph-tauri` (Tauri v2 plugin), and
|
|
36
|
+
`entity_graph_flutter` (Riverpod 3, via pub.dev).
|
|
37
|
+
|
|
38
|
+
All integrations ship as optional peer dependencies; the core bundle stays
|
|
39
|
+
`zustand + immer`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Travis James / Prometheus AGS / KnowMe LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# `@prometheus-ags/entity-graph-core`
|
|
2
|
+
|
|
3
|
+
Framework-neutral normalized entity graph for the Prometheus entity-management ecosystem. The package contains no React code. React, Svelte, Solid, Alpine, Lit, Tauri, and other bindings share this graph so an entity is stored once and every subscribed view observes the same value.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @prometheus-ags/entity-graph-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The core runtime depends on Zustand and Immer. Optional integrations such as AG-UI, Loro, and Tauri SQL are loaded only when their adapters are used.
|
|
12
|
+
|
|
13
|
+
## The data model
|
|
14
|
+
|
|
15
|
+
The graph keeps three distinct structures:
|
|
16
|
+
|
|
17
|
+
- `entities[type][id]` is canonical server-confirmed data.
|
|
18
|
+
- `patches[type][id]` contains local UI-only augmentation merged at read time.
|
|
19
|
+
- `lists[queryKey].ids` contains ordered identifiers, never copied entity records.
|
|
20
|
+
|
|
21
|
+
This ID-only list rule is what makes cross-view updates reliable: changing one canonical entity updates every list, detail view, and relation that reads that identifier.
|
|
22
|
+
|
|
23
|
+
## Register a transport
|
|
24
|
+
|
|
25
|
+
Register I/O once at application boot. Framework hooks call store and engine methods; transports and adapters own external communication.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import {
|
|
29
|
+
registerEntityTransport,
|
|
30
|
+
} from "@prometheus-ags/entity-graph-core";
|
|
31
|
+
|
|
32
|
+
registerEntityTransport("users", {
|
|
33
|
+
identify: (user) => user.id,
|
|
34
|
+
authoritative: false,
|
|
35
|
+
async list(query) {
|
|
36
|
+
const response = await fetch(`/api/users?limit=${query.limit ?? 50}`, {
|
|
37
|
+
signal: query.signal,
|
|
38
|
+
});
|
|
39
|
+
const rows = await response.json();
|
|
40
|
+
return { rows, total: rows.length, nextCursor: null };
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Custom transports implement `EntityTransport<T>` with `identify`, `authoritative`, and `list`; `get` and `subscribe` are optional.
|
|
46
|
+
|
|
47
|
+
## Create, read, and update graphs outside a UI framework
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import {
|
|
51
|
+
createGraphStore,
|
|
52
|
+
graphStore,
|
|
53
|
+
} from "@prometheus-ags/entity-graph-core";
|
|
54
|
+
|
|
55
|
+
const graph = graphStore.getState();
|
|
56
|
+
|
|
57
|
+
graph.upsertEntity("users", "user-1", {
|
|
58
|
+
id: "user-1",
|
|
59
|
+
name: "Ada Lovelace",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
graph.setListResult("users:active", ["user-1"], {
|
|
63
|
+
total: 1,
|
|
64
|
+
hasNextPage: false,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const user = graphStore.getState().readEntity("users", "user-1");
|
|
68
|
+
|
|
69
|
+
// Isolated stores are useful for SSR requests, tests, and workers.
|
|
70
|
+
const requestGraph = createGraphStore();
|
|
71
|
+
requestGraph.getState().upsertEntity("users", "request-user", {
|
|
72
|
+
id: "request-user",
|
|
73
|
+
name: "Grace Hopper",
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
UI components should consume the hooks provided by their framework binding instead of reading the store directly.
|
|
78
|
+
|
|
79
|
+
The deprecated core `useGraphStore` name is a StoreApi-shaped alias for `graphStore`, not a React hook. React consumers import the callable `useGraphStore(selector)` hook from `@prometheus-ags/prometheus-entity-management`. See the repository's `release/framework-neutral-core.md` migration contract for the complete boundary.
|
|
80
|
+
|
|
81
|
+
## Optional Loro merge strategy
|
|
82
|
+
|
|
83
|
+
`loro-crdt` remains an optional peer. Node consumers can let core load it at
|
|
84
|
+
runtime; browser bundlers should provide a statically visible loader:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import {
|
|
88
|
+
createLoroMergeStrategy,
|
|
89
|
+
registerMergeStrategy,
|
|
90
|
+
} from "@prometheus-ags/entity-graph-core";
|
|
91
|
+
|
|
92
|
+
const strategy = await createLoroMergeStrategy(
|
|
93
|
+
() => import("loro-crdt"),
|
|
94
|
+
);
|
|
95
|
+
registerMergeStrategy("Document", strategy);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The public `LoroModuleLoader` type describes this callback. Supplying it does
|
|
99
|
+
not make Loro part of the mandatory core bundle.
|
|
100
|
+
|
|
101
|
+
## Major capabilities
|
|
102
|
+
|
|
103
|
+
- request deduplication, stale-while-revalidate, subscriber tracking, and garbage collection
|
|
104
|
+
- transport-neutral filtering, sorting, search, pagination, and incremental views
|
|
105
|
+
- realtime adapters with coalesced graph writes
|
|
106
|
+
- graph actions, transactions, effects, snapshots, and time travel
|
|
107
|
+
- local-first persistence and retryable action replay
|
|
108
|
+
- schema and relation registries with cascade invalidation
|
|
109
|
+
- AG-UI snapshot/delta ingestion and JSON Patch
|
|
110
|
+
- REST, WebSocket, Supabase, GraphQL, ElectricSQL, PGlite, Tauri SQL, SurrealDB, and Flint adapter seams
|
|
111
|
+
- framework-neutral table row models and faceting
|
|
112
|
+
|
|
113
|
+
## Module support
|
|
114
|
+
|
|
115
|
+
The package publishes loader-specific artifacts and declarations:
|
|
116
|
+
|
|
117
|
+
- Node ESM and modern bundlers use `dist/index.mjs` with `dist/index.d.ts`.
|
|
118
|
+
- Node CommonJS uses `dist/index.cjs` with `dist/index.d.cts`.
|
|
119
|
+
|
|
120
|
+
Both paths are selected through conditional package exports.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|