@ostro/filesystem 1.0.3 → 2.0.0-alpha.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.
Files changed (66) hide show
  1. package/adapter/CoreAdapter.d.ts +139 -0
  2. package/adapter/CoreAdapter.d.ts.map +1 -0
  3. package/adapter/CoreAdapter.js +164 -57
  4. package/adapter/CoreAdapter.js.map +1 -0
  5. package/adapter/azure.d.ts +36 -0
  6. package/adapter/azure.d.ts.map +1 -0
  7. package/adapter/azure.js +93 -56
  8. package/adapter/azure.js.map +1 -0
  9. package/adapter/local.d.ts +78 -0
  10. package/adapter/local.d.ts.map +1 -0
  11. package/adapter/local.js +136 -66
  12. package/adapter/local.js.map +1 -0
  13. package/adapter/s3.d.ts +36 -0
  14. package/adapter/s3.d.ts.map +1 -0
  15. package/adapter/s3.js +102 -70
  16. package/adapter/s3.js.map +1 -0
  17. package/callbackHandler.d.ts +69 -0
  18. package/callbackHandler.d.ts.map +1 -0
  19. package/callbackHandler.js +93 -23
  20. package/callbackHandler.js.map +1 -0
  21. package/clients/azure.d.ts +32 -0
  22. package/clients/azure.d.ts.map +1 -0
  23. package/clients/azure.js +43 -13
  24. package/clients/azure.js.map +1 -0
  25. package/clients/s3.d.ts +27 -0
  26. package/clients/s3.d.ts.map +1 -0
  27. package/clients/s3.js +40 -9
  28. package/clients/s3.js.map +1 -0
  29. package/directoryCreateException.d.ts +18 -0
  30. package/directoryCreateException.d.ts.map +1 -0
  31. package/directoryCreateException.js +27 -5
  32. package/directoryCreateException.js.map +1 -0
  33. package/fileDeleteException.d.ts +19 -0
  34. package/fileDeleteException.d.ts.map +1 -0
  35. package/fileDeleteException.js +28 -4
  36. package/fileDeleteException.js.map +1 -0
  37. package/fileNotFoundException.d.ts +18 -0
  38. package/fileNotFoundException.d.ts.map +1 -0
  39. package/fileNotFoundException.js +27 -5
  40. package/fileNotFoundException.js.map +1 -0
  41. package/fileUploadException.d.ts +18 -0
  42. package/fileUploadException.d.ts.map +1 -0
  43. package/fileUploadException.js +28 -5
  44. package/fileUploadException.js.map +1 -0
  45. package/filesystem.d.ts +300 -0
  46. package/filesystem.d.ts.map +1 -0
  47. package/filesystem.js +389 -192
  48. package/filesystem.js.map +1 -0
  49. package/filesystemAdapter.d.ts +91 -0
  50. package/filesystemAdapter.d.ts.map +1 -0
  51. package/filesystemAdapter.js +134 -52
  52. package/filesystemAdapter.js.map +1 -0
  53. package/filesystemManager.d.ts +94 -0
  54. package/filesystemManager.d.ts.map +1 -0
  55. package/filesystemManager.js +141 -57
  56. package/filesystemManager.js.map +1 -0
  57. package/filesystemServiceProvider.d.ts +40 -0
  58. package/filesystemServiceProvider.d.ts.map +1 -0
  59. package/filesystemServiceProvider.js +49 -21
  60. package/filesystemServiceProvider.js.map +1 -0
  61. package/invalidArgumentException.d.ts +17 -0
  62. package/invalidArgumentException.d.ts.map +1 -0
  63. package/invalidArgumentException.js +26 -4
  64. package/invalidArgumentException.js.map +1 -0
  65. package/package.json +24 -10
  66. package/.github/workflows/npm-publish.yml +0 -22
@@ -0,0 +1,139 @@
1
+ import path from 'path';
2
+ declare const kConfig: unique symbol;
3
+ declare const kRootPath: unique symbol;
4
+ declare const kRootUrlPath: unique symbol;
5
+ /**
6
+ * Class CoreAdapter.
7
+ */
8
+ declare class CoreAdapter {
9
+ [kConfig]: Record<string, any> | null;
10
+ [kRootPath]: string;
11
+ [kRootUrlPath]: string;
12
+ /**
13
+ * setConfig method.
14
+ *
15
+ * @param config - Configuration object.
16
+ */
17
+ setConfig(config: Record<string, any>): void;
18
+ /**
19
+ * getConfig method.
20
+ *
21
+ * @returns Configuration object or null.
22
+ */
23
+ getConfig(): Record<string, any> | null;
24
+ /**
25
+ * setPathPrefix method.
26
+ *
27
+ * @param root - Root directory path prefix.
28
+ */
29
+ setPathPrefix(root: string): void;
30
+ /**
31
+ * setUrlPrefix method.
32
+ *
33
+ * @param root - Root URL prefix.
34
+ */
35
+ setUrlPrefix(root: string): void;
36
+ /**
37
+ * applyPathPrefix method.
38
+ *
39
+ * @param dest - Target path.
40
+ * @returns Resolved absolute path.
41
+ */
42
+ applyPathPrefix(dest: string): string;
43
+ /**
44
+ * applyUrlPrefix method.
45
+ *
46
+ * @param dest - Target path or URL segment.
47
+ * @returns Resolved URL string.
48
+ */
49
+ applyUrlPrefix(dest?: string): string;
50
+ /**
51
+ * ensureDirectory method.
52
+ *
53
+ * @param dir - Directory path to ensure exists.
54
+ * @param callback - Completion callback.
55
+ */
56
+ ensureDirectory(dir: string, callback: (err?: any) => void): void;
57
+ /**
58
+ * parsePath method.
59
+ *
60
+ * @param dest - Path to parse.
61
+ * @returns Parsed path object.
62
+ */
63
+ parsePath(dest: string): path.ParsedPath;
64
+ /**
65
+ * dirname method.
66
+ *
67
+ * @param dest - Path to get directory name of.
68
+ * @returns Directory path.
69
+ */
70
+ dirname(dest: string): string;
71
+ /**
72
+ * getContent method.
73
+ *
74
+ * @param content - Content or array of contents.
75
+ * @returns Single content element.
76
+ */
77
+ getContent<T = unknown>(content: T | T[]): T;
78
+ /**
79
+ * getBufferData method.
80
+ *
81
+ * @param content - Content containing buffer.
82
+ * @returns Buffer instance.
83
+ */
84
+ getBufferData(content: any): any;
85
+ /**
86
+ * move method.
87
+ *
88
+ * @param path - Source path.
89
+ * @param newpath - Destination path.
90
+ * @param callback - Result callback.
91
+ */
92
+ move(path: string, newpath: any, callback: Function): void;
93
+ /**
94
+ * delete method.
95
+ *
96
+ * @param $path - Target path.
97
+ * @param options - Deletion options.
98
+ * @param callback - Result callback.
99
+ */
100
+ delete($path: string, options: Record<string, any>, callback: Function): void;
101
+ /**
102
+ * has method.
103
+ *
104
+ * @param $path - Target path.
105
+ * @param options - Check options.
106
+ * @param callback - Result callback.
107
+ */
108
+ has($path: string, options: Record<string, any>, callback: Function): void;
109
+ /**
110
+ * write method.
111
+ *
112
+ * @param $path - Target path.
113
+ * @param $contents - Contents to write.
114
+ * @param options - Write options.
115
+ * @param rest - Additional arguments including callback.
116
+ */
117
+ write($path: string, $contents: any, options?: Record<string, any>, ...rest: any[]): void;
118
+ /**
119
+ * read method.
120
+ *
121
+ * @param $path - Target path.
122
+ * @param options - Read options.
123
+ * @param callback - Result callback.
124
+ */
125
+ read($path: string, options: Record<string, any>, callback: Function): void;
126
+ /**
127
+ * formatError method.
128
+ *
129
+ * @param err - Inner error.
130
+ * @returns Formatted error object.
131
+ */
132
+ formatError(err: unknown): {
133
+ message: string;
134
+ errors: unknown;
135
+ status: number;
136
+ };
137
+ }
138
+ export default CoreAdapter;
139
+ //# sourceMappingURL=CoreAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreAdapter.d.ts","sourceRoot":"","sources":["../../src/adapter/CoreAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,QAAA,MAAM,OAAO,EAAE,OAAO,MAAyB,CAAC;AAChD,QAAA,MAAM,SAAS,EAAE,OAAO,MAA2B,CAAC;AACpD,QAAA,MAAM,YAAY,EAAE,OAAO,MAA8B,CAAC;AAE1D;;GAEG;AACH,cAAM,WAAW;IACb,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAQ;IAC7C,CAAC,SAAS,CAAC,EAAE,MAAM,CAAM;IACzB,CAAC,YAAY,CAAC,EAAE,MAAM,CAAM;IAE5B;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAInD;;;;OAIG;IACI,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAI9C;;;;OAIG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxC;;;;OAIG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC;;;;;OAKG;IACI,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;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AQ,GAAG,IAAI;IAIvF;;;;;OAKG;IACI,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAOzF;AAED,eAAe,WAAW,CAAC"}
@@ -1,85 +1,192 @@
1
- const path = require('path')
2
- const url = require('url')
3
- const { ensureDir } = require('fs-extra')
4
- const kConfig = Symbol('config')
5
- const kRootPath = Symbol('rootPath')
6
- const kRootUrlPath = Symbol('rootUrlPath')
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 path_1 = __importDefault(require("path"));
7
+ const url_1 = __importDefault(require("url"));
8
+ const fs_extra_1 = require("fs-extra");
9
+ const kConfig = Symbol('config');
10
+ const kRootPath = Symbol('rootPath');
11
+ const kRootUrlPath = Symbol('rootUrlPath');
12
+ /**
13
+ * Class CoreAdapter.
14
+ */
7
15
  class CoreAdapter {
16
+ [kConfig] = null;
17
+ [kRootPath] = '';
18
+ [kRootUrlPath] = '';
19
+ /**
20
+ * setConfig method.
21
+ *
22
+ * @param config - Configuration object.
23
+ */
8
24
  setConfig(config) {
9
- this[kConfig] = config
25
+ this[kConfig] = config;
10
26
  }
11
-
27
+ /**
28
+ * getConfig method.
29
+ *
30
+ * @returns Configuration object or null.
31
+ */
12
32
  getConfig() {
13
- return this[kConfig] || null
33
+ return this[kConfig] || null;
14
34
  }
15
-
35
+ /**
36
+ * setPathPrefix method.
37
+ *
38
+ * @param root - Root directory path prefix.
39
+ */
16
40
  setPathPrefix(root) {
17
- this[kRootPath] = root
41
+ this[kRootPath] = root;
18
42
  }
19
-
43
+ /**
44
+ * setUrlPrefix method.
45
+ *
46
+ * @param root - Root URL prefix.
47
+ */
20
48
  setUrlPrefix(root) {
21
- this[kRootUrlPath] = root
22
- }
23
-
49
+ this[kRootUrlPath] = root;
50
+ }
51
+ /**
52
+ * applyPathPrefix method.
53
+ *
54
+ * @param dest - Target path.
55
+ * @returns Resolved absolute path.
56
+ */
24
57
  applyPathPrefix(dest) {
25
- return path.resolve(path.join(this[kRootPath], path.join('/', path.normalize(dest))))
26
- }
27
-
58
+ return path_1.default.resolve(path_1.default.join(this[kRootPath], path_1.default.join('/', path_1.default.normalize(dest))));
59
+ }
60
+ /**
61
+ * applyUrlPrefix method.
62
+ *
63
+ * @param dest - Target path or URL segment.
64
+ * @returns Resolved URL string.
65
+ */
28
66
  applyUrlPrefix(dest) {
29
- return url.resolve(([this[kRootUrlPath], (dest || '')].join('/')), '')
30
- }
31
-
67
+ return url_1.default.resolve(([this[kRootUrlPath], (dest || '')].join('/')), '');
68
+ }
69
+ /**
70
+ * ensureDirectory method.
71
+ *
72
+ * @param dir - Directory path to ensure exists.
73
+ * @param callback - Completion callback.
74
+ */
32
75
  ensureDirectory(dir, callback) {
33
- ensureDir(dir, callback)
34
- }
35
-
76
+ (0, fs_extra_1.ensureDir)(dir, callback);
77
+ }
78
+ /**
79
+ * parsePath method.
80
+ *
81
+ * @param dest - Path to parse.
82
+ * @returns Parsed path object.
83
+ */
36
84
  parsePath(dest) {
37
- return path.parse(dest)
38
- }
39
-
85
+ return path_1.default.parse(dest);
86
+ }
87
+ /**
88
+ * dirname method.
89
+ *
90
+ * @param dest - Path to get directory name of.
91
+ * @returns Directory path.
92
+ */
40
93
  dirname(dest) {
41
- return this.parsePath(dest).dir
42
- }
43
-
94
+ return this.parsePath(dest).dir;
95
+ }
96
+ /**
97
+ * getContent method.
98
+ *
99
+ * @param content - Content or array of contents.
100
+ * @returns Single content element.
101
+ */
44
102
  getContent(content) {
45
- if (Array.isArray(content))
46
- return content[0]
47
- else
48
- return content
103
+ if (Array.isArray(content)) {
104
+ return content[0];
105
+ }
106
+ else {
107
+ return content;
108
+ }
49
109
  }
50
-
110
+ /**
111
+ * getBufferData method.
112
+ *
113
+ * @param content - Content containing buffer.
114
+ * @returns Buffer instance.
115
+ */
51
116
  getBufferData(content) {
52
- return this.getContent(content).buffer
53
- }
117
+ return this.getContent(content).buffer;
118
+ }
119
+ /**
120
+ * move method.
121
+ *
122
+ * @param path - Source path.
123
+ * @param newpath - Destination path.
124
+ * @param callback - Result callback.
125
+ */
54
126
  move(path, newpath, callback) {
55
- callback(this.formatError({ message: 'there was no such functionality available.' }), {})
56
- }
57
-
127
+ callback(this.formatError({ message: 'there was no such functionality available.' }), {});
128
+ }
129
+ /**
130
+ * delete method.
131
+ *
132
+ * @param $path - Target path.
133
+ * @param options - Deletion options.
134
+ * @param callback - Result callback.
135
+ */
58
136
  delete($path, options = {}, callback) {
59
- callback(this.formatError({ message: 'there was no such functionality available.' }), {})
60
-
61
- }
62
-
137
+ callback(this.formatError({ message: 'there was no such functionality available.' }), {});
138
+ }
139
+ /**
140
+ * has method.
141
+ *
142
+ * @param $path - Target path.
143
+ * @param options - Check options.
144
+ * @param callback - Result callback.
145
+ */
63
146
  has($path, options = {}, callback) {
64
- callback(this.formatError({ message: 'there was no such functionality available.' }), {})
65
-
66
- }
67
-
147
+ callback(this.formatError({ message: 'there was no such functionality available.' }), {});
148
+ }
149
+ /**
150
+ * write method.
151
+ *
152
+ * @param $path - Target path.
153
+ * @param $contents - Contents to write.
154
+ * @param options - Write options.
155
+ * @param rest - Additional arguments including callback.
156
+ */
68
157
  write($path, $contents, options = {}, ...rest) {
69
- callback(this.formatError({ message: 'there was no such functionality available.' }), {})
70
-
71
- }
72
-
158
+ const callback = Array.from(rest).find(arg => typeof arg == 'function') || (typeof options == 'function' ? options : () => { });
159
+ callback(this.formatError({ message: 'there was no such functionality available.' }), {});
160
+ }
161
+ /**
162
+ * read method.
163
+ *
164
+ * @param $path - Target path.
165
+ * @param options - Read options.
166
+ * @param callback - Result callback.
167
+ */
73
168
  read($path, options = {}, callback) {
74
- callback(this.formatError({ message: 'there was no such functionality available.' }), {})
75
-
76
- }
169
+ callback(this.formatError({ message: 'there was no such functionality available.' }), {});
170
+ }
171
+ /**
172
+ * formatError method.
173
+ *
174
+ * @param err - Inner error.
175
+ * @returns Formatted error object.
176
+ */
77
177
  formatError(err) {
78
178
  return {
79
179
  'message': 'Storage Error',
80
180
  'errors': err,
81
181
  'status': 500
82
- }
182
+ };
83
183
  }
84
184
  }
85
- module.exports = CoreAdapter
185
+ exports.default = CoreAdapter;
186
+ //# sourceMappingURL=CoreAdapter.js.map
187
+ if (exports.default) {
188
+ const d = exports.default;
189
+ module.exports = d;
190
+ Object.assign(module.exports, exports);
191
+ module.exports.default = d;
192
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreAdapter.js","sourceRoot":"","sources":["../../src/adapter/CoreAdapter.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,8CAAsB;AACtB,uCAAqC;AAErC,MAAM,OAAO,GAAkB,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChD,MAAM,SAAS,GAAkB,MAAM,CAAC,UAAU,CAAC,CAAC;AACpD,MAAM,YAAY,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW;IACb,CAAC,OAAO,CAAC,GAA+B,IAAI,CAAC;IAC7C,CAAC,SAAS,CAAC,GAAW,EAAE,CAAC;IACzB,CAAC,YAAY,CAAC,GAAW,EAAE,CAAC;IAE5B;;;;OAIG;IACI,SAAS,CAAC,MAA2B;QACxC,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,IAAY;QAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,IAAY;QAC5B,IAAI,CAAC,YAAY,CAAC,GAAG,IAA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B,QAAQ,EAAE,GAAG;YACb,QAAQ,EAAE,GAAG;SAChB,CAAC;IACN,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,36 @@
1
+ import CoreAdapter from './CoreAdapter';
2
+ declare const kClient: unique symbol;
3
+ declare const kHandler: unique symbol;
4
+ /**
5
+ * Class Azure.
6
+ */
7
+ declare class Azure extends CoreAdapter {
8
+ [kClient]: any;
9
+ [kHandler]: any;
10
+ /**
11
+ * Create a new instance.
12
+ *
13
+ * @param $client - Azure client instance.
14
+ * @param $config - Configuration options.
15
+ */
16
+ constructor($client: any, $config: Record<string, any>);
17
+ /**
18
+ * read method.
19
+ *
20
+ * @param $path - File path to read.
21
+ * @param options - Read options.
22
+ * @param callback - Completion callback.
23
+ */
24
+ read($path: string, options: Record<string, any>, callback: Function): void;
25
+ /**
26
+ * write method.
27
+ *
28
+ * @param $path - Destination file path.
29
+ * @param data - File content to upload.
30
+ * @param options - Upload options.
31
+ * @param callback - Completion callback.
32
+ */
33
+ write($path: string, data: any, options: Record<string, any>, callback: Function): void;
34
+ }
35
+ export default Azure;
36
+ //# sourceMappingURL=azure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.d.ts","sourceRoot":"","sources":["../../src/adapter/azure.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,QAAA,MAAM,OAAO,EAAE,OAAO,MAAyB,CAAC;AAChD,QAAA,MAAM,QAAQ,EAAE,OAAO,MAA0B,CAAC;AAElD;;GAEG;AACH,cAAM,KAAM,SAAQ,WAAW;IAC3B,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;IAEhB;;;;;OAKG;gBACS,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOtD;;;;;;OAMG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA2BvF;;;;;;;OAOG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;CA2BtG;AAED,eAAe,KAAK,CAAC"}
package/adapter/azure.js CHANGED
@@ -1,68 +1,105 @@
1
- const CoreAdapter = require('./CoreAdapter')
2
- const kClient = Symbol('client')
3
- const kHandler = Symbol('handler')
4
- class Azure extends CoreAdapter {
5
-
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 CoreAdapter_1 = __importDefault(require("./CoreAdapter"));
7
+ const kClient = Symbol('client');
8
+ const kHandler = Symbol('handler');
9
+ /**
10
+ * Class Azure.
11
+ */
12
+ class Azure extends CoreAdapter_1.default {
13
+ [kClient];
14
+ [kHandler];
15
+ /**
16
+ * Create a new instance.
17
+ *
18
+ * @param $client - Azure client instance.
19
+ * @param $config - Configuration options.
20
+ */
6
21
  constructor($client, $config) {
7
- super()
22
+ super();
8
23
  this[kClient] = $client;
9
- this[kHandler] = typeof $config.handler == 'function' ? new $config.handler : typeof $config.handler == 'object' ? $config.handler : {};
10
- this.setUrlPrefix(this[kClient].url)
24
+ this[kHandler] = typeof $config.handler == 'function' ? new $config.handler() : typeof $config.handler == 'object' ? $config.handler : {};
25
+ this.setUrlPrefix(this[kClient].url);
11
26
  }
12
-
27
+ /**
28
+ * read method.
29
+ *
30
+ * @param $path - File path to read.
31
+ * @param options - Read options.
32
+ * @param callback - Completion callback.
33
+ */
13
34
  read($path, options = {}, callback) {
14
- let basePath = this.applyUrlPrefix();
35
+ const basePath = this.applyUrlPrefix();
15
36
  this[kClient].getContainer(options.container).getBlockBlobClient($path).downloadToBuffer()
16
- .then(data => ({ error: null, data: data }))
17
- .catch(error => Promise.resolve({ error, data: null }))
37
+ .then((data) => ({ error: null, data: data }))
38
+ .catch((error) => Promise.resolve({ error, data: null }))
18
39
  .then(({ error, data }) => {
19
- if (typeof this[kHandler].read == 'function') {
20
- this[kHandler].read({
21
- path: $path,
22
- options,
23
- callback,
24
- error,
25
- basePath,
26
- contents: data
27
- })
28
- } else {
29
- callback(error, function() {
30
- return {
31
- 'type': 'file',
32
- 'path': $path,
33
- 'contents': (options.dataType == 'base64') ? data.toString('base64') : data.toString(),
34
- }
35
- }, basePath)
36
- }
37
- });
40
+ if (typeof this[kHandler].read == 'function') {
41
+ this[kHandler].read({
42
+ path: $path,
43
+ options,
44
+ callback,
45
+ error,
46
+ basePath,
47
+ contents: data
48
+ });
49
+ }
50
+ else {
51
+ callback(error, function () {
52
+ return {
53
+ 'type': 'file',
54
+ 'path': $path,
55
+ 'contents': (options.dataType == 'base64') ? data.toString('base64') : data.toString(),
56
+ };
57
+ }, basePath);
58
+ }
59
+ });
38
60
  }
61
+ /**
62
+ * write method.
63
+ *
64
+ * @param $path - Destination file path.
65
+ * @param data - File content to upload.
66
+ * @param options - Upload options.
67
+ * @param callback - Completion callback.
68
+ */
39
69
  write($path, data, options = {}, callback) {
40
- let basePath = this.applyUrlPrefix();
70
+ const basePath = this.applyUrlPrefix();
41
71
  this[kClient].getContainer(options.container).getBlockBlobClient($path).upload(data, data.length)
42
- .then(response => ({ error: null, response }))
43
- .catch(error => Promise.resolve({ error, response: null }))
72
+ .then((response) => ({ error: null, response }))
73
+ .catch((error) => Promise.resolve({ error, response: null }))
44
74
  .then(({ error, response }) => {
45
- if (typeof this[kHandler].read == 'function') {
46
- this[kHandler].write({
47
- path: $path,
48
- options,
49
- callback,
50
- error,
51
- basePath,
52
- response,
53
- contents: data
54
- })
55
- } else {
56
- callback(error, function() {
57
- return {
58
- 'type': 'file',
59
- 'path': $path,
60
- 'message': 'File uploaded successfully'
61
- }
62
- }, basePath)
63
- }
64
- });
75
+ if (typeof this[kHandler].write == 'function') {
76
+ this[kHandler].write({
77
+ path: $path,
78
+ options,
79
+ callback,
80
+ error,
81
+ basePath,
82
+ response,
83
+ contents: data
84
+ });
85
+ }
86
+ else {
87
+ callback(error, function () {
88
+ return {
89
+ 'type': 'file',
90
+ 'path': $path,
91
+ 'message': 'File uploaded successfully'
92
+ };
93
+ }, basePath);
94
+ }
95
+ });
65
96
  }
66
-
67
97
  }
68
- module.exports = Azure
98
+ exports.default = Azure;
99
+ //# sourceMappingURL=azure.js.map
100
+ if (exports.default) {
101
+ const d = exports.default;
102
+ module.exports = d;
103
+ Object.assign(module.exports, exports);
104
+ module.exports.default = d;
105
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.js","sourceRoot":"","sources":["../../src/adapter/azure.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC,MAAM,OAAO,GAAkB,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChD,MAAM,QAAQ,GAAkB,MAAM,CAAC,SAAS,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,KAAM,SAAQ,qBAAW;IAC3B,CAAC,OAAO,CAAC,CAAM;IACf,CAAC,QAAQ,CAAC,CAAM;IAEhB;;;;;OAKG;IACH,YAAY,OAAY,EAAE,OAA4B;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1I,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG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