@contractspec/lib.files 1.44.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,201 @@
1
+ //#region src/storage/index.d.ts
2
+ /**
3
+ * File storage adapters for different backends.
4
+ */
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>;
13
+ }
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;
25
+ }
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>[];
37
+ }
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;
45
+ }
46
+ interface PresignedUrl {
47
+ url: string;
48
+ fields?: Record<string, string>;
49
+ expiresAt: Date;
50
+ }
51
+ interface ListOptions {
52
+ /** Path prefix */
53
+ prefix?: string;
54
+ /** Maximum results */
55
+ limit?: number;
56
+ /** Continuation token */
57
+ cursor?: string;
58
+ }
59
+ interface ListResult {
60
+ files: StorageFile[];
61
+ cursor?: string;
62
+ hasMore: boolean;
63
+ }
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>;
107
+ }
108
+ interface LocalStorageOptions {
109
+ /** Base directory for file storage */
110
+ basePath: string;
111
+ /** Base URL for serving files (optional) */
112
+ baseUrl?: string;
113
+ }
114
+ /**
115
+ * Local filesystem storage adapter.
116
+ * For development and testing purposes.
117
+ */
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>;
133
+ }
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';
149
+ }
150
+ /**
151
+ * S3 storage adapter interface.
152
+ * Implementation would use AWS SDK or compatible client.
153
+ *
154
+ * This is a placeholder that defines the interface.
155
+ * Actual implementation would require @aws-sdk/client-s3 dependency.
156
+ */
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>;
171
+ }
172
+ /**
173
+ * In-memory storage adapter for testing.
174
+ */
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;
189
+ }
190
+ interface StorageConfig {
191
+ provider: StorageProvider;
192
+ local?: LocalStorageOptions;
193
+ s3?: S3StorageOptions;
194
+ }
195
+ /**
196
+ * Create a storage adapter based on configuration.
197
+ */
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 };
201
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;EAM7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AsBI,aAAA;YACL;UACF;OACH;;;;;iBAMS,oBAAA,SAA6B,gBAAgB"}
@@ -0,0 +1,269 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as path from "node:path";
3
+ import * as crypto from "node:crypto";
4
+
5
+ //#region src/storage/index.ts
6
+ /**
7
+ * Local filesystem storage adapter.
8
+ * For development and testing purposes.
9
+ */
10
+ var LocalStorageAdapter = class {
11
+ provider = "LOCAL";
12
+ basePath;
13
+ baseUrl;
14
+ constructor(options) {
15
+ this.basePath = options.basePath;
16
+ this.baseUrl = options.baseUrl;
17
+ }
18
+ async upload(options) {
19
+ const fullPath = path.join(this.basePath, options.path);
20
+ const dir = path.dirname(fullPath);
21
+ await fs.mkdir(dir, { recursive: true });
22
+ const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
23
+ await fs.writeFile(fullPath, content);
24
+ const checksum = crypto.createHash("sha256").update(content).digest("hex");
25
+ return {
26
+ path: options.path,
27
+ size: content.length,
28
+ mimeType: options.mimeType,
29
+ checksum,
30
+ metadata: options.metadata
31
+ };
32
+ }
33
+ async download(filePath) {
34
+ const fullPath = path.join(this.basePath, filePath);
35
+ return fs.readFile(fullPath);
36
+ }
37
+ async delete(filePath) {
38
+ const fullPath = path.join(this.basePath, filePath);
39
+ await fs.unlink(fullPath);
40
+ }
41
+ async exists(filePath) {
42
+ const fullPath = path.join(this.basePath, filePath);
43
+ try {
44
+ await fs.access(fullPath);
45
+ return true;
46
+ } catch {
47
+ return false;
48
+ }
49
+ }
50
+ async getMetadata(filePath) {
51
+ const fullPath = path.join(this.basePath, filePath);
52
+ try {
53
+ return {
54
+ path: filePath,
55
+ size: (await fs.stat(fullPath)).size,
56
+ mimeType: "application/octet-stream"
57
+ };
58
+ } catch {
59
+ return null;
60
+ }
61
+ }
62
+ async list(options) {
63
+ const dir = options?.prefix ? path.join(this.basePath, options.prefix) : this.basePath;
64
+ try {
65
+ const entries = await fs.readdir(dir, { withFileTypes: true });
66
+ const files = [];
67
+ for (const entry of entries) if (entry.isFile()) {
68
+ const filePath = options?.prefix ? path.join(options.prefix, entry.name) : entry.name;
69
+ const stat = await fs.stat(path.join(dir, entry.name));
70
+ files.push({
71
+ path: filePath,
72
+ size: stat.size,
73
+ mimeType: "application/octet-stream"
74
+ });
75
+ }
76
+ const limit = options?.limit || files.length;
77
+ return {
78
+ files: files.slice(0, limit),
79
+ hasMore: files.length > limit
80
+ };
81
+ } catch {
82
+ return {
83
+ files: [],
84
+ hasMore: false
85
+ };
86
+ }
87
+ }
88
+ async createPresignedUpload(options) {
89
+ const expiresIn = options.expiresIn || 3600;
90
+ const expiresAt = new Date(Date.now() + expiresIn * 1e3);
91
+ return {
92
+ url: this.baseUrl ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}` : `/upload?path=${encodeURIComponent(options.path)}`,
93
+ fields: {
94
+ path: options.path,
95
+ mimeType: options.mimeType
96
+ },
97
+ expiresAt
98
+ };
99
+ }
100
+ async createPresignedDownload(options) {
101
+ const expiresIn = options.expiresIn || 3600;
102
+ const expiresAt = new Date(Date.now() + expiresIn * 1e3);
103
+ return {
104
+ url: this.baseUrl ? `${this.baseUrl}/download/${options.path}` : `/download/${options.path}`,
105
+ expiresAt
106
+ };
107
+ }
108
+ getPublicUrl(filePath) {
109
+ if (!this.baseUrl) return null;
110
+ return `${this.baseUrl}/${filePath}`;
111
+ }
112
+ async copy(sourcePath, destinationPath) {
113
+ const sourceFullPath = path.join(this.basePath, sourcePath);
114
+ const destFullPath = path.join(this.basePath, destinationPath);
115
+ const destDir = path.dirname(destFullPath);
116
+ await fs.mkdir(destDir, { recursive: true });
117
+ await fs.copyFile(sourceFullPath, destFullPath);
118
+ return {
119
+ path: destinationPath,
120
+ size: (await fs.stat(destFullPath)).size,
121
+ mimeType: "application/octet-stream"
122
+ };
123
+ }
124
+ };
125
+ /**
126
+ * S3 storage adapter interface.
127
+ * Implementation would use AWS SDK or compatible client.
128
+ *
129
+ * This is a placeholder that defines the interface.
130
+ * Actual implementation would require @aws-sdk/client-s3 dependency.
131
+ */
132
+ var S3StorageAdapter = class {
133
+ provider = "S3";
134
+ config;
135
+ constructor(options) {
136
+ this.config = options;
137
+ }
138
+ async upload(_options) {
139
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.");
140
+ }
141
+ async download(_filePath) {
142
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.");
143
+ }
144
+ async delete(_filePath) {
145
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.");
146
+ }
147
+ async exists(_filePath) {
148
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.");
149
+ }
150
+ async getMetadata(_filePath) {
151
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.");
152
+ }
153
+ async list(_options) {
154
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.");
155
+ }
156
+ async createPresignedUpload(_options) {
157
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.");
158
+ }
159
+ async createPresignedDownload(_options) {
160
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.");
161
+ }
162
+ getPublicUrl(filePath) {
163
+ const { bucket, region, endpoint } = this.config;
164
+ if (endpoint) return `${endpoint}/${bucket}/${filePath}`;
165
+ return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;
166
+ }
167
+ async copy(_sourcePath, _destinationPath) {
168
+ throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.");
169
+ }
170
+ };
171
+ /**
172
+ * In-memory storage adapter for testing.
173
+ */
174
+ var InMemoryStorageAdapter = class {
175
+ provider = "LOCAL";
176
+ files = /* @__PURE__ */ new Map();
177
+ async upload(options) {
178
+ const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
179
+ const checksum = crypto.createHash("sha256").update(content).digest("hex");
180
+ const metadata = {
181
+ path: options.path,
182
+ size: content.length,
183
+ mimeType: options.mimeType,
184
+ checksum,
185
+ metadata: options.metadata
186
+ };
187
+ this.files.set(options.path, {
188
+ content,
189
+ metadata
190
+ });
191
+ return metadata;
192
+ }
193
+ async download(filePath) {
194
+ const file = this.files.get(filePath);
195
+ if (!file) throw new Error(`File not found: ${filePath}`);
196
+ return file.content;
197
+ }
198
+ async delete(filePath) {
199
+ this.files.delete(filePath);
200
+ }
201
+ async exists(filePath) {
202
+ return this.files.has(filePath);
203
+ }
204
+ async getMetadata(filePath) {
205
+ return this.files.get(filePath)?.metadata || null;
206
+ }
207
+ async list(options) {
208
+ const prefix = options?.prefix || "";
209
+ const files = [];
210
+ for (const [path$1, file] of this.files) if (path$1.startsWith(prefix)) files.push(file.metadata);
211
+ const limit = options?.limit || files.length;
212
+ return {
213
+ files: files.slice(0, limit),
214
+ hasMore: files.length > limit
215
+ };
216
+ }
217
+ async createPresignedUpload(options) {
218
+ const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1e3);
219
+ return {
220
+ url: `/upload?path=${encodeURIComponent(options.path)}`,
221
+ fields: { path: options.path },
222
+ expiresAt
223
+ };
224
+ }
225
+ async createPresignedDownload(options) {
226
+ const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1e3);
227
+ return {
228
+ url: `/download/${options.path}`,
229
+ expiresAt
230
+ };
231
+ }
232
+ getPublicUrl(filePath) {
233
+ return `/files/${filePath}`;
234
+ }
235
+ async copy(sourcePath, destinationPath) {
236
+ const source = this.files.get(sourcePath);
237
+ if (!source) throw new Error(`Source file not found: ${sourcePath}`);
238
+ const metadata = {
239
+ ...source.metadata,
240
+ path: destinationPath
241
+ };
242
+ this.files.set(destinationPath, {
243
+ content: source.content,
244
+ metadata
245
+ });
246
+ return metadata;
247
+ }
248
+ clear() {
249
+ this.files.clear();
250
+ }
251
+ };
252
+ /**
253
+ * Create a storage adapter based on configuration.
254
+ */
255
+ function createStorageAdapter(config) {
256
+ switch (config.provider) {
257
+ case "LOCAL":
258
+ if (!config.local) throw new Error("Local storage configuration required");
259
+ return new LocalStorageAdapter(config.local);
260
+ case "S3":
261
+ if (!config.s3) throw new Error("S3 storage configuration required");
262
+ return new S3StorageAdapter(config.s3);
263
+ default: throw new Error(`Unsupported storage provider: ${config.provider}`);
264
+ }
265
+ }
266
+
267
+ //#endregion
268
+ export { InMemoryStorageAdapter, LocalStorageAdapter, S3StorageAdapter, createStorageAdapter };
269
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["files: StorageFile[]","metadata: StorageFile","path"],"sources":["../../src/storage/index.ts"],"sourcesContent":["/**\n * File storage adapters for different backends.\n */\n\n// ============ Types ============\n\nexport type StorageProvider = 'LOCAL' | 'S3' | 'GCS' | 'AZURE' | 'CLOUDFLARE';\n\nexport interface StorageFile {\n path: string;\n size: number;\n mimeType: string;\n checksum?: string;\n etag?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface UploadOptions {\n /** Target path in storage */\n path: string;\n /** File content */\n content: Buffer | string;\n /** MIME type */\n mimeType: string;\n /** Additional metadata */\n metadata?: Record<string, string>;\n /** Whether file should be publicly accessible */\n isPublic?: boolean;\n}\n\nexport interface PresignedUploadOptions {\n /** Target path in storage */\n path: string;\n /** MIME type */\n mimeType: string;\n /** File size in bytes */\n size: number;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Additional conditions */\n conditions?: Record<string, unknown>[];\n}\n\nexport interface PresignedDownloadOptions {\n /** File path in storage */\n path: string;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Response content disposition */\n contentDisposition?: string;\n}\n\nexport interface PresignedUrl {\n url: string;\n fields?: Record<string, string>;\n expiresAt: Date;\n}\n\nexport interface ListOptions {\n /** Path prefix */\n prefix?: string;\n /** Maximum results */\n limit?: number;\n /** Continuation token */\n cursor?: string;\n}\n\nexport interface ListResult {\n files: StorageFile[];\n cursor?: string;\n hasMore: boolean;\n}\n\n// ============ Storage Adapter Interface ============\n\nexport interface StorageAdapter {\n /** Storage provider type */\n readonly provider: StorageProvider;\n\n /**\n * Upload a file to storage.\n */\n upload(options: UploadOptions): Promise<StorageFile>;\n\n /**\n * Download a file from storage.\n */\n download(path: string): Promise<Buffer>;\n\n /**\n * Delete a file from storage.\n */\n delete(path: string): Promise<void>;\n\n /**\n * Check if a file exists.\n */\n exists(path: string): Promise<boolean>;\n\n /**\n * Get file metadata.\n */\n getMetadata(path: string): Promise<StorageFile | null>;\n\n /**\n * List files in a directory.\n */\n list(options?: ListOptions): Promise<ListResult>;\n\n /**\n * Generate a presigned URL for uploading.\n */\n createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;\n\n /**\n * Generate a presigned URL for downloading.\n */\n createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl>;\n\n /**\n * Get public URL for a file (if applicable).\n */\n getPublicUrl(path: string): string | null;\n\n /**\n * Copy a file within storage.\n */\n copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;\n}\n\n// ============ Local Storage Adapter ============\n\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\n\nexport interface LocalStorageOptions {\n /** Base directory for file storage */\n basePath: string;\n /** Base URL for serving files (optional) */\n baseUrl?: string;\n}\n\n/**\n * Local filesystem storage adapter.\n * For development and testing purposes.\n */\nexport class LocalStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private basePath: string;\n private baseUrl?: string;\n\n constructor(options: LocalStorageOptions) {\n this.basePath = options.basePath;\n this.baseUrl = options.baseUrl;\n }\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const fullPath = path.join(this.basePath, options.path);\n const dir = path.dirname(fullPath);\n\n // Ensure directory exists\n await fs.mkdir(dir, { recursive: true });\n\n // Write file\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n await fs.writeFile(fullPath, content);\n\n // Calculate checksum\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n return {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n }\n\n async download(filePath: string): Promise<Buffer> {\n const fullPath = path.join(this.basePath, filePath);\n return fs.readFile(fullPath);\n }\n\n async delete(filePath: string): Promise<void> {\n const fullPath = path.join(this.basePath, filePath);\n await fs.unlink(fullPath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n await fs.access(fullPath);\n return true;\n } catch {\n return false;\n }\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n const stat = await fs.stat(fullPath);\n return {\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream', // Would need mime type detection\n };\n } catch {\n return null;\n }\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const dir = options?.prefix\n ? path.join(this.basePath, options.prefix)\n : this.basePath;\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n const files: StorageFile[] = [];\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const filePath = options?.prefix\n ? path.join(options.prefix, entry.name)\n : entry.name;\n const stat = await fs.stat(path.join(dir, entry.name));\n files.push({\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n });\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n } catch {\n return { files: [], hasMore: false };\n }\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n // Local storage doesn't support real presigned URLs\n // Return a placeholder that would work with a local upload endpoint\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}`\n : `/upload?path=${encodeURIComponent(options.path)}`,\n fields: {\n path: options.path,\n mimeType: options.mimeType,\n },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/download/${options.path}`\n : `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n if (!this.baseUrl) return null;\n return `${this.baseUrl}/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const sourceFullPath = path.join(this.basePath, sourcePath);\n const destFullPath = path.join(this.basePath, destinationPath);\n const destDir = path.dirname(destFullPath);\n\n await fs.mkdir(destDir, { recursive: true });\n await fs.copyFile(sourceFullPath, destFullPath);\n\n const stat = await fs.stat(destFullPath);\n return {\n path: destinationPath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n };\n }\n}\n\n// ============ S3 Storage Adapter Interface ============\n\nexport interface S3StorageOptions {\n /** S3 bucket name */\n bucket: string;\n /** AWS region */\n region: string;\n /** AWS access key ID */\n accessKeyId?: string;\n /** AWS secret access key */\n secretAccessKey?: string;\n /** Endpoint URL (for S3-compatible services) */\n endpoint?: string;\n /** Force path style (for S3-compatible services) */\n forcePathStyle?: boolean;\n /** Default ACL for uploads */\n defaultAcl?: 'private' | 'public-read';\n}\n\n/**\n * S3 storage adapter interface.\n * Implementation would use AWS SDK or compatible client.\n *\n * This is a placeholder that defines the interface.\n * Actual implementation would require @aws-sdk/client-s3 dependency.\n */\nexport class S3StorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'S3';\n private config: S3StorageOptions;\n\n constructor(options: S3StorageOptions) {\n this.config = options;\n }\n\n async upload(_options: UploadOptions): Promise<StorageFile> {\n // Placeholder - actual implementation would use S3 SDK\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.'\n );\n }\n\n async download(_filePath: string): Promise<Buffer> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.'\n );\n }\n\n async delete(_filePath: string): Promise<void> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.'\n );\n }\n\n async exists(_filePath: string): Promise<boolean> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.'\n );\n }\n\n async getMetadata(_filePath: string): Promise<StorageFile | null> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.'\n );\n }\n\n async list(_options?: ListOptions): Promise<ListResult> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.'\n );\n }\n\n async createPresignedUpload(\n _options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.'\n );\n }\n\n async createPresignedDownload(\n _options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.'\n );\n }\n\n getPublicUrl(filePath: string): string | null {\n const { bucket, region, endpoint } = this.config;\n if (endpoint) {\n return `${endpoint}/${bucket}/${filePath}`;\n }\n return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;\n }\n\n async copy(\n _sourcePath: string,\n _destinationPath: string\n ): Promise<StorageFile> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.'\n );\n }\n}\n\n// ============ In-Memory Storage Adapter ============\n\n/**\n * In-memory storage adapter for testing.\n */\nexport class InMemoryStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private files = new Map<string, { content: Buffer; metadata: StorageFile }>();\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n const metadata: StorageFile = {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n\n this.files.set(options.path, { content, metadata });\n return metadata;\n }\n\n async download(filePath: string): Promise<Buffer> {\n const file = this.files.get(filePath);\n if (!file) {\n throw new Error(`File not found: ${filePath}`);\n }\n return file.content;\n }\n\n async delete(filePath: string): Promise<void> {\n this.files.delete(filePath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n return this.files.has(filePath);\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const file = this.files.get(filePath);\n return file?.metadata || null;\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const prefix = options?.prefix || '';\n const files: StorageFile[] = [];\n\n for (const [path, file] of this.files) {\n if (path.startsWith(prefix)) {\n files.push(file.metadata);\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/upload?path=${encodeURIComponent(options.path)}`,\n fields: { path: options.path },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n return `/files/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const source = this.files.get(sourcePath);\n if (!source) {\n throw new Error(`Source file not found: ${sourcePath}`);\n }\n\n const metadata: StorageFile = {\n ...source.metadata,\n path: destinationPath,\n };\n\n this.files.set(destinationPath, { content: source.content, metadata });\n return metadata;\n }\n\n clear(): void {\n this.files.clear();\n }\n}\n\n// ============ Factory ============\n\nexport interface StorageConfig {\n provider: StorageProvider;\n local?: LocalStorageOptions;\n s3?: S3StorageOptions;\n}\n\n/**\n * Create a storage adapter based on configuration.\n */\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n switch (config.provider) {\n case 'LOCAL':\n if (!config.local) {\n throw new Error('Local storage configuration required');\n }\n return new LocalStorageAdapter(config.local);\n\n case 'S3':\n if (!config.s3) {\n throw new Error('S3 storage configuration required');\n }\n return new S3StorageAdapter(config.s3);\n\n default:\n throw new Error(`Unsupported storage provider: ${config.provider}`);\n }\n}\n"],"mappings":";;;;;;;;;AAqJA,IAAa,sBAAb,MAA2D;CACzD,AAAS,WAA4B;CACrC,AAAQ;CACR,AAAQ;CAER,YAAY,SAA8B;AACxC,OAAK,WAAW,QAAQ;AACxB,OAAK,UAAU,QAAQ;;CAGzB,MAAM,OAAO,SAA8C;EACzD,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,QAAQ,KAAK;EACvD,MAAM,MAAM,KAAK,QAAQ,SAAS;AAGlC,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;EAGxC,MAAM,UACJ,OAAO,QAAQ,YAAY,WACvB,OAAO,KAAK,QAAQ,SAAS,SAAS,GACtC,QAAQ;AAEd,QAAM,GAAG,UAAU,UAAU,QAAQ;EAGrC,MAAM,WAAW,OAAO,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM;AAE1E,SAAO;GACL,MAAM,QAAQ;GACd,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB;GACA,UAAU,QAAQ;GACnB;;CAGH,MAAM,SAAS,UAAmC;EAChD,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,SAAS;AACnD,SAAO,GAAG,SAAS,SAAS;;CAG9B,MAAM,OAAO,UAAiC;EAC5C,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,SAAS;AACnD,QAAM,GAAG,OAAO,SAAS;;CAG3B,MAAM,OAAO,UAAoC;EAC/C,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,SAAS;AACnD,MAAI;AACF,SAAM,GAAG,OAAO,SAAS;AACzB,UAAO;UACD;AACN,U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;CAGH,MAAM,sBACJ,SACuB;EACvB,MAAM,YAAY,IAAI,KAAK,KAAK,KAAK,IAAI,QAAQ,aAAa,QAAQ,IAAK;AAC3E,SAAO;GACL,KAAK,gBAAgB,mBAAmB,QAAQ,KAAK;GACrD,QAAQ,EAAE,MAAM,QAAQ,MAAM;GAC9B;GACD;;CAGH,MAAM,wBACJ,SACuB;EACvB,MAAM,YAAY,IAAI,KAAK,KAAK,KAAK,IAAI,QAAQ,aAAa,QAAQ,IAAK;AAC3E,SAAO;GACL,KAAK,aAAa,QAAQ;GAC1B;GACD;;CAGH,aAAa,UAAiC;AAC5C,SAAO,UAAU;;CAGnB,MAAM,KACJ,YACA,iBACsB;EACtB,MAAM,SAAS,KAAK,MAAM,IAAI,WAAW;AACzC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,0BAA0B,aAAa;EAGzD,MAAMD,WAAwB;GAC5B,GAAG,OAAO;GACV,MAAM;GACP;AAED,OAAK,MAAM,IAAI,iBAAiB;GAAE,SAAS,OAAO;GAAS;GAAU,CAAC;AACtE,SAAO;;CAGT,QAAc;AACZ,OAAK,MAAM,OAAO;;;;;;AAetB,SAAgB,qBAAqB,QAAuC;AAC1E,SAAQ,OAAO,UAAf;EACE,KAAK;AACH,OAAI,CAAC,OAAO,MACV,OAAM,IAAI,MAAM,uCAAuC;AAEzD,UAAO,IAAI,oBAAoB,OAAO,MAAM;EAE9C,KAAK;AACH,OAAI,CAAC,OAAO,GACV,OAAM,IAAI,MAAM,oCAAoC;AAEtD,UAAO,IAAI,iBAAiB,OAAO,GAAG;EAExC,QACE,OAAM,IAAI,MAAM,iCAAiC,OAAO,WAAW"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@contractspec/lib.files",
3
+ "version": "1.44.0",
4
+ "description": "Files, documents and attachments module for ContractSpec applications",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
10
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
11
+ "build": "bun build:types && bun build:bundle",
12
+ "build:bundle": "tsdown",
13
+ "build:types": "tsc --noEmit",
14
+ "dev": "bun build:bundle --watch",
15
+ "clean": "rimraf dist .turbo",
16
+ "lint": "bun lint:fix",
17
+ "lint:fix": "eslint src --fix",
18
+ "lint:check": "eslint src"
19
+ },
20
+ "dependencies": {
21
+ "@contractspec/lib.schema": "1.44.0",
22
+ "@contractspec/lib.contracts": "1.44.0",
23
+ "zod": "^4.1.13"
24
+ },
25
+ "devDependencies": {
26
+ "@contractspec/tool.typescript": "1.44.0",
27
+ "@contractspec/tool.tsdown": "1.44.0",
28
+ "typescript": "^5.9.3"
29
+ },
30
+ "exports": {
31
+ ".": "./dist/index.js",
32
+ "./contracts": "./dist/contracts/index.js",
33
+ "./docs": "./dist/docs/index.js",
34
+ "./docs/files.docblock": "./dist/docs/files.docblock.js",
35
+ "./entities": "./dist/entities/index.js",
36
+ "./events": "./dist/events.js",
37
+ "./files.feature": "./dist/files.feature.js",
38
+ "./storage": "./dist/storage/index.js",
39
+ "./*": "./*"
40
+ },
41
+ "module": "./dist/index.js",
42
+ "files": [
43
+ "dist",
44
+ "README.md"
45
+ ],
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "exports": {
49
+ ".": "./dist/index.js",
50
+ "./contracts": "./dist/contracts/index.js",
51
+ "./docs": "./dist/docs/index.js",
52
+ "./docs/files.docblock": "./dist/docs/files.docblock.js",
53
+ "./entities": "./dist/entities/index.js",
54
+ "./events": "./dist/events.js",
55
+ "./files.feature": "./dist/files.feature.js",
56
+ "./storage": "./dist/storage/index.js",
57
+ "./*": "./*"
58
+ },
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "license": "MIT",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://github.com/lssm-tech/contractspec.git",
65
+ "directory": "packages/libs/files"
66
+ },
67
+ "homepage": "https://contractspec.io"
68
+ }