@pi-r/gcp 0.3.2 → 0.3.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 Studio Trigger
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 Aina
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];
@@ -714,6 +715,7 @@ function setPublicRead(acl, pathname, requested, service = 'gcp') {
714
715
  }
715
716
  exports.setPublicRead = setPublicRead;
716
717
  async function setPredefinedAcl(target, value, bucket, pathname = '', metadata = {}, requested = true, service = 'gcp') {
718
+ var _a;
717
719
  let revoke;
718
720
  if (metadata === true) {
719
721
  revoke = true;
@@ -728,7 +730,7 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
728
730
  items = [{ entity: 'allUsers' }, { entity: 'allAuthenticatedUsers', role: revoke ? undefined : 'READER' }];
729
731
  break;
730
732
  default: {
731
- const owner = metadata.owner?.entity;
733
+ const owner = (_a = metadata.owner) === null || _a === void 0 ? void 0 : _a.entity;
732
734
  let acl = metadata.acl;
733
735
  if ((0, types_1.isArray)(acl)) {
734
736
  items = [];
@@ -786,7 +788,7 @@ async function setPredefinedAcl(target, value, bucket, pathname = '', metadata =
786
788
  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 });
787
789
  }
788
790
  else if (requested && (bucket || pathname)) {
789
- this.formatMessage(64, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket?.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
791
+ this.formatMessage(64, service, [(revoke ? 'Revoke' : 'Grant') + ' ' + value, bucket === null || bucket === void 0 ? void 0 : bucket.name], pathname, { ...Cloud.LOG_CLOUD_COMMAND });
790
792
  }
791
793
  });
792
794
  }
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.3.2",
3
+ "version": "0.3.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.6.1",
24
- "@e-mc/module": "^0.6.1",
25
- "@e-mc/types": "^0.6.1",
23
+ "@e-mc/cloud": "^0.6.3",
24
+ "@e-mc/module": "^0.6.3",
25
+ "@e-mc/types": "^0.6.3",
26
26
  "@google-cloud/firestore": "^6.8.0",
27
- "@google-cloud/storage": "^7.7.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");
@@ -14,6 +13,7 @@ function upload(credential, service = 'gcp') {
14
13
  const storage = client_1.createStorageClient.call(this, credential);
15
14
  return async (data, callback) => {
16
15
  var _a;
16
+ var _b;
17
17
  const firebase = (0, client_1.isFirebaseApp)(credential, true, true);
18
18
  const { bucket, localUri } = data;
19
19
  const { pathname = '', fileGroup, contentType, metadata, endpoint, active, publicRead, acl, admin = {}, overwrite, options } = data.upload;
@@ -43,7 +43,7 @@ function upload(credential, service = 'gcp') {
43
43
  else {
44
44
  if (!BUCKET_SESSION.has(bucket)) {
45
45
  const bucketAcl = admin.publicRead ? 'publicRead' : admin.acl;
46
- const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, admin.configBucket?.create || (0, client_1.createBucketRequest)(credential)));
46
+ const response = BUCKET_RESPONSE[_b = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_b] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, ((_a = admin.configBucket) === null || _a === void 0 ? void 0 : _a.create) || (0, client_1.createBucketRequest)(credential)));
47
47
  if (!await response) {
48
48
  uploadResponse(null);
49
49
  return;
@@ -226,9 +226,5 @@ function upload(credential, service = 'gcp') {
226
226
  }
227
227
  };
228
228
  }
229
- exports.default = upload;
230
229
 
231
- if (exports.default) {
232
- module.exports = exports.default;
233
- module.exports.default = exports.default;
234
- }
230
+ module.exports = upload;