@mdbase-dev/sdk 0.1.0-beta.187 → 0.1.0-beta.188

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 (155) hide show
  1. package/README.md +188 -953
  2. package/dist/app-grant/client.js +7 -3
  3. package/dist/app-grant/client.js.map +1 -1
  4. package/dist/app-grant/setup.js +2 -2
  5. package/dist/app-grant/setup.js.map +1 -1
  6. package/dist/app-host/cloud-copy-host.js +1 -1
  7. package/dist/app-host/cloud-copy-host.js.map +1 -1
  8. package/dist/app-host/collection-readiness.js +10 -12
  9. package/dist/app-host/collection-readiness.js.map +1 -1
  10. package/dist/app-host/handover.js +1 -1
  11. package/dist/app-host/handover.js.map +1 -1
  12. package/dist/app-host/initial-sync.js +4 -4
  13. package/dist/app-host/initial-sync.js.map +1 -1
  14. package/dist/application/browser-capabilities.d.ts +1 -1
  15. package/dist/application/browser-capabilities.js +3 -2
  16. package/dist/application/browser-capabilities.js.map +1 -1
  17. package/dist/application/configuration.js +12 -12
  18. package/dist/application/configuration.js.map +1 -1
  19. package/dist/application/entry.d.ts +51 -107
  20. package/dist/application/entry.js +139 -86
  21. package/dist/application/entry.js.map +1 -1
  22. package/dist/application/front-door.d.ts +30 -12
  23. package/dist/application/front-door.js +2 -89
  24. package/dist/application/front-door.js.map +1 -1
  25. package/dist/application/phase.d.ts +4 -1
  26. package/dist/application/phase.js +5 -4
  27. package/dist/application/phase.js.map +1 -1
  28. package/dist/application/private-collections.js +2 -1
  29. package/dist/application/private-collections.js.map +1 -1
  30. package/dist/application/registration-refusal.d.ts +1 -1
  31. package/dist/application/registration-refusal.js +1 -3
  32. package/dist/application/registration-refusal.js.map +1 -1
  33. package/dist/application/registration.js +1 -4
  34. package/dist/application/registration.js.map +1 -1
  35. package/dist/application/setup.d.ts +6 -9
  36. package/dist/application/setup.js +16 -0
  37. package/dist/application/setup.js.map +1 -1
  38. package/dist/application/tabs.d.ts +15 -2
  39. package/dist/application/tabs.js +35 -13
  40. package/dist/application/tabs.js.map +1 -1
  41. package/dist/application/unsynced-transfer.d.ts +1 -1
  42. package/dist/application/unsynced-transfer.js +3 -3
  43. package/dist/application/unsynced-transfer.js.map +1 -1
  44. package/dist/application/worker.js +928 -449
  45. package/dist/browser/mdbase-sdk.js +21271 -20750
  46. package/dist/browser/mdbase-sdk.min.js +65 -65
  47. package/dist/browser.d.ts +1 -0
  48. package/dist/browser.js +1 -0
  49. package/dist/browser.js.map +1 -1
  50. package/dist/client.d.ts +169 -81
  51. package/dist/client.js +236 -178
  52. package/dist/client.js.map +1 -1
  53. package/dist/codec.d.ts +15 -0
  54. package/dist/codec.js +44 -2
  55. package/dist/codec.js.map +1 -1
  56. package/dist/collection-api.d.ts +44 -0
  57. package/dist/collection-api.js +24 -0
  58. package/dist/collection-api.js.map +1 -0
  59. package/dist/collection-availability.js +1 -1
  60. package/dist/collection-availability.js.map +1 -1
  61. package/dist/contract-query.d.ts +22 -3
  62. package/dist/contract-query.js.map +1 -1
  63. package/dist/contract-records.d.ts +2 -1
  64. package/dist/contract-records.js.map +1 -1
  65. package/dist/describe-error.d.ts +1 -1
  66. package/dist/describe-error.js +7 -6
  67. package/dist/describe-error.js.map +1 -1
  68. package/dist/errors.d.ts +3 -5
  69. package/dist/errors.js +3 -8
  70. package/dist/errors.js.map +1 -1
  71. package/dist/files.d.ts +7 -5
  72. package/dist/files.js +16 -17
  73. package/dist/files.js.map +1 -1
  74. package/dist/holds.d.ts +2 -1
  75. package/dist/holds.js.map +1 -1
  76. package/dist/index.d.ts +7 -11
  77. package/dist/index.js +5 -7
  78. package/dist/index.js.map +1 -1
  79. package/dist/live.d.ts +2 -1
  80. package/dist/live.js.map +1 -1
  81. package/dist/manifest.d.ts +1 -1
  82. package/dist/manifest.js +1 -1
  83. package/dist/native/provenance.json +1 -1
  84. package/dist/people.js +3 -7
  85. package/dist/people.js.map +1 -1
  86. package/dist/plain.d.ts +102 -0
  87. package/dist/plain.js +62 -0
  88. package/dist/plain.js.map +1 -0
  89. package/dist/presence.d.ts +2 -1
  90. package/dist/presence.js +3 -3
  91. package/dist/presence.js.map +1 -1
  92. package/dist/read-helpers.d.ts +8 -6
  93. package/dist/read-helpers.js +20 -13
  94. package/dist/read-helpers.js.map +1 -1
  95. package/dist/record-set.d.ts +98 -0
  96. package/dist/record-set.js +347 -0
  97. package/dist/record-set.js.map +1 -0
  98. package/dist/records/session.d.ts +2 -1
  99. package/dist/records/session.js +22 -20
  100. package/dist/records/session.js.map +1 -1
  101. package/dist/records/types.d.ts +5 -3
  102. package/dist/records/witness.d.ts +7 -4
  103. package/dist/records/witness.js +13 -8
  104. package/dist/records/witness.js.map +1 -1
  105. package/dist/records.js +5 -2
  106. package/dist/records.js.map +1 -1
  107. package/dist/saved-views.d.ts +12 -4
  108. package/dist/saved-views.js +51 -43
  109. package/dist/saved-views.js.map +1 -1
  110. package/dist/settle.d.ts +62 -0
  111. package/dist/settle.js +119 -0
  112. package/dist/settle.js.map +1 -0
  113. package/dist/status.d.ts +84 -28
  114. package/dist/status.js +54 -48
  115. package/dist/status.js.map +1 -1
  116. package/dist/testing/application.d.ts +16 -9
  117. package/dist/testing/application.js +48 -45
  118. package/dist/testing/application.js.map +1 -1
  119. package/dist/testing/index.d.ts +2 -2
  120. package/dist/testing/memory-contracts.d.ts +5 -0
  121. package/dist/testing/memory-contracts.js.map +1 -1
  122. package/dist/testing/memory-replica.d.ts +58 -5
  123. package/dist/testing/memory-replica.js +126 -19
  124. package/dist/testing/memory-replica.js.map +1 -1
  125. package/dist/testing/test-app.d.ts +9 -10
  126. package/dist/testing/test-app.js +8 -17
  127. package/dist/testing/test-app.js.map +1 -1
  128. package/dist/thin-client.d.ts +15 -38
  129. package/dist/thin-client.js +11 -20
  130. package/dist/thin-client.js.map +1 -1
  131. package/dist/transport/control-route.js +1 -1
  132. package/dist/transport/control-route.js.map +1 -1
  133. package/dist/transport/relay-close.d.ts +0 -1
  134. package/dist/transport/relay-close.js +4 -2
  135. package/dist/transport/relay-close.js.map +1 -1
  136. package/dist/transport/relay-pipe.js +2 -2
  137. package/dist/transport/relay-pipe.js.map +1 -1
  138. package/dist/type-packs.js +4 -4
  139. package/dist/type-packs.js.map +1 -1
  140. package/dist/validation.d.ts +1 -1
  141. package/dist/validation.js +2 -2
  142. package/dist/validation.js.map +1 -1
  143. package/dist/values.d.ts +4 -20
  144. package/dist/values.js +3 -49
  145. package/dist/values.js.map +1 -1
  146. package/dist/view-sources.d.ts +2 -1
  147. package/dist/view-sources.js +1 -1
  148. package/dist/view-sources.js.map +1 -1
  149. package/dist/wire.d.ts +7 -3
  150. package/dist/wire.js +4 -4
  151. package/dist/wire.js.map +1 -1
  152. package/dist/write-ledger.d.ts +2 -1
  153. package/dist/write-ledger.js +3 -6
  154. package/dist/write-ledger.js.map +1 -1
  155. package/package.json +1 -1
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /** Classic-script browser surface: existing APIs only; no runtime or authority defaults. */
2
2
  export * from "./index.js";
3
+ export * from "./thin-client.js";
3
4
  export * as Client from "./client.js";
4
5
  export * as AppHost from "./app-host/index.js";
package/dist/browser.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Classic-script browser surface: existing APIs only; no runtime or authority defaults. */
2
2
  export * from "./index.js";
3
+ export * from "./thin-client.js";
3
4
  export * as Client from "./client.js";
4
5
  export * as AppHost from "./app-host/index.js";
5
6
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
package/dist/client.d.ts CHANGED
@@ -18,6 +18,7 @@ import { type AppBasesPagesOptions } from "./app-host/bases-pages.js";
18
18
  import { type RecordValidation } from "./validation.js";
19
19
  import { MdbaseError } from "./errors.js";
20
20
  import { FilesApi } from "./files.js";
21
+ import { type Settlement, type SettleOptions } from "./settle.js";
21
22
  import { type ReadManyOptions } from "./read-helpers.js";
22
23
  import { type Records } from "./records.js";
23
24
  import { type ExecuteViewOptions, type ListViewsResult } from "./saved-views.js";
@@ -25,16 +26,20 @@ import { type ViewSourceCreateInput, type ViewSourceWriteOptions, type ViewSourc
25
26
  import { type ContractRecordView, type ContractSelector } from "./contract-records.js";
26
27
  import { type ContractQueryOptions, type ContractQueryResult, type ContractRef } from "./contract-query.js";
27
28
  import { LiveListener, LiveQueryState } from "./live.js";
29
+ import { RecordSet, type RecordSetOptions } from "./record-set.js";
28
30
  import { PresenceApi } from "./presence.js";
29
31
  import { Session } from "./session.js";
30
32
  import type { Connector } from "./transport/port.js";
31
33
  import { type TypePackApplyResult, type TypePackOptions, type TypePackPlan, type TypePackProvision } from "./type-packs.js";
32
34
  import { PlainValue } from "./values.js";
33
35
  import { PendingDevice, RecoveryKeyStatus, AccountKeyStatus } from "./private.js";
34
- import { BacklinksResult, ResolveLinksResult, DescribeResult, DescribeTypingResult, PendingMutation, Preflight, ResourceView, ViewSourceDocument } from "./wire.js";
36
+ import { ResolveLinksResult, DescribeTypingResult, Preflight, ResourceView, ViewSourceDocument } from "./wire.js";
35
37
  import { type WriteLedgerStore, type WriteLedgerView } from "./write-ledger.js";
36
- import type { Problem } from "./wire.js";
37
- import { BodyEdit, ChangesResult, ConflictEntry, ConflictMode, FenceApply, FenceReportEntry, FmMap, Hold, HoldResolution, HelloResult, Include, Op, QueryResult, QueryUpdate, Receipt, RecordView, ValidationLevel, SyncStatus, AppliedPrefix, Uuid, Value } from "./wire.js";
38
+ import { type Codec } from "./codec.js";
39
+ import type { Plain } from "./plain.js";
40
+ import type { BacklinksResult, ConflictEntry, DescribeResult, PendingMutation, QueryResult, QueryUpdate, Receipt, RecordView } from "./plain.js";
41
+ import type { HelloResult, Hold, Problem, SyncStatus } from "./wire.js";
42
+ import { BodyEdit, ChangesResult, ConflictMode, FenceApply, FenceReportEntry, FmMap, HoldResolution, Include, Op, ValidationLevel, AppliedPrefix, Uuid, Value } from "./wire.js";
38
43
  export interface ClientOptions {
39
44
  connector: Connector;
40
45
  /** App ID and version, sent in `hello`. */
@@ -59,15 +64,6 @@ export interface ClientOptions {
59
64
  ledger?: WriteLedgerStore;
60
65
  signal?: AbortSignal;
61
66
  }
62
- /** What {@link MdbaseClient.save} settled to. */
63
- export interface SaveResult {
64
- readonly outcome: "confirmed" | "saved_on_device" | "rejected";
65
- readonly mutationId: Uuid;
66
- readonly records: readonly RecordView[];
67
- /** The first record, read back when asked. */
68
- readonly record?: RecordView;
69
- readonly problem?: Problem;
70
- }
71
67
  /** A type created by {@link MdbaseClient.createType}. */
72
68
  export interface TypeCreation {
73
69
  name: string;
@@ -84,7 +80,6 @@ export interface DescribeOptions {
84
80
  export type LinkState = "open" | "reconnecting" | "closed";
85
81
  /** Local subscription state, not cache completeness or fresh authority. */
86
82
  export type ChangesWatchState = "starting" | "active" | "stale" | "failed" | "closed";
87
- /** Callable for compatibility with the former stop-only return value. */
88
83
  export interface ChangesWatch {
89
84
  (): void;
90
85
  /** First current-session watch ACK; rejects initial failure or stop. */
@@ -178,6 +173,15 @@ export interface UpdateInput {
178
173
  */
179
174
  promote?: boolean;
180
175
  }
176
+ /** What every read takes. */
177
+ export interface ReadOptions {
178
+ signal?: AbortSignal;
179
+ }
180
+ /** A read that returns records. */
181
+ export interface RecordReadOptions extends ReadOptions {
182
+ /** What each record carries beyond its path, type and frontmatter. */
183
+ include?: Include;
184
+ }
181
185
  export interface WriteOptions {
182
186
  mutationId?: Uuid;
183
187
  /**
@@ -218,6 +222,8 @@ export declare class Write {
218
222
  * is a final non-publication, not success. Without files, settles at confirmation.
219
223
  * Rejects rejected/unknown outcomes; not a native custody/durable ACK gate. */
220
224
  readonly published: Promise<Receipt>;
225
+ /** The record a single-record write targets (create, update, replace, rename, delete). */
226
+ recordId?: Uuid;
221
227
  constructor(receipt: Receipt);
222
228
  get mutationId(): Uuid;
223
229
  /** The records as they now read locally (optimistic until confirmed). */
@@ -227,8 +233,8 @@ export declare class Write {
227
233
  /** SDK-internal: apply a newer receipt. Kept in the published types (apps' tests use it). */
228
234
  update(r: Receipt): void;
229
235
  }
230
- /** A create receipt with the record identity minted by the SDK, even when the
231
- * replica omits optimistic records from its response. */
236
+ /** A create, with the record ID the SDK minted: known even when the replica
237
+ * omits optimistic records from its response. */
232
238
  export interface RecordWrite extends Write {
233
239
  readonly recordId: Uuid;
234
240
  }
@@ -257,8 +263,12 @@ export declare class LiveQuery implements LiveQueryState {
257
263
  get(id: Uuid): RecordView | undefined;
258
264
  /** Call `fn` now and on every change. Returns an unsubscribe function. */
259
265
  subscribe(fn: LiveListener): () => void;
260
- /** Change the query (for example a larger `limit` window). Re-subscribes. */
261
- setQuery(query: Query, include?: Include | undefined): Promise<void>;
266
+ /** Change the query (for example a larger `limit` window). Re-subscribes.
267
+ * `o.include` replaces what each record carries; without it the current
268
+ * include is kept. */
269
+ setQuery(query: Query, o?: {
270
+ include?: Include;
271
+ }): Promise<void>;
262
272
  close(): void;
263
273
  private emit;
264
274
  }
@@ -341,12 +351,20 @@ export declare class MdbaseClient {
341
351
  /**
342
352
  * Advanced: run a request on the current session; on a dropped link, wait for the
343
353
  * reconnect and retry when `retry` (idempotent requests only).
354
+ *
355
+ * With a `codec` the answer is decoded and its values are plain JSON, as from
356
+ * every other method. Without one it is the exact CBOR answer: decode that
357
+ * with a `wire` codec to keep `Map` order, `Float64` and `bigint`.
344
358
  */
345
- call<T = CborValue>(method: string, p: CborValue, o?: {
359
+ call(method: string, p: CborValue, o?: {
346
360
  signal?: AbortSignal;
347
- codec?: import("./codec.js").Codec<T>;
348
361
  retry?: boolean;
349
- }): Promise<T>;
362
+ }): Promise<CborValue>;
363
+ call<T>(method: string, p: CborValue, o: {
364
+ signal?: AbortSignal;
365
+ codec: Codec<T>;
366
+ retry?: boolean;
367
+ }): Promise<Plain<T>>;
350
368
  /** Pass head witnesses between replicas (log-entry.md §11); best effort. */
351
369
  private relayWitnesses;
352
370
  /** Transport-authenticated replica identity (Noise target), NOT hello/witness
@@ -369,8 +387,9 @@ export declare class MdbaseClient {
369
387
  * revalidate the authenticated session and all readiness gates after any await.
370
388
  * Missing chain or any error means remain hosted; never substitute asOf or the
371
389
  * current head/generations. Decoding does not authenticate a witness or switch.
390
+ * `o.signal` cancels the read.
372
391
  */
373
- appliedPrefix(seq: number, signal?: AbortSignal): Promise<AppliedPrefix>;
392
+ appliedPrefix(seq: number, o?: ReadOptions): Promise<AppliedPrefix>;
374
393
  /** Call `fn` with the status now and on every change (pushed, ≤ 4/s). */
375
394
  onStatus(fn: (s: SyncStatus) => void): () => void;
376
395
  private setStatus;
@@ -380,8 +399,9 @@ export declare class MdbaseClient {
380
399
  * definition and schema and each contract's schemas, bounded by the replica
381
400
  * (`too_large` when over budget; read them with `resources.get` instead).
382
401
  * A producer that cannot describe definitions fails `upgrade_required`.
402
+ * `o.signal` cancels the read.
383
403
  */
384
- describe(options?: AbortSignal | DescribeOptions): Promise<DescribeResult>;
404
+ describe(o?: DescribeOptions): Promise<DescribeResult>;
385
405
  /**
386
406
  * Create a type from its complete type-file `document`. The replica's Core
387
407
  * derives the name and path (`<types_folder>/<name>.md`) from the local
@@ -398,10 +418,12 @@ export declare class MdbaseClient {
398
418
  * Core's temporal typing for top-level fields under a query's exact `types` OR list
399
419
  * (`date` / `date_time` only when every type agrees; otherwise `none`). The answer is
400
420
  * bound to a catalog generation; nested paths are `none`. The SDK never infers typing.
421
+ * `o.signal` cancels the read.
401
422
  */
402
- describeTyping(types: readonly string[], paths: readonly string[], signal?: AbortSignal): Promise<DescribeTypingResult>;
403
- /** One record by ID or path. Throws `not_found`. */
404
- get(ref: RecordRef, include?: Include, signal?: AbortSignal): Promise<RecordView>;
423
+ describeTyping(types: readonly string[], paths: readonly string[], o?: ReadOptions): Promise<DescribeTypingResult>;
424
+ /** One record by ID or path. Throws `not_found`. `o.include` adds the body
425
+ * and other parts to the record; `o.signal` cancels the read. */
426
+ get(ref: RecordRef, o?: RecordReadOptions): Promise<RecordView>;
405
427
  /**
406
428
  * One record's valid view through a record contract, mapped by the replica's
407
429
  * Core. Refusals: `not_found` (no record, or `data_contract_not_implemented`
@@ -409,22 +431,27 @@ export declare class MdbaseClient {
409
431
  * `invalid_request`/`data_contract_ambiguous` (select `type`; details: the types),
410
432
  * `invalid_record`/`data_contract_record_invalid` (with issues), and
411
433
  * `upgrade_required`/`contract_records_unsupported` from an older replica.
434
+ * `o.signal` cancels the read.
412
435
  */
413
- getContract(ref: RecordRef, contract: ContractSelector, signal?: AbortSignal): Promise<ContractRecordView>;
436
+ getContract(ref: RecordRef, contract: ContractSelector, o?: ReadOptions): Promise<ContractRecordView>;
414
437
  private contractCall;
415
438
  /** Bounded ordered ordinary gets. Missing/refused reads fail the batch;
416
- * duplicate slots and the original signal are retained, not a snapshot. */
417
- readMany(refs: readonly RecordRef[], include?: Include, signal?: AbortSignal, options?: ReadManyOptions): Promise<RecordView[]>;
418
- /** One record, or `null` when there is none. */
419
- find(ref: RecordRef, include?: Include, signal?: AbortSignal): Promise<RecordView | null>;
439
+ * duplicate slots and the original signal are retained, not a snapshot.
440
+ * `o.include` and `o.signal` apply to every get; `o.concurrency` bounds the
441
+ * gets in flight. */
442
+ readMany(refs: readonly RecordRef[], o?: RecordReadOptions & ReadManyOptions): Promise<RecordView[]>;
443
+ /** One record, or `null` when there is none. `o` is as for {@link get}. */
444
+ find(ref: RecordRef, o?: RecordReadOptions): Promise<RecordView | null>;
420
445
  /**
421
446
  * One page of a query, evaluated by the replica (body predicates and links
422
447
  * included, §4). Pass `result.cursor` back as `query.cursor` for the next.
423
- * `opts.contract` is not supported by the live replica dispatch. Supplying it
448
+ * `o.include` adds the body and other parts to each record; `o.signal`
449
+ * cancels the read.
450
+ * `o.contract` is not supported by the live replica dispatch. Supplying it
424
451
  * returns `invalid_request` with reason `unknown_param`; no contract filter
425
452
  * is applied. The option remains encoded unchanged for API compatibility.
426
453
  */
427
- query(query: Query, include?: Include, signal?: AbortSignal, opts?: {
454
+ query(query: Query, o?: RecordReadOptions & {
428
455
  contract?: string;
429
456
  }): Promise<QueryResult>;
430
457
  /** Canonical contract projections with validation issues and ordinary cursor
@@ -466,7 +493,8 @@ export declare class MdbaseClient {
466
493
  }): Promise<ResolveLinksResult>;
467
494
  /** Definitions: `mdbase.yaml`, type files, contract files (§4.1). */
468
495
  readonly resources: {
469
- get: (path: string, signal?: AbortSignal) => Promise<ResourceView>;
496
+ /** One definition by path. `o.signal` cancels the read. */
497
+ get: (path: string, o?: ReadOptions) => Promise<ResourceView>;
470
498
  /** One bounded resource inventory page. Text defaults to false; limit defaults
471
499
  * to 64 (maximum 128). Preserve folder/text/limit on continuation. Collect all
472
500
  * pages before assessing a complete snapshot; stale/expired cursors require
@@ -477,7 +505,17 @@ export declare class MdbaseClient {
477
505
  cursor?: string;
478
506
  limit?: number;
479
507
  signal?: AbortSignal;
480
- }) => Promise<import("./wire.js").ListResourcesResult>;
508
+ }) => Promise<{
509
+ resources: {
510
+ path: string;
511
+ revision: import("./wire.js").Hash;
512
+ size: number;
513
+ state: "confirmed" | "pending";
514
+ text?: string | undefined;
515
+ }[];
516
+ complete: boolean;
517
+ cursor?: string | undefined;
518
+ }>;
481
519
  /**
482
520
  * Write a resource. CAS: pass the revision you read as `baseRevision`, or
483
521
  * `mustNotExist` to create only (a taken path is `conflict` / `path_taken`). Not both.
@@ -506,19 +544,26 @@ export declare class MdbaseClient {
506
544
  updateSource: (seen: RecordView, document: string, options: ViewSourceWriteOptions) => Promise<Write>;
507
545
  getSourceRecord: (source: RecordRef, options?: ViewSourceReadOptions) => Promise<RecordView>;
508
546
  /** `mdbase.view` sources (spec 12 `list_views` shape), resolved over served
509
- * contract queries: the native runtime has no `list_views` RPC. */
510
- list: (folder?: string, signal?: AbortSignal) => Promise<ListViewsResult>;
547
+ * contract queries: the native runtime has no `list_views` RPC. `o.folder`
548
+ * keeps the sources under one folder; `o.signal` cancels the read. */
549
+ list: (o?: {
550
+ folder?: string;
551
+ signal?: AbortSignal;
552
+ }) => Promise<ListViewsResult>;
511
553
  /** Spec 11 named-view resolution, executed as one ordinary native query. */
512
554
  execute: (source: RecordRef, view: string, o?: ExecuteViewOptions) => Promise<QueryResult>;
513
- readSource: (source: RecordRef, signal?: AbortSignal) => Promise<ViewSourceDocument>;
555
+ /** The current source document of one `mdbase.view` record. `o.signal`
556
+ * cancels the read. */
557
+ readSource: (source: RecordRef, o?: ReadOptions) => Promise<ViewSourceDocument>;
514
558
  };
515
559
  /**
516
560
  * Pending mutations of this session's owner (its grant, or the device), oldest
517
561
  * first (§6): a new session after a reload sees writes made before it. Follow
518
562
  * each with `awaitReceipt`, or keep the `mutationId` you chose and call
519
- * `receipt(id)` / `awaitReceipt(id)`. Pages through everything.
563
+ * `receipt(id)` / `awaitReceipt(id)`. Pages through everything; `o.signal`
564
+ * cancels the read.
520
565
  */
521
- pendingWrites(signal?: AbortSignal): Promise<PendingMutation[]>;
566
+ pendingWrites(o?: ReadOptions): Promise<PendingMutation[]>;
522
567
  /**
523
568
  * What a rename would do to links (dry run, §5): the rewrites, and links left broken.
524
569
  * Throws the problem the real rename would get.
@@ -529,33 +574,62 @@ export declare class MdbaseClient {
529
574
  /** Links a delete would break (dry run, §5). */
530
575
  preflightDelete(target: RecordRef): Promise<Preflight>;
531
576
  private preflight;
532
- /** Every page of a query. Cursor resets require explicit caller clearing;
533
- * otherwise cursor_expired/cursor_stale is thrown unchanged. */
534
- pages(query: Query, include?: Include, signal?: AbortSignal, options?: PagesOptions): AsyncGenerator<QueryResult>;
535
- /** Shared alias of pages(): whole native pages, no implicit cursor reset. */
536
- queryPages(query: Query, include?: Include, signal?: AbortSignal, options?: PagesOptions): AsyncGenerator<QueryResult>;
577
+ /** Every page of a query. `o.include` and `o.signal` apply to every page.
578
+ * Cursor resets require explicit caller clearing through `o.onReset`;
579
+ * otherwise cursor_expired/cursor_stale is thrown unchanged. The query and
580
+ * `o` are captured when iteration starts. */
581
+ pages(query: Query, o?: RecordReadOptions & PagesOptions): AsyncGenerator<QueryResult>;
582
+ /** Shared alias of pages(): whole native pages, no implicit cursor reset.
583
+ * `o.include` and `o.signal` apply to every page; `o.onReset` opts in to one
584
+ * first-page restart. */
585
+ queryPages(query: Query, o?: RecordReadOptions & PagesOptions): AsyncGenerator<QueryResult>;
586
+ /**
587
+ * Every record of the chosen types (default: all), read completely and then
588
+ * kept current: the set an app lists, searches and renders from. Close it
589
+ * when done.
590
+ */
591
+ recordSet(options?: RecordSetOptions): RecordSet;
537
592
  /**
538
- * A live query. Subscribe for pushes; keep lists cheap with a `limit` window and no
539
- * bodies, and widen the window with `setQuery`.
593
+ * A live query: one window of at most 1,000 records and 1 MiB, with the
594
+ * replica's order and counts. Subscribe for pushes; keep lists cheap with a
595
+ * `limit` window and no bodies, and widen the window with `setQuery`. For a
596
+ * whole collection use `recordSet`. `o.include` adds the body and other
597
+ * parts to each record.
540
598
  */
541
- live(query: Query, include?: Include): LiveQuery;
542
- /** One page of the change feed. A `reset: true` result means "re-read what you cache". */
543
- changes(cursor?: string, limit?: number, signal?: AbortSignal): Promise<ChangesResult>;
599
+ live(query: Query, o?: {
600
+ include?: Include;
601
+ }): LiveQuery;
602
+ /** One page of the change feed, from `o.cursor` (default: the start) and of
603
+ * at most `o.limit` changes. A `reset: true` result means "re-read what you
604
+ * cache". `o.signal` cancels the read. */
605
+ changes(o?: {
606
+ cursor?: string;
607
+ limit?: number;
608
+ signal?: AbortSignal;
609
+ }): Promise<ChangesResult>;
544
610
  /**
545
- * Follow the change feed from `cursor`. `onChanges` gets every batch; `reset: true`
546
- * means the app must re-read what it caches. Survives reconnects.
611
+ * Follow the change feed from `o.cursor` (default: the start). `onChanges` gets
612
+ * every batch; `reset: true` means the app must re-read what it caches. Survives
613
+ * reconnects.
547
614
  * `ready` confirms the first watch ACK, not a complete/current collection cache.
548
615
  * After reconnect, observe `state`; an already-resolved promise is not freshness.
549
616
  */
550
- watchChanges(cursor: string | undefined, onChanges: (batch: ChangesResult) => void): ChangesWatch;
551
- /** Validate these records, or every record. Every record is validated a
617
+ watchChanges(onChanges: (batch: ChangesResult) => void, o?: {
618
+ cursor?: string;
619
+ }): ChangesWatch;
620
+ /** Validate `o.refs`, or every record without them. Every record is validated a
552
621
  * page at a time when the replica grants `validate-page-v1`; each page is an
553
622
  * independent READ, so records changed meanwhile may be missed or repeated.
554
- * Older replicas validate every record in one bounded request. */
555
- validate(refs?: readonly RecordRef[], signal?: AbortSignal): Promise<RecordValidation[]>;
623
+ * Older replicas validate every record in one bounded request. `o.signal`
624
+ * cancels the read. */
625
+ validate(o?: {
626
+ refs?: readonly RecordRef[];
627
+ signal?: AbortSignal;
628
+ }): Promise<RecordValidation[]>;
556
629
  /** Independent native app-host Bases READ, exact original held session.
557
- * Unsupported transports refuse: no generic execute_view/data fallback. */
558
- executeAppBases(request: AppBasesRequest, signal?: AbortSignal): Promise<AppBasesResult>;
630
+ * Unsupported transports refuse: no generic execute_view/data fallback.
631
+ * `o.signal` cancels the read. */
632
+ executeAppBases(request: AppBasesRequest, o?: ReadOptions): Promise<AppBasesResult>;
559
633
  /** All rows of a saved view, page by page over native windows (prod
560
634
  * `executeViewPages`). Each page is an independent READ; `changedSinceFirst`
561
635
  * marks pages taken after the collection changed. */
@@ -564,16 +638,16 @@ export declare class MdbaseClient {
564
638
  problem: Problem;
565
639
  } | import("./app-host/bases-pages.js").AppBasesPage, any, any>;
566
640
  /** One bounded native discovery page. Empty views do not mean EOF when a
567
- * continuation is present. Supplied handles never silently restart/retry. */
568
- listAppBasesViews(request: AppBasesDiscoveryRequest, signal?: AbortSignal): Promise<AppBasesDiscoveryResult>;
641
+ * continuation is present. Supplied handles never silently restart/retry.
642
+ * `o.signal` cancels the read. */
643
+ listAppBasesViews(request: AppBasesDiscoveryRequest, o?: ReadOptions): Promise<AppBasesDiscoveryResult>;
569
644
  /** Exact current source for one native UUID/SHA/original ordinal, never path
570
- * aliases, inferred catalog entries, generic RPC or cached document fallback. */
571
- readAppBasesViewSource(request: AppBasesSourceRequest, signal?: AbortSignal): Promise<AppBasesSourceResult>;
572
- /** Submit operations as one mutation (or one per op with `allowPartial`). */
573
- submit(ops: Op[], o?: WriteOptions & {
574
- allowPartial?: boolean;
575
- }): Promise<Write[]>;
576
- private one;
645
+ * aliases, inferred catalog entries, generic RPC or cached document fallback.
646
+ * `o.signal` cancels the read. */
647
+ readAppBasesViewSource(request: AppBasesSourceRequest, o?: ReadOptions): Promise<AppBasesSourceResult>;
648
+ /** Submit operations as one mutation: they apply together or not at all. */
649
+ submit(ops: Op[], o?: WriteOptions): Promise<Write>;
650
+ private record;
577
651
  /** Create a record. The ID is minted here, so the app can use it before confirmation. */
578
652
  create(input: CreateInput, o?: WriteOptions): Promise<RecordWrite>;
579
653
  private createThroughContract;
@@ -609,28 +683,39 @@ export declare class MdbaseClient {
609
683
  contract?: ContractSelector;
610
684
  }): Promise<Write>;
611
685
  /**
612
- * Settle a write for the UI: waits up to `timeoutMs` (default 3 s) for the log
613
- * to confirm it. Still pending then is `saved_on_device`, not a failure: the
614
- * write is kept on this device and the ledger settles it later. With
615
- * `readBack`, `record` is the record as it now reads here.
686
+ * Settle a write: wait for the sync service to confirm it (3 s by default),
687
+ * and with `read`, read the record back as it now reads here.
688
+ *
689
+ * Pass the write, the promise of one, or the mutation ID of an earlier write
690
+ * whose result was `unknown`. The answer is a {@link Settlement}; the only
691
+ * rejections are cancellation and a call that cannot be settled as asked.
692
+ * Nothing is ever submitted again.
693
+ *
694
+ * const saved = await db.settle(db.update(record, { patch }), { read: true });
695
+ * if (saved.outcome === "rejected") show(describeError(saved.problem));
616
696
  */
617
- save(write: Write | Promise<Write>, o?: {
618
- readBack?: boolean;
697
+ settle(write: Write | Promise<Write> | Uuid, options?: SettleOptions): Promise<Settlement>;
698
+ /** The current receipt of a mutation. Failures carry `mutationId`. `o.signal` cancels the read. */
699
+ receipt(mutation: Uuid, o?: ReadOptions): Promise<Receipt>;
700
+ /** Resolves when the receipt leaves `pending`, or at `o.timeoutMs` with the
701
+ * pending receipt. `o.signal` cancels the wait. */
702
+ awaitReceipt(mutation: Uuid, o?: {
619
703
  timeoutMs?: number;
620
704
  signal?: AbortSignal;
621
- }): Promise<SaveResult>;
622
- /** The current receipt of a mutation. Failures carry `mutationId`. */
623
- receipt(mutation: Uuid, signal?: AbortSignal): Promise<Receipt>;
624
- /** Resolves when the receipt leaves `pending`, or at `timeoutMs` with the pending receipt. */
625
- awaitReceipt(mutation: Uuid, timeoutMs?: number, signal?: AbortSignal): Promise<Receipt>;
626
- listHolds(signal?: AbortSignal): Promise<Hold[]>;
705
+ }): Promise<Receipt>;
706
+ /** The current holds. `o.signal` cancels the read. */
707
+ listHolds(o?: ReadOptions): Promise<Hold[]>;
627
708
  /** Call `fn` with the holds now and on every change. */
628
709
  onHolds(fn: (h: Hold[]) => void): () => void;
629
710
  private refreshHolds;
630
711
  private emitHolds;
631
712
  /** Resolve a hold. Submits an ordinary mutation and returns its write. */
632
713
  resolveHold(id: Uuid, how: HoldResolution, use?: string): Promise<Write>;
633
- listConflicts(record?: Uuid, signal?: AbortSignal): Promise<ConflictEntry[]>;
714
+ /** The current conflicts, of `o.record` only when given. `o.signal` cancels the read. */
715
+ listConflicts(o?: {
716
+ record?: Uuid;
717
+ signal?: AbortSignal;
718
+ }): Promise<ConflictEntry[]>;
634
719
  onConflicts(fn: (c: ConflictEntry[]) => void): () => void;
635
720
  private refreshConflicts;
636
721
  private emitConflicts;
@@ -643,8 +728,9 @@ export declare class MdbaseClient {
643
728
  * hosting the replica (no grant). `exchangeReady` is challenge/reveal readiness,
644
729
  * NOT approval/key delivery. Once ready, `sas` is the host-only comparison code
645
730
  * to display beside Allow; the user must check it matches on the other computer.
731
+ * `o.signal` cancels the read.
646
732
  */
647
- pendingDevices(signal?: AbortSignal): Promise<PendingDevice[]>;
733
+ pendingDevices(o?: ReadOptions): Promise<PendingDevice[]>;
648
734
  /**
649
735
  * Confirm with the six digits displayed for the current host exchange, only
650
736
  * after the user visually checks they match on the requesting computer. Nothing
@@ -664,7 +750,9 @@ export declare class MdbaseClient {
664
750
  setup: (secret: Uint8Array) => Promise<Write>;
665
751
  /** Unlock step 3: start the recovery-signed self-grant; poll `status` until `keyed` or `refused`. */
666
752
  unlock: (secret: Uint8Array) => Promise<void>;
667
- status: (signal?: AbortSignal) => Promise<AccountKeyStatus>;
753
+ /** Where an account-key unlock stands on this replica. `o.signal` cancels
754
+ * the read. */
755
+ status: (o?: ReadOptions) => Promise<AccountKeyStatus>;
668
756
  };
669
757
  /** Recovery key for a private collection (hosting app only). */
670
758
  readonly recoveryKey: {