@pi-r/gcp 0.5.2 → 0.5.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Wit Studio
1
+ Copyright 2024 An Pham
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,6 +1,6 @@
1
1
  # @pi-r/gcp
2
2
 
3
- PEP 402 - Forever Vivy
3
+ PEP 402 - Forever
4
4
 
5
5
  ## LICENSE
6
6
 
package/client/index.js CHANGED
@@ -70,7 +70,7 @@ function updatePredefinedAcl(acl, values, metadata = {}) {
70
70
  let defaultObjectAcl;
71
71
  ({ projectNumber, defaultObjectAcl } = metadata);
72
72
  if (projectNumber === undefined && (0, types_1.isArray)(defaultObjectAcl)) {
73
- const target = defaultObjectAcl.find(item => item.projectTeam?.projectNumber);
73
+ const target = defaultObjectAcl.find(item => { var _a; return (_a = item.projectTeam) === null || _a === void 0 ? void 0 : _a.projectNumber; });
74
74
  if (target !== undefined) {
75
75
  projectNumber = target.projectTeam.projectNumber;
76
76
  }
@@ -210,6 +210,7 @@ async function createBucketV2(credential, bucket, acl, options, service = 'gcp')
210
210
  }
211
211
  exports.createBucketV2 = createBucketV2;
212
212
  async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
213
+ var _a;
213
214
  if (isFirebaseApp(credential, true, true)) {
214
215
  return false;
215
216
  }
@@ -226,7 +227,7 @@ async function setBucketPolicy(credential, bucket, options, service = 'gcp') {
226
227
  case 'private':
227
228
  case 'projectPrivate':
228
229
  await client.makePrivate(options).catch(err => !isErrorConflict(err) && errors.push(err));
229
- await setPredefinedAcl.call(this, client.acl, acl, client, '', options.bucket?.metadata).catch(err => errors.push(err));
230
+ await setPredefinedAcl.call(this, client.acl, acl, client, '', (_a = options.bucket) === null || _a === void 0 ? void 0 : _a.metadata).catch(err => errors.push(err));
230
231
  break;
231
232
  case 'authenticatedRead':
232
233
  await client.makePublic(options).catch(err => !isErrorConflict(err) && errors.push(err));
@@ -384,7 +385,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
384
385
  };
385
386
  const closeClient = () => {
386
387
  const fs = clients[3];
387
- fs?.terminate();
388
+ fs === null || fs === void 0 ? void 0 : fs.terminate();
388
389
  };
389
390
  const getFamily = (data, row, family) => {
390
391
  const familyData = data[family];
@@ -712,6 +713,7 @@ function setPublicRead(acl, pathname, requested, service = 'gcp') {
712
713
  }
713
714
  exports.setPublicRead = setPublicRead;
714
715
  async function setPredefinedAcl(target, value, bucket, pathname = '', metadata = {}, requested = true, service = 'gcp') {
716
+ var _a;
715
717
  let revoke;
716
718
  if (metadata === true) {
717
719
  revoke = true;
@@ -726,7 +728,7 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
726
728
  items = [{ entity: 'allUsers' }, { entity: 'allAuthenticatedUsers', role: revoke ? undefined : 'READER' }];
727
729
  break;
728
730
  default: {
729
- const owner = metadata.owner?.entity;
731
+ const owner = (_a = metadata.owner) === null || _a === void 0 ? void 0 : _a.entity;
730
732
  let acl = metadata.acl;
731
733
  if ((0, types_1.isArray)(acl)) {
732
734
  items = [];
@@ -784,7 +786,7 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
784
786
  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 });
785
787
  }
786
788
  else if (requested && (bucket || pathname)) {
787
- this.formatMessage(64, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket?.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
789
+ this.formatMessage(64, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket === null || bucket === void 0 ? void 0 : bucket.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
788
790
  }
789
791
  });
790
792
  }
package/download/index.js CHANGED
@@ -1,5 +1,4 @@
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");
@@ -78,9 +77,5 @@ function download(credential, service = 'gcp') {
78
77
  }
79
78
  };
80
79
  }
81
- exports.default = download;
82
80
 
83
- if (exports.default) {
84
- module.exports = exports.default;
85
- module.exports.default = exports.default;
86
- }
81
+ module.exports = download;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/gcp",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Google (GCP) cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -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.7.2",
24
- "@e-mc/module": "^0.7.2",
25
- "@e-mc/types": "^0.7.2",
26
- "@google-cloud/firestore": "^7.3.1",
27
- "@google-cloud/storage": "^7.7.0"
23
+ "@e-mc/cloud": "^0.7.5",
24
+ "@e-mc/module": "^0.7.5",
25
+ "@e-mc/types": "^0.7.5",
26
+ "@google-cloud/firestore": "^7.6.0",
27
+ "@google-cloud/storage": "^7.9.0"
28
28
  }
29
29
  }
package/upload/index.js CHANGED
@@ -1,5 +1,4 @@
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 util_1 = require("@e-mc/cloud/util");
@@ -45,7 +44,7 @@ function upload(credential, service = 'gcp') {
45
44
  const configBucket = admin.configBucket;
46
45
  if (!BUCKET_SESSION.has(bucket)) {
47
46
  const bucketAcl = admin.publicRead ? 'publicRead' : admin.acl;
48
- const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, configBucket?.create || (0, client_1.createBucketRequest)(credential)));
47
+ const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, (configBucket === null || configBucket === void 0 ? void 0 : configBucket.create) || (0, client_1.createBucketRequest)(credential)));
49
48
  if (!await response) {
50
49
  uploadResponse(null);
51
50
  return;
@@ -53,11 +52,12 @@ function upload(credential, service = 'gcp') {
53
52
  BUCKET_SESSION.add(bucket);
54
53
  }
55
54
  bucketClient = storage.bucket(bucket);
56
- const retentionPolicy = configBucket?.retentionPolicy;
55
+ const retentionPolicy = configBucket === null || configBucket === void 0 ? void 0 : configBucket.retentionPolicy;
57
56
  if (typeof retentionPolicy === 'number') {
58
57
  bucketClient.setRetentionPeriod(retentionPolicy)
59
58
  .then(([response]) => {
60
- this.formatMessage(64, service, ["Bucket configured" + ' (retention policy)', bucket], response.retentionPolicy?.effectiveTime, { ...Cloud.LOG_CLOUD_COMMAND });
59
+ var _a;
60
+ this.formatMessage(64, service, ["Bucket configured" + ' (retention policy)', bucket], (_a = response.retentionPolicy) === null || _a === void 0 ? void 0 : _a.effectiveTime, { ...Cloud.LOG_CLOUD_COMMAND });
61
61
  })
62
62
  .catch(err => addLog(err));
63
63
  }
@@ -235,9 +235,5 @@ function upload(credential, service = 'gcp') {
235
235
  }
236
236
  };
237
237
  }
238
- exports.default = upload;
239
238
 
240
- if (exports.default) {
241
- module.exports = exports.default;
242
- module.exports.default = exports.default;
243
- }
239
+ module.exports = upload;