@baukit/data-contracts 0.4.0 → 0.5.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Runtime-neutral data contracts, measurement helpers, and executable adapter conformance tests.
4
4
 
5
- The package defines JSON key/value storage, ID-ordered record storage with bounded keyset pagination, atomic transaction callbacks, and schema metadata/migration conventions. It deliberately contains no product entities and no Expo SQLite, Dexie, or Node database adapters.
5
+ The package defines JSON key/value storage, ID-ordered record storage with bounded keyset pagination, atomic transaction callbacks, and schema metadata/migration conventions. It deliberately contains no product entities and no Expo SQLite, Dexie, or Node database adapters. The one storage adapter it ships is `WebStorageKeyValueStore`, because Web Storage needs no dependency.
6
6
 
7
7
  ## Using the contracts
8
8
 
@@ -23,6 +23,24 @@ be serialized by the adapter. After `close()` resolves, all operations reject
23
23
  with `StorageError.code === "storage_closed"`. Quota failures use
24
24
  `storage_quota_exceeded`; callers never need to parse provider error text.
25
25
 
26
+ `KeyValueStore.clearPrefix(prefix)` deletes every key that starts with `prefix`, for example all
27
+ drafts of one account on sign-out when keys look like `draft:<account>:<document>`. Matching is
28
+ exact and case-sensitive by UTF-16 code units, no character is a wildcard, and an empty prefix
29
+ clears the store. `clear()` still empties the whole store.
30
+
31
+ `WebStorageKeyValueStore` is a `KeyValueStore` over `sessionStorage` or `localStorage`. It stores
32
+ each value as JSON text under a namespace you pass, so `clear()` and `clearPrefix()` never remove
33
+ other keys of the origin. An empty namespace throws a `RangeError`. Storage failures reject the
34
+ returned promise, and a full storage rejects with `StorageError.code === "storage_quota_exceeded"`.
35
+
36
+ ```ts
37
+ import { WebStorageKeyValueStore } from '@baukit/data-contracts';
38
+
39
+ const drafts = new WebStorageKeyValueStore(sessionStorage, 'app:drafts:v1:');
40
+ await drafts.set('note:new', { title: '' });
41
+ await drafts.clearPrefix('note:');
42
+ ```
43
+
26
44
  The older `StorageTransaction` and `Transaction` interfaces remain available
27
45
  for adapters that implement only the original surface.
28
46
 
@@ -54,6 +72,32 @@ with `trimmedUnicodeScalarCount(value)`, and replace a `JSON.stringify` plus `Te
54
72
  with `compactJsonUtf8Bytes(value)`. Unlike raw `JSON.stringify`, the helper rejects values that JSON
55
73
  would omit or replace with `null`.
56
74
 
75
+ ### Limits policy files
76
+
77
+ `parseLimitsPolicy(value, schema)` validates a product's limits policy file, such as the
78
+ `limits.json` the templates generate. The schema names the supported version and the keys of each
79
+ section. The parser requires a string `$comment`, the exact version, the exact section and key sets,
80
+ and positive safe integers. Keys listed in `allowZero` as `section.key` also accept zero. Any other
81
+ shape throws `LimitsPolicyError`, whose message names the failing path but never a value. Pass the
82
+ schema `as const` so the result type has one `number` property per declared key.
83
+
84
+ `enforceLimit(field, reason, check)` runs one check and turns `LimitExceededError` into
85
+ `LimitError`, which carries `reason`, `field`, `measured`, and `allowed`. Other errors pass through.
86
+
87
+ ```ts
88
+ import { checkTrimmedUnicodeScalars, enforceLimit, parseLimitsPolicy } from '@baukit/data-contracts/limits';
89
+
90
+ const schema = { version: 1, sections: { text: ['max_characters'] } } as const;
91
+ const policy = parseLimitsPolicy(limitsJson, schema);
92
+
93
+ enforceLimit('title', 'text_too_long', () =>
94
+ checkTrimmedUnicodeScalars(title, policy.text.max_characters),
95
+ );
96
+ ```
97
+
98
+ Cross-field rules, such as one limit that must not exceed another, stay in product code after the
99
+ parse.
100
+
57
101
  ## Import envelopes
58
102
 
59
103
  The `/import-envelope` subpath separates import safety from a product's file format. The product
@@ -95,6 +139,235 @@ This API is additive. Existing import code can migrate by wrapping its current d
95
139
  planner first, then moving the write loop into `commitImportEnvelope`. It does not require a file
96
140
  format or database migration.
97
141
 
142
+ ## Exports
143
+
144
+ The `/export` subpath is the counterpart of the import envelope. `encodeCsv` turns rows into an RFC
145
+ 4180 CSV string: every record ends with CRLF, and a cell is quoted when it contains a comma, a double
146
+ quote, CR, or LF. A row holding one empty cell is written as `""` so a reader still sees one field.
147
+ The helper has no runtime dependencies; the product writes the string to a file and shares it.
148
+
149
+ ```ts
150
+ import { csvNumeric, encodeCsv } from '@baukit/data-contracts/export';
151
+
152
+ const csv = encodeCsv(
153
+ [
154
+ ['note', 'amount', 'price'],
155
+ ['=HYPERLINK("https://example.test")', -5, csvNumeric('1.50')],
156
+ ],
157
+ { byteOrderMark: true },
158
+ );
159
+ ```
160
+
161
+ Formula neutralization is on by default. A text cell gets a leading apostrophe when its first
162
+ character is `=`, `+`, `-`, `@`, tab, or CR, or when `=`, `+`, `-`, or `@` follows leading spaces,
163
+ tabs, CR, or LF. Only these ASCII characters are checked. The apostrophe changes the value, so a
164
+ file that your own importer reads back must either strip it or be written with
165
+ `neutralizeFormulas: false`. Use the opt-out only for machine-read files that never open in a
166
+ spreadsheet.
167
+
168
+ Text that looks like a negative number, such as `'-5'`, is neutralized. Pass real numbers as a
169
+ finite `number` or as `csvNumeric(text)` when the formatting matters, for example `'1.50'`. Numeric
170
+ cells must match the JSON number grammar and are written unchanged. `null` is an empty cell.
171
+ `byteOrderMark: true` starts the output with U+FEFF for spreadsheet programs that need it to detect
172
+ UTF-8.
173
+
174
+ By default `null` and `''` both write an empty field, so a reader cannot tell them apart. Two options
175
+ keep them distinct for a file your own importer reads back:
176
+
177
+ - `quoteAllCells: true` quotes every text and numeric cell. A null cell stays unquoted, so `''`
178
+ becomes `""` and `null` stays empty. A row holding only one null cell still writes `""`.
179
+ - `nullMarker: '\\N'` writes the marker unquoted for a null cell and quotes a text cell with the same
180
+ content, so `"\N"` reads back as text. The marker must be non-empty and free of double quotes,
181
+ commas, CR, and LF; `encodeCsv` throws a `RangeError` otherwise.
182
+
183
+ ```ts
184
+ encodeCsv([[null, '\\N', '', 'x']], { nullMarker: '\\N' }); // \N,"\N",,x
185
+ encodeCsv([[null, '', -5]], { quoteAllCells: true }); // ,"","-5"
186
+ ```
187
+
188
+ `CsvEncodeError.code` is `invalid_numeric_cell` for a non-finite number or a numeric cell outside
189
+ the JSON grammar, `invalid_unicode` for a string with an unpaired surrogate, or `unsupported_cell`
190
+ for any other runtime value. The error carries `rowIndex` and `columnIndex` and never the cell
191
+ value. `baukit_core::export::encode_csv` in Rust passes the same vectors
192
+ (`fixtures/export-csv/csv-encoding-v1.json`).
193
+
194
+ `ShareOutcome` names what happened after the product handed the file to the platform:
195
+
196
+ - `shared`: a share sheet or the Web Share API accepted the file. Some native share sheets report
197
+ this even when the user closed them without picking a target.
198
+ - `saved`: the file was written to a place the user can open, such as a browser download.
199
+ - `cancelled`: the user dismissed the share or save UI and the platform said so, for example with a
200
+ Web Share `AbortError`.
201
+ - `unavailable`: the runtime has no share or save mechanism, so nothing was attempted.
202
+ - `failed`: a mechanism was attempted and reported an error other than cancellation.
203
+
204
+ `SHARE_OUTCOMES` lists the same values. The package ships no Expo or browser implementation yet.
205
+
206
+ ## Revisioned writes
207
+
208
+ The `/revisioned-writes` subpath sends edits of one server document one at a time, each checked
209
+ against a revision. It has no React dependency. Wrap it in a hook with `useSyncExternalStore`: the
210
+ snapshot object only changes when state changes.
211
+
212
+ ```ts
213
+ import { createRevisionedWriteQueue } from '@baukit/data-contracts/revisioned-writes';
214
+
215
+ const queue = createRevisionedWriteQueue({
216
+ initial: { scope: accountId, document: noteId, acknowledgedRevision: loaded.revision },
217
+ write: async ({ scope, document, value, expectedRevision, afterUnknownOutcome, signal }) => {
218
+ const response = await api.saveNote(scope, document, value, {
219
+ ifMatch: expectedRevision,
220
+ idempotencyKey: await keyFor(document, value, expectedRevision),
221
+ signal,
222
+ });
223
+ if (response.status === 409) {
224
+ return { kind: 'conflict', currentRevision: response.revision, conflict: response.body };
225
+ }
226
+ if (!response.ok) {
227
+ return { kind: 'rejected', error: response.problem };
228
+ }
229
+ return { kind: 'accepted', revision: response.revision };
230
+ },
231
+ signal: pageLifetime.signal,
232
+ });
233
+
234
+ queue.enqueue(editedValue);
235
+ await queue.flush();
236
+ ```
237
+
238
+ The snapshot keeps two values apart. `acknowledgedRevision` is the last revision the server
239
+ confirmed. `unsent` is the local value no write has carried yet. A write sends the value it took
240
+ from `unsent` with the acknowledged revision as `expectedRevision`. Edits made while that write is
241
+ in flight go into a fresh `unsent` and the status stays `dirty`. An acknowledgement for the older
242
+ value never marks the newer one saved. Queued edits are combined with `coalesce(older, newer)`,
243
+ which keeps the newer value by default. Pass your own function when a write carries a patch instead
244
+ of the whole document.
245
+
246
+ `enqueue` never sends. Debounce in the product and call `flush`. Concurrent `flush` calls share one
247
+ drain, which resolves with the snapshot once the queue is idle or paused.
248
+
249
+ The write callback reports one of three outcomes:
250
+
251
+ - `accepted` stores the new revision and sends the next unsent value, if any.
252
+ - `rejected` means the server refused the write before accepting it. The value goes back into
253
+ `unsent`, merged with newer edits, and the status is `failed`. `flush` or `retry` sends it again.
254
+ - `conflict` pauses the queue with the server's revision and conflict payload. Nothing more is sent
255
+ until the product calls `reset` with a revision it trusts. To keep the local value, `reset` to
256
+ the current server revision and `enqueue` the value again.
257
+
258
+ A throw from the write callback, or a rejected promise, means the outcome is unknown. The server may
259
+ have applied the write and lost the response. The queue moves to `unknown-outcome` and keeps the
260
+ exact value and expected revision in `uncertain`, apart from newer edits. `flush` does nothing in
261
+ that state. `retry` sends the same value and revision with `afterUnknownOutcome: true`, so the
262
+ product can reuse its idempotency key. Otherwise read the server and call `reset`. The queue never
263
+ treats an unknown outcome as a failure that happened before the server accepted the write.
264
+
265
+ `reset(next)` is the generation fence for an account or document switch. It aborts the current
266
+ write through the `signal` passed to the callback, drops unsent and uncertain state, and ignores
267
+ any late result of the old generation. `cancel()` does the same and keeps the queue in `cancelled`
268
+ until the next `reset`. Aborting the injected `signal` option calls `cancel`.
269
+
270
+ Status is `cancelled`, `writing`, `failed`, `unknown-outcome`, `conflict`, `dirty`, or `idle`, in
271
+ that order of precedence. `error` holds the `rejected` error or the thrown value.
272
+
273
+ ## Durable drafts
274
+
275
+ The `/durable-draft` subpath keeps an unsent form value in any `KeyValueStore`, so it survives a
276
+ reload or crash. It has no React dependency.
277
+
278
+ ```ts
279
+ import { createDurableDraft, type DraftCodec } from '@baukit/data-contracts/durable-draft';
280
+
281
+ const noteCodec: DraftCodec<NoteDraft> = {
282
+ version: 2,
283
+ encode: (value) => ({ body: value.body, baseRevision: value.baseRevision }),
284
+ decode: (value, version) => decodeNoteDraft(value, version),
285
+ };
286
+
287
+ const draft = createDurableDraft({
288
+ store,
289
+ key: (scope: { accountId: string; noteId: string }) =>
290
+ `note-draft:${scope.accountId}:${scope.noteId}`,
291
+ codec: noteCodec,
292
+ });
293
+
294
+ await draft.open({ accountId, noteId }, { body: loaded.body, baseRevision: loaded.revision });
295
+ draft.update({ body: editedBody, baseRevision: loaded.revision });
296
+ await draft.save();
297
+ ```
298
+
299
+ Storage holds `{ version, value }`. The codec owns the value: `encode` returns JSON, and `decode`
300
+ receives unchecked JSON plus the stored version and returns `decoded`, `corrupt`, or
301
+ `unsupported-version`. Validate every field in `decode`. A decoded value from an older version
302
+ counts as upgraded, so the draft opens dirty and the next `save` rewrites it. The helper returns
303
+ `unsupported-version` without calling `decode` when the stored version is above `codec.version`,
304
+ and `corrupt` when the envelope is malformed or `decode` throws. Keep a server base revision or ETag
305
+ inside the value when the product needs it for a later conflict check.
306
+
307
+ An open snapshot has two groups of state. `recovery` says what `open` found: `none`, `restored`,
308
+ `corrupt`, `unsupported-version`, or `unavailable` when the read failed. `persistence` says what
309
+ storage is doing now: `loading`, `idle`, `saving`, `clearing`, or `failed`. `dirty` is true when
310
+ the value differs from what storage holds, and `localRevision` counts local changes. A restored
311
+ draft can also be dirty.
312
+
313
+ `open` never writes or deletes. While recovery is `corrupt` or `unsupported-version`, `save`
314
+ resolves `blocked` so the unreadable data stays in place. Call `clear({ reason: 'discarded' })` to
315
+ remove it.
316
+
317
+ `clear` takes the reason for the deletion:
318
+
319
+ - `{ reason: 'submitted', localRevision }` reports that the server confirmed the value at that local
320
+ revision. The snapshot shows `submission: 'confirmed'` and keeps the value visible. If the user
321
+ edited after that revision, the stored draft stays and `clear` resolves `newer-edits-kept`.
322
+ - `{ reason: 'discarded' }` deletes the draft and returns the value to the one passed to `open`.
323
+
324
+ A failed deletion rejects with a `DraftPersistenceError` and stays in the snapshot as
325
+ `persistence: 'failed'`. After a submission, `submission` stays `confirmed`, so the product can tell
326
+ "the server has it, but the local copy may come back" apart from "nothing was sent". Read, write,
327
+ and delete failures use `DraftPersistenceError` with `code: 'draft_persistence_failed'` and an
328
+ `operation`. The message never includes the key or the value.
329
+
330
+ `open` for a new scope fences the previous one. Storage work of the old scope that had not started
331
+ is skipped and resolves `stale`. Work that already started finishes but does not change the new
332
+ snapshot. All storage work runs in order, so switching from A to B and back to A reads what A's last
333
+ write left. `close()` does not save; call `save` on `pagehide` or when the app moves to the
334
+ background.
335
+
336
+ `move(scope)` hands the open draft to another scope. The usual case is a "new note" draft whose
337
+ server create just succeeded:
338
+
339
+ ```ts
340
+ await draft.clear({ reason: 'submitted', localRevision });
341
+ await draft.move({ accountId, noteId: created.id });
342
+ ```
343
+
344
+ When the value is dirty or came from storage, `move` writes it under the new key first, replacing
345
+ anything stored there. It then deletes the old key in every case. The value, `localRevision`, and
346
+ `submission` stay as they were, and later saves go to the new key. A corrupt or unsupported draft
347
+ resolves `blocked`. If the write or the delete fails, `move` rejects with a `DraftPersistenceError`,
348
+ the draft stays on the old scope, and calling `move` again retries it. `move` does not remember where
349
+ a draft went. If a second editor still holds the old scope, the product stores its own pointer from
350
+ the old scope to the new one.
351
+
352
+ `isScopeActive` fences writes when several editors can hold the same scope, for example two tabs
353
+ with a shared lease. The helper calls it before every write or delete of `save`, `clear`, and
354
+ `move`, for both scopes of a move, when the queued work starts. When it returns false the operation
355
+ resolves `stale` and storage is not touched. Reads are not fenced.
356
+
357
+ ```ts
358
+ const draft = createDurableDraft({
359
+ store,
360
+ key: noteDraftKey,
361
+ codec: noteCodec,
362
+ isScopeActive: (scope) => lease.holds(scope.accountId),
363
+ });
364
+ ```
365
+
366
+ Snapshots are read through `getSnapshot()` and `subscribe`, which suit `useSyncExternalStore`. The
367
+ stored value itself is always read asynchronously, because `KeyValueStore` is asynchronous over
368
+ IndexedDB and SQLite. Render the loading state while `persistence` is `loading`. With
369
+ `WebStorageKeyValueStore` that lasts one microtask.
370
+
98
371
  ## Authenticated partitions
99
372
 
100
373
  `deriveScopedStoreName(namespace, subject)` hashes a length-delimited canonical
@@ -130,7 +403,7 @@ adoption or an outbox push.
130
403
 
131
404
  ## Proving an adapter
132
405
 
133
- Vitest helpers are isolated in a test-only subpath. Vitest is deliberately not a peer dependency, so it is never installed in Jest or production consumers. Install Vitest in an adapter project's development dependencies before importing the subpath, then register the applicable suites:
406
+ Vitest helpers are isolated in a test-only subpath. Vitest is deliberately not a peer dependency, so it is never installed in Jest or production consumers. The subpath has no `default` export condition, so a Jest suite cannot resolve it by accident. Install Vitest in an adapter project's development dependencies before importing the subpath, then register the applicable suites:
134
407
 
135
408
  ```ts
136
409
  import {
@@ -12,6 +12,11 @@ export interface KeyValueStore {
12
12
  /** Deletes a key if present. Deleting a missing key is a no-op. */
13
13
  delete(key: string): Promise<void>;
14
14
  clear(): Promise<void>;
15
+ /**
16
+ * Deletes every key that starts with `prefix`, compared by UTF-16 code units and case-sensitively.
17
+ * No character in the prefix is a wildcard. An empty prefix clears the store.
18
+ */
19
+ clearPrefix(prefix: string): Promise<void>;
15
20
  }
16
21
  /** Records use an immutable string ID as their stable ordering and lookup key. */
17
22
  export interface StoredRecord {
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE7D,6CAA6C;AAC7C,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,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AAS,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,IAAI,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,oBAAoB,EAAE,CAAC;YAC3D,OAAO,IAAI,YAAY,CACrB,wBAAwB,EACxB,sDAAsD,EACtD,EAAE,KAAK,EAAE,CACV,CAAC;QACJ,CAAC;QACD,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,KAAa;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7F,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { type JsonValue, type KeyValueStore } from './contracts.js';
2
+ /** The result of decoding a stored draft value. Return `corrupt` for any value that fails validation. */
3
+ export type DraftDecodeResult<TValue> = {
4
+ readonly kind: 'decoded';
5
+ readonly value: TValue;
6
+ } | {
7
+ readonly kind: 'corrupt';
8
+ } | {
9
+ readonly kind: 'unsupported-version';
10
+ };
11
+ /**
12
+ * Converts a form value to and from stored JSON. The helper stores `{ version, value }` and never
13
+ * calls `decode` for a version above `version`. `decode` receives unchecked JSON and must validate
14
+ * it; an older `version` must be upgraded to the current value shape.
15
+ */
16
+ export interface DraftCodec<TValue> {
17
+ /** The positive integer written with every save. */
18
+ readonly version: number;
19
+ encode(value: TValue): JsonValue;
20
+ decode(value: JsonValue, version: number): DraftDecodeResult<TValue>;
21
+ }
22
+ export type DraftPersistenceOperation = 'read' | 'write' | 'delete';
23
+ /** A storage failure. The message names only the operation, never keys or draft content. */
24
+ export declare class DraftPersistenceError extends Error {
25
+ readonly operation: DraftPersistenceOperation;
26
+ readonly name = "DraftPersistenceError";
27
+ readonly code = "draft_persistence_failed";
28
+ constructor(operation: DraftPersistenceOperation, options?: ErrorOptions);
29
+ }
30
+ /** What `open` found in storage. */
31
+ export type DraftRecovery = 'none' | 'restored' | 'corrupt' | 'unsupported-version' | 'unavailable';
32
+ export type DraftPersistence = 'loading' | 'idle' | 'saving' | 'clearing' | 'failed';
33
+ export type DraftSubmission = 'none' | 'confirmed';
34
+ export interface ClosedDurableDraftSnapshot {
35
+ readonly open: false;
36
+ }
37
+ export interface OpenDurableDraftSnapshot<TScope, TValue> {
38
+ readonly open: true;
39
+ readonly scope: TScope;
40
+ readonly value: TValue;
41
+ /** Increments on every local change. Pass it to `clear` after a submission. */
42
+ readonly localRevision: number;
43
+ /** True when `value` differs from what storage holds for this scope. */
44
+ readonly dirty: boolean;
45
+ readonly recovery: DraftRecovery;
46
+ readonly persistence: DraftPersistence;
47
+ readonly error: DraftPersistenceError | null;
48
+ /** `confirmed` once the product reported a successful server submission through `clear`. */
49
+ readonly submission: DraftSubmission;
50
+ }
51
+ export type DurableDraftSnapshot<TScope, TValue> = ClosedDurableDraftSnapshot | OpenDurableDraftSnapshot<TScope, TValue>;
52
+ export type DraftClearRequest = {
53
+ readonly reason: 'discarded';
54
+ } | {
55
+ readonly reason: 'submitted';
56
+ readonly localRevision: number;
57
+ };
58
+ /**
59
+ * `stale` means the scope changed, closed, or was reported inactive by `isScopeActive` before the
60
+ * operation started, so storage was not touched.
61
+ */
62
+ export type DraftSaveOutcome = 'saved' | 'clean' | 'blocked' | 'stale';
63
+ export type DraftClearOutcome = 'cleared' | 'newer-edits-kept' | 'stale';
64
+ export type DraftMoveOutcome = 'moved' | 'blocked' | 'stale';
65
+ export interface DurableDraftOptions<TScope, TValue> {
66
+ readonly store: KeyValueStore;
67
+ /** Encodes the scope to a storage key. Include the identity and document. */
68
+ readonly key: (scope: TScope) => string;
69
+ readonly codec: DraftCodec<TValue>;
70
+ /**
71
+ * Called before every write or delete. Return false when this editor no longer owns the scope,
72
+ * for example after another editor took a lease on it; the operation then resolves `stale`.
73
+ * Reads are not checked. Every scope is active when omitted.
74
+ */
75
+ readonly isScopeActive?: (scope: TScope) => boolean;
76
+ }
77
+ export interface DurableDraft<TScope, TValue> {
78
+ getSnapshot(): DurableDraftSnapshot<TScope, TValue>;
79
+ subscribe(listener: () => void): () => void;
80
+ /** Switches to a scope and reads its stored draft. Late work of the previous scope is ignored. */
81
+ open(scope: TScope, initial: TValue): Promise<void>;
82
+ /** Replaces the value in memory. Debounce and call `save` to persist it. */
83
+ update(value: TValue): void;
84
+ /**
85
+ * Writes the current value. Resolves `blocked` without writing while recovery is `corrupt` or
86
+ * `unsupported-version`. Rejects with `DraftPersistenceError` when storage fails.
87
+ */
88
+ save(): Promise<DraftSaveOutcome>;
89
+ /**
90
+ * Deletes the stored draft. `submitted` keeps the value visible and keeps newer edits made after
91
+ * `localRevision`; `discarded` returns to the initial value. Rejects with a `delete`
92
+ * `DraftPersistenceError` that stays in the snapshot.
93
+ */
94
+ clear(request: DraftClearRequest): Promise<DraftClearOutcome>;
95
+ /**
96
+ * Moves the open draft to another scope, for example from a "new document" scope to the document
97
+ * the server created. When the value is dirty or stored, it is first written under the new key,
98
+ * replacing what was there. The old key is then deleted in every case. Value, revision, and
99
+ * submission stay as they are, and later saves go to the new key. Resolves `blocked` while recovery is `corrupt` or
100
+ * `unsupported-version`. Rejects with `DraftPersistenceError` when storage fails; the draft then
101
+ * stays on the old scope and the move can be retried.
102
+ */
103
+ move(scope: TScope): Promise<DraftMoveOutcome>;
104
+ /** Closes the scope without saving and resolves after in-flight storage work settles. */
105
+ close(): Promise<void>;
106
+ }
107
+ /** Creates a framework-free durable draft over a `KeyValueStore`. */
108
+ export declare function createDurableDraft<TScope, TValue>(options: DurableDraftOptions<TScope, TValue>): DurableDraft<T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