@korajs/sync 1.0.0-beta.10 → 1.0.0-beta.12

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SyncScopeMap, D as DeltaCursor, a as SyncMessage, b as SerializedOperation, W as WireFormat, c as SyncTransport, T as TransportOptions, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, B as BlobChunkRequestMessage, g as BlobChunkResponseMessage, h as BlobChunkPushMessage, i as SyncEncryptionConfig, V as VersionedKey, Y as YjsDocUpdateMessage, Q as QueueStorage, j as SyncState, k as SyncStatusInfo, l as SyncConfig, R as RejectedOperationStorage, m as SyncStatePersistence, n as SyncQuerySubset, o as RejectedOperation } from './transport-B2GQerqJ.cjs';
2
- export { A as AcknowledgmentMessage, p as AwarenessStateWire, q as AwarenessUpdateMessage, E as EncryptedPayload, r as ErrorMessage, H as HandshakeMessage, s as HandshakeResponseMessage, I as InvalidScopeError, M as MemoryRejectedOperationStorage, O as OperationBatchMessage, t as OperationRejectedMessage, u as SYNC_STATES, v as SYNC_STATUSES, w as ScopeViolationError, x as SyncEncryptionAlgorithm, y as SyncScopeContext, z as SyncStatus, C as dedupeQuerySubsets, F as isAcknowledgmentMessage, G as isAwarenessUpdateMessage, J as isBlobChunkPushMessage, K as isBlobChunkRequestMessage, L as isBlobChunkResponseMessage, N as isErrorMessage, P as isHandshakeMessage, U as isHandshakeResponseMessage, X as isOperationBatchMessage, Z as isOperationRejectedMessage, _ as isSyncMessage, $ as isYjsDocUpdateMessage, a0 as operationMatchesQuerySubsets } from './transport-B2GQerqJ.cjs';
1
+ import { S as SyncScopeMap, D as DeltaCursor, a as SyncMessage, b as SerializedOperation, W as WireFormat, c as SyncTransport, T as TransportOptions, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, B as BlobChunkRequestMessage, g as BlobChunkResponseMessage, h as BlobChunkPushMessage, i as SyncEncryptionConfig, V as VersionedKey, Y as YjsDocUpdateMessage, Q as QueueStorage, j as SyncState, k as SyncStatusInfo, l as SyncConfig, R as RejectedOperationStorage, m as SyncStatePersistence, n as SyncQuerySubset, o as RejectedOperation } from './transport-CJvRO5ix.cjs';
2
+ export { A as AcknowledgmentMessage, p as ActiveApplyFailure, q as AwarenessStateWire, r as AwarenessUpdateMessage, E as EncryptedPayload, s as ErrorMessage, H as HandshakeMessage, t as HandshakeResponseMessage, I as InvalidScopeError, M as MemoryRejectedOperationStorage, O as OperationBatchMessage, u as OperationRejectedMessage, v as SYNC_STATES, w as SYNC_STATUSES, x as ScopeViolationError, y as SyncEncryptionAlgorithm, z as SyncPhase, C as SyncScopeContext, F as SyncSettlementOptions, G as SyncSettlementResult, J as SyncStatus, K as dedupeQuerySubsets, L as isAcknowledgmentMessage, N as isAwarenessUpdateMessage, P as isBlobChunkPushMessage, U as isBlobChunkRequestMessage, X as isBlobChunkResponseMessage, Z as isErrorMessage, _ as isHandshakeMessage, $ as isHandshakeResponseMessage, a0 as isOperationBatchMessage, a1 as isOperationRejectedMessage, a2 as isSyncMessage, a3 as isYjsDocUpdateMessage, a4 as operationMatchesQuerySubsets, a5 as querySubsetContains } from './transport-CJvRO5ix.cjs';
3
3
  import * as _korajs_core from '@korajs/core';
4
4
  import { Operation, VersionVector, ApplyResult, KoraEventEmitter, TimeSource, SyncError, ConnectionQuality } from '@korajs/core';
5
5
  export { ApplyFailureReason, ApplyResult } from '@korajs/core';
@@ -106,6 +106,16 @@ interface SyncStore {
106
106
  * @returns the record's fields, or null when it cannot be read.
107
107
  */
108
108
  readRecordFields?(collection: string, recordId: string): Promise<Record<string, unknown> | null>;
109
+ /**
110
+ * Remove a record from this client's materialized authorization view without
111
+ * writing a domain delete to the replicated operation log.
112
+ */
113
+ applyScopeRetraction?(collection: string, recordId: string): Promise<void>;
114
+ /** Retract every currently materialized row outside a newly accepted scope. */
115
+ applyScopeNarrowing?(scopes: Record<string, Record<string, unknown>>): Promise<Array<{
116
+ collection: string;
117
+ recordId: string;
118
+ }>>;
109
119
  }
110
120
 
111
121
  /** Prefix for handshake rejection when client schema version is unsupported. */
@@ -879,6 +889,8 @@ declare class OutboundQueue {
879
889
  * or null if it was not present (already acknowledged and removed).
880
890
  */
881
891
  reject(opId: string): Promise<Operation | null>;
892
+ /** Remove every pending/in-flight operation for a record so authorization loss cannot upload it. */
893
+ rejectRecord(collection: string, recordId: string): Promise<Operation[]>;
882
894
  /**
883
895
  * Remove operations by id from queue and persistent storage.
884
896
  * Used when ops were already sent during handshake delta exchange.
@@ -956,6 +968,8 @@ declare class SyncEngine {
956
968
  private readonly rejectedStorage;
957
969
  private readonly batchSize;
958
970
  private readonly outboundAckTimeoutMs;
971
+ private readonly outboundRetryBaseDelayMs;
972
+ private readonly outboundRetryMaxDelayMs;
959
973
  private readonly encryptor;
960
974
  private readonly awarenessManager;
961
975
  private readonly richtextDocChannel;
@@ -971,11 +985,19 @@ declare class SyncEngine {
971
985
  private conflictCount;
972
986
  private currentBatch;
973
987
  private currentBatchRequiresPartialAck;
988
+ private currentBatchRequiresRetryBackoff;
989
+ private outboundRetryAttempt;
990
+ private outboundRetryTimer;
974
991
  private reconnecting;
975
992
  private schemaBlocked;
976
993
  private clockBlocked;
977
994
  private clockSkewMs;
978
995
  private blobStorageEnabled;
996
+ private suspensionReason;
997
+ private authRejected;
998
+ private serverFrontier;
999
+ private hasInFlightDeliveryBatch;
1000
+ private blockedFailure;
979
1001
  private outboundAckTimer;
980
1002
  private startPromise;
981
1003
  private stopPromise;
@@ -993,8 +1015,12 @@ declare class SyncEngine {
993
1015
  * with the server-accepted scope (server is authoritative).
994
1016
  */
995
1017
  private activeScope;
1018
+ /** Server-authoritative upload authorization, separate from the downloaded view. */
1019
+ private activeUplinkScope;
1020
+ private hasDirectionalScopes;
996
1021
  /** Live query subsets registered from reactive subscriptions */
997
1022
  private querySubsets;
1023
+ private staticQuerySubsets;
998
1024
  private querySubsetReconnectTimer;
999
1025
  /** Resume cursor for paginated initial sync (persisted across reconnects) */
1000
1026
  private resumeDeltaCursor;
@@ -1051,6 +1077,7 @@ declare class SyncEngine {
1051
1077
  * Get the current developer-facing sync status.
1052
1078
  */
1053
1079
  getStatus(): SyncStatusInfo;
1080
+ private resolvePhase;
1054
1081
  /**
1055
1082
  * True when the server rejected the client's schema version at handshake.
1056
1083
  * Sync stays blocked until the app schema is upgraded or sync config changes.
@@ -1088,6 +1115,8 @@ declare class SyncEngine {
1088
1115
  * or in error state, restarts the sync. If already connected, no-op.
1089
1116
  */
1090
1117
  retryNow(): Promise<void>;
1118
+ /** Wake a permanent auth suspension after the binding reports a new auth state. */
1119
+ notifyAuthChanged(): void;
1091
1120
  /**
1092
1121
  * Atomically refresh the transport session. Overlapping callers share one
1093
1122
  * reconnect, in-flight outbound batches are returned to the queue by stop(), and the
@@ -1160,11 +1189,16 @@ declare class SyncEngine {
1160
1189
  * Get the currently active scope map. Returns undefined if no scope is configured.
1161
1190
  */
1162
1191
  getActiveScope(): SyncScopeMap | undefined;
1192
+ /** Get the server-accepted upload authorization scope. */
1193
+ getActiveUplinkScope(): SyncScopeMap | undefined;
1163
1194
  /**
1164
1195
  * Register a live query subset that narrows synced data for a collection.
1165
1196
  * Takes effect on the next connection; reconnects when already connected.
1166
1197
  */
1167
1198
  registerQuerySubset(subset: SyncQuerySubset): () => void;
1199
+ private switchDeliveryViewWithInheritance;
1200
+ /** Atomically replace the manifest used by static query-subset mode. */
1201
+ setQuerySubsets(subsets: SyncQuerySubset[]): void;
1168
1202
  /**
1169
1203
  * Returns deduplicated active query subsets from registered subscriptions.
1170
1204
  */
@@ -1230,6 +1264,7 @@ declare class SyncEngine {
1230
1264
  * the app can reconcile. Unlike {@link handleError}, this is a normal per-op
1231
1265
  * signal, so the connection stays up.
1232
1266
  */
1267
+ private applyScopeRetraction;
1233
1268
  private handleOperationRejected;
1234
1269
  /**
1235
1270
  * Every operation the server rejected that has not yet been reconciled. The app
@@ -1264,6 +1299,8 @@ declare class SyncEngine {
1264
1299
  private flushQueue;
1265
1300
  private startOutboundAckTimer;
1266
1301
  private clearOutboundAckTimer;
1302
+ private scheduleOutboundRetry;
1303
+ private clearOutboundRetryTimer;
1267
1304
  private handleOutboundAckTimeout;
1268
1305
  private handleAwarenessUpdate;
1269
1306
  private handleTransportClose;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SyncScopeMap, D as DeltaCursor, a as SyncMessage, b as SerializedOperation, W as WireFormat, c as SyncTransport, T as TransportOptions, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, B as BlobChunkRequestMessage, g as BlobChunkResponseMessage, h as BlobChunkPushMessage, i as SyncEncryptionConfig, V as VersionedKey, Y as YjsDocUpdateMessage, Q as QueueStorage, j as SyncState, k as SyncStatusInfo, l as SyncConfig, R as RejectedOperationStorage, m as SyncStatePersistence, n as SyncQuerySubset, o as RejectedOperation } from './transport-B2GQerqJ.js';
2
- export { A as AcknowledgmentMessage, p as AwarenessStateWire, q as AwarenessUpdateMessage, E as EncryptedPayload, r as ErrorMessage, H as HandshakeMessage, s as HandshakeResponseMessage, I as InvalidScopeError, M as MemoryRejectedOperationStorage, O as OperationBatchMessage, t as OperationRejectedMessage, u as SYNC_STATES, v as SYNC_STATUSES, w as ScopeViolationError, x as SyncEncryptionAlgorithm, y as SyncScopeContext, z as SyncStatus, C as dedupeQuerySubsets, F as isAcknowledgmentMessage, G as isAwarenessUpdateMessage, J as isBlobChunkPushMessage, K as isBlobChunkRequestMessage, L as isBlobChunkResponseMessage, N as isErrorMessage, P as isHandshakeMessage, U as isHandshakeResponseMessage, X as isOperationBatchMessage, Z as isOperationRejectedMessage, _ as isSyncMessage, $ as isYjsDocUpdateMessage, a0 as operationMatchesQuerySubsets } from './transport-B2GQerqJ.js';
1
+ import { S as SyncScopeMap, D as DeltaCursor, a as SyncMessage, b as SerializedOperation, W as WireFormat, c as SyncTransport, T as TransportOptions, d as TransportMessageHandler, e as TransportCloseHandler, f as TransportErrorHandler, B as BlobChunkRequestMessage, g as BlobChunkResponseMessage, h as BlobChunkPushMessage, i as SyncEncryptionConfig, V as VersionedKey, Y as YjsDocUpdateMessage, Q as QueueStorage, j as SyncState, k as SyncStatusInfo, l as SyncConfig, R as RejectedOperationStorage, m as SyncStatePersistence, n as SyncQuerySubset, o as RejectedOperation } from './transport-CJvRO5ix.js';
2
+ export { A as AcknowledgmentMessage, p as ActiveApplyFailure, q as AwarenessStateWire, r as AwarenessUpdateMessage, E as EncryptedPayload, s as ErrorMessage, H as HandshakeMessage, t as HandshakeResponseMessage, I as InvalidScopeError, M as MemoryRejectedOperationStorage, O as OperationBatchMessage, u as OperationRejectedMessage, v as SYNC_STATES, w as SYNC_STATUSES, x as ScopeViolationError, y as SyncEncryptionAlgorithm, z as SyncPhase, C as SyncScopeContext, F as SyncSettlementOptions, G as SyncSettlementResult, J as SyncStatus, K as dedupeQuerySubsets, L as isAcknowledgmentMessage, N as isAwarenessUpdateMessage, P as isBlobChunkPushMessage, U as isBlobChunkRequestMessage, X as isBlobChunkResponseMessage, Z as isErrorMessage, _ as isHandshakeMessage, $ as isHandshakeResponseMessage, a0 as isOperationBatchMessage, a1 as isOperationRejectedMessage, a2 as isSyncMessage, a3 as isYjsDocUpdateMessage, a4 as operationMatchesQuerySubsets, a5 as querySubsetContains } from './transport-CJvRO5ix.js';
3
3
  import * as _korajs_core from '@korajs/core';
4
4
  import { Operation, VersionVector, ApplyResult, KoraEventEmitter, TimeSource, SyncError, ConnectionQuality } from '@korajs/core';
5
5
  export { ApplyFailureReason, ApplyResult } from '@korajs/core';
@@ -106,6 +106,16 @@ interface SyncStore {
106
106
  * @returns the record's fields, or null when it cannot be read.
107
107
  */
108
108
  readRecordFields?(collection: string, recordId: string): Promise<Record<string, unknown> | null>;
109
+ /**
110
+ * Remove a record from this client's materialized authorization view without
111
+ * writing a domain delete to the replicated operation log.
112
+ */
113
+ applyScopeRetraction?(collection: string, recordId: string): Promise<void>;
114
+ /** Retract every currently materialized row outside a newly accepted scope. */
115
+ applyScopeNarrowing?(scopes: Record<string, Record<string, unknown>>): Promise<Array<{
116
+ collection: string;
117
+ recordId: string;
118
+ }>>;
109
119
  }
110
120
 
111
121
  /** Prefix for handshake rejection when client schema version is unsupported. */
@@ -879,6 +889,8 @@ declare class OutboundQueue {
879
889
  * or null if it was not present (already acknowledged and removed).
880
890
  */
881
891
  reject(opId: string): Promise<Operation | null>;
892
+ /** Remove every pending/in-flight operation for a record so authorization loss cannot upload it. */
893
+ rejectRecord(collection: string, recordId: string): Promise<Operation[]>;
882
894
  /**
883
895
  * Remove operations by id from queue and persistent storage.
884
896
  * Used when ops were already sent during handshake delta exchange.
@@ -956,6 +968,8 @@ declare class SyncEngine {
956
968
  private readonly rejectedStorage;
957
969
  private readonly batchSize;
958
970
  private readonly outboundAckTimeoutMs;
971
+ private readonly outboundRetryBaseDelayMs;
972
+ private readonly outboundRetryMaxDelayMs;
959
973
  private readonly encryptor;
960
974
  private readonly awarenessManager;
961
975
  private readonly richtextDocChannel;
@@ -971,11 +985,19 @@ declare class SyncEngine {
971
985
  private conflictCount;
972
986
  private currentBatch;
973
987
  private currentBatchRequiresPartialAck;
988
+ private currentBatchRequiresRetryBackoff;
989
+ private outboundRetryAttempt;
990
+ private outboundRetryTimer;
974
991
  private reconnecting;
975
992
  private schemaBlocked;
976
993
  private clockBlocked;
977
994
  private clockSkewMs;
978
995
  private blobStorageEnabled;
996
+ private suspensionReason;
997
+ private authRejected;
998
+ private serverFrontier;
999
+ private hasInFlightDeliveryBatch;
1000
+ private blockedFailure;
979
1001
  private outboundAckTimer;
980
1002
  private startPromise;
981
1003
  private stopPromise;
@@ -993,8 +1015,12 @@ declare class SyncEngine {
993
1015
  * with the server-accepted scope (server is authoritative).
994
1016
  */
995
1017
  private activeScope;
1018
+ /** Server-authoritative upload authorization, separate from the downloaded view. */
1019
+ private activeUplinkScope;
1020
+ private hasDirectionalScopes;
996
1021
  /** Live query subsets registered from reactive subscriptions */
997
1022
  private querySubsets;
1023
+ private staticQuerySubsets;
998
1024
  private querySubsetReconnectTimer;
999
1025
  /** Resume cursor for paginated initial sync (persisted across reconnects) */
1000
1026
  private resumeDeltaCursor;
@@ -1051,6 +1077,7 @@ declare class SyncEngine {
1051
1077
  * Get the current developer-facing sync status.
1052
1078
  */
1053
1079
  getStatus(): SyncStatusInfo;
1080
+ private resolvePhase;
1054
1081
  /**
1055
1082
  * True when the server rejected the client's schema version at handshake.
1056
1083
  * Sync stays blocked until the app schema is upgraded or sync config changes.
@@ -1088,6 +1115,8 @@ declare class SyncEngine {
1088
1115
  * or in error state, restarts the sync. If already connected, no-op.
1089
1116
  */
1090
1117
  retryNow(): Promise<void>;
1118
+ /** Wake a permanent auth suspension after the binding reports a new auth state. */
1119
+ notifyAuthChanged(): void;
1091
1120
  /**
1092
1121
  * Atomically refresh the transport session. Overlapping callers share one
1093
1122
  * reconnect, in-flight outbound batches are returned to the queue by stop(), and the
@@ -1160,11 +1189,16 @@ declare class SyncEngine {
1160
1189
  * Get the currently active scope map. Returns undefined if no scope is configured.
1161
1190
  */
1162
1191
  getActiveScope(): SyncScopeMap | undefined;
1192
+ /** Get the server-accepted upload authorization scope. */
1193
+ getActiveUplinkScope(): SyncScopeMap | undefined;
1163
1194
  /**
1164
1195
  * Register a live query subset that narrows synced data for a collection.
1165
1196
  * Takes effect on the next connection; reconnects when already connected.
1166
1197
  */
1167
1198
  registerQuerySubset(subset: SyncQuerySubset): () => void;
1199
+ private switchDeliveryViewWithInheritance;
1200
+ /** Atomically replace the manifest used by static query-subset mode. */
1201
+ setQuerySubsets(subsets: SyncQuerySubset[]): void;
1168
1202
  /**
1169
1203
  * Returns deduplicated active query subsets from registered subscriptions.
1170
1204
  */
@@ -1230,6 +1264,7 @@ declare class SyncEngine {
1230
1264
  * the app can reconcile. Unlike {@link handleError}, this is a normal per-op
1231
1265
  * signal, so the connection stays up.
1232
1266
  */
1267
+ private applyScopeRetraction;
1233
1268
  private handleOperationRejected;
1234
1269
  /**
1235
1270
  * Every operation the server rejected that has not yet been reconciled. The app
@@ -1264,6 +1299,8 @@ declare class SyncEngine {
1264
1299
  private flushQueue;
1265
1300
  private startOutboundAckTimer;
1266
1301
  private clearOutboundAckTimer;
1302
+ private scheduleOutboundRetry;
1303
+ private clearOutboundRetryTimer;
1267
1304
  private handleOutboundAckTimeout;
1268
1305
  private handleAwarenessUpdate;
1269
1306
  private handleTransportClose;