@delali/sirannon-db 0.3.4-next.62 → 0.3.4

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 (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -1,71 +1,71 @@
1
- import { g as BackupChain, k as BackupChainRecord, o as BackupCycleStatus, z as BackupVerifyResult } from '../types-DPSmjU54.js';
2
- import { b as BackupRestoreProgress, a as BackupRestoreReport } from '../restore-options-CksYsH1l.js';
3
- import { a as TransactionStatement, Q as QueryResponse, E as ExecuteResponse, T as TransactionResponse, B as BatchResponse, L as LoadResponse, A as AckResponse } from '../protocol-HI-nY8DD.js';
4
- export { b as BatchRequest, c as ErrorResponse, d as ExecuteRequest, e as LoadRequest, f as QueryRequest, g as TransactionRequest, t as toExecuteResponse } from '../protocol-HI-nY8DD.js';
5
- import { S as Sirannon } from '../sirannon-BPxC5tC2.js';
6
- import { B as BulkLoadDurability, S as ServerOptions, W as WSHandlerOptions } from '../server-options-Bj5iJnjx.js';
7
- import { W as WriteConcern, R as ReadConcern } from '../query-types-p1liOP-b.js';
8
- import '../database-BLQvqjsw.js';
9
- import '../database-backup-B7oszQ2n.js';
10
- import '../change-tracker-CjRFuZdB.js';
11
- import '../types-CjhxcjhA.js';
12
- import '../types-DTO4CYhW.js';
13
- import '../operation-registry-oiPuSYI6.js';
1
+ import { g as BackupChain, k as BackupChainRecord, o as BackupCycleStatus, z as BackupVerifyResult } from '../types-Dc8oWlxj.js';
2
+ import { b as BackupRestoreProgress, a as BackupRestoreReport } from '../restore-options-CH8mE-Tb.js';
3
+ import { a as TransactionStatement, Q as QueryResponse, E as ExecuteResponse, T as TransactionResponse, B as BatchResponse, L as LoadResponse, A as AckResponse } from '../protocol-DFpNNsIT.js';
4
+ export { b as BatchRequest, c as ErrorResponse, d as ExecuteRequest, e as LoadRequest, f as QueryRequest, g as TransactionRequest, t as toExecuteResponse } from '../protocol-DFpNNsIT.js';
5
+ import { S as Sirannon } from '../sirannon-J3EgPVD7.js';
6
+ import { B as BulkLoadDurability, S as ServerOptions, W as WSHandlerOptions } from '../server-options-aYtCkefX.js';
7
+ import { W as WriteConcern, R as ReadConcern } from '../query-types-5B02ixH0.js';
8
+ import '../database-CGDsXW1K.js';
9
+ import '../database-backup-DcLhxoa1.js';
10
+ import '../change-tracker-DqCdeEyx.js';
11
+ import '../types-DqODKeOq.js';
12
+ import '../types-CEJG0eFS.js';
13
+ import '../operation-registry-CGhNT-Sn.js';
14
14
 
15
- /** The answer to a backup a caller triggered, which the server takes on and does not wait for.
15
+ /** The server's answer when a caller triggers a backup, which it sends once it accepts the turn and before the backup finishes.
16
16
  * @public
17
17
  */
18
18
  interface BackupTriggerResponse {
19
- /** True whenever the server answers, since it answers only once it has accepted the turn. */
19
+ /** Always true, because the server sends this answer only after it accepts the turn. */
20
20
  started: true;
21
21
  }
22
- /** What the cycle is doing, and what its recent turns produced.
22
+ /** The checkpoint cycle's current activity, and the results of its recent turns.
23
23
  * @public
24
24
  */
25
25
  type BackupStatusResponse = BackupCycleStatus;
26
- /** Every chain the destination stores.
26
+ /** Every chain in the backup destination.
27
27
  * @public
28
28
  */
29
29
  interface BackupChainResponse {
30
30
  /** One entry per chain, newest first, each with its full copy and its change pieces in order. */
31
31
  chains: BackupChain[];
32
32
  }
33
- /** Names the backup to read back out of the destination.
33
+ /** The backup to read back from the destination.
34
34
  * @public
35
35
  */
36
36
  interface BackupVerifyRequest {
37
- /** Name the backup is stored under, which every chain record states. */
37
+ /** The name under which the destination stores the backup, as it appears in every chain record. */
38
38
  name?: unknown;
39
39
  }
40
- /** What Sirannon found when it read one backup back.
40
+ /** The result of reading one backup back from the destination.
41
41
  * @public
42
42
  */
43
43
  type BackupVerifyResponse = BackupVerifyResult;
44
- /** How far back a restore must still reach.
44
+ /** How far back you must still be able to restore.
45
45
  * @public
46
46
  */
47
47
  interface BackupSafeToDeleteRequest {
48
- /** Epoch milliseconds of the earliest moment a restore must still reach. Leave it out and the answer covers only the backups no restore could ever use. */
48
+ /** The earliest moment, in epoch milliseconds, that you must still be able to restore to. When it is absent, the server lists only the backups that you cannot restore from. */
49
49
  restorableFrom?: unknown;
50
50
  }
51
- /** The records no restore still needs.
51
+ /** The records that you no longer need for any restore.
52
52
  * @public
53
53
  */
54
54
  interface BackupSafeToDeleteResponse {
55
- /** The records you may delete, oldest first. */
55
+ /** The records that you can delete, oldest first. */
56
56
  records: BackupChainRecord[];
57
57
  }
58
- /** The moment to rebuild the database at, and how many change pieces one batch replays.
58
+ /** The moment to which the server rebuilds the database, and how many change pieces it replays in one batch.
59
59
  * @public
60
60
  */
61
61
  interface BackupRestoreRequest {
62
- /** Epoch milliseconds you want back. Leave it out for the newest backup the destination stores. */
62
+ /** The moment, in epoch milliseconds, to restore the database to. When it is absent, the server uses the current time, so it restores the newest state that the destination stores. */
63
63
  moment?: unknown;
64
- /** How many change pieces to replay between one checkpoint and the next. Leave it out for the default of 16. */
64
+ /** How many change pieces the server replays between one checkpoint and the next. Defaults to 16. */
65
65
  batchSize?: unknown;
66
66
  }
67
67
 
68
- /** Where one database's restore stands. `idle` means that none has started since the server did.
68
+ /** The state of one database's restore. `idle` means that no restore has started since the server started.
69
69
  * @public
70
70
  */
71
71
  type BackupRestoreState = 'idle' | 'running' | 'done' | 'failed';
@@ -73,28 +73,28 @@ type BackupRestoreState = 'idle' | 'running' | 'done' | 'failed';
73
73
  * @public
74
74
  */
75
75
  interface BackupRestoreStatus {
76
- /** Where the restore stands. */
76
+ /** The state of the restore. */
77
77
  state: BackupRestoreState;
78
- /** Epoch milliseconds the caller asked to be taken back to. */
78
+ /** The moment, in epoch milliseconds, that the caller asked to restore to. */
79
79
  moment?: number;
80
- /** Epoch milliseconds the restore started. */
80
+ /** When the restore started, in epoch milliseconds. */
81
81
  startedAt?: number;
82
- /** Epoch milliseconds it finished, whether it succeeded or failed. */
82
+ /** When the restore finished, in epoch milliseconds, whether it succeeded or failed. */
83
83
  finishedAt?: number;
84
- /** How far it has got, reported after every piece it fetches. */
84
+ /** The restore's progress, which the server updates after it fetches each piece. */
85
85
  progress?: BackupRestoreProgress;
86
- /** What a finished restore produced. */
86
+ /** The report of a finished restore. */
87
87
  report?: BackupRestoreReport;
88
88
  /**
89
- * Why the database it replaced would not open again. The rebuilt data is on
90
- * disk and the registry has nothing open under the identifier, so an operator
91
- * who sees this restarts the process.
89
+ * The error that stopped the rebuilt database from opening again. The rebuilt
90
+ * data is on disk, but the registry has no database open under the identifier,
91
+ * so restart the process when you see this error.
92
92
  */
93
93
  reopenError?: {
94
94
  code: string;
95
95
  message: string;
96
96
  };
97
- /** Why a failed restore stopped. */
97
+ /** The error that stopped a failed restore. */
98
98
  error?: {
99
99
  code: string;
100
100
  message: string;
@@ -102,358 +102,363 @@ interface BackupRestoreStatus {
102
102
  }
103
103
 
104
104
  /**
105
- * Every message a client sends over the WebSocket. Each carries a `type` and a
106
- * client-chosen `id` the reply echoes.
105
+ * Every message that a client sends over the WebSocket. Each message has a `type`
106
+ * and an `id` that the client chooses and the server repeats in its reply.
107
107
  *
108
108
  * @public
109
109
  */
110
110
  type WSClientMessage = WSSubscribeMessage | WSUnsubscribeMessage | WSAckMessage | WSQueryMessage | WSExecuteMessage | WSTransactionMessage | WSBatchMessage | WSLoadMessage;
111
111
  /**
112
- * Opens a change subscription on one or more tables, or a live query on a registered read.
112
+ * A request to open a change subscription on one or more tables, or a live query on a registered read.
113
113
  *
114
114
  * @public
115
115
  */
116
116
  interface WSSubscribeMessage {
117
- /** Names this message as a subscribe. */
117
+ /** The message type for a subscribe. */
118
118
  type: 'subscribe';
119
- /** Client-chosen identifier the replies and change events echo. */
119
+ /** The identifier that the client chooses, which the server repeats in its replies and change events. */
120
120
  id: string;
121
- /** Table to subscribe to. */
121
+ /** The table to subscribe to. */
122
122
  table?: string;
123
123
  /** Several tables to subscribe to at once. */
124
124
  tables?: string[];
125
125
  /** Narrows the subscription to rows whose columns equal these values. */
126
126
  filter?: Record<string, unknown>;
127
- /** Name of a registered read, which opens a live query instead of a change subscription. */
127
+ /** The name of a registered read, so that the server opens a live query on that read. */
128
128
  name?: string;
129
- /** Arguments that registered read takes. */
129
+ /** The arguments that the registered read takes. */
130
130
  args?: Record<string, unknown>;
131
- /** Digest of the operation registry the client built its live query against. */
131
+ /** The digest of the operation registry that the client built its live query against. */
132
132
  registryDigest?: string;
133
133
  /**
134
- * Highest `seq` the client has already processed. When present, the server
135
- * replays every retained change with a greater seq before delivering live
136
- * events so that a reconnecting subscriber does not miss changes. Sent as a
137
- * decimal string to preserve values beyond `Number.MAX_SAFE_INTEGER`.
134
+ * The highest `seq` that the client has processed. When it is present, the server
135
+ * replays every retained change with a greater seq before it sends live events, so
136
+ * that a reconnecting subscriber receives the changes that it missed. When the server
137
+ * answers with `resync: true`, it skips the replay. The client sends the value as a
138
+ * decimal string, so that a value beyond `Number.MAX_SAFE_INTEGER` stays exact.
138
139
  */
139
140
  sinceSeq?: string;
140
141
  /**
141
- * The `epoch` the server reported when this cursor was issued. A `sinceSeq`
142
- * only means something within the sequence space that produced it, so a
143
- * mismatch tells the server the cursor came from another database and it must
144
- * resync rather than replay foreign rows against it.
142
+ * The `epoch` that the server reported with this cursor. A `sinceSeq` is valid
143
+ * only within the sequence space that produced it, so when this epoch differs
144
+ * from the server's own, the server answers with `resync: true` and skips the
145
+ * replay.
145
146
  */
146
147
  epoch?: string;
147
- /** Identifies the device, which turns this into a device-sync subscription. */
148
+ /** The device's identifier, which makes this a device-sync subscription. */
148
149
  deviceId?: string;
149
- /** Schema version the device's local database is at, which the server gates the stream on. */
150
+ /** The schema version of the device's local database, which the server checks before it opens the stream. */
150
151
  schemaVersion?: number;
151
152
  /**
152
- * Declares that this device stages pulled changes durably and
153
+ * Set to true when this device stages pulled changes durably and
153
154
  * acknowledges staged sequences. The server then packs several events
154
- * into each `changes` frame and paces the delivery window continuously
155
- * instead of per transaction. Meaningful only with `deviceId`.
155
+ * into each `changes` frame and can pause the stream at any event. The
156
+ * server accepts it only with `deviceId`.
156
157
  */
157
158
  stagedStream?: boolean;
158
159
  }
159
160
  /**
160
- * Ends a subscription.
161
+ * A request to end a subscription.
161
162
  *
162
163
  * @public
163
164
  */
164
165
  interface WSUnsubscribeMessage {
165
- /** Names this message as an unsubscribe. */
166
+ /** The message type for an unsubscribe. */
166
167
  type: 'unsubscribe';
167
- /** Identifier of the subscription to end. */
168
+ /** The identifier of the subscription to end. */
168
169
  id: string;
169
170
  }
170
171
  /**
171
- * Acknowledges every change a device has stored up to a sequence.
172
+ * A device's acknowledgement of every change that it has stored up to a sequence.
172
173
  *
173
174
  * @public
174
175
  */
175
176
  interface WSAckMessage {
176
- /** Names this message as an acknowledgement. */
177
+ /** The message type for an acknowledgement. */
177
178
  type: 'ack';
178
- /** Client-chosen identifier the reply echoes. */
179
+ /** The identifier that the client chooses, which the server repeats in its reply. */
179
180
  id: string;
180
- /** Identifies the device acknowledging. */
181
+ /** The identifier of the device that sends the acknowledgement. */
181
182
  deviceId: string;
182
- /** Highest sequence the device has stored, as a decimal string. */
183
+ /** The highest sequence that the device has stored, as a decimal string. */
183
184
  seq: string;
184
185
  }
185
186
  /**
186
- * Runs a read, either as SQL or by the name of a registered read.
187
+ * A request to execute a read, either as SQL or by the name of a registered read.
187
188
  *
188
189
  * @public
189
190
  */
190
191
  interface WSQueryMessage {
191
- /** Names this message as a read. */
192
+ /** The message type for a read. */
192
193
  type: 'query';
193
- /** Client-chosen identifier the reply echoes. */
194
+ /** The identifier that the client chooses, which the server repeats in its reply. */
194
195
  id: string;
195
- /** The statement to run. The server refuses it unless it accepts SQL. */
196
+ /** The statement to execute, which the server executes only when it accepts SQL. */
196
197
  sql?: string;
197
- /** Values bound to that statement, named or positional. */
198
+ /** The values to bind to that statement, by name or by position. */
198
199
  params?: Record<string, unknown> | unknown[];
199
- /** Name of a registered read to run instead, which carries no SQL. */
200
+ /** The name of a registered read to execute in place of `sql`. */
200
201
  name?: string;
201
- /** Arguments that registered read takes. */
202
+ /** The arguments that the registered read takes. */
202
203
  args?: Record<string, unknown>;
203
- /** Currency this read requires. */
204
+ /** The read concern that this read requires. */
204
205
  readConcern?: ReadConcern;
205
206
  }
206
207
  /**
207
- * Runs a write, either as SQL or by the name of a registered write.
208
+ * A request to execute a write, either as SQL or by the name of a registered write.
208
209
  *
209
210
  * @public
210
211
  */
211
212
  interface WSExecuteMessage {
212
- /** Names this message as a write. */
213
+ /** The message type for a write. */
213
214
  type: 'execute';
214
- /** Client-chosen identifier the reply echoes. */
215
+ /** The identifier that the client chooses, which the server repeats in its reply. */
215
216
  id: string;
216
- /** The statement to run. The server refuses it unless it accepts SQL. */
217
+ /** The statement to execute, which the server executes only when it accepts SQL. */
217
218
  sql?: string;
218
- /** Values bound to that statement, named or positional. */
219
+ /** The values to bind to that statement, by name or by position. */
219
220
  params?: Record<string, unknown> | unknown[];
220
- /** Name of a registered write to run instead, which carries no SQL. */
221
+ /** The name of a registered write to execute in place of `sql`. */
221
222
  name?: string;
222
- /** Arguments that registered write takes. */
223
+ /** The arguments that the registered write takes. */
223
224
  args?: Record<string, unknown>;
224
- /** Acknowledgements this write waits for. */
225
+ /** The acknowledgements that the server waits for before it confirms this write. */
225
226
  writeConcern?: WriteConcern;
226
227
  }
227
228
  /**
228
- * Runs every statement in one server-side transaction and replies once with
229
- * all results. The client is never in the loop between statements, so the
230
- * single writer lock is held only for the duration of local execution.
229
+ * A request to execute every statement in one server-side transaction, to which the
230
+ * server replies once with all the results. The server makes no round trip to the
231
+ * client between statements, so it holds the single writer lock only while the
232
+ * statements execute.
231
233
  *
232
234
  * @public
233
235
  */
234
236
  interface WSTransactionMessage {
235
- /** Names this message as a transaction. */
237
+ /** The message type for a transaction. */
236
238
  type: 'transaction';
237
- /** Client-chosen identifier the reply echoes. */
239
+ /** The identifier that the client chooses, which the server repeats in its reply. */
238
240
  id: string;
239
- /** The statements to run, in order. */
241
+ /** The statements to execute, in order. */
240
242
  statements: TransactionStatement[];
241
- /** Acknowledgements the transaction waits for. */
243
+ /** The acknowledgements that the server waits for before it confirms the transaction. */
242
244
  writeConcern?: WriteConcern;
243
245
  }
244
246
  /**
245
- * Applies one statement over many parameter sets in a single server-side transaction.
247
+ * A request to execute one statement with many parameter sets in a single server-side transaction.
246
248
  *
247
249
  * @public
248
250
  */
249
251
  interface WSBatchMessage {
250
- /** Names this message as a batch. */
252
+ /** The message type for a batch. */
251
253
  type: 'batch';
252
- /** Client-chosen identifier the reply echoes. */
254
+ /** The identifier that the client chooses, which the server repeats in its reply. */
253
255
  id: string;
254
- /** The statement to run for each parameter set. */
256
+ /** The statement to execute for each parameter set. */
255
257
  sql: string;
256
- /** One parameter set per run. */
258
+ /** One parameter set for each execution of the statement. */
257
259
  paramsBatch: (Record<string, unknown> | unknown[])[];
258
- /** Acknowledgements the batch waits for. */
260
+ /** The acknowledgements that the server waits for before it confirms the batch. */
259
261
  writeConcern?: WriteConcern;
260
262
  }
261
263
  /**
262
- * Imports many rows at relaxed durability, which the server restores before it replies.
264
+ * A request to import many rows at relaxed durability, which the server restores before it replies.
263
265
  *
264
266
  * @public
265
267
  */
266
268
  interface WSLoadMessage {
267
- /** Names this message as a load. */
269
+ /** The message type for a load. */
268
270
  type: 'load';
269
- /** Client-chosen identifier the reply echoes. */
271
+ /** The identifier that the client chooses, which the server repeats in its reply. */
270
272
  id: string;
271
- /** The statement to run for each parameter set. */
273
+ /** The statement to execute for each parameter set. */
272
274
  sql: string;
273
275
  /** One parameter set per row. */
274
276
  paramsBatch: (Record<string, unknown> | unknown[])[];
275
- /** Durability in force while the load runs. Default: 'off'. */
277
+ /** The writer's durability level during the load. Defaults to 'off'. */
276
278
  durability?: BulkLoadDurability;
277
- /** Whether this load ends with a checkpoint. */
279
+ /** Whether the server checkpoints the WAL after this load. Defaults to true. */
278
280
  checkpoint?: boolean;
279
281
  }
282
+
280
283
  /**
281
- * Every message the server sends over the WebSocket.
284
+ * Every message that the server sends over the WebSocket.
282
285
  *
283
286
  * @public
284
287
  */
285
288
  type WSServerMessage = WSSubscribedMessage | WSUnsubscribedMessage | WSChangeMessage | WSChangesMessage | WSLiveMessage | WSResultMessage | WSErrorMessage;
286
289
  /**
287
- * One edit to a live query's result set, as a position and the row at it.
290
+ * One edit to a live query's result set, as a position and the row at that position.
288
291
  *
289
292
  * @public
290
293
  */
291
294
  type WSLiveOp = {
292
295
  /** Which edit this is: `'insert'` for a row added, `'update'` for a row changed in place, `'delete'` for a row removed. */
293
296
  op: 'insert';
294
- /** Position in the result set the edit applies to, counted from zero. */
297
+ /** The zero-based position in the result set that the edit applies to. */
295
298
  index: number;
296
- /** The row that now sits at that position. */
299
+ /** The row that is now at that position. */
297
300
  row: unknown;
298
301
  } | {
299
- /** Names this edit as a row changed in place. */
302
+ /** The edit type for a row changed in place. */
300
303
  op: 'update';
301
- /** Position of the row that changed. */
304
+ /** The position of the row that changed. */
302
305
  index: number;
303
- /** The row as it now reads. */
306
+ /** The row's new values. */
304
307
  row: unknown;
305
308
  } | {
306
- /** Names this edit as a row removed. */
309
+ /** The edit type for a removed row. */
307
310
  op: 'delete';
308
- /** Position the removed row held. */
311
+ /** The position of the removed row. */
309
312
  index: number;
310
313
  };
311
314
  /**
312
- * Carries a live query's new state: the edits that move it, a full replacement, or notice that a re-read has started.
315
+ * A live query's new state, which is the edits that move it, a full replacement, or a notice that the server has started to read the query again.
313
316
  *
314
317
  * @public
315
318
  */
316
319
  interface WSLiveMessage {
317
- /** Names this message as a live-query update. */
320
+ /** The message type for a live-query update. */
318
321
  type: 'live';
319
- /** Identifier of the subscription this update belongs to. */
322
+ /** The identifier of the subscription that this update is for. */
320
323
  id: string;
321
324
  /** The edits that move the result set to its new state. */
322
325
  ops?: WSLiveOp[];
323
326
  /** A complete replacement result set. */
324
327
  rows?: unknown[];
325
- /** Set while the server re-reads the query. */
328
+ /** Set while the server reads the query again. */
326
329
  revalidating?: boolean;
327
330
  }
328
331
  /**
329
- * Confirms a subscription opened, and states the cursor and sequence space it streams from.
332
+ * The server's confirmation that a subscription is open, with the cursor and the epoch that it streams from.
330
333
  *
331
334
  * @public
332
335
  */
333
336
  interface WSSubscribedMessage {
334
- /** Names this message as a subscription confirmation. */
337
+ /** The message type for a subscription confirmation. */
335
338
  type: 'subscribed';
336
- /** Identifier of the subscription that opened. */
339
+ /** The identifier of the subscription that is now open. */
337
340
  id: string;
338
341
  /**
339
- * How far a device may run ahead of its acknowledged cursor before the
340
- * server holds delivery. Present only for a device subscription.
342
+ * The number of changes that the server sends past the device's acknowledged
343
+ * cursor before it pauses delivery. The server sends it only for a device subscription.
341
344
  */
342
345
  maxUnacknowledgedChanges?: number;
343
346
  /**
344
- * The seq the subscription is live from. A client that has not yet seen any
345
- * change adopts this as its resume cursor so that a reconnect during an idle
346
- * spell still replays what it missed instead of silently skipping it.
347
+ * The seq from which the subscription is live. A client that has not yet received
348
+ * any change stores this seq as its resume cursor, so that after a reconnect during
349
+ * a quiet period, the server still replays every change that the client missed.
347
350
  */
348
351
  seq?: string;
349
352
  /**
350
- * Set when a requested `sinceSeq` fell below the retained history, so the
351
- * gap cannot be replayed. The subscription still starts live from now; the
352
- * client must treat its prior state as stale and re-read.
353
+ * Set when the server cannot replay from the requested `sinceSeq`, because that seq
354
+ * is older than the history that the server retains, the client's `epoch` differs
355
+ * from the server's, or the replay fails. The server skips the replay and the
356
+ * subscription starts from the server's current position, so the client must treat
357
+ * its earlier state as stale and read it again.
353
358
  */
354
359
  resync?: boolean;
355
360
  /**
356
- * Identifies the sequence space this subscription streams from. The client
357
- * stores it and echoes it when resuming so that a cursor carried to a different
358
- * database forces a resync instead of a silent replay of unrelated rows.
361
+ * The identifier of the sequence space that this subscription streams from. The
362
+ * client stores it and sends it back when it resumes, so that the server answers a
363
+ * cursor from a different database with `resync: true`.
359
364
  */
360
365
  epoch?: string;
361
- /** First result set of a live query, sent when the subscription named a registered read. */
366
+ /** The first result set of a live query, which the server sends when the subscription names a registered read. */
362
367
  rows?: unknown[];
363
368
  }
364
369
  /**
365
- * Confirms a subscription ended.
370
+ * The server's confirmation that a subscription has ended.
366
371
  *
367
372
  * @public
368
373
  */
369
374
  interface WSUnsubscribedMessage {
370
- /** Names this message as an unsubscribe confirmation. */
375
+ /** The message type for an unsubscribe confirmation. */
371
376
  type: 'unsubscribed';
372
- /** Identifier of the subscription that ended. */
377
+ /** The identifier of the subscription that has ended. */
373
378
  id: string;
374
379
  }
375
380
  /**
376
- * One change event as it crosses the wire, with sequences as decimal strings
377
- * so a value beyond the safe integer range survives JSON.
381
+ * One change event in its wire form, with the sequence as a decimal string,
382
+ * so that JSON keeps a value beyond the safe integer range exact.
378
383
  *
379
384
  * @public
380
385
  */
381
386
  interface WSWireChangeEvent {
382
387
  /** Whether the row was inserted, updated, or deleted. */
383
388
  type: 'insert' | 'update' | 'delete';
384
- /** Table the row belongs to. */
389
+ /** The table of the row. */
385
390
  table: string;
386
- /** The row as it stands after the change. */
391
+ /** The row's values after the change. */
387
392
  row: Record<string, unknown>;
388
- /** The row as it stood before an update or a delete. */
393
+ /** The row's values before an update or a delete. */
389
394
  oldRow?: Record<string, unknown>;
390
- /** Position of this change in the database's change log, as a decimal string. */
395
+ /** The position of this change in the database's change log, as a decimal string. */
391
396
  seq: string;
392
- /** Milliseconds since the Unix epoch, taken when the change was recorded. */
397
+ /** Milliseconds since the Unix epoch, from when the database recorded the change. */
393
398
  timestamp: number;
394
- /** Hybrid logical clock stamp the writing node gave this change. */
399
+ /** The hybrid logical clock stamp that the writing node gave this change. */
395
400
  hlc?: string;
396
- /** Identifier of the node that authored the change. */
401
+ /** The identifier of the node or device that wrote the change. */
397
402
  origin?: string;
398
- /** Primary key of the changed row, encoded as a string. */
403
+ /** The primary key of the changed row, encoded as a string. */
399
404
  rowId?: string;
400
- /** Identifier of the transaction that produced this change. */
405
+ /** The identifier of the transaction that made this change. */
401
406
  txId?: string;
402
407
  /** Set on the last change of a transaction. */
403
408
  txEnd?: boolean;
404
409
  }
405
410
  /**
406
- * Carries one change event to a subscriber.
411
+ * One change event for a subscriber.
407
412
  *
408
413
  * @public
409
414
  */
410
415
  interface WSChangeMessage {
411
- /** Names this message as a single change event. */
416
+ /** The message type for a single change event. */
412
417
  type: 'change';
413
- /** Identifier of the subscription this change belongs to. */
418
+ /** The identifier of the subscription that this change is for. */
414
419
  id: string;
415
420
  /** The change itself. */
416
421
  event: WSWireChangeEvent;
417
422
  }
418
423
  /**
419
- * Several change events in one frame, in ascending seq order. Sent only on
420
- * a device subscription that requested `stagedStream`; the events carry the
421
- * same fields as a `change` frame's event.
424
+ * Several change events in one frame, in ascending seq order. The server sends
425
+ * this frame only on a device subscription that asks for `stagedStream`, and
426
+ * each event has the same fields as the event in a `change` frame.
422
427
  *
423
428
  * @public
424
429
  */
425
430
  interface WSChangesMessage {
426
- /** Names this message as a run of change events. */
431
+ /** The message type for several change events. */
427
432
  type: 'changes';
428
- /** Identifier of the subscription these changes belong to. */
433
+ /** The identifier of the subscription that these changes are for. */
429
434
  id: string;
430
435
  /** The changes, in ascending sequence order. */
431
436
  events: WSWireChangeEvent[];
432
437
  }
433
438
  /**
434
- * Replies to a read, write, transaction, batch, load, or acknowledgement.
439
+ * The server's reply to a read, write, transaction, batch, load, or acknowledgement.
435
440
  *
436
441
  * @public
437
442
  */
438
443
  interface WSResultMessage {
439
- /** Names this message as a reply to a read, write, transaction, batch, load, or acknowledgement. */
444
+ /** The message type for a reply to a read, write, transaction, batch, load, or acknowledgement. */
440
445
  type: 'result';
441
- /** Identifier the request carried. */
446
+ /** The identifier from the request. */
442
447
  id: string;
443
- /** The reply body, whose shape follows the request that produced it. */
448
+ /** The reply body, whose shape depends on the request. */
444
449
  data: QueryResponse | ExecuteResponse | TransactionResponse | BatchResponse | LoadResponse | AckResponse;
445
450
  }
446
451
  /**
447
- * Reports that a request failed.
452
+ * The server's report that a request failed.
448
453
  *
449
454
  * @public
450
455
  */
451
456
  interface WSErrorMessage {
452
- /** Names this message as a failure. */
457
+ /** The message type for a failure. */
453
458
  type: 'error';
454
- /** Identifier the request carried. */
459
+ /** The identifier from the request, or an empty string when the server cannot read one. */
455
460
  id: string;
456
- /** Machine-readable code and human-readable message. */
461
+ /** A machine-readable code and a human-readable message. */
457
462
  error: {
458
463
  code: string;
459
464
  message: string;
@@ -468,7 +473,8 @@ interface WSErrorMessage {
468
473
  * @public
469
474
  */
470
475
  declare class SirannonServer<Identity = unknown> {
471
- private app;
476
+ private runtime;
477
+ private runtimeLoad;
472
478
  private listenSocket;
473
479
  private readonly host;
474
480
  private readonly port;
@@ -476,6 +482,7 @@ declare class SirannonServer<Identity = unknown> {
476
482
  private readonly authenticateHook;
477
483
  private readonly acceptSql;
478
484
  private readonly acceptBackupRestore;
485
+ private readonly acceptDeviceSync;
479
486
  private readonly restoreRuns;
480
487
  private readonly operations;
481
488
  private readonly registryDigest;
@@ -489,77 +496,79 @@ declare class SirannonServer<Identity = unknown> {
489
496
  private readonly maxWsBackpressureBytes;
490
497
  constructor(sirannon: Sirannon, options?: ServerOptions<Identity>);
491
498
  /**
492
- * Binds the configured host and port and starts serving.
499
+ * Loads uWebSockets.js and starts serving on the configured host and port.
493
500
  *
494
- * @throws When the port is already in use.
501
+ * @throws A `SirannonError` with code `SERVER_DEPENDENCY_MISSING` when this process cannot load uWebSockets.js.
502
+ * @throws An `Error` when uWebSockets.js cannot listen on the host and port, for example because the port is already in use.
495
503
  */
496
504
  listen(): Promise<void>;
497
505
  /**
498
- * Stops serving and closes every open connection.
506
+ * Stops listening for new connections and closes every open WebSocket connection.
499
507
  */
500
508
  close(): Promise<void>;
501
509
  /**
502
- * Port the server bound to, which is the resolved port when you asked for 0.
510
+ * The port that the server listens on, which the operating system chooses when you set `port` to 0, or -1 while the server is not listening.
503
511
  */
504
512
  get listeningPort(): number;
513
+ private loadRuntime;
505
514
  private registerRoutes;
506
515
  private registerBackupRoutes;
507
- private registerWebSocketRoute;
508
516
  private withCors;
517
+ private routeDeps;
509
518
  private wrapDbRoute;
510
- private wrapOperationRoute;
511
519
  private wrapDbGetRoute;
520
+ private wrapOperationRoute;
512
521
  }
513
522
  /**
514
- * Builds a server over a database registry.
523
+ * Builds a server that exposes the databases of one registry.
515
524
  *
516
525
  * @param sirannon - The registry whose databases the server exposes.
517
526
  * @param options - Address, cross-origin rules, size limits, authentication, registered operations, and whether the server accepts SQL.
518
- * @returns The server, ready to listen.
527
+ * @returns The server, which starts serving when you call {@link SirannonServer.listen}.
519
528
  *
520
529
  * @public
521
530
  */
522
531
  declare function createServer<Identity = unknown>(sirannon: Sirannon, options?: ServerOptions<Identity>): SirannonServer<Identity>;
523
532
 
524
533
  /**
525
- * Result of writing a frame to a WebSocket connection.
534
+ * The outcome of writing one frame to a WebSocket connection.
526
535
  *
527
- * - `sent`: delivered with no backpressure.
528
- * - `buffered`: accepted into the socket's outbound buffer under the
529
- * backpressure limit; it will drain over time and must not be resent.
530
- * - `dropped`: rejected because it would exceed the backpressure limit, so
531
- * the frame was not delivered. The caller must fail loud rather than treat
532
- * the request as answered.
536
+ * - `sent`: uWebSockets writes the whole frame with no backpressure.
537
+ * - `buffered`: uWebSockets queues the frame in the socket's outbound buffer,
538
+ * under the backpressure limit, and sends it later, so the caller must not send it again.
539
+ * - `dropped`: uWebSockets discards the frame, because the socket is closed or the
540
+ * frame would push its buffer past the backpressure limit, so the client never
541
+ * receives it. The caller must then report the request as failed.
533
542
  */
534
543
  type WSSendOutcome = 'sent' | 'buffered' | 'dropped';
535
544
  /**
536
- * One open WebSocket, as the handler sends over it.
545
+ * The methods that the handler uses to write to one open WebSocket.
537
546
  *
538
547
  * @internal
539
548
  */
540
549
  interface WSConnection {
541
550
  /**
542
- * Sends one frame and reports whether it went out, was buffered, or was dropped.
551
+ * Sends one frame and returns whether uWebSockets sent it, buffered it, or dropped it.
543
552
  */
544
553
  send(data: string): WSSendOutcome;
545
554
  /**
546
- * Reports how many bytes the socket still holds unsent.
555
+ * Returns the number of bytes that the socket has buffered and not yet sent.
547
556
  *
548
- * A `buffered` outcome promises no later drain notification, because a send that
549
- * queues only the tail of a frame can flush that tail without the socket ever
550
- * becoming writable again. A sender that paused itself reads this to find out
551
- * whether it is still waiting on anything.
557
+ * After a `buffered` outcome, uWebSockets may never fire a drain event, because
558
+ * when it queues only the tail of a frame, it can flush that tail without the
559
+ * socket becoming writable again. A paused device stream calls this method to
560
+ * check whether the socket still has bytes left to send.
552
561
  */
553
562
  bufferedAmount(): number;
554
563
  /**
555
- * Writes a control frame so the socket flushes what it is holding.
564
+ * Sends a ping frame so that uWebSockets flushes the bytes that the socket has buffered.
556
565
  *
557
566
  * uWebSockets keeps a partial write queued until the next write on that socket,
558
- * so a sender with nothing left to send calls this to move the remainder.
567
+ * so a caller with nothing left to send calls this method to send the rest.
559
568
  */
560
569
  flush(): void;
561
570
  /**
562
- * Closes the connection with a code and reason.
571
+ * Closes the connection with a close code and a reason.
563
572
  */
564
573
  close(code?: number, reason?: string): void;
565
574
  }
@@ -578,14 +587,15 @@ declare class WSHandler<Identity = unknown> {
578
587
  private readonly maxUnacknowledgedChanges;
579
588
  private readonly socketResumeBytes;
580
589
  private readonly acceptSql;
590
+ private readonly acceptDeviceSync;
581
591
  private readonly operations;
582
592
  private closed;
583
593
  constructor(sirannon: Sirannon, options?: WSHandlerOptions<Identity>);
584
594
  handleOpen(conn: WSConnection, databaseId: string, identity?: unknown): Promise<void>;
585
595
  /**
586
- * Tears down a connection whose outbound buffer overflowed. Closing lets the
587
- * client reject in-flight requests and reconnect; guarding on `overloaded`
588
- * keeps a burst of dropped frames from repeatedly re-closing the socket.
596
+ * Closes a connection after the server drops a frame on it at the backpressure limit,
597
+ * so the client can reject its pending requests and reconnect. The `overloaded` flag
598
+ * makes the handler close the socket once, however many frames the server drops in a burst.
589
599
  */
590
600
  handleOverload(conn: WSConnection): void;
591
601
  handleMessage(conn: WSConnection, data: string): void;
@@ -608,7 +618,7 @@ declare class WSHandler<Identity = unknown> {
608
618
  private sendText;
609
619
  }
610
620
  /**
611
- * Builds the WebSocket handler a server routes its upgrades and messages through.
621
+ * Builds the handler that processes a server's WebSocket connections and messages.
612
622
  *
613
623
  * @internal
614
624
  */