docusaurus-plugin-generate-schema-docs 1.7.0 → 1.8.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/README.md +39 -0
- package/__tests__/ExampleDataLayer.test.js +149 -2
- package/__tests__/__fixtures__/schema-processing/components/dataLayer.json +9 -0
- package/__tests__/__fixtures__/schema-processing/event-reference.json +14 -0
- package/__tests__/__fixtures__/schema-processing/purchase-event.json +14 -0
- package/__tests__/components/PropertyRow.test.js +30 -0
- package/__tests__/components/__snapshots__/ConnectorLines.visualRegression.test.js.snap +3 -3
- package/__tests__/helpers/exampleModel.test.js +88 -0
- package/__tests__/helpers/schema-processing.test.js +56 -0
- package/__tests__/helpers/snippetTargets.test.js +744 -0
- package/__tests__/helpers/trackingTargets.test.js +42 -0
- package/__tests__/runtimePayload.android.test.js +292 -0
- package/__tests__/runtimePayload.ios.test.js +282 -0
- package/__tests__/runtimePayload.web.test.js +32 -0
- package/__tests__/syncGtm.test.js +346 -0
- package/__tests__/validateSchemas.test.js +53 -1
- package/components/ExampleDataLayer.js +191 -56
- package/components/PropertyRow.js +3 -2
- package/components/SchemaRows.css +10 -1
- package/helpers/exampleModel.js +70 -0
- package/helpers/schema-processing.js +41 -5
- package/helpers/snippetTargets.js +853 -0
- package/helpers/trackingTargets.js +73 -0
- package/helpers/validator.js +1 -0
- package/index.js +34 -0
- package/package.json +1 -1
- package/scripts/sync-gtm.js +397 -0
- package/test-data/payloadContracts.js +155 -0
- package/validateSchemas.js +15 -0
package/validateSchemas.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import processSchema from './helpers/processSchema.js';
|
|
5
5
|
import { schemaToExamples } from './helpers/schemaToExamples.js';
|
|
6
|
+
import { resolveTrackingTargets } from './helpers/trackingTargets.js';
|
|
6
7
|
|
|
7
8
|
const validateSingleSchema = async (filePath, schemaPath) => {
|
|
8
9
|
const file = path.basename(filePath);
|
|
@@ -13,6 +14,20 @@ const validateSingleSchema = async (filePath, schemaPath) => {
|
|
|
13
14
|
const mergedSchema = await processSchema(filePath);
|
|
14
15
|
const exampleGroups = schemaToExamples(mergedSchema);
|
|
15
16
|
const originalSchema = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
17
|
+
const trackingTargets = resolveTrackingTargets(originalSchema, {
|
|
18
|
+
schemaFile: file,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (trackingTargets.warning) {
|
|
22
|
+
console.warn(trackingTargets.warning);
|
|
23
|
+
}
|
|
24
|
+
if (trackingTargets.errors.length > 0) {
|
|
25
|
+
trackingTargets.errors.forEach((error) =>
|
|
26
|
+
errors.push(`x Schema ${file} ${error}`),
|
|
27
|
+
);
|
|
28
|
+
return { allValid: false, errors };
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
const validate = await createValidator([], originalSchema, schemaPath);
|
|
17
32
|
|
|
18
33
|
if (exampleGroups.length === 0) {
|