@pittica/google-business-intelligence-csv 1.1.4 → 1.2.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/config.js CHANGED
@@ -38,9 +38,11 @@ exports.config = (config = {}) => {
38
38
  },
39
39
  files: {
40
40
  json: path.join(process.cwd(), "json"),
41
- sql: path.join(process.cwd(), "sql")
41
+ sql: path.join(process.cwd(), "sql"),
42
+ bootstrap: null
42
43
  },
43
- order: []
44
+ order: [],
45
+ bootstrap: []
44
46
  };
45
47
  global.config = {
46
48
  ...initial,
@@ -23,6 +23,7 @@ const {
23
23
  * Gets BigQuery load job default metadata.
24
24
  *
25
25
  * @param {string} filename Filename.
26
+ * @param {string} location Dataset location.
26
27
  * @returns {JobLoadMetadata} BigQuery base metadata.
27
28
  */
28
- exports.getJobMetadata = filename => jobMetadata(getSchema(filename, config.files.json));
29
+ exports.getJobMetadata = (filename, location = "us-central1") => jobMetadata(getSchema(filename, config.files.json), location);
package/dist/index.js CHANGED
@@ -21,6 +21,9 @@ const {
21
21
  const {
22
22
  file
23
23
  } = require("./scripts/file");
24
+ const {
25
+ bootstrap
26
+ } = require("./scripts/bootstrap");
24
27
  const {
25
28
  config
26
29
  } = require("./config");
@@ -28,5 +31,6 @@ exports.config = config;
28
31
  exports.scripts = {
29
32
  bulk,
30
33
  day,
31
- file
34
+ file,
35
+ bootstrap
32
36
  };
@@ -0,0 +1,24 @@
1
+ // Copyright 2024-2026 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
+ executeSqlFolder
17
+ } = require("@pittica/google-bigquery-helpers");
18
+
19
+ /**
20
+ * Processes a the files from the configuration.
21
+ *
22
+ * @returns {boolean} A value indicating whether the process has been done.
23
+ */
24
+ exports.bootstrap = async () => config.files.bootstrap ? executeSqlFolder(config.files.bootstrap, config.bootstrap) : false;
@@ -101,7 +101,7 @@ exports.process = (dataset, source, temporary, destination, files, now, index =
101
101
  if (temp) {
102
102
  deleteFile(file);
103
103
  const table = dataset.table(getTemporaryTableName(filedata, config.dataset.temporary.prefix));
104
- table.load(temp, getJobMetadata(filedata.name)).then(response => {
104
+ table.load(temp, getJobMetadata(filedata.name, config.dataset.temporary.location)).then(response => {
105
105
  if (jobDone(response)) {
106
106
  getSafeFilenameFromBucket(destination, mergeFiledata(filedata), now).then(merged => temp.copy(destination.file(`${now}/${mergeFiledata(merged)}`)).then(destinationResponse => {
107
107
  const copy = copiedFile(destinationResponse);
@@ -85,7 +85,7 @@ exports.file = async (name, bucketSource, bucketTemporary, bucketDestination, cl
85
85
  */
86
86
  exports.run = async (table, destination, file, filedata, day, clean = false) => {
87
87
  const storage = getStorage();
88
- return await table.load(file, getJobMetadata(filedata.name)).then(async response => {
88
+ return await table.load(file, getJobMetadata(filedata.name, config.dataset.temporary.location)).then(async response => {
89
89
  if (jobDone(response)) {
90
90
  return await file.copy(storage.bucket(destination).file(`${day}/${file.name}`)).then(async () => {
91
91
  deleteFile(file);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pittica/google-business-intelligence-csv",
3
3
  "private": false,
4
- "version": "1.1.4",
4
+ "version": "1.2.0",
5
5
  "description": "CSV importer for business intelligence for Google Cloud.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "homepage": "https://github.com/pittica/google-business-intelligence-csv#README.md",
27
27
  "dependencies": {
28
- "@pittica/google-bigquery-helpers": "^1.2.5",
28
+ "@pittica/google-bigquery-helpers": "^1.4.4",
29
29
  "@pittica/google-business-intelligence-helpers": "^1.12.7",
30
30
  "@pittica/google-cloud-storage-helpers": "^1.3.5",
31
31
  "@pittica/logger-helpers": "^1.0.4",