@relate/contrib-web 0.0.0-stage → 0.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.
Files changed (191) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +242 -2
  3. package/conformance/example-site/blank.html +2 -0
  4. package/conformance/example-site/broken.html +35 -0
  5. package/conformance/example-site/index.html +35 -0
  6. package/conformance/example-site/notes.html +35 -0
  7. package/conformance/example-site/page-1.html +35 -0
  8. package/conformance/example-site/page-2.html +35 -0
  9. package/conformance/example-site/public/descriptor-b.json +16 -0
  10. package/conformance/example-site/public/descriptor-broken.json +16 -0
  11. package/conformance/example-site/public/descriptor-mismatch.json +16 -0
  12. package/conformance/example-site/public/descriptor.json +16 -0
  13. package/conformance/example-site/public/graph-b.json +14408 -0
  14. package/conformance/example-site/public/graph.json +10808 -0
  15. package/conformance/example-site/rel-page.ts +147 -0
  16. package/conformance/example-site/vite.config.ts +23 -0
  17. package/conformance/make-example.ts +22 -0
  18. package/conformance/run.ts +152 -0
  19. package/conformance/scenarios.ts +285 -0
  20. package/dist/application/options.d.ts +9 -0
  21. package/dist/application/options.js +64 -0
  22. package/dist/application/options.js.map +1 -0
  23. package/dist/application/ranges.d.ts +7 -0
  24. package/dist/application/ranges.js +14 -0
  25. package/dist/application/ranges.js.map +1 -0
  26. package/dist/application/storage.d.ts +34 -0
  27. package/dist/application/storage.js +60 -0
  28. package/dist/application/storage.js.map +1 -0
  29. package/dist/application/types.d.ts +49 -0
  30. package/dist/application/types.js +2 -0
  31. package/dist/application/types.js.map +1 -0
  32. package/dist/build/canonical.d.ts +5 -0
  33. package/dist/build/canonical.js +26 -0
  34. package/dist/build/canonical.js.map +1 -0
  35. package/dist/build/descriptor.d.ts +16 -0
  36. package/dist/build/descriptor.js +13 -0
  37. package/dist/build/descriptor.js.map +1 -0
  38. package/dist/build/index.d.ts +6 -0
  39. package/dist/build/index.js +6 -0
  40. package/dist/build/index.js.map +1 -0
  41. package/dist/build/inline.d.ts +16 -0
  42. package/dist/build/inline.js +44 -0
  43. package/dist/build/inline.js.map +1 -0
  44. package/dist/build/prepare.d.ts +11 -0
  45. package/dist/build/prepare.js +25 -0
  46. package/dist/build/prepare.js.map +1 -0
  47. package/dist/catalog/api.d.ts +30 -0
  48. package/dist/catalog/api.js +56 -0
  49. package/dist/catalog/api.js.map +1 -0
  50. package/dist/catalog/catalog.d.ts +51 -0
  51. package/dist/catalog/catalog.js +104 -0
  52. package/dist/catalog/catalog.js.map +1 -0
  53. package/dist/catalog/directory.d.ts +30 -0
  54. package/dist/catalog/directory.js +116 -0
  55. package/dist/catalog/directory.js.map +1 -0
  56. package/dist/catalog/file.d.ts +12 -0
  57. package/dist/catalog/file.js +84 -0
  58. package/dist/catalog/file.js.map +1 -0
  59. package/dist/catalog/index.d.ts +10 -0
  60. package/dist/catalog/index.js +12 -0
  61. package/dist/catalog/index.js.map +1 -0
  62. package/dist/catalog/memory-storage.d.ts +16 -0
  63. package/dist/catalog/memory-storage.js +56 -0
  64. package/dist/catalog/memory-storage.js.map +1 -0
  65. package/dist/catalog/opfs-storage.d.ts +10 -0
  66. package/dist/catalog/opfs-storage.js +71 -0
  67. package/dist/catalog/opfs-storage.js.map +1 -0
  68. package/dist/catalog/remove.d.ts +21 -0
  69. package/dist/catalog/remove.js +85 -0
  70. package/dist/catalog/remove.js.map +1 -0
  71. package/dist/catalog/storage.d.ts +11 -0
  72. package/dist/catalog/storage.js +4 -0
  73. package/dist/catalog/storage.js.map +1 -0
  74. package/dist/catalog/types.d.ts +68 -0
  75. package/dist/catalog/types.js +4 -0
  76. package/dist/catalog/types.js.map +1 -0
  77. package/dist/client/application.d.ts +32 -0
  78. package/dist/client/application.js +99 -0
  79. package/dist/client/application.js.map +1 -0
  80. package/dist/client/client.d.ts +2 -0
  81. package/dist/client/client.js +445 -0
  82. package/dist/client/client.js.map +1 -0
  83. package/dist/client/diagnostic.d.ts +6 -0
  84. package/dist/client/diagnostic.js +35 -0
  85. package/dist/client/diagnostic.js.map +1 -0
  86. package/dist/client/events.d.ts +27 -0
  87. package/dist/client/events.js +31 -0
  88. package/dist/client/events.js.map +1 -0
  89. package/dist/client/failure.d.ts +13 -0
  90. package/dist/client/failure.js +40 -0
  91. package/dist/client/failure.js.map +1 -0
  92. package/dist/client/scope.d.ts +15 -0
  93. package/dist/client/scope.js +39 -0
  94. package/dist/client/scope.js.map +1 -0
  95. package/dist/client/status.d.ts +14 -0
  96. package/dist/client/status.js +34 -0
  97. package/dist/client/status.js.map +1 -0
  98. package/dist/client/subscriptions.d.ts +31 -0
  99. package/dist/client/subscriptions.js +64 -0
  100. package/dist/client/subscriptions.js.map +1 -0
  101. package/dist/client/types.d.ts +82 -0
  102. package/dist/client/types.js +2 -0
  103. package/dist/client/types.js.map +1 -0
  104. package/dist/config.d.ts +30 -0
  105. package/dist/config.js +28 -0
  106. package/dist/config.js.map +1 -0
  107. package/dist/conformance/run.d.ts +61 -0
  108. package/dist/conformance/run.js +121 -0
  109. package/dist/conformance/run.js.map +1 -0
  110. package/dist/conformance/scenarios.d.ts +25 -0
  111. package/dist/conformance/scenarios.js +257 -0
  112. package/dist/conformance/scenarios.js.map +1 -0
  113. package/dist/data/descriptor.d.ts +20 -0
  114. package/dist/data/descriptor.js +75 -0
  115. package/dist/data/descriptor.js.map +1 -0
  116. package/dist/data/types.d.ts +41 -0
  117. package/dist/data/types.js +3 -0
  118. package/dist/data/types.js.map +1 -0
  119. package/dist/data/validate.d.ts +22 -0
  120. package/dist/data/validate.js +118 -0
  121. package/dist/data/validate.js.map +1 -0
  122. package/dist/errors.d.ts +9 -0
  123. package/dist/errors.js +14 -0
  124. package/dist/errors.js.map +1 -0
  125. package/dist/index.d.ts +17 -0
  126. package/dist/index.js +8 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/profiles/index.d.ts +5 -0
  129. package/dist/profiles/index.js +9 -0
  130. package/dist/profiles/index.js.map +1 -0
  131. package/dist/profiles/per-page.d.ts +2 -0
  132. package/dist/profiles/per-page.js +11 -0
  133. package/dist/profiles/per-page.js.map +1 -0
  134. package/dist/profiles/persistent.d.ts +5 -0
  135. package/dist/profiles/persistent.js +14 -0
  136. package/dist/profiles/persistent.js.map +1 -0
  137. package/dist/validate.d.ts +5 -0
  138. package/dist/validate.js +4 -0
  139. package/dist/validate.js.map +1 -0
  140. package/dist/worker/application/classify.d.ts +30 -0
  141. package/dist/worker/application/classify.js +57 -0
  142. package/dist/worker/application/classify.js.map +1 -0
  143. package/dist/worker/application/init.d.ts +12 -0
  144. package/dist/worker/application/init.js +64 -0
  145. package/dist/worker/application/init.js.map +1 -0
  146. package/dist/worker/application/lifecycle.d.ts +29 -0
  147. package/dist/worker/application/lifecycle.js +86 -0
  148. package/dist/worker/application/lifecycle.js.map +1 -0
  149. package/dist/worker/application/losses.d.ts +11 -0
  150. package/dist/worker/application/losses.js +61 -0
  151. package/dist/worker/application/losses.js.map +1 -0
  152. package/dist/worker/application/migrate.d.ts +16 -0
  153. package/dist/worker/application/migrate.js +54 -0
  154. package/dist/worker/application/migrate.js.map +1 -0
  155. package/dist/worker/application/open-store.d.ts +31 -0
  156. package/dist/worker/application/open-store.js +60 -0
  157. package/dist/worker/application/open-store.js.map +1 -0
  158. package/dist/worker/application/seed.d.ts +14 -0
  159. package/dist/worker/application/seed.js +50 -0
  160. package/dist/worker/application/seed.js.map +1 -0
  161. package/dist/worker/application/transfer.d.ts +31 -0
  162. package/dist/worker/application/transfer.js +134 -0
  163. package/dist/worker/application/transfer.js.map +1 -0
  164. package/dist/worker/cache.d.ts +15 -0
  165. package/dist/worker/cache.js +45 -0
  166. package/dist/worker/cache.js.map +1 -0
  167. package/dist/worker/encode.d.ts +1 -0
  168. package/dist/worker/encode.js +43 -0
  169. package/dist/worker/encode.js.map +1 -0
  170. package/dist/worker/engine.d.ts +35 -0
  171. package/dist/worker/engine.js +99 -0
  172. package/dist/worker/engine.js.map +1 -0
  173. package/dist/worker/legacy-copy.d.ts +2 -0
  174. package/dist/worker/legacy-copy.js +19 -0
  175. package/dist/worker/legacy-copy.js.map +1 -0
  176. package/dist/worker/loader.d.ts +40 -0
  177. package/dist/worker/loader.js +96 -0
  178. package/dist/worker/loader.js.map +1 -0
  179. package/dist/worker/protocol.d.ts +121 -0
  180. package/dist/worker/protocol.js +2 -0
  181. package/dist/worker/protocol.js.map +1 -0
  182. package/dist/worker/store.d.ts +12 -0
  183. package/dist/worker/store.js +39 -0
  184. package/dist/worker/store.js.map +1 -0
  185. package/dist/worker/sweep.d.ts +8 -0
  186. package/dist/worker/sweep.js +21 -0
  187. package/dist/worker/sweep.js.map +1 -0
  188. package/dist/worker/worker.d.ts +1 -0
  189. package/dist/worker/worker.js +198 -0
  190. package/dist/worker/worker.js.map +1 -0
  191. package/package.json +81 -3
@@ -0,0 +1,257 @@
1
+ // Framework-neutral conformance scenarios (specs contracts/conformance.md). They drive the example pages by what a
2
+ // visitor can see: `data-rel-*` elements and attributes, links, buttons and the network. They know nothing about
3
+ // the framework that serves the pages, so an adapter passes by producing the same markup and behavior.
4
+ import assert from "node:assert/strict";
5
+ const BOTH = ["client-routing", "multi-page"];
6
+ const PAGES = "300"; // variant a of the example graph
7
+ const PAGES_B = "400"; // variant b
8
+ const text = async (page, name) => ((await page.locator(`[data-rel-${name}]`).first().textContent()) ?? "").trim();
9
+ const settled = (page, status = "ready", timeout = 60_000) => page.waitForFunction((s) => document.documentElement.dataset.relState === s, status, { timeout });
10
+ const showing = (page, name, value, timeout = 30_000) => page.waitForFunction(([n, v]) => document.querySelector(`[data-rel-${n}]`)?.textContent?.trim() === v, [name, value], { timeout });
11
+ /** Click a link and wait until the page it leads to is showing (works for a client-side swap and a full load). */
12
+ async function follow(page, label, title) {
13
+ await page.locator(`a[data-rel-link]`, { hasText: label }).first().click();
14
+ await page.waitForFunction((t) => document.querySelector("[data-rel-title]")?.textContent?.trim() === t, title);
15
+ }
16
+ export const scenarios = [
17
+ {
18
+ id: "C-01",
19
+ title: "a per-page query returns what the data implies, and links work before the graph is ready",
20
+ spec: ["US1", "FR-006", "FR-003"],
21
+ behavior: "a page's first render must not depend on the instance, and a subscription delivers the query's rows",
22
+ profiles: BOTH,
23
+ async run(ctx) {
24
+ const raw = await (await ctx.context.request.get(`${ctx.baseUrl}/page-1.html`)).text();
25
+ assert.match(raw, /data-rel-link/, "the navigation links are in the page as served, before any script runs");
26
+ assert.match(raw, /data-rel-status/, "the status placeholder is in the page as served");
27
+ const page = await ctx.open("/page-1.html");
28
+ await settled(page);
29
+ assert.equal(await text(page, "count"), PAGES, "the query result is shown");
30
+ assert.ok((await page.locator("a[data-rel-link]").count()) >= 4, "the links are present");
31
+ },
32
+ },
33
+ {
34
+ id: "C-02",
35
+ title: "the shared graph is visible from several pages without being loaded again",
36
+ spec: ["US4", "US5", "FR-020", "FR-021"],
37
+ behavior: "the graph must live as long as the profile allows: one instance per visit (client-routing) or a restore from the store (multi-page)",
38
+ profiles: BOTH,
39
+ async run(ctx) {
40
+ if (ctx.profile === "client-routing") {
41
+ const page = await ctx.open("/index.html");
42
+ await settled(page);
43
+ const instance = await text(page, "instance");
44
+ for (const [label, title] of [["Page 1", "Example site: page 1"], ["Page 2", "Example site: page 2"], ["Notes", "Example site: notes"], ["Home", "Example site: home"]]) {
45
+ await follow(page, label, title);
46
+ await showing(page, "count", PAGES);
47
+ assert.equal(await text(page, "instance"), instance, `the same instance serves ${label}`);
48
+ assert.equal(await text(page, "generation"), "1", `the generation is unchanged at ${label}`);
49
+ }
50
+ }
51
+ else {
52
+ const first = await ctx.open("/page-1.html");
53
+ await settled(first);
54
+ assert.equal(await text(first, "restored"), "false", "the first page loads the graph");
55
+ await first.close();
56
+ const requests = [];
57
+ const second = await ctx.open("/page-2.html", undefined, requests);
58
+ await settled(second);
59
+ assert.equal(await text(second, "restored"), "true", "the second page restores the graph from the store");
60
+ assert.equal(await text(second, "count"), PAGES);
61
+ assert.deepEqual(requests.filter((u) => ctx.isDataA(u)), [], "the data document is not requested again");
62
+ }
63
+ },
64
+ },
65
+ {
66
+ id: "C-03",
67
+ title: "a graph that cannot load ends in `failed`, and the page's links still work",
68
+ spec: ["US3", "FR-033", "FR-034"],
69
+ behavior: "after three failed attempts the status must be `failed`, with the failure wording shown and the page usable",
70
+ profiles: BOTH,
71
+ async run(ctx) {
72
+ const page = await ctx.open("/broken.html");
73
+ await settled(page, "failed", 90_000);
74
+ assert.match(await text(page, "failure"), /3 attempts/, "the failure wording says how many attempts were made");
75
+ assert.match(await text(page, "failure"), /report this as an issue/, "the wording suggests reporting an issue");
76
+ await follow(page, "Home", "Example site: home");
77
+ },
78
+ },
79
+ {
80
+ id: "C-04",
81
+ title: "a crash is recovered from: the instance is replaced and subscriptions re-run",
82
+ spec: ["US3", "FR-009", "FR-004"],
83
+ behavior: "subscriptions re-run after a replacement, and the page is not reloaded",
84
+ profiles: BOTH,
85
+ async run(ctx) {
86
+ const page = await ctx.open("/page-1.html");
87
+ await settled(page);
88
+ await page.evaluate(() => (window.__kept = true));
89
+ const before = Number(await text(page, "updates"));
90
+ await page.locator('[data-rel-action="trap"]').click();
91
+ await showing(page, "generation", "2", 60_000);
92
+ await settled(page);
93
+ await page.waitForFunction((n) => Number(document.querySelector("[data-rel-updates]")?.textContent) > n, before, { timeout: 30_000 });
94
+ assert.equal(await text(page, "last-error"), "trap");
95
+ assert.equal(await page.evaluate(() => window.__kept), true, "the page was not reloaded");
96
+ },
97
+ },
98
+ {
99
+ id: "C-05",
100
+ title: "a statement that exceeds its timeout fails with `timeout` and the instance is replaced",
101
+ spec: ["US3", "US6", "FR-009"],
102
+ behavior: "a call's timeout must reject it with `timeout` and replace the instance",
103
+ profiles: BOTH,
104
+ async run(ctx) {
105
+ const page = await ctx.open("/page-1.html");
106
+ await settled(page);
107
+ await page.locator('[data-rel-action="timeout"]').click();
108
+ await showing(page, "generation", "2", 60_000);
109
+ await settled(page);
110
+ assert.equal(await text(page, "last-error"), "timeout");
111
+ },
112
+ },
113
+ {
114
+ id: "C-06",
115
+ title: "a page's own data is added on arrival, dropped on departure and added again after a replacement",
116
+ spec: ["US4", "FR-026"],
117
+ behavior: "page-scoped data must be keyed to the page view: added on arrival, dropped on departure, re-added after a replacement",
118
+ profiles: BOTH,
119
+ async run(ctx) {
120
+ const page = await ctx.open("/notes.html");
121
+ await settled(page);
122
+ await showing(page, "notes", "2");
123
+ await page.locator('[data-rel-action="trap"]').click();
124
+ await showing(page, "generation", "2", 60_000);
125
+ await showing(page, "notes", "2", 60_000);
126
+ if (ctx.profile === "client-routing") {
127
+ await follow(page, "Home", "Example site: home");
128
+ await follow(page, "Notes", "Example site: notes");
129
+ await showing(page, "notes", "2");
130
+ assert.equal(await page.evaluate(async () => 0), 0);
131
+ }
132
+ else {
133
+ await page.reload();
134
+ await settled(page);
135
+ await showing(page, "notes", "2");
136
+ }
137
+ },
138
+ },
139
+ {
140
+ id: "C-07",
141
+ title: "a changed revision replaces the stored graph and shows none of the old data",
142
+ spec: ["US5", "FR-022", "FR-038", "SC-013"],
143
+ behavior: "staleness must be decided by the descriptor's revision against the revision in the cache's catalog entry, and a matching revision must not fetch the data",
144
+ profiles: ["multi-page"],
145
+ async run(ctx) {
146
+ const a = await ctx.open("/page-1.html");
147
+ await settled(a);
148
+ assert.equal(await text(a, "count"), PAGES);
149
+ await a.close();
150
+ const requests = [];
151
+ const b = await ctx.open("/page-1.html", "variant=b", requests);
152
+ await settled(b);
153
+ assert.equal(await text(b, "restored"), "false", "a new revision is loaded, not restored");
154
+ assert.equal(await text(b, "count"), PAGES_B, "only the new data is shown");
155
+ assert.ok(requests.some((u) => ctx.isDataB(u)), "the new data was fetched");
156
+ await b.close();
157
+ const again = [];
158
+ const c = await ctx.open("/page-1.html", "variant=b", again);
159
+ await settled(c);
160
+ assert.equal(await text(c, "restored"), "true", "the same revision is restored");
161
+ assert.deepEqual(again.filter((u) => ctx.isDataB(u)), [], "and the data is not fetched");
162
+ },
163
+ },
164
+ {
165
+ id: "C-08",
166
+ title: "a store held by another page falls back to an in-memory graph",
167
+ spec: ["US5", "FR-012", "SC-007"],
168
+ behavior: "a locked store must be retried for at most five seconds, then the page continues with an in-memory graph",
169
+ profiles: ["multi-page"],
170
+ async run(ctx) {
171
+ const holder = await ctx.open("/page-1.html");
172
+ await settled(holder);
173
+ const started = Date.now();
174
+ const second = await ctx.open("/page-2.html");
175
+ await settled(second, "ready", 60_000);
176
+ const elapsed = Date.now() - started;
177
+ assert.equal(await text(second, "restored"), "false", "the second page could not use the held store");
178
+ assert.equal(await text(second, "count"), PAGES);
179
+ assert.ok(elapsed >= 4500 && elapsed < 11_000, `it waited about five seconds before falling back (${elapsed} ms)`);
180
+ await second.close();
181
+ await holder.close();
182
+ const third = await ctx.open("/page-1.html");
183
+ await settled(third);
184
+ assert.equal(await text(third, "restored"), "true", "the held store was left intact");
185
+ },
186
+ },
187
+ {
188
+ id: "C-09",
189
+ title: "the configured profile decides",
190
+ spec: ["FR-028"],
191
+ behavior: "the `navigation` configuration value must decide the profile",
192
+ profiles: BOTH,
193
+ async run(ctx) {
194
+ const own = await ctx.open("/page-1.html");
195
+ await settled(own);
196
+ assert.equal(await text(own, "profile"), ctx.profile === "client-routing" ? "persistent" : "per-page");
197
+ await own.close();
198
+ const otherProfile = ctx.profile === "client-routing" ? "multi-page" : "client-routing";
199
+ const other = await ctx.context.newPage();
200
+ await other.goto(`${ctx.baseUrl}/page-1.html?navigation=${otherProfile}`);
201
+ await settled(other);
202
+ assert.equal(await text(other, "profile"), otherProfile === "client-routing" ? "persistent" : "per-page");
203
+ },
204
+ },
205
+ {
206
+ id: "C-10",
207
+ title: "data that disagrees with its descriptor is rejected and nothing is loaded",
208
+ spec: ["FR-039"],
209
+ behavior: "the loader must check the data's counts and revision against the descriptor and load nothing on a mismatch",
210
+ profiles: BOTH,
211
+ async run(ctx) {
212
+ const page = await ctx.open("/page-1.html", "variant=mismatch");
213
+ await settled(page, "failed", 90_000);
214
+ assert.notEqual(await text(page, "count"), PAGES, "no data was loaded");
215
+ assert.match(await text(page, "failure"), /mismatch|nodes/, "the failure says what disagreed");
216
+ },
217
+ },
218
+ {
219
+ id: "C-11",
220
+ title: "a store emptied while its catalog entry remains is treated as stale",
221
+ spec: ["US5", "FR-038"],
222
+ behavior: "the node count of a restored store must be checked against the descriptor's, and a difference treated as stale",
223
+ profiles: ["multi-page"],
224
+ async run(ctx) {
225
+ const first = await ctx.open("/page-1.html");
226
+ await settled(first);
227
+ await first.close();
228
+ const tool = await ctx.context.newPage();
229
+ await tool.goto(`${ctx.baseUrl}/blank.html`);
230
+ const deadline = Date.now() + 30_000;
231
+ let removed = "";
232
+ while (Date.now() < deadline && removed !== "removed") {
233
+ removed = await tool.evaluate(async () => {
234
+ try {
235
+ const root = await navigator.storage.getDirectory();
236
+ await (await root.getDirectoryHandle("relate")).removeEntry("rel-example", { recursive: true });
237
+ return "removed";
238
+ }
239
+ catch (e) {
240
+ return String(e);
241
+ }
242
+ });
243
+ if (removed !== "removed")
244
+ await tool.waitForTimeout(500);
245
+ }
246
+ assert.equal(removed, "removed", "the test could not empty the store");
247
+ await tool.close();
248
+ const requests = [];
249
+ const again = await ctx.open("/page-1.html", undefined, requests);
250
+ await settled(again);
251
+ assert.equal(await text(again, "restored"), "false", "an emptied store is not restored");
252
+ assert.equal(await text(again, "count"), PAGES);
253
+ assert.ok(requests.some((u) => ctx.isDataA(u)), "the data was fetched again");
254
+ },
255
+ },
256
+ ];
257
+ //# sourceMappingURL=scenarios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../conformance/scenarios.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,iHAAiH;AACjH,uGAAuG;AACvG,OAAO,MAAM,MAAM,oBAAoB,CAAC;AA6BxC,MAAM,IAAI,GAAc,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACzD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,iCAAiC;AACtD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,YAAY;AAEnC,MAA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E,CAAC;YAC9B,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YAClE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,kCAAkC,CAAC,CAAC;YACzF,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;YAChD,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,4BAA4B,CAAC,CAAC;QAChF,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Descriptor, GraphDocument } from "./types.js";
2
+ export type DescriptorValidationResult = {
3
+ ok: true;
4
+ descriptor: Descriptor;
5
+ } | {
6
+ ok: false;
7
+ path: string;
8
+ message: string;
9
+ };
10
+ export type AgreementResult = {
11
+ ok: true;
12
+ } | {
13
+ ok: false;
14
+ path: string;
15
+ message: string;
16
+ };
17
+ /** Check a descriptor. Reports the path of the first problem, for example `data.nodes`. */
18
+ export declare function validateDescriptor(input: unknown): DescriptorValidationResult;
19
+ /** A data document's `revision` (when it has one) and counts must equal the descriptor's (ADR-003 2.2). */
20
+ export declare function checkAgreement(descriptor: Descriptor, document: GraphDocument): AgreementResult;
@@ -0,0 +1,75 @@
1
+ // Validator for the graph descriptor (ADR-003) and the check that a descriptor and its data document agree.
2
+ import { ID_PATTERN } from "../config.js";
3
+ import { isNonEmptyString, isObject, Problem } from "./validate.js";
4
+ const isCount = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0;
5
+ /** Check a descriptor. Reports the path of the first problem, for example `data.nodes`. */
6
+ export function validateDescriptor(input) {
7
+ try {
8
+ if (!isObject(input))
9
+ throw new Problem("", "a descriptor must be an object");
10
+ for (const key of Object.keys(input)) {
11
+ if (key === "shape" || key === "embeddings")
12
+ throw new Problem(key, `"${key}" is reserved and not defined in version 1`);
13
+ if (!["version", "id", "revision", "data", "indexes"].includes(key))
14
+ throw new Problem(key, `unknown key "${key}"`);
15
+ }
16
+ if (input.version !== 1) {
17
+ throw new Problem("version", input.version === undefined ? "version is required" : `unknown descriptor version ${String(input.version)}`);
18
+ }
19
+ if (typeof input.id !== "string" || !ID_PATTERN.test(input.id)) {
20
+ throw new Problem("id", "id must be 1 to 48 characters from A-Z a-z 0-9 _ -");
21
+ }
22
+ if (!isNonEmptyString(input.revision))
23
+ throw new Problem("revision", "revision must be a non-empty string");
24
+ const data = input.data;
25
+ if (!isObject(data))
26
+ throw new Problem("data", "data must be an object");
27
+ for (const key of Object.keys(data)) {
28
+ if (!["url", "nodes", "links"].includes(key))
29
+ throw new Problem(`data.${key}`, `unknown key "${key}"`);
30
+ }
31
+ if (!isNonEmptyString(data.url))
32
+ throw new Problem("data.url", "data.url must be a non-empty string");
33
+ if (!isCount(data.nodes))
34
+ throw new Problem("data.nodes", "data.nodes must be a non-negative integer");
35
+ if (!isCount(data.links))
36
+ throw new Problem("data.links", "data.links must be a non-negative integer");
37
+ if ("indexes" in input) {
38
+ if (!Array.isArray(input.indexes))
39
+ throw new Problem("indexes", "indexes must be an array");
40
+ input.indexes.forEach((spec, i) => {
41
+ const path = `indexes[${i}]`;
42
+ if (!isObject(spec))
43
+ throw new Problem(path, "an index must be an object");
44
+ for (const key of Object.keys(spec)) {
45
+ if (key !== "label" && key !== "property")
46
+ throw new Problem(`${path}.${key}`, `unknown key "${key}"`);
47
+ }
48
+ if (!isNonEmptyString(spec.label))
49
+ throw new Problem(`${path}.label`, "label must be a non-empty string");
50
+ if (!isNonEmptyString(spec.property))
51
+ throw new Problem(`${path}.property`, "property must be a non-empty string");
52
+ });
53
+ }
54
+ return { ok: true, descriptor: input };
55
+ }
56
+ catch (e) {
57
+ if (e instanceof Problem)
58
+ return { ok: false, path: e.path, message: e.message };
59
+ throw e;
60
+ }
61
+ }
62
+ /** A data document's `revision` (when it has one) and counts must equal the descriptor's (ADR-003 2.2). */
63
+ export function checkAgreement(descriptor, document) {
64
+ if (document.revision !== undefined && document.revision !== descriptor.revision) {
65
+ return { ok: false, path: "revision", message: `the data's revision "${document.revision}" differs from the descriptor's "${descriptor.revision}"` };
66
+ }
67
+ if (document.nodes.length !== descriptor.data.nodes) {
68
+ return { ok: false, path: "nodes", message: `the data has ${document.nodes.length} nodes but the descriptor says ${descriptor.data.nodes}` };
69
+ }
70
+ if (document.links.length !== descriptor.data.links) {
71
+ return { ok: false, path: "links", message: `the data has ${document.links.length} links but the descriptor says ${descriptor.data.links}` };
72
+ }
73
+ return { ok: true };
74
+ }
75
+ //# sourceMappingURL=descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../src/data/descriptor.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQpE,MAAM,OAAO,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEpG,2FAA2F;AAC3F,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,OAAO,CAAC,EAAE,EAAE,gCAAgC,CAAC,CAAC;QAC9E,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,YA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,CAAC,KAAK,CAAC,MAAM,kCAAkC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;IAC/I,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,41 @@
1
+ export type PropertyValue = string | number | boolean | string[] | number[] | boolean[];
2
+ export type Properties = Record<string, PropertyValue>;
3
+ export interface GraphNode {
4
+ id: string;
5
+ labels?: string[];
6
+ properties?: Properties;
7
+ }
8
+ export interface GraphLink {
9
+ source: string;
10
+ target: string;
11
+ type: string;
12
+ properties?: Properties;
13
+ }
14
+ export interface GraphDocument {
15
+ version: 1;
16
+ revision?: string;
17
+ nodes: GraphNode[];
18
+ links: GraphLink[];
19
+ }
20
+ export interface IndexSpec {
21
+ label: string;
22
+ property: string;
23
+ }
24
+ export interface Descriptor {
25
+ version: 1;
26
+ id: string;
27
+ revision: string;
28
+ data: {
29
+ url: string;
30
+ nodes: number;
31
+ links: number;
32
+ };
33
+ indexes?: IndexSpec[];
34
+ }
35
+ /** The engine's result envelope, exactly as it arrives. Nothing is added or reshaped. */
36
+ export interface Envelope {
37
+ columns: string[];
38
+ rows: Array<Record<string, unknown>>;
39
+ error: string | null;
40
+ [key: string]: unknown;
41
+ }
@@ -0,0 +1,3 @@
1
+ // Shared types for graph data (ADR-002) and the descriptor (ADR-003). See specs/001-core-package/data-model.md.
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data/types.ts"],"names":[],"mappings":"AAAA,gHAAgH"}
@@ -0,0 +1,22 @@
1
+ import type { GraphDocument } from "./types.js";
2
+ export type ValidationResult = {
3
+ ok: true;
4
+ document: GraphDocument;
5
+ } | {
6
+ ok: false;
7
+ path: string;
8
+ message: string;
9
+ };
10
+ export declare class Problem extends Error {
11
+ readonly path: string;
12
+ constructor(path: string, message: string);
13
+ }
14
+ export declare const isObject: (v: unknown) => v is Record<string, unknown>;
15
+ export declare const isNonEmptyString: (v: unknown) => v is string;
16
+ /**
17
+ * Check a graph data document. Reports the path of the first problem, for example `nodes[3].properties.id`.
18
+ * With `scoped: true` a `scope` property on a node is also an error (a scoped load adds it itself).
19
+ */
20
+ export declare function validate(input: unknown, opts?: {
21
+ scoped?: boolean;
22
+ }): ValidationResult;
@@ -0,0 +1,118 @@
1
+ export class Problem extends Error {
2
+ path;
3
+ constructor(path, message) {
4
+ super(message);
5
+ this.name = "Problem";
6
+ this.path = path;
7
+ }
8
+ }
9
+ export const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
10
+ export const isNonEmptyString = (v) => typeof v === "string" && v !== "";
11
+ const finite = (v) => typeof v === "number" && Number.isFinite(v);
12
+ /** A property value is "string, finite number, boolean, or a non-empty array of one of those kinds". */
13
+ function checkPropertyValue(value, path) {
14
+ if (typeof value === "string" || typeof value === "boolean" || finite(value))
15
+ return;
16
+ if (Array.isArray(value)) {
17
+ if (value.length === 0)
18
+ throw new Problem(path, "an empty array is not a value; leave the property out");
19
+ if (value.every((v) => typeof v === "string"))
20
+ return;
21
+ if (value.every(finite))
22
+ return;
23
+ if (value.every((v) => typeof v === "boolean"))
24
+ return;
25
+ throw new Problem(path, "an array must hold only strings, only finite numbers or only booleans");
26
+ }
27
+ throw new Problem(path, "a property value must be a string, a finite number, a boolean or a non-empty array of one kind");
28
+ }
29
+ function checkProperties(value, path, options) {
30
+ if (!isObject(value))
31
+ throw new Problem(path, "properties must be an object");
32
+ for (const [key, v] of Object.entries(value)) {
33
+ const keyPath = `${path}.${key}`;
34
+ if (options.reserved.includes(key))
35
+ throw new Problem(keyPath, `"${key}" is reserved and cannot be a property`);
36
+ checkPropertyValue(v, keyPath);
37
+ }
38
+ }
39
+ function checkNode(node, path, ids, scoped) {
40
+ if (!isObject(node))
41
+ throw new Problem(path, "a node must be an object");
42
+ for (const key of Object.keys(node)) {
43
+ if (key !== "id" && key !== "labels" && key !== "properties")
44
+ throw new Problem(`${path}.${key}`, `unknown key "${key}"`);
45
+ }
46
+ if (!isNonEmptyString(node.id))
47
+ throw new Problem(`${path}.id`, "a node id must be a non-empty string");
48
+ if (ids.has(node.id))
49
+ throw new Problem(`${path}.id`, `duplicate node id "${node.id}"`);
50
+ ids.add(node.id);
51
+ if ("labels" in node) {
52
+ if (!Array.isArray(node.labels))
53
+ throw new Problem(`${path}.labels`, "labels must be an array");
54
+ const seen = new Set();
55
+ node.labels.forEach((label, j) => {
56
+ if (!isNonEmptyString(label))
57
+ throw new Problem(`${path}.labels[${j}]`, "a label must be a non-empty string");
58
+ if (seen.has(label))
59
+ throw new Problem(`${path}.labels[${j}]`, `duplicate label "${label}"`);
60
+ seen.add(label);
61
+ });
62
+ }
63
+ if ("properties" in node) {
64
+ checkProperties(node.properties, `${path}.properties`, { reserved: scoped ? ["id", "scope"] : ["id"] });
65
+ }
66
+ }
67
+ function checkLink(link, path, ids) {
68
+ if (!isObject(link))
69
+ throw new Problem(path, "a link must be an object");
70
+ for (const key of Object.keys(link)) {
71
+ if (!["source", "target", "type", "properties"].includes(key))
72
+ throw new Problem(`${path}.${key}`, `unknown key "${key}"`);
73
+ }
74
+ for (const end of ["source", "target"]) {
75
+ const id = link[end];
76
+ if (!isNonEmptyString(id))
77
+ throw new Problem(`${path}.${end}`, `a link ${end} must be a node id`);
78
+ if (!ids.has(id))
79
+ throw new Problem(`${path}.${end}`, `the ${end} "${id}" names no node in the document`);
80
+ }
81
+ if (!isNonEmptyString(link.type))
82
+ throw new Problem(`${path}.type`, "a link type must be a non-empty string");
83
+ if ("properties" in link)
84
+ checkProperties(link.properties, `${path}.properties`, { reserved: [] });
85
+ }
86
+ /**
87
+ * Check a graph data document. Reports the path of the first problem, for example `nodes[3].properties.id`.
88
+ * With `scoped: true` a `scope` property on a node is also an error (a scoped load adds it itself).
89
+ */
90
+ export function validate(input, opts = {}) {
91
+ try {
92
+ if (!isObject(input))
93
+ throw new Problem("", "a graph data document must be an object");
94
+ for (const key of Object.keys(input)) {
95
+ if (!["version", "revision", "nodes", "links"].includes(key))
96
+ throw new Problem(key, `unknown key "${key}"`);
97
+ }
98
+ if (input.version !== 1) {
99
+ throw new Problem("version", input.version === undefined ? "version is required" : `unknown format version ${String(input.version)}`);
100
+ }
101
+ if ("revision" in input && !isNonEmptyString(input.revision))
102
+ throw new Problem("revision", "revision must be a non-empty string");
103
+ if (!Array.isArray(input.nodes))
104
+ throw new Problem("nodes", "nodes must be an array");
105
+ if (!Array.isArray(input.links))
106
+ throw new Problem("links", "links must be an array");
107
+ const ids = new Set();
108
+ input.nodes.forEach((n, i) => checkNode(n, `nodes[${i}]`, ids, opts.scoped === true));
109
+ input.links.forEach((l, i) => checkLink(l, `links[${i}]`, ids));
110
+ return { ok: true, document: input };
111
+ }
112
+ catch (e) {
113
+ if (e instanceof Problem)
114
+ return { ok: false, path: e.path, message: e.message };
115
+ throw e;
116
+ }
117
+ }
118
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/data/validate.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,OAAQ,SAAQ,KAAK;IACvB,IAAI,CAAS;IACtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CACnE,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;AAE/F,MAAM,MAAM,GAAG,CA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1
+ export type Reason = "trap" | "timeout" | "lost" | "stopped" | "failed" | "unsupported" | "worker-error" | "invalid-document" | "export-loss";
2
+ /** Why a call to the client did not produce a result. Engine errors are not GraphErrors: they arrive in the envelope. */
3
+ export declare class GraphError extends Error {
4
+ readonly reason: Reason;
5
+ readonly engineError: string | undefined;
6
+ /** Set for `export-loss`: what the export format could not carry. */
7
+ losses?: import("./application/types.js").LossReport;
8
+ constructor(reason: Reason, message?: string, engineError?: string);
9
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,14 @@
1
+ /** Why a call to the client did not produce a result. Engine errors are not GraphErrors: they arrive in the envelope. */
2
+ export class GraphError extends Error {
3
+ reason;
4
+ engineError;
5
+ /** Set for `export-loss`: what the export format could not carry. */
6
+ losses;
7
+ constructor(reason, message, engineError) {
8
+ super(message ?? reason);
9
+ this.name = "GraphError";
10
+ this.reason = reason;
11
+ this.engineError = engineError;
12
+ }
13
+ }
14
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,yHAAyH;AACzH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,MAAM,CAAS;IACf,WAAW,CAAqB;IACzC,qEAAqE;IACrE,MAAM,CAA+C;IAErD,YAAY,MAAc,EAAE,OAAgB,EAAE,WAAoB;QAChE,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF"}