@nuvix/storage 0.1.0 → 1.0.0

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/index.d.ts CHANGED
@@ -61,7 +61,7 @@ declare abstract class Device {
61
61
  * Upload file contents to desired destination in the selected disk.
62
62
  * return number of chunks uploaded or 0 if it fails.
63
63
  */
64
- abstract uploadData(data: string, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
64
+ abstract uploadData(data: string | Buffer, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
65
65
  /**
66
66
  * Abort Chunked Upload
67
67
  */
@@ -69,7 +69,7 @@ declare abstract class Device {
69
69
  /**
70
70
  * Read file by given path.
71
71
  */
72
- abstract read(path: string, offset?: number, length?: number): Promise<string>;
72
+ abstract read(path: string, offset?: number, length?: number): Promise<Buffer>;
73
73
  /**
74
74
  * Transfer
75
75
  * Transfer a file from current device to destination device.
@@ -78,7 +78,7 @@ declare abstract class Device {
78
78
  /**
79
79
  * Write file by given path.
80
80
  */
81
- abstract write(path: string, data: string, contentType: string): Promise<boolean>;
81
+ abstract write(path: string, data: string | Buffer, contentType: string): Promise<boolean>;
82
82
  /**
83
83
  * Move file from given source to given path, return true on success and false on failure.
84
84
  */
@@ -151,6 +151,7 @@ declare class Storage {
151
151
  static readonly DEVICE_LOCAL = "local";
152
152
  static readonly DEVICE_S3 = "s3";
153
153
  static readonly DEVICE_WASABI = "wasabi";
154
+ static readonly DEVICE_MINIO = "minio";
154
155
  /**
155
156
  * Devices.
156
157
  *
@@ -196,7 +197,7 @@ declare class Storage {
196
197
  * @param system
197
198
  * @returns string
198
199
  */
199
- static human(bytes: number, decimals?: number, system?: 'binary' | 'metric'): string;
200
+ static human(bytes: number, decimals?: number, system?: "binary" | "metric"): string;
200
201
  }
201
202
 
202
203
  declare abstract class Validator {
@@ -218,22 +219,6 @@ declare class File extends Validator {
218
219
  * @return boolean
219
220
  */
220
221
  isValid(name: any): boolean;
221
- /**
222
- * Is array
223
- *
224
- * Function will return true if object is array.
225
- *
226
- * @return boolean
227
- */
228
- isArray(): boolean;
229
- /**
230
- * Get Type
231
- *
232
- * Returns validator type.
233
- *
234
- * @return string
235
- */
236
- getType(): string;
237
222
  }
238
223
 
239
224
  declare class FileExt extends Validator {
@@ -247,8 +232,6 @@ declare class FileExt extends Validator {
247
232
  constructor(allowed: string[]);
248
233
  getDescription(): string;
249
234
  isValid(filename: string): boolean;
250
- isArray(): boolean;
251
- getType(): string;
252
235
  private getFileExtension;
253
236
  }
254
237
 
@@ -264,22 +247,6 @@ declare class FileName extends Validator {
264
247
  * @returns boolean indicating if the filename is valid
265
248
  */
266
249
  isValid(name: any): boolean;
267
- /**
268
- * Is array
269
- *
270
- * Function will return true if object is array.
271
- *
272
- * @returns boolean
273
- */
274
- isArray(): boolean;
275
- /**
276
- * Get Type
277
- *
278
- * Returns validator type.
279
- *
280
- * @returns string
281
- */
282
- getType(): string;
283
250
  }
284
251
 
285
252
  declare class FileSize extends Validator {
@@ -296,18 +263,6 @@ declare class FileSize extends Validator {
296
263
  * Finds whether a file size is smaller than required limit.
297
264
  */
298
265
  isValid(fileSize: any): boolean;
299
- /**
300
- * Is array
301
- *
302
- * Function will return true if object is array.
303
- */
304
- isArray(): boolean;
305
- /**
306
- * Get Type
307
- *
308
- * Returns validator type.
309
- */
310
- getType(): string;
311
266
  }
312
267
 
313
268
  declare class FileType extends Validator {
@@ -334,14 +289,6 @@ declare class FileType extends Validator {
334
289
  * Binary check to finds whether a file is of valid type
335
290
  */
336
291
  isValid(path: string): Promise<boolean>;
337
- /**
338
- * Is array
339
- */
340
- isArray(): boolean;
341
- /**
342
- * Get Type
343
- */
344
- getType(): string;
345
292
  }
346
293
 
347
294
  declare class Upload extends Validator {
@@ -356,22 +303,6 @@ declare class Upload extends Validator {
356
303
  * @returns Promise that resolves to true if valid upload file, false otherwise
357
304
  */
358
305
  isValid(path: unknown): Promise<boolean>;
359
- /**
360
- * Is array
361
- *
362
- * Function will return true if object is array.
363
- *
364
- * @returns false - this validator doesn't handle arrays
365
- */
366
- isArray(): boolean;
367
- /**
368
- * Get Type
369
- *
370
- * Returns validator type.
371
- *
372
- * @returns The validator type
373
- */
374
- getType(): string;
375
306
  }
376
307
 
377
308
  declare class Local extends Device {
@@ -384,12 +315,12 @@ declare class Local extends Device {
384
315
  getRoot(): string;
385
316
  getPath(filename: string, prefix?: string): string;
386
317
  upload(source: string, filePath: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
387
- uploadData(data: string, filePath: string, contentType: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
318
+ uploadData(data: string | Buffer, filePath: string, contentType: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
388
319
  private joinChunks;
389
320
  transfer(filePath: string, destination: string, device: Device): Promise<boolean>;
390
321
  abort(filePath: string, extra?: string): Promise<boolean>;
391
- read(filePath: string, offset?: number, length?: number): Promise<string>;
392
- write(filePath: string, data: string, contentType?: string): Promise<boolean>;
322
+ read(filePath: string, offset?: number, length?: number): Promise<Buffer>;
323
+ write(filePath: string, data: string | Buffer, contentType?: string): Promise<boolean>;
393
324
  move(source: string, target: string): Promise<boolean>;
394
325
  delete(filePath: string, recursive?: boolean): Promise<boolean>;
395
326
  deletePath(filePath: string): Promise<boolean>;
@@ -465,14 +396,14 @@ declare class S3 extends Device {
465
396
  static setRetryAttempts(attempts: number): void;
466
397
  static setRetryDelay(delay: number): void;
467
398
  upload(source: string | Buffer, path: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
468
- uploadData(data: string, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
399
+ uploadData(data: Buffer, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: Record<string, any>): Promise<number>;
469
400
  transfer(path: string, destination: string, device: Device): Promise<boolean>;
470
401
  protected createMultipartUpload(path: string, contentType: string): Promise<string>;
471
- protected uploadPart(data: string, path: string, contentType: string, chunk: number, uploadId: string): Promise<string>;
402
+ protected uploadPart(data: Buffer, path: string, contentType: string, chunk: number, uploadId: string): Promise<string>;
472
403
  protected completeMultipartUpload(path: string, uploadId: string, parts: Record<number, string>): Promise<boolean>;
473
404
  abort(path: string, extra?: string): Promise<boolean>;
474
- read(path: string, offset?: number, length?: number): Promise<string>;
475
- write(path: string, data: string, contentType?: string): Promise<boolean>;
405
+ read(path: string, offset?: number, length?: number): Promise<Buffer>;
406
+ write(path: string, data: Buffer, contentType?: string): Promise<boolean>;
476
407
  delete(path: string, recursive?: boolean): Promise<boolean>;
477
408
  protected listObjects(prefix?: string, maxKeys?: number, continuationToken?: string): Promise<any>;
478
409
  deletePath(path: string): Promise<boolean>;
@@ -485,11 +416,16 @@ declare class S3 extends Device {
485
416
  getPartitionFreeSpace(): Promise<number>;
486
417
  getFiles(dir: string, max?: number, continuationToken?: string): Promise<any>;
487
418
  private getInfo;
488
- private getSignatureV4;
489
- protected call(method: string, uri: string, data?: string, parameters?: Record<string, string>, decode?: boolean): Promise<any>;
490
- private md5;
491
- private sha256;
492
- private hmacSha256;
419
+ protected getSignatureV4(method: string, uri: string, parameters?: Record<string, string>): string;
420
+ protected call(method: string, uri: string, data?: string | Buffer, parameters?: Record<string, string>, decode?: boolean): Promise<{
421
+ body: any;
422
+ buffer: ArrayBuffer;
423
+ headers: Record<string, string>;
424
+ code: number;
425
+ }>;
426
+ protected md5(data: string | Buffer): Buffer;
427
+ protected sha256(data: string | Buffer): string;
428
+ protected hmacSha256(data: string | Buffer, key: string | Buffer, encoding?: "hex" | "binary"): string | Buffer;
493
429
  }
494
430
 
495
431
  declare class Wasabi extends S3 {
@@ -515,5 +451,20 @@ declare class Wasabi extends S3 {
515
451
  getType(): string;
516
452
  }
517
453
 
518
- export { Device, File, FileExt, FileName, FileSize, FileType, Local, S3, Storage, Upload, Wasabi };
454
+ declare class MinIO extends S3 {
455
+ /**
456
+ * MinIO Constructor
457
+ */
458
+ constructor(root: string, accessKey: string, secretKey: string, bucket: string, endpoint?: string, acl?: string, useSSL?: boolean);
459
+ private endpointUrl;
460
+ getName(): string;
461
+ getDescription(): string;
462
+ getType(): string;
463
+ /**
464
+ * Override the call method to use the custom endpoint
465
+ */
466
+ protected call(method: string, uri: string, data?: string | Buffer, parameters?: Record<string, string>, decode?: boolean): Promise<any>;
467
+ }
468
+
469
+ export { Device, File, FileExt, FileName, FileSize, FileType, Local, MinIO, S3, Storage, Upload, Wasabi };
519
470
  export type { DeviceMetadata };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}