@sab-js/adapter-local 0.0.0-stage → 3.0.4

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.
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AdapterLocal = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const glob_1 = require("glob");
19
+ const rimraf_1 = require("rimraf");
20
+ const stream_1 = require("stream");
21
+ const general_1 = require("./types/general");
22
+ const AbstractAdapter_1 = require("./AbstractAdapter");
23
+ const util_1 = require("./util");
24
+ class AdapterLocal extends AbstractAdapter_1.AbstractAdapter {
25
+ constructor(config) {
26
+ super(config);
27
+ this._provider = general_1.Provider.LOCAL;
28
+ this._configError = null;
29
+ if (typeof config !== "string") {
30
+ this._config = Object.assign({}, config);
31
+ }
32
+ else {
33
+ const { value, error } = (0, util_1.parseUrl)(config);
34
+ if (value === null) {
35
+ this._configError = `[configError] ${error}`;
36
+ }
37
+ else {
38
+ const { protocol: type, username: directory, host: bucketName, searchParams } = value;
39
+ if (directory === null) {
40
+ this._configError = `[configError] please specify a directory`;
41
+ return;
42
+ }
43
+ if (searchParams !== null) {
44
+ this._config = Object.assign({ type, directory }, searchParams);
45
+ }
46
+ else {
47
+ this._config = { type, directory };
48
+ }
49
+ if (bucketName !== null) {
50
+ this._config.bucketName = bucketName;
51
+ }
52
+ }
53
+ // console.log(this._config);
54
+ }
55
+ if (typeof this.config.mode !== "undefined") {
56
+ this._config.mode = 0o777;
57
+ const { value, error } = (0, util_1.parseMode)(this.config.mode);
58
+ if (error !== null) {
59
+ this._configError = `[configError] ${error}`;
60
+ }
61
+ else if (value !== null) {
62
+ this._config.mode = value;
63
+ }
64
+ }
65
+ if (typeof this.config.directory !== "string") {
66
+ this._configError =
67
+ "[configError] You must specify a value for 'directory' for storage type 'local'";
68
+ }
69
+ if (typeof this.config.bucketName !== "undefined") {
70
+ this._bucketName = this.config.bucketName;
71
+ }
72
+ }
73
+ /**
74
+ * @param path
75
+ * creates a directory if it doesn't exist
76
+ */
77
+ createDirectory(path) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ try {
80
+ yield fs_1.default.promises.access(path, this._config.mode);
81
+ // return { value: false, error: `directory ${path} already exists` };
82
+ return { value: true, error: null };
83
+ }
84
+ catch (e) {
85
+ try {
86
+ yield fs_1.default.promises.mkdir(path, {
87
+ recursive: true,
88
+ mode: this._config.mode,
89
+ });
90
+ // const m = (await fs.promises.stat(path)).mode;
91
+ // console.log(m, this.options.mode);
92
+ return { value: true, error: null };
93
+ }
94
+ catch (e) {
95
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
96
+ }
97
+ }
98
+ });
99
+ }
100
+ globFiles(folder_1) {
101
+ return __awaiter(this, arguments, void 0, function* (folder, pattern = "**/*.*") {
102
+ try {
103
+ const files = yield (0, glob_1.glob)(`${folder}/${pattern}`, {});
104
+ return { value: files, error: null };
105
+ }
106
+ catch (e) {
107
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
108
+ }
109
+ });
110
+ }
111
+ // protected, called by methods of public API via AbstractAdapter
112
+ _listBuckets() {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ try {
115
+ const dirents = yield fs_1.default.promises.readdir(this._config.directory, { withFileTypes: true });
116
+ const files = dirents
117
+ .filter((dirent) => dirent.isFile() === false)
118
+ .map((dirent) => dirent.name);
119
+ // const stats = await Promise.all(
120
+ // files.map((f) => fs.promises.stat(path.join(this._config.directory, f)))
121
+ // );
122
+ return { value: files, error: null };
123
+ }
124
+ catch (e) {
125
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
126
+ }
127
+ });
128
+ }
129
+ _createBucket(name, _options) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ try {
132
+ const p = path_1.default.join(this._config.directory, name);
133
+ const created = yield this.createDirectory(p);
134
+ if (created) {
135
+ return { value: "ok", error: null };
136
+ }
137
+ else {
138
+ return { value: null, error: `Could not create bucket ${p}` };
139
+ }
140
+ }
141
+ catch (e) {
142
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
143
+ }
144
+ });
145
+ }
146
+ _addFile(params) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ const dest = path_1.default.join(this._config.directory, params.bucketName, params.targetPath);
149
+ const { error } = yield this.createDirectory(path_1.default.dirname(dest));
150
+ if (error !== null) {
151
+ return { value: null, error };
152
+ }
153
+ try {
154
+ let readStream;
155
+ if (typeof params.buffer !== "undefined") {
156
+ readStream = new stream_1.Readable();
157
+ readStream._read = () => { }; // _read is required but you can noop it
158
+ readStream.push(params.buffer);
159
+ readStream.push(null);
160
+ }
161
+ else if (typeof params.stream !== "undefined") {
162
+ readStream = params.stream;
163
+ }
164
+ // console.time();
165
+ const writeStream = fs_1.default.createWriteStream(dest, params.options);
166
+ return new Promise((resolve) => {
167
+ readStream
168
+ .pipe(writeStream)
169
+ .on("error", (e) => {
170
+ resolve({ value: null, error: `[readStream error] ${e.message}` });
171
+ })
172
+ .on("finish", () => {
173
+ resolve({ value: "ok", error: null });
174
+ });
175
+ writeStream.on("error", (e) => {
176
+ resolve({ value: null, error: `[writeStream error] ${e.message}` });
177
+ });
178
+ });
179
+ // console.timeEnd();
180
+ }
181
+ catch (e) {
182
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
183
+ }
184
+ });
185
+ }
186
+ _clearBucket(name) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ try {
189
+ // remove all files and folders inside bucket directory, but not the directory itself
190
+ const p = path_1.default.join(this._config.directory, name);
191
+ yield (0, rimraf_1.rimraf)(p, { preserveRoot: false });
192
+ return { value: "ok", error: null };
193
+ }
194
+ catch (e) {
195
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
196
+ }
197
+ });
198
+ }
199
+ _deleteBucket(name) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ try {
202
+ const p = path_1.default.join(this._config.directory, name);
203
+ yield (0, rimraf_1.rimraf)(p);
204
+ return { value: "ok", error: null };
205
+ }
206
+ catch (e) {
207
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
208
+ }
209
+ });
210
+ }
211
+ _listFiles(bucketName) {
212
+ return __awaiter(this, void 0, void 0, function* () {
213
+ try {
214
+ const storagePath = path_1.default.join(this._config.directory, bucketName);
215
+ const { value: files, error } = yield this.globFiles(storagePath);
216
+ if (files === null) {
217
+ return { value: null, error };
218
+ }
219
+ const result = [];
220
+ for (let i = 0; i < files.length; i += 1) {
221
+ const f = files[i];
222
+ const stat = yield fs_1.default.promises.stat(f);
223
+ // result.push([path.basename(f), stat.size])
224
+ result.push([f.replace(`${storagePath}/`, ""), stat.size]);
225
+ }
226
+ return { value: result, error: null };
227
+ }
228
+ catch (e) {
229
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
230
+ }
231
+ });
232
+ }
233
+ _getFileAsStream(bucketName, fileName, options) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ try {
236
+ const p = path_1.default.join(this._config.directory, bucketName, fileName);
237
+ yield fs_1.default.promises.access(p);
238
+ const stream = fs_1.default.createReadStream(p, options);
239
+ return { value: stream, error: null };
240
+ }
241
+ catch (e) {
242
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
243
+ }
244
+ });
245
+ }
246
+ _getPublicURL(bucketName, fileName, options) {
247
+ return __awaiter(this, void 0, void 0, function* () {
248
+ try {
249
+ const p = path_1.default.join(this._config.directory, bucketName, fileName);
250
+ try {
251
+ yield fs_1.default.promises.access(p);
252
+ }
253
+ catch (e) {
254
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
255
+ }
256
+ if (options.withoutDirectory) {
257
+ return { value: path_1.default.join(bucketName, fileName), error: null };
258
+ }
259
+ // public url is actually just a local path
260
+ return { value: p, error: null };
261
+ }
262
+ catch (e) {
263
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
264
+ }
265
+ });
266
+ }
267
+ _getSignedURL(bucketName, fileName, options) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ // signed urls are not available for the local adapter, return the public url
270
+ return this._getPublicURL(bucketName, fileName, options);
271
+ });
272
+ }
273
+ _removeFile(bucketName, fileName) {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ try {
276
+ const p = path_1.default.join(this._config.directory, bucketName, fileName);
277
+ yield fs_1.default.promises.unlink(p);
278
+ return { value: "ok", error: null };
279
+ }
280
+ catch (e) {
281
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
282
+ }
283
+ });
284
+ }
285
+ _sizeOf(bucketName, fileName) {
286
+ return __awaiter(this, void 0, void 0, function* () {
287
+ try {
288
+ const p = path_1.default.join(this._config.directory, bucketName, fileName);
289
+ const { size } = yield fs_1.default.promises.stat(p);
290
+ return { value: size, error: null };
291
+ }
292
+ catch (e) {
293
+ return { value: null, error: (0, util_1.getErrorMessage)(e) };
294
+ }
295
+ });
296
+ }
297
+ _bucketExists(bucketName) {
298
+ return __awaiter(this, void 0, void 0, function* () {
299
+ try {
300
+ const p = path_1.default.join(this._config.directory, bucketName);
301
+ // const r = fs.existsSync(p);
302
+ const m = yield fs_1.default.promises.stat(p);
303
+ return { value: true, error: null };
304
+ }
305
+ catch (e) {
306
+ // console.log(e);
307
+ // error only means that the directory does not exist
308
+ return { value: false, error: null };
309
+ }
310
+ });
311
+ }
312
+ _bucketIsPublic(bucketName) {
313
+ return __awaiter(this, void 0, void 0, function* () {
314
+ // always true
315
+ return { value: true, error: null };
316
+ });
317
+ }
318
+ _fileExists(bucketName, fileName) {
319
+ return __awaiter(this, void 0, void 0, function* () {
320
+ try {
321
+ yield fs_1.default.promises.access(path_1.default.join(this._config.directory, bucketName, fileName));
322
+ return { value: true, error: null };
323
+ }
324
+ catch (e) {
325
+ return { value: false, error: null };
326
+ }
327
+ });
328
+ }
329
+ _getPresignedUploadURL(bucketName, fileName, options) {
330
+ return __awaiter(this, void 0, void 0, function* () {
331
+ return { value: { url: "" }, error: null };
332
+ });
333
+ }
334
+ // public
335
+ get config() {
336
+ return this._config;
337
+ }
338
+ getConfig() {
339
+ return this.config;
340
+ }
341
+ }
342
+ exports.AdapterLocal = AdapterLocal;
343
+ //# sourceMappingURL=AdapterLocal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdapterLocal.js","sourceRoot":"","sources":["../../src/AdapterLocal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,+BAA4B;AAC5B,mCAAgC;AAChC,mCAAkC;AAClC,6CAAmE;AAInE,uDAAoD;AACpD,iCAA8D;AAE9D,MAAa,YAAa,SAAQ,iCAAe;IAK/C,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QALN,cAAS,GAAG,kBAAQ,CAAC,KAAK,CAAC;QAE3B,iBAAY,GAAkB,IAAI,CAAC;QAI3C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,qBAAQ,MAAM,CAAE,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAA,eAAQ,EAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gB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AAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAClF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;KAAA;IAEwB,sBAAsB,CAC7C,UAAkB,EAClB,QAAgB,EAChB,OAAgB;;YAEhB,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC7C,CAAC;KAAA;IAED,SAAS;IAET,IAAa,MAAM;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAjTD,oCAiTC"}
@@ -0,0 +1,5 @@
1
+ export { AdapterLocal } from "../AdapterLocal";
2
+ export * from "../types/adapter_local";
3
+ export * from "../types/general";
4
+ export * from "../types/result";
5
+ export * from "../types/add_file_params";
@@ -0,0 +1,24 @@
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
+ exports.AdapterLocal = void 0;
18
+ var AdapterLocal_1 = require("../AdapterLocal");
19
+ Object.defineProperty(exports, "AdapterLocal", { enumerable: true, get: function () { return AdapterLocal_1.AdapterLocal; } });
20
+ __exportStar(require("../types/adapter_local"), exports);
21
+ __exportStar(require("../types/general"), exports);
22
+ __exportStar(require("../types/result"), exports);
23
+ __exportStar(require("../types/add_file_params"), exports);
24
+ //# sourceMappingURL=AdapterLocal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdapterLocal.js","sourceRoot":"","sources":["../../../src/indexes/AdapterLocal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAA+C;AAAtC,4GAAA,YAAY,OAAA;AACrB,yDAAuC;AACvC,mDAAiC;AACjC,kDAAgC;AAChC,2DAAyC"}
@@ -0,0 +1,5 @@
1
+ import { AdapterConfig } from "./general";
2
+ export interface AdapterConfigLocal extends AdapterConfig {
3
+ directory: string;
4
+ mode?: number;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=adapter_local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter_local.js","sourceRoot":"","sources":["../../../src/types/adapter_local.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { Readable } from "stream";
2
+ import { Options } from "./general";
3
+ /**
4
+ * @param bucketName name of the bucket you want to use
5
+ * @param origPath path of the file to be copied
6
+ * @param targetPath path to copy the file to, folders will be created automatically
7
+ * @param options additional option such as access rights
8
+ **/
9
+ export type FilePathParams = {
10
+ bucketName?: string;
11
+ origPath: string;
12
+ targetPath: string;
13
+ options?: Options;
14
+ };
15
+ /**
16
+ * @param bucketName name of the bucket you want to use
17
+ * @param buffer file as buffer
18
+ * @param targetPath path to the file to save the buffer to, folders will be created automatically
19
+ * @param options additional option such as access rights
20
+ **/
21
+ export type FileBufferParams = {
22
+ bucketName?: string;
23
+ buffer: Buffer;
24
+ targetPath: string;
25
+ options?: Options;
26
+ };
27
+ /**
28
+ * @param bucketName name of the bucket you want to use
29
+ * @param stream a read stream
30
+ * @param targetPath path to the file to save the stream to, folders will be created automatically
31
+ * @param options additional option such as access rights
32
+ **/
33
+ export type FileStreamParams = {
34
+ bucketName?: string;
35
+ stream: Readable;
36
+ targetPath: string;
37
+ options?: Options;
38
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=add_file_params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add_file_params.js","sourceRoot":"","sources":["../../../src/types/add_file_params.ts"],"names":[],"mappings":""}