@powersync/common 0.0.0-dev-20260311081226 → 0.0.0-dev-20260414110516
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 +775 -485
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +769 -481
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +773 -484
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +767 -480
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +175 -94
- 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 +1 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +69 -88
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/triggers/TriggerManager.d.ts +12 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +2 -2
- package/lib/client/triggers/TriggerManagerImpl.js +3 -2
- package/lib/client/triggers/TriggerManagerImpl.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/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 +82 -83
- package/src/client/triggers/TriggerManager.ts +13 -1
- package/src/client/triggers/TriggerManagerImpl.ts +4 -2
- package/src/db/DBAdapter.ts +167 -9
- 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 {
|
|
@@ -1012,6 +1027,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
|
|
|
1012
1027
|
*/
|
|
1013
1028
|
private requireKeyFormat;
|
|
1014
1029
|
protected streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<RustIterationResult | null>;
|
|
1030
|
+
private receiveSyncLines;
|
|
1015
1031
|
private legacyStreamingSyncIteration;
|
|
1016
1032
|
private rustSyncIteration;
|
|
1017
1033
|
private updateSyncStatusForStartingCheckpoint;
|
|
@@ -2684,13 +2700,24 @@ interface CreateDiffTriggerOptions extends BaseCreateDiffTriggerOptions {
|
|
|
2684
2700
|
* This table will be dropped once the trigger is removed.
|
|
2685
2701
|
*/
|
|
2686
2702
|
destination: string;
|
|
2703
|
+
/**
|
|
2704
|
+
* Context to use for the setup operation.
|
|
2705
|
+
* This is useful for when the setup operation needs to be executed in a specific context.
|
|
2706
|
+
*/
|
|
2687
2707
|
setupContext?: LockContext;
|
|
2688
2708
|
}
|
|
2709
|
+
/**
|
|
2710
|
+
* @experimental
|
|
2711
|
+
* Options for {@link TriggerRemoveCallback}.
|
|
2712
|
+
*/
|
|
2713
|
+
interface TriggerRemoveCallbackOptions {
|
|
2714
|
+
context?: LockContext;
|
|
2715
|
+
}
|
|
2689
2716
|
/**
|
|
2690
2717
|
* @experimental
|
|
2691
2718
|
* Callback to drop a trigger after it has been created.
|
|
2692
2719
|
*/
|
|
2693
|
-
type TriggerRemoveCallback = (
|
|
2720
|
+
type TriggerRemoveCallback = (options?: TriggerRemoveCallbackOptions) => Promise<void>;
|
|
2694
2721
|
/**
|
|
2695
2722
|
* @experimental
|
|
2696
2723
|
* Options for {@link TriggerDiffHandlerContext#withDiff}.
|
|
@@ -2975,10 +3002,60 @@ declare class TriggerManagerImpl implements TriggerManager {
|
|
|
2975
3002
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
2976
3003
|
*/
|
|
2977
3004
|
cleanupResources(): Promise<void>;
|
|
2978
|
-
createDiffTrigger(options: CreateDiffTriggerOptions): Promise<(
|
|
3005
|
+
createDiffTrigger(options: CreateDiffTriggerOptions): Promise<(options?: TriggerRemoveCallbackOptions) => Promise<void>>;
|
|
2979
3006
|
trackTableDiff(options: TrackDiffOptions): Promise<TriggerRemoveCallback>;
|
|
2980
3007
|
}
|
|
2981
3008
|
|
|
3009
|
+
type UnlockFn = () => void;
|
|
3010
|
+
/**
|
|
3011
|
+
* An asynchronous semaphore implementation with associated items per lease.
|
|
3012
|
+
*
|
|
3013
|
+
* @internal This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
|
|
3014
|
+
*/
|
|
3015
|
+
declare class Semaphore<T> {
|
|
3016
|
+
private readonly available;
|
|
3017
|
+
readonly size: number;
|
|
3018
|
+
private firstWaiter?;
|
|
3019
|
+
private lastWaiter?;
|
|
3020
|
+
constructor(elements: Iterable<T>);
|
|
3021
|
+
private addWaiter;
|
|
3022
|
+
private deactivateWaiter;
|
|
3023
|
+
private requestPermits;
|
|
3024
|
+
/**
|
|
3025
|
+
* Requests a single item from the pool.
|
|
3026
|
+
*
|
|
3027
|
+
* The returned `release` callback must be invoked to return the item into the pool.
|
|
3028
|
+
*/
|
|
3029
|
+
requestOne(abort?: AbortSignal): Promise<{
|
|
3030
|
+
item: T;
|
|
3031
|
+
release: UnlockFn;
|
|
3032
|
+
}>;
|
|
3033
|
+
/**
|
|
3034
|
+
* Requests access to all items from the pool.
|
|
3035
|
+
*
|
|
3036
|
+
* The returned `release` callback must be invoked to return items into the pool.
|
|
3037
|
+
*/
|
|
3038
|
+
requestAll(abort?: AbortSignal): Promise<{
|
|
3039
|
+
items: T[];
|
|
3040
|
+
release: UnlockFn;
|
|
3041
|
+
}>;
|
|
3042
|
+
}
|
|
3043
|
+
/**
|
|
3044
|
+
* An asynchronous mutex implementation.
|
|
3045
|
+
*
|
|
3046
|
+
* @internal This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
|
|
3047
|
+
*/
|
|
3048
|
+
declare class Mutex {
|
|
3049
|
+
private inner;
|
|
3050
|
+
acquire(abort?: AbortSignal): Promise<UnlockFn>;
|
|
3051
|
+
runExclusive<T>(fn: () => PromiseLike<T> | T, abort?: AbortSignal): Promise<T>;
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* Creates a signal aborting after the set timeout.
|
|
3055
|
+
*/
|
|
3056
|
+
declare function timeoutSignal(timeout: number): AbortSignal;
|
|
3057
|
+
declare function timeoutSignal(timeout?: number): AbortSignal | undefined;
|
|
3058
|
+
|
|
2982
3059
|
interface DisconnectAndClearOptions {
|
|
2983
3060
|
/** When set to false, data in local-only tables is preserved. */
|
|
2984
3061
|
clearLocal?: boolean;
|
|
@@ -3326,6 +3403,10 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
3326
3403
|
* Execute a SQL write (INSERT/UPDATE/DELETE) query
|
|
3327
3404
|
* and optionally return results.
|
|
3328
3405
|
*
|
|
3406
|
+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
|
|
3407
|
+
* the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
|
|
3408
|
+
* Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
|
|
3409
|
+
*
|
|
3329
3410
|
* @param sql The SQL query to execute
|
|
3330
3411
|
* @param parameters Optional array of parameters to bind to the query
|
|
3331
3412
|
* @returns The query result as an object with structured key-value pairs
|
|
@@ -3906,9 +3987,15 @@ declare class AttachmentQueue {
|
|
|
3906
3987
|
readonly tableName: string;
|
|
3907
3988
|
/** Logger instance for diagnostic information */
|
|
3908
3989
|
readonly logger: ILogger;
|
|
3909
|
-
/** Interval in milliseconds between periodic sync operations.
|
|
3990
|
+
/** Interval in milliseconds between periodic sync operations. Acts as a polling timer to retry
|
|
3991
|
+
* failed uploads/downloads, especially after the app goes offline. Default: 30000 (30 seconds) */
|
|
3910
3992
|
readonly syncIntervalMs: number;
|
|
3911
|
-
/**
|
|
3993
|
+
/** Throttle duration in milliseconds for the reactive watch query on the attachments table.
|
|
3994
|
+
* When attachment records change, a watch query detects the change and triggers a sync.
|
|
3995
|
+
* This throttle prevents the sync from firing too rapidly when many changes happen in
|
|
3996
|
+
* quick succession (e.g., bulk inserts). This is distinct from syncIntervalMs — it controls
|
|
3997
|
+
* how quickly the queue reacts to changes, while syncIntervalMs controls how often it polls
|
|
3998
|
+
* for retries. Default: 30 (from DEFAULT_WATCH_THROTTLE_MS) */
|
|
3912
3999
|
readonly syncThrottleDuration: number;
|
|
3913
4000
|
/** Whether to automatically download remote attachments. Default: true */
|
|
3914
4001
|
readonly downloadAttachments: boolean;
|
|
@@ -3932,8 +4019,8 @@ declare class AttachmentQueue {
|
|
|
3932
4019
|
* @param options.watchAttachments - Callback for monitoring attachment changes in your data model
|
|
3933
4020
|
* @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
|
|
3934
4021
|
* @param options.logger - Logger instance. Defaults to db.logger
|
|
3935
|
-
* @param options.syncIntervalMs -
|
|
3936
|
-
* @param options.syncThrottleDuration - Throttle duration for
|
|
4022
|
+
* @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
|
|
4023
|
+
* @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
|
|
3937
4024
|
* @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
|
|
3938
4025
|
* @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
|
|
3939
4026
|
*/
|
|
@@ -4089,9 +4176,10 @@ declare class SyncingService {
|
|
|
4089
4176
|
* On failure, defers to error handler or archives.
|
|
4090
4177
|
*
|
|
4091
4178
|
* @param attachment - The attachment record to delete
|
|
4179
|
+
* @param context - Attachment context for database operations
|
|
4092
4180
|
* @returns Updated attachment record
|
|
4093
4181
|
*/
|
|
4094
|
-
deleteAttachment(attachment: AttachmentRecord): Promise<AttachmentRecord>;
|
|
4182
|
+
deleteAttachment(attachment: AttachmentRecord, context: AttachmentContext): Promise<AttachmentRecord>;
|
|
4095
4183
|
/**
|
|
4096
4184
|
* Performs cleanup of archived attachments by removing their local files and records.
|
|
4097
4185
|
* Errors during local file deletion are logged but do not prevent record deletion.
|
|
@@ -4301,18 +4389,11 @@ declare class ControlledExecutor<T> {
|
|
|
4301
4389
|
private execute;
|
|
4302
4390
|
}
|
|
4303
4391
|
|
|
4304
|
-
/**
|
|
4305
|
-
* Wrapper for async-mutex runExclusive, which allows for a timeout on each exclusive lock.
|
|
4306
|
-
*/
|
|
4307
|
-
declare function mutexRunExclusive<T>(mutex: Mutex, callback: () => Promise<T>, options?: {
|
|
4308
|
-
timeoutMs?: number;
|
|
4309
|
-
}): Promise<T>;
|
|
4310
|
-
|
|
4311
4392
|
interface ParsedQuery {
|
|
4312
4393
|
sqlStatement: string;
|
|
4313
4394
|
parameters: any[];
|
|
4314
4395
|
}
|
|
4315
4396
|
declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
|
|
4316
4397
|
|
|
4317
|
-
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,
|
|
4318
|
-
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,
|
|
4398
|
+
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 };
|
|
4399
|
+
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,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAC1B,oDAAo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AAC,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,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAoB,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAKlB;IACA;IACA;IANF,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;IACpB,OAAO,CAAoB;IAEnC,YACU,EAA6B,EAC7B,MAAe,EACf,YAAoB,aAAa,EACzC,qBAA6B,GAAG;QAHxB,OAAE,GAAF,EAAE,CAA2B;QAC7B,WAAM,GAAN,MAAM,CAAS;QACf,cAAS,GAAT,SAAS,CAAwB;QAGzC,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACH,sBAAsB,CAAC,EAAE,UAAU,KAA8B,EAAE;QACjE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE;aAClB,KAAK,CAAmB;YACvB,GAAG,EAAE,SAAS,CAAC;;;;cAIT,IAAI,CAAC,SAAS;;;;;;;SAOnB;YACD,UAAU,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,eAAe,EAAE,eAAe,CAAC,aAAa,CAAC;SAC5G,CAAC;aACD,iBAAiB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAI,QAAoD;QACvE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE;YACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -51,9 +51,10 @@ export declare class SyncingService {
|
|
|
51
51
|
* On failure, defers to error handler or archives.
|
|
52
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncingService.js","sourceRoot":"","sources":["../../src/attachments/SyncingService.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACjB,iBAAiB,CAAoB;IACrC,YAAY,CAAsB;IAClC,aAAa,CAAuB;I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