@delali/sirannon-db 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backup-scheduler/index.d.ts +15 -1
- package/dist/backup-scheduler/index.mjs +2 -2
- package/dist/baseline-D93hcIEE.d.ts +17 -0
- package/dist/{change-tracker-DKRVUC3l.d.ts → change-tracker-DDmXB754.d.ts} +56 -8
- package/dist/{chunk-5NOIGN5Y.mjs → chunk-2QLXDHAP.mjs} +1 -1
- package/dist/{chunk-LNY2VVHE.mjs → chunk-7C36BCSN.mjs} +1 -1
- package/dist/{chunk-NVQS53NT.mjs → chunk-7FQRQH5Z.mjs} +53 -64
- package/dist/{chunk-D7LAYTKN.mjs → chunk-7R4ER4FB.mjs} +1 -1
- package/dist/{chunk-FHWTZFI4.mjs → chunk-BQFQ65OL.mjs} +1 -1
- package/dist/{chunk-O7SLN3GI.mjs → chunk-BTTFW4Z4.mjs} +1 -1
- package/dist/{chunk-H6PIVVDN.mjs → chunk-CCZK6LCB.mjs} +38 -25
- package/dist/{chunk-JZGINXTN.mjs → chunk-HCCGEIZ2.mjs} +2 -2
- package/dist/{chunk-67M7KAH6.mjs → chunk-IWGIYDMZ.mjs} +1 -1
- package/dist/{chunk-LFZ37BSX.mjs → chunk-OUSWVNWT.mjs} +1 -1
- package/dist/{chunk-HR5CWTLC.mjs → chunk-P2VJYRVY.mjs} +60 -7
- package/dist/{chunk-UC3SCMIN.mjs → chunk-PBRXXISQ.mjs} +3 -0
- package/dist/{chunk-JU64Y7HM.mjs → chunk-SBL6GN43.mjs} +1 -1
- package/dist/{chunk-EBJXPQQO.mjs → chunk-UPKKSUPA.mjs} +2 -2
- package/dist/{chunk-TJF5GZSV.mjs → chunk-VOSJBZ6Q.mjs} +1 -1
- package/dist/{chunk-PIKHN33N.mjs → chunk-VOYGMAU7.mjs} +9 -1
- package/dist/{chunk-H237TXZW.mjs → chunk-WJ67DTD6.mjs} +48 -6
- package/dist/{chunk-OQVZBEBY.mjs → chunk-XF2HH5E6.mjs} +4 -61
- package/dist/client/index.d.ts +211 -12
- package/dist/client/index.mjs +155 -67
- package/dist/client/topology.d.ts +55 -7
- package/dist/client/topology.mjs +20 -1
- package/dist/{client-base-CLWmH5Ln.d.ts → client-base-CmZO0v3m.d.ts} +133 -24
- package/dist/codegen/cli.mjs +3 -3
- package/dist/codegen/index.d.ts +92 -2
- package/dist/codegen/index.mjs +3 -3
- package/dist/core/index.d.ts +177 -15
- package/dist/core/index.mjs +2481 -2226
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-B5Qv1-cU.d.ts +380 -0
- package/dist/driver/better-sqlite3.d.ts +18 -1
- package/dist/driver/better-sqlite3.mjs +5 -5
- package/dist/driver/bun.d.ts +28 -0
- package/dist/driver/expo.d.ts +17 -0
- package/dist/driver/node.d.ts +18 -1
- package/dist/driver/node.mjs +5 -5
- package/dist/driver/wa-sqlite.d.ts +18 -1
- package/dist/{errors-Bw5MdNCu.d.ts → errors-Dei4GdBb.d.ts} +80 -7
- package/dist/file-migrations/index.d.ts +54 -2
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/{operation-registry-9DcvxcE5.d.ts → operation-registry-hlbhqu7q.d.ts} +50 -1
- package/dist/{primary-wins-DPAm2AKG.d.ts → primary-wins-B0np8JS3.d.ts} +25 -1
- package/dist/protocol-rqANt-9Q.d.ts +152 -0
- package/dist/query-types-DL3LtPvY.d.ts +95 -0
- package/dist/react/index.d.ts +58 -3
- package/dist/replication/coordinator/etcd.d.ts +63 -3
- package/dist/replication/coordinator/etcd.mjs +82 -46
- package/dist/replication/index.d.ts +329 -95
- package/dist/replication/index.mjs +256 -141
- package/dist/server/index.d.ts +230 -12
- package/dist/server/index.mjs +63 -50
- package/dist/{server-options-1JHu8pid.d.ts → server-options-Dab_Jvd_.d.ts} +96 -12
- package/dist/sirannon-CMhiJa5Y.d.ts +111 -0
- package/dist/transport/grpc.d.ts +93 -9
- package/dist/transport/grpc.mjs +63 -20
- package/dist/transport/memory.d.ts +50 -20
- package/dist/transport/memory.mjs +25 -0
- package/dist/{types-CL6piSnD.d.ts → types-BCejqzNA.d.ts} +20 -0
- package/dist/types-CMBcFPhb.d.ts +336 -0
- package/dist/types-CjhxcjhA.d.ts +123 -0
- package/dist/types-DyrCiWuc.d.ts +499 -0
- package/dist/types-rVZKnKN-.d.ts +591 -0
- package/package.json +7 -1
- package/dist/baseline-Br77Fnhb.d.ts +0 -6
- package/dist/database-BY0L5Q2n.d.ts +0 -172
- package/dist/protocol-6KrSq2Hy.d.ts +0 -66
- package/dist/sirannon-DaQSyhbJ.d.ts +0 -36
- package/dist/types-B7gmEsZW.d.ts +0 -221
- package/dist/types-BsVabqSI.d.ts +0 -139
- package/dist/types-C_D8IhpO.d.ts +0 -60
- package/dist/types-zhnRXrsb.d.ts +0 -384
package/dist/client/index.d.ts
CHANGED
|
@@ -1,31 +1,66 @@
|
|
|
1
|
-
export { F as FieldMergeResolver, L as LWWResolver, P as PrimaryWinsResolver } from '../primary-wins-
|
|
2
|
-
import { C as ConflictResolver, R as ReplicationBatch } from '../types-
|
|
3
|
-
export { a as ConflictContext, b as ConflictResolution } from '../types-
|
|
4
|
-
import { C as ClientOptions, B as BulkLoadDurability } from '../server-options-
|
|
5
|
-
import { D as DatabaseClient, T as Transport, L as LiveHandlers, R as RemoteSubscription, a as RemoteSubscriptionBuilder, S as SubscribeOptions, b as RegistryDigestSource } from '../client-base-
|
|
6
|
-
export { c as LoadAllOptions, d as RemoteDatabase, e as RemoteError, f as SQL_REFUSED_MESSAGE, g as ServerCapabilities, h as ServerCapabilityCheck } from '../client-base-
|
|
7
|
-
import { a as LiveQuery, b as LiveQueryState, c as LiveUpdate } from '../types-
|
|
8
|
-
import { e as DeviceSyncPort, D as Database } from '../database-
|
|
9
|
-
import {
|
|
10
|
-
import { Q as QueryResponse, E as ExecuteResponse, a as TransactionResponse, B as BatchResponse, L as LoadResponse, A as AckResponse } from '../protocol-
|
|
11
|
-
import '../operation-registry-
|
|
1
|
+
export { F as FieldMergeResolver, L as LWWResolver, P as PrimaryWinsResolver } from '../primary-wins-B0np8JS3.js';
|
|
2
|
+
import { C as ConflictResolver, R as ReplicationBatch } from '../types-CjhxcjhA.js';
|
|
3
|
+
export { a as ConflictContext, b as ConflictResolution } from '../types-CjhxcjhA.js';
|
|
4
|
+
import { C as ClientOptions, B as BulkLoadDurability } from '../server-options-Dab_Jvd_.js';
|
|
5
|
+
import { D as DatabaseClient, T as Transport, L as LiveHandlers, R as RemoteSubscription, a as RemoteSubscriptionBuilder, S as SubscribeOptions, b as RegistryDigestSource } from '../client-base-CmZO0v3m.js';
|
|
6
|
+
export { c as LoadAllOptions, d as RemoteDatabase, e as RemoteError, f as SQL_REFUSED_MESSAGE, g as ServerCapabilities, h as ServerCapabilityCheck } from '../client-base-CmZO0v3m.js';
|
|
7
|
+
import { a as LiveQuery, b as LiveQueryState, c as LiveUpdate } from '../types-BCejqzNA.js';
|
|
8
|
+
import { e as DeviceSyncPort, D as Database } from '../database-B5Qv1-cU.js';
|
|
9
|
+
import { C as ChangeEvent, P as Params, R as ReadConcern, W as WriteConcern } from '../query-types-DL3LtPvY.js';
|
|
10
|
+
import { Q as QueryResponse, E as ExecuteResponse, a as TransactionResponse, B as BatchResponse, L as LoadResponse, A as AckResponse } from '../protocol-rqANt-9Q.js';
|
|
11
|
+
import '../operation-registry-hlbhqu7q.js';
|
|
12
|
+
import '../types-rVZKnKN-.js';
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*
|
|
17
|
+
* Connects to one sirannon-db server and hands out a {@link RemoteDatabase} per database.
|
|
18
|
+
*/
|
|
13
19
|
declare class SirannonClient extends DatabaseClient {
|
|
14
20
|
private readonly baseUrl;
|
|
15
21
|
constructor(url: string, options?: ClientOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Builds the transport a database's requests travel over.
|
|
24
|
+
*
|
|
25
|
+
* @param databaseId - Identifier of the database.
|
|
26
|
+
* @returns A transport bound to that database.
|
|
27
|
+
*/
|
|
16
28
|
protected createTransport(databaseId: string): Transport;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the address requests are sent to.
|
|
31
|
+
*
|
|
32
|
+
* @returns The server's base address.
|
|
33
|
+
*/
|
|
17
34
|
protected resolveServerUrl(): string;
|
|
18
35
|
}
|
|
19
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
*
|
|
40
|
+
* A live query running against a remote server, which keeps its rows current as the tables behind it change.
|
|
41
|
+
*/
|
|
20
42
|
declare class RemoteLiveQuery<T> implements LiveQuery<T> {
|
|
21
43
|
private state;
|
|
22
44
|
private rows;
|
|
23
45
|
private readonly listeners;
|
|
24
46
|
private subscription;
|
|
25
47
|
private closed;
|
|
48
|
+
/** @internal */
|
|
26
49
|
static open<T>(subscribe: (handlers: LiveHandlers) => Promise<RemoteSubscription>): Promise<RemoteLiveQuery<T>>;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the rows the query holds right now.
|
|
52
|
+
*/
|
|
27
53
|
getState(): LiveQueryState<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Calls back on each update and returns a function that stops the listener.
|
|
56
|
+
*
|
|
57
|
+
* @param listener - Receives each update.
|
|
58
|
+
* @returns A function that removes the listener.
|
|
59
|
+
*/
|
|
28
60
|
subscribe(listener: (update: LiveUpdate<T>) => void): () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Ends the query and releases its subscription.
|
|
63
|
+
*/
|
|
29
64
|
close(): Promise<void>;
|
|
30
65
|
private handlers;
|
|
31
66
|
private replace;
|
|
@@ -35,34 +70,75 @@ declare class RemoteLiveQuery<T> implements LiveQuery<T> {
|
|
|
35
70
|
private publish;
|
|
36
71
|
}
|
|
37
72
|
|
|
73
|
+
/**
|
|
74
|
+
* How far a snapshot download has progressed, for the table in flight and overall.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
38
78
|
interface SnapshotProgress {
|
|
79
|
+
/** Table the download is reading right now. */
|
|
39
80
|
table: string;
|
|
81
|
+
/** Rows loaded from that table so far. */
|
|
40
82
|
tableLoadedRows: number;
|
|
83
|
+
/** Rows that table holds in total. */
|
|
41
84
|
tableTotalRows: number;
|
|
85
|
+
/** Rows loaded across every table so far. */
|
|
42
86
|
loadedRows: number;
|
|
87
|
+
/** Rows the whole snapshot holds. */
|
|
43
88
|
totalRows: number;
|
|
44
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Where a snapshot comes from and how it is read.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
45
95
|
interface SnapshotDownloadOptions {
|
|
96
|
+
/** Address of the server serving the snapshot. */
|
|
46
97
|
url: string;
|
|
98
|
+
/** Identifier of the database to copy. */
|
|
47
99
|
databaseId: string;
|
|
100
|
+
/** Headers attached to each snapshot request. */
|
|
48
101
|
headers?: Record<string, string>;
|
|
102
|
+
/** Rows requested per page. Default: 500. */
|
|
49
103
|
pageSize?: number;
|
|
104
|
+
/** Milliseconds a single page request may take. */
|
|
50
105
|
requestTimeoutMs?: number;
|
|
106
|
+
/** Called as each page arrives. */
|
|
51
107
|
onProgress?: (progress: SnapshotProgress) => void;
|
|
52
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* What one snapshot download produced.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
53
114
|
interface SnapshotDownloadResult {
|
|
115
|
+
/** Change-log position the device resumes its subscription from. */
|
|
54
116
|
startSeq: bigint;
|
|
117
|
+
/** Sequence space that position belongs to. */
|
|
55
118
|
epoch: string;
|
|
119
|
+
/** Tables the snapshot carried. */
|
|
56
120
|
tables: string[];
|
|
121
|
+
/** Rows the download wrote. */
|
|
57
122
|
loadedRows: number;
|
|
58
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* @public
|
|
126
|
+
*
|
|
127
|
+
* Copies a database from a server into a local one, replacing what the local database holds.
|
|
128
|
+
*
|
|
129
|
+
* @param port - The local database the snapshot is written into.
|
|
130
|
+
* @param options - Where the snapshot comes from and how it is read.
|
|
131
|
+
* @returns The change-log position and sequence space to resume from, the tables copied, and the rows written.
|
|
132
|
+
*/
|
|
59
133
|
declare function downloadDatabaseSnapshot(port: DeviceSyncPort, options: SnapshotDownloadOptions): Promise<SnapshotDownloadResult>;
|
|
60
134
|
|
|
61
135
|
/**
|
|
62
136
|
* Builds a remote CDC subscription with optional row-level filters.
|
|
63
|
-
* Mirrors the core
|
|
137
|
+
* Mirrors the core `SubscriptionBuilder` interface but returns
|
|
64
138
|
* a promise from `subscribe()` since confirming the subscription
|
|
65
139
|
* requires a server round-trip.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
66
142
|
*/
|
|
67
143
|
declare class RemoteSubscriptionBuilderImpl implements RemoteSubscriptionBuilder {
|
|
68
144
|
private readonly table;
|
|
@@ -73,27 +149,56 @@ declare class RemoteSubscriptionBuilderImpl implements RemoteSubscriptionBuilder
|
|
|
73
149
|
subscribe(callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
|
|
74
150
|
}
|
|
75
151
|
|
|
152
|
+
/**
|
|
153
|
+
* How a device keeps its local database in step with a server.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
76
157
|
interface SyncControllerOptions {
|
|
158
|
+
/** Address of the server this device syncs with. */
|
|
77
159
|
url: string;
|
|
160
|
+
/** Identifier of the database on that server. */
|
|
78
161
|
databaseId: string;
|
|
162
|
+
/** Tables this device syncs. */
|
|
79
163
|
tables: readonly string[];
|
|
164
|
+
/** Headers attached to every request and to the WebSocket upgrade. */
|
|
80
165
|
headers?: Record<string, string>;
|
|
166
|
+
/** Changes sent in one push. */
|
|
81
167
|
batchSize?: number;
|
|
168
|
+
/** Milliseconds between pushes of locally recorded changes. */
|
|
82
169
|
pushIntervalMs?: number;
|
|
170
|
+
/** Milliseconds between acknowledgements of pulled changes. */
|
|
83
171
|
ackIntervalMs?: number;
|
|
172
|
+
/** Longest delay, in milliseconds, between retries of a failed push. */
|
|
84
173
|
maxPushRetryDelayMs?: number;
|
|
174
|
+
/** Milliseconds a single request may take. */
|
|
85
175
|
requestTimeout?: number;
|
|
176
|
+
/** Downloads a fresh snapshot on its own when the server says the cursor is too old. Default: true. */
|
|
86
177
|
autoResync?: boolean;
|
|
178
|
+
/** Milliseconds before the first retry of a failed snapshot download. */
|
|
87
179
|
snapshotRetryDelayMs?: number;
|
|
180
|
+
/** Longest delay, in milliseconds, between snapshot retries. */
|
|
88
181
|
maxSnapshotRetryDelayMs?: number;
|
|
182
|
+
/** Rows requested per snapshot page. */
|
|
89
183
|
snapshotPageSize?: number;
|
|
184
|
+
/** Changes after which the device acknowledges at once instead of waiting for the interval. */
|
|
90
185
|
immediateAckAfterChanges?: number;
|
|
186
|
+
/** Resolves which version of a row wins when a pulled change meets a local one. */
|
|
91
187
|
resolver?: ConflictResolver | ((table: string) => ConflictResolver);
|
|
188
|
+
/** Called for each change this device pulls. */
|
|
92
189
|
onChange?: (event: ChangeEvent) => void;
|
|
190
|
+
/** Called when the server says the device must download a fresh snapshot. */
|
|
93
191
|
onResyncRequired?: () => void;
|
|
192
|
+
/** Called as each snapshot page arrives. */
|
|
94
193
|
onSnapshotProgress?: (progress: SnapshotProgress) => void;
|
|
194
|
+
/** Called once a snapshot download settles, whether it succeeded or failed. */
|
|
95
195
|
onSnapshotComplete?: (outcome: SnapshotOutcome) => void;
|
|
96
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* How a snapshot download settled, and whether the local database is usable afterwards.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
97
202
|
type SnapshotOutcome = {
|
|
98
203
|
ok: true;
|
|
99
204
|
error: null;
|
|
@@ -108,27 +213,59 @@ type SnapshotOutcome = {
|
|
|
108
213
|
databaseUsable: boolean;
|
|
109
214
|
retrying: boolean;
|
|
110
215
|
};
|
|
216
|
+
/**
|
|
217
|
+
* What a sync controller is doing right now.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
111
221
|
type SyncState = 'stopped' | 'starting' | 'running' | 'paused' | 'snapshotting';
|
|
222
|
+
/**
|
|
223
|
+
* Settings for one snapshot download.
|
|
224
|
+
*
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
112
227
|
interface SnapshotOptions {
|
|
228
|
+
/** Rows requested per page. */
|
|
113
229
|
pageSize?: number;
|
|
230
|
+
/** Called as each page arrives. */
|
|
114
231
|
onProgress?: (progress: SnapshotProgress) => void;
|
|
115
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Where a device stands against its server.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
116
238
|
interface SyncStatus {
|
|
239
|
+
/** What the controller is doing right now. */
|
|
117
240
|
state: SyncState;
|
|
241
|
+
/** Identifier this device is known by on the server. */
|
|
118
242
|
deviceId: string | null;
|
|
243
|
+
/** Capabilities the server announced, or null before the device has asked. */
|
|
119
244
|
serverCapabilities: string[] | null;
|
|
245
|
+
/** Schema version the local database is at. */
|
|
120
246
|
schemaVersion: number | null;
|
|
247
|
+
/** Local changes waiting to be pushed. */
|
|
121
248
|
pendingPushCount: number;
|
|
249
|
+
/** Highest local change-log position the server has accepted. */
|
|
122
250
|
lastPushedSeq: bigint;
|
|
251
|
+
/** Highest server change-log position this device has applied. */
|
|
123
252
|
lastPulledSeq: bigint | null;
|
|
253
|
+
/** Whether every local change has reached the server. */
|
|
124
254
|
pushCaughtUp: boolean;
|
|
255
|
+
/** Whether the server has told this device to download a fresh snapshot. */
|
|
125
256
|
resyncRequired: boolean;
|
|
257
|
+
/** The most recent failure, or null when the last try succeeded. */
|
|
126
258
|
lastError: {
|
|
127
259
|
code: string;
|
|
128
260
|
message: string;
|
|
129
261
|
} | null;
|
|
130
262
|
}
|
|
131
263
|
|
|
264
|
+
/**
|
|
265
|
+
* @public
|
|
266
|
+
*
|
|
267
|
+
* Keeps one device's local database in step with a server: it pushes local changes, pulls the server's, and downloads a fresh snapshot when the device falls too far behind.
|
|
268
|
+
*/
|
|
132
269
|
declare class SyncController {
|
|
133
270
|
private readonly db;
|
|
134
271
|
private readonly options;
|
|
@@ -147,16 +284,41 @@ declare class SyncController {
|
|
|
147
284
|
private consecutivePullFailures;
|
|
148
285
|
private lastError;
|
|
149
286
|
constructor(db: Database, options: SyncControllerOptions);
|
|
287
|
+
/**
|
|
288
|
+
* Connects to the server and starts pushing and pulling changes.
|
|
289
|
+
*/
|
|
150
290
|
start(): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Holds pushing and pulling without disconnecting.
|
|
293
|
+
*/
|
|
151
294
|
pause(): void;
|
|
295
|
+
/**
|
|
296
|
+
* Resumes pushing and pulling after a pause.
|
|
297
|
+
*/
|
|
152
298
|
resume(): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Stops syncing and closes the connection to the server.
|
|
301
|
+
*/
|
|
153
302
|
stop(): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Reports where this device stands against the server.
|
|
305
|
+
*
|
|
306
|
+
* @returns The device's state, cursors, pending push count, and last failure.
|
|
307
|
+
*/
|
|
154
308
|
status(): Promise<SyncStatus>;
|
|
309
|
+
/**
|
|
310
|
+
* Pushes local changes now instead of waiting for the next interval.
|
|
311
|
+
*/
|
|
155
312
|
triggerPush(): void;
|
|
156
313
|
private verifyCapabilities;
|
|
157
314
|
private localSchemaVersion;
|
|
158
315
|
private reconcileSchema;
|
|
159
316
|
private markResyncRequired;
|
|
317
|
+
/**
|
|
318
|
+
* Replaces the local database with a fresh copy from the server and resumes syncing from it.
|
|
319
|
+
*
|
|
320
|
+
* @param options - Page size and the progress callback for this download.
|
|
321
|
+
*/
|
|
160
322
|
downloadSnapshot(options?: SnapshotOptions): Promise<void>;
|
|
161
323
|
/**
|
|
162
324
|
* Answers whether the local database serves reads and writes again. A failure
|
|
@@ -210,7 +372,17 @@ interface ChangesResponse {
|
|
|
210
372
|
conflicts: number;
|
|
211
373
|
}
|
|
212
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Encodes a device-sync batch into the shape the changes route accepts.
|
|
377
|
+
*
|
|
378
|
+
* @internal
|
|
379
|
+
*/
|
|
213
380
|
declare function encodeSyncBatch(batch: ReplicationBatch): ChangesRequest['batch'];
|
|
381
|
+
/**
|
|
382
|
+
* Sends a device-sync batch to the server and returns what the server applied.
|
|
383
|
+
*
|
|
384
|
+
* @internal
|
|
385
|
+
*/
|
|
214
386
|
declare function pushSyncBatch(baseUrl: string, databaseId: string, batch: ReplicationBatch, headers?: Record<string, string>, timeoutMs?: number, schemaVersion?: number): Promise<ChangesResponse>;
|
|
215
387
|
|
|
216
388
|
/**
|
|
@@ -218,25 +390,38 @@ declare function pushSyncBatch(baseUrl: string, databaseId: string, batch: Repli
|
|
|
218
390
|
* server's REST endpoints. Supports query, execute, transaction, batch,
|
|
219
391
|
* and load operations. Real-time subscriptions are not available over
|
|
220
392
|
* HTTP; use {@link WebSocketTransport} for CDC subscriptions.
|
|
393
|
+
*
|
|
394
|
+
* @public
|
|
221
395
|
*/
|
|
222
396
|
declare class HttpTransport implements Transport {
|
|
397
|
+
/** @internal */
|
|
223
398
|
readonly carriesReadConcern = true;
|
|
224
399
|
private readonly baseUrl;
|
|
225
400
|
private readonly headers;
|
|
226
401
|
private closed;
|
|
227
402
|
constructor(baseUrl: string, headers?: Record<string, string>);
|
|
403
|
+
/** Sends a read and returns its rows. */
|
|
228
404
|
query(sql: string, params?: Params, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
405
|
+
/** Sends one write. */
|
|
229
406
|
execute(sql: string, params?: Params): Promise<ExecuteResponse>;
|
|
407
|
+
/** Sends several statements the server runs in one transaction. */
|
|
230
408
|
transaction(statements: Array<{
|
|
231
409
|
sql: string;
|
|
232
410
|
params?: Params;
|
|
233
411
|
}>): Promise<TransactionResponse>;
|
|
412
|
+
/** Sends one statement over many parameter sets, which the server runs in one transaction. */
|
|
234
413
|
batch(sql: string, paramsBatch: Params[], writeConcern?: WriteConcern): Promise<BatchResponse>;
|
|
414
|
+
/** Sends a bulk load, which the server runs at relaxed durability. */
|
|
235
415
|
load(sql: string, paramsBatch: Params[], durability?: BulkLoadDurability, checkpoint?: boolean): Promise<LoadResponse>;
|
|
416
|
+
/** Runs a registered read by name and returns its rows. */
|
|
236
417
|
queryNamed(name: string, args?: Record<string, unknown>, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
418
|
+
/** Runs a registered write by name. */
|
|
237
419
|
executeNamed(name: string, args?: Record<string, unknown>, writeConcern?: WriteConcern): Promise<TransactionResponse>;
|
|
420
|
+
/** Opens a live query on a registered read and delivers its updates to the handlers. */
|
|
238
421
|
liveSubscribe(): Promise<RemoteSubscription>;
|
|
422
|
+
/** Opens a change subscription on a watched table. */
|
|
239
423
|
subscribe(_table: string, _filter: Record<string, unknown> | undefined, _callback: (event: ChangeEvent) => void): Promise<RemoteSubscription>;
|
|
424
|
+
/** Closes the transport and every subscription running on it. */
|
|
240
425
|
close(): void;
|
|
241
426
|
private post;
|
|
242
427
|
}
|
|
@@ -250,8 +435,11 @@ declare class HttpTransport implements Transport {
|
|
|
250
435
|
* Connections are established lazily on first use and will
|
|
251
436
|
* auto-reconnect (with subscription restoration) when
|
|
252
437
|
* `autoReconnect` is enabled.
|
|
438
|
+
*
|
|
439
|
+
* @public
|
|
253
440
|
*/
|
|
254
441
|
declare class WebSocketTransport implements Transport {
|
|
442
|
+
/** @internal */
|
|
255
443
|
readonly carriesReadConcern = true;
|
|
256
444
|
private ws;
|
|
257
445
|
private readonly url;
|
|
@@ -275,20 +463,31 @@ declare class WebSocketTransport implements Transport {
|
|
|
275
463
|
protocols?: string | string[];
|
|
276
464
|
headers?: Record<string, string>;
|
|
277
465
|
});
|
|
466
|
+
/** Sends a read and returns its rows. */
|
|
278
467
|
query(sql: string, params?: Params, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
468
|
+
/** Sends one write. */
|
|
279
469
|
execute(sql: string, params?: Params): Promise<ExecuteResponse>;
|
|
470
|
+
/** Sends several statements the server runs in one transaction. */
|
|
280
471
|
transaction(statements: Array<{
|
|
281
472
|
sql: string;
|
|
282
473
|
params?: Params;
|
|
283
474
|
}>): Promise<TransactionResponse>;
|
|
475
|
+
/** Sends one statement over many parameter sets, which the server runs in one transaction. */
|
|
284
476
|
batch(sql: string, paramsBatch: Params[], writeConcern?: WriteConcern): Promise<BatchResponse>;
|
|
477
|
+
/** Sends a bulk load, which the server runs at relaxed durability. */
|
|
285
478
|
load(sql: string, paramsBatch: Params[], durability?: BulkLoadDurability, checkpoint?: boolean): Promise<LoadResponse>;
|
|
479
|
+
/** Runs a registered read by name and returns its rows. */
|
|
286
480
|
queryNamed(name: string, args?: Record<string, unknown>, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
481
|
+
/** Runs a registered write by name. */
|
|
287
482
|
executeNamed(name: string, args?: Record<string, unknown>, writeConcern?: WriteConcern): Promise<TransactionResponse>;
|
|
483
|
+
/** Opens a live query on a registered read and delivers its updates to the handlers. */
|
|
288
484
|
liveSubscribe(name: string, args: Record<string, unknown> | undefined, handlers: LiveHandlers, registryDigest?: RegistryDigestSource): Promise<RemoteSubscription>;
|
|
485
|
+
/** Opens a change subscription on a watched table. */
|
|
289
486
|
subscribe(table: string, filter: Record<string, unknown> | undefined, callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
|
|
290
487
|
private sendUnsubscribe;
|
|
488
|
+
/** @internal */
|
|
291
489
|
ack(deviceId: string, seq: bigint): Promise<AckResponse>;
|
|
490
|
+
/** Closes the transport and every subscription running on it. */
|
|
292
491
|
close(): void;
|
|
293
492
|
private nextId;
|
|
294
493
|
private ensureConnected;
|