@stacksjs/storage 0.70.87 → 0.70.88

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/types.d.ts DELETED
@@ -1,229 +0,0 @@
1
- import type { Buffer } from 'node:buffer';
2
- /**
3
- * Helper to create async iterable from array
4
- */
5
- export declare function createDirectoryListing(entries: DirectoryEntry[]): DirectoryListing;
6
- /**
7
- * Convert expiry to milliseconds
8
- */
9
- export declare function normalizeExpiryToMilliseconds(expiry: number | Date): number;
10
- /**
11
- * Convert expiry to Date
12
- */
13
- export declare function normalizeExpiryToDate(expiry: number | Date): Date;
14
- /**
15
- * Check if entry is a file
16
- */
17
- export declare function isFile(entry: DirectoryEntry | StatEntry): boolean;
18
- /**
19
- * Check if entry is a directory
20
- */
21
- export declare function isDirectory(entry: DirectoryEntry | StatEntry): boolean;
22
- /**
23
- * File stat entry information
24
- */
25
- export declare interface StatEntry {
26
- path: string
27
- type: 'file' | 'directory'
28
- visibility: Visibility
29
- size: number
30
- lastModified: number
31
- mimeType?: string
32
- metadata?: Record<string, any>
33
- }
34
- /**
35
- * Options for `Storage.getStream(path, options?)`
36
- * (stacksjs/stacks#1886).
37
- */
38
- export declare interface GetStreamOptions {
39
- signal?: AbortSignal
40
- }
41
- /**
42
- * Options for `Storage.putStream(path, stream, options?)`
43
- * (stacksjs/stacks#1886). All fields are optional; the S3 driver
44
- * reads them to tune its multipart pipeline, other drivers
45
- * generally only honor `contentType` and `signal`.
46
- */
47
- export declare interface PutStreamOptions {
48
- contentType?: string
49
- signal?: AbortSignal
50
- partSize?: number
51
- concurrency?: number
52
- maxRetries?: number
53
- }
54
- /**
55
- * Result returned from `Storage.put()` (stacksjs/stacks#1888 S-8).
56
- *
57
- * Pre-fix `put()` returned `Promise<void>` — callers that wanted to
58
- * record an etag for cache-invalidation or a size for storage-quota
59
- * accounting had to issue a second `.stat()` round-trip. This shape
60
- * carries the metadata back from the write itself.
61
- *
62
- * Fields beyond `path` are best-effort: drivers that don't expose
63
- * (or can't cheaply compute) a value omit it rather than synthesizing
64
- * a fake one. Callers should treat them as nullable.
65
- */
66
- export declare interface PutResult {
67
- path: string
68
- size: number
69
- contentType?: string
70
- lastModified?: number
71
- etag?: string
72
- }
73
- /**
74
- * Directory listing entry
75
- */
76
- export declare interface DirectoryEntry {
77
- path: string
78
- type: 'file' | 'directory'
79
- }
80
- /**
81
- * Directory listing iterator
82
- */
83
- export declare interface DirectoryListing extends AsyncIterable<DirectoryEntry> {
84
- [Symbol.asyncIterator](): AsyncIterator<DirectoryEntry>
85
- }
86
- /**
87
- * Options for listing directories
88
- */
89
- export declare interface ListOptions {
90
- deep?: boolean
91
- }
92
- /**
93
- * Options for generating public URLs
94
- */
95
- export declare interface PublicUrlOptions {
96
- domain?: string
97
- }
98
- /**
99
- * Options for generating temporary URLs
100
- */
101
- export declare interface TemporaryUrlOptions {
102
- expiresIn: number | Date
103
- }
104
- /**
105
- * Options for generating signed (JWT-style) URLs.
106
- *
107
- * Distinct from `TemporaryUrlOptions` so adapters that don't natively
108
- * support the richer claims set (in-memory mocks) can throw a clear
109
- * "unsupported" error rather than silently returning a useless URL.
110
- */
111
- export declare interface SignedUrlOptions {
112
- expiresIn: number | Date
113
- issuer?: string
114
- baseUrl?: string
115
- }
116
- /**
117
- * Options for `presignedUploadPolicy()` — the POST-form upload
118
- * primitive that S3 can enforce server-side (stacksjs/stacks#1888
119
- * Phase B). Distinct from {@link PresignedUploadUrlOptions} (PUT-
120
- * form): the POST policy carries a `Content-Length-Range` condition
121
- * that S3 enforces server-side, so this is the right primitive when
122
- * you genuinely need a size cap against an untrusted client.
123
- */
124
- export declare interface PresignedUploadPolicyOptions {
125
- key: string | { startsWith: string }
126
- contentType: string | { startsWith: string }
127
- contentLengthRange?: { min: number, max: number }
128
- acl?: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read' | 'bucket-owner-read' | 'bucket-owner-full-control'
129
- expiresIn: number
130
- fields?: Record<string, string>
131
- }
132
- /**
133
- * What the caller hands to the browser. Submit as
134
- * `multipart/form-data` to `url` with every entry of `fields` as a
135
- * form field, then the actual file LAST under the field name
136
- * `'file'`. `key` is what the upload will land at — store on the
137
- * domain record.
138
- */
139
- export declare interface PresignedUploadPolicy {
140
- url: string
141
- fields: Record<string, string>
142
- key: string
143
- }
144
- /**
145
- * Options for `presignedUploadUrl()` (stacksjs/stacks#1856 Stage 6).
146
- */
147
- export declare interface PresignedUploadUrlOptions {
148
- contentType: string
149
- expiresIn: number
150
- dir?: string
151
- filename?: string
152
- maxBytes?: number
153
- }
154
- export declare interface PresignedUploadUrl {
155
- url: string
156
- path: string
157
- key: string
158
- contentType: string
159
- maxBytes?: number
160
- }
161
- /**
162
- * Checksum algorithm options
163
- */
164
- export declare interface ChecksumOptions {
165
- algorithm?: 'md5' | 'sha1' | 'sha256'
166
- }
167
- /**
168
- * MIME type detection options
169
- */
170
- export declare interface MimeTypeOptions {
171
- useExtension?: boolean
172
- }
173
- /**
174
- * Storage adapter configuration
175
- */
176
- export declare interface StorageAdapterConfig {
177
- root?: string
178
- bucket?: string
179
- region?: string
180
- prefix?: string
181
- credentials?: {
182
- accessKeyId: string
183
- secretAccessKey: string
184
- sessionToken?: string
185
- }
186
- }
187
- /**
188
- * Base storage adapter interface
189
- */
190
- export declare interface StorageAdapter {
191
- write(path: string, contents: FileContents): Promise<PutResult>
192
- read(path: string): Promise<FileContents>
193
- readToString(path: string): Promise<string>
194
- readToBuffer(path: string): Promise<Buffer>
195
- readToUint8Array(path: string): Promise<Uint8Array>
196
- deleteFile(path: string): Promise<void>
197
- deleteDirectory(path: string): Promise<void>
198
- createDirectory(path: string): Promise<void>
199
- moveFile(from: string, to: string): Promise<void>
200
- copyFile(from: string, to: string): Promise<void>
201
- stat(path: string): Promise<StatEntry>
202
- list(path: string, options?: ListOptions): DirectoryListing
203
- changeVisibility(path: string, visibility: Visibility): Promise<void>
204
- visibility(path: string): Promise<Visibility>
205
- fileExists(path: string): Promise<boolean>
206
- directoryExists(path: string): Promise<boolean>
207
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>
208
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>
209
- signedUrl?(path: string, options: SignedUrlOptions): Promise<string>
210
- presignedUploadUrl?(options: PresignedUploadUrlOptions): Promise<PresignedUploadUrl>
211
- presignedUploadPolicy?(options: PresignedUploadPolicyOptions): Promise<PresignedUploadPolicy>
212
- getStream?(path: string, options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>
213
- putStream?(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>
214
- checksum(path: string, options?: ChecksumOptions): Promise<string>
215
- mimeType(path: string, options?: MimeTypeOptions): Promise<string>
216
- lastModified(path: string): Promise<number>
217
- fileSize(path: string): Promise<number>
218
- }
219
- /**
220
- * File contents can be a string, Buffer, Uint8Array, or ReadableStream
221
- */
222
- export type FileContents = string | Buffer | Uint8Array | ReadableStream;
223
- /**
224
- * Visibility options for files
225
- */
226
- export declare enum Visibility {
227
- PUBLIC = 'public',
228
- PRIVATE = 'private',
229
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Create UploadedFile from native File
3
- */
4
- export declare function uploadedFile(file: File): UploadedFile;
5
- /**
6
- * Create multiple UploadedFiles from native Files
7
- */
8
- export declare function uploadedFiles(files: File[]): UploadedFile[];
9
- export declare interface UploadedFileOptions {
10
- hashName?: boolean
11
- }
12
- export declare class UploadedFile {
13
- constructor(file: File);
14
- get name(): string;
15
- get extension(): string;
16
- get mimeType(): string;
17
- get size(): number;
18
- get file(): File;
19
- hashName(extension?: string): string;
20
- arrayBuffer(): Promise<ArrayBuffer>;
21
- bytes(): Promise<Uint8Array>;
22
- text(): Promise<string>;
23
- isValid(): boolean;
24
- store(path?: string, disk?: string): Promise<string>;
25
- storeAs(path: string, name: string, disk?: string): Promise<string>;
26
- storePublicly(path?: string): Promise<string>;
27
- storePubliclyAs(path: string, name: string): Promise<string>;
28
- move(path: string, disk?: string): Promise<string>;
29
- getClientOriginalName(): string;
30
- getClientOriginalExtension(): string;
31
- getClientMimeType(): string;
32
- getSize(): string;
33
- isOneOf(mimeTypes: string[]): boolean;
34
- isImage(): boolean;
35
- isVideo(): boolean;
36
- isAudio(): boolean;
37
- isPdf(): boolean;
38
- }
@@ -1,3 +0,0 @@
1
- // type Visibility = 'public' | 'private'
2
- // export function setVisibility(path: string, visibility: Visibility) {
3
- export declare function setVisibility(): string;
package/dist/zip.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { ZlibCompressionOptions } from 'bun';
2
- import type { CommandError, Subprocess } from '@stacksjs/types';
3
- import type { Result } from '@stacksjs/error-handling';
4
- export declare function zip(from: string | string[], to?: string, options?: ZipOptions): Promise<Result<Subprocess, CommandError>>;
5
- export declare function unzip(paths: string | string[]): Promise<Result<Subprocess, CommandError>>;
6
- export declare function archive(paths: string | string[]): Promise<Result<Subprocess, CommandError>>;
7
- export declare function unarchive(paths: string | string[]): Promise<Result<Subprocess, CommandError>>;
8
- export declare function compress(paths: string[]): Promise<Result<Subprocess, CommandError>>;
9
- export declare function decompress(paths: string | string[]): Promise<Result<Subprocess, CommandError>>;
10
- export declare function gzipSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
11
- export declare function gunzipSync(data: Uint8Array): Uint8Array;
12
- export declare function deflateSync(data: Uint8Array, options?: ZlibCompressionOptions): Uint8Array;
13
- export declare function inflateSync(data: Uint8Array): Uint8Array;
14
- declare interface ZipOptions {
15
- cwd?: string
16
- }