@superbee/core 0.2.0-pre.1 → 0.2.0-pre.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -0
- package/dist/artifact-contract.d.ts +90 -0
- package/dist/artifact-contract.d.ts.map +1 -0
- package/dist/artifact-contract.js +205 -0
- package/dist/artifact-contract.js.map +1 -0
- package/dist/backend.d.ts +16 -1
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +85 -42
- package/dist/backend.js.map +1 -1
- package/dist/bundle-ops.d.ts +1 -1
- package/dist/bundle-ops.d.ts.map +1 -1
- package/dist/bundle-ops.js +2 -2
- package/dist/bundle-ops.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/document-codec.d.ts +6 -1
- package/dist/document-codec.d.ts.map +1 -1
- package/dist/document-codec.js +8 -4
- package/dist/document-codec.js.map +1 -1
- package/dist/document-field-actions.d.ts +13 -1
- package/dist/document-field-actions.d.ts.map +1 -1
- package/dist/document-field-actions.js +47 -6
- package/dist/document-field-actions.js.map +1 -1
- package/dist/document-mutation.d.ts +15 -1
- package/dist/document-mutation.d.ts.map +1 -1
- package/dist/document-mutation.js +42 -11
- package/dist/document-mutation.js.map +1 -1
- package/dist/document-write-policy.d.ts.map +1 -1
- package/dist/document-write-policy.js +4 -2
- package/dist/document-write-policy.js.map +1 -1
- package/dist/engine.d.ts +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -3
- package/dist/engine.js.map +1 -1
- package/dist/file-journaled-backend-internal.d.ts +19 -0
- package/dist/file-journaled-backend-internal.d.ts.map +1 -0
- package/dist/file-journaled-backend-internal.js +10 -0
- package/dist/file-journaled-backend-internal.js.map +1 -0
- package/dist/file-journaled-backend.d.ts +162 -0
- package/dist/file-journaled-backend.d.ts.map +1 -0
- package/dist/file-journaled-backend.js +1113 -0
- package/dist/file-journaled-backend.js.map +1 -0
- 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 +86 -4
- package/dist/filesystem-identity.d.ts.map +1 -1
- package/dist/filesystem-identity.js +338 -102
- package/dist/filesystem-identity.js.map +1 -1
- package/dist/filesystem-lock.d.ts +16 -3
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +323 -77
- package/dist/filesystem-lock.js.map +1 -1
- package/dist/filesystem-push-role.d.ts +77 -0
- package/dist/filesystem-push-role.d.ts.map +1 -0
- package/dist/filesystem-push-role.js +165 -0
- package/dist/filesystem-push-role.js.map +1 -0
- 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/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 +106 -0
- package/dist/governed-body-write.d.ts.map +1 -0
- package/dist/governed-body-write.js +251 -0
- package/dist/governed-body-write.js.map +1 -0
- 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/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/host-text.d.ts +31 -0
- package/dist/host-text.d.ts.map +1 -0
- package/dist/host-text.js +77 -0
- package/dist/host-text.js.map +1 -0
- package/dist/hosted-transport/answer-rows.d.ts +216 -0
- package/dist/hosted-transport/answer-rows.d.ts.map +1 -0
- package/dist/hosted-transport/answer-rows.js +396 -0
- package/dist/hosted-transport/answer-rows.js.map +1 -0
- package/dist/hosted-transport/carrier.d.ts +142 -0
- package/dist/hosted-transport/carrier.d.ts.map +1 -0
- package/dist/hosted-transport/carrier.js +241 -0
- package/dist/hosted-transport/carrier.js.map +1 -0
- package/dist/hosted-transport/history-pages.d.ts +55 -0
- package/dist/hosted-transport/history-pages.d.ts.map +1 -0
- package/dist/hosted-transport/history-pages.js +69 -0
- package/dist/hosted-transport/history-pages.js.map +1 -0
- package/dist/hosted-transport/index.d.ts +18 -0
- package/dist/hosted-transport/index.d.ts.map +1 -0
- package/dist/hosted-transport/index.js +18 -0
- package/dist/hosted-transport/index.js.map +1 -0
- package/dist/hosted-transport/operations.d.ts +85 -0
- package/dist/hosted-transport/operations.d.ts.map +1 -0
- package/dist/hosted-transport/operations.js +128 -0
- package/dist/hosted-transport/operations.js.map +1 -0
- package/dist/hosted-transport/paged-reads.d.ts +87 -0
- package/dist/hosted-transport/paged-reads.d.ts.map +1 -0
- package/dist/hosted-transport/paged-reads.js +238 -0
- package/dist/hosted-transport/paged-reads.js.map +1 -0
- package/dist/hosted-transport/read-adapter.d.ts +250 -0
- package/dist/hosted-transport/read-adapter.d.ts.map +1 -0
- package/dist/hosted-transport/read-adapter.js +557 -0
- package/dist/hosted-transport/read-adapter.js.map +1 -0
- package/dist/hosted-transport/root-write.d.ts +114 -0
- package/dist/hosted-transport/root-write.d.ts.map +1 -0
- package/dist/hosted-transport/root-write.js +171 -0
- package/dist/hosted-transport/root-write.js.map +1 -0
- package/dist/hosted-transport/whole-document-transport.d.ts +203 -0
- package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -0
- package/dist/hosted-transport/whole-document-transport.js +438 -0
- package/dist/hosted-transport/whole-document-transport.js.map +1 -0
- package/dist/index.d.ts +22 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +38 -6
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +511 -46
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +296 -7
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +312 -0
- package/dist/journaled-backend.js.map +1 -1
- package/dist/kind-coverage.d.ts +99 -0
- package/dist/kind-coverage.d.ts.map +1 -0
- package/dist/kind-coverage.js +186 -0
- package/dist/kind-coverage.js.map +1 -0
- package/dist/kinds.d.ts +31 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +83 -16
- package/dist/kinds.js.map +1 -1
- package/dist/links.d.ts +1 -1
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +5 -10
- package/dist/links.js.map +1 -1
- package/dist/managed-document-metadata.d.ts +2 -0
- package/dist/managed-document-metadata.d.ts.map +1 -0
- package/dist/managed-document-metadata.js +9 -0
- package/dist/managed-document-metadata.js.map +1 -0
- package/dist/memory-backend.d.ts +2 -2
- package/dist/memory-backend.d.ts.map +1 -1
- package/dist/memory-backend.js +32 -16
- 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 +84 -6
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +9 -4
- package/dist/platform.js.map +1 -1
- package/dist/portable-export.d.ts +119 -0
- package/dist/portable-export.d.ts.map +1 -0
- package/dist/portable-export.js +501 -0
- package/dist/portable-export.js.map +1 -0
- package/dist/publication-filesystem.d.ts +1 -1
- package/dist/publication-filesystem.d.ts.map +1 -1
- package/dist/publication-filesystem.js +1 -1
- package/dist/publication-filesystem.js.map +1 -1
- package/dist/query-filter.d.ts +7 -2
- package/dist/query-filter.d.ts.map +1 -1
- package/dist/query-filter.js +24 -1
- package/dist/query-filter.js.map +1 -1
- package/dist/query-order.d.ts +22 -0
- package/dist/query-order.d.ts.map +1 -0
- package/dist/query-order.js +42 -0
- package/dist/query-order.js.map +1 -0
- package/dist/remote-backend.d.ts +91 -27
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +217 -49
- 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 +38 -0
- package/dist/remote-error.d.ts.map +1 -0
- package/dist/remote-error.js +59 -0
- package/dist/remote-error.js.map +1 -0
- package/dist/remote-operations.d.ts +6 -3
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +20 -5
- 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 +7 -2
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +6 -1
- package/dist/remote.js.map +1 -1
- package/dist/site-capabilities.d.ts +339 -0
- package/dist/site-capabilities.d.ts.map +1 -0
- package/dist/site-capabilities.js +717 -0
- package/dist/site-capabilities.js.map +1 -0
- 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/dist/types.d.ts +28 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/uncertain-write.d.ts +49 -13
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +36 -12
- package/dist/uncertain-write.js.map +1 -1
- package/dist/versioning.d.ts +9 -4
- package/dist/versioning.d.ts.map +1 -1
- package/dist/versioning.js +9 -4
- package/dist/versioning.js.map +1 -1
- package/package.json +38 -2
package/dist/query-filter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-filter.js","sourceRoot":"","sources":["../src/query-filter.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"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wB;IAC1E,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface MeaningfulChangeOrderKey {
|
|
2
|
+
id: string;
|
|
3
|
+
/** The raw selected clock when it is a string, else `""`. */
|
|
4
|
+
timestamp: string;
|
|
5
|
+
/** The clock parsed under the bundle's OKF edition, or `null` when missing or invalid. */
|
|
6
|
+
timestampMs: number | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function meaningfulChangeOrderKey(id: string, frontmatter: {
|
|
9
|
+
readonly generated?: unknown;
|
|
10
|
+
readonly timestamp?: unknown;
|
|
11
|
+
}, okfVersion?: string | null): MeaningfulChangeOrderKey;
|
|
12
|
+
/** Newest usable meaningful-change time first; canonical ID in code-unit order for all ties. */
|
|
13
|
+
export declare function compareByMeaningfulChange(a: MeaningfulChangeOrderKey, b: MeaningfulChangeOrderKey): number;
|
|
14
|
+
/** Return a new array of `rows` in newest-first order; the input array is left untouched. */
|
|
15
|
+
export declare function sortByMeaningfulChange<T extends {
|
|
16
|
+
id: string;
|
|
17
|
+
frontmatter: {
|
|
18
|
+
readonly generated?: unknown;
|
|
19
|
+
readonly timestamp?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}>(rows: readonly T[], okfVersion?: string | null): T[];
|
|
22
|
+
//# sourceMappingURL=query-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-order.d.ts","sourceRoot":"","sources":["../src/query-order.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,EACV,WAAW,EAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3E,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,wBAAwB,CAO1B;AAED,gGAAgG;AAChG,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAS1G;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,EAC1I,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,CAAC,EAAE,CAKL"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Newest-first order shared by `list`, `home` and the View Bridge `order: "newest"` query.
|
|
3
|
+
*
|
|
4
|
+
* Rows sort by their parsed meaningful-change time (`generated.at`, else legacy `timestamp`),
|
|
5
|
+
* newest first. Rows with a missing or unparseable time follow every timed row. Every tie,
|
|
6
|
+
* including the untimed tail, breaks on the canonical ID in UTF-16 code-unit order, which every
|
|
7
|
+
* host computes identically; `localeCompare` depends on the platform's ICU data.
|
|
8
|
+
*
|
|
9
|
+
* Browser-safe and pure.
|
|
10
|
+
*/
|
|
11
|
+
import { parseTimestamp } from "./freshness.js";
|
|
12
|
+
import { meaningfulChangeTimeValue } from "./meaningful-change-time.js";
|
|
13
|
+
export function meaningfulChangeOrderKey(id, frontmatter, okfVersion) {
|
|
14
|
+
const value = meaningfulChangeTimeValue(frontmatter);
|
|
15
|
+
return {
|
|
16
|
+
id,
|
|
17
|
+
timestamp: typeof value === "string" ? value : "",
|
|
18
|
+
timestampMs: parseTimestamp(value, okfVersion ?? undefined),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Newest usable meaningful-change time first; canonical ID in code-unit order for all ties. */
|
|
22
|
+
export function compareByMeaningfulChange(a, b) {
|
|
23
|
+
if (a.timestampMs !== null && b.timestampMs !== null) {
|
|
24
|
+
if (a.timestampMs !== b.timestampMs)
|
|
25
|
+
return b.timestampMs - a.timestampMs;
|
|
26
|
+
}
|
|
27
|
+
else if (a.timestampMs !== null) {
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
else if (b.timestampMs !== null) {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
34
|
+
}
|
|
35
|
+
/** Return a new array of `rows` in newest-first order; the input array is left untouched. */
|
|
36
|
+
export function sortByMeaningfulChange(rows, okfVersion) {
|
|
37
|
+
return rows
|
|
38
|
+
.map((row) => ({ row, key: meaningfulChangeOrderKey(row.id, row.frontmatter, okfVersion) }))
|
|
39
|
+
.sort((a, b) => compareByMeaningfulChange(a.key, b.key))
|
|
40
|
+
.map(({ row }) => row);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=query-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-order.js","sourceRoot":"","sources":["../src/query-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAUxE,MAAM,UAAU,wBAAwB,CACtC,EAAU,EACV,WAA2E,EAC3E,UAA0B;IAE1B,MAAM,KAAK,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO;QACL,EAAE;QACF,SAAS,EAAE,OAAO,KA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,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/remote-backend.d.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* `RemoteBackend` — a {@link StorageBackend} implemented over the wire-protocol v0
|
|
3
3
|
* reference contract (`docs/WIRE-PROTOCOL.md`, `@superbee/server`).
|
|
4
4
|
*
|
|
5
|
-
* This is the client half of the seam over HTTP: every method maps directly to a wire endpoint
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This is the client half of the seam over HTTP: every method maps directly to a wire endpoint
|
|
6
|
+
* (a guarded document write may first ask `GET /v0/capabilities` whether the host records
|
|
7
|
+
* outcomes; see {@link RemoteBackendOptions.maxRetries}), and response versions remain the same
|
|
8
|
+
* content-addressed {@link Version} tokens local backends produce. Tri-backend contract tests pin
|
|
9
|
+
* that invariant.
|
|
8
10
|
*
|
|
9
11
|
* Zero new dependencies: it calls an injectable {@link FetchLike} transport
|
|
10
|
-
* (defaulting to the global `fetch`, available
|
|
12
|
+
* (defaulting to the global `fetch`, available in every supported Node runtime) with a constructed
|
|
11
13
|
* `Request`. That means the SAME adapter runs against a real HTTP server, or — in
|
|
12
14
|
* tests — directly against an in-process `createRouter(bundle)` function with no
|
|
13
15
|
* sockets: `createRouter` returns exactly the `(req: Request) => Promise<Response>`
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
* This module touches NO filesystem and parses NO markdown — like {@link MemoryBackend},
|
|
41
43
|
* it proves the engine leaks no assumptions beyond the {@link StorageBackend} contract.
|
|
42
44
|
*/
|
|
45
|
+
import { type HeadsResult, type RemoteSnapshot } from "./remote-parsers.js";
|
|
43
46
|
import { type Outcome } from "./uncertain-write.js";
|
|
44
47
|
import type { BlobKey, ConceptId, DeleteOptions, HeadResult, OkfDocument, QueryFilter, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageBackend, Version, VersionInfo, WriteOptions } from "./types.js";
|
|
45
48
|
/**
|
|
@@ -54,7 +57,7 @@ export interface RemoteBackendOptions {
|
|
|
54
57
|
baseUrl: string;
|
|
55
58
|
/** Bundle name segment in the `/v0/bundles/{bundle}/…` path. */
|
|
56
59
|
bundle: string;
|
|
57
|
-
/** Transport override; defaults to the global `fetch`
|
|
60
|
+
/** Transport override; defaults to the global `fetch` in supported Node runtimes. Tests inject a router directly. */
|
|
58
61
|
fetchImpl?: FetchLike;
|
|
59
62
|
/**
|
|
60
63
|
* Optional bearer token sent as `Authorization: Bearer <token>` on EVERY request. The
|
|
@@ -68,26 +71,28 @@ export interface RemoteBackendOptions {
|
|
|
68
71
|
* e.g. a Cloudflare D1 cold-start's 500 "storage caused object to be reset" when a hibernated
|
|
69
72
|
* database is first hit) or a network/transport error. Each retry backs off exponentially with
|
|
70
73
|
* jitter. A 4xx (incl. 412 VersionConflict), 401, or any 2xx is a REAL result, never retried.
|
|
71
|
-
* Default 3; set 0 to disable.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
+
* Default 3; set 0 to disable. A retried read is idempotent.
|
|
75
|
+
*
|
|
76
|
+
* A guarded document write (`write` with `expectedVersion`, or `delete` with a content-version
|
|
77
|
+
* `expectedVersion`) travels with an `Idempotency-Key`: the caller's `requestId`, or else, when
|
|
78
|
+
* the host's capabilities report `operations`, one minted for that call. Every retry of the
|
|
79
|
+
* request carries the same key, so while the host keeps the record a retry is answered from the
|
|
80
|
+
* recorded outcome and cannot apply the write a second time.
|
|
81
|
+
*
|
|
82
|
+
* Other guarded writes retry as a plain resubmission: a guarded document write sent without a key
|
|
83
|
+
* (to a host without `operations`, after a capability question that ended in a transient status,
|
|
84
|
+
* or resent after the host refused a key minted under a stale answer), a `delete` whose
|
|
85
|
+
* `expectedVersion` is not a content version, and every guarded reserved-file and blob write,
|
|
86
|
+
* none of which the wire identifies. Such a retry lands the same version or a conflict, possibly
|
|
87
|
+
* SPURIOUS if a prior attempt committed before its response was lost. It is not free of lost
|
|
88
|
+
* updates: versions are content hashes, so if another writer returns the document to the exact
|
|
89
|
+
* state the premise names before a retry arrives, the retry applies the write again over that
|
|
90
|
+
* change and reports success. An unconditional write carries no minted key and can simply be
|
|
91
|
+
* repeated.
|
|
74
92
|
*/
|
|
75
93
|
maxRetries?: number;
|
|
76
94
|
}
|
|
77
|
-
|
|
78
|
-
* A non-2xx wire response that is neither a `404` (ENOENT-shaped) nor a `412`
|
|
79
|
-
* ({@link VersionConflict}) — the generic case, carrying the error envelope's `code` alongside
|
|
80
|
-
* the raw HTTP `status`, so a caller can distinguish e.g.
|
|
81
|
-
* `AUTH_REQUIRED` (401, an unauthenticated/misconfigured `--remote`) from `RUNTIME` (5xx, a
|
|
82
|
-
* genuine server-side bug) instead of both collapsing into a generically-classified `Error`.
|
|
83
|
-
*/
|
|
84
|
-
export declare class RemoteError extends Error {
|
|
85
|
-
/** The envelope's `code` field, or a status-derived guess when the envelope is missing/unparseable. */
|
|
86
|
-
readonly code: string;
|
|
87
|
-
/** The raw HTTP status that produced this error. */
|
|
88
|
-
readonly status: number;
|
|
89
|
-
constructor(message: string, code: string, status: number);
|
|
90
|
-
}
|
|
95
|
+
export { RemoteError } from "./remote-error.js";
|
|
91
96
|
/** The deployment-scoped capability booleans a wire authority reports (`docs/WIRE-PROTOCOL.md`). */
|
|
92
97
|
export interface WireCapabilities {
|
|
93
98
|
history: boolean;
|
|
@@ -97,6 +102,15 @@ export interface WireCapabilities {
|
|
|
97
102
|
blobs: boolean;
|
|
98
103
|
/** Whether document writes carrying `Idempotency-Key` are recorded and readable by lookup. */
|
|
99
104
|
operations: boolean;
|
|
105
|
+
/** Whether `GET /heads` answers every document id and version under one digest, with `304`. */
|
|
106
|
+
heads: boolean;
|
|
107
|
+
/** Whether `GET /snapshot` streams every document as terminated NDJSON. */
|
|
108
|
+
snapshot: boolean;
|
|
109
|
+
}
|
|
110
|
+
/** Options for {@link RemoteBackend.heads}. */
|
|
111
|
+
export interface HeadsOptions {
|
|
112
|
+
/** A digest from an earlier `heads` or `snapshot` answer; the authority answers `304` when it still holds it. */
|
|
113
|
+
ifNoneMatch?: string;
|
|
100
114
|
}
|
|
101
115
|
/**
|
|
102
116
|
* The client half of the wire-protocol v0 contract: implements {@link StorageBackend}
|
|
@@ -109,6 +123,8 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
109
123
|
private readonly fetchImpl;
|
|
110
124
|
private readonly authToken?;
|
|
111
125
|
private readonly maxRetries;
|
|
126
|
+
/** The pending or settled answer to whether this host records outcomes; see {@link recordsOutcomes}. */
|
|
127
|
+
private operationsSupport?;
|
|
112
128
|
constructor(options: RemoteBackendOptions);
|
|
113
129
|
/** The authority's base URL as configured, without a trailing slash. */
|
|
114
130
|
get origin(): string;
|
|
@@ -122,12 +138,55 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
122
138
|
write(id: ConceptId, doc: OkfDocument, options?: WriteOptions): Promise<Version>;
|
|
123
139
|
/**
|
|
124
140
|
* `GET /v0/capabilities`, deployment-scoped: what this authority implements. `operations` says
|
|
125
|
-
* whether it records outcomes by request identity.
|
|
126
|
-
* and
|
|
127
|
-
*
|
|
128
|
-
*
|
|
141
|
+
* whether it records outcomes by request identity. The reference router without it refuses any
|
|
142
|
+
* request carrying `Idempotency-Key`, and the lookup route, with `400 USAGE`; a host that lacks
|
|
143
|
+
* the lookup route altogether answers it with a route-miss `404`, which {@link lookupOperation}
|
|
144
|
+
* cannot tell from "never recorded". A consumer that relies on identity checks this once before
|
|
145
|
+
* it sends any intent. Missing booleans read as `false`.
|
|
129
146
|
*/
|
|
130
147
|
wireCapabilities(): Promise<WireCapabilities>;
|
|
148
|
+
/**
|
|
149
|
+
* Whether this host records outcomes by request identity, asked through `GET /v0/capabilities`
|
|
150
|
+
* and shared by concurrent callers. A host that answers anything but a `2xx` with
|
|
151
|
+
* `operations: true` is treated as not recording them, since a host that does not record them
|
|
152
|
+
* refuses a key with `400`. That answer is kept for the backend's lifetime, except that a
|
|
153
|
+
* transient status still returned after `send`'s retries, or a transport failure, is not kept:
|
|
154
|
+
* the former sends this write unidentified, and the latter rejects the write before it is sent.
|
|
155
|
+
* A kept yes is also dropped when a minted key meets the host's identity refusal; see
|
|
156
|
+
* {@link sendDocWrite}.
|
|
157
|
+
*/
|
|
158
|
+
private recordsOutcomes;
|
|
159
|
+
private probeOperations;
|
|
160
|
+
/**
|
|
161
|
+
* Send a document `PUT` or `DELETE`. When its `Idempotency-Key` was minted here, a kept
|
|
162
|
+
* `operations` answer may be stale: a host that has since lost its outcome store refuses every
|
|
163
|
+
* key with the wire's `400` {@link IDENTITY_UNSUPPORTED} before applying anything. That answer
|
|
164
|
+
* is dropped and the write is sent once more without a key, as to any host without
|
|
165
|
+
* `operations`. A caller's own `requestId` is never dropped, so its refusal is the answer.
|
|
166
|
+
*/
|
|
167
|
+
private sendDocWrite;
|
|
168
|
+
/**
|
|
169
|
+
* `GET /heads`: every document id and version the authority holds, under one digest, or
|
|
170
|
+
* `null` when `ifNoneMatch` named the digest it still holds (a `304`: nothing changed). A
|
|
171
|
+
* `200` is diffed against the caller's own copy: an id missing from `heads` was deleted, a
|
|
172
|
+
* differing version changed. A `200` without a well-formed digest, whose `count` and rows
|
|
173
|
+
* disagree, or whose rows digest by the documented recipe to something other than the served
|
|
174
|
+
* digest, is rejected rather than trusted ({@link parseHeadsAnswer} owns that admission), as
|
|
175
|
+
* is a `304` to a request that sent no `ifNoneMatch`. Not part of the {@link StorageBackend}
|
|
176
|
+
* seam.
|
|
177
|
+
*/
|
|
178
|
+
heads(options?: HeadsOptions): Promise<HeadsResult | null>;
|
|
179
|
+
/**
|
|
180
|
+
* `GET /snapshot`: the whole bundle in one response. The header line is parsed before this
|
|
181
|
+
* resolves, so a non-2xx or a body without a header rejects here with the usual typed error;
|
|
182
|
+
* the documents then stream through {@link RemoteSnapshot.docs}. Transient retry applies only
|
|
183
|
+
* to obtaining the response: a body cut mid-stream is reported to the consumer as
|
|
184
|
+
* `SNAPSHOT_TRUNCATED`, a whole body whose heads do not digest to the header's announcement as
|
|
185
|
+
* `SNAPSHOT_DIGEST_MISMATCH` ({@link readSnapshotStream} owns the grammar), and re-requesting
|
|
186
|
+
* is the consumer's decision. Reserved files are not part of a snapshot. Not part of the
|
|
187
|
+
* {@link StorageBackend} seam.
|
|
188
|
+
*/
|
|
189
|
+
snapshot(): Promise<RemoteSnapshot>;
|
|
131
190
|
/**
|
|
132
191
|
* `GET /operations/{requestId}`: the authority's recorded outcome for an identified write, or
|
|
133
192
|
* `null` when it holds nothing under that identity (never recorded, or recorded and expired;
|
|
@@ -155,7 +214,12 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
155
214
|
* `docs/WIRE-PROTOCOL.md`); the engine's `queryHeads` re-filter covers it, per the
|
|
156
215
|
* seam contract (over-returning is fine; semantics live in core).
|
|
157
216
|
*/
|
|
158
|
-
queryHeads(filter?: QueryFilter
|
|
217
|
+
queryHeads(filter?: QueryFilter, options?: {
|
|
218
|
+
onSkip?: (skip: {
|
|
219
|
+
id: ConceptId;
|
|
220
|
+
reason: string;
|
|
221
|
+
}) => void;
|
|
222
|
+
}): Promise<HeadResult[]>;
|
|
159
223
|
versions(id: ConceptId): Promise<VersionInfo[]>;
|
|
160
224
|
readReserved(dir: string, name: ReservedFilename): Promise<ReservedReadResult | null>;
|
|
161
225
|
writeReserved(dir: string, name: ReservedFilename, content: string, options?: WriteOptions): Promise<Version>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAOH,OAAO,EAA4D,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAAoC,KAAK,OAAO,E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