@modernrelay/orbit-omnigraph 0.13.6 → 0.15.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/README.md +37 -39
- package/dist/{chunk-NT5KJVIT.js → chunk-WMBDYPK2.js} +66 -74
- package/dist/chunk-WMBDYPK2.js.map +1 -0
- package/dist/codegen-cli.js +21 -14
- package/dist/codegen-cli.js.map +1 -1
- package/dist/index.d.ts +113 -113
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +9 -9
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-NT5KJVIT.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# @modernrelay/orbit-omnigraph
|
|
2
2
|
|
|
3
|
-
Optional Omnigraph data-source adapter for Orbit
|
|
3
|
+
Optional Omnigraph data-source adapter for Orbit. Framework-agnostic:
|
|
4
4
|
depends only on the framework-free ingestion/error surface of `@modernrelay/orbit-core`
|
|
5
|
-
and the official TypeScript SDK `@modernrelay/omnigraph` (0.
|
|
5
|
+
and the official TypeScript SDK `@modernrelay/omnigraph` (0.9.x) — never on React, and
|
|
6
6
|
core never depends on it.
|
|
7
7
|
|
|
8
|
-
## The v1 rule
|
|
8
|
+
## The v1 rule
|
|
9
9
|
|
|
10
|
-
> **v1 loads graphs via `og.export()`; queries only ever resolve ids**
|
|
11
|
-
> selection
|
|
10
|
+
> **v1 loads graphs via `og.export()`; queries only ever resolve ids** for search and
|
|
11
|
+
> overlay selection. The query path never introduces nodes or
|
|
12
12
|
> edges into the graph.
|
|
13
13
|
|
|
14
14
|
Export is the only complete-graph read: it streams NDJSON with full identity — physical
|
|
15
15
|
edge ids included — so every v1 edge carries an export id and no synthesized-id scheme ever
|
|
16
|
-
mixes in
|
|
17
|
-
|
|
16
|
+
mixes in. Server-backed expansion, query-path loading, and authenticated blob fetches
|
|
17
|
+
remain outside the adapter's v1 scope.
|
|
18
18
|
|
|
19
19
|
## Quick start
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
// server.ts — the ONLY place authenticated construction lives
|
|
22
|
+
// server.ts — the ONLY place authenticated construction lives
|
|
23
23
|
import { createOmnigraphServerClient } from '@modernrelay/orbit-omnigraph/server';
|
|
24
24
|
|
|
25
25
|
const client = createOmnigraphServerClient({
|
|
@@ -34,12 +34,12 @@ import { createOmnigraphSource } from '@modernrelay/orbit-omnigraph';
|
|
|
34
34
|
import { createGraphInstance } from '@modernrelay/orbit-core';
|
|
35
35
|
|
|
36
36
|
const source = createOmnigraphSource({
|
|
37
|
-
client,
|
|
37
|
+
client, // preconfigured SDK client — no token option here
|
|
38
38
|
graphId: 'demo',
|
|
39
|
-
branch: 'main',
|
|
40
|
-
// typeNames: ['Signal', 'Correlates'],
|
|
41
|
-
// driftPolicy: 'reject',
|
|
42
|
-
// maxPendingBytes:
|
|
39
|
+
branch: 'main', // default
|
|
40
|
+
// typeNames: ['Signal', 'Correlates'], // partial per-type load (wire: type_names)
|
|
41
|
+
// driftPolicy: 'reject', // default; see below
|
|
42
|
+
// maxPendingBytes: 512 * 1024 * 1024, // default whole-load atomic budget
|
|
43
43
|
onProgress: ({ lines, nodes, edges, bytes }) => console.log(lines, nodes, edges, bytes),
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -50,10 +50,9 @@ const result = await source.load(instance /*, abortSignal */);
|
|
|
50
50
|
|
|
51
51
|
`load()` drives one streamed export pass into a `purpose:'replace'` ingest session
|
|
52
52
|
(`datasetKey` = `og:<graphId>:<branch>`): edge lines arrive first (lexicographic table-key
|
|
53
|
-
order) and pass straight through — core's pending-endpoint index links them as nodes land
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
graph. Ids are namespaced through the B.3 codec, and B.6 wire encodings are normalized to
|
|
53
|
+
order) and pass straight through — core's pending-endpoint index links them as nodes land. Every append is awaited, and the atomic load has a finite whole-export byte budget
|
|
54
|
+
(`maxPendingBytes`, 512 MiB by default); exceeding it aborts without publishing a partial
|
|
55
|
+
graph. Ids are namespaced through the codec, and wire encodings are normalized to
|
|
57
56
|
the query-path string forms. Byte progress and budgets use re-serialized UTF-8 NDJSON size,
|
|
58
57
|
including one line break per export row.
|
|
59
58
|
|
|
@@ -61,7 +60,7 @@ The `target` is structural (`IngestTarget`: `beginIngest` + `getRevisions` +
|
|
|
61
60
|
optional `getDiagnostics`) — deliberately decoupled from `GraphInstance`, which satisfies
|
|
62
61
|
it structurally; so does any recorder or headless pipeline.
|
|
63
62
|
|
|
64
|
-
## `sourceRevision` and drift
|
|
63
|
+
## `sourceRevision` and drift
|
|
65
64
|
|
|
66
65
|
The canonical `sourceRevision` is a hash of
|
|
67
66
|
`{ graphId, branch, headBefore, headAfter, schemaFingerprint }` — but `/export` is
|
|
@@ -81,17 +80,17 @@ until that second head is known, then opens one session under the canonical fina
|
|
|
81
80
|
**both** heads and a warning is added to the result.
|
|
82
81
|
- `'retry-once'` — abort and restart the whole load once; a second drift rejects.
|
|
83
82
|
|
|
84
|
-
This is sound because a replace session is atomic and invisible until commit
|
|
83
|
+
This is sound because a replace session is atomic and invisible until commit:
|
|
85
84
|
nothing publishes under a revision the policy did not explicitly accept, and the decision
|
|
86
85
|
is never hidden — every accepted drift or retry appears in `result.warnings`.
|
|
87
86
|
|
|
88
87
|
A second identical load of a quiescent branch produces the same
|
|
89
|
-
`{datasetKey, sourceRevision}` and replays idempotently — core publishes nothing
|
|
88
|
+
`{datasetKey, sourceRevision}` and replays idempotently — core publishes nothing.
|
|
90
89
|
|
|
91
|
-
## Search: stored-query `SearchService`
|
|
90
|
+
## Search: stored-query `SearchService`
|
|
92
91
|
|
|
93
92
|
`createOmnigraphSearchService` wires a stored server-side search query (BM25 / fuzzy /
|
|
94
|
-
vector / RRF with `order { score desc } limit K`) as a
|
|
93
|
+
vector / RRF with `order { score desc } limit K`) as a core `SearchService` — plug it into
|
|
95
94
|
core as `services.search` and the instance owns `RequestContext` creation, revision-keyed
|
|
96
95
|
caching, supersede cancellation, and stale-result admission. The service declares
|
|
97
96
|
`revisionDependencies: ['source']` and passes `ctx.signal` through SDK `CallOptions`, so a
|
|
@@ -101,13 +100,13 @@ superseded keystroke cancels the in-flight HTTP call.
|
|
|
101
100
|
import { createOmnigraphSearchService } from '@modernrelay/orbit-omnigraph';
|
|
102
101
|
|
|
103
102
|
const search = createOmnigraphSearchService({
|
|
104
|
-
client,
|
|
103
|
+
client, // preconfigured SDK client — same rule as the loader
|
|
105
104
|
graphId: 'demo',
|
|
106
|
-
branch: 'main',
|
|
107
|
-
queryName: 'search-intel',
|
|
108
|
-
// params: (q, limit) => ({ q, limit }),
|
|
109
|
-
typeOf: { $s: 'Signal' },
|
|
110
|
-
// labelColumn: '$s.title',
|
|
105
|
+
branch: 'main', // default
|
|
106
|
+
queryName: 'search-intel', // registry name; invoked as POST /queries/search-intel
|
|
107
|
+
// params: (q, limit) => ({ q, limit }), // default — reshape for your query's params
|
|
108
|
+
typeOf: { $s: 'Signal' }, // REQUIRED: column → node type for the id encoding
|
|
109
|
+
// labelColumn: '$s.title', // default: the first string-valued column per row
|
|
111
110
|
});
|
|
112
111
|
|
|
113
112
|
const instance = createGraphInstance({ engine, services: { search } });
|
|
@@ -128,14 +127,14 @@ Row mapping (override wholesale with `mapRow: (row) => SearchResult | null`, `nu
|
|
|
128
127
|
row key order.
|
|
129
128
|
|
|
130
129
|
Trivial calls (empty query, non-positive limit) resolve `[]` without a network call, and
|
|
131
|
-
results are defensively capped at the requested limit.
|
|
130
|
+
results are defensively capped at the requested limit. SDK typed errors
|
|
132
131
|
rethrow as plain `omnigraph:`-prefixed `Error`s; aborts surface as `AbortError`.
|
|
133
132
|
|
|
134
|
-
> **v1 caveat
|
|
133
|
+
> **v1 caveat:** the stored query searches the WHOLE branch server-side, so against a
|
|
135
134
|
> *partial* export load (`typeNames`) it can return ids outside the loaded set.
|
|
136
|
-
> `activateSearchResult` classifies those as `'not-loaded'`
|
|
135
|
+
> `activateSearchResult` classifies those as `'not-loaded'` — the host may remedy
|
|
137
136
|
> that only by re-running export for the relevant types (query-path single-node fetch is
|
|
138
|
-
>
|
|
137
|
+
> not implemented in v1). Constrain the stored query to the loaded types, or load the
|
|
139
138
|
> full graph, to avoid the mismatch. Discovery via `og.queries.list()` returns only the
|
|
140
139
|
> `mcp.expose == true` registry subset — invoking a known `queryName` works regardless.
|
|
141
140
|
|
|
@@ -143,25 +142,24 @@ rethrow as plain `omnigraph:`-prefixed `Error`s; aborts surface as `AbortError`.
|
|
|
143
142
|
|
|
144
143
|
`@modernrelay/orbit-omnigraph/server` (`createOmnigraphServerClient`) is the only
|
|
145
144
|
authenticated SDK construction and must stay server-side: `omnigraph-server` ships no CORS
|
|
146
|
-
configuration and uses static bearer tokens (secret material)
|
|
145
|
+
configuration and uses static bearer tokens (secret material). Browser deployments
|
|
147
146
|
pass a preconfigured safe same-origin/public client to `createOmnigraphSource` — the
|
|
148
147
|
browser entry deliberately has no `baseUrl`/`token` option — and typically route reads
|
|
149
148
|
through a proxy/BFF. A client-bundle exclusion gate (`scripts/pack-smoke.mjs`,
|
|
150
149
|
`treeshake:omnigraph-client`) asserts the server entry never reaches a client bundle.
|
|
151
150
|
|
|
152
|
-
## Error surface
|
|
151
|
+
## Error surface
|
|
153
152
|
|
|
154
153
|
SDK typed errors (`NetworkError`, `ConflictError`, …) never cross this package's public
|
|
155
154
|
surface — failures rethrow as plain `Error`s with a stable `omnigraph:` message prefix.
|
|
156
155
|
Cancellation (`AbortSignal`) surfaces as an `AbortError`; the session is aborted and the
|
|
157
156
|
graph left untouched. SDK/server `major.minor` version mismatches (`og.health()` vs the
|
|
158
|
-
SDK's pinned `SERVER_VERSION`) surface as a result warning, never a hard failure
|
|
157
|
+
SDK's pinned `SERVER_VERSION`) surface as a result warning, never a hard failure.
|
|
159
158
|
|
|
160
159
|
## Also in the box
|
|
161
160
|
|
|
162
|
-
- `encodeSourceId`/`decodeSourceId`/`encodeSyntheticEdgeId` — the
|
|
161
|
+
- `encodeSourceId`/`decodeSourceId`/`encodeSyntheticEdgeId` — the identity codec
|
|
163
162
|
every adapter path must use.
|
|
164
163
|
- `parsePgSchema`/`edgeEndpointTypes`/`schemaFingerprint`/`bigIntKeyWarnings` — the `.pg`
|
|
165
|
-
schema model
|
|
166
|
-
- `classifyExportLine`/`normalizeNode`/`normalizeEdge` — export-line normalization
|
|
167
|
-
(B.2/B.6).
|
|
164
|
+
schema model: endpoint-type resolution, wire-type knowledge, revision fingerprint.
|
|
165
|
+
- `classifyExportLine`/`normalizeNode`/`normalizeEdge` — export-line normalization.
|
|
@@ -91,42 +91,14 @@ function findBlockEnd(src, openIdx) {
|
|
|
91
91
|
}
|
|
92
92
|
return n;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (ch === '"') {
|
|
103
|
-
current += ch;
|
|
104
|
-
i++;
|
|
105
|
-
while (i < n) {
|
|
106
|
-
const c = body.charAt(i);
|
|
107
|
-
current += c;
|
|
108
|
-
i++;
|
|
109
|
-
if (c === "\\" && i < n) {
|
|
110
|
-
current += body.charAt(i);
|
|
111
|
-
i++;
|
|
112
|
-
} else if (c === '"') break;
|
|
113
|
-
}
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (ch === "(" || ch === "[") depth++;
|
|
117
|
-
else if (ch === ")" || ch === "]") depth = Math.max(0, depth - 1);
|
|
118
|
-
if (ch === "\n" && depth === 0) {
|
|
119
|
-
out.push(current);
|
|
120
|
-
current = "";
|
|
121
|
-
} else {
|
|
122
|
-
current += ch;
|
|
123
|
-
}
|
|
124
|
-
i++;
|
|
125
|
-
}
|
|
126
|
-
out.push(current);
|
|
127
|
-
return out.map((s) => s.trim()).filter((s) => s.length > 0);
|
|
128
|
-
}
|
|
129
|
-
function scanAnnotations(src, start) {
|
|
94
|
+
var BODY_CONSTRAINT_NAMES = /* @__PURE__ */ new Set([
|
|
95
|
+
"key",
|
|
96
|
+
"unique",
|
|
97
|
+
"index",
|
|
98
|
+
"range",
|
|
99
|
+
"check"
|
|
100
|
+
]);
|
|
101
|
+
function scanAnnotations(src, start, stopBeforeBodyConstraint = false) {
|
|
130
102
|
const anns = [];
|
|
131
103
|
let i = start;
|
|
132
104
|
const n = src.length;
|
|
@@ -134,14 +106,16 @@ function scanAnnotations(src, start) {
|
|
|
134
106
|
let j = i;
|
|
135
107
|
while (j < n && /\s/.test(src.charAt(j))) j++;
|
|
136
108
|
if (src.charAt(j) !== "@") break;
|
|
137
|
-
const m =
|
|
109
|
+
const m = /^@\s*([A-Za-z_]\w*)/.exec(src.slice(j));
|
|
138
110
|
if (!m || m[1] === void 0) break;
|
|
139
111
|
const name = m[1];
|
|
140
112
|
let end = j + m[0].length;
|
|
141
113
|
let args;
|
|
142
|
-
|
|
114
|
+
let open = end;
|
|
115
|
+
while (open < n && /\s/.test(src.charAt(open))) open++;
|
|
116
|
+
if (src.charAt(open) === "(") {
|
|
143
117
|
let depth = 0;
|
|
144
|
-
let k =
|
|
118
|
+
let k = open;
|
|
145
119
|
while (k < n) {
|
|
146
120
|
const ch = src.charAt(k);
|
|
147
121
|
if (ch === '"') {
|
|
@@ -164,9 +138,12 @@ function scanAnnotations(src, start) {
|
|
|
164
138
|
}
|
|
165
139
|
k++;
|
|
166
140
|
}
|
|
167
|
-
args = src.slice(
|
|
141
|
+
args = src.slice(open + 1, k - 1);
|
|
168
142
|
end = k;
|
|
169
143
|
}
|
|
144
|
+
if (stopBeforeBodyConstraint && args !== void 0 && BODY_CONSTRAINT_NAMES.has(name)) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
170
147
|
const entry = { name, raw: src.slice(j, end) };
|
|
171
148
|
if (args !== void 0) entry.args = args;
|
|
172
149
|
anns.push(entry);
|
|
@@ -218,20 +195,30 @@ function parseTypeRef(text) {
|
|
|
218
195
|
i += m[0].length;
|
|
219
196
|
} else {
|
|
220
197
|
const close = text.indexOf("]", i);
|
|
221
|
-
const
|
|
198
|
+
const nextLine = text.indexOf("\n", i);
|
|
199
|
+
let end = close === -1 ? n : close + 1;
|
|
200
|
+
if (nextLine !== -1 && nextLine < end) end = nextLine;
|
|
222
201
|
type = { kind: "unknown", raw: text.slice(i, end).trim() };
|
|
223
202
|
i = end;
|
|
224
203
|
}
|
|
225
204
|
} else {
|
|
226
205
|
const m = /^([A-Za-z_]\w*)/.exec(text.slice(i));
|
|
227
206
|
if (!m || m[1] === void 0) {
|
|
228
|
-
|
|
207
|
+
const nextLine = text.indexOf("\n", i);
|
|
208
|
+
const end = nextLine === -1 ? n : nextLine;
|
|
209
|
+
return {
|
|
210
|
+
type: { kind: "unknown", raw: text.slice(i, end).trim() },
|
|
211
|
+
optional: false,
|
|
212
|
+
end
|
|
213
|
+
};
|
|
229
214
|
}
|
|
230
215
|
const ident = m[1];
|
|
231
216
|
i += m[0].length;
|
|
232
|
-
|
|
217
|
+
let open = i;
|
|
218
|
+
while (open < n && /\s/.test(text.charAt(open))) open++;
|
|
219
|
+
if ((ident === "enum" || ident === "Vector") && text.charAt(open) === "(") {
|
|
233
220
|
let depth = 0;
|
|
234
|
-
let k =
|
|
221
|
+
let k = open;
|
|
235
222
|
while (k < n) {
|
|
236
223
|
const ch = text.charAt(k);
|
|
237
224
|
if (ch === "(") depth++;
|
|
@@ -244,7 +231,7 @@ function parseTypeRef(text) {
|
|
|
244
231
|
}
|
|
245
232
|
k++;
|
|
246
233
|
}
|
|
247
|
-
const inner = text.slice(
|
|
234
|
+
const inner = text.slice(open + 1, k - 1);
|
|
248
235
|
i = k;
|
|
249
236
|
if (ident === "enum") {
|
|
250
237
|
const values = splitArgs(inner).map((v) => v.replace(/^"(.*)"$/s, "$1"));
|
|
@@ -260,6 +247,7 @@ function parseTypeRef(text) {
|
|
|
260
247
|
}
|
|
261
248
|
}
|
|
262
249
|
let optional = false;
|
|
250
|
+
while (i < n && /\s/.test(text.charAt(i))) i++;
|
|
263
251
|
if (text.charAt(i) === "?") {
|
|
264
252
|
optional = true;
|
|
265
253
|
i++;
|
|
@@ -269,35 +257,39 @@ function parseTypeRef(text) {
|
|
|
269
257
|
function parseBody(body) {
|
|
270
258
|
const properties = [];
|
|
271
259
|
const constraints = [];
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
260
|
+
let cursor = body.trimStart();
|
|
261
|
+
while (cursor !== "") {
|
|
262
|
+
if (cursor.startsWith("@")) {
|
|
263
|
+
const { anns: anns2, end: end2 } = scanAnnotations(cursor, 0);
|
|
264
|
+
if (anns2.length === 0 || end2 === 0) break;
|
|
265
|
+
for (const a of anns2) constraints.push(a.raw);
|
|
266
|
+
cursor = cursor.slice(end2).trimStart();
|
|
276
267
|
continue;
|
|
277
268
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const { type, optional, end } = parseTypeRef(rest);
|
|
285
|
-
const { anns, end: annsEnd } = scanAnnotations(rest, end);
|
|
286
|
-
properties.push({
|
|
287
|
-
name,
|
|
288
|
-
type,
|
|
289
|
-
optional,
|
|
290
|
-
key: anns.some((a) => a.name === "key"),
|
|
291
|
-
unique: anns.some((a) => a.name === "unique"),
|
|
292
|
-
index: anns.some((a) => a.name === "index"),
|
|
293
|
-
annotations: anns.map((a) => a.raw)
|
|
294
|
-
});
|
|
295
|
-
cursor = rest.slice(annsEnd).trimStart();
|
|
296
|
-
if (cursor === "") break;
|
|
269
|
+
const head = /^([A-Za-z_]\w*)\s*:\s*/.exec(cursor);
|
|
270
|
+
if (!head || head[1] === void 0) {
|
|
271
|
+
const nextLine = cursor.indexOf("\n");
|
|
272
|
+
if (nextLine === -1) break;
|
|
273
|
+
cursor = cursor.slice(nextLine + 1).trimStart();
|
|
274
|
+
continue;
|
|
297
275
|
}
|
|
276
|
+
const name = head[1];
|
|
277
|
+
const rest = cursor.slice(head[0].length);
|
|
278
|
+
const { type, optional, end } = parseTypeRef(rest);
|
|
279
|
+
const { anns, end: annsEnd } = scanAnnotations(rest, end, true);
|
|
280
|
+
properties.push({
|
|
281
|
+
name,
|
|
282
|
+
type,
|
|
283
|
+
optional,
|
|
284
|
+
key: anns.some((a) => a.name === "key"),
|
|
285
|
+
unique: anns.some((a) => a.name === "unique"),
|
|
286
|
+
index: anns.some((a) => a.name === "index"),
|
|
287
|
+
annotations: anns.map((a) => a.raw)
|
|
288
|
+
});
|
|
289
|
+
cursor = rest.slice(annsEnd).trimStart();
|
|
298
290
|
}
|
|
299
291
|
for (const raw of constraints) {
|
|
300
|
-
const m =
|
|
292
|
+
const m = /^@\s*(key|unique|index)\s*\((.*)\)$/s.exec(raw);
|
|
301
293
|
if (!m || m[1] === void 0 || m[2] === void 0) continue;
|
|
302
294
|
const flag = m[1];
|
|
303
295
|
for (const propName of splitArgs(m[2])) {
|
|
@@ -425,7 +417,7 @@ var UnknownEdgeTypeError = class extends Error {
|
|
|
425
417
|
edgeName;
|
|
426
418
|
constructor(edgeName) {
|
|
427
419
|
super(
|
|
428
|
-
`Unknown edge type '${edgeName}': not declared in the graph schema, so its endpoint node types cannot be resolved
|
|
420
|
+
`Unknown edge type '${edgeName}': not declared in the graph schema, so its endpoint node types cannot be resolved.`
|
|
429
421
|
);
|
|
430
422
|
this.edgeName = edgeName;
|
|
431
423
|
}
|
|
@@ -496,7 +488,7 @@ function requireStringId(data, what) {
|
|
|
496
488
|
const id = data["id"];
|
|
497
489
|
if (typeof id !== "string") {
|
|
498
490
|
throw new InvalidExportLineError(
|
|
499
|
-
`${what} export line has ${id === void 0 ? "no" : "a non-string"} 'data.id' \u2014 cannot build a stable orbit id
|
|
491
|
+
`${what} export line has ${id === void 0 ? "no" : "a non-string"} 'data.id' \u2014 cannot build a stable orbit id; data.id must be a string.`
|
|
500
492
|
);
|
|
501
493
|
}
|
|
502
494
|
return id;
|
|
@@ -509,7 +501,7 @@ function normalizeNode(line, schema) {
|
|
|
509
501
|
id,
|
|
510
502
|
// The discriminator is adapter-owned identity metadata. It lands LAST so
|
|
511
503
|
// a forward-compatible export field literally named `orbit:type` cannot
|
|
512
|
-
// forge the value the generated attrs unions promise
|
|
504
|
+
// forge the value the generated attrs unions promise.
|
|
513
505
|
attrs: { ...normalizeData(line.data, propTypeMap(nodeType)), [ORBIT_TYPE_KEY]: line.type }
|
|
514
506
|
};
|
|
515
507
|
}
|
|
@@ -530,5 +522,5 @@ function normalizeEdge(line, schema) {
|
|
|
530
522
|
}
|
|
531
523
|
|
|
532
524
|
export { InvalidExportLineError, ORBIT_TYPE_KEY, UnknownEdgeTypeError, bigIntKeyWarnings, classifyExportLine, decodeSourceId, edgeEndpointTypes, encodeSourceId, encodeSyntheticEdgeId, normalizeEdge, normalizeNode, parsePgSchema, schemaFingerprint };
|
|
533
|
-
//# sourceMappingURL=chunk-
|
|
534
|
-
//# sourceMappingURL=chunk-
|
|
525
|
+
//# sourceMappingURL=chunk-WMBDYPK2.js.map
|
|
526
|
+
//# sourceMappingURL=chunk-WMBDYPK2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/idCodec.ts","../src/pgSchema.ts","../src/normalize.ts"],"names":["anns","end","body","braceIdx","blockEnd"],"mappings":";AA6BO,SAAS,cAAA,CAAe,MAAc,QAAA,EAA0B;AACrE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,CAAC,IAAA,EAAM,QAAQ,CAAC,CAAA;AACxC;AASO,SAAS,eAAe,EAAA,EAAoC;AACjE,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAA,CAAK,MAAM,EAAE,CAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,MAAM,OAAA,CAAQ,MAAM,KAAK,MAAA,CAAO,MAAA,KAAW,GAAG,OAAO,IAAA;AAC1D,EAAA,MAAM,CAAC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AAA,GAAY,iBAAA,CAAkB,MAAA,EAAQ,IAAA,CAAK,IAAI,CAAA;AACrD,EAAA,IAAI,cAAc,IAAA,EAAM,MAAM,IAAI,oBAAA,CAAqB,KAAK,IAAI,CAAA;AAChE,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,WAAA,EAAY;AACpC,EAAA,MAAM,QAAA,GACJ,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,IAAA,CAAK,IAAI,KAC7C,MAAA,CAAO,KAAA,CAAM,KAAK,CAAC,CAAA,KAAM,EAAE,IAAA,CAAK,WAAA,OAAkB,KAAK,CAAA;AACzD,EAAA,MAAM,EAAA,GAAK,cAAA,CAAe,IAAA,CAAK,IAAA,EAAM,eAAA,CAAgB,IAAA,CAAK,IAAA,EAAM,CAAA,MAAA,EAAS,IAAA,CAAK,IAAI,CAAA,CAAA,CAAG,CAAC,CAAA;AACtF,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,MAAA,EAAQ,cAAA,CAAe,SAAA,CAAU,IAAA,EAAM,KAAK,IAAI,CAAA;AAAA,IAChD,MAAA,EAAQ,cAAA,CAAe,SAAA,CAAU,EAAA,EAAI,KAAK,EAAE,CAAA;AAAA;AAAA;AAAA,IAG5C,KAAA,EAAO,EAAE,GAAG,aAAA,CAAc,KAAK,IAAA,EAAM,WAAA,CAAY,QAAQ,CAAC,CAAA,EAAG,CAAC,cAAc,GAAG,KAAK,IAAA;AAAK,GAC3F;AACF","file":"chunk-WMBDYPK2.js","sourcesContent":["/**\n * Identity codec.\n *\n * Omnigraph node ids are unique **per type only** (derived from the `@key`\n * tuple within each type's table), so unqualified ids are unsound as orbit\n * `NodeId`s. Every adapter path — nodes, edges, search results, view state,\n * services — MUST qualify ids through this one collision-proof tuple codec.\n * `JSON.stringify` of a fixed-arity string tuple is injective over its inputs\n * (quotes, brackets, commas, and unicode in either component are escaped), so\n * no `(kind, sourceId)` pair can collide with a different pair.\n *\n * Human-readable labels stay separate from identity; there is deliberately no\n * `namespaceIds:false` escape hatch.\n */\n\nexport interface DecodedSourceId {\n /** The namespace component: a node type name or an edge type name. */\n kind: string;\n /** The physical Omnigraph id within that type's table. */\n sourceId: string;\n}\n\n/**\n * Encode a `(kind, sourceId)` pair as a collision-proof orbit id.\n *\n * - Nodes: `encodeSourceId(NodeType, data.id)`\n * - Edges: `encodeSourceId(EdgeName, data.id)`; endpoints use\n * `encodeSourceId(endpointType, from|to)`.\n */\nexport function encodeSourceId(kind: string, sourceId: string): string {\n return JSON.stringify([kind, sourceId]);\n}\n\n/**\n * Decode an id produced by {@link encodeSourceId}.\n *\n * Returns `null` for anything that does not conform exactly (non-JSON input,\n * non-array JSON, wrong arity — including synthetic edge ids, which are\n * 4-tuples — or non-string elements). Never throws.\n */\nexport function decodeSourceId(id: string): DecodedSourceId | null {\n let parsed: unknown;\n try {\n parsed = JSON.parse(id);\n } catch {\n return null;\n }\n if (!Array.isArray(parsed) || parsed.length !== 2) return null;\n const [kind, sourceId] = parsed as unknown[];\n if (typeof kind !== 'string' || typeof sourceId !== 'string') return null;\n return { kind, sourceId };\n}\n\n/**\n * Synthetic edge id for **query-derived** subgraphs.\n *\n * The GQ grammar has no edge variable, so the query path can never surface\n * physical edge ids; query-derived edges are identified by\n * `['synthetic-edge', EdgeName, source, target]` where `source`/`target` are\n * the already-encoded endpoint node ids.\n *\n * Exported for the future query path.\n * Caveats: parallel edges collapse under this scheme, and a dataset\n * MUST NOT mix synthetic ids with physical `/export` ids for the same edges\n * one scheme per dataset, never both. Because a synthetic id is a 4-tuple,\n * {@link decodeSourceId} rejects it (`null`), keeping the two schemes\n * mechanically un-confusable.\n */\nexport function encodeSyntheticEdgeId(edgeName: string, source: string, target: string): string {\n return JSON.stringify(['synthetic-edge', edgeName, source, target]);\n}\n","/**\n * `.pg` schema model + tolerant parser.\n *\n * The adapter needs three things from the graph schema, all served here:\n * 1. edge endpoint-type resolution (export edge lines carry bare `from`/`to`\n * ids without endpoint types),\n * 2. per-property wire-type knowledge for temporal/blob normalization,\n * 3. a stable schema fingerprint for the export revision stamp.\n *\n * The parser is deliberately tolerant: it extracts the declarations it\n * understands (interfaces, node blocks, edge declarations, properties,\n * constraints) and preserves anything else — unknown annotations survive as\n * raw strings, unknown type spellings become `{ kind: 'unknown' }` — so a\n * newer server grammar degrades gracefully instead of failing the load.\n *\n * Browser-safe: no `node:` imports. The fingerprint is a pure FNV-1a 64-bit\n * hash rather than `node:crypto` sha256 so this module can sit on the\n * browser entry's critical path.\n */\n\n// ---------------------------------------------------------------------------\n// Model\n// ---------------------------------------------------------------------------\n\n/** Closed scalar set per the `.pg` grammar (docs/user/schema). */\nexport type PgScalarName =\n | 'String'\n | 'Blob'\n | 'Bool'\n | 'I32'\n | 'I64'\n | 'U32'\n | 'U64'\n | 'F32'\n | 'F64'\n | 'Date'\n | 'DateTime';\n\nexport type PgType =\n | PgScalarName\n | { kind: 'vector'; dim: number }\n | { kind: 'enum'; values: readonly string[] }\n | { kind: 'list'; element: PgScalarName }\n | { kind: 'unknown'; raw: string };\n\nexport interface PgProperty {\n name: string;\n type: PgType;\n /** `T?` nullability. */\n optional: boolean;\n /** Set by inline `@key` or a body-level `@key(...)` naming this property. */\n key: boolean;\n /** Set by inline `@unique` or a body-level `@unique(...)` naming this property. */\n unique: boolean;\n /** Set by inline `@index` or a body-level `@index(...)` naming this property. */\n index: boolean;\n /** Every annotation as written (`'@key'`, `'@embed(\"body\")'`) — unknown ones preserved verbatim. */\n annotations: readonly string[];\n}\n\nexport interface PgInterfaceType {\n name: string;\n properties: readonly PgProperty[];\n /** Body-level constraint declarations preserved verbatim (e.g. `'@unique(a, b)'`). */\n constraints: readonly string[];\n}\n\nexport interface PgNodeType {\n name: string;\n /** Interface names from the `implements` clause (already expanded into `properties`). */\n implements: readonly string[];\n properties: readonly PgProperty[];\n constraints: readonly string[];\n}\n\nexport interface PgEdgeType {\n name: string;\n /** Source (from) node type name. */\n from: string;\n /** Destination (to) node type name. */\n to: string;\n /** Raw `@card` bounds, e.g. `'1..1'`, `'0..*'`. Absent means the default `0..*`. */\n card?: string;\n /** Header annotations as written (including the `@card(...)` one, if any). */\n annotations: readonly string[];\n properties: readonly PgProperty[];\n constraints: readonly string[];\n}\n\nexport interface PgSchema {\n interfaces: readonly PgInterfaceType[];\n nodes: readonly PgNodeType[];\n edges: readonly PgEdgeType[];\n}\n\nconst SCALARS: ReadonlySet<string> = new Set<PgScalarName>([\n 'String',\n 'Blob',\n 'Bool',\n 'I32',\n 'I64',\n 'U32',\n 'U64',\n 'F32',\n 'F64',\n 'Date',\n 'DateTime',\n]);\n\n// ---------------------------------------------------------------------------\n// Lexical helpers (string-aware; `.pg` strings are double-quoted with `\\` escapes)\n// ---------------------------------------------------------------------------\n\n/** Blank out line and block comments, preserving newlines and string literals. */\nfunction stripComments(src: string): string {\n let out = '';\n let i = 0;\n const n = src.length;\n while (i < n) {\n const ch = src.charAt(i);\n if (ch === '\"') {\n out += ch;\n i++;\n while (i < n) {\n const c = src.charAt(i);\n out += c;\n i++;\n if (c === '\\\\' && i < n) {\n out += src.charAt(i);\n i++;\n } else if (c === '\"') break;\n }\n } else if (ch === '/' && src.charAt(i + 1) === '/') {\n while (i < n && src.charAt(i) !== '\\n') i++;\n } else if (ch === '/' && src.charAt(i + 1) === '*') {\n i += 2;\n while (i < n && !(src.charAt(i) === '*' && src.charAt(i + 1) === '/')) {\n out += src.charAt(i) === '\\n' ? '\\n' : ' ';\n i++;\n }\n i += 2;\n } else {\n out += ch;\n i++;\n }\n }\n return out;\n}\n\n/** Index just past the `}` matching the `{` at `openIdx`, or `src.length` if unbalanced. */\nfunction findBlockEnd(src: string, openIdx: number): number {\n let depth = 0;\n let i = openIdx;\n const n = src.length;\n while (i < n) {\n const ch = src.charAt(i);\n if (ch === '\"') {\n i++;\n while (i < n) {\n const c = src.charAt(i);\n i++;\n if (c === '\\\\') i++;\n else if (c === '\"') break;\n }\n continue;\n }\n if (ch === '{') depth++;\n else if (ch === '}') {\n depth--;\n if (depth === 0) return i + 1;\n }\n i++;\n }\n return n;\n}\n\ninterface RawAnnotation {\n name: string;\n args?: string;\n raw: string;\n}\n\nconst BODY_CONSTRAINT_NAMES: ReadonlySet<string> = new Set([\n 'key',\n 'unique',\n 'index',\n 'range',\n 'check',\n]);\n\n/** Scan a run of `@ident` / `@ident(...)` annotations starting at `start`. */\nfunction scanAnnotations(\n src: string,\n start: number,\n stopBeforeBodyConstraint = false,\n): { anns: RawAnnotation[]; end: number } {\n const anns: RawAnnotation[] = [];\n let i = start;\n const n = src.length;\n for (;;) {\n let j = i;\n while (j < n && /\\s/.test(src.charAt(j))) j++;\n if (src.charAt(j) !== '@') break;\n // `annotation` and `body_constraint` spell the sigil and name as\n // separate Pest sequence terms (`\"@\" ~ ident`), so implicit whitespace\n // is legal here too (`@ key`, `@ rename_from (...)`).\n const m = /^@\\s*([A-Za-z_]\\w*)/.exec(src.slice(j));\n if (!m || m[1] === undefined) break;\n const name = m[1];\n let end = j + m[0].length;\n let args: string | undefined;\n // Pest inserts the silent WHITESPACE rule around `~`, so all schema\n // annotations permit whitespace between their name and argument list\n // (`@card (1..1)`, `@embed (\"body\")`, ...). Keep that whitespace in the\n // preserved raw spelling while using the actual `(` as the parse cursor.\n let open = end;\n while (open < n && /\\s/.test(src.charAt(open))) open++;\n if (src.charAt(open) === '(') {\n let depth = 0;\n let k = open;\n while (k < n) {\n const ch = src.charAt(k);\n if (ch === '\"') {\n k++;\n while (k < n) {\n const c = src.charAt(k);\n k++;\n if (c === '\\\\') k++;\n else if (c === '\"') break;\n }\n continue;\n }\n if (ch === '(') depth++;\n else if (ch === ')') {\n depth--;\n if (depth === 0) {\n k++;\n break;\n }\n }\n k++;\n }\n args = src.slice(open + 1, k - 1);\n end = k;\n }\n // In a property declaration these call-shaped keywords begin the next\n // `body_constraint`; the Pest annotation rule explicitly excludes them.\n // Bare `@key`/`@unique`/`@index` remain valid property annotations.\n if (stopBeforeBodyConstraint && args !== undefined && BODY_CONSTRAINT_NAMES.has(name)) {\n break;\n }\n const entry: RawAnnotation = { name, raw: src.slice(j, end) };\n if (args !== undefined) entry.args = args;\n anns.push(entry);\n i = end;\n }\n return { anns, end: i };\n}\n\n/** Split on top-level commas (outside parens/strings), trim, drop empties. */\nfunction splitArgs(args: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let current = '';\n for (let i = 0; i < args.length; i++) {\n const ch = args.charAt(i);\n if (ch === '\"') {\n current += ch;\n i++;\n while (i < args.length) {\n const c = args.charAt(i);\n current += c;\n if (c === '\\\\') {\n i++;\n current += args.charAt(i);\n } else if (c === '\"') break;\n i++;\n }\n continue;\n }\n if (ch === '(' || ch === '[') depth++;\n else if (ch === ')' || ch === ']') depth = Math.max(0, depth - 1);\n if (ch === ',' && depth === 0) {\n out.push(current);\n current = '';\n } else {\n current += ch;\n }\n }\n out.push(current);\n return out.map((s) => s.trim()).filter((s) => s.length > 0);\n}\n\n// ---------------------------------------------------------------------------\n// Statement parsing\n// ---------------------------------------------------------------------------\n\ninterface MutableTypeBody {\n properties: PgProperty[];\n constraints: string[];\n}\n\nfunction parseTypeRef(text: string): { type: PgType; optional: boolean; end: number } {\n let i = 0;\n const n = text.length;\n while (i < n && /\\s/.test(text.charAt(i))) i++;\n let type: PgType;\n if (text.charAt(i) === '[') {\n const m = /^\\[\\s*([A-Za-z_]\\w*)\\s*\\]/.exec(text.slice(i));\n if (m && m[1] !== undefined && SCALARS.has(m[1])) {\n type = { kind: 'list', element: m[1] as PgScalarName };\n i += m[0].length;\n } else {\n const close = text.indexOf(']', i);\n const nextLine = text.indexOf('\\n', i);\n let end = close === -1 ? n : close + 1;\n if (nextLine !== -1 && nextLine < end) end = nextLine;\n type = { kind: 'unknown', raw: text.slice(i, end).trim() };\n i = end;\n }\n } else {\n const m = /^([A-Za-z_]\\w*)/.exec(text.slice(i));\n if (!m || m[1] === undefined) {\n const nextLine = text.indexOf('\\n', i);\n const end = nextLine === -1 ? n : nextLine;\n return {\n type: { kind: 'unknown', raw: text.slice(i, end).trim() },\n optional: false,\n end,\n };\n }\n const ident = m[1];\n i += m[0].length;\n // As with annotations, the server grammar's silent WHITESPACE rule makes\n // `Vector (3)` and `enum (a, b)` equivalent to their compact spellings.\n let open = i;\n while (open < n && /\\s/.test(text.charAt(open))) open++;\n if ((ident === 'enum' || ident === 'Vector') && text.charAt(open) === '(') {\n let depth = 0;\n let k = open;\n while (k < n) {\n const ch = text.charAt(k);\n if (ch === '(') depth++;\n else if (ch === ')') {\n depth--;\n if (depth === 0) {\n k++;\n break;\n }\n }\n k++;\n }\n const inner = text.slice(open + 1, k - 1);\n i = k;\n if (ident === 'enum') {\n const values = splitArgs(inner).map((v) => v.replace(/^\"(.*)\"$/s, '$1'));\n type = { kind: 'enum', values };\n } else {\n const dim = Number.parseInt(inner.trim(), 10);\n type = Number.isFinite(dim)\n ? { kind: 'vector', dim }\n : { kind: 'unknown', raw: `Vector(${inner})` };\n }\n } else if (SCALARS.has(ident)) {\n type = ident as PgScalarName;\n } else {\n type = { kind: 'unknown', raw: ident };\n }\n }\n let optional = false;\n // `type_ref = { core_type ~ \"?\"? }`: implicit whitespace also applies\n // before the optional marker (`String ?`, `[String] ?`, `Vector (3) ?`).\n while (i < n && /\\s/.test(text.charAt(i))) i++;\n if (text.charAt(i) === '?') {\n optional = true;\n i++;\n }\n return { type, optional, end: i };\n}\n\nfunction parseBody(body: string): MutableTypeBody {\n const properties: PgProperty[] = [];\n const constraints: string[] = [];\n // Pest's implicit WHITESPACE includes newlines, so a newline is not a\n // statement delimiter: `String\\n?`, `Vector\\n(3)`, and same-line adjacent\n // declarations are all legal. Consume the body as one token stream.\n let cursor = body.trimStart();\n while (cursor !== '') {\n if (cursor.startsWith('@')) {\n const { anns, end } = scanAnnotations(cursor, 0);\n if (anns.length === 0 || end === 0) break;\n for (const a of anns) constraints.push(a.raw);\n cursor = cursor.slice(end).trimStart();\n continue;\n }\n\n const head = /^([A-Za-z_]\\w*)\\s*:\\s*/.exec(cursor);\n if (!head || head[1] === undefined) {\n // Tolerant recovery: discard only the malformed physical line, then\n // resume. Valid declarations do not need newlines, but this preserves\n // the historical ability to salvage later lines after unknown syntax.\n const nextLine = cursor.indexOf('\\n');\n if (nextLine === -1) break;\n cursor = cursor.slice(nextLine + 1).trimStart();\n continue;\n }\n const name = head[1];\n const rest = cursor.slice(head[0].length);\n const { type, optional, end } = parseTypeRef(rest);\n const { anns, end: annsEnd } = scanAnnotations(rest, end, true);\n properties.push({\n name,\n type,\n optional,\n key: anns.some((a) => a.name === 'key'),\n unique: anns.some((a) => a.name === 'unique'),\n index: anns.some((a) => a.name === 'index'),\n annotations: anns.map((a) => a.raw),\n });\n cursor = rest.slice(annsEnd).trimStart();\n }\n // Body-level @key(a, b) / @unique(a) / @index(a) constraints flag the named properties.\n for (const raw of constraints) {\n const m = /^@\\s*(key|unique|index)\\s*\\((.*)\\)$/s.exec(raw);\n if (!m || m[1] === undefined || m[2] === undefined) continue;\n const flag = m[1] as 'key' | 'unique' | 'index';\n for (const propName of splitArgs(m[2])) {\n const prop = properties.find((p) => p.name === propName);\n if (prop) prop[flag] = true;\n }\n }\n return { properties, constraints };\n}\n\n// ---------------------------------------------------------------------------\n// Top-level parse\n// ---------------------------------------------------------------------------\n\n/**\n * Parse `.pg` source into a {@link PgSchema}. Tolerant by design: malformed\n * or unrecognized declarations are skipped, not fatal; `implements` clauses\n * are expanded into node properties (node-declared properties win on name\n * collisions, matching the server's table layout).\n */\nexport function parsePgSchema(source: string): PgSchema {\n const src = stripComments(source);\n const interfaces: PgInterfaceType[] = [];\n const nodes: (PgNodeType & { properties: PgProperty[] })[] = [];\n const edges: PgEdgeType[] = [];\n\n const headRe = /\\b(interface|node|edge)\\s+([A-Za-z_]\\w*)/g;\n let m: RegExpExecArray | null;\n while ((m = headRe.exec(src)) !== null) {\n const kw = m[1];\n const name = m[2];\n if (kw === undefined || name === undefined) continue;\n let pos = headRe.lastIndex;\n\n if (kw === 'edge') {\n const em = /^\\s*:\\s*([A-Za-z_]\\w*)\\s*->\\s*([A-Za-z_]\\w*)/.exec(src.slice(pos));\n if (!em || em[1] === undefined || em[2] === undefined) continue; // tolerant skip\n pos += em[0].length;\n const { anns, end } = scanAnnotations(src, pos);\n pos = end;\n let body: MutableTypeBody = { properties: [], constraints: [] };\n let braceIdx = pos;\n while (braceIdx < src.length && /\\s/.test(src.charAt(braceIdx))) braceIdx++;\n if (src.charAt(braceIdx) === '{') {\n const blockEnd = findBlockEnd(src, braceIdx);\n body = parseBody(src.slice(braceIdx + 1, blockEnd - 1));\n pos = blockEnd;\n }\n const card = anns.find((a) => a.name === 'card')?.args?.trim();\n const edge: PgEdgeType = {\n name,\n from: em[1],\n to: em[2],\n annotations: anns.map((a) => a.raw),\n properties: body.properties,\n constraints: body.constraints,\n ...(card !== undefined ? { card } : {}),\n };\n edges.push(edge);\n headRe.lastIndex = pos;\n continue;\n }\n\n // interface / node: optional `implements A, B` (node only), then a block.\n let impls: string[] = [];\n // The grammar carries head annotations (`@card`/`@unique` prove the\n // family). `node Account @rename_from(\"User\") { … }` previously hit the\n // tolerant skip and silently dropped the whole declaration.\n // Annotations are consumed (and ignored — migration metadata) on either\n // side of `implements`, through the SAME scanner the body lane uses. It\n // honors nested parens and escaped quotes; a first-`)` regex would\n // truncate `@rename_from(\"User (legacy)\")` and drop the node.\n const skipAnnotations = (): void => {\n pos = scanAnnotations(src, pos).end;\n };\n skipAnnotations();\n if (kw === 'node') {\n const im = /^\\s*implements\\s+([A-Za-z_]\\w*(?:\\s*,\\s*[A-Za-z_]\\w*)*)/.exec(src.slice(pos));\n if (im && im[1] !== undefined) {\n impls = im[1].split(',').map((s) => s.trim());\n pos += im[0].length;\n }\n skipAnnotations();\n }\n let braceIdx = pos;\n while (braceIdx < src.length && /\\s/.test(src.charAt(braceIdx))) braceIdx++;\n if (src.charAt(braceIdx) !== '{') continue; // tolerant skip\n const blockEnd = findBlockEnd(src, braceIdx);\n const body = parseBody(src.slice(braceIdx + 1, blockEnd - 1));\n headRe.lastIndex = blockEnd;\n if (kw === 'interface') {\n interfaces.push({ name, properties: body.properties, constraints: body.constraints });\n } else {\n nodes.push({\n name,\n implements: impls,\n properties: body.properties,\n constraints: body.constraints,\n });\n }\n }\n\n // Expand implements clauses: interface properties precede the node's own,\n // except where the node re-declares a name (node declaration wins).\n for (const node of nodes) {\n if (node.implements.length === 0) continue;\n const own = new Set(node.properties.map((p) => p.name));\n const inherited: PgProperty[] = [];\n for (const ifaceName of node.implements) {\n const iface = interfaces.find((i) => i.name === ifaceName);\n if (!iface) continue; // tolerant: unknown interface\n for (const p of iface.properties) {\n if (!own.has(p.name) && !inherited.some((q) => q.name === p.name)) inherited.push(p);\n }\n }\n node.properties = [...inherited, ...node.properties];\n }\n\n return { interfaces, nodes, edges };\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve an edge type's declared endpoint node types. Export edge\n * lines carry bare `from`/`to` ids, so endpoint types come from here. Edge\n * names match exactly first, then case-insensitively (the server matches edge\n * names case-insensitively). Returns `null` for an unknown edge name.\n */\nexport function edgeEndpointTypes(\n schema: PgSchema,\n edgeName: string,\n): { from: string; to: string } | null {\n const lower = edgeName.toLowerCase();\n const edge =\n schema.edges.find((e) => e.name === edgeName) ??\n schema.edges.find((e) => e.name.toLowerCase() === lower);\n return edge ? { from: edge.from, to: edge.to } : null;\n}\n\n/**\n * Stable fingerprint of `.pg` source for the adapter revision stamp: FNV-1a\n * 64-bit over the UTF-8 bytes of the source, as 16 lowercase hex chars.\n *\n * Pure and browser-safe (no `node:crypto`). Hashes the source **verbatim**:\n * any textual change — including comments or whitespace — changes the\n * fingerprint, which is the conservative choice for drift detection.\n */\nexport function schemaFingerprint(source: string): string {\n const MASK64 = 0xffffffffffffffffn;\n let h = 0xcbf29ce484222325n;\n const bytes = new TextEncoder().encode(source);\n for (const b of bytes) {\n h ^= BigInt(b);\n h = (h * 0x100000001b3n) & MASK64;\n }\n return h.toString(16).padStart(16, '0');\n}\n\nexport interface BigIntKeyWarning {\n /** Node or edge type name. */\n type: string;\n /** The hazardous property. */\n property: string;\n}\n\n/**\n * Find `I64`/`U64` properties used as identity (`@key` or named `id`). The\n * HTTP path emits native JSON numbers even past ±2^53, where `JSON.parse`\n * silently rounds them, so two distinct big-int ids can collapse. Surface\n * these hazards before loading.\n */\nexport function bigIntKeyWarnings(schema: PgSchema): BigIntKeyWarning[] {\n const out: BigIntKeyWarning[] = [];\n for (const t of [...schema.nodes, ...schema.edges]) {\n for (const p of t.properties) {\n if ((p.type === 'I64' || p.type === 'U64') && (p.key || p.name === 'id')) {\n out.push({ type: t.name, property: p.name });\n }\n }\n }\n return out;\n}\n","/**\n * Export-line classification and normalization.\n *\n * `/export` streams NDJSON — one JSON object per line, `data` passed through\n * **verbatim** by the SDK. This module turns those lines into orbit\n * `GraphNode`/`GraphEdge` values:\n *\n * - ids are namespaced through the adapter identity codec (`encodeSourceId`),\n * - the node/edge KIND is injected as {@link ORBIT_TYPE_KEY} — namespaced so\n * a schema's own `type` property passes through as ordinary data,\n * - edge endpoint types are resolved from the `.pg` schema because edge lines\n * carry bare `from`/`to` ids,\n * - attr values are normalized to the query-path string forms so\n * generated types and temporal dimensions see one encoding\n * regardless of read path:\n * * `Date` — export sends **days since Unix epoch** (number) →\n * `'YYYY-MM-DD'` (UTC)\n * * `DateTime` — export sends **epoch milliseconds** (number) →\n * ISO 8601 (`'YYYY-MM-DDTHH:MM:SS.mmmZ'`)\n * * `Blob` — inline internal blobs arrive as `'base64:<data>'` →\n * `'data:application/octet-stream;base64,<data>'`;\n * external-URI refs pass through verbatim\n * * everything else — verbatim.\n *\n * Non-finite float sentinels (`'NaN'`/`'Infinity'`/`'-Infinity'`) are a\n * **query-path-only** encoding: a non-finite stored float aborts `/export`\n * server-side, so export-loaded data never contains the sentinels.\n * This module therefore does NOT special-case them.\n */\n\nimport type { GraphEdge, GraphNode } from '@modernrelay/orbit-core';\nimport { encodeSourceId } from './idCodec';\nimport {\n edgeEndpointTypes,\n type PgEdgeType,\n type PgNodeType,\n type PgProperty,\n type PgSchema,\n type PgType,\n} from './pgSchema';\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\n/** An edge line names an edge type the `.pg` schema does not declare. */\nexport class UnknownEdgeTypeError extends Error {\n override readonly name = 'UnknownEdgeTypeError';\n readonly edgeName: string;\n constructor(edgeName: string) {\n super(\n `Unknown edge type '${edgeName}': not declared in the graph schema, so its ` +\n `endpoint node types cannot be resolved.`,\n );\n this.edgeName = edgeName;\n }\n}\n\n/** An export line is structurally unusable (e.g. missing/non-string `data.id`). */\nexport class InvalidExportLineError extends Error {\n override readonly name = 'InvalidExportLineError';\n constructor(message: string) {\n super(message);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Classification\n// ---------------------------------------------------------------------------\n\nexport interface NodeExportLine {\n kind: 'node';\n type: string;\n data: Record<string, unknown>;\n}\n\nexport interface EdgeExportLine {\n kind: 'edge';\n edge: string;\n from: string;\n to: string;\n data: Record<string, unknown>;\n}\n\nexport type ClassifiedExportLine = NodeExportLine | EdgeExportLine | { kind: 'unknown' };\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Classify one parsed export line using the adapter's wire shapes:\n * - node line: `{\"type\": \"<NodeType>\", \"data\": {\"id\", …props}}`\n * - edge line: `{\"edge\": \"<EdgeName>\", \"from\": <src id>, \"to\": <dst id>, \"data\": {\"id\", …props}}`\n * Anything else is `{ kind: 'unknown' }`.\n */\nexport function classifyExportLine(line: unknown): ClassifiedExportLine {\n if (!isRecord(line) || !isRecord(line['data'])) return { kind: 'unknown' };\n const data = line['data'];\n if (\n typeof line['edge'] === 'string' &&\n typeof line['from'] === 'string' &&\n typeof line['to'] === 'string'\n ) {\n return { kind: 'edge', edge: line['edge'], from: line['from'], to: line['to'], data };\n }\n if (typeof line['type'] === 'string') {\n return { kind: 'node', type: line['type'], data };\n }\n return { kind: 'unknown' };\n}\n\n// ---------------------------------------------------------------------------\n// Value normalization\n// ---------------------------------------------------------------------------\n\nconst MS_PER_DAY = 86_400_000;\n\n/** Format an epoch-day count as `'YYYY-MM-DD'` (UTC). Handles negative days. */\nfunction formatEpochDay(days: number): string {\n const d = new Date(days * MS_PER_DAY);\n const t = d.getTime();\n if (!Number.isFinite(t)) return String(days); // out of Date range — leave a readable value\n const y = d.getUTCFullYear();\n const year =\n y < 0\n ? `-${String(-y).padStart(6, '0')}`\n : y > 9999\n ? `+${String(y).padStart(6, '0')}`\n : String(y).padStart(4, '0');\n const month = String(d.getUTCMonth() + 1).padStart(2, '0');\n const day = String(d.getUTCDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\nfunction normalizeValue(type: PgType | undefined, value: unknown): unknown {\n if (type === undefined || value === null || value === undefined) return value;\n if (type === 'Date' && typeof value === 'number' && Number.isInteger(value)) {\n return formatEpochDay(value);\n }\n if (type === 'DateTime' && typeof value === 'number' && Number.isFinite(value)) {\n const d = new Date(value);\n return Number.isFinite(d.getTime()) ? d.toISOString() : value;\n }\n if (type === 'Blob' && typeof value === 'string' && value.startsWith('base64:')) {\n return `data:application/octet-stream;base64,${value.slice('base64:'.length)}`;\n }\n return value;\n}\n\nfunction propTypeMap(t: PgNodeType | PgEdgeType | undefined): ReadonlyMap<string, PgType> {\n const map = new Map<string, PgType>();\n if (t) for (const p of t.properties as readonly PgProperty[]) map.set(p.name, p.type);\n return map;\n}\n\nfunction normalizeData(\n data: Record<string, unknown>,\n types: ReadonlyMap<string, PgType>,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n // Source data can carry '__proto__' as an own key (JSON.parse creates it);\n // defineProperty writes the own property, never the setter.\n for (const [k, v] of Object.entries(data)) {\n Object.defineProperty(out, k, {\n value: normalizeValue(types.get(k), v),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n}\n\nfunction requireStringId(data: Record<string, unknown>, what: string): string {\n const id = data['id'];\n if (typeof id !== 'string') {\n throw new InvalidExportLineError(\n `${what} export line has ${id === undefined ? 'no' : 'a non-string'} 'data.id' — ` +\n `cannot build a stable orbit id; data.id must be a string.`,\n );\n }\n return id;\n}\n\n// ---------------------------------------------------------------------------\n// Node / edge normalization\n// ---------------------------------------------------------------------------\n\n/**\n * The adapter's node/edge KIND discriminator key.\n *\n * Namespaced on purpose: the adapter injects this field into someone else's\n * data, so it takes the awkward key and leaves the generic word `type` to the\n * schema author, who means something real by it (`Company.type = investor`).\n * A colon is illegal in `.pg` identifiers, so no schema property can ever\n * claim this key — the collision class is closed by construction, and a\n * source-declared `type` now flows through untouched with no preservation\n * mechanism, no warning, and no schema migration. Same convention as\n * GraphQL's `__typename` / JSON-LD's `@type`.\n */\nexport const ORBIT_TYPE_KEY = 'orbit:type';\n\n/**\n * Normalize a node export line to a `GraphNode`:\n * `id = encodeSourceId(type, data.id)`, `attrs = { …data, 'orbit:type' }`\n * with value normalization driven by the schema's property types. A node type\n * absent from the schema is tolerated — its attrs pass through verbatim\n * (identity never needs the schema on the node path).\n */\nexport function normalizeNode(\n line: { type: string; data: Record<string, unknown> },\n schema: PgSchema,\n): GraphNode {\n const nodeType = schema.nodes.find((n) => n.name === line.type);\n const id = encodeSourceId(line.type, requireStringId(line.data, `Node '${line.type}'`));\n return {\n id,\n // The discriminator is adapter-owned identity metadata. It lands LAST so\n // a forward-compatible export field literally named `orbit:type` cannot\n // forge the value the generated attrs unions promise.\n attrs: { ...normalizeData(line.data, propTypeMap(nodeType)), [ORBIT_TYPE_KEY]: line.type },\n };\n}\n\n/**\n * Normalize an edge export line to a `GraphEdge`:\n * `id = encodeSourceId(edge, data.id)`; `source`/`target` namespace the bare\n * `from`/`to` ids with the endpoint node types resolved from the schema.\n * Throws {@link UnknownEdgeTypeError} when the schema does not declare\n * the edge — endpoint identity cannot be constructed without it.\n */\nexport function normalizeEdge(\n line: { edge: string; from: string; to: string; data: Record<string, unknown> },\n schema: PgSchema,\n): GraphEdge {\n const endpoints = edgeEndpointTypes(schema, line.edge);\n if (endpoints === null) throw new UnknownEdgeTypeError(line.edge);\n const lower = line.edge.toLowerCase();\n const edgeType =\n schema.edges.find((e) => e.name === line.edge) ??\n schema.edges.find((e) => e.name.toLowerCase() === lower);\n const id = encodeSourceId(line.edge, requireStringId(line.data, `Edge '${line.edge}'`));\n return {\n id,\n source: encodeSourceId(endpoints.from, line.from),\n target: encodeSourceId(endpoints.to, line.to),\n // As on nodes, the adapter's resolved edge name lands last and always\n // wins the discriminator key; a source `type` property is ordinary data.\n attrs: { ...normalizeData(line.data, propTypeMap(edgeType)), [ORBIT_TYPE_KEY]: line.edge },\n };\n}\n"]}
|
package/dist/codegen-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { parsePgSchema, schemaFingerprint, ORBIT_TYPE_KEY } from './chunk-
|
|
2
|
+
import { parsePgSchema, schemaFingerprint, ORBIT_TYPE_KEY } from './chunk-WMBDYPK2.js';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
4
4
|
import process from 'process';
|
|
5
5
|
import { Omnigraph } from '@modernrelay/omnigraph';
|
|
@@ -38,14 +38,14 @@ function wireNote(type) {
|
|
|
38
38
|
if (typeof type === "string") {
|
|
39
39
|
switch (type) {
|
|
40
40
|
case "Date":
|
|
41
|
-
return "`Date` \u2014 normalized to 'YYYY-MM-DD' (UTC) on load
|
|
41
|
+
return "`Date` \u2014 normalized to 'YYYY-MM-DD' (UTC) on load.";
|
|
42
42
|
case "DateTime":
|
|
43
|
-
return "`DateTime` \u2014 normalized to ISO 8601 UTC on load
|
|
43
|
+
return "`DateTime` \u2014 normalized to ISO 8601 UTC on load.";
|
|
44
44
|
case "Blob":
|
|
45
|
-
return "`Blob` \u2014 `data:` URI for inline blobs, stored URI refs verbatim
|
|
45
|
+
return "`Blob` \u2014 `data:` URI for inline blobs, stored URI refs verbatim.";
|
|
46
46
|
case "I64":
|
|
47
47
|
case "U64":
|
|
48
|
-
return `\`${type}\` \u2014 JSON numbers round silently past \xB12^53
|
|
48
|
+
return `\`${type}\` \u2014 JSON numbers round silently past \xB12^53.`;
|
|
49
49
|
default:
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
@@ -70,15 +70,22 @@ function emitProperty(lines, prop) {
|
|
|
70
70
|
lines.push(` ${propertyKey(prop.name)}: ${prop.optional ? `${base} | null` : base};`);
|
|
71
71
|
}
|
|
72
72
|
function emitPropsInterface(lines, interfaceName, kindLabel, typeName, properties) {
|
|
73
|
-
lines.push(`/** Normalized attrs for ${kindLabel} type \`${typeName}
|
|
73
|
+
lines.push(`/** Normalized attrs for ${kindLabel} type \`${typeName}\`. */`);
|
|
74
74
|
lines.push(`export interface ${interfaceName} {`);
|
|
75
75
|
if (!properties.some((p) => p.name === "id")) {
|
|
76
76
|
lines.push(
|
|
77
|
-
` /** Physical Omnigraph id \u2014 injected into every export line's \`data
|
|
77
|
+
` /** Physical Omnigraph id \u2014 injected into every export line's \`data\`; unique per ${kindLabel} type only. */`
|
|
78
78
|
);
|
|
79
79
|
lines.push(" id: string;");
|
|
80
80
|
}
|
|
81
81
|
for (const prop of properties) {
|
|
82
|
+
if (prop.name === "id") {
|
|
83
|
+
lines.push(
|
|
84
|
+
` /** Physical Omnigraph id \u2014 normalized as a required string regardless of its schema wire type. */`
|
|
85
|
+
);
|
|
86
|
+
lines.push(" id: string;");
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
82
89
|
emitProperty(lines, prop);
|
|
83
90
|
}
|
|
84
91
|
lines.push("}");
|
|
@@ -103,7 +110,7 @@ function headerBanner(fingerprintLine, extra) {
|
|
|
103
110
|
const lines = [
|
|
104
111
|
"// AUTO-GENERATED \u2014 DO NOT EDIT.",
|
|
105
112
|
"//",
|
|
106
|
-
"// .pg \u2192 TypeScript typed attrs (
|
|
113
|
+
"// .pg \u2192 TypeScript typed attrs (wire-normalized), generated by",
|
|
107
114
|
"// @modernrelay/orbit-omnigraph (`orbit-omnigraph-codegen`).",
|
|
108
115
|
`// ${fingerprintLine}`
|
|
109
116
|
];
|
|
@@ -114,7 +121,7 @@ function headerBanner(fingerprintLine, extra) {
|
|
|
114
121
|
}
|
|
115
122
|
lines.push(
|
|
116
123
|
"//",
|
|
117
|
-
"// Shapes describe attrs AFTER the adapter's
|
|
124
|
+
"// Shapes describe attrs AFTER the adapter's wire normalization (both read",
|
|
118
125
|
"// paths converge on the query-path string encodings):",
|
|
119
126
|
"// Date \u2192 'YYYY-MM-DD' \xB7 DateTime \u2192 ISO 8601 \xB7 enum(...) \u2192 literal union",
|
|
120
127
|
"// I64/U64/F32/F64 \u2192 number \xB7 Vector(n) \u2192 number[] \xB7 T? \u2192 T | null",
|
|
@@ -124,7 +131,7 @@ function headerBanner(fingerprintLine, extra) {
|
|
|
124
131
|
return lines;
|
|
125
132
|
}
|
|
126
133
|
function generateTypes(schema, opts) {
|
|
127
|
-
const fingerprintLine = opts?.fingerprint !== void 0 ? `Schema fingerprint: ${opts.fingerprint}
|
|
134
|
+
const fingerprintLine = opts?.fingerprint !== void 0 ? `Schema fingerprint: ${opts.fingerprint}.` : `Schema fingerprint: ${schemaFingerprint(JSON.stringify(schema))} (parsed model \u2014 regenerate from .pg source for the source fingerprint).`;
|
|
128
135
|
const lines = headerBanner(fingerprintLine, opts?.header);
|
|
129
136
|
const nodeMembers = schema.nodes.map((n) => ({
|
|
130
137
|
typeName: n.name,
|
|
@@ -145,16 +152,16 @@ function generateTypes(schema, opts) {
|
|
|
145
152
|
emitAttrsUnion(
|
|
146
153
|
lines,
|
|
147
154
|
"NodeAttrs",
|
|
148
|
-
"Discriminated union over every node type's normalized attrs \u2014 `'orbit:type'` is injected by the adapter
|
|
155
|
+
"Discriminated union over every node type's normalized attrs \u2014 `'orbit:type'` is injected by the adapter.",
|
|
149
156
|
nodeMembers
|
|
150
157
|
);
|
|
151
158
|
emitAttrsUnion(
|
|
152
159
|
lines,
|
|
153
160
|
"EdgeAttrs",
|
|
154
|
-
"Discriminated union over every edge type's normalized attrs \u2014 `'orbit:type'` is the edge name
|
|
161
|
+
"Discriminated union over every edge type's normalized attrs \u2014 `'orbit:type'` is the edge name.",
|
|
155
162
|
edgeMembers
|
|
156
163
|
);
|
|
157
|
-
lines.push("/** Type-name \u2192 props lookup for both kinds (closed sets from the schema \u2014
|
|
164
|
+
lines.push("/** Type-name \u2192 props lookup for both kinds (closed sets from the schema \u2014 the wire contract). */");
|
|
158
165
|
lines.push("export interface TypeMap {");
|
|
159
166
|
lines.push(" nodes: {");
|
|
160
167
|
for (const m of nodeMembers) lines.push(` ${propertyKey(m.typeName)}: ${m.interfaceName};`);
|
|
@@ -181,7 +188,7 @@ var USAGE = `Usage:
|
|
|
181
188
|
orbit-omnigraph-codegen <schema.pg> [-o <out.ts>]
|
|
182
189
|
orbit-omnigraph-codegen --from-server <baseUrl> --graph <id> [-o <out.ts>]
|
|
183
190
|
|
|
184
|
-
Generates TypeScript typed attrs
|
|
191
|
+
Generates TypeScript typed attrs from a .pg schema \u2014 read from a
|
|
185
192
|
file, or fetched from a running omnigraph-server (unauthenticated client).
|
|
186
193
|
Writes to stdout unless -o is given.
|
|
187
194
|
`;
|