@superbee/core 0.2.0-pre.1 → 0.2.0-pre.3
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.map +1 -1
- package/dist/backend.js +9 -6
- package/dist/backend.js.map +1 -1
- package/dist/document-codec.d.ts +1 -0
- package/dist/document-codec.d.ts.map +1 -1
- package/dist/document-codec.js +1 -0
- package/dist/document-codec.js.map +1 -1
- package/dist/frontmatter.d.ts +8 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +14 -4
- package/dist/frontmatter.js.map +1 -1
- package/dist/heads-digest.d.ts +32 -0
- package/dist/heads-digest.d.ts.map +1 -0
- package/dist/heads-digest.js +37 -0
- package/dist/heads-digest.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +12 -2
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +120 -6
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +83 -1
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +54 -0
- package/dist/journaled-backend.js.map +1 -1
- package/dist/memory-backend.d.ts +2 -2
- package/dist/memory-backend.d.ts.map +1 -1
- package/dist/memory-backend.js +27 -15
- package/dist/memory-backend.js.map +1 -1
- package/dist/paths.d.ts +6 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +35 -33
- package/dist/paths.js.map +1 -1
- package/dist/platform.d.ts +77 -6
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +9 -4
- package/dist/platform.js.map +1 -1
- package/dist/remote-backend.d.ts +66 -2
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +207 -6
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-document-codec.d.ts +15 -0
- package/dist/remote-document-codec.d.ts.map +1 -0
- package/dist/remote-document-codec.js +103 -0
- package/dist/remote-document-codec.js.map +1 -0
- package/dist/remote-operations.d.ts +3 -1
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +6 -1
- package/dist/remote-operations.js.map +1 -1
- package/dist/remote.d.ts +3 -1
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +1 -0
- package/dist/remote.js.map +1 -1
- package/dist/storage.d.ts +4 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -1
- package/dist/storage.js.map +1 -1
- package/package.json +1 -1
package/dist/memory-backend.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* - per-write ACTOR attribution recorded on every revision;
|
|
13
13
|
* - a real batch {@link MemoryBackend.readMany}.
|
|
14
14
|
*
|
|
15
|
-
* It touches NO filesystem and
|
|
16
|
-
*
|
|
15
|
+
* It touches NO filesystem — bodies and YAML metadata snapshots are held in memory,
|
|
16
|
+
* keyed by concept id — so running the
|
|
17
17
|
* core operations over it exercises exactly the parts of the engine that must be
|
|
18
18
|
* backend-neutral. Version tokens are still content-addressed via {@link contentVersion},
|
|
19
19
|
* so an engine-written document carries the SAME token here as on disk.
|
|
@@ -25,12 +25,10 @@
|
|
|
25
25
|
* the dual-backend / wire-protocol contract tests diverge.
|
|
26
26
|
*/
|
|
27
27
|
import { resolveContentType } from "./content-type.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return structuredClone(value);
|
|
33
|
-
}
|
|
28
|
+
import { readBundleOkfVersion } from "./engine.js";
|
|
29
|
+
import { MalformedDocumentError, parseFrontmatter, stringifyFrontmatter, stringifyWithSerializedFrontmatter } from "./frontmatter.js";
|
|
30
|
+
import { assertSafeBlobKey, assertSafeConceptId, assertSafeReservedDir, assertSafeReservedFilename, compareStorageKeys } from "./paths.js";
|
|
31
|
+
import { blobVersion, defaultActor, VersionConflict, versionOfBytes } from "./versioning.js";
|
|
34
32
|
/** An ENOENT-shaped rejection so missing-document handling matches {@link FilesystemBackend}. */
|
|
35
33
|
function notFound(id) {
|
|
36
34
|
const err = new Error(`no concept document '${id}'`);
|
|
@@ -39,8 +37,7 @@ function notFound(id) {
|
|
|
39
37
|
}
|
|
40
38
|
/** Bundle-relative key for a reserved file (`""` = bundle root), mirroring the fs adapter's layout. */
|
|
41
39
|
function reservedKey(dir, name) {
|
|
42
|
-
|
|
43
|
-
return d === "" ? name : `${d}/${name}`;
|
|
40
|
+
return dir === "" ? name : `${dir}/${name}`;
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
43
|
* A fully in-memory OKF store implementing the {@link StorageBackend} contract for
|
|
@@ -61,7 +58,18 @@ export class MemoryBackend {
|
|
|
61
58
|
const head = this.chains.get(id)?.[0];
|
|
62
59
|
if (!head)
|
|
63
60
|
throw notFound(id);
|
|
64
|
-
|
|
61
|
+
let okfVersion;
|
|
62
|
+
try {
|
|
63
|
+
okfVersion = await readBundleOkfVersion(this);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (!(error instanceof MalformedDocumentError))
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
doc: { ...head.doc, frontmatter: parseFrontmatter(head.frontmatterSource, id, { okfVersion }) },
|
|
71
|
+
version: head.version,
|
|
72
|
+
};
|
|
65
73
|
}
|
|
66
74
|
async readMany(ids) {
|
|
67
75
|
// Validate every id up front (same contract as FilesystemBackend.readMany), then a
|
|
@@ -82,7 +90,8 @@ export class MemoryBackend {
|
|
|
82
90
|
// that route id on reads because document bytes do not serialize `doc.id`; mirror them here
|
|
83
91
|
// instead of retaining a mismatched caller-supplied `doc.id` in the in-memory snapshot.
|
|
84
92
|
const storedDoc = { ...doc, id };
|
|
85
|
-
const
|
|
93
|
+
const frontmatterSource = stringifyFrontmatter(storedDoc.frontmatter);
|
|
94
|
+
const version = versionOfBytes(stringifyWithSerializedFrontmatter(frontmatterSource, storedDoc.body));
|
|
86
95
|
// Idempotent: re-writing byte-identical content is a no-op that does not grow the
|
|
87
96
|
// chain (the content address is unchanged). A genuine content change appends a revision.
|
|
88
97
|
if (current === version)
|
|
@@ -93,7 +102,8 @@ export class MemoryBackend {
|
|
|
93
102
|
timestamp: new Date().toISOString(),
|
|
94
103
|
// Unlike `actor`, an unattested agent is simply absent — no default is applied.
|
|
95
104
|
agent: options.agent?.trim() || undefined,
|
|
96
|
-
|
|
105
|
+
frontmatterSource,
|
|
106
|
+
doc: { id, body: storedDoc.body },
|
|
97
107
|
};
|
|
98
108
|
this.chains.set(id, chain ? [revision, ...chain] : [revision]);
|
|
99
109
|
return version;
|
|
@@ -120,7 +130,7 @@ export class MemoryBackend {
|
|
|
120
130
|
}
|
|
121
131
|
async list(prefix) {
|
|
122
132
|
const ids = [...this.chains.keys()].filter((id) => !prefix || id.startsWith(prefix));
|
|
123
|
-
ids.sort(
|
|
133
|
+
ids.sort(compareStorageKeys);
|
|
124
134
|
return ids;
|
|
125
135
|
}
|
|
126
136
|
async versions(id) {
|
|
@@ -133,6 +143,7 @@ export class MemoryBackend {
|
|
|
133
143
|
}
|
|
134
144
|
async readReserved(dir, name) {
|
|
135
145
|
assertSafeReservedDir(dir);
|
|
146
|
+
assertSafeReservedFilename(name);
|
|
136
147
|
const content = this.reserved.get(reservedKey(dir, name));
|
|
137
148
|
if (content === undefined)
|
|
138
149
|
return null;
|
|
@@ -141,6 +152,7 @@ export class MemoryBackend {
|
|
|
141
152
|
}
|
|
142
153
|
async writeReserved(dir, name, content, options = {}) {
|
|
143
154
|
assertSafeReservedDir(dir);
|
|
155
|
+
assertSafeReservedFilename(name);
|
|
144
156
|
const key = reservedKey(dir, name);
|
|
145
157
|
const existing = this.reserved.get(key);
|
|
146
158
|
const current = existing === undefined ? null : versionOfBytes(existing);
|
|
@@ -207,7 +219,7 @@ export class MemoryBackend {
|
|
|
207
219
|
}
|
|
208
220
|
async listBlobs(prefix) {
|
|
209
221
|
const keys = [...this.blobs.keys()].filter((k) => !prefix || k.startsWith(prefix));
|
|
210
|
-
keys.sort(
|
|
222
|
+
keys.sort(compareStorageKeys);
|
|
211
223
|
return keys;
|
|
212
224
|
}
|
|
213
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-backend.js","sourceRoot":"","sources":["../src/memory-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"memory-backend.js","sourceRoot":"","sources":["../src/memory-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,MAAM,kBAAkB,CAAC;AACtI,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3I,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAyC7F,iGAAiG;AACjG,SAAS,QAAQ,CAAC,EAAa;IAC7B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAA0B,CAAC;IAC9E,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC;IACpB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uGAAuG;AACvG,SAAS,WAAW,CAAC,GAAW,EAAE,IAAsB;IACtD,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,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OAAO,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAY;QAC3B,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAe;QAC7B,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/paths.d.ts
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
import type { ConceptId } from "./types.js";
|
|
12
12
|
/** The two OKF reserved filenames, valid at any directory level (§3.1). */
|
|
13
13
|
export declare const RESERVED_FILENAMES: readonly ["index.md", "log.md"];
|
|
14
|
+
/** Keep locale ordering, but never let distinct spellings depend on insertion order. */
|
|
15
|
+
export declare function compareStorageKeys(a: string, b: string): number;
|
|
16
|
+
/** Runtime callers must obey the same finite reserved-name type as TypeScript callers. */
|
|
17
|
+
export declare function assertSafeReservedFilename(name: unknown): asserts name is typeof RESERVED_FILENAMES[number];
|
|
14
18
|
/** Normalize any separators to forward slashes and collapse duplicate slashes. */
|
|
15
19
|
export declare function toPosix(p: string): string;
|
|
16
20
|
/**
|
|
@@ -71,8 +75,8 @@ export declare function assertSafeBlobKey(key: string): void;
|
|
|
71
75
|
* Guard a reserved-file directory (the `dir` argument to `readReserved`/`writeReserved`,
|
|
72
76
|
* where `""` denotes the bundle root) against path traversal / absolute escape before it
|
|
73
77
|
* is joined onto the bundle root. Unlike {@link assertSafeConceptId}, an empty string IS
|
|
74
|
-
* valid here (it means "the bundle root itself").
|
|
75
|
-
*
|
|
78
|
+
* valid here (it means "the bundle root itself"). Other spellings must be canonical;
|
|
79
|
+
* aliases are rejected rather than silently normalized.
|
|
76
80
|
*/
|
|
77
81
|
export declare function assertSafeReservedDir(dir: string): void;
|
|
78
82
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,iCAAkC,CAAC;AAElE,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,iCAAkC,CAAC;AAElE,wFAAwF;AACxF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS/D;AAYD,0FAA0F;AAC1F,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAI3G;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAWvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAgBnD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKvD"}
|
package/dist/paths.js
CHANGED
|
@@ -11,6 +11,34 @@
|
|
|
11
11
|
import { InvalidInputError } from "./errors.js";
|
|
12
12
|
/** The two OKF reserved filenames, valid at any directory level (§3.1). */
|
|
13
13
|
export const RESERVED_FILENAMES = ["index.md", "log.md"];
|
|
14
|
+
/** Keep locale ordering, but never let distinct spellings depend on insertion order. */
|
|
15
|
+
export function compareStorageKeys(a, b) {
|
|
16
|
+
const primary = a.localeCompare(b);
|
|
17
|
+
if (primary !== 0 || a === b)
|
|
18
|
+
return primary;
|
|
19
|
+
const left = Array.from(a, (character) => character.codePointAt(0));
|
|
20
|
+
const right = Array.from(b, (character) => character.codePointAt(0));
|
|
21
|
+
for (let i = 0; i < Math.min(left.length, right.length); i++) {
|
|
22
|
+
if (left[i] !== right[i])
|
|
23
|
+
return left[i] - right[i];
|
|
24
|
+
}
|
|
25
|
+
return left.length - right.length;
|
|
26
|
+
}
|
|
27
|
+
/** Reject spellings that cannot remain the same key across storage and wire adapters. */
|
|
28
|
+
function assertPortablePath(value, label) {
|
|
29
|
+
if (/[\u0000-\u001f\u007f]/u.test(value) || /^[a-z]:/i.test(value)) {
|
|
30
|
+
throw new InvalidInputError(`${label} must not contain controls or start with a drive prefix.`);
|
|
31
|
+
}
|
|
32
|
+
if (value.includes("\\") || value.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
33
|
+
throw new InvalidInputError(`${label} must be canonical and bundle-relative.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Runtime callers must obey the same finite reserved-name type as TypeScript callers. */
|
|
37
|
+
export function assertSafeReservedFilename(name) {
|
|
38
|
+
if (!RESERVED_FILENAMES.includes(name)) {
|
|
39
|
+
throw new InvalidInputError("Reserved filename must be index.md or log.md.");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
14
42
|
/** Normalize any separators to forward slashes and collapse duplicate slashes. */
|
|
15
43
|
export function toPosix(p) {
|
|
16
44
|
return p.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
@@ -58,19 +86,8 @@ export function assertSafeConceptId(id) {
|
|
|
58
86
|
if (typeof id !== "string" || id.trim() === "") {
|
|
59
87
|
throw new InvalidInputError("Concept id must be a non-empty string.");
|
|
60
88
|
}
|
|
61
|
-
|
|
62
|
-
throw new InvalidInputError(`Concept id must be bundle-relative, got absolute '${id}'.`);
|
|
63
|
-
}
|
|
64
|
-
if (id.includes("\\")) {
|
|
65
|
-
throw new InvalidInputError(`Concept id must use forward slashes: '${id}'.`);
|
|
66
|
-
}
|
|
89
|
+
assertPortablePath(id, "Concept id");
|
|
67
90
|
const segments = id.split("/");
|
|
68
|
-
if (segments.some((seg) => seg === "..")) {
|
|
69
|
-
throw new InvalidInputError(`Concept id must not contain '..' segments: '${id}'.`);
|
|
70
|
-
}
|
|
71
|
-
if (segments.some((seg) => seg === "." || seg === "")) {
|
|
72
|
-
throw new InvalidInputError(`Concept id must be canonical (no '.', duplicate-slash, leading './', or trailing-slash segments): '${id}'.`);
|
|
73
|
-
}
|
|
74
91
|
if (segments.slice(0, -1).some((seg) => seg.toLowerCase().endsWith(".md"))) {
|
|
75
92
|
throw new InvalidInputError(`Concept id must not contain a non-final segment ending in '.md': '${id}' (it collides with a concept file at that path).`);
|
|
76
93
|
}
|
|
@@ -105,21 +122,11 @@ export function assertSafeBlobKey(key) {
|
|
|
105
122
|
if (typeof key !== "string" || key.trim() === "") {
|
|
106
123
|
throw new InvalidInputError("Blob key must be a non-empty string.");
|
|
107
124
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw new InvalidInputError(`Blob key must be bundle-relative, got absolute '${key}'.`);
|
|
111
|
-
}
|
|
112
|
-
const segments = norm.split("/");
|
|
113
|
-
if (segments.some((seg) => seg === "..")) {
|
|
114
|
-
throw new InvalidInputError(`Blob key must not contain '..' segments: '${key}'.`);
|
|
115
|
-
}
|
|
125
|
+
assertPortablePath(key, "Blob key");
|
|
126
|
+
const segments = key.split("/");
|
|
116
127
|
if (segments.some((seg) => seg.startsWith("."))) {
|
|
117
128
|
throw new InvalidInputError(`Blob key must not contain dot-prefixed segments: '${key}'.`);
|
|
118
129
|
}
|
|
119
|
-
const last = segments[segments.length - 1] ?? "";
|
|
120
|
-
if (last === "") {
|
|
121
|
-
throw new InvalidInputError(`Blob key must name a file, not end with '/': '${key}'.`);
|
|
122
|
-
}
|
|
123
130
|
if (segments.some((seg) => seg.toLowerCase().endsWith(".md"))) {
|
|
124
131
|
throw new InvalidInputError(`Blob key '${key}' has a path segment ending in '.md' (checked case-insensitively, at ` +
|
|
125
132
|
`any depth), which collides with the concept-document namespace — write it as a doc ` +
|
|
@@ -130,19 +137,14 @@ export function assertSafeBlobKey(key) {
|
|
|
130
137
|
* Guard a reserved-file directory (the `dir` argument to `readReserved`/`writeReserved`,
|
|
131
138
|
* where `""` denotes the bundle root) against path traversal / absolute escape before it
|
|
132
139
|
* is joined onto the bundle root. Unlike {@link assertSafeConceptId}, an empty string IS
|
|
133
|
-
* valid here (it means "the bundle root itself").
|
|
134
|
-
*
|
|
140
|
+
* valid here (it means "the bundle root itself"). Other spellings must be canonical;
|
|
141
|
+
* aliases are rejected rather than silently normalized.
|
|
135
142
|
*/
|
|
136
143
|
export function assertSafeReservedDir(dir) {
|
|
137
144
|
if (typeof dir !== "string") {
|
|
138
145
|
throw new InvalidInputError("Reserved-file directory must be a string.");
|
|
139
146
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
throw new InvalidInputError(`Reserved-file directory must be bundle-relative, got absolute '${dir}'.`);
|
|
143
|
-
}
|
|
144
|
-
if (norm.split("/").some((seg) => seg === "..")) {
|
|
145
|
-
throw new InvalidInputError(`Reserved-file directory must not contain '..' segments: '${dir}'.`);
|
|
146
|
-
}
|
|
147
|
+
if (dir !== "")
|
|
148
|
+
assertPortablePath(dir, "Reserved-file directory");
|
|
147
149
|
}
|
|
148
150
|
//# sourceMappingURL=paths.js.map
|
package/dist/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAU,CAAC;AAElE,
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAU,CAAC;AAElE,wFAAwF;AACxF,MAAM,UAAU,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qDAAqD,GAAG,IAAI,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,iBAAiB,CACzB,aAAa,GAAG,uEAAuE;YACrF,qFAAqF;YACrF,UAAU,CACb,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,iBAAiB,CAAC,2CAA2C,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,GAAG,KAAK,EAAE;QAAE,kBAAkB,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -17,10 +17,15 @@
|
|
|
17
17
|
* presentation can report shared confirmation without an acknowledgement. It says nothing
|
|
18
18
|
* about what the authority holds now: request-driven's last exchange is the request itself,
|
|
19
19
|
* browser-local's is its last sync, and the authority may have moved (or deleted the document)
|
|
20
|
-
* since.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* since. A document the authority deleted disappears from a browser-local working copy at
|
|
21
|
+
* its next sync (pull reconciles deletions against the authority's heads) unless a local
|
|
22
|
+
* edit holds it, in which case pull retains the local content and rewrites its base to an
|
|
23
|
+
* absent shared version, and the document reads `local-pending` until push delivers the edit
|
|
24
|
+
* and settles the authority's conflict answer (a 412 whose actual version is `null`) as a
|
|
25
|
+
* conflict against an absent remote, from which point it reads `local-conflict` with
|
|
26
|
+
* `remote: null`; request-driven answers absence directly. Between syncs a deleted document
|
|
27
|
+
* still reads `shared-confirmed` at its last served version, so a presentation must not read
|
|
28
|
+
* `shared-confirmed` as proof of present existence.
|
|
24
29
|
* - `local-pending`: the working copy holds a local edit the authority has not accepted;
|
|
25
30
|
* `requestId` names the journaled intent that will deliver it and `base` the shared version
|
|
26
31
|
* the edit was made against.
|
|
@@ -111,6 +116,62 @@ export interface PlatformCommit {
|
|
|
111
116
|
changed: boolean;
|
|
112
117
|
provenance: Provenance;
|
|
113
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Why a browser-local sync applied none of the deletions a verified listing implied:
|
|
121
|
+
* `empty-listing` names no document while the working copy holds some, `over-half` names so
|
|
122
|
+
* few that more than half of the working copy would go. Only a listing that would remove at
|
|
123
|
+
* least eight documents is bounded; fewer are applied on the authority's word.
|
|
124
|
+
*/
|
|
125
|
+
export type RefusedDeletionsReason = "empty-listing" | "over-half";
|
|
126
|
+
/**
|
|
127
|
+
* The deletions a browser-local sync refused to apply, exactly as recorded on its last pull.
|
|
128
|
+
* `digest` names the listing that implied them; a caller that has judged the shrink genuine
|
|
129
|
+
* passes the record back as {@link PlatformSyncOptions.acceptRefusedDeletions}.
|
|
130
|
+
*/
|
|
131
|
+
export interface RefusedDeletions {
|
|
132
|
+
/** How many documents the listing would have removed from the working copy. */
|
|
133
|
+
deletions: number;
|
|
134
|
+
reason: RefusedDeletionsReason;
|
|
135
|
+
/** The heads digest of the listing that was refused. */
|
|
136
|
+
digest: string;
|
|
137
|
+
}
|
|
138
|
+
/** How the runtime's last sync ended; see {@link PlatformSyncStatus.lastSync}. */
|
|
139
|
+
export interface PlatformSyncOutcome {
|
|
140
|
+
/** False when the sync rejected (a carrier failure, or an authority answer the runtime could not apply). */
|
|
141
|
+
ok: boolean;
|
|
142
|
+
/** The rejection's `name: message` when `ok` is false. */
|
|
143
|
+
error?: string;
|
|
144
|
+
/** The deletions the last completed pull refused; present until a pull applies or clears them. */
|
|
145
|
+
refusedDeletions?: RefusedDeletions;
|
|
146
|
+
}
|
|
147
|
+
export interface PlatformSyncOptions {
|
|
148
|
+
/**
|
|
149
|
+
* The refusal the last sync reported (`lastSync.refusedDeletions`), passed back to say the
|
|
150
|
+
* shrink it describes is genuine. Browser-local applies the deletions only when the
|
|
151
|
+
* authority's current listing still carries the same digest, count and reason; a listing
|
|
152
|
+
* that has moved since is refused afresh. Request-driven ignores it: nothing is ever
|
|
153
|
+
* refused there.
|
|
154
|
+
*/
|
|
155
|
+
acceptRefusedDeletions?: RefusedDeletions;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The runtime's relation to the authority as of its last exchange. `online` reports the
|
|
159
|
+
* carrier: it turns false only when a request could not reach the authority, never on an
|
|
160
|
+
* answer the authority gave. `lastSync` reports the sync verb itself, and is the field a
|
|
161
|
+
* presentation must show to distinguish "synchronized" from "tried and failed": `ok` is false
|
|
162
|
+
* whenever `sync` rejected, whatever the cause, with the rejection's text in `error`.
|
|
163
|
+
*
|
|
164
|
+
* Browser-local applies a verified heads listing on the authority's word, including the
|
|
165
|
+
* documents it no longer names, with one bound: a listing that would remove at least eight
|
|
166
|
+
* documents and more than half of the working copy (or every document) is refused as a whole.
|
|
167
|
+
* The refreshes in that sync still apply, nothing is removed, `lastSync.ok` stays true, and
|
|
168
|
+
* `lastSync.refusedDeletions` carries the refusal until a later pull applies or clears it. A
|
|
169
|
+
* genuine shrink of that size therefore never reconciles on its own; the recovery path is to
|
|
170
|
+
* pass the recorded refusal back as `sync({ acceptRefusedDeletions })`, which applies the
|
|
171
|
+
* deletions if the authority still lists the same state and refuses afresh if it has moved.
|
|
172
|
+
* Request-driven has no working copy and leaves `lastSync` undefined: the status is the answer
|
|
173
|
+
* to the request that produced it.
|
|
174
|
+
*/
|
|
114
175
|
export interface PlatformSyncStatus {
|
|
115
176
|
mode: ExecutionMode;
|
|
116
177
|
/** Whether the last request to the authority succeeded; `null` before any was made. */
|
|
@@ -131,6 +192,12 @@ export interface PlatformSyncStatus {
|
|
|
131
192
|
pausedReason?: string;
|
|
132
193
|
/** The runtime's working set is complete: the authority's for request-driven, a finished bootstrap for browser-local. */
|
|
133
194
|
complete: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* How the last sync ended, and any deletions its pull refused. Browser-local fills it from
|
|
197
|
+
* the sync's own outcome and the pull marker (so a refusal recorded before this runtime was
|
|
198
|
+
* created still shows); request-driven leaves it undefined. Absent before any sync.
|
|
199
|
+
*/
|
|
200
|
+
lastSync?: PlatformSyncOutcome;
|
|
134
201
|
}
|
|
135
202
|
export interface PlatformRuntime {
|
|
136
203
|
capabilities(): PlatformCapabilities;
|
|
@@ -141,8 +208,12 @@ export interface PlatformRuntime {
|
|
|
141
208
|
validate(id: ConceptId): Promise<PlatformValidation>;
|
|
142
209
|
commit(id: ConceptId, edit: PlatformEdit): Promise<PlatformCommit>;
|
|
143
210
|
syncStatus(): Promise<PlatformSyncStatus>;
|
|
144
|
-
/**
|
|
145
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Push pending work and pull the authority's changes; a no-op returning the status in
|
|
213
|
+
* request-driven mode. `options` carries the recovery path for refused deletions; see
|
|
214
|
+
* {@link PlatformSyncOptions}.
|
|
215
|
+
*/
|
|
216
|
+
sync(options?: PlatformSyncOptions): Promise<PlatformSyncStatus>;
|
|
146
217
|
}
|
|
147
218
|
/** The word a presentation shows for a provenance. */
|
|
148
219
|
export declare function provenanceLabel(provenance: Provenance): ProvenanceLabel;
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,gEAAgE;A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@
|
|
|
17
17
|
* presentation can report shared confirmation without an acknowledgement. It says nothing
|
|
18
18
|
* about what the authority holds now: request-driven's last exchange is the request itself,
|
|
19
19
|
* browser-local's is its last sync, and the authority may have moved (or deleted the document)
|
|
20
|
-
* since.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* since. A document the authority deleted disappears from a browser-local working copy at
|
|
21
|
+
* its next sync (pull reconciles deletions against the authority's heads) unless a local
|
|
22
|
+
* edit holds it, in which case pull retains the local content and rewrites its base to an
|
|
23
|
+
* absent shared version, and the document reads `local-pending` until push delivers the edit
|
|
24
|
+
* and settles the authority's conflict answer (a 412 whose actual version is `null`) as a
|
|
25
|
+
* conflict against an absent remote, from which point it reads `local-conflict` with
|
|
26
|
+
* `remote: null`; request-driven answers absence directly. Between syncs a deleted document
|
|
27
|
+
* still reads `shared-confirmed` at its last served version, so a presentation must not read
|
|
28
|
+
* `shared-confirmed` as proof of present existence.
|
|
24
29
|
* - `local-pending`: the working copy holds a local edit the authority has not accepted;
|
|
25
30
|
* `requestId` names the journaled intent that will deliver it and `base` the shared version
|
|
26
31
|
* the edit was made against.
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AA2KH,sDAAsD;AACtD,MAAM,UAAU,eAAe,CAAC,UAAsB;IACpD,QAAQ,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,kBAAkB;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,eAAe;YAClB,OAAO,SAAS,CAAC;QACnB,KAAK,gBAAgB;YACnB,OAAO,UAAU,CAAC;IACtB,CAAC;AACH,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,iBAAiB,CAAC,UAAsB;IACtD,OAAO,UAAU,CAAC,KAAK,KAAK,kBAAkB,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB,EAAE,eAAwB,OAAO;IAC/E,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAoB,EAAE,SAAiB;IACpF,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,IAAoB,EAAE,MAAsB,EAAE,SAAiB;IAC7G,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACvE,CAAC"}
|
package/dist/remote-backend.d.ts
CHANGED
|
@@ -40,8 +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 DocumentHead } from "./heads-digest.js";
|
|
43
44
|
import { type Outcome } from "./uncertain-write.js";
|
|
44
|
-
import type { BlobKey, ConceptId, DeleteOptions, HeadResult, OkfDocument, QueryFilter, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageBackend, Version, VersionInfo, WriteOptions } from "./types.js";
|
|
45
|
+
import type { BlobKey, ConceptId, DeleteOptions, Frontmatter, HeadResult, OkfDocument, QueryFilter, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageBackend, Version, VersionInfo, WriteOptions } from "./types.js";
|
|
45
46
|
/**
|
|
46
47
|
* An injectable fetch-like transport: given a `Request`, resolve a `Response`. This
|
|
47
48
|
* is exactly the shape {@link createRouter} (in `@superbee/server`) returns,
|
|
@@ -86,7 +87,7 @@ export declare class RemoteError extends Error {
|
|
|
86
87
|
readonly code: string;
|
|
87
88
|
/** The raw HTTP status that produced this error. */
|
|
88
89
|
readonly status: number;
|
|
89
|
-
constructor(message: string, code: string, status: number);
|
|
90
|
+
constructor(message: string, code: string, status: number, cause?: unknown);
|
|
90
91
|
}
|
|
91
92
|
/** The deployment-scoped capability booleans a wire authority reports (`docs/WIRE-PROTOCOL.md`). */
|
|
92
93
|
export interface WireCapabilities {
|
|
@@ -97,6 +98,47 @@ export interface WireCapabilities {
|
|
|
97
98
|
blobs: boolean;
|
|
98
99
|
/** Whether document writes carrying `Idempotency-Key` are recorded and readable by lookup. */
|
|
99
100
|
operations: boolean;
|
|
101
|
+
/** Whether `GET /heads` answers every document id and version under one digest, with `304`. */
|
|
102
|
+
heads: boolean;
|
|
103
|
+
/** Whether `GET /snapshot` streams every document as terminated NDJSON. */
|
|
104
|
+
snapshot: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** Options for {@link RemoteBackend.heads}. */
|
|
107
|
+
export interface HeadsOptions {
|
|
108
|
+
/** A digest from an earlier `heads` or `snapshot` answer; the authority answers `304` when it still holds it. */
|
|
109
|
+
ifNoneMatch?: string;
|
|
110
|
+
}
|
|
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>;
|
|
100
142
|
}
|
|
101
143
|
/**
|
|
102
144
|
* The client half of the wire-protocol v0 contract: implements {@link StorageBackend}
|
|
@@ -128,6 +170,28 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
128
170
|
* sends any intent. Missing booleans read as `false`.
|
|
129
171
|
*/
|
|
130
172
|
wireCapabilities(): Promise<WireCapabilities>;
|
|
173
|
+
/**
|
|
174
|
+
* `GET /heads`: every document id and version the authority holds, under one digest, or
|
|
175
|
+
* `null` when `ifNoneMatch` named the digest it still holds (a `304`: nothing changed). A
|
|
176
|
+
* `200` is diffed against the caller's own copy: an id missing from `heads` was deleted, a
|
|
177
|
+
* differing version changed. A `200` without a well-formed digest, whose `count` and rows
|
|
178
|
+
* disagree, or whose rows digest by the documented recipe to something other than the served
|
|
179
|
+
* digest, is rejected rather than trusted, as is a `304` to a request that sent no
|
|
180
|
+
* `ifNoneMatch`. The recomputation is what stops a listing that is whole by its own count
|
|
181
|
+
* but not the state its digest names (a shortened listing under the real digest) from being
|
|
182
|
+
* diffed as a mass deletion. Not part of the {@link StorageBackend} seam.
|
|
183
|
+
*/
|
|
184
|
+
heads(options?: HeadsOptions): Promise<HeadsResult | null>;
|
|
185
|
+
/**
|
|
186
|
+
* `GET /snapshot`: the whole bundle in one response. The header line is parsed before this
|
|
187
|
+
* resolves, so a non-2xx or a body without a header rejects here with the usual typed error;
|
|
188
|
+
* the documents then stream through {@link RemoteSnapshot.docs}. Transient retry applies only
|
|
189
|
+
* to obtaining the response: a body cut mid-stream is reported to the consumer as
|
|
190
|
+
* `SNAPSHOT_TRUNCATED`, a whole body whose heads do not digest to the header's announcement as
|
|
191
|
+
* `SNAPSHOT_DIGEST_MISMATCH`, and re-requesting is the consumer's decision. Reserved files are
|
|
192
|
+
* not part of a snapshot. Not part of the {@link StorageBackend} seam.
|
|
193
|
+
*/
|
|
194
|
+
snapshot(): Promise<RemoteSnapshot>;
|
|
131
195
|
/**
|
|
132
196
|
* `GET /operations/{requestId}`: the authority's recorded outcome for an identified write, or
|
|
133
197
|
* `null` when it holds nothing under that identity (never recorded, or recorded and expired;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,aAAa,
|
|
1
|
+
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,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