@powersync/common 0.0.0-dev-20260311103504 → 0.0.0-dev-20260503073249
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.cjs +791 -489
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +785 -485
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +789 -488
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +783 -484
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +165 -103
- package/lib/attachments/AttachmentQueue.d.ts +10 -4
- package/lib/attachments/AttachmentQueue.js +10 -4
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentService.js +2 -3
- package/lib/attachments/AttachmentService.js.map +1 -1
- package/lib/attachments/SyncingService.d.ts +2 -1
- package/lib/attachments/SyncingService.js +4 -5
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/client/AbstractPowerSyncDatabase.d.ts +5 -1
- package/lib/client/AbstractPowerSyncDatabase.js +9 -5
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +29 -8
- package/lib/client/sync/stream/AbstractRemote.js +154 -177
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +4 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +88 -88
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +55 -9
- package/lib/db/DBAdapter.js +126 -0
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +0 -4
- package/lib/db/crud/SyncStatus.js +0 -4
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +0 -5
- package/lib/db/schema/Schema.d.ts +0 -2
- package/lib/db/schema/Schema.js +0 -2
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/async.d.ts +0 -9
- package/lib/utils/async.js +0 -9
- package/lib/utils/async.js.map +1 -1
- package/lib/utils/mutex.d.ts +47 -5
- package/lib/utils/mutex.js +146 -21
- package/lib/utils/mutex.js.map +1 -1
- package/lib/utils/queue.d.ts +16 -0
- package/lib/utils/queue.js +42 -0
- package/lib/utils/queue.js.map +1 -0
- package/lib/utils/stream_transform.d.ts +39 -0
- package/lib/utils/stream_transform.js +206 -0
- package/lib/utils/stream_transform.js.map +1 -0
- package/package.json +9 -8
- package/src/attachments/AttachmentQueue.ts +10 -4
- package/src/attachments/AttachmentService.ts +2 -3
- package/src/attachments/README.md +6 -4
- package/src/attachments/SyncingService.ts +4 -5
- package/src/client/AbstractPowerSyncDatabase.ts +9 -5
- package/src/client/sync/stream/AbstractRemote.ts +182 -206
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +96 -83
- package/src/db/DBAdapter.ts +167 -9
- package/src/db/crud/SyncStatus.ts +0 -4
- package/src/db/schema/RawTable.ts +0 -5
- package/src/db/schema/Schema.ts +0 -2
- package/src/index.ts +1 -1
- package/src/utils/async.ts +0 -11
- package/src/utils/mutex.ts +184 -26
- package/src/utils/queue.ts +48 -0
- package/src/utils/stream_transform.ts +252 -0
- package/lib/utils/DataStream.d.ts +0 -62
- package/lib/utils/DataStream.js +0 -169
- package/lib/utils/DataStream.js.map +0 -1
- package/src/utils/DataStream.ts +0 -222
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Mutex } from 'async-mutex';
|
|
2
1
|
import Logger, { ILogger, ILogLevel } from 'js-logger';
|
|
3
2
|
export { GlobalLogger, ILogHandler, ILogLevel, ILogger, ILoggerOpts } from 'js-logger';
|
|
4
3
|
import { BSON } from 'bson';
|
|
@@ -38,7 +37,13 @@ declare class BaseObserver<T extends BaseListener = BaseListener> implements Bas
|
|
|
38
37
|
type QueryResult = {
|
|
39
38
|
/** Represents the auto-generated row id if applicable. */
|
|
40
39
|
insertId?: number;
|
|
41
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Number of affected rows reported by SQLite for a write query.
|
|
42
|
+
*
|
|
43
|
+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
|
|
44
|
+
* `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
|
|
45
|
+
* Use a `RETURNING` clause and inspect `rows` when you need to confirm which rows changed.
|
|
46
|
+
*/
|
|
42
47
|
rowsAffected: number;
|
|
43
48
|
/** if status is undefined or 0 this object will contain the query results */
|
|
44
49
|
rows?: {
|
|
@@ -61,7 +66,7 @@ interface DBGetUtils {
|
|
|
61
66
|
/** Execute a read-only query and return the first result, error if the ResultSet is empty. */
|
|
62
67
|
get<T>(sql: string, parameters?: any[]): Promise<T>;
|
|
63
68
|
}
|
|
64
|
-
interface
|
|
69
|
+
interface SqlExecutor {
|
|
65
70
|
/** Execute a single write statement. */
|
|
66
71
|
execute: (query: string, params?: any[] | undefined) => Promise<QueryResult>;
|
|
67
72
|
/**
|
|
@@ -79,7 +84,23 @@ interface LockContext extends DBGetUtils {
|
|
|
79
84
|
* ```[ { id: '33', name: 'list 1', content: 'Post content', list_id: '1' } ]```
|
|
80
85
|
*/
|
|
81
86
|
executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
|
|
87
|
+
executeBatch: (query: string, params?: any[][]) => Promise<QueryResult>;
|
|
88
|
+
}
|
|
89
|
+
interface LockContext extends SqlExecutor, DBGetUtils {
|
|
82
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Implements {@link DBGetUtils} on a {@link SqlRunner}.
|
|
93
|
+
*/
|
|
94
|
+
declare function DBGetUtilsDefaultMixin<TBase extends new (...args: any[]) => Omit<SqlExecutor, 'executeBatch'>>(Base: TBase): {
|
|
95
|
+
new (...args: any[]): {
|
|
96
|
+
getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
|
|
97
|
+
getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
|
|
98
|
+
get<T>(sql: string, parameters?: any[]): Promise<T>;
|
|
99
|
+
executeBatch(query: string, params?: any[][]): Promise<QueryResult>;
|
|
100
|
+
execute: (query: string, params?: any[] | undefined) => Promise<QueryResult>;
|
|
101
|
+
executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
|
|
102
|
+
};
|
|
103
|
+
} & TBase;
|
|
83
104
|
interface Transaction extends LockContext {
|
|
84
105
|
/** Commit multiple changes to the local DB using the Transaction context. */
|
|
85
106
|
commit: () => Promise<QueryResult>;
|
|
@@ -121,21 +142,45 @@ interface DBAdapterListener extends BaseListener {
|
|
|
121
142
|
interface DBLockOptions {
|
|
122
143
|
timeoutMs?: number;
|
|
123
144
|
}
|
|
124
|
-
interface
|
|
125
|
-
close: () => void | Promise<void>;
|
|
126
|
-
execute: (query: string, params?: any[]) => Promise<QueryResult>;
|
|
127
|
-
executeRaw: (query: string, params?: any[]) => Promise<any[][]>;
|
|
128
|
-
executeBatch: (query: string, params?: any[][]) => Promise<QueryResult>;
|
|
145
|
+
interface ConnectionPool extends BaseObserverInterface<DBAdapterListener> {
|
|
129
146
|
name: string;
|
|
147
|
+
close: () => void | Promise<void>;
|
|
130
148
|
readLock: <T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
131
|
-
readTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
132
149
|
writeLock: <T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
133
|
-
writeTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
134
150
|
/**
|
|
135
151
|
* This method refreshes the schema information across all connections. This is for advanced use cases, and should generally not be needed.
|
|
136
152
|
*/
|
|
137
153
|
refreshSchema: () => Promise<void>;
|
|
138
154
|
}
|
|
155
|
+
interface DBAdapter extends ConnectionPool, SqlExecutor, DBGetUtils {
|
|
156
|
+
readTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
157
|
+
writeTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool.readLock} and
|
|
161
|
+
* {@link ConnectionPool.writeLock}.
|
|
162
|
+
*/
|
|
163
|
+
declare function DBAdapterDefaultMixin<TBase extends new (...args: any[]) => ConnectionPool>(Base: TBase): {
|
|
164
|
+
new (...args: any[]): {
|
|
165
|
+
readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
166
|
+
writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
167
|
+
getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
|
|
168
|
+
getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
|
|
169
|
+
get<T>(sql: string, parameters?: any[]): Promise<T>;
|
|
170
|
+
execute(query: string, params?: any[]): Promise<QueryResult>;
|
|
171
|
+
executeRaw(query: string, params?: any[]): Promise<any[][]>;
|
|
172
|
+
executeBatch(query: string, params?: any[][]): Promise<QueryResult>;
|
|
173
|
+
name: string;
|
|
174
|
+
close: () => void | Promise<void>;
|
|
175
|
+
readLock: <T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
176
|
+
writeLock: <T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) => Promise<T>;
|
|
177
|
+
/**
|
|
178
|
+
* This method refreshes the schema information across all connections. This is for advanced use cases, and should generally not be needed.
|
|
179
|
+
*/
|
|
180
|
+
refreshSchema: () => Promise<void>;
|
|
181
|
+
registerListener(listener: Partial<DBAdapterListener>): () => void;
|
|
182
|
+
};
|
|
183
|
+
} & TBase;
|
|
139
184
|
declare function isBatchedUpdateNotification(update: BatchedUpdateNotification | UpdateNotification): update is BatchedUpdateNotification;
|
|
140
185
|
declare function extractTableUpdates(update: BatchedUpdateNotification | UpdateNotification): string[];
|
|
141
186
|
|
|
@@ -448,67 +493,6 @@ interface BucketStorageAdapter extends BaseObserverInterface<BucketStorageListen
|
|
|
448
493
|
control(op: PowerSyncControlCommand, payload: string | Uint8Array | null): Promise<string>;
|
|
449
494
|
}
|
|
450
495
|
|
|
451
|
-
type DataStreamOptions<ParsedData, SourceData> = {
|
|
452
|
-
mapLine?: (line: SourceData) => ParsedData;
|
|
453
|
-
/**
|
|
454
|
-
* Close the stream if any consumer throws an error
|
|
455
|
-
*/
|
|
456
|
-
closeOnError?: boolean;
|
|
457
|
-
pressure?: {
|
|
458
|
-
highWaterMark?: number;
|
|
459
|
-
lowWaterMark?: number;
|
|
460
|
-
};
|
|
461
|
-
logger?: ILogger;
|
|
462
|
-
};
|
|
463
|
-
type DataStreamCallback<Data extends any = any> = (data: Data) => Promise<void>;
|
|
464
|
-
interface DataStreamListener<Data extends any = any> extends BaseListener {
|
|
465
|
-
data: (data: Data) => Promise<void>;
|
|
466
|
-
closed: () => void;
|
|
467
|
-
error: (error: Error) => void;
|
|
468
|
-
highWater: () => Promise<void>;
|
|
469
|
-
lowWater: () => Promise<void>;
|
|
470
|
-
}
|
|
471
|
-
declare const DEFAULT_PRESSURE_LIMITS: {
|
|
472
|
-
highWater: number;
|
|
473
|
-
lowWater: number;
|
|
474
|
-
};
|
|
475
|
-
/**
|
|
476
|
-
* A very basic implementation of a data stream with backpressure support which does not use
|
|
477
|
-
* native JS streams or async iterators.
|
|
478
|
-
* This is handy for environments such as React Native which need polyfills for the above.
|
|
479
|
-
*/
|
|
480
|
-
declare class DataStream<ParsedData, SourceData = any> extends BaseObserver<DataStreamListener<ParsedData>> {
|
|
481
|
-
protected options?: DataStreamOptions<ParsedData, SourceData> | undefined;
|
|
482
|
-
dataQueue: SourceData[];
|
|
483
|
-
protected isClosed: boolean;
|
|
484
|
-
protected processingPromise: Promise<void> | null;
|
|
485
|
-
protected notifyDataAdded: (() => void) | null;
|
|
486
|
-
protected logger: ILogger;
|
|
487
|
-
protected mapLine: (line: SourceData) => ParsedData;
|
|
488
|
-
constructor(options?: DataStreamOptions<ParsedData, SourceData> | undefined);
|
|
489
|
-
get highWatermark(): number;
|
|
490
|
-
get lowWatermark(): number;
|
|
491
|
-
get closed(): boolean;
|
|
492
|
-
close(): Promise<void>;
|
|
493
|
-
/**
|
|
494
|
-
* Enqueues data for the consumers to read
|
|
495
|
-
*/
|
|
496
|
-
enqueueData(data: SourceData): void;
|
|
497
|
-
/**
|
|
498
|
-
* Reads data once from the data stream
|
|
499
|
-
* @returns a Data payload or Null if the stream closed.
|
|
500
|
-
*/
|
|
501
|
-
read(): Promise<ParsedData | null>;
|
|
502
|
-
/**
|
|
503
|
-
* Executes a callback for each data item in the stream
|
|
504
|
-
*/
|
|
505
|
-
forEach(callback: DataStreamCallback<ParsedData>): () => void;
|
|
506
|
-
protected processQueue(): Promise<void> | undefined;
|
|
507
|
-
protected hasDataReader(): boolean;
|
|
508
|
-
protected _processQueue(): Promise<void>;
|
|
509
|
-
protected iterateAsyncErrored(cb: (l: Partial<DataStreamListener<ParsedData>>) => Promise<void>): Promise<void>;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
496
|
interface PowerSyncCredentials {
|
|
513
497
|
endpoint: string;
|
|
514
498
|
token: string;
|
|
@@ -655,6 +639,16 @@ interface CrudResponse {
|
|
|
655
639
|
checkpoint?: OpId;
|
|
656
640
|
}
|
|
657
641
|
|
|
642
|
+
/**
|
|
643
|
+
* An async iterator that can't be cancelled.
|
|
644
|
+
*
|
|
645
|
+
* To keep data flow simple, we always pass an explicit cancellation token when subscribing to async streams. Once the
|
|
646
|
+
* {@link AbortSignal} aborts, iterators are supposed to clean up and then emit a final `{done: true}` event. This means
|
|
647
|
+
* that there's no way to distinguish between streams that have completed normally and streams that have been cancelled,
|
|
648
|
+
* but that is acceptable for our uses of this.
|
|
649
|
+
*/
|
|
650
|
+
type SimpleAsyncIterator<T> = Pick<AsyncIterator<T>, 'next'>;
|
|
651
|
+
|
|
658
652
|
type BSONImplementation = typeof BSON;
|
|
659
653
|
type RemoteConnector = {
|
|
660
654
|
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
|
|
@@ -665,7 +659,7 @@ type SyncStreamOptions = {
|
|
|
665
659
|
path: string;
|
|
666
660
|
data: StreamingSyncRequest;
|
|
667
661
|
headers?: Record<string, string>;
|
|
668
|
-
abortSignal
|
|
662
|
+
abortSignal: AbortSignal;
|
|
669
663
|
fetchOptions?: Request;
|
|
670
664
|
};
|
|
671
665
|
declare enum FetchStrategy {
|
|
@@ -774,20 +768,41 @@ declare abstract class AbstractRemote {
|
|
|
774
768
|
* @returns A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the
|
|
775
769
|
* builtin, without forcing us to bundle a polyfill with `@powersync/common`.
|
|
776
770
|
*/
|
|
777
|
-
|
|
771
|
+
createTextDecoder(): TextDecoder;
|
|
778
772
|
protected createSocket(url: string): WebSocket;
|
|
779
773
|
/**
|
|
780
|
-
* Returns a data stream of sync line data.
|
|
774
|
+
* Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.
|
|
775
|
+
*
|
|
776
|
+
* The only mechanism to abort the returned stream is to use the abort signal in {@link SocketSyncStreamOptions}.
|
|
781
777
|
*
|
|
782
|
-
* @param map Maps received payload frames to the typed event value.
|
|
783
778
|
* @param bson A BSON encoder and decoder. When set, the data stream will be requested with a BSON payload
|
|
784
779
|
* (required for compatibility with older sync services).
|
|
785
780
|
*/
|
|
786
|
-
socketStreamRaw
|
|
781
|
+
socketStreamRaw(options: SocketSyncStreamOptions, bson?: typeof BSON): Promise<SimpleAsyncIterator<Uint8Array>>;
|
|
787
782
|
/**
|
|
788
|
-
*
|
|
783
|
+
* @returns Whether the HTTP implementation on this platform can receive streamed binary responses. This is true on
|
|
784
|
+
* all platforms except React Native (who would have guessed...), where we must not request BSON responses.
|
|
785
|
+
*
|
|
786
|
+
* @see https://github.com/react-native-community/fetch?tab=readme-ov-file#motivation
|
|
789
787
|
*/
|
|
790
|
-
|
|
788
|
+
protected get supportsStreamingBinaryResponses(): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Posts a `/sync/stream` request, asserts that it completes successfully and returns the streaming response as an
|
|
791
|
+
* async iterator of byte blobs.
|
|
792
|
+
*
|
|
793
|
+
* To cancel the async iterator, use the abort signal from {@link SyncStreamOptions} passed to this method.
|
|
794
|
+
*/
|
|
795
|
+
protected fetchStreamRaw(options: SyncStreamOptions): Promise<{
|
|
796
|
+
isBson: boolean;
|
|
797
|
+
stream: SimpleAsyncIterator<Uint8Array>;
|
|
798
|
+
}>;
|
|
799
|
+
/**
|
|
800
|
+
* Posts a `/sync/stream` request.
|
|
801
|
+
*
|
|
802
|
+
* Depending on the `Content-Type` of the response, this returns strings for sync lines or encoded BSON documents as
|
|
803
|
+
* {@link Uint8Array}s.
|
|
804
|
+
*/
|
|
805
|
+
fetchStream(options: SyncStreamOptions): Promise<SimpleAsyncIterator<Uint8Array | string>>;
|
|
791
806
|
}
|
|
792
807
|
|
|
793
808
|
declare enum LockType {
|
|
@@ -950,6 +965,7 @@ interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyn
|
|
|
950
965
|
waitForStatus(status: SyncStatusOptions): Promise<void>;
|
|
951
966
|
waitUntilStatusMatches(predicate: (status: SyncStatus) => boolean): Promise<void>;
|
|
952
967
|
updateSubscriptions(subscriptions: SubscribedStream[]): void;
|
|
968
|
+
markConnectionMayHaveChanged(): void;
|
|
953
969
|
}
|
|
954
970
|
declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
|
|
955
971
|
declare const DEFAULT_RETRY_DELAY_MS = 5000;
|
|
@@ -972,6 +988,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
972
988
|
protected streamingSyncPromise?: Promise<void>;
|
|
973
989
|
protected logger: ILogger;
|
|
974
990
|
private activeStreams;
|
|
991
|
+
private connectionMayHaveChanged;
|
|
975
992
|
private isUploadingCrud;
|
|
976
993
|
private notifyCompletedUploads?;
|
|
977
994
|
private handleActiveStreamsChange?;
|
|
@@ -994,6 +1011,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
994
1011
|
* @deprecated use [connect instead]
|
|
995
1012
|
*/
|
|
996
1013
|
streamingSync(signal?: AbortSignal, options?: PowerSyncConnectionOptions): Promise<void>;
|
|
1014
|
+
markConnectionMayHaveChanged(): void;
|
|
997
1015
|
private collectLocalBucketState;
|
|
998
1016
|
/**
|
|
999
1017
|
* Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
|
|
@@ -1012,6 +1030,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
1012
1030
|
*/
|
|
1013
1031
|
private requireKeyFormat;
|
|
1014
1032
|
protected streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<RustIterationResult | null>;
|
|
1033
|
+
private receiveSyncLines;
|
|
1015
1034
|
private legacyStreamingSyncIteration;
|
|
1016
1035
|
private rustSyncIteration;
|
|
1017
1036
|
private updateSyncStatusForStartingCheckpoint;
|
|
@@ -1315,14 +1334,10 @@ declare class SyncStatus {
|
|
|
1315
1334
|
*
|
|
1316
1335
|
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
1317
1336
|
* included streams yet.
|
|
1318
|
-
*
|
|
1319
|
-
* @experimental Sync streams are currently in alpha.
|
|
1320
1337
|
*/
|
|
1321
1338
|
get syncStreams(): SyncStreamStatus[] | undefined;
|
|
1322
1339
|
/**
|
|
1323
1340
|
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
1324
|
-
*
|
|
1325
|
-
* @experimental Sync streams are currently in alpha.
|
|
1326
1341
|
*/
|
|
1327
1342
|
forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
|
|
1328
1343
|
/**
|
|
@@ -1667,11 +1682,6 @@ declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
1667
1682
|
* To collect local writes to raw tables with PowerSync, custom triggers are required. See
|
|
1668
1683
|
* {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
|
|
1669
1684
|
* using raw tables.
|
|
1670
|
-
*
|
|
1671
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1672
|
-
*
|
|
1673
|
-
* @experimental Please note that this feature is experimental at the moment, and not covered by PowerSync semver or
|
|
1674
|
-
* stability guarantees.
|
|
1675
1685
|
*/
|
|
1676
1686
|
type RawTableType = RawTableTypeWithStatements | InferredRawTableType;
|
|
1677
1687
|
interface RawTableTypeWithStatements {
|
|
@@ -1771,10 +1781,8 @@ declare class Schema<S extends SchemaType = SchemaType> {
|
|
|
1771
1781
|
* developer instead of automatically by PowerSync.
|
|
1772
1782
|
* Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
|
|
1773
1783
|
* using client-side table and column constraints.
|
|
1774
|
-
* Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
|
|
1775
1784
|
*
|
|
1776
1785
|
* @param tables An object of (table name, raw table definition) entries.
|
|
1777
|
-
* @experimental Note that the raw tables API is still experimental and may change in the future.
|
|
1778
1786
|
*/
|
|
1779
1787
|
withRawTables(tables: Record<string, RawTableType>): void;
|
|
1780
1788
|
validate(): void;
|
|
@@ -2990,6 +2998,56 @@ declare class TriggerManagerImpl implements TriggerManager {
|
|
|
2990
2998
|
trackTableDiff(options: TrackDiffOptions): Promise<TriggerRemoveCallback>;
|
|
2991
2999
|
}
|
|
2992
3000
|
|
|
3001
|
+
type UnlockFn = () => void;
|
|
3002
|
+
/**
|
|
3003
|
+
* An asynchronous semaphore implementation with associated items per lease.
|
|
3004
|
+
*
|
|
3005
|
+
* @internal This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
|
|
3006
|
+
*/
|
|
3007
|
+
declare class Semaphore<T> {
|
|
3008
|
+
private readonly available;
|
|
3009
|
+
readonly size: number;
|
|
3010
|
+
private firstWaiter?;
|
|
3011
|
+
private lastWaiter?;
|
|
3012
|
+
constructor(elements: Iterable<T>);
|
|
3013
|
+
private addWaiter;
|
|
3014
|
+
private deactivateWaiter;
|
|
3015
|
+
private requestPermits;
|
|
3016
|
+
/**
|
|
3017
|
+
* Requests a single item from the pool.
|
|
3018
|
+
*
|
|
3019
|
+
* The returned `release` callback must be invoked to return the item into the pool.
|
|
3020
|
+
*/
|
|
3021
|
+
requestOne(abort?: AbortSignal): Promise<{
|
|
3022
|
+
item: T;
|
|
3023
|
+
release: UnlockFn;
|
|
3024
|
+
}>;
|
|
3025
|
+
/**
|
|
3026
|
+
* Requests access to all items from the pool.
|
|
3027
|
+
*
|
|
3028
|
+
* The returned `release` callback must be invoked to return items into the pool.
|
|
3029
|
+
*/
|
|
3030
|
+
requestAll(abort?: AbortSignal): Promise<{
|
|
3031
|
+
items: T[];
|
|
3032
|
+
release: UnlockFn;
|
|
3033
|
+
}>;
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* An asynchronous mutex implementation.
|
|
3037
|
+
*
|
|
3038
|
+
* @internal This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
|
|
3039
|
+
*/
|
|
3040
|
+
declare class Mutex {
|
|
3041
|
+
private inner;
|
|
3042
|
+
acquire(abort?: AbortSignal): Promise<UnlockFn>;
|
|
3043
|
+
runExclusive<T>(fn: () => PromiseLike<T> | T, abort?: AbortSignal): Promise<T>;
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Creates a signal aborting after the set timeout.
|
|
3047
|
+
*/
|
|
3048
|
+
declare function timeoutSignal(timeout: number): AbortSignal;
|
|
3049
|
+
declare function timeoutSignal(timeout?: number): AbortSignal | undefined;
|
|
3050
|
+
|
|
2993
3051
|
interface DisconnectAndClearOptions {
|
|
2994
3052
|
/** When set to false, data in local-only tables is preserved. */
|
|
2995
3053
|
clearLocal?: boolean;
|
|
@@ -3337,6 +3395,10 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
3337
3395
|
* Execute a SQL write (INSERT/UPDATE/DELETE) query
|
|
3338
3396
|
* and optionally return results.
|
|
3339
3397
|
*
|
|
3398
|
+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
|
|
3399
|
+
* the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
|
|
3400
|
+
* Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
|
|
3401
|
+
*
|
|
3340
3402
|
* @param sql The SQL query to execute
|
|
3341
3403
|
* @param parameters Optional array of parameters to bind to the query
|
|
3342
3404
|
* @returns The query result as an object with structured key-value pairs
|
|
@@ -3917,9 +3979,15 @@ declare class AttachmentQueue {
|
|
|
3917
3979
|
readonly tableName: string;
|
|
3918
3980
|
/** Logger instance for diagnostic information */
|
|
3919
3981
|
readonly logger: ILogger;
|
|
3920
|
-
/** Interval in milliseconds between periodic sync operations.
|
|
3982
|
+
/** Interval in milliseconds between periodic sync operations. Acts as a polling timer to retry
|
|
3983
|
+
* failed uploads/downloads, especially after the app goes offline. Default: 30000 (30 seconds) */
|
|
3921
3984
|
readonly syncIntervalMs: number;
|
|
3922
|
-
/**
|
|
3985
|
+
/** Throttle duration in milliseconds for the reactive watch query on the attachments table.
|
|
3986
|
+
* When attachment records change, a watch query detects the change and triggers a sync.
|
|
3987
|
+
* This throttle prevents the sync from firing too rapidly when many changes happen in
|
|
3988
|
+
* quick succession (e.g., bulk inserts). This is distinct from syncIntervalMs — it controls
|
|
3989
|
+
* how quickly the queue reacts to changes, while syncIntervalMs controls how often it polls
|
|
3990
|
+
* for retries. Default: 30 (from DEFAULT_WATCH_THROTTLE_MS) */
|
|
3923
3991
|
readonly syncThrottleDuration: number;
|
|
3924
3992
|
/** Whether to automatically download remote attachments. Default: true */
|
|
3925
3993
|
readonly downloadAttachments: boolean;
|
|
@@ -3943,8 +4011,8 @@ declare class AttachmentQueue {
|
|
|
3943
4011
|
* @param options.watchAttachments - Callback for monitoring attachment changes in your data model
|
|
3944
4012
|
* @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
|
|
3945
4013
|
* @param options.logger - Logger instance. Defaults to db.logger
|
|
3946
|
-
* @param options.syncIntervalMs -
|
|
3947
|
-
* @param options.syncThrottleDuration - Throttle duration for
|
|
4014
|
+
* @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
|
|
4015
|
+
* @param options.syncThrottleDuration - Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
|
|
3948
4016
|
* @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
|
|
3949
4017
|
* @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
|
|
3950
4018
|
*/
|
|
@@ -4100,9 +4168,10 @@ declare class SyncingService {
|
|
|
4100
4168
|
* On failure, defers to error handler or archives.
|
|
4101
4169
|
*
|
|
4102
4170
|
* @param attachment - The attachment record to delete
|
|
4171
|
+
* @param context - Attachment context for database operations
|
|
4103
4172
|
* @returns Updated attachment record
|
|
4104
4173
|
*/
|
|
4105
|
-
deleteAttachment(attachment: AttachmentRecord): Promise<AttachmentRecord>;
|
|
4174
|
+
deleteAttachment(attachment: AttachmentRecord, context: AttachmentContext): Promise<AttachmentRecord>;
|
|
4106
4175
|
/**
|
|
4107
4176
|
* Performs cleanup of archived attachments by removing their local files and records.
|
|
4108
4177
|
* Errors during local file deletion are logged but do not prevent record deletion.
|
|
@@ -4312,18 +4381,11 @@ declare class ControlledExecutor<T> {
|
|
|
4312
4381
|
private execute;
|
|
4313
4382
|
}
|
|
4314
4383
|
|
|
4315
|
-
/**
|
|
4316
|
-
* Wrapper for async-mutex runExclusive, which allows for a timeout on each exclusive lock.
|
|
4317
|
-
*/
|
|
4318
|
-
declare function mutexRunExclusive<T>(mutex: Mutex, callback: () => Promise<T>, options?: {
|
|
4319
|
-
timeoutMs?: number;
|
|
4320
|
-
}): Promise<T>;
|
|
4321
|
-
|
|
4322
4384
|
interface ParsedQuery {
|
|
4323
4385
|
sqlStatement: string;
|
|
4324
4386
|
parameters: any[];
|
|
4325
4387
|
}
|
|
4326
4388
|
declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
|
|
4327
4389
|
|
|
4328
|
-
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS,
|
|
4329
|
-
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, AttachmentData, AttachmentErrorHandler, AttachmentRecord, AttachmentTableOptions, BSONImplementation, BaseColumnType, BaseConnectionOptions, BaseListener, BaseObserverInterface, BasePowerSyncDatabaseOptions, BaseTriggerDiffRecord, BatchedUpdateNotification, BucketChecksum, BucketDescription, BucketOperationProgress, BucketRequest, BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, ChecksumCache, ColumnOptions, ColumnsType, CompilableQuery, CompilableQueryWatchHandler, CompiledQuery, ConnectionManagerListener, ConnectionManagerOptions, ConnectionManagerSyncImplementationResult, ContinueCheckpointRequest, ControlledExecutorOptions, CreateDiffTriggerOptions, CreateLoggerOptions, CreateSyncImplementationOptions, CrudRequest, CrudResponse, CrudUploadNotification, DBAdapter, DBAdapterListener, DBGetUtils, DBLockOptions,
|
|
4390
|
+
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DBAdapterDefaultMixin, DBGetUtilsDefaultMixin, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, Mutex, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, Semaphore, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID, timeoutSignal };
|
|
4391
|
+
export type { AbstractQueryProcessorOptions, AbstractRemoteOptions, AbstractStreamingSyncImplementationOptions, AdditionalConnectionOptions, ArrayComparatorOptions, ArrayQueryDefinition, AttachmentData, AttachmentErrorHandler, AttachmentRecord, AttachmentTableOptions, BSONImplementation, BaseColumnType, BaseConnectionOptions, BaseListener, BaseObserverInterface, BasePowerSyncDatabaseOptions, BaseTriggerDiffRecord, BatchedUpdateNotification, BucketChecksum, BucketDescription, BucketOperationProgress, BucketRequest, BucketState, BucketStorageAdapter, BucketStorageListener, Checkpoint, ChecksumCache, ColumnOptions, ColumnsType, CompilableQuery, CompilableQueryWatchHandler, CompiledQuery, ConnectionManagerListener, ConnectionManagerOptions, ConnectionManagerSyncImplementationResult, ConnectionPool, ContinueCheckpointRequest, ControlledExecutorOptions, CreateDiffTriggerOptions, CreateLoggerOptions, CreateSyncImplementationOptions, CrudRequest, CrudResponse, CrudUploadNotification, DBAdapter, DBAdapterListener, DBGetUtils, DBLockOptions, DifferentialQueryProcessorOptions, DifferentialWatchedQuery, DifferentialWatchedQueryComparator, DifferentialWatchedQueryListener, DifferentialWatchedQueryOptions, DifferentialWatchedQuerySettings, DisconnectAndClearOptions, Disposable, ExtractColumnValueType, ExtractedTriggerDiffRecord, FetchImplementation, GetAllQueryOptions, IndexColumnOptions, IndexOptions, IndexShorthand, InternalConnectionOptions, InternalSubscriptionAdapter, LinkQueryOptions, LocalStorageAdapter, LockContext, LockOptions, MutableWatchedQueryState, OnChangeQueryProcessorOptions, OpId, OpTypeJSON, OplogEntryJSON, ParsedQuery, PendingStatement, PendingStatementParameter, PowerSyncBackendConnector, PowerSyncCloseOptions, PowerSyncConnectionOptions, PowerSyncCredentials, PowerSyncDBListener, PowerSyncDatabaseOptions, PowerSyncDatabaseOptionsWithDBAdapter, PowerSyncDatabaseOptionsWithOpenFactory, PowerSyncDatabaseOptionsWithSettings, PowerSyncOpenFactoryOptions, ProgressWithOperations, Query, QueryParam, QueryResult, RawTableType, RemoteConnector, RemoteStorageAdapter, RequiredAdditionalConnectionOptions, RequiredPowerSyncConnectionOptions, RowType, SQLOnChangeOptions, SQLOpenFactory, SQLOpenOptions, SQLWatchOptions, SavedProgress, SchemaTableType, SimpleAsyncIterator, SocketSyncStreamOptions, SqlExecutor, StandardWatchedQuery, StandardWatchedQueryOptions, StreamingSyncCheckpoint, StreamingSyncCheckpointComplete, StreamingSyncCheckpointDiff, StreamingSyncCheckpointPartiallyComplete, StreamingSyncDataJSON, StreamingSyncImplementation, StreamingSyncImplementationListener, StreamingSyncKeepalive, StreamingSyncLine, StreamingSyncLineOrCrudUploadComplete, StreamingSyncRequest, StreamingSyncRequestParameterType, SubscribedStream, SyncDataBucketJSON, SyncDataFlowStatus, SyncLocalDatabaseResult, SyncNewCheckpointRequest, SyncPriorityStatus, SyncRequest, SyncResponse, SyncStatusOptions, SyncStream, SyncStreamDescription, SyncStreamOptions, SyncStreamStatus, SyncStreamSubscribeOptions, SyncStreamSubscription, SyncSubscriptionDescription, TableOptions, TableOrRawTableOptions, TableUpdateOperation, TableV2Options, TrackDiffOptions, TrackPreviousOptions, Transaction, TriggerClaimManager, TriggerCreationHooks, TriggerDiffDeleteRecord, TriggerDiffHandlerContext, TriggerDiffInsertRecord, TriggerDiffRecord, TriggerDiffUpdateRecord, TriggerManager, TriggerManagerConfig, TriggerRemoveCallback, TriggerRemoveCallbackOptions, UnlockFn, UpdateNotification, WatchCompatibleQuery, WatchExecuteOptions, WatchHandler, WatchOnChangeEvent, WatchOnChangeHandler, WatchedAttachmentItem, WatchedQuery, WatchedQueryComparator, WatchedQueryDifferential, WatchedQueryListener, WatchedQueryOptions, WatchedQueryRowDifferential, WatchedQuerySettings, WatchedQueryState, WithDiffOptions };
|
|
@@ -36,9 +36,15 @@ export declare class AttachmentQueue {
|
|
|
36
36
|
readonly tableName: string;
|
|
37
37
|
/** Logger instance for diagnostic information */
|
|
38
38
|
readonly logger: ILogger;
|
|
39
|
-
/** Interval in milliseconds between periodic sync operations.
|
|
39
|
+
/** Interval in milliseconds between periodic sync operations. Acts as a polling timer to retry
|
|
40
|
+
* failed uploads/downloads, especially after the app goes offline. Default: 30000 (30 seconds) */
|
|
40
41
|
readonly syncIntervalMs: number;
|
|
41
|
-
/**
|
|
42
|
+
/** Throttle duration in milliseconds for the reactive watch query on the attachments table.
|
|
43
|
+
* When attachment records change, a watch query detects the change and triggers a sync.
|
|
44
|
+
* This throttle prevents the sync from firing too rapidly when many changes happen in
|
|
45
|
+
* quick succession (e.g., bulk inserts). This is distinct from syncIntervalMs — it controls
|
|
46
|
+
* how quickly the queue reacts to changes, while syncIntervalMs controls how often it polls
|
|
47
|
+
* for retries. Default: 30 (from DEFAULT_WATCH_THROTTLE_MS) */
|
|
42
48
|
readonly syncThrottleDuration: number;
|
|
43
49
|
/** Whether to automatically download remote attachments. Default: true */
|
|
44
50
|
readonly downloadAttachments: boolean;
|
|
@@ -62,8 +68,8 @@ export declare class AttachmentQueue {
|
|
|
62
68
|
* @param options.watchAttachments - Callback for monitoring attachment changes in your data model
|
|
63
69
|
* @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
|
|
64
70
|
* @param options.logger - Logger instance. Defaults to db.logger
|
|
65
|
-
* @param options.syncIntervalMs -
|
|
66
|
-
* @param options.syncThrottleDuration - Throttle duration for
|
|
71
|
+
* @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
|
|
72
|
+
* @param options.syncThrottleDuration - Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
|
|
67
73
|
* @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
|
|
68
74
|
* @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
|
|
69
75
|
*/
|
|
@@ -32,9 +32,15 @@ export class AttachmentQueue {
|
|
|
32
32
|
tableName;
|
|
33
33
|
/** Logger instance for diagnostic information */
|
|
34
34
|
logger;
|
|
35
|
-
/** Interval in milliseconds between periodic sync operations.
|
|
35
|
+
/** Interval in milliseconds between periodic sync operations. Acts as a polling timer to retry
|
|
36
|
+
* failed uploads/downloads, especially after the app goes offline. Default: 30000 (30 seconds) */
|
|
36
37
|
syncIntervalMs = 30 * 1000;
|
|
37
|
-
/**
|
|
38
|
+
/** Throttle duration in milliseconds for the reactive watch query on the attachments table.
|
|
39
|
+
* When attachment records change, a watch query detects the change and triggers a sync.
|
|
40
|
+
* This throttle prevents the sync from firing too rapidly when many changes happen in
|
|
41
|
+
* quick succession (e.g., bulk inserts). This is distinct from syncIntervalMs — it controls
|
|
42
|
+
* how quickly the queue reacts to changes, while syncIntervalMs controls how often it polls
|
|
43
|
+
* for retries. Default: 30 (from DEFAULT_WATCH_THROTTLE_MS) */
|
|
38
44
|
syncThrottleDuration;
|
|
39
45
|
/** Whether to automatically download remote attachments. Default: true */
|
|
40
46
|
downloadAttachments = true;
|
|
@@ -58,8 +64,8 @@ export class AttachmentQueue {
|
|
|
58
64
|
* @param options.watchAttachments - Callback for monitoring attachment changes in your data model
|
|
59
65
|
* @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
|
|
60
66
|
* @param options.logger - Logger instance. Defaults to db.logger
|
|
61
|
-
* @param options.syncIntervalMs -
|
|
62
|
-
* @param options.syncThrottleDuration - Throttle duration for
|
|
67
|
+
* @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
|
|
68
|
+
* @param options.syncThrottleDuration - Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
|
|
63
69
|
* @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
|
|
64
70
|
* @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
|
|
65
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentQueue.js","sourceRoot":"","sources":["../../src/attachments/AttachmentQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAM9E,OAAO,EAAE,gBAAgB,EAAoB,eAAe,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAC1B,oDAAoD;IAC5C,iBAAiB,CAAkC;IAE3D,6EAA6E;IAC5D,cAAc,CAAiB;IAEhD,gDAAgD;IACvC,YAAY,CAAsB;IAE3C,iDAAiD;IACxC,aAAa,CAAuB;IAE7C;;;;;;OAMG;IACc,gBAAgB,CAGvB;IAEV,4DAA4D;IACnD,SAAS,CAAS;IAE3B,iDAAiD;IACxC,MAAM,CAAU;IAEzB
|
|
1
|
+
{"version":3,"file":"AttachmentQueue.js","sourceRoot":"","sources":["../../src/attachments/AttachmentQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAM9E,OAAO,EAAE,gBAAgB,EAAoB,eAAe,EAAE,MAAM,aAAa,CA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AAI,UAAU,CAAC,KAAK,KAAK,eAAe,CAAC,MAAM,EAAE,CAAC;wBAChD,yEAAyE;wBACzE,uBAAuB;wBACvB,OAAO,CAAC,IAAI,CAAC;4BACX,GAAG,UAAU;4BACb,KAAK,EAAE,eAAe,CAAC,eAAe;4BACtC,QAAQ,EAAE,SAAS;yBACpB,CAAC,CAAC;oBACL,CAAC;yBAAM,CAAC;wBACN,uEAAuE;wBACvE,OAAO,CAAC,IAAI,CAAC;4BACX,GAAG,UAAU;4BACb,KAAK,EAAE,eAAe,CAAC,QAAQ;4BAC/B,QAAQ,EAAE,SAAS,CAAC,mBAAmB;yBACxC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Mutex } from '
|
|
2
|
-
import { mutexRunExclusive } from '../utils/mutex.js';
|
|
1
|
+
import { Mutex } from '../utils/mutex.js';
|
|
3
2
|
import { AttachmentContext } from './AttachmentContext.js';
|
|
4
3
|
import { AttachmentState } from './Schema.js';
|
|
5
4
|
/**
|
|
@@ -48,7 +47,7 @@ export class AttachmentService {
|
|
|
48
47
|
* Executes a callback with exclusive access to the attachment context.
|
|
49
48
|
*/
|
|
50
49
|
async withContext(callback) {
|
|
51
|
-
return
|
|
50
|
+
return this.mutex.runExclusive(async () => {
|
|
52
51
|
return callback(this.context);
|
|
53
52
|
});
|
|
54
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentService.js","sourceRoot":"","sources":["../../src/attachments/AttachmentService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AttachmentService.js","sourceRoot":"","sources":["../../src/attachments/AttachmentService.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,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52
|
*
|
|
53
53
|
* @param attachment - The attachment record to delete
|
|
54
|
+
* @param context - Attachment context for database operations
|
|
54
55
|
* @returns Updated attachment record
|
|
55
56
|
*/
|
|
56
|
-
deleteAttachment(attachment: AttachmentRecord): Promise<AttachmentRecord>;
|
|
57
|
+
deleteAttachment(attachment: AttachmentRecord, context: AttachmentContext): Promise<AttachmentRecord>;
|
|
57
58
|
/**
|
|
58
59
|
* Performs cleanup of archived attachments by removing their local files and records.
|
|
59
60
|
* Errors during local file deletion are logged but do not prevent record deletion.
|
|
@@ -39,7 +39,7 @@ export class SyncingService {
|
|
|
39
39
|
updatedAttachments.push(downloaded);
|
|
40
40
|
break;
|
|
41
41
|
case AttachmentState.QUEUED_DELETE:
|
|
42
|
-
const deleted = await this.deleteAttachment(attachment);
|
|
42
|
+
const deleted = await this.deleteAttachment(attachment, context);
|
|
43
43
|
updatedAttachments.push(deleted);
|
|
44
44
|
break;
|
|
45
45
|
default:
|
|
@@ -119,17 +119,16 @@ export class SyncingService {
|
|
|
119
119
|
* On failure, defers to error handler or archives.
|
|
120
120
|
*
|
|
121
121
|
* @param attachment - The attachment record to delete
|
|
122
|
+
* @param context - Attachment context for database operations
|
|
122
123
|
* @returns Updated attachment record
|
|
123
124
|
*/
|
|
124
|
-
async deleteAttachment(attachment) {
|
|
125
|
+
async deleteAttachment(attachment, context) {
|
|
125
126
|
try {
|
|
126
127
|
await this.remoteStorage.deleteFile(attachment);
|
|
127
128
|
if (attachment.localUri) {
|
|
128
129
|
await this.localStorage.deleteFile(attachment.localUri);
|
|
129
130
|
}
|
|
130
|
-
await
|
|
131
|
-
await ctx.deleteAttachment(attachment.id);
|
|
132
|
-
});
|
|
131
|
+
await context.deleteAttachment(attachment.id);
|
|
133
132
|
return {
|
|
134
133
|
...attachment,
|
|
135
134
|
state: AttachmentState.ARCHIVED
|