@powersync/common 1.17.0 → 1.18.1

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 (98) hide show
  1. package/dist/bundle.mjs +17 -0
  2. package/lib/client/AbstractPowerSyncDatabase.d.ts +14 -14
  3. package/lib/client/AbstractPowerSyncDatabase.js +15 -16
  4. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +5 -5
  5. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -1
  6. package/lib/client/SQLOpenFactory.d.ts +1 -1
  7. package/lib/client/SQLOpenFactory.js +0 -1
  8. package/lib/client/connection/PowerSyncBackendConnector.d.ts +2 -2
  9. package/lib/client/connection/PowerSyncBackendConnector.js +0 -1
  10. package/lib/client/connection/PowerSyncCredentials.js +0 -1
  11. package/lib/client/constants.js +0 -1
  12. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +4 -4
  13. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -1
  14. package/lib/client/sync/bucket/CrudBatch.d.ts +1 -1
  15. package/lib/client/sync/bucket/CrudBatch.js +0 -1
  16. package/lib/client/sync/bucket/CrudEntry.js +0 -1
  17. package/lib/client/sync/bucket/CrudTransaction.d.ts +2 -2
  18. package/lib/client/sync/bucket/CrudTransaction.js +1 -2
  19. package/lib/client/sync/bucket/OpType.js +0 -1
  20. package/lib/client/sync/bucket/OplogEntry.d.ts +2 -2
  21. package/lib/client/sync/bucket/OplogEntry.js +1 -2
  22. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +6 -6
  23. package/lib/client/sync/bucket/SqliteBucketStorage.js +5 -6
  24. package/lib/client/sync/bucket/SyncDataBatch.d.ts +1 -1
  25. package/lib/client/sync/bucket/SyncDataBatch.js +1 -2
  26. package/lib/client/sync/bucket/SyncDataBucket.d.ts +2 -2
  27. package/lib/client/sync/bucket/SyncDataBucket.js +1 -2
  28. package/lib/client/sync/stream/AbstractRemote.d.ts +6 -6
  29. package/lib/client/sync/stream/AbstractRemote.js +4 -5
  30. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +8 -8
  31. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +9 -10
  32. package/lib/client/sync/stream/streaming-sync-types.d.ts +3 -3
  33. package/lib/client/sync/stream/streaming-sync-types.js +0 -1
  34. package/lib/db/DBAdapter.d.ts +1 -1
  35. package/lib/db/DBAdapter.js +0 -1
  36. package/lib/db/crud/SyncStatus.js +0 -1
  37. package/lib/db/crud/UploadQueueStatus.js +0 -1
  38. package/lib/db/schema/Column.js +0 -1
  39. package/lib/db/schema/Index.d.ts +3 -3
  40. package/lib/db/schema/Index.js +1 -2
  41. package/lib/db/schema/IndexedColumn.d.ts +2 -2
  42. package/lib/db/schema/IndexedColumn.js +1 -2
  43. package/lib/db/schema/Schema.d.ts +3 -3
  44. package/lib/db/schema/Schema.js +1 -2
  45. package/lib/db/schema/Table.d.ts +17 -17
  46. package/lib/db/schema/Table.js +3 -4
  47. package/lib/db/schema/TableV2.d.ts +2 -2
  48. package/lib/db/schema/TableV2.js +1 -2
  49. package/lib/index.d.ts +34 -34
  50. package/lib/index.js +34 -35
  51. package/lib/types/types.js +0 -1
  52. package/lib/utils/AbortOperation.js +0 -1
  53. package/lib/utils/BaseObserver.js +0 -1
  54. package/lib/utils/ControlledExecutor.js +0 -1
  55. package/lib/utils/DataStream.d.ts +1 -1
  56. package/lib/utils/DataStream.js +1 -2
  57. package/lib/utils/mutex.js +0 -1
  58. package/lib/utils/parseQuery.d.ts +1 -1
  59. package/lib/utils/parseQuery.js +0 -1
  60. package/lib/utils/throttle.d.ts +14 -0
  61. package/lib/utils/throttle.js +45 -0
  62. package/package.json +13 -5
  63. package/dist/index.js +0 -16
  64. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  65. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  66. package/lib/client/SQLOpenFactory.js.map +0 -1
  67. package/lib/client/connection/PowerSyncBackendConnector.js.map +0 -1
  68. package/lib/client/connection/PowerSyncCredentials.js.map +0 -1
  69. package/lib/client/constants.js.map +0 -1
  70. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  71. package/lib/client/sync/bucket/CrudBatch.js.map +0 -1
  72. package/lib/client/sync/bucket/CrudEntry.js.map +0 -1
  73. package/lib/client/sync/bucket/CrudTransaction.js.map +0 -1
  74. package/lib/client/sync/bucket/OpType.js.map +0 -1
  75. package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
  76. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  77. package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
  78. package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
  79. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  80. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  81. package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
  82. package/lib/db/DBAdapter.js.map +0 -1
  83. package/lib/db/crud/SyncStatus.js.map +0 -1
  84. package/lib/db/crud/UploadQueueStatus.js.map +0 -1
  85. package/lib/db/schema/Column.js.map +0 -1
  86. package/lib/db/schema/Index.js.map +0 -1
  87. package/lib/db/schema/IndexedColumn.js.map +0 -1
  88. package/lib/db/schema/Schema.js.map +0 -1
  89. package/lib/db/schema/Table.js.map +0 -1
  90. package/lib/db/schema/TableV2.js.map +0 -1
  91. package/lib/index.js.map +0 -1
  92. package/lib/types/types.js.map +0 -1
  93. package/lib/utils/AbortOperation.js.map +0 -1
  94. package/lib/utils/BaseObserver.js.map +0 -1
  95. package/lib/utils/ControlledExecutor.js.map +0 -1
  96. package/lib/utils/DataStream.js.map +0 -1
  97. package/lib/utils/mutex.js.map +0 -1
  98. package/lib/utils/parseQuery.js.map +0 -1
@@ -1,16 +1,16 @@
1
1
  import { Mutex } from 'async-mutex';
2
- import { ILogger } from 'js-logger';
3
- import { DBAdapter, QueryResult, Transaction } from '../db/DBAdapter';
4
- import { SyncStatus } from '../db/crud/SyncStatus';
5
- import { UploadQueueStats } from '../db/crud/UploadQueueStatus';
6
- import { Schema } from '../db/schema/Schema';
7
- import { BaseObserver } from '../utils/BaseObserver';
8
- import { SQLOpenFactory, SQLOpenOptions } from './SQLOpenFactory';
9
- import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector';
10
- import { BucketStorageAdapter } from './sync/bucket/BucketStorageAdapter';
11
- import { CrudBatch } from './sync/bucket/CrudBatch';
12
- import { CrudTransaction } from './sync/bucket/CrudTransaction';
13
- import { PowerSyncConnectionOptions, StreamingSyncImplementation, StreamingSyncImplementationListener } from './sync/stream/AbstractStreamingSyncImplementation';
2
+ import Logger, { ILogger } from 'js-logger';
3
+ import { DBAdapter, QueryResult, Transaction } from '../db/DBAdapter.js';
4
+ import { SyncStatus } from '../db/crud/SyncStatus.js';
5
+ import { UploadQueueStats } from '../db/crud/UploadQueueStatus.js';
6
+ import { Schema } from '../db/schema/Schema.js';
7
+ import { BaseObserver } from '../utils/BaseObserver.js';
8
+ import { SQLOpenFactory, SQLOpenOptions } from './SQLOpenFactory.js';
9
+ import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector.js';
10
+ import { BucketStorageAdapter } from './sync/bucket/BucketStorageAdapter.js';
11
+ import { CrudBatch } from './sync/bucket/CrudBatch.js';
12
+ import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
13
+ import { PowerSyncConnectionOptions, StreamingSyncImplementation, StreamingSyncImplementationListener } from './sync/stream/AbstractStreamingSyncImplementation.js';
14
14
  export interface DisconnectAndClearOptions {
15
15
  /** When set to false, data in local-only tables is preserved. */
16
16
  clearLocal?: boolean;
@@ -87,7 +87,7 @@ export declare const DEFAULT_POWERSYNC_CLOSE_OPTIONS: PowerSyncCloseOptions;
87
87
  export declare const DEFAULT_WATCH_THROTTLE_MS = 30;
88
88
  export declare const DEFAULT_POWERSYNC_DB_OPTIONS: {
89
89
  retryDelay: number;
90
- logger: ILogger;
90
+ logger: Logger.ILogger;
91
91
  crudUploadThrottleMs: number;
92
92
  };
93
93
  /**
@@ -132,7 +132,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
132
132
  * Schema used for the local database.
133
133
  */
134
134
  get schema(): Schema<{
135
- [x: string]: import("..").Table<any>;
135
+ [x: string]: import("../index.js").Table<any>;
136
136
  }>;
137
137
  /**
138
138
  * The underlying database.
@@ -1,19 +1,19 @@
1
1
  import { Mutex } from 'async-mutex';
2
2
  import { EventIterator } from 'event-iterator';
3
3
  import Logger from 'js-logger';
4
- import throttle from 'lodash/throttle';
5
- import { isBatchedUpdateNotification } from '../db/DBAdapter';
6
- import { SyncStatus } from '../db/crud/SyncStatus';
7
- import { UploadQueueStats } from '../db/crud/UploadQueueStatus';
8
- import { BaseObserver } from '../utils/BaseObserver';
9
- import { ControlledExecutor } from '../utils/ControlledExecutor';
10
- import { mutexRunExclusive } from '../utils/mutex';
11
- import { isDBAdapter, isSQLOpenFactory, isSQLOpenOptions } from './SQLOpenFactory';
12
- import { PSInternalTable } from './sync/bucket/BucketStorageAdapter';
13
- import { CrudBatch } from './sync/bucket/CrudBatch';
14
- import { CrudEntry } from './sync/bucket/CrudEntry';
15
- import { CrudTransaction } from './sync/bucket/CrudTransaction';
16
- import { DEFAULT_CRUD_UPLOAD_THROTTLE_MS } from './sync/stream/AbstractStreamingSyncImplementation';
4
+ import { isBatchedUpdateNotification } from '../db/DBAdapter.js';
5
+ import { SyncStatus } from '../db/crud/SyncStatus.js';
6
+ import { UploadQueueStats } from '../db/crud/UploadQueueStatus.js';
7
+ import { BaseObserver } from '../utils/BaseObserver.js';
8
+ import { ControlledExecutor } from '../utils/ControlledExecutor.js';
9
+ import { mutexRunExclusive } from '../utils/mutex.js';
10
+ import { throttleTrailing } from '../utils/throttle.js';
11
+ import { isDBAdapter, isSQLOpenFactory, isSQLOpenOptions } from './SQLOpenFactory.js';
12
+ import { PSInternalTable } from './sync/bucket/BucketStorageAdapter.js';
13
+ import { CrudBatch } from './sync/bucket/CrudBatch.js';
14
+ import { CrudEntry } from './sync/bucket/CrudEntry.js';
15
+ import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
16
+ import { DEFAULT_CRUD_UPLOAD_THROTTLE_MS } from './sync/stream/AbstractStreamingSyncImplementation.js';
17
17
  const POWERSYNC_TABLE_MATCH = /(^ps_data__|^ps_data_local__)/;
18
18
  const DEFAULT_DISCONNECT_CLEAR_OPTIONS = {
19
19
  clearLocal: true
@@ -594,11 +594,11 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
594
594
  const executor = new ControlledExecutor(async (e) => {
595
595
  await onChange(e);
596
596
  });
597
- const flushTableUpdates = throttle(() => this.handleTableChanges(changedTables, watchedTables, (intersection) => {
597
+ const flushTableUpdates = throttleTrailing(() => this.handleTableChanges(changedTables, watchedTables, (intersection) => {
598
598
  if (resolvedOptions?.signal?.aborted)
599
599
  return;
600
600
  executor.schedule({ changedTables: intersection });
601
- }), throttleMs, { leading: false, trailing: true });
601
+ }), throttleMs);
602
602
  const dispose = this.database.registerListener({
603
603
  tablesUpdated: async (update) => {
604
604
  try {
@@ -676,4 +676,3 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
676
676
  return this.database.readLock((tx) => tx.execute(sql, params));
677
677
  }
678
678
  }
679
- //# sourceMappingURL=AbstractPowerSyncDatabase.js.map
@@ -1,7 +1,7 @@
1
- import { DBAdapter } from '../db/DBAdapter';
2
- import { Schema } from '../db/schema/Schema';
3
- import { AbstractPowerSyncDatabase, PowerSyncDatabaseOptions } from './AbstractPowerSyncDatabase';
4
- import { SQLOpenOptions } from './SQLOpenFactory';
1
+ import { DBAdapter } from '../db/DBAdapter.js';
2
+ import { Schema } from '../db/schema/Schema.js';
3
+ import { AbstractPowerSyncDatabase, PowerSyncDatabaseOptions } from './AbstractPowerSyncDatabase.js';
4
+ import { SQLOpenOptions } from './SQLOpenFactory.js';
5
5
  export interface PowerSyncOpenFactoryOptions extends Partial<PowerSyncDatabaseOptions>, SQLOpenOptions {
6
6
  /** Schema used for the local database. */
7
7
  schema: Schema;
@@ -13,7 +13,7 @@ export declare abstract class AbstractPowerSyncDatabaseOpenFactory {
13
13
  * Schema used for the local database.
14
14
  */
15
15
  get schema(): Schema<{
16
- [x: string]: import("..").Table<any>;
16
+ [x: string]: import("../index.js").Table<any>;
17
17
  }>;
18
18
  protected abstract openDB(): DBAdapter;
19
19
  generateOptions(): PowerSyncDatabaseOptions;
@@ -22,4 +22,3 @@ export class AbstractPowerSyncDatabaseOpenFactory {
22
22
  return this.generateInstance(options);
23
23
  }
24
24
  }
25
- //# sourceMappingURL=AbstractPowerSyncOpenFactory.js.map
@@ -1,4 +1,4 @@
1
- import { DBAdapter } from '../db/DBAdapter';
1
+ import { DBAdapter } from '../db/DBAdapter.js';
2
2
  export interface SQLOpenOptions {
3
3
  /**
4
4
  * Filename for the database.
@@ -17,4 +17,3 @@ export const isSQLOpenFactory = (test) => {
17
17
  export const isDBAdapter = (test) => {
18
18
  return typeof test?.writeTransaction == 'function';
19
19
  };
20
- //# sourceMappingURL=SQLOpenFactory.js.map
@@ -1,5 +1,5 @@
1
- import { PowerSyncCredentials } from './PowerSyncCredentials';
2
- import type { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase';
1
+ import { PowerSyncCredentials } from './PowerSyncCredentials.js';
2
+ import type { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase.js';
3
3
  export interface PowerSyncBackendConnector {
4
4
  /** Allows the PowerSync client to retrieve an authentication token from your backend
5
5
  * which is used to authenticate against the PowerSync service.
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=PowerSyncBackendConnector.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=PowerSyncCredentials.js.map
@@ -1,2 +1 @@
1
1
  export const MAX_OP_ID = '9223372036854775807';
2
- //# sourceMappingURL=constants.js.map
@@ -1,7 +1,7 @@
1
- import { BaseListener, BaseObserver, Disposable } from '../../../utils/BaseObserver';
2
- import { CrudBatch } from './CrudBatch';
3
- import { CrudEntry, OpId } from './CrudEntry';
4
- import { SyncDataBatch } from './SyncDataBatch';
1
+ import { BaseListener, BaseObserver, Disposable } from '../../../utils/BaseObserver.js';
2
+ import { CrudBatch } from './CrudBatch.js';
3
+ import { CrudEntry, OpId } from './CrudEntry.js';
4
+ import { SyncDataBatch } from './SyncDataBatch.js';
5
5
  export interface Checkpoint {
6
6
  last_op_id: OpId;
7
7
  buckets: BucketChecksum[];
@@ -6,4 +6,3 @@ export var PSInternalTable;
6
6
  PSInternalTable["OPLOG"] = "ps_oplog";
7
7
  PSInternalTable["UNTYPED"] = "ps_untyped";
8
8
  })(PSInternalTable || (PSInternalTable = {}));
9
- //# sourceMappingURL=BucketStorageAdapter.js.map
@@ -1,4 +1,4 @@
1
- import { CrudEntry } from './CrudEntry';
1
+ import { CrudEntry } from './CrudEntry.js';
2
2
  /**
3
3
  * A batch of client-side changes.
4
4
  */
@@ -23,4 +23,3 @@ export class CrudBatch {
23
23
  this.complete = complete;
24
24
  }
25
25
  }
26
- //# sourceMappingURL=CrudBatch.js.map
@@ -82,4 +82,3 @@ export class CrudEntry {
82
82
  return [this.transactionId, this.clientId, this.op, this.table, this.id, this.opData];
83
83
  }
84
84
  }
85
- //# sourceMappingURL=CrudEntry.js.map
@@ -1,5 +1,5 @@
1
- import { CrudBatch } from './CrudBatch';
2
- import { CrudEntry } from './CrudEntry';
1
+ import { CrudBatch } from './CrudBatch.js';
2
+ import { CrudEntry } from './CrudEntry.js';
3
3
  export declare class CrudTransaction extends CrudBatch {
4
4
  /**
5
5
  * List of client-side changes.
@@ -1,4 +1,4 @@
1
- import { CrudBatch } from './CrudBatch';
1
+ import { CrudBatch } from './CrudBatch.js';
2
2
  export class CrudTransaction extends CrudBatch {
3
3
  crud;
4
4
  complete;
@@ -22,4 +22,3 @@ export class CrudTransaction extends CrudBatch {
22
22
  this.transactionId = transactionId;
23
23
  }
24
24
  }
25
- //# sourceMappingURL=CrudTransaction.js.map
@@ -20,4 +20,3 @@ export class OpType {
20
20
  return Object.entries(OpTypeEnum).find(([, value]) => value === this.value)[0];
21
21
  }
22
22
  }
23
- //# sourceMappingURL=OpType.js.map
@@ -1,5 +1,5 @@
1
- import { OpId } from './CrudEntry';
2
- import { OpType, OpTypeJSON } from './OpType';
1
+ import { OpId } from './CrudEntry.js';
2
+ import { OpType, OpTypeJSON } from './OpType.js';
3
3
  export interface OplogEntryJSON {
4
4
  checksum: number;
5
5
  data?: string;
@@ -1,4 +1,4 @@
1
- import { OpType } from './OpType';
1
+ import { OpType } from './OpType.js';
2
2
  export class OplogEntry {
3
3
  op_id;
4
4
  op;
@@ -31,4 +31,3 @@ export class OplogEntry {
31
31
  };
32
32
  }
33
33
  }
34
- //# sourceMappingURL=OplogEntry.js.map
@@ -1,11 +1,11 @@
1
1
  import { Mutex } from 'async-mutex';
2
2
  import { ILogger } from 'js-logger';
3
- import { DBAdapter, Transaction } from '../../../db/DBAdapter';
4
- import { BaseObserver } from '../../../utils/BaseObserver';
5
- import { BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, SyncLocalDatabaseResult } from './BucketStorageAdapter';
6
- import { CrudBatch } from './CrudBatch';
7
- import { CrudEntry } from './CrudEntry';
8
- import { SyncDataBatch } from './SyncDataBatch';
3
+ import { DBAdapter, Transaction } from '../../../db/DBAdapter.js';
4
+ import { BaseObserver } from '../../../utils/BaseObserver.js';
5
+ import { BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, SyncLocalDatabaseResult } from './BucketStorageAdapter.js';
6
+ import { CrudBatch } from './CrudBatch.js';
7
+ import { CrudEntry } from './CrudEntry.js';
8
+ import { SyncDataBatch } from './SyncDataBatch.js';
9
9
  export declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> implements BucketStorageAdapter {
10
10
  private db;
11
11
  private mutex;
@@ -1,9 +1,9 @@
1
1
  import Logger from 'js-logger';
2
- import { extractTableUpdates } from '../../../db/DBAdapter';
3
- import { BaseObserver } from '../../../utils/BaseObserver';
4
- import { PSInternalTable } from './BucketStorageAdapter';
5
- import { MAX_OP_ID } from '../../constants';
6
- import { CrudEntry } from './CrudEntry';
2
+ import { extractTableUpdates } from '../../../db/DBAdapter.js';
3
+ import { BaseObserver } from '../../../utils/BaseObserver.js';
4
+ import { MAX_OP_ID } from '../../constants.js';
5
+ import { PSInternalTable } from './BucketStorageAdapter.js';
6
+ import { CrudEntry } from './CrudEntry.js';
7
7
  const COMPACT_OPERATION_INTERVAL = 1_000;
8
8
  export class SqliteBucketStorage extends BaseObserver {
9
9
  db;
@@ -306,4 +306,3 @@ export class SqliteBucketStorage extends BaseObserver {
306
306
  // No-op for now
307
307
  }
308
308
  }
309
- //# sourceMappingURL=SqliteBucketStorage.js.map
@@ -1,4 +1,4 @@
1
- import { SyncDataBucket } from './SyncDataBucket';
1
+ import { SyncDataBucket } from './SyncDataBucket.js';
2
2
  export declare class SyncDataBatch {
3
3
  buckets: SyncDataBucket[];
4
4
  static fromJSON(json: any): SyncDataBatch;
@@ -1,4 +1,4 @@
1
- import { SyncDataBucket } from './SyncDataBucket';
1
+ import { SyncDataBucket } from './SyncDataBucket.js';
2
2
  // TODO JSON
3
3
  export class SyncDataBatch {
4
4
  buckets;
@@ -9,4 +9,3 @@ export class SyncDataBatch {
9
9
  this.buckets = buckets;
10
10
  }
11
11
  }
12
- //# sourceMappingURL=SyncDataBatch.js.map
@@ -1,5 +1,5 @@
1
- import { OpId } from './CrudEntry';
2
- import { OplogEntry, OplogEntryJSON } from './OplogEntry';
1
+ import { OpId } from './CrudEntry.js';
2
+ import { OplogEntry, OplogEntryJSON } from './OplogEntry.js';
3
3
  export type SyncDataBucketJSON = {
4
4
  bucket: string;
5
5
  has_more?: boolean;
@@ -1,4 +1,4 @@
1
- import { OplogEntry } from './OplogEntry';
1
+ import { OplogEntry } from './OplogEntry.js';
2
2
  export class SyncDataBucket {
3
3
  bucket;
4
4
  data;
@@ -37,4 +37,3 @@ export class SyncDataBucket {
37
37
  };
38
38
  }
39
39
  }
40
- //# sourceMappingURL=SyncDataBucket.js.map
@@ -1,14 +1,14 @@
1
- import { ILogger } from 'js-logger';
2
- import { type fetch } from 'cross-fetch';
3
- import { PowerSyncCredentials } from '../../connection/PowerSyncCredentials';
4
- import { StreamingSyncLine, StreamingSyncRequest } from './streaming-sync-types';
5
- import { DataStream } from '../../../utils/DataStream';
6
1
  import type { BSON } from 'bson';
2
+ import { type fetch } from 'cross-fetch';
3
+ import Logger, { ILogger } from 'js-logger';
4
+ import { DataStream } from '../../../utils/DataStream.js';
5
+ import { PowerSyncCredentials } from '../../connection/PowerSyncCredentials.js';
6
+ import { StreamingSyncLine, StreamingSyncRequest } from './streaming-sync-types.js';
7
7
  export type BSONImplementation = typeof BSON;
8
8
  export type RemoteConnector = {
9
9
  fetchCredentials: () => Promise<PowerSyncCredentials | null>;
10
10
  };
11
- export declare const DEFAULT_REMOTE_LOGGER: ILogger;
11
+ export declare const DEFAULT_REMOTE_LOGGER: Logger.ILogger;
12
12
  export type SyncStreamOptions = {
13
13
  path: string;
14
14
  data: StreamingSyncRequest;
@@ -1,10 +1,10 @@
1
- import Logger from 'js-logger';
2
- import { DataStream } from '../../../utils/DataStream';
1
+ import { Buffer } from 'buffer';
3
2
  import ndjsonStream from 'can-ndjson-stream';
3
+ import Logger from 'js-logger';
4
4
  import { RSocketConnector } from 'rsocket-core';
5
5
  import { WebsocketClientTransport } from 'rsocket-websocket-client';
6
- import { AbortOperation } from '../../../utils/AbortOperation';
7
- import { Buffer } from 'buffer';
6
+ import { AbortOperation } from '../../../utils/AbortOperation.js';
7
+ import { DataStream } from '../../../utils/DataStream.js';
8
8
  import { version as POWERSYNC_JS_VERSION } from '../../../../package.json';
9
9
  // Refresh at least 30 sec before it expires
10
10
  const REFRESH_CREDENTIALS_SAFETY_PERIOD_MS = 30_000;
@@ -394,4 +394,3 @@ export class AbstractRemote {
394
394
  return stream;
395
395
  }
396
396
  }
397
- //# sourceMappingURL=AbstractRemote.js.map
@@ -1,9 +1,9 @@
1
- import { ILogger } from 'js-logger';
2
- import { SyncStatus, SyncStatusOptions } from '../../../db/crud/SyncStatus';
3
- import { BaseListener, BaseObserver, Disposable } from '../../../utils/BaseObserver';
4
- import { BucketStorageAdapter } from '../bucket/BucketStorageAdapter';
5
- import { AbstractRemote } from './AbstractRemote';
6
- import { StreamingSyncRequestParameterType } from './streaming-sync-types';
1
+ import Logger, { ILogger } from 'js-logger';
2
+ import { SyncStatus, SyncStatusOptions } from '../../../db/crud/SyncStatus.js';
3
+ import { BaseListener, BaseObserver, Disposable } from '../../../utils/BaseObserver.js';
4
+ import { BucketStorageAdapter } from '../bucket/BucketStorageAdapter.js';
5
+ import { AbstractRemote } from './AbstractRemote.js';
6
+ import { StreamingSyncRequestParameterType } from './streaming-sync-types.js';
7
7
  export declare enum LockType {
8
8
  CRUD = "crud",
9
9
  SYNC = "sync"
@@ -82,7 +82,7 @@ export interface StreamingSyncImplementation extends BaseObserver<StreamingSyncI
82
82
  export declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
83
83
  export declare const DEFAULT_STREAMING_SYNC_OPTIONS: {
84
84
  retryDelayMs: number;
85
- logger: ILogger;
85
+ logger: Logger.ILogger;
86
86
  crudUploadThrottleMs: number;
87
87
  };
88
88
  export declare const DEFAULT_STREAM_CONNECTION_OPTIONS: Required<PowerSyncConnectionOptions>;
@@ -99,7 +99,7 @@ export declare abstract class AbstractStreamingSyncImplementation extends BaseOb
99
99
  waitForStatus(status: SyncStatusOptions): Promise<void>;
100
100
  get lastSyncedAt(): Date | undefined;
101
101
  get isConnected(): boolean;
102
- protected get logger(): ILogger;
102
+ protected get logger(): Logger.ILogger;
103
103
  dispose(): Promise<void>;
104
104
  abstract obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
105
105
  hasCompletedSync(): Promise<boolean>;
@@ -1,10 +1,10 @@
1
- import throttle from 'lodash/throttle';
2
1
  import Logger from 'js-logger';
3
- import { SyncStatus } from '../../../db/crud/SyncStatus';
4
- import { AbortOperation } from '../../../utils/AbortOperation';
5
- import { BaseObserver } from '../../../utils/BaseObserver';
6
- import { SyncDataBucket } from '../bucket/SyncDataBucket';
7
- import { isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncData } from './streaming-sync-types';
2
+ import { SyncStatus } from '../../../db/crud/SyncStatus.js';
3
+ import { AbortOperation } from '../../../utils/AbortOperation.js';
4
+ import { BaseObserver } from '../../../utils/BaseObserver.js';
5
+ import { throttleLeadingTrailing } from '../../../utils/throttle.js';
6
+ import { SyncDataBucket } from '../bucket/SyncDataBucket.js';
7
+ import { isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncData } from './streaming-sync-types.js';
8
8
  export var LockType;
9
9
  (function (LockType) {
10
10
  LockType["CRUD"] = "crud";
@@ -45,12 +45,12 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
45
45
  }
46
46
  });
47
47
  this.abortController = null;
48
- this.triggerCrudUpload = throttle(() => {
48
+ this.triggerCrudUpload = throttleLeadingTrailing(() => {
49
49
  if (!this.syncStatus.connected || this.syncStatus.dataFlowStatus.uploading) {
50
50
  return;
51
51
  }
52
52
  this._uploadAllCrud();
53
- }, this.options.crudUploadThrottleMs, { trailing: true });
53
+ }, this.options.crudUploadThrottleMs);
54
54
  }
55
55
  async waitForReady() { }
56
56
  waitForStatus(status) {
@@ -121,7 +121,7 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
121
121
  */
122
122
  const nextCrudItem = await this.options.adapter.nextCrudItem();
123
123
  if (nextCrudItem) {
124
- if (nextCrudItem.id == checkedCrudItem?.id) {
124
+ if (nextCrudItem.clientId == checkedCrudItem?.clientId) {
125
125
  // This will force a higher log level than exceptions which are caught here.
126
126
  this.logger.warn(`Potentially previously uploaded CRUD entries are still present in the upload queue.
127
127
  Make sure to handle uploads and complete CRUD transactions or batches by calling and awaiting their [.complete()] method.
@@ -507,4 +507,3 @@ The next upload iteration will be delayed.`);
507
507
  return new Promise((resolve) => setTimeout(resolve, this.options.retryDelayMs));
508
508
  }
509
509
  }
510
- //# sourceMappingURL=AbstractStreamingSyncImplementation.js.map
@@ -1,6 +1,6 @@
1
- import { BucketChecksum, Checkpoint } from '../bucket/BucketStorageAdapter';
2
- import { CrudEntry, OpId } from '../bucket/CrudEntry';
3
- import { SyncDataBucketJSON } from '../bucket/SyncDataBucket';
1
+ import { BucketChecksum, Checkpoint } from '../bucket/BucketStorageAdapter.js';
2
+ import { CrudEntry, OpId } from '../bucket/CrudEntry.js';
3
+ import { SyncDataBucketJSON } from '../bucket/SyncDataBucket.js';
4
4
  /**
5
5
  * For sync2.json
6
6
  */
@@ -20,4 +20,3 @@ export function isContinueCheckpointRequest(request) {
20
20
  export function isSyncNewCheckpointRequest(request) {
21
21
  return typeof request.request_checkpoint == 'object';
22
22
  }
23
- //# sourceMappingURL=streaming-sync-types.js.map
@@ -2,7 +2,7 @@
2
2
  * Set of generic interfaces to allow PowerSync compatibility with
3
3
  * different SQLite DB implementations.
4
4
  */
5
- import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver';
5
+ import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver.js';
6
6
  /**
7
7
  * TODO most of these types could be exported to a common `types` package
8
8
  * which is used by the DB adapter libraries as well.
@@ -17,4 +17,3 @@ export function isBatchedUpdateNotification(update) {
17
17
  export function extractTableUpdates(update) {
18
18
  return isBatchedUpdateNotification(update) ? update.tables : [update.table];
19
19
  }
20
- //# sourceMappingURL=DBAdapter.js.map
@@ -55,4 +55,3 @@ export class SyncStatus {
55
55
  };
56
56
  }
57
57
  }
58
- //# sourceMappingURL=SyncStatus.js.map
@@ -22,4 +22,3 @@ export class UploadQueueStats {
22
22
  }
23
23
  }
24
24
  }
25
- //# sourceMappingURL=UploadQueueStatus.js.map
@@ -40,4 +40,3 @@ export class Column {
40
40
  };
41
41
  }
42
42
  }
43
- //# sourceMappingURL=Column.js.map
@@ -1,5 +1,5 @@
1
- import { IndexedColumn } from './IndexedColumn';
2
- import { Table } from './Table';
1
+ import { IndexedColumn } from './IndexedColumn.js';
2
+ import { Table } from './Table.js';
3
3
  export interface IndexOptions {
4
4
  name: string;
5
5
  columns?: IndexedColumn[];
@@ -16,7 +16,7 @@ export declare class Index {
16
16
  columns: {
17
17
  name: string;
18
18
  ascending: boolean | undefined;
19
- type: import("./Column").ColumnType;
19
+ type: import("./Column.js").ColumnType;
20
20
  }[];
21
21
  };
22
22
  }
@@ -1,4 +1,4 @@
1
- import { IndexedColumn } from './IndexedColumn';
1
+ import { IndexedColumn } from './IndexedColumn.js';
2
2
  export const DEFAULT_INDEX_OPTIONS = {
3
3
  columns: []
4
4
  };
@@ -27,4 +27,3 @@ export class Index {
27
27
  };
28
28
  }
29
29
  }
30
- //# sourceMappingURL=Index.js.map
@@ -1,5 +1,5 @@
1
- import { ColumnType } from './Column';
2
- import { Table } from './Table';
1
+ import { ColumnType } from './Column.js';
2
+ import { Table } from './Table.js';
3
3
  export interface IndexColumnOptions {
4
4
  name: string;
5
5
  ascending?: boolean;
@@ -1,4 +1,4 @@
1
- import { ColumnType } from './Column';
1
+ import { ColumnType } from './Column.js';
2
2
  export const DEFAULT_INDEX_COLUMN_OPTIONS = {
3
3
  ascending: true
4
4
  };
@@ -27,4 +27,3 @@ export class IndexedColumn {
27
27
  };
28
28
  }
29
29
  }
30
- //# sourceMappingURL=IndexedColumn.js.map
@@ -1,4 +1,4 @@
1
- import { RowType, Table } from './Table';
1
+ import { RowType, Table } from './Table.js';
2
2
  type SchemaType = Record<string, Table<any>>;
3
3
  type SchemaTableType<S extends SchemaType> = {
4
4
  [K in keyof S]: RowType<S[K]>;
@@ -20,14 +20,14 @@ export declare class Schema<S extends SchemaType = SchemaType> {
20
20
  insert_only: boolean;
21
21
  columns: {
22
22
  name: string;
23
- type: import("./Column").ColumnType | undefined;
23
+ type: import("./Column.js").ColumnType | undefined;
24
24
  }[];
25
25
  indexes: {
26
26
  name: string;
27
27
  columns: {
28
28
  name: string;
29
29
  ascending: boolean | undefined;
30
- type: import("./Column").ColumnType;
30
+ type: import("./Column.js").ColumnType;
31
31
  }[];
32
32
  }[];
33
33
  }[];
@@ -1,4 +1,4 @@
1
- import { Table } from './Table';
1
+ import { Table } from './Table.js';
2
2
  /**
3
3
  * A schema is a collection of tables. It is used to define the structure of a database.
4
4
  */
@@ -43,4 +43,3 @@ export class Schema {
43
43
  });
44
44
  }
45
45
  }
46
- //# sourceMappingURL=Schema.js.map