@powersync/common 1.57.2 → 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 -42
  117. package/src/utils/MetaBaseObserver.ts +14 -60
  118. package/src/utils/mutex.ts +4 -201
  119. package/dist/bundle.cjs +0 -14393
  120. package/dist/bundle.cjs.map +0 -1
  121. package/dist/bundle.mjs +0 -14312
  122. package/dist/bundle.mjs.map +0 -1
  123. package/dist/bundle.node.cjs +0 -12024
  124. package/dist/bundle.node.cjs.map +0 -1
  125. package/dist/bundle.node.mjs +0 -11943
  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 -508
  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 -648
  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
@@ -19,33 +19,12 @@ export declare enum UpdateType {
19
19
  /** Delete existing row. Contains the id. Generated by DELETE statements. */
20
20
  DELETE = "DELETE"
21
21
  }
22
- /**
23
- * @internal
24
- */
25
- export type CrudEntryJSON = {
26
- id: string;
27
- data: string;
28
- tx_id?: number;
29
- };
30
- /**
31
- * The output JSON seems to be a third type of JSON, not the same as the input JSON.
32
- */
33
- type CrudEntryOutputJSON = {
34
- op_id: number;
35
- op: UpdateType;
36
- type: string;
37
- id: string;
38
- tx_id?: number;
39
- data?: Record<string, any>;
40
- old?: Record<string, any>;
41
- metadata?: string;
42
- };
43
22
  /**
44
23
  * A single client-side change.
45
24
  *
46
25
  * @public
47
26
  */
48
- export declare class CrudEntry {
27
+ export interface CrudEntry {
49
28
  /**
50
29
  * Auto-incrementing client-side id.
51
30
  */
@@ -82,23 +61,13 @@ export declare class CrudEntry {
82
61
  * and the insert or update statement set the `_metadata` column.
83
62
  */
84
63
  metadata?: string;
85
- static fromRow(dbRow: CrudEntryJSON): CrudEntry;
86
- constructor(clientId: number, op: UpdateType, table: string, id: string, transactionId?: number, opData?: Record<string, any>, previousValues?: Record<string, any>, metadata?: string);
87
64
  /**
88
65
  * Converts the change to JSON format.
89
66
  */
90
- toJSON(): CrudEntryOutputJSON;
67
+ toJSON(): unknown;
91
68
  equals(entry: CrudEntry): boolean;
92
- /**
93
- * The hash code for this object.
94
- * @deprecated This should not be necessary in the JS SDK.
95
- * Use the @see CrudEntry#equals method instead.
96
- * TODO remove in the next major release.
97
- */
98
- hashCode(): string;
99
69
  /**
100
70
  * Generates an array for use in deep comparison operations
101
71
  */
102
- toComparisonArray(): (string | number | Record<string, any> | undefined)[];
72
+ toComparisonArray(): unknown[];
103
73
  }
104
- export {};
@@ -12,103 +12,4 @@ export var UpdateType;
12
12
  /** Delete existing row. Contains the id. Generated by DELETE statements. */
13
13
  UpdateType["DELETE"] = "DELETE";
14
14
  })(UpdateType || (UpdateType = {}));
15
- /**
16
- * A single client-side change.
17
- *
18
- * @public
19
- */
20
- export class CrudEntry {
21
- /**
22
- * Auto-incrementing client-side id.
23
- */
24
- clientId;
25
- /**
26
- * ID of the changed row.
27
- */
28
- id;
29
- /**
30
- * Type of change.
31
- */
32
- op;
33
- /**
34
- * Data associated with the change.
35
- */
36
- opData;
37
- /**
38
- * For tables where the `trackPreviousValues` option has been enabled, this tracks previous values for
39
- * `UPDATE` and `DELETE` statements.
40
- */
41
- previousValues;
42
- /**
43
- * Table that contained the change.
44
- */
45
- table;
46
- /**
47
- * Auto-incrementing transaction id. This is the same for all operations within the same transaction.
48
- */
49
- transactionId;
50
- /**
51
- * Client-side metadata attached with this write.
52
- *
53
- * This field is only available when the `trackMetadata` option was set to `true` when creating a table
54
- * and the insert or update statement set the `_metadata` column.
55
- */
56
- metadata;
57
- static fromRow(dbRow) {
58
- const data = JSON.parse(dbRow.data);
59
- return new CrudEntry(parseInt(dbRow.id), data.op, data.type, data.id, dbRow.tx_id, data.data, data.old, data.metadata);
60
- }
61
- constructor(clientId, op, table, id, transactionId, opData, previousValues, metadata) {
62
- this.clientId = clientId;
63
- this.id = id;
64
- this.op = op;
65
- this.opData = opData;
66
- this.table = table;
67
- this.transactionId = transactionId;
68
- this.previousValues = previousValues;
69
- this.metadata = metadata;
70
- }
71
- /**
72
- * Converts the change to JSON format.
73
- */
74
- toJSON() {
75
- return {
76
- op_id: this.clientId,
77
- op: this.op,
78
- type: this.table,
79
- id: this.id,
80
- tx_id: this.transactionId,
81
- data: this.opData,
82
- old: this.previousValues,
83
- metadata: this.metadata
84
- };
85
- }
86
- equals(entry) {
87
- return JSON.stringify(this.toComparisonArray()) == JSON.stringify(entry.toComparisonArray());
88
- }
89
- /**
90
- * The hash code for this object.
91
- * @deprecated This should not be necessary in the JS SDK.
92
- * Use the @see CrudEntry#equals method instead.
93
- * TODO remove in the next major release.
94
- */
95
- hashCode() {
96
- return JSON.stringify(this.toComparisonArray());
97
- }
98
- /**
99
- * Generates an array for use in deep comparison operations
100
- */
101
- toComparisonArray() {
102
- return [
103
- this.transactionId,
104
- this.clientId,
105
- this.op,
106
- this.table,
107
- this.id,
108
- this.opData,
109
- this.previousValues,
110
- this.metadata
111
- ];
112
- }
113
- }
114
15
  //# sourceMappingURL=CrudEntry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,qHAAqH;IACrH,yBAAW,CAAA;IACX,8GAA8G;IAC9G,6BAAe,CAAA;IACf,4EAA4E;IAC5E,+BAAiB,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB;AAkCD;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACpB;;OAEG;IACH,QAAQ,CAAS;IACjB;;OAEG;IACH,EAAE,CAAS;IACX;;OAEG;IACH,EAAE,CAAa;IACf;;OAEG;IACH,MAAM,CAAuB;IAE7B;;;OAGG;IACH,cAAc,CAAuB;IAErC;;OAEG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,aAAa,CAAU;IAEvB;;;;;OAKG;IACH,QAAQ,CAAU;IAElB,MAAM,CAAC,OAAO,CAAC,KAAoB;QACjC,MAAM,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,IAAI,SAAS,CAClB,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAClB,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,EAAE,EACP,KAAK,CAAC,KAAK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,CAAC,aAAa;YAClB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,EAAE;YACP,IAAI,CAAC,KAAK;YACV,IAAI,CAAC,EAAE;YACP,IAAI,CAAC,MAAM;YACX,IAAI,CAAC,cAAc;YACnB,IAAI,CAAC,QAAQ;SACd,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,qHAAqH;IACrH,yBAAW,CAAA;IACX,8GAA8G;IAC9G,6BAAe,CAAA;IACf,4EAA4E;IAC5E,+BAAiB,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB"}
@@ -0,0 +1,65 @@
1
+ import { StreamingSyncRequestParameterType } from './stream/JsonValue.js';
2
+ /**
3
+ * Options that affect how the PowerSync SDK connects to the PowerSync Service.
4
+ *
5
+ * @public
6
+ */
7
+ export interface SyncOptions {
8
+ /**
9
+ * A set of metadata to be included in service logs.
10
+ */
11
+ appMetadata?: Record<string, string>;
12
+ /**
13
+ * These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
14
+ */
15
+ params?: Record<string, StreamingSyncRequestParameterType>;
16
+ /**
17
+ * The connection method to use when streaming updates from
18
+ * the PowerSync backend instance.
19
+ *
20
+ * The default value is SDK-specific. {@link SyncStreamConnectionMethod.HTTP} is the preferred implementation and used
21
+ * by default, except for React Native apps without Expo. Those don't support streaming HTTP responses, which is why
22
+ * {@link SyncStreamConnectionMethod.WEB_SOCKET} is used as a workaround.
23
+ */
24
+ connectionMethod?: SyncStreamConnectionMethod;
25
+ fetchStrategy?: FetchStrategy;
26
+ /**
27
+ * Whether to include streams that have `auto_subscribe: true` in their definition.
28
+ *
29
+ * This defaults to `true`.
30
+ */
31
+ includeDefaultStreams?: boolean;
32
+ /**
33
+ * Delay for retrying sync streaming operations
34
+ * from the PowerSync backend after an error occurs.
35
+ */
36
+ retryDelayMs?: number;
37
+ /**
38
+ * Backend Connector CRUD operations are throttled
39
+ * to occur at most every `crudUploadThrottleMs`
40
+ * milliseconds.
41
+ */
42
+ crudUploadThrottleMs?: number;
43
+ }
44
+ /**
45
+ * @public
46
+ */
47
+ export declare enum SyncStreamConnectionMethod {
48
+ HTTP = "http",
49
+ WEB_SOCKET = "web-socket"
50
+ }
51
+ /**
52
+ * @public
53
+ */
54
+ export declare enum FetchStrategy {
55
+ /**
56
+ * Queues multiple sync events before processing, reducing round-trips.
57
+ * This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
58
+ */
59
+ Buffered = "buffered",
60
+ /**
61
+ * Processes each sync event immediately before requesting the next.
62
+ * This reduces processing overhead and improves real-time responsiveness.
63
+ */
64
+ Sequential = "sequential"
65
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export var SyncStreamConnectionMethod;
5
+ (function (SyncStreamConnectionMethod) {
6
+ SyncStreamConnectionMethod["HTTP"] = "http";
7
+ SyncStreamConnectionMethod["WEB_SOCKET"] = "web-socket";
8
+ })(SyncStreamConnectionMethod || (SyncStreamConnectionMethod = {}));
9
+ /**
10
+ * @public
11
+ */
12
+ export var FetchStrategy;
13
+ (function (FetchStrategy) {
14
+ /**
15
+ * Queues multiple sync events before processing, reducing round-trips.
16
+ * This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
17
+ */
18
+ FetchStrategy["Buffered"] = "buffered";
19
+ /**
20
+ * Processes each sync event immediately before requesting the next.
21
+ * This reduces processing overhead and improves real-time responsiveness.
22
+ */
23
+ FetchStrategy["Sequential"] = "sequential";
24
+ })(FetchStrategy || (FetchStrategy = {}));
25
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/client/sync/options.ts"],"names":[],"mappings":"AAqDA;;GAEG;AACH,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,2CAAa,CAAA;IACb,uDAAyB,CAAA;AAC3B,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB;;;OAGG;IACH,sCAAqB,CAAA;IAErB;;;OAGG;IACH,0CAAyB,CAAA;AAC3B,CAAC,EAZW,aAAa,KAAb,aAAa,QAYxB"}
@@ -77,7 +77,7 @@ export interface SyncStreamSubscribeOptions {
77
77
  /**
78
78
  * A handle to a {@link SyncStreamDescription} that allows subscribing to the stream.
79
79
  *
80
- * To obtain an instance of {@link SyncStream}, call {@link AbstractPowerSyncDatabase.syncStream}.
80
+ * To obtain an instance of {@link SyncStream}, call {@link CommonPowerSyncDatabase.syncStream}.
81
81
  *
82
82
  * @public
83
83
  */
@@ -144,8 +144,10 @@ export interface TriggerCreationHooks {
144
144
  }
145
145
  /**
146
146
  * Common interface for options used in creating a diff trigger.
147
+ *
148
+ * @alpha @experimental
147
149
  */
148
- interface BaseCreateDiffTriggerOptions {
150
+ export interface BaseCreateDiffTriggerOptions {
149
151
  /**
150
152
  * PowerSync source table/view to trigger and track changes from.
151
153
  * This should be present in the PowerSync database's schema.
@@ -166,16 +168,18 @@ interface BaseCreateDiffTriggerOptions {
166
168
  * The row id is available in the `id` column.
167
169
  *
168
170
  * NB! The WHEN clauses here are added directly to the SQLite trigger creation SQL.
169
- * Any user input strings here should be sanitized externally. The {@link when} string template function performs
170
- * some basic sanitization, extra external sanitization is recommended.
171
+ * Any user input strings here should be sanitized externally. The {@link BaseCreateDiffTriggerOptions.when} string
172
+ * template function performs some basic sanitization, extra external sanitization is recommended.
171
173
  *
172
174
  * @example
175
+ * ```JavaScript
173
176
  * {
174
177
  * 'INSERT': sanitizeSQL`json_extract(NEW.data, '$.list_id') = ${sanitizeUUID(list.id)}`,
175
178
  * 'INSERT': `TRUE`,
176
179
  * 'UPDATE': sanitizeSQL`NEW.id = 'abcd' AND json_extract(NEW.data, '$.status') = 'active'`,
177
180
  * 'DELETE': sanitizeSQL`json_extract(OLD.data, '$.list_id') = 'abcd'`
178
181
  * }
182
+ * ```
179
183
  */
180
184
  when: Partial<Record<DiffTriggerOperation, string>>;
181
185
  /**
@@ -235,7 +239,8 @@ export interface WithDiffOptions {
235
239
  * @experimental @alpha
236
240
  * Context for the `onChange` handler provided to {@link TriggerManager#trackTableDiff}.
237
241
  */
238
- export interface TriggerDiffHandlerContext extends LockContext {
242
+ export interface TriggerDiffHandlerContext {
243
+ context: LockContext;
239
244
  /**
240
245
  * The name of the temporary destination table created by the trigger.
241
246
  */
@@ -330,7 +335,6 @@ export interface TrackDiffOptions extends BaseCreateDiffTriggerOptions {
330
335
  onChange: (context: TriggerDiffHandlerContext) => Promise<void>;
331
336
  /**
332
337
  * The minimum interval, in milliseconds, between {@link TrackDiffOptions.onChange} invocations.
333
- * @default {@link DEFAULT_WATCH_THROTTLE_MS}
334
338
  */
335
339
  throttleMs?: number;
336
340
  }
@@ -437,36 +441,3 @@ export interface TriggerManager {
437
441
  */
438
442
  trackTableDiff(options: TrackDiffOptions): Promise<TriggerRemoveCallback>;
439
443
  }
440
- /**
441
- * @experimental
442
- * @internal
443
- * Manages claims on persisted SQLite triggers and destination tables to enable proper cleanup
444
- * when they are no longer actively in use.
445
- *
446
- * When using persisted triggers (especially for OPFS multi-tab scenarios), we need a reliable way to determine which resources are still actively in use across different connections/tabs so stale resources can be safely cleaned up without interfering with active triggers.
447
- *
448
- * A cleanup process runs
449
- * on database creation (and every 2 minutes) that:
450
- * 1. Queries for existing managed persisted resources
451
- * 2. Checks with the claim manager if any consumer is actively using those resources
452
- * 3. Deletes unused resources
453
- */
454
- export interface TriggerClaimManager {
455
- /**
456
- * Obtains or marks a claim on a certain identifier.
457
- * @returns a callback to release the claim.
458
- */
459
- obtainClaim: (identifier: string) => Promise<() => Promise<void>>;
460
- /**
461
- * Checks if a claim is present for an identifier.
462
- */
463
- checkClaim: (identifier: string) => Promise<boolean>;
464
- }
465
- /**
466
- * @experimental
467
- * @internal
468
- */
469
- export interface TriggerManagerConfig {
470
- claimManager: TriggerClaimManager;
471
- }
472
- export {};
@@ -1,5 +1,5 @@
1
1
  import { CompiledQuery } from '../../types/types.js';
2
- import { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase.js';
2
+ import { CommonPowerSyncDatabase } from '../CommonPowerSyncDatabase.js';
3
3
  import { WatchCompatibleQuery } from './WatchedQuery.js';
4
4
  /**
5
5
  * Options for {@link GetAllQuery}.
@@ -22,7 +22,7 @@ export type GetAllQueryOptions<RowType = unknown> = {
22
22
  mapper?: (rawRow: Record<string, unknown>) => RowType;
23
23
  };
24
24
  /**
25
- * Performs a {@link AbstractPowerSyncDatabase.getAll} operation for a watched query.
25
+ * Performs a {@link DBGetUtils.getAll} operation for a watched query.
26
26
  *
27
27
  * @public
28
28
  */
@@ -31,6 +31,6 @@ export declare class GetAllQuery<RowType = unknown> implements WatchCompatibleQu
31
31
  constructor(options: GetAllQueryOptions<RowType>);
32
32
  compile(): CompiledQuery;
33
33
  execute(options: {
34
- db: AbstractPowerSyncDatabase;
34
+ db: CommonPowerSyncDatabase;
35
35
  }): Promise<RowType[]>;
36
36
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Performs a {@link AbstractPowerSyncDatabase.getAll} operation for a watched query.
2
+ * Performs a {@link DBGetUtils.getAll} operation for a watched query.
3
3
  *
4
4
  * @public
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GetAllQuery.js","sourceRoot":"","sources":["../../../src/client/watched/GetAllQuery.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACA;IAAtB,YAAsB,OAAoC;QAApC,YAAO,GAAP,OAAO,CAA6B;IAAG,CAAC;IAE9D,OAAO;QACL,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;YACrB,UAAU,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O,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,SAAsB,CAAC;IAChC,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { CompiledQuery } from '../../types/types.js';
2
2
  import { BaseListener } from '../../utils/BaseObserver.js';
3
3
  import { MetaBaseObserverInterface } from '../../utils/MetaBaseObserver.js';
4
- import { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase.js';
4
+ import { CommonPowerSyncDatabase } from '../CommonPowerSyncDatabase.js';
5
5
  /**
6
6
  * State for {@link WatchedQuery} instances.
7
7
  *
@@ -39,7 +39,7 @@ export interface WatchedQueryState<Data> {
39
39
  export interface WatchExecuteOptions {
40
40
  sql: string;
41
41
  parameters: any[];
42
- db: AbstractPowerSyncDatabase;
42
+ db: CommonPowerSyncDatabase;
43
43
  }
44
44
  /**
45
45
  *
@@ -88,14 +88,6 @@ export interface WatchedQueryListener<Data> extends BaseListener {
88
88
  [WatchedQueryListenerEvent.SETTINGS_WILL_UPDATE]?: () => void;
89
89
  [WatchedQueryListenerEvent.CLOSED]?: () => void | Promise<void>;
90
90
  }
91
- /**
92
- * @internal
93
- */
94
- export declare const DEFAULT_WATCH_THROTTLE_MS = 30;
95
- /**
96
- * @internal
97
- */
98
- export declare const DEFAULT_WATCH_QUERY_OPTIONS: WatchedQueryOptions;
99
91
  /**
100
92
  * @public
101
93
  */
@@ -9,15 +9,4 @@ export var WatchedQueryListenerEvent;
9
9
  WatchedQueryListenerEvent["SETTINGS_WILL_UPDATE"] = "settingsWillUpdate";
10
10
  WatchedQueryListenerEvent["CLOSED"] = "closed";
11
11
  })(WatchedQueryListenerEvent || (WatchedQueryListenerEvent = {}));
12
- /**
13
- * @internal
14
- */
15
- export const DEFAULT_WATCH_THROTTLE_MS = 30;
16
- /**
17
- * @internal
18
- */
19
- export const DEFAULT_WATCH_QUERY_OPTIONS = {
20
- throttleMs: DEFAULT_WATCH_THROTTLE_MS,
21
- reportFetching: true
22
- };
23
12
  //# sourceMappingURL=WatchedQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WatchedQuery.js","sourceRoot":"","sources":["../../../src/client/watched/WatchedQuery.ts"],"names":[],"mappings":"AA4EA;;GAEG;AACH,MAAM,CAAN,IAAY,yBAMX;AAND,WAAY,yBAAyB;IACnC,+CAAkB,CAAA;IAClB,iDAAoB,CAAA;IACpB,8DAAiC,CAAA;IACjC,wEAA2C,CAAA;IAC3C,8CAAiB,CAAA;AACnB,CAAC,EANW,yBAAyB,KAAzB,yBAAyB,QAMpC;AAaD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB;IAC9D,UAAU,EAAE,yBAAyB;IACrC,cAAc,EAAE,IAAI;CACrB,CAAC"}
1
+ {"version":3,"file":"WatchedQuery.js","sourceRoot":"","sources":["../../../src/client/watched/WatchedQuery.ts"],"names":[],"mappings":"AA4EA;;GAEG;AACH,MAAM,CAAN,IAAY,yBAMX;AAND,WAAY,yBAAyB;IACnC,+CAAkB,CAAA;IAClB,iDAAoB,CAAA;IACpB,8DAAiC,CAAA;IACjC,wEAA2C,CAAA;IAC3C,8CAAiB,CAAA;AACnB,CAAC,EANW,yBAAyB,KAAzB,yBAAyB,QAMpC"}
@@ -1,5 +1,4 @@
1
1
  import { WatchCompatibleQuery, WatchedQuery, WatchedQueryListener, WatchedQueryOptions } from '../WatchedQuery.js';
2
- import { AbstractQueryProcessor, AbstractQueryProcessorOptions, LinkQueryOptions } from './AbstractQueryProcessor.js';
3
2
  /**
4
3
  * Represents an updated row in a differential watched query.
5
4
  * It contains both the current and previous state of the row.
@@ -66,7 +65,6 @@ export interface DifferentialWatchedQueryOptions<RowType> extends WatchedQueryOp
66
65
  * Row comparator used to identify and compare rows in the result set.
67
66
  * If not provided, the default comparator will be used which keys items by their `id` property if available,
68
67
  * otherwise it uses JSON stringification of the entire item for keying and comparison.
69
- * @defaultValue {@link DEFAULT_ROW_COMPARATOR}
70
68
  */
71
69
  rowComparator?: DifferentialWatchedQueryComparator<RowType>;
72
70
  }
@@ -91,51 +89,3 @@ export interface DifferentialWatchedQueryListener<RowType> extends WatchedQueryL
91
89
  * @public
92
90
  */
93
91
  export type DifferentialWatchedQuery<RowType> = WatchedQuery<ReadonlyArray<Readonly<RowType>>, DifferentialWatchedQuerySettings<RowType>, DifferentialWatchedQueryListener<RowType>>;
94
- /**
95
- * @internal
96
- */
97
- export interface DifferentialQueryProcessorOptions<RowType> extends AbstractQueryProcessorOptions<RowType[], DifferentialWatchedQuerySettings<RowType>> {
98
- rowComparator?: DifferentialWatchedQueryComparator<RowType>;
99
- }
100
- type DataHashMap<RowType> = Map<string, {
101
- hash: string;
102
- item: RowType;
103
- }>;
104
- /**
105
- * An empty differential result set.
106
- * This is used as the initial state for differential incrementally watched queries.
107
- *
108
- * @internal
109
- */
110
- export declare const EMPTY_DIFFERENTIAL: {
111
- added: never[];
112
- all: never[];
113
- removed: never[];
114
- updated: never[];
115
- unchanged: never[];
116
- };
117
- /**
118
- * Default implementation of the {@link DifferentialWatchedQueryComparator} for watched queries.
119
- * It keys items by their `id` property if available, alternatively it uses JSON stringification
120
- * of the entire item for the key and comparison.
121
- *
122
- * @internal
123
- */
124
- export declare const DEFAULT_ROW_COMPARATOR: DifferentialWatchedQueryComparator<any>;
125
- /**
126
- * Uses the PowerSync onChange event to trigger watched queries.
127
- * Results are emitted on every change of the relevant tables.
128
- * @internal
129
- */
130
- export declare class DifferentialQueryProcessor<RowType> extends AbstractQueryProcessor<ReadonlyArray<Readonly<RowType>>, DifferentialWatchedQuerySettings<RowType>> implements DifferentialWatchedQuery<RowType> {
131
- protected options: DifferentialQueryProcessorOptions<RowType>;
132
- protected comparator: DifferentialWatchedQueryComparator<RowType>;
133
- constructor(options: DifferentialQueryProcessorOptions<RowType>);
134
- protected differentiate(current: RowType[], previousMap: DataHashMap<RowType>): {
135
- diff: WatchedQueryDifferential<RowType>;
136
- map: DataHashMap<RowType>;
137
- hasChanged: boolean;
138
- };
139
- protected linkQuery(options: LinkQueryOptions<WatchedQueryDifferential<RowType>>): Promise<void>;
140
- }
141
- export {};