@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.
- package/README.md +79 -56
- package/dist/backup/index.d.ts +44 -45
- package/dist/backup/index.mjs +7 -7
- package/dist/backup-scheduler/index.d.ts +42 -41
- package/dist/backup-scheduler/index.mjs +4 -4
- package/dist/baseline-Co3iIsN_.d.ts +19 -0
- package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
- package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
- package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
- package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
- package/dist/chunk-4KASJKKK.mjs +2501 -0
- package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
- package/dist/chunk-55YRLSM2.mjs +57 -0
- package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
- package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
- package/dist/chunk-ADNWEHGZ.mjs +299 -0
- package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
- package/dist/chunk-BVMZJOVM.mjs +5 -0
- package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
- package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
- package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
- package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
- package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
- package/dist/chunk-HR7K3GZW.mjs +36 -0
- package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
- package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
- package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
- package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
- package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
- package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
- package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
- package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
- package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
- package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
- package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
- package/dist/chunk-WOMADPM4.mjs +12 -0
- package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
- package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
- package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
- package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
- package/dist/client/index.d.ts +135 -137
- package/dist/client/index.mjs +177 -82
- package/dist/client/topology.d.ts +31 -31
- package/dist/client/topology.mjs +42 -23
- package/dist/client-base-BxTocU1x.d.ts +398 -0
- package/dist/client-streams-YKANXMWO.mjs +112 -0
- package/dist/codegen/cli.mjs +4 -4
- package/dist/codegen/index.d.ts +36 -29
- package/dist/codegen/index.mjs +4 -4
- package/dist/core/index.d.ts +130 -115
- package/dist/core/index.mjs +387 -297
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-CGDsXW1K.d.ts +959 -0
- package/dist/database-backup-DcLhxoa1.d.ts +143 -0
- package/dist/driver/better-sqlite3.d.ts +11 -10
- package/dist/driver/better-sqlite3.mjs +11 -11
- package/dist/driver/bun.d.ts +9 -8
- package/dist/driver/expo.d.ts +6 -7
- package/dist/driver/node.d.ts +11 -10
- package/dist/driver/node.mjs +13 -11
- package/dist/driver/wa-sqlite.d.ts +6 -6
- package/dist/errors-CJUkQ-KL.d.ts +199 -0
- package/dist/file-migrations/index.d.ts +20 -18
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
- package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
- package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
- package/dist/protocol-DFpNNsIT.d.ts +153 -0
- package/dist/query-types-5B02ixH0.d.ts +129 -0
- package/dist/react/index.d.ts +22 -22
- package/dist/replication/coordinator/etcd.d.ts +37 -31
- package/dist/replication/coordinator/etcd.mjs +296 -131
- package/dist/replication/index.d.ts +201 -161
- package/dist/replication/index.mjs +630 -529
- package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
- package/dist/server/index.d.ts +201 -191
- package/dist/server/index.mjs +736 -619
- package/dist/server-options-aYtCkefX.d.ts +317 -0
- package/dist/server-streams-24XL4T43.mjs +254 -0
- package/dist/sirannon-J3EgPVD7.d.ts +179 -0
- package/dist/transport/grpc.d.ts +37 -24
- package/dist/transport/grpc.mjs +83 -3199
- package/dist/transport/memory.d.ts +25 -26
- package/dist/transport/memory.mjs +18 -9
- package/dist/types-BrAiDGOb.d.ts +505 -0
- package/dist/types-CEJG0eFS.d.ts +88 -0
- package/dist/types-Dc8oWlxj.d.ts +1580 -0
- package/dist/types-DqODKeOq.d.ts +123 -0
- package/dist/types-guEKSzMr.d.ts +367 -0
- package/package.json +7 -7
- package/dist/baseline-D93hcIEE.d.ts +0 -17
- package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
- package/dist/client-base-Cmd9EVme.d.ts +0 -397
- package/dist/database-BLQvqjsw.d.ts +0 -917
- package/dist/database-backup-B7oszQ2n.d.ts +0 -141
- package/dist/errors-Dei4GdBb.d.ts +0 -196
- package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
- package/dist/primary-wins-B0np8JS3.d.ts +0 -85
- package/dist/protocol-HI-nY8DD.d.ts +0 -152
- package/dist/query-types-p1liOP-b.d.ts +0 -127
- package/dist/restore-options-CksYsH1l.d.ts +0 -83
- package/dist/server-options-Bj5iJnjx.d.ts +0 -292
- package/dist/sirannon-BPxC5tC2.d.ts +0 -178
- package/dist/types-B0EhgDbr.d.ts +0 -340
- package/dist/types-CbjfRwrK.d.ts +0 -499
- package/dist/types-CjhxcjhA.d.ts +0 -123
- package/dist/types-DPSmjU54.d.ts +0 -1518
- package/dist/types-DTO4CYhW.d.ts +0 -88
package/dist/server/index.d.ts
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { g as BackupChain, k as BackupChainRecord, o as BackupCycleStatus, z as BackupVerifyResult } from '../types-
|
|
2
|
-
import { b as BackupRestoreProgress, a as BackupRestoreReport } from '../restore-options-
|
|
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-
|
|
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-
|
|
5
|
-
import { S as Sirannon } from '../sirannon-
|
|
6
|
-
import { B as BulkLoadDurability, S as ServerOptions, W as WSHandlerOptions } from '../server-options-
|
|
7
|
-
import { W as WriteConcern, R as ReadConcern } from '../query-types-
|
|
8
|
-
import '../database-
|
|
9
|
-
import '../database-backup-
|
|
10
|
-
import '../change-tracker-
|
|
11
|
-
import '../types-
|
|
12
|
-
import '../types-
|
|
13
|
-
import '../operation-registry-
|
|
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
|
|
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
|
-
/**
|
|
19
|
+
/** Always true, because the server sends this answer only after it accepts the turn. */
|
|
20
20
|
started: true;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
33
|
+
/** The backup to read back from the destination.
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
36
36
|
interface BackupVerifyRequest {
|
|
37
|
-
/**
|
|
37
|
+
/** The name under which the destination stores the backup, as it appears in every chain record. */
|
|
38
38
|
name?: unknown;
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
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
|
|
44
|
+
/** How far back you must still be able to restore.
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
47
|
interface BackupSafeToDeleteRequest {
|
|
48
|
-
/**
|
|
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
|
|
51
|
+
/** The records that you no longer need for any restore.
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
54
|
interface BackupSafeToDeleteResponse {
|
|
55
|
-
/** The records you
|
|
55
|
+
/** The records that you can delete, oldest first. */
|
|
56
56
|
records: BackupChainRecord[];
|
|
57
57
|
}
|
|
58
|
-
/** The moment to
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
76
|
+
/** The state of the restore. */
|
|
77
77
|
state: BackupRestoreState;
|
|
78
|
-
/**
|
|
78
|
+
/** The moment, in epoch milliseconds, that the caller asked to restore to. */
|
|
79
79
|
moment?: number;
|
|
80
|
-
/**
|
|
80
|
+
/** When the restore started, in epoch milliseconds. */
|
|
81
81
|
startedAt?: number;
|
|
82
|
-
/**
|
|
82
|
+
/** When the restore finished, in epoch milliseconds, whether it succeeded or failed. */
|
|
83
83
|
finishedAt?: number;
|
|
84
|
-
/**
|
|
84
|
+
/** The restore's progress, which the server updates after it fetches each piece. */
|
|
85
85
|
progress?: BackupRestoreProgress;
|
|
86
|
-
/**
|
|
86
|
+
/** The report of a finished restore. */
|
|
87
87
|
report?: BackupRestoreReport;
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
* disk
|
|
91
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
106
|
-
*
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
117
|
+
/** The message type for a subscribe. */
|
|
118
118
|
type: 'subscribe';
|
|
119
|
-
/**
|
|
119
|
+
/** The identifier that the client chooses, which the server repeats in its replies and change events. */
|
|
120
120
|
id: string;
|
|
121
|
-
/**
|
|
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
|
-
/**
|
|
127
|
+
/** The name of a registered read, so that the server opens a live query on that read. */
|
|
128
128
|
name?: string;
|
|
129
|
-
/**
|
|
129
|
+
/** The arguments that the registered read takes. */
|
|
130
130
|
args?: Record<string, unknown>;
|
|
131
|
-
/**
|
|
131
|
+
/** The digest of the operation registry that the client built its live query against. */
|
|
132
132
|
registryDigest?: string;
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
135
|
-
* replays every retained change with a greater seq before
|
|
136
|
-
*
|
|
137
|
-
*
|
|
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
|
|
142
|
-
* only
|
|
143
|
-
*
|
|
144
|
-
*
|
|
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
|
-
/**
|
|
148
|
+
/** The device's identifier, which makes this a device-sync subscription. */
|
|
148
149
|
deviceId?: string;
|
|
149
|
-
/**
|
|
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
|
-
*
|
|
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
|
|
155
|
-
*
|
|
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
|
-
*
|
|
161
|
+
* A request to end a subscription.
|
|
161
162
|
*
|
|
162
163
|
* @public
|
|
163
164
|
*/
|
|
164
165
|
interface WSUnsubscribeMessage {
|
|
165
|
-
/**
|
|
166
|
+
/** The message type for an unsubscribe. */
|
|
166
167
|
type: 'unsubscribe';
|
|
167
|
-
/**
|
|
168
|
+
/** The identifier of the subscription to end. */
|
|
168
169
|
id: string;
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
|
-
*
|
|
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
|
-
/**
|
|
177
|
+
/** The message type for an acknowledgement. */
|
|
177
178
|
type: 'ack';
|
|
178
|
-
/**
|
|
179
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
179
180
|
id: string;
|
|
180
|
-
/**
|
|
181
|
+
/** The identifier of the device that sends the acknowledgement. */
|
|
181
182
|
deviceId: string;
|
|
182
|
-
/**
|
|
183
|
+
/** The highest sequence that the device has stored, as a decimal string. */
|
|
183
184
|
seq: string;
|
|
184
185
|
}
|
|
185
186
|
/**
|
|
186
|
-
*
|
|
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
|
-
/**
|
|
192
|
+
/** The message type for a read. */
|
|
192
193
|
type: 'query';
|
|
193
|
-
/**
|
|
194
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
194
195
|
id: string;
|
|
195
|
-
/** The statement to
|
|
196
|
+
/** The statement to execute, which the server executes only when it accepts SQL. */
|
|
196
197
|
sql?: string;
|
|
197
|
-
/**
|
|
198
|
+
/** The values to bind to that statement, by name or by position. */
|
|
198
199
|
params?: Record<string, unknown> | unknown[];
|
|
199
|
-
/**
|
|
200
|
+
/** The name of a registered read to execute in place of `sql`. */
|
|
200
201
|
name?: string;
|
|
201
|
-
/**
|
|
202
|
+
/** The arguments that the registered read takes. */
|
|
202
203
|
args?: Record<string, unknown>;
|
|
203
|
-
/**
|
|
204
|
+
/** The read concern that this read requires. */
|
|
204
205
|
readConcern?: ReadConcern;
|
|
205
206
|
}
|
|
206
207
|
/**
|
|
207
|
-
*
|
|
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
|
-
/**
|
|
213
|
+
/** The message type for a write. */
|
|
213
214
|
type: 'execute';
|
|
214
|
-
/**
|
|
215
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
215
216
|
id: string;
|
|
216
|
-
/** The statement to
|
|
217
|
+
/** The statement to execute, which the server executes only when it accepts SQL. */
|
|
217
218
|
sql?: string;
|
|
218
|
-
/**
|
|
219
|
+
/** The values to bind to that statement, by name or by position. */
|
|
219
220
|
params?: Record<string, unknown> | unknown[];
|
|
220
|
-
/**
|
|
221
|
+
/** The name of a registered write to execute in place of `sql`. */
|
|
221
222
|
name?: string;
|
|
222
|
-
/**
|
|
223
|
+
/** The arguments that the registered write takes. */
|
|
223
224
|
args?: Record<string, unknown>;
|
|
224
|
-
/**
|
|
225
|
+
/** The acknowledgements that the server waits for before it confirms this write. */
|
|
225
226
|
writeConcern?: WriteConcern;
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
228
|
-
*
|
|
229
|
-
* all results. The
|
|
230
|
-
*
|
|
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
|
-
/**
|
|
237
|
+
/** The message type for a transaction. */
|
|
236
238
|
type: 'transaction';
|
|
237
|
-
/**
|
|
239
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
238
240
|
id: string;
|
|
239
|
-
/** The statements to
|
|
241
|
+
/** The statements to execute, in order. */
|
|
240
242
|
statements: TransactionStatement[];
|
|
241
|
-
/**
|
|
243
|
+
/** The acknowledgements that the server waits for before it confirms the transaction. */
|
|
242
244
|
writeConcern?: WriteConcern;
|
|
243
245
|
}
|
|
244
246
|
/**
|
|
245
|
-
*
|
|
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
|
-
/**
|
|
252
|
+
/** The message type for a batch. */
|
|
251
253
|
type: 'batch';
|
|
252
|
-
/**
|
|
254
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
253
255
|
id: string;
|
|
254
|
-
/** The statement to
|
|
256
|
+
/** The statement to execute for each parameter set. */
|
|
255
257
|
sql: string;
|
|
256
|
-
/** One parameter set
|
|
258
|
+
/** One parameter set for each execution of the statement. */
|
|
257
259
|
paramsBatch: (Record<string, unknown> | unknown[])[];
|
|
258
|
-
/**
|
|
260
|
+
/** The acknowledgements that the server waits for before it confirms the batch. */
|
|
259
261
|
writeConcern?: WriteConcern;
|
|
260
262
|
}
|
|
261
263
|
/**
|
|
262
|
-
*
|
|
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
|
-
/**
|
|
269
|
+
/** The message type for a load. */
|
|
268
270
|
type: 'load';
|
|
269
|
-
/**
|
|
271
|
+
/** The identifier that the client chooses, which the server repeats in its reply. */
|
|
270
272
|
id: string;
|
|
271
|
-
/** The statement to
|
|
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
|
-
/**
|
|
277
|
+
/** The writer's durability level during the load. Defaults to 'off'. */
|
|
276
278
|
durability?: BulkLoadDurability;
|
|
277
|
-
/** Whether this load
|
|
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
|
|
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
|
-
/**
|
|
297
|
+
/** The zero-based position in the result set that the edit applies to. */
|
|
295
298
|
index: number;
|
|
296
|
-
/** The row that now
|
|
299
|
+
/** The row that is now at that position. */
|
|
297
300
|
row: unknown;
|
|
298
301
|
} | {
|
|
299
|
-
/**
|
|
302
|
+
/** The edit type for a row changed in place. */
|
|
300
303
|
op: 'update';
|
|
301
|
-
/**
|
|
304
|
+
/** The position of the row that changed. */
|
|
302
305
|
index: number;
|
|
303
|
-
/** The row
|
|
306
|
+
/** The row's new values. */
|
|
304
307
|
row: unknown;
|
|
305
308
|
} | {
|
|
306
|
-
/**
|
|
309
|
+
/** The edit type for a removed row. */
|
|
307
310
|
op: 'delete';
|
|
308
|
-
/**
|
|
311
|
+
/** The position of the removed row. */
|
|
309
312
|
index: number;
|
|
310
313
|
};
|
|
311
314
|
/**
|
|
312
|
-
*
|
|
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
|
-
/**
|
|
320
|
+
/** The message type for a live-query update. */
|
|
318
321
|
type: 'live';
|
|
319
|
-
/**
|
|
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
|
|
328
|
+
/** Set while the server reads the query again. */
|
|
326
329
|
revalidating?: boolean;
|
|
327
330
|
}
|
|
328
331
|
/**
|
|
329
|
-
*
|
|
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
|
-
/**
|
|
337
|
+
/** The message type for a subscription confirmation. */
|
|
335
338
|
type: 'subscribed';
|
|
336
|
-
/**
|
|
339
|
+
/** The identifier of the subscription that is now open. */
|
|
337
340
|
id: string;
|
|
338
341
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
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
|
|
345
|
-
* change
|
|
346
|
-
*
|
|
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
|
|
351
|
-
*
|
|
352
|
-
*
|
|
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
|
-
*
|
|
357
|
-
* stores it and
|
|
358
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
370
|
+
* The server's confirmation that a subscription has ended.
|
|
366
371
|
*
|
|
367
372
|
* @public
|
|
368
373
|
*/
|
|
369
374
|
interface WSUnsubscribedMessage {
|
|
370
|
-
/**
|
|
375
|
+
/** The message type for an unsubscribe confirmation. */
|
|
371
376
|
type: 'unsubscribed';
|
|
372
|
-
/**
|
|
377
|
+
/** The identifier of the subscription that has ended. */
|
|
373
378
|
id: string;
|
|
374
379
|
}
|
|
375
380
|
/**
|
|
376
|
-
* One change event
|
|
377
|
-
* so a value beyond the safe integer range
|
|
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
|
-
/**
|
|
389
|
+
/** The table of the row. */
|
|
385
390
|
table: string;
|
|
386
|
-
/** The row
|
|
391
|
+
/** The row's values after the change. */
|
|
387
392
|
row: Record<string, unknown>;
|
|
388
|
-
/** The row
|
|
393
|
+
/** The row's values before an update or a delete. */
|
|
389
394
|
oldRow?: Record<string, unknown>;
|
|
390
|
-
/**
|
|
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,
|
|
397
|
+
/** Milliseconds since the Unix epoch, from when the database recorded the change. */
|
|
393
398
|
timestamp: number;
|
|
394
|
-
/**
|
|
399
|
+
/** The hybrid logical clock stamp that the writing node gave this change. */
|
|
395
400
|
hlc?: string;
|
|
396
|
-
/**
|
|
401
|
+
/** The identifier of the node or device that wrote the change. */
|
|
397
402
|
origin?: string;
|
|
398
|
-
/**
|
|
403
|
+
/** The primary key of the changed row, encoded as a string. */
|
|
399
404
|
rowId?: string;
|
|
400
|
-
/**
|
|
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
|
-
*
|
|
411
|
+
* One change event for a subscriber.
|
|
407
412
|
*
|
|
408
413
|
* @public
|
|
409
414
|
*/
|
|
410
415
|
interface WSChangeMessage {
|
|
411
|
-
/**
|
|
416
|
+
/** The message type for a single change event. */
|
|
412
417
|
type: 'change';
|
|
413
|
-
/**
|
|
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.
|
|
420
|
-
* a device subscription that
|
|
421
|
-
* same fields as a `change` frame
|
|
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
|
-
/**
|
|
431
|
+
/** The message type for several change events. */
|
|
427
432
|
type: 'changes';
|
|
428
|
-
/**
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
444
|
+
/** The message type for a reply to a read, write, transaction, batch, load, or acknowledgement. */
|
|
440
445
|
type: 'result';
|
|
441
|
-
/**
|
|
446
|
+
/** The identifier from the request. */
|
|
442
447
|
id: string;
|
|
443
|
-
/** The reply body, whose shape
|
|
448
|
+
/** The reply body, whose shape depends on the request. */
|
|
444
449
|
data: QueryResponse | ExecuteResponse | TransactionResponse | BatchResponse | LoadResponse | AckResponse;
|
|
445
450
|
}
|
|
446
451
|
/**
|
|
447
|
-
*
|
|
452
|
+
* The server's report that a request failed.
|
|
448
453
|
*
|
|
449
454
|
* @public
|
|
450
455
|
*/
|
|
451
456
|
interface WSErrorMessage {
|
|
452
|
-
/**
|
|
457
|
+
/** The message type for a failure. */
|
|
453
458
|
type: 'error';
|
|
454
|
-
/**
|
|
459
|
+
/** The identifier from the request, or an empty string when the server cannot read one. */
|
|
455
460
|
id: string;
|
|
456
|
-
/**
|
|
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
|
|
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
|
-
*
|
|
499
|
+
* Loads uWebSockets.js and starts serving on the configured host and port.
|
|
493
500
|
*
|
|
494
|
-
* @throws
|
|
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
|
|
506
|
+
* Stops listening for new connections and closes every open WebSocket connection.
|
|
499
507
|
*/
|
|
500
508
|
close(): Promise<void>;
|
|
501
509
|
/**
|
|
502
|
-
*
|
|
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
|
|
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,
|
|
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
|
-
*
|
|
534
|
+
* The outcome of writing one frame to a WebSocket connection.
|
|
526
535
|
*
|
|
527
|
-
* - `sent`:
|
|
528
|
-
* - `buffered`:
|
|
529
|
-
* backpressure limit
|
|
530
|
-
* - `dropped`:
|
|
531
|
-
*
|
|
532
|
-
* the request as
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
555
|
+
* Returns the number of bytes that the socket has buffered and not yet sent.
|
|
547
556
|
*
|
|
548
|
-
*
|
|
549
|
-
* queues only the tail of a frame can flush that tail without the
|
|
550
|
-
* becoming writable again. A
|
|
551
|
-
* whether
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
587
|
-
* client reject
|
|
588
|
-
*
|
|
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
|
|
621
|
+
* Builds the handler that processes a server's WebSocket connections and messages.
|
|
612
622
|
*
|
|
613
623
|
* @internal
|
|
614
624
|
*/
|