@pittica/google-business-intelligence-helpers 1.15.4 → 1.17.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 +5 -1
- package/dist/naming/file.js +24 -3
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -58,7 +58,9 @@ const {
|
|
|
58
58
|
getJsonStorageName,
|
|
59
59
|
createFilename,
|
|
60
60
|
mergeFilename,
|
|
61
|
-
mergeFiledata
|
|
61
|
+
mergeFiledata,
|
|
62
|
+
isFiledataMatch,
|
|
63
|
+
safeFilenamesProcess
|
|
62
64
|
} = require("./naming/file");
|
|
63
65
|
const {
|
|
64
66
|
splitName,
|
|
@@ -114,6 +116,8 @@ exports.getJsonStorageName = getJsonStorageName;
|
|
|
114
116
|
exports.createFilename = createFilename;
|
|
115
117
|
exports.mergeFilename = mergeFilename;
|
|
116
118
|
exports.mergeFiledata = mergeFiledata;
|
|
119
|
+
exports.isFiledataMatch = isFiledataMatch;
|
|
120
|
+
exports.safeFilenamesProcess = safeFilenamesProcess;
|
|
117
121
|
exports.splitName = splitName;
|
|
118
122
|
exports.splitIdByKeys = splitIdByKeys;
|
|
119
123
|
exports.scripts = {
|
package/dist/naming/file.js
CHANGED
|
@@ -58,9 +58,10 @@ exports.getJsonStorageName = (date, file) => `${format(date, "YYYY-MM-DD")}/${fo
|
|
|
58
58
|
* Generates a filename from the givend data.
|
|
59
59
|
*
|
|
60
60
|
* @param {object} filedata File data.
|
|
61
|
+
* @param {string} format Date format.
|
|
61
62
|
* @returns {string} A filename from the givend data.
|
|
62
63
|
*/
|
|
63
|
-
exports.createFilename = filedata => `${format(filedata.date,
|
|
64
|
+
exports.createFilename = (filedata, format = "YYYY-MM-DD") => `${format(filedata.date, format)}-${filedata.fullname}.${filedata.extension}`;
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Merges the given filename parts.
|
|
@@ -69,9 +70,10 @@ exports.createFilename = filedata => `${format(filedata.date, "YYYY-MM-DD")}-${f
|
|
|
69
70
|
* @param {string} name File or function name.
|
|
70
71
|
* @param {string} extension File extension.
|
|
71
72
|
* @param {int} version File version.
|
|
73
|
+
* @param {string} format Date format.
|
|
72
74
|
* @returns {string} The merged given filename parts.
|
|
73
75
|
*/
|
|
74
|
-
exports.mergeFilename = (date, name, extension, version = 0) => `${format(date,
|
|
76
|
+
exports.mergeFilename = (date, name, extension, version = 0, format = "YYYY-MM-DD") => `${format(date, format)}-${name}${version ? `_${version}` : ""}.${extension.toLowerCase()}`;
|
|
75
77
|
|
|
76
78
|
/**
|
|
77
79
|
* Merges the given filename data.
|
|
@@ -85,4 +87,23 @@ exports.mergeFiledata = ({
|
|
|
85
87
|
name,
|
|
86
88
|
extension,
|
|
87
89
|
version
|
|
88
|
-
}, increment = false) => exports.mergeFilename(date, name, extension, increment ? typeof version !== "undefined" ? version + 1 : 1 : version);
|
|
90
|
+
}, increment = false) => exports.mergeFilename(date, name, extension, increment ? typeof version !== "undefined" ? version + 1 : 1 : version);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Checks if two file data objects have matching filenames.
|
|
94
|
+
*
|
|
95
|
+
* @param {object} first First object compare.
|
|
96
|
+
* @param {object} second Second object compare.
|
|
97
|
+
* @returns {boolean} True if the filenames match, false otherwise.
|
|
98
|
+
*/
|
|
99
|
+
exports.isFiledataMatch = (first, second) => exports.mergeFilename(first) === exports.mergeFilename(second);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Processes filenames safely based on the provided configuration.
|
|
103
|
+
*
|
|
104
|
+
* @param {Array} files Array of file objects.
|
|
105
|
+
* @param {Array} configuration Array of allowed filenames.
|
|
106
|
+
* @returns {Array} Array of processed filenames.
|
|
107
|
+
* @since 1.17.0
|
|
108
|
+
*/
|
|
109
|
+
exports.safeFilenamesProcess = (files, configuration = []) => files.map(file => splitName(file)).filter(file => configuration.includes(file.name)).map(file => mergeFiledata(file));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pittica/google-business-intelligence-helpers",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.17.0",
|
|
5
5
|
"description": "Helpers for business intelligence for Google Cloud.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@pittica/google-bigquery-helpers": "^1.7.0",
|
|
40
|
-
"@pittica/google-cloud-storage-helpers": "^1.
|
|
40
|
+
"@pittica/google-cloud-storage-helpers": "^1.7.1",
|
|
41
41
|
"@pittica/logger-helpers": "^1.2.2",
|
|
42
|
-
"date-and-time": "^4.7.
|
|
42
|
+
"date-and-time": "^4.7.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@babel/cli": "^8.0
|
|
45
|
+
"@babel/cli": "^8.1.0",
|
|
46
46
|
"mkdirp": "^3.0.1",
|
|
47
|
-
"prettier": "^3.
|
|
48
|
-
"rimraf": "^6.1.
|
|
47
|
+
"prettier": "^3.10.0",
|
|
48
|
+
"rimraf": "^6.1.4",
|
|
49
49
|
"run-func": "^3.0.0"
|
|
50
50
|
}
|
|
51
51
|
}
|