@powersync/common 1.53.2 → 1.55.0
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/bundle.cjs +922 -772
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +922 -772
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +923 -619
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +923 -619
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +749 -205
- package/lib/attachments/AttachmentContext.d.ts +7 -6
- package/lib/attachments/AttachmentContext.js +2 -1
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.d.ts +82 -33
- package/lib/attachments/AttachmentQueue.js +16 -18
- package/lib/attachments/AttachmentQueue.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 +12 -4
- package/lib/attachments/Schema.js +8 -3
- package/lib/attachments/Schema.js.map +1 -1
- package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
- package/lib/client/AbstractPowerSyncDatabase.d.ts +110 -60
- package/lib/client/AbstractPowerSyncDatabase.js +77 -74
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +6 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js +3 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +1 -1
- package/lib/client/ConnectionManager.d.ts +4 -1
- package/lib/client/ConnectionManager.js +1 -1
- package/lib/client/ConnectionManager.js.map +1 -1
- package/lib/client/Query.d.ts +9 -0
- package/lib/client/SQLOpenFactory.d.ts +12 -0
- package/lib/client/SQLOpenFactory.js +6 -0
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +6 -0
- package/lib/client/compilableQueryWatch.js +3 -0
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -0
- package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
- package/lib/client/constants.d.ts +3 -0
- package/lib/client/constants.js +3 -0
- package/lib/client/constants.js.map +1 -1
- package/lib/client/runOnSchemaChange.d.ts +3 -0
- package/lib/client/runOnSchemaChange.js +3 -0
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +12 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js +6 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.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 -0
- package/lib/client/sync/bucket/CrudEntry.js +4 -0
- 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/bucket/SqliteBucketStorage.d.ts +3 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js +3 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +30 -1
- package/lib/client/sync/stream/AbstractRemote.js +59 -27
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +55 -5
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +32 -4
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/JsonValue.d.ts +3 -0
- package/lib/client/sync/stream/WebsocketClientTransport.js +2 -1
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +1 -1
- package/lib/client/sync/sync-streams.d.ts +22 -7
- package/lib/client/triggers/TriggerManager.d.ts +19 -18
- package/lib/client/triggers/TriggerManager.js +2 -1
- package/lib/client/triggers/TriggerManager.js.map +1 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +1 -1
- package/lib/client/triggers/TriggerManagerImpl.js +3 -3
- package/lib/client/triggers/TriggerManagerImpl.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 +4 -0
- package/lib/client/watched/GetAllQuery.js +2 -0
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +24 -2
- package/lib/client/watched/WatchedQuery.js +9 -0
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +1 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +20 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +4 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -0
- 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/ConnectionClosedError.d.ts +2 -0
- package/lib/db/ConnectionClosedError.js +2 -0
- package/lib/db/ConnectionClosedError.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +56 -6
- package/lib/db/DBAdapter.js +15 -3
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/crud/SyncProgress.d.ts +6 -1
- package/lib/db/crud/SyncProgress.js +2 -0
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +36 -38
- package/lib/db/crud/SyncStatus.js +19 -14
- 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 +28 -0
- package/lib/db/schema/Column.js +16 -3
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +9 -0
- package/lib/db/schema/Index.js +6 -0
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +9 -0
- package/lib/db/schema/IndexedColumn.js +6 -0
- 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 +6 -1
- package/lib/db/schema/Schema.js +3 -1
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +27 -3
- package/lib/db/schema/Table.js +9 -0
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/db/schema/TableV2.d.ts +2 -0
- package/lib/db/schema/TableV2.js +2 -0
- package/lib/db/schema/TableV2.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/types/types.d.ts +6 -0
- package/lib/utils/AbortOperation.d.ts +2 -0
- package/lib/utils/AbortOperation.js +2 -0
- package/lib/utils/AbortOperation.js.map +1 -1
- 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/ControlledExecutor.d.ts +6 -0
- package/lib/utils/ControlledExecutor.js +3 -0
- package/lib/utils/ControlledExecutor.js.map +1 -1
- package/lib/utils/Logger.d.ts +9 -0
- package/lib/utils/Logger.js +6 -0
- package/lib/utils/Logger.js.map +1 -1
- package/lib/utils/async.d.ts +26 -0
- package/lib/utils/async.js +114 -27
- package/lib/utils/async.js.map +1 -1
- package/lib/utils/compatibility.d.ts +8 -0
- package/lib/utils/compatibility.js +9 -0
- package/lib/utils/compatibility.js.map +1 -0
- package/lib/utils/mutex.d.ts +8 -0
- package/lib/utils/mutex.js +3 -0
- package/lib/utils/mutex.js.map +1 -1
- package/lib/utils/parseQuery.d.ts +6 -0
- package/lib/utils/parseQuery.js +3 -0
- package/lib/utils/parseQuery.js.map +1 -1
- package/lib/utils/stream_transform.d.ts +3 -1
- package/lib/utils/stream_transform.js.map +1 -1
- package/package.json +3 -3
- package/src/attachments/AttachmentContext.ts +7 -6
- package/src/attachments/AttachmentErrorHandler.ts +6 -6
- package/src/attachments/AttachmentQueue.ts +93 -35
- 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 +12 -4
- package/src/attachments/WatchedAttachmentItem.ts +3 -1
- package/src/client/AbstractPowerSyncDatabase.ts +135 -91
- package/src/client/AbstractPowerSyncOpenFactory.ts +6 -0
- package/src/client/ConnectionManager.ts +4 -1
- package/src/client/Query.ts +9 -0
- package/src/client/SQLOpenFactory.ts +12 -0
- package/src/client/compilableQueryWatch.ts +6 -0
- package/src/client/connection/PowerSyncBackendConnector.ts +3 -0
- package/src/client/connection/PowerSyncCredentials.ts +3 -0
- package/src/client/constants.ts +3 -0
- package/src/client/runOnSchemaChange.ts +3 -0
- package/src/client/sync/bucket/BucketStorageAdapter.ts +12 -0
- package/src/client/sync/bucket/CrudBatch.ts +2 -0
- package/src/client/sync/bucket/CrudEntry.ts +9 -0
- package/src/client/sync/bucket/CrudTransaction.ts +3 -0
- package/src/client/sync/bucket/SqliteBucketStorage.ts +3 -0
- package/src/client/sync/stream/AbstractRemote.ts +76 -34
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +55 -5
- package/src/client/sync/stream/JsonValue.ts +3 -0
- package/src/client/sync/stream/WebsocketClientTransport.ts +3 -1
- package/src/client/sync/sync-streams.ts +22 -9
- package/src/client/triggers/TriggerManager.ts +19 -18
- package/src/client/triggers/TriggerManagerImpl.ts +5 -5
- package/src/client/triggers/sanitizeSQL.ts +5 -0
- package/src/client/watched/GetAllQuery.ts +5 -1
- package/src/client/watched/WatchedQuery.ts +24 -2
- package/src/client/watched/processors/AbstractQueryProcessor.ts +6 -6
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +28 -5
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +9 -3
- package/src/client/watched/processors/comparators.ts +8 -0
- package/src/db/ConnectionClosedError.ts +2 -0
- package/src/db/DBAdapter.ts +58 -6
- package/src/db/crud/SyncProgress.ts +6 -1
- package/src/db/crud/SyncStatus.ts +40 -21
- package/src/db/crud/UploadQueueStatus.ts +3 -0
- package/src/db/schema/Column.ts +28 -3
- package/src/db/schema/Index.ts +9 -0
- package/src/db/schema/IndexedColumn.ts +9 -0
- package/src/db/schema/RawTable.ts +7 -1
- package/src/db/schema/Schema.ts +8 -3
- package/src/db/schema/Table.ts +30 -5
- package/src/db/schema/TableV2.ts +2 -0
- package/src/index.ts +1 -1
- package/src/types/types.ts +6 -0
- package/src/utils/AbortOperation.ts +2 -0
- package/src/utils/BaseObserver.ts +12 -0
- package/src/utils/ControlledExecutor.ts +6 -0
- package/src/utils/Logger.ts +9 -0
- package/src/utils/async.ts +136 -28
- package/src/utils/compatibility.ts +9 -0
- package/src/utils/mutex.ts +12 -0
- package/src/utils/parseQuery.ts +6 -0
- package/src/utils/stream_transform.ts +3 -1
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* A basic comparator for incrementally watched queries. This performs a single comparison which
|
|
3
3
|
* determines if the result set has changed. The {@link WatchedQuery} will only emit the new result
|
|
4
4
|
* if a change has been detected.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
5
7
|
*/
|
|
6
8
|
export interface WatchedQueryComparator<Data> {
|
|
7
9
|
checkEquality: (current: Data, previous: Data) => boolean;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Options for {@link ArrayComparator}
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
11
15
|
*/
|
|
12
16
|
export type ArrayComparatorOptions<ItemType> = {
|
|
13
17
|
/**
|
|
@@ -18,6 +22,8 @@ export type ArrayComparatorOptions<ItemType> = {
|
|
|
18
22
|
/**
|
|
19
23
|
* An efficient comparator for {@link WatchedQuery} created with {@link Query#watch}. This has the ability to determine if a query
|
|
20
24
|
* result has changes without necessarily processing all items in the result.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
21
27
|
*/
|
|
22
28
|
export declare class ArrayComparator<ItemType> implements WatchedQueryComparator<ItemType[]> {
|
|
23
29
|
protected options: ArrayComparatorOptions<ItemType>;
|
|
@@ -26,5 +32,7 @@ export declare class ArrayComparator<ItemType> implements WatchedQueryComparator
|
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Watched query comparator that always reports changed result sets.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
29
37
|
*/
|
|
30
38
|
export declare const FalsyComparator: WatchedQueryComparator<unknown>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An efficient comparator for {@link WatchedQuery} created with {@link Query#watch}. This has the ability to determine if a query
|
|
3
3
|
* result has changes without necessarily processing all items in the result.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
4
6
|
*/
|
|
5
7
|
export class ArrayComparator {
|
|
6
8
|
options;
|
|
@@ -28,6 +30,8 @@ export class ArrayComparator {
|
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Watched query comparator that always reports changed result sets.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
31
35
|
*/
|
|
32
36
|
export const FalsyComparator = {
|
|
33
37
|
checkEquality: () => false // Default comparator that always returns false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comparators.js","sourceRoot":"","sources":["../../../../src/client/watched/processors/comparators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comparators.js","sourceRoot":"","sources":["../../../../src/client/watched/processors/comparators.ts"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACJ;IAAtB,YAAsB,OAAyC;QAAzC,YAAO,GAAP,OAAO,CAAkC;IAAG,CAAC;IAEnE,aAAa,CAAC,OAAmB,EAAE,QAAoB;QACrD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEnC,sCAAsC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAE5C,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;gBACjC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoC;IAC9D,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,+CAA+C;CAC3E,CAAC"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Thrown when an underlying database connection is closed.
|
|
3
3
|
* This is particularly relevant when worker connections are marked as closed while
|
|
4
4
|
* operations are still in progress.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
5
7
|
*/
|
|
6
8
|
export declare class ConnectionClosedError extends Error {
|
|
7
9
|
static NAME: string;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Thrown when an underlying database connection is closed.
|
|
3
3
|
* This is particularly relevant when worker connections are marked as closed while
|
|
4
4
|
* operations are still in progress.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
5
7
|
*/
|
|
6
8
|
export class ConnectionClosedError extends Error {
|
|
7
9
|
static NAME = 'ConnectionClosedError';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionClosedError.js","sourceRoot":"","sources":["../../src/db/ConnectionClosedError.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ConnectionClosedError.js","sourceRoot":"","sources":["../../src/db/ConnectionClosedError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,MAAM,CAAC,IAAI,GAAG,uBAAuB,CAAC;IAEtC,MAAM,CAAC,OAAO,CAAC,KAAU;QACvB;;;;WAIG;QACH,OAAO,CACL,KAAK,YAAY,qBAAqB,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAC/G,CAAC;IACJ,CAAC;IACD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;IACzC,CAAC"}
|
package/lib/db/DBAdapter.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver.js';
|
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* Object returned by SQL Query executions.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
12
14
|
*/
|
|
13
15
|
export type QueryResult = {
|
|
14
16
|
/** Represents the auto-generated row id if applicable. */
|
|
@@ -28,12 +30,15 @@ export type QueryResult = {
|
|
|
28
30
|
/** The length of the dataset */
|
|
29
31
|
length: number;
|
|
30
32
|
/** A convenience function to acess the index based the row object
|
|
31
|
-
* @param idx the row index
|
|
33
|
+
* @param idx - the row index
|
|
32
34
|
* @returns the row structure identified by column names
|
|
33
35
|
*/
|
|
34
36
|
item: (idx: number) => any;
|
|
35
37
|
};
|
|
36
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
37
42
|
export interface DBGetUtils {
|
|
38
43
|
/** Execute a read-only query and return results. */
|
|
39
44
|
getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
|
|
@@ -42,6 +47,9 @@ export interface DBGetUtils {
|
|
|
42
47
|
/** Execute a read-only query and return the first result, error if the ResultSet is empty. */
|
|
43
48
|
get<T>(sql: string, parameters?: any[]): Promise<T>;
|
|
44
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
45
53
|
export interface SqlExecutor {
|
|
46
54
|
/** Execute a single write statement. */
|
|
47
55
|
execute: (query: string, params?: any[] | undefined) => Promise<QueryResult>;
|
|
@@ -53,15 +61,22 @@ export interface SqlExecutor {
|
|
|
53
61
|
*
|
|
54
62
|
* Example result:
|
|
55
63
|
*
|
|
56
|
-
* ```
|
|
64
|
+
* ```JavaScript
|
|
65
|
+
* [ [ '1', 'list 1', '33', 'Post content', '1' ] ]
|
|
66
|
+
* ```
|
|
57
67
|
*
|
|
58
68
|
* Where as `execute`'s `rows._array` would have been:
|
|
59
69
|
*
|
|
60
|
-
* ```
|
|
70
|
+
* ```JavaScript
|
|
71
|
+
* [ { id: '33', name: 'list 1', content: 'Post content', list_id: '1' } ]
|
|
72
|
+
* ```
|
|
61
73
|
*/
|
|
62
74
|
executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
|
|
63
75
|
executeBatch: (query: string, params?: any[][]) => Promise<QueryResult>;
|
|
64
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
65
80
|
export interface LockContext extends SqlExecutor, DBGetUtils {
|
|
66
81
|
/**
|
|
67
82
|
* How the connection has been opened.
|
|
@@ -74,7 +89,9 @@ export interface LockContext extends SqlExecutor, DBGetUtils {
|
|
|
74
89
|
connectionType?: 'writer' | 'queryOnly' | 'readOnly';
|
|
75
90
|
}
|
|
76
91
|
/**
|
|
77
|
-
* Implements {@link DBGetUtils} on a {@link
|
|
92
|
+
* Implements {@link DBGetUtils} on a {@link SqlExecutor}.
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
78
95
|
*/
|
|
79
96
|
export declare function DBGetUtilsDefaultMixin<TBase extends new (...args: any[]) => Omit<SqlExecutor, 'executeBatch'>>(Base: TBase): {
|
|
80
97
|
new (...args: any[]): {
|
|
@@ -86,6 +103,9 @@ export declare function DBGetUtilsDefaultMixin<TBase extends new (...args: any[]
|
|
|
86
103
|
executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
|
|
87
104
|
};
|
|
88
105
|
} & TBase;
|
|
106
|
+
/**
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
89
109
|
export interface Transaction extends LockContext {
|
|
90
110
|
/** Commit multiple changes to the local DB using the Transaction context. */
|
|
91
111
|
commit: () => Promise<QueryResult>;
|
|
@@ -94,27 +114,40 @@ export interface Transaction extends LockContext {
|
|
|
94
114
|
}
|
|
95
115
|
/**
|
|
96
116
|
* Update table operation numbers from SQLite
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
97
119
|
*/
|
|
98
120
|
export declare enum RowUpdateType {
|
|
99
121
|
SQLITE_INSERT = 18,
|
|
100
122
|
SQLITE_DELETE = 9,
|
|
101
123
|
SQLITE_UPDATE = 23
|
|
102
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
103
128
|
export interface TableUpdateOperation {
|
|
104
129
|
opType: RowUpdateType;
|
|
105
130
|
rowId: number;
|
|
106
131
|
}
|
|
107
132
|
/**
|
|
108
133
|
* Notification of an update to one or more tables, for the purpose of realtime change notifications.
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
109
136
|
*/
|
|
110
137
|
export interface UpdateNotification extends TableUpdateOperation {
|
|
111
138
|
table: string;
|
|
112
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
113
143
|
export interface BatchedUpdateNotification {
|
|
114
144
|
rawUpdates: UpdateNotification[];
|
|
115
145
|
tables: string[];
|
|
116
146
|
groupedUpdates: Record<string, TableUpdateOperation[]>;
|
|
117
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
118
151
|
export interface DBAdapterListener extends BaseListener {
|
|
119
152
|
/**
|
|
120
153
|
* Listener for table updates.
|
|
@@ -124,9 +157,15 @@ export interface DBAdapterListener extends BaseListener {
|
|
|
124
157
|
*/
|
|
125
158
|
tablesUpdated: (updateNotification: BatchedUpdateNotification | UpdateNotification) => void;
|
|
126
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
127
163
|
export interface DBLockOptions {
|
|
128
164
|
timeoutMs?: number;
|
|
129
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
130
169
|
export interface ConnectionPool extends BaseObserverInterface<DBAdapterListener> {
|
|
131
170
|
name: string;
|
|
132
171
|
close: () => void | Promise<void>;
|
|
@@ -137,13 +176,18 @@ export interface ConnectionPool extends BaseObserverInterface<DBAdapterListener>
|
|
|
137
176
|
*/
|
|
138
177
|
refreshSchema: () => Promise<void>;
|
|
139
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
140
182
|
export interface DBAdapter extends ConnectionPool, SqlExecutor, DBGetUtils {
|
|
141
183
|
readTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
142
184
|
writeTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
143
185
|
}
|
|
144
186
|
/**
|
|
145
|
-
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool
|
|
146
|
-
* {@link ConnectionPool
|
|
187
|
+
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool#readLock} and
|
|
188
|
+
* {@link ConnectionPool#writeLock}.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
147
191
|
*/
|
|
148
192
|
export declare function DBAdapterDefaultMixin<TBase extends new (...args: any[]) => ConnectionPool>(Base: TBase): {
|
|
149
193
|
new (...args: any[]): {
|
|
@@ -166,5 +210,11 @@ export declare function DBAdapterDefaultMixin<TBase extends new (...args: any[])
|
|
|
166
210
|
registerListener(listener: Partial<DBAdapterListener>): () => void;
|
|
167
211
|
};
|
|
168
212
|
} & TBase;
|
|
213
|
+
/**
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
169
216
|
export declare function isBatchedUpdateNotification(update: BatchedUpdateNotification | UpdateNotification): update is BatchedUpdateNotification;
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
170
220
|
export declare function extractTableUpdates(update: BatchedUpdateNotification | UpdateNotification): string[];
|
package/lib/db/DBAdapter.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* different SQLite DB implementations.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Implements {@link DBGetUtils} on a {@link
|
|
6
|
+
* Implements {@link DBGetUtils} on a {@link SqlExecutor}.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
7
9
|
*/
|
|
8
10
|
export function DBGetUtilsDefaultMixin(Base) {
|
|
9
11
|
return class extends Base {
|
|
@@ -47,6 +49,8 @@ export function DBGetUtilsDefaultMixin(Base) {
|
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Update table operation numbers from SQLite
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
50
54
|
*/
|
|
51
55
|
export var RowUpdateType;
|
|
52
56
|
(function (RowUpdateType) {
|
|
@@ -55,8 +59,10 @@ export var RowUpdateType;
|
|
|
55
59
|
RowUpdateType[RowUpdateType["SQLITE_UPDATE"] = 23] = "SQLITE_UPDATE";
|
|
56
60
|
})(RowUpdateType || (RowUpdateType = {}));
|
|
57
61
|
/**
|
|
58
|
-
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool
|
|
59
|
-
* {@link ConnectionPool
|
|
62
|
+
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool#readLock} and
|
|
63
|
+
* {@link ConnectionPool#writeLock}.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
60
66
|
*/
|
|
61
67
|
export function DBAdapterDefaultMixin(Base) {
|
|
62
68
|
return class extends Base {
|
|
@@ -144,9 +150,15 @@ class TransactionImplementation extends DBGetUtilsDefaultMixin(BaseTransaction)
|
|
|
144
150
|
}
|
|
145
151
|
}
|
|
146
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
147
156
|
export function isBatchedUpdateNotification(update) {
|
|
148
157
|
return 'tables' in update;
|
|
149
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
150
162
|
export function extractTableUpdates(update) {
|
|
151
163
|
return isBatchedUpdateNotification(update) ? update.tables : [update.table];
|
|
152
164
|
}
|
package/lib/db/DBAdapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBAdapter.js","sourceRoot":"","sources":["../../src/db/DBAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"DBAdapter.js","sourceRoot":"","sources":["../../src/db/DBAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+FH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAW;IAEX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AAE,CAAC;QACX,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAsD;IAEtD,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAsD;IACxF,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -10,6 +10,8 @@ export declare const FULL_SYNC_PRIORITY = 2147483647;
|
|
|
10
10
|
*
|
|
11
11
|
* To obtain these values, use {@link SyncProgress}, available through
|
|
12
12
|
* {@link SyncStatus#downloadProgress}.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
13
15
|
*/
|
|
14
16
|
export interface ProgressWithOperations {
|
|
15
17
|
/**
|
|
@@ -22,7 +24,8 @@ export interface ProgressWithOperations {
|
|
|
22
24
|
*/
|
|
23
25
|
downloadedOperations: number;
|
|
24
26
|
/**
|
|
25
|
-
* Relative progress, as {@link downloadedOperations} of
|
|
27
|
+
* Relative progress, as {@link ProgressWithOperations.downloadedOperations} of
|
|
28
|
+
* {@link ProgressWithOperations.totalOperations}.
|
|
26
29
|
*
|
|
27
30
|
* This will be a number between `0.0` and `1.0` (inclusive).
|
|
28
31
|
*
|
|
@@ -51,6 +54,8 @@ export interface ProgressWithOperations {
|
|
|
51
54
|
*
|
|
52
55
|
* Also note that data is downloaded in bulk, which means that individual counters are unlikely
|
|
53
56
|
* to be updated one-by-one.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
54
59
|
*/
|
|
55
60
|
export declare class SyncProgress implements ProgressWithOperations {
|
|
56
61
|
protected internal: InternalProgressInformation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncProgress.js","sourceRoot":"","sources":["../../../src/db/crud/SyncProgress.ts"],"names":[],"mappings":"A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E,UAAU;YAChC,kBAAkB,EAAE,QAAQ;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,6 +2,9 @@ import { SyncClientImplementation } from '../../client/sync/stream/AbstractStrea
|
|
|
2
2
|
import { CoreStreamSubscription } from '../../client/sync/stream/core-instruction.js';
|
|
3
3
|
import { SyncStreamDescription, SyncSubscriptionDescription } from '../../client/sync/sync-streams.js';
|
|
4
4
|
import { InternalProgressInformation, ProgressWithOperations, SyncProgress } from './SyncProgress.js';
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
5
8
|
export type SyncDataFlowStatus = Partial<{
|
|
6
9
|
downloading: boolean;
|
|
7
10
|
uploading: boolean;
|
|
@@ -19,16 +22,25 @@ export type SyncDataFlowStatus = Partial<{
|
|
|
19
22
|
/**
|
|
20
23
|
* Internal information about how far we are downloading operations in buckets.
|
|
21
24
|
*
|
|
22
|
-
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
25
|
+
* @internal Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
23
26
|
*/
|
|
24
27
|
downloadProgress: InternalProgressInformation | null;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
25
31
|
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
26
32
|
}>;
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
27
36
|
export interface SyncPriorityStatus {
|
|
28
37
|
priority: number;
|
|
29
38
|
lastSyncedAt?: Date;
|
|
30
39
|
hasSynced?: boolean;
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
32
44
|
export type SyncStatusOptions = {
|
|
33
45
|
connected?: boolean;
|
|
34
46
|
connecting?: boolean;
|
|
@@ -41,6 +53,9 @@ export type SyncStatusOptions = {
|
|
|
41
53
|
*/
|
|
42
54
|
clientImplementation?: SyncClientImplementation;
|
|
43
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
44
59
|
export declare class SyncStatus {
|
|
45
60
|
protected options: SyncStatusOptions;
|
|
46
61
|
constructor(options: SyncStatusOptions);
|
|
@@ -49,64 +64,45 @@ export declare class SyncStatus {
|
|
|
49
64
|
* implementation).
|
|
50
65
|
*
|
|
51
66
|
* This information is only available after a connection has been requested.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated This always returns the Rust client (the only option).
|
|
52
69
|
*/
|
|
53
70
|
get clientImplementation(): SyncClientImplementation | undefined;
|
|
54
71
|
/**
|
|
55
72
|
* Indicates if the client is currently connected to the PowerSync service.
|
|
56
73
|
*
|
|
57
|
-
* @returns
|
|
74
|
+
* @returns True if connected, false otherwise. Defaults to false if not specified.
|
|
58
75
|
*/
|
|
59
76
|
get connected(): boolean;
|
|
60
77
|
/**
|
|
61
78
|
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
62
79
|
*
|
|
63
|
-
* @returns
|
|
80
|
+
* @returns True if connecting, false otherwise. Defaults to false if not specified.
|
|
64
81
|
*/
|
|
65
82
|
get connecting(): boolean;
|
|
66
83
|
/**
|
|
67
84
|
* Time that a last sync has fully completed, if any.
|
|
68
85
|
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
69
86
|
*
|
|
70
|
-
* @returns
|
|
87
|
+
* @returns The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
71
88
|
*/
|
|
72
89
|
get lastSyncedAt(): Date | undefined;
|
|
73
90
|
/**
|
|
74
91
|
* Indicates whether there has been at least one full sync completed since initialization.
|
|
75
92
|
*
|
|
76
|
-
* @returns
|
|
93
|
+
* @returns True if at least one sync has completed, false if no sync has completed,
|
|
77
94
|
* or undefined when the state is still being loaded from the database.
|
|
78
95
|
*/
|
|
79
96
|
get hasSynced(): boolean | undefined;
|
|
80
97
|
/**
|
|
81
98
|
* Provides the current data flow status regarding uploads and downloads.
|
|
82
99
|
*
|
|
83
|
-
* @returns
|
|
100
|
+
* @returns An object containing:
|
|
84
101
|
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
85
102
|
* - uploading: True if actively uploading changes
|
|
86
|
-
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
87
|
-
*/
|
|
88
|
-
get dataFlowStatus():
|
|
89
|
-
downloading: boolean;
|
|
90
|
-
uploading: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Error during downloading (including connecting).
|
|
93
|
-
*
|
|
94
|
-
* Cleared on the next successful data download.
|
|
95
|
-
*/
|
|
96
|
-
downloadError?: Error;
|
|
97
|
-
/**
|
|
98
|
-
* Error during uploading.
|
|
99
|
-
* Cleared on the next successful upload.
|
|
100
|
-
*/
|
|
101
|
-
uploadError?: Error;
|
|
102
|
-
/**
|
|
103
|
-
* Internal information about how far we are downloading operations in buckets.
|
|
104
|
-
*
|
|
105
|
-
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
106
|
-
*/
|
|
107
|
-
downloadProgress: InternalProgressInformation | null;
|
|
108
|
-
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
109
|
-
}>;
|
|
103
|
+
* Defaults to `{downloading: false, uploading: false}` if not specified.
|
|
104
|
+
*/
|
|
105
|
+
get dataFlowStatus(): SyncDataFlowStatus;
|
|
110
106
|
/**
|
|
111
107
|
* All sync streams currently being tracked in teh database.
|
|
112
108
|
*
|
|
@@ -115,13 +111,13 @@ export declare class SyncStatus {
|
|
|
115
111
|
*/
|
|
116
112
|
get syncStreams(): SyncStreamStatus[] | undefined;
|
|
117
113
|
/**
|
|
118
|
-
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
114
|
+
* If the `stream` appears in {@link SyncStatus.syncStreams}, returns the current status for that stream.
|
|
119
115
|
*/
|
|
120
116
|
forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
|
|
121
117
|
/**
|
|
122
118
|
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
123
119
|
*
|
|
124
|
-
* @returns
|
|
120
|
+
* @returns An array of status entries for different sync priority levels,
|
|
125
121
|
* sorted with highest priorities (lower numbers) first.
|
|
126
122
|
*/
|
|
127
123
|
get priorityStatusEntries(): SyncPriorityStatus[];
|
|
@@ -148,29 +144,29 @@ export declare class SyncStatus {
|
|
|
148
144
|
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
149
145
|
* with a priority of 1 may return information for priority level 3.
|
|
150
146
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @returns
|
|
147
|
+
* @param priority - The bucket priority for which the status should be reported
|
|
148
|
+
* @returns Status information for the requested priority level or the next higher level with available status
|
|
153
149
|
*/
|
|
154
150
|
statusForPriority(priority: number): SyncPriorityStatus;
|
|
155
151
|
/**
|
|
156
152
|
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
157
153
|
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
158
154
|
*
|
|
159
|
-
* @param
|
|
160
|
-
* @returns
|
|
155
|
+
* @param status - The SyncStatus instance to compare against
|
|
156
|
+
* @returns True if the instances are considered equal, false otherwise
|
|
161
157
|
*/
|
|
162
158
|
isEqual(status: SyncStatus): boolean;
|
|
163
159
|
/**
|
|
164
160
|
* Creates a human-readable string representation of the current sync status.
|
|
165
161
|
* Includes information about connection state, sync completion, and data flow.
|
|
166
162
|
*
|
|
167
|
-
* @returns
|
|
163
|
+
* @returns A string representation of the sync status
|
|
168
164
|
*/
|
|
169
165
|
getMessage(): string;
|
|
170
166
|
/**
|
|
171
167
|
* Serializes the SyncStatus instance to a plain object.
|
|
172
168
|
*
|
|
173
|
-
* @returns
|
|
169
|
+
* @returns A plain object representation of the sync status
|
|
174
170
|
*/
|
|
175
171
|
toJSON(): SyncStatusOptions;
|
|
176
172
|
/**
|
|
@@ -186,6 +182,8 @@ export declare class SyncStatus {
|
|
|
186
182
|
}
|
|
187
183
|
/**
|
|
188
184
|
* Information about a sync stream subscription.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
189
187
|
*/
|
|
190
188
|
export interface SyncStreamStatus {
|
|
191
189
|
progress: ProgressWithOperations | null;
|