@pelatform/storage 1.0.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.
package/dist/s3.d.cts ADDED
@@ -0,0 +1,108 @@
1
+ import { S as StorageInterface, v as S3Config, U as UploadOptions, a as UploadResult, D as DownloadOptions, b as DownloadResult, c as DeleteOptions, d as DeleteResult, B as BatchDeleteOptions, e as BatchDeleteResult, L as ListOptions, f as ListResult, E as ExistsResult, g as CopyOptions, h as CopyResult, M as MoveOptions, i as MoveResult, j as DuplicateOptions, k as DuplicateResult, P as PresignedUrlOptions, l as PresignedUrlResult, m as CreateFolderOptions, n as CreateFolderResult, o as DeleteFolderOptions, p as DeleteFolderResult, q as ListFoldersOptions, r as ListFoldersResult, F as FolderExistsResult, R as RenameFolderOptions, s as RenameFolderResult, t as CopyFolderOptions, u as CopyFolderResult } from './storage-interface-BKeDAlGP.cjs';
2
+
3
+ /**
4
+ * S3 storage service implementation
5
+ * High-level service wrapper for S3-compatible storage operations with convenience methods
6
+ */
7
+
8
+ /**
9
+ * S3 storage service
10
+ * High-level service for S3-compatible storage operations with convenience methods
11
+ * @public
12
+ */
13
+ declare class S3Service implements StorageInterface {
14
+ private provider;
15
+ private config;
16
+ constructor();
17
+ constructor(config: S3Config);
18
+ private createProvider;
19
+ getConfig(): S3Config;
20
+ getBucket(): string;
21
+ getRegion(): string;
22
+ getProvider(): string;
23
+ getPublicUrl(key: string): string;
24
+ upload(options: UploadOptions): Promise<UploadResult>;
25
+ download(options: DownloadOptions): Promise<DownloadResult>;
26
+ delete(options: DeleteOptions): Promise<DeleteResult>;
27
+ batchDelete(options: BatchDeleteOptions): Promise<BatchDeleteResult>;
28
+ list(options?: ListOptions): Promise<ListResult>;
29
+ exists(key: string): Promise<ExistsResult>;
30
+ copy(options: CopyOptions): Promise<CopyResult>;
31
+ move(options: MoveOptions): Promise<MoveResult>;
32
+ duplicate(options: DuplicateOptions): Promise<DuplicateResult>;
33
+ getPresignedUrl(options: PresignedUrlOptions): Promise<PresignedUrlResult>;
34
+ createFolder(options: CreateFolderOptions): Promise<CreateFolderResult>;
35
+ deleteFolder(options: DeleteFolderOptions): Promise<DeleteFolderResult>;
36
+ listFolders(options?: ListFoldersOptions): Promise<ListFoldersResult>;
37
+ folderExists(path: string): Promise<FolderExistsResult>;
38
+ renameFolder(options: RenameFolderOptions): Promise<RenameFolderResult>;
39
+ copyFolder(options: CopyFolderOptions): Promise<CopyFolderResult>;
40
+ uploadFile(key: string, file: Buffer | Uint8Array | string, options?: Partial<UploadOptions>): Promise<UploadResult>;
41
+ downloadFile(key: string): Promise<DownloadResult>;
42
+ deleteFile(key: string): Promise<DeleteResult>;
43
+ deleteFiles(keys: string[]): Promise<BatchDeleteResult>;
44
+ fileExists(key: string): Promise<boolean>;
45
+ copyFile(sourceKey: string, destinationKey: string, options?: Partial<CopyOptions>): Promise<CopyResult>;
46
+ moveFile(sourceKey: string, destinationKey: string, options?: Partial<MoveOptions>): Promise<MoveResult>;
47
+ duplicateFile(sourceKey: string, destinationKey: string, options?: Partial<DuplicateOptions>): Promise<DuplicateResult>;
48
+ renameFile(sourceKey: string, newKey: string, options?: Partial<MoveOptions>): Promise<MoveResult>;
49
+ getDownloadUrl(key: string, expiresIn?: number): Promise<PresignedUrlResult>;
50
+ getUploadUrl(key: string, contentType?: string, expiresIn?: number): Promise<PresignedUrlResult>;
51
+ createFolderPath(path: string): Promise<CreateFolderResult>;
52
+ deleteFolderPath(path: string, recursive?: boolean): Promise<DeleteFolderResult>;
53
+ folderPathExists(path: string): Promise<boolean>;
54
+ renameFolderPath(oldPath: string, newPath: string): Promise<RenameFolderResult>;
55
+ copyFolderPath(sourcePath: string, destinationPath: string, recursive?: boolean): Promise<CopyFolderResult>;
56
+ }
57
+
58
+ /**
59
+ * Create S3 service using environment variables or manual configuration
60
+ * @param config Optional S3 configuration. If not provided, loads from environment variables
61
+ * @returns S3Service instance
62
+ * @throws Error if configuration is invalid or environment variables are missing
63
+ * @public
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { createS3 } from '@pelatform/storage/s3';
68
+ *
69
+ * // Using environment variables
70
+ * // Set: PELATFORM_S3_PROVIDER=aws, PELATFORM_S3_REGION=us-east-1, etc.
71
+ * const s3FromEnv = createS3();
72
+ * await s3FromEnv.uploadFile('test.txt', 'Hello World');
73
+ *
74
+ * // Using manual configuration
75
+ * const s3Manual = createS3({
76
+ * provider: 'aws',
77
+ * region: 'us-east-1',
78
+ * bucket: 'my-bucket',
79
+ * accessKeyId: 'AKIA...',
80
+ * secretAccessKey: 'secret...'
81
+ * });
82
+ *
83
+ * // Cloudflare R2
84
+ * const r2 = createS3({
85
+ * provider: 'cloudflare-r2',
86
+ * region: 'auto',
87
+ * bucket: 'my-r2-bucket',
88
+ * accessKeyId: 'your-r2-key',
89
+ * secretAccessKey: 'your-r2-secret',
90
+ * endpoint: 'https://account-id.r2.cloudflarestorage.com'
91
+ * });
92
+ *
93
+ * // MinIO
94
+ * const minio = createS3({
95
+ * provider: 'minio',
96
+ * region: 'us-east-1',
97
+ * bucket: 'my-minio-bucket',
98
+ * accessKeyId: 'minioadmin',
99
+ * secretAccessKey: 'minioadmin',
100
+ * endpoint: 'http://localhost:9000',
101
+ * forcePathStyle: true
102
+ * });
103
+ * ```
104
+ */
105
+ declare function createS3(): S3Service;
106
+ declare function createS3(config: S3Config): S3Service;
107
+
108
+ export { S3Service, createS3 };
package/dist/s3.d.ts ADDED
@@ -0,0 +1,108 @@
1
+ import { S as StorageInterface, v as S3Config, U as UploadOptions, a as UploadResult, D as DownloadOptions, b as DownloadResult, c as DeleteOptions, d as DeleteResult, B as BatchDeleteOptions, e as BatchDeleteResult, L as ListOptions, f as ListResult, E as ExistsResult, g as CopyOptions, h as CopyResult, M as MoveOptions, i as MoveResult, j as DuplicateOptions, k as DuplicateResult, P as PresignedUrlOptions, l as PresignedUrlResult, m as CreateFolderOptions, n as CreateFolderResult, o as DeleteFolderOptions, p as DeleteFolderResult, q as ListFoldersOptions, r as ListFoldersResult, F as FolderExistsResult, R as RenameFolderOptions, s as RenameFolderResult, t as CopyFolderOptions, u as CopyFolderResult } from './storage-interface-BKeDAlGP.js';
2
+
3
+ /**
4
+ * S3 storage service implementation
5
+ * High-level service wrapper for S3-compatible storage operations with convenience methods
6
+ */
7
+
8
+ /**
9
+ * S3 storage service
10
+ * High-level service for S3-compatible storage operations with convenience methods
11
+ * @public
12
+ */
13
+ declare class S3Service implements StorageInterface {
14
+ private provider;
15
+ private config;
16
+ constructor();
17
+ constructor(config: S3Config);
18
+ private createProvider;
19
+ getConfig(): S3Config;
20
+ getBucket(): string;
21
+ getRegion(): string;
22
+ getProvider(): string;
23
+ getPublicUrl(key: string): string;
24
+ upload(options: UploadOptions): Promise<UploadResult>;
25
+ download(options: DownloadOptions): Promise<DownloadResult>;
26
+ delete(options: DeleteOptions): Promise<DeleteResult>;
27
+ batchDelete(options: BatchDeleteOptions): Promise<BatchDeleteResult>;
28
+ list(options?: ListOptions): Promise<ListResult>;
29
+ exists(key: string): Promise<ExistsResult>;
30
+ copy(options: CopyOptions): Promise<CopyResult>;
31
+ move(options: MoveOptions): Promise<MoveResult>;
32
+ duplicate(options: DuplicateOptions): Promise<DuplicateResult>;
33
+ getPresignedUrl(options: PresignedUrlOptions): Promise<PresignedUrlResult>;
34
+ createFolder(options: CreateFolderOptions): Promise<CreateFolderResult>;
35
+ deleteFolder(options: DeleteFolderOptions): Promise<DeleteFolderResult>;
36
+ listFolders(options?: ListFoldersOptions): Promise<ListFoldersResult>;
37
+ folderExists(path: string): Promise<FolderExistsResult>;
38
+ renameFolder(options: RenameFolderOptions): Promise<RenameFolderResult>;
39
+ copyFolder(options: CopyFolderOptions): Promise<CopyFolderResult>;
40
+ uploadFile(key: string, file: Buffer | Uint8Array | string, options?: Partial<UploadOptions>): Promise<UploadResult>;
41
+ downloadFile(key: string): Promise<DownloadResult>;
42
+ deleteFile(key: string): Promise<DeleteResult>;
43
+ deleteFiles(keys: string[]): Promise<BatchDeleteResult>;
44
+ fileExists(key: string): Promise<boolean>;
45
+ copyFile(sourceKey: string, destinationKey: string, options?: Partial<CopyOptions>): Promise<CopyResult>;
46
+ moveFile(sourceKey: string, destinationKey: string, options?: Partial<MoveOptions>): Promise<MoveResult>;
47
+ duplicateFile(sourceKey: string, destinationKey: string, options?: Partial<DuplicateOptions>): Promise<DuplicateResult>;
48
+ renameFile(sourceKey: string, newKey: string, options?: Partial<MoveOptions>): Promise<MoveResult>;
49
+ getDownloadUrl(key: string, expiresIn?: number): Promise<PresignedUrlResult>;
50
+ getUploadUrl(key: string, contentType?: string, expiresIn?: number): Promise<PresignedUrlResult>;
51
+ createFolderPath(path: string): Promise<CreateFolderResult>;
52
+ deleteFolderPath(path: string, recursive?: boolean): Promise<DeleteFolderResult>;
53
+ folderPathExists(path: string): Promise<boolean>;
54
+ renameFolderPath(oldPath: string, newPath: string): Promise<RenameFolderResult>;
55
+ copyFolderPath(sourcePath: string, destinationPath: string, recursive?: boolean): Promise<CopyFolderResult>;
56
+ }
57
+
58
+ /**
59
+ * Create S3 service using environment variables or manual configuration
60
+ * @param config Optional S3 configuration. If not provided, loads from environment variables
61
+ * @returns S3Service instance
62
+ * @throws Error if configuration is invalid or environment variables are missing
63
+ * @public
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { createS3 } from '@pelatform/storage/s3';
68
+ *
69
+ * // Using environment variables
70
+ * // Set: PELATFORM_S3_PROVIDER=aws, PELATFORM_S3_REGION=us-east-1, etc.
71
+ * const s3FromEnv = createS3();
72
+ * await s3FromEnv.uploadFile('test.txt', 'Hello World');
73
+ *
74
+ * // Using manual configuration
75
+ * const s3Manual = createS3({
76
+ * provider: 'aws',
77
+ * region: 'us-east-1',
78
+ * bucket: 'my-bucket',
79
+ * accessKeyId: 'AKIA...',
80
+ * secretAccessKey: 'secret...'
81
+ * });
82
+ *
83
+ * // Cloudflare R2
84
+ * const r2 = createS3({
85
+ * provider: 'cloudflare-r2',
86
+ * region: 'auto',
87
+ * bucket: 'my-r2-bucket',
88
+ * accessKeyId: 'your-r2-key',
89
+ * secretAccessKey: 'your-r2-secret',
90
+ * endpoint: 'https://account-id.r2.cloudflarestorage.com'
91
+ * });
92
+ *
93
+ * // MinIO
94
+ * const minio = createS3({
95
+ * provider: 'minio',
96
+ * region: 'us-east-1',
97
+ * bucket: 'my-minio-bucket',
98
+ * accessKeyId: 'minioadmin',
99
+ * secretAccessKey: 'minioadmin',
100
+ * endpoint: 'http://localhost:9000',
101
+ * forcePathStyle: true
102
+ * });
103
+ * ```
104
+ */
105
+ declare function createS3(): S3Service;
106
+ declare function createS3(config: S3Config): S3Service;
107
+
108
+ export { S3Service, createS3 };