@pittica/google-business-intelligence-helpers 1.3.0 → 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
@@ -32,6 +32,9 @@ const {
32
32
  partsToDate,
33
33
  stringToDate
34
34
  } = require("./naming/date");
35
+ const {
36
+ isDataCsv
37
+ } = require("./naming/schema");
35
38
  const {
36
39
  getFilenameVersion,
37
40
  incrementFilenameVersion,
@@ -56,6 +59,7 @@ exports.getTemporaryTableName = getTemporaryTableName;
56
59
  exports.getTemporaryTableSuffix = getTemporaryTableSuffix;
57
60
  exports.partsToDate = partsToDate;
58
61
  exports.stringToDate = stringToDate;
62
+ exports.isDataCsv = isDataCsv;
59
63
  exports.getFilenameVersion = getFilenameVersion;
60
64
  exports.incrementFilenameVersion = incrementFilenameVersion;
61
65
  exports.getJsonStorageName = getJsonStorageName;
@@ -63,6 +63,7 @@ exports.createFilename = filedata => `${format(filedata.date, "YYYY-MM-DD")}-${f
63
63
  * @param {Date} date File date.
64
64
  * @param {string} name File or function name.
65
65
  * @param {string} extension File extension.
66
+ * @param {int} version File version.
66
67
  * @returns {string} The merged given filename parts.
67
68
  */
68
- exports.mergeFilename = (date, name, extension) => `${format(date, "YYYY-MM-DD")}-${name}.${extension.toLowerCase()}`;
69
+ exports.mergeFilename = (date, name, extension, version = 0) => `${format(date, "YYYY-MM-DD")}-${name}${version ? `_${version}` : ""}.${extension.toLowerCase()}`;
@@ -0,0 +1,30 @@
1
+ // Copyright 2024-2025 Pittica S.r.l.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ const {
16
+ hasSchema
17
+ } = require("../contents/schema");
18
+
19
+ /**
20
+ * Determines whether the given file data matches the whitelist requirements.
21
+ *
22
+ * @param {object} data Filename data.
23
+ * @param {string} folder Path of the folder to scan.
24
+ * @returns {boolean} A value indicating whether the given file data matches the whitelist requirements.
25
+ */
26
+ exports.isDataCsv = ({
27
+ match,
28
+ extension,
29
+ name
30
+ }, folder) => match && extension && extension.toLowerCase() === "csv" && hasSchema(name, folder);
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.3.0",
4
+ "version": "1.4.0",
5
5
  "description": "Helpers for business intelligence for Google Cloud.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {