@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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/storage",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.87",
5
+ "version": "0.70.88",
6
6
  "description": "The Stacks file system.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -63,12 +63,12 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@stacksjs/arrays": "0.70.87",
66
+ "@stacksjs/arrays": "0.70.88",
67
67
  "better-dx": "^0.2.16",
68
- "@stacksjs/error-handling": "0.70.87",
69
- "@stacksjs/path": "0.70.87",
70
- "@stacksjs/strings": "0.70.87",
71
- "@stacksjs/types": "0.70.87",
68
+ "@stacksjs/error-handling": "0.70.88",
69
+ "@stacksjs/path": "0.70.88",
70
+ "@stacksjs/strings": "0.70.88",
71
+ "@stacksjs/types": "0.70.88",
72
72
  "sharp": "^0.35.3"
73
73
  }
74
74
  }
@@ -1,31 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, StorageAdapterConfig, TemporaryUrlOptions, Visibility } from '../types';
3
- export declare function createBunStorage(config?: StorageAdapterConfig): BunStorageAdapter;
4
- export declare class BunStorageAdapter implements StorageAdapter {
5
- constructor(config?: StorageAdapterConfig);
6
- write(path: string, contents: FileContents): Promise<PutResult>;
7
- read(path: string): Promise<FileContents>;
8
- getStream(path: string, _options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
9
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
10
- readToString(path: string): Promise<string>;
11
- readToBuffer(path: string): Promise<Buffer>;
12
- readToUint8Array(path: string): Promise<Uint8Array>;
13
- deleteFile(path: string): Promise<void>;
14
- deleteDirectory(path: string): Promise<void>;
15
- createDirectory(path: string): Promise<void>;
16
- moveFile(from: string, to: string): Promise<void>;
17
- copyFile(from: string, to: string): Promise<void>;
18
- stat(path: string): Promise<StatEntry>;
19
- list(path: string, options?: ListOptions): DirectoryListing;
20
- changeVisibility(path: string, vis: Visibility): Promise<void>;
21
- visibility(path: string): Promise<Visibility>;
22
- fileExists(path: string): Promise<boolean>;
23
- directoryExists(path: string): Promise<boolean>;
24
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>;
25
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>;
26
- signedUrl(path: string, options: SignedUrlOptions): Promise<string>;
27
- checksum(path: string, options?: ChecksumOptions): Promise<string>;
28
- mimeType(path: string, _options?: MimeTypeOptions): Promise<string>;
29
- lastModified(path: string): Promise<number>;
30
- fileSize(path: string): Promise<number>;
31
- }
@@ -1,6 +0,0 @@
1
- export * from './local';
2
- export * from './memory';
3
- export * from './s3';
4
- export * from './bun';
5
- // Per-tenant prefix scoping wrapper (stacksjs/stacks#1887 S-11)
6
- export * from './scoped';
@@ -1,38 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import { copyFile, stat } from 'node:fs/promises';
3
- import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, StorageAdapterConfig, TemporaryUrlOptions, Visibility } from '../types';
4
- /**
5
- * Create a local storage adapter instance
6
- */
7
- export declare function createLocalStorage(config?: StorageAdapterConfig): LocalStorageAdapter;
8
- /**
9
- * Local filesystem storage adapter using Node.js fs APIs
10
- */
11
- export declare class LocalStorageAdapter implements StorageAdapter {
12
- constructor(config?: StorageAdapterConfig);
13
- write(path: string, contents: FileContents): Promise<PutResult>;
14
- read(path: string): Promise<FileContents>;
15
- getStream(path: string, options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
16
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
17
- readToString(path: string): Promise<string>;
18
- readToBuffer(path: string): Promise<Buffer>;
19
- readToUint8Array(path: string): Promise<Uint8Array>;
20
- deleteFile(path: string): Promise<void>;
21
- deleteDirectory(path: string): Promise<void>;
22
- createDirectory(path: string): Promise<void>;
23
- moveFile(from: string, to: string): Promise<void>;
24
- copyFile(from: string, to: string): Promise<void>;
25
- stat(path: string): Promise<StatEntry>;
26
- list(path: string, options?: ListOptions): DirectoryListing;
27
- changeVisibility(path: string, vis: Visibility): Promise<void>;
28
- visibility(path: string): Promise<Visibility>;
29
- fileExists(path: string): Promise<boolean>;
30
- directoryExists(path: string): Promise<boolean>;
31
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>;
32
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>;
33
- signedUrl(path: string, options: SignedUrlOptions): Promise<string>;
34
- checksum(path: string, options?: ChecksumOptions): Promise<string>;
35
- mimeType(path: string, options?: MimeTypeOptions): Promise<string>;
36
- lastModified(path: string): Promise<number>;
37
- fileSize(path: string): Promise<number>;
38
- }
@@ -1,38 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, TemporaryUrlOptions, Visibility } from '../types';
3
- /**
4
- * Create an in-memory storage adapter instance
5
- */
6
- export declare function createMemoryStorage(): InMemoryStorageAdapter;
7
- /**
8
- * In-memory storage adapter for testing and temporary storage
9
- */
10
- export declare class InMemoryStorageAdapter implements StorageAdapter {
11
- constructor();
12
- write(path: string, contents: FileContents): Promise<PutResult>;
13
- read(path: string): Promise<FileContents>;
14
- getStream(path: string, _options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
15
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
16
- readToString(path: string): Promise<string>;
17
- readToBuffer(path: string): Promise<Buffer>;
18
- readToUint8Array(path: string): Promise<Uint8Array>;
19
- deleteFile(path: string): Promise<void>;
20
- deleteDirectory(path: string): Promise<void>;
21
- createDirectory(path: string): Promise<void>;
22
- moveFile(from: string, to: string): Promise<void>;
23
- copyFile(from: string, to: string): Promise<void>;
24
- stat(path: string): Promise<StatEntry>;
25
- list(path: string, options?: ListOptions): DirectoryListing;
26
- changeVisibility(path: string, visibility: Visibility): Promise<void>;
27
- visibility(path: string): Promise<Visibility>;
28
- fileExists(path: string): Promise<boolean>;
29
- directoryExists(path: string): Promise<boolean>;
30
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>;
31
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>;
32
- signedUrl(_path: string, _options: SignedUrlOptions): Promise<string>;
33
- checksum(path: string, options?: ChecksumOptions): Promise<string>;
34
- mimeType(path: string, _options?: MimeTypeOptions): Promise<string>;
35
- lastModified(path: string): Promise<number>;
36
- fileSize(path: string): Promise<number>;
37
- clear(): void;
38
- }
@@ -1,53 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PresignedUploadPolicy, PresignedUploadPolicyOptions, PresignedUploadUrl, PresignedUploadUrlOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, StorageAdapterConfig, TemporaryUrlOptions, Visibility } from '../types';
3
- import type { S3Client } from '@stacksjs/ts-cloud';
4
- /**
5
- * Create an S3 storage adapter instance
6
- */
7
- export declare function createS3Storage(client: S3Client | null, config: StorageAdapterConfig): S3StorageAdapter;
8
- /**
9
- * Append-and-take byte buffer used by the multipart pipeline
10
- * (stacksjs/stacks#1886). Holds incoming chunks until they reach
11
- * the configured part size, then yields them as a single Uint8Array
12
- * via `take(n)` or `flush()`.
13
- */
14
- declare class ChunkBuffer {
15
- constructor(_partSize: number);
16
- get length(): number;
17
- push(c: Uint8Array): void;
18
- take(n: number): Uint8Array;
19
- flush(): Uint8Array;
20
- }
21
- /**
22
- * AWS S3 storage adapter using ts-cloud S3Client
23
- */
24
- export declare class S3StorageAdapter implements StorageAdapter {
25
- constructor(client: S3Client | null, config: StorageAdapterConfig);
26
- write(path: string, contents: FileContents): Promise<PutResult>;
27
- read(path: string): Promise<FileContents>;
28
- getStream(path: string, _options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
29
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
30
- readToString(path: string): Promise<string>;
31
- readToBuffer(path: string): Promise<Buffer>;
32
- readToUint8Array(path: string): Promise<Uint8Array>;
33
- deleteFile(path: string): Promise<void>;
34
- deleteDirectory(path: string): Promise<void>;
35
- createDirectory(_path: string): Promise<void>;
36
- moveFile(from: string, to: string): Promise<void>;
37
- copyFile(from: string, to: string): Promise<void>;
38
- stat(path: string): Promise<StatEntry>;
39
- list(path: string, options?: ListOptions): DirectoryListing;
40
- changeVisibility(path: string, vis: Visibility): Promise<void>;
41
- visibility(path: string): Promise<Visibility>;
42
- fileExists(path: string): Promise<boolean>;
43
- directoryExists(path: string): Promise<boolean>;
44
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>;
45
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>;
46
- signedUrl(path: string, options: SignedUrlOptions): Promise<string>;
47
- presignedUploadUrl(options: PresignedUploadUrlOptions): Promise<PresignedUploadUrl>;
48
- presignedUploadPolicy(options: PresignedUploadPolicyOptions): Promise<PresignedUploadPolicy>;
49
- checksum(path: string, options?: ChecksumOptions): Promise<string>;
50
- mimeType(path: string, _options?: MimeTypeOptions): Promise<string>;
51
- lastModified(path: string): Promise<number>;
52
- fileSize(path: string): Promise<number>;
53
- }
@@ -1,68 +0,0 @@
1
- import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PresignedUploadPolicy, PresignedUploadPolicyOptions, PresignedUploadUrl, PresignedUploadUrlOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, TemporaryUrlOptions, Visibility } from '../types';
2
- /**
3
- * Convenience factory — most app code reads cleaner with the
4
- * function form than `new ScopedStorageAdapter(...)`.
5
- *
6
- * @example
7
- * ```ts
8
- * const tenantDisk = scoped(Storage.disk('s3'), { scope: `tenant-${id}` })
9
- * ```
10
- */
11
- export declare function scoped(inner: StorageAdapter, options: ScopedAdapterOptions): ScopedStorageAdapter;
12
- /**
13
- * Configuration for a scoped adapter.
14
- */
15
- export declare interface ScopedAdapterOptions {
16
- scope: string
17
- scopePattern?: RegExp
18
- }
19
- /**
20
- * Wrap any `StorageAdapter` to scope every operation under a
21
- * per-tenant prefix. The wrapped instance presents the same
22
- * `StorageAdapter` interface so the session middleware /
23
- * `Storage.disk()` / cross-disk copy all work transparently.
24
- *
25
- * Construction validates the scope against
26
- * {@link ScopedAdapterOptions.scopePattern} so a hostile or
27
- * malformed tenant id can't escape via `..` segments or path
28
- * separators.
29
- *
30
- * @example
31
- * ```ts
32
- * const tenantDisk = new ScopedStorageAdapter(
33
- * Storage.disk('s3'),
34
- * { scope: `tenant-${tenantId}` },
35
- * )
36
- * await tenantDisk.write('avatar.jpg', file) // → tenant-42/avatar.jpg
37
- * ```
38
- */
39
- export declare class ScopedStorageAdapter implements StorageAdapter {
40
- constructor(inner: StorageAdapter, options: ScopedAdapterOptions);
41
- write(path: string, contents: FileContents): Promise<PutResult>;
42
- read(path: string): Promise<FileContents>;
43
- readToString(path: string): Promise<string>;
44
- readToBuffer(path: string): Promise<Buffer>;
45
- readToUint8Array(path: string): Promise<Uint8Array>;
46
- deleteFile(path: string): Promise<void>;
47
- deleteDirectory(path: string): Promise<void>;
48
- createDirectory(path: string): Promise<void>;
49
- moveFile(from: string, to: string): Promise<void>;
50
- copyFile(from: string, to: string): Promise<void>;
51
- stat(path: string): Promise<StatEntry>;
52
- list(path: string, options?: ListOptions): DirectoryListing;
53
- changeVisibility(path: string, visibility: Visibility): Promise<void>;
54
- visibility(path: string): Promise<Visibility>;
55
- fileExists(path: string): Promise<boolean>;
56
- directoryExists(path: string): Promise<boolean>;
57
- publicUrl(path: string, options?: PublicUrlOptions): Promise<string>;
58
- temporaryUrl(path: string, options: TemporaryUrlOptions): Promise<string>;
59
- signedUrl(path: string, options: SignedUrlOptions): Promise<string>;
60
- presignedUploadUrl(options: PresignedUploadUrlOptions): Promise<PresignedUploadUrl>;
61
- presignedUploadPolicy(options: PresignedUploadPolicyOptions): Promise<PresignedUploadPolicy>;
62
- getStream(path: string, options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
63
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
64
- checksum(path: string, options?: ChecksumOptions): Promise<string>;
65
- mimeType(path: string, options?: MimeTypeOptions): Promise<string>;
66
- lastModified(path: string): Promise<number>;
67
- fileSize(path: string): Promise<number>;
68
- }
package/dist/copy.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare function copy(src: string | string[], dest: string, exclude?: string[]): void;
2
- export declare function copyFile(src: string, dest: string): void;
3
- export declare function copyFolder(src: string, dest: string, exclude?: string[]): void;
package/dist/delete.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { Result } from '@stacksjs/error-handling';
2
- export declare function deleteFolder(path: string): Promise<Result<string, Error>>;
3
- export declare function isDirectoryEmpty(path: string): Promise<Result<boolean, Error>>;
4
- export declare function deleteEmptyFolder(path: string): Promise<Result<string, Error>>;
5
- export declare function deleteEmptyFolders(dir: string): Promise<Result<string, Error>>;
6
- export declare function deleteFile(path: string): Promise<Result<string, Error>>;
7
- export declare function deleteGlob(path: string): Promise<Result<string, Error>>;
8
- export declare function del(path: string): Promise<Result<string, Error>>;
@@ -1,4 +0,0 @@
1
- import type { StorageAdapter } from '../types';
2
- import type { StorageDriver } from '@stacksjs/types';
3
- export declare function getAwsStorage(): Promise<StorageAdapter>;
4
- export declare const aws: StorageDriver;
@@ -1,4 +0,0 @@
1
- import type { StorageAdapter } from '../types';
2
- import type { StorageDriver } from '@stacksjs/types';
3
- export declare function getBunStorage(): Promise<StorageAdapter>;
4
- export declare const bun: StorageDriver;
@@ -1,4 +0,0 @@
1
- export * from './aws';
2
- export * from './local';
3
- export * from './memory';
4
- export * from './bun';
@@ -1,4 +0,0 @@
1
- import type { StorageAdapter } from '../types';
2
- import type { StorageDriver } from '@stacksjs/types';
3
- export declare function getLocalStorage(): Promise<StorageAdapter>;
4
- export declare const local: StorageDriver;
@@ -1,4 +0,0 @@
1
- import type { StorageDriver } from '@stacksjs/types';
2
- declare const adapter: unknown;
3
- export declare const memoryStorage: unknown;
4
- export declare const memory: StorageDriver;
package/dist/facade.d.ts DELETED
@@ -1,53 +0,0 @@
1
- import type { DiskConfig, DiskName, FilesystemConfig, LocalDiskConfig, S3DiskConfig } from './types/filesystem';
2
- import type { GetStreamOptions, PresignedUploadPolicy, PresignedUploadPolicyOptions, PresignedUploadUrl, PresignedUploadUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter } from './types';
3
- import type { PutFileOptions, UploadedFileLike } from './put-file';
4
- export type {
5
- DiskConfig,
6
- FilesystemConfig,
7
- LocalDiskConfig,
8
- S3DiskConfig,
9
- } from './types/filesystem';
10
- // =============================================================================
11
- // Exports
12
- // =============================================================================
13
- export declare const Storage: StorageManager;
14
- // =============================================================================
15
- // Storage Manager
16
- // =============================================================================
17
- declare class StorageManager {
18
- init(config: Partial<FilesystemConfig>): this;
19
- disk(name?: DiskName): StorageAdapter;
20
- put(path: string, contents: string | Uint8Array | Buffer): Promise<PutResult>;
21
- put(file: UploadedFileLike, opts?: PutFileOptions): Promise<PutResult & { url: string }>;
22
- put(pathOrFile: string | UploadedFileLike, contentsOrOpts?: string | Uint8Array | Buffer | PutFileOptions): Promise<PutResult | (PutResult & { url: string })>;
23
- stat(path: string): Promise<StatEntry>;
24
- getStream(path: string, options?: GetStreamOptions): Promise<ReadableStream<Uint8Array>>;
25
- putStream(path: string, stream: ReadableStream<Uint8Array>, options?: PutStreamOptions): Promise<PutResult>;
26
- copyAcross(source: string, dest: string): Promise<PutResult>;
27
- moveAcross(source: string, dest: string): Promise<PutResult>;
28
- get(path: string): Promise<string>;
29
- exists(path: string): Promise<boolean>;
30
- missing(path: string): Promise<boolean>;
31
- delete(path: string): Promise<void>;
32
- copy(from: string, to: string): Promise<void>;
33
- move(from: string, to: string): Promise<void>;
34
- url(path: string): Promise<string>;
35
- signedUrl(path: string, options: SignedUrlOptions): Promise<string>;
36
- presignedUploadUrl(options: PresignedUploadUrlOptions): Promise<PresignedUploadUrl>;
37
- presignedUploadPolicy(options: PresignedUploadPolicyOptions): Promise<PresignedUploadPolicy>;
38
- size(path: string): Promise<number>;
39
- lastModified(path: string): Promise<number>;
40
- mimeType(path: string): Promise<string>;
41
- checksum(path: string, algorithm?: 'md5' | 'sha1' | 'sha256'): Promise<string>;
42
- makeDirectory(path: string): Promise<void>;
43
- deleteDirectory(path: string): Promise<void>;
44
- files(path?: string): AsyncIterable<{ path: string; type: 'file' | 'directory' }>;
45
- allFiles(path?: string): AsyncIterable<{ path: string; type: 'file' | 'directory' }>;
46
- configure(name: string, config: DiskConfig): this;
47
- setDefaultDisk(name: string): this;
48
- getDiskConfig(name?: string): DiskConfig | undefined;
49
- getConfiguredDisks(): string[];
50
- getDefaultDisk(): string;
51
- reset(): this;
52
- }
53
- export { StorageManager };
package/dist/files.d.ts DELETED
@@ -1,52 +0,0 @@
1
- import type { JsonFile, PackageJson, TextFile } from '@stacksjs/types';
2
- /**
3
- * Reads a JSON file and returns the parsed data.
4
- */
5
- export declare function readJsonFile(name: string, cwd?: string): Promise<JsonFile>;
6
- /**
7
- * Reads a package.json file and returns the parsed data.
8
- */
9
- export declare function readPackageJson(name: string, cwd?: string): Promise<PackageJson>;
10
- /**
11
- * Writes the given text to the specified file.
12
- */
13
- export declare function writeFile(path: string, data: any): Promise<number>;
14
- /**
15
- * Writes the given data to the specified JSON file.
16
- */
17
- export declare function writeJsonFile(file: JsonFile): Promise<number>;
18
- /**
19
- * Reads a text file and returns its contents.
20
- */
21
- export declare function readTextFile(name: string, cwd?: string): Promise<TextFile>;
22
- /**
23
- * Writes the given text to the specified file.
24
- */
25
- export declare function writeTextFile(file: TextFile): Promise<number>;
26
- export declare function doesExist(path: string): boolean;
27
- export declare function doesNotExist(path: string): boolean;
28
- /**
29
- * Determine whether a folder has any files in it.
30
- */
31
- export declare function hasFiles(folder: string): boolean;
32
- export declare function hasComponents(): boolean;
33
- export declare function hasFunctions(): boolean;
34
- export declare function deleteFiles(dir: string, exclude?: string[]): void;
35
- export declare function getFiles(dir: string, exclude?: string[]): string[];
36
- export declare function put(path: string, contents: string): void;
37
- export declare function get(path: string): Promise<string>;
38
- export declare const files: Files;
39
- export declare interface Files {
40
- readJsonFile: typeof readJsonFile
41
- readPackageJson: typeof readPackageJson
42
- readTextFile: typeof readTextFile
43
- writeJsonFile: typeof writeJsonFile
44
- writeTextFile: typeof writeTextFile
45
- hasFiles: typeof hasFiles
46
- hasComponents: typeof hasComponents
47
- hasFunctions: typeof hasFunctions
48
- deleteFiles: typeof deleteFiles
49
- getFiles: typeof getFiles
50
- put: typeof put
51
- get: typeof get
52
- }
package/dist/folders.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Determine whether a path is a folder.
3
- */
4
- export declare function isFolder(path: string): boolean;
5
- // export function isDirectory(path: string): boolean {
6
- // return isFolder(path)
7
- // }
8
- export declare function isDir(path: string): boolean;
9
- export declare function doesFolderExist(path: string): boolean;
10
- export declare function createFolder(dir: string): Promise<void>;
11
- export declare function getFolders(dir: string): string[];
12
- export declare const folders: Folders;
13
- export declare interface Folders {
14
- isFolder: (path: string) => boolean
15
- doesFolderExist: (path: string) => boolean
16
- createFolder: (dir: string) => Promise<void>
17
- getFolders: (dir: string) => string[]
18
- }
package/dist/fs.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { existsSync, watch as fsWatch, mkdirSync, readFileSync, watchFile, writeFileSync } from 'node:fs';
2
- import * as fs from 'node:fs';
3
- export declare function exists(path: string): boolean;
4
- export { existsSync, fsWatch, mkdirSync, readFileSync, watchFile, writeFileSync, fs };
package/dist/glob.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare function globSync(patterns: string | string[], options?: Omit<GlobOptions, 'patterns'>): string[];
2
- export declare function glob(patterns: string | string[], options?: Omit<GlobOptions, 'patterns'>): Promise<string[]>;
3
- export declare interface GlobOptions {
4
- absolute?: boolean
5
- cwd?: string
6
- patterns?: string[]
7
- ignore?: string[]
8
- dot?: boolean
9
- deep?: number
10
- expandDirectories?: boolean
11
- onlyDirectories?: boolean
12
- onlyFiles?: boolean
13
- }
package/dist/hash.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Hash } from 'node:crypto';
2
- export declare function hashFileOrDirectory(path: string, hash: Hash): void;
3
- export declare function hashDirectory(directory: string): string;
4
- export declare function hashPath(path: string): string;
5
- export declare function hashPaths(paths: string | string[]): string;
package/dist/helpers.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export declare function updateConfigFile(filePath: string, newConfig: Record<string, unknown>): Promise<void>;
2
- export declare const _dirname: string;
3
- export declare const helpers: Helpers;
4
- declare interface Helpers {
5
- _dirname: string
6
- updateConfigFile: (filePath: string, newConfig: Record<string, unknown>) => Promise<void>
7
- }
package/dist/image.d.ts DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * Wrap a Sharp pipeline so it composes with
3
- * `Storage.put(file, { transform })`. The pipeline function receives a
4
- * fresh Sharp instance preloaded with the file's bytes; its return
5
- * value is the final pipeline chain (sharp's methods are chainable so
6
- * "return img.resize(...)" is the normal shape).
7
- *
8
- * The wrapper handles the buffer normalisation + final `.toBuffer()`
9
- * call so callers don't have to.
10
- */
11
- export declare function transform(pipeline: (img: SharpInstance) => SharpInstance | Promise<SharpInstance>): (input: Uint8Array | Buffer | ArrayBuffer) => Promise<Buffer>;
12
- /**
13
- * Common preset for square avatars — resizes + crops to fit, encodes
14
- * as WebP at quality 85. Covers the by-far most common
15
- * `Storage.put(file, { transform: ... })` callsite.
16
- *
17
- * @example
18
- * ```ts
19
- * import { avatar } from '@stacksjs/storage/image'
20
- *
21
- * await Storage.put(file, {
22
- * dir: 'avatars',
23
- * transform: avatar(512),
24
- * })
25
- * ```
26
- */
27
- export declare function avatar(size?: number, quality?: number): (input: Uint8Array | Buffer | ArrayBuffer) => Promise<Buffer>;
28
- /**
29
- * Generic resize preset. `fit` defaults to `'inside'` (preserve aspect
30
- * ratio, don't crop) which is the most common non-avatar case.
31
- */
32
- export declare function resize(width: number, height: number, fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside'): (input: Uint8Array | Buffer | ArrayBuffer) => Promise<Buffer>;
33
- /**
34
- * Strip EXIF + colour profile + other embedded metadata. Useful when
35
- * accepting user uploads where you don't want to leak GPS coordinates
36
- * embedded in phone photos. Pairs well with resize/format presets via
37
- * the explicit `transform()` form when needed.
38
- *
39
- * sharp strips metadata by default unless `withMetadata()` is called;
40
- * this preset just makes the intent explicit.
41
- */
42
- export declare function stripMetadata(): (input: Uint8Array | Buffer | ArrayBuffer) => Promise<Buffer>;
43
- declare interface SharpInstance {
44
- toBuffer(): Promise<Buffer>
45
- resize: (...args: unknown[]) => SharpInstance
46
- jpeg: (...args: unknown[]) => SharpInstance
47
- png: (...args: unknown[]) => SharpInstance
48
- webp: (...args: unknown[]) => SharpInstance
49
- avif: (...args: unknown[]) => SharpInstance
50
- gif: (...args: unknown[]) => SharpInstance
51
- rotate: (...args: unknown[]) => SharpInstance
52
- blur: (...args: unknown[]) => SharpInstance
53
- withMetadata: (...args: unknown[]) => SharpInstance
54
- [k: string]: unknown
55
- }
package/dist/image.js DELETED
@@ -1,43 +0,0 @@
1
- // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/image.ts
5
- var cachedSharp = null;
6
- async function loadSharp() {
7
- if (cachedSharp)
8
- return cachedSharp;
9
- try {
10
- const mod = await import("sharp");
11
- cachedSharp = mod.default ?? mod;
12
- return cachedSharp;
13
- } catch (err) {
14
- throw new Error(`[storage/image] \`sharp\` is not installed. Image transforms require it as a peer dependency.
15
- Install with: \`bun add sharp\`
16
- Original load error: ${err instanceof Error ? err.message : String(err)}`);
17
- }
18
- }
19
- function transform(pipeline) {
20
- return async (input) => {
21
- const sharp = await loadSharp();
22
- const bytes = input instanceof ArrayBuffer ? new Uint8Array(input) : input;
23
- const buf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes);
24
- const img = sharp(buf);
25
- const piped = await pipeline(img);
26
- return piped.toBuffer();
27
- };
28
- }
29
- function avatar(size = 512, quality = 85) {
30
- return transform((img) => img.resize(size, size, { fit: "cover" }).webp({ quality }));
31
- }
32
- function resize(width, height, fit = "inside") {
33
- return transform((img) => img.resize(width, height, { fit }));
34
- }
35
- function stripMetadata() {
36
- return transform((img) => img);
37
- }
38
- export {
39
- transform,
40
- stripMetadata,
41
- resize,
42
- avatar
43
- };
package/dist/index.d.ts DELETED
@@ -1,60 +0,0 @@
1
- export type { ServeFileOptions } from './static-serve';
2
- export type { DiskConfig, FilesystemConfig, LocalDiskConfig, S3DiskConfig } from './facade';
3
- export type { FilenameStrategy, PutFileOptions, UploadedFileLike } from './put-file';
4
- // Disk-name autocomplete: userland augments `KnownDisks` to get
5
- // completion on `Storage.disk('…')` (stacksjs/stacks#1924).
6
- export type { DiskName, KnownDisks } from './types/filesystem';
7
- export type { SignedTokenVerification } from './signed-url';
8
- export type { SignedUrlOptions } from './types';
9
- export type { ParsedDiskPath } from './path-sanitize';
10
- export type { MimeVerifyResult } from './mime-verify';
11
- export type { S3PresignedPostInput, S3PresignedPostResult } from './s3-presigned-post';
12
- export type {
13
- GetStreamOptions,
14
- PresignedUploadPolicy,
15
- PresignedUploadPolicyOptions,
16
- PutResult,
17
- PutStreamOptions,
18
- } from './types';
19
- export * from './copy';
20
- export * from './delete';
21
- export * from './files';
22
- export * from './folders';
23
- export * from './fs';
24
- export * from './glob';
25
- export * from './hash';
26
- export * from './helpers';
27
- export * as storage from './storage';
28
- export * from './zip';
29
- // Storage adapters and types
30
- export * from './adapters/index';
31
- export * from './types';
32
- export * from './drivers/index';
33
- // Static asset serving with ETag/Last-Modified/Cache-Control
34
- export { serveFile } from './static-serve';
35
- // Laravel-style Storage facade and UploadedFile
36
- export { Storage, StorageManager } from './facade';
37
- export { UploadedFile, uploadedFile, uploadedFiles } from './uploaded-file';
38
- // Filesystem type helpers
39
- export { configFromEnv, localDisk, s3Disk } from './types/filesystem';
40
- // Signed-URL helpers (used by Storage.disk('local').signedUrl())
41
- export {
42
- clearRevokedSignedStorageTokens,
43
- createSignedStorageToken,
44
- isSignedStorageTokenRevoked,
45
- revokeSignedStorageToken,
46
- verifySignedStorageToken,
47
- } from './signed-url';
48
- // Path-sanitization helpers (used internally by S3 presignedUploadUrl;
49
- // also re-exported so user code can pre-validate input from request
50
- // bodies and surface 400s with a clean `PathSanitizeError`.)
51
- export { parseDiskPath, PathSanitizeError, sanitizePresignedDir, sanitizePresignedFilename } from './path-sanitize';
52
- // MIME re-verification — server-side check that uploaded bytes match
53
- // the claimed content type. Run this after a presigned upload
54
- // completes since `Content-Type` on a presigned PUT is caller-attested.
55
- export { detectMimeFromMagicBytes, verifyUploadedMime } from './mime-verify';
56
- // S3 presigned-POST policy signer (stacksjs/stacks#1888 Phase B).
57
- // Exposed as a standalone for callers that have their own S3 client
58
- // and just need the policy-signing logic; the Storage facade wraps
59
- // it as `presignedUploadPolicy()`.
60
- export { signS3PresignedPost } from './s3-presigned-post';