@e-mc/cloud 0.12.9 → 0.13.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/cloud
2
2
 
3
- * NodeJS 18
3
+ * NodeJS 18.20.5 LTS
4
4
  * ES2022
5
5
 
6
6
  ## General Usage
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.12.9/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.1/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IHost, IScopeOrigin } from "./index";
@@ -31,6 +31,7 @@ interface ICloud extends IClientDb<IHost, CloudModule, CloudDatabase, CloudServi
31
31
  setBucketWebsite(service: string, credential: unknown, bucket: string, options: BucketWebsiteOptions): Promise<boolean>;
32
32
  deleteObjects(service: string, credential: unknown, bucket: string, options: DeleteObjectsOptions): Promise<void>;
33
33
  deleteObjects(service: string, credential: unknown, bucket: string, recursive?: boolean | DeleteObjectsOptions): Promise<void>;
34
+ copyObject(service: string, credential: unknown, bucketSource: string, keySource: string, bucket: string, key: string, options?: CopyObjectOptions): Promise<void>;
34
35
  uploadObject(service: string, credential: unknown, bucket: string, upload: CloudStorageUpload, localUri: string, beforeResolve?: ((value: string) => Promise<void> | void)): Promise<string>;
35
36
  downloadObject(service: string, credential: unknown, bucket: string, download: CloudStorageDownload, beforeResolve?: ((value: Buffer | string | null) => Promise<string | undefined> | void)): Promise<Buffer | string>;
36
37
  getStorage(action: CloudFunctions, data: CloudStorage[] | undefined): CloudStorage | undefined;
@@ -51,6 +52,7 @@ interface ICloud extends IClientDb<IHost, CloudModule, CloudDatabase, CloudServi
51
52
  }
52
53
 
53
54
  interface CloudConstructor extends ClientDbConstructor<IHost> {
55
+ LOG_CLOUD_SUCCESS: LogMessageOptions;
54
56
  LOG_CLOUD_FAIL: LogMessageOptions;
55
57
  LOG_CLOUD_COMMAND: LogMessageOptions;
56
58
  LOG_CLOUD_WARN: LogMessageOptions;
@@ -62,7 +64,9 @@ interface CloudConstructor extends ClientDbConstructor<IHost> {
62
64
  uploadAsset(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, options: UploadAssetOptions): Promise<void>[];
63
65
  uploadAsset(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, ignoreProcess: boolean): Promise<void>[];
64
66
  uploadAsset(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, contentType?: string, ignoreProcess?: boolean): Promise<void>[];
67
+ uploadAssetSuccess(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, active?: boolean): (value: string) => Promise<void> | void;
65
68
  sanitizeAssets(assets: ExternalAsset[]): ExternalAsset[];
69
+ optionsLogMessage(type: "SUCCESS" | "FAIL" | "COMMAND" | "WARN" | "UPLOAD" | "DOWNLOAD" | "DELETE" | "DELAYED", options?: LogMessageOptions & LogFailOptions): LogMessageOptions & LogFailOptions;
66
70
  readonly prototype: ICloud;
67
71
  new(module?: CloudModule, database?: CloudDatabase[], ...args: unknown[]): ICloud;
68
72
  }
@@ -88,6 +92,7 @@ interface ICloudServiceClient {
88
92
  /** @deprecated */
89
93
  deleteObjectsV2?(this: IModule, credential: unknown, bucket: string, recursive?: boolean, service?: string, sdk?: string): Promise<void>;
90
94
  deleteObjectsV3?(this: IModule, credential: U, bucket: string, options?: DeleteObjectsOptions, service?: string, sdk?: string): Promise<void>;
95
+ copyObject?(this: IModule, credential: U, bucketSource: string, keySource: string, bucket: string, key: string, options?: unknown, service?: string, sdk?: string): Promise<void>;
91
96
  executeQuery?(this: ICloud, credential: unknown, data: CloudDatabase, sessionKey?: string): Promise<QueryResult>;
92
97
  executeBatchQuery?(this: ICloud, credential: unknown, batch: CloudDatabase[], sessionKey?: string): Promise<BatchQueryResult>;
93
98
  }
@@ -175,12 +180,12 @@ const rows = await instance.getDatabaseRows({ service: "aws-v3", credential: "ma
175
180
 
176
181
  ## References
177
182
 
178
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/asset.d.ts
179
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/cloud.d.ts
180
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/core.d.ts
181
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/db.d.ts
182
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/logger.d.ts
183
- - https://www.unpkg.com/@e-mc/types@0.12.9/lib/settings.d.ts
183
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/asset.d.ts
184
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/cloud.d.ts
185
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/core.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/db.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/logger.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.13.1/lib/settings.d.ts
184
189
 
185
190
  ## LICENSE
186
191
 
package/index.js CHANGED
@@ -6,8 +6,8 @@ const types_1 = require("@e-mc/types");
6
6
  const core_1 = require("@e-mc/core");
7
7
  const kCloud = Symbol.for('cloud:constructor');
8
8
  const SERVICE_CLIENT = new Map();
9
- const SERVICE_UPLOAD = {};
10
- const SERVICE_DOWNLOAD = {};
9
+ const SERVICE_UPLOAD = Object.create(null);
10
+ const SERVICE_DOWNLOAD = Object.create(null);
11
11
  function setUploadFilename(upload, filename) {
12
12
  filename = Cloud.toPosix(filename.replace(/^\.*[\\/]+/, ''));
13
13
  const index = filename.lastIndexOf('/');
@@ -39,17 +39,6 @@ function getFiles(file, data) {
39
39
  }
40
40
  return [grouped];
41
41
  }
42
- function createUploadCallback(state, file, active) {
43
- return async (value) => {
44
- if ((0, types_1.isString)(value)) {
45
- for (const { instance: document } of state.host.Document) {
46
- if (document.cloudUpload && await document.cloudUpload(state, file, value, active)) {
47
- return;
48
- }
49
- }
50
- }
51
- };
52
- }
53
42
  function renameTrailing(map, item, folder, value) {
54
43
  const location = folder + value;
55
44
  map[location] ||= 1;
@@ -57,7 +46,7 @@ function renameTrailing(map, item, folder, value) {
57
46
  item.filename = (index !== -1 ? value.substring(0, index) : value) + '_' + map[location]++ + (index !== -1 ? value.substring(index) : '');
58
47
  }
59
48
  function errorResponse(instance, service, bucket, err) {
60
- instance.formatMessage(64, service, ["Unable to empty bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
49
+ instance.formatMessage(64, service, ["Unable to empty bucket", bucket], err, Cloud.optionsLogMessage('WARN'));
61
50
  }
62
51
  const errorObject = (err, service, value) => err instanceof Error ? err : typeof err === 'string' ? new Error(err) : (0, types_1.errorMessage)(service, value);
63
52
  const assignFilename = (value) => crypto.randomUUID() + (path.extname(value) || '');
@@ -65,6 +54,7 @@ class Cloud extends core_1.ClientDb {
65
54
  static [kCloud] = true;
66
55
  static STORE_RESULT_PARTITION_SIZE = 16;
67
56
  static STORE_RESULT_PARTITION_MULT = 2;
57
+ static LOG_CLOUD_SUCCESS = core_1.ClientDb.LOG_STYLE_SUCCESS;
68
58
  static LOG_CLOUD_FAIL = core_1.ClientDb.LOG_STYLE_FAIL;
69
59
  static LOG_CLOUD_COMMAND = Object.freeze({ titleColor: 'blue' });
70
60
  static LOG_CLOUD_WARN = Object.freeze({ titleColor: 'yellow' });
@@ -72,6 +62,29 @@ class Cloud extends core_1.ClientDb {
72
62
  static LOG_CLOUD_DOWNLOAD = Object.freeze({ titleColor: 'cyan' });
73
63
  static LOG_CLOUD_DELETE = Object.freeze({ titleColor: 'grey' });
74
64
  static LOG_CLOUD_DELAYED = Object.freeze({ titleColor: 'grey' });
65
+ static toPosix(value, filename, normalize) {
66
+ if (typeof filename === 'boolean') {
67
+ normalize = filename;
68
+ filename = undefined;
69
+ }
70
+ if (typeof value === 'string') {
71
+ let pathname = value;
72
+ if (normalize) {
73
+ pathname = path.posix.normalize(pathname);
74
+ }
75
+ if (pathname) {
76
+ pathname = pathname.replace(/(?<!^)\/+$/, '');
77
+ if (!filename) {
78
+ return pathname;
79
+ }
80
+ if (pathname !== '/') {
81
+ pathname += '/';
82
+ }
83
+ return pathname + filename;
84
+ }
85
+ }
86
+ return filename || '';
87
+ }
75
88
  static async finalize(instance) {
76
89
  if (instance.aborted) {
77
90
  return (0, types_1.createAbortError)(true);
@@ -87,7 +100,7 @@ class Cloud extends core_1.ClientDb {
87
100
  const startTime = process.hrtime.bigint();
88
101
  let tasks = [], downloadMap;
89
102
  if (await instance.commit()) {
90
- instance.writeTimeElapsed(instance.moduleName, "Transactions were committed", startTime, { type: 64, ...Cloud.LOG_STYLE_SUCCESS });
103
+ instance.writeTimeElapsed(instance.moduleName, "Transactions were committed", startTime, Cloud.optionsLogMessage('SUCCESS'));
91
104
  }
92
105
  for (const { instance: document } of this.Document) {
93
106
  document.cloudInit?.(state);
@@ -97,7 +110,7 @@ class Cloud extends core_1.ClientDb {
97
110
  if ((0, types_1.isArray)(cloudStorage) && !(0, types_1.ignoreFlag)(item)) {
98
111
  if (item.invalid) {
99
112
  cloudStorage.forEach(storage => {
100
- instance.formatMessage(64, storage.service, ["Upload failed", storage.bucket], (0, types_1.errorValue)("File not found", item.uri || item.filename || "Unknown"), { ...Cloud.LOG_CLOUD_WARN });
113
+ instance.formatMessage(64, storage.service, ["Upload failed", storage.bucket], (0, types_1.errorValue)("File not found", item.uri || item.filename || "Unknown"), Cloud.optionsLogMessage('WARN'));
101
114
  });
102
115
  continue;
103
116
  }
@@ -305,11 +318,11 @@ class Cloud extends core_1.ClientDb {
305
318
  this.addDownload(size = value.length);
306
319
  }
307
320
  this.add(destUri);
308
- this.formatMessage(64, service, ["Download success", (0, types_1.formatSize)(size)], destUri, { ...Cloud.LOG_CLOUD_DOWNLOAD });
321
+ this.formatMessage(64, service, ["Download success", (0, types_1.formatSize)(size)], destUri, Cloud.optionsLogMessage('DOWNLOAD'));
309
322
  result ||= destUri;
310
323
  }
311
324
  catch (err) {
312
- if (!copy && core_1.ClientDb.isErrorCode(err, 'EXDEV')) {
325
+ if (!copy && (0, types_1.isErrorCode)(err, 'EXDEV')) {
313
326
  copy = true;
314
327
  --i;
315
328
  }
@@ -441,7 +454,7 @@ class Cloud extends core_1.ClientDb {
441
454
  if (index > 0 || !options.contentType) {
442
455
  options.contentType = index === 0 && contentType || this.lookupMime(path.basename(localUri)) || "application/octet-stream";
443
456
  }
444
- uploading.push(instance.uploadObject(service, { ...credential }, bucket, options, localUri, !ignoreProcess ? createUploadCallback(state, file, active) : undefined)
457
+ uploading.push(instance.uploadObject(service, { ...credential }, bucket, options, localUri, !ignoreProcess ? this.uploadAssetSuccess(state, file, active) : undefined)
445
458
  .catch((err) => {
446
459
  instance.writeFail(["Upload failed", path.basename(localUri)], err, { type: 64, fatal: i === 0 && index === 0 });
447
460
  }));
@@ -457,6 +470,15 @@ class Cloud extends core_1.ClientDb {
457
470
  }
458
471
  return tasks;
459
472
  }
473
+ static uploadAssetSuccess(state, file, active = false) {
474
+ return async (value) => {
475
+ for (const { instance: document } of state.host.Document) {
476
+ if (document.cloudUpload && await document.cloudUpload(state, file, value, active)) {
477
+ return;
478
+ }
479
+ }
480
+ };
481
+ }
460
482
  static sanitizeAssets(assets) {
461
483
  const storage = [];
462
484
  for (const item of assets) {
@@ -520,6 +542,9 @@ class Cloud extends core_1.ClientDb {
520
542
  }
521
543
  return assets;
522
544
  }
545
+ static optionsLogMessage(type, options) {
546
+ return { type: 64, ...this[`LOG_CLOUD_${type}`], ...options };
547
+ }
523
548
  _moduleName = 'cloud';
524
549
  _threadable = true;
525
550
  uploaded = [];
@@ -533,27 +558,27 @@ class Cloud extends core_1.ClientDb {
533
558
  }
534
559
  return super.setQueryResult(service, credential, queryString, result, sessionKey);
535
560
  }
536
- async createBucket(service, credential, bucket, publicRead, options) {
561
+ async createBucket(service, credential, bucket, acl, options) {
537
562
  if (this.aborted) {
538
563
  return (0, types_1.createAbortError)(true);
539
564
  }
540
565
  const client = this.getClient(service);
541
566
  try {
542
- if (publicRead === undefined || typeof publicRead === 'boolean') {
567
+ if (acl === undefined || typeof acl === 'boolean') {
543
568
  const handler = client.createBucket?.bind(this);
544
569
  if (handler) {
545
- return handler.call(this, credential, bucket, publicRead);
570
+ return handler.call(this, credential, bucket, acl);
546
571
  }
547
572
  }
548
573
  else {
549
574
  const handler = client.createBucketV2?.bind(this);
550
575
  if (handler) {
551
- return handler.call(this, credential, bucket, publicRead, options);
576
+ return handler.call(this, credential, bucket, acl, options);
552
577
  }
553
578
  }
554
579
  }
555
580
  catch (err) {
556
- this.formatMessage(64, service, ["Unable to create bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
581
+ this.formatMessage(64, service, ["Unable to create bucket", bucket], err, Cloud.optionsLogMessage('WARN'));
557
582
  throw err;
558
583
  }
559
584
  throw (0, types_1.errorMessage)(service, "Create bucket not supported");
@@ -568,7 +593,7 @@ class Cloud extends core_1.ClientDb {
568
593
  return handler.call(this, credential, bucket, options);
569
594
  }
570
595
  catch (err) {
571
- this.formatMessage(64, service, ["Unable to update bucket policy", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
596
+ this.formatMessage(64, service, ["Unable to update bucket policy", bucket], err, Cloud.optionsLogMessage('WARN'));
572
597
  throw err;
573
598
  }
574
599
  }
@@ -584,7 +609,7 @@ class Cloud extends core_1.ClientDb {
584
609
  return handler.call(this, credential, bucket, options);
585
610
  }
586
611
  catch (err) {
587
- this.formatMessage(64, service, ["Unable to update bucket tagging", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
612
+ this.formatMessage(64, service, ["Unable to update bucket tagging", bucket], err, Cloud.optionsLogMessage('WARN'));
588
613
  throw err;
589
614
  }
590
615
  }
@@ -600,7 +625,7 @@ class Cloud extends core_1.ClientDb {
600
625
  return handler.call(this, credential, bucket, options);
601
626
  }
602
627
  catch (err) {
603
- this.formatMessage(64, service, ["Unable to configure bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
628
+ this.formatMessage(64, service, ["Unable to configure bucket", bucket], err, Cloud.optionsLogMessage('WARN'));
604
629
  throw err;
605
630
  }
606
631
  }
@@ -632,6 +657,18 @@ class Cloud extends core_1.ClientDb {
632
657
  }
633
658
  throw (0, types_1.errorMessage)(service, "Delete objects not supported");
634
659
  }
660
+ async copyObject(service, credential, bucketSource, keySource, bucket, key, options) {
661
+ if (this.aborted) {
662
+ return (0, types_1.createAbortError)(true);
663
+ }
664
+ const handler = this.getClient(service).copyObject?.bind(this);
665
+ if (handler) {
666
+ return handler.call(this, credential, bucketSource, keySource, bucket, key, options, service).catch((err) => {
667
+ errorResponse(this, service, bucket, err);
668
+ });
669
+ }
670
+ throw (0, types_1.errorMessage)(service, "Copy object not supported");
671
+ }
635
672
  async uploadObject(service, credential, bucket, upload, localUri, beforeResolve) {
636
673
  if (this.aborted) {
637
674
  return (0, types_1.createAbortError)(true);
@@ -641,7 +678,7 @@ class Cloud extends core_1.ClientDb {
641
678
  handler = this.getUploadHandler(service, credential).bind(this);
642
679
  }
643
680
  catch (err) {
644
- this.formatMessage(64, service, ["Upload function not supported", bucket], localUri, { ...Cloud.LOG_CLOUD_WARN });
681
+ this.formatMessage(64, service, ["Upload function not supported", bucket], localUri, Cloud.optionsLogMessage('WARN'));
645
682
  throw err;
646
683
  }
647
684
  return new Promise((resolve, reject) => {
@@ -650,7 +687,7 @@ class Cloud extends core_1.ClientDb {
650
687
  if (err) {
651
688
  reject(errorObject(err, service, "Upload failed"));
652
689
  }
653
- else if (value) {
690
+ else if ((0, types_1.isString)(value)) {
654
691
  if (beforeResolve) {
655
692
  await beforeResolve(value);
656
693
  }
@@ -676,7 +713,7 @@ class Cloud extends core_1.ClientDb {
676
713
  handler = this.getDownloadHandler(service, credential).bind(this);
677
714
  }
678
715
  catch (err) {
679
- this.formatMessage(64, service, ["Download function not supported", bucket], Cloud.joinPath(download.pathname, download.filename), { ...Cloud.LOG_CLOUD_WARN });
716
+ this.formatMessage(64, service, ["Download function not supported", bucket], Cloud.joinPath(download.pathname, download.filename), Cloud.optionsLogMessage('WARN'));
680
717
  throw err;
681
718
  }
682
719
  return new Promise((resolve, reject) => {
@@ -726,7 +763,7 @@ class Cloud extends core_1.ClientDb {
726
763
  return await client.executeQuery.call(this, credential, item, sessionKey);
727
764
  }
728
765
  catch (err) {
729
- this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
766
+ this.formatFail(64, service, "Unable to execute query", err, Cloud.optionsLogMessage('FAIL'));
730
767
  throw err;
731
768
  }
732
769
  }
@@ -762,7 +799,7 @@ class Cloud extends core_1.ClientDb {
762
799
  return await client.executeBatchQuery.call(this, credential, batch, sessionKey);
763
800
  }
764
801
  catch (err) {
765
- this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
802
+ this.formatFail(64, service, "Unable to execute query", err, Cloud.optionsLogMessage('FAIL'));
766
803
  throw err;
767
804
  }
768
805
  }
@@ -828,7 +865,7 @@ class Cloud extends core_1.ClientDb {
828
865
  }
829
866
  }
830
867
  catch (err) {
831
- this.formatFail(64, data.service, "Cloud provider not found", err, { ...Cloud.LOG_CLOUD_FAIL });
868
+ this.formatFail(64, data.service, "Cloud provider not found", err, Cloud.optionsLogMessage('FAIL'));
832
869
  }
833
870
  return false;
834
871
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/cloud",
3
- "version": "0.12.9",
3
+ "version": "0.13.1",
4
4
  "description": "Cloud constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "license": "BSD-3-Clause",
20
20
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
21
  "dependencies": {
22
- "@e-mc/core": "0.12.9",
23
- "@e-mc/db": "0.12.9",
24
- "@e-mc/types": "0.12.9",
25
- "mime-types": "^2.1.35"
22
+ "@e-mc/core": "0.13.1",
23
+ "@e-mc/db": "0.13.1",
24
+ "@e-mc/types": "0.13.1",
25
+ "mime-types": "^3.0.1"
26
26
  }
27
27
  }
package/types/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface ICloudServiceClient<T extends CloudDatabase = CloudDatabase, U
23
23
  /** @deprecated */
24
24
  deleteObjectsV2?(this: IModule, credential: U, bucket: string, recursive?: boolean, service?: string, sdk?: string): Promise<void>;
25
25
  deleteObjectsV3?(this: IModule, credential: U, bucket: string, options?: DeleteObjectsOptions, service?: string, sdk?: string): Promise<void>;
26
+ copyObject?(this: IModule, credential: U, bucketSource: string, keySource: string, bucket: string, key: string, options?: unknown, service?: string, sdk?: string): Promise<void>;
26
27
  executeQuery?(this: ICloud, credential: V, data: T, sessionKey?: string): Promise<QueryResult>;
27
28
  executeBatchQuery?(this: ICloud, credential: V, batch: T[], sessionKey?: string): Promise<BatchQueryResult>;
28
29
  }
package/util.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { IModule } from '@e-mc/types/lib';
1
2
  import type { UploadContent } from '@e-mc/types/lib/cloud';
2
3
  import type { AuthValue } from '@e-mc/types/lib/http';
3
4
 
@@ -6,10 +7,12 @@ import type { Readable } from 'node:stream';
6
7
  declare namespace util {
7
8
  function readableAsBuffer(from: Readable): Promise<Buffer | null>;
8
9
  function createKeyAndBody<T = Buffer>(filename: string, items: UploadContent[], chunkSize?: number | string | FunctionType<void>, errorCallback?: FunctionType<void> | number, flags?: number): [string[], T[], string[]];
10
+ function createErrorHandler(instance: IModule, service: string, bucket: string): (err: unknown) => void;
9
11
  function generateFilename(filename: string): (i: number) => [string, boolean];
10
12
  function getBasicAuth(auth: AuthValue): string;
11
13
  function getBasicAuth(username: unknown, password?: unknown): string;
12
14
  function hasBasicAuth(value: string): boolean;
15
+ function intoArray<T>(value: T | undefined | null): (T extends Array<infer U> ? U[] : T[]) | null;
13
16
  function formatError(title: string | { service: string }, message: string, hint?: string): Error;
14
17
  }
15
18
 
package/util.js CHANGED
@@ -2,6 +2,8 @@
2
2
  exports.hasBasicAuth = exports.getBasicAuth = void 0;
3
3
  exports.readableAsBuffer = readableAsBuffer;
4
4
  exports.createKeyAndBody = createKeyAndBody;
5
+ exports.createErrorHandler = createErrorHandler;
6
+ exports.intoArray = intoArray;
5
7
  exports.generateFilename = generateFilename;
6
8
  exports.formatError = formatError;
7
9
  const path = require("node:path");
@@ -114,6 +116,17 @@ function createKeyAndBody(filename, items, chunkSize = 0, errorCallback, flags =
114
116
  }
115
117
  return [key, body, type];
116
118
  }
119
+ function createErrorHandler(instance, service, bucket) {
120
+ return (err) => {
121
+ instance.addLog(3, err, service, bucket);
122
+ };
123
+ }
124
+ function intoArray(value) {
125
+ if (value != null) {
126
+ return Array.isArray(value) ? value : [value];
127
+ }
128
+ return null;
129
+ }
117
130
  function generateFilename(filename) {
118
131
  let basename, suffix;
119
132
  return (i) => {