@heilgar/file-storage-adapter-fs 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/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +192 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseAdapter, DownloadOptions, FileMetadata, FileObject, FileStorageAdapterConfig, ListOptions, ListResult, SignedUrlOptions, UploadOptions } from '@heilgar/file-storage-adapter-core';
|
|
2
|
+
export interface FsAdapterConfig extends FileStorageAdapterConfig {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class FsAdapter extends BaseAdapter {
|
|
7
|
+
private rootDir;
|
|
8
|
+
private baseUrl?;
|
|
9
|
+
constructor(config: FsAdapterConfig);
|
|
10
|
+
private getFilePath;
|
|
11
|
+
private getMetadataPath;
|
|
12
|
+
private ensureDir;
|
|
13
|
+
upload(key: string, file: Buffer | NodeJS.ReadableStream | File, options?: UploadOptions): Promise<FileMetadata>;
|
|
14
|
+
download(key: string, options?: DownloadOptions): Promise<FileObject>;
|
|
15
|
+
getMetadata(key: string): Promise<FileMetadata | null>;
|
|
16
|
+
delete(key: string): Promise<boolean>;
|
|
17
|
+
exists(key: string): Promise<boolean>;
|
|
18
|
+
list(options?: ListOptions): Promise<ListResult>;
|
|
19
|
+
getSignedUrl(key: string, options: SignedUrlOptions): Promise<string>;
|
|
20
|
+
getSignedUrlUpload(key: string, options: SignedUrlOptions): Promise<{
|
|
21
|
+
url: string;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
}>;
|
|
24
|
+
copy(sourceKey: string, destinationKey: string): Promise<FileMetadata>;
|
|
25
|
+
move(sourceKey: string, destinationKey: string): Promise<FileMetadata>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL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OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IAIvD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBtE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAK7E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { BaseAdapter, } from '@heilgar/file-storage-adapter-core';
|
|
2
|
+
import { createReadStream, promises as fs } from 'node:fs';
|
|
3
|
+
import { dirname, join, relative } from 'node:path';
|
|
4
|
+
import { lookup } from 'mime-types';
|
|
5
|
+
export class FsAdapter extends BaseAdapter {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
this.rootDir = config.rootDir;
|
|
9
|
+
this.baseUrl = config.baseUrl;
|
|
10
|
+
}
|
|
11
|
+
getFilePath(key) {
|
|
12
|
+
const fullKey = this.getFullKey(key);
|
|
13
|
+
return join(this.rootDir, fullKey);
|
|
14
|
+
}
|
|
15
|
+
getMetadataPath(key) {
|
|
16
|
+
return `${this.getFilePath(key)}.meta.json`;
|
|
17
|
+
}
|
|
18
|
+
async ensureDir(filePath) {
|
|
19
|
+
const dir = dirname(filePath);
|
|
20
|
+
await fs.mkdir(dir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
async upload(key, file, options) {
|
|
23
|
+
const filePath = this.getFilePath(key);
|
|
24
|
+
await this.ensureDir(filePath);
|
|
25
|
+
const buffer = await this.toBuffer(file);
|
|
26
|
+
await fs.writeFile(filePath, buffer);
|
|
27
|
+
const stat = await fs.stat(filePath);
|
|
28
|
+
const metadata = {
|
|
29
|
+
name: key.split('/').pop() || key,
|
|
30
|
+
mimeType: options?.contentType || lookup(key) || 'application/octet-stream',
|
|
31
|
+
size: stat.size,
|
|
32
|
+
uploadedAt: new Date(),
|
|
33
|
+
metadata: options?.metadata,
|
|
34
|
+
};
|
|
35
|
+
const metadataPath = this.getMetadataPath(key);
|
|
36
|
+
await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2));
|
|
37
|
+
return metadata;
|
|
38
|
+
}
|
|
39
|
+
async download(key, options) {
|
|
40
|
+
const filePath = this.getFilePath(key);
|
|
41
|
+
const metadataPath = this.getMetadataPath(key);
|
|
42
|
+
let content;
|
|
43
|
+
if (options?.range) {
|
|
44
|
+
const { start, end } = options.range;
|
|
45
|
+
const stream = createReadStream(filePath, { start, end });
|
|
46
|
+
content = await this.toBuffer(stream);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
content = await fs.readFile(filePath);
|
|
50
|
+
}
|
|
51
|
+
let metadata;
|
|
52
|
+
try {
|
|
53
|
+
const metaContent = await fs.readFile(metadataPath, 'utf-8');
|
|
54
|
+
metadata = JSON.parse(metaContent);
|
|
55
|
+
metadata.uploadedAt = new Date(metadata.uploadedAt);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Fallback if metadata doesn't exist
|
|
59
|
+
const stats = await fs.stat(filePath);
|
|
60
|
+
metadata = {
|
|
61
|
+
name: key.split('/').pop() || key,
|
|
62
|
+
mimeType: lookup(key) || 'application/octet-stream',
|
|
63
|
+
size: stats.size,
|
|
64
|
+
uploadedAt: stats.mtime,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...metadata,
|
|
69
|
+
content,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async getMetadata(key) {
|
|
73
|
+
try {
|
|
74
|
+
const metadataPath = this.getMetadataPath(key);
|
|
75
|
+
const content = await fs.readFile(metadataPath, 'utf-8');
|
|
76
|
+
const metadata = JSON.parse(content);
|
|
77
|
+
metadata.uploadedAt = new Date(metadata.uploadedAt);
|
|
78
|
+
return metadata;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Try to get basic metadata from file stats
|
|
82
|
+
try {
|
|
83
|
+
const filePath = this.getFilePath(key);
|
|
84
|
+
const stats = await fs.stat(filePath);
|
|
85
|
+
return {
|
|
86
|
+
name: key.split('/').pop() || key,
|
|
87
|
+
mimeType: lookup(key) || 'application/octet-stream',
|
|
88
|
+
size: stats.size,
|
|
89
|
+
uploadedAt: stats.mtime,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async delete(key) {
|
|
98
|
+
try {
|
|
99
|
+
const filePath = this.getFilePath(key);
|
|
100
|
+
const metadataPath = this.getMetadataPath(key);
|
|
101
|
+
await fs.unlink(filePath);
|
|
102
|
+
await fs.unlink(metadataPath).catch(() => { }); // Ignore if metadata doesn't exist
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async exists(key) {
|
|
110
|
+
try {
|
|
111
|
+
const filePath = this.getFilePath(key);
|
|
112
|
+
await fs.access(filePath);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async list(options = {}) {
|
|
120
|
+
const { prefix = '', limit = 1000 } = options;
|
|
121
|
+
const files = [];
|
|
122
|
+
const searchDir = prefix
|
|
123
|
+
? join(this.rootDir, this.getFullKey(prefix))
|
|
124
|
+
: join(this.rootDir, this.config.basePath || '');
|
|
125
|
+
const walkDir = async (dir) => {
|
|
126
|
+
try {
|
|
127
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
if (files.length >= limit)
|
|
130
|
+
break;
|
|
131
|
+
const fullPath = join(dir, entry.name);
|
|
132
|
+
if (entry.isDirectory()) {
|
|
133
|
+
await walkDir(fullPath);
|
|
134
|
+
}
|
|
135
|
+
else if (entry.isFile() && !entry.name.endsWith('.meta.json')) {
|
|
136
|
+
const relativePath = relative(this.rootDir, fullPath);
|
|
137
|
+
const key = this.stripBasePath(relativePath);
|
|
138
|
+
const metadata = await this.getMetadata(key);
|
|
139
|
+
if (metadata) {
|
|
140
|
+
files.push(metadata);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Directory doesn't exist or not accessible
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
await walkDir(searchDir);
|
|
150
|
+
return {
|
|
151
|
+
files,
|
|
152
|
+
hasMore: false, // Filesystem adapter loads all at once
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async getSignedUrl(key, options) {
|
|
156
|
+
// Filesystem doesn't support signed URLs, return public URL if baseUrl is set
|
|
157
|
+
if (this.baseUrl) {
|
|
158
|
+
const fullKey = this.getFullKey(key);
|
|
159
|
+
return `${this.baseUrl}/${fullKey}`;
|
|
160
|
+
}
|
|
161
|
+
throw new Error('baseUrl not configured for FsAdapter');
|
|
162
|
+
}
|
|
163
|
+
async getSignedUrlUpload(key, options) {
|
|
164
|
+
throw new Error('Signed upload URLs not supported for filesystem adapter');
|
|
165
|
+
}
|
|
166
|
+
async copy(sourceKey, destinationKey) {
|
|
167
|
+
const sourcePath = this.getFilePath(sourceKey);
|
|
168
|
+
const destPath = this.getFilePath(destinationKey);
|
|
169
|
+
await this.ensureDir(destPath);
|
|
170
|
+
await fs.copyFile(sourcePath, destPath);
|
|
171
|
+
// Copy metadata
|
|
172
|
+
const sourceMetaPath = this.getMetadataPath(sourceKey);
|
|
173
|
+
const destMetaPath = this.getMetadataPath(destinationKey);
|
|
174
|
+
try {
|
|
175
|
+
await fs.copyFile(sourceMetaPath, destMetaPath);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Metadata doesn't exist, create new
|
|
179
|
+
}
|
|
180
|
+
const metadata = await this.getMetadata(destinationKey);
|
|
181
|
+
if (!metadata) {
|
|
182
|
+
throw new Error('Failed to copy file');
|
|
183
|
+
}
|
|
184
|
+
return metadata;
|
|
185
|
+
}
|
|
186
|
+
async move(sourceKey, destinationKey) {
|
|
187
|
+
const metadata = await this.copy(sourceKey, destinationKey);
|
|
188
|
+
await this.delete(sourceKey);
|
|
189
|
+
return metadata;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GASZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAOpC,MAAM,OAAO,SAAU,SAAQ,WAAW;IAIxC,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAEO,WAAW,CAAC,GAAW;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAEO,eAAe,CAAC,GAAW;QACjC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,SAAS,C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,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAElD,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC/B,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAExC,gBAAgB;QAChB,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC1D,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,cAAsB;QAClD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC7B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@heilgar/file-storage-adapter-fs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Filesystem storage adapter",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc --build",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"storage",
|
|
25
|
+
"filesystem",
|
|
26
|
+
"files"
|
|
27
|
+
],
|
|
28
|
+
"author": "Oleh Hrebeniuk",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@heilgar/file-storage-adapter-core": "^1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@heilgar/file-storage-adapter-core": "*",
|
|
35
|
+
"@types/mime-types": "^3.0.1"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"mime-types": "^3.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|