@powersync/common 1.53.2 → 1.54.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 +548 -345
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +548 -345
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +548 -345
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +548 -345
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +727 -189
- 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 +61 -20
- 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 -58
- package/lib/client/AbstractPowerSyncDatabase.js +59 -48
- 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 +15 -1
- 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/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 -2
- package/src/attachments/AttachmentContext.ts +7 -6
- package/src/attachments/AttachmentErrorHandler.ts +6 -6
- package/src/attachments/AttachmentQueue.ts +71 -23
- 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 +117 -62
- 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 +30 -1
- 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/mutex.ts +12 -0
- package/src/utils/parseQuery.ts +6 -0
- package/src/utils/stream_transform.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncProgress.js","sourceRoot":"","sources":["../../../src/db/crud/SyncProgress.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"SyncProgress.js","sourceRoot":"","sources":["../../../src/db/crud/SyncProgress.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAkC7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,YAAY;IAKD;IAJtB,eAAe,CAAS;IACxB,oBAAoB,CAAS;IAC7B,kBAAkB,CAAS;IAE3B,YAAsB,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;QACzD,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAE/D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;QACvD,IAAI,CAAC,oBAAoB,GAAG,eAAe,CAAC,oBAAoB,CAAC;QACjE,IAAI,CAAC,kBAAkB,GAAG,eAAe,CAAC,kBAAkB,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAAgB;QAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,UAAU,GAAG,CAAC,CAAC;QAEnB,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpD,2EAA2E;YAC3E,IAAI,QAAQ,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBAClC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC;gBAClC,KAAK,IAAI,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;YACpD,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;QACrD,OAAO;YACL,eAAe,EAAE,KAAK;YACtB,oBAAoB,EAAE,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;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { SyncProgress } from './SyncProgress.js';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export class SyncStatus {
|
|
3
6
|
options;
|
|
4
7
|
constructor(options) {
|
|
@@ -9,6 +12,8 @@ export class SyncStatus {
|
|
|
9
12
|
* implementation).
|
|
10
13
|
*
|
|
11
14
|
* This information is only available after a connection has been requested.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated This always returns the Rust client (the only option).
|
|
12
17
|
*/
|
|
13
18
|
get clientImplementation() {
|
|
14
19
|
return this.options.clientImplementation;
|
|
@@ -16,7 +21,7 @@ export class SyncStatus {
|
|
|
16
21
|
/**
|
|
17
22
|
* Indicates if the client is currently connected to the PowerSync service.
|
|
18
23
|
*
|
|
19
|
-
* @returns
|
|
24
|
+
* @returns True if connected, false otherwise. Defaults to false if not specified.
|
|
20
25
|
*/
|
|
21
26
|
get connected() {
|
|
22
27
|
return this.options.connected ?? false;
|
|
@@ -24,7 +29,7 @@ export class SyncStatus {
|
|
|
24
29
|
/**
|
|
25
30
|
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
26
31
|
*
|
|
27
|
-
* @returns
|
|
32
|
+
* @returns True if connecting, false otherwise. Defaults to false if not specified.
|
|
28
33
|
*/
|
|
29
34
|
get connecting() {
|
|
30
35
|
return this.options.connecting ?? false;
|
|
@@ -33,7 +38,7 @@ export class SyncStatus {
|
|
|
33
38
|
* Time that a last sync has fully completed, if any.
|
|
34
39
|
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
35
40
|
*
|
|
36
|
-
* @returns
|
|
41
|
+
* @returns The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
37
42
|
*/
|
|
38
43
|
get lastSyncedAt() {
|
|
39
44
|
return this.options.lastSyncedAt;
|
|
@@ -41,7 +46,7 @@ export class SyncStatus {
|
|
|
41
46
|
/**
|
|
42
47
|
* Indicates whether there has been at least one full sync completed since initialization.
|
|
43
48
|
*
|
|
44
|
-
* @returns
|
|
49
|
+
* @returns True if at least one sync has completed, false if no sync has completed,
|
|
45
50
|
* or undefined when the state is still being loaded from the database.
|
|
46
51
|
*/
|
|
47
52
|
get hasSynced() {
|
|
@@ -50,10 +55,10 @@ export class SyncStatus {
|
|
|
50
55
|
/**
|
|
51
56
|
* Provides the current data flow status regarding uploads and downloads.
|
|
52
57
|
*
|
|
53
|
-
* @returns
|
|
58
|
+
* @returns An object containing:
|
|
54
59
|
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
55
60
|
* - uploading: True if actively uploading changes
|
|
56
|
-
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
61
|
+
* Defaults to `{downloading: false, uploading: false}` if not specified.
|
|
57
62
|
*/
|
|
58
63
|
get dataFlowStatus() {
|
|
59
64
|
return (this.options.dataFlow ?? {
|
|
@@ -78,7 +83,7 @@ export class SyncStatus {
|
|
|
78
83
|
return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
|
-
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
86
|
+
* If the `stream` appears in {@link SyncStatus.syncStreams}, returns the current status for that stream.
|
|
82
87
|
*/
|
|
83
88
|
forStream(stream) {
|
|
84
89
|
const asJson = JSON.stringify(stream.parameters);
|
|
@@ -88,7 +93,7 @@ export class SyncStatus {
|
|
|
88
93
|
/**
|
|
89
94
|
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
90
95
|
*
|
|
91
|
-
* @returns
|
|
96
|
+
* @returns An array of status entries for different sync priority levels,
|
|
92
97
|
* sorted with highest priorities (lower numbers) first.
|
|
93
98
|
*/
|
|
94
99
|
get priorityStatusEntries() {
|
|
@@ -123,8 +128,8 @@ export class SyncStatus {
|
|
|
123
128
|
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
124
129
|
* with a priority of 1 may return information for priority level 3.
|
|
125
130
|
*
|
|
126
|
-
* @param
|
|
127
|
-
* @returns
|
|
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
|
|
128
133
|
*/
|
|
129
134
|
statusForPriority(priority) {
|
|
130
135
|
// priorityStatusEntries are sorted by ascending priorities (so higher numbers to lower numbers).
|
|
@@ -145,8 +150,8 @@ export class SyncStatus {
|
|
|
145
150
|
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
146
151
|
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
147
152
|
*
|
|
148
|
-
* @param
|
|
149
|
-
* @returns
|
|
153
|
+
* @param status - The SyncStatus instance to compare against
|
|
154
|
+
* @returns True if the instances are considered equal, false otherwise
|
|
150
155
|
*/
|
|
151
156
|
isEqual(status) {
|
|
152
157
|
/**
|
|
@@ -169,7 +174,7 @@ export class SyncStatus {
|
|
|
169
174
|
* Creates a human-readable string representation of the current sync status.
|
|
170
175
|
* Includes information about connection state, sync completion, and data flow.
|
|
171
176
|
*
|
|
172
|
-
* @returns
|
|
177
|
+
* @returns A string representation of the sync status
|
|
173
178
|
*/
|
|
174
179
|
getMessage() {
|
|
175
180
|
const dataFlow = this.dataFlowStatus;
|
|
@@ -178,7 +183,7 @@ export class SyncStatus {
|
|
|
178
183
|
/**
|
|
179
184
|
* Serializes the SyncStatus instance to a plain object.
|
|
180
185
|
*
|
|
181
|
-
* @returns
|
|
186
|
+
* @returns A plain object representation of the sync status
|
|
182
187
|
*/
|
|
183
188
|
toJSON() {
|
|
184
189
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncStatus.js","sourceRoot":"","sources":["../../../src/db/crud/SyncStatus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuD,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"SyncStatus.js","sourceRoot":"","sources":["../../../src/db/crud/SyncStatus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuD,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwDtG;;GAEG;AACH,MAAM,OAAO,UAAU;IACC;IAAtB,YAAsB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,oB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AAkB,EAAE,QAAQ,EAAE,CAAC;IACpG,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadQueueStatus.js","sourceRoot":"","sources":["../../../src/db/crud/UploadQueueStatus.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAgB;IAKlB;IAIA;IART;IACE;;OAEG;IACI,KAAa;IACpB;;OAEG;IACI,OAAsB,IAAI;QAJ1B,UAAK,GAAL,KAAK,CAAQ;QAIb,SAAI,GAAJ,IAAI,CAAsB;IAChC,CAAC;IAEJ,QAAQ;QACN,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,0BAA0B,IAAI,CAAC,KAAK,GAAG,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"UploadQueueStatus.js","sourceRoot":"","sources":["../../../src/db/crud/UploadQueueStatus.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAKlB;IAIA;IART;IACE;;OAEG;IACI,KAAa;IACpB;;OAEG;IACI,OAAsB,IAAI;QAJ1B,UAAK,GAAL,KAAK,CAAQ;QAIb,SAAI,GAAJ,IAAI,CAAsB;IAChC,CAAC;IAEJ,QAAQ;QACN,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,0BAA0B,IAAI,CAAC,KAAK,GAAG,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,wCAAwC,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,23 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://www.sqlite.org/lang_expr.html#castexpr
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
1
5
|
export declare enum ColumnType {
|
|
2
6
|
TEXT = "TEXT",
|
|
3
7
|
INTEGER = "INTEGER",
|
|
4
8
|
REAL = "REAL"
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
6
13
|
export interface ColumnOptions {
|
|
7
14
|
name: string;
|
|
8
15
|
type?: ColumnType;
|
|
9
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
10
20
|
export type BaseColumnType<T extends number | string | null> = {
|
|
11
21
|
type: ColumnType;
|
|
12
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
13
26
|
export type ColumnsType = Record<string, BaseColumnType<any>>;
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
14
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
|
+
*/
|
|
15
37
|
export declare const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
16
41
|
export declare const column: {
|
|
17
42
|
text: BaseColumnType<string | null>;
|
|
18
43
|
integer: BaseColumnType<number | null>;
|
|
19
44
|
real: BaseColumnType<number | null>;
|
|
20
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
21
49
|
export declare class Column {
|
|
22
50
|
protected options: ColumnOptions;
|
|
23
51
|
constructor(options: ColumnOptions);
|
package/lib/db/schema/Column.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @see https://www.sqlite.org/lang_expr.html#castexpr
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export var ColumnType;
|
|
3
6
|
(function (ColumnType) {
|
|
4
7
|
ColumnType["TEXT"] = "TEXT";
|
|
@@ -14,14 +17,24 @@ const integer = {
|
|
|
14
17
|
const real = {
|
|
15
18
|
type: ColumnType.REAL
|
|
16
19
|
};
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
*/
|
|
19
26
|
export const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
20
30
|
export const column = {
|
|
21
31
|
text,
|
|
22
32
|
integer,
|
|
23
33
|
real
|
|
24
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
25
38
|
export class Column {
|
|
26
39
|
options;
|
|
27
40
|
constructor(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../../src/db/schema/Column.ts"],"names":[],"mappings":"AAAA
|
|
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;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;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,10 +1,19 @@
|
|
|
1
1
|
import { IndexedColumn } from './IndexedColumn.js';
|
|
2
2
|
import { Table } from './Table.js';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
3
6
|
export interface IndexOptions {
|
|
4
7
|
name: string;
|
|
5
8
|
columns?: IndexedColumn[];
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
7
13
|
export declare const DEFAULT_INDEX_OPTIONS: Partial<IndexOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
8
17
|
export declare class Index {
|
|
9
18
|
protected options: IndexOptions;
|
|
10
19
|
static createAscending(options: IndexOptions, columnNames: string[]): Index;
|
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;
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/db/schema/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWnD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,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,KAAY;QACjB,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,10 +1,19 @@
|
|
|
1
1
|
import { ColumnType } from './Column.js';
|
|
2
2
|
import { Table } from './Table.js';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
3
6
|
export interface IndexColumnOptions {
|
|
4
7
|
name: string;
|
|
5
8
|
ascending?: boolean;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
7
13
|
export declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
8
17
|
export declare class IndexedColumn {
|
|
9
18
|
protected options: IndexColumnOptions;
|
|
10
19
|
static createAscending(column: string): IndexedColumn;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"IndexedColumn.js","sourceRoot":"","sources":["../../../src/db/schema/IndexedColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAgC;IACvE,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,KAAY;QACjB,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"}
|
|
@@ -6,8 +6,10 @@ import { TableOrRawTableOptions } from './Table.js';
|
|
|
6
6
|
* using client-side table and column constraints.
|
|
7
7
|
*
|
|
8
8
|
* To collect local writes to raw tables with PowerSync, custom triggers are required. See
|
|
9
|
-
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables
|
|
9
|
+
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables} for details and an example on
|
|
10
10
|
* using raw tables.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*/
|
|
12
14
|
export type RawTableType = RawTableTypeWithStatements | InferredRawTableType;
|
|
13
15
|
interface RawTableTypeWithStatements {
|
|
@@ -63,12 +65,16 @@ interface InferredRawTableType extends Partial<RawTableTypeWithStatements> {
|
|
|
63
65
|
* `{Column: 'name'}`.
|
|
64
66
|
* The `"Rest"` parameter gets resolved to a JSON object covering all values from the synced row that haven't been
|
|
65
67
|
* covered by a `Column` parameter.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
66
70
|
*/
|
|
67
71
|
export type PendingStatementParameter = 'Id' | {
|
|
68
72
|
Column: string;
|
|
69
73
|
} | 'Rest';
|
|
70
74
|
/**
|
|
71
75
|
* A statement that the PowerSync client should use to insert or delete data into a table managed by the user.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
72
78
|
*/
|
|
73
79
|
export type PendingStatement = {
|
|
74
80
|
sql: string;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { RawTable, RawTableType } from './RawTable.js';
|
|
2
2
|
import { RowType, Table } from './Table.js';
|
|
3
3
|
type SchemaType = Record<string, Table<any>>;
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
4
7
|
export type SchemaTableType<S extends SchemaType> = {
|
|
5
8
|
[K in keyof S]: RowType<S[K]>;
|
|
6
9
|
};
|
|
7
10
|
/**
|
|
8
11
|
* A schema is a collection of tables. It is used to define the structure of a database.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
9
14
|
*/
|
|
10
15
|
export declare class Schema<S extends SchemaType = SchemaType> {
|
|
11
16
|
readonly types: SchemaTableType<S>;
|
|
@@ -19,7 +24,7 @@ export declare class Schema<S extends SchemaType = SchemaType> {
|
|
|
19
24
|
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
20
25
|
* using client-side table and column constraints.
|
|
21
26
|
*
|
|
22
|
-
* @param tables An object of (table name, raw table definition) entries.
|
|
27
|
+
* @param tables - An object of (table name, raw table definition) entries.
|
|
23
28
|
*/
|
|
24
29
|
withRawTables(tables: Record<string, RawTableType>): void;
|
|
25
30
|
validate(): void;
|
package/lib/db/schema/Schema.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { encodeTableOptions } from './internal.js';
|
|
2
2
|
/**
|
|
3
3
|
* A schema is a collection of tables. It is used to define the structure of a database.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
4
6
|
*/
|
|
5
7
|
export class Schema {
|
|
6
8
|
/*
|
|
@@ -37,7 +39,7 @@ export class Schema {
|
|
|
37
39
|
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
38
40
|
* using client-side table and column constraints.
|
|
39
41
|
*
|
|
40
|
-
* @param tables An object of (table name, raw table definition) entries.
|
|
42
|
+
* @param tables - An object of (table name, raw table definition) entries.
|
|
41
43
|
*/
|
|
42
44
|
withRawTables(tables) {
|
|
43
45
|
for (const [name, rawTableDefinition] of Object.entries(tables)) {
|
|
@@ -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;
|
|
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,CAAU;IAChB,SAAS,CAAa;IAE/B,YAAY,MAAmB;QAC7B,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,CA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