@superbee/core 0.4.10 → 0.4.11-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.
Files changed (94) hide show
  1. package/README.md +3 -422
  2. package/dist/body-pages.js +2 -2
  3. package/dist/body-pages.js.map +1 -1
  4. package/dist/builtin-recipes/content.js +7 -7
  5. package/dist/builtin-recipes/content.js.map +1 -1
  6. package/dist/content-type.d.ts +1 -2
  7. package/dist/content-type.d.ts.map +1 -1
  8. package/dist/content-type.js +1 -2
  9. package/dist/content-type.js.map +1 -1
  10. package/dist/document-mutation.d.ts.map +1 -1
  11. package/dist/document-mutation.js +3 -4
  12. package/dist/document-mutation.js.map +1 -1
  13. package/dist/hosted-transport/answer-rows.js +3 -3
  14. package/dist/hosted-transport/answer-rows.js.map +1 -1
  15. package/dist/hosted-transport/attribution.d.ts +3 -3
  16. package/dist/hosted-transport/attribution.d.ts.map +1 -1
  17. package/dist/hosted-transport/attribution.js +3 -3
  18. package/dist/hosted-transport/attribution.js.map +1 -1
  19. package/dist/hosted-transport/index.d.ts +1 -1
  20. package/dist/hosted-transport/index.js +1 -1
  21. package/dist/hosted-transport/port-run.d.ts +2 -2
  22. package/dist/hosted-transport/port-run.js +2 -2
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/kinds.d.ts +4 -4
  26. package/dist/kinds.js +4 -4
  27. package/dist/kinds.js.map +1 -1
  28. package/dist/portable-export.js +1 -1
  29. package/dist/portable-export.js.map +1 -1
  30. package/dist/recipe-lifecycle/legacy-aliases.js +1 -1
  31. package/dist/recipe-lifecycle/legacy-aliases.js.map +1 -1
  32. package/dist/remote.d.ts +1 -1
  33. package/dist/remote.d.ts.map +1 -1
  34. package/dist/remote.js +1 -1
  35. package/dist/remote.js.map +1 -1
  36. package/dist/validation.d.ts +1 -1
  37. package/dist/validation.js +1 -1
  38. package/package.json +1 -9
  39. package/dist/hosted-client/binding.d.ts +0 -7
  40. package/dist/hosted-client/binding.d.ts.map +0 -1
  41. package/dist/hosted-client/binding.js +0 -10
  42. package/dist/hosted-client/binding.js.map +0 -1
  43. package/dist/hosted-client/blob-delivery.d.ts +0 -68
  44. package/dist/hosted-client/blob-delivery.d.ts.map +0 -1
  45. package/dist/hosted-client/blob-delivery.js +0 -170
  46. package/dist/hosted-client/blob-delivery.js.map +0 -1
  47. package/dist/hosted-client/blob-write.d.ts +0 -387
  48. package/dist/hosted-client/blob-write.d.ts.map +0 -1
  49. package/dist/hosted-client/blob-write.js +0 -770
  50. package/dist/hosted-client/blob-write.js.map +0 -1
  51. package/dist/hosted-client/bundle-listing.d.ts +0 -46
  52. package/dist/hosted-client/bundle-listing.d.ts.map +0 -1
  53. package/dist/hosted-client/bundle-listing.js +0 -36
  54. package/dist/hosted-client/bundle-listing.js.map +0 -1
  55. package/dist/hosted-client/client.d.ts +0 -249
  56. package/dist/hosted-client/client.d.ts.map +0 -1
  57. package/dist/hosted-client/client.js +0 -381
  58. package/dist/hosted-client/client.js.map +0 -1
  59. package/dist/hosted-client/directory.d.ts +0 -46
  60. package/dist/hosted-client/directory.d.ts.map +0 -1
  61. package/dist/hosted-client/directory.js +0 -74
  62. package/dist/hosted-client/directory.js.map +0 -1
  63. package/dist/hosted-client/errors.d.ts +0 -26
  64. package/dist/hosted-client/errors.d.ts.map +0 -1
  65. package/dist/hosted-client/errors.js +0 -35
  66. package/dist/hosted-client/errors.js.map +0 -1
  67. package/dist/hosted-client/inbox.d.ts +0 -320
  68. package/dist/hosted-client/inbox.d.ts.map +0 -1
  69. package/dist/hosted-client/inbox.js +0 -379
  70. package/dist/hosted-client/inbox.js.map +0 -1
  71. package/dist/hosted-client/index.d.ts +0 -31
  72. package/dist/hosted-client/index.d.ts.map +0 -1
  73. package/dist/hosted-client/index.js +0 -33
  74. package/dist/hosted-client/index.js.map +0 -1
  75. package/dist/hosted-client/journal.d.ts +0 -103
  76. package/dist/hosted-client/journal.d.ts.map +0 -1
  77. package/dist/hosted-client/journal.js +0 -464
  78. package/dist/hosted-client/journal.js.map +0 -1
  79. package/dist/hosted-client/node.d.ts +0 -74
  80. package/dist/hosted-client/node.d.ts.map +0 -1
  81. package/dist/hosted-client/node.js +0 -219
  82. package/dist/hosted-client/node.js.map +0 -1
  83. package/dist/hosted-client/reference.d.ts +0 -12
  84. package/dist/hosted-client/reference.d.ts.map +0 -1
  85. package/dist/hosted-client/reference.js +0 -29
  86. package/dist/hosted-client/reference.js.map +0 -1
  87. package/dist/hosted-client/view-content.d.ts +0 -184
  88. package/dist/hosted-client/view-content.d.ts.map +0 -1
  89. package/dist/hosted-client/view-content.js +0 -268
  90. package/dist/hosted-client/view-content.js.map +0 -1
  91. package/dist/hosted-client/write.d.ts +0 -219
  92. package/dist/hosted-client/write.d.ts.map +0 -1
  93. package/dist/hosted-client/write.js +0 -419
  94. package/dist/hosted-client/write.js.map +0 -1
@@ -1,268 +0,0 @@
1
- // A registered View's page (its `entry`, under `views/`) read and replaced whole on a hosted bundle:
2
- // `<prefix>/view-content-read` (`views.content.read.v1`) and `<prefix>/view-content-update`
3
- // (`views.content.update.v1`). Both are pinned to the registration's version, and an update to the
4
- // page's own version as well, so neither reads or replaces a page the caller did not look at.
5
- // `<prefix>/view-create` (`views.create.v1`) adds a new View: the host builds the registration
6
- // (`views-registry/<name>`) and stores the page (`views/<name>.html`) together, both expecting
7
- // absence; the caller names the View, never a path.
8
- //
9
- // A page's version is `sha256:<hex>` of its exact UTF-8 bytes (`blobVersion`), the same digest a
10
- // Portal site pins as `entrySha256`. Every answer is checked against the bytes it describes (a
11
- // read's html against its version and byte count, an update's version against the html sent), so
12
- // a stored page is never reported under a version it does not have. Uploading never approves
13
- // execution: that stays a separate act (a hosted app slot's approval, a site's pin).
14
- import { isAnyEntryKey, isAnyRegistryId, isViewEntryKey, isViewRegistryId, parseRegistration, VIEW_ENTRY_PREFIX, VIEW_REGISTRY_PREFIX } from "../page.js";
15
- import { malformed } from "../remote-error.js";
16
- import { sha256HexOfBytes } from "../sha256.js";
17
- import { REFUSAL_CODE } from "../hosted-transport/index.js";
18
- import { stripHostText } from "../host-text.js";
19
- export const VIEW_CONTENT_READ_OPERATION = "views.content.read.v1";
20
- export const VIEW_CONTENT_UPDATE_OPERATION = "views.content.update.v1";
21
- export const VIEW_CREATE_OPERATION = "views.create.v1";
22
- /** The largest page an update sends: 512 KiB of UTF-8, the host's bound. */
23
- export const VIEW_CONTENT_MAX_BYTES = 512 * 1024;
24
- /** A read's answer: the page and its envelope, at most the page's bound as JSON (escapes included) plus slack. */
25
- export const VIEW_CONTENT_READ_ANSWER_BYTES = 6 * VIEW_CONTENT_MAX_BYTES + 64 * 1024;
26
- /** An update's answer carries no html; neither does a create's. */
27
- export const VIEW_CONTENT_UPDATE_ANSWER_BYTES = 64 * 1024;
28
- /**
29
- * A created View's name, as the host's View listing admits it: the registration is
30
- * `views-registry/<name>` and its page `views/<name>.html`. Narrower than the registry-id grammar
31
- * ({@link isViewRegistryId}), which every derived id must still pass.
32
- */
33
- export const VIEW_CREATE_NAME = /^[a-z][a-z0-9-]{0,54}$/;
34
- /** A created View's title and description bounds (trimmed), as the host's listing shows them. */
35
- export const VIEW_TITLE_MAX_CHARS = 120;
36
- export const VIEW_DESCRIPTION_MAX_CHARS = 320;
37
- /** The access a created View may declare; `bundle-read` unless the caller says otherwise. */
38
- export const VIEW_CREATE_ACCESS = ["bundle-read", "none"];
39
- const VERSION = /^sha256:[0-9a-f]{64}$/;
40
- const REQUEST_ID = /^[\x21-\x7e]{1,256}$/;
41
- const CONTENT_TYPE = /^[\x20-\x7e]{1,256}$/;
42
- const REFUSAL_MESSAGE_CHARS = 500;
43
- /** True for a version token in the content-version grammar (`sha256:` and 64 lowercase hex digits). */
44
- export function isViewContentVersion(value) {
45
- return typeof value === "string" && VERSION.test(value);
46
- }
47
- /** The version of a page's exact UTF-8 bytes. */
48
- export function viewContentVersion(bytes) {
49
- return `sha256:${sha256HexOfBytes(bytes)}`;
50
- }
51
- /** The refusal an update reports when it sent its request and read no answer it could trust. */
52
- export const WRITE_OUTCOME_UNKNOWN = "write_outcome_unknown";
53
- /** An update whose outcome is not known: the request may have left and been applied. */
54
- export function unknownOutcome(status, message) {
55
- return Object.freeze({ code: WRITE_OUTCOME_UNKNOWN, status, message, writeState: "unknown", retryable: false });
56
- }
57
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
58
- /** A request's fields, refused before sending when they are not what the host admits. */
59
- export function viewContentReadBody(bundleId, request) {
60
- if (!isAnyRegistryId(request.registryId))
61
- throw new RangeError("a View content request names a View registration id (views-registry/...)");
62
- if (!isViewContentVersion(request.expectedRegistryVersion))
63
- throw new RangeError("a View content request pins the registration's sha256 version");
64
- return { bundleId, registryId: request.registryId, expectedRegistryVersion: request.expectedRegistryVersion };
65
- }
66
- /** An update's fields and the exact bytes it sends, refused before sending as the read's are, and when the page is over its bound. */
67
- export function viewContentUpdateBody(bundleId, request) {
68
- const read = viewContentReadBody(bundleId, request);
69
- if (!isViewContentVersion(request.expectedContentVersion))
70
- throw new RangeError("a View content update pins the page's sha256 version");
71
- const bytes = viewPageBytes(request.html);
72
- return { body: { ...read, expectedContentVersion: request.expectedContentVersion, html: request.html }, bytes };
73
- }
74
- /** A page's exact UTF-8 bytes, refused when the text has no exact UTF-8 form or is over the bound. */
75
- function viewPageBytes(html) {
76
- if (typeof html !== "string")
77
- throw new TypeError("a View page is sent as text");
78
- const bytes = new TextEncoder().encode(html);
79
- // A lone surrogate has no UTF-8 form: the encoder would send U+FFFD, not the text given.
80
- if (new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes) !== html)
81
- throw new RangeError("a View page must be valid Unicode text");
82
- if (bytes.byteLength > VIEW_CONTENT_MAX_BYTES)
83
- throw new RangeError(`a View page is at most ${VIEW_CONTENT_MAX_BYTES} bytes of UTF-8`);
84
- return bytes;
85
- }
86
- /**
87
- * The registration id and page key a create names, or null for a name outside
88
- * {@link VIEW_CREATE_NAME}. Both also pass the View registration grammar ({@link parseRegistration}),
89
- * so a View this creates is one every local surface reads as registered.
90
- */
91
- export function viewCreateTarget(name) {
92
- if (typeof name !== "string" || !VIEW_CREATE_NAME.test(name))
93
- return null;
94
- const registryId = `${VIEW_REGISTRY_PREFIX}${name}`;
95
- const key = `${VIEW_ENTRY_PREFIX}${name}.html`;
96
- if (!isViewRegistryId(registryId) || !isViewEntryKey(key) || parseRegistration(registryId, { type: "View", entry: key }) === null)
97
- return null;
98
- return { registryId, key };
99
- }
100
- /** Why a title or description is not one a created View may carry, or null when it is. */
101
- export function viewCreateTextProblem(field, value) {
102
- const max = field === "title" ? VIEW_TITLE_MAX_CHARS : VIEW_DESCRIPTION_MAX_CHARS;
103
- const trimmed = value.trim();
104
- if (trimmed === "")
105
- return `a View's ${field} is not empty`;
106
- if (trimmed.length > max)
107
- return `a View's ${field} is at most ${max} characters`;
108
- return null;
109
- }
110
- /**
111
- * A create's fields and the exact page bytes it sends, refused before sending when the host would
112
- * refuse them: a name outside the grammar, an empty or long title or description, an access value
113
- * other than {@link VIEW_CREATE_ACCESS}, or a page that is not UTF-8 text within the bound. The
114
- * title and description are sent trimmed; `access` is always sent.
115
- */
116
- export function viewCreateBody(bundleId, request) {
117
- const target = viewCreateTarget(request.name);
118
- if (!target)
119
- throw new RangeError("a View's name is a lowercase letter then up to 54 lowercase letters, digits or hyphens");
120
- if (typeof request.title !== "string")
121
- throw new TypeError("a View's title is text");
122
- const titleProblem = viewCreateTextProblem("title", request.title);
123
- if (titleProblem)
124
- throw new RangeError(titleProblem);
125
- if (request.description !== undefined) {
126
- if (typeof request.description !== "string")
127
- throw new TypeError("a View's description is text");
128
- const problem = viewCreateTextProblem("description", request.description);
129
- if (problem)
130
- throw new RangeError(problem);
131
- }
132
- const access = request.access ?? "bundle-read";
133
- if (!VIEW_CREATE_ACCESS.includes(access))
134
- throw new RangeError(`a created View's access is ${VIEW_CREATE_ACCESS.join(" or ")}`);
135
- const bytes = viewPageBytes(request.html);
136
- return {
137
- body: { bundleId, name: request.name, title: request.title.trim(), ...(request.description === undefined ? {} : { description: request.description.trim() }), access, html: request.html },
138
- bytes,
139
- ...target,
140
- };
141
- }
142
- /**
143
- * The refusal an answer carries (`ok: false` naming `operationId`), or undefined for an answer
144
- * that is not one. An `ok: false` envelope naming another operation, or a code outside the
145
- * refusal grammar, is malformed. `defaultWriteState` is what a refusal that states none means.
146
- */
147
- export function viewContentRefusal(status, body, operationId, defaultWriteState, route) {
148
- if (!isRecord(body) || body.ok !== false)
149
- return undefined;
150
- const error = body.error;
151
- if (body.operationId !== operationId || !isRecord(error) || typeof error.code !== "string" || !REFUSAL_CODE.test(error.code)) {
152
- throw malformed(`answered a refusal that is not ${operationId}'s`, route);
153
- }
154
- const writeState = error.writeState === "not_applied" || error.writeState === "unknown" ? error.writeState : defaultWriteState;
155
- const text = typeof error.message === "string" ? stripHostText(error.message, REFUSAL_MESSAGE_CHARS) : "";
156
- const pinned = (value) => (value === null ? null : isViewContentVersion(value) ? value : undefined);
157
- const expected = pinned(error.expected);
158
- const actual = pinned(error.actual);
159
- return Object.freeze({
160
- code: error.code,
161
- status,
162
- message: text === "" ? error.code : text,
163
- writeState,
164
- retryable: error.retryable === true,
165
- ...(error.target === "registry" || error.target === "content" ? { target: error.target } : {}),
166
- ...(expected !== undefined ? { expected } : {}),
167
- ...(actual !== undefined ? { actual } : {}),
168
- });
169
- }
170
- function common(data, bundleId, request, fail) {
171
- if (data.bundleId !== bundleId)
172
- fail("an answer for another bundle");
173
- if (data.registryId !== request.registryId)
174
- fail("an answer for another View");
175
- if (data.registryVersion !== request.expectedRegistryVersion)
176
- fail("an answer at another registration version");
177
- if (!isAnyEntryKey(data.key))
178
- fail("a key that is not a View entry");
179
- if (!isViewContentVersion(data.version))
180
- fail("a version that is not a sha256 version");
181
- if (typeof data.contentType !== "string" || !CONTENT_TYPE.test(data.contentType))
182
- fail("no content type");
183
- const byteCount = data.byteCount;
184
- if (typeof byteCount !== "number" || !Number.isSafeInteger(byteCount) || byteCount < 0)
185
- fail("a byte count that is not a count");
186
- return { bundleId, registryId: request.registryId, registryVersion: request.expectedRegistryVersion, key: data.key, version: data.version, contentType: data.contentType, byteCount: byteCount };
187
- }
188
- /**
189
- * A read's `200` answer, for the View asked for: its html must have exactly the stated byte count
190
- * and version, or the answer is malformed.
191
- */
192
- export function decodeViewContentRead(bundleId, request, body, route) {
193
- const fail = (why) => {
194
- throw malformed(`view-content-read answered ${why}`, route);
195
- };
196
- const data = isRecord(body) && body.ok === true && body.operationId === VIEW_CONTENT_READ_OPERATION && isRecord(body.data) ? body.data : fail(`an envelope that is not ${VIEW_CONTENT_READ_OPERATION}'s result`);
197
- const fields = common(data, bundleId, request, fail);
198
- if (typeof data.html !== "string")
199
- fail("no html");
200
- const bytes = new TextEncoder().encode(data.html);
201
- if (bytes.byteLength !== fields.byteCount)
202
- fail("html whose length is not its byte count");
203
- if (viewContentVersion(bytes) !== fields.version)
204
- fail("html whose digest is not its version");
205
- return Object.freeze({ ...fields, html: data.html });
206
- }
207
- /**
208
- * An update's `200` answer, for the update sent: its version must be the digest of the bytes sent
209
- * (an unchanged page's previous version is the same), or the answer is malformed.
210
- */
211
- export function decodeViewContentUpdate(bundleId, request, sent, body, route) {
212
- const fail = (why) => {
213
- throw malformed(`view-content-update answered ${why}`, route);
214
- };
215
- const data = isRecord(body) && body.ok === true && body.operationId === VIEW_CONTENT_UPDATE_OPERATION && isRecord(body.data) ? body.data : fail(`an envelope that is not ${VIEW_CONTENT_UPDATE_OPERATION}'s result`);
216
- const fields = common(data, bundleId, request, fail);
217
- if (typeof data.changed !== "boolean")
218
- fail("no changed flag");
219
- if (!isViewContentVersion(data.previousVersion))
220
- fail("a previous version that is not a sha256 version");
221
- if (typeof data.requestId !== "string" || !REQUEST_ID.test(data.requestId))
222
- fail("no request id");
223
- if (fields.version !== viewContentVersion(sent) || fields.byteCount !== sent.byteLength)
224
- fail("a version other than the page sent");
225
- if (!data.changed && data.previousVersion !== fields.version)
226
- fail("an unchanged page whose previous version differs");
227
- if (data.changed && data.previousVersion === fields.version)
228
- fail("a changed page whose previous version is the same");
229
- return Object.freeze({ ...fields, changed: data.changed, previousVersion: data.previousVersion, requestId: data.requestId });
230
- }
231
- /**
232
- * A create's `200` answer, for the create sent: the View named, its derived page key, and the
233
- * version and size of the bytes sent, or the answer is malformed.
234
- */
235
- export function decodeViewCreate(bundleId, target, sent, body, route) {
236
- const fail = (why) => {
237
- throw malformed(`view-create answered ${why}`, route);
238
- };
239
- const data = isRecord(body) && body.ok === true && body.operationId === VIEW_CREATE_OPERATION && isRecord(body.data) ? body.data : fail(`an envelope that is not ${VIEW_CREATE_OPERATION}'s result`);
240
- if (data.bundleId !== bundleId)
241
- fail("an answer for another bundle");
242
- if (data.registryId !== target.registryId)
243
- fail("an answer for another View");
244
- if (data.key !== target.key)
245
- fail("a page key other than the View's");
246
- if (!isViewContentVersion(data.registryVersion))
247
- fail("a registration version that is not a sha256 version");
248
- if (data.version !== viewContentVersion(sent) || data.byteCount !== sent.byteLength)
249
- fail("a version other than the page sent");
250
- if (typeof data.contentType !== "string" || !CONTENT_TYPE.test(data.contentType))
251
- fail("no content type");
252
- if (typeof data.created !== "boolean")
253
- fail("no created flag");
254
- if (typeof data.requestId !== "string" || !REQUEST_ID.test(data.requestId))
255
- fail("no request id");
256
- return Object.freeze({
257
- bundleId,
258
- registryId: target.registryId,
259
- registryVersion: data.registryVersion,
260
- key: target.key,
261
- version: data.version,
262
- byteCount: sent.byteLength,
263
- contentType: data.contentType,
264
- created: data.created,
265
- requestId: data.requestId,
266
- });
267
- }
268
- //# sourceMappingURL=view-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view-content.js","sourceRoot":"","sources":["../../src/hosted-client/view-content.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,4FAA4F;AAC5F,mGAAmG;AACnG,8FAA8F;AAC9F,+FAA+F;AAC/F,+FAA+F;AAC/F,oDAAoD;AACpD,EAAE;AACF,iGAAiG;AACjG,+FAA+F;A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,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU;QAAE,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAChI,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC1G,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC/D,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ;QACR,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,eAAe,EAAE,IAAI,CAAC,eAAyB;QAC/C,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,IAAI,CAAC,OAAiB;QAC/B,SAAS,EAAE,IAAI,CAAC,UAAU;QAC1B,WAAW,EAAE,IAAI,CAAC,WAAqB;QACvC,OAAO,EAAE,IAAI,CAAC,OAAkB;QAChC,SAAS,EAAE,IAAI,CAAC,SAAmB;KACpC,CAAC,CAAC;AACL,CAAC"}
@@ -1,219 +0,0 @@
1
- import { type HostedCarrier, type HostedCapabilities, type HostedReadAdapter, type HostedReadRoutes, type HostedRunDecisions, type WriteErrorCode } from "../hosted-transport/index.js";
2
- import type { Version } from "../types.js";
3
- import { type OperationState } from "../uncertain-write.js";
4
- /** What one write asks: a create of an absent document, or a replace at exactly `expectedVersion`. */
5
- export type HostedWriteInput = {
6
- readonly id: string;
7
- readonly document: string;
8
- readonly expectedVersion: Version;
9
- readonly expectAbsent?: never;
10
- } | {
11
- readonly id: string;
12
- readonly document: string;
13
- readonly expectAbsent: true;
14
- readonly expectedVersion?: never;
15
- };
16
- export interface HostedWriteOptions {
17
- /**
18
- * The request identity to send under, a lowercase UUID v4. Default: a fresh one. Pass the
19
- * identity of a write this client's intent store holds to confirm it again: the same write
20
- * resumes under that identity (nothing new is applied), and a different write is refused.
21
- */
22
- readonly requestId?: string;
23
- /** Ends this write's requests; an abort after sending leaves the outcome unknown. */
24
- readonly signal?: AbortSignal;
25
- }
26
- /**
27
- * A recorded write, everything its outcome lookup needs to rebuild the exact request: the
28
- * operation, the bundle (and the workspace it was named in), the document and its digest, the
29
- * precondition, the request identity and the binding.
30
- */
31
- export interface HostedWriteIntent {
32
- readonly requestId: string;
33
- /** The client binding (`X-Superbee-Checkout`) the write and every lookup of it carry. */
34
- readonly binding: string;
35
- readonly bundleId: string;
36
- /** The workspace slug the bundle was named in (`within`), or null. */
37
- readonly workspace: string | null;
38
- readonly operation: "create" | "replace";
39
- readonly documentId: string;
40
- /** The whole serialized document, as sent. */
41
- readonly document: string;
42
- /** `sha256:<hex>` of the document's UTF-8 bytes. */
43
- readonly digest: Version;
44
- /** The version replaced, or null for a create. */
45
- readonly expectedVersion: Version | null;
46
- /** The bundle's OKF edition the document was parsed under, or null when the bundle names none. */
47
- readonly okfVersion: string | null;
48
- /** When the intent was recorded (ISO instant): its age decides whether absence is still evidence. */
49
- readonly createdAt: string;
50
- /** Submissions made or about to leave; a non-zero count starts any later delivery at the lookup. */
51
- readonly attempts: number;
52
- readonly state: OperationState;
53
- }
54
- /**
55
- * Where a client keeps its writes until they settle. The default is in memory
56
- * ({@link createMemoryIntentStore}); a service that must recover a write across restarts passes
57
- * a durable one. `put` replaces the record under its request identity; a settled write is
58
- * deleted, and a write whose outcome is unknown stays for `lookupWrite` and `settleWrite`.
59
- * `list`, when the store has it, yields every record it holds, so a service restarting with a
60
- * durable store finds its unsettled writes (`heldWrites`).
61
- */
62
- export interface HostedIntentStore {
63
- put(intent: HostedWriteIntent): Promise<void> | void;
64
- get(requestId: string): Promise<HostedWriteIntent | undefined> | HostedWriteIntent | undefined;
65
- delete(requestId: string): Promise<void> | void;
66
- list?(): AsyncIterable<HostedWriteIntent>;
67
- }
68
- /** An in-memory {@link HostedIntentStore}: records live as long as the store. */
69
- export declare function createMemoryIntentStore(): HostedIntentStore;
70
- /** The code of {@link HostedIntentsNotListable}. */
71
- export declare const INTENTS_NOT_LISTABLE = "INTENTS_NOT_LISTABLE";
72
- /** `heldWrites` was asked of a client whose intent store has no `list`. */
73
- export declare class HostedIntentsNotListable extends Error {
74
- readonly code = "INTENTS_NOT_LISTABLE";
75
- constructor();
76
- }
77
- /** A refusal's code: the host's own (`validation_failed`, ...) or one the client names. */
78
- export type HostedWriteRefusalCode = "AUTH_REQUIRED" | "PERMISSION_DENIED" | "REQUEST_CAPACITY_PRINCIPAL" | "REQUEST_CAPACITY_BUNDLE"
79
- /** The host serves this bundle no identified writes. */
80
- | "read_only" | "unsupported_operation" | WriteErrorCode | (string & {});
81
- interface WriteResultBase {
82
- readonly requestId: string;
83
- readonly documentId: string;
84
- }
85
- /**
86
- * A write's settled answer, or `unknown`. A conflict is final for this request identity: nothing
87
- * was written, and a further attempt is the caller's decision, as a new write.
88
- */
89
- export type HostedWriteResult = (WriteResultBase & {
90
- readonly status: "committed";
91
- readonly version: Version;
92
- })
93
- /**
94
- * The document is not at the expected version (or, for a create, exists): `currentVersion` is
95
- * the version the host serves, or null when it serves none. `tombstone` names the deletion a
96
- * create of a deleted id ran into, when the host named one.
97
- */
98
- | (WriteResultBase & {
99
- readonly status: "conflict";
100
- readonly reason: "version_conflict";
101
- readonly currentVersion: Version | null;
102
- readonly tombstone?: Version;
103
- })
104
- /** Another write to the bundle overlapped this one past the host's own retries; nothing was applied. */
105
- | (WriteResultBase & {
106
- readonly status: "conflict";
107
- readonly reason: "concurrent_change";
108
- readonly message: string;
109
- }) | (WriteResultBase & {
110
- readonly status: "refused";
111
- readonly code: HostedWriteRefusalCode;
112
- readonly message: string;
113
- })
114
- /**
115
- * The host may or may not hold the write. `lookupWrite` or `settleWrite` asks again later.
116
- * `refusal` is the refusal of this call's resend, when one ended it: the resend was refused
117
- * before it ran (access withdrawn, signed out, a spent quota, a malformed request) while an
118
- * earlier delivery may still commit, so the write is kept. It says why settling must wait.
119
- */
120
- | (WriteResultBase & {
121
- readonly status: "unknown";
122
- readonly refusal?: {
123
- readonly code: string;
124
- readonly message: string;
125
- };
126
- });
127
- /**
128
- * What `lookupWrite` and `settleWrite` answer: a write's result, or `unrecorded` when the intent
129
- * store holds no write under the identity (never recorded, or already settled and deleted).
130
- */
131
- export type HostedWriteLookupResult = HostedWriteResult | {
132
- readonly status: "unrecorded";
133
- readonly requestId: string;
134
- };
135
- /** What a write needs from its client: the carrier for a workspace, the routes and the store. */
136
- export interface HostedWriteContext {
137
- readonly binding: string;
138
- readonly store: HostedIntentStore;
139
- /** One chain per request identity in flight, shared by a client and its `within` clients. */
140
- readonly inFlight: Map<string, Promise<unknown>>;
141
- readonly prefix: string;
142
- readonly workspace: string | null;
143
- readonly signal: AbortSignal;
144
- /** The wait between outcome lookups (default 250 ms). */
145
- readonly lookupDelayMs?: number;
146
- /** Each bundle's capabilities as writes use them, shared by a client and its `within` clients. */
147
- readonly capabilities: HostedCapabilitiesCache;
148
- carrierFor(workspace: string | null): HostedCarrier;
149
- readRoutes: HostedReadRoutes;
150
- /** How this host takes each operation with an older route, decided once for the client (`createPortRunner`). */
151
- readonly runDecisions: HostedRunDecisions;
152
- }
153
- /** The capabilities a write uses, from one answer: the flags and bounds, and the edition its root declares. */
154
- interface WriteSideAnswer {
155
- readonly capabilities: HostedCapabilities;
156
- readonly okfVersion: "0.1" | "0.2" | "0.3" | null;
157
- }
158
- /**
159
- * One bundle's write side: a reader of its own (never the public `reader()`, whose held answer
160
- * is checked against heads answers) and its one capabilities answer, in flight or arrived.
161
- */
162
- export interface WriteSide {
163
- readonly reader: HostedReadAdapter;
164
- readonly answer: Promise<WriteSideAnswer>;
165
- /** When the answer arrived, by the cache's clock; undefined while it is in flight. */
166
- answeredAt: number | undefined;
167
- }
168
- /**
169
- * Each bundle's write side, keyed by the workspace the bundle is named in and its id, and held
170
- * for `ttlMs` after its answer arrives. A `ttlMs` of 0 holds nothing: every write reads anew.
171
- */
172
- export interface HostedCapabilitiesCache {
173
- readonly ttlMs: number;
174
- readonly now: () => number;
175
- readonly entries: Map<string, WriteSide>;
176
- }
177
- /** The default time a bundle's capabilities answer serves writes: 60 s. */
178
- export declare const DEFAULT_CAPABILITIES_TTL_MS = 60000;
179
- export declare function createCapabilitiesCache(ttlMs?: number, now?: () => number): HostedCapabilitiesCache;
180
- /**
181
- * The write side of a bundle named in `workspace`: the held one while its answer is in flight or
182
- * fresh, so concurrent writes share one read, else (or when `fresh`) a new reader and read, which
183
- * replaces the held one. A read that fails is never held. Each new read also removes every
184
- * expired entry, so a long-lived client holds only bundles written within the TTL.
185
- */
186
- export declare function writeSide(context: HostedWriteContext, workspace: string | null, bundleId: string, fresh?: boolean): WriteSide;
187
- /** Forget `side` as the bundle's held write side, so the next write reads its capabilities again. */
188
- export declare function dropWriteSide(context: HostedWriteContext, workspace: string | null, bundleId: string, side: WriteSide): void;
189
- /**
190
- * `work`, or the abort's reason as soon as `signal` aborts, whichever comes first. For a read made
191
- * before anything is sent (the capabilities answer), so a hung credential provider never holds a
192
- * caller past its own abort; the read itself goes on for any other caller sharing it.
193
- */
194
- export declare function untilAborted<T>(work: Promise<T>, signal: AbortSignal): Promise<T>;
195
- /** The signal a write's requests run under: the client's, and the caller's when given. */
196
- export declare function writeSignal(context: HostedWriteContext, signal: AbortSignal | undefined): AbortSignal;
197
- /** `HostedClient.write`. */
198
- export declare function hostedWrite(context: HostedWriteContext, bundleId: string, input: HostedWriteInput, options?: HostedWriteOptions): Promise<HostedWriteResult>;
199
- /**
200
- * `HostedClient.lookupWrite`: what the host recorded for a held write, by one outcome lookup under
201
- * the identity and binding it was sent with. It never sends the write: a host that holds no
202
- * outcome yet (absent or pending), or a lookup that fails, is `unknown`.
203
- */
204
- export declare function hostedLookupWrite(context: HostedWriteContext, requestId: string, options?: {
205
- signal?: AbortSignal;
206
- }): Promise<HostedWriteLookupResult>;
207
- /**
208
- * `HostedClient.settleWrite`: settle a held write. It looks the identity up under the binding it
209
- * was sent with; when the host never recorded it (within the retention window it serves), it
210
- * delivers that same identity once more, as the write itself would have. An unclear lookup is
211
- * `unknown` again. A bundle the host serves no writes for is only looked up.
212
- */
213
- export declare function hostedSettleWrite(context: HostedWriteContext, requestId: string, options?: {
214
- signal?: AbortSignal;
215
- }): Promise<HostedWriteLookupResult>;
216
- /** `HostedClient.heldWrites`: every write the intent store holds. */
217
- export declare function hostedHeldWrites(context: HostedWriteContext): Promise<HostedWriteIntent[]>;
218
- export {};
219
- //# sourceMappingURL=write.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/hosted-client/write.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAIL,KAAK,cAAc,EAGpB,MAAM,uBAAuB,CAAC;AAI/B,sGAAsG;AACtG,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,GACpH;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,KAA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