@ostro/filesystem 1.0.4 → 2.0.0-alpha.2

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 (66) hide show
  1. package/adapter/CoreAdapter.js +164 -57
  2. package/adapter/CoreAdapter.js.map +1 -0
  3. package/adapter/azure.js +93 -56
  4. package/adapter/azure.js.map +1 -0
  5. package/adapter/local.js +136 -66
  6. package/adapter/local.js.map +1 -0
  7. package/adapter/s3.js +102 -70
  8. package/adapter/s3.js.map +1 -0
  9. package/callbackHandler.js +93 -23
  10. package/callbackHandler.js.map +1 -0
  11. package/clients/azure.js +43 -13
  12. package/clients/azure.js.map +1 -0
  13. package/clients/s3.js +40 -9
  14. package/clients/s3.js.map +1 -0
  15. package/directoryCreateException.js +27 -5
  16. package/directoryCreateException.js.map +1 -0
  17. package/fileDeleteException.js +28 -4
  18. package/fileDeleteException.js.map +1 -0
  19. package/fileNotFoundException.js +27 -5
  20. package/fileNotFoundException.js.map +1 -0
  21. package/fileUploadException.js +28 -5
  22. package/fileUploadException.js.map +1 -0
  23. package/filesystem.js +388 -193
  24. package/filesystem.js.map +1 -0
  25. package/filesystemAdapter.js +134 -52
  26. package/filesystemAdapter.js.map +1 -0
  27. package/filesystemManager.js +140 -57
  28. package/filesystemManager.js.map +1 -0
  29. package/filesystemServiceProvider.js +49 -21
  30. package/filesystemServiceProvider.js.map +1 -0
  31. package/invalidArgumentException.js +26 -4
  32. package/invalidArgumentException.js.map +1 -0
  33. package/package.json +24 -10
  34. package/types/adapter/CoreAdapter.d.ts +139 -0
  35. package/types/adapter/CoreAdapter.d.ts.map +1 -0
  36. package/types/adapter/azure.d.ts +36 -0
  37. package/types/adapter/azure.d.ts.map +1 -0
  38. package/types/adapter/local.d.ts +78 -0
  39. package/types/adapter/local.d.ts.map +1 -0
  40. package/types/adapter/s3.d.ts +36 -0
  41. package/types/adapter/s3.d.ts.map +1 -0
  42. package/types/callbackHandler.d.ts +69 -0
  43. package/types/callbackHandler.d.ts.map +1 -0
  44. package/types/clients/azure.d.ts +32 -0
  45. package/types/clients/azure.d.ts.map +1 -0
  46. package/types/clients/s3.d.ts +27 -0
  47. package/types/clients/s3.d.ts.map +1 -0
  48. package/types/directoryCreateException.d.ts +18 -0
  49. package/types/directoryCreateException.d.ts.map +1 -0
  50. package/types/fileDeleteException.d.ts +19 -0
  51. package/types/fileDeleteException.d.ts.map +1 -0
  52. package/types/fileNotFoundException.d.ts +18 -0
  53. package/types/fileNotFoundException.d.ts.map +1 -0
  54. package/types/fileUploadException.d.ts +18 -0
  55. package/types/fileUploadException.d.ts.map +1 -0
  56. package/types/filesystem.d.ts +300 -0
  57. package/types/filesystem.d.ts.map +1 -0
  58. package/types/filesystemAdapter.d.ts +91 -0
  59. package/types/filesystemAdapter.d.ts.map +1 -0
  60. package/types/filesystemManager.d.ts +93 -0
  61. package/types/filesystemManager.d.ts.map +1 -0
  62. package/types/filesystemServiceProvider.d.ts +40 -0
  63. package/types/filesystemServiceProvider.d.ts.map +1 -0
  64. package/types/invalidArgumentException.d.ts +17 -0
  65. package/types/invalidArgumentException.d.ts.map +1 -0
  66. package/.github/workflows/npm-publish.yml +0 -22
package/clients/azure.js CHANGED
@@ -1,27 +1,57 @@
1
- const { BlobServiceClient, StorageSharedKeyCredential } = require("@azure/storage-blob");
2
- const kContainer = Symbol('container')
3
- const kConnection = Symbol('connection')
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const kContainer = Symbol('container');
4
+ const kConnection = Symbol('connection');
5
+ /**
6
+ * Class AzureClient.
7
+ */
4
8
  class AzureClient {
9
+ [kContainer];
10
+ [kConnection];
11
+ /**
12
+ * Create a new instance.
13
+ *
14
+ * @param $config - Azure connection configuration.
15
+ */
5
16
  constructor($config) {
6
17
  this[kConnection] = this.getConnection($config['account'], Buffer.from($config['key'], 'base64').toString('ascii'));
7
18
  this[kContainer] = this.getContainer($config['container']);
8
- return this
19
+ return this;
9
20
  }
21
+ /**
22
+ * getConnection method.
23
+ *
24
+ * @param account - Storage account name.
25
+ * @param key - Storage account key.
26
+ * @returns BlobServiceClient instance or existing connection.
27
+ */
10
28
  getConnection(account, key) {
11
29
  if (account || key) {
12
- return new BlobServiceClient(
13
- `https://${account}.blob.core.windows.net`,
14
- new StorageSharedKeyCredential(account, key)
15
- );
30
+ const azureBlob = require('@azure/storage-blob');
31
+ const BlobServiceClient = azureBlob.BlobServiceClient;
32
+ const StorageSharedKeyCredential = azureBlob.StorageSharedKeyCredential;
33
+ return new BlobServiceClient(`https://${account}.blob.core.windows.net`, new StorageSharedKeyCredential(account, key));
16
34
  }
17
- return this[kConnection]
35
+ return this[kConnection];
18
36
  }
37
+ /**
38
+ * getContainer method.
39
+ *
40
+ * @param container - Container name.
41
+ * @returns ContainerClient instance or default container.
42
+ */
19
43
  getContainer(container) {
20
44
  if (container) {
21
- return this[kConnection].getContainerClient(container)
45
+ return this[kConnection].getContainerClient(container);
22
46
  }
23
- return this[kContainer]
47
+ return this[kContainer];
24
48
  }
25
-
26
49
  }
27
- module.exports = AzureClient
50
+ exports.default = AzureClient;
51
+ //# sourceMappingURL=azure.js.map
52
+ if (exports.default) {
53
+ const d = exports.default;
54
+ module.exports = d;
55
+ Object.assign(module.exports, exports);
56
+ module.exports.default = d;
57
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.js","sourceRoot":"","sources":["../../src/clients/azure.ts"],"names":[],"mappings":";;AAAA,MAAM,UAAU,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AACtD,MAAM,WAAW,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW;IACb,CAAC,UAAU,CAAC,CAAM;IAClB,CAAC,WAAW,CAAC,CAAM;IAEnB;;;;OAIG;IACH,YAAY,OAA4B;QACpC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACpH,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,OAAgB,EAAE,GAAY;QAC/C,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;YACjD,MAAM,iBAAiB,GAAG,SAAS,CAAC,iBAAiB,CAAC;YACtD,MAAM,0BAA0B,GAAG,SAAS,CAAC,0BAA0B,CAAC;YACxE,OAAO,IAAI,iBAAiB,CACxB,WAAW,OAAO,wBAAwB,EAC1C,IAAI,0BAA0B,CAAC,OAAQ,EAAE,GAAI,CAAC,CACjD,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,SAAkB;QAClC,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
package/clients/s3.js CHANGED
@@ -1,17 +1,48 @@
1
- const { S3 } = require("aws-sdk");
2
- const kConnection = Symbol('connection')
3
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const kConnection = Symbol('connection');
4
+ /**
5
+ * Class S3Client.
6
+ */
4
7
  class S3Client {
8
+ [kConnection];
9
+ /**
10
+ * Create a new instance.
11
+ *
12
+ * @param $config - S3 connection options.
13
+ */
5
14
  constructor($config) {
6
- this.applyConnection($config)
7
- return this
15
+ this.applyConnection($config);
16
+ return this;
8
17
  }
18
+ /**
19
+ * getConnection method.
20
+ *
21
+ * @returns S3 instance.
22
+ */
9
23
  getConnection() {
10
- return this[kConnection]
24
+ return this[kConnection];
11
25
  }
26
+ /**
27
+ * applyConnection method.
28
+ *
29
+ * @param $config - S3 connection options.
30
+ */
12
31
  applyConnection($config) {
13
- this[kConnection] = new S3({ accessKeyId: $config['key'], secretAccessKey: $config['secret'], params: { Bucket: $config['bucket'] } })
32
+ const awsSdk = require('aws-sdk');
33
+ const S3 = awsSdk.S3;
34
+ this[kConnection] = new S3({
35
+ accessKeyId: $config['key'],
36
+ secretAccessKey: $config['secret'],
37
+ params: { Bucket: $config['bucket'] }
38
+ });
14
39
  }
15
-
16
40
  }
17
- module.exports = S3Client
41
+ exports.default = S3Client;
42
+ //# sourceMappingURL=s3.js.map
43
+ if (exports.default) {
44
+ const d = exports.default;
45
+ module.exports = d;
46
+ Object.assign(module.exports, exports);
47
+ module.exports.default = d;
48
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3.js","sourceRoot":"","sources":["../../src/clients/s3.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,QAAQ;IACV,CAAC,WAAW,CAAC,CAAM;IAEnB;;;;OAIG;IACH,YAAY,OAA4B;QACpC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,aAAa;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,eAAe,CAAC,OAA4B;QAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,EAAE,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC;YAC3B,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC;YAClC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;SACxC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,kBAAe,QAAQ,CAAC"}
@@ -1,14 +1,36 @@
1
- const DirectoryCreateExceptionContract = require('@ostro/contracts/filesystem/directoryCreateException')
2
- class DirectoryCreateException extends DirectoryCreateExceptionContract {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const directoryCreateException_1 = __importDefault(require("@ostro/contracts/filesystem/directoryCreateException"));
7
+ /**
8
+ * Class DirectoryCreateException.
9
+ */
10
+ class DirectoryCreateException extends directoryCreateException_1.default {
11
+ name;
12
+ message;
13
+ errors;
14
+ statusCode;
15
+ /**
16
+ * Create a new instance.
17
+ *
18
+ * @param errors - Error details or message.
19
+ */
3
20
  constructor(errors) {
4
21
  super();
5
-
6
22
  this.name = this.constructor.name;
7
23
  this.message = 'Unable to create directory';
8
24
  this.errors = errors;
9
25
  this.statusCode = 404;
10
26
  Error.captureStackTrace(this, this.constructor);
11
-
12
27
  }
13
28
  }
14
- module.exports = DirectoryCreateException
29
+ exports.default = DirectoryCreateException;
30
+ //# sourceMappingURL=directoryCreateException.js.map
31
+ if (exports.default) {
32
+ const d = exports.default;
33
+ module.exports = d;
34
+ Object.assign(module.exports, exports);
35
+ module.exports.default = d;
36
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryCreateException.js","sourceRoot":"","sources":["../src/directoryCreateException.ts"],"names":[],"mappings":";;;;;AAAA,oHAAoG;AAEpG;;GAEG;AACH,MAAM,wBAAyB,SAAQ,kCAAgC;IAC5D,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,UAAU,CAAS;IAE1B;;;;OAIG;IACH,YAAY,MAAe;QACvB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,4BAA4B,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ;AAED,kBAAe,wBAAwB,CAAC"}
@@ -1,5 +1,23 @@
1
- const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
2
- class FileNotFoundException extends fileNotFoundExceptionContract {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fileNotFoundException_1 = __importDefault(require("@ostro/contracts/filesystem/fileNotFoundException"));
7
+ /**
8
+ * Class FileNotFoundException.
9
+ */
10
+ class FileNotFoundException extends fileNotFoundException_1.default {
11
+ name;
12
+ message;
13
+ errors;
14
+ statusCode;
15
+ /**
16
+ * Create a new instance.
17
+ *
18
+ * @param errors - Error details or message.
19
+ * @param path - File path that failed to delete.
20
+ */
3
21
  constructor(errors, path) {
4
22
  super();
5
23
  this.name = this.constructor.name;
@@ -7,7 +25,13 @@ class FileNotFoundException extends fileNotFoundExceptionContract {
7
25
  this.errors = errors;
8
26
  this.statusCode = 500;
9
27
  Error.captureStackTrace(this, this.constructor);
10
-
11
28
  }
12
29
  }
13
- module.exports = FileNotFoundException
30
+ exports.default = FileNotFoundException;
31
+ //# sourceMappingURL=fileDeleteException.js.map
32
+ if (exports.default) {
33
+ const d = exports.default;
34
+ module.exports = d;
35
+ Object.assign(module.exports, exports);
36
+ module.exports.default = d;
37
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileDeleteException.js","sourceRoot":"","sources":["../src/fileDeleteException.ts"],"names":[],"mappings":";;;;;AAAA,8GAA8F;AAE9F;;GAEG;AACH,MAAM,qBAAsB,SAAQ,+BAA6B;IACtD,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,UAAU,CAAS;IAE1B;;;;;OAKG;IACH,YAAY,MAAe,EAAE,IAAa;QACtC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ;AAED,kBAAe,qBAAqB,CAAC"}
@@ -1,14 +1,36 @@
1
- const fileNotFoundExceptionContract = require('@ostro/contracts/filesystem/fileNotFoundException')
2
- class FileNotFoundException extends fileNotFoundExceptionContract {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fileNotFoundException_1 = __importDefault(require("@ostro/contracts/filesystem/fileNotFoundException"));
7
+ /**
8
+ * Class FileNotFoundException.
9
+ */
10
+ class FileNotFoundException extends fileNotFoundException_1.default {
11
+ name;
12
+ message;
13
+ errors;
14
+ statusCode;
15
+ /**
16
+ * Create a new instance.
17
+ *
18
+ * @param errors - Error details or message.
19
+ */
3
20
  constructor(errors) {
4
21
  super();
5
-
6
22
  this.name = this.constructor.name;
7
23
  this.message = 'Specefied file is not found';
8
24
  this.errors = errors;
9
25
  this.statusCode = 404;
10
26
  Error.captureStackTrace(this, this.constructor);
11
-
12
27
  }
13
28
  }
14
- module.exports = FileNotFoundException
29
+ exports.default = FileNotFoundException;
30
+ //# sourceMappingURL=fileNotFoundException.js.map
31
+ if (exports.default) {
32
+ const d = exports.default;
33
+ module.exports = d;
34
+ Object.assign(module.exports, exports);
35
+ module.exports.default = d;
36
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileNotFoundException.js","sourceRoot":"","sources":["../src/fileNotFoundException.ts"],"names":[],"mappings":";;;;;AAAA,8GAA8F;AAE9F;;GAEG;AACH,MAAM,qBAAsB,SAAQ,+BAA6B;IACtD,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,UAAU,CAAS;IAE1B;;;;OAIG;IACH,YAAY,MAAe;QACvB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,6BAA6B,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ;AAED,kBAAe,qBAAqB,CAAC"}
@@ -1,13 +1,36 @@
1
- const FileUploadExceptionContract = require('@ostro/contracts/filesystem/fileUploadException')
2
- class FileUploadException extends FileUploadExceptionContract {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fileUploadException_1 = __importDefault(require("@ostro/contracts/filesystem/fileUploadException"));
7
+ /**
8
+ * Class FileUploadException.
9
+ */
10
+ class FileUploadException extends fileUploadException_1.default {
11
+ name;
12
+ message;
13
+ errors;
14
+ statusCode;
15
+ /**
16
+ * Create a new instance.
17
+ *
18
+ * @param errors - Error details or message.
19
+ */
3
20
  constructor(errors) {
4
21
  super();
5
22
  this.name = this.constructor.name;
6
23
  this.message = 'Error in upload file';
7
- this.errors = errors
24
+ this.errors = errors;
8
25
  this.statusCode = 500;
9
26
  Error.captureStackTrace(this, this.constructor);
10
-
11
27
  }
12
28
  }
13
- module.exports = FileUploadException
29
+ exports.default = FileUploadException;
30
+ //# sourceMappingURL=fileUploadException.js.map
31
+ if (exports.default) {
32
+ const d = exports.default;
33
+ module.exports = d;
34
+ Object.assign(module.exports, exports);
35
+ module.exports.default = d;
36
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileUploadException.js","sourceRoot":"","sources":["../src/fileUploadException.ts"],"names":[],"mappings":";;;;;AAAA,0GAA0F;AAE1F;;GAEG;AACH,MAAM,mBAAoB,SAAQ,6BAA2B;IAClD,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,UAAU,CAAS;IAE1B;;;;OAIG;IACH,YAAY,MAAe;QACvB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ;AAED,kBAAe,mBAAmB,CAAC"}