@korajs/sync 1.0.0-beta.4 → 1.0.0-beta.6
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/index.cjs +347 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +91 -2
- package/dist/index.d.ts +91 -2
- package/dist/index.js +347 -44
- package/dist/index.js.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/{transport-BGr-_eH8.d.cts → transport-ByWfWBbB.d.cts} +59 -0
- package/dist/{transport-BGr-_eH8.d.ts → transport-ByWfWBbB.d.ts} +59 -0
- package/package.json +3 -3
package/dist/internal.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as SyncTransport, T as TransportOptions, a as SyncMessage, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, Q as QueueStorage } from './transport-
|
|
1
|
+
import { c as SyncTransport, T as TransportOptions, a as SyncMessage, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, Q as QueueStorage } from './transport-ByWfWBbB.cjs';
|
|
2
2
|
import { Operation } from '@korajs/core';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as SyncTransport, T as TransportOptions, a as SyncMessage, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, Q as QueueStorage } from './transport-
|
|
1
|
+
import { c as SyncTransport, T as TransportOptions, a as SyncMessage, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, Q as QueueStorage } from './transport-ByWfWBbB.js';
|
|
2
2
|
import { Operation } from '@korajs/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -141,6 +141,13 @@ interface SyncConfig {
|
|
|
141
141
|
scopeMap?: SyncScopeMap;
|
|
142
142
|
/** Number of operations per batch. Defaults to 100. */
|
|
143
143
|
batchSize?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Maximum time to wait for the server to acknowledge an outbound batch before
|
|
146
|
+
* treating the connection as stalled. The batch is returned to the durable
|
|
147
|
+
* outbound queue before disconnecting so it can be retried on reconnect.
|
|
148
|
+
* Defaults to 30000ms. Set to 0 to disable the watchdog.
|
|
149
|
+
*/
|
|
150
|
+
outboundAckTimeoutMs?: number;
|
|
144
151
|
/** Initial reconnection delay in ms. Defaults to 1000. */
|
|
145
152
|
reconnectInterval?: number;
|
|
146
153
|
/** Maximum reconnection delay in ms. Defaults to 30000. */
|
|
@@ -193,6 +200,23 @@ interface SyncStatePersistence {
|
|
|
193
200
|
/** Resume position for paginated initial sync (optional). */
|
|
194
201
|
loadDeltaCursor?(): Promise<DeltaCursor | null>;
|
|
195
202
|
saveDeltaCursor?(cursor: DeltaCursor | null): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* The delivery watermark for a sync view, keyed by an opaque view signature (the auth
|
|
205
|
+
* scope plus active query subscriptions). Persisted per view so a restarted client
|
|
206
|
+
* resumes each view's gap-free stream from the right point, and switching views does not
|
|
207
|
+
* re-sync a view already synced. The empty-string signature is the default, unfiltered
|
|
208
|
+
* view. Optional: a persistence layer that omits these falls back to re-sync on restart.
|
|
209
|
+
*/
|
|
210
|
+
loadDeliveryWatermark?(signature: string): Promise<number>;
|
|
211
|
+
saveDeliveryWatermark?(signature: string, watermark: number): Promise<void>;
|
|
212
|
+
/** Load every persisted view watermark, keyed by signature. */
|
|
213
|
+
loadAllDeliveryWatermarks?(): Promise<Record<string, number>>;
|
|
214
|
+
/**
|
|
215
|
+
* Delete a persisted view watermark. Used to bound the number of stored view watermarks
|
|
216
|
+
* (a cold view is evicted from the client's cache and its persisted row removed). Safe:
|
|
217
|
+
* an evicted view back-fills from 0 (deduplicated) when next visited.
|
|
218
|
+
*/
|
|
219
|
+
deleteDeliveryWatermark?(signature: string): Promise<void>;
|
|
196
220
|
}
|
|
197
221
|
/**
|
|
198
222
|
* Interface for persisting the outbound operation queue.
|
|
@@ -328,6 +352,14 @@ interface HandshakeMessage {
|
|
|
328
352
|
deltaCursor?: string;
|
|
329
353
|
/** Live query filters that further narrow synced data within auth/schema scope */
|
|
330
354
|
syncQueries?: SyncQuerySubset[];
|
|
355
|
+
/**
|
|
356
|
+
* The client's persisted delivery watermark: the highest server delivery sequence
|
|
357
|
+
* up to which it has contiguously applied every in-scope operation. Omitted (or 0)
|
|
358
|
+
* on first sync. When present, the server resumes the gap-free server->client
|
|
359
|
+
* stream from just after it, superseding the version-vector delta and the resume
|
|
360
|
+
* cursor for the server->client direction. Optional, so old servers ignore it.
|
|
361
|
+
*/
|
|
362
|
+
lastDeliverySequence?: number;
|
|
331
363
|
}
|
|
332
364
|
/**
|
|
333
365
|
* Server response to a handshake.
|
|
@@ -355,6 +387,13 @@ interface HandshakeResponseMessage {
|
|
|
355
387
|
* available to other devices even after the authoring device goes offline.
|
|
356
388
|
*/
|
|
357
389
|
blobStorageEnabled?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* The server's highest delivery sequence at handshake time. A client whose
|
|
392
|
+
* persisted delivery watermark exceeds this (the server's operation log was rolled
|
|
393
|
+
* back, for example by a backup restore) resets its watermark to 0 so it resyncs
|
|
394
|
+
* from the beginning instead of sitting above a frontier that no longer exists.
|
|
395
|
+
*/
|
|
396
|
+
serverMaxDeliverySequence?: number;
|
|
358
397
|
}
|
|
359
398
|
/**
|
|
360
399
|
* Batch of operations sent during delta exchange or streaming.
|
|
@@ -371,6 +410,20 @@ interface OperationBatchMessage {
|
|
|
371
410
|
cursor?: string;
|
|
372
411
|
/** Total batches in this delta exchange (for progress reporting) */
|
|
373
412
|
totalBatches?: number;
|
|
413
|
+
/**
|
|
414
|
+
* Delivery-watermark chaining (server->client). `baseDeliverySequence` is the
|
|
415
|
+
* delivery sequence the client must already hold for this batch to apply in order
|
|
416
|
+
* (it equals the previous batch's `maxDeliverySequence`, or the client's reported
|
|
417
|
+
* watermark for the first batch after a handshake). `maxDeliverySequence` is the
|
|
418
|
+
* highest delivery sequence carried by this batch. The client applies the batch
|
|
419
|
+
* only when its watermark equals `baseDeliverySequence`, then advances the
|
|
420
|
+
* watermark to `maxDeliverySequence`. A dropped batch breaks the chain and stalls
|
|
421
|
+
* the watermark, so the reconnect resend recovers it. Present only on batches the
|
|
422
|
+
* server sends as part of the delivery stream; absent on legacy version-vector
|
|
423
|
+
* batches.
|
|
424
|
+
*/
|
|
425
|
+
baseDeliverySequence?: number;
|
|
426
|
+
maxDeliverySequence?: number;
|
|
374
427
|
}
|
|
375
428
|
/**
|
|
376
429
|
* Acknowledgment of a received message.
|
|
@@ -380,6 +433,12 @@ interface AcknowledgmentMessage {
|
|
|
380
433
|
messageId: string;
|
|
381
434
|
acknowledgedMessageId: string;
|
|
382
435
|
lastSequenceNumber: number;
|
|
436
|
+
/**
|
|
437
|
+
* The acknowledged batch's `maxDeliverySequence`, echoed so the server can advance
|
|
438
|
+
* this client's durable delivery watermark. Present only when acking a delivery-
|
|
439
|
+
* stream batch. `lastSequenceNumber` stays for existing per-node behavior.
|
|
440
|
+
*/
|
|
441
|
+
deliverySequence?: number;
|
|
383
442
|
}
|
|
384
443
|
/**
|
|
385
444
|
* Error message from the server or client.
|
|
@@ -141,6 +141,13 @@ interface SyncConfig {
|
|
|
141
141
|
scopeMap?: SyncScopeMap;
|
|
142
142
|
/** Number of operations per batch. Defaults to 100. */
|
|
143
143
|
batchSize?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Maximum time to wait for the server to acknowledge an outbound batch before
|
|
146
|
+
* treating the connection as stalled. The batch is returned to the durable
|
|
147
|
+
* outbound queue before disconnecting so it can be retried on reconnect.
|
|
148
|
+
* Defaults to 30000ms. Set to 0 to disable the watchdog.
|
|
149
|
+
*/
|
|
150
|
+
outboundAckTimeoutMs?: number;
|
|
144
151
|
/** Initial reconnection delay in ms. Defaults to 1000. */
|
|
145
152
|
reconnectInterval?: number;
|
|
146
153
|
/** Maximum reconnection delay in ms. Defaults to 30000. */
|
|
@@ -193,6 +200,23 @@ interface SyncStatePersistence {
|
|
|
193
200
|
/** Resume position for paginated initial sync (optional). */
|
|
194
201
|
loadDeltaCursor?(): Promise<DeltaCursor | null>;
|
|
195
202
|
saveDeltaCursor?(cursor: DeltaCursor | null): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* The delivery watermark for a sync view, keyed by an opaque view signature (the auth
|
|
205
|
+
* scope plus active query subscriptions). Persisted per view so a restarted client
|
|
206
|
+
* resumes each view's gap-free stream from the right point, and switching views does not
|
|
207
|
+
* re-sync a view already synced. The empty-string signature is the default, unfiltered
|
|
208
|
+
* view. Optional: a persistence layer that omits these falls back to re-sync on restart.
|
|
209
|
+
*/
|
|
210
|
+
loadDeliveryWatermark?(signature: string): Promise<number>;
|
|
211
|
+
saveDeliveryWatermark?(signature: string, watermark: number): Promise<void>;
|
|
212
|
+
/** Load every persisted view watermark, keyed by signature. */
|
|
213
|
+
loadAllDeliveryWatermarks?(): Promise<Record<string, number>>;
|
|
214
|
+
/**
|
|
215
|
+
* Delete a persisted view watermark. Used to bound the number of stored view watermarks
|
|
216
|
+
* (a cold view is evicted from the client's cache and its persisted row removed). Safe:
|
|
217
|
+
* an evicted view back-fills from 0 (deduplicated) when next visited.
|
|
218
|
+
*/
|
|
219
|
+
deleteDeliveryWatermark?(signature: string): Promise<void>;
|
|
196
220
|
}
|
|
197
221
|
/**
|
|
198
222
|
* Interface for persisting the outbound operation queue.
|
|
@@ -328,6 +352,14 @@ interface HandshakeMessage {
|
|
|
328
352
|
deltaCursor?: string;
|
|
329
353
|
/** Live query filters that further narrow synced data within auth/schema scope */
|
|
330
354
|
syncQueries?: SyncQuerySubset[];
|
|
355
|
+
/**
|
|
356
|
+
* The client's persisted delivery watermark: the highest server delivery sequence
|
|
357
|
+
* up to which it has contiguously applied every in-scope operation. Omitted (or 0)
|
|
358
|
+
* on first sync. When present, the server resumes the gap-free server->client
|
|
359
|
+
* stream from just after it, superseding the version-vector delta and the resume
|
|
360
|
+
* cursor for the server->client direction. Optional, so old servers ignore it.
|
|
361
|
+
*/
|
|
362
|
+
lastDeliverySequence?: number;
|
|
331
363
|
}
|
|
332
364
|
/**
|
|
333
365
|
* Server response to a handshake.
|
|
@@ -355,6 +387,13 @@ interface HandshakeResponseMessage {
|
|
|
355
387
|
* available to other devices even after the authoring device goes offline.
|
|
356
388
|
*/
|
|
357
389
|
blobStorageEnabled?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* The server's highest delivery sequence at handshake time. A client whose
|
|
392
|
+
* persisted delivery watermark exceeds this (the server's operation log was rolled
|
|
393
|
+
* back, for example by a backup restore) resets its watermark to 0 so it resyncs
|
|
394
|
+
* from the beginning instead of sitting above a frontier that no longer exists.
|
|
395
|
+
*/
|
|
396
|
+
serverMaxDeliverySequence?: number;
|
|
358
397
|
}
|
|
359
398
|
/**
|
|
360
399
|
* Batch of operations sent during delta exchange or streaming.
|
|
@@ -371,6 +410,20 @@ interface OperationBatchMessage {
|
|
|
371
410
|
cursor?: string;
|
|
372
411
|
/** Total batches in this delta exchange (for progress reporting) */
|
|
373
412
|
totalBatches?: number;
|
|
413
|
+
/**
|
|
414
|
+
* Delivery-watermark chaining (server->client). `baseDeliverySequence` is the
|
|
415
|
+
* delivery sequence the client must already hold for this batch to apply in order
|
|
416
|
+
* (it equals the previous batch's `maxDeliverySequence`, or the client's reported
|
|
417
|
+
* watermark for the first batch after a handshake). `maxDeliverySequence` is the
|
|
418
|
+
* highest delivery sequence carried by this batch. The client applies the batch
|
|
419
|
+
* only when its watermark equals `baseDeliverySequence`, then advances the
|
|
420
|
+
* watermark to `maxDeliverySequence`. A dropped batch breaks the chain and stalls
|
|
421
|
+
* the watermark, so the reconnect resend recovers it. Present only on batches the
|
|
422
|
+
* server sends as part of the delivery stream; absent on legacy version-vector
|
|
423
|
+
* batches.
|
|
424
|
+
*/
|
|
425
|
+
baseDeliverySequence?: number;
|
|
426
|
+
maxDeliverySequence?: number;
|
|
374
427
|
}
|
|
375
428
|
/**
|
|
376
429
|
* Acknowledgment of a received message.
|
|
@@ -380,6 +433,12 @@ interface AcknowledgmentMessage {
|
|
|
380
433
|
messageId: string;
|
|
381
434
|
acknowledgedMessageId: string;
|
|
382
435
|
lastSequenceNumber: number;
|
|
436
|
+
/**
|
|
437
|
+
* The acknowledged batch's `maxDeliverySequence`, echoed so the server can advance
|
|
438
|
+
* this client's durable delivery watermark. Present only when acking a delivery-
|
|
439
|
+
* stream batch. `lastSequenceNumber` stays for existing per-node behavior.
|
|
440
|
+
*/
|
|
441
|
+
deliverySequence?: number;
|
|
383
442
|
}
|
|
384
443
|
/**
|
|
385
444
|
* Error message from the server or client.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korajs/sync",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Sync protocol and transports for Kora.js with delta sync, causal ordering, and automatic reconnection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"protobufjs": "^8.0.1",
|
|
37
|
-
"@korajs/core": "1.0.0-beta.
|
|
38
|
-
"@korajs/merge": "1.0.0-beta.
|
|
37
|
+
"@korajs/core": "1.0.0-beta.6",
|
|
38
|
+
"@korajs/merge": "1.0.0-beta.6"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@fast-check/vitest": "0.2.0",
|