@pittica/google-cloud-storage-helpers 1.2.1 → 1.3.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/LICENSE +1 -1
- package/dist/storage/file.js +41 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@ Apache License
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2024 Pittica S.r.l.
|
|
189
|
+
Copyright 2024-2025 Pittica S.r.l.
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/dist/storage/file.js
CHANGED
|
@@ -78,9 +78,49 @@ exports.deleteFile = file => file.delete().then(response => {
|
|
|
78
78
|
* @returns {Array} Files from the given bucket.
|
|
79
79
|
*/
|
|
80
80
|
exports.getFiles = (storage, source, prefix) => storage.bucket(source).getFiles({
|
|
81
|
-
prefix
|
|
81
|
+
prefix,
|
|
82
|
+
autoPaginate: false
|
|
82
83
|
}).then(files => files).catch(() => []);
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Lists the files from the given bucket.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} bucket Bucket name.
|
|
89
|
+
* @param {string} prefix Files prefix.
|
|
90
|
+
* @returns {Array} Files from the given bucket.
|
|
91
|
+
* @since 1.3.0
|
|
92
|
+
*/
|
|
93
|
+
exports.listFiles = (source, prefix) => getStorage().bucket(source).getFiles({
|
|
94
|
+
prefix,
|
|
95
|
+
autoPaginate: false,
|
|
96
|
+
fields: "items(name)"
|
|
97
|
+
}).then(res => {
|
|
98
|
+
const [items] = res;
|
|
99
|
+
return items.map(({
|
|
100
|
+
name
|
|
101
|
+
}) => name);
|
|
102
|
+
}).catch(() => []);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Lists the folders from the given bucket.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} bucket Bucket name.
|
|
108
|
+
* @param {string} prefix Files prefix.
|
|
109
|
+
* @returns {Array} Folders from the given bucket.
|
|
110
|
+
* @since 1.3.0
|
|
111
|
+
*/
|
|
112
|
+
exports.listFolders = async (source, prefix = "") => await getStorage().bucket(source).getFiles({
|
|
113
|
+
prefix,
|
|
114
|
+
autoPaginate: false,
|
|
115
|
+
delimiter: "/",
|
|
116
|
+
fields: "prefixes"
|
|
117
|
+
}).then(res => {
|
|
118
|
+
const [,, {
|
|
119
|
+
prefixes
|
|
120
|
+
}] = res;
|
|
121
|
+
return prefixes.map(prefix => prefix.replace(/\/+$/, ""));
|
|
122
|
+
}).catch(() => []);
|
|
123
|
+
|
|
84
124
|
/**
|
|
85
125
|
* Process the response from copy API and extracts the response file object.
|
|
86
126
|
*
|
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.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "Helpers for Google Cloud Storage.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/pittica/google-cloud-storage-helpers#README.md",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@google-cloud/storage": "^7.
|
|
29
|
+
"@google-cloud/storage": "^7.17.2",
|
|
30
30
|
"@pittica/logger-helpers": "^0.9.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/cli": "^7.
|
|
33
|
+
"@babel/cli": "^7.28.3",
|
|
34
34
|
"mkdirp": "^3.0.1",
|
|
35
|
-
"prettier": "^3.
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
36
|
"rimraf": "^6.0.1",
|
|
37
37
|
"run-func": "^3.0.0"
|
|
38
38
|
}
|