@superbee/core 0.2.0-pre.2 → 0.2.0-pre.4
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/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/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/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +4 -5
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +217 -91
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +103 -4
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +236 -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 +21 -10
- package/dist/memory-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 +15 -174
- 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-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-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-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/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 +5 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed rejection of the wire client, shared by {@link RemoteBackend} and the heads and
|
|
3
|
+
* snapshot parsers in `remote-parsers.ts`, which the backend calls; a module of its own so the
|
|
4
|
+
* two need no import cycle. Runtime-neutral: nothing from Node.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A non-2xx wire response that is neither a `404` (ENOENT-shaped) nor a `412`
|
|
8
|
+
* ({@link VersionConflict}): the generic case, carrying the error envelope's `code` alongside
|
|
9
|
+
* the raw HTTP `status`, so a caller can distinguish e.g.
|
|
10
|
+
* `AUTH_REQUIRED` (401, an unauthenticated/misconfigured `--remote`) from `RUNTIME` (5xx, a
|
|
11
|
+
* genuine server-side bug) instead of both collapsing into a generically-classified `Error`.
|
|
12
|
+
*/
|
|
13
|
+
export class RemoteError extends Error {
|
|
14
|
+
/** The envelope's `code` field, or a status-derived guess when the envelope is missing/unparseable. */
|
|
15
|
+
code;
|
|
16
|
+
/** The raw HTTP status that produced this error. */
|
|
17
|
+
status;
|
|
18
|
+
constructor(message, code, status, cause) {
|
|
19
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
20
|
+
this.name = "RemoteError";
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.status = status;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** A wire payload the authority produced but the contract does not admit: not retried, not truncation. */
|
|
26
|
+
export function malformed(message) {
|
|
27
|
+
return new RemoteError(message, "RUNTIME", 502);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=remote-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-error.js","sourceRoot":"","sources":["../src/remote-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,uGAAuG;IAC9F,IAAI,CAAS;IACtB,oDAAoD;IAC3C,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,IAAY,EAAE,MAAc,EAAE,KAAe;QACxE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,0GAA0G;AAC1G,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* carrier failure and a 5xx response both propagate unchanged: a 502 or 504 from an intermediary,
|
|
13
13
|
* or the authority's own runtime failure, says nothing about whether the write was applied, so
|
|
14
14
|
* the primitive classifies it as unknown and resolves it by lookup, which is the whole reason
|
|
15
|
-
* the identity exists.
|
|
15
|
+
* the identity exists. A 4xx is final because the authority answered and declined. A local
|
|
16
|
+
* metadata encoding refusal is also final because no PUT was sent, not because the authority
|
|
17
|
+
* recorded an outcome.
|
|
16
18
|
*
|
|
17
19
|
* The transport is only sound against an authority that implements identity. A host that
|
|
18
20
|
* predates it ignores the header, applies every retry as a fresh write, and answers the lookup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-operations.d.ts","sourceRoot":"","sources":["../src/remote-operations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"remote-operations.d.ts","sourceRoot":"","sources":["../src/remote-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,OAAO,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAAmB,kBAAkB,EAAW,MAAM,sBAAsB,CAAC;AAGzF,MAAM,WAAW,+BAA+B;IAC9C,0GAA0G;IAC1G,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kFAAkF;AAClF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,4BAA4B;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,+BAAoC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIpJ;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,+BAAoC,GAAG,kBAAkB,CAEvI"}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* carrier failure and a 5xx response both propagate unchanged: a 502 or 504 from an intermediary,
|
|
13
13
|
* or the authority's own runtime failure, says nothing about whether the write was applied, so
|
|
14
14
|
* the primitive classifies it as unknown and resolves it by lookup, which is the whole reason
|
|
15
|
-
* the identity exists.
|
|
15
|
+
* the identity exists. A 4xx is final because the authority answered and declined. A local
|
|
16
|
+
* metadata encoding refusal is also final because no PUT was sent, not because the authority
|
|
17
|
+
* recorded an outcome.
|
|
16
18
|
*
|
|
17
19
|
* The transport is only sound against an authority that implements identity. A host that
|
|
18
20
|
* predates it ignores the header, applies every retry as a fresh write, and answers the lookup
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
import { parseMarkdown } from "./frontmatter.js";
|
|
40
42
|
import { pathFromConceptId } from "./paths.js";
|
|
41
43
|
import { RemoteBackend, RemoteError } from "./remote-backend.js";
|
|
44
|
+
import { RemoteDocumentValueError } from "./remote-document-codec.js";
|
|
42
45
|
import { VersionConflict } from "./version-transport.js";
|
|
43
46
|
/** The authority behind a remote does not record outcomes by request identity. */
|
|
44
47
|
export class OperationsUnsupportedError extends Error {
|
|
@@ -93,6 +96,8 @@ function buildTransport(remote, options) {
|
|
|
93
96
|
return { kind: "committed", version };
|
|
94
97
|
}
|
|
95
98
|
catch (error) {
|
|
99
|
+
if (error instanceof RemoteDocumentValueError)
|
|
100
|
+
return { kind: "refused", code: "USAGE", message: error.message };
|
|
96
101
|
if (error instanceof VersionConflict)
|
|
97
102
|
return { kind: "conflict", actual: error.actual };
|
|
98
103
|
if (error instanceof RemoteError && error.status < 500)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-operations.js","sourceRoot":"","sources":["../src/remote-operations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"remote-operations.js","sourceRoot":"","sources":["../src/remote-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAOzD,kFAAkF;AAClF,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAG,wBAAwB,CAAC;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,gDAAgD,OAAO,sFAAsF,CAAC,CAAC;Q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
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client side of the wire's heads and snapshot grammar (`docs/WIRE-PROTOCOL.md`, "Heads and
|
|
3
|
+
* snapshot"): what a heads answer must carry before its rows may be diffed as deletions, and
|
|
4
|
+
* how a snapshot body is read so that iterating it to completion is the completeness signal.
|
|
5
|
+
* {@link RemoteBackend.heads} and {@link RemoteBackend.snapshot} are thin callers over these
|
|
6
|
+
* two functions; a host that serves the same grammar through routes of its own validates the
|
|
7
|
+
* answers with the same functions rather than a second parser, since this grammar decides what
|
|
8
|
+
* a working copy deletes locally.
|
|
9
|
+
*
|
|
10
|
+
* Only `TextDecoder` and the Web Streams reader are used, so the same code runs in a browser, a
|
|
11
|
+
* Worker, and Node.
|
|
12
|
+
*/
|
|
13
|
+
import { type DocumentHead } from "./heads-digest.js";
|
|
14
|
+
import type { ConceptId, Frontmatter, Version } from "./types.js";
|
|
15
|
+
/** A snapshot body that ended, or failed, before its terminator arrived with the announced count. */
|
|
16
|
+
export declare const SNAPSHOT_TRUNCATED = "SNAPSHOT_TRUNCATED";
|
|
17
|
+
/**
|
|
18
|
+
* A snapshot whose body arrived whole, with its terminator and the announced count, but whose
|
|
19
|
+
* rows digest to something other than the header announced. Not truncation: re-requesting will
|
|
20
|
+
* not necessarily repair it, since the authority contradicted itself. A consumer discards the
|
|
21
|
+
* documents' claim to the header digest either way.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SNAPSHOT_DIGEST_MISMATCH = "SNAPSHOT_DIGEST_MISMATCH";
|
|
24
|
+
/** A `200` from `GET /heads`: every document id and version, and the digest over them. */
|
|
25
|
+
export interface HeadsResult {
|
|
26
|
+
digest: string;
|
|
27
|
+
heads: DocumentHead[];
|
|
28
|
+
}
|
|
29
|
+
/** The snapshot's first line: how many documents follow and the digest `heads` would return for this state. */
|
|
30
|
+
export interface SnapshotHeader {
|
|
31
|
+
count: number;
|
|
32
|
+
digest: string;
|
|
33
|
+
}
|
|
34
|
+
/** One `doc` line of a snapshot. */
|
|
35
|
+
export interface SnapshotDocument {
|
|
36
|
+
id: ConceptId;
|
|
37
|
+
version: Version;
|
|
38
|
+
frontmatter: Frontmatter;
|
|
39
|
+
body: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A snapshot as {@link readSnapshotStream} hands it over: the header, already parsed, and the
|
|
43
|
+
* documents as they stream. Iterating `docs` to completion is the completeness signal: the
|
|
44
|
+
* loop ends only after the `end` line arrived with the announced count and the digest recomputed
|
|
45
|
+
* over the received `{ id, version }` rows equals the header's, and it throws
|
|
46
|
+
* `SNAPSHOT_TRUNCATED` (the body ended or failed first) or `SNAPSHOT_DIGEST_MISMATCH` (the body
|
|
47
|
+
* was whole but describes a state the header did not announce) otherwise, so a consumer that
|
|
48
|
+
* writes batches as they arrive has one control path and never needs to inspect a terminator
|
|
49
|
+
* or a digest itself. A consumer records the header digest as matched only after the loop
|
|
50
|
+
* ended normally.
|
|
51
|
+
*/
|
|
52
|
+
export interface RemoteSnapshot {
|
|
53
|
+
header: SnapshotHeader;
|
|
54
|
+
docs: AsyncIterable<SnapshotDocument>;
|
|
55
|
+
}
|
|
56
|
+
/** Options for {@link readSnapshotStream}. */
|
|
57
|
+
export interface ReadSnapshotStreamOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The HTTP status the response carried, reported as `RemoteError.status` by the truncation and
|
|
60
|
+
* digest-mismatch rejections; a caller that has already checked `res.ok` passes `res.status`.
|
|
61
|
+
* Defaults to `200`, the only status a snapshot body is read under.
|
|
62
|
+
*/
|
|
63
|
+
status?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The `200` body of `GET /heads`, admitted or refused as one: a well-formed digest, a `heads`
|
|
67
|
+
* array of `{ id, version }` rows, a `count` equal to the number of rows, and rows that digest
|
|
68
|
+
* by the documented recipe to the digest served. Anything else rejects as malformed (a
|
|
69
|
+
* {@link RemoteError} with code `RUNTIME` and status `502`) rather than being trusted. The
|
|
70
|
+
* recomputation is what stops a listing that is whole by its own count but not the state its
|
|
71
|
+
* digest names (a shortened listing under the real digest) from being diffed as a mass
|
|
72
|
+
* deletion. Rows keep the order served: the recipe sorts for itself, so order does not decide
|
|
73
|
+
* admission.
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseHeadsAnswer(payload: unknown): HeadsResult;
|
|
76
|
+
/**
|
|
77
|
+
* Read a `GET /snapshot` body by the documented grammar. The header line is parsed before this
|
|
78
|
+
* resolves, so a body that ends before it rejects here with `SNAPSHOT_TRUNCATED` and a first
|
|
79
|
+
* line that is not the header rejects as malformed; the documents then stream through
|
|
80
|
+
* {@link RemoteSnapshot.docs}, which ends normally only for a whole body whose rows digest to
|
|
81
|
+
* the header's announcement (see {@link RemoteSnapshot}). Obtaining the response, checking its
|
|
82
|
+
* status, and re-requesting a truncated snapshot are the caller's: this function reads one body
|
|
83
|
+
* once and cancels the reader when the iteration is abandoned or fails.
|
|
84
|
+
*/
|
|
85
|
+
export declare function readSnapshotStream(body: ReadableStream<Uint8Array>, options?: ReadSnapshotStreamOptions): Promise<RemoteSnapshot>;
|
|
86
|
+
//# sourceMappingURL=remote-parsers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-parsers.d.ts","sourceRoot":"","sources":["../src/remote-parsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAElE,qGAAqG;AACrG,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,0FAA0F;AAC1F,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,+GAA+G;AAC/G,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,SAAS,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACvC;AAED,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAe9D;AA6GD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,cAAc,CAAC,CAa3I"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client side of the wire's heads and snapshot grammar (`docs/WIRE-PROTOCOL.md`, "Heads and
|
|
3
|
+
* snapshot"): what a heads answer must carry before its rows may be diffed as deletions, and
|
|
4
|
+
* how a snapshot body is read so that iterating it to completion is the completeness signal.
|
|
5
|
+
* {@link RemoteBackend.heads} and {@link RemoteBackend.snapshot} are thin callers over these
|
|
6
|
+
* two functions; a host that serves the same grammar through routes of its own validates the
|
|
7
|
+
* answers with the same functions rather than a second parser, since this grammar decides what
|
|
8
|
+
* a working copy deletes locally.
|
|
9
|
+
*
|
|
10
|
+
* Only `TextDecoder` and the Web Streams reader are used, so the same code runs in a browser, a
|
|
11
|
+
* Worker, and Node.
|
|
12
|
+
*/
|
|
13
|
+
import { headsDigest, isHeadsDigest } from "./heads-digest.js";
|
|
14
|
+
import { RemoteError, malformed } from "./remote-error.js";
|
|
15
|
+
/** A snapshot body that ended, or failed, before its terminator arrived with the announced count. */
|
|
16
|
+
export const SNAPSHOT_TRUNCATED = "SNAPSHOT_TRUNCATED";
|
|
17
|
+
/**
|
|
18
|
+
* A snapshot whose body arrived whole, with its terminator and the announced count, but whose
|
|
19
|
+
* rows digest to something other than the header announced. Not truncation: re-requesting will
|
|
20
|
+
* not necessarily repair it, since the authority contradicted itself. A consumer discards the
|
|
21
|
+
* documents' claim to the header digest either way.
|
|
22
|
+
*/
|
|
23
|
+
export const SNAPSHOT_DIGEST_MISMATCH = "SNAPSHOT_DIGEST_MISMATCH";
|
|
24
|
+
function isDocumentHead(value) {
|
|
25
|
+
if (typeof value !== "object" || value === null)
|
|
26
|
+
return false;
|
|
27
|
+
const head = value;
|
|
28
|
+
return typeof head.id === "string" && typeof head.version === "string";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The `200` body of `GET /heads`, admitted or refused as one: a well-formed digest, a `heads`
|
|
32
|
+
* array of `{ id, version }` rows, a `count` equal to the number of rows, and rows that digest
|
|
33
|
+
* by the documented recipe to the digest served. Anything else rejects as malformed (a
|
|
34
|
+
* {@link RemoteError} with code `RUNTIME` and status `502`) rather than being trusted. The
|
|
35
|
+
* recomputation is what stops a listing that is whole by its own count but not the state its
|
|
36
|
+
* digest names (a shortened listing under the real digest) from being diffed as a mass
|
|
37
|
+
* deletion. Rows keep the order served: the recipe sorts for itself, so order does not decide
|
|
38
|
+
* admission.
|
|
39
|
+
*/
|
|
40
|
+
export function parseHeadsAnswer(payload) {
|
|
41
|
+
const answer = payload;
|
|
42
|
+
if (!isHeadsDigest(answer?.digest))
|
|
43
|
+
throw malformed("wire heads answered without a well-formed digest");
|
|
44
|
+
if (!Array.isArray(answer.heads) || !answer.heads.every(isDocumentHead)) {
|
|
45
|
+
throw malformed("wire heads answered without a heads array of { id, version } rows");
|
|
46
|
+
}
|
|
47
|
+
if (answer.count !== answer.heads.length) {
|
|
48
|
+
throw malformed(`wire heads count ${String(answer.count)} disagrees with its ${answer.heads.length} row(s)`);
|
|
49
|
+
}
|
|
50
|
+
const heads = answer.heads.map(({ id, version }) => ({ id, version }));
|
|
51
|
+
const recomputed = headsDigest(heads);
|
|
52
|
+
if (recomputed !== answer.digest) {
|
|
53
|
+
throw malformed(`wire heads served digest ${answer.digest}, but its ${heads.length} row(s) digest to ${recomputed}`);
|
|
54
|
+
}
|
|
55
|
+
return { digest: answer.digest, heads };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Split a response body into its NDJSON lines as they arrive, decoding UTF-8 across chunk
|
|
59
|
+
* boundaries. A partial trailing line at the end of the body is a cut line and is not yielded; a
|
|
60
|
+
* transport failure while reading is reported as truncation, since either way the terminator
|
|
61
|
+
* never arrived. Leaving the loop early cancels the reader so the connection is released.
|
|
62
|
+
*/
|
|
63
|
+
async function* ndjsonLines(body, status) {
|
|
64
|
+
const reader = body.getReader();
|
|
65
|
+
const decoder = new TextDecoder();
|
|
66
|
+
let buffered = "";
|
|
67
|
+
try {
|
|
68
|
+
for (;;) {
|
|
69
|
+
let chunk;
|
|
70
|
+
try {
|
|
71
|
+
chunk = await reader.read();
|
|
72
|
+
}
|
|
73
|
+
catch (cause) {
|
|
74
|
+
throw new RemoteError("snapshot body failed before its end line arrived", SNAPSHOT_TRUNCATED, status, cause);
|
|
75
|
+
}
|
|
76
|
+
buffered += decoder.decode(chunk.value, { stream: !chunk.done });
|
|
77
|
+
let start = 0;
|
|
78
|
+
for (let newline = buffered.indexOf("\n"); newline !== -1; newline = buffered.indexOf("\n", start)) {
|
|
79
|
+
yield buffered.slice(start, newline);
|
|
80
|
+
start = newline + 1;
|
|
81
|
+
}
|
|
82
|
+
buffered = buffered.slice(start);
|
|
83
|
+
if (chunk.done)
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await reader.cancel().catch(() => undefined);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function parseSnapshotLine(line) {
|
|
92
|
+
let record;
|
|
93
|
+
try {
|
|
94
|
+
record = JSON.parse(line);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw malformed("snapshot line is not JSON");
|
|
98
|
+
}
|
|
99
|
+
if (typeof record !== "object" || record === null)
|
|
100
|
+
throw malformed("snapshot line is not a JSON object");
|
|
101
|
+
return record;
|
|
102
|
+
}
|
|
103
|
+
function parseSnapshotHeader(line) {
|
|
104
|
+
const record = parseSnapshotLine(line);
|
|
105
|
+
if (record.kind !== "snapshot")
|
|
106
|
+
throw malformed("snapshot did not begin with its header line");
|
|
107
|
+
if (typeof record.count !== "number" || !Number.isInteger(record.count) || record.count < 0) {
|
|
108
|
+
throw malformed("snapshot header carries no document count");
|
|
109
|
+
}
|
|
110
|
+
if (!isHeadsDigest(record.digest))
|
|
111
|
+
throw malformed("snapshot header carries no well-formed digest");
|
|
112
|
+
return { count: record.count, digest: record.digest };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The document lines of a snapshot, ending normally only at an `end` line whose count equals
|
|
116
|
+
* both the header's announcement and the documents actually seen, and only when the digest
|
|
117
|
+
* recomputed over the received heads equals the header's. Anything else is a rejection: a body
|
|
118
|
+
* that ends first is `SNAPSHOT_TRUNCATED`; a whole body whose heads digest differently is
|
|
119
|
+
* `SNAPSHOT_DIGEST_MISMATCH`; a line the contract does not admit is malformed. The digest is the
|
|
120
|
+
* client's own check of the listing it is about to trust: a count and a terminator say the body
|
|
121
|
+
* is whole, only the recipe says it is the state the header named.
|
|
122
|
+
*/
|
|
123
|
+
async function* snapshotDocuments(lines, header, status) {
|
|
124
|
+
let seen = 0;
|
|
125
|
+
const received = [];
|
|
126
|
+
for await (const line of lines) {
|
|
127
|
+
const record = parseSnapshotLine(line);
|
|
128
|
+
if (record.kind === "doc") {
|
|
129
|
+
if (typeof record.id !== "string" || typeof record.version !== "string" || typeof record.body !== "string") {
|
|
130
|
+
throw malformed("snapshot doc line lacks id, version, or body");
|
|
131
|
+
}
|
|
132
|
+
if (typeof record.frontmatter !== "object" || record.frontmatter === null || Array.isArray(record.frontmatter)) {
|
|
133
|
+
throw malformed("snapshot doc line lacks a frontmatter object");
|
|
134
|
+
}
|
|
135
|
+
seen += 1;
|
|
136
|
+
if (seen > header.count)
|
|
137
|
+
throw malformed(`snapshot delivered more than the ${header.count} announced document(s)`);
|
|
138
|
+
received.push({ id: record.id, version: record.version });
|
|
139
|
+
yield { id: record.id, version: record.version, frontmatter: record.frontmatter, body: record.body };
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (record.kind === "end") {
|
|
143
|
+
if (record.count !== seen || seen !== header.count) {
|
|
144
|
+
throw new RemoteError(`snapshot end line counts ${String(record.count)} document(s), but ${seen} of ${header.count} announced arrived`, SNAPSHOT_TRUNCATED, status);
|
|
145
|
+
}
|
|
146
|
+
const recomputed = headsDigest(received);
|
|
147
|
+
if (recomputed !== header.digest) {
|
|
148
|
+
throw new RemoteError(`snapshot header announced digest ${header.digest}, but its ${seen} document(s) digest to ${recomputed}`, SNAPSHOT_DIGEST_MISMATCH, status);
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
throw malformed(`snapshot line has unexpected kind ${JSON.stringify(record.kind)}`);
|
|
153
|
+
}
|
|
154
|
+
throw new RemoteError(`snapshot ended after ${seen} of ${header.count} document(s) without its end line`, SNAPSHOT_TRUNCATED, status);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Read a `GET /snapshot` body by the documented grammar. The header line is parsed before this
|
|
158
|
+
* resolves, so a body that ends before it rejects here with `SNAPSHOT_TRUNCATED` and a first
|
|
159
|
+
* line that is not the header rejects as malformed; the documents then stream through
|
|
160
|
+
* {@link RemoteSnapshot.docs}, which ends normally only for a whole body whose rows digest to
|
|
161
|
+
* the header's announcement (see {@link RemoteSnapshot}). Obtaining the response, checking its
|
|
162
|
+
* status, and re-requesting a truncated snapshot are the caller's: this function reads one body
|
|
163
|
+
* once and cancels the reader when the iteration is abandoned or fails.
|
|
164
|
+
*/
|
|
165
|
+
export async function readSnapshotStream(body, options = {}) {
|
|
166
|
+
const status = options.status ?? 200;
|
|
167
|
+
const lines = ndjsonLines(body, status);
|
|
168
|
+
const first = await lines.next();
|
|
169
|
+
if (first.done)
|
|
170
|
+
throw new RemoteError("snapshot ended before its header line", SNAPSHOT_TRUNCATED, status);
|
|
171
|
+
let header;
|
|
172
|
+
try {
|
|
173
|
+
header = parseSnapshotHeader(first.value);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
await lines.return(undefined);
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
return { header, docs: snapshotDocuments(lines, header, status) };
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=remote-parsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-parsers.js","sourceRoot":"","sources":["../src/remote-parsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAqB,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG3D,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAgDnE,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAG,KAA4C,CAAC;IAC1D,OAAO,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC;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|
3
|
-
export type { FetchLike, HeadsOptions,
|
|
2
|
+
export { RemoteBackend } from "./remote-backend.js";
|
|
3
|
+
export type { FetchLike, HeadsOptions, RemoteBackendOptions, WireCapabilities } from "./remote-backend.js";
|
|
4
|
+
export { RemoteError } from "./remote-error.js";
|
|
5
|
+
export { SNAPSHOT_DIGEST_MISMATCH, SNAPSHOT_TRUNCATED, parseHeadsAnswer, readSnapshotStream } from "./remote-parsers.js";
|
|
6
|
+
export type { HeadsResult, ReadSnapshotStreamOptions, RemoteSnapshot, SnapshotDocument, SnapshotHeader } from "./remote-parsers.js";
|
|
4
7
|
export { headsDigest, isHeadsDigest, sortHeads } from "./heads-digest.js";
|
|
5
8
|
export type { DocumentHead } from "./heads-digest.js";
|
|
6
9
|
//# sourceMappingURL=remote.d.ts.map
|
package/dist/remote.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzH,YAAY,EAAE,WAAW,EAAE,yBAAyB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpI,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/remote.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/** Browser-safe client adapter for the Superbee wire protocol. */
|
|
2
|
-
export { RemoteBackend
|
|
2
|
+
export { RemoteBackend } from "./remote-backend.js";
|
|
3
|
+
export { RemoteError } from "./remote-error.js";
|
|
4
|
+
// The heads and snapshot grammar's reference validators, for a host that serves the same grammar
|
|
5
|
+
// through routes of its own; `RemoteBackend.heads` and `RemoteBackend.snapshot` call these.
|
|
6
|
+
export { SNAPSHOT_DIGEST_MISMATCH, SNAPSHOT_TRUNCATED, parseHeadsAnswer, readSnapshotStream } from "./remote-parsers.js";
|
|
3
7
|
export { headsDigest, isHeadsDigest, sortHeads } from "./heads-digest.js";
|
|
4
8
|
//# sourceMappingURL=remote.js.map
|
package/dist/remote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,iGAAiG;AACjG,4FAA4F;AAC5F,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -72,6 +72,8 @@ export interface OperationTransport {
|
|
|
72
72
|
/** Wait `ms`, resolving early and harmlessly when `signal` aborts. Injected by tests. */
|
|
73
73
|
export type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
74
74
|
export interface UncertainWriteOptions {
|
|
75
|
+
/** Exact-content writes may settle matching conflicts; governed writes require recorded evidence. */
|
|
76
|
+
settlement?: "exact-content" | "recorded-only";
|
|
75
77
|
/** How long one submission may take before its outcome is treated as unknown. */
|
|
76
78
|
deadlineMs?: number;
|
|
77
79
|
/** Lookups attempted after an unknown submission before giving up (default 3). */
|
|
@@ -135,8 +137,8 @@ export declare function settleAgainstIntent(outcome: Outcome, intent: OperationI
|
|
|
135
137
|
* twice, and even on one with it the retry can only ever learn what the lookup already knew.
|
|
136
138
|
* The lookup is what turns "unknown" into a fact before any second delivery.
|
|
137
139
|
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
+
* By default every outcome passes through {@link settleAgainstIntent}, so a conflict naming the
|
|
141
|
+
* intent's own version is committed. `recorded-only` preserves the recorded outcome instead.
|
|
140
142
|
*/
|
|
141
143
|
export declare function performUncertainWrite(transport: OperationTransport, intent: OperationIntent, options?: UncertainWriteOptions): Promise<UncertainWriteResult>;
|
|
142
144
|
//# sourceMappingURL=uncertain-write.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uncertain-write.d.ts","sourceRoot":"","sources":["../src/uncertain-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE3G,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,8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AAM,EAAE,eAAe,EACvB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CA4C/B"}
|
package/dist/uncertain-write.js
CHANGED
|
@@ -122,10 +122,13 @@ async function submitOnce(transport, intent, deadlineMs, sleep) {
|
|
|
122
122
|
* twice, and even on one with it the retry can only ever learn what the lookup already knew.
|
|
123
123
|
* The lookup is what turns "unknown" into a fact before any second delivery.
|
|
124
124
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
125
|
+
* By default every outcome passes through {@link settleAgainstIntent}, so a conflict naming the
|
|
126
|
+
* intent's own version is committed. `recorded-only` preserves the recorded outcome instead.
|
|
127
127
|
*/
|
|
128
128
|
export async function performUncertainWrite(transport, intent, options = {}) {
|
|
129
|
+
if (options.settlement !== undefined && options.settlement !== "exact-content" && options.settlement !== "recorded-only") {
|
|
130
|
+
throw new Error("Unknown uncertain-write settlement mode.");
|
|
131
|
+
}
|
|
129
132
|
const sleep = options.sleep ?? defaultSleep;
|
|
130
133
|
const maxLookups = Math.max(1, options.maxLookups ?? 3);
|
|
131
134
|
const maxSubmissions = Math.max(1, options.maxSubmissions ?? 2);
|
|
@@ -134,7 +137,7 @@ export async function performUncertainWrite(transport, intent, options = {}) {
|
|
|
134
137
|
let submissions = 0;
|
|
135
138
|
let lookups = 0;
|
|
136
139
|
const finish = (raw) => {
|
|
137
|
-
const outcome = settleAgainstIntent(raw, intent);
|
|
140
|
+
const outcome = options.settlement === "recorded-only" ? raw : settleAgainstIntent(raw, intent);
|
|
138
141
|
return { intent: { ...intent, attempts, state: stateForOutcome(outcome) }, outcome, lookups };
|
|
139
142
|
};
|
|
140
143
|
// A previously submitted intent starts at the lookup, never at a submission.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uncertain-write.js","sourceRoot":"","sources":["../src/uncertain-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"uncertain-write.js","sourceRo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GAAG,KAAK,CAAC;QACvB,IAAI,QAAoC,CAAC;QACzC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,IAAI,KAAK,GAAG,CAAC;gBAAE,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,CAAC;gBACH,QAAQ,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACtD,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,SAAS,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,MAAM;QACR,CAAC;QACD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superbee/core",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OKF store engine — bundle I/O, cross-links, derived backlinks, freshness, and versioned writes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"./dist/bundle.js"
|
|
16
16
|
],
|
|
17
17
|
"exports": {
|
|
18
|
+
"./governed-body-write": {
|
|
19
|
+
"types": "./dist/governed-body-write.d.ts",
|
|
20
|
+
"default": "./dist/governed-body-write.js"
|
|
21
|
+
},
|
|
18
22
|
"./view-admission": {
|
|
19
23
|
"types": "./dist/view-admission.d.ts",
|
|
20
24
|
"default": "./dist/view-admission.js"
|