@pi-r/gcp 0.2.2 → 0.2.9

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 2020-24 Code Geass
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
- ### @pi-r/gcp
1
+ # @pi-r/gcp
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Josee + Nunnally
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/client/index.js CHANGED
@@ -184,7 +184,7 @@ async function createBucketV2(credential, bucket, acl, options, service = 'gcp')
184
184
  }
185
185
  return storage.createBucket(bucket, options)
186
186
  .then(async ([target]) => {
187
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket created" /* VAL_CLOUD.CREATE_BUCKET */, bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
187
+ this.formatMessage(64, service, ["Bucket created", bucket], '', { ...Cloud.LOG_CLOUD_COMMAND });
188
188
  if (acl) {
189
189
  await setBucketPolicy.call(this, credential, bucket, { acl, bucket: target }, service);
190
190
  }
@@ -194,7 +194,7 @@ async function createBucketV2(credential, bucket, acl, options, service = 'gcp')
194
194
  if (isErrorConflict(err)) {
195
195
  return acl ? await setBucketPolicy.call(this, credential, bucket, { acl }, service) : true;
196
196
  }
197
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to create bucket" /* ERR_CLOUD.CREATE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_FAIL });
197
+ this.formatFail(64, service, ["Unable to create bucket", bucket], err, { ...Cloud.LOG_CLOUD_FAIL });
198
198
  return false;
199
199
  });
200
200
  }
@@ -205,7 +205,7 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
205
205
  }
206
206
  const client = createStorageClient.call(this, credential, bucket).bucket(bucket);
207
207
  if (!await hasBucket(client)) {
208
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Bucket does not exist" /* ERR_CLOUD.EXISTS_BUCKET */, bucket], (0, util_1.formatError)(service, "Bucket does not exist" /* ERR_CLOUD.EXISTS_BUCKET */), { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
208
+ this.formatFail(64, service, ["Bucket does not exist", bucket], (0, util_1.formatError)(service, "Bucket does not exist"), { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
209
209
  return false;
210
210
  }
211
211
  const errors = [];
@@ -246,10 +246,10 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
246
246
  errors.push(...await updatePredefinedAcl(client.acl, options.acl, options));
247
247
  }
248
248
  if (errors.length) {
249
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, bucket], errors[0], { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
249
+ this.formatFail(64, service, ["Unable to update bucket policy", bucket], errors[0], { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
250
250
  return false;
251
251
  }
252
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket ACL configured" /* VAL_CLOUD.ACL_BUCKET */, bucket], (0, types_1.isString)(acl) ? acl : '', { ...Cloud.LOG_CLOUD_COMMAND });
252
+ this.formatMessage(64, service, ["Bucket ACL configured", bucket], (0, types_1.isString)(acl) ? acl : '', { ...Cloud.LOG_CLOUD_COMMAND });
253
253
  return true;
254
254
  }
255
255
  exports.setBucketPolicy = setBucketPolicy;
@@ -266,11 +266,11 @@ function setBucketWebsite(credential, bucket, options, service = 'gcp') {
266
266
  }
267
267
  return createStorageClient.call(this, credential, bucket).bucket(bucket).setMetadata({ website })
268
268
  .then(() => {
269
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket configured" /* VAL_CLOUD.CONFIGURE_BUCKET */, bucket], website, { ...Cloud.LOG_CLOUD_COMMAND });
269
+ this.formatMessage(64, service, ["Bucket configured", bucket], website, { ...Cloud.LOG_CLOUD_COMMAND });
270
270
  return true;
271
271
  })
272
272
  .catch(err => {
273
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to configure bucket" /* ERR_CLOUD.CONFIGURE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
273
+ this.formatFail(64, service, ["Unable to configure bucket", bucket], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
274
274
  return false;
275
275
  });
276
276
  }
@@ -310,14 +310,14 @@ async function deleteObjectsV2(credential, bucket, recursive = true, service = '
310
310
  const client = storage.bucket(bucket);
311
311
  if (await hasBucket(client)) {
312
312
  if (recursive) {
313
- return client.deleteFiles({ force: true }).then(() => this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Bucket emptied" /* VAL_CLOUD.EMPTY_BUCKET */ + ' (recursive)', bucket, { ...Cloud.LOG_CLOUD_COMMAND }));
313
+ return client.deleteFiles({ force: true }).then(() => this.formatMessage(64, service, "Bucket emptied" + ' (recursive)', bucket, { ...Cloud.LOG_CLOUD_COMMAND }));
314
314
  }
315
315
  const tasks = [];
316
316
  try {
317
317
  const result = await client.getFiles();
318
318
  for (const { name } of result[0]) {
319
319
  if (name.indexOf('/') === -1) {
320
- tasks.push(client.file(name).delete({ ignoreNotFound: true }).catch(err => this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Delete failed" /* ERR_CLOUD.DELETE_FAIL */, name], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false })));
320
+ tasks.push(client.file(name).delete({ ignoreNotFound: true }).catch(err => this.formatFail(64, service, ["Delete failed", name], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: false })));
321
321
  }
322
322
  }
323
323
  }
@@ -331,7 +331,7 @@ async function deleteObjectsV2(credential, bucket, recursive = true, service = '
331
331
  }
332
332
  const checkErrors = () => {
333
333
  if (errors.length) {
334
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */ + (recursive ? ' (recursive)' : ''), errors.length + ' errors'], errors[0], { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
334
+ this.formatFail(64, service, ["Unable to empty bucket" + (recursive ? ' (recursive)' : ''), errors.length + ' errors'], errors[0], { ...Cloud.LOG_CLOUD_FAIL, fatal: false });
335
335
  return true;
336
336
  }
337
337
  return false;
@@ -341,7 +341,7 @@ async function deleteObjectsV2(credential, bucket, recursive = true, service = '
341
341
  errors.push(...result.filter(item => item.status === 'rejected').map((item) => item.reason));
342
342
  if (!checkErrors()) {
343
343
  const files = result.length + ' files';
344
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Bucket emptied" /* VAL_CLOUD.EMPTY_BUCKET */ + ` (${recursive ? 'recursive' : files})`, bucket], recursive ? files : '', { ...Cloud.LOG_CLOUD_COMMAND });
344
+ this.formatMessage(64, service, ["Bucket emptied" + ` (${recursive ? 'recursive' : files})`, bucket], recursive ? files : '', { ...Cloud.LOG_CLOUD_COMMAND });
345
345
  }
346
346
  })
347
347
  .catch(err => {
@@ -372,7 +372,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
372
372
  return (clients[type] = createDatabaseClient.call(this, item, data));
373
373
  };
374
374
  const closeClient = () => {
375
- const fs = clients[3 /* DB.FIRESTORE */];
375
+ const fs = clients[3];
376
376
  if (fs) {
377
377
  fs.terminate();
378
378
  }
@@ -421,7 +421,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
421
421
  result[i] = rows;
422
422
  continue;
423
423
  }
424
- const db = createClient(item, 4 /* DB.BIGTABLE */).instance(name).table(table);
424
+ const db = createClient(item, 4).instance(name).table(table);
425
425
  if (id) {
426
426
  const row = db.row(id);
427
427
  if (Array.isArray(columns)) {
@@ -447,11 +447,11 @@ async function executeBatchQuery(credential, batch, sessionKey) {
447
447
  const columns = (0, types_1.isPlainObject)(query) && query.columns || item.columns;
448
448
  if (!(query || table && columns)) {
449
449
  closeClient();
450
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
450
+ throw (0, util_1.formatError)(item, "Missing database query");
451
451
  }
452
452
  if (!name || !database) {
453
453
  closeClient();
454
- throw (0, util_1.formatError)(item, !name ? "Missing instance name" /* ERR_DB.INSTANCE */ : "Missing database name" /* ERR_DB.NAME */);
454
+ throw (0, util_1.formatError)(item, !name ? "Missing instance name" : "Missing database name");
455
455
  }
456
456
  const { updateType, options = {} } = item;
457
457
  if (cached) {
@@ -461,7 +461,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
461
461
  continue;
462
462
  }
463
463
  }
464
- const db = createClient(item, 5 /* DB.SPANNER */).instance(name).database(database, options.databasePool, options.databaseQuery);
464
+ const db = createClient(item, 5).instance(name).database(database, options.databasePool, options.databaseQuery);
465
465
  if (table) {
466
466
  if ((0, types_1.isPlainObject)(update)) {
467
467
  await db.table(table)[updateType === 1 ? 'insert' : updateType === 2 ? 'replace' : 'update'](update, options.tableUpdate);
@@ -480,7 +480,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
480
480
  await new Promise((resolve, reject) => {
481
481
  db.runTransaction((err, transaction) => {
482
482
  if (err || !transaction) {
483
- reject(err || new Error("Unknown" /* ERR_MESSAGE.UNKNOWN */));
483
+ reject(err || new Error("Unknown"));
484
484
  }
485
485
  else {
486
486
  transaction.runUpdate(update)
@@ -501,7 +501,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
501
501
  else if (product === 'firebase' || product === 'bigquery' || !product && !table && typeof query === 'string') {
502
502
  if (!(0, types_1.isString)(query)) {
503
503
  closeClient();
504
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
504
+ throw (0, util_1.formatError)(item, "Missing database query");
505
505
  }
506
506
  const firebaseApp = product === 'firebase' || isFirebaseApp(credential);
507
507
  if (cached) {
@@ -544,7 +544,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
544
544
  }
545
545
  }
546
546
  }
547
- const db = createClient(item, 0 /* DB.FIREBASE */);
547
+ const db = createClient(item, 0);
548
548
  if ((0, types_1.isPlainObject)(update)) {
549
549
  await updateDB(ref(db, query), update);
550
550
  }
@@ -562,20 +562,20 @@ async function executeBatchQuery(credential, batch, sessionKey) {
562
562
  if (limit > 0) {
563
563
  options.maxResults = limit;
564
564
  }
565
- const [job] = await createClient(item, 1 /* DB.BIGQUERY */).createQueryJob(options);
565
+ const [job] = await createClient(item, 1).createQueryJob(options);
566
566
  [rows] = await job.getQueryResults();
567
567
  }
568
568
  }
569
569
  else if (product === 'datastore' || !product && !table && (keys || query)) {
570
570
  if (!keys && !Array.isArray(query)) {
571
571
  closeClient();
572
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
572
+ throw (0, util_1.formatError)(item, "Missing database query");
573
573
  }
574
574
  if (cached && (rows = getCache(queryString = Module.asString(keys || query, true) + Module.asString(item.options, true) + limit))) {
575
575
  result[i] = rows;
576
576
  continue;
577
577
  }
578
- const db = createClient(item, 2 /* DB.DATASTORE */);
578
+ const db = createClient(item, 2);
579
579
  if (keys) {
580
580
  const items = !Array.isArray(keys) ? db.key(keys) : keys.map((key) => db.key(key));
581
581
  rows = await db.get(items, item.options);
@@ -598,7 +598,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
598
598
  case 'order':
599
599
  case 'select':
600
600
  case 'start':
601
- task[method].apply(task, args.slice(1)); // eslint-disable-line prefer-spread
601
+ task[method].apply(task, args.slice(1));
602
602
  break;
603
603
  }
604
604
  }
@@ -612,7 +612,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
612
612
  else if (product === 'firestore' || !product && table) {
613
613
  if (!table) {
614
614
  closeClient();
615
- throw (0, util_1.formatError)(item, "Missing database table" /* ERR_DB.TABLE */);
615
+ throw (0, util_1.formatError)(item, "Missing database table");
616
616
  }
617
617
  if (cached) {
618
618
  queryString = table + '_';
@@ -625,7 +625,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
625
625
  continue;
626
626
  }
627
627
  }
628
- const db = createClient(item, 3 /* DB.FIRESTORE */).collection(table).doc(id);
628
+ const db = createClient(item, 3).collection(table).doc(id);
629
629
  if ((0, types_1.isPlainObject)(update)) {
630
630
  await db.update(update, { exists: true });
631
631
  }
@@ -639,7 +639,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
639
639
  result[i] = rows;
640
640
  continue;
641
641
  }
642
- let db = createClient(item, 3 /* DB.FIRESTORE */).collection(table);
642
+ let db = createClient(item, 3).collection(table);
643
643
  for (const args of query) {
644
644
  if ((0, types_1.isArray)(args)) {
645
645
  const method = args[0];
@@ -655,7 +655,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
655
655
  case 'startAt':
656
656
  case 'where':
657
657
  case 'withConverter':
658
- db = db[method].apply(db, args.slice(1)); // eslint-disable-line prefer-spread
658
+ db = db[method].apply(db, args.slice(1));
659
659
  break;
660
660
  }
661
661
  }
@@ -674,12 +674,12 @@ async function executeBatchQuery(credential, batch, sessionKey) {
674
674
  }
675
675
  else {
676
676
  closeClient();
677
- throw (0, util_1.formatError)(item, "Missing database query" /* ERR_DB.QUERY */);
677
+ throw (0, util_1.formatError)(item, "Missing database query");
678
678
  }
679
679
  }
680
680
  else {
681
681
  closeClient();
682
- throw (0, util_1.formatError)(item, "Missing database product" /* ERR_DB.PRODUCT */);
682
+ throw (0, util_1.formatError)(item, "Missing database product");
683
683
  }
684
684
  result[i] = this.setQueryResult(service, credential, queryString, rows, cacheValue);
685
685
  }
@@ -691,12 +691,12 @@ function setPublicRead(acl, pathname, requested, service = 'gcp') {
691
691
  acl.add({ entity: 'allUsers', role: 'READER' })
692
692
  .then(() => {
693
693
  if (requested) {
694
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Grant public-read" /* VAL_CLOUD.PUBLIC_READ */, pathname, { ...Cloud.LOG_CLOUD_COMMAND });
694
+ this.formatMessage(64, service, "Grant public-read", pathname, { ...Cloud.LOG_CLOUD_COMMAND });
695
695
  }
696
696
  })
697
697
  .catch(err => {
698
698
  if (requested) {
699
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to grant public-read" /* ERR_CLOUD.PUBLIC_READ */, pathname], err, { ...Cloud.LOG_CLOUD_WARN });
699
+ this.formatMessage(64, service, ["Unable to grant public-read", pathname], err, { ...Cloud.LOG_CLOUD_WARN });
700
700
  }
701
701
  });
702
702
  }
@@ -778,10 +778,10 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
778
778
  }
779
779
  return updatePredefinedAcl(target, items, metadata).then(errors => {
780
780
  if (errors.length) {
781
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, [`Unable to ${revoke ? 'revoke' : 'grant'} ` + value, bucket && pathname ? bucket.name + '/' + pathname : bucket ? bucket.name : pathname], errors[0], { ...Cloud.LOG_CLOUD_WARN });
781
+ this.formatMessage(64, service, [`Unable to ${revoke ? 'revoke' : 'grant'} ` + value, bucket && pathname ? bucket.name + '/' + pathname : bucket ? bucket.name : pathname], errors[0], { ...Cloud.LOG_CLOUD_WARN });
782
782
  }
783
783
  else if (requested && (bucket || pathname)) {
784
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket?.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
784
+ this.formatMessage(64, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket?.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
785
785
  }
786
786
  });
787
787
  }
package/download/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const fs = require("fs");
5
4
  const https = require("https");
6
- const client_1 = require("../client");
5
+ const client_1 = require("@pi-r/gcp");
7
6
  const types_1 = require("@e-mc/types");
8
7
  const Module = require("@e-mc/module");
9
8
  const Cloud = require("@e-mc/cloud");
@@ -25,12 +24,12 @@ function download(credential, service = 'gcp') {
25
24
  return;
26
25
  }
27
26
  if (!(tempDir = this.getTempDir({ uuidDir: true }))) {
28
- downloadResponse(new Error("Unable to create temp directory" /* ERR_CLOUD.TEMP_DIR */));
27
+ downloadResponse(new Error("Unable to create temp directory"));
29
28
  return;
30
29
  }
31
30
  const location = Module.joinPath(Bucket, Key);
32
31
  const destination = path.join(tempDir, path.basename(Key));
33
- const deleteMessage = () => this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Delete success" /* VAL_CLOUD.DELETE_FILE */, location, { ...Cloud.LOG_CLOUD_DELETE });
32
+ const deleteMessage = () => this.formatMessage(64, service, "Delete success", location, { ...Cloud.LOG_CLOUD_DELETE });
34
33
  if (firebase) {
35
34
  const { ref, getDownloadURL, deleteObject } = require('@firebase/storage');
36
35
  const objectRef = ref(storage, Key);
@@ -45,7 +44,7 @@ function download(credential, service = 'gcp') {
45
44
  if (target.deleteObject) {
46
45
  deleteObject(objectRef)
47
46
  .then(() => deleteMessage())
48
- .catch(err => this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Delete failed" /* ERR_CLOUD.DELETE_FAIL */, location], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active }));
47
+ .catch(err => this.formatFail(64, service, ["Delete failed", location], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active }));
49
48
  }
50
49
  })
51
50
  .on('error', err => downloadResponse(err)));
@@ -69,7 +68,7 @@ function download(credential, service = 'gcp') {
69
68
  deleteMessage();
70
69
  }
71
70
  else {
72
- this.formatFail(64 /* LOG_TYPE.CLOUD */, service, ["Delete failed" /* ERR_CLOUD.DELETE_FAIL */, location], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active });
71
+ this.formatFail(64, service, ["Delete failed", location], err, { ...Cloud.LOG_CLOUD_FAIL, fatal: !!target.active });
73
72
  }
74
73
  });
75
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/gcp",
3
- "version": "0.2.2",
3
+ "version": "0.2.9",
4
4
  "description": "Google (GCP) cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/anpham6/pi-r.git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
12
  "directory": "src/cloud/gcp"
13
13
  },
14
14
  "keywords": [
@@ -20,10 +20,10 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "^0.5.3",
24
- "@e-mc/module": "^0.5.3",
25
- "@e-mc/types": "^0.5.3",
26
- "@google-cloud/firestore": "^6.5.0",
27
- "@google-cloud/storage": "^6.10.1"
23
+ "@e-mc/cloud": "^0.5.5",
24
+ "@e-mc/module": "^0.5.5",
25
+ "@e-mc/types": "^0.5.5",
26
+ "@google-cloud/firestore": "^6.8.0",
27
+ "@google-cloud/storage": "^6.12.0"
28
28
  }
29
29
  }
package/upload/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const fs = require("fs");
5
- const client_1 = require("../client");
4
+ const client_1 = require("@pi-r/gcp");
6
5
  const util_1 = require("@e-mc/cloud/util");
7
6
  const types_1 = require("@e-mc/types");
8
7
  const Module = require("@e-mc/module");
@@ -72,13 +71,13 @@ function upload(credential, service = 'gcp') {
72
71
  }
73
72
  } while (exists && ++i);
74
73
  if (i > 0) {
75
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["File renamed" /* VAL_CLOUD.RENAME_FILE */, current], filename, { ...Cloud.LOG_CLOUD_WARN });
74
+ this.formatMessage(64, service, ["File renamed", current], filename, { ...Cloud.LOG_CLOUD_WARN });
76
75
  }
77
76
  }
78
77
  const Key = [filename];
79
78
  const Body = [data.buffer];
80
79
  const ContentType = [contentType];
81
- const getURL = (value) => endpoint ? Module.joinPath(endpoint, value) : Module.joinPath("https://storage.googleapis.com" /* STRINGS.BASE_URL */, bucket, value);
80
+ const getURL = (value) => endpoint ? Module.joinPath(endpoint, value) : Module.joinPath("https://storage.googleapis.com", bucket, value);
82
81
  const addLog = (err) => err instanceof Error && this.addLog(this.statusType.WARN, err.message, service + ': ' + bucket);
83
82
  if (fileGroup) {
84
83
  for (const [content, ext, localFile] of fileGroup) {
@@ -123,7 +122,7 @@ function upload(credential, service = 'gcp') {
123
122
  uploadBytes(ref(bucketClient, destination), Body[i], params)
124
123
  .then(() => {
125
124
  const url = getURL(destination);
126
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Upload success" /* VAL_CLOUD.UPLOAD_FILE */, url, { ...Cloud.LOG_CLOUD_UPLOAD });
125
+ this.formatMessage(64, service, "Upload success", url, { ...Cloud.LOG_CLOUD_UPLOAD });
127
126
  if (first) {
128
127
  uploadResponse(null, url);
129
128
  }
@@ -143,7 +142,7 @@ function upload(credential, service = 'gcp') {
143
142
  const output = Body[i];
144
143
  if (Buffer.isBuffer(output) || path.basename(output) !== Key[i]) {
145
144
  if (!(tempDir = this.getTempDir({ uuidDir: true }))) {
146
- throw new Error("Unable to create temp directory" /* ERR_CLOUD.TEMP_DIR */);
145
+ throw new Error("Unable to create temp directory");
147
146
  }
148
147
  outputUri = path.join(tempDir, Key[i]);
149
148
  if (typeof output === 'string') {
@@ -204,7 +203,7 @@ function upload(credential, service = 'gcp') {
204
203
  bucketClient.upload(outputUri, params, (err, file) => {
205
204
  if (file) {
206
205
  const url = getURL(file.name);
207
- this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, "Upload success" /* VAL_CLOUD.UPLOAD_FILE */, url, { ...Cloud.LOG_CLOUD_UPLOAD });
206
+ this.formatMessage(64, service, "Upload success", url, { ...Cloud.LOG_CLOUD_UPLOAD });
208
207
  if (first) {
209
208
  uploadResponse(null, url);
210
209
  }