ga4-export-fixer 0.4.6-dev.1 → 0.4.6

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/README.md CHANGED
@@ -150,7 +150,7 @@ Include the package in the package.json file in your Dataform repository.
150
150
  {
151
151
  "dependencies": {
152
152
  "@dataform/core": "3.0.42",
153
- "ga4-export-fixer": "0.4.5"
153
+ "ga4-export-fixer": "0.4.6"
154
154
  }
155
155
  }
156
156
  ```
@@ -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
- // self - required, must be valid format
17
- if (config.test !== true) {
18
- if (typeof config.self !== 'string' || !config.self.trim() || !/^`[^`]+`$/.test(config.self.trim())) {
19
- 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)}`);
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
- // incremental - required, must be boolean
24
- if (typeof config.incremental !== 'boolean') {
25
- throw new Error(`config.incremental must be a boolean. Received: ${JSON.stringify(config.incremental)}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.4.6-dev.1",
3
+ "version": "0.4.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -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) => {