@cosmicdrift/kumiko-types 0.159.1 → 0.161.0

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.
@@ -0,0 +1,39 @@
1
+ // Options for `getSignedUrl`. `contentDisposition` lets the caller hint the
2
+ // browser to download-with-name vs inline-display (maps to ResponseContent-
3
+ // Disposition on S3). Keep the option-bag small and additive; provider impls
4
+ // that don't support a given hint should ignore it rather than error.
5
+ export type SignedUrlOptions = {
6
+ readonly contentDisposition?: string;
7
+ };
8
+
9
+ // Options for `writeStream`. `mimeType` is a Content-Type hint analogous to
10
+ // `write`. `contentLength` is optional for providers that need a Length
11
+ // header (S3 multipart has a TransferManager and can work without it);
12
+ // local providers ignore both.
13
+ export type WriteStreamOptions = {
14
+ readonly mimeType?: string;
15
+ readonly contentLength?: number;
16
+ };
17
+
18
+ // Primitive storage contract: key+bytes in, bytes out. Metadata (fileName,
19
+ // mimeType, size) lives on the FileRef row — the provider only needs to
20
+ // shuttle bytes. `mimeType` on write() is a hint for providers that need a
21
+ // Content-Type header (S3/R2/…); local filesystems can ignore it.
22
+ //
23
+ // getSignedUrl is optional — providers without native presigned-URL support
24
+ // (filesystem) leave it undefined; the route then returns 501 and the
25
+ // client falls back to streaming via GET /files/:id. Callers must
26
+ // feature-detect via `typeof provider.getSignedUrl === "function"`.
27
+ export type FileStorageProvider = {
28
+ write(key: string, data: Uint8Array, mimeType?: string): Promise<void>;
29
+ writeStream(
30
+ key: string,
31
+ source: AsyncIterable<Uint8Array>,
32
+ options?: WriteStreamOptions,
33
+ ): Promise<void>;
34
+ read(key: string): Promise<Uint8Array>;
35
+ readStream(key: string): AsyncIterable<Uint8Array>;
36
+ delete(key: string): Promise<void>;
37
+ exists(key: string): Promise<boolean>;
38
+ getSignedUrl?(key: string, expiresInSeconds: number, options?: SignedUrlOptions): Promise<string>;
39
+ };