Skip to content

Commit 3afcbb6

Browse files
khawarizmusclaude
andcommitted
fix(common): resolve api-extractor report and doc warnings
Tag LocatedAttachmentRecord as @Alpha, use a qualified @link to AttachmentQueue.saveFile, and update etc/common.api.md for the new attachment transport API. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bf2d8cc commit 3afcbb6

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

packages/common/etc/common.api.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ export class AttachmentQueue {
105105
id?: string;
106106
updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => Promise<void>;
107107
}): Promise<AttachmentRecord>;
108+
saveFileFromUri(input: {
109+
localUri: string;
110+
fileExtension: string;
111+
mediaType?: string;
112+
metaData?: string;
113+
id?: string;
114+
updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => Promise<void>;
115+
}): Promise<AttachmentRecord>;
108116
startSync(): Promise<void>;
109117
stopSync(): Promise<void>;
110118
readonly syncIntervalMs: number;
@@ -127,6 +135,7 @@ export interface AttachmentQueueOptions {
127135
syncIntervalMs?: number;
128136
syncThrottleDuration?: number;
129137
tableName?: string;
138+
transportAdapter?: AttachmentTransportAdapter;
130139
watchAttachments: (onUpdate: (attachment: WatchedAttachmentItem[]) => Promise<void>, signal: AbortSignal) => void;
131140
}
132141

@@ -178,6 +187,12 @@ export interface AttachmentTableOptions extends Omit<TableOptions, 'name' | 'col
178187
// @alpha
179188
export type AttachmentTableRecord = RowType<AttachmentTable>;
180189

190+
// @alpha
191+
export interface AttachmentTransportAdapter {
192+
download(attachment: LocatedAttachmentRecord): Promise<void>;
193+
upload(attachment: LocatedAttachmentRecord): Promise<void>;
194+
}
195+
181196
// @public (undocumented)
182197
export type BaseColumnType<T extends number | string | null> = {
183198
type: ColumnType;
@@ -242,6 +257,15 @@ export interface BatchedUpdateNotification {
242257
tables: string[];
243258
}
244259

260+
// @alpha
261+
export class BufferedAttachmentTransport implements AttachmentTransportAdapter {
262+
constructor(localStorage: LocalStorageAdapter, remoteStorage: RemoteStorageAdapter);
263+
// (undocumented)
264+
download(attachment: LocatedAttachmentRecord): Promise<void>;
265+
// (undocumented)
266+
upload(attachment: LocatedAttachmentRecord): Promise<void>;
267+
}
268+
245269
// @public (undocumented)
246270
export class Column {
247271
constructor(options: ColumnOptions);
@@ -651,11 +675,17 @@ export interface LocalStorageAdapter {
651675
getLocalUri(filename: string): string;
652676
initialize(): Promise<void>;
653677
makeDir(path: string): Promise<void>;
678+
moveFile?(sourceUri: string, targetUri: string): Promise<number>;
654679
readFile(filePath: string): Promise<ArrayBuffer>;
655680
rmDir(path: string): Promise<void>;
656681
saveFile(filePath: string, data: AttachmentData): Promise<number>;
657682
}
658683

684+
// @alpha
685+
export type LocatedAttachmentRecord = AttachmentRecord & {
686+
localUri: string;
687+
};
688+
659689
// @public (undocumented)
660690
export abstract class LockContext implements SqlExecutor, DBGetUtils {
661691
// (undocumented)

packages/common/src/attachments/AttachmentQueue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,9 @@ export class AttachmentQueue {
489489
* Registers a file that already exists on disk and queues it for upload, moving it
490490
* into managed storage without loading it into memory.
491491
*
492-
* Prefer this over {@link saveFile} for large, app-originated files (recordings,
493-
* videos): it avoids reading the file into an `ArrayBuffer` just to write it back to
494-
* disk. Requires the local storage adapter to implement `moveFile`.
492+
* Prefer this over {@link AttachmentQueue.saveFile} for large, app-originated files
493+
* (recordings, videos): it avoids reading the file into an `ArrayBuffer` just to write
494+
* it back to disk. Requires the local storage adapter to implement `moveFile`.
495495
*
496496
* @param options - File registration options
497497
* @returns Promise resolving to the created attachment record

packages/common/src/attachments/AttachmentTransportAdapter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { AttachmentRecord } from './Schema.js';
55
*
66
* The syncing service assigns `localUri` before invoking a transport download,
77
* so implementations always receive both the metadata and the destination path.
8+
*
9+
* @alpha
810
*/
911
export type LocatedAttachmentRecord = AttachmentRecord & { localUri: string };
1012

0 commit comments

Comments
 (0)