@powersync/common 0.0.0-dev-20260202162549 → 0.0.0-dev-20260216124709
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 +14470 -0
- package/dist/bundle.cjs.map +1 -0
- package/dist/bundle.mjs +14379 -0
- package/dist/bundle.mjs.map +1 -0
- package/dist/bundle.node.cjs +11948 -0
- package/dist/bundle.node.cjs.map +1 -0
- package/dist/bundle.node.mjs +11857 -0
- package/dist/bundle.node.mjs.map +1 -0
- package/dist/index.d.cts +4272 -0
- package/lib/attachments/AttachmentContext.d.ts +86 -0
- package/lib/attachments/AttachmentContext.js +229 -0
- package/lib/attachments/AttachmentContext.js.map +1 -0
- package/lib/attachments/AttachmentErrorHandler.d.ts +31 -0
- package/lib/attachments/AttachmentErrorHandler.js +2 -0
- package/lib/attachments/AttachmentErrorHandler.js.map +1 -0
- package/lib/attachments/AttachmentQueue.d.ts +149 -0
- package/lib/attachments/AttachmentQueue.js +362 -0
- package/lib/attachments/AttachmentQueue.js.map +1 -0
- package/lib/attachments/AttachmentService.d.ts +29 -0
- package/lib/attachments/AttachmentService.js +56 -0
- package/lib/attachments/AttachmentService.js.map +1 -0
- package/lib/attachments/LocalStorageAdapter.d.ts +62 -0
- package/lib/attachments/LocalStorageAdapter.js +6 -0
- package/lib/attachments/LocalStorageAdapter.js.map +1 -0
- package/lib/attachments/RemoteStorageAdapter.d.ts +27 -0
- package/lib/attachments/RemoteStorageAdapter.js +2 -0
- package/lib/attachments/RemoteStorageAdapter.js.map +1 -0
- package/lib/attachments/Schema.d.ts +50 -0
- package/lib/attachments/Schema.js +62 -0
- package/lib/attachments/Schema.js.map +1 -0
- package/lib/attachments/SyncingService.d.ts +62 -0
- package/lib/attachments/SyncingService.js +168 -0
- package/lib/attachments/SyncingService.js.map +1 -0
- package/lib/attachments/WatchedAttachmentItem.d.ts +17 -0
- package/lib/attachments/WatchedAttachmentItem.js +2 -0
- package/lib/attachments/WatchedAttachmentItem.js.map +1 -0
- package/lib/client/AbstractPowerSyncDatabase.d.ts +615 -0
- package/lib/client/AbstractPowerSyncDatabase.js +983 -0
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -0
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +22 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js +25 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +1 -0
- package/lib/client/ConnectionManager.d.ts +112 -0
- package/lib/client/ConnectionManager.js +294 -0
- package/lib/client/ConnectionManager.js.map +1 -0
- package/lib/client/CustomQuery.d.ts +22 -0
- package/lib/client/CustomQuery.js +43 -0
- package/lib/client/CustomQuery.js.map +1 -0
- package/lib/client/Query.d.ts +97 -0
- package/lib/client/Query.js +2 -0
- package/lib/client/Query.js.map +1 -0
- package/lib/client/SQLOpenFactory.d.ts +42 -0
- package/lib/client/SQLOpenFactory.js +20 -0
- package/lib/client/SQLOpenFactory.js.map +1 -0
- package/lib/client/compilableQueryWatch.d.ts +7 -0
- package/lib/client/compilableQueryWatch.js +38 -0
- package/lib/client/compilableQueryWatch.js.map +1 -0
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +23 -0
- package/lib/client/connection/PowerSyncBackendConnector.js +2 -0
- package/lib/client/connection/PowerSyncBackendConnector.js.map +1 -0
- package/lib/client/connection/PowerSyncCredentials.d.ts +5 -0
- package/lib/client/connection/PowerSyncCredentials.js +2 -0
- package/lib/client/connection/PowerSyncCredentials.js.map +1 -0
- package/lib/client/constants.d.ts +1 -0
- package/lib/client/constants.js +2 -0
- package/lib/client/constants.js.map +1 -0
- package/lib/client/runOnSchemaChange.d.ts +2 -0
- package/lib/client/runOnSchemaChange.js +24 -0
- package/lib/client/runOnSchemaChange.js.map +1 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +102 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js +19 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -0
- package/lib/client/sync/bucket/CrudBatch.d.ts +31 -0
- package/lib/client/sync/bucket/CrudBatch.js +26 -0
- package/lib/client/sync/bucket/CrudBatch.js.map +1 -0
- package/lib/client/sync/bucket/CrudEntry.d.ts +95 -0
- package/lib/client/sync/bucket/CrudEntry.js +110 -0
- package/lib/client/sync/bucket/CrudEntry.js.map +1 -0
- package/lib/client/sync/bucket/CrudTransaction.d.ts +29 -0
- package/lib/client/sync/bucket/CrudTransaction.js +25 -0
- package/lib/client/sync/bucket/CrudTransaction.js.map +1 -0
- package/lib/client/sync/bucket/OpType.d.ts +16 -0
- package/lib/client/sync/bucket/OpType.js +23 -0
- package/lib/client/sync/bucket/OpType.js.map +1 -0
- package/lib/client/sync/bucket/OplogEntry.d.ts +23 -0
- package/lib/client/sync/bucket/OplogEntry.js +36 -0
- package/lib/client/sync/bucket/OplogEntry.js.map +1 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +61 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js +324 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -0
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +6 -0
- package/lib/client/sync/bucket/SyncDataBatch.js +12 -0
- package/lib/client/sync/bucket/SyncDataBatch.js.map +1 -0
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +40 -0
- package/lib/client/sync/bucket/SyncDataBucket.js +40 -0
- package/lib/client/sync/bucket/SyncDataBucket.js.map +1 -0
- package/lib/client/sync/stream/AbstractRemote.d.ts +140 -0
- package/lib/client/sync/stream/AbstractRemote.js +506 -0
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +240 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +990 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -0
- package/lib/client/sync/stream/WebsocketClientTransport.d.ts +15 -0
- package/lib/client/sync/stream/WebsocketClientTransport.js +61 -0
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +1 -0
- package/lib/client/sync/stream/core-instruction.d.ts +72 -0
- package/lib/client/sync/stream/core-instruction.js +27 -0
- package/lib/client/sync/stream/core-instruction.js.map +1 -0
- package/lib/client/sync/stream/streaming-sync-types.d.ts +143 -0
- package/lib/client/sync/stream/streaming-sync-types.js +26 -0
- package/lib/client/sync/stream/streaming-sync-types.js.map +1 -0
- package/lib/client/sync/sync-streams.d.ts +98 -0
- package/lib/client/sync/sync-streams.js +2 -0
- package/lib/client/sync/sync-streams.js.map +1 -0
- package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +6 -0
- package/lib/client/triggers/MemoryTriggerClaimManager.js +21 -0
- package/lib/client/triggers/MemoryTriggerClaimManager.js.map +1 -0
- package/lib/client/triggers/TriggerManager.d.ts +459 -0
- package/lib/client/triggers/TriggerManager.js +11 -0
- package/lib/client/triggers/TriggerManager.js.map +1 -0
- package/lib/client/triggers/TriggerManagerImpl.d.ts +39 -0
- package/lib/client/triggers/TriggerManagerImpl.js +393 -0
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -0
- package/lib/client/triggers/sanitizeSQL.d.ts +34 -0
- package/lib/client/triggers/sanitizeSQL.js +69 -0
- package/lib/client/triggers/sanitizeSQL.js.map +1 -0
- package/lib/client/watched/GetAllQuery.d.ts +32 -0
- package/lib/client/watched/GetAllQuery.js +25 -0
- package/lib/client/watched/GetAllQuery.js.map +1 -0
- package/lib/client/watched/WatchedQuery.d.ts +100 -0
- package/lib/client/watched/WatchedQuery.js +14 -0
- package/lib/client/watched/WatchedQuery.js.map +1 -0
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +68 -0
- package/lib/client/watched/processors/AbstractQueryProcessor.js +151 -0
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +1 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +121 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +173 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -0
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +33 -0
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +83 -0
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -0
- package/lib/client/watched/processors/comparators.d.ts +30 -0
- package/lib/client/watched/processors/comparators.js +35 -0
- package/lib/client/watched/processors/comparators.js.map +1 -0
- package/lib/db/ConnectionClosedError.d.ts +10 -0
- package/lib/db/ConnectionClosedError.js +21 -0
- package/lib/db/ConnectionClosedError.js.map +1 -0
- package/lib/db/DBAdapter.d.ts +115 -0
- package/lib/db/DBAdapter.js +20 -0
- package/lib/db/DBAdapter.js.map +1 -0
- package/lib/db/crud/SyncProgress.d.ts +68 -0
- package/lib/db/crud/SyncProgress.js +61 -0
- package/lib/db/crud/SyncProgress.js.map +1 -0
- package/lib/db/crud/SyncStatus.d.ts +195 -0
- package/lib/db/crud/SyncStatus.js +250 -0
- package/lib/db/crud/SyncStatus.js.map +1 -0
- package/lib/db/crud/UploadQueueStatus.d.ts +20 -0
- package/lib/db/crud/UploadQueueStatus.js +25 -0
- package/lib/db/crud/UploadQueueStatus.js.map +1 -0
- package/lib/db/schema/Column.d.ts +30 -0
- package/lib/db/schema/Column.js +43 -0
- package/lib/db/schema/Column.js.map +1 -0
- package/lib/db/schema/Index.d.ts +22 -0
- package/lib/db/schema/Index.js +30 -0
- package/lib/db/schema/Index.js.map +1 -0
- package/lib/db/schema/IndexedColumn.d.ts +19 -0
- package/lib/db/schema/IndexedColumn.js +30 -0
- package/lib/db/schema/IndexedColumn.js.map +1 -0
- package/lib/db/schema/RawTable.d.ts +61 -0
- package/lib/db/schema/RawTable.js +33 -0
- package/lib/db/schema/RawTable.js.map +1 -0
- package/lib/db/schema/Schema.d.ts +54 -0
- package/lib/db/schema/Schema.js +61 -0
- package/lib/db/schema/Schema.js.map +1 -0
- package/lib/db/schema/Table.d.ts +157 -0
- package/lib/db/schema/Table.js +208 -0
- package/lib/db/schema/Table.js.map +1 -0
- package/lib/db/schema/TableV2.d.ts +9 -0
- package/lib/db/schema/TableV2.js +9 -0
- package/lib/db/schema/TableV2.js.map +1 -0
- package/lib/index.d.ts +62 -0
- package/lib/index.js +63 -0
- package/lib/index.js.map +1 -0
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.js +2 -0
- package/lib/types/types.js.map +1 -0
- package/lib/utils/AbortOperation.d.ts +9 -0
- package/lib/utils/AbortOperation.js +19 -0
- package/lib/utils/AbortOperation.js.map +1 -0
- package/lib/utils/BaseObserver.d.ts +18 -0
- package/lib/utils/BaseObserver.js +27 -0
- package/lib/utils/BaseObserver.js.map +1 -0
- package/lib/utils/ControlledExecutor.d.ts +25 -0
- package/lib/utils/ControlledExecutor.js +51 -0
- package/lib/utils/ControlledExecutor.js.map +1 -0
- package/lib/utils/DataStream.d.ts +62 -0
- package/lib/utils/DataStream.js +169 -0
- package/lib/utils/DataStream.js.map +1 -0
- package/lib/utils/Logger.d.ts +31 -0
- package/lib/utils/Logger.js +37 -0
- package/lib/utils/Logger.js.map +1 -0
- package/lib/utils/MetaBaseObserver.d.ts +29 -0
- package/lib/utils/MetaBaseObserver.js +51 -0
- package/lib/utils/MetaBaseObserver.js.map +1 -0
- package/lib/utils/async.d.ts +23 -0
- package/lib/utils/async.js +55 -0
- package/lib/utils/async.js.map +1 -0
- package/lib/utils/mutex.d.ts +7 -0
- package/lib/utils/mutex.js +29 -0
- package/lib/utils/mutex.js.map +1 -0
- package/lib/utils/parseQuery.d.ts +6 -0
- package/lib/utils/parseQuery.js +17 -0
- package/lib/utils/parseQuery.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { SyncClientImplementation } from '../../client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
2
|
+
import { CoreStreamSubscription } from '../../client/sync/stream/core-instruction.js';
|
|
3
|
+
import { SyncStreamDescription, SyncSubscriptionDescription } from '../../client/sync/sync-streams.js';
|
|
4
|
+
import { InternalProgressInformation, ProgressWithOperations, SyncProgress } from './SyncProgress.js';
|
|
5
|
+
export type SyncDataFlowStatus = Partial<{
|
|
6
|
+
downloading: boolean;
|
|
7
|
+
uploading: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Error during downloading (including connecting).
|
|
10
|
+
*
|
|
11
|
+
* Cleared on the next successful data download.
|
|
12
|
+
*/
|
|
13
|
+
downloadError?: Error;
|
|
14
|
+
/**
|
|
15
|
+
* Error during uploading.
|
|
16
|
+
* Cleared on the next successful upload.
|
|
17
|
+
*/
|
|
18
|
+
uploadError?: Error;
|
|
19
|
+
/**
|
|
20
|
+
* Internal information about how far we are downloading operations in buckets.
|
|
21
|
+
*
|
|
22
|
+
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
23
|
+
*/
|
|
24
|
+
downloadProgress: InternalProgressInformation | null;
|
|
25
|
+
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
26
|
+
}>;
|
|
27
|
+
export interface SyncPriorityStatus {
|
|
28
|
+
priority: number;
|
|
29
|
+
lastSyncedAt?: Date;
|
|
30
|
+
hasSynced?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type SyncStatusOptions = {
|
|
33
|
+
connected?: boolean;
|
|
34
|
+
connecting?: boolean;
|
|
35
|
+
dataFlow?: SyncDataFlowStatus;
|
|
36
|
+
lastSyncedAt?: Date;
|
|
37
|
+
hasSynced?: boolean;
|
|
38
|
+
priorityStatusEntries?: SyncPriorityStatus[];
|
|
39
|
+
clientImplementation?: SyncClientImplementation;
|
|
40
|
+
};
|
|
41
|
+
export declare class SyncStatus {
|
|
42
|
+
protected options: SyncStatusOptions;
|
|
43
|
+
constructor(options: SyncStatusOptions);
|
|
44
|
+
/**
|
|
45
|
+
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
46
|
+
* implementation).
|
|
47
|
+
*
|
|
48
|
+
* This information is only available after a connection has been requested.
|
|
49
|
+
*/
|
|
50
|
+
get clientImplementation(): SyncClientImplementation | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Indicates if the client is currently connected to the PowerSync service.
|
|
53
|
+
*
|
|
54
|
+
* @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
|
|
55
|
+
*/
|
|
56
|
+
get connected(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean} True if connecting, false otherwise. Defaults to false if not specified.
|
|
61
|
+
*/
|
|
62
|
+
get connecting(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Time that a last sync has fully completed, if any.
|
|
65
|
+
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
66
|
+
*
|
|
67
|
+
* @returns {Date | undefined} The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
68
|
+
*/
|
|
69
|
+
get lastSyncedAt(): Date | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Indicates whether there has been at least one full sync completed since initialization.
|
|
72
|
+
*
|
|
73
|
+
* @returns {boolean | undefined} True if at least one sync has completed, false if no sync has completed,
|
|
74
|
+
* or undefined when the state is still being loaded from the database.
|
|
75
|
+
*/
|
|
76
|
+
get hasSynced(): boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Provides the current data flow status regarding uploads and downloads.
|
|
79
|
+
*
|
|
80
|
+
* @returns {SyncDataFlowStatus} An object containing:
|
|
81
|
+
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
82
|
+
* - uploading: True if actively uploading changes
|
|
83
|
+
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
84
|
+
*/
|
|
85
|
+
get dataFlowStatus(): Partial<{
|
|
86
|
+
downloading: boolean;
|
|
87
|
+
uploading: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Error during downloading (including connecting).
|
|
90
|
+
*
|
|
91
|
+
* Cleared on the next successful data download.
|
|
92
|
+
*/
|
|
93
|
+
downloadError?: Error;
|
|
94
|
+
/**
|
|
95
|
+
* Error during uploading.
|
|
96
|
+
* Cleared on the next successful upload.
|
|
97
|
+
*/
|
|
98
|
+
uploadError?: Error;
|
|
99
|
+
/**
|
|
100
|
+
* Internal information about how far we are downloading operations in buckets.
|
|
101
|
+
*
|
|
102
|
+
* Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
|
|
103
|
+
*/
|
|
104
|
+
downloadProgress: InternalProgressInformation | null;
|
|
105
|
+
internalStreamSubscriptions: CoreStreamSubscription[] | null;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* All sync streams currently being tracked in teh database.
|
|
109
|
+
*
|
|
110
|
+
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
111
|
+
* included streams yet.
|
|
112
|
+
*
|
|
113
|
+
* @experimental Sync streams are currently in alpha.
|
|
114
|
+
*/
|
|
115
|
+
get syncStreams(): SyncStreamStatus[] | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
118
|
+
*
|
|
119
|
+
* @experimental Sync streams are currently in alpha.
|
|
120
|
+
*/
|
|
121
|
+
forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
124
|
+
*
|
|
125
|
+
* @returns {SyncPriorityStatus[]} An array of status entries for different sync priority levels,
|
|
126
|
+
* sorted with highest priorities (lower numbers) first.
|
|
127
|
+
*/
|
|
128
|
+
get priorityStatusEntries(): SyncPriorityStatus[];
|
|
129
|
+
/**
|
|
130
|
+
* A realtime progress report on how many operations have been downloaded and
|
|
131
|
+
* how many are necessary in total to complete the next sync iteration.
|
|
132
|
+
*
|
|
133
|
+
* This field is only set when {@link SyncDataFlowStatus#downloading} is also true.
|
|
134
|
+
*/
|
|
135
|
+
get downloadProgress(): SyncProgress | null;
|
|
136
|
+
/**
|
|
137
|
+
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
|
|
138
|
+
* for a specific bucket priority level.
|
|
139
|
+
*
|
|
140
|
+
* When buckets with different priorities are declared, PowerSync may choose to synchronize higher-priority
|
|
141
|
+
* buckets first. When a consistent view over all buckets for all priorities up until the given priority is
|
|
142
|
+
* reached, PowerSync makes data from those buckets available before lower-priority buckets have finished
|
|
143
|
+
* syncing.
|
|
144
|
+
*
|
|
145
|
+
* This method returns the status for the requested priority or the next higher priority level that has
|
|
146
|
+
* status information available. This is because when PowerSync makes data for a given priority available,
|
|
147
|
+
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
|
|
148
|
+
*
|
|
149
|
+
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
150
|
+
* with a priority of 1 may return information for priority level 3.
|
|
151
|
+
*
|
|
152
|
+
* @param {number} priority The bucket priority for which the status should be reported
|
|
153
|
+
* @returns {SyncPriorityStatus} Status information for the requested priority level or the next higher level with available status
|
|
154
|
+
*/
|
|
155
|
+
statusForPriority(priority: number): SyncPriorityStatus;
|
|
156
|
+
/**
|
|
157
|
+
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
158
|
+
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
159
|
+
*
|
|
160
|
+
* @param {SyncStatus} status The SyncStatus instance to compare against
|
|
161
|
+
* @returns {boolean} True if the instances are considered equal, false otherwise
|
|
162
|
+
*/
|
|
163
|
+
isEqual(status: SyncStatus): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Creates a human-readable string representation of the current sync status.
|
|
166
|
+
* Includes information about connection state, sync completion, and data flow.
|
|
167
|
+
*
|
|
168
|
+
* @returns {string} A string representation of the sync status
|
|
169
|
+
*/
|
|
170
|
+
getMessage(): string;
|
|
171
|
+
/**
|
|
172
|
+
* Serializes the SyncStatus instance to a plain object.
|
|
173
|
+
*
|
|
174
|
+
* @returns {SyncStatusOptions} A plain object representation of the sync status
|
|
175
|
+
*/
|
|
176
|
+
toJSON(): SyncStatusOptions;
|
|
177
|
+
/**
|
|
178
|
+
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
179
|
+
* This explicitly serializes errors in the SyncStatus.
|
|
180
|
+
*/
|
|
181
|
+
protected serializeError(error?: Error): {
|
|
182
|
+
name: string;
|
|
183
|
+
message: string;
|
|
184
|
+
stack: string | undefined;
|
|
185
|
+
} | undefined;
|
|
186
|
+
private static comparePriorities;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Information about a sync stream subscription.
|
|
190
|
+
*/
|
|
191
|
+
export interface SyncStreamStatus {
|
|
192
|
+
progress: ProgressWithOperations | null;
|
|
193
|
+
subscription: SyncSubscriptionDescription;
|
|
194
|
+
priority: number | null;
|
|
195
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { SyncProgress } from './SyncProgress.js';
|
|
2
|
+
export class SyncStatus {
|
|
3
|
+
options;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
9
|
+
* implementation).
|
|
10
|
+
*
|
|
11
|
+
* This information is only available after a connection has been requested.
|
|
12
|
+
*/
|
|
13
|
+
get clientImplementation() {
|
|
14
|
+
return this.options.clientImplementation;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Indicates if the client is currently connected to the PowerSync service.
|
|
18
|
+
*
|
|
19
|
+
* @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
|
|
20
|
+
*/
|
|
21
|
+
get connected() {
|
|
22
|
+
return this.options.connected ?? false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
|
|
26
|
+
*
|
|
27
|
+
* @returns {boolean} True if connecting, false otherwise. Defaults to false if not specified.
|
|
28
|
+
*/
|
|
29
|
+
get connecting() {
|
|
30
|
+
return this.options.connecting ?? false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Time that a last sync has fully completed, if any.
|
|
34
|
+
* This timestamp is reset to null after a restart of the PowerSync service.
|
|
35
|
+
*
|
|
36
|
+
* @returns {Date | undefined} The timestamp of the last successful sync, or undefined if no sync has completed.
|
|
37
|
+
*/
|
|
38
|
+
get lastSyncedAt() {
|
|
39
|
+
return this.options.lastSyncedAt;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Indicates whether there has been at least one full sync completed since initialization.
|
|
43
|
+
*
|
|
44
|
+
* @returns {boolean | undefined} True if at least one sync has completed, false if no sync has completed,
|
|
45
|
+
* or undefined when the state is still being loaded from the database.
|
|
46
|
+
*/
|
|
47
|
+
get hasSynced() {
|
|
48
|
+
return this.options.hasSynced;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Provides the current data flow status regarding uploads and downloads.
|
|
52
|
+
*
|
|
53
|
+
* @returns {SyncDataFlowStatus} An object containing:
|
|
54
|
+
* - downloading: True if actively downloading changes (only when connected is also true)
|
|
55
|
+
* - uploading: True if actively uploading changes
|
|
56
|
+
* Defaults to {downloading: false, uploading: false} if not specified.
|
|
57
|
+
*/
|
|
58
|
+
get dataFlowStatus() {
|
|
59
|
+
return (this.options.dataFlow ?? {
|
|
60
|
+
/**
|
|
61
|
+
* true if actively downloading changes.
|
|
62
|
+
* This is only true when {@link connected} is also true.
|
|
63
|
+
*/
|
|
64
|
+
downloading: false,
|
|
65
|
+
/**
|
|
66
|
+
* true if uploading changes.
|
|
67
|
+
*/
|
|
68
|
+
uploading: false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* All sync streams currently being tracked in teh database.
|
|
73
|
+
*
|
|
74
|
+
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
75
|
+
* included streams yet.
|
|
76
|
+
*
|
|
77
|
+
* @experimental Sync streams are currently in alpha.
|
|
78
|
+
*/
|
|
79
|
+
get syncStreams() {
|
|
80
|
+
return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
84
|
+
*
|
|
85
|
+
* @experimental Sync streams are currently in alpha.
|
|
86
|
+
*/
|
|
87
|
+
forStream(stream) {
|
|
88
|
+
const asJson = JSON.stringify(stream.parameters);
|
|
89
|
+
const raw = this.options.dataFlow?.internalStreamSubscriptions?.find((r) => r.name == stream.name && asJson == JSON.stringify(r.parameters));
|
|
90
|
+
return raw && new SyncStreamStatusView(this, raw);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
94
|
+
*
|
|
95
|
+
* @returns {SyncPriorityStatus[]} An array of status entries for different sync priority levels,
|
|
96
|
+
* sorted with highest priorities (lower numbers) first.
|
|
97
|
+
*/
|
|
98
|
+
get priorityStatusEntries() {
|
|
99
|
+
return (this.options.priorityStatusEntries ?? []).slice().sort(SyncStatus.comparePriorities);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A realtime progress report on how many operations have been downloaded and
|
|
103
|
+
* how many are necessary in total to complete the next sync iteration.
|
|
104
|
+
*
|
|
105
|
+
* This field is only set when {@link SyncDataFlowStatus#downloading} is also true.
|
|
106
|
+
*/
|
|
107
|
+
get downloadProgress() {
|
|
108
|
+
const internalProgress = this.options.dataFlow?.downloadProgress;
|
|
109
|
+
if (internalProgress == null) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return new SyncProgress(internalProgress);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
|
|
116
|
+
* for a specific bucket priority level.
|
|
117
|
+
*
|
|
118
|
+
* When buckets with different priorities are declared, PowerSync may choose to synchronize higher-priority
|
|
119
|
+
* buckets first. When a consistent view over all buckets for all priorities up until the given priority is
|
|
120
|
+
* reached, PowerSync makes data from those buckets available before lower-priority buckets have finished
|
|
121
|
+
* syncing.
|
|
122
|
+
*
|
|
123
|
+
* This method returns the status for the requested priority or the next higher priority level that has
|
|
124
|
+
* status information available. This is because when PowerSync makes data for a given priority available,
|
|
125
|
+
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
|
|
126
|
+
*
|
|
127
|
+
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
|
|
128
|
+
* with a priority of 1 may return information for priority level 3.
|
|
129
|
+
*
|
|
130
|
+
* @param {number} priority The bucket priority for which the status should be reported
|
|
131
|
+
* @returns {SyncPriorityStatus} Status information for the requested priority level or the next higher level with available status
|
|
132
|
+
*/
|
|
133
|
+
statusForPriority(priority) {
|
|
134
|
+
// priorityStatusEntries are sorted by ascending priorities (so higher numbers to lower numbers).
|
|
135
|
+
for (const known of this.priorityStatusEntries) {
|
|
136
|
+
// We look for the first entry that doesn't have a higher priority.
|
|
137
|
+
if (known.priority >= priority) {
|
|
138
|
+
return known;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// If we have a complete sync, that necessarily includes all priorities.
|
|
142
|
+
return {
|
|
143
|
+
priority,
|
|
144
|
+
lastSyncedAt: this.lastSyncedAt,
|
|
145
|
+
hasSynced: this.hasSynced
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Compares this SyncStatus instance with another to determine if they are equal.
|
|
150
|
+
* Equality is determined by comparing the serialized JSON representation of both instances.
|
|
151
|
+
*
|
|
152
|
+
* @param {SyncStatus} status The SyncStatus instance to compare against
|
|
153
|
+
* @returns {boolean} True if the instances are considered equal, false otherwise
|
|
154
|
+
*/
|
|
155
|
+
isEqual(status) {
|
|
156
|
+
/**
|
|
157
|
+
* By default Error object are serialized to an empty object.
|
|
158
|
+
* This replaces Errors with more useful information before serialization.
|
|
159
|
+
*/
|
|
160
|
+
const replacer = (_, value) => {
|
|
161
|
+
if (value instanceof Error) {
|
|
162
|
+
return {
|
|
163
|
+
name: value.name,
|
|
164
|
+
message: value.message,
|
|
165
|
+
stack: value.stack
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return value;
|
|
169
|
+
};
|
|
170
|
+
return JSON.stringify(this.options, replacer) == JSON.stringify(status.options, replacer);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Creates a human-readable string representation of the current sync status.
|
|
174
|
+
* Includes information about connection state, sync completion, and data flow.
|
|
175
|
+
*
|
|
176
|
+
* @returns {string} A string representation of the sync status
|
|
177
|
+
*/
|
|
178
|
+
getMessage() {
|
|
179
|
+
const dataFlow = this.dataFlowStatus;
|
|
180
|
+
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}>`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Serializes the SyncStatus instance to a plain object.
|
|
184
|
+
*
|
|
185
|
+
* @returns {SyncStatusOptions} A plain object representation of the sync status
|
|
186
|
+
*/
|
|
187
|
+
toJSON() {
|
|
188
|
+
return {
|
|
189
|
+
connected: this.connected,
|
|
190
|
+
connecting: this.connecting,
|
|
191
|
+
dataFlow: {
|
|
192
|
+
...this.dataFlowStatus,
|
|
193
|
+
uploadError: this.serializeError(this.dataFlowStatus.uploadError),
|
|
194
|
+
downloadError: this.serializeError(this.dataFlowStatus.downloadError)
|
|
195
|
+
},
|
|
196
|
+
lastSyncedAt: this.lastSyncedAt,
|
|
197
|
+
hasSynced: this.hasSynced,
|
|
198
|
+
priorityStatusEntries: this.priorityStatusEntries
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
203
|
+
* This explicitly serializes errors in the SyncStatus.
|
|
204
|
+
*/
|
|
205
|
+
serializeError(error) {
|
|
206
|
+
if (typeof error == 'undefined') {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
name: error.name,
|
|
211
|
+
message: error.message,
|
|
212
|
+
stack: error.stack
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
static comparePriorities(a, b) {
|
|
216
|
+
return b.priority - a.priority; // Reverse because higher priorities have lower numbers
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
class SyncStreamStatusView {
|
|
220
|
+
status;
|
|
221
|
+
core;
|
|
222
|
+
subscription;
|
|
223
|
+
constructor(status, core) {
|
|
224
|
+
this.status = status;
|
|
225
|
+
this.core = core;
|
|
226
|
+
this.subscription = {
|
|
227
|
+
name: core.name,
|
|
228
|
+
parameters: core.parameters,
|
|
229
|
+
active: core.active,
|
|
230
|
+
isDefault: core.is_default,
|
|
231
|
+
hasExplicitSubscription: core.has_explicit_subscription,
|
|
232
|
+
expiresAt: core.expires_at != null ? new Date(core.expires_at * 1000) : null,
|
|
233
|
+
hasSynced: core.last_synced_at != null,
|
|
234
|
+
lastSyncedAt: core.last_synced_at != null ? new Date(core.last_synced_at * 1000) : null
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
get progress() {
|
|
238
|
+
if (this.status.dataFlowStatus.downloadProgress == null) {
|
|
239
|
+
// Don't make download progress public if we're not currently downloading.
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const { total, downloaded } = this.core.progress;
|
|
243
|
+
const progress = total == 0 ? 0.0 : downloaded / total;
|
|
244
|
+
return { totalOperations: total, downloadedOperations: downloaded, downloadedFraction: progress };
|
|
245
|
+
}
|
|
246
|
+
get priority() {
|
|
247
|
+
return this.core.priority;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=SyncStatus.js.map
|
|
@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I,IAAI,EAAE,CAAC;YACxD,0EAA0E;YAC1E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACjD,MAAM,QAAQ,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;QAEvD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IACpG,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class UploadQueueStats {
|
|
2
|
+
/**
|
|
3
|
+
* Number of records in the upload queue.
|
|
4
|
+
*/
|
|
5
|
+
count: number;
|
|
6
|
+
/**
|
|
7
|
+
* Size of the upload queue in bytes.
|
|
8
|
+
*/
|
|
9
|
+
size: number | null;
|
|
10
|
+
constructor(
|
|
11
|
+
/**
|
|
12
|
+
* Number of records in the upload queue.
|
|
13
|
+
*/
|
|
14
|
+
count: number,
|
|
15
|
+
/**
|
|
16
|
+
* Size of the upload queue in bytes.
|
|
17
|
+
*/
|
|
18
|
+
size?: number | null);
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class UploadQueueStats {
|
|
2
|
+
count;
|
|
3
|
+
size;
|
|
4
|
+
constructor(
|
|
5
|
+
/**
|
|
6
|
+
* Number of records in the upload queue.
|
|
7
|
+
*/
|
|
8
|
+
count,
|
|
9
|
+
/**
|
|
10
|
+
* Size of the upload queue in bytes.
|
|
11
|
+
*/
|
|
12
|
+
size = null) {
|
|
13
|
+
this.count = count;
|
|
14
|
+
this.size = size;
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
if (this.size == null) {
|
|
18
|
+
return `UploadQueueStats<count:${this.count}>`;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return `UploadQueueStats<count: $count size: ${this.size / 1024}kB>`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=UploadQueueStatus.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare enum ColumnType {
|
|
2
|
+
TEXT = "TEXT",
|
|
3
|
+
INTEGER = "INTEGER",
|
|
4
|
+
REAL = "REAL"
|
|
5
|
+
}
|
|
6
|
+
export interface ColumnOptions {
|
|
7
|
+
name: string;
|
|
8
|
+
type?: ColumnType;
|
|
9
|
+
}
|
|
10
|
+
export type BaseColumnType<T extends number | string | null> = {
|
|
11
|
+
type: ColumnType;
|
|
12
|
+
};
|
|
13
|
+
export type ColumnsType = Record<string, BaseColumnType<any>>;
|
|
14
|
+
export type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
|
|
15
|
+
export declare const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
16
|
+
export declare const column: {
|
|
17
|
+
text: BaseColumnType<string | null>;
|
|
18
|
+
integer: BaseColumnType<number | null>;
|
|
19
|
+
real: BaseColumnType<number | null>;
|
|
20
|
+
};
|
|
21
|
+
export declare class Column {
|
|
22
|
+
protected options: ColumnOptions;
|
|
23
|
+
constructor(options: ColumnOptions);
|
|
24
|
+
get name(): string;
|
|
25
|
+
get type(): ColumnType | undefined;
|
|
26
|
+
toJSON(): {
|
|
27
|
+
name: string;
|
|
28
|
+
type: ColumnType | undefined;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
2
|
+
export var ColumnType;
|
|
3
|
+
(function (ColumnType) {
|
|
4
|
+
ColumnType["TEXT"] = "TEXT";
|
|
5
|
+
ColumnType["INTEGER"] = "INTEGER";
|
|
6
|
+
ColumnType["REAL"] = "REAL";
|
|
7
|
+
})(ColumnType || (ColumnType = {}));
|
|
8
|
+
const text = {
|
|
9
|
+
type: ColumnType.TEXT
|
|
10
|
+
};
|
|
11
|
+
const integer = {
|
|
12
|
+
type: ColumnType.INTEGER
|
|
13
|
+
};
|
|
14
|
+
const real = {
|
|
15
|
+
type: ColumnType.REAL
|
|
16
|
+
};
|
|
17
|
+
// powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
|
|
18
|
+
// In earlier versions this was limited to 63.
|
|
19
|
+
export const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
20
|
+
export const column = {
|
|
21
|
+
text,
|
|
22
|
+
integer,
|
|
23
|
+
real
|
|
24
|
+
};
|
|
25
|
+
export class Column {
|
|
26
|
+
options;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
get name() {
|
|
31
|
+
return this.options.name;
|
|
32
|
+
}
|
|
33
|
+
get type() {
|
|
34
|
+
return this.options.type;
|
|
35
|
+
}
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {
|
|
38
|
+
name: this.name,
|
|
39
|
+
type: this.type
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../../src/db/schema/Column.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAeD,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,sGAAsG;AACtG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,IAAI;CACL,CAAC;AAEF,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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IndexedColumn } from './IndexedColumn.js';
|
|
2
|
+
import { Table } from './Table.js';
|
|
3
|
+
export interface IndexOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
columns?: IndexedColumn[];
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_INDEX_OPTIONS: Partial<IndexOptions>;
|
|
8
|
+
export declare class Index {
|
|
9
|
+
protected options: IndexOptions;
|
|
10
|
+
static createAscending(options: IndexOptions, columnNames: string[]): Index;
|
|
11
|
+
constructor(options: IndexOptions);
|
|
12
|
+
get name(): string;
|
|
13
|
+
get columns(): IndexedColumn[];
|
|
14
|
+
toJSON(table: Table): {
|
|
15
|
+
name: string;
|
|
16
|
+
columns: {
|
|
17
|
+
name: string;
|
|
18
|
+
ascending: boolean | undefined;
|
|
19
|
+
type: import("./Column.js").ColumnType;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IndexedColumn } from './IndexedColumn.js';
|
|
2
|
+
export const DEFAULT_INDEX_OPTIONS = {
|
|
3
|
+
columns: []
|
|
4
|
+
};
|
|
5
|
+
export class Index {
|
|
6
|
+
options;
|
|
7
|
+
static createAscending(options, columnNames) {
|
|
8
|
+
return new Index({
|
|
9
|
+
...options,
|
|
10
|
+
columns: columnNames.map((name) => IndexedColumn.createAscending(name))
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
this.options = { ...DEFAULT_INDEX_OPTIONS, ...options };
|
|
16
|
+
}
|
|
17
|
+
get name() {
|
|
18
|
+
return this.options.name;
|
|
19
|
+
}
|
|
20
|
+
get columns() {
|
|
21
|
+
return this.options.columns ?? [];
|
|
22
|
+
}
|
|
23
|
+
toJSON(table) {
|
|
24
|
+
return {
|
|
25
|
+
name: this.name,
|
|
26
|
+
columns: this.columns.map((c) => c.toJSON(table))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=Index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/db/schema/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnType } from './Column.js';
|
|
2
|
+
import { Table } from './Table.js';
|
|
3
|
+
export interface IndexColumnOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
ascending?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
|
|
8
|
+
export declare class IndexedColumn {
|
|
9
|
+
protected options: IndexColumnOptions;
|
|
10
|
+
static createAscending(column: string): IndexedColumn;
|
|
11
|
+
constructor(options: IndexColumnOptions);
|
|
12
|
+
get name(): string;
|
|
13
|
+
get ascending(): boolean | undefined;
|
|
14
|
+
toJSON(table: Table): {
|
|
15
|
+
name: string;
|
|
16
|
+
ascending: boolean | undefined;
|
|
17
|
+
type: ColumnType;
|
|
18
|
+
};
|
|
19
|
+
}
|