ga4-export-fixer 0.4.6-dev.0 → 0.4.6-dev.2
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/index.js +2 -2
- package/inputValidation.js +16 -11
- package/package.json +1 -1
- package/tables/ga4EventsEnhanced.js +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const helpers = require('./helpers/index.js');
|
|
2
2
|
const ga4EventsEnhanced = require('./tables/ga4EventsEnhanced.js');
|
|
3
|
-
const { setPreOperations } = require('./preOperations.js');
|
|
3
|
+
const { setPreOperations: setPreOperationsRaw } = require('./preOperations.js');
|
|
4
4
|
const { validateBaseConfig } = require('./inputValidation.js');
|
|
5
5
|
const { mergeSQLConfigurations } = require('./utils.js');
|
|
6
6
|
const { baseConfig } = require('./defaultConfig.js');
|
|
@@ -13,7 +13,7 @@ const setPreOperations = (config) => {
|
|
|
13
13
|
// do input validation on the merged config
|
|
14
14
|
validateBaseConfig(mergedConfig);
|
|
15
15
|
|
|
16
|
-
return
|
|
16
|
+
return setPreOperationsRaw(mergedConfig);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
module.exports = {
|
package/inputValidation.js
CHANGED
|
@@ -6,23 +6,28 @@ const { isDataformTableReferenceObject } = require('./utils.js');
|
|
|
6
6
|
* self, incremental, test, testConfig, and preOperations.
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} config - The merged configuration object to validate.
|
|
9
|
+
* @param {Object} [options] - Validation options.
|
|
10
|
+
* @param {boolean} [options.skipDataformContextFields=false] - Skip validation of `self` and `incremental`,
|
|
11
|
+
* which are set by Dataform's publish() context rather than user input.
|
|
9
12
|
* @throws {Error} If any base configuration value is invalid or missing.
|
|
10
13
|
*/
|
|
11
|
-
const validateBaseConfig = (config) => {
|
|
14
|
+
const validateBaseConfig = (config, options = {}) => {
|
|
12
15
|
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
13
16
|
throw new Error(`config must be a non-null object. Received: ${JSON.stringify(config)}`);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
19
|
+
if (!options.skipDataformContextFields) {
|
|
20
|
+
// self - required, must be valid format
|
|
21
|
+
if (config.test !== true) {
|
|
22
|
+
if (typeof config.self !== 'string' || !config.self.trim() || !/^`[^`]+`$/.test(config.self.trim())) {
|
|
23
|
+
throw new Error(`config.self is required when config.test !== true and must be a non-empty string in format '\`project.dataset.table\`' (using the ref() function). Received: ${JSON.stringify(config.self)}`);
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
|
-
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// incremental - required, must be boolean
|
|
28
|
+
if (typeof config.incremental !== 'boolean') {
|
|
29
|
+
throw new Error(`config.incremental must be a boolean. Received: ${JSON.stringify(config.incremental)}`);
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
// test - optional; when defined, must be a boolean
|
|
@@ -96,14 +101,14 @@ const validateBaseConfig = (config) => {
|
|
|
96
101
|
* @param {Object} config - The merged configuration object to validate.
|
|
97
102
|
* @throws {Error} If any configuration value is invalid or missing.
|
|
98
103
|
*/
|
|
99
|
-
const validateEnhancedEventsConfig = (config) => {
|
|
104
|
+
const validateEnhancedEventsConfig = (config, options = {}) => {
|
|
100
105
|
try {
|
|
101
106
|
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
102
107
|
throw new Error(`config must be a non-null object. Received: ${JSON.stringify(config)}`);
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
// base config fields (self, incremental, test, testConfig, preOperations)
|
|
106
|
-
validateBaseConfig(config);
|
|
111
|
+
validateBaseConfig(config, options);
|
|
107
112
|
|
|
108
113
|
/*
|
|
109
114
|
Rest of the validations are related to ga4_events_enhanced table specific fields
|
package/package.json
CHANGED
|
@@ -318,7 +318,7 @@ const generateEnhancedEventsSQL = (config) => {
|
|
|
318
318
|
*/
|
|
319
319
|
const createEnhancedEventsTable = (dataformPublish, config) => {
|
|
320
320
|
const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
|
|
321
|
-
inputValidation.validateEnhancedEventsConfig(mergedConfig);
|
|
321
|
+
inputValidation.validateEnhancedEventsConfig(mergedConfig, { skipDataformContextFields: true });
|
|
322
322
|
|
|
323
323
|
// Compute dynamic fields from merged SQL config
|
|
324
324
|
const getDatasetName = (sourceTable) => {
|