@powersync/common 0.0.0-dev-20260503073249 → 0.0.0-dev-20260630141119
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 +10 -0
- package/lib/client/sync/stream/JsonValue.js +2 -0
- package/lib/client/sync/stream/JsonValue.js.map +1 -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 +7 -27
- package/lib/index.js +6 -27
- 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 +8 -42
- 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 +11 -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 +7 -27
- 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 -14781
- package/dist/bundle.cjs.map +0 -1
- package/dist/bundle.mjs +0 -14689
- package/dist/bundle.mjs.map +0 -1
- package/dist/bundle.node.cjs +0 -12258
- package/dist/bundle.node.cjs.map +0 -1
- package/dist/bundle.node.mjs +0 -12166
- package/dist/bundle.node.mjs.map +0 -1
- package/dist/index.d.cts +0 -4391
- 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 -102
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/OpType.d.ts +0 -16
- package/lib/client/sync/bucket/OpType.js +0 -23
- package/lib/client/sync/bucket/OpType.js.map +0 -1
- package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
- package/lib/client/sync/bucket/OplogEntry.js +0 -36
- package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -61
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -324
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
- package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
- package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +0 -161
- package/lib/client/sync/stream/AbstractRemote.js +0 -483
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -244
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -990
- 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 -72
- package/lib/client/sync/stream/core-instruction.js +0 -27
- package/lib/client/sync/stream/core-instruction.js.map +0 -1
- package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
- package/lib/client/sync/stream/streaming-sync-types.js +0 -26
- package/lib/client/sync/stream/streaming-sync-types.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 -118
- package/src/client/sync/bucket/OpType.ts +0 -23
- package/src/client/sync/bucket/OplogEntry.ts +0 -50
- package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -395
- package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
- package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
- package/src/client/sync/stream/AbstractRemote.ts +0 -624
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -1285
- package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
- package/src/client/sync/stream/core-instruction.ts +0 -99
- package/src/client/sync/stream/streaming-sync-types.ts +0 -210
- 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,4 +1,7 @@
|
|
|
1
1
|
import { DBAdapter } from '../db/DBAdapter.js';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export interface SQLOpenOptions {
|
|
3
6
|
/**
|
|
4
7
|
* Filename for the database.
|
|
@@ -22,6 +25,9 @@ export interface SQLOpenOptions {
|
|
|
22
25
|
*/
|
|
23
26
|
debugMode?: boolean;
|
|
24
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
25
31
|
export interface SQLOpenFactory {
|
|
26
32
|
/**
|
|
27
33
|
* Opens a connection adapter to a SQLite DB
|
|
@@ -29,14 +35,42 @@ export interface SQLOpenFactory {
|
|
|
29
35
|
openDB(): DBAdapter;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
|
-
*
|
|
38
|
+
* A source describing how to open databases.
|
|
39
|
+
*
|
|
40
|
+
* - A {@link DBAdapter} providing access to an opened SQLite connection pool.
|
|
41
|
+
* - A {@link SQLOpenFactory} which will be used to open a SQLite connection pool lazily.
|
|
42
|
+
* - A {@link SQLOpenOptions} for opening a SQLite connection with a default {@link SQLOpenFactory} for the current
|
|
43
|
+
* platform.
|
|
44
|
+
*
|
|
45
|
+
* For most apps, using the `database` key with {@link SQLOpenOptions} is the easiest and recommended option.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
33
48
|
*/
|
|
34
|
-
export
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
export type DatabaseSource<OpenOptions extends SQLOpenOptions = SQLOpenOptions> = {
|
|
50
|
+
/**
|
|
51
|
+
* Wrap an opened {@link DBAdapter} as a PowerSync database instance.
|
|
52
|
+
*
|
|
53
|
+
* This is primarily useful for testing. On most platforms, PowerSync would open a pool of SQLite connections by
|
|
54
|
+
* default. This option allows using a single in-memory instance instead. It can also be used to customize the
|
|
55
|
+
* database used by default, e.g. to install additional logging on SQL statements by intercepting methods.
|
|
56
|
+
*/
|
|
57
|
+
opened: DBAdapter;
|
|
58
|
+
} | {
|
|
59
|
+
/**
|
|
60
|
+
* Construct a PowerSync database that will call {@link SQLOpenFactory.openDB} when opened.
|
|
61
|
+
*
|
|
62
|
+
* On most SDKs, passing {@link SQLOpenOptions} is a better option. An exception is React Native, where using an
|
|
63
|
+
* [OP-SQLite factory](https://docs.powersync.com/client-sdks/reference/react-native-and-expo#op-sqlite) is
|
|
64
|
+
* recommended.
|
|
65
|
+
*/
|
|
66
|
+
factory: SQLOpenFactory;
|
|
67
|
+
} | {
|
|
68
|
+
/**
|
|
69
|
+
* Construct a PowerSync database opening a connection pool from the {@link SQLOpenOptions}.
|
|
70
|
+
*
|
|
71
|
+
* At the very least, options include the {@link SQLOpenOptions.dbFilename} to open. Depending on the PowerSync
|
|
72
|
+
* SDK used, additional options are available. For example, the web SDK allows configuring the virtual file system
|
|
73
|
+
* implementation used to persist files on the web too.
|
|
74
|
+
*/
|
|
75
|
+
database: OpenOptions;
|
|
76
|
+
};
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Tests if the input is a {@link SQLOpenOptions}
|
|
3
|
-
*/
|
|
4
|
-
export const isSQLOpenOptions = (test) => {
|
|
5
|
-
// typeof null is `object`, but you cannot use the `in` operator on `null.
|
|
6
|
-
return test && typeof test == 'object' && 'dbFilename' in test;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Tests if input is a {@link SQLOpenFactory}
|
|
10
|
-
*/
|
|
11
|
-
export const isSQLOpenFactory = (test) => {
|
|
12
|
-
return typeof test?.openDB == 'function';
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Tests if input is a {@link DBAdapter}
|
|
16
|
-
*/
|
|
17
|
-
export const isDBAdapter = (test) => {
|
|
18
|
-
return typeof test?.writeTransaction == 'function';
|
|
19
|
-
};
|
|
1
|
+
export {};
|
|
20
2
|
//# sourceMappingURL=SQLOpenFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLOpenFactory.js","sourceRoot":"","sources":["../../src/client/SQLOpenFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SQLOpenFactory.js","sourceRoot":"","sources":["../../src/client/SQLOpenFactory.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { CompilableQuery } from './../types/types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CommonPowerSyncDatabase, SQLWatchOptions } from './CommonPowerSyncDatabase.js';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
3
6
|
export interface CompilableQueryWatchHandler<T> {
|
|
4
7
|
onResult: (results: T[]) => void;
|
|
5
8
|
onError?: (error: Error) => void;
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function compilableQueryWatch<T>(db: CommonPowerSyncDatabase, query: CompilableQuery<T>, handler: CompilableQueryWatchHandler<T>, options?: SQLWatchOptions): void;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { runOnSchemaChange } from './runOnSchemaChange.js';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export function compilableQueryWatch(db, query, handler, options) {
|
|
3
6
|
const { onResult, onError = (e) => { } } = handler ?? {};
|
|
4
7
|
if (!onResult) {
|
|
@@ -20,8 +23,7 @@ export function compilableQueryWatch(db, query, handler, options) {
|
|
|
20
23
|
catch (error) {
|
|
21
24
|
onError(error);
|
|
22
25
|
}
|
|
23
|
-
}
|
|
24
|
-
onError
|
|
26
|
+
}
|
|
25
27
|
}, {
|
|
26
28
|
...(options ?? {}),
|
|
27
29
|
tables: resolvedTables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilableQueryWatch.js","sourceRoot":"","sources":["../../src/client/compilableQueryWatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"compilableQueryWatch.js","sourceRoot":"","sources":["../../src/client/compilableQueryWatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAU3D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,EAA2B,EAC3B,KAAyB,EACzB,OAAuC,EACvC,OAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,CAAQ,EAAE,EAAE,GAAE,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,EAAE,WAAwB,EAAE,EAAE;QACpD,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,UAAgB,EAAE,OAAO,CAAC,CAAC;YAE1F,qBAAqB;YACrB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;YACrC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAEjB,EAAE,CAAC,oBAAoB,CACrB;gBACE,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,IAAI,CAAC;wBACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;wBACrC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBACnB,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACpB,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC;gBACH,CAAC;aACF,EACD;gBACE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;gBAClB,MAAM,EAAE,cAAc;gBACtB,kDAAkD;gBAClD,MAAM,EAAE,WAAW;aACpB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;IAEF,iBAAiB,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { PowerSyncCredentials } from './PowerSyncCredentials.js';
|
|
2
|
-
import
|
|
2
|
+
import { CommonPowerSyncDatabase } from '../CommonPowerSyncDatabase.js';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
3
6
|
export interface PowerSyncBackendConnector {
|
|
4
7
|
/** Allows the PowerSync client to retrieve an authentication token from your backend
|
|
5
8
|
* which is used to authenticate against the PowerSync service.
|
|
@@ -15,9 +18,9 @@ export interface PowerSyncBackendConnector {
|
|
|
15
18
|
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
16
19
|
/** Upload local changes to the app backend.
|
|
17
20
|
*
|
|
18
|
-
* Use {@link
|
|
21
|
+
* Use {@link CommonPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
|
|
19
22
|
*
|
|
20
23
|
* Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
|
|
21
24
|
*/
|
|
22
|
-
uploadData: (database:
|
|
25
|
+
uploadData: (database: CommonPowerSyncDatabase) => Promise<void>;
|
|
23
26
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CommonPowerSyncDatabase, SQLWatchOptions } from './CommonPowerSyncDatabase.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function runOnSchemaChange(callback: (signal: AbortSignal) => void, db: CommonPowerSyncDatabase, options?: SQLWatchOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runOnSchemaChange.js","sourceRoot":"","sources":["../../src/client/runOnSchemaChange.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAC/B,QAAuC,EACvC,
|
|
1
|
+
{"version":3,"file":"runOnSchemaChange.js","sourceRoot":"","sources":["../../src/client/runOnSchemaChange.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAuC,EACvC,EAA2B,EAC3B,OAAyB;IAEzB,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,IAAI,qBAAqB,GAAwB,IAAI,CAAC;QACtD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACzC,qBAAqB,EAAE,EAAE,CAAC;YAC1B,qBAAqB,GAAG,IAAI,CAAC;YAC7B,kDAAkD;YAClD,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC9D,CAAC,CAAC;QAEF,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,qBAAqB,GAAG,EAAE,CAAC,gBAAgB,CAAC;YAC1C,aAAa,EAAE,KAAK,IAAI,EAAE;gBACxB,YAAY,EAAE,CAAC;gBACf,yIAAyI;gBACzI,UAAU,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;SACF,CAAC,CAAC;QACH,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,mBAAmB,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudBatch.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"CrudBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudBatch.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAKX;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAiB;IACxB;;OAEG;IACI,QAAqD;QARrD,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAS;QAIjB,aAAQ,GAAR,QAAQ,CAA6C;IAC3D,CAAC;CACL"}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* 64-bit unsigned integer stored as a string in base-10.
|
|
3
3
|
*
|
|
4
4
|
* Not sortable as a string.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
5
7
|
*/
|
|
6
8
|
export type OpId = string;
|
|
7
9
|
/**
|
|
8
10
|
* Type of local change.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
9
13
|
*/
|
|
10
14
|
export declare enum UpdateType {
|
|
11
15
|
/** Insert or replace existing row. All non-null columns are included in the data. Generated by INSERT statements. */
|
|
@@ -15,28 +19,12 @@ export declare enum UpdateType {
|
|
|
15
19
|
/** Delete existing row. Contains the id. Generated by DELETE statements. */
|
|
16
20
|
DELETE = "DELETE"
|
|
17
21
|
}
|
|
18
|
-
export type CrudEntryJSON = {
|
|
19
|
-
id: string;
|
|
20
|
-
data: string;
|
|
21
|
-
tx_id?: number;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* The output JSON seems to be a third type of JSON, not the same as the input JSON.
|
|
25
|
-
*/
|
|
26
|
-
type CrudEntryOutputJSON = {
|
|
27
|
-
op_id: number;
|
|
28
|
-
op: UpdateType;
|
|
29
|
-
type: string;
|
|
30
|
-
id: string;
|
|
31
|
-
tx_id?: number;
|
|
32
|
-
data?: Record<string, any>;
|
|
33
|
-
old?: Record<string, any>;
|
|
34
|
-
metadata?: string;
|
|
35
|
-
};
|
|
36
22
|
/**
|
|
37
23
|
* A single client-side change.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
38
26
|
*/
|
|
39
|
-
export
|
|
27
|
+
export interface CrudEntry {
|
|
40
28
|
/**
|
|
41
29
|
* Auto-incrementing client-side id.
|
|
42
30
|
*/
|
|
@@ -73,23 +61,13 @@ export declare class CrudEntry {
|
|
|
73
61
|
* and the insert or update statement set the `_metadata` column.
|
|
74
62
|
*/
|
|
75
63
|
metadata?: string;
|
|
76
|
-
static fromRow(dbRow: CrudEntryJSON): CrudEntry;
|
|
77
|
-
constructor(clientId: number, op: UpdateType, table: string, id: string, transactionId?: number, opData?: Record<string, any>, previousValues?: Record<string, any>, metadata?: string);
|
|
78
64
|
/**
|
|
79
65
|
* Converts the change to JSON format.
|
|
80
66
|
*/
|
|
81
|
-
toJSON():
|
|
67
|
+
toJSON(): unknown;
|
|
82
68
|
equals(entry: CrudEntry): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* The hash code for this object.
|
|
85
|
-
* @deprecated This should not be necessary in the JS SDK.
|
|
86
|
-
* Use the @see CrudEntry#equals method instead.
|
|
87
|
-
* TODO remove in the next major release.
|
|
88
|
-
*/
|
|
89
|
-
hashCode(): string;
|
|
90
69
|
/**
|
|
91
70
|
* Generates an array for use in deep comparison operations
|
|
92
71
|
*/
|
|
93
|
-
toComparisonArray():
|
|
72
|
+
toComparisonArray(): unknown[];
|
|
94
73
|
}
|
|
95
|
-
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type of local change.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
3
5
|
*/
|
|
4
6
|
export var UpdateType;
|
|
5
7
|
(function (UpdateType) {
|
|
@@ -10,101 +12,4 @@ export var UpdateType;
|
|
|
10
12
|
/** Delete existing row. Contains the id. Generated by DELETE statements. */
|
|
11
13
|
UpdateType["DELETE"] = "DELETE";
|
|
12
14
|
})(UpdateType || (UpdateType = {}));
|
|
13
|
-
/**
|
|
14
|
-
* A single client-side change.
|
|
15
|
-
*/
|
|
16
|
-
export class CrudEntry {
|
|
17
|
-
/**
|
|
18
|
-
* Auto-incrementing client-side id.
|
|
19
|
-
*/
|
|
20
|
-
clientId;
|
|
21
|
-
/**
|
|
22
|
-
* ID of the changed row.
|
|
23
|
-
*/
|
|
24
|
-
id;
|
|
25
|
-
/**
|
|
26
|
-
* Type of change.
|
|
27
|
-
*/
|
|
28
|
-
op;
|
|
29
|
-
/**
|
|
30
|
-
* Data associated with the change.
|
|
31
|
-
*/
|
|
32
|
-
opData;
|
|
33
|
-
/**
|
|
34
|
-
* For tables where the `trackPreviousValues` option has been enabled, this tracks previous values for
|
|
35
|
-
* `UPDATE` and `DELETE` statements.
|
|
36
|
-
*/
|
|
37
|
-
previousValues;
|
|
38
|
-
/**
|
|
39
|
-
* Table that contained the change.
|
|
40
|
-
*/
|
|
41
|
-
table;
|
|
42
|
-
/**
|
|
43
|
-
* Auto-incrementing transaction id. This is the same for all operations within the same transaction.
|
|
44
|
-
*/
|
|
45
|
-
transactionId;
|
|
46
|
-
/**
|
|
47
|
-
* Client-side metadata attached with this write.
|
|
48
|
-
*
|
|
49
|
-
* This field is only available when the `trackMetadata` option was set to `true` when creating a table
|
|
50
|
-
* and the insert or update statement set the `_metadata` column.
|
|
51
|
-
*/
|
|
52
|
-
metadata;
|
|
53
|
-
static fromRow(dbRow) {
|
|
54
|
-
const data = JSON.parse(dbRow.data);
|
|
55
|
-
return new CrudEntry(parseInt(dbRow.id), data.op, data.type, data.id, dbRow.tx_id, data.data, data.old, data.metadata);
|
|
56
|
-
}
|
|
57
|
-
constructor(clientId, op, table, id, transactionId, opData, previousValues, metadata) {
|
|
58
|
-
this.clientId = clientId;
|
|
59
|
-
this.id = id;
|
|
60
|
-
this.op = op;
|
|
61
|
-
this.opData = opData;
|
|
62
|
-
this.table = table;
|
|
63
|
-
this.transactionId = transactionId;
|
|
64
|
-
this.previousValues = previousValues;
|
|
65
|
-
this.metadata = metadata;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Converts the change to JSON format.
|
|
69
|
-
*/
|
|
70
|
-
toJSON() {
|
|
71
|
-
return {
|
|
72
|
-
op_id: this.clientId,
|
|
73
|
-
op: this.op,
|
|
74
|
-
type: this.table,
|
|
75
|
-
id: this.id,
|
|
76
|
-
tx_id: this.transactionId,
|
|
77
|
-
data: this.opData,
|
|
78
|
-
old: this.previousValues,
|
|
79
|
-
metadata: this.metadata
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
equals(entry) {
|
|
83
|
-
return JSON.stringify(this.toComparisonArray()) == JSON.stringify(entry.toComparisonArray());
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The hash code for this object.
|
|
87
|
-
* @deprecated This should not be necessary in the JS SDK.
|
|
88
|
-
* Use the @see CrudEntry#equals method instead.
|
|
89
|
-
* TODO remove in the next major release.
|
|
90
|
-
*/
|
|
91
|
-
hashCode() {
|
|
92
|
-
return JSON.stringify(this.toComparisonArray());
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Generates an array for use in deep comparison operations
|
|
96
|
-
*/
|
|
97
|
-
toComparisonArray() {
|
|
98
|
-
return [
|
|
99
|
-
this.transactionId,
|
|
100
|
-
this.clientId,
|
|
101
|
-
this.op,
|
|
102
|
-
this.table,
|
|
103
|
-
this.id,
|
|
104
|
-
this.opData,
|
|
105
|
-
this.previousValues,
|
|
106
|
-
this.metadata
|
|
107
|
-
];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
15
|
//# sourceMappingURL=CrudEntry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,qHAAqH;IACrH,yBAAW,CAAA;IACX,8GAA8G;IAC9G,6BAAe,CAAA;IACf,4EAA4E;IAC5E,+BAAiB,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudTransaction.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAKnC;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAgD;IACvD;;OAEG;IACI,aAAsB;QAE7B,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAVtB,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAwC;QAIhD,kBAAa,GAAb,aAAa,CAAS;IAG/B,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"CrudTransaction.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAKnC;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAgD;IACvD;;OAEG;IACI,aAAsB;QAE7B,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAVtB,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAwC;QAIhD,kBAAa,GAAb,aAAa,CAAS;IAG/B,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { StreamingSyncRequestParameterType } from './stream/JsonValue.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options that affect how the PowerSync SDK connects to the PowerSync Service.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface SyncOptions {
|
|
8
|
+
/**
|
|
9
|
+
* A set of metadata to be included in service logs.
|
|
10
|
+
*/
|
|
11
|
+
appMetadata?: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
|
|
14
|
+
*/
|
|
15
|
+
params?: Record<string, StreamingSyncRequestParameterType>;
|
|
16
|
+
/**
|
|
17
|
+
* The connection method to use when streaming updates from
|
|
18
|
+
* the PowerSync backend instance.
|
|
19
|
+
*
|
|
20
|
+
* The default value is SDK-specific. {@link SyncStreamConnectionMethod.HTTP} is the preferred implementation and used
|
|
21
|
+
* by default, except for React Native apps without Expo. Those don't support streaming HTTP responses, which is why
|
|
22
|
+
* {@link SyncStreamConnectionMethod.WEB_SOCKET} is used as a workaround.
|
|
23
|
+
*/
|
|
24
|
+
connectionMethod?: SyncStreamConnectionMethod;
|
|
25
|
+
fetchStrategy?: FetchStrategy;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to include streams that have `auto_subscribe: true` in their definition.
|
|
28
|
+
*
|
|
29
|
+
* This defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
includeDefaultStreams?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Delay for retrying sync streaming operations
|
|
34
|
+
* from the PowerSync backend after an error occurs.
|
|
35
|
+
*/
|
|
36
|
+
retryDelayMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Backend Connector CRUD operations are throttled
|
|
39
|
+
* to occur at most every `crudUploadThrottleMs`
|
|
40
|
+
* milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
crudUploadThrottleMs?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare enum SyncStreamConnectionMethod {
|
|
48
|
+
HTTP = "http",
|
|
49
|
+
WEB_SOCKET = "web-socket"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare enum FetchStrategy {
|
|
55
|
+
/**
|
|
56
|
+
* Queues multiple sync events before processing, reducing round-trips.
|
|
57
|
+
* This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
|
|
58
|
+
*/
|
|
59
|
+
Buffered = "buffered",
|
|
60
|
+
/**
|
|
61
|
+
* Processes each sync event immediately before requesting the next.
|
|
62
|
+
* This reduces processing overhead and improves real-time responsiveness.
|
|
63
|
+
*/
|
|
64
|
+
Sequential = "sequential"
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export var SyncStreamConnectionMethod;
|
|
5
|
+
(function (SyncStreamConnectionMethod) {
|
|
6
|
+
SyncStreamConnectionMethod["HTTP"] = "http";
|
|
7
|
+
SyncStreamConnectionMethod["WEB_SOCKET"] = "web-socket";
|
|
8
|
+
})(SyncStreamConnectionMethod || (SyncStreamConnectionMethod = {}));
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export var FetchStrategy;
|
|
13
|
+
(function (FetchStrategy) {
|
|
14
|
+
/**
|
|
15
|
+
* Queues multiple sync events before processing, reducing round-trips.
|
|
16
|
+
* This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
|
|
17
|
+
*/
|
|
18
|
+
FetchStrategy["Buffered"] = "buffered";
|
|
19
|
+
/**
|
|
20
|
+
* Processes each sync event immediately before requesting the next.
|
|
21
|
+
* This reduces processing overhead and improves real-time responsiveness.
|
|
22
|
+
*/
|
|
23
|
+
FetchStrategy["Sequential"] = "sequential";
|
|
24
|
+
})(FetchStrategy || (FetchStrategy = {}));
|
|
25
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/client/sync/options.ts"],"names":[],"mappings":"AAqDA;;GAEG;AACH,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,2CAAa,CAAA;IACb,uDAAyB,CAAA;AAC3B,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB;;;OAGG;IACH,sCAAqB,CAAA;IAErB;;;OAGG;IACH,0CAAyB,CAAA;AAC3B,CAAC,EAZW,aAAa,KAAb,aAAa,QAYxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray;
|
|
2
|
+
interface JSONObject {
|
|
3
|
+
[key: string]: JSONValue;
|
|
4
|
+
}
|
|
5
|
+
type JSONArray = JSONValue[];
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type StreamingSyncRequestParameterType = JSONValue;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonValue.js","sourceRoot":"","sources":["../../../../src/client/sync/stream/JsonValue.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A description of a sync stream, consisting of its {@link name} and the
|
|
2
|
+
* A description of a sync stream, consisting of its {@link SyncStreamDescription.name} and the
|
|
3
|
+
* {@link SyncStreamDescription.parameters} used when subscribing.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
3
6
|
*/
|
|
4
7
|
export interface SyncStreamDescription {
|
|
5
8
|
/**
|
|
@@ -17,6 +20,8 @@ export interface SyncStreamDescription {
|
|
|
17
20
|
* Information about a subscribed sync stream.
|
|
18
21
|
*
|
|
19
22
|
* This includes the {@link SyncStreamDescription}, along with information about the current sync status.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
20
25
|
*/
|
|
21
26
|
export interface SyncSubscriptionDescription extends SyncStreamDescription {
|
|
22
27
|
active: boolean;
|
|
@@ -24,15 +29,17 @@ export interface SyncSubscriptionDescription extends SyncStreamDescription {
|
|
|
24
29
|
* Whether this stream subscription is included by default, regardless of whether the stream has explicitly been
|
|
25
30
|
* subscribed to or not.
|
|
26
31
|
*
|
|
27
|
-
* It's possible for both {@link isDefault} and
|
|
28
|
-
*
|
|
32
|
+
* It's possible for both {@link SyncSubscriptionDescription.isDefault} and
|
|
33
|
+
* {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
|
|
34
|
+
* default stream was subscribed explicitly.
|
|
29
35
|
*/
|
|
30
36
|
isDefault: boolean;
|
|
31
37
|
/**
|
|
32
38
|
* Whether this stream has been subscribed to explicitly.
|
|
33
39
|
*
|
|
34
|
-
* It's possible for both {@link isDefault} and
|
|
35
|
-
*
|
|
40
|
+
* It's possible for both {@link SyncSubscriptionDescription.isDefault} and
|
|
41
|
+
* {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
|
|
42
|
+
* default stream was subscribed explicitly.
|
|
36
43
|
*/
|
|
37
44
|
hasExplicitSubscription: boolean;
|
|
38
45
|
/**
|
|
@@ -45,10 +52,13 @@ export interface SyncSubscriptionDescription extends SyncStreamDescription {
|
|
|
45
52
|
*/
|
|
46
53
|
hasSynced: boolean;
|
|
47
54
|
/**
|
|
48
|
-
* If {@link hasSynced} is true, the last time data from this stream has been synced.
|
|
55
|
+
* If {@link SyncSubscriptionDescription.hasSynced} is true, the last time data from this stream has been synced.
|
|
49
56
|
*/
|
|
50
57
|
lastSyncedAt: Date | null;
|
|
51
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
52
62
|
export interface SyncStreamSubscribeOptions {
|
|
53
63
|
/**
|
|
54
64
|
* A "time to live" for this stream subscription, in seconds.
|
|
@@ -67,7 +77,9 @@ export interface SyncStreamSubscribeOptions {
|
|
|
67
77
|
/**
|
|
68
78
|
* A handle to a {@link SyncStreamDescription} that allows subscribing to the stream.
|
|
69
79
|
*
|
|
70
|
-
* To obtain an instance of {@link SyncStream}, call {@link
|
|
80
|
+
* To obtain an instance of {@link SyncStream}, call {@link CommonPowerSyncDatabase.syncStream}.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
71
83
|
*/
|
|
72
84
|
export interface SyncStream extends SyncStreamDescription {
|
|
73
85
|
/**
|
|
@@ -76,7 +88,7 @@ export interface SyncStream extends SyncStreamDescription {
|
|
|
76
88
|
* You should keep a reference to the returned {@link SyncStreamSubscription} object along as you need data for that
|
|
77
89
|
* stream. As soon as {@link SyncStreamSubscription.unsubscribe} is called for all subscriptions on this stream
|
|
78
90
|
* (including subscriptions created on other tabs), the {@link SyncStreamSubscribeOptions.ttl} starts ticking and will
|
|
79
|
-
* eventually evict the stream (unless {@link subscribe} is called again).
|
|
91
|
+
* eventually evict the stream (unless {@link SyncStream.subscribe} is called again).
|
|
80
92
|
*/
|
|
81
93
|
subscribe(options?: SyncStreamSubscribeOptions): Promise<SyncStreamSubscription>;
|
|
82
94
|
/**
|
|
@@ -86,6 +98,9 @@ export interface SyncStream extends SyncStreamDescription {
|
|
|
86
98
|
*/
|
|
87
99
|
unsubscribeAll(): Promise<void>;
|
|
88
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
89
104
|
export interface SyncStreamSubscription extends SyncStreamDescription {
|
|
90
105
|
/**
|
|
91
106
|
* A promise that resolves once data from in this sync stream has been synced and applied.
|