@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.
Files changed (219) hide show
  1. package/lib/attachments/AttachmentContext.d.ts +5 -5
  2. package/lib/attachments/AttachmentContext.js +6 -2
  3. package/lib/attachments/AttachmentContext.js.map +1 -1
  4. package/lib/attachments/AttachmentQueue.d.ts +6 -6
  5. package/lib/attachments/AttachmentQueue.js +9 -8
  6. package/lib/attachments/AttachmentQueue.js.map +1 -1
  7. package/lib/attachments/AttachmentService.d.ts +3 -3
  8. package/lib/attachments/AttachmentService.js +4 -3
  9. package/lib/attachments/AttachmentService.js.map +1 -1
  10. package/lib/attachments/Schema.d.ts +2 -2
  11. package/lib/attachments/SyncingService.d.ts +2 -2
  12. package/lib/attachments/SyncingService.js +21 -6
  13. package/lib/attachments/SyncingService.js.map +1 -1
  14. package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +56 -232
  15. package/lib/client/CommonPowerSyncDatabase.js +2 -0
  16. package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
  17. package/lib/client/SQLOpenFactory.d.ts +35 -13
  18. package/lib/client/SQLOpenFactory.js +1 -25
  19. package/lib/client/SQLOpenFactory.js.map +1 -1
  20. package/lib/client/compilableQueryWatch.d.ts +2 -2
  21. package/lib/client/compilableQueryWatch.js +1 -2
  22. package/lib/client/compilableQueryWatch.js.map +1 -1
  23. package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -3
  24. package/lib/client/runOnSchemaChange.d.ts +2 -2
  25. package/lib/client/runOnSchemaChange.js.map +1 -1
  26. package/lib/client/sync/bucket/CrudEntry.d.ts +3 -34
  27. package/lib/client/sync/bucket/CrudEntry.js +0 -99
  28. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  29. package/lib/client/sync/options.d.ts +65 -0
  30. package/lib/client/sync/options.js +25 -0
  31. package/lib/client/sync/options.js.map +1 -0
  32. package/lib/client/sync/sync-streams.d.ts +1 -1
  33. package/lib/client/triggers/TriggerManager.d.ts +9 -38
  34. package/lib/client/watched/GetAllQuery.d.ts +3 -3
  35. package/lib/client/watched/GetAllQuery.js +1 -1
  36. package/lib/client/watched/GetAllQuery.js.map +1 -1
  37. package/lib/client/watched/WatchedQuery.d.ts +2 -10
  38. package/lib/client/watched/WatchedQuery.js +0 -11
  39. package/lib/client/watched/WatchedQuery.js.map +1 -1
  40. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +0 -50
  41. package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -176
  42. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  43. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +0 -22
  44. package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
  45. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  46. package/lib/db/DBAdapter.d.ts +72 -154
  47. package/lib/db/DBAdapter.js +70 -108
  48. package/lib/db/DBAdapter.js.map +1 -1
  49. package/lib/db/QueryResult.d.ts +104 -0
  50. package/lib/db/QueryResult.js +96 -0
  51. package/lib/db/QueryResult.js.map +1 -0
  52. package/lib/db/crud/SyncProgress.d.ts +1 -13
  53. package/lib/db/crud/SyncProgress.js +1 -62
  54. package/lib/db/crud/SyncProgress.js.map +1 -1
  55. package/lib/db/crud/SyncStatus.d.ts +32 -66
  56. package/lib/db/crud/SyncStatus.js +1 -253
  57. package/lib/db/crud/SyncStatus.js.map +1 -1
  58. package/lib/db/schema/Column.d.ts +0 -7
  59. package/lib/db/schema/Column.js +0 -7
  60. package/lib/db/schema/Column.js.map +1 -1
  61. package/lib/db/schema/Index.d.ts +2 -6
  62. package/lib/db/schema/Index.js +1 -4
  63. package/lib/db/schema/Index.js.map +1 -1
  64. package/lib/db/schema/IndexedColumn.d.ts +2 -6
  65. package/lib/db/schema/IndexedColumn.js +1 -4
  66. package/lib/db/schema/IndexedColumn.js.map +1 -1
  67. package/lib/db/schema/Schema.d.ts +4 -28
  68. package/lib/db/schema/Schema.js.map +1 -1
  69. package/lib/db/schema/Table.d.ts +50 -96
  70. package/lib/db/schema/Table.js +83 -91
  71. package/lib/db/schema/Table.js.map +1 -1
  72. package/lib/index.d.ts +5 -21
  73. package/lib/index.js +5 -22
  74. package/lib/index.js.map +1 -1
  75. package/lib/utils/BaseObserver.d.ts +1 -1
  76. package/lib/utils/BaseObserver.js +1 -1
  77. package/lib/utils/Logger.d.ts +52 -23
  78. package/lib/utils/Logger.js +35 -33
  79. package/lib/utils/Logger.js.map +1 -1
  80. package/lib/utils/MetaBaseObserver.d.ts +11 -11
  81. package/lib/utils/MetaBaseObserver.js +1 -50
  82. package/lib/utils/MetaBaseObserver.js.map +1 -1
  83. package/lib/utils/mutex.d.ts +3 -53
  84. package/lib/utils/mutex.js +1 -156
  85. package/lib/utils/mutex.js.map +1 -1
  86. package/package.json +8 -45
  87. package/src/attachments/AttachmentContext.ts +11 -10
  88. package/src/attachments/AttachmentQueue.ts +15 -14
  89. package/src/attachments/AttachmentService.ts +7 -6
  90. package/src/attachments/Schema.ts +2 -2
  91. package/src/attachments/SyncingService.ts +23 -9
  92. package/src/client/CommonPowerSyncDatabase.ts +540 -0
  93. package/src/client/SQLOpenFactory.ts +38 -22
  94. package/src/client/compilableQueryWatch.ts +3 -4
  95. package/src/client/connection/PowerSyncBackendConnector.ts +3 -3
  96. package/src/client/runOnSchemaChange.ts +2 -2
  97. package/src/client/sync/bucket/CrudEntry.ts +4 -104
  98. package/src/client/sync/options.ts +77 -0
  99. package/src/client/sync/sync-streams.ts +1 -1
  100. package/src/client/triggers/TriggerManager.ts +10 -41
  101. package/src/client/watched/GetAllQuery.ts +3 -3
  102. package/src/client/watched/WatchedQuery.ts +2 -15
  103. package/src/client/watched/processors/DifferentialQueryProcessor.ts +0 -223
  104. package/src/client/watched/processors/OnChangeQueryProcessor.ts +0 -111
  105. package/src/db/DBAdapter.ts +141 -226
  106. package/src/db/QueryResult.ts +195 -0
  107. package/src/db/crud/SyncProgress.ts +2 -42
  108. package/src/db/crud/SyncStatus.ts +45 -220
  109. package/src/db/schema/Column.ts +0 -8
  110. package/src/db/schema/Index.ts +3 -6
  111. package/src/db/schema/IndexedColumn.ts +3 -6
  112. package/src/db/schema/Schema.ts +4 -4
  113. package/src/db/schema/Table.ts +111 -186
  114. package/src/index.ts +5 -21
  115. package/src/utils/BaseObserver.ts +1 -1
  116. package/src/utils/Logger.ts +80 -34
  117. package/src/utils/MetaBaseObserver.ts +14 -60
  118. package/src/utils/mutex.ts +4 -201
  119. package/dist/bundle.cjs +0 -14390
  120. package/dist/bundle.cjs.map +0 -1
  121. package/dist/bundle.mjs +0 -14309
  122. package/dist/bundle.mjs.map +0 -1
  123. package/dist/bundle.node.cjs +0 -12021
  124. package/dist/bundle.node.cjs.map +0 -1
  125. package/dist/bundle.node.mjs +0 -11940
  126. package/dist/bundle.node.mjs.map +0 -1
  127. package/dist/index.d.cts +0 -4651
  128. package/legacy/sync_protocol.d.ts +0 -103
  129. package/lib/client/AbstractPowerSyncDatabase.js +0 -990
  130. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  131. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -28
  132. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -28
  133. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  134. package/lib/client/ConnectionManager.d.ts +0 -115
  135. package/lib/client/ConnectionManager.js +0 -294
  136. package/lib/client/ConnectionManager.js.map +0 -1
  137. package/lib/client/CustomQuery.d.ts +0 -22
  138. package/lib/client/CustomQuery.js +0 -43
  139. package/lib/client/CustomQuery.js.map +0 -1
  140. package/lib/client/constants.d.ts +0 -4
  141. package/lib/client/constants.js +0 -5
  142. package/lib/client/constants.js.map +0 -1
  143. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -56
  144. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -29
  145. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  146. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -37
  147. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -165
  148. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  149. package/lib/client/sync/stream/AbstractRemote.d.ts +0 -180
  150. package/lib/client/sync/stream/AbstractRemote.js +0 -505
  151. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  152. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -265
  153. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -705
  154. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  155. package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
  156. package/lib/client/sync/stream/WebsocketClientTransport.js +0 -62
  157. package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
  158. package/lib/client/sync/stream/core-instruction.d.ts +0 -77
  159. package/lib/client/sync/stream/core-instruction.js +0 -30
  160. package/lib/client/sync/stream/core-instruction.js.map +0 -1
  161. package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
  162. package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
  163. package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
  164. package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
  165. package/lib/client/triggers/TriggerManagerImpl.js +0 -410
  166. package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
  167. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
  168. package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
  169. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
  170. package/lib/db/ConnectionClosedError.d.ts +0 -12
  171. package/lib/db/ConnectionClosedError.js +0 -23
  172. package/lib/db/ConnectionClosedError.js.map +0 -1
  173. package/lib/db/schema/TableV2.d.ts +0 -11
  174. package/lib/db/schema/TableV2.js +0 -11
  175. package/lib/db/schema/TableV2.js.map +0 -1
  176. package/lib/utils/AbortOperation.d.ts +0 -11
  177. package/lib/utils/AbortOperation.js +0 -21
  178. package/lib/utils/AbortOperation.js.map +0 -1
  179. package/lib/utils/ControlledExecutor.d.ts +0 -31
  180. package/lib/utils/ControlledExecutor.js +0 -54
  181. package/lib/utils/ControlledExecutor.js.map +0 -1
  182. package/lib/utils/async.d.ts +0 -46
  183. package/lib/utils/async.js +0 -147
  184. package/lib/utils/async.js.map +0 -1
  185. package/lib/utils/compatibility.d.ts +0 -8
  186. package/lib/utils/compatibility.js +0 -9
  187. package/lib/utils/compatibility.js.map +0 -1
  188. package/lib/utils/parseQuery.d.ts +0 -12
  189. package/lib/utils/parseQuery.js +0 -20
  190. package/lib/utils/parseQuery.js.map +0 -1
  191. package/lib/utils/queue.d.ts +0 -16
  192. package/lib/utils/queue.js +0 -42
  193. package/lib/utils/queue.js.map +0 -1
  194. package/lib/utils/stream_transform.d.ts +0 -41
  195. package/lib/utils/stream_transform.js +0 -211
  196. package/lib/utils/stream_transform.js.map +0 -1
  197. package/src/client/AbstractPowerSyncDatabase.ts +0 -1408
  198. package/src/client/AbstractPowerSyncOpenFactory.ts +0 -45
  199. package/src/client/ConnectionManager.ts +0 -405
  200. package/src/client/CustomQuery.ts +0 -56
  201. package/src/client/constants.ts +0 -4
  202. package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -65
  203. package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -202
  204. package/src/client/sync/stream/AbstractRemote.ts +0 -644
  205. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -970
  206. package/src/client/sync/stream/WebsocketClientTransport.ts +0 -82
  207. package/src/client/sync/stream/core-instruction.ts +0 -109
  208. package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
  209. package/src/client/triggers/TriggerManagerImpl.ts +0 -501
  210. package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
  211. package/src/db/ConnectionClosedError.ts +0 -25
  212. package/src/db/schema/TableV2.ts +0 -11
  213. package/src/utils/AbortOperation.ts +0 -19
  214. package/src/utils/ControlledExecutor.ts +0 -78
  215. package/src/utils/async.ts +0 -185
  216. package/src/utils/compatibility.ts +0 -9
  217. package/src/utils/parseQuery.ts +0 -31
  218. package/src/utils/queue.ts +0 -48
  219. 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 { InternalProgressInformation, ProgressWithOperations, SyncProgress } from './SyncProgress.js';
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 type SyncDataFlowStatus = Partial<{
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 declare class SyncStatus {
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 SyncDataFlowStatus#downloading} is also true.
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
- import { SyncProgress } from './SyncProgress.js';
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":"AAGA,OAAO,EAAuD,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwDtG;;GAEG;AAC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IAAI,QAAQ;QACV,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,gBAAgB,IAAI,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"}
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
  */
@@ -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;;;;;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"}
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"}
@@ -1,5 +1,5 @@
1
1
  import { IndexedColumn } from './IndexedColumn.js';
2
- import { Table } from './Table.js';
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: Table): {
19
+ toJSON(table: ResolvedTable): {
24
20
  name: string;
25
21
  columns: {
26
22
  name: string;
@@ -1,8 +1,5 @@
1
1
  import { IndexedColumn } from './IndexedColumn.js';
2
- /**
3
- * @internal
4
- */
5
- export const DEFAULT_INDEX_OPTIONS = {
2
+ const DEFAULT_INDEX_OPTIONS = {
6
3
  columns: []
7
4
  };
8
5
  /**
@@ -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;;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
+ {"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 { Table } from './Table.js';
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: Table): {
19
+ toJSON(table: ResolvedTable): {
24
20
  name: string;
25
21
  ascending: boolean | undefined;
26
22
  type: ColumnType;
@@ -1,8 +1,5 @@
1
1
  import { ColumnType } from './Column.js';
2
- /**
3
- * @internal
4
- */
5
- export const DEFAULT_INDEX_COLUMN_OPTIONS = {
2
+ const DEFAULT_INDEX_COLUMN_OPTIONS = {
6
3
  ascending: true
7
4
  };
8
5
  /**
@@ -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;;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"}
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: Table[];
18
+ readonly tables: ResolvedTable[];
19
19
  readonly rawTables: RawTable[];
20
- constructor(tables: Table[] | S);
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,CAAU;IAChB,SAAS,CAAa;IAE/B,YAAY,MAAmB;QAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B;;;;cAIE;YACF,KAAK,MAAM,KA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