@korajs/sync 1.0.0-beta.4 → 1.0.0-beta.5
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 +283 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -2
- package/dist/index.d.ts +82 -2
- package/dist/index.js +283 -41
- 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-DXmZ8kyI.d.cts} +52 -0
- package/dist/{transport-BGr-_eH8.d.ts → transport-DXmZ8kyI.d.ts} +52 -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-DXmZ8kyI.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-DXmZ8kyI.js';
|
|
2
2
|
import { Operation } from '@korajs/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -193,6 +193,23 @@ interface SyncStatePersistence {
|
|
|
193
193
|
/** Resume position for paginated initial sync (optional). */
|
|
194
194
|
loadDeltaCursor?(): Promise<DeltaCursor | null>;
|
|
195
195
|
saveDeltaCursor?(cursor: DeltaCursor | null): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* The delivery watermark for a sync view, keyed by an opaque view signature (the auth
|
|
198
|
+
* scope plus active query subscriptions). Persisted per view so a restarted client
|
|
199
|
+
* resumes each view's gap-free stream from the right point, and switching views does not
|
|
200
|
+
* re-sync a view already synced. The empty-string signature is the default, unfiltered
|
|
201
|
+
* view. Optional: a persistence layer that omits these falls back to re-sync on restart.
|
|
202
|
+
*/
|
|
203
|
+
loadDeliveryWatermark?(signature: string): Promise<number>;
|
|
204
|
+
saveDeliveryWatermark?(signature: string, watermark: number): Promise<void>;
|
|
205
|
+
/** Load every persisted view watermark, keyed by signature. */
|
|
206
|
+
loadAllDeliveryWatermarks?(): Promise<Record<string, number>>;
|
|
207
|
+
/**
|
|
208
|
+
* Delete a persisted view watermark. Used to bound the number of stored view watermarks
|
|
209
|
+
* (a cold view is evicted from the client's cache and its persisted row removed). Safe:
|
|
210
|
+
* an evicted view back-fills from 0 (deduplicated) when next visited.
|
|
211
|
+
*/
|
|
212
|
+
deleteDeliveryWatermark?(signature: string): Promise<void>;
|
|
196
213
|
}
|
|
197
214
|
/**
|
|
198
215
|
* Interface for persisting the outbound operation queue.
|
|
@@ -328,6 +345,14 @@ interface HandshakeMessage {
|
|
|
328
345
|
deltaCursor?: string;
|
|
329
346
|
/** Live query filters that further narrow synced data within auth/schema scope */
|
|
330
347
|
syncQueries?: SyncQuerySubset[];
|
|
348
|
+
/**
|
|
349
|
+
* The client's persisted delivery watermark: the highest server delivery sequence
|
|
350
|
+
* up to which it has contiguously applied every in-scope operation. Omitted (or 0)
|
|
351
|
+
* on first sync. When present, the server resumes the gap-free server->client
|
|
352
|
+
* stream from just after it, superseding the version-vector delta and the resume
|
|
353
|
+
* cursor for the server->client direction. Optional, so old servers ignore it.
|
|
354
|
+
*/
|
|
355
|
+
lastDeliverySequence?: number;
|
|
331
356
|
}
|
|
332
357
|
/**
|
|
333
358
|
* Server response to a handshake.
|
|
@@ -355,6 +380,13 @@ interface HandshakeResponseMessage {
|
|
|
355
380
|
* available to other devices even after the authoring device goes offline.
|
|
356
381
|
*/
|
|
357
382
|
blobStorageEnabled?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* The server's highest delivery sequence at handshake time. A client whose
|
|
385
|
+
* persisted delivery watermark exceeds this (the server's operation log was rolled
|
|
386
|
+
* back, for example by a backup restore) resets its watermark to 0 so it resyncs
|
|
387
|
+
* from the beginning instead of sitting above a frontier that no longer exists.
|
|
388
|
+
*/
|
|
389
|
+
serverMaxDeliverySequence?: number;
|
|
358
390
|
}
|
|
359
391
|
/**
|
|
360
392
|
* Batch of operations sent during delta exchange or streaming.
|
|
@@ -371,6 +403,20 @@ interface OperationBatchMessage {
|
|
|
371
403
|
cursor?: string;
|
|
372
404
|
/** Total batches in this delta exchange (for progress reporting) */
|
|
373
405
|
totalBatches?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Delivery-watermark chaining (server->client). `baseDeliverySequence` is the
|
|
408
|
+
* delivery sequence the client must already hold for this batch to apply in order
|
|
409
|
+
* (it equals the previous batch's `maxDeliverySequence`, or the client's reported
|
|
410
|
+
* watermark for the first batch after a handshake). `maxDeliverySequence` is the
|
|
411
|
+
* highest delivery sequence carried by this batch. The client applies the batch
|
|
412
|
+
* only when its watermark equals `baseDeliverySequence`, then advances the
|
|
413
|
+
* watermark to `maxDeliverySequence`. A dropped batch breaks the chain and stalls
|
|
414
|
+
* the watermark, so the reconnect resend recovers it. Present only on batches the
|
|
415
|
+
* server sends as part of the delivery stream; absent on legacy version-vector
|
|
416
|
+
* batches.
|
|
417
|
+
*/
|
|
418
|
+
baseDeliverySequence?: number;
|
|
419
|
+
maxDeliverySequence?: number;
|
|
374
420
|
}
|
|
375
421
|
/**
|
|
376
422
|
* Acknowledgment of a received message.
|
|
@@ -380,6 +426,12 @@ interface AcknowledgmentMessage {
|
|
|
380
426
|
messageId: string;
|
|
381
427
|
acknowledgedMessageId: string;
|
|
382
428
|
lastSequenceNumber: number;
|
|
429
|
+
/**
|
|
430
|
+
* The acknowledged batch's `maxDeliverySequence`, echoed so the server can advance
|
|
431
|
+
* this client's durable delivery watermark. Present only when acking a delivery-
|
|
432
|
+
* stream batch. `lastSequenceNumber` stays for existing per-node behavior.
|
|
433
|
+
*/
|
|
434
|
+
deliverySequence?: number;
|
|
383
435
|
}
|
|
384
436
|
/**
|
|
385
437
|
* Error message from the server or client.
|
|
@@ -193,6 +193,23 @@ interface SyncStatePersistence {
|
|
|
193
193
|
/** Resume position for paginated initial sync (optional). */
|
|
194
194
|
loadDeltaCursor?(): Promise<DeltaCursor | null>;
|
|
195
195
|
saveDeltaCursor?(cursor: DeltaCursor | null): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* The delivery watermark for a sync view, keyed by an opaque view signature (the auth
|
|
198
|
+
* scope plus active query subscriptions). Persisted per view so a restarted client
|
|
199
|
+
* resumes each view's gap-free stream from the right point, and switching views does not
|
|
200
|
+
* re-sync a view already synced. The empty-string signature is the default, unfiltered
|
|
201
|
+
* view. Optional: a persistence layer that omits these falls back to re-sync on restart.
|
|
202
|
+
*/
|
|
203
|
+
loadDeliveryWatermark?(signature: string): Promise<number>;
|
|
204
|
+
saveDeliveryWatermark?(signature: string, watermark: number): Promise<void>;
|
|
205
|
+
/** Load every persisted view watermark, keyed by signature. */
|
|
206
|
+
loadAllDeliveryWatermarks?(): Promise<Record<string, number>>;
|
|
207
|
+
/**
|
|
208
|
+
* Delete a persisted view watermark. Used to bound the number of stored view watermarks
|
|
209
|
+
* (a cold view is evicted from the client's cache and its persisted row removed). Safe:
|
|
210
|
+
* an evicted view back-fills from 0 (deduplicated) when next visited.
|
|
211
|
+
*/
|
|
212
|
+
deleteDeliveryWatermark?(signature: string): Promise<void>;
|
|
196
213
|
}
|
|
197
214
|
/**
|
|
198
215
|
* Interface for persisting the outbound operation queue.
|
|
@@ -328,6 +345,14 @@ interface HandshakeMessage {
|
|
|
328
345
|
deltaCursor?: string;
|
|
329
346
|
/** Live query filters that further narrow synced data within auth/schema scope */
|
|
330
347
|
syncQueries?: SyncQuerySubset[];
|
|
348
|
+
/**
|
|
349
|
+
* The client's persisted delivery watermark: the highest server delivery sequence
|
|
350
|
+
* up to which it has contiguously applied every in-scope operation. Omitted (or 0)
|
|
351
|
+
* on first sync. When present, the server resumes the gap-free server->client
|
|
352
|
+
* stream from just after it, superseding the version-vector delta and the resume
|
|
353
|
+
* cursor for the server->client direction. Optional, so old servers ignore it.
|
|
354
|
+
*/
|
|
355
|
+
lastDeliverySequence?: number;
|
|
331
356
|
}
|
|
332
357
|
/**
|
|
333
358
|
* Server response to a handshake.
|
|
@@ -355,6 +380,13 @@ interface HandshakeResponseMessage {
|
|
|
355
380
|
* available to other devices even after the authoring device goes offline.
|
|
356
381
|
*/
|
|
357
382
|
blobStorageEnabled?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* The server's highest delivery sequence at handshake time. A client whose
|
|
385
|
+
* persisted delivery watermark exceeds this (the server's operation log was rolled
|
|
386
|
+
* back, for example by a backup restore) resets its watermark to 0 so it resyncs
|
|
387
|
+
* from the beginning instead of sitting above a frontier that no longer exists.
|
|
388
|
+
*/
|
|
389
|
+
serverMaxDeliverySequence?: number;
|
|
358
390
|
}
|
|
359
391
|
/**
|
|
360
392
|
* Batch of operations sent during delta exchange or streaming.
|
|
@@ -371,6 +403,20 @@ interface OperationBatchMessage {
|
|
|
371
403
|
cursor?: string;
|
|
372
404
|
/** Total batches in this delta exchange (for progress reporting) */
|
|
373
405
|
totalBatches?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Delivery-watermark chaining (server->client). `baseDeliverySequence` is the
|
|
408
|
+
* delivery sequence the client must already hold for this batch to apply in order
|
|
409
|
+
* (it equals the previous batch's `maxDeliverySequence`, or the client's reported
|
|
410
|
+
* watermark for the first batch after a handshake). `maxDeliverySequence` is the
|
|
411
|
+
* highest delivery sequence carried by this batch. The client applies the batch
|
|
412
|
+
* only when its watermark equals `baseDeliverySequence`, then advances the
|
|
413
|
+
* watermark to `maxDeliverySequence`. A dropped batch breaks the chain and stalls
|
|
414
|
+
* the watermark, so the reconnect resend recovers it. Present only on batches the
|
|
415
|
+
* server sends as part of the delivery stream; absent on legacy version-vector
|
|
416
|
+
* batches.
|
|
417
|
+
*/
|
|
418
|
+
baseDeliverySequence?: number;
|
|
419
|
+
maxDeliverySequence?: number;
|
|
374
420
|
}
|
|
375
421
|
/**
|
|
376
422
|
* Acknowledgment of a received message.
|
|
@@ -380,6 +426,12 @@ interface AcknowledgmentMessage {
|
|
|
380
426
|
messageId: string;
|
|
381
427
|
acknowledgedMessageId: string;
|
|
382
428
|
lastSequenceNumber: number;
|
|
429
|
+
/**
|
|
430
|
+
* The acknowledged batch's `maxDeliverySequence`, echoed so the server can advance
|
|
431
|
+
* this client's durable delivery watermark. Present only when acking a delivery-
|
|
432
|
+
* stream batch. `lastSequenceNumber` stays for existing per-node behavior.
|
|
433
|
+
*/
|
|
434
|
+
deliverySequence?: number;
|
|
383
435
|
}
|
|
384
436
|
/**
|
|
385
437
|
* 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.5",
|
|
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/
|
|
38
|
-
"@korajs/
|
|
37
|
+
"@korajs/merge": "1.0.0-beta.5",
|
|
38
|
+
"@korajs/core": "1.0.0-beta.5"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@fast-check/vitest": "0.2.0",
|