@pittica/google-cloud-storage-helpers 1.3.5 → 1.4.0

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/dist/index.js CHANGED
@@ -31,7 +31,8 @@ const {
31
31
  groupJson
32
32
  } = require("./storage/json");
33
33
  const {
34
- getStorage
34
+ getStorage,
35
+ getBucket
35
36
  } = require("./storage/storage");
36
37
  exports.copyFile = copyFile;
37
38
  exports.deleteFile = deleteFile;
@@ -45,4 +46,5 @@ exports.groupJson = groupJson;
45
46
  exports.downloadFile = downloadFile;
46
47
  exports.downloadBucket = downloadBucket;
47
48
  exports.downloadFolder = downloadFolder;
48
- exports.getStorage = getStorage;
49
+ exports.getStorage = getStorage;
50
+ exports.getBucket = getBucket;
package/dist/scripts.js CHANGED
@@ -13,7 +13,7 @@
13
13
  // limitations under the License.
14
14
 
15
15
  const {
16
- bucket
16
+ downloadBucket
17
17
  } = require("./storage/download");
18
18
 
19
19
  /**
@@ -22,4 +22,4 @@ const {
22
22
  * @param {string} name Bucket name.
23
23
  * @param {string} destination Destination path.
24
24
  */
25
- exports.download = async (name, destination = __dirname) => bucket(name, destination);
25
+ exports.download = async (name, destination = __dirname) => downloadBucket(name, destination);
@@ -32,7 +32,7 @@ exports.downloadBucket = async (bucket, destination = __dirname) => {
32
32
  const [files] = await source.getFiles();
33
33
  files.forEach(({
34
34
  name
35
- }) => this.downloadFile(name, source, destination));
35
+ }) => exports.downloadFile(name, source, destination));
36
36
  };
37
37
 
38
38
  /**
@@ -59,8 +59,7 @@ exports.downloadFile = async (file, bucket, directory = __dirname) => {
59
59
  * @param {string} folder Folder name.
60
60
  * @param {Bucket} bucket Google Cloud Storage bucket object.
61
61
  * @param {string} directory Destination directory.
62
- *
63
- * @returns {Promise}
62
+ * @returns {Promise} Response.
64
63
  */
65
64
  exports.downloadFolder = (folder, bucket, directory = __dirname) => {
66
65
  const storage = new Storage();
@@ -30,7 +30,7 @@ exports.moveFiles = async (source, destination) => {
30
30
  const storage = getStorage();
31
31
  const bucket = storage.bucket(destination);
32
32
  const [files] = await storage.bucket(source).getFiles();
33
- files.forEach(results => Array.isArray(results) ? results.forEach(file => this.moveFile(file, bucket)) : this.moveFile(results, bucket));
33
+ files.forEach(results => Array.isArray(results) ? results.forEach(file => exports.moveFile(file, bucket)) : exports.moveFile(results, bucket));
34
34
  };
35
35
 
36
36
  /**
@@ -46,7 +46,7 @@ exports.moveFile = async (file, bucket) => {
46
46
  const source = file.metadata.bucket;
47
47
  const destination = bucket.id;
48
48
  log.info(`Moving "${id}" from "${source}" to "${destination}"`);
49
- file.copy(bucket.file(id)).then(() => this.deleteFile(file) ? log.success(`Moved "${id}" from "${source}" to "${destination}"`) : log.error(`Failed deleted "${id}" in "${source}"`)).catch(() => log.error(`Failed moving "${id}" from "${source}" to "${destination}"`));
49
+ file.copy(bucket.file(id)).then(() => exports.deleteFile(file) ? log.success(`Moved "${id}" from "${source}" to "${destination}"`) : log.error(`Failed deleted "${id}" in "${source}"`)).catch(() => log.error(`Failed moving "${id}" from "${source}" to "${destination}"`));
50
50
  };
51
51
 
52
52
  /**
@@ -26,4 +26,13 @@ exports.getStorage = () => new Storage({
26
26
  autoRetry: true,
27
27
  retryDelayMultiplier: 4
28
28
  }
29
- });
29
+ });
30
+
31
+ /**
32
+ * Gets a Google Cloud Storage bucket.
33
+ *
34
+ * @param {string} bucket Bucket name.
35
+ * @returns {Storage} A Google Cloud Storage client.
36
+ * @since 1.4.0
37
+ */
38
+ exports.getBucket = bucket => exports.getStorage().bucket(bucket);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pittica/google-cloud-storage-helpers",
3
3
  "private": false,
4
- "version": "1.3.5",
4
+ "version": "1.4.0",
5
5
  "description": "Helpers for Google Cloud Storage.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -26,14 +26,14 @@
26
26
  },
27
27
  "homepage": "https://github.com/pittica/google-cloud-storage-helpers#README.md",
28
28
  "dependencies": {
29
- "@google-cloud/storage": "^7.18.0",
30
- "@pittica/logger-helpers": "^1.0.4"
29
+ "@google-cloud/storage": "^7.21.0",
30
+ "@pittica/logger-helpers": "^1.0.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/cli": "^7.28.3",
33
+ "@babel/cli": "^7.29.7",
34
34
  "mkdirp": "^3.0.1",
35
- "prettier": "^3.7.4",
36
- "rimraf": "^6.1.2",
35
+ "prettier": "^3.9.0",
36
+ "rimraf": "^6.1.3",
37
37
  "run-func": "^3.0.0"
38
38
  }
39
39
  }