@flystorage/file-storage 0.1.3 → 0.1.5
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/cjs/checksum-from-stream.js +6 -3
- package/dist/cjs/errors.js +47 -22
- package/dist/cjs/file-storage.js +36 -23
- package/dist/cjs/index.js +22 -6
- package/dist/cjs/path-normalizer.js +11 -5
- package/dist/cjs/path-prefixer.js +7 -3
- package/dist/cjs/portable-visibility.js +5 -2
- package/dist/types/checksum-from-stream.d.ts +0 -2
- package/dist/types/file-storage.d.ts +3 -4
- package/dist/types/path-prefixer.d.ts +0 -1
- package/package.json +7 -7
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checksumFromStream = checksumFromStream;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
async function checksumFromStream(stream, options) {
|
|
3
6
|
return new Promise(async (resolve, reject) => {
|
|
4
|
-
const hash = createHash(options.algo ?? 'md5');
|
|
7
|
+
const hash = (0, crypto_1.createHash)(options.algo ?? 'md5');
|
|
5
8
|
stream.on('error', reject);
|
|
6
9
|
stream.pipe(hash, { end: false });
|
|
7
10
|
stream.on('end', () => {
|
package/dist/cjs/errors.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnableToListDirectory = exports.UnableToCheckDirectoryExistence = exports.UnableToCheckFileExistence = exports.UnableToDeleteFile = exports.UnableToDeleteDirectory = exports.UnableToCreateDirectory = exports.UnableToGetStat = exports.UnableToMoveFile = exports.UnableToCopyFile = exports.UnableToGetTemporaryUrl = exports.UnableToGetPublicUrl = exports.UnableToGetVisibility = exports.UnableToSetVisibility = exports.UnableToReadFile = exports.UnableToWriteFile = exports.UnableToGetFileSize = exports.UnableToGetLastModified = exports.UnableToGetMimeType = exports.UnableToGetChecksum = exports.ChecksumIsNotAvailable = exports.FlystorageError = void 0;
|
|
4
|
+
exports.errorToMessage = errorToMessage;
|
|
5
|
+
function errorToMessage(error) {
|
|
2
6
|
return error instanceof Error ? error.message : String(error);
|
|
3
7
|
}
|
|
4
|
-
|
|
8
|
+
class FlystorageError extends Error {
|
|
5
9
|
context;
|
|
6
10
|
code = 'unknown_error';
|
|
7
11
|
constructor(message, context = {}, cause = undefined) {
|
|
@@ -11,11 +15,12 @@ export class FlystorageError extends Error {
|
|
|
11
15
|
this.context = context;
|
|
12
16
|
}
|
|
13
17
|
}
|
|
18
|
+
exports.FlystorageError = FlystorageError;
|
|
14
19
|
/**
|
|
15
20
|
* Thrown when the checksum algo is not supported or not pre-computed. This error
|
|
16
21
|
* is thrown with the intention of falling back to computing it based on a file read.
|
|
17
22
|
*/
|
|
18
|
-
|
|
23
|
+
class ChecksumIsNotAvailable extends FlystorageError {
|
|
19
24
|
algo;
|
|
20
25
|
code = 'flystorage.checksum_not_supported';
|
|
21
26
|
constructor(message, algo, context = {}, cause = undefined) {
|
|
@@ -24,80 +29,100 @@ export class ChecksumIsNotAvailable extends FlystorageError {
|
|
|
24
29
|
}
|
|
25
30
|
static checksumNotSupported = (algo, { context = {}, cause = undefined } = {}) => new ChecksumIsNotAvailable(`Checksum algo "${algo}" is not supported`, algo, { ...context, algo }, cause);
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
exports.ChecksumIsNotAvailable = ChecksumIsNotAvailable;
|
|
33
|
+
class UnableToGetChecksum extends FlystorageError {
|
|
28
34
|
code = 'flystorage.unable_to_get_checksum';
|
|
29
35
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetChecksum(`Unable to write the file. Reason: ${reason}`, context, cause);
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
exports.UnableToGetChecksum = UnableToGetChecksum;
|
|
38
|
+
class UnableToGetMimeType extends FlystorageError {
|
|
32
39
|
code = 'flystorage.unable_to_get_mimetype';
|
|
33
40
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetMimeType(`Unable to get mime-type. Reason: ${reason}`, context, cause);
|
|
34
41
|
}
|
|
35
|
-
|
|
42
|
+
exports.UnableToGetMimeType = UnableToGetMimeType;
|
|
43
|
+
class UnableToGetLastModified extends FlystorageError {
|
|
36
44
|
code = 'flystorage.unable_to_get_last_modified';
|
|
37
45
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetLastModified(`Unable to get last modified. Reason: ${reason}`, context, cause);
|
|
38
46
|
}
|
|
39
|
-
|
|
47
|
+
exports.UnableToGetLastModified = UnableToGetLastModified;
|
|
48
|
+
class UnableToGetFileSize extends FlystorageError {
|
|
40
49
|
code = 'flystorage.unable_to_get_file_size';
|
|
41
50
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetFileSize(`Unable to get file size. Reason: ${reason}`, context, cause);
|
|
42
51
|
}
|
|
43
|
-
|
|
52
|
+
exports.UnableToGetFileSize = UnableToGetFileSize;
|
|
53
|
+
class UnableToWriteFile extends FlystorageError {
|
|
44
54
|
code = 'flystorage.unable_to_write_file';
|
|
45
55
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToWriteFile(`Unable to write the file. Reason: ${reason}`, context, cause);
|
|
46
56
|
}
|
|
47
|
-
|
|
57
|
+
exports.UnableToWriteFile = UnableToWriteFile;
|
|
58
|
+
class UnableToReadFile extends FlystorageError {
|
|
48
59
|
code = 'flystorage.unable_to_read_file';
|
|
49
60
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToReadFile(`Unable to read the file. Reason: ${reason}`, context, cause);
|
|
50
61
|
}
|
|
51
|
-
|
|
62
|
+
exports.UnableToReadFile = UnableToReadFile;
|
|
63
|
+
class UnableToSetVisibility extends FlystorageError {
|
|
52
64
|
code = 'flystorage.unable_to_set_visibility';
|
|
53
65
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToSetVisibility(`Unable to set visibility. Reason: ${reason}`, context, cause);
|
|
54
66
|
}
|
|
55
|
-
|
|
67
|
+
exports.UnableToSetVisibility = UnableToSetVisibility;
|
|
68
|
+
class UnableToGetVisibility extends FlystorageError {
|
|
56
69
|
code = 'flystorage.unable_to_get_visibility';
|
|
57
70
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetVisibility(`Unable to get visibility. Reason: ${reason}`, context, cause);
|
|
58
71
|
}
|
|
59
|
-
|
|
72
|
+
exports.UnableToGetVisibility = UnableToGetVisibility;
|
|
73
|
+
class UnableToGetPublicUrl extends FlystorageError {
|
|
60
74
|
code = 'flystorage.unable_to_get_public_url';
|
|
61
75
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetPublicUrl(`Unable to get public URL. Reason: ${reason}`, context, cause);
|
|
62
76
|
}
|
|
63
|
-
|
|
77
|
+
exports.UnableToGetPublicUrl = UnableToGetPublicUrl;
|
|
78
|
+
class UnableToGetTemporaryUrl extends FlystorageError {
|
|
64
79
|
code = 'flystorage.unable_to_get_temporary_url';
|
|
65
80
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetTemporaryUrl(`Unable to get temporary URL. Reason: ${reason}`, context, cause);
|
|
66
81
|
}
|
|
67
|
-
|
|
82
|
+
exports.UnableToGetTemporaryUrl = UnableToGetTemporaryUrl;
|
|
83
|
+
class UnableToCopyFile extends FlystorageError {
|
|
68
84
|
code = 'flystorage.unable_to_copy_file';
|
|
69
85
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToCopyFile(`Unable to copy file. Reason: ${reason}`, context, cause);
|
|
70
86
|
}
|
|
71
|
-
|
|
87
|
+
exports.UnableToCopyFile = UnableToCopyFile;
|
|
88
|
+
class UnableToMoveFile extends FlystorageError {
|
|
72
89
|
code = 'flystorage.unable_to_move_file';
|
|
73
90
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToMoveFile(`Unable to move file. Reason: ${reason}`, context, cause);
|
|
74
91
|
}
|
|
75
|
-
|
|
92
|
+
exports.UnableToMoveFile = UnableToMoveFile;
|
|
93
|
+
class UnableToGetStat extends FlystorageError {
|
|
76
94
|
code = 'flystorage.unable_to_get_stat';
|
|
77
95
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToGetStat(`Unable to get stat. Reason: ${reason}`, context, cause);
|
|
78
96
|
static noFileStatResolved = ({ context = {}, cause = undefined }) => new UnableToGetStat(`Stat was not a file.`, context, cause);
|
|
79
97
|
}
|
|
80
|
-
|
|
98
|
+
exports.UnableToGetStat = UnableToGetStat;
|
|
99
|
+
class UnableToCreateDirectory extends FlystorageError {
|
|
81
100
|
code = 'flystorage.unable_to_create_directory';
|
|
82
101
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToCreateDirectory(`Unable to create directory. Reason: ${reason}`, context, cause);
|
|
83
102
|
}
|
|
84
|
-
|
|
103
|
+
exports.UnableToCreateDirectory = UnableToCreateDirectory;
|
|
104
|
+
class UnableToDeleteDirectory extends FlystorageError {
|
|
85
105
|
code = 'flystorage.unable_to_delete_directory';
|
|
86
106
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToDeleteDirectory(`Unable to delete directory. Reason: ${reason}`, context, cause);
|
|
87
107
|
}
|
|
88
|
-
|
|
108
|
+
exports.UnableToDeleteDirectory = UnableToDeleteDirectory;
|
|
109
|
+
class UnableToDeleteFile extends FlystorageError {
|
|
89
110
|
code = 'flystorage.unable_to_delete_file';
|
|
90
111
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToDeleteFile(`Unable to delete file. Reason: ${reason}`, context, cause);
|
|
91
112
|
}
|
|
92
|
-
|
|
113
|
+
exports.UnableToDeleteFile = UnableToDeleteFile;
|
|
114
|
+
class UnableToCheckFileExistence extends FlystorageError {
|
|
93
115
|
code = 'flystorage.unable_to_check_file_existence';
|
|
94
116
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToCheckFileExistence(`Unable to check file existence. Reason: ${reason}`, context, cause);
|
|
95
117
|
}
|
|
96
|
-
|
|
118
|
+
exports.UnableToCheckFileExistence = UnableToCheckFileExistence;
|
|
119
|
+
class UnableToCheckDirectoryExistence extends FlystorageError {
|
|
97
120
|
code = 'flystorage.unable_to_check_directory_existence';
|
|
98
121
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToCheckDirectoryExistence(`Unable to check directory existence. Reason: ${reason}`, context, cause);
|
|
99
122
|
}
|
|
100
|
-
|
|
123
|
+
exports.UnableToCheckDirectoryExistence = UnableToCheckDirectoryExistence;
|
|
124
|
+
class UnableToListDirectory extends FlystorageError {
|
|
101
125
|
code = 'flystorage.unable_to_list_directory_contents';
|
|
102
126
|
static because = (reason, { context = {}, cause = undefined }) => new UnableToListDirectory(`Unable to list directory contents. Reason: ${reason}`, context, cause);
|
|
103
127
|
}
|
|
128
|
+
exports.UnableToListDirectory = UnableToListDirectory;
|
package/dist/cjs/file-storage.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileStorage = exports.DirectoryListing = void 0;
|
|
4
|
+
exports.isFile = isFile;
|
|
5
|
+
exports.isDirectory = isDirectory;
|
|
6
|
+
exports.toReadable = toReadable;
|
|
7
|
+
exports.normalizeExpiryToDate = normalizeExpiryToDate;
|
|
8
|
+
exports.normalizeExpiryToMilliseconds = normalizeExpiryToMilliseconds;
|
|
9
|
+
exports.closeReadable = closeReadable;
|
|
10
|
+
exports.readableToString = readableToString;
|
|
11
|
+
exports.readableToUint8Array = readableToUint8Array;
|
|
12
|
+
const stream_1 = require("stream");
|
|
13
|
+
const checksum_from_stream_js_1 = require("./checksum-from-stream.js");
|
|
14
|
+
const errors = require("./errors.js");
|
|
15
|
+
const errors_js_1 = require("./errors.js");
|
|
16
|
+
const path_normalizer_js_1 = require("./path-normalizer.js");
|
|
17
|
+
const util_1 = require("util");
|
|
18
|
+
function isFile(stat) {
|
|
8
19
|
return stat.isFile;
|
|
9
20
|
}
|
|
10
|
-
|
|
21
|
+
function isDirectory(stat) {
|
|
11
22
|
return stat.isDirectory;
|
|
12
23
|
}
|
|
13
|
-
|
|
24
|
+
class DirectoryListing {
|
|
14
25
|
listing;
|
|
15
26
|
path;
|
|
16
27
|
deep;
|
|
@@ -48,21 +59,22 @@ export class DirectoryListing {
|
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
exports.DirectoryListing = DirectoryListing;
|
|
63
|
+
function toReadable(contents) {
|
|
64
|
+
if (contents instanceof stream_1.Readable) {
|
|
53
65
|
return contents;
|
|
54
66
|
}
|
|
55
|
-
return Readable.from(contents);
|
|
67
|
+
return stream_1.Readable.from(contents);
|
|
56
68
|
}
|
|
57
69
|
const naturalSorting = new Intl.Collator(undefined, {
|
|
58
70
|
numeric: true,
|
|
59
71
|
sensitivity: 'base'
|
|
60
72
|
});
|
|
61
|
-
|
|
73
|
+
class FileStorage {
|
|
62
74
|
adapter;
|
|
63
75
|
pathNormalizer;
|
|
64
76
|
options;
|
|
65
|
-
constructor(adapter, pathNormalizer = new PathNormalizerV1(), options = {}) {
|
|
77
|
+
constructor(adapter, pathNormalizer = new path_normalizer_js_1.PathNormalizerV1(), options = {}) {
|
|
66
78
|
this.adapter = adapter;
|
|
67
79
|
this.pathNormalizer = pathNormalizer;
|
|
68
80
|
this.options = options;
|
|
@@ -79,7 +91,7 @@ export class FileStorage {
|
|
|
79
91
|
}
|
|
80
92
|
async read(path) {
|
|
81
93
|
try {
|
|
82
|
-
return Readable.from(await this.adapter.read(this.pathNormalizer.normalizePath(path)));
|
|
94
|
+
return stream_1.Readable.from(await this.adapter.read(this.pathNormalizer.normalizePath(path)));
|
|
83
95
|
}
|
|
84
96
|
catch (error) {
|
|
85
97
|
throw errors.UnableToReadFile.because(errors.errorToMessage(error), { cause: error, context: { path } });
|
|
@@ -211,7 +223,7 @@ export class FileStorage {
|
|
|
211
223
|
return await this.adapter.checksum(this.pathNormalizer.normalizePath(path), { ...this.options.checksums, ...options });
|
|
212
224
|
}
|
|
213
225
|
catch (error) {
|
|
214
|
-
if (error instanceof ChecksumIsNotAvailable) {
|
|
226
|
+
if (error instanceof errors_js_1.ChecksumIsNotAvailable) {
|
|
215
227
|
return this.calculateChecksum(path, options);
|
|
216
228
|
}
|
|
217
229
|
throw errors.UnableToGetChecksum.because(errors.errorToMessage(error), { cause: error, context: { path, options } });
|
|
@@ -243,20 +255,21 @@ export class FileStorage {
|
|
|
243
255
|
}
|
|
244
256
|
async calculateChecksum(path, options) {
|
|
245
257
|
try {
|
|
246
|
-
return await checksumFromStream(await this.read(path), options);
|
|
258
|
+
return await (0, checksum_from_stream_js_1.checksumFromStream)(await this.read(path), options);
|
|
247
259
|
}
|
|
248
260
|
catch (error) {
|
|
249
261
|
throw errors.UnableToGetChecksum.because(errors.errorToMessage(error), { cause: error, context: { path, options } });
|
|
250
262
|
}
|
|
251
263
|
}
|
|
252
264
|
}
|
|
253
|
-
|
|
265
|
+
exports.FileStorage = FileStorage;
|
|
266
|
+
function normalizeExpiryToDate(expiresAt) {
|
|
254
267
|
return expiresAt instanceof Date ? expiresAt : new Date(expiresAt);
|
|
255
268
|
}
|
|
256
|
-
|
|
269
|
+
function normalizeExpiryToMilliseconds(expiresAt) {
|
|
257
270
|
return expiresAt instanceof Date ? expiresAt.getTime() : expiresAt;
|
|
258
271
|
}
|
|
259
|
-
|
|
272
|
+
async function closeReadable(body) {
|
|
260
273
|
if (body.closed) {
|
|
261
274
|
return;
|
|
262
275
|
}
|
|
@@ -268,13 +281,13 @@ export async function closeReadable(body) {
|
|
|
268
281
|
});
|
|
269
282
|
}
|
|
270
283
|
const decoder = new TextDecoder();
|
|
271
|
-
|
|
284
|
+
async function readableToString(stream) {
|
|
272
285
|
const contents = decoder.decode(await readableToUint8Array(stream));
|
|
273
286
|
await closeReadable(stream);
|
|
274
287
|
return contents;
|
|
275
288
|
}
|
|
276
|
-
const encoder = new TextEncoder();
|
|
277
|
-
|
|
289
|
+
const encoder = new util_1.TextEncoder();
|
|
290
|
+
function readableToUint8Array(stream) {
|
|
278
291
|
return new Promise((resolve, reject) => {
|
|
279
292
|
const parts = [];
|
|
280
293
|
stream.on('data', (chunk) => {
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./checksum-from-stream.js"), exports);
|
|
18
|
+
__exportStar(require("./file-storage.js"), exports);
|
|
19
|
+
__exportStar(require("./errors.js"), exports);
|
|
20
|
+
__exportStar(require("./path-normalizer.js"), exports);
|
|
21
|
+
__exportStar(require("./path-prefixer.js"), exports);
|
|
22
|
+
__exportStar(require("./portable-visibility.js"), exports);
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PathTraversalDetected = exports.CorruptedPathDetected = exports.PathNormalizerV1 = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
2
5
|
const funkyWhiteSpaceRegex = new RegExp('\\p{C}+', 'u');
|
|
3
|
-
|
|
6
|
+
class PathNormalizerV1 {
|
|
4
7
|
normalizePath(path) {
|
|
5
8
|
if (funkyWhiteSpaceRegex.test(path)) {
|
|
6
9
|
throw CorruptedPathDetected.unexpectedWhitespace(path);
|
|
7
10
|
}
|
|
8
|
-
const normalized = join(...(path.split('/')));
|
|
11
|
+
const normalized = (0, node_path_1.join)(...(path.split('/')));
|
|
9
12
|
if (normalized.indexOf('../') !== -1 || normalized == '..') {
|
|
10
13
|
throw PathTraversalDetected.forPath(path);
|
|
11
14
|
}
|
|
12
15
|
return normalized === '.' ? '' : normalized;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
exports.PathNormalizerV1 = PathNormalizerV1;
|
|
19
|
+
class CorruptedPathDetected extends Error {
|
|
16
20
|
static unexpectedWhitespace = (path) => new CorruptedPathDetected(`Corrupted path detected with unexpected whitespace: ${path}`);
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
exports.CorruptedPathDetected = CorruptedPathDetected;
|
|
23
|
+
class PathTraversalDetected extends Error {
|
|
19
24
|
static forPath = (path) => new PathTraversalDetected(`Path traversal detected for: ${path}`);
|
|
20
25
|
}
|
|
26
|
+
exports.PathTraversalDetected = PathTraversalDetected;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PathPrefixer = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
class PathPrefixer {
|
|
3
6
|
separator;
|
|
4
7
|
joinFunc;
|
|
5
8
|
prefix = '';
|
|
6
|
-
constructor(prefix = '', separator = '/', joinFunc = join) {
|
|
9
|
+
constructor(prefix = '', separator = '/', joinFunc = node_path_1.join) {
|
|
7
10
|
this.separator = separator;
|
|
8
11
|
this.joinFunc = joinFunc;
|
|
9
12
|
if (prefix.length > 0) {
|
|
@@ -23,3 +26,4 @@ export class PathPrefixer {
|
|
|
23
26
|
return this.stripFilePath(path).replace(/\/+$/g, '');
|
|
24
27
|
}
|
|
25
28
|
}
|
|
29
|
+
exports.PathPrefixer = PathPrefixer;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Visibility = void 0;
|
|
4
|
+
var Visibility;
|
|
2
5
|
(function (Visibility) {
|
|
3
6
|
Visibility["PUBLIC"] = "public";
|
|
4
7
|
Visibility["PRIVATE"] = "private";
|
|
5
|
-
})(Visibility || (Visibility = {}));
|
|
8
|
+
})(Visibility || (exports.Visibility = Visibility = {}));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { BinaryToTextEncoding } from 'crypto';
|
|
4
2
|
import { Readable } from 'node:stream';
|
|
5
3
|
export declare function checksumFromStream(stream: Readable, options: {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
5
1
|
import { BinaryToTextEncoding } from 'crypto';
|
|
6
2
|
import { Readable } from 'stream';
|
|
7
3
|
import { PathNormalizer } from './path-normalizer.js';
|
|
@@ -87,6 +83,9 @@ export type ListOptions = {
|
|
|
87
83
|
};
|
|
88
84
|
export type TemporaryUrlOptions = MiscellaneousOptions & {
|
|
89
85
|
expiresAt: ExpiresAt;
|
|
86
|
+
responseHeaders?: {
|
|
87
|
+
[header: string]: string;
|
|
88
|
+
};
|
|
90
89
|
};
|
|
91
90
|
export type ChecksumOptions = MiscellaneousOptions & {
|
|
92
91
|
algo?: string;
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flystorage/file-storage",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"description": "File-storage abstraction: multiple filesystems, one API.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
7
7
|
"types": "./dist/types/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"default": "./dist/esm/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/index.js"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"compile": "rm -rf ./dist/ && concurrently npm:compile:* && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
|
|
22
22
|
"compile:esm": "tsc --outDir ./dist/esm/ --declaration false",
|
|
23
|
-
"compile:cjs": "tsc --outDir ./dist/cjs/ --declaration false --module
|
|
23
|
+
"compile:cjs": "tsc --outDir ./dist/cjs/ --declaration false --module commonjs --moduleResolution node",
|
|
24
24
|
"compile:types": "tsc --outDir ./dist/types/ --declaration --emitDeclarationOnly",
|
|
25
25
|
"watch": "tsc --watch"
|
|
26
26
|
},
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"storage"
|
|
40
40
|
],
|
|
41
41
|
"license": "MIT"
|
|
42
|
-
}
|
|
42
|
+
}
|