@powersync/common 0.0.0-dev-20260504100448 → 0.0.0-dev-20260630144038
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/lib/attachments/AttachmentContext.d.ts +9 -8
- package/lib/attachments/AttachmentContext.js +8 -3
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.d.ts +85 -36
- package/lib/attachments/AttachmentQueue.js +19 -21
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentService.d.ts +3 -3
- package/lib/attachments/AttachmentService.js +4 -3
- package/lib/attachments/AttachmentService.js.map +1 -1
- package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
- package/lib/attachments/LocalStorageAdapter.js +3 -0
- package/lib/attachments/LocalStorageAdapter.js.map +1 -1
- package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
- package/lib/attachments/Schema.d.ts +14 -6
- package/lib/attachments/Schema.js +8 -3
- package/lib/attachments/Schema.js.map +1 -1
- package/lib/attachments/SyncingService.d.ts +2 -2
- package/lib/attachments/SyncingService.js +8 -3
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
- package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +112 -238
- package/lib/client/CommonPowerSyncDatabase.js +2 -0
- package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
- package/lib/client/Query.d.ts +9 -0
- package/lib/client/SQLOpenFactory.d.ts +44 -10
- package/lib/client/SQLOpenFactory.js +1 -19
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +8 -2
- package/lib/client/compilableQueryWatch.js +4 -2
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +6 -3
- package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
- package/lib/client/runOnSchemaChange.d.ts +5 -2
- package/lib/client/runOnSchemaChange.js +3 -0
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
- package/lib/client/sync/bucket/CrudBatch.js +2 -0
- package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
- package/lib/client/sync/bucket/CrudEntry.d.ts +9 -31
- package/lib/client/sync/bucket/CrudEntry.js +2 -97
- package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
- package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
- package/lib/client/sync/options.d.ts +65 -0
- package/lib/client/sync/options.js +25 -0
- package/lib/client/sync/options.js.map +1 -0
- package/lib/client/sync/stream/JsonValue.d.ts +3 -0
- package/lib/client/sync/sync-streams.d.ts +23 -8
- package/lib/client/triggers/TriggerManager.d.ts +28 -56
- package/lib/client/triggers/TriggerManager.js +2 -1
- package/lib/client/triggers/TriggerManager.js.map +1 -1
- package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
- package/lib/client/triggers/sanitizeSQL.js +4 -0
- package/lib/client/triggers/sanitizeSQL.js.map +1 -1
- package/lib/client/watched/GetAllQuery.d.ts +7 -3
- package/lib/client/watched/GetAllQuery.js +3 -1
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +20 -6
- package/lib/client/watched/WatchedQuery.js +3 -5
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +15 -45
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -172
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -22
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/comparators.d.ts +8 -0
- package/lib/client/watched/processors/comparators.js +4 -0
- package/lib/client/watched/processors/comparators.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +90 -113
- package/lib/db/DBAdapter.js +70 -89
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/QueryResult.d.ts +104 -0
- package/lib/db/QueryResult.js +96 -0
- package/lib/db/QueryResult.js.map +1 -0
- package/lib/db/crud/SyncProgress.d.ts +7 -14
- package/lib/db/crud/SyncProgress.js +1 -60
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +54 -91
- package/lib/db/crud/SyncStatus.js +1 -245
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
- package/lib/db/crud/UploadQueueStatus.js +3 -0
- package/lib/db/crud/UploadQueueStatus.js.map +1 -1
- package/lib/db/schema/Column.d.ts +22 -1
- package/lib/db/schema/Column.js +10 -4
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +8 -3
- package/lib/db/schema/Index.js +4 -1
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +8 -3
- package/lib/db/schema/IndexedColumn.js +4 -1
- package/lib/db/schema/IndexedColumn.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +7 -1
- package/lib/db/schema/Schema.d.ts +10 -29
- package/lib/db/schema/Schema.js +3 -1
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +69 -91
- package/lib/db/schema/Table.js +88 -87
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/index.d.ts +6 -22
- package/lib/index.js +5 -22
- package/lib/index.js.map +1 -1
- package/lib/types/types.d.ts +6 -0
- package/lib/utils/BaseObserver.d.ts +12 -0
- package/lib/utils/BaseObserver.js +3 -0
- package/lib/utils/BaseObserver.js.map +1 -1
- package/lib/utils/Logger.d.ts +60 -22
- package/lib/utils/Logger.js +38 -30
- package/lib/utils/Logger.js.map +1 -1
- package/lib/utils/MetaBaseObserver.d.ts +11 -11
- package/lib/utils/MetaBaseObserver.js +1 -50
- package/lib/utils/MetaBaseObserver.js.map +1 -1
- package/lib/utils/mutex.d.ts +3 -45
- package/lib/utils/mutex.js +1 -153
- package/lib/utils/mutex.js.map +1 -1
- package/package.json +9 -46
- package/src/attachments/AttachmentContext.ts +15 -13
- package/src/attachments/AttachmentErrorHandler.ts +6 -6
- package/src/attachments/AttachmentQueue.ts +99 -42
- package/src/attachments/AttachmentService.ts +7 -6
- package/src/attachments/LocalStorageAdapter.ts +14 -8
- package/src/attachments/README.md +2 -0
- package/src/attachments/RemoteStorageAdapter.ts +4 -4
- package/src/attachments/Schema.ts +14 -6
- package/src/attachments/SyncingService.ts +10 -6
- package/src/attachments/WatchedAttachmentItem.ts +3 -1
- package/src/client/CommonPowerSyncDatabase.ts +540 -0
- package/src/client/Query.ts +9 -0
- package/src/client/SQLOpenFactory.ts +47 -19
- package/src/client/compilableQueryWatch.ts +9 -4
- package/src/client/connection/PowerSyncBackendConnector.ts +6 -3
- package/src/client/connection/PowerSyncCredentials.ts +3 -0
- package/src/client/runOnSchemaChange.ts +5 -2
- package/src/client/sync/bucket/CrudBatch.ts +2 -0
- package/src/client/sync/bucket/CrudEntry.ts +10 -101
- package/src/client/sync/bucket/CrudTransaction.ts +3 -0
- package/src/client/sync/options.ts +77 -0
- package/src/client/sync/stream/JsonValue.ts +3 -0
- package/src/client/sync/sync-streams.ts +23 -10
- package/src/client/triggers/TriggerManager.ts +29 -59
- package/src/client/triggers/sanitizeSQL.ts +5 -0
- package/src/client/watched/GetAllQuery.ts +8 -4
- package/src/client/watched/WatchedQuery.ts +20 -11
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +19 -219
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +4 -109
- package/src/client/watched/processors/comparators.ts +8 -0
- package/src/db/DBAdapter.ts +160 -175
- package/src/db/QueryResult.ts +195 -0
- package/src/db/crud/SyncProgress.ts +8 -43
- package/src/db/crud/SyncStatus.ts +66 -216
- package/src/db/crud/UploadQueueStatus.ts +3 -0
- package/src/db/schema/Column.ts +22 -5
- package/src/db/schema/Index.ts +9 -3
- package/src/db/schema/IndexedColumn.ts +9 -3
- package/src/db/schema/RawTable.ts +7 -1
- package/src/db/schema/Schema.ts +12 -7
- package/src/db/schema/Table.ts +130 -180
- package/src/index.ts +6 -22
- package/src/types/types.ts +6 -0
- package/src/utils/BaseObserver.ts +12 -0
- package/src/utils/Logger.ts +86 -31
- package/src/utils/MetaBaseObserver.ts +14 -60
- package/src/utils/mutex.ts +4 -189
- package/dist/bundle.cjs +0 -14136
- package/dist/bundle.cjs.map +0 -1
- package/dist/bundle.mjs +0 -14056
- package/dist/bundle.mjs.map +0 -1
- package/dist/bundle.node.cjs +0 -11613
- package/dist/bundle.node.cjs.map +0 -1
- package/dist/bundle.node.mjs +0 -11533
- package/dist/bundle.node.mjs.map +0 -1
- package/dist/index.d.cts +0 -4052
- package/legacy/sync_protocol.d.ts +0 -103
- package/lib/client/AbstractPowerSyncDatabase.js +0 -987
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -22
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -25
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/ConnectionManager.d.ts +0 -112
- package/lib/client/ConnectionManager.js +0 -294
- package/lib/client/ConnectionManager.js.map +0 -1
- package/lib/client/CustomQuery.d.ts +0 -22
- package/lib/client/CustomQuery.js +0 -43
- package/lib/client/CustomQuery.js.map +0 -1
- package/lib/client/constants.d.ts +0 -1
- package/lib/client/constants.js +0 -2
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -40
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -34
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +0 -151
- package/lib/client/sync/stream/AbstractRemote.js +0 -473
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -218
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -663
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
- package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
- package/lib/client/sync/stream/WebsocketClientTransport.js +0 -61
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
- package/lib/client/sync/stream/core-instruction.d.ts +0 -71
- package/lib/client/sync/stream/core-instruction.js +0 -27
- package/lib/client/sync/stream/core-instruction.js.map +0 -1
- package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
- package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
- package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
- package/lib/client/triggers/TriggerManagerImpl.js +0 -405
- package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
- package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
- package/lib/db/ConnectionClosedError.d.ts +0 -10
- package/lib/db/ConnectionClosedError.js +0 -21
- package/lib/db/ConnectionClosedError.js.map +0 -1
- package/lib/db/schema/TableV2.d.ts +0 -9
- package/lib/db/schema/TableV2.js +0 -9
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/utils/AbortOperation.d.ts +0 -9
- package/lib/utils/AbortOperation.js +0 -19
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/ControlledExecutor.d.ts +0 -25
- package/lib/utils/ControlledExecutor.js +0 -51
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/async.d.ts +0 -14
- package/lib/utils/async.js +0 -46
- package/lib/utils/async.js.map +0 -1
- package/lib/utils/parseQuery.d.ts +0 -6
- package/lib/utils/parseQuery.js +0 -17
- package/lib/utils/parseQuery.js.map +0 -1
- package/lib/utils/queue.d.ts +0 -16
- package/lib/utils/queue.js +0 -42
- package/lib/utils/queue.js.map +0 -1
- package/lib/utils/stream_transform.d.ts +0 -39
- package/lib/utils/stream_transform.js +0 -206
- package/lib/utils/stream_transform.js.map +0 -1
- package/src/client/AbstractPowerSyncDatabase.ts +0 -1362
- package/src/client/AbstractPowerSyncOpenFactory.ts +0 -39
- package/src/client/ConnectionManager.ts +0 -402
- package/src/client/CustomQuery.ts +0 -56
- package/src/client/constants.ts +0 -1
- package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -49
- package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -199
- package/src/client/sync/stream/AbstractRemote.ts +0 -602
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -905
- package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
- package/src/client/sync/stream/core-instruction.ts +0 -98
- package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
- package/src/client/triggers/TriggerManagerImpl.ts +0 -496
- package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
- package/src/db/ConnectionClosedError.ts +0 -23
- package/src/db/schema/TableV2.ts +0 -9
- package/src/utils/AbortOperation.ts +0 -17
- package/src/utils/ControlledExecutor.ts +0 -72
- package/src/utils/async.ts +0 -50
- package/src/utils/parseQuery.ts +0 -25
- package/src/utils/queue.ts +0 -48
- package/src/utils/stream_transform.ts +0 -252
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { ILogger } from 'js-logger';
|
|
2
|
-
import { SyncStatus, SyncStatusOptions } from '../../../db/crud/SyncStatus.js';
|
|
3
|
-
import { BaseListener, BaseObserver, BaseObserverInterface, Disposable } from '../../../utils/BaseObserver.js';
|
|
4
|
-
import { BucketStorageAdapter } from '../bucket/BucketStorageAdapter.js';
|
|
5
|
-
import { AbstractRemote, FetchStrategy } from './AbstractRemote.js';
|
|
6
|
-
import { StreamingSyncRequestParameterType } from './JsonValue.js';
|
|
7
|
-
export declare enum LockType {
|
|
8
|
-
CRUD = "crud",
|
|
9
|
-
SYNC = "sync"
|
|
10
|
-
}
|
|
11
|
-
export declare enum SyncStreamConnectionMethod {
|
|
12
|
-
HTTP = "http",
|
|
13
|
-
WEB_SOCKET = "web-socket"
|
|
14
|
-
}
|
|
15
|
-
export declare enum SyncClientImplementation {
|
|
16
|
-
/**
|
|
17
|
-
* This implementation offloads the sync line decoding and handling into the PowerSync
|
|
18
|
-
* core extension.
|
|
19
|
-
*
|
|
20
|
-
* This is the only option, as an older JavaScript client implementation has been removed from the SDK.
|
|
21
|
-
*
|
|
22
|
-
* ## Compatibility warning
|
|
23
|
-
*
|
|
24
|
-
* The Rust sync client stores sync data in a format that is slightly different than the one used
|
|
25
|
-
* by the old JavaScript client. When adopting the {@link RUST} client on existing databases, the PowerSync SDK will
|
|
26
|
-
* migrate the format automatically.
|
|
27
|
-
*
|
|
28
|
-
* SDK versions supporting both the JavaScript and the Rust client support both formats with the JavaScript client
|
|
29
|
-
* implementaiton. However, downgrading to an SDK version that only supports the JavaScript client would not be
|
|
30
|
-
* possible anymore. Problematic SDK versions have been released before 2025-06-09.
|
|
31
|
-
*/
|
|
32
|
-
RUST = "rust"
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The default {@link SyncClientImplementation} to use, {@link SyncClientImplementation.RUST}.
|
|
36
|
-
*/
|
|
37
|
-
export declare const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.RUST;
|
|
38
|
-
/**
|
|
39
|
-
* Abstract Lock to be implemented by various JS environments
|
|
40
|
-
*/
|
|
41
|
-
export interface LockOptions<T> {
|
|
42
|
-
callback: () => Promise<T>;
|
|
43
|
-
type: LockType;
|
|
44
|
-
signal?: AbortSignal;
|
|
45
|
-
}
|
|
46
|
-
export interface AbstractStreamingSyncImplementationOptions extends RequiredAdditionalConnectionOptions {
|
|
47
|
-
adapter: BucketStorageAdapter;
|
|
48
|
-
subscriptions: SubscribedStream[];
|
|
49
|
-
uploadCrud: () => Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* An identifier for which PowerSync DB this sync implementation is
|
|
52
|
-
* linked to. Most commonly DB name, but not restricted to DB name.
|
|
53
|
-
*/
|
|
54
|
-
identifier?: string;
|
|
55
|
-
logger?: ILogger;
|
|
56
|
-
remote: AbstractRemote;
|
|
57
|
-
}
|
|
58
|
-
export interface StreamingSyncImplementationListener extends BaseListener {
|
|
59
|
-
/**
|
|
60
|
-
* Triggered whenever a status update has been attempted to be made or
|
|
61
|
-
* refreshed.
|
|
62
|
-
*/
|
|
63
|
-
statusUpdated?: ((statusUpdate: SyncStatusOptions) => void) | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* Triggers whenever the status' members have changed in value
|
|
66
|
-
*/
|
|
67
|
-
statusChanged?: ((status: SyncStatus) => void) | undefined;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Configurable options to be used when connecting to the PowerSync
|
|
71
|
-
* backend instance.
|
|
72
|
-
*/
|
|
73
|
-
export type PowerSyncConnectionOptions = Omit<InternalConnectionOptions, 'serializedSchema'>;
|
|
74
|
-
export interface InternalConnectionOptions extends BaseConnectionOptions, AdditionalConnectionOptions {
|
|
75
|
-
}
|
|
76
|
-
/** @internal */
|
|
77
|
-
export interface BaseConnectionOptions {
|
|
78
|
-
/**
|
|
79
|
-
* A set of metadata to be included in service logs.
|
|
80
|
-
*/
|
|
81
|
-
appMetadata?: Record<string, string>;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated The Rust sync client is used unconditionally, so this option can't be configured.
|
|
84
|
-
*/
|
|
85
|
-
clientImplementation?: SyncClientImplementation;
|
|
86
|
-
/**
|
|
87
|
-
* The connection method to use when streaming updates from
|
|
88
|
-
* the PowerSync backend instance.
|
|
89
|
-
* Defaults to a HTTP streaming connection.
|
|
90
|
-
*/
|
|
91
|
-
connectionMethod?: SyncStreamConnectionMethod;
|
|
92
|
-
/**
|
|
93
|
-
* The fetch strategy to use when streaming updates from the PowerSync backend instance.
|
|
94
|
-
*/
|
|
95
|
-
fetchStrategy?: FetchStrategy;
|
|
96
|
-
/**
|
|
97
|
-
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
|
|
98
|
-
*/
|
|
99
|
-
params?: Record<string, StreamingSyncRequestParameterType>;
|
|
100
|
-
/**
|
|
101
|
-
* Whether to include streams that have `auto_subscribe: true` in their definition.
|
|
102
|
-
*
|
|
103
|
-
* This defaults to `true`.
|
|
104
|
-
*/
|
|
105
|
-
includeDefaultStreams?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* The serialized schema - mainly used to forward information about raw tables to the sync client.
|
|
108
|
-
*/
|
|
109
|
-
serializedSchema?: any;
|
|
110
|
-
}
|
|
111
|
-
/** @internal */
|
|
112
|
-
export interface AdditionalConnectionOptions {
|
|
113
|
-
/**
|
|
114
|
-
* Delay for retrying sync streaming operations
|
|
115
|
-
* from the PowerSync backend after an error occurs.
|
|
116
|
-
*/
|
|
117
|
-
retryDelayMs?: number;
|
|
118
|
-
/**
|
|
119
|
-
* Backend Connector CRUD operations are throttled
|
|
120
|
-
* to occur at most every `crudUploadThrottleMs`
|
|
121
|
-
* milliseconds.
|
|
122
|
-
*/
|
|
123
|
-
crudUploadThrottleMs?: number;
|
|
124
|
-
}
|
|
125
|
-
/** @internal */
|
|
126
|
-
export interface RequiredAdditionalConnectionOptions extends Required<AdditionalConnectionOptions> {
|
|
127
|
-
subscriptions: SubscribedStream[];
|
|
128
|
-
}
|
|
129
|
-
export interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyncImplementationListener>, Disposable {
|
|
130
|
-
/**
|
|
131
|
-
* Connects to the sync service
|
|
132
|
-
*/
|
|
133
|
-
connect(options?: InternalConnectionOptions): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Disconnects from the sync services.
|
|
136
|
-
* @throws if not connected or if abort is not controlled internally
|
|
137
|
-
*/
|
|
138
|
-
disconnect(): Promise<void>;
|
|
139
|
-
getWriteCheckpoint: () => Promise<string>;
|
|
140
|
-
isConnected: boolean;
|
|
141
|
-
syncStatus: SyncStatus;
|
|
142
|
-
triggerCrudUpload: () => void;
|
|
143
|
-
waitForReady(): Promise<void>;
|
|
144
|
-
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
145
|
-
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
146
|
-
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
147
|
-
markConnectionMayHaveChanged(): void;
|
|
148
|
-
}
|
|
149
|
-
export declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
|
|
150
|
-
export declare const DEFAULT_RETRY_DELAY_MS = 5000;
|
|
151
|
-
export declare const DEFAULT_STREAMING_SYNC_OPTIONS: {
|
|
152
|
-
retryDelayMs: number;
|
|
153
|
-
crudUploadThrottleMs: number;
|
|
154
|
-
};
|
|
155
|
-
export type RequiredPowerSyncConnectionOptions = Required<BaseConnectionOptions>;
|
|
156
|
-
export declare const DEFAULT_STREAM_CONNECTION_OPTIONS: RequiredPowerSyncConnectionOptions;
|
|
157
|
-
export type SubscribedStream = {
|
|
158
|
-
name: string;
|
|
159
|
-
params: Record<string, any> | null;
|
|
160
|
-
};
|
|
161
|
-
export declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener> implements StreamingSyncImplementation {
|
|
162
|
-
protected options: AbstractStreamingSyncImplementationOptions;
|
|
163
|
-
protected abortController: AbortController | null;
|
|
164
|
-
protected uploadAbortController: AbortController | undefined;
|
|
165
|
-
protected crudUpdateListener?: () => void;
|
|
166
|
-
protected streamingSyncPromise?: Promise<void>;
|
|
167
|
-
protected logger: ILogger;
|
|
168
|
-
private activeStreams;
|
|
169
|
-
private connectionMayHaveChanged;
|
|
170
|
-
private isUploadingCrud;
|
|
171
|
-
private notifyCompletedUploads?;
|
|
172
|
-
private handleActiveStreamsChange?;
|
|
173
|
-
syncStatus: SyncStatus;
|
|
174
|
-
triggerCrudUpload: () => void;
|
|
175
|
-
constructor(options: AbstractStreamingSyncImplementationOptions);
|
|
176
|
-
waitForReady(): Promise<void>;
|
|
177
|
-
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
178
|
-
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
179
|
-
get lastSyncedAt(): Date | undefined;
|
|
180
|
-
get isConnected(): boolean;
|
|
181
|
-
dispose(): Promise<void>;
|
|
182
|
-
abstract obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
|
|
183
|
-
getWriteCheckpoint(): Promise<string>;
|
|
184
|
-
protected _uploadAllCrud(): Promise<void>;
|
|
185
|
-
connect(options?: PowerSyncConnectionOptions): Promise<void>;
|
|
186
|
-
disconnect(): Promise<void>;
|
|
187
|
-
/**
|
|
188
|
-
* @deprecated use [connect instead]
|
|
189
|
-
*/
|
|
190
|
-
streamingSync(signal?: AbortSignal, options?: PowerSyncConnectionOptions): Promise<void>;
|
|
191
|
-
markConnectionMayHaveChanged(): void;
|
|
192
|
-
/**
|
|
193
|
-
* Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
|
|
194
|
-
* Because subkeys are always strings, this leads to quotes being added around them in `ps_oplog`.
|
|
195
|
-
* While this is not a problem as long as it's done consistently, it causes issues when a database
|
|
196
|
-
* created by the JS SDK is used with other SDKs, or (more likely) when the new Rust sync client
|
|
197
|
-
* is enabled.
|
|
198
|
-
*
|
|
199
|
-
* So, we add a migration from the old key format (with quotes) to the new one (no quotes). The
|
|
200
|
-
* migration is only triggered when necessary (for now). The function returns whether the new format
|
|
201
|
-
* should be used, so that the JS SDK is able to write to updated databases.
|
|
202
|
-
*
|
|
203
|
-
* @param requireFixedKeyFormat Whether we require the new format or also support the old one.
|
|
204
|
-
* The Rust client requires the new subkey format.
|
|
205
|
-
* @returns Whether the database is now using the new, fixed subkey format.
|
|
206
|
-
*/
|
|
207
|
-
private requireKeyFormat;
|
|
208
|
-
protected streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<RustIterationResult | null>;
|
|
209
|
-
private receiveSyncLines;
|
|
210
|
-
private rustSyncIteration;
|
|
211
|
-
protected updateSyncStatus(options: SyncStatusOptions): void;
|
|
212
|
-
private delayRetry;
|
|
213
|
-
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
214
|
-
}
|
|
215
|
-
interface RustIterationResult {
|
|
216
|
-
immediateRestart: boolean;
|
|
217
|
-
}
|
|
218
|
-
export {};
|