@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.
- package/dist/bundle.mjs +17 -0
- package/lib/client/AbstractPowerSyncDatabase.d.ts +14 -14
- package/lib/client/AbstractPowerSyncDatabase.js +15 -16
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +5 -5
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -1
- package/lib/client/SQLOpenFactory.d.ts +1 -1
- package/lib/client/SQLOpenFactory.js +0 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +2 -2
- package/lib/client/connection/PowerSyncBackendConnector.js +0 -1
- package/lib/client/connection/PowerSyncCredentials.js +0 -1
- package/lib/client/constants.js +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +4 -4
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -1
- package/lib/client/sync/bucket/CrudBatch.d.ts +1 -1
- package/lib/client/sync/bucket/CrudBatch.js +0 -1
- package/lib/client/sync/bucket/CrudEntry.js +0 -1
- package/lib/client/sync/bucket/CrudTransaction.d.ts +2 -2
- package/lib/client/sync/bucket/CrudTransaction.js +1 -2
- package/lib/client/sync/bucket/OpType.js +0 -1
- package/lib/client/sync/bucket/OplogEntry.d.ts +2 -2
- package/lib/client/sync/bucket/OplogEntry.js +1 -2
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +6 -6
- package/lib/client/sync/bucket/SqliteBucketStorage.js +5 -6
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +1 -1
- package/lib/client/sync/bucket/SyncDataBatch.js +1 -2
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +2 -2
- package/lib/client/sync/bucket/SyncDataBucket.js +1 -2
- package/lib/client/sync/stream/AbstractRemote.d.ts +6 -6
- package/lib/client/sync/stream/AbstractRemote.js +4 -5
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +8 -8
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +9 -10
- package/lib/client/sync/stream/streaming-sync-types.d.ts +3 -3
- package/lib/client/sync/stream/streaming-sync-types.js +0 -1
- package/lib/db/DBAdapter.d.ts +1 -1
- package/lib/db/DBAdapter.js +0 -1
- package/lib/db/crud/SyncStatus.js +0 -1
- package/lib/db/crud/UploadQueueStatus.js +0 -1
- package/lib/db/schema/Column.js +0 -1
- package/lib/db/schema/Index.d.ts +3 -3
- package/lib/db/schema/Index.js +1 -2
- package/lib/db/schema/IndexedColumn.d.ts +2 -2
- package/lib/db/schema/IndexedColumn.js +1 -2
- package/lib/db/schema/Schema.d.ts +3 -3
- package/lib/db/schema/Schema.js +1 -2
- package/lib/db/schema/Table.d.ts +17 -17
- package/lib/db/schema/Table.js +3 -4
- package/lib/db/schema/TableV2.d.ts +2 -2
- package/lib/db/schema/TableV2.js +1 -2
- package/lib/index.d.ts +34 -34
- package/lib/index.js +34 -35
- package/lib/types/types.js +0 -1
- package/lib/utils/AbortOperation.js +0 -1
- package/lib/utils/BaseObserver.js +0 -1
- package/lib/utils/ControlledExecutor.js +0 -1
- package/lib/utils/DataStream.d.ts +1 -1
- package/lib/utils/DataStream.js +1 -2
- package/lib/utils/mutex.js +0 -1
- package/lib/utils/parseQuery.d.ts +1 -1
- package/lib/utils/parseQuery.js +0 -1
- package/lib/utils/throttle.d.ts +14 -0
- package/lib/utils/throttle.js +45 -0
- package/package.json +13 -5
- package/dist/index.js +0 -16
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/SQLOpenFactory.js.map +0 -1
- package/lib/client/connection/PowerSyncBackendConnector.js.map +0 -1
- package/lib/client/connection/PowerSyncCredentials.js.map +0 -1
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/CrudBatch.js.map +0 -1
- package/lib/client/sync/bucket/CrudEntry.js.map +0 -1
- package/lib/client/sync/bucket/CrudTransaction.js.map +0 -1
- package/lib/client/sync/bucket/OpType.js.map +0 -1
- package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
- package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
- package/lib/db/DBAdapter.js.map +0 -1
- package/lib/db/crud/SyncStatus.js.map +0 -1
- package/lib/db/crud/UploadQueueStatus.js.map +0 -1
- package/lib/db/schema/Column.js.map +0 -1
- package/lib/db/schema/Index.js.map +0 -1
- package/lib/db/schema/IndexedColumn.js.map +0 -1
- package/lib/db/schema/Schema.js.map +0 -1
- package/lib/db/schema/Table.js.map +0 -1
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/types.js.map +0 -1
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/BaseObserver.js.map +0 -1
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/DataStream.js.map +0 -1
- package/lib/utils/mutex.js.map +0 -1
- 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("
|
|
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
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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 =
|
|
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
|
|
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("
|
|
16
|
+
[x: string]: import("../index.js").Table<any>;
|
|
17
17
|
}>;
|
|
18
18
|
protected abstract openDB(): DBAdapter;
|
|
19
19
|
generateOptions(): PowerSyncDatabaseOptions;
|
|
@@ -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.
|
package/lib/client/constants.js
CHANGED
|
@@ -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[];
|
|
@@ -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
|
|
@@ -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 {
|
|
5
|
-
import {
|
|
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
|
// 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,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
|
|
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 {
|
|
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 {
|
|
7
|
-
import {
|
|
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 =
|
|
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
|
|
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.
|
|
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
|
*/
|
package/lib/db/DBAdapter.d.ts
CHANGED
|
@@ -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.
|
package/lib/db/DBAdapter.js
CHANGED
package/lib/db/schema/Column.js
CHANGED
package/lib/db/schema/Index.d.ts
CHANGED
|
@@ -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
|
}
|
package/lib/db/schema/Index.js
CHANGED
|
@@ -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
|
}[];
|
package/lib/db/schema/Schema.js
CHANGED
|
@@ -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
|