@e-mc/cloud 0.8.4 → 0.8.6

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2024 An Pham
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
4
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/index.d.ts
13
13
 
14
14
  ```typescript
15
15
  import type { IHost, IScopeOrigin } from "./index";
@@ -45,7 +45,6 @@ interface ICloud extends IClientDb<IHost, CloudModule, CloudDatabase, CloudServi
45
45
  getUploadHandler(service: string, credential: unknown): (...args: unknown[]) => void;
46
46
  getDownloadHandler(service: string, credential: unknown): (...args: unknown[]) => void;
47
47
  resolveService(service: string, folder?: string): string;
48
- getUserSettings(): unknown;
49
48
  get settings(): CloudSettings;
50
49
  }
51
50
 
@@ -68,12 +67,12 @@ interface CloudConstructor extends ClientDbConstructor<IHost> {
68
67
 
69
68
  ## References
70
69
 
71
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/asset.d.ts
72
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/cloud.d.ts
73
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/core.d.ts
74
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/db.d.ts
75
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/logger.d.ts
76
- - https://www.unpkg.com/@e-mc/types@0.8.4/lib/settings.d.ts
70
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/asset.d.ts
71
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/cloud.d.ts
72
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/core.d.ts
73
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/db.d.ts
74
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/logger.d.ts
75
+ - https://www.unpkg.com/@e-mc/types@0.8.6/lib/settings.d.ts
77
76
 
78
77
  ## LICENSE
79
78
 
package/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
- const types_1 = require("../types");
6
- const core_1 = require("../core");
7
- const util_1 = require("./util");
5
+ const types_1 = require("@e-mc/types");
6
+ const core_1 = require("@e-mc/core");
7
+ const util_1 = require("@e-mc/cloud/util");
8
8
  const SERVICE_CLIENT = new Map();
9
9
  const SERVICE_UPLOAD = {};
10
10
  const SERVICE_DOWNLOAD = {};
@@ -64,7 +64,7 @@ class Cloud extends core_1.ClientDb {
64
64
  const startTime = process.hrtime();
65
65
  let tasks = [], downloadMap;
66
66
  if (await instance.commit()) {
67
- instance.writeTimeElapsed(instance.moduleName, "Transactions were committed" /* VAL_MESSAGE.COMMIT_TRANSACTION */, startTime, { type: 64 /* LOG_TYPE.CLOUD */, ...Cloud.LOG_STYLE_SUCCESS });
67
+ instance.writeTimeElapsed(instance.moduleName, "Transactions were committed", startTime, { type: 64, ...Cloud.LOG_STYLE_SUCCESS });
68
68
  }
69
69
  for (const { instance: document } of this.Document) {
70
70
  document.cloudInit?.(state);
@@ -73,7 +73,7 @@ class Cloud extends core_1.ClientDb {
73
73
  const cloudStorage = item.cloudStorage;
74
74
  if ((0, types_1.isArray)(cloudStorage) && !(0, types_1.ignoreFlag)(item.flags)) {
75
75
  if (item.invalid) {
76
- cloudStorage.forEach(storage => instance.formatMessage(64 /* LOG_TYPE.CLOUD */, storage.service, ["Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */, storage.bucket], (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, item.uri || item.filename || "Unknown" /* ERR_MESSAGE.UNKNOWN */), { ...Cloud.LOG_CLOUD_WARN }));
76
+ cloudStorage.forEach(storage => 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 }));
77
77
  continue;
78
78
  }
79
79
  ignore: {
@@ -122,7 +122,7 @@ class Cloud extends core_1.ClientDb {
122
122
  const map = bucketDelete[service];
123
123
  for (const bucket in map) {
124
124
  const [credential, recursive] = map[bucket];
125
- tasks.push(instance.deleteObjects(service, credential, bucket, recursive).catch(err => instance.writeFail(["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */, service + ': ' + bucket], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime })));
125
+ tasks.push(instance.deleteObjects(service, credential, bucket, recursive).catch(err => instance.writeFail(["Unable to empty bucket", service + ': ' + bucket], err, { type: 64, startTime })));
126
126
  }
127
127
  }
128
128
  if (tasks.length) {
@@ -144,7 +144,7 @@ class Cloud extends core_1.ClientDb {
144
144
  const map = bucketPolicy[service];
145
145
  for (const bucket in map) {
146
146
  const params = map[bucket];
147
- tasks.push(instance.setBucketPolicy(...params).catch(err => instance.writeFail(["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, params[0] + ': ' + params[2]], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime })));
147
+ tasks.push(instance.setBucketPolicy(...params).catch(err => instance.writeFail(["Unable to update bucket policy", params[0] + ': ' + params[2]], err, { type: 64, startTime })));
148
148
  }
149
149
  }
150
150
  if (tasks.length) {
@@ -156,7 +156,7 @@ class Cloud extends core_1.ClientDb {
156
156
  }
157
157
  for (const { instance: document } of this.Document) {
158
158
  if (document.cloudFinalize) {
159
- await document.cloudFinalize(state).catch(err => document.writeFail(["Handled rejection" /* ERR_MESSAGE.HANDLED_REJECTION */, document.moduleName], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime }));
159
+ await document.cloudFinalize(state).catch(err => document.writeFail(["Handled rejection", document.moduleName], err, { type: 64, startTime }));
160
160
  if (document.aborted) {
161
161
  return Promise.reject((0, types_1.createAbortError)());
162
162
  }
@@ -182,7 +182,7 @@ class Cloud extends core_1.ClientDb {
182
182
  if (pathname && path.isAbsolute(pathname)) {
183
183
  downloadUri = path.join(pathname, filename);
184
184
  if (!Cloud.isPath(downloadUri) && !this.canWrite(pathname)) {
185
- instance.writeFail(["Unable to download file" /* ERR_MESSAGE.DOWNLOAD_FILE */, filename], (0, types_1.errorValue)("Unsupported access" /* ERR_MESSAGE.UNSUPPORTED_ACCESS */, pathname), { type: 64 /* LOG_TYPE.CLOUD */, fatal: !!active, startTime });
185
+ instance.writeFail(["Unable to download file", filename], (0, types_1.errorValue)("Unsupported access", pathname), { type: 64, fatal: !!active, startTime });
186
186
  continue;
187
187
  }
188
188
  }
@@ -197,7 +197,7 @@ class Cloud extends core_1.ClientDb {
197
197
  active = true;
198
198
  }
199
199
  else if (!Cloud.createDir(destDir)) {
200
- instance.writeFail(["Unable to create directory" /* ERR_MESSAGE.CREATE_DIRECTORY */, filename], (0, types_1.errorValue)("Path is not a directory" /* ERR_MESSAGE.NOT_DIRECTORY */, destDir), { type: 64 /* LOG_TYPE.CLOUD */, fatal: !!active, startTime });
200
+ instance.writeFail(["Unable to create directory", filename], (0, types_1.errorValue)("Path is not a directory", destDir), { type: 64, fatal: !!active, startTime });
201
201
  continue;
202
202
  }
203
203
  else if (active) {
@@ -237,7 +237,7 @@ class Cloud extends core_1.ClientDb {
237
237
  this.addDownload(size = value.length);
238
238
  }
239
239
  this.add(destUri);
240
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, data.service, ["Download success" /* VAL_CLOUD.DOWNLOAD_FILE */, (0, types_1.formatSize)(size)], destUri, { ...Cloud.LOG_CLOUD_DOWNLOAD });
240
+ this.formatMessage(64, data.service, ["Download success", (0, types_1.formatSize)(size)], destUri, { ...Cloud.LOG_CLOUD_DOWNLOAD });
241
241
  result || (result = destUri);
242
242
  }
243
243
  catch (err) {
@@ -246,14 +246,14 @@ class Cloud extends core_1.ClientDb {
246
246
  --i;
247
247
  }
248
248
  else {
249
- instance.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(destUri)], err, { type: 32 /* LOG_TYPE.FILE */, fatal: !!active, startTime });
249
+ instance.writeFail(["Unable to write file", path.basename(destUri)], err, { type: 32, fatal: !!active, startTime });
250
250
  }
251
251
  }
252
252
  }
253
253
  }
254
254
  return result;
255
255
  })
256
- .catch(err => instance.writeFail(["Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */, path.basename(downloadUri)], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime }));
256
+ .catch(err => instance.writeFail(["Download failed", path.basename(downloadUri)], err, { type: 64, startTime }));
257
257
  if (active || waitStatus || this.incremental === 'staging') {
258
258
  tasks.push(task);
259
259
  }
@@ -306,7 +306,7 @@ class Cloud extends core_1.ClientDb {
306
306
  let fileGroup;
307
307
  if (index === 0) {
308
308
  if (!group[0]) {
309
- instance.writeFail("Unable to read file" /* ERR_MESSAGE.READ_FILE */, (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, service), { type: 64 /* LOG_TYPE.CLOUD */, fatal: true });
309
+ instance.writeFail("Unable to read file", (0, types_1.errorValue)("File not found", service), { type: 64, fatal: true });
310
310
  return;
311
311
  }
312
312
  if (group.length > 1) {
@@ -322,7 +322,7 @@ class Cloud extends core_1.ClientDb {
322
322
  fileGroup.push([typeof minStreamSize === 'number' ? await this.streamFile(value, { minStreamSize, cache: false, signal: instance.signal }) : fs.readFileSync(value), path.extname(value), value]);
323
323
  }
324
324
  catch (err) {
325
- instance.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(value)], err, { type: 32 /* LOG_TYPE.FILE */, fatal: false });
325
+ instance.writeFail(["Unable to read file", path.basename(value)], err, { type: 32, fatal: false });
326
326
  }
327
327
  }
328
328
  }
@@ -334,7 +334,7 @@ class Cloud extends core_1.ClientDb {
334
334
  const localUri = group[i];
335
335
  const exists = index === 0 || this.isPath(localUri, true);
336
336
  if (!exists || !instance.canRead(localUri, { ownPermissionOnly: true })) {
337
- instance.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], (0, types_1.errorValue)(exists ? "Not permitted to read file" /* ERR_MESSAGE.UNSUPPORTED_READ */ : "File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, localUri), { type: 64 /* LOG_TYPE.CLOUD */, fatal: i === 0 && index === 0 });
337
+ instance.writeFail(["Unable to read file", path.basename(localUri)], (0, types_1.errorValue)(exists ? "Not permitted to read file" : "File not found", localUri), { type: 64, fatal: i === 0 && index === 0 });
338
338
  continue;
339
339
  }
340
340
  let buffer, filename;
@@ -358,10 +358,10 @@ class Cloud extends core_1.ClientDb {
358
358
  options.contentType = contentType;
359
359
  }
360
360
  uploading.push(instance.uploadObject(service, { ...credential }, bucket, options, localUri, callback)
361
- .catch(err => instance.writeFail(["Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */, path.basename(localUri)], err, { type: 64 /* LOG_TYPE.CLOUD */, fatal: i === 0 && index === 0 })));
361
+ .catch(err => instance.writeFail(["Upload failed", path.basename(localUri)], err, { type: 64, fatal: i === 0 && index === 0 })));
362
362
  }
363
363
  });
364
- instance.allSettled(uploading, [`Upload file "${contentType || "Unknown" /* ERR_MESSAGE.UNKNOWN */}"`, storage.service + ': ' + path.basename(file.localUri)]).then(() => resolve());
364
+ instance.allSettled(uploading, [`Upload file "${contentType || "Unknown"}"`, storage.service + ': ' + path.basename(file.localUri)]).then(() => resolve());
365
365
  });
366
366
  if (active) {
367
367
  tasks.push(task);
@@ -466,10 +466,10 @@ class Cloud extends core_1.ClientDb {
466
466
  return handler.call(this, credential, bucket, publicRead, options);
467
467
  }
468
468
  }
469
- return Promise.reject((0, types_1.errorMessage)(service, "Create bucket not supported" /* ERR_CLOUD.CREATE_BUCKET_SUPPORT */));
469
+ return Promise.reject((0, types_1.errorMessage)(service, "Create bucket not supported"));
470
470
  }
471
471
  catch (err) {
472
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to create bucket" /* ERR_CLOUD.CREATE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
472
+ this.formatMessage(64, service, ["Unable to create bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
473
473
  return Promise.reject(err);
474
474
  }
475
475
  }
@@ -488,11 +488,11 @@ class Cloud extends core_1.ClientDb {
488
488
  return handler.call(this, credential, bucket, options);
489
489
  }
490
490
  catch (err) {
491
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
491
+ this.formatMessage(64, service, ["Unable to update bucket policy", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
492
492
  return Promise.reject(err);
493
493
  }
494
494
  }
495
- return Promise.reject((0, types_1.errorMessage)(service, "Bucket policy not supported" /* ERR_CLOUD.BUCKET_POLICY_SUPPORT */));
495
+ return Promise.reject((0, types_1.errorMessage)(service, "Bucket policy not supported"));
496
496
  }
497
497
  catch (err) {
498
498
  return Promise.reject(err);
@@ -509,11 +509,11 @@ class Cloud extends core_1.ClientDb {
509
509
  return handler.call(this, credential, bucket, options);
510
510
  }
511
511
  catch (err) {
512
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to configure bucket" /* ERR_CLOUD.CONFIGURE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
512
+ this.formatMessage(64, service, ["Unable to configure bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
513
513
  return Promise.reject(err);
514
514
  }
515
515
  }
516
- return Promise.reject((0, types_1.errorMessage)(service, "Set bucket website not supported" /* ERR_CLOUD.BUCKET_WEBSITE_SUPPORT */));
516
+ return Promise.reject((0, types_1.errorMessage)(service, "Set bucket website not supported"));
517
517
  }
518
518
  catch (err) {
519
519
  return Promise.reject(err);
@@ -524,7 +524,7 @@ class Cloud extends core_1.ClientDb {
524
524
  return Promise.reject((0, types_1.createAbortError)());
525
525
  }
526
526
  try {
527
- const errorResponse = (err) => this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
527
+ const errorResponse = (err) => this.formatMessage(64, service, ["Unable to empty bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
528
528
  const client = this.getClient(service);
529
529
  const handlerV2 = client.deleteObjectsV2?.bind(this);
530
530
  if (handlerV2) {
@@ -534,7 +534,7 @@ class Cloud extends core_1.ClientDb {
534
534
  if (handlerV1) {
535
535
  return handlerV1.call(this, credential, bucket, service, undefined, recursive).catch(err => errorResponse(err));
536
536
  }
537
- return Promise.reject((0, types_1.errorMessage)(service, "Delete objects not supported" /* ERR_CLOUD.DELETE_OBJECTS_SUPPORT */));
537
+ return Promise.reject((0, types_1.errorMessage)(service, "Delete objects not supported"));
538
538
  }
539
539
  catch (err) {
540
540
  return Promise.reject(err);
@@ -549,14 +549,14 @@ class Cloud extends core_1.ClientDb {
549
549
  handler = this.getUploadHandler(service, credential).bind(this);
550
550
  }
551
551
  catch (err) {
552
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Upload function not supported" /* ERR_CLOUD.UPLOAD_SUPPORT */, bucket], localUri, { ...Cloud.LOG_CLOUD_WARN });
552
+ this.formatMessage(64, service, ["Upload function not supported", bucket], localUri, { ...Cloud.LOG_CLOUD_WARN });
553
553
  return Promise.reject(err);
554
554
  }
555
555
  return new Promise((resolve, reject) => {
556
556
  try {
557
557
  handler({ bucket, upload, buffer: upload.buffer || fs.readFileSync(localUri), localUri }, async (err, value) => {
558
558
  if (err) {
559
- reject(errorObject(err, service, "Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */));
559
+ reject(errorObject(err, service, "Upload failed"));
560
560
  }
561
561
  else if (value) {
562
562
  if (beforeResolve) {
@@ -566,7 +566,7 @@ class Cloud extends core_1.ClientDb {
566
566
  resolve(value);
567
567
  }
568
568
  else {
569
- reject((0, types_1.errorMessage)(service, "Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */));
569
+ reject((0, types_1.errorMessage)(service, "Upload failed"));
570
570
  }
571
571
  });
572
572
  }
@@ -587,14 +587,14 @@ class Cloud extends core_1.ClientDb {
587
587
  handler = this.getDownloadHandler(service, credential).bind(this);
588
588
  }
589
589
  catch (err) {
590
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Download function not supported" /* ERR_CLOUD.DOWNLOAD_SUPPORT */, bucket], Cloud.joinPath(download.pathname, download.filename), { ...Cloud.LOG_CLOUD_WARN });
590
+ this.formatMessage(64, service, ["Download function not supported", bucket], Cloud.joinPath(download.pathname, download.filename), { ...Cloud.LOG_CLOUD_WARN });
591
591
  return Promise.reject(err);
592
592
  }
593
593
  return new Promise((resolve, reject) => {
594
594
  try {
595
595
  handler({ bucket, download }, async (err, value) => {
596
596
  if (err) {
597
- reject(errorObject(err, service, "Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */));
597
+ reject(errorObject(err, service, "Download failed"));
598
598
  }
599
599
  else if (value) {
600
600
  if (beforeResolve) {
@@ -610,7 +610,7 @@ class Cloud extends core_1.ClientDb {
610
610
  resolve(value);
611
611
  }
612
612
  else {
613
- reject((0, types_1.errorMessage)(service, "Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */));
613
+ reject((0, types_1.errorMessage)(service, "Download failed"));
614
614
  }
615
615
  });
616
616
  }
@@ -642,13 +642,13 @@ class Cloud extends core_1.ClientDb {
642
642
  return await client.executeQuery.call(this, credential, item, sessionKey);
643
643
  }
644
644
  catch (err) {
645
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, "Unable to execute query" /* ERR_DB.EXEC_QUERY */, err, { ...Cloud.LOG_CLOUD_FAIL });
645
+ this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
646
646
  return Promise.reject(err);
647
647
  }
648
648
  }
649
- return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported" /* ERR_CLOUD.EXECUTE_QUERY_SUPPORT */));
649
+ return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported"));
650
650
  }
651
- return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials" /* ERR_DB.CREDENTIALS */));
651
+ return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials"));
652
652
  }
653
653
  async getDatabaseBatchRows(batch, ignoreErrors, sessionKey) {
654
654
  if (this.aborted) {
@@ -674,13 +674,13 @@ class Cloud extends core_1.ClientDb {
674
674
  return await client.executeBatchQuery.call(this, credential, batch, sessionKey);
675
675
  }
676
676
  catch (err) {
677
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, "Unable to execute query" /* ERR_DB.EXEC_QUERY */, err, { ...Cloud.LOG_CLOUD_FAIL });
677
+ this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
678
678
  return Promise.reject(err);
679
679
  }
680
680
  }
681
- return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported" /* ERR_CLOUD.EXECUTE_QUERY_SUPPORT */));
681
+ return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported"));
682
682
  }
683
- return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials" /* ERR_DB.CREDENTIALS */));
683
+ return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials"));
684
684
  }
685
685
  getCredential(item, unused) {
686
686
  const service = item.service;
@@ -708,7 +708,7 @@ class Cloud extends core_1.ClientDb {
708
708
  if ((0, types_1.isArray)(data)) {
709
709
  for (const item of data) {
710
710
  const service = this.hasStorage(action, item);
711
- if (service && service.active) { // eslint-disable-line @typescript-eslint/prefer-optional-chain
711
+ if (service && service.active) {
712
712
  return item;
713
713
  }
714
714
  }
@@ -740,7 +740,7 @@ class Cloud extends core_1.ClientDb {
740
740
  }
741
741
  }
742
742
  catch (err) {
743
- this.formatFail(64 /* LOG_TYPE.CLOUD */, data.service, "Cloud provider not found" /* ERR_CLOUD.PROVIDER_NOTFOUND */, err, { ...Cloud.LOG_CLOUD_FAIL });
743
+ this.formatFail(64, data.service, "Cloud provider not found", err, { ...Cloud.LOG_CLOUD_FAIL });
744
744
  }
745
745
  return false;
746
746
  }
@@ -755,7 +755,7 @@ class Cloud extends core_1.ClientDb {
755
755
  if (!service.startsWith('@')) {
756
756
  result = this.settings.imports?.[service] || util_1.IMPORTS[service];
757
757
  }
758
- else if (!folder && !service.startsWith("@squared-functions/" /* NAMESPACE.SQUARED_FUNCTIONS */)) {
758
+ else if (!folder && !service.startsWith("@squared-functions/")) {
759
759
  folder = 'client';
760
760
  }
761
761
  return (result || service) + (folder ? '/' + folder : '');
@@ -772,7 +772,7 @@ class Cloud extends core_1.ClientDb {
772
772
  data.ignoreCache ?? (data.ignoreCache = true);
773
773
  return this.getDatabaseRows(data, true);
774
774
  });
775
- return items.length === 0 ? false : this.allSettled(items, ["Execute unassigned queries" /* VAL_DB.EXEC_QUERYUNASSIGNED */, this.moduleName]).then(result => result.length > 0).catch(() => false);
775
+ return items.length === 0 ? false : this.allSettled(items, ["Execute unassigned queries", this.moduleName]).then(result => result.length > 0).catch(() => false);
776
776
  }
777
777
  getClient(service) {
778
778
  let client = SERVICE_CLIENT.get(service);
@@ -788,11 +788,11 @@ class Cloud extends core_1.ClientDb {
788
788
  }
789
789
  catch {
790
790
  }
791
- throw (0, types_1.errorMessage)(service, "Cloud provider not found" /* ERR_CLOUD.PROVIDER_NOTFOUND */);
791
+ throw (0, types_1.errorMessage)(service, "Cloud provider not found");
792
792
  }
793
793
  }
794
- Cloud.STORE_RESULT_PARTITION_SIZE = 16 /* CACHE_SIZE.CLOUD_PARTITION_SIZE */;
795
- Cloud.STORE_RESULT_PARTITION_MULT = 2 /* CACHE_SIZE.CLOUD_PARTITION_MULT */;
794
+ Cloud.STORE_RESULT_PARTITION_SIZE = 16;
795
+ Cloud.STORE_RESULT_PARTITION_MULT = 2;
796
796
  Cloud.LOG_CLOUD_FAIL = core_1.ClientDb.LOG_STYLE_FAIL;
797
797
  Cloud.LOG_CLOUD_COMMAND = Object.freeze({ titleColor: 'blue' });
798
798
  Cloud.LOG_CLOUD_WARN = Object.freeze({ titleColor: 'yellow' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/cloud",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Cloud constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,9 +20,9 @@
20
20
  "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.8.4",
24
- "@e-mc/db": "0.8.4",
25
- "@e-mc/types": "0.8.4",
23
+ "@e-mc/core": "0.8.6",
24
+ "@e-mc/db": "0.8.6",
25
+ "@e-mc/types": "0.8.6",
26
26
  "mime-types": "^2.1.35"
27
27
  }
28
28
  }
package/util.js CHANGED
@@ -4,8 +4,8 @@ exports.hasBasicAuth = exports.getBasicAuth = exports.formatError = exports.gene
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
  const mime = require("mime-types");
7
- const types_1 = require("../types");
8
- const util_1 = require("../db/util");
7
+ const types_1 = require("@e-mc/types");
8
+ const util_1 = require("@e-mc/db/util");
9
9
  Object.defineProperty(exports, "getBasicAuth", { enumerable: true, get: function () { return util_1.getBasicAuth; } });
10
10
  Object.defineProperty(exports, "hasBasicAuth", { enumerable: true, get: function () { return util_1.hasBasicAuth; } });
11
11
  exports.IMPORTS = {
@@ -74,9 +74,10 @@ function generateFilename(filename) {
74
74
  let basename, suffix;
75
75
  return (i) => {
76
76
  if (i === 1) {
77
- const j = filename.indexOf('.');
77
+ const type = /\.[a-z0-9]+\.[a-z0-9]+$/i.exec(filename);
78
+ const j = type ? type.index : filename.lastIndexOf('.');
78
79
  if (j !== -1) {
79
- const match = /^([\S\s]+?)_(\d+)$/.exec(basename = filename.substring(0, j));
80
+ const match = /^(.+)_(\d+)$/.exec(basename = filename.substring(0, j));
80
81
  if (match) {
81
82
  basename = match[1];
82
83
  i = parseInt(match[2]) + 1;