@superbee/view-host 0.0.0-stage → 0.1.1-pre.1

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 CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # Superbee View host
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The browser-safe host side of the Superbee View protocol (`docs/VIEW-PROTOCOL.md`), for a page
4
+ that runs a View in a sandboxed frame. Its one runtime dependency is `@superbee/core`.
5
+
6
+ | Entry | What it holds |
7
+ | --- | --- |
8
+ | `@superbee/view-host/view-bridge-host` | `createViewBridgeHost`: maps each View request onto a named operation that the page's `execute` callback runs |
9
+ | `@superbee/view-host/action-bridge` | The v1 View action contract: message parsing and replies |
10
+ | `@superbee/view-host/action-preparation` | `prepareViewDocumentAction`: the host-neutral proposal policy over Core |
11
+ | `@superbee/view-host/view-frame` | `viewFrameHeaders` and `viewFramePolicy`: the response headers a View entry is served with |
12
+ | `@superbee/view-host/query-pages` | `readQueryPages`: how a View's `query` reads `documents.query.v1` a page at a time, shared with the local View bridge |
13
+ | `@superbee/view-host` | The host and the frame headers together |
14
+
15
+ ```ts
16
+ import { createViewBridgeHost } from "@superbee/view-host";
17
+
18
+ const host = createViewBridgeHost(frame.contentWindow, { id: bundleId, name: bundleTitle }, execute, {
19
+ operations: ["documents.read.v1", "documents.query.v1", "documents.relationships.v1", "documents.edges.v1"],
20
+ invalidate: () => frame.remove(),
21
+ });
22
+ window.addEventListener("message", (event) => void host.receive(event));
23
+ ```
24
+
25
+ | Request | Operation |
26
+ | --- | --- |
27
+ | `query` | `documents.query.v1` |
28
+ | `read`, `read-versioned`, `render-document` | `documents.read.v1` |
29
+ | `relationships` | `documents.relationships.v1` |
30
+ | `edges` | `documents.edges.v1` |
31
+ | `graph` | `bundles.graph.v1` |
32
+ | `action.propose` (v1) | the page's `proposeAction` |
33
+
34
+ `execute(operation, input, signal)` runs the operation on the person's behalf and answers its
35
+ result envelope, `{ ok: true, data }` or `{ ok: false, error: { code, message } }`. Every input
36
+ carries the host's fixed `bundleId`.
37
+
38
+ ## `query`: up to 500 rows, a page at a time
39
+
40
+ A View may ask for up to 500 rows (`limits.query` is 500; `limit` 0 or absent means 500, and 501
41
+ or more answers `USAGE`). `documents.query.v1` answers at most 100 a call, so one `query` is several
42
+ `execute` calls:
43
+
44
+ - In id order the host reads pages of at most 100 (`limit`), the first with `after: ""` and each
45
+ later one with `after` set to the last id of the page before, until a page comes back short or
46
+ the View's `limit` is reached. A 500-row answer is five calls.
47
+ - When the walk filled the `limit`, one more call (`count: true`, `after` the last id) counts the
48
+ rest, so `count` is every match and `more: true` is set exactly when `count` is above the rows.
49
+ A walk that ended short makes no count call.
50
+ - `order: "newest"` is one call of at most 100 rows, because the operation pages only in id order.
51
+ Past 100 matches the reply is the newest 100, with the full `count` and `more: true`, whatever
52
+ the `limit`.
53
+ - `field` with several values is sent as `fieldsAnyOf` (an OR), `progress_status` included, which
54
+ the operation resolves through the Kind; `open: true` is sent as `open`. The host declares
55
+ `query.count`, `query.field-or`, `query.newest` and `query.open`. Rows carry raw frontmatter, so
56
+ it does not declare `query.kind-projection`.
57
+ - The calls are separate reads, not one snapshot. A document written between calls is answered at
58
+ whichever version its page read, or missed when its id sorts before a page already read, and
59
+ never answered twice. `count` is never below the rows answered.
60
+ - Any failing call (a refusal, a thrown error, lost access) fails the whole `query` with that
61
+ error. The View never gets a partial list. `skipped` names each document the operation left out
62
+ once, in id order.
63
+
64
+ `execute` is called up to six times per `query`, each checked against `admitted()` as a single
65
+ call is. The host declares in `hello` only the requests whose
66
+ operation the page offers and refuses the rest with `FORBIDDEN`. The page owns the frame, the
67
+ data source, authorization and any confirmation; the host owns parsing, limits, queuing and the
68
+ protocol's replies. It admits messages only from the frame it was given, at the opaque origin a
69
+ `sandbox="allow-scripts"` frame has.
70
+
71
+ ## What the page must do itself
72
+
73
+ The host trusts the frame it was given, not what is loaded in it. A page that embeds a View is
74
+ safe only if it also does these:
75
+
76
+ - **Keep the frame on the View.** Send the embedding page with a `Content-Security-Policy` whose
77
+ `frame-src` (and `child-src`) allow only the page's own origin. Without it a View can navigate
78
+ its frame to another site, and that site then receives every answer and has the network.
79
+ - **Sandbox the frame with scripts only.** Embed the entry in `<iframe sandbox="allow-scripts">`.
80
+ Never add `allow-same-origin`, `allow-popups` or `allow-top-navigation`.
81
+ - **Serve the entry with `viewFrameHeaders(pageOrigin)`.** Take `pageOrigin` from the page's own
82
+ configuration, never from a request header.
83
+ - **Authorize in `execute`.** Check who is asking on every call; the host passes requests
84
+ through and does not know the viewer. Run the operations' own input and output checks there:
85
+ the host asks `documents.query.v1` for at most 100 rows a call and `documents.edges.v1` within
86
+ its ceiling, but answers whatever `execute` returns, up to its reply size cap.
87
+
88
+ Install one `@superbee/core`. The package takes a Core range so a page's own Core satisfies it;
89
+ `prepareViewDocumentAction` passes Core's typed errors through, and callers classify them by
90
+ class, which needs a single copy.
91
+
92
+ A `view-host/v<version>` tag on `main` publishes this package through
93
+ `.github/workflows/release-view-host.yml`; its workspace `prepublishOnly` refuses a direct publish.
@@ -0,0 +1,52 @@
1
+ export declare const ACTION_BRIDGE_PROTOCOL = "v1";
2
+ export declare const MAX_ACTION_BODY_BYTES: number;
3
+ export type ActionScalar = string | number | boolean;
4
+ export interface DocumentSetFieldAction {
5
+ kind: "document.set-field";
6
+ docId: string;
7
+ field: string;
8
+ value: ActionScalar;
9
+ expectedVersion: string;
10
+ }
11
+ export interface DocumentSetBodyAction {
12
+ kind: "document.set-body";
13
+ docId: string;
14
+ field: "body";
15
+ value: string;
16
+ expectedVersion: string;
17
+ }
18
+ export interface DocumentUpdateAction {
19
+ kind: "document.update";
20
+ docId: string;
21
+ field: "document";
22
+ value: {
23
+ fields: Record<string, ActionScalar>;
24
+ body: string;
25
+ };
26
+ expectedVersion: string;
27
+ }
28
+ export type DocumentAction = DocumentSetFieldAction | DocumentSetBodyAction | DocumentUpdateAction;
29
+ export declare function parseDocumentAction(value: unknown): DocumentAction;
30
+ export type ActionBridgeMessage = {
31
+ bridge: "v1";
32
+ type: "read-versioned";
33
+ id: string;
34
+ docId: string;
35
+ } | {
36
+ bridge: "v1";
37
+ type: "action.propose";
38
+ requestId: string;
39
+ action: DocumentAction;
40
+ };
41
+ export declare function parseDocumentSetFieldAction(value: unknown): DocumentSetFieldAction;
42
+ /** Validate the complete structured-clone message before any shell work or confirmation UI. */
43
+ export declare function parseActionBridgeMessage(value: unknown): {
44
+ ok: true;
45
+ message: ActionBridgeMessage;
46
+ } | {
47
+ ok: false;
48
+ message: string;
49
+ } | null;
50
+ export declare function actionReply(requestId: string, result: unknown): Record<string, unknown>;
51
+ export declare function actionError(id: string | undefined, message: string): Record<string, unknown>;
52
+ //# sourceMappingURL=action-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-bridge.d.ts","sourceRoot":"","sources":["../src/action-bridge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,eAAO,MAAM,qBAAqB,QAAY,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAA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_BYTES = 512 * 1024;
3
+ export const MAX_ACTION_BODY_BYTES = 64 * 1024;
4
+ export function parseDocumentAction(value) {
5
+ if (isPlainRecord(value) && value.kind === "document.update") {
6
+ if (!exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"]) || value.field !== "document" ||
7
+ !isPlainRecord(value.value) || !exactKeys(value.value, ["fields", "body"]) || !isPlainRecord(value.value.fields))
8
+ throw new Error("document update requires exact fields and body");
9
+ const body = parseDocumentAction({ ...value, kind: "document.set-body", field: "body", value: value.value.body });
10
+ const entries = Object.entries(value.value.fields);
11
+ if (entries.length < 1 || entries.length > 8)
12
+ throw new Error("document update requires one to eight scalar fields");
13
+ for (const [field, scalar] of entries) {
14
+ const parsed = parseDocumentSetFieldAction({ kind: "document.set-field", docId: body.docId, field, value: scalar, expectedVersion: body.expectedVersion });
15
+ if (parsed.field !== field)
16
+ throw new Error("field names must be canonical");
17
+ }
18
+ return { kind: "document.update", docId: body.docId, field: "document", value: { fields: Object.fromEntries(entries), body: body.value }, expectedVersion: body.expectedVersion };
19
+ }
20
+ if (!isPlainRecord(value) || value.kind !== "document.set-body")
21
+ return parseDocumentSetFieldAction(value);
22
+ if (!exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"]) ||
23
+ !safeDocId(value.docId) || value.field !== "body" || typeof value.value !== "string" ||
24
+ byteLength(value.value) > MAX_ACTION_BODY_BYTES || typeof value.expectedVersion !== "string" ||
25
+ !value.expectedVersion.trim() || value.expectedVersion.length > 256)
26
+ throw new Error("body action requires a safe docId, field body, text of at most 64 KiB, and expectedVersion");
27
+ return { kind: "document.set-body", docId: value.docId, field: "body", value: value.value, expectedVersion: value.expectedVersion.trim() };
28
+ }
29
+ function isPlainRecord(value) {
30
+ if (typeof value !== "object" || value === null || Array.isArray(value))
31
+ return false;
32
+ const prototype = Object.getPrototypeOf(value);
33
+ return prototype === Object.prototype || prototype === null;
34
+ }
35
+ function exactKeys(record, expected) {
36
+ const actual = Object.keys(record).sort();
37
+ const sortedExpected = [...expected].sort();
38
+ return actual.length === sortedExpected.length && actual.every((key, index) => key === sortedExpected[index]);
39
+ }
40
+ function byteLength(value) {
41
+ return new TextEncoder().encode(value).byteLength;
42
+ }
43
+ function safeDocId(value) {
44
+ if (typeof value !== "string" || value.trim() === "" || value.startsWith("/") || value.includes("\\"))
45
+ return false;
46
+ const segments = value.split("/");
47
+ return (!segments.some((segment) => segment === "" || segment === "." || segment === "..") &&
48
+ !segments.slice(0, -1).some((segment) => segment.toLowerCase().endsWith(".md")));
49
+ }
50
+ function safeScalar(value) {
51
+ if (typeof value === "string")
52
+ return byteLength(value) <= 4096;
53
+ if (typeof value === "number")
54
+ return Number.isFinite(value);
55
+ return typeof value === "boolean";
56
+ }
57
+ function jsonSize(value) {
58
+ try {
59
+ return byteLength(JSON.stringify(value));
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ }
65
+ export function parseDocumentSetFieldAction(value) {
66
+ if (!isPlainRecord(value) || !exactKeys(value, ["kind", "docId", "field", "value", "expectedVersion"])) {
67
+ throw new Error("action must contain exactly kind, docId, field, value, and expectedVersion");
68
+ }
69
+ if (value.kind !== "document.set-field")
70
+ throw new Error("unsupported action kind");
71
+ if (!safeDocId(value.docId))
72
+ throw new Error("docId must be one canonical bundle-relative concept id");
73
+ const field = typeof value.field === "string" ? value.field.trim() : "";
74
+ if (!field || byteLength(field) > 128)
75
+ throw new Error("field must be a non-empty string of at most 128 bytes");
76
+ const expectedVersion = typeof value.expectedVersion === "string" ? value.expectedVersion.trim() : "";
77
+ if (!expectedVersion || expectedVersion.length > 256) {
78
+ throw new Error("expectedVersion must be a non-empty string of at most 256 characters");
79
+ }
80
+ if (!safeScalar(value.value)) {
81
+ throw new Error("value must be a string (at most 4 KiB), finite number, or boolean");
82
+ }
83
+ return {
84
+ kind: "document.set-field",
85
+ docId: value.docId,
86
+ field,
87
+ value: value.value,
88
+ expectedVersion,
89
+ };
90
+ }
91
+ /** Validate the complete structured-clone message before any shell work or confirmation UI. */
92
+ export function parseActionBridgeMessage(value) {
93
+ if (!isPlainRecord(value) || value.bridge !== ACTION_BRIDGE_PROTOCOL || typeof value.type !== "string")
94
+ return null;
95
+ const size = jsonSize(value);
96
+ const limit = value.type === "action.propose" && isPlainRecord(value.action) && ["document.set-body", "document.update"].includes(String(value.action.kind)) ? MAX_MESSAGE_BYTES : 8 * 1024;
97
+ if (size === null || size > limit)
98
+ return { ok: false, message: `action bridge message must be acyclic JSON of at most ${limit / 1024} KiB` };
99
+ if (value.type === "read-versioned") {
100
+ if (!exactKeys(value, ["bridge", "type", "id", "docId"]) || typeof value.id !== "string" || !value.id || value.id.length > 64 || !safeDocId(value.docId)) {
101
+ return { ok: false, message: "read-versioned requires exact bridge, type, id, and safe docId fields" };
102
+ }
103
+ return { ok: true, message: value };
104
+ }
105
+ if (value.type === "action.propose") {
106
+ if (!exactKeys(value, ["bridge", "type", "requestId", "action"]) || typeof value.requestId !== "string" || !value.requestId || value.requestId.length > 64) {
107
+ return { ok: false, message: "action.propose requires an exact non-empty requestId of at most 64 characters" };
108
+ }
109
+ try {
110
+ const action = parseDocumentAction(value.action);
111
+ return { ok: true, message: { bridge: ACTION_BRIDGE_PROTOCOL, type: "action.propose", requestId: value.requestId, action } };
112
+ }
113
+ catch {
114
+ return { ok: false, message: "action.propose requires one valid document.set-field or document.set-body action" };
115
+ }
116
+ }
117
+ return { ok: false, message: `unknown action bridge request '${value.type}'` };
118
+ }
119
+ export function actionReply(requestId, result) {
120
+ return { bridge: ACTION_BRIDGE_PROTOCOL, requestId, type: "action.result", result };
121
+ }
122
+ export function actionError(id, message) {
123
+ return { bridge: ACTION_BRIDGE_PROTOCOL, id, type: "error", error: { code: "REJECTED", message } };
124
+ }
125
+ //# sourceMappingURL=action-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-bridge.js","sourceRoot":"","sources":["../src/action-bridge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC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AAC,CAAC;YACjD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;QAC/H,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,kFAAkF,EAAE,CAAC;QACpH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,kCAAkC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAe;IAC5D,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAsB,EAAE,OAAe;IACjE,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;AACrG,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type KindRegistry } from "@superbee/core/kinds";
2
+ import type { OkfDocument } from "@superbee/core/storage";
3
+ import { type ActionScalar } from "./action-bridge.js";
4
+ export interface ViewActionPreparationContext {
5
+ registry: KindRegistry;
6
+ okfVersion: string | undefined;
7
+ actor: string;
8
+ producer?: string;
9
+ timestamp: string;
10
+ }
11
+ /** Host-neutral proposal policy. Hosts retain authority, confirmation, and final CAS. */
12
+ export declare function prepareViewDocumentAction(doc: OkfDocument, rawAction: unknown, options: ViewActionPreparationContext): {
13
+ action: import("./action-bridge.js").DocumentAction;
14
+ kind: import("@superbee/core/kinds").KindConvention;
15
+ storageField: string;
16
+ storageFields: {
17
+ [k: string]: string;
18
+ };
19
+ before: ActionScalar | null;
20
+ after: ActionScalar;
21
+ candidate: import("@superbee/core/document-mutation").DocumentMutationCandidate;
22
+ changed: boolean;
23
+ warnings: import("@superbee/core/kinds").ValidationWarning[];
24
+ guidance: import("@superbee/core/kinds").KindValueGuidance[];
25
+ };
26
+ //# sourceMappingURL=action-preparation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-preparation.d.ts","sourceRoot":"","sources":["../src/action-preparation.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAA8C,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnG,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,yFAAyF;AACzF,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,4BAA4B;;;;;;;;;;;;;EA0DpH"}
@@ -0,0 +1,76 @@
1
+ import { resolveOkfAuthoringVersion } from "@superbee/core/okf-authoring";
2
+ import { prepareDocumentFieldAction } from "@superbee/core/document-field-actions";
3
+ import { droppedLinks, prepareDocumentMutationCandidate } from "@superbee/core/document-mutation";
4
+ import { resolveKindFieldCoordinate } from "@superbee/core/kinds";
5
+ import { parseDocumentAction, MAX_ACTION_BODY_BYTES } from "./action-bridge.js";
6
+ function isActionScalar(value) {
7
+ return typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value));
8
+ }
9
+ /** Host-neutral proposal policy. Hosts retain authority, confirmation, and final CAS. */
10
+ export function prepareViewDocumentAction(doc, rawAction, options) {
11
+ const action = parseDocumentAction(rawAction);
12
+ const { registry, timestamp } = options;
13
+ const okfVersion = resolveOkfAuthoringVersion(options.okfVersion ?? "0.1");
14
+ const actor = options.actor.trim();
15
+ if (!actor)
16
+ throw new Error("set an action actor for this View host before proposing writes");
17
+ if (doc.id !== action.docId)
18
+ throw new Error("the action target does not match the loaded document");
19
+ if (["type", "timestamp", "actor"].includes(action.field))
20
+ throw new Error(`field '${action.field}' is shell-managed and cannot be proposed`);
21
+ const targetType = String(doc.frontmatter.type ?? "");
22
+ const kind = registry.kinds.get(targetType);
23
+ if (!kind)
24
+ throw new Error(`document '${action.docId}' is not governed by a declared Kind`);
25
+ const update = action.kind === "document.update";
26
+ const bodyAction = action.kind !== "document.set-field";
27
+ const proposedBody = action.kind === "document.update" ? action.value.body : bodyAction ? action.value : doc.body;
28
+ const updates = action.kind === "document.update" ? Object.entries(action.value.fields) : [];
29
+ const beforeFields = {};
30
+ const mapped = new Set();
31
+ for (const [field] of updates) {
32
+ const coordinate = resolveKindFieldCoordinate(okfVersion, kind, field);
33
+ if (["type", "timestamp", "actor"].includes(field) || !coordinate || mapped.has(coordinate.storageField))
34
+ throw new Error("update fields must be distinct declared scalar fields, not shell-managed fields");
35
+ mapped.add(coordinate.storageField);
36
+ const prior = doc.frontmatter[coordinate.storageField];
37
+ if (prior != null && (!isActionScalar(prior) || (typeof prior === "string" && new TextEncoder().encode(prior).byteLength > 4096)))
38
+ throw new Error("updates cannot replace non-scalar fields");
39
+ beforeFields[field] = prior == null ? null : prior;
40
+ }
41
+ const fieldCoordinate = bodyAction ? { storageField: action.field } : resolveKindFieldCoordinate(okfVersion, kind, action.field);
42
+ if (!fieldCoordinate) {
43
+ throw new Error(`field '${action.field}' is not declared by the '${kind.governs}' Kind`);
44
+ }
45
+ if (bodyAction && new TextEncoder().encode(doc.body).byteLength > MAX_ACTION_BODY_BYTES)
46
+ throw new Error("the existing body exceeds the 64 KiB confirmation limit");
47
+ if (bodyAction && droppedLinks(undefined, doc, proposedBody, okfVersion, undefined, "exact-edge").length > 0) {
48
+ throw new Error("body proposals must preserve existing cross-links; use the canonical link tools to change relationships");
49
+ }
50
+ const beforeRaw = update ? JSON.stringify({ fields: beforeFields, body: doc.body }, null, 2) : bodyAction ? doc.body : doc.frontmatter[fieldCoordinate.storageField];
51
+ let before;
52
+ if (beforeRaw === undefined || beforeRaw === null) {
53
+ before = null;
54
+ }
55
+ else if (!isActionScalar(beforeRaw)) {
56
+ throw new Error(`field '${action.field}' currently contains a non-scalar value; trusted scalar actions cannot replace it`);
57
+ }
58
+ else {
59
+ before = beforeRaw;
60
+ }
61
+ const context = { registry, okfVersion, now: () => timestamp };
62
+ let candidate = action.kind === "document.set-field"
63
+ ? prepareDocumentFieldAction(doc, { action: "set", field: action.field, value: action.value }, context).candidate
64
+ : { frontmatter: doc.frontmatter, body: proposedBody };
65
+ for (const [field, value] of updates)
66
+ candidate = prepareDocumentFieldAction({ ...doc, ...candidate }, { action: "set", field, value }, context).candidate;
67
+ const prepared = prepareDocumentMutationCandidate(doc, candidate, {
68
+ ...context, id: action.docId, strict: true, actor, producer: options.producer, persistActor: true,
69
+ });
70
+ const storageFields = Object.fromEntries(updates.map(([field]) => [field, resolveKindFieldCoordinate(okfVersion, kind, field).storageField]));
71
+ return {
72
+ ...prepared, action, kind, storageField: fieldCoordinate.storageField, storageFields, before,
73
+ after: action.kind === "document.update" ? JSON.stringify({ fields: action.value.fields, body: prepared.candidate.body }, null, 2) : bodyAction ? prepared.candidate.body : action.value,
74
+ };
75
+ }
76
+ //# sourceMappingURL=action-preparation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-preparation.js","sourceRoot":"","sources":["../src/action-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,gCAAgC,E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O,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI;KAClG,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/I,OAAO;QACL,GAAG,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM;QAC5F,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAqB;KACzM,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./view-bridge-host.js";
2
+ export { viewFrameHeaders, viewFramePolicy } from "./view-frame.js";
3
+ export { readQueryPages, VIEW_QUERY_MAX_ROWS, QUERY_PAGE_ROWS } from "./query-pages.js";
4
+ export type { QueryPage, QueryPageReader, QuerySkipped } from "./query-pages.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxF,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./view-bridge-host.js";
2
+ export { viewFrameHeaders, viewFramePolicy } from "./view-frame.js";
3
+ export { readQueryPages, VIEW_QUERY_MAX_ROWS, QUERY_PAGE_ROWS } from "./query-pages.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /** The most rows a View's `query` answers (`limits.query`), and the default when `limit` is 0. */
2
+ export declare const VIEW_QUERY_MAX_ROWS = 500;
3
+ /** `documents.query.v1`'s own row ceiling per call, and so the size of one page and of a `newest`
4
+ * reply. */
5
+ export declare const QUERY_PAGE_ROWS = 100;
6
+ /** A document the operation left out, with its reason. */
7
+ export interface QuerySkipped {
8
+ id: string;
9
+ reason: string;
10
+ }
11
+ /** What one `documents.query.v1` call answers, as the walk reads it. */
12
+ export interface QueryPage<Row extends {
13
+ id: string;
14
+ }> {
15
+ documents: readonly Row[];
16
+ skipped?: readonly QuerySkipped[];
17
+ count?: number;
18
+ }
19
+ /** Runs `documents.query.v1` once with `input` and answers its data, or throws. */
20
+ export type QueryPageReader<Row extends {
21
+ id: string;
22
+ }> = (input: Record<string, unknown>) => Promise<QueryPage<Row>>;
23
+ /**
24
+ * Up to `limit` rows (1 to {@link VIEW_QUERY_MAX_ROWS}) matching `selection`: the operation's input
25
+ * without `limit`, `after` or `count` (`type`, `prefix`, `fieldsAnyOf`, `open`, `order`). `skipped`
26
+ * holds each document the reads left out once, in id order. `more` is `count > rows.length`.
27
+ */
28
+ export declare function readQueryPages<Row extends {
29
+ id: string;
30
+ }>(read: QueryPageReader<Row>, selection: Record<string, unknown>, limit: number): Promise<{
31
+ rows: Row[];
32
+ count: number;
33
+ skipped: QuerySkipped[];
34
+ }>;
35
+ //# sourceMappingURL=query-pages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-pages.d.ts","sourceRoot":"","sources":["../src/query-pages.ts"],"names":[],"mappings":"AAsBA,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC;YACY;AACZ,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,wEAAwE;AACxE,MAAM,WAAW,SAAS,CAAC,GAAG,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IACnD,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,mFAAmF;AACnF,MAAM,MAAM,eAAe,CAAC,GAAG,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtH;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,GAAG,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC7D,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC,EAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAyClE"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * A View's `query` read from `documents.query.v1`, a page at a time: the one paging rule every View
3
+ * host shares (the local View bridge in `view-runtime` and this package's operation-mapped host), so
4
+ * one View gets the same rows, `count` and `more` on each.
5
+ *
6
+ * The operation answers at most 100 rows a call and pages only in id order (`after`). A View may ask
7
+ * for up to 500. In id order the walk reads pages of at most 100, each starting after the last id of
8
+ * the one before, until a page comes back short or `limit` rows are in. `order: "newest"` is one page,
9
+ * because the operation refuses `after` with `newest`.
10
+ *
11
+ * The pages are separate reads, not one snapshot: a document written between pages is answered at
12
+ * whichever version its page read, or missed when its id sorts before a page already read, and never
13
+ * answered twice. `count` is the rows when the walk ended short (it holds every match); when the walk
14
+ * filled what it asked for, one more read counts the rest (past the last id in id order, everything
15
+ * for `newest`), and `count` never reads below the rows answered.
16
+ *
17
+ * A failing read fails the whole query: the error `read` throws is thrown here, and no partial rows
18
+ * are returned. So does a page whose last id does not sort after the one before (an operation
19
+ * that ignored `after`), rather than reading it again forever.
20
+ */
21
+ import { compareCodeUnits } from "@superbee/core/code-unit-order";
22
+ /** The most rows a View's `query` answers (`limits.query`), and the default when `limit` is 0. */
23
+ export const VIEW_QUERY_MAX_ROWS = 500;
24
+ /** `documents.query.v1`'s own row ceiling per call, and so the size of one page and of a `newest`
25
+ * reply. */
26
+ export const QUERY_PAGE_ROWS = 100;
27
+ /**
28
+ * Up to `limit` rows (1 to {@link VIEW_QUERY_MAX_ROWS}) matching `selection`: the operation's input
29
+ * without `limit`, `after` or `count` (`type`, `prefix`, `fieldsAnyOf`, `open`, `order`). `skipped`
30
+ * holds each document the reads left out once, in id order. `more` is `count > rows.length`.
31
+ */
32
+ export async function readQueryPages(read, selection, limit) {
33
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > VIEW_QUERY_MAX_ROWS)
34
+ throw new RangeError(`limit must be 1 to ${VIEW_QUERY_MAX_ROWS}`);
35
+ const newest = selection.order === "newest";
36
+ const rows = new Map();
37
+ const skipped = new Map();
38
+ const note = (page) => {
39
+ for (const { id, reason } of page.skipped ?? [])
40
+ if (!skipped.has(id))
41
+ skipped.set(id, reason);
42
+ };
43
+ let after = "";
44
+ let filled;
45
+ for (;;) {
46
+ const want = Math.min(QUERY_PAGE_ROWS, limit - rows.size);
47
+ const page = await read({ ...selection, limit: want, ...(newest ? {} : { after }) });
48
+ note(page);
49
+ // Each page starts after the last id of the one before, so an id is answered once.
50
+ for (const row of page.documents)
51
+ if (!rows.has(row.id))
52
+ rows.set(row.id, row);
53
+ const last = page.documents.at(-1);
54
+ filled = page.documents.length >= want;
55
+ if (!filled || newest || last === undefined || rows.size >= limit)
56
+ break;
57
+ // A page that does not move past `after` would be read again forever; fail the query instead.
58
+ if (compareCodeUnits(last.id, after) <= 0)
59
+ throw new Error("documents.query.v1 answered a page that did not advance");
60
+ after = last.id;
61
+ }
62
+ const answered = [...rows.values()];
63
+ let count = answered.length;
64
+ if (filled) {
65
+ const last = answered.at(-1);
66
+ const rest = newest || last === undefined ? {} : { after: last.id };
67
+ const total = await read({ ...selection, ...rest, count: true });
68
+ note(total);
69
+ const counted = total.count ?? 0;
70
+ count = "after" in rest ? answered.length + counted : Math.max(counted, answered.length);
71
+ }
72
+ return {
73
+ rows: answered,
74
+ count,
75
+ skipped: [...skipped]
76
+ .map(([id, reason]) => ({ id, reason }))
77
+ .sort((a, b) => compareCodeUnits(a.id, b.id)),
78
+ };
79
+ }
80
+ //# sourceMappingURL=query-pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-pages.js","sourceRoot":"","sources":["../src/query-pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,kGAAkG;AAClG,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC;YACY;AACZ,MAAM,CAAC,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AAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,KAAK;QACL,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;aAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;aACvC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** A read adapter's own refusal, apart from any schemas that raise it, so a module that only
2
+ * recognizes it (the View bridge host) loads no schema library. An adapter that checks the shape of
3
+ * an operation's result throws this class, so the host tells a malformed result (`RUNTIME`) from a
4
+ * result-size ceiling (`TOO_LARGE`), which throws a plain `Error("invalid_response")`. */
5
+ export declare class ReadAdapterError extends Error {
6
+ readonly code: "invalid_input" | "invalid_response";
7
+ constructor(code: "invalid_input" | "invalid_response");
8
+ }
9
+ //# sourceMappingURL=read-adapter-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-adapter-error.d.ts","sourceRoot":"","sources":["../src/read-adapter-error.ts"],"names":[],"mappings":"AAAA;;;0FAG0F;AAC1F,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,kBAAkB;gBAA1C,IAAI,EAAE,eAAe,GAAG,kBAAkB;CAGhE"}
@@ -0,0 +1,12 @@
1
+ /** A read adapter's own refusal, apart from any schemas that raise it, so a module that only
2
+ * recognizes it (the View bridge host) loads no schema library. An adapter that checks the shape of
3
+ * an operation's result throws this class, so the host tells a malformed result (`RUNTIME`) from a
4
+ * result-size ceiling (`TOO_LARGE`), which throws a plain `Error("invalid_response")`. */
5
+ export class ReadAdapterError extends Error {
6
+ code;
7
+ constructor(code) {
8
+ super(code);
9
+ this.code = code;
10
+ }
11
+ }
12
+ //# sourceMappingURL=read-adapter-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-adapter-error.js","sourceRoot":"","sources":["../src/read-adapter-error.ts"],"names":[],"mappings":"AAAA;;;0FAG0F;AAC1F,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACpB;IAArB,YAAqB,IAA0C;QAC7D,KAAK,CAAC,IAAI,CAAC,CAAC;QADO,SAAI,GAAJ,IAAI,CAAsC;IAE/D,CAAC;CACF"}