@flystorage/file-storage 0.1.0 → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2023-2024 Frank de Jonge
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is furnished
8
+ to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://avatars.githubusercontent.com/u/151840999" width="50px" height="50px" />
1
+ <img src="https://raw.githubusercontent.com/duna-oss/flystorage/main/flystorage.svg" width="50px" height="50px" />
2
2
 
3
3
  # Flystorage
4
4
  Flystorage is a file storage abstraction for NodeJS and TypeScript. It is an 80/20 solution
@@ -39,12 +39,12 @@ to, simply because they cannot be abstracted over in a reasonable manner.
39
39
  ## Implementations / Adapters
40
40
 
41
41
  ### Implemented
42
- - [x] Local Filesystem
43
- - [x] AWS S3 (using the V3 SDK)
44
- - [x] Azure Blob Storage
45
- - [x] Test implementation (in-memory)
46
- - [x] Google Cloud Storage
47
- - [x] Chaos adapter decorator
42
+ - [x] [Local Filesystem](https://www.npmjs.com/package/@flystorage/local-fs)
43
+ - [x] [AWS S3 (using the V3 SDK)](https://www.npmjs.com/package/@flystorage/aws-s3)
44
+ - [x] [Azure Blob Storage](https://www.npmjs.com/package/@flystorage/file-storage)
45
+ - [x] [Test implementation (in-memory)](https://www.npmjs.com/package/@flystorage/in-memory)
46
+ - [x] [Google Cloud Storage](https://www.npmjs.com/package/@flystorage/google-cloud-storage)
47
+ - [x] [Chaos adapter decorator](https://www.npmjs.com/package/@flystorage/chaos)
48
48
 
49
49
  ### Planned
50
50
  - [ ] FTP (using `basic-ftp`)
@@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PathPrefixer = void 0;
4
4
  const node_path_1 = require("node:path");
5
5
  class PathPrefixer {
6
+ separator;
7
+ joinFunc;
6
8
  prefix = '';
7
- constructor(prefix = '') {
9
+ constructor(prefix = '', separator = '/', joinFunc = node_path_1.join) {
10
+ this.separator = separator;
11
+ this.joinFunc = joinFunc;
8
12
  if (prefix.length > 0) {
9
- this.prefix = (0, node_path_1.join)(prefix, '/');
13
+ this.prefix = this.joinFunc(prefix, this.separator);
10
14
  }
11
15
  }
12
16
  prefixFilePath(path) {
13
- return this.prefix.length > 0 ? (0, node_path_1.join)(this.prefix, path) : path;
17
+ return this.prefix.length > 0 ? this.joinFunc(this.prefix, path) : path;
14
18
  }
15
19
  prefixDirectoryPath(path) {
16
- return this.prefix.length > 0 ? (0, node_path_1.join)(this.prefix, path, '/') : (0, node_path_1.join)(path, '/');
20
+ return this.prefix.length > 0 ? this.joinFunc(this.prefix, path, '/') : this.joinFunc(path, '/');
17
21
  }
18
22
  stripFilePath(path) {
19
23
  return path.substring(this.prefix.length);
@@ -1,16 +1,20 @@
1
1
  import { join } from 'node:path';
2
2
  export class PathPrefixer {
3
+ separator;
4
+ joinFunc;
3
5
  prefix = '';
4
- constructor(prefix = '') {
6
+ constructor(prefix = '', separator = '/', joinFunc = join) {
7
+ this.separator = separator;
8
+ this.joinFunc = joinFunc;
5
9
  if (prefix.length > 0) {
6
- this.prefix = join(prefix, '/');
10
+ this.prefix = this.joinFunc(prefix, this.separator);
7
11
  }
8
12
  }
9
13
  prefixFilePath(path) {
10
- return this.prefix.length > 0 ? join(this.prefix, path) : path;
14
+ return this.prefix.length > 0 ? this.joinFunc(this.prefix, path) : path;
11
15
  }
12
16
  prefixDirectoryPath(path) {
13
- return this.prefix.length > 0 ? join(this.prefix, path, '/') : join(path, '/');
17
+ return this.prefix.length > 0 ? this.joinFunc(this.prefix, path, '/') : this.joinFunc(path, '/');
14
18
  }
15
19
  stripFilePath(path) {
16
20
  return path.substring(this.prefix.length);
@@ -1,6 +1,10 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { join } from 'node:path';
1
3
  export declare class PathPrefixer {
4
+ private readonly separator;
5
+ private readonly joinFunc;
2
6
  private readonly prefix;
3
- constructor(prefix?: string);
7
+ constructor(prefix?: string, separator?: string, joinFunc?: typeof join);
4
8
  prefixFilePath(path: string): string;
5
9
  prefixDirectoryPath(path: string): string;
6
10
  stripFilePath(path: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flystorage/file-storage",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
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",