@contractspec/lib.files 1.56.1 → 1.58.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.
Files changed (44) hide show
  1. package/dist/contracts/index.d.ts +1080 -1086
  2. package/dist/contracts/index.d.ts.map +1 -1
  3. package/dist/contracts/index.js +575 -854
  4. package/dist/docs/files.docblock.d.ts +2 -1
  5. package/dist/docs/files.docblock.d.ts.map +1 -0
  6. package/dist/docs/files.docblock.js +17 -22
  7. package/dist/docs/index.d.ts +2 -1
  8. package/dist/docs/index.d.ts.map +1 -0
  9. package/dist/docs/index.js +66 -1
  10. package/dist/entities/index.d.ts +134 -139
  11. package/dist/entities/index.d.ts.map +1 -1
  12. package/dist/entities/index.js +228 -257
  13. package/dist/events.d.ts +357 -363
  14. package/dist/events.d.ts.map +1 -1
  15. package/dist/events.js +217 -400
  16. package/dist/files.capability.d.ts +2 -7
  17. package/dist/files.capability.d.ts.map +1 -1
  18. package/dist/files.capability.js +29 -25
  19. package/dist/files.feature.d.ts +1 -7
  20. package/dist/files.feature.d.ts.map +1 -1
  21. package/dist/files.feature.js +50 -131
  22. package/dist/index.d.ts +7 -6
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +1411 -8
  25. package/dist/node/contracts/index.js +576 -0
  26. package/dist/node/docs/files.docblock.js +65 -0
  27. package/dist/node/docs/index.js +65 -0
  28. package/dist/node/entities/index.js +235 -0
  29. package/dist/node/events.js +219 -0
  30. package/dist/node/files.capability.js +28 -0
  31. package/dist/node/files.feature.js +51 -0
  32. package/dist/node/index.js +1410 -0
  33. package/dist/node/storage/index.js +268 -0
  34. package/dist/storage/index.d.ts +163 -166
  35. package/dist/storage/index.d.ts.map +1 -1
  36. package/dist/storage/index.js +266 -266
  37. package/package.json +104 -30
  38. package/dist/contracts/index.js.map +0 -1
  39. package/dist/docs/files.docblock.js.map +0 -1
  40. package/dist/entities/index.js.map +0 -1
  41. package/dist/events.js.map +0 -1
  42. package/dist/files.capability.js.map +0 -1
  43. package/dist/files.feature.js.map +0 -1
  44. package/dist/storage/index.js.map +0 -1
@@ -0,0 +1,268 @@
1
+ // src/storage/index.ts
2
+ import * as fs from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ import * as crypto from "node:crypto";
5
+
6
+ class LocalStorageAdapter {
7
+ provider = "LOCAL";
8
+ basePath;
9
+ baseUrl;
10
+ constructor(options) {
11
+ this.basePath = options.basePath;
12
+ this.baseUrl = options.baseUrl;
13
+ }
14
+ async upload(options) {
15
+ const fullPath = path.join(this.basePath, options.path);
16
+ const dir = path.dirname(fullPath);
17
+ await fs.mkdir(dir, { recursive: true });
18
+ const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
19
+ await fs.writeFile(fullPath, content);
20
+ const checksum = crypto.createHash("sha256").update(content).digest("hex");
21
+ return {
22
+ path: options.path,
23
+ size: content.length,
24
+ mimeType: options.mimeType,
25
+ checksum,
26
+ metadata: options.metadata
27
+ };
28
+ }
29
+ async download(filePath) {
30
+ const fullPath = path.join(this.basePath, filePath);
31
+ return fs.readFile(fullPath);
32
+ }
33
+ async delete(filePath) {
34
+ const fullPath = path.join(this.basePath, filePath);
35
+ await fs.unlink(fullPath);
36
+ }
37
+ async exists(filePath) {
38
+ const fullPath = path.join(this.basePath, filePath);
39
+ try {
40
+ await fs.access(fullPath);
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ async getMetadata(filePath) {
47
+ const fullPath = path.join(this.basePath, filePath);
48
+ try {
49
+ const stat2 = await fs.stat(fullPath);
50
+ return {
51
+ path: filePath,
52
+ size: stat2.size,
53
+ mimeType: "application/octet-stream"
54
+ };
55
+ } catch {
56
+ return null;
57
+ }
58
+ }
59
+ async list(options) {
60
+ const dir = options?.prefix ? path.join(this.basePath, options.prefix) : this.basePath;
61
+ try {
62
+ const entries = await fs.readdir(dir, { withFileTypes: true });
63
+ const files = [];
64
+ for (const entry of entries) {
65
+ if (entry.isFile()) {
66
+ const filePath = options?.prefix ? path.join(options.prefix, entry.name) : entry.name;
67
+ const stat2 = await fs.stat(path.join(dir, entry.name));
68
+ files.push({
69
+ path: filePath,
70
+ size: stat2.size,
71
+ mimeType: "application/octet-stream"
72
+ });
73
+ }
74
+ }
75
+ const limit = options?.limit || files.length;
76
+ return {
77
+ files: files.slice(0, limit),
78
+ hasMore: files.length > limit
79
+ };
80
+ } catch {
81
+ return { files: [], hasMore: false };
82
+ }
83
+ }
84
+ async createPresignedUpload(options) {
85
+ const expiresIn = options.expiresIn || 3600;
86
+ const expiresAt = new Date(Date.now() + expiresIn * 1000);
87
+ return {
88
+ url: this.baseUrl ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}` : `/upload?path=${encodeURIComponent(options.path)}`,
89
+ fields: {
90
+ path: options.path,
91
+ mimeType: options.mimeType
92
+ },
93
+ expiresAt
94
+ };
95
+ }
96
+ async createPresignedDownload(options) {
97
+ const expiresIn = options.expiresIn || 3600;
98
+ const expiresAt = new Date(Date.now() + expiresIn * 1000);
99
+ return {
100
+ url: this.baseUrl ? `${this.baseUrl}/download/${options.path}` : `/download/${options.path}`,
101
+ expiresAt
102
+ };
103
+ }
104
+ getPublicUrl(filePath) {
105
+ if (!this.baseUrl)
106
+ return null;
107
+ return `${this.baseUrl}/${filePath}`;
108
+ }
109
+ async copy(sourcePath, destinationPath) {
110
+ const sourceFullPath = path.join(this.basePath, sourcePath);
111
+ const destFullPath = path.join(this.basePath, destinationPath);
112
+ const destDir = path.dirname(destFullPath);
113
+ await fs.mkdir(destDir, { recursive: true });
114
+ await fs.copyFile(sourceFullPath, destFullPath);
115
+ const stat2 = await fs.stat(destFullPath);
116
+ return {
117
+ path: destinationPath,
118
+ size: stat2.size,
119
+ mimeType: "application/octet-stream"
120
+ };
121
+ }
122
+ }
123
+
124
+ class S3StorageAdapter {
125
+ provider = "S3";
126
+ config;
127
+ constructor(options) {
128
+ this.config = options;
129
+ }
130
+ async upload(_options) {
131
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.");
132
+ }
133
+ async download(_filePath) {
134
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.");
135
+ }
136
+ async delete(_filePath) {
137
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.");
138
+ }
139
+ async exists(_filePath) {
140
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.");
141
+ }
142
+ async getMetadata(_filePath) {
143
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.");
144
+ }
145
+ async list(_options) {
146
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.");
147
+ }
148
+ async createPresignedUpload(_options) {
149
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.");
150
+ }
151
+ async createPresignedDownload(_options) {
152
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.");
153
+ }
154
+ getPublicUrl(filePath) {
155
+ const { bucket, region, endpoint } = this.config;
156
+ if (endpoint) {
157
+ return `${endpoint}/${bucket}/${filePath}`;
158
+ }
159
+ return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;
160
+ }
161
+ async copy(_sourcePath, _destinationPath) {
162
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.");
163
+ }
164
+ }
165
+
166
+ class InMemoryStorageAdapter {
167
+ provider = "LOCAL";
168
+ files = new Map;
169
+ async upload(options) {
170
+ const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
171
+ const checksum = crypto.createHash("sha256").update(content).digest("hex");
172
+ const metadata = {
173
+ path: options.path,
174
+ size: content.length,
175
+ mimeType: options.mimeType,
176
+ checksum,
177
+ metadata: options.metadata
178
+ };
179
+ this.files.set(options.path, { content, metadata });
180
+ return metadata;
181
+ }
182
+ async download(filePath) {
183
+ const file = this.files.get(filePath);
184
+ if (!file) {
185
+ throw new Error(`File not found: ${filePath}`);
186
+ }
187
+ return file.content;
188
+ }
189
+ async delete(filePath) {
190
+ this.files.delete(filePath);
191
+ }
192
+ async exists(filePath) {
193
+ return this.files.has(filePath);
194
+ }
195
+ async getMetadata(filePath) {
196
+ const file = this.files.get(filePath);
197
+ return file?.metadata || null;
198
+ }
199
+ async list(options) {
200
+ const prefix = options?.prefix || "";
201
+ const files = [];
202
+ for (const [path2, file] of this.files) {
203
+ if (path2.startsWith(prefix)) {
204
+ files.push(file.metadata);
205
+ }
206
+ }
207
+ const limit = options?.limit || files.length;
208
+ return {
209
+ files: files.slice(0, limit),
210
+ hasMore: files.length > limit
211
+ };
212
+ }
213
+ async createPresignedUpload(options) {
214
+ const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);
215
+ return {
216
+ url: `/upload?path=${encodeURIComponent(options.path)}`,
217
+ fields: { path: options.path },
218
+ expiresAt
219
+ };
220
+ }
221
+ async createPresignedDownload(options) {
222
+ const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);
223
+ return {
224
+ url: `/download/${options.path}`,
225
+ expiresAt
226
+ };
227
+ }
228
+ getPublicUrl(filePath) {
229
+ return `/files/${filePath}`;
230
+ }
231
+ async copy(sourcePath, destinationPath) {
232
+ const source = this.files.get(sourcePath);
233
+ if (!source) {
234
+ throw new Error(`Source file not found: ${sourcePath}`);
235
+ }
236
+ const metadata = {
237
+ ...source.metadata,
238
+ path: destinationPath
239
+ };
240
+ this.files.set(destinationPath, { content: source.content, metadata });
241
+ return metadata;
242
+ }
243
+ clear() {
244
+ this.files.clear();
245
+ }
246
+ }
247
+ function createStorageAdapter(config) {
248
+ switch (config.provider) {
249
+ case "LOCAL":
250
+ if (!config.local) {
251
+ throw new Error("Local storage configuration required");
252
+ }
253
+ return new LocalStorageAdapter(config.local);
254
+ case "S3":
255
+ if (!config.s3) {
256
+ throw new Error("S3 storage configuration required");
257
+ }
258
+ return new S3StorageAdapter(config.s3);
259
+ default:
260
+ throw new Error(`Unsupported storage provider: ${config.provider}`);
261
+ }
262
+ }
263
+ export {
264
+ createStorageAdapter,
265
+ S3StorageAdapter,
266
+ LocalStorageAdapter,
267
+ InMemoryStorageAdapter
268
+ };
@@ -1,151 +1,150 @@
1
- //#region src/storage/index.d.ts
2
1
  /**
3
2
  * File storage adapters for different backends.
4
3
  */
5
- type StorageProvider = 'LOCAL' | 'S3' | 'GCS' | 'AZURE' | 'CLOUDFLARE';
6
- interface StorageFile {
7
- path: string;
8
- size: number;
9
- mimeType: string;
10
- checksum?: string;
11
- etag?: string;
12
- metadata?: Record<string, string>;
4
+ export type StorageProvider = 'LOCAL' | 'S3' | 'GCS' | 'AZURE' | 'CLOUDFLARE';
5
+ export interface StorageFile {
6
+ path: string;
7
+ size: number;
8
+ mimeType: string;
9
+ checksum?: string;
10
+ etag?: string;
11
+ metadata?: Record<string, string>;
13
12
  }
14
- interface UploadOptions {
15
- /** Target path in storage */
16
- path: string;
17
- /** File content */
18
- content: Buffer | string;
19
- /** MIME type */
20
- mimeType: string;
21
- /** Additional metadata */
22
- metadata?: Record<string, string>;
23
- /** Whether file should be publicly accessible */
24
- isPublic?: boolean;
13
+ export interface UploadOptions {
14
+ /** Target path in storage */
15
+ path: string;
16
+ /** File content */
17
+ content: Buffer | string;
18
+ /** MIME type */
19
+ mimeType: string;
20
+ /** Additional metadata */
21
+ metadata?: Record<string, string>;
22
+ /** Whether file should be publicly accessible */
23
+ isPublic?: boolean;
25
24
  }
26
- interface PresignedUploadOptions {
27
- /** Target path in storage */
28
- path: string;
29
- /** MIME type */
30
- mimeType: string;
31
- /** File size in bytes */
32
- size: number;
33
- /** Expiration time in seconds */
34
- expiresIn?: number;
35
- /** Additional conditions */
36
- conditions?: Record<string, unknown>[];
25
+ export interface PresignedUploadOptions {
26
+ /** Target path in storage */
27
+ path: string;
28
+ /** MIME type */
29
+ mimeType: string;
30
+ /** File size in bytes */
31
+ size: number;
32
+ /** Expiration time in seconds */
33
+ expiresIn?: number;
34
+ /** Additional conditions */
35
+ conditions?: Record<string, unknown>[];
37
36
  }
38
- interface PresignedDownloadOptions {
39
- /** File path in storage */
40
- path: string;
41
- /** Expiration time in seconds */
42
- expiresIn?: number;
43
- /** Response content disposition */
44
- contentDisposition?: string;
37
+ export interface PresignedDownloadOptions {
38
+ /** File path in storage */
39
+ path: string;
40
+ /** Expiration time in seconds */
41
+ expiresIn?: number;
42
+ /** Response content disposition */
43
+ contentDisposition?: string;
45
44
  }
46
- interface PresignedUrl {
47
- url: string;
48
- fields?: Record<string, string>;
49
- expiresAt: Date;
45
+ export interface PresignedUrl {
46
+ url: string;
47
+ fields?: Record<string, string>;
48
+ expiresAt: Date;
50
49
  }
51
- interface ListOptions {
52
- /** Path prefix */
53
- prefix?: string;
54
- /** Maximum results */
55
- limit?: number;
56
- /** Continuation token */
57
- cursor?: string;
50
+ export interface ListOptions {
51
+ /** Path prefix */
52
+ prefix?: string;
53
+ /** Maximum results */
54
+ limit?: number;
55
+ /** Continuation token */
56
+ cursor?: string;
58
57
  }
59
- interface ListResult {
60
- files: StorageFile[];
61
- cursor?: string;
62
- hasMore: boolean;
58
+ export interface ListResult {
59
+ files: StorageFile[];
60
+ cursor?: string;
61
+ hasMore: boolean;
63
62
  }
64
- interface StorageAdapter {
65
- /** Storage provider type */
66
- readonly provider: StorageProvider;
67
- /**
68
- * Upload a file to storage.
69
- */
70
- upload(options: UploadOptions): Promise<StorageFile>;
71
- /**
72
- * Download a file from storage.
73
- */
74
- download(path: string): Promise<Buffer>;
75
- /**
76
- * Delete a file from storage.
77
- */
78
- delete(path: string): Promise<void>;
79
- /**
80
- * Check if a file exists.
81
- */
82
- exists(path: string): Promise<boolean>;
83
- /**
84
- * Get file metadata.
85
- */
86
- getMetadata(path: string): Promise<StorageFile | null>;
87
- /**
88
- * List files in a directory.
89
- */
90
- list(options?: ListOptions): Promise<ListResult>;
91
- /**
92
- * Generate a presigned URL for uploading.
93
- */
94
- createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
95
- /**
96
- * Generate a presigned URL for downloading.
97
- */
98
- createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
99
- /**
100
- * Get public URL for a file (if applicable).
101
- */
102
- getPublicUrl(path: string): string | null;
103
- /**
104
- * Copy a file within storage.
105
- */
106
- copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
63
+ export interface StorageAdapter {
64
+ /** Storage provider type */
65
+ readonly provider: StorageProvider;
66
+ /**
67
+ * Upload a file to storage.
68
+ */
69
+ upload(options: UploadOptions): Promise<StorageFile>;
70
+ /**
71
+ * Download a file from storage.
72
+ */
73
+ download(path: string): Promise<Buffer>;
74
+ /**
75
+ * Delete a file from storage.
76
+ */
77
+ delete(path: string): Promise<void>;
78
+ /**
79
+ * Check if a file exists.
80
+ */
81
+ exists(path: string): Promise<boolean>;
82
+ /**
83
+ * Get file metadata.
84
+ */
85
+ getMetadata(path: string): Promise<StorageFile | null>;
86
+ /**
87
+ * List files in a directory.
88
+ */
89
+ list(options?: ListOptions): Promise<ListResult>;
90
+ /**
91
+ * Generate a presigned URL for uploading.
92
+ */
93
+ createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
94
+ /**
95
+ * Generate a presigned URL for downloading.
96
+ */
97
+ createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
98
+ /**
99
+ * Get public URL for a file (if applicable).
100
+ */
101
+ getPublicUrl(path: string): string | null;
102
+ /**
103
+ * Copy a file within storage.
104
+ */
105
+ copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
107
106
  }
108
- interface LocalStorageOptions {
109
- /** Base directory for file storage */
110
- basePath: string;
111
- /** Base URL for serving files (optional) */
112
- baseUrl?: string;
107
+ export interface LocalStorageOptions {
108
+ /** Base directory for file storage */
109
+ basePath: string;
110
+ /** Base URL for serving files (optional) */
111
+ baseUrl?: string;
113
112
  }
114
113
  /**
115
114
  * Local filesystem storage adapter.
116
115
  * For development and testing purposes.
117
116
  */
118
- declare class LocalStorageAdapter implements StorageAdapter {
119
- readonly provider: StorageProvider;
120
- private basePath;
121
- private baseUrl?;
122
- constructor(options: LocalStorageOptions);
123
- upload(options: UploadOptions): Promise<StorageFile>;
124
- download(filePath: string): Promise<Buffer>;
125
- delete(filePath: string): Promise<void>;
126
- exists(filePath: string): Promise<boolean>;
127
- getMetadata(filePath: string): Promise<StorageFile | null>;
128
- list(options?: ListOptions): Promise<ListResult>;
129
- createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
130
- createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
131
- getPublicUrl(filePath: string): string | null;
132
- copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
117
+ export declare class LocalStorageAdapter implements StorageAdapter {
118
+ readonly provider: StorageProvider;
119
+ private basePath;
120
+ private baseUrl?;
121
+ constructor(options: LocalStorageOptions);
122
+ upload(options: UploadOptions): Promise<StorageFile>;
123
+ download(filePath: string): Promise<Buffer>;
124
+ delete(filePath: string): Promise<void>;
125
+ exists(filePath: string): Promise<boolean>;
126
+ getMetadata(filePath: string): Promise<StorageFile | null>;
127
+ list(options?: ListOptions): Promise<ListResult>;
128
+ createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
129
+ createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
130
+ getPublicUrl(filePath: string): string | null;
131
+ copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
133
132
  }
134
- interface S3StorageOptions {
135
- /** S3 bucket name */
136
- bucket: string;
137
- /** AWS region */
138
- region: string;
139
- /** AWS access key ID */
140
- accessKeyId?: string;
141
- /** AWS secret access key */
142
- secretAccessKey?: string;
143
- /** Endpoint URL (for S3-compatible services) */
144
- endpoint?: string;
145
- /** Force path style (for S3-compatible services) */
146
- forcePathStyle?: boolean;
147
- /** Default ACL for uploads */
148
- defaultAcl?: 'private' | 'public-read';
133
+ export interface S3StorageOptions {
134
+ /** S3 bucket name */
135
+ bucket: string;
136
+ /** AWS region */
137
+ region: string;
138
+ /** AWS access key ID */
139
+ accessKeyId?: string;
140
+ /** AWS secret access key */
141
+ secretAccessKey?: string;
142
+ /** Endpoint URL (for S3-compatible services) */
143
+ endpoint?: string;
144
+ /** Force path style (for S3-compatible services) */
145
+ forcePathStyle?: boolean;
146
+ /** Default ACL for uploads */
147
+ defaultAcl?: 'private' | 'public-read';
149
148
  }
150
149
  /**
151
150
  * S3 storage adapter interface.
@@ -154,48 +153,46 @@ interface S3StorageOptions {
154
153
  * This is a placeholder that defines the interface.
155
154
  * Actual implementation would require @aws-sdk/client-s3 dependency.
156
155
  */
157
- declare class S3StorageAdapter implements StorageAdapter {
158
- readonly provider: StorageProvider;
159
- private config;
160
- constructor(options: S3StorageOptions);
161
- upload(_options: UploadOptions): Promise<StorageFile>;
162
- download(_filePath: string): Promise<Buffer>;
163
- delete(_filePath: string): Promise<void>;
164
- exists(_filePath: string): Promise<boolean>;
165
- getMetadata(_filePath: string): Promise<StorageFile | null>;
166
- list(_options?: ListOptions): Promise<ListResult>;
167
- createPresignedUpload(_options: PresignedUploadOptions): Promise<PresignedUrl>;
168
- createPresignedDownload(_options: PresignedDownloadOptions): Promise<PresignedUrl>;
169
- getPublicUrl(filePath: string): string | null;
170
- copy(_sourcePath: string, _destinationPath: string): Promise<StorageFile>;
156
+ export declare class S3StorageAdapter implements StorageAdapter {
157
+ readonly provider: StorageProvider;
158
+ private config;
159
+ constructor(options: S3StorageOptions);
160
+ upload(_options: UploadOptions): Promise<StorageFile>;
161
+ download(_filePath: string): Promise<Buffer>;
162
+ delete(_filePath: string): Promise<void>;
163
+ exists(_filePath: string): Promise<boolean>;
164
+ getMetadata(_filePath: string): Promise<StorageFile | null>;
165
+ list(_options?: ListOptions): Promise<ListResult>;
166
+ createPresignedUpload(_options: PresignedUploadOptions): Promise<PresignedUrl>;
167
+ createPresignedDownload(_options: PresignedDownloadOptions): Promise<PresignedUrl>;
168
+ getPublicUrl(filePath: string): string | null;
169
+ copy(_sourcePath: string, _destinationPath: string): Promise<StorageFile>;
171
170
  }
172
171
  /**
173
172
  * In-memory storage adapter for testing.
174
173
  */
175
- declare class InMemoryStorageAdapter implements StorageAdapter {
176
- readonly provider: StorageProvider;
177
- private files;
178
- upload(options: UploadOptions): Promise<StorageFile>;
179
- download(filePath: string): Promise<Buffer>;
180
- delete(filePath: string): Promise<void>;
181
- exists(filePath: string): Promise<boolean>;
182
- getMetadata(filePath: string): Promise<StorageFile | null>;
183
- list(options?: ListOptions): Promise<ListResult>;
184
- createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
185
- createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
186
- getPublicUrl(filePath: string): string | null;
187
- copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
188
- clear(): void;
174
+ export declare class InMemoryStorageAdapter implements StorageAdapter {
175
+ readonly provider: StorageProvider;
176
+ private files;
177
+ upload(options: UploadOptions): Promise<StorageFile>;
178
+ download(filePath: string): Promise<Buffer>;
179
+ delete(filePath: string): Promise<void>;
180
+ exists(filePath: string): Promise<boolean>;
181
+ getMetadata(filePath: string): Promise<StorageFile | null>;
182
+ list(options?: ListOptions): Promise<ListResult>;
183
+ createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;
184
+ createPresignedDownload(options: PresignedDownloadOptions): Promise<PresignedUrl>;
185
+ getPublicUrl(filePath: string): string | null;
186
+ copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;
187
+ clear(): void;
189
188
  }
190
- interface StorageConfig {
191
- provider: StorageProvider;
192
- local?: LocalStorageOptions;
193
- s3?: S3StorageOptions;
189
+ export interface StorageConfig {
190
+ provider: StorageProvider;
191
+ local?: LocalStorageOptions;
192
+ s3?: S3StorageOptions;
194
193
  }
195
194
  /**
196
195
  * Create a storage adapter based on configuration.
197
196
  */
198
- declare function createStorageAdapter(config: StorageConfig): StorageAdapter;
199
- //#endregion
200
- export { InMemoryStorageAdapter, ListOptions, ListResult, LocalStorageAdapter, LocalStorageOptions, PresignedDownloadOptions, PresignedUploadOptions, PresignedUrl, S3StorageAdapter, S3StorageOptions, StorageAdapter, StorageConfig, StorageFile, StorageProvider, UploadOptions, createStorageAdapter };
197
+ export declare function createStorageAdapter(config: StorageConfig): StorageAdapter;
201
198
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/storage/index.ts"],"sourcesContent":[],"mappings":";;AAMA;AAEA;AASiB,KAXL,eAAA,GAWkB,OAInB,GAIE,IAAA,GAAM,KAAA,GAAA,OAAA,GAAA,YAAA;AAKF,UAtBA,WAAA,CAsBsB;EAatB,IAAA,EAAA,MAAA;EASA,IAAA,EAAA,MAAA;EAMA,QAAA,EAAA,MAAW;EASX,QAAA,CAAA,EAAA,MAAU;EAQV,IAAA,CAAA,EAAA,MAAA;EAEI,QAAA,CAAA,EA/DR,MA+DQ,CAAA,MAAA,EAAA,MAAA,CAAA;;AAKqB,UAjEzB,aAAA,CAiEyB;EAAR;EAKA,IAAA,EAAA,MAAA;EAAR;EAKF,OAAA,EAvEb,MAuEa,GAAA,MAAA;EAKA;EAKa,QAAA,EAAA,MAAA;EAAR;EAKZ,QAAA,CAAA,EAlFJ,MAkFI,CAAA,MAAA,EAAA,MAAA,CAAA;EAAsB;EAAR,QAAA,CAAA,EAAA,OAAA;;AAKmC,UAlFjD,sBAAA,CAkFiD;EAAR;EAM7C,IAAA,EAAA,MAAA;EACA;EAAR,QAAA,EAAA,MAAA;EAUwD;EAAR,IAAA,EAAA,MAAA;EAAO;EAS3C,SAAA,CAAA,EAAA,MAAA;EAWJ;EACQ,UAAA,CAAA,EA9GN,MA8GM,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA;;AASG,UApHP,wBAAA,CAoHO;EAAwB;EAAR,IAAA,EAAA,MAAA;EA2BI;EAAR,SAAA,CAAA,EAAA,MAAA;EAKF;EAKA,kBAAA,CAAA,EAAA,MAAA;;AAUK,UA1JtB,Y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