@powersync/common 1.57.1 → 2.0.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/lib/attachments/AttachmentContext.d.ts +5 -5
- package/lib/attachments/AttachmentContext.js +6 -2
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentQueue.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.js +9 -8
- 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/Schema.d.ts +2 -2
- package/lib/attachments/SyncingService.d.ts +2 -2
- package/lib/attachments/SyncingService.js +21 -6
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +56 -232
- package/lib/client/CommonPowerSyncDatabase.js +2 -0
- package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
- package/lib/client/SQLOpenFactory.d.ts +35 -13
- package/lib/client/SQLOpenFactory.js +1 -25
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +2 -2
- package/lib/client/compilableQueryWatch.js +1 -2
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -3
- package/lib/client/runOnSchemaChange.d.ts +2 -2
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/CrudEntry.d.ts +3 -34
- package/lib/client/sync/bucket/CrudEntry.js +0 -99
- package/lib/client/sync/bucket/CrudEntry.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/sync-streams.d.ts +1 -1
- package/lib/client/triggers/TriggerManager.d.ts +9 -38
- package/lib/client/watched/GetAllQuery.d.ts +3 -3
- package/lib/client/watched/GetAllQuery.js +1 -1
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +2 -10
- package/lib/client/watched/WatchedQuery.js +0 -11
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +0 -50
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -176
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +0 -22
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +72 -154
- package/lib/db/DBAdapter.js +70 -108
- 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 +1 -13
- package/lib/db/crud/SyncProgress.js +1 -62
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +32 -66
- package/lib/db/crud/SyncStatus.js +1 -253
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/schema/Column.d.ts +0 -7
- package/lib/db/schema/Column.js +0 -7
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +2 -6
- package/lib/db/schema/Index.js +1 -4
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +2 -6
- package/lib/db/schema/IndexedColumn.js +1 -4
- package/lib/db/schema/IndexedColumn.js.map +1 -1
- package/lib/db/schema/Schema.d.ts +4 -28
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +50 -96
- package/lib/db/schema/Table.js +83 -91
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/index.d.ts +5 -21
- package/lib/index.js +5 -22
- package/lib/index.js.map +1 -1
- package/lib/utils/BaseObserver.d.ts +1 -1
- package/lib/utils/BaseObserver.js +1 -1
- package/lib/utils/Logger.d.ts +52 -23
- package/lib/utils/Logger.js +35 -33
- 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 -53
- package/lib/utils/mutex.js +1 -156
- package/lib/utils/mutex.js.map +1 -1
- package/package.json +8 -45
- package/src/attachments/AttachmentContext.ts +11 -10
- package/src/attachments/AttachmentQueue.ts +15 -14
- package/src/attachments/AttachmentService.ts +7 -6
- package/src/attachments/Schema.ts +2 -2
- package/src/attachments/SyncingService.ts +23 -9
- package/src/client/CommonPowerSyncDatabase.ts +540 -0
- package/src/client/SQLOpenFactory.ts +38 -22
- package/src/client/compilableQueryWatch.ts +3 -4
- package/src/client/connection/PowerSyncBackendConnector.ts +3 -3
- package/src/client/runOnSchemaChange.ts +2 -2
- package/src/client/sync/bucket/CrudEntry.ts +4 -104
- package/src/client/sync/options.ts +77 -0
- package/src/client/sync/sync-streams.ts +1 -1
- package/src/client/triggers/TriggerManager.ts +10 -41
- package/src/client/watched/GetAllQuery.ts +3 -3
- package/src/client/watched/WatchedQuery.ts +2 -15
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +0 -223
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +0 -111
- package/src/db/DBAdapter.ts +141 -226
- package/src/db/QueryResult.ts +195 -0
- package/src/db/crud/SyncProgress.ts +2 -42
- package/src/db/crud/SyncStatus.ts +45 -220
- package/src/db/schema/Column.ts +0 -8
- package/src/db/schema/Index.ts +3 -6
- package/src/db/schema/IndexedColumn.ts +3 -6
- package/src/db/schema/Schema.ts +4 -4
- package/src/db/schema/Table.ts +111 -186
- package/src/index.ts +5 -21
- package/src/utils/BaseObserver.ts +1 -1
- package/src/utils/Logger.ts +80 -34
- package/src/utils/MetaBaseObserver.ts +14 -60
- package/src/utils/mutex.ts +4 -201
- package/dist/bundle.cjs +0 -14390
- package/dist/bundle.cjs.map +0 -1
- package/dist/bundle.mjs +0 -14309
- package/dist/bundle.mjs.map +0 -1
- package/dist/bundle.node.cjs +0 -12021
- package/dist/bundle.node.cjs.map +0 -1
- package/dist/bundle.node.mjs +0 -11940
- package/dist/bundle.node.mjs.map +0 -1
- package/dist/index.d.cts +0 -4651
- package/legacy/sync_protocol.d.ts +0 -103
- package/lib/client/AbstractPowerSyncDatabase.js +0 -990
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -28
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -28
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/ConnectionManager.d.ts +0 -115
- 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 -4
- package/lib/client/constants.js +0 -5
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -56
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -29
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -37
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -165
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +0 -180
- package/lib/client/sync/stream/AbstractRemote.js +0 -505
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -265
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -705
- 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 -62
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
- package/lib/client/sync/stream/core-instruction.d.ts +0 -77
- package/lib/client/sync/stream/core-instruction.js +0 -30
- 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 -410
- 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 -12
- package/lib/db/ConnectionClosedError.js +0 -23
- package/lib/db/ConnectionClosedError.js.map +0 -1
- package/lib/db/schema/TableV2.d.ts +0 -11
- package/lib/db/schema/TableV2.js +0 -11
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/utils/AbortOperation.d.ts +0 -11
- package/lib/utils/AbortOperation.js +0 -21
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/ControlledExecutor.d.ts +0 -31
- package/lib/utils/ControlledExecutor.js +0 -54
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/async.d.ts +0 -46
- package/lib/utils/async.js +0 -147
- package/lib/utils/async.js.map +0 -1
- package/lib/utils/compatibility.d.ts +0 -8
- package/lib/utils/compatibility.js +0 -9
- package/lib/utils/compatibility.js.map +0 -1
- package/lib/utils/parseQuery.d.ts +0 -12
- package/lib/utils/parseQuery.js +0 -20
- 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 -41
- package/lib/utils/stream_transform.js +0 -211
- package/lib/utils/stream_transform.js.map +0 -1
- package/src/client/AbstractPowerSyncDatabase.ts +0 -1408
- package/src/client/AbstractPowerSyncOpenFactory.ts +0 -45
- package/src/client/ConnectionManager.ts +0 -405
- package/src/client/CustomQuery.ts +0 -56
- package/src/client/constants.ts +0 -4
- package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -65
- package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -202
- package/src/client/sync/stream/AbstractRemote.ts +0 -644
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -970
- package/src/client/sync/stream/WebsocketClientTransport.ts +0 -82
- package/src/client/sync/stream/core-instruction.ts +0 -109
- package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
- package/src/client/triggers/TriggerManagerImpl.ts +0 -501
- package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
- package/src/db/ConnectionClosedError.ts +0 -25
- package/src/db/schema/TableV2.ts +0 -11
- package/src/utils/AbortOperation.ts +0 -19
- package/src/utils/ControlledExecutor.ts +0 -78
- package/src/utils/async.ts +0 -185
- package/src/utils/compatibility.ts +0 -9
- package/src/utils/parseQuery.ts +0 -31
- package/src/utils/queue.ts +0 -48
- package/src/utils/stream_transform.ts +0 -260
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { SyncClientImplementation } from '../../client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
2
|
-
import { CoreStreamSubscription } from '../../client/sync/stream/core-instruction.js';
|
|
3
1
|
import { SyncStreamDescription, SyncSubscriptionDescription } from '../../client/sync/sync-streams.js';
|
|
4
|
-
import {
|
|
2
|
+
import { ProgressWithOperations, SyncProgress } from './SyncProgress.js';
|
|
5
3
|
/**
|
|
6
4
|
* @public
|
|
5
|
+
* @deprecated All fields are available on {@link SyncStatus} directly.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
7
|
+
export interface SyncDataFlowStatus {
|
|
9
8
|
downloading: boolean;
|
|
10
9
|
uploading: boolean;
|
|
11
10
|
/**
|
|
@@ -19,17 +18,7 @@ export type SyncDataFlowStatus = Partial<{
|
|
|
19
18
|
* Cleared on the next successful upload.
|
|
20
19
|
*/
|
|
21
20
|
uploadError?: Error;
|
|
22
|
-
|
|
23
|
-
* Internal information about how far we are downloading operations in buckets.
|
|
24
|
-
*
|
|
25
|
-
* @internal Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
26
|
-
*/
|
|
27
|
-
downloadProgress: InternalProgressInformation | null;
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
32
|
-
}>;
|
|
21
|
+
}
|
|
33
22
|
/**
|
|
34
23
|
* @public
|
|
35
24
|
*/
|
|
@@ -38,36 +27,10 @@ export interface SyncPriorityStatus {
|
|
|
38
27
|
lastSyncedAt?: Date;
|
|
39
28
|
hasSynced?: boolean;
|
|
40
29
|
}
|
|
41
|
-
/**
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export type SyncStatusOptions = {
|
|
45
|
-
connected?: boolean;
|
|
46
|
-
connecting?: boolean;
|
|
47
|
-
dataFlow?: SyncDataFlowStatus;
|
|
48
|
-
lastSyncedAt?: Date;
|
|
49
|
-
hasSynced?: boolean;
|
|
50
|
-
priorityStatusEntries?: SyncPriorityStatus[];
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated This field is no longer set, since {@link SyncClientImplementation.RUST} is the only option.
|
|
53
|
-
*/
|
|
54
|
-
clientImplementation?: SyncClientImplementation;
|
|
55
|
-
};
|
|
56
30
|
/**
|
|
57
31
|
* @public
|
|
58
32
|
*/
|
|
59
|
-
export
|
|
60
|
-
protected options: SyncStatusOptions;
|
|
61
|
-
constructor(options: SyncStatusOptions);
|
|
62
|
-
/**
|
|
63
|
-
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
64
|
-
* implementation).
|
|
65
|
-
*
|
|
66
|
-
* This information is only available after a connection has been requested.
|
|
67
|
-
*
|
|
68
|
-
* @deprecated This always returns the Rust client (the only option).
|
|
69
|
-
*/
|
|
70
|
-
get clientImplementation(): SyncClientImplementation | undefined;
|
|
33
|
+
export interface SyncStatus {
|
|
71
34
|
/**
|
|
72
35
|
* Indicates if the client is currently connected to the PowerSync service.
|
|
73
36
|
*
|
|
@@ -80,6 +43,30 @@ export declare class SyncStatus {
|
|
|
80
43
|
* @returns True if connecting, false otherwise. Defaults to false if not specified.
|
|
81
44
|
*/
|
|
82
45
|
get connecting(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the PowerSync SDK is currently downloading data from the connected PowerSync service.
|
|
48
|
+
*/
|
|
49
|
+
get downloading(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the PowerSync SDK is currently uploading local mutations through the configured
|
|
52
|
+
* {@link PowerSyncBackendConnector}.
|
|
53
|
+
*/
|
|
54
|
+
get uploading(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* An error that occurred during downloads (including connection establishment errors).
|
|
57
|
+
*
|
|
58
|
+
* A download error will be reported on all sync status entries until the next successful sync.
|
|
59
|
+
*/
|
|
60
|
+
get downloadError(): Error | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Error during uploading.
|
|
63
|
+
* Cleared on the next successful upload.
|
|
64
|
+
*/
|
|
65
|
+
get uploadError(): Error | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated All fields on {@link SyncDataFlowStatus} are available on {@link SyncStatus} directly.
|
|
68
|
+
*/
|
|
69
|
+
get dataFlowStatus(): SyncDataFlowStatus;
|
|
83
70
|
/**
|
|
84
71
|
* Time that a last sync has fully completed, if any.
|
|
85
72
|
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
@@ -94,15 +81,6 @@ export declare class SyncStatus {
|
|
|
94
81
|
* or undefined when the state is still being loaded from the database.
|
|
95
82
|
*/
|
|
96
83
|
get hasSynced(): boolean | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Provides the current data flow status regarding uploads and downloads.
|
|
99
|
-
*
|
|
100
|
-
* @returns An object containing:
|
|
101
|
-
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
102
|
-
* - uploading: True if actively uploading changes
|
|
103
|
-
* Defaults to `{downloading: false, uploading: false}` if not specified.
|
|
104
|
-
*/
|
|
105
|
-
get dataFlowStatus(): SyncDataFlowStatus;
|
|
106
84
|
/**
|
|
107
85
|
* All sync streams currently being tracked in the database.
|
|
108
86
|
*
|
|
@@ -120,12 +98,12 @@ export declare class SyncStatus {
|
|
|
120
98
|
* @returns An array of status entries for different sync priority levels,
|
|
121
99
|
* sorted with highest priorities (lower numbers) first.
|
|
122
100
|
*/
|
|
123
|
-
get priorityStatusEntries(): SyncPriorityStatus[];
|
|
101
|
+
get priorityStatusEntries(): SyncPriorityStatus[] | undefined;
|
|
124
102
|
/**
|
|
125
103
|
* A realtime progress report on how many operations have been downloaded and
|
|
126
104
|
* how many are necessary in total to complete the next sync iteration.
|
|
127
105
|
*
|
|
128
|
-
* This field is only set when {@link
|
|
106
|
+
* This field is only set when {@link SyncStatus#downloading} is also true.
|
|
129
107
|
*/
|
|
130
108
|
get downloadProgress(): SyncProgress | null;
|
|
131
109
|
/**
|
|
@@ -147,7 +125,7 @@ export declare class SyncStatus {
|
|
|
147
125
|
* @param priority - The bucket priority for which the status should be reported
|
|
148
126
|
* @returns Status information for the requested priority level or the next higher level with available status
|
|
149
127
|
*/
|
|
150
|
-
statusForPriority(priority: number): SyncPriorityStatus;
|
|
128
|
+
statusForPriority(priority: number): SyncPriorityStatus | undefined;
|
|
151
129
|
/**
|
|
152
130
|
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
153
131
|
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
@@ -163,18 +141,6 @@ export declare class SyncStatus {
|
|
|
163
141
|
* @returns A string representation of the sync status
|
|
164
142
|
*/
|
|
165
143
|
getMessage(): string;
|
|
166
|
-
/**
|
|
167
|
-
* Serializes the SyncStatus instance to a plain object.
|
|
168
|
-
*
|
|
169
|
-
* @returns A plain object representation of the sync status
|
|
170
|
-
*/
|
|
171
|
-
toJSON(): SyncStatusOptions;
|
|
172
|
-
/**
|
|
173
|
-
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
174
|
-
* This explicitly serializes errors in the SyncStatus.
|
|
175
|
-
*/
|
|
176
|
-
protected serializeError(error?: Error): Error | undefined;
|
|
177
|
-
private static comparePriorities;
|
|
178
144
|
}
|
|
179
145
|
/**
|
|
180
146
|
* Information about a sync stream subscription.
|
|
@@ -1,254 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export class SyncStatus {
|
|
6
|
-
options;
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
12
|
-
* implementation).
|
|
13
|
-
*
|
|
14
|
-
* This information is only available after a connection has been requested.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated This always returns the Rust client (the only option).
|
|
17
|
-
*/
|
|
18
|
-
get clientImplementation() {
|
|
19
|
-
return this.options.clientImplementation;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Indicates if the client is currently connected to the PowerSync service.
|
|
23
|
-
*
|
|
24
|
-
* @returns True if connected, false otherwise. Defaults to false if not specified.
|
|
25
|
-
*/
|
|
26
|
-
get connected() {
|
|
27
|
-
return this.options.connected ?? false;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
31
|
-
*
|
|
32
|
-
* @returns True if connecting, false otherwise. Defaults to false if not specified.
|
|
33
|
-
*/
|
|
34
|
-
get connecting() {
|
|
35
|
-
return this.options.connecting ?? false;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Time that a last sync has fully completed, if any.
|
|
39
|
-
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
40
|
-
*
|
|
41
|
-
* @returns The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
42
|
-
*/
|
|
43
|
-
get lastSyncedAt() {
|
|
44
|
-
return this.options.lastSyncedAt;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Indicates whether there has been at least one full sync completed since initialization.
|
|
48
|
-
*
|
|
49
|
-
* @returns True if at least one sync has completed, false if no sync has completed,
|
|
50
|
-
* or undefined when the state is still being loaded from the database.
|
|
51
|
-
*/
|
|
52
|
-
get hasSynced() {
|
|
53
|
-
return this.options.hasSynced;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Provides the current data flow status regarding uploads and downloads.
|
|
57
|
-
*
|
|
58
|
-
* @returns An object containing:
|
|
59
|
-
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
60
|
-
* - uploading: True if actively uploading changes
|
|
61
|
-
* Defaults to `{downloading: false, uploading: false}` if not specified.
|
|
62
|
-
*/
|
|
63
|
-
get dataFlowStatus() {
|
|
64
|
-
return (this.options.dataFlow ?? {
|
|
65
|
-
/**
|
|
66
|
-
* true if actively downloading changes.
|
|
67
|
-
* This is only true when {@link connected} is also true.
|
|
68
|
-
*/
|
|
69
|
-
downloading: false,
|
|
70
|
-
/**
|
|
71
|
-
* true if uploading changes.
|
|
72
|
-
*/
|
|
73
|
-
uploading: false
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* All sync streams currently being tracked in the database.
|
|
78
|
-
*
|
|
79
|
-
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
80
|
-
* included streams yet.
|
|
81
|
-
*/
|
|
82
|
-
get syncStreams() {
|
|
83
|
-
return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* If the `stream` appears in {@link SyncStatus.syncStreams}, returns the current status for that stream.
|
|
87
|
-
*/
|
|
88
|
-
forStream(stream) {
|
|
89
|
-
const asJson = JSON.stringify(stream.parameters);
|
|
90
|
-
const raw = this.options.dataFlow?.internalStreamSubscriptions?.find((r) => r.name == stream.name && asJson == JSON.stringify(r.parameters));
|
|
91
|
-
return raw && new SyncStreamStatusView(this, raw);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
95
|
-
*
|
|
96
|
-
* @returns An array of status entries for different sync priority levels,
|
|
97
|
-
* sorted with highest priorities (lower numbers) first.
|
|
98
|
-
*/
|
|
99
|
-
get priorityStatusEntries() {
|
|
100
|
-
return (this.options.priorityStatusEntries ?? []).slice().sort(SyncStatus.comparePriorities);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* A realtime progress report on how many operations have been downloaded and
|
|
104
|
-
* how many are necessary in total to complete the next sync iteration.
|
|
105
|
-
*
|
|
106
|
-
* This field is only set when {@link SyncDataFlowStatus#downloading} is also true.
|
|
107
|
-
*/
|
|
108
|
-
get downloadProgress() {
|
|
109
|
-
const internalProgress = this.options.dataFlow?.downloadProgress;
|
|
110
|
-
if (internalProgress == null) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
return new SyncProgress(internalProgress);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
|
|
117
|
-
* for a specific bucket priority level.
|
|
118
|
-
*
|
|
119
|
-
* When buckets with different priorities are declared, PowerSync may choose to synchronize higher-priority
|
|
120
|
-
* buckets first. When a consistent view over all buckets for all priorities up until the given priority is
|
|
121
|
-
* reached, PowerSync makes data from those buckets available before lower-priority buckets have finished
|
|
122
|
-
* syncing.
|
|
123
|
-
*
|
|
124
|
-
* This method returns the status for the requested priority or the next higher priority level that has
|
|
125
|
-
* status information available. This is because when PowerSync makes data for a given priority available,
|
|
126
|
-
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
|
|
127
|
-
*
|
|
128
|
-
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
129
|
-
* with a priority of 1 may return information for priority level 3.
|
|
130
|
-
*
|
|
131
|
-
* @param priority - The bucket priority for which the status should be reported
|
|
132
|
-
* @returns Status information for the requested priority level or the next higher level with available status
|
|
133
|
-
*/
|
|
134
|
-
statusForPriority(priority) {
|
|
135
|
-
// priorityStatusEntries are sorted by ascending priorities (so higher numbers to lower numbers).
|
|
136
|
-
for (const known of this.priorityStatusEntries) {
|
|
137
|
-
// We look for the first entry that doesn't have a higher priority.
|
|
138
|
-
if (known.priority >= priority) {
|
|
139
|
-
return known;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// If we have a complete sync, that necessarily includes all priorities.
|
|
143
|
-
return {
|
|
144
|
-
priority,
|
|
145
|
-
lastSyncedAt: this.lastSyncedAt,
|
|
146
|
-
hasSynced: this.hasSynced
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
151
|
-
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
152
|
-
*
|
|
153
|
-
* @param status - The SyncStatus instance to compare against
|
|
154
|
-
* @returns True if the instances are considered equal, false otherwise
|
|
155
|
-
*/
|
|
156
|
-
isEqual(status) {
|
|
157
|
-
/**
|
|
158
|
-
* By default Error object are serialized to an empty object.
|
|
159
|
-
* This replaces Errors with more useful information before serialization.
|
|
160
|
-
*/
|
|
161
|
-
const replacer = (_, value) => {
|
|
162
|
-
if (value instanceof Error) {
|
|
163
|
-
return this.serializeError(value);
|
|
164
|
-
}
|
|
165
|
-
return value;
|
|
166
|
-
};
|
|
167
|
-
return JSON.stringify(this.options, replacer) == JSON.stringify(status.options, replacer);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Creates a human-readable string representation of the current sync status.
|
|
171
|
-
* Includes information about connection state, sync completion, and data flow.
|
|
172
|
-
*
|
|
173
|
-
* @returns A string representation of the sync status
|
|
174
|
-
*/
|
|
175
|
-
getMessage() {
|
|
176
|
-
const dataFlow = this.dataFlowStatus;
|
|
177
|
-
return `SyncStatus<connected: ${this.connected} connecting: ${this.connecting} lastSyncedAt: ${this.lastSyncedAt} hasSynced: ${this.hasSynced}. Downloading: ${dataFlow.downloading}. Uploading: ${dataFlow.uploading}. UploadError: ${dataFlow.uploadError}, DownloadError?: ${dataFlow.downloadError}>`;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Serializes the SyncStatus instance to a plain object.
|
|
181
|
-
*
|
|
182
|
-
* @returns A plain object representation of the sync status
|
|
183
|
-
*/
|
|
184
|
-
toJSON() {
|
|
185
|
-
return {
|
|
186
|
-
connected: this.connected,
|
|
187
|
-
connecting: this.connecting,
|
|
188
|
-
dataFlow: {
|
|
189
|
-
...this.dataFlowStatus,
|
|
190
|
-
uploadError: this.serializeError(this.dataFlowStatus.uploadError),
|
|
191
|
-
downloadError: this.serializeError(this.dataFlowStatus.downloadError)
|
|
192
|
-
},
|
|
193
|
-
lastSyncedAt: this.lastSyncedAt,
|
|
194
|
-
hasSynced: this.hasSynced,
|
|
195
|
-
priorityStatusEntries: this.priorityStatusEntries
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
200
|
-
* This explicitly serializes errors in the SyncStatus.
|
|
201
|
-
*/
|
|
202
|
-
serializeError(error) {
|
|
203
|
-
if (typeof error == 'undefined') {
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
const serialized = {
|
|
207
|
-
name: error.name,
|
|
208
|
-
message: error.message,
|
|
209
|
-
stack: error.stack
|
|
210
|
-
};
|
|
211
|
-
// `Error.cause` can be any value (the spec types it as unknown). Preserve it
|
|
212
|
-
// so consumers reading uploadError/downloadError keep the failure context.
|
|
213
|
-
// Recurse for Error causes so the whole chain is flattened the same way.
|
|
214
|
-
if (typeof error.cause != 'undefined') {
|
|
215
|
-
serialized.cause = error.cause instanceof Error ? this.serializeError(error.cause) : error.cause;
|
|
216
|
-
}
|
|
217
|
-
return serialized;
|
|
218
|
-
}
|
|
219
|
-
static comparePriorities(a, b) {
|
|
220
|
-
return b.priority - a.priority; // Reverse because higher priorities have lower numbers
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
class SyncStreamStatusView {
|
|
224
|
-
status;
|
|
225
|
-
core;
|
|
226
|
-
subscription;
|
|
227
|
-
constructor(status, core) {
|
|
228
|
-
this.status = status;
|
|
229
|
-
this.core = core;
|
|
230
|
-
this.subscription = {
|
|
231
|
-
name: core.name,
|
|
232
|
-
parameters: core.parameters,
|
|
233
|
-
active: core.active,
|
|
234
|
-
isDefault: core.is_default,
|
|
235
|
-
hasExplicitSubscription: core.has_explicit_subscription,
|
|
236
|
-
expiresAt: core.expires_at != null ? new Date(core.expires_at * 1000) : null,
|
|
237
|
-
hasSynced: core.last_synced_at != null,
|
|
238
|
-
lastSyncedAt: core.last_synced_at != null ? new Date(core.last_synced_at * 1000) : null
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
get progress() {
|
|
242
|
-
if (this.status.dataFlowStatus.downloadProgress == null) {
|
|
243
|
-
// Don't make download progress public if we're not currently downloading.
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
const { total, downloaded } = this.core.progress;
|
|
247
|
-
const progress = total == 0 ? 0.0 : downloaded / total;
|
|
248
|
-
return { totalOperations: total, downloadedOperations: downloaded, downloadedFraction: progress };
|
|
249
|
-
}
|
|
250
|
-
get priority() {
|
|
251
|
-
return this.core.priority;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
1
|
+
export {};
|
|
254
2
|
//# sourceMappingURL=SyncStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncStatus.js","sourceRoot":"","sources":["../../../src/db/crud/SyncStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SyncStatus.js","sourceRoot":"","sources":["../../../src/db/crud/SyncStatus.ts"],"names":[],"mappings":""}
|
|
@@ -28,13 +28,6 @@ export type ColumnsType = Record<string, BaseColumnType<any>>;
|
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
30
|
export type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
|
|
31
|
-
/**
|
|
32
|
-
* powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
|
|
33
|
-
* In earlier versions this was limited to 63.
|
|
34
|
-
*
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
export declare const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
38
31
|
/**
|
|
39
32
|
* @public
|
|
40
33
|
*/
|
package/lib/db/schema/Column.js
CHANGED
|
@@ -17,13 +17,6 @@ const integer = {
|
|
|
17
17
|
const real = {
|
|
18
18
|
type: ColumnType.REAL
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
|
|
22
|
-
* In earlier versions this was limited to 63.
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
export const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
27
20
|
/**
|
|
28
21
|
* @public
|
|
29
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../../src/db/schema/Column.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AA2BD,MAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;CACtB,CAAC;AAEF,MAAM,OAAO,GAAkC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO;CACzB,CAAC;AAEF,MAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;CACtB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../../src/db/schema/Column.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AA2BD,MAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;CACtB,CAAC;AAEF,MAAM,OAAO,GAAkC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO;CACzB,CAAC;AAEF,MAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,IAAI;CACL,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,MAAM;IACK;IAAtB,YAAsB,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAEhD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF"}
|
package/lib/db/schema/Index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexedColumn } from './IndexedColumn.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedTable } from './Table.js';
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
@@ -7,10 +7,6 @@ export interface IndexOptions {
|
|
|
7
7
|
name: string;
|
|
8
8
|
columns?: IndexedColumn[];
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_INDEX_OPTIONS: Partial<IndexOptions>;
|
|
14
10
|
/**
|
|
15
11
|
* @public
|
|
16
12
|
*/
|
|
@@ -20,7 +16,7 @@ export declare class Index {
|
|
|
20
16
|
constructor(options: IndexOptions);
|
|
21
17
|
get name(): string;
|
|
22
18
|
get columns(): IndexedColumn[];
|
|
23
|
-
toJSON(table:
|
|
19
|
+
toJSON(table: ResolvedTable): {
|
|
24
20
|
name: string;
|
|
25
21
|
columns: {
|
|
26
22
|
name: string;
|
package/lib/db/schema/Index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/db/schema/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWnD
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/db/schema/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWnD,MAAM,qBAAqB,GAA0B;IACnD,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,KAAK;IAQM;IAPtB,MAAM,CAAC,eAAe,CAAC,OAAqB,EAAE,WAAqB;QACjE,OAAO,IAAI,KAAK,CAAC;YACf,GAAG,OAAO;YACV,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;IAED,YAAsB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACzC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,qBAAqB,EAAE,GAAG,OAAO,EAAE,CAAC;IAC1D,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,KAAoB;QACzB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAClD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnType } from './Column.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedTable } from './Table.js';
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
@@ -7,10 +7,6 @@ export interface IndexColumnOptions {
|
|
|
7
7
|
name: string;
|
|
8
8
|
ascending?: boolean;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
|
|
14
10
|
/**
|
|
15
11
|
* @public
|
|
16
12
|
*/
|
|
@@ -20,7 +16,7 @@ export declare class IndexedColumn {
|
|
|
20
16
|
constructor(options: IndexColumnOptions);
|
|
21
17
|
get name(): string;
|
|
22
18
|
get ascending(): boolean | undefined;
|
|
23
|
-
toJSON(table:
|
|
19
|
+
toJSON(table: ResolvedTable): {
|
|
24
20
|
name: string;
|
|
25
21
|
ascending: boolean | undefined;
|
|
26
22
|
type: ColumnType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedColumn.js","sourceRoot":"","sources":["../../../src/db/schema/IndexedColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC
|
|
1
|
+
{"version":3,"file":"IndexedColumn.js","sourceRoot":"","sources":["../../../src/db/schema/IndexedColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,4BAA4B,GAAgC;IAChE,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,aAAa;IACd,OAAO,CAAqB;IAEtC,MAAM,CAAC,eAAe,CAAC,MAAc;QACnC,OAAO,IAAI,aAAa,CAAC;YACvB,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAED,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAO,EAAE,CAAC;IACjE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,KAAoB;QACzB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,UAAU,CAAC,IAAI;SACzF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RawTable, RawTableType } from './RawTable.js';
|
|
2
|
-
import { RowType, Table } from './Table.js';
|
|
2
|
+
import { ResolvedTable, RowType, Table } from './Table.js';
|
|
3
3
|
type SchemaType = Record<string, Table<any>>;
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
@@ -15,9 +15,9 @@ export type SchemaTableType<S extends SchemaType> = {
|
|
|
15
15
|
export declare class Schema<S extends SchemaType = SchemaType> {
|
|
16
16
|
readonly types: SchemaTableType<S>;
|
|
17
17
|
readonly props: S;
|
|
18
|
-
readonly tables:
|
|
18
|
+
readonly tables: ResolvedTable[];
|
|
19
19
|
readonly rawTables: RawTable[];
|
|
20
|
-
constructor(tables:
|
|
20
|
+
constructor(tables: ResolvedTable[] | S);
|
|
21
21
|
/**
|
|
22
22
|
* Adds raw tables to this schema. Raw tables are identified by their name, but entirely managed by the application
|
|
23
23
|
* developer instead of automatically by PowerSync.
|
|
@@ -28,31 +28,7 @@ export declare class Schema<S extends SchemaType = SchemaType> {
|
|
|
28
28
|
*/
|
|
29
29
|
withRawTables(tables: Record<string, RawTableType>): void;
|
|
30
30
|
validate(): void;
|
|
31
|
-
toJSON():
|
|
32
|
-
tables: {
|
|
33
|
-
local_only: boolean | undefined;
|
|
34
|
-
insert_only: boolean | undefined;
|
|
35
|
-
include_old: any;
|
|
36
|
-
include_old_only_when_changed: boolean;
|
|
37
|
-
include_metadata: boolean | undefined;
|
|
38
|
-
ignore_empty_update: boolean | undefined;
|
|
39
|
-
name: string;
|
|
40
|
-
view_name: string;
|
|
41
|
-
columns: {
|
|
42
|
-
name: string;
|
|
43
|
-
type: import("./Column.js").ColumnType | undefined;
|
|
44
|
-
}[];
|
|
45
|
-
indexes: {
|
|
46
|
-
name: string;
|
|
47
|
-
columns: {
|
|
48
|
-
name: string;
|
|
49
|
-
ascending: boolean | undefined;
|
|
50
|
-
type: import("./Column.js").ColumnType;
|
|
51
|
-
}[];
|
|
52
|
-
}[];
|
|
53
|
-
}[];
|
|
54
|
-
raw_tables: unknown[];
|
|
55
|
-
};
|
|
31
|
+
toJSON(): unknown;
|
|
56
32
|
/**
|
|
57
33
|
* Returns a representation of the raw table that is understood by the PowerSync SQLite core extension.
|
|
58
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../../src/db/schema/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAanD;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACjB;;MAEE;IACO,KAAK,CAAsB;IAC3B,KAAK,CAAK;IACV,MAAM,
|
|
1
|
+
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../../src/db/schema/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAanD;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACjB;;MAEE;IACO,KAAK,CAAsB;IAC3B,KAAK,CAAK;IACV,MAAM,CAAkB;IACxB,SAAS,CAAa;IAE/B,YAAY,MAA2B;QACrC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B;;;;cAIE;YACF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;oBACtB,MAAM,IAAI,KAAK,CACb,2KAA2K,CAC5K,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,4DAA4D;YAC5D,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAC7B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAC1F,CAAC;YACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,MAAoC;QAChD,KAAK,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,kBAAkB,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,QAAQ;QACN,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC1C,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC;SACtD,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAe;QACnC,MAAM,UAAU,GAAQ;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACF,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;YACtB,iGAAiG;YACjG,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAC5B,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC;YACvD,UAAU,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|