@superbee/core 0.2.0-pre.3 → 0.2.0-pre.5
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/dist/backend.d.ts +2 -1
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +34 -32
- package/dist/backend.js.map +1 -1
- package/dist/bundle.d.ts +2 -1
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +3 -3
- package/dist/bundle.js.map +1 -1
- package/dist/filesystem-host.d.ts +15 -0
- package/dist/filesystem-host.d.ts.map +1 -0
- package/dist/filesystem-host.js +20 -0
- package/dist/filesystem-host.js.map +1 -0
- package/dist/filesystem-identity.d.ts +6 -4
- package/dist/filesystem-identity.d.ts.map +1 -1
- package/dist/filesystem-identity.js +106 -96
- package/dist/filesystem-identity.js.map +1 -1
- package/dist/filesystem-lock.d.ts +6 -3
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +41 -56
- package/dist/filesystem-lock.js.map +1 -1
- package/dist/filesystem.d.ts +17 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +18 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/governed-body-write.d.ts +99 -0
- package/dist/governed-body-write.d.ts.map +1 -0
- package/dist/governed-body-write.js +244 -0
- package/dist/governed-body-write.js.map +1 -0
- package/dist/host-policy-snapshot.d.ts +9 -0
- package/dist/host-policy-snapshot.d.ts.map +1 -0
- package/dist/host-policy-snapshot.js +33 -0
- package/dist/host-policy-snapshot.js.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +23 -6
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +395 -115
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +148 -9
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +209 -5
- package/dist/journaled-backend.js.map +1 -1
- package/dist/remote-backend.d.ts +9 -54
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +13 -173
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-error.d.ts +22 -0
- package/dist/remote-error.d.ts.map +1 -0
- package/dist/remote-error.js +29 -0
- package/dist/remote-error.js.map +1 -0
- package/dist/remote-parsers.d.ts +86 -0
- package/dist/remote-parsers.d.ts.map +1 -0
- package/dist/remote-parsers.js +181 -0
- package/dist/remote-parsers.js.map +1 -0
- package/dist/remote.d.ts +5 -2
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +5 -1
- package/dist/remote.js.map +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/uncertain-write.d.ts +4 -2
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +6 -3
- package/dist/uncertain-write.js.map +1 -1
- package/package.json +10 -2
|
@@ -32,13 +32,25 @@
|
|
|
32
32
|
* holding intent between the refusal and the rewrite.
|
|
33
33
|
* - `resolveIntents` on either journaled mutation requires document CAS and the exact complete
|
|
34
34
|
* unsettled target journal. It retires those records atomically with the document, meta, and
|
|
35
|
-
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire a
|
|
36
|
+
* chain whose head is a recorded conflict or refusal, with conflicted, refused, and
|
|
37
|
+
* never-attempted pending successors behind it, never uncertain delivery. The caller
|
|
38
|
+
* preserves recovery evidence in meta; retirement does not assert remote acceptance.
|
|
38
39
|
* - {@link JournaledBackend.readWithJournal} is ONE snapshot: the document, every intent
|
|
39
40
|
* targeting it, and the named meta rows, read in one readonly transaction, so a write in
|
|
40
41
|
* another realm between separate reads can never show a caller a document of one moment
|
|
41
42
|
* beside a journal of another. Intents come back in local commit order (by `sequence`).
|
|
43
|
+
* - {@link JournaledBackend.readHeads} is that snapshot over every document at once: each
|
|
44
|
+
* record's head (id, version, writer, time), its leading frontmatter parsed as `read` parses
|
|
45
|
+
* it, its exact bytes, every intent targeting it, and the meta rows the caller names for it,
|
|
46
|
+
* all from ONE readonly transaction, so every row describes the same moment. Bodies are
|
|
47
|
+
* never parsed. A record whose leading block does not parse is a row with `frontmatter`
|
|
48
|
+
* null and the parser's error, never a dropped row and never a failed listing. A caller that
|
|
49
|
+
* keeps less than the row (a version and a provenance, say) passes `project`, which maps
|
|
50
|
+
* each row as it is read so the listing over a large store never holds every document's
|
|
51
|
+
* stored bytes at once; the journal is read whole before the walk, so intents and the
|
|
52
|
+
* content they carry are held for its duration, as a single read holds them. Keys every row
|
|
53
|
+
* needs go in `shared`, read once. Rows come back in the order `list` orders ids.
|
|
42
54
|
* - {@link JournaledBackend.updateIntent} is a compare-and-swap on the intent's `state`: the
|
|
43
55
|
* patch applies only while the record is in `expectedState`, together with any meta rows, in
|
|
44
56
|
* one transaction. A different state or a missing record rejects with
|
|
@@ -53,6 +65,192 @@
|
|
|
53
65
|
* the shipping implementation; a test-only in-memory adapter proves the seam is not a
|
|
54
66
|
* description of that one class.
|
|
55
67
|
*/
|
|
68
|
+
import { assertSafeConceptId } from "./paths.js";
|
|
69
|
+
/** A full snapshot or metadata admission premise changed; nothing was written. */
|
|
70
|
+
export class JournalGuardConflict extends Error {
|
|
71
|
+
name = "JournalGuardConflict";
|
|
72
|
+
target;
|
|
73
|
+
constructor(target) {
|
|
74
|
+
super(`journal guard for '${target}' does not match or is invalid`);
|
|
75
|
+
this.target = target;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Guard values are acyclic plain records, arrays, and primitive values (including undefined).
|
|
80
|
+
* Symbols, accessors, functions, and objects with other prototypes are refused. This restriction
|
|
81
|
+
* applies only to guarded operations; the unguarded metadata store remains opaque.
|
|
82
|
+
*/
|
|
83
|
+
export function captureJournalValue(value) {
|
|
84
|
+
const ancestors = new Set();
|
|
85
|
+
const check = (entry) => {
|
|
86
|
+
if (typeof entry === "function" || typeof entry === "symbol")
|
|
87
|
+
throw new JournalGuardConflict("value");
|
|
88
|
+
if (entry === null || typeof entry !== "object")
|
|
89
|
+
return;
|
|
90
|
+
if (ancestors.has(entry) || (!Array.isArray(entry) && Object.getPrototypeOf(entry) !== Object.prototype && Object.getPrototypeOf(entry) !== null))
|
|
91
|
+
throw new JournalGuardConflict("value");
|
|
92
|
+
ancestors.add(entry);
|
|
93
|
+
for (const key of Reflect.ownKeys(entry)) {
|
|
94
|
+
if (typeof key !== "string")
|
|
95
|
+
throw new JournalGuardConflict("value");
|
|
96
|
+
const descriptor = Object.getOwnPropertyDescriptor(entry, key);
|
|
97
|
+
if (!("value" in descriptor) || (!descriptor.enumerable && !(Array.isArray(entry) && key === "length")))
|
|
98
|
+
throw new JournalGuardConflict("value");
|
|
99
|
+
check(descriptor.value);
|
|
100
|
+
}
|
|
101
|
+
ancestors.delete(entry);
|
|
102
|
+
};
|
|
103
|
+
check(value);
|
|
104
|
+
return structuredClone(value);
|
|
105
|
+
}
|
|
106
|
+
function equalJournalValue(a, b) {
|
|
107
|
+
if (Object.is(a, b))
|
|
108
|
+
return true;
|
|
109
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object" || Array.isArray(a) !== Array.isArray(b))
|
|
110
|
+
return false;
|
|
111
|
+
if (Array.isArray(a) && a.length !== b.length)
|
|
112
|
+
return false;
|
|
113
|
+
const keys = Object.keys(a);
|
|
114
|
+
return keys.length === Object.keys(b).length && keys.every(key => Object.hasOwn(b, key) && equalJournalValue(a[key], b[key]));
|
|
115
|
+
}
|
|
116
|
+
function assertMetaExpectation(value) {
|
|
117
|
+
if (!value || typeof value !== "object" || typeof value.present !== "boolean" ||
|
|
118
|
+
!equalJournalValue(Object.keys(value).sort(), (value.present ? ["present", "value"] : ["present"]).sort()))
|
|
119
|
+
throw new JournalGuardConflict("meta");
|
|
120
|
+
}
|
|
121
|
+
export function captureJournalGuard(value, target) {
|
|
122
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
123
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
124
|
+
const guard = captureJournalValue(value);
|
|
125
|
+
if (typeof guard.target !== "string")
|
|
126
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
127
|
+
target ??= guard.target;
|
|
128
|
+
assertSafeConceptId(guard.target);
|
|
129
|
+
if (guard.target !== target || !Array.isArray(guard.intents) || !Array.isArray(guard.meta) ||
|
|
130
|
+
(guard.document !== null && (!guard.document || typeof guard.document.version !== "string" || typeof guard.document.raw !== "string")))
|
|
131
|
+
throw new JournalGuardConflict(target);
|
|
132
|
+
const requests = new Set(), sequences = new Set(), keys = new Set();
|
|
133
|
+
for (const row of guard.intents) {
|
|
134
|
+
if (!row || row.target !== target || typeof row.requestId !== "string" || requests.has(row.requestId) || !Number.isSafeInteger(row.sequence) || sequences.has(row.sequence))
|
|
135
|
+
throw new JournalGuardConflict(target);
|
|
136
|
+
requests.add(row.requestId);
|
|
137
|
+
sequences.add(row.sequence);
|
|
138
|
+
}
|
|
139
|
+
for (const row of guard.meta) {
|
|
140
|
+
if (!row || typeof row.key !== "string" || keys.has(row.key))
|
|
141
|
+
throw new JournalGuardConflict(target);
|
|
142
|
+
keys.add(row.key);
|
|
143
|
+
assertMetaExpectation(row.expected);
|
|
144
|
+
}
|
|
145
|
+
return guard;
|
|
146
|
+
}
|
|
147
|
+
/** Only omission or undefined selects the unguarded compatibility path. */
|
|
148
|
+
export function captureJournalGuardOption(options, target) {
|
|
149
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, "guard");
|
|
150
|
+
if (!descriptor) {
|
|
151
|
+
if ("guard" in options)
|
|
152
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
if (!("value" in descriptor))
|
|
156
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
157
|
+
return descriptor.value === undefined ? undefined : captureJournalGuard(descriptor.value, target);
|
|
158
|
+
}
|
|
159
|
+
/** Compare all target records, including acknowledged history, and exact named row presence. */
|
|
160
|
+
export function assertJournalGuard(expected, current) {
|
|
161
|
+
const a = captureJournalGuard(expected), b = captureJournalGuard(current, a.target);
|
|
162
|
+
a.intents.sort((x, y) => x.sequence - y.sequence);
|
|
163
|
+
b.intents.sort((x, y) => x.sequence - y.sequence);
|
|
164
|
+
a.meta.sort((x, y) => x.key.localeCompare(y.key));
|
|
165
|
+
b.meta.sort((x, y) => x.key.localeCompare(y.key));
|
|
166
|
+
if (!equalJournalValue(a, b))
|
|
167
|
+
throw new JournalGuardConflict(a.target);
|
|
168
|
+
}
|
|
169
|
+
/** Capture guarded updates before any asynchronous adapter work and protect original history. */
|
|
170
|
+
export function captureIntentUpdate(patch, options) {
|
|
171
|
+
const guard = captureJournalGuardOption(options);
|
|
172
|
+
if (guard !== undefined)
|
|
173
|
+
captureJournalValue({ patch, options });
|
|
174
|
+
if (options.document && guard === undefined)
|
|
175
|
+
throw new JournalGuardConflict(options.document.id);
|
|
176
|
+
const captured = structuredClone({ patch, options });
|
|
177
|
+
if (guard !== undefined) {
|
|
178
|
+
captured.options.guard = guard;
|
|
179
|
+
const mutable = new Set(["state", "attempts", "acknowledgedVersion", "remote", "refusal", "finding", "updatedAt"]);
|
|
180
|
+
if (Object.keys(patch).some(key => !mutable.has(key)) || (captured.options.document && captured.options.document.id !== captured.options.guard.target))
|
|
181
|
+
throw new JournalGuardConflict(captured.options.guard.target);
|
|
182
|
+
assertJournalMetaChanges(captured.options.guard, captured.options.meta ?? [], undefined);
|
|
183
|
+
}
|
|
184
|
+
return captured;
|
|
185
|
+
}
|
|
186
|
+
export function captureMetaWrite(options) {
|
|
187
|
+
const result = captureJournalValue(options);
|
|
188
|
+
if (Object.hasOwn(result, "expected"))
|
|
189
|
+
assertMetaExpectation(result.expected);
|
|
190
|
+
if (result.requireEmptyJournal !== undefined && typeof result.requireEmptyJournal !== "boolean")
|
|
191
|
+
throw new JournalGuardConflict("meta");
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
export function assertMetaWrite(key, options, actual, intents) {
|
|
195
|
+
if (options.expected !== undefined && !equalJournalValue(captureJournalValue(options.expected), captureJournalValue(actual)))
|
|
196
|
+
throw new JournalGuardConflict(key);
|
|
197
|
+
if (options.requireEmptyJournal && intents.length !== 0)
|
|
198
|
+
throw new JournalGuardConflict(key);
|
|
199
|
+
}
|
|
200
|
+
/** Metadata removal is admitted only with an explicit full-snapshot premise. */
|
|
201
|
+
export function assertJournalMetaChanges(guard, puts, removals) {
|
|
202
|
+
if (guard) {
|
|
203
|
+
captureJournalValue(puts);
|
|
204
|
+
if (puts.some(row => !guard.meta.some(expected => expected.key === row.key)))
|
|
205
|
+
throw new JournalGuardConflict(guard.target);
|
|
206
|
+
}
|
|
207
|
+
if (removals === undefined)
|
|
208
|
+
return;
|
|
209
|
+
if (!guard || !Array.isArray(removals) || removals.some(key => typeof key !== "string") || new Set(removals).size !== removals.length ||
|
|
210
|
+
removals.some(key => puts.some(row => row.key === key) || !guard.meta.some(expected => expected.key === key)))
|
|
211
|
+
throw new JournalGuardConflict(guard?.target ?? "meta");
|
|
212
|
+
}
|
|
213
|
+
/** A guarded write owns one target and creates a globally fresh journal identity. */
|
|
214
|
+
export function assertJournalIntentChanges(guard, existingIdentity, superseded) {
|
|
215
|
+
if (guard && (existingIdentity !== undefined || (superseded !== undefined && superseded.target !== guard.target)))
|
|
216
|
+
throw new JournalGuardConflict(guard.target);
|
|
217
|
+
}
|
|
218
|
+
/** Capture write options while retaining the existing synchronous metadata producer. */
|
|
219
|
+
export function captureJournalWriteOptions(options) {
|
|
220
|
+
const descriptors = Object.getOwnPropertyDescriptors(options);
|
|
221
|
+
const data = {};
|
|
222
|
+
let producer;
|
|
223
|
+
for (const key of Reflect.ownKeys(options)) {
|
|
224
|
+
if (typeof key !== "string")
|
|
225
|
+
throw new JournalGuardConflict("options");
|
|
226
|
+
const descriptor = descriptors[key];
|
|
227
|
+
if (!("value" in descriptor) || !descriptor.enumerable)
|
|
228
|
+
throw new JournalGuardConflict("options");
|
|
229
|
+
if (key === "meta" && typeof descriptor.value === "function")
|
|
230
|
+
producer = descriptor.value;
|
|
231
|
+
else
|
|
232
|
+
data[key] = descriptor.value;
|
|
233
|
+
}
|
|
234
|
+
const captured = captureJournalValue(data);
|
|
235
|
+
if (producer)
|
|
236
|
+
captured.meta = producer;
|
|
237
|
+
return captured;
|
|
238
|
+
}
|
|
239
|
+
/** Capture every guarded deletion branch before evaluating held or absent state. */
|
|
240
|
+
export function captureJournalDeleteOptions(target, options) {
|
|
241
|
+
const guard = captureJournalGuardOption(options, target);
|
|
242
|
+
if (guard === undefined)
|
|
243
|
+
return options;
|
|
244
|
+
const captured = captureJournalValue(options);
|
|
245
|
+
captured.guard = guard;
|
|
246
|
+
assertJournalMetaChanges(guard, captured.meta ?? [], captured.removeMeta);
|
|
247
|
+
if (captured.onHeld !== undefined) {
|
|
248
|
+
if (!captured.onHeld || !Array.isArray(captured.onHeld.meta))
|
|
249
|
+
throw new JournalGuardConflict(target);
|
|
250
|
+
assertJournalMetaChanges(guard, captured.onHeld.meta, undefined);
|
|
251
|
+
}
|
|
252
|
+
return captured;
|
|
253
|
+
}
|
|
56
254
|
/**
|
|
57
255
|
* An intent's journal state was not the one the caller expected, or the intent is gone. Settling
|
|
58
256
|
* and superseding are compare-and-swap operations on the intent's own record so two realms (a
|
|
@@ -108,7 +306,12 @@ export function assertJournalResolutionOptions(target, options) {
|
|
|
108
306
|
throw new JournalSnapshotConflict(target);
|
|
109
307
|
}
|
|
110
308
|
}
|
|
111
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* Compare full records, not only state: a changed outcome or retry is new recovery evidence.
|
|
311
|
+
* The head of the set (its lowest sequence) must hold a recorded terminal answer, `conflict` or
|
|
312
|
+
* `refused`; every later row must be `conflict`, `refused` or never-attempted `pending`. An
|
|
313
|
+
* `unknown`, `in_flight` or attempted `pending` head is uncertain delivery and stays refused.
|
|
314
|
+
*/
|
|
112
315
|
export function assertJournalSnapshot(target, expected, current, freshRequestId) {
|
|
113
316
|
const equal = (a, b) => {
|
|
114
317
|
if (Object.is(a, b))
|
|
@@ -121,8 +324,9 @@ export function assertJournalSnapshot(target, expected, current, freshRequestId)
|
|
|
121
324
|
};
|
|
122
325
|
const actual = current.filter(row => row.target === target && row.state !== "acknowledged");
|
|
123
326
|
const ids = new Set(expected.map(row => row.requestId));
|
|
327
|
+
const head = expected.reduce((lowest, row) => lowest === undefined || row.sequence < lowest.sequence ? row : lowest, undefined);
|
|
124
328
|
if ((freshRequestId !== undefined && current.some(row => row.requestId === freshRequestId)) ||
|
|
125
|
-
ids.size !== expected.length || actual.length !== expected.length || !
|
|
329
|
+
ids.size !== expected.length || actual.length !== expected.length || head === undefined || !(head.state === "conflict" || head.state === "refused") ||
|
|
126
330
|
expected.some(row => row.target !== target || !(row.state === "conflict" || row.state === "refused" || (row.state === "pending" && row.attempts === 0))) ||
|
|
127
331
|
expected.some(row => !equal(row, actual.find(candidate => candidate.requestId === row.requestId)))) {
|
|
128
332
|
throw new JournalSnapshotConflict(target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journaled-backend.js","sourceRoot":"","sources":["../src/journaled-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAKH;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC1B,IAAI,GAAG,qBAAqB,CAAC;IACtC,SAAS,CAAS;IAClB,QAAQ,CAAiB;IACzB,MAAM,CAAwB;IAEvC,YAAY,SAAiB,EAAE,QAAwB,EAAE,MAA6B;QACpF,KAAK,CACH,MAAM,KAAK,IAAI;YACb,CAAC,CAAC,WAAW,SAAS,qCAAqC,QAAQ,IAAI;YACvE,CAAC,CAAC,WAAW,S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AAC;QACxJ,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACvG,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/dist/remote-backend.d.ts
CHANGED
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
* This module touches NO filesystem and parses NO markdown — like {@link MemoryBackend},
|
|
41
41
|
* it proves the engine leaks no assumptions beyond the {@link StorageBackend} contract.
|
|
42
42
|
*/
|
|
43
|
-
import { type
|
|
43
|
+
import { type HeadsResult, type RemoteSnapshot } from "./remote-parsers.js";
|
|
44
44
|
import { type Outcome } from "./uncertain-write.js";
|
|
45
|
-
import type { BlobKey, ConceptId, DeleteOptions,
|
|
45
|
+
import type { BlobKey, ConceptId, DeleteOptions, HeadResult, OkfDocument, QueryFilter, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageBackend, Version, VersionInfo, WriteOptions } from "./types.js";
|
|
46
46
|
/**
|
|
47
47
|
* An injectable fetch-like transport: given a `Request`, resolve a `Response`. This
|
|
48
48
|
* is exactly the shape {@link createRouter} (in `@superbee/server`) returns,
|
|
@@ -75,20 +75,7 @@ export interface RemoteBackendOptions {
|
|
|
75
75
|
*/
|
|
76
76
|
maxRetries?: number;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
* A non-2xx wire response that is neither a `404` (ENOENT-shaped) nor a `412`
|
|
80
|
-
* ({@link VersionConflict}) — the generic case, carrying the error envelope's `code` alongside
|
|
81
|
-
* the raw HTTP `status`, so a caller can distinguish e.g.
|
|
82
|
-
* `AUTH_REQUIRED` (401, an unauthenticated/misconfigured `--remote`) from `RUNTIME` (5xx, a
|
|
83
|
-
* genuine server-side bug) instead of both collapsing into a generically-classified `Error`.
|
|
84
|
-
*/
|
|
85
|
-
export declare class RemoteError extends Error {
|
|
86
|
-
/** The envelope's `code` field, or a status-derived guess when the envelope is missing/unparseable. */
|
|
87
|
-
readonly code: string;
|
|
88
|
-
/** The raw HTTP status that produced this error. */
|
|
89
|
-
readonly status: number;
|
|
90
|
-
constructor(message: string, code: string, status: number, cause?: unknown);
|
|
91
|
-
}
|
|
78
|
+
export { RemoteError } from "./remote-error.js";
|
|
92
79
|
/** The deployment-scoped capability booleans a wire authority reports (`docs/WIRE-PROTOCOL.md`). */
|
|
93
80
|
export interface WireCapabilities {
|
|
94
81
|
history: boolean;
|
|
@@ -108,38 +95,6 @@ export interface HeadsOptions {
|
|
|
108
95
|
/** A digest from an earlier `heads` or `snapshot` answer; the authority answers `304` when it still holds it. */
|
|
109
96
|
ifNoneMatch?: string;
|
|
110
97
|
}
|
|
111
|
-
/** A `200` from `GET /heads`: every document id and version, and the digest over them. */
|
|
112
|
-
export interface HeadsResult {
|
|
113
|
-
digest: string;
|
|
114
|
-
heads: DocumentHead[];
|
|
115
|
-
}
|
|
116
|
-
/** The snapshot's first line: how many documents follow and the digest `heads` would return for this state. */
|
|
117
|
-
export interface SnapshotHeader {
|
|
118
|
-
count: number;
|
|
119
|
-
digest: string;
|
|
120
|
-
}
|
|
121
|
-
/** One `doc` line of a snapshot. */
|
|
122
|
-
export interface SnapshotDocument {
|
|
123
|
-
id: ConceptId;
|
|
124
|
-
version: Version;
|
|
125
|
-
frontmatter: Frontmatter;
|
|
126
|
-
body: string;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* A snapshot as {@link RemoteBackend.snapshot} hands it over: the header, already parsed, and
|
|
130
|
-
* the documents as they stream. Iterating `docs` to completion is the completeness signal: the
|
|
131
|
-
* loop ends only after the `end` line arrived with the announced count and the digest recomputed
|
|
132
|
-
* over the received `{ id, version }` rows equals the header's, and it throws
|
|
133
|
-
* `SNAPSHOT_TRUNCATED` (the body ended or failed first) or `SNAPSHOT_DIGEST_MISMATCH` (the body
|
|
134
|
-
* was whole but describes a state the header did not announce) otherwise, so a consumer that
|
|
135
|
-
* writes batches as they arrive has one control path and never needs to inspect a terminator
|
|
136
|
-
* or a digest itself. A consumer records the header digest as matched only after the loop
|
|
137
|
-
* ended normally.
|
|
138
|
-
*/
|
|
139
|
-
export interface RemoteSnapshot {
|
|
140
|
-
header: SnapshotHeader;
|
|
141
|
-
docs: AsyncIterable<SnapshotDocument>;
|
|
142
|
-
}
|
|
143
98
|
/**
|
|
144
99
|
* The client half of the wire-protocol v0 contract: implements {@link StorageBackend}
|
|
145
100
|
* over HTTP against a `@superbee/server` instance (or any conformant
|
|
@@ -176,10 +131,9 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
176
131
|
* `200` is diffed against the caller's own copy: an id missing from `heads` was deleted, a
|
|
177
132
|
* differing version changed. A `200` without a well-formed digest, whose `count` and rows
|
|
178
133
|
* disagree, or whose rows digest by the documented recipe to something other than the served
|
|
179
|
-
* digest, is rejected rather than trusted
|
|
180
|
-
* `
|
|
181
|
-
*
|
|
182
|
-
* diffed as a mass deletion. Not part of the {@link StorageBackend} seam.
|
|
134
|
+
* digest, is rejected rather than trusted ({@link parseHeadsAnswer} owns that admission), as
|
|
135
|
+
* is a `304` to a request that sent no `ifNoneMatch`. Not part of the {@link StorageBackend}
|
|
136
|
+
* seam.
|
|
183
137
|
*/
|
|
184
138
|
heads(options?: HeadsOptions): Promise<HeadsResult | null>;
|
|
185
139
|
/**
|
|
@@ -188,8 +142,9 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
188
142
|
* the documents then stream through {@link RemoteSnapshot.docs}. Transient retry applies only
|
|
189
143
|
* to obtaining the response: a body cut mid-stream is reported to the consumer as
|
|
190
144
|
* `SNAPSHOT_TRUNCATED`, a whole body whose heads do not digest to the header's announcement as
|
|
191
|
-
* `SNAPSHOT_DIGEST_MISMATCH
|
|
192
|
-
* not part of a snapshot. Not part of the
|
|
145
|
+
* `SNAPSHOT_DIGEST_MISMATCH` ({@link readSnapshotStream} owns the grammar), and re-requesting
|
|
146
|
+
* is the consumer's decision. Reserved files are not part of a snapshot. Not part of the
|
|
147
|
+
* {@link StorageBackend} seam.
|
|
193
148
|
*/
|
|
194
149
|
snapshot(): Promise<RemoteSnapshot>;
|
|
195
150
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;
|
|
1
|
+
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAMH,OAAO,EAA4D,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,aAAa,EAEb,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAC;AAWpB;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEhE,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,yGAAyG;IACzG,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,uGAAuG;IACvG,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,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AC;IAmBnB,8FAA8F;IACxF,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAYvE,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ1C,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAiBrD"}
|
package/dist/remote-backend.js
CHANGED
|
@@ -43,29 +43,14 @@
|
|
|
43
43
|
import { DEFAULT_BLOB_CONTENT_TYPE } from "./content-type.js";
|
|
44
44
|
import { InvalidInputError } from "./errors.js";
|
|
45
45
|
import { encodeRemoteDocument } from "./remote-document-codec.js";
|
|
46
|
-
import {
|
|
46
|
+
import { RemoteError, malformed } from "./remote-error.js";
|
|
47
|
+
import { SNAPSHOT_TRUNCATED, parseHeadsAnswer, readSnapshotStream } from "./remote-parsers.js";
|
|
47
48
|
import { assertSafeBlobKey, assertSafeConceptId, assertSafeReservedDir, assertSafeReservedFilename, compareStorageKeys } from "./paths.js";
|
|
48
49
|
import { isRequestIdentity } from "./uncertain-write.js";
|
|
49
50
|
import { VersionConflict, stripETagWrapper } from "./version-transport.js";
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* the raw HTTP `status`, so a caller can distinguish e.g.
|
|
54
|
-
* `AUTH_REQUIRED` (401, an unauthenticated/misconfigured `--remote`) from `RUNTIME` (5xx, a
|
|
55
|
-
* genuine server-side bug) instead of both collapsing into a generically-classified `Error`.
|
|
56
|
-
*/
|
|
57
|
-
export class RemoteError extends Error {
|
|
58
|
-
/** The envelope's `code` field, or a status-derived guess when the envelope is missing/unparseable. */
|
|
59
|
-
code;
|
|
60
|
-
/** The raw HTTP status that produced this error. */
|
|
61
|
-
status;
|
|
62
|
-
constructor(message, code, status, cause) {
|
|
63
|
-
super(message, cause === undefined ? undefined : { cause });
|
|
64
|
-
this.name = "RemoteError";
|
|
65
|
-
this.code = code;
|
|
66
|
-
this.status = status;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
51
|
+
// The typed rejection lives in `remote-error.ts`, shared with the heads and snapshot parsers this
|
|
52
|
+
// backend calls; it stays importable from here for every existing consumer.
|
|
53
|
+
export { RemoteError } from "./remote-error.js";
|
|
69
54
|
/** An ENOENT-shaped rejection so missing-document handling matches the local adapters. */
|
|
70
55
|
function notFound(id) {
|
|
71
56
|
const err = new Error(`no concept document '${id}'`);
|
|
@@ -124,129 +109,10 @@ function assertRequestIdentity(requestId) {
|
|
|
124
109
|
}
|
|
125
110
|
/** The lookup route's `200` body: a recorded outcome, never `unknown`. */
|
|
126
111
|
const RECORDED_OUTCOME_KINDS = new Set(["committed", "conflict", "refused"]);
|
|
127
|
-
/** A snapshot body that ended, or failed, before its terminator arrived with the announced count. */
|
|
128
|
-
const SNAPSHOT_TRUNCATED = "SNAPSHOT_TRUNCATED";
|
|
129
|
-
/**
|
|
130
|
-
* A snapshot whose body arrived whole, with its terminator and the announced count, but whose
|
|
131
|
-
* rows digest to something other than the header announced. Not truncation: re-requesting will
|
|
132
|
-
* not necessarily repair it, since the authority contradicted itself. A consumer discards the
|
|
133
|
-
* documents' claim to the header digest either way.
|
|
134
|
-
*/
|
|
135
|
-
const SNAPSHOT_DIGEST_MISMATCH = "SNAPSHOT_DIGEST_MISMATCH";
|
|
136
|
-
function isDocumentHead(value) {
|
|
137
|
-
if (typeof value !== "object" || value === null)
|
|
138
|
-
return false;
|
|
139
|
-
const head = value;
|
|
140
|
-
return typeof head.id === "string" && typeof head.version === "string";
|
|
141
|
-
}
|
|
142
|
-
/** A wire payload the authority produced but the contract does not admit: not retried, not truncation. */
|
|
143
|
-
function malformed(message) {
|
|
144
|
-
return new RemoteError(message, "RUNTIME", 502);
|
|
145
|
-
}
|
|
146
112
|
/** Quote a bare digest for `If-None-Match`; an already quoted or weak form passes through. */
|
|
147
113
|
function etagForm(token) {
|
|
148
114
|
return token.startsWith('"') || token.startsWith("W/") ? token : `"${token}"`;
|
|
149
115
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Split a response body into its NDJSON lines as they arrive, decoding UTF-8 across chunk
|
|
152
|
-
* boundaries. Only `TextDecoder` and the Web Streams reader are used, so the same code runs in a
|
|
153
|
-
* browser. A partial trailing line at the end of the body is a cut line and is not yielded; a
|
|
154
|
-
* transport failure while reading is reported as truncation, since either way the terminator
|
|
155
|
-
* never arrived. Leaving the loop early cancels the reader so the connection is released.
|
|
156
|
-
*/
|
|
157
|
-
async function* ndjsonLines(body, status) {
|
|
158
|
-
const reader = body.getReader();
|
|
159
|
-
const decoder = new TextDecoder();
|
|
160
|
-
let buffered = "";
|
|
161
|
-
try {
|
|
162
|
-
for (;;) {
|
|
163
|
-
let chunk;
|
|
164
|
-
try {
|
|
165
|
-
chunk = await reader.read();
|
|
166
|
-
}
|
|
167
|
-
catch (cause) {
|
|
168
|
-
throw new RemoteError("snapshot body failed before its end line arrived", SNAPSHOT_TRUNCATED, status, cause);
|
|
169
|
-
}
|
|
170
|
-
buffered += decoder.decode(chunk.value, { stream: !chunk.done });
|
|
171
|
-
let start = 0;
|
|
172
|
-
for (let newline = buffered.indexOf("\n"); newline !== -1; newline = buffered.indexOf("\n", start)) {
|
|
173
|
-
yield buffered.slice(start, newline);
|
|
174
|
-
start = newline + 1;
|
|
175
|
-
}
|
|
176
|
-
buffered = buffered.slice(start);
|
|
177
|
-
if (chunk.done)
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
await reader.cancel().catch(() => undefined);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function parseSnapshotLine(line) {
|
|
186
|
-
let record;
|
|
187
|
-
try {
|
|
188
|
-
record = JSON.parse(line);
|
|
189
|
-
}
|
|
190
|
-
catch {
|
|
191
|
-
throw malformed("snapshot line is not JSON");
|
|
192
|
-
}
|
|
193
|
-
if (typeof record !== "object" || record === null)
|
|
194
|
-
throw malformed("snapshot line is not a JSON object");
|
|
195
|
-
return record;
|
|
196
|
-
}
|
|
197
|
-
function parseSnapshotHeader(line) {
|
|
198
|
-
const record = parseSnapshotLine(line);
|
|
199
|
-
if (record.kind !== "snapshot")
|
|
200
|
-
throw malformed("snapshot did not begin with its header line");
|
|
201
|
-
if (typeof record.count !== "number" || !Number.isInteger(record.count) || record.count < 0) {
|
|
202
|
-
throw malformed("snapshot header carries no document count");
|
|
203
|
-
}
|
|
204
|
-
if (!isHeadsDigest(record.digest))
|
|
205
|
-
throw malformed("snapshot header carries no well-formed digest");
|
|
206
|
-
return { count: record.count, digest: record.digest };
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* The document lines of a snapshot, ending normally only at an `end` line whose count equals
|
|
210
|
-
* both the header's announcement and the documents actually seen, and only when the digest
|
|
211
|
-
* recomputed over the received heads equals the header's. Anything else is a rejection: a body
|
|
212
|
-
* that ends first is `SNAPSHOT_TRUNCATED`; a whole body whose heads digest differently is
|
|
213
|
-
* `SNAPSHOT_DIGEST_MISMATCH`; a line the contract does not admit is malformed. The digest is the
|
|
214
|
-
* client's own check of the listing it is about to trust: a count and a terminator say the body
|
|
215
|
-
* is whole, only the recipe says it is the state the header named.
|
|
216
|
-
*/
|
|
217
|
-
async function* snapshotDocuments(lines, header, status) {
|
|
218
|
-
let seen = 0;
|
|
219
|
-
const received = [];
|
|
220
|
-
for await (const line of lines) {
|
|
221
|
-
const record = parseSnapshotLine(line);
|
|
222
|
-
if (record.kind === "doc") {
|
|
223
|
-
if (typeof record.id !== "string" || typeof record.version !== "string" || typeof record.body !== "string") {
|
|
224
|
-
throw malformed("snapshot doc line lacks id, version, or body");
|
|
225
|
-
}
|
|
226
|
-
if (typeof record.frontmatter !== "object" || record.frontmatter === null || Array.isArray(record.frontmatter)) {
|
|
227
|
-
throw malformed("snapshot doc line lacks a frontmatter object");
|
|
228
|
-
}
|
|
229
|
-
seen += 1;
|
|
230
|
-
if (seen > header.count)
|
|
231
|
-
throw malformed(`snapshot delivered more than the ${header.count} announced document(s)`);
|
|
232
|
-
received.push({ id: record.id, version: record.version });
|
|
233
|
-
yield { id: record.id, version: record.version, frontmatter: record.frontmatter, body: record.body };
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (record.kind === "end") {
|
|
237
|
-
if (record.count !== seen || seen !== header.count) {
|
|
238
|
-
throw new RemoteError(`snapshot end line counts ${String(record.count)} document(s), but ${seen} of ${header.count} announced arrived`, SNAPSHOT_TRUNCATED, status);
|
|
239
|
-
}
|
|
240
|
-
const recomputed = headsDigest(received);
|
|
241
|
-
if (recomputed !== header.digest) {
|
|
242
|
-
throw new RemoteError(`snapshot header announced digest ${header.digest}, but its ${seen} document(s) digest to ${recomputed}`, SNAPSHOT_DIGEST_MISMATCH, status);
|
|
243
|
-
}
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
throw malformed(`snapshot line has unexpected kind ${JSON.stringify(record.kind)}`);
|
|
247
|
-
}
|
|
248
|
-
throw new RemoteError(`snapshot ended after ${seen} of ${header.count} document(s) without its end line`, SNAPSHOT_TRUNCATED, status);
|
|
249
|
-
}
|
|
250
116
|
/**
|
|
251
117
|
* Transient HTTP statuses worth retrying: 500 (a Cloudflare D1 cold-start surfaces as a 500
|
|
252
118
|
* "storage caused object to be reset" the first time a hibernated database is hit), plus the edge
|
|
@@ -478,10 +344,9 @@ export class RemoteBackend {
|
|
|
478
344
|
* `200` is diffed against the caller's own copy: an id missing from `heads` was deleted, a
|
|
479
345
|
* differing version changed. A `200` without a well-formed digest, whose `count` and rows
|
|
480
346
|
* disagree, or whose rows digest by the documented recipe to something other than the served
|
|
481
|
-
* digest, is rejected rather than trusted
|
|
482
|
-
* `
|
|
483
|
-
*
|
|
484
|
-
* diffed as a mass deletion. Not part of the {@link StorageBackend} seam.
|
|
347
|
+
* digest, is rejected rather than trusted ({@link parseHeadsAnswer} owns that admission), as
|
|
348
|
+
* is a `304` to a request that sent no `ifNoneMatch`. Not part of the {@link StorageBackend}
|
|
349
|
+
* seam.
|
|
485
350
|
*/
|
|
486
351
|
async heads(options = {}) {
|
|
487
352
|
const headers = {};
|
|
@@ -497,21 +362,7 @@ export class RemoteBackend {
|
|
|
497
362
|
}
|
|
498
363
|
if (!res.ok)
|
|
499
364
|
throw await this.toError(res, "heads");
|
|
500
|
-
|
|
501
|
-
if (!isHeadsDigest(payload?.digest))
|
|
502
|
-
throw malformed("wire heads answered without a well-formed digest");
|
|
503
|
-
if (!Array.isArray(payload.heads) || !payload.heads.every(isDocumentHead)) {
|
|
504
|
-
throw malformed("wire heads answered without a heads array of { id, version } rows");
|
|
505
|
-
}
|
|
506
|
-
if (payload.count !== payload.heads.length) {
|
|
507
|
-
throw malformed(`wire heads count ${String(payload.count)} disagrees with its ${payload.heads.length} row(s)`);
|
|
508
|
-
}
|
|
509
|
-
const heads = payload.heads.map(({ id, version }) => ({ id, version }));
|
|
510
|
-
const recomputed = headsDigest(heads);
|
|
511
|
-
if (recomputed !== payload.digest) {
|
|
512
|
-
throw malformed(`wire heads served digest ${payload.digest}, but its ${heads.length} row(s) digest to ${recomputed}`);
|
|
513
|
-
}
|
|
514
|
-
return { digest: payload.digest, heads };
|
|
365
|
+
return parseHeadsAnswer(await res.json());
|
|
515
366
|
}
|
|
516
367
|
/**
|
|
517
368
|
* `GET /snapshot`: the whole bundle in one response. The header line is parsed before this
|
|
@@ -519,8 +370,9 @@ export class RemoteBackend {
|
|
|
519
370
|
* the documents then stream through {@link RemoteSnapshot.docs}. Transient retry applies only
|
|
520
371
|
* to obtaining the response: a body cut mid-stream is reported to the consumer as
|
|
521
372
|
* `SNAPSHOT_TRUNCATED`, a whole body whose heads do not digest to the header's announcement as
|
|
522
|
-
* `SNAPSHOT_DIGEST_MISMATCH
|
|
523
|
-
* not part of a snapshot. Not part of the
|
|
373
|
+
* `SNAPSHOT_DIGEST_MISMATCH` ({@link readSnapshotStream} owns the grammar), and re-requesting
|
|
374
|
+
* is the consumer's decision. Reserved files are not part of a snapshot. Not part of the
|
|
375
|
+
* {@link StorageBackend} seam.
|
|
524
376
|
*/
|
|
525
377
|
async snapshot() {
|
|
526
378
|
const res = await this.send("/snapshot", { method: "GET" });
|
|
@@ -528,19 +380,7 @@ export class RemoteBackend {
|
|
|
528
380
|
throw await this.toError(res, "snapshot");
|
|
529
381
|
if (!res.body)
|
|
530
382
|
throw new RemoteError("snapshot response carried no body", SNAPSHOT_TRUNCATED, res.status);
|
|
531
|
-
|
|
532
|
-
const first = await lines.next();
|
|
533
|
-
if (first.done)
|
|
534
|
-
throw new RemoteError("snapshot ended before its header line", SNAPSHOT_TRUNCATED, res.status);
|
|
535
|
-
let header;
|
|
536
|
-
try {
|
|
537
|
-
header = parseSnapshotHeader(first.value);
|
|
538
|
-
}
|
|
539
|
-
catch (err) {
|
|
540
|
-
await lines.return(undefined);
|
|
541
|
-
throw err;
|
|
542
|
-
}
|
|
543
|
-
return { header, docs: snapshotDocuments(lines, header, res.status) };
|
|
383
|
+
return readSnapshotStream(res.body, { status: res.status });
|
|
544
384
|
}
|
|
545
385
|
/**
|
|
546
386
|
* `GET /operations/{requestId}`: the authority's recorded outcome for an identified write, or
|