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

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 +173 -84
  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 +49 -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 +60 -5
  123. package/dist/testing/memory-replica.js +127 -20
  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;
@@ -78,13 +74,12 @@ export interface TypeCreation {
78
74
  export interface DescribeOptions {
79
75
  /** Include type definitions/schemas and contract schemas. */
80
76
  definitions?: boolean;
81
- signal?: AbortSignal;
77
+ signal?: AbortSignal | undefined;
82
78
  }
83
79
  /** The link between this client and its replica (not the replica's sync state). */
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,16 @@ export interface UpdateInput {
178
173
  */
179
174
  promote?: boolean;
180
175
  }
176
+ /** What every read takes. `signal` may be passed as `undefined`, so a caller's
177
+ * own optional signal goes straight in under `exactOptionalPropertyTypes`. */
178
+ export interface ReadOptions {
179
+ signal?: AbortSignal | undefined;
180
+ }
181
+ /** A read that returns records. */
182
+ export interface RecordReadOptions extends ReadOptions {
183
+ /** What each record carries beyond its path, type and frontmatter. */
184
+ include?: Include;
185
+ }
181
186
  export interface WriteOptions {
182
187
  mutationId?: Uuid;
183
188
  /**
@@ -218,6 +223,8 @@ export declare class Write {
218
223
  * is a final non-publication, not success. Without files, settles at confirmation.
219
224
  * Rejects rejected/unknown outcomes; not a native custody/durable ACK gate. */
220
225
  readonly published: Promise<Receipt>;
226
+ /** The record a single-record write targets (create, update, replace, rename, delete). */
227
+ recordId?: Uuid;
221
228
  constructor(receipt: Receipt);
222
229
  get mutationId(): Uuid;
223
230
  /** The records as they now read locally (optimistic until confirmed). */
@@ -227,8 +234,8 @@ export declare class Write {
227
234
  /** SDK-internal: apply a newer receipt. Kept in the published types (apps' tests use it). */
228
235
  update(r: Receipt): void;
229
236
  }
230
- /** A create receipt with the record identity minted by the SDK, even when the
231
- * replica omits optimistic records from its response. */
237
+ /** A create, with the record ID the SDK minted: known even when the replica
238
+ * omits optimistic records from its response. */
232
239
  export interface RecordWrite extends Write {
233
240
  readonly recordId: Uuid;
234
241
  }
@@ -257,8 +264,12 @@ export declare class LiveQuery implements LiveQueryState {
257
264
  get(id: Uuid): RecordView | undefined;
258
265
  /** Call `fn` now and on every change. Returns an unsubscribe function. */
259
266
  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>;
267
+ /** Change the query (for example a larger `limit` window). Re-subscribes.
268
+ * `o.include` replaces what each record carries; without it the current
269
+ * include is kept. */
270
+ setQuery(query: Query, o?: {
271
+ include?: Include;
272
+ }): Promise<void>;
262
273
  close(): void;
263
274
  private emit;
264
275
  }
@@ -341,12 +352,20 @@ export declare class MdbaseClient {
341
352
  /**
342
353
  * Advanced: run a request on the current session; on a dropped link, wait for the
343
354
  * reconnect and retry when `retry` (idempotent requests only).
355
+ *
356
+ * With a `codec` the answer is decoded and its values are plain JSON, as from
357
+ * every other method. Without one it is the exact CBOR answer: decode that
358
+ * with a `wire` codec to keep `Map` order, `Float64` and `bigint`.
344
359
  */
345
- call<T = CborValue>(method: string, p: CborValue, o?: {
360
+ call(method: string, p: CborValue, o?: {
346
361
  signal?: AbortSignal;
347
- codec?: import("./codec.js").Codec<T>;
348
362
  retry?: boolean;
349
- }): Promise<T>;
363
+ }): Promise<CborValue>;
364
+ call<T>(method: string, p: CborValue, o: {
365
+ signal?: AbortSignal;
366
+ codec: Codec<T>;
367
+ retry?: boolean;
368
+ }): Promise<Plain<T>>;
350
369
  /** Pass head witnesses between replicas (log-entry.md §11); best effort. */
351
370
  private relayWitnesses;
352
371
  /** Transport-authenticated replica identity (Noise target), NOT hello/witness
@@ -369,8 +388,9 @@ export declare class MdbaseClient {
369
388
  * revalidate the authenticated session and all readiness gates after any await.
370
389
  * Missing chain or any error means remain hosted; never substitute asOf or the
371
390
  * current head/generations. Decoding does not authenticate a witness or switch.
391
+ * `o.signal` cancels the read.
372
392
  */
373
- appliedPrefix(seq: number, signal?: AbortSignal): Promise<AppliedPrefix>;
393
+ appliedPrefix(seq: number, o?: ReadOptions): Promise<AppliedPrefix>;
374
394
  /** Call `fn` with the status now and on every change (pushed, ≤ 4/s). */
375
395
  onStatus(fn: (s: SyncStatus) => void): () => void;
376
396
  private setStatus;
@@ -380,8 +400,9 @@ export declare class MdbaseClient {
380
400
  * definition and schema and each contract's schemas, bounded by the replica
381
401
  * (`too_large` when over budget; read them with `resources.get` instead).
382
402
  * A producer that cannot describe definitions fails `upgrade_required`.
403
+ * `o.signal` cancels the read.
383
404
  */
384
- describe(options?: AbortSignal | DescribeOptions): Promise<DescribeResult>;
405
+ describe(o?: DescribeOptions): Promise<DescribeResult>;
385
406
  /**
386
407
  * Create a type from its complete type-file `document`. The replica's Core
387
408
  * derives the name and path (`<types_folder>/<name>.md`) from the local
@@ -398,10 +419,12 @@ export declare class MdbaseClient {
398
419
  * Core's temporal typing for top-level fields under a query's exact `types` OR list
399
420
  * (`date` / `date_time` only when every type agrees; otherwise `none`). The answer is
400
421
  * bound to a catalog generation; nested paths are `none`. The SDK never infers typing.
422
+ * `o.signal` cancels the read.
401
423
  */
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>;
424
+ describeTyping(types: readonly string[], paths: readonly string[], o?: ReadOptions): Promise<DescribeTypingResult>;
425
+ /** One record by ID or path. Throws `not_found`. `o.include` adds the body
426
+ * and other parts to the record; `o.signal` cancels the read. */
427
+ get(ref: RecordRef, o?: RecordReadOptions): Promise<RecordView>;
405
428
  /**
406
429
  * One record's valid view through a record contract, mapped by the replica's
407
430
  * Core. Refusals: `not_found` (no record, or `data_contract_not_implemented`
@@ -409,22 +432,27 @@ export declare class MdbaseClient {
409
432
  * `invalid_request`/`data_contract_ambiguous` (select `type`; details: the types),
410
433
  * `invalid_record`/`data_contract_record_invalid` (with issues), and
411
434
  * `upgrade_required`/`contract_records_unsupported` from an older replica.
435
+ * `o.signal` cancels the read.
412
436
  */
413
- getContract(ref: RecordRef, contract: ContractSelector, signal?: AbortSignal): Promise<ContractRecordView>;
437
+ getContract(ref: RecordRef, contract: ContractSelector, o?: ReadOptions): Promise<ContractRecordView>;
414
438
  private contractCall;
415
439
  /** 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>;
440
+ * duplicate slots and the original signal are retained, not a snapshot.
441
+ * `o.include` and `o.signal` apply to every get; `o.concurrency` bounds the
442
+ * gets in flight. */
443
+ readMany(refs: readonly RecordRef[], o?: RecordReadOptions & ReadManyOptions): Promise<RecordView[]>;
444
+ /** One record, or `null` when there is none. `o` is as for {@link get}. */
445
+ find(ref: RecordRef, o?: RecordReadOptions): Promise<RecordView | null>;
420
446
  /**
421
447
  * One page of a query, evaluated by the replica (body predicates and links
422
448
  * 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
449
+ * `o.include` adds the body and other parts to each record; `o.signal`
450
+ * cancels the read.
451
+ * `o.contract` is not supported by the live replica dispatch. Supplying it
424
452
  * returns `invalid_request` with reason `unknown_param`; no contract filter
425
453
  * is applied. The option remains encoded unchanged for API compatibility.
426
454
  */
427
- query(query: Query, include?: Include, signal?: AbortSignal, opts?: {
455
+ query(query: Query, o?: RecordReadOptions & {
428
456
  contract?: string;
429
457
  }): Promise<QueryResult>;
430
458
  /** Canonical contract projections with validation issues and ordinary cursor
@@ -466,7 +494,8 @@ export declare class MdbaseClient {
466
494
  }): Promise<ResolveLinksResult>;
467
495
  /** Definitions: `mdbase.yaml`, type files, contract files (§4.1). */
468
496
  readonly resources: {
469
- get: (path: string, signal?: AbortSignal) => Promise<ResourceView>;
497
+ /** One definition by path. `o.signal` cancels the read. */
498
+ get: (path: string, o?: ReadOptions) => Promise<ResourceView>;
470
499
  /** One bounded resource inventory page. Text defaults to false; limit defaults
471
500
  * to 64 (maximum 128). Preserve folder/text/limit on continuation. Collect all
472
501
  * pages before assessing a complete snapshot; stale/expired cursors require
@@ -477,7 +506,17 @@ export declare class MdbaseClient {
477
506
  cursor?: string;
478
507
  limit?: number;
479
508
  signal?: AbortSignal;
480
- }) => Promise<import("./wire.js").ListResourcesResult>;
509
+ }) => Promise<{
510
+ resources: {
511
+ path: string;
512
+ revision: import("./wire.js").Hash;
513
+ size: number;
514
+ state: "confirmed" | "pending";
515
+ text?: string | undefined;
516
+ }[];
517
+ complete: boolean;
518
+ cursor?: string | undefined;
519
+ }>;
481
520
  /**
482
521
  * Write a resource. CAS: pass the revision you read as `baseRevision`, or
483
522
  * `mustNotExist` to create only (a taken path is `conflict` / `path_taken`). Not both.
@@ -506,19 +545,26 @@ export declare class MdbaseClient {
506
545
  updateSource: (seen: RecordView, document: string, options: ViewSourceWriteOptions) => Promise<Write>;
507
546
  getSourceRecord: (source: RecordRef, options?: ViewSourceReadOptions) => Promise<RecordView>;
508
547
  /** `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>;
548
+ * contract queries: the native runtime has no `list_views` RPC. `o.folder`
549
+ * keeps the sources under one folder; `o.signal` cancels the read. */
550
+ list: (o?: {
551
+ folder?: string;
552
+ signal?: AbortSignal;
553
+ }) => Promise<ListViewsResult>;
511
554
  /** Spec 11 named-view resolution, executed as one ordinary native query. */
512
555
  execute: (source: RecordRef, view: string, o?: ExecuteViewOptions) => Promise<QueryResult>;
513
- readSource: (source: RecordRef, signal?: AbortSignal) => Promise<ViewSourceDocument>;
556
+ /** The current source document of one `mdbase.view` record. `o.signal`
557
+ * cancels the read. */
558
+ readSource: (source: RecordRef, o?: ReadOptions) => Promise<ViewSourceDocument>;
514
559
  };
515
560
  /**
516
561
  * Pending mutations of this session's owner (its grant, or the device), oldest
517
562
  * first (§6): a new session after a reload sees writes made before it. Follow
518
563
  * each with `awaitReceipt`, or keep the `mutationId` you chose and call
519
- * `receipt(id)` / `awaitReceipt(id)`. Pages through everything.
564
+ * `receipt(id)` / `awaitReceipt(id)`. Pages through everything; `o.signal`
565
+ * cancels the read.
520
566
  */
521
- pendingWrites(signal?: AbortSignal): Promise<PendingMutation[]>;
567
+ pendingWrites(o?: ReadOptions): Promise<PendingMutation[]>;
522
568
  /**
523
569
  * What a rename would do to links (dry run, §5): the rewrites, and links left broken.
524
570
  * Throws the problem the real rename would get.
@@ -529,33 +575,62 @@ export declare class MdbaseClient {
529
575
  /** Links a delete would break (dry run, §5). */
530
576
  preflightDelete(target: RecordRef): Promise<Preflight>;
531
577
  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>;
578
+ /** Every page of a query. `o.include` and `o.signal` apply to every page.
579
+ * Cursor resets require explicit caller clearing through `o.onReset`;
580
+ * otherwise cursor_expired/cursor_stale is thrown unchanged. The query and
581
+ * `o` are captured when iteration starts. */
582
+ pages(query: Query, o?: RecordReadOptions & PagesOptions): AsyncGenerator<QueryResult>;
583
+ /** Shared alias of pages(): whole native pages, no implicit cursor reset.
584
+ * `o.include` and `o.signal` apply to every page; `o.onReset` opts in to one
585
+ * first-page restart. */
586
+ queryPages(query: Query, o?: RecordReadOptions & PagesOptions): AsyncGenerator<QueryResult>;
537
587
  /**
538
- * A live query. Subscribe for pushes; keep lists cheap with a `limit` window and no
539
- * bodies, and widen the window with `setQuery`.
588
+ * Every record of the chosen types (default: all), read completely and then
589
+ * kept current: the set an app lists, searches and renders from. Close it
590
+ * when done.
540
591
  */
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>;
592
+ recordSet(options?: RecordSetOptions): RecordSet;
544
593
  /**
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.
594
+ * A live query: one window of at most 1,000 records and 1 MiB, with the
595
+ * replica's order and counts. Subscribe for pushes; keep lists cheap with a
596
+ * `limit` window and no bodies, and widen the window with `setQuery`. For a
597
+ * whole collection use `recordSet`. `o.include` adds the body and other
598
+ * parts to each record.
599
+ */
600
+ live(query: Query, o?: {
601
+ include?: Include;
602
+ }): LiveQuery;
603
+ /** One page of the change feed, from `o.cursor` (default: the start) and of
604
+ * at most `o.limit` changes. A `reset: true` result means "re-read what you
605
+ * cache". `o.signal` cancels the read. */
606
+ changes(o?: {
607
+ cursor?: string;
608
+ limit?: number;
609
+ signal?: AbortSignal;
610
+ }): Promise<ChangesResult>;
611
+ /**
612
+ * Follow the change feed from `o.cursor` (default: the start). `onChanges` gets
613
+ * every batch; `reset: true` means the app must re-read what it caches. Survives
614
+ * reconnects.
547
615
  * `ready` confirms the first watch ACK, not a complete/current collection cache.
548
616
  * After reconnect, observe `state`; an already-resolved promise is not freshness.
549
617
  */
550
- watchChanges(cursor: string | undefined, onChanges: (batch: ChangesResult) => void): ChangesWatch;
551
- /** Validate these records, or every record. Every record is validated a
618
+ watchChanges(onChanges: (batch: ChangesResult) => void, o?: {
619
+ cursor?: string;
620
+ }): ChangesWatch;
621
+ /** Validate `o.refs`, or every record without them. Every record is validated a
552
622
  * page at a time when the replica grants `validate-page-v1`; each page is an
553
623
  * 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[]>;
624
+ * Older replicas validate every record in one bounded request. `o.signal`
625
+ * cancels the read. */
626
+ validate(o?: {
627
+ refs?: readonly RecordRef[];
628
+ signal?: AbortSignal;
629
+ }): Promise<RecordValidation[]>;
556
630
  /** 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>;
631
+ * Unsupported transports refuse: no generic execute_view/data fallback.
632
+ * `o.signal` cancels the read. */
633
+ executeAppBases(request: AppBasesRequest, o?: ReadOptions): Promise<AppBasesResult>;
559
634
  /** All rows of a saved view, page by page over native windows (prod
560
635
  * `executeViewPages`). Each page is an independent READ; `changedSinceFirst`
561
636
  * marks pages taken after the collection changed. */
@@ -564,16 +639,16 @@ export declare class MdbaseClient {
564
639
  problem: Problem;
565
640
  } | import("./app-host/bases-pages.js").AppBasesPage, any, any>;
566
641
  /** 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>;
642
+ * continuation is present. Supplied handles never silently restart/retry.
643
+ * `o.signal` cancels the read. */
644
+ listAppBasesViews(request: AppBasesDiscoveryRequest, o?: ReadOptions): Promise<AppBasesDiscoveryResult>;
569
645
  /** 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;
646
+ * aliases, inferred catalog entries, generic RPC or cached document fallback.
647
+ * `o.signal` cancels the read. */
648
+ readAppBasesViewSource(request: AppBasesSourceRequest, o?: ReadOptions): Promise<AppBasesSourceResult>;
649
+ /** Submit operations as one mutation: they apply together or not at all. */
650
+ submit(ops: Op[], o?: WriteOptions): Promise<Write>;
651
+ private record;
577
652
  /** Create a record. The ID is minted here, so the app can use it before confirmation. */
578
653
  create(input: CreateInput, o?: WriteOptions): Promise<RecordWrite>;
579
654
  private createThroughContract;
@@ -609,28 +684,39 @@ export declare class MdbaseClient {
609
684
  contract?: ContractSelector;
610
685
  }): Promise<Write>;
611
686
  /**
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.
687
+ * Settle a write: wait for the sync service to confirm it (3 s by default),
688
+ * and with `read`, read the record back as it now reads here.
689
+ *
690
+ * Pass the write, the promise of one, or the mutation ID of an earlier write
691
+ * whose result was `unknown`. The answer is a {@link Settlement}; the only
692
+ * rejections are cancellation and a call that cannot be settled as asked.
693
+ * Nothing is ever submitted again.
694
+ *
695
+ * const saved = await db.settle(db.update(record, { patch }), { read: true });
696
+ * if (saved.outcome === "rejected") show(describeError(saved.problem));
616
697
  */
617
- save(write: Write | Promise<Write>, o?: {
618
- readBack?: boolean;
619
- timeoutMs?: number;
620
- 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[]>;
698
+ settle(write: Write | Promise<Write> | Uuid, options?: SettleOptions): Promise<Settlement>;
699
+ /** The current receipt of a mutation. Failures carry `mutationId`. `o.signal` cancels the read. */
700
+ receipt(mutation: Uuid, o?: ReadOptions): Promise<Receipt>;
701
+ /** Resolves when the receipt leaves `pending`, or at `o.timeoutMs` with the
702
+ * pending receipt. `o.signal` cancels the wait. */
703
+ awaitReceipt(mutation: Uuid, o?: {
704
+ timeoutMs?: number | undefined;
705
+ signal?: AbortSignal | undefined;
706
+ }): Promise<Receipt>;
707
+ /** The current holds. `o.signal` cancels the read. */
708
+ listHolds(o?: ReadOptions): Promise<Hold[]>;
627
709
  /** Call `fn` with the holds now and on every change. */
628
710
  onHolds(fn: (h: Hold[]) => void): () => void;
629
711
  private refreshHolds;
630
712
  private emitHolds;
631
713
  /** Resolve a hold. Submits an ordinary mutation and returns its write. */
632
714
  resolveHold(id: Uuid, how: HoldResolution, use?: string): Promise<Write>;
633
- listConflicts(record?: Uuid, signal?: AbortSignal): Promise<ConflictEntry[]>;
715
+ /** The current conflicts, of `o.record` only when given. `o.signal` cancels the read. */
716
+ listConflicts(o?: {
717
+ record?: Uuid;
718
+ signal?: AbortSignal;
719
+ }): Promise<ConflictEntry[]>;
634
720
  onConflicts(fn: (c: ConflictEntry[]) => void): () => void;
635
721
  private refreshConflicts;
636
722
  private emitConflicts;
@@ -643,8 +729,9 @@ export declare class MdbaseClient {
643
729
  * hosting the replica (no grant). `exchangeReady` is challenge/reveal readiness,
644
730
  * NOT approval/key delivery. Once ready, `sas` is the host-only comparison code
645
731
  * to display beside Allow; the user must check it matches on the other computer.
732
+ * `o.signal` cancels the read.
646
733
  */
647
- pendingDevices(signal?: AbortSignal): Promise<PendingDevice[]>;
734
+ pendingDevices(o?: ReadOptions): Promise<PendingDevice[]>;
648
735
  /**
649
736
  * Confirm with the six digits displayed for the current host exchange, only
650
737
  * after the user visually checks they match on the requesting computer. Nothing
@@ -664,7 +751,9 @@ export declare class MdbaseClient {
664
751
  setup: (secret: Uint8Array) => Promise<Write>;
665
752
  /** Unlock step 3: start the recovery-signed self-grant; poll `status` until `keyed` or `refused`. */
666
753
  unlock: (secret: Uint8Array) => Promise<void>;
667
- status: (signal?: AbortSignal) => Promise<AccountKeyStatus>;
754
+ /** Where an account-key unlock stands on this replica. `o.signal` cancels
755
+ * the read. */
756
+ status: (o?: ReadOptions) => Promise<AccountKeyStatus>;
668
757
  };
669
758
  /** Recovery key for a private collection (hosting app only). */
670
759
  readonly recoveryKey: {