@powersync/common 0.0.0-dev-20260630141119 → 0.0.0-dev-20260827080125
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/lib/attachments/AttachmentQueue.d.ts +97 -42
- package/lib/attachments/AttachmentQueue.js +91 -18
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentTransportAdapter.d.ts +47 -0
- package/lib/attachments/AttachmentTransportAdapter.js +2 -0
- package/lib/attachments/AttachmentTransportAdapter.js.map +1 -0
- package/lib/attachments/BufferedAttachmentTransport.d.ts +24 -0
- package/lib/attachments/BufferedAttachmentTransport.js +32 -0
- package/lib/attachments/BufferedAttachmentTransport.js.map +1 -0
- package/lib/attachments/LocalStorageAdapter.d.ts +19 -0
- package/lib/attachments/Schema.d.ts +21 -2
- package/lib/attachments/Schema.js +14 -10
- package/lib/attachments/Schema.js.map +1 -1
- package/lib/attachments/SyncingService.d.ts +21 -8
- package/lib/attachments/SyncingService.js +59 -30
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/client/CommonPowerSyncDatabase.d.ts +14 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +11 -0
- package/lib/client/sync/CheckpointRequest.d.ts +32 -0
- package/lib/client/sync/CheckpointRequest.js +2 -0
- package/lib/client/sync/CheckpointRequest.js.map +1 -0
- package/lib/client/sync/options.d.ts +34 -0
- package/lib/client/sync/options.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/attachments/AttachmentQueue.ts +162 -63
- package/src/attachments/AttachmentTransportAdapter.ts +49 -0
- package/src/attachments/BufferedAttachmentTransport.ts +37 -0
- package/src/attachments/LocalStorageAdapter.ts +20 -0
- package/src/attachments/Schema.ts +29 -20
- package/src/attachments/SyncingService.ts +67 -34
- package/src/client/CommonPowerSyncDatabase.ts +15 -1
- package/src/client/connection/PowerSyncBackendConnector.ts +12 -0
- package/src/client/sync/CheckpointRequest.ts +31 -0
- package/src/client/sync/options.ts +35 -0
- package/src/db/crud/SyncStatus.ts +1 -1
- package/src/index.ts +9 -1
|
@@ -2,30 +2,29 @@ import { PowerSyncLogger } from '../utils/Logger.js';
|
|
|
2
2
|
import { Transaction } from '../db/DBAdapter.js';
|
|
3
3
|
import { AttachmentContext } from './AttachmentContext.js';
|
|
4
4
|
import { AttachmentErrorHandler } from './AttachmentErrorHandler.js';
|
|
5
|
-
import {
|
|
5
|
+
import { AttachmentTransportAdapter } from './AttachmentTransportAdapter.js';
|
|
6
|
+
import { AttachmentData, LocalStorageAdapter, StreamingLocalStorageAdapter } from './LocalStorageAdapter.js';
|
|
6
7
|
import { RemoteStorageAdapter } from './RemoteStorageAdapter.js';
|
|
7
8
|
import { AttachmentRecord } from './Schema.js';
|
|
8
9
|
import { WatchedAttachmentItem } from './WatchedAttachmentItem.js';
|
|
9
10
|
import { CommonPowerSyncDatabase } from '../client/CommonPowerSyncDatabase.js';
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Fields common to every {@link AttachmentQueueOptions} variant.
|
|
12
13
|
*
|
|
13
14
|
* @experimental
|
|
14
15
|
* @alpha This is currently experimental and may change without a major version bump.
|
|
15
16
|
*/
|
|
16
|
-
export interface
|
|
17
|
+
export interface BaseAttachmentQueueOptions<TLocal extends LocalStorageAdapter = LocalStorageAdapter> {
|
|
17
18
|
/**
|
|
18
19
|
* PowerSync database instance
|
|
19
20
|
*/
|
|
20
21
|
db: CommonPowerSyncDatabase;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Local storage adapter for file persistence. Its type determines whether
|
|
24
|
+
* {@link AttachmentQueue.saveFileFromUri} is available (a
|
|
25
|
+
* {@link StreamingLocalStorageAdapter} enables it).
|
|
23
26
|
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Local storage adapter for file persistence
|
|
27
|
-
*/
|
|
28
|
-
localStorage: LocalStorageAdapter;
|
|
27
|
+
localStorage: TLocal;
|
|
29
28
|
/**
|
|
30
29
|
* Callback for monitoring attachment changes in your data model
|
|
31
30
|
*/
|
|
@@ -57,6 +56,48 @@ export interface AttachmentQueueOptions {
|
|
|
57
56
|
/** Handler for upload, download and delete errors */
|
|
58
57
|
errorHandler?: AttachmentErrorHandler;
|
|
59
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Configuration options for {@link AttachmentQueue}.
|
|
61
|
+
*
|
|
62
|
+
* Provide **exactly one** remote mechanism:
|
|
63
|
+
* - `remoteStorage` — a {@link RemoteStorageAdapter}, wrapped in the default
|
|
64
|
+
* default buffered transport that delegates upload/download/delete to it.
|
|
65
|
+
* - `transportAdapter` — an {@link AttachmentTransportAdapter} that owns all remote
|
|
66
|
+
* operations directly (e.g. a native file-URI implementation for buffer-free
|
|
67
|
+
* transfer of large files). No `remoteStorage` is needed in this case.
|
|
68
|
+
*
|
|
69
|
+
* Supplying both, or neither, is a type error.
|
|
70
|
+
*
|
|
71
|
+
* @experimental
|
|
72
|
+
* @alpha This is currently experimental and may change without a major version bump.
|
|
73
|
+
*/
|
|
74
|
+
export type AttachmentQueueOptions<TLocal extends LocalStorageAdapter = LocalStorageAdapter> = BaseAttachmentQueueOptions<TLocal> & ({
|
|
75
|
+
remoteStorage: RemoteStorageAdapter;
|
|
76
|
+
transportAdapter?: never;
|
|
77
|
+
} | {
|
|
78
|
+
transportAdapter: AttachmentTransportAdapter;
|
|
79
|
+
remoteStorage?: never;
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Fields shared by {@link AttachmentQueue.saveFile} and {@link AttachmentQueue.saveFileFromUri}.
|
|
83
|
+
*
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
export interface SaveAttachmentOptions {
|
|
87
|
+
/** File extension (e.g., 'jpg', 'pdf') */
|
|
88
|
+
fileExtension: string;
|
|
89
|
+
/** MIME type of the file (e.g., 'image/jpeg') */
|
|
90
|
+
mediaType?: string;
|
|
91
|
+
/** Optional metadata to associate with the attachment */
|
|
92
|
+
metaData?: string;
|
|
93
|
+
/** Optional custom ID. If not provided, a UUID will be generated */
|
|
94
|
+
id?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Optional callback to execute additional database operations within the same transaction as the
|
|
97
|
+
* attachment creation.
|
|
98
|
+
*/
|
|
99
|
+
updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => Promise<void>;
|
|
100
|
+
}
|
|
60
101
|
/**
|
|
61
102
|
* AttachmentQueue manages the lifecycle and synchronization of attachments
|
|
62
103
|
* between local and remote storage.
|
|
@@ -66,15 +107,13 @@ export interface AttachmentQueueOptions {
|
|
|
66
107
|
* @experimental
|
|
67
108
|
* @alpha This is currently experimental and may change without a major version bump.
|
|
68
109
|
*/
|
|
69
|
-
export declare class AttachmentQueue {
|
|
110
|
+
export declare class AttachmentQueue<TLocal extends LocalStorageAdapter = LocalStorageAdapter> {
|
|
70
111
|
/** Timer for periodic synchronization operations */
|
|
71
112
|
private periodicSyncTimer?;
|
|
72
113
|
/** Service for synchronizing attachments between local and remote storage */
|
|
73
114
|
private readonly syncingService;
|
|
74
115
|
/** Adapter for local file storage operations */
|
|
75
|
-
readonly localStorage:
|
|
76
|
-
/** Adapter for remote file storage operations */
|
|
77
|
-
readonly remoteStorage: RemoteStorageAdapter;
|
|
116
|
+
readonly localStorage: TLocal;
|
|
78
117
|
/**
|
|
79
118
|
* Callback function to watch for changes in attachment references in your data model.
|
|
80
119
|
*
|
|
@@ -109,12 +148,25 @@ export declare class AttachmentQueue {
|
|
|
109
148
|
private statusListenerDispose?;
|
|
110
149
|
private watchActiveAttachments;
|
|
111
150
|
private watchAttachmentsAbortController;
|
|
151
|
+
/**
|
|
152
|
+
* Serializes concurrent `syncStorage()` triggers (periodic timer, watch-onDiff,
|
|
153
|
+
* status-changed). Held across the whole batch, but only contended by other
|
|
154
|
+
* sync triggers — foreground `saveFile` / `deleteFile` / watched-attachment
|
|
155
|
+
* processing don't take this lock and proceed in parallel via the
|
|
156
|
+
* `AttachmentService` mutex, which is acquired only briefly per row.
|
|
157
|
+
*/
|
|
158
|
+
private syncLoopMutex;
|
|
159
|
+
/**
|
|
160
|
+
* Aborted by `stopSync()` to interrupt an in-flight batch within one
|
|
161
|
+
* attachment's processing time. Polled between rows by `SyncingService`.
|
|
162
|
+
*/
|
|
163
|
+
private syncAbortController?;
|
|
112
164
|
/**
|
|
113
165
|
* Creates a new AttachmentQueue instance.
|
|
114
166
|
*
|
|
115
167
|
* @param options - Configuration options
|
|
116
168
|
*/
|
|
117
|
-
constructor({ db, localStorage, remoteStorage, watchAttachments, logger, tableName, syncIntervalMs, syncThrottleDuration, downloadAttachments, archivedCacheLimit, errorHandler }: AttachmentQueueOptions);
|
|
169
|
+
constructor({ db, localStorage, remoteStorage, transportAdapter, watchAttachments, logger, tableName, syncIntervalMs, syncThrottleDuration, downloadAttachments, archivedCacheLimit, errorHandler }: AttachmentQueueOptions<TLocal>);
|
|
118
170
|
/**
|
|
119
171
|
* Generates a new attachment ID using a SQLite UUID function.
|
|
120
172
|
*
|
|
@@ -137,12 +189,16 @@ export declare class AttachmentQueue {
|
|
|
137
189
|
*
|
|
138
190
|
* This is called automatically at regular intervals when sync is started,
|
|
139
191
|
* but can also be called manually to trigger an immediate sync.
|
|
192
|
+
*
|
|
193
|
+
* Concurrent invocations are serialized via `syncLoopMutex`.
|
|
140
194
|
*/
|
|
141
195
|
syncStorage(): Promise<void>;
|
|
142
196
|
/**
|
|
143
197
|
* Stops the attachment synchronization process.
|
|
144
198
|
*
|
|
145
|
-
* Clears the periodic sync timer
|
|
199
|
+
* Clears the periodic sync timer, closes all active attachment watchers, and
|
|
200
|
+
* aborts any in-flight `syncStorage()` call so it exits within one
|
|
201
|
+
* attachment's processing time instead of running the batch to completion.
|
|
146
202
|
*/
|
|
147
203
|
stopSync(): Promise<void>;
|
|
148
204
|
/**
|
|
@@ -154,37 +210,36 @@ export declare class AttachmentQueue {
|
|
|
154
210
|
*/
|
|
155
211
|
withAttachmentContext<T>(callback: (context: AttachmentContext) => Promise<T>): Promise<T>;
|
|
156
212
|
/**
|
|
157
|
-
*
|
|
213
|
+
* Creates a `QUEUED_UPLOAD` attachment record, placing the file at the managed
|
|
214
|
+
* `localUri` from the given `source`, and persists the record
|
|
215
|
+
* alongside the caller's `updateHook` in a single transaction.
|
|
216
|
+
*/
|
|
217
|
+
private createUploadAttachment;
|
|
218
|
+
/**
|
|
219
|
+
* Saves in-memory file data to local storage and queues it for upload.
|
|
158
220
|
*
|
|
159
|
-
* @param options - File
|
|
221
|
+
* @param options - File data plus {@link SaveAttachmentOptions}
|
|
160
222
|
* @returns Promise resolving to the created attachment record
|
|
161
223
|
*/
|
|
162
|
-
saveFile(
|
|
163
|
-
/**
|
|
164
|
-
* The file data as ArrayBuffer, Blob, or base64 string
|
|
165
|
-
*/
|
|
224
|
+
saveFile(options: SaveAttachmentOptions & {
|
|
166
225
|
data: AttachmentData;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
* Optional callback to execute additional database operations within the same transaction as the attachment
|
|
185
|
-
* creation.
|
|
186
|
-
*/
|
|
187
|
-
updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => Promise<void>;
|
|
226
|
+
}): Promise<AttachmentRecord>;
|
|
227
|
+
/**
|
|
228
|
+
* Registers a file that already exists on disk and queues it for upload, moving it
|
|
229
|
+
* into managed storage without loading it into memory.
|
|
230
|
+
*
|
|
231
|
+
* Prefer this over {@link AttachmentQueue.saveFile} for large, app-originated files
|
|
232
|
+
* (recordings, videos): it avoids reading the file into an `ArrayBuffer` just to write
|
|
233
|
+
* it back to disk. Requires the local storage adapter to implement `moveFile`.
|
|
234
|
+
*
|
|
235
|
+
* Only available when the queue is configured with a {@link StreamingLocalStorageAdapter}
|
|
236
|
+
* (one that implements `moveFile`).
|
|
237
|
+
*
|
|
238
|
+
* @param options - The existing file's `localUri` plus {@link SaveAttachmentOptions}
|
|
239
|
+
* @returns Promise resolving to the created attachment record
|
|
240
|
+
*/
|
|
241
|
+
saveFileFromUri(this: AttachmentQueue<StreamingLocalStorageAdapter>, options: SaveAttachmentOptions & {
|
|
242
|
+
localUri: string;
|
|
188
243
|
}): Promise<AttachmentRecord>;
|
|
189
244
|
deleteFile({ id, updateHook }: {
|
|
190
245
|
id: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LogLevels } from '../utils/Logger.js';
|
|
2
2
|
import { AttachmentService } from './AttachmentService.js';
|
|
3
|
+
import { BufferedAttachmentTransport } from './BufferedAttachmentTransport.js';
|
|
3
4
|
import { ATTACHMENT_TABLE, AttachmentState } from './Schema.js';
|
|
4
5
|
import { SyncingService } from './SyncingService.js';
|
|
5
6
|
/**
|
|
@@ -18,8 +19,6 @@ export class AttachmentQueue {
|
|
|
18
19
|
syncingService;
|
|
19
20
|
/** Adapter for local file storage operations */
|
|
20
21
|
localStorage;
|
|
21
|
-
/** Adapter for remote file storage operations */
|
|
22
|
-
remoteStorage;
|
|
23
22
|
/**
|
|
24
23
|
* Callback function to watch for changes in attachment references in your data model.
|
|
25
24
|
*
|
|
@@ -54,14 +53,27 @@ export class AttachmentQueue {
|
|
|
54
53
|
statusListenerDispose;
|
|
55
54
|
watchActiveAttachments;
|
|
56
55
|
watchAttachmentsAbortController;
|
|
56
|
+
/**
|
|
57
|
+
* Serializes concurrent `syncStorage()` triggers (periodic timer, watch-onDiff,
|
|
58
|
+
* status-changed). Held across the whole batch, but only contended by other
|
|
59
|
+
* sync triggers — foreground `saveFile` / `deleteFile` / watched-attachment
|
|
60
|
+
* processing don't take this lock and proceed in parallel via the
|
|
61
|
+
* `AttachmentService` mutex, which is acquired only briefly per row.
|
|
62
|
+
*/
|
|
63
|
+
syncLoopMutex;
|
|
64
|
+
/**
|
|
65
|
+
* Aborted by `stopSync()` to interrupt an in-flight batch within one
|
|
66
|
+
* attachment's processing time. Polled between rows by `SyncingService`.
|
|
67
|
+
*/
|
|
68
|
+
syncAbortController;
|
|
57
69
|
/**
|
|
58
70
|
* Creates a new AttachmentQueue instance.
|
|
59
71
|
*
|
|
60
72
|
* @param options - Configuration options
|
|
61
73
|
*/
|
|
62
|
-
constructor({ db, localStorage, remoteStorage, watchAttachments, logger, tableName = ATTACHMENT_TABLE, syncIntervalMs = 30 * 1000, syncThrottleDuration, downloadAttachments = true, archivedCacheLimit = 100, errorHandler }) {
|
|
74
|
+
constructor({ db, localStorage, remoteStorage, transportAdapter, watchAttachments, logger, tableName = ATTACHMENT_TABLE, syncIntervalMs = 30 * 1000, syncThrottleDuration, downloadAttachments = true, archivedCacheLimit = 100, errorHandler }) {
|
|
63
75
|
this.db = db;
|
|
64
|
-
this.
|
|
76
|
+
this.syncLoopMutex = db.createMutex();
|
|
65
77
|
this.localStorage = localStorage;
|
|
66
78
|
this.watchAttachments = watchAttachments;
|
|
67
79
|
this.tableName = tableName;
|
|
@@ -71,7 +83,8 @@ export class AttachmentQueue {
|
|
|
71
83
|
this.downloadAttachments = downloadAttachments;
|
|
72
84
|
this.logger = logger ?? db.logger;
|
|
73
85
|
this.attachmentService = new AttachmentService(db, this.logger, tableName, archivedCacheLimit);
|
|
74
|
-
|
|
86
|
+
const transport = transportAdapter ?? new BufferedAttachmentTransport(localStorage, remoteStorage);
|
|
87
|
+
this.syncingService = new SyncingService(this.attachmentService, localStorage, transport, this.logger, errorHandler);
|
|
75
88
|
}
|
|
76
89
|
/**
|
|
77
90
|
* Generates a new attachment ID using a SQLite UUID function.
|
|
@@ -93,6 +106,7 @@ export class AttachmentQueue {
|
|
|
93
106
|
*/
|
|
94
107
|
async startSync() {
|
|
95
108
|
await this.stopSync();
|
|
109
|
+
this.syncAbortController = new AbortController();
|
|
96
110
|
this.watchActiveAttachments = this.attachmentService.watchActiveAttachments({
|
|
97
111
|
throttleMs: this.syncThrottleDuration
|
|
98
112
|
});
|
|
@@ -207,23 +221,45 @@ export class AttachmentQueue {
|
|
|
207
221
|
*
|
|
208
222
|
* This is called automatically at regular intervals when sync is started,
|
|
209
223
|
* but can also be called manually to trigger an immediate sync.
|
|
224
|
+
*
|
|
225
|
+
* Concurrent invocations are serialized via `syncLoopMutex`.
|
|
210
226
|
*/
|
|
211
227
|
async syncStorage() {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
228
|
+
const signal = this.syncAbortController?.signal;
|
|
229
|
+
// We have a signal from startSync() to stopSync(), so treat the absence of one like an aborted sync.
|
|
230
|
+
if (signal == null || signal?.aborted)
|
|
231
|
+
return;
|
|
232
|
+
try {
|
|
233
|
+
await this.syncLoopMutex.runExclusive(async () => {
|
|
234
|
+
const activeAttachments = await this.attachmentService.withContext((ctx) => ctx.getActiveAttachments());
|
|
235
|
+
await this.localStorage.initialize();
|
|
236
|
+
await this.syncingService.processAttachments(activeAttachments, { signal });
|
|
237
|
+
if (signal.aborted)
|
|
238
|
+
return;
|
|
239
|
+
await this.attachmentService.withContext((ctx) => this.syncingService.deleteArchivedAttachments(ctx));
|
|
240
|
+
}, signal);
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
// A queued batch's acquire rejects when `stopSync` aborts — expected, not an error.
|
|
244
|
+
if (signal.aborted)
|
|
245
|
+
return;
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
218
248
|
}
|
|
219
249
|
/**
|
|
220
250
|
* Stops the attachment synchronization process.
|
|
221
251
|
*
|
|
222
|
-
* Clears the periodic sync timer
|
|
252
|
+
* Clears the periodic sync timer, closes all active attachment watchers, and
|
|
253
|
+
* aborts any in-flight `syncStorage()` call so it exits within one
|
|
254
|
+
* attachment's processing time instead of running the batch to completion.
|
|
223
255
|
*/
|
|
224
256
|
async stopSync() {
|
|
225
257
|
clearInterval(this.periodicSyncTimer);
|
|
226
258
|
this.periodicSyncTimer = undefined;
|
|
259
|
+
if (this.syncAbortController) {
|
|
260
|
+
this.syncAbortController.abort();
|
|
261
|
+
this.syncAbortController = undefined;
|
|
262
|
+
}
|
|
227
263
|
if (this.watchActiveAttachments)
|
|
228
264
|
await this.watchActiveAttachments.close();
|
|
229
265
|
if (this.watchAttachmentsAbortController) {
|
|
@@ -249,16 +285,27 @@ export class AttachmentQueue {
|
|
|
249
285
|
return this.attachmentService.withContext(callback);
|
|
250
286
|
}
|
|
251
287
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* @returns Promise resolving to the created attachment record
|
|
288
|
+
* Creates a `QUEUED_UPLOAD` attachment record, placing the file at the managed
|
|
289
|
+
* `localUri` from the given `source`, and persists the record
|
|
290
|
+
* alongside the caller's `updateHook` in a single transaction.
|
|
256
291
|
*/
|
|
257
|
-
async
|
|
292
|
+
async createUploadAttachment({ fileExtension, mediaType, metaData, id, updateHook }, source) {
|
|
258
293
|
const resolvedId = id ?? (await this.generateAttachmentId());
|
|
259
294
|
const filename = `${resolvedId}.${fileExtension}`;
|
|
260
295
|
const localUri = this.localStorage.getLocalUri(filename);
|
|
261
|
-
|
|
296
|
+
let size;
|
|
297
|
+
if (source.kind === 'data') {
|
|
298
|
+
size = await this.localStorage.saveFile(localUri, source.data);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// saveFileFromUri is only exposed for streaming-capable local adapters; guard at
|
|
302
|
+
// runtime too for plain-JS callers.
|
|
303
|
+
const localStorage = this.localStorage;
|
|
304
|
+
if (!localStorage.moveFile) {
|
|
305
|
+
throw new Error('The configured local storage adapter does not support moveFile, required by saveFileFromUri.');
|
|
306
|
+
}
|
|
307
|
+
size = await localStorage.moveFile(source.localUri, localUri);
|
|
308
|
+
}
|
|
262
309
|
const attachment = {
|
|
263
310
|
id: resolvedId,
|
|
264
311
|
filename,
|
|
@@ -278,6 +325,32 @@ export class AttachmentQueue {
|
|
|
278
325
|
});
|
|
279
326
|
return attachment;
|
|
280
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Saves in-memory file data to local storage and queues it for upload.
|
|
330
|
+
*
|
|
331
|
+
* @param options - File data plus {@link SaveAttachmentOptions}
|
|
332
|
+
* @returns Promise resolving to the created attachment record
|
|
333
|
+
*/
|
|
334
|
+
async saveFile(options) {
|
|
335
|
+
return this.createUploadAttachment(options, { kind: 'data', data: options.data });
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Registers a file that already exists on disk and queues it for upload, moving it
|
|
339
|
+
* into managed storage without loading it into memory.
|
|
340
|
+
*
|
|
341
|
+
* Prefer this over {@link AttachmentQueue.saveFile} for large, app-originated files
|
|
342
|
+
* (recordings, videos): it avoids reading the file into an `ArrayBuffer` just to write
|
|
343
|
+
* it back to disk. Requires the local storage adapter to implement `moveFile`.
|
|
344
|
+
*
|
|
345
|
+
* Only available when the queue is configured with a {@link StreamingLocalStorageAdapter}
|
|
346
|
+
* (one that implements `moveFile`).
|
|
347
|
+
*
|
|
348
|
+
* @param options - The existing file's `localUri` plus {@link SaveAttachmentOptions}
|
|
349
|
+
* @returns Promise resolving to the created attachment record
|
|
350
|
+
*/
|
|
351
|
+
async saveFileFromUri(options) {
|
|
352
|
+
return this.createUploadAttachment(options, { kind: 'uri', localUri: options.localUri });
|
|
353
|
+
}
|
|
281
354
|
async deleteFile({ id, updateHook }) {
|
|
282
355
|
await this.attachmentService.withContext(async (ctx) => {
|
|
283
356
|
const attachment = await ctx.getAttachment(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentQueue.js","sourceRoot":"","sources":["../../src/attachments/AttachmentQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAIhE,OAAO,EAAE,iBAAiB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CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBACvE,IAAI,MAAM,EAAE,CAAC;oBACX,mCAAmC;oBACnC,SAAS;gBACX,CAAC;gBAED,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBACvE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;gBAClE,IAAI,SAAS,EAAE,CAAC;oBACd,oEAAoE;oBACpE,OAAO,CAAC,IAAI,CAAC;wBACX,GAAG,UAAU;wBACb,QAAQ,EAAE,WAAW;qBACtB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,kCAAkC;oBAClC,IAAI,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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AttachmentRecord } from './Schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* An {@link AttachmentRecord} that is guaranteed to have a `localUri`.
|
|
4
|
+
*
|
|
5
|
+
* The syncing service assigns `localUri` before invoking a transport download,
|
|
6
|
+
* so implementations always receive both the metadata and the destination path.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export type LocatedAttachmentRecord = AttachmentRecord & {
|
|
11
|
+
localUri: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* AttachmentTransportAdapter owns all remote-side operations for an attachment —
|
|
15
|
+
* transfer (upload/download) and delete — as single operations.
|
|
16
|
+
*
|
|
17
|
+
* A transport owns the entire transfer, letting implementations pick the most
|
|
18
|
+
* efficient mechanism available (buffer, stream, or a platform-native file-URI
|
|
19
|
+
* upload/download API). On platforms like React Native this allows large files to
|
|
20
|
+
* be transferred without ever materializing them in the JS heap.
|
|
21
|
+
*
|
|
22
|
+
* The default transport composes the local and remote storage adapters. Provide a custom transport (via
|
|
23
|
+
* `AttachmentQueue`'s `transportAdapter` option) to own the whole remote side; in
|
|
24
|
+
* that case a separate `remoteStorage` is not required.
|
|
25
|
+
*
|
|
26
|
+
* @experimental
|
|
27
|
+
* @alpha This is currently experimental and may change without a major version bump.
|
|
28
|
+
*/
|
|
29
|
+
export interface AttachmentTransportAdapter {
|
|
30
|
+
/**
|
|
31
|
+
* Uploads the attachment's local file to remote storage.
|
|
32
|
+
* @param attachment - The attachment to upload. `localUri` points at the source file.
|
|
33
|
+
*/
|
|
34
|
+
upload(attachment: LocatedAttachmentRecord): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Downloads the remote file into `attachment.localUri`.
|
|
37
|
+
* @param attachment - The attachment to download. `localUri` is the destination path,
|
|
38
|
+
* assigned by the syncing service before this call.
|
|
39
|
+
*/
|
|
40
|
+
download(attachment: LocatedAttachmentRecord): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Deletes the attachment's file from remote storage. Local file removal is handled
|
|
43
|
+
* separately by the syncing service.
|
|
44
|
+
* @param attachment - The attachment to delete.
|
|
45
|
+
*/
|
|
46
|
+
delete(attachment: AttachmentRecord): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentTransportAdapter.js","sourceRoot":"","sources":["../../src/attachments/AttachmentTransportAdapter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AttachmentTransportAdapter, LocatedAttachmentRecord } from './AttachmentTransportAdapter.js';
|
|
2
|
+
import { LocalStorageAdapter } from './LocalStorageAdapter.js';
|
|
3
|
+
import { RemoteStorageAdapter } from './RemoteStorageAdapter.js';
|
|
4
|
+
import { AttachmentRecord } from './Schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default {@link AttachmentTransportAdapter}, composing the local and remote
|
|
7
|
+
* storage adapters.
|
|
8
|
+
*
|
|
9
|
+
* The full file body is materialized as an `ArrayBuffer` in JS memory between the
|
|
10
|
+
* two adapter calls. This is fine for small files but can cause memory pressure on
|
|
11
|
+
* large ones — environments that support native transfer should provide a custom
|
|
12
|
+
* transport instead.
|
|
13
|
+
*
|
|
14
|
+
* @experimental
|
|
15
|
+
* @alpha This is currently experimental and may change without a major version bump.
|
|
16
|
+
*/
|
|
17
|
+
export declare class BufferedAttachmentTransport implements AttachmentTransportAdapter {
|
|
18
|
+
private localStorage;
|
|
19
|
+
private remoteStorage;
|
|
20
|
+
constructor(localStorage: LocalStorageAdapter, remoteStorage: RemoteStorageAdapter);
|
|
21
|
+
upload(attachment: LocatedAttachmentRecord): Promise<void>;
|
|
22
|
+
download(attachment: LocatedAttachmentRecord): Promise<void>;
|
|
23
|
+
delete(attachment: AttachmentRecord): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default {@link AttachmentTransportAdapter}, composing the local and remote
|
|
3
|
+
* storage adapters.
|
|
4
|
+
*
|
|
5
|
+
* The full file body is materialized as an `ArrayBuffer` in JS memory between the
|
|
6
|
+
* two adapter calls. This is fine for small files but can cause memory pressure on
|
|
7
|
+
* large ones — environments that support native transfer should provide a custom
|
|
8
|
+
* transport instead.
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
* @alpha This is currently experimental and may change without a major version bump.
|
|
12
|
+
*/
|
|
13
|
+
export class BufferedAttachmentTransport {
|
|
14
|
+
localStorage;
|
|
15
|
+
remoteStorage;
|
|
16
|
+
constructor(localStorage, remoteStorage) {
|
|
17
|
+
this.localStorage = localStorage;
|
|
18
|
+
this.remoteStorage = remoteStorage;
|
|
19
|
+
}
|
|
20
|
+
async upload(attachment) {
|
|
21
|
+
const fileData = await this.localStorage.readFile(attachment.localUri);
|
|
22
|
+
await this.remoteStorage.uploadFile(fileData, attachment);
|
|
23
|
+
}
|
|
24
|
+
async download(attachment) {
|
|
25
|
+
const fileData = await this.remoteStorage.downloadFile(attachment);
|
|
26
|
+
await this.localStorage.saveFile(attachment.localUri, fileData);
|
|
27
|
+
}
|
|
28
|
+
async delete(attachment) {
|
|
29
|
+
await this.remoteStorage.deleteFile(attachment);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=BufferedAttachmentTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferedAttachmentTransport.js","sourceRoot":"","sources":["../../src/attachments/BufferedAttachmentTransport.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,2BAA2B;IAE5B;IACA;IAFV,YACU,YAAiC,EACjC,aAAmC;QADnC,iBAAY,GAAZ,YAAY,CAAqB;QACjC,kBAAa,GAAb,aAAa,CAAsB;IAC1C,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,UAAmC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACvE,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAmC;QAChD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACnE,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAA4B;QACvC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -66,3 +66,22 @@ export interface LocalStorageAdapter {
|
|
|
66
66
|
*/
|
|
67
67
|
getLocalUri(filename: string): string;
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A {@link LocalStorageAdapter} that can relocate a file into managed storage without
|
|
71
|
+
* loading it into memory. Required for {@link AttachmentQueue.saveFileFromUri}; only
|
|
72
|
+
* queues configured with a streaming-capable local adapter expose that method.
|
|
73
|
+
*
|
|
74
|
+
* @experimental
|
|
75
|
+
* @alpha This is currently experimental and may change without a major version bump.
|
|
76
|
+
*/
|
|
77
|
+
export interface StreamingLocalStorageAdapter extends LocalStorageAdapter {
|
|
78
|
+
/**
|
|
79
|
+
* Moves a file into managed storage without loading it into memory.
|
|
80
|
+
* Overwrites any existing file at the target. When source and target are the same
|
|
81
|
+
* path, this is a no-op that just reports the size.
|
|
82
|
+
* @param sourceUri - Path of the existing file
|
|
83
|
+
* @param targetUri - Destination path within managed storage
|
|
84
|
+
* @returns Number of bytes in the moved file
|
|
85
|
+
*/
|
|
86
|
+
moveFile(sourceUri: string, targetUri: string): Promise<number>;
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Table } from '../db/schema/Table.js';
|
|
1
|
+
import { RowType, Table } from '../db/schema/Table.js';
|
|
2
2
|
import { TableOptions } from '../db/schema/Table.js';
|
|
3
3
|
/**
|
|
4
4
|
* The default name of the local table storing attachment data.
|
|
@@ -48,11 +48,30 @@ export declare enum AttachmentState {
|
|
|
48
48
|
*/
|
|
49
49
|
export interface AttachmentTableOptions extends Omit<TableOptions, 'name' | 'columns'> {
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @alpha
|
|
53
|
+
*/
|
|
54
|
+
export declare const ATTACHMENT_TABLE_COLUMNS: {
|
|
55
|
+
filename: import("../db/schema/Column.js").BaseColumnType<string | null>;
|
|
56
|
+
local_uri: import("../db/schema/Column.js").BaseColumnType<string | null>;
|
|
57
|
+
timestamp: import("../db/schema/Column.js").BaseColumnType<number | null>;
|
|
58
|
+
size: import("../db/schema/Column.js").BaseColumnType<number | null>;
|
|
59
|
+
media_type: import("../db/schema/Column.js").BaseColumnType<string | null>;
|
|
60
|
+
state: import("../db/schema/Column.js").BaseColumnType<number | null>;
|
|
61
|
+
has_synced: import("../db/schema/Column.js").BaseColumnType<number | null>;
|
|
62
|
+
meta_data: import("../db/schema/Column.js").BaseColumnType<string | null>;
|
|
63
|
+
};
|
|
51
64
|
/**
|
|
52
65
|
* AttachmentTable defines the schema for the attachment queue table.
|
|
53
66
|
*
|
|
54
67
|
* @alpha
|
|
55
68
|
*/
|
|
56
|
-
export declare class AttachmentTable extends Table {
|
|
69
|
+
export declare class AttachmentTable extends Table<typeof ATTACHMENT_TABLE_COLUMNS> {
|
|
57
70
|
constructor(options?: AttachmentTableOptions);
|
|
58
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* AttachmentTableRecord represents the row type of the attachment table.
|
|
74
|
+
*
|
|
75
|
+
* @alpha
|
|
76
|
+
*/
|
|
77
|
+
export type AttachmentTableRecord = RowType<AttachmentTable>;
|