@powersync/common 0.0.0-dev-20251209082930 → 0.0.0-dev-20260112083235

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 (33) hide show
  1. package/dist/bundle.cjs +112 -78
  2. package/dist/bundle.cjs.map +1 -1
  3. package/dist/bundle.mjs +112 -79
  4. package/dist/bundle.mjs.map +1 -1
  5. package/dist/bundle.node.cjs +100 -66
  6. package/dist/bundle.node.cjs.map +1 -1
  7. package/dist/bundle.node.mjs +100 -67
  8. package/dist/bundle.node.mjs.map +1 -1
  9. package/dist/index.d.cts +25 -2
  10. package/lib/client/AbstractPowerSyncDatabase.d.ts +1 -1
  11. package/lib/client/AbstractPowerSyncDatabase.js +2 -2
  12. package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
  13. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +4 -0
  14. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +8 -0
  15. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
  16. package/lib/client/sync/stream/streaming-sync-types.d.ts +4 -0
  17. package/lib/client/sync/stream/streaming-sync-types.js.map +1 -1
  18. package/lib/db/ConnectionClosedError.d.ts +10 -0
  19. package/lib/db/ConnectionClosedError.js +21 -0
  20. package/lib/db/ConnectionClosedError.js.map +1 -0
  21. package/lib/db/crud/SyncStatus.d.ts +4 -0
  22. package/lib/db/crud/SyncStatus.js +4 -0
  23. package/lib/db/crud/SyncStatus.js.map +1 -1
  24. package/lib/index.d.ts +1 -0
  25. package/lib/index.js +1 -0
  26. package/lib/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/client/AbstractPowerSyncDatabase.ts +2 -2
  29. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +18 -0
  30. package/src/client/sync/stream/streaming-sync-types.ts +5 -0
  31. package/src/db/ConnectionClosedError.ts +23 -0
  32. package/src/db/crud/SyncStatus.ts +4 -0
  33. package/src/index.ts +1 -0
@@ -90,6 +90,11 @@ export interface StreamingSyncRequest {
90
90
  */
91
91
  parameters?: Record<string, StreamingSyncRequestParameterType>;
92
92
 
93
+ /**
94
+ * Application metadata to be included in service logs.
95
+ */
96
+ app_metadata?: Record<string, string>;
97
+
93
98
  client_id?: string;
94
99
  }
95
100
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Thrown when an underlying database connection is closed.
3
+ * This is particularly relevant when worker connections are marked as closed while
4
+ * operations are still in progress.
5
+ */
6
+ export class ConnectionClosedError extends Error {
7
+ static NAME = 'ConnectionClosedError';
8
+
9
+ static MATCHES(input: any) {
10
+ /**
11
+ * If there are weird package issues which cause multiple versions of classes to be present, the instanceof
12
+ * check might fail. This also performs a failsafe check.
13
+ * This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
14
+ */
15
+ return (
16
+ input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME)
17
+ );
18
+ }
19
+ constructor(message: string) {
20
+ super(message);
21
+ this.name = ConnectionClosedError.NAME;
22
+ }
23
+ }
@@ -261,6 +261,10 @@ export class SyncStatus {
261
261
  };
262
262
  }
263
263
 
264
+ /**
265
+ * Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
266
+ * This explicitly serializes errors in the SyncStatus.
267
+ */
264
268
  protected serializeError(error?: Error) {
265
269
  if (typeof error == 'undefined') {
266
270
  return undefined;
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from './client/sync/stream/streaming-sync-types.js';
21
21
  export * from './client/sync/sync-streams.js';
22
22
 
23
23
  export * from './client/ConnectionManager.js';
24
+ export * from './db/ConnectionClosedError.js';
24
25
  export { ProgressWithOperations, SyncProgress } from './db/crud/SyncProgress.js';
25
26
  export * from './db/crud/SyncStatus.js';
26
27
  export * from './db/crud/UploadQueueStatus.js';