@powerhousedao/reactor-attachments 6.0.0-dev.208
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/LICENSE +661 -0
- package/dist/index.d.ts +442 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +580 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { AttachmentHash, AttachmentRef, JwtHandler } from "@powerhousedao/reactor";
|
|
3
|
+
|
|
4
|
+
//#region src/errors.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when an attachment ref or hash is not known to the store.
|
|
7
|
+
*/
|
|
8
|
+
declare class AttachmentNotFound extends Error {
|
|
9
|
+
constructor(identifier: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when a reservation ID is not found in the reservation store.
|
|
13
|
+
*/
|
|
14
|
+
declare class ReservationNotFound extends Error {
|
|
15
|
+
constructor(reservationId: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when an attachment ref string does not match the expected format.
|
|
19
|
+
*/
|
|
20
|
+
declare class InvalidAttachmentRef extends Error {
|
|
21
|
+
constructor(ref: string);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/types.d.ts
|
|
25
|
+
/**
|
|
26
|
+
* Status of attachment data in the local store.
|
|
27
|
+
*/
|
|
28
|
+
type AttachmentStatus = "available" | "evicted";
|
|
29
|
+
/**
|
|
30
|
+
* Metadata about an attachment. Only exists after data is stored
|
|
31
|
+
* (via upload.send for client uploads, or put for sync).
|
|
32
|
+
*/
|
|
33
|
+
type AttachmentHeader = {
|
|
34
|
+
hash: AttachmentHash;
|
|
35
|
+
mimeType: string;
|
|
36
|
+
fileName: string;
|
|
37
|
+
sizeBytes: number;
|
|
38
|
+
extension: string | null;
|
|
39
|
+
status: AttachmentStatus;
|
|
40
|
+
source: "local" | "sync";
|
|
41
|
+
createdAtUtc: string;
|
|
42
|
+
lastAccessedAtUtc: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Metadata provided alongside attachment data during sync.
|
|
46
|
+
* The remaining fields (hash, status, source, createdAtUtc, lastAccessedAtUtc)
|
|
47
|
+
* are set by the store when it creates the attachment record.
|
|
48
|
+
*/
|
|
49
|
+
type AttachmentMetadata = {
|
|
50
|
+
mimeType: string;
|
|
51
|
+
fileName: string;
|
|
52
|
+
sizeBytes: number;
|
|
53
|
+
extension: string | null;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Options provided when reserving an attachment slot.
|
|
57
|
+
*/
|
|
58
|
+
type ReserveAttachmentOptions = {
|
|
59
|
+
mimeType: string;
|
|
60
|
+
fileName: string;
|
|
61
|
+
extension?: string | null;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Result of uploading attachment data through a handle.
|
|
65
|
+
*/
|
|
66
|
+
type AttachmentUploadResult = {
|
|
67
|
+
hash: AttachmentHash;
|
|
68
|
+
ref: AttachmentRef;
|
|
69
|
+
header: AttachmentHeader;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Response when retrieving attachment data from the local store.
|
|
73
|
+
*/
|
|
74
|
+
type AttachmentResponse = {
|
|
75
|
+
header: AttachmentHeader;
|
|
76
|
+
body: ReadableStream<Uint8Array>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Response when fetching attachment data from a remote transport.
|
|
80
|
+
* Lighter than AttachmentResponse -- a remote peer cannot meaningfully
|
|
81
|
+
* populate status or source, which are local reactor concerns.
|
|
82
|
+
* The store assigns those fields when it calls put() on receipt.
|
|
83
|
+
*/
|
|
84
|
+
type TransportResponse = {
|
|
85
|
+
hash: AttachmentHash;
|
|
86
|
+
metadata: AttachmentMetadata;
|
|
87
|
+
body: ReadableStream<Uint8Array>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Configuration for creating an attachment transport instance.
|
|
91
|
+
*/
|
|
92
|
+
type AttachmentTransportConfig = {
|
|
93
|
+
type: string;
|
|
94
|
+
parameters: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A reservation for an in-progress attachment upload.
|
|
98
|
+
* Created by reserve(), deleted when upload.send() completes.
|
|
99
|
+
*/
|
|
100
|
+
type Reservation = {
|
|
101
|
+
reservationId: string;
|
|
102
|
+
mimeType: string;
|
|
103
|
+
fileName: string;
|
|
104
|
+
extension: string | null;
|
|
105
|
+
createdAtUtc: string;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/interfaces.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* Client-facing interface for uploading, querying, and retrieving attachments.
|
|
111
|
+
* This is what applications (editors, Connect, CLI tools) interact with.
|
|
112
|
+
*/
|
|
113
|
+
interface IAttachmentService {
|
|
114
|
+
/**
|
|
115
|
+
* Reserve a new attachment slot and return an upload handle.
|
|
116
|
+
*
|
|
117
|
+
* The handle abstracts the transport -- the caller streams data
|
|
118
|
+
* through it without knowing whether bytes flow via HTTP, S3,
|
|
119
|
+
* or any other mechanism.
|
|
120
|
+
*/
|
|
121
|
+
reserve(options: ReserveAttachmentOptions): Promise<IAttachmentUpload>;
|
|
122
|
+
/**
|
|
123
|
+
* Get attachment metadata by ref.
|
|
124
|
+
*
|
|
125
|
+
* @throws AttachmentNotFound if the ref is unknown.
|
|
126
|
+
*/
|
|
127
|
+
stat(ref: AttachmentRef): Promise<AttachmentHeader>;
|
|
128
|
+
/**
|
|
129
|
+
* Retrieve attachment data.
|
|
130
|
+
*
|
|
131
|
+
* Always succeeds for any known ref. The underlying store handles
|
|
132
|
+
* re-fetching evicted data from the transport transparently.
|
|
133
|
+
*/
|
|
134
|
+
get(ref: AttachmentRef, signal?: AbortSignal): Promise<AttachmentResponse>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Upload handle returned by reserve(). Encapsulates all transport-specific
|
|
138
|
+
* concerns (URLs, credentials, streaming protocols) behind a single send() method.
|
|
139
|
+
*/
|
|
140
|
+
interface IAttachmentUpload {
|
|
141
|
+
/**
|
|
142
|
+
* Unique identifier for this reservation.
|
|
143
|
+
*/
|
|
144
|
+
reservationId: string;
|
|
145
|
+
/**
|
|
146
|
+
* Stream attachment data through this handle.
|
|
147
|
+
*
|
|
148
|
+
* The handle manages the full upload lifecycle internally:
|
|
149
|
+
* writing bytes to the backing store, computing or verifying
|
|
150
|
+
* the content hash, creating the attachment record, and
|
|
151
|
+
* cleaning up the reservation.
|
|
152
|
+
*
|
|
153
|
+
* Dedup: if an attachment with the same content hash already
|
|
154
|
+
* exists, send() returns the existing ref. Content-addressed
|
|
155
|
+
* storage means identical uploads converge on the same hash.
|
|
156
|
+
*
|
|
157
|
+
* @returns The content hash, ref, and header for the uploaded attachment.
|
|
158
|
+
*/
|
|
159
|
+
send(data: ReadableStream<Uint8Array>): Promise<AttachmentUploadResult>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Reactor-facing interface for managing local attachment data.
|
|
163
|
+
* The IAttachmentTransport calls put when it receives data from a remote.
|
|
164
|
+
* The store notifies its configured transport when new data arrives,
|
|
165
|
+
* forming a bidirectional store-transport pair.
|
|
166
|
+
*/
|
|
167
|
+
interface IAttachmentStore {
|
|
168
|
+
/**
|
|
169
|
+
* Get attachment metadata without streaming body data.
|
|
170
|
+
* Does NOT update lastAccessedAtUtc -- this is a metadata check,
|
|
171
|
+
* not a data access.
|
|
172
|
+
*
|
|
173
|
+
* @throws AttachmentNotFound if the hash is unknown.
|
|
174
|
+
*/
|
|
175
|
+
stat(hash: AttachmentHash): Promise<AttachmentHeader>;
|
|
176
|
+
/**
|
|
177
|
+
* Check whether attachment data is available locally.
|
|
178
|
+
* Returns true if the bytes can be served from this reactor's store
|
|
179
|
+
* without a transport round-trip. Does not trigger a remote fetch.
|
|
180
|
+
*/
|
|
181
|
+
has(hash: AttachmentHash): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Retrieve attachment header and data stream by hash.
|
|
184
|
+
* Updates lastAccessedAtUtc on access.
|
|
185
|
+
*
|
|
186
|
+
* If the data has been evicted, re-fetches it from the transport,
|
|
187
|
+
* restores it locally via put(), and returns the data. This makes
|
|
188
|
+
* eviction transparent to callers -- get() always succeeds for
|
|
189
|
+
* any known hash.
|
|
190
|
+
*
|
|
191
|
+
* @throws AttachmentNotFound if the hash is unknown (no metadata
|
|
192
|
+
* record exists).
|
|
193
|
+
*/
|
|
194
|
+
get(hash: AttachmentHash, signal?: AbortSignal): Promise<AttachmentResponse>;
|
|
195
|
+
/**
|
|
196
|
+
* Store attachment data received from a remote (during sync or re-fetch).
|
|
197
|
+
* Called by IAttachmentTransport implementations during sync, and
|
|
198
|
+
* internally by get() when restoring evicted data.
|
|
199
|
+
*
|
|
200
|
+
* Behavior depends on existing state:
|
|
201
|
+
* - No existing row: INSERT with source='sync', status='available'.
|
|
202
|
+
* - Existing row with status='evicted': restore data, set status
|
|
203
|
+
* to 'available'.
|
|
204
|
+
* - Existing row with status='available': no-op (dedup).
|
|
205
|
+
*/
|
|
206
|
+
put(hash: AttachmentHash, metadata: AttachmentMetadata, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Evict attachment data to reclaim storage.
|
|
209
|
+
*
|
|
210
|
+
* Removes the local bytes and sets status to 'evicted'. The
|
|
211
|
+
* metadata record is retained so the hash is still known. If the
|
|
212
|
+
* data is needed again, the service fetches it via the transport.
|
|
213
|
+
*
|
|
214
|
+
* Eviction must not destroy data while a get() stream is in
|
|
215
|
+
* flight. Implementations must skip hashes with active readers
|
|
216
|
+
* (e.g. via a refcount or lease) and revisit them on the next
|
|
217
|
+
* GC pass.
|
|
218
|
+
*
|
|
219
|
+
* On immutable backends, this unpins/stops serving rather
|
|
220
|
+
* than deleting.
|
|
221
|
+
*/
|
|
222
|
+
evict(hash: AttachmentHash): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Get the total storage used by locally available attachment data.
|
|
225
|
+
* Used by the GC policy to decide when to evict.
|
|
226
|
+
*/
|
|
227
|
+
storageUsed(): Promise<number>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Transport for moving attachment data between reactors.
|
|
231
|
+
*
|
|
232
|
+
* Forms a bidirectional pair with IAttachmentStore. The store calls
|
|
233
|
+
* announce/push when new data arrives locally. The transport calls
|
|
234
|
+
* store.put() when data arrives from a remote.
|
|
235
|
+
*/
|
|
236
|
+
interface IAttachmentTransport {
|
|
237
|
+
/**
|
|
238
|
+
* Fetch attachment data by hash from a remote source.
|
|
239
|
+
*
|
|
240
|
+
* The transport resolves the hash to a data source (server endpoint,
|
|
241
|
+
* S3 presigned URL, etc.) and returns a stream.
|
|
242
|
+
*
|
|
243
|
+
* @param hash - Content hash of the attachment
|
|
244
|
+
* @param signal - Abort signal for cancellation
|
|
245
|
+
* @returns The attachment data with metadata, or null if not available.
|
|
246
|
+
* Returns TransportResponse (not AttachmentResponse) because
|
|
247
|
+
* remote peers cannot populate local concerns like status/source.
|
|
248
|
+
*/
|
|
249
|
+
fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportResponse | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Announce that this reactor has attachment data available.
|
|
252
|
+
*
|
|
253
|
+
* For server-centric transports, this may be a no-op (the server
|
|
254
|
+
* already has the data after upload).
|
|
255
|
+
*/
|
|
256
|
+
announce(hash: AttachmentHash): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Push attachment data to a specific remote.
|
|
259
|
+
*
|
|
260
|
+
* Used for eager replication strategies where the source reactor
|
|
261
|
+
* pushes data to known peers rather than waiting for pull requests.
|
|
262
|
+
*
|
|
263
|
+
* @param hash - Content hash of the attachment
|
|
264
|
+
* @param remote - Target remote identifier
|
|
265
|
+
* @param data - The attachment data stream
|
|
266
|
+
*/
|
|
267
|
+
push(hash: AttachmentHash, remote: string, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Factory for creating attachment transport instances.
|
|
271
|
+
* Mirrors IChannelFactory for operation sync.
|
|
272
|
+
*/
|
|
273
|
+
interface IAttachmentTransportFactory {
|
|
274
|
+
instance(config: AttachmentTransportConfig): IAttachmentTransport;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Store for managing attachment reservations.
|
|
278
|
+
* Reservations are transient records tracking in-progress uploads.
|
|
279
|
+
*/
|
|
280
|
+
interface IReservationStore {
|
|
281
|
+
create(options: ReserveAttachmentOptions): Promise<Reservation>;
|
|
282
|
+
get(reservationId: string): Promise<Reservation>;
|
|
283
|
+
delete(reservationId: string): Promise<void>;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Factory for creating transport-specific upload handles.
|
|
287
|
+
* The service calls this during reserve() to create a handle
|
|
288
|
+
* that knows how to stream bytes to the appropriate backend.
|
|
289
|
+
*/
|
|
290
|
+
interface IAttachmentUploadFactory {
|
|
291
|
+
createUpload(reservationId: string, options: ReserveAttachmentOptions): IAttachmentUpload;
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/attachment-service.d.ts
|
|
295
|
+
declare class AttachmentService implements IAttachmentService {
|
|
296
|
+
private readonly store;
|
|
297
|
+
private readonly reservations;
|
|
298
|
+
private readonly uploadFactory;
|
|
299
|
+
constructor(store: IAttachmentStore, reservations: IReservationStore, uploadFactory: IAttachmentUploadFactory);
|
|
300
|
+
reserve(options: ReserveAttachmentOptions): Promise<IAttachmentUpload>;
|
|
301
|
+
stat(ref: AttachmentRef): Promise<AttachmentHeader>;
|
|
302
|
+
get(ref: AttachmentRef, signal?: AbortSignal): Promise<AttachmentResponse>;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/ref.d.ts
|
|
306
|
+
type ParsedRef = {
|
|
307
|
+
version: number;
|
|
308
|
+
hash: AttachmentHash;
|
|
309
|
+
};
|
|
310
|
+
declare function parseRef(ref: AttachmentRef): ParsedRef;
|
|
311
|
+
declare function createRef(hash: AttachmentHash, version?: number): AttachmentRef;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/storage/kysely/types.d.ts
|
|
314
|
+
interface AttachmentTable {
|
|
315
|
+
hash: string;
|
|
316
|
+
mime_type: string;
|
|
317
|
+
file_name: string;
|
|
318
|
+
size_bytes: number;
|
|
319
|
+
extension: string | null;
|
|
320
|
+
status: string;
|
|
321
|
+
storage_path: string;
|
|
322
|
+
source: string;
|
|
323
|
+
created_at_utc: string;
|
|
324
|
+
last_accessed_at_utc: string;
|
|
325
|
+
}
|
|
326
|
+
interface AttachmentReservationTable {
|
|
327
|
+
reservation_id: string;
|
|
328
|
+
mime_type: string;
|
|
329
|
+
file_name: string;
|
|
330
|
+
extension: string | null;
|
|
331
|
+
created_at_utc: string;
|
|
332
|
+
}
|
|
333
|
+
interface AttachmentDatabase {
|
|
334
|
+
attachment: AttachmentTable;
|
|
335
|
+
attachment_reservation: AttachmentReservationTable;
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/storage/kysely/attachment-store.d.ts
|
|
339
|
+
declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
340
|
+
private readonly db;
|
|
341
|
+
private readonly transport;
|
|
342
|
+
private readonly basePath;
|
|
343
|
+
private readonly activeReaders;
|
|
344
|
+
constructor(db: Kysely<AttachmentDatabase>, transport: IAttachmentTransport, basePath: string);
|
|
345
|
+
stat(hash: AttachmentHash): Promise<AttachmentHeader>;
|
|
346
|
+
has(hash: AttachmentHash): Promise<boolean>;
|
|
347
|
+
get(hash: AttachmentHash, signal?: AbortSignal): Promise<AttachmentResponse>;
|
|
348
|
+
put(hash: AttachmentHash, metadata: AttachmentMetadata, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
349
|
+
evict(hash: AttachmentHash): Promise<void>;
|
|
350
|
+
storageUsed(): Promise<number>;
|
|
351
|
+
private acquireReader;
|
|
352
|
+
private releaseReader;
|
|
353
|
+
private hasActiveReaders;
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/storage/kysely/reservation-store.d.ts
|
|
357
|
+
declare class KyselyReservationStore implements IReservationStore {
|
|
358
|
+
private readonly db;
|
|
359
|
+
constructor(db: Kysely<AttachmentDatabase>);
|
|
360
|
+
create(options: ReserveAttachmentOptions): Promise<Reservation>;
|
|
361
|
+
get(reservationId: string): Promise<Reservation>;
|
|
362
|
+
delete(reservationId: string): Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/storage/migrations/migrator.d.ts
|
|
366
|
+
declare const ATTACHMENT_SCHEMA = "attachments";
|
|
367
|
+
interface MigrationResult {
|
|
368
|
+
success: boolean;
|
|
369
|
+
migrationsExecuted: string[];
|
|
370
|
+
error?: Error;
|
|
371
|
+
}
|
|
372
|
+
declare function runAttachmentMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/direct/direct-attachment-upload.d.ts
|
|
375
|
+
declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
376
|
+
private readonly options;
|
|
377
|
+
private readonly db;
|
|
378
|
+
private readonly basePath;
|
|
379
|
+
private readonly reservations;
|
|
380
|
+
readonly reservationId: string;
|
|
381
|
+
constructor(reservationId: string, options: ReserveAttachmentOptions, db: Kysely<AttachmentDatabase>, basePath: string, reservations: IReservationStore);
|
|
382
|
+
send(data: ReadableStream<Uint8Array>): Promise<AttachmentUploadResult>;
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/direct/direct-attachment-upload-factory.d.ts
|
|
386
|
+
declare class DirectAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
387
|
+
private readonly db;
|
|
388
|
+
private readonly basePath;
|
|
389
|
+
private readonly reservations;
|
|
390
|
+
constructor(db: Kysely<AttachmentDatabase>, basePath: string, reservations: IReservationStore);
|
|
391
|
+
createUpload(reservationId: string, options: ReserveAttachmentOptions): IAttachmentUpload;
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/switchboard/switchboard-attachment-transport.d.ts
|
|
395
|
+
type SwitchboardTransportConfig = {
|
|
396
|
+
remoteUrl: string;
|
|
397
|
+
jwtHandler?: JwtHandler;
|
|
398
|
+
fetchFn?: typeof fetch;
|
|
399
|
+
};
|
|
400
|
+
declare class SwitchboardAttachmentTransport implements IAttachmentTransport {
|
|
401
|
+
private readonly remoteUrl;
|
|
402
|
+
private readonly jwtHandler?;
|
|
403
|
+
private readonly fetchFn;
|
|
404
|
+
constructor(config: SwitchboardTransportConfig);
|
|
405
|
+
fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportResponse | null>;
|
|
406
|
+
announce(_hash: AttachmentHash): Promise<void>;
|
|
407
|
+
push(hash: AttachmentHash, remote: string, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
408
|
+
private buildHeaders;
|
|
409
|
+
private parseMetadataHeaders;
|
|
410
|
+
}
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/null-attachment-transport.d.ts
|
|
413
|
+
/**
|
|
414
|
+
* No-op transport for deployments without remote sync.
|
|
415
|
+
* fetch() always returns null, announce() and push() are no-ops.
|
|
416
|
+
*/
|
|
417
|
+
declare class NullAttachmentTransport implements IAttachmentTransport {
|
|
418
|
+
fetch(): Promise<TransportResponse | null>;
|
|
419
|
+
announce(): Promise<void>;
|
|
420
|
+
push(): Promise<void>;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/attachment-builder.d.ts
|
|
424
|
+
type AttachmentBuildResult = {
|
|
425
|
+
service: AttachmentService;
|
|
426
|
+
store: KyselyAttachmentStore;
|
|
427
|
+
reservations: KyselyReservationStore;
|
|
428
|
+
uploadFactory: IAttachmentUploadFactory;
|
|
429
|
+
};
|
|
430
|
+
declare class AttachmentBuilder {
|
|
431
|
+
private readonly db;
|
|
432
|
+
private readonly storagePath;
|
|
433
|
+
private transport;
|
|
434
|
+
private customUploadFactory?;
|
|
435
|
+
constructor(db: Kysely<any>, storagePath: string);
|
|
436
|
+
withTransport(transport: IAttachmentTransport): this;
|
|
437
|
+
withUploadFactory(factory: IAttachmentUploadFactory): this;
|
|
438
|
+
build(): Promise<AttachmentBuildResult>;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
export { ATTACHMENT_SCHEMA, type AttachmentBuildResult, AttachmentBuilder, type AttachmentDatabase, type AttachmentHeader, type AttachmentMetadata, AttachmentNotFound, type AttachmentResponse, AttachmentService, type AttachmentStatus, type AttachmentTransportConfig, type AttachmentUploadResult, DirectAttachmentUpload, DirectAttachmentUploadFactory, type IAttachmentService, type IAttachmentStore, type IAttachmentTransport, type IAttachmentTransportFactory, type IAttachmentUpload, type IAttachmentUploadFactory, type IReservationStore, InvalidAttachmentRef, KyselyAttachmentStore, KyselyReservationStore, NullAttachmentTransport, type ParsedRef, type Reservation, ReservationNotFound, type ReserveAttachmentOptions, SwitchboardAttachmentTransport, type SwitchboardTransportConfig, type TransportResponse, createRef, parseRef, runAttachmentMigrations };
|
|
442
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/interfaces.ts","../src/attachment-service.ts","../src/ref.ts","../src/storage/kysely/types.ts","../src/storage/kysely/attachment-store.ts","../src/storage/kysely/reservation-store.ts","../src/storage/migrations/migrator.ts","../src/direct/direct-attachment-upload.ts","../src/direct/direct-attachment-upload-factory.ts","../src/switchboard/switchboard-attachment-transport.ts","../src/null-attachment-transport.ts","../src/attachment-builder.ts"],"mappings":";;;;;;;cAGa,kBAAA,SAA2B,KAAA;cAC1B,UAAA;AAAA;;;;cASD,mBAAA,SAA4B,KAAA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