@contrail/cli 3.4.5 → 3.4.6-alpha.cffb28e
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 +1 -1
- package/dist/commands/groups/import.js +4 -1
- package/dist/commands/load-local/index.js +25 -30
- package/dist/helpers/pipeline/formatters.d.ts +2 -3
- package/dist/helpers/pipeline/formatters.js +63 -63
- package/node_modules/@contrail/entity-compare/CHANGELOG.md +13 -0
- package/node_modules/@contrail/entity-compare/README.md +0 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/entity-compare.client.d.ts +36 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/entity-compare.client.js +118 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/index.d.ts +1 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/index.js +17 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/mockData.d.ts +11 -0
- package/node_modules/@contrail/entity-compare/lib/entity-compare/mockData.js +99 -0
- package/node_modules/@contrail/entity-compare/lib/index.d.ts +1 -0
- package/node_modules/@contrail/entity-compare/lib/index.js +17 -0
- package/node_modules/@contrail/entity-compare/package.json +45 -0
- package/node_modules/@contrail/loader/lib/__mocks__/@contrail/cache.d.ts +2 -0
- package/node_modules/@contrail/loader/lib/__mocks__/@contrail/cache.js +18 -0
- package/node_modules/@contrail/loader/lib/base-processor.d.ts +17 -0
- package/node_modules/@contrail/loader/lib/base-processor.js +26 -0
- package/node_modules/@contrail/loader/lib/color-processor.d.ts +19 -0
- package/node_modules/@contrail/loader/lib/color-processor.js +76 -0
- package/node_modules/@contrail/loader/lib/color-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/color-processor.spec.js +307 -0
- package/node_modules/@contrail/loader/lib/common/conditional-columns.d.ts +16 -0
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +84 -0
- package/node_modules/@contrail/loader/lib/common/conditional-columns.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/conditional-columns.spec.js +644 -0
- package/node_modules/@contrail/loader/lib/common/constants.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/constants.js +4 -0
- package/node_modules/@contrail/loader/lib/common/csv-file-helper.d.ts +6 -0
- package/node_modules/@contrail/loader/lib/common/csv-file-helper.js +66 -0
- package/node_modules/@contrail/loader/lib/common/csv-file-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/csv-file-helper.spec.js +34 -0
- package/node_modules/@contrail/loader/lib/common/data-transformer-functions.d.ts +32 -0
- package/node_modules/@contrail/loader/lib/common/data-transformer-functions.js +309 -0
- package/node_modules/@contrail/loader/lib/common/data-transformer.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/data-transformer.spec.js +744 -0
- package/node_modules/@contrail/loader/lib/common/entities-helper.d.ts +33 -0
- package/node_modules/@contrail/loader/lib/common/entities-helper.js +300 -0
- package/node_modules/@contrail/loader/lib/common/entities-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/entities-helper.spec.js +287 -0
- package/node_modules/@contrail/loader/lib/common/entity-builder-helpers.d.ts +6 -0
- package/node_modules/@contrail/loader/lib/common/entity-builder-helpers.js +114 -0
- package/node_modules/@contrail/loader/lib/common/entity-builder-helpers.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/entity-builder-helpers.spec.js +137 -0
- package/node_modules/@contrail/loader/lib/common/file-helper.d.ts +3 -0
- package/node_modules/@contrail/loader/lib/common/file-helper.js +37 -0
- package/node_modules/@contrail/loader/lib/common/file-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/file-helper.spec.js +65 -0
- package/node_modules/@contrail/loader/lib/common/size-range-helpers.d.ts +42 -0
- package/node_modules/@contrail/loader/lib/common/size-range-helpers.js +162 -0
- package/node_modules/@contrail/loader/lib/common/size-range-helpers.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/size-range-helpers.spec.js +320 -0
- package/node_modules/@contrail/loader/lib/common/type-helper.d.ts +18 -0
- package/node_modules/@contrail/loader/lib/common/type-helper.js +232 -0
- package/node_modules/@contrail/loader/lib/common/type-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/type-helper.spec.js +110 -0
- package/node_modules/@contrail/loader/lib/common/util.d.ts +11 -0
- package/node_modules/@contrail/loader/lib/common/util.js +85 -0
- package/node_modules/@contrail/loader/lib/common/util.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/common/util.spec.js +109 -0
- package/node_modules/@contrail/loader/lib/constants.d.ts +29 -0
- package/node_modules/@contrail/loader/lib/constants.js +32 -0
- package/node_modules/@contrail/loader/lib/custom-entity-processor.d.ts +20 -0
- package/node_modules/@contrail/loader/lib/custom-entity-processor.js +59 -0
- package/node_modules/@contrail/loader/lib/custom-entity-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/custom-entity-processor.spec.js +161 -0
- package/node_modules/@contrail/loader/lib/entities-v2/base-processor-v2.d.ts +27 -0
- package/node_modules/@contrail/loader/lib/entities-v2/base-processor-v2.js +55 -0
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.d.ts +19 -0
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.js +92 -0
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/colors-v2/color-processor-v2.spec.js +456 -0
- package/node_modules/@contrail/loader/lib/entities-v2/custom-entities-v2/custom-entity-processor-v2.d.ts +20 -0
- package/node_modules/@contrail/loader/lib/entities-v2/custom-entities-v2/custom-entity-processor-v2.js +75 -0
- package/node_modules/@contrail/loader/lib/entities-v2/custom-entities-v2/custom-entity-processor-v2.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/custom-entities-v2/custom-entity-processor-v2.spec.js +211 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.d.ts +33 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.js +298 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entities-helper.spec.js +137 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entity-processor-v2.d.ts +36 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entity-processor-v2.js +316 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entity-processor-v2.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/entity-processor-v2.spec.js +973 -0
- package/node_modules/@contrail/loader/lib/entities-v2/file-preprocessor-v2.d.ts +40 -0
- package/node_modules/@contrail/loader/lib/entities-v2/file-preprocessor-v2.js +276 -0
- package/node_modules/@contrail/loader/lib/entities-v2/file-preprocessor-v2.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/file-preprocessor-v2.spec.js +161 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.d.ts +49 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.js +388 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/assortment-processor.spec.js +411 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-helper.d.ts +20 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-helper.js +193 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-helper.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-helper.spec.js +190 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +37 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +271 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +654 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/partial-assortment-processor.d.ts +35 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/partial-assortment-processor.js +242 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/partial-assortment-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/partial-assortment-processor.spec.js +167 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/project-item-processor.d.ts +20 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/project-item-processor.js +104 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/project-item-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/project-item-processor.spec.js +172 -0
- package/node_modules/@contrail/loader/lib/entity-processor.d.ts +34 -0
- package/node_modules/@contrail/loader/lib/entity-processor.js +214 -0
- package/node_modules/@contrail/loader/lib/entity-processor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/entity-processor.spec.js +693 -0
- package/node_modules/@contrail/loader/lib/file-preprocessor.d.ts +31 -0
- package/node_modules/@contrail/loader/lib/file-preprocessor.js +212 -0
- package/node_modules/@contrail/loader/lib/file-preprocessor.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/file-preprocessor.spec.js +151 -0
- package/node_modules/@contrail/loader/lib/index.d.ts +9 -941
- package/node_modules/@contrail/loader/lib/index.js +25 -12492
- package/node_modules/@contrail/loader/lib/mockData.d.ts +36 -0
- package/node_modules/@contrail/loader/lib/mockData.js +209 -0
- package/node_modules/@contrail/loader/lib/pipeline/assortment-execute-helpers.d.ts +9 -0
- package/node_modules/@contrail/loader/lib/pipeline/assortment-execute-helpers.js +226 -0
- package/node_modules/@contrail/loader/lib/pipeline/assortment-execute-helpers.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/assortment-execute-helpers.spec.js +305 -0
- package/node_modules/@contrail/loader/lib/pipeline/coerce-values-by-type.d.ts +7 -0
- package/node_modules/@contrail/loader/lib/pipeline/coerce-values-by-type.js +133 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute-multi-type.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute-multi-type.spec.js +454 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute.d.ts +3 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute.js +271 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/execute.spec.js +186 -0
- package/node_modules/@contrail/loader/lib/pipeline/index.d.ts +7 -0
- package/node_modules/@contrail/loader/lib/pipeline/index.js +29 -0
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.d.ts +38 -0
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.js +517 -0
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/item-execute-helpers.spec.js +170 -0
- package/node_modules/@contrail/loader/lib/pipeline/loader-pipeline.d.ts +10 -0
- package/node_modules/@contrail/loader/lib/pipeline/loader-pipeline.js +26 -0
- package/node_modules/@contrail/loader/lib/pipeline/loader-pipeline.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/loader-pipeline.spec.js +125 -0
- package/node_modules/@contrail/loader/lib/pipeline/preview.d.ts +3 -0
- package/node_modules/@contrail/loader/lib/pipeline/preview.js +219 -0
- package/node_modules/@contrail/loader/lib/pipeline/preview.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/preview.spec.js +155 -0
- package/node_modules/@contrail/loader/lib/pipeline/project-item-execute-helpers.d.ts +5 -0
- package/node_modules/@contrail/loader/lib/pipeline/project-item-execute-helpers.js +580 -0
- package/node_modules/@contrail/loader/lib/pipeline/transform.d.ts +3 -0
- package/node_modules/@contrail/loader/lib/pipeline/transform.js +356 -0
- package/node_modules/@contrail/loader/lib/pipeline/transform.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/transform.spec.js +442 -0
- package/node_modules/@contrail/loader/lib/pipeline/types.d.ts +251 -0
- package/node_modules/@contrail/loader/lib/pipeline/types.js +140 -0
- package/node_modules/@contrail/loader/lib/pipeline/validate.d.ts +2 -0
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +1217 -0
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +1214 -0
- package/node_modules/@contrail/loader/lib/processor-registry.d.ts +3 -0
- package/node_modules/@contrail/loader/lib/processor-registry.js +53 -0
- package/node_modules/@contrail/loader/lib/processor-registry.spec.d.ts +1 -0
- package/node_modules/@contrail/loader/lib/processor-registry.spec.js +8 -0
- package/node_modules/@contrail/loader/package.json +9 -11
- package/node_modules/@contrail/telemetry/CHANGELOG.md +24 -0
- package/node_modules/@contrail/telemetry/README.md +1 -0
- package/node_modules/@contrail/telemetry/lib/index.d.ts +1 -0
- package/node_modules/@contrail/telemetry/lib/index.js +17 -0
- package/node_modules/@contrail/telemetry/lib/logger/index.d.ts +3 -0
- package/node_modules/@contrail/telemetry/lib/logger/index.js +30 -0
- package/node_modules/@contrail/telemetry/package.json +44 -0
- package/node_modules/@pinojs/redact/.github/dependabot.yml +13 -0
- package/node_modules/@pinojs/redact/.github/workflows/ci.yml +48 -0
- package/node_modules/@pinojs/redact/.github/workflows/publish-release.yml +43 -0
- package/node_modules/@pinojs/redact/LICENSE +21 -0
- package/node_modules/@pinojs/redact/README.md +350 -0
- package/node_modules/@pinojs/redact/benchmarks/basic.js +184 -0
- package/node_modules/@pinojs/redact/eslint.config.js +1 -0
- package/node_modules/@pinojs/redact/index.d.ts +52 -0
- package/node_modules/@pinojs/redact/index.js +529 -0
- package/node_modules/@pinojs/redact/index.test-d.ts +22 -0
- package/node_modules/@pinojs/redact/package.json +37 -0
- package/node_modules/@pinojs/redact/scripts/sync-version.mjs +20 -0
- package/node_modules/@pinojs/redact/test/actual-redact-comparison.test.js +211 -0
- package/node_modules/@pinojs/redact/test/index.test.js +824 -0
- package/node_modules/@pinojs/redact/test/integration.test.js +390 -0
- package/node_modules/@pinojs/redact/test/multiple-wildcards.test.js +227 -0
- package/node_modules/@pinojs/redact/test/prototype-pollution.test.js +223 -0
- package/node_modules/@pinojs/redact/test/selective-clone.test.js +115 -0
- package/node_modules/@pinojs/redact/tsconfig.json +19 -0
- package/node_modules/atomic-sleep/.travis.yml +11 -0
- package/node_modules/atomic-sleep/LICENSE +22 -0
- package/node_modules/atomic-sleep/index.js +38 -0
- package/node_modules/atomic-sleep/package.json +37 -0
- package/node_modules/atomic-sleep/readme.md +58 -0
- package/node_modules/atomic-sleep/test.js +47 -0
- package/node_modules/on-exit-leak-free/.github/dependabot.yml +12 -0
- package/node_modules/on-exit-leak-free/.github/workflows/ci.yml +46 -0
- package/node_modules/on-exit-leak-free/LICENSE +21 -0
- package/node_modules/on-exit-leak-free/README.md +54 -0
- package/node_modules/on-exit-leak-free/index.js +108 -0
- package/node_modules/on-exit-leak-free/package.json +37 -0
- package/node_modules/on-exit-leak-free/test/base.test.js +30 -0
- package/node_modules/on-exit-leak-free/test/event-emitter-leak.test.js +23 -0
- package/node_modules/on-exit-leak-free/test/fixtures/beforeExit.js +33 -0
- package/node_modules/on-exit-leak-free/test/fixtures/close.js +21 -0
- package/node_modules/on-exit-leak-free/test/fixtures/gc-not-close.js +24 -0
- package/node_modules/on-exit-leak-free/test/fixtures/unregister.js +24 -0
- package/node_modules/pino/.nojekyll +0 -0
- package/node_modules/pino/.prettierignore +1 -0
- package/node_modules/pino/CNAME +1 -0
- package/node_modules/pino/CONTRIBUTING.md +30 -0
- package/node_modules/pino/LICENSE +21 -0
- package/node_modules/pino/README.md +177 -0
- package/node_modules/pino/SECURITY.md +87 -0
- package/node_modules/pino/benchmarks/basic.bench.js +95 -0
- package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
- package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
- package/node_modules/pino/benchmarks/child.bench.js +62 -0
- package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
- package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
- package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
- package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
- package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
- package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
- package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
- package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
- package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
- package/node_modules/pino/benchmarks/multistream.js +98 -0
- package/node_modules/pino/benchmarks/object.bench.js +82 -0
- package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
- package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
- package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
- package/node_modules/pino/bin.js +6 -0
- package/node_modules/pino/browser.js +547 -0
- package/node_modules/pino/build/sync-version.js +25 -0
- package/node_modules/pino/docs/api.md +1593 -0
- package/node_modules/pino/docs/asynchronous.md +40 -0
- package/node_modules/pino/docs/benchmarks.md +55 -0
- package/node_modules/pino/docs/browser.md +278 -0
- package/node_modules/pino/docs/bundling.md +40 -0
- package/node_modules/pino/docs/child-loggers.md +95 -0
- package/node_modules/pino/docs/diagnostics.md +16 -0
- package/node_modules/pino/docs/ecosystem.md +86 -0
- package/node_modules/pino/docs/help.md +345 -0
- package/node_modules/pino/docs/lts.md +64 -0
- package/node_modules/pino/docs/pretty.md +35 -0
- package/node_modules/pino/docs/redaction.md +135 -0
- package/node_modules/pino/docs/transports.md +1376 -0
- package/node_modules/pino/docs/web.md +309 -0
- package/node_modules/pino/eslint.config.js +28 -0
- package/node_modules/pino/examples/basic.js +43 -0
- package/node_modules/pino/examples/transport.js +68 -0
- package/node_modules/pino/favicon.ico +0 -0
- package/node_modules/pino/file.js +12 -0
- package/node_modules/pino/inc-version.sh +42 -0
- package/node_modules/pino/index.html +55 -0
- package/node_modules/pino/lib/caller.js +30 -0
- package/node_modules/pino/lib/constants.js +28 -0
- package/node_modules/pino/lib/deprecations.js +8 -0
- package/node_modules/pino/lib/levels.js +241 -0
- package/node_modules/pino/lib/meta.js +3 -0
- package/node_modules/pino/lib/multistream.js +203 -0
- package/node_modules/pino/lib/proto.js +256 -0
- package/node_modules/pino/lib/redaction.js +114 -0
- package/node_modules/pino/lib/symbols.js +74 -0
- package/node_modules/pino/lib/time.js +39 -0
- package/node_modules/pino/lib/tools.js +427 -0
- package/node_modules/pino/lib/transport-stream.js +56 -0
- package/node_modules/pino/lib/transport.js +289 -0
- package/node_modules/pino/lib/worker.js +194 -0
- package/node_modules/pino/package.json +120 -0
- package/node_modules/pino/pino.d.ts +908 -0
- package/node_modules/pino/pino.js +234 -0
- package/node_modules/pino/test/basic.test.js +886 -0
- package/node_modules/pino/test/broken-pipe.test.js +59 -0
- package/node_modules/pino/test/browser-child.test.js +132 -0
- package/node_modules/pino/test/browser-disabled.test.js +87 -0
- package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
- package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
- package/node_modules/pino/test/browser-levels.test.js +241 -0
- package/node_modules/pino/test/browser-serializers.test.js +352 -0
- package/node_modules/pino/test/browser-timestamp.test.js +88 -0
- package/node_modules/pino/test/browser-transmit.test.js +417 -0
- package/node_modules/pino/test/browser.test.js +698 -0
- package/node_modules/pino/test/complex-objects.test.js +36 -0
- package/node_modules/pino/test/crlf.test.js +34 -0
- package/node_modules/pino/test/custom-levels.test.js +267 -0
- package/node_modules/pino/test/diagnostics.test.js +107 -0
- package/node_modules/pino/test/error-key.test.js +37 -0
- package/node_modules/pino/test/error.test.js +403 -0
- package/node_modules/pino/test/escaping.test.js +93 -0
- package/node_modules/pino/test/esm/esm.mjs +14 -0
- package/node_modules/pino/test/esm/index.test.js +21 -0
- package/node_modules/pino/test/esm/named-exports.mjs +29 -0
- package/node_modules/pino/test/exit.test.js +79 -0
- package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
- package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
- package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
- package/node_modules/pino/test/fixtures/console-transport.js +13 -0
- package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
- package/node_modules/pino/test/fixtures/default-exit.js +8 -0
- package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
- package/node_modules/pino/test/fixtures/eval/index.js +13 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
- package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
- package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
- package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
- package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
- package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
- package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
- package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
- package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
- package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
- package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
- package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
- package/node_modules/pino/test/fixtures/transport/index.js +12 -0
- package/node_modules/pino/test/fixtures/transport/package.json +5 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
- package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
- package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
- package/node_modules/pino/test/fixtures/transport-main.js +9 -0
- package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
- package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
- package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
- package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
- package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
- package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
- package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
- package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
- package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
- package/node_modules/pino/test/formatters.test.js +364 -0
- package/node_modules/pino/test/helper.d.ts +4 -0
- package/node_modules/pino/test/helper.js +155 -0
- package/node_modules/pino/test/hooks.test.js +114 -0
- package/node_modules/pino/test/http.test.js +214 -0
- package/node_modules/pino/test/internals/version.test.js +17 -0
- package/node_modules/pino/test/is-level-enabled.test.js +179 -0
- package/node_modules/pino/test/jest/basic.spec.js +10 -0
- package/node_modules/pino/test/levels.test.js +810 -0
- package/node_modules/pino/test/metadata.test.js +120 -0
- package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
- package/node_modules/pino/test/mixin.test.js +241 -0
- package/node_modules/pino/test/multistream.test.js +729 -0
- package/node_modules/pino/test/redact.test.js +893 -0
- package/node_modules/pino/test/serializers.test.js +257 -0
- package/node_modules/pino/test/stdout-protection.test.js +41 -0
- package/node_modules/pino/test/syncfalse.test.js +186 -0
- package/node_modules/pino/test/timestamp-nano.test.js +37 -0
- package/node_modules/pino/test/timestamp.test.js +124 -0
- package/node_modules/pino/test/transport/big.test.js +42 -0
- package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
- package/node_modules/pino/test/transport/caller.test.js +24 -0
- package/node_modules/pino/test/transport/core.test.js +733 -0
- package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
- package/node_modules/pino/test/transport/crash.test.js +36 -0
- package/node_modules/pino/test/transport/module-link.test.js +241 -0
- package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
- package/node_modules/pino/test/transport/node-options.test.js +116 -0
- package/node_modules/pino/test/transport/pipeline.test.js +137 -0
- package/node_modules/pino/test/transport/preload.test.js +54 -0
- package/node_modules/pino/test/transport/repl.test.js +15 -0
- package/node_modules/pino/test/transport/sync-false.test.js +67 -0
- package/node_modules/pino/test/transport/sync-true.test.js +57 -0
- package/node_modules/pino/test/transport/targets.test.js +48 -0
- package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
- package/node_modules/pino/test/transport-stream.test.js +40 -0
- package/node_modules/pino/test/types/pino-import.test-d.cts +30 -0
- package/node_modules/pino/test/types/pino-multistream.test-d.ts +28 -0
- package/node_modules/pino/test/types/pino-top-export.test-d.ts +34 -0
- package/node_modules/pino/test/types/pino-transport.test-d.ts +156 -0
- package/node_modules/pino/test/types/pino-type-only.test-d.ts +75 -0
- package/node_modules/pino/test/types/pino.test-d.ts +683 -0
- package/node_modules/pino/test/types/pino.ts +91 -0
- package/node_modules/pino/tsconfig.json +14 -0
- package/node_modules/pino-abstract-transport/.github/dependabot.yml +13 -0
- package/node_modules/pino-abstract-transport/.github/workflows/ci.yml +80 -0
- package/node_modules/pino-abstract-transport/.husky/pre-commit +4 -0
- package/node_modules/pino-abstract-transport/LICENSE +21 -0
- package/node_modules/pino-abstract-transport/README.md +171 -0
- package/node_modules/pino-abstract-transport/index.d.ts +122 -0
- package/node_modules/pino-abstract-transport/index.js +128 -0
- package/node_modules/pino-abstract-transport/package.json +41 -0
- package/node_modules/pino-abstract-transport/test/base.test.js +473 -0
- package/node_modules/pino-abstract-transport/test/fixtures/transport-async-iteration.js +22 -0
- package/node_modules/pino-abstract-transport/test/fixtures/transport-on-data.js +22 -0
- package/node_modules/pino-abstract-transport/test/fixtures/transport-transform.js +24 -0
- package/node_modules/pino-abstract-transport/test/fixtures/worker-pipeline.js +15 -0
- package/node_modules/pino-abstract-transport/test/match.js +24 -0
- package/node_modules/pino-abstract-transport/test/types/index.test-d.ts +31 -0
- package/node_modules/pino-abstract-transport/test/worker.test.js +372 -0
- package/node_modules/pino-std-serializers/.editorconfig +13 -0
- package/node_modules/pino-std-serializers/.github/dependabot.yml +13 -0
- package/node_modules/pino-std-serializers/.github/workflows/ci.yml +81 -0
- package/node_modules/pino-std-serializers/LICENSE +7 -0
- package/node_modules/pino-std-serializers/Readme.md +182 -0
- package/node_modules/pino-std-serializers/eslint.config.js +7 -0
- package/node_modules/pino-std-serializers/index.d.ts +145 -0
- package/node_modules/pino-std-serializers/index.js +36 -0
- package/node_modules/pino-std-serializers/lib/err-helpers.js +118 -0
- package/node_modules/pino-std-serializers/lib/err-proto.js +48 -0
- package/node_modules/pino-std-serializers/lib/err-with-cause.js +48 -0
- package/node_modules/pino-std-serializers/lib/err.js +45 -0
- package/node_modules/pino-std-serializers/lib/req.js +100 -0
- package/node_modules/pino-std-serializers/lib/res.js +47 -0
- package/node_modules/pino-std-serializers/package.json +42 -0
- package/node_modules/pino-std-serializers/test/err-with-cause.test.js +187 -0
- package/node_modules/pino-std-serializers/test/err.test.js +200 -0
- package/node_modules/pino-std-serializers/test/req.test.js +477 -0
- package/node_modules/pino-std-serializers/test/res.test.js +120 -0
- package/node_modules/pino-std-serializers/test/types/index.test-d.ts +71 -0
- package/node_modules/pino-std-serializers/tsconfig.json +13 -0
- package/node_modules/process-warning/.gitattributes +2 -0
- package/node_modules/process-warning/.github/dependabot.yml +13 -0
- package/node_modules/process-warning/.github/workflows/ci.yml +22 -0
- package/node_modules/process-warning/LICENSE +21 -0
- package/node_modules/process-warning/README.md +118 -0
- package/node_modules/process-warning/benchmarks/warn.js +25 -0
- package/node_modules/process-warning/eslint.config.js +6 -0
- package/node_modules/process-warning/examples/example.js +11 -0
- package/node_modules/process-warning/index.js +124 -0
- package/node_modules/process-warning/package.json +73 -0
- package/node_modules/process-warning/test/emit-interpolated-string.test.js +34 -0
- package/node_modules/process-warning/test/emit-once-only.test.js +33 -0
- package/node_modules/process-warning/test/emit-reset.test.js +40 -0
- package/node_modules/process-warning/test/emit-set.test.js +35 -0
- package/node_modules/process-warning/test/emit-unlimited.test.js +42 -0
- package/node_modules/process-warning/test/index.test.js +99 -0
- package/node_modules/process-warning/test/issue-88.test.js +38 -0
- package/node_modules/process-warning/test/jest.test.js +24 -0
- package/node_modules/process-warning/test/no-warnings.test.js +80 -0
- package/node_modules/process-warning/test/promise.js +10 -0
- package/node_modules/process-warning/types/index.d.ts +37 -0
- package/node_modules/process-warning/types/index.test-d.ts +36 -0
- package/node_modules/quick-format-unescaped/.github/workflows/ci.yml +21 -0
- package/node_modules/quick-format-unescaped/LICENSE +21 -0
- package/node_modules/quick-format-unescaped/benchmark.js +24 -0
- package/node_modules/quick-format-unescaped/index.js +109 -0
- package/node_modules/quick-format-unescaped/package.json +29 -0
- package/node_modules/quick-format-unescaped/readme.md +66 -0
- package/node_modules/quick-format-unescaped/test/index.js +136 -0
- package/node_modules/real-require/LICENSE.md +21 -0
- package/node_modules/real-require/README.md +51 -0
- package/node_modules/real-require/package.json +49 -0
- package/node_modules/real-require/src/index.js +14 -0
- package/node_modules/safe-stable-stringify/LICENSE +21 -0
- package/node_modules/safe-stable-stringify/esm/package.json +4 -0
- package/node_modules/safe-stable-stringify/esm/wrapper.d.ts +4 -0
- package/node_modules/safe-stable-stringify/esm/wrapper.js +6 -0
- package/node_modules/safe-stable-stringify/index.d.ts +22 -0
- package/node_modules/safe-stable-stringify/index.js +612 -0
- package/node_modules/safe-stable-stringify/package.json +65 -0
- package/node_modules/safe-stable-stringify/readme.md +177 -0
- package/node_modules/sonic-boom/.eslintignore +2 -0
- package/node_modules/sonic-boom/.taprc +3 -0
- package/node_modules/sonic-boom/LICENSE +21 -0
- package/node_modules/sonic-boom/README.md +153 -0
- package/node_modules/sonic-boom/bench.js +98 -0
- package/node_modules/sonic-boom/check.js +18 -0
- package/node_modules/sonic-boom/example.js +8 -0
- package/node_modules/sonic-boom/fixtures/firehose.js +22 -0
- package/node_modules/sonic-boom/index.js +733 -0
- package/node_modules/sonic-boom/package.json +52 -0
- package/node_modules/sonic-boom/test/destroy.test.js +49 -0
- package/node_modules/sonic-boom/test/end.test.js +98 -0
- package/node_modules/sonic-boom/test/flush-sync.test.js +140 -0
- package/node_modules/sonic-boom/test/flush.test.js +419 -0
- package/node_modules/sonic-boom/test/fsync.test.js +63 -0
- package/node_modules/sonic-boom/test/helper.js +42 -0
- package/node_modules/sonic-boom/test/minlength.test.js +35 -0
- package/node_modules/sonic-boom/test/mode.test.js +116 -0
- package/node_modules/sonic-boom/test/periodicflush.test.js +61 -0
- package/node_modules/sonic-boom/test/reopen.test.js +239 -0
- package/node_modules/sonic-boom/test/retry.test.js +414 -0
- package/node_modules/sonic-boom/test/sync.test.js +261 -0
- package/node_modules/sonic-boom/test/write.test.js +515 -0
- package/node_modules/sonic-boom/types/index.d.ts +63 -0
- package/node_modules/sonic-boom/types/tests/test.ts +4 -0
- package/node_modules/split2/LICENSE +13 -0
- package/node_modules/split2/README.md +85 -0
- package/node_modules/split2/bench.js +27 -0
- package/node_modules/split2/index.js +141 -0
- package/node_modules/split2/package.json +39 -0
- package/node_modules/split2/test.js +409 -0
- package/node_modules/thread-stream/.github/dependabot.yml +13 -0
- package/node_modules/thread-stream/.github/workflows/ci.yml +74 -0
- package/node_modules/thread-stream/.husky/pre-commit +4 -0
- package/node_modules/thread-stream/CLAUDE.md +53 -0
- package/node_modules/thread-stream/LICENSE +21 -0
- package/node_modules/thread-stream/README.md +135 -0
- package/node_modules/thread-stream/bench.js +85 -0
- package/node_modules/thread-stream/eslint.config.js +10 -0
- package/node_modules/thread-stream/index.d.ts +92 -0
- package/node_modules/thread-stream/index.js +541 -0
- package/node_modules/thread-stream/lib/indexes.js +9 -0
- package/node_modules/thread-stream/lib/wait.js +68 -0
- package/node_modules/thread-stream/lib/worker.js +179 -0
- package/node_modules/thread-stream/package.json +52 -0
- package/node_modules/thread-stream/test/base.test.js +259 -0
- package/node_modules/thread-stream/test/bench.test.js +38 -0
- package/node_modules/thread-stream/test/bundlers.test.js +59 -0
- package/node_modules/thread-stream/test/close-on-gc.js +37 -0
- package/node_modules/thread-stream/test/commonjs-fallback.test.js +75 -0
- package/node_modules/thread-stream/test/context.test.js +21 -0
- package/node_modules/thread-stream/test/create-and-exit.js +16 -0
- package/node_modules/thread-stream/test/custom-worker.js +9 -0
- package/node_modules/thread-stream/test/dir with spaces/test-package.zip +0 -0
- package/node_modules/thread-stream/test/emit-event.js +22 -0
- package/node_modules/thread-stream/test/end.test.js +56 -0
- package/node_modules/thread-stream/test/error.js +14 -0
- package/node_modules/thread-stream/test/esm.test.mjs +46 -0
- package/node_modules/thread-stream/test/event.test.js +24 -0
- package/node_modules/thread-stream/test/exit.js +14 -0
- package/node_modules/thread-stream/test/get-context.js +22 -0
- package/node_modules/thread-stream/test/helper.d.ts +1 -0
- package/node_modules/thread-stream/test/helper.js +26 -0
- package/node_modules/thread-stream/test/indexes.test.js +11 -0
- package/node_modules/thread-stream/test/multibyte-chars.test.mjs +75 -0
- package/node_modules/thread-stream/test/on-message.js +18 -0
- package/node_modules/thread-stream/test/pkg/index.js +37 -0
- package/node_modules/thread-stream/test/pkg/pkg.config.json +14 -0
- package/node_modules/thread-stream/test/pkg/pkg.test.js +45 -0
- package/node_modules/thread-stream/test/port.js +16 -0
- package/node_modules/thread-stream/test/post-message.test.js +23 -0
- package/node_modules/thread-stream/test/string-limit-2.test.js +35 -0
- package/node_modules/thread-stream/test/string-limit.test.js +37 -0
- package/node_modules/thread-stream/test/syntax-error.mjs +2 -0
- package/node_modules/thread-stream/test/thread-management.test.js +138 -0
- package/node_modules/thread-stream/test/to-file-on-destroy.js +23 -0
- package/node_modules/thread-stream/test/to-file-on-final.js +24 -0
- package/node_modules/thread-stream/test/to-file.js +12 -0
- package/node_modules/thread-stream/test/to-file.mjs +8 -0
- package/node_modules/thread-stream/test/to-next.js +9 -0
- package/node_modules/thread-stream/test/transpiled.test.js +29 -0
- package/node_modules/thread-stream/test/ts/to-file.ts +10 -0
- package/node_modules/thread-stream/test/ts/transpile.sh +19 -0
- package/node_modules/thread-stream/test/ts-commonjs-default-export.zip +0 -0
- package/node_modules/thread-stream/test/ts-native.test.mjs +35 -0
- package/node_modules/thread-stream/test/ts-node-fallback.test.js +35 -0
- package/node_modules/thread-stream/test/uncaughtException.js +21 -0
- package/node_modules/thread-stream/test/unhandledRejection.js +21 -0
- package/node_modules/thread-stream/test/yarnrc.yml +7 -0
- package/node_modules/thread-stream/tsconfig.json +8 -0
- package/oclif.manifest.json +6 -7
- package/package.json +11 -3
- package/node_modules/@contrail/loader/lib/index.js.map +0 -1
|
@@ -0,0 +1,1214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("./types");
|
|
4
|
+
const types_2 = require("@contrail/types");
|
|
5
|
+
const validate_1 = require("./validate");
|
|
6
|
+
const types_3 = require("./types");
|
|
7
|
+
describe('validate', () => {
|
|
8
|
+
const makeAnalysis = (typePropertyMaps, typesByPath) => ({
|
|
9
|
+
columns: [],
|
|
10
|
+
unmappedTypeProperties: [],
|
|
11
|
+
typePropertyMaps: {
|
|
12
|
+
typePropertiesBySlug: {},
|
|
13
|
+
typePropertiesByLabel: {},
|
|
14
|
+
optionSetUsingTypePropertiesBySlug: {},
|
|
15
|
+
...typePropertyMaps,
|
|
16
|
+
},
|
|
17
|
+
typesByPath: typesByPath ?? {},
|
|
18
|
+
});
|
|
19
|
+
const baseConfig = {
|
|
20
|
+
loadType: [types_1.LoadType.ITEM],
|
|
21
|
+
federatedMappings: { federatedId: 'federatedId', name: 'name' },
|
|
22
|
+
};
|
|
23
|
+
it('should return valid for empty rows', async () => {
|
|
24
|
+
const result = await (0, validate_1.validate)([], baseConfig, makeAnalysis());
|
|
25
|
+
expect(result.valid).toBe(true);
|
|
26
|
+
expect(result.issues).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
it('should detect missing option set values', async () => {
|
|
29
|
+
const analysis = makeAnalysis({
|
|
30
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
31
|
+
status: {
|
|
32
|
+
slug: 'status',
|
|
33
|
+
label: 'Status',
|
|
34
|
+
propertyType: 'choice',
|
|
35
|
+
typePropertyOptionSetId: 'os-1',
|
|
36
|
+
options: [{ value: 'active', display: 'Active' }],
|
|
37
|
+
optionLookupByValue: { active: { value: 'active', display: 'Active' } },
|
|
38
|
+
optionLookupByDisplay: { Active: { value: 'active', display: 'Active' } },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const rows = [
|
|
43
|
+
{ federatedId: '1', name: 'A', status: 'active' },
|
|
44
|
+
{ federatedId: '2', name: 'B', status: 'inactive' },
|
|
45
|
+
{ federatedId: '3', name: 'C', status: 'retired' },
|
|
46
|
+
];
|
|
47
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
48
|
+
expect(result.valid).toBe(false);
|
|
49
|
+
const optionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'status');
|
|
50
|
+
expect(optionIssues.length).toBeGreaterThan(0);
|
|
51
|
+
const inactiveIssue = optionIssues.find((i) => i.message.includes('inactive'));
|
|
52
|
+
expect(inactiveIssue).toBeDefined();
|
|
53
|
+
expect(inactiveIssue.suggestedFix?.type).toBe(types_3.SuggestedFixType.ADD_OPTION_SET_VALUES);
|
|
54
|
+
});
|
|
55
|
+
it('should detect multi-select missing values', async () => {
|
|
56
|
+
const analysis = makeAnalysis({
|
|
57
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
58
|
+
tags: {
|
|
59
|
+
slug: 'tags',
|
|
60
|
+
label: 'Tags',
|
|
61
|
+
propertyType: 'multi_select',
|
|
62
|
+
typePropertyOptionSetId: 'os-2',
|
|
63
|
+
options: [{ value: 'sale', display: 'Sale' }],
|
|
64
|
+
optionLookupByValue: { sale: { value: 'sale', display: 'Sale' } },
|
|
65
|
+
optionLookupByDisplay: { Sale: { value: 'sale', display: 'Sale' } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const rows = [{ federatedId: '1', name: 'A', tags: 'sale,new,clearance' }];
|
|
70
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
71
|
+
expect(result.valid).toBe(false);
|
|
72
|
+
const tagIssues = result.issues.filter((i) => i.columnName === 'tags');
|
|
73
|
+
expect(tagIssues.length).toBeGreaterThan(0);
|
|
74
|
+
});
|
|
75
|
+
it('should detect non-standard boolean values', async () => {
|
|
76
|
+
const analysis = makeAnalysis({
|
|
77
|
+
typePropertiesBySlug: {
|
|
78
|
+
isActive: { slug: 'isActive', label: 'Is Active', propertyType: 'boolean' },
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const rows = [
|
|
82
|
+
{ federatedId: '1', name: 'A', isActive: 'yes' },
|
|
83
|
+
{ federatedId: '2', name: 'B', isActive: 'maybe' },
|
|
84
|
+
];
|
|
85
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
86
|
+
const boolIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_BOOLEAN);
|
|
87
|
+
expect(boolIssues).toHaveLength(1);
|
|
88
|
+
expect(boolIssues[0].severity).toBe(types_3.PreValidationSeverity.WARNING);
|
|
89
|
+
expect(boolIssues[0].affectedRows).toHaveLength(1);
|
|
90
|
+
expect(boolIssues[0].affectedRows[0].value).toBe('maybe');
|
|
91
|
+
});
|
|
92
|
+
it('should detect semicolons in multi-select columns', async () => {
|
|
93
|
+
const analysis = makeAnalysis({
|
|
94
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
95
|
+
colors: {
|
|
96
|
+
slug: 'colors',
|
|
97
|
+
label: 'Colors',
|
|
98
|
+
propertyType: 'multi_select',
|
|
99
|
+
typePropertyOptionSetId: 'os-3',
|
|
100
|
+
options: [
|
|
101
|
+
{ value: 'red', display: 'Red' },
|
|
102
|
+
{ value: 'blue', display: 'Blue' },
|
|
103
|
+
],
|
|
104
|
+
optionLookupByValue: {
|
|
105
|
+
red: { value: 'red', display: 'Red' },
|
|
106
|
+
blue: { value: 'blue', display: 'Blue' },
|
|
107
|
+
},
|
|
108
|
+
optionLookupByDisplay: {
|
|
109
|
+
Red: { value: 'red', display: 'Red' },
|
|
110
|
+
Blue: { value: 'blue', display: 'Blue' },
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
const rows = [{ federatedId: '1', name: 'A', colors: 'red;blue' }];
|
|
116
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
117
|
+
const multiSelectIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_MULTI_SELECT);
|
|
118
|
+
expect(multiSelectIssues).toHaveLength(1);
|
|
119
|
+
expect(multiSelectIssues[0].suggestedFix?.type).toBe(types_3.SuggestedFixType.CHANGE_SEPARATOR);
|
|
120
|
+
});
|
|
121
|
+
it('should skip empty values in option set validation', async () => {
|
|
122
|
+
const analysis = makeAnalysis({
|
|
123
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
124
|
+
status: {
|
|
125
|
+
slug: 'status',
|
|
126
|
+
label: 'Status',
|
|
127
|
+
propertyType: 'choice',
|
|
128
|
+
typePropertyOptionSetId: 'os-1',
|
|
129
|
+
options: [{ value: 'active', display: 'Active' }],
|
|
130
|
+
optionLookupByValue: { active: { value: 'active', display: 'Active' } },
|
|
131
|
+
optionLookupByDisplay: { Active: { value: 'active', display: 'Active' } },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
const rows = [
|
|
136
|
+
{ federatedId: '1', name: 'A', status: '' },
|
|
137
|
+
{ federatedId: '2', name: 'B', status: null },
|
|
138
|
+
];
|
|
139
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
140
|
+
const optionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'status');
|
|
141
|
+
expect(optionIssues).toHaveLength(0);
|
|
142
|
+
});
|
|
143
|
+
describe('family property consistency', () => {
|
|
144
|
+
const itemConfig = {
|
|
145
|
+
loadType: [types_1.LoadType.ITEM],
|
|
146
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
147
|
+
};
|
|
148
|
+
const typesByPathWithFamilyProp = {
|
|
149
|
+
item: {
|
|
150
|
+
type: {
|
|
151
|
+
typeProperties: [
|
|
152
|
+
{ slug: 'globalProjectedVolume', propertyLevel: types_2.PropertyLevel.FAMILY, propertyType: 'number' },
|
|
153
|
+
{ slug: 'sport', propertyLevel: types_2.PropertyLevel.OVERRIDABLE, propertyType: 'string' },
|
|
154
|
+
{ slug: 'color', propertyLevel: types_2.PropertyLevel.OPTION, propertyType: 'string' },
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
allPropertiesSlugs: ['globalProjectedVolume', 'sport', 'color'],
|
|
158
|
+
typePropertyToValueType: {},
|
|
159
|
+
objectReferenceProperties: [],
|
|
160
|
+
userListProperties: [],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
it('should detect inconsistent family-level property values with family-specific message', async () => {
|
|
164
|
+
const rows = [
|
|
165
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', globalProjectedVolume: '200', sportFamily: 'basketball' },
|
|
166
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', globalProjectedVolume: '300', sportFamily: 'basketball' },
|
|
167
|
+
];
|
|
168
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
169
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
170
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
171
|
+
expect(consistencyIssues).toHaveLength(1);
|
|
172
|
+
expect(consistencyIssues[0].columnName).toBe('globalProjectedVolume');
|
|
173
|
+
expect(consistencyIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
174
|
+
expect(consistencyIssues[0].category).toBe(types_3.PreValidationCategory.FAMILY_PROPERTY_VALUES_INCONSISTENT);
|
|
175
|
+
expect(consistencyIssues[0].message).toContain('Family-level property');
|
|
176
|
+
expect(consistencyIssues[0].message).toContain('fam-1');
|
|
177
|
+
expect(consistencyIssues[0].message).toContain('"200"');
|
|
178
|
+
expect(consistencyIssues[0].message).toContain('"300"');
|
|
179
|
+
});
|
|
180
|
+
it('should pass when family-level property values are consistent', async () => {
|
|
181
|
+
const rows = [
|
|
182
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', globalProjectedVolume: '200' },
|
|
183
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', globalProjectedVolume: '200' },
|
|
184
|
+
];
|
|
185
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
186
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
187
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
188
|
+
expect(consistencyIssues).toHaveLength(0);
|
|
189
|
+
});
|
|
190
|
+
it('should not flag option-level properties', async () => {
|
|
191
|
+
const rows = [
|
|
192
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', color: 'red' },
|
|
193
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', color: 'blue' },
|
|
194
|
+
];
|
|
195
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
196
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
197
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
198
|
+
expect(consistencyIssues).toHaveLength(0);
|
|
199
|
+
});
|
|
200
|
+
it('should detect inconsistency in overridable Family-suffixed columns with family message', async () => {
|
|
201
|
+
const rows = [
|
|
202
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', sportFamily: 'basketball' },
|
|
203
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', sportFamily: 'soccer' },
|
|
204
|
+
];
|
|
205
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
206
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
207
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
208
|
+
expect(consistencyIssues).toHaveLength(1);
|
|
209
|
+
expect(consistencyIssues[0].columnName).toBe('sportFamily');
|
|
210
|
+
expect(consistencyIssues[0].message).toContain('Family-level property');
|
|
211
|
+
});
|
|
212
|
+
it('should suggest splitting into Family/Option columns for unsuffixed overridable properties', async () => {
|
|
213
|
+
const rows = [
|
|
214
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', sport: 'basketball' },
|
|
215
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', sport: 'soccer' },
|
|
216
|
+
];
|
|
217
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
218
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
219
|
+
const consistencyIssues = result.issues.filter((i) => i.columnName === 'sport' && i.category === types_3.PreValidationCategory.FAMILY_PROPERTY_VALUES_INCONSISTENT);
|
|
220
|
+
expect(consistencyIssues).toHaveLength(1);
|
|
221
|
+
expect(consistencyIssues[0].message).toContain('Override-level property');
|
|
222
|
+
expect(consistencyIssues[0].message).toContain('"sportFamily"');
|
|
223
|
+
expect(consistencyIssues[0].message).toContain('"sportOption"');
|
|
224
|
+
const suffixIssues = result.issues.filter((i) => i.columnName === 'sport' && i.category === types_3.PreValidationCategory.CONFIG);
|
|
225
|
+
expect(suffixIssues).toHaveLength(1);
|
|
226
|
+
});
|
|
227
|
+
it('should suggest splitting into Family/Option columns for "all" level properties', async () => {
|
|
228
|
+
const typesByPathWithAllProp = {
|
|
229
|
+
item: {
|
|
230
|
+
type: {
|
|
231
|
+
typeProperties: [
|
|
232
|
+
{ slug: 'sharedProp', propertyLevel: types_2.PropertyLevel.ALL, propertyType: 'string' },
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
allPropertiesSlugs: ['sharedProp'],
|
|
236
|
+
typePropertyToValueType: {},
|
|
237
|
+
objectReferenceProperties: [],
|
|
238
|
+
userListProperties: [],
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
const rows = [
|
|
242
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', sharedProp: 'a' },
|
|
243
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', sharedProp: 'b' },
|
|
244
|
+
];
|
|
245
|
+
const analysis = makeAnalysis({}, typesByPathWithAllProp);
|
|
246
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
247
|
+
const consistencyIssues = result.issues.filter((i) => i.columnName === 'sharedProp' && i.category === types_3.PreValidationCategory.FAMILY_PROPERTY_VALUES_INCONSISTENT);
|
|
248
|
+
expect(consistencyIssues).toHaveLength(1);
|
|
249
|
+
expect(consistencyIssues[0].message).toContain('All-level property');
|
|
250
|
+
expect(consistencyIssues[0].message).toContain('"sharedPropFamily"');
|
|
251
|
+
expect(consistencyIssues[0].message).toContain('"sharedPropOption"');
|
|
252
|
+
const suffixIssues = result.issues.filter((i) => i.columnName === 'sharedProp' && i.category === types_3.PreValidationCategory.CONFIG);
|
|
253
|
+
expect(suffixIssues).toHaveLength(1);
|
|
254
|
+
});
|
|
255
|
+
it('should skip validation for non-item load types', async () => {
|
|
256
|
+
const colorConfig = {
|
|
257
|
+
loadType: [types_1.LoadType.COLOR],
|
|
258
|
+
federatedMappings: { federatedId: 'federatedId', name: 'name' },
|
|
259
|
+
};
|
|
260
|
+
const rows = [
|
|
261
|
+
{ federatedId: 'c1', name: 'Color 1', globalProjectedVolume: '200' },
|
|
262
|
+
{ federatedId: 'c1', name: 'Color 1', globalProjectedVolume: '300' },
|
|
263
|
+
];
|
|
264
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
265
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
266
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
267
|
+
expect(consistencyIssues).toHaveLength(0);
|
|
268
|
+
});
|
|
269
|
+
it('should not flag single-row families', async () => {
|
|
270
|
+
const rows = [
|
|
271
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', globalProjectedVolume: '200' },
|
|
272
|
+
];
|
|
273
|
+
const analysis = makeAnalysis({}, typesByPathWithFamilyProp);
|
|
274
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
275
|
+
const consistencyIssues = result.issues.filter((i) => i.message.includes('inconsistent values'));
|
|
276
|
+
expect(consistencyIssues).toHaveLength(0);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
it('should detect empty option set for choice property', async () => {
|
|
280
|
+
const analysis = makeAnalysis({
|
|
281
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
282
|
+
status: {
|
|
283
|
+
slug: 'status',
|
|
284
|
+
label: 'Status',
|
|
285
|
+
propertyType: 'choice',
|
|
286
|
+
typePropertyOptionSetId: 'some-id',
|
|
287
|
+
options: [],
|
|
288
|
+
optionLookupByValue: {},
|
|
289
|
+
optionLookupByDisplay: {},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
const rows = [
|
|
294
|
+
{ federatedId: '1', name: 'A', status: 'active' },
|
|
295
|
+
{ federatedId: '2', name: 'B', status: 'inactive' },
|
|
296
|
+
];
|
|
297
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
298
|
+
const optionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'status');
|
|
299
|
+
expect(optionIssues).toHaveLength(1);
|
|
300
|
+
expect(optionIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
301
|
+
expect(optionIssues[0].message).toContain('is empty');
|
|
302
|
+
expect(optionIssues[0].affectedRows).toHaveLength(2);
|
|
303
|
+
expect(optionIssues[0].affectedRows).toEqual(expect.arrayContaining([
|
|
304
|
+
{ row: 2, value: 'active' },
|
|
305
|
+
{ row: 3, value: 'inactive' },
|
|
306
|
+
]));
|
|
307
|
+
});
|
|
308
|
+
it('should detect empty option set for multi_select property', async () => {
|
|
309
|
+
const analysis = makeAnalysis({
|
|
310
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
311
|
+
tags: {
|
|
312
|
+
slug: 'tags',
|
|
313
|
+
label: 'Tags',
|
|
314
|
+
propertyType: 'multi_select',
|
|
315
|
+
typePropertyOptionSetId: 'some-id',
|
|
316
|
+
options: undefined,
|
|
317
|
+
optionLookupByValue: {},
|
|
318
|
+
optionLookupByDisplay: {},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
const rows = [{ federatedId: '1', name: 'A', tags: 'sale,new' }];
|
|
323
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
324
|
+
const tagIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'tags');
|
|
325
|
+
expect(tagIssues).toHaveLength(1);
|
|
326
|
+
expect(tagIssues[0].message).toContain('is empty');
|
|
327
|
+
expect(tagIssues[0].affectedRows).toHaveLength(1);
|
|
328
|
+
expect(tagIssues[0].affectedRows[0]).toEqual({ row: 2, value: 'sale,new' });
|
|
329
|
+
});
|
|
330
|
+
it('should detect option set not attached to property', async () => {
|
|
331
|
+
const analysis = makeAnalysis({
|
|
332
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
333
|
+
category: {
|
|
334
|
+
slug: 'category',
|
|
335
|
+
label: 'Category',
|
|
336
|
+
propertyType: 'choice',
|
|
337
|
+
typePropertyOptionSetId: null,
|
|
338
|
+
options: [],
|
|
339
|
+
optionLookupByValue: {},
|
|
340
|
+
optionLookupByDisplay: {},
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
const rows = [{ federatedId: '1', name: 'A', category: 'shoes' }];
|
|
345
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
346
|
+
const categoryIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'category');
|
|
347
|
+
expect(categoryIssues).toHaveLength(1);
|
|
348
|
+
expect(categoryIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
349
|
+
expect(categoryIssues[0].message).toContain('no option set attached');
|
|
350
|
+
expect(categoryIssues[0].affectedRows).toHaveLength(1);
|
|
351
|
+
expect(categoryIssues[0].affectedRows[0]).toEqual({ row: 2, value: 'shoes' });
|
|
352
|
+
});
|
|
353
|
+
it('should not produce per-row errors when option set is empty', async () => {
|
|
354
|
+
const analysis = makeAnalysis({
|
|
355
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
356
|
+
status: {
|
|
357
|
+
slug: 'status',
|
|
358
|
+
label: 'Status',
|
|
359
|
+
propertyType: 'choice',
|
|
360
|
+
typePropertyOptionSetId: 'some-id',
|
|
361
|
+
options: [],
|
|
362
|
+
optionLookupByValue: {},
|
|
363
|
+
optionLookupByDisplay: {},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
const rows = [
|
|
368
|
+
{ federatedId: '1', name: 'A', status: 'active' },
|
|
369
|
+
{ federatedId: '2', name: 'B', status: 'inactive' },
|
|
370
|
+
{ federatedId: '3', name: 'C', status: 'retired' },
|
|
371
|
+
];
|
|
372
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
373
|
+
const optionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.OPTION_SET && i.columnName === 'status');
|
|
374
|
+
expect(optionIssues).toHaveLength(1);
|
|
375
|
+
expect(optionIssues[0].message).not.toContain('Value "');
|
|
376
|
+
expect(optionIssues[0].affectedRows).toHaveLength(3);
|
|
377
|
+
expect(optionIssues[0].affectedRows).toEqual(expect.arrayContaining([
|
|
378
|
+
{ row: 2, value: 'active' },
|
|
379
|
+
{ row: 3, value: 'inactive' },
|
|
380
|
+
{ row: 4, value: 'retired' },
|
|
381
|
+
]));
|
|
382
|
+
});
|
|
383
|
+
it('should include summary with correct counts', async () => {
|
|
384
|
+
const analysis = makeAnalysis({
|
|
385
|
+
typePropertiesBySlug: {
|
|
386
|
+
isActive: { slug: 'isActive', label: 'Is Active', propertyType: 'boolean' },
|
|
387
|
+
},
|
|
388
|
+
optionSetUsingTypePropertiesBySlug: {
|
|
389
|
+
status: {
|
|
390
|
+
slug: 'status',
|
|
391
|
+
propertyType: 'choice',
|
|
392
|
+
typePropertyOptionSetId: 'os-4',
|
|
393
|
+
options: [{ value: 'ok', display: 'OK' }],
|
|
394
|
+
optionLookupByValue: { ok: { value: 'ok', display: 'OK' } },
|
|
395
|
+
optionLookupByDisplay: { OK: { value: 'ok', display: 'OK' } },
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
const rows = [{ federatedId: '1', name: 'A', status: 'bad', isActive: 'maybe' }];
|
|
400
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
401
|
+
expect(result.summary.errorCount).toBeGreaterThanOrEqual(1);
|
|
402
|
+
expect(result.summary.warningCount).toBeGreaterThanOrEqual(1);
|
|
403
|
+
expect(result.valid).toBe(false);
|
|
404
|
+
});
|
|
405
|
+
describe('number precision validation', () => {
|
|
406
|
+
const makePrecisionAnalysis = (properties) => makeAnalysis({ typePropertiesBySlug: properties });
|
|
407
|
+
it('should warn when value exceeds configured precision', async () => {
|
|
408
|
+
const analysis = makePrecisionAnalysis({
|
|
409
|
+
wholesale: {
|
|
410
|
+
slug: 'wholesale',
|
|
411
|
+
label: 'Wholesale',
|
|
412
|
+
propertyType: 'currency',
|
|
413
|
+
numberFormat: { format: 'currency', precision: 2 },
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
const rows = [
|
|
417
|
+
{ federatedId: '1', name: 'A', wholesale: 1.333 },
|
|
418
|
+
{ federatedId: '2', name: 'B', wholesale: 2.5 },
|
|
419
|
+
];
|
|
420
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
421
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
422
|
+
expect(precisionIssues).toHaveLength(1);
|
|
423
|
+
expect(precisionIssues[0].severity).toBe(types_3.PreValidationSeverity.WARNING);
|
|
424
|
+
expect(precisionIssues[0].affectedRows).toHaveLength(1);
|
|
425
|
+
expect(precisionIssues[0].affectedRows[0].value).toBe('1.333');
|
|
426
|
+
expect(precisionIssues[0].message).toContain('2 decimal places');
|
|
427
|
+
});
|
|
428
|
+
it('should not warn when value is within configured precision', async () => {
|
|
429
|
+
const analysis = makePrecisionAnalysis({
|
|
430
|
+
wholesale: {
|
|
431
|
+
slug: 'wholesale',
|
|
432
|
+
label: 'Wholesale',
|
|
433
|
+
propertyType: 'currency',
|
|
434
|
+
numberFormat: { format: 'currency', precision: 2 },
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
const rows = [
|
|
438
|
+
{ federatedId: '1', name: 'A', wholesale: 1.33 },
|
|
439
|
+
{ federatedId: '2', name: 'B', wholesale: 2.5 },
|
|
440
|
+
];
|
|
441
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
442
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
443
|
+
expect(precisionIssues).toHaveLength(0);
|
|
444
|
+
});
|
|
445
|
+
it('should not warn when no precision is configured', async () => {
|
|
446
|
+
const analysis = makePrecisionAnalysis({
|
|
447
|
+
wholesale: {
|
|
448
|
+
slug: 'wholesale',
|
|
449
|
+
label: 'Wholesale',
|
|
450
|
+
propertyType: 'number',
|
|
451
|
+
},
|
|
452
|
+
});
|
|
453
|
+
const rows = [{ federatedId: '1', name: 'A', wholesale: 1.33333 }];
|
|
454
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
455
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
456
|
+
expect(precisionIssues).toHaveLength(0);
|
|
457
|
+
});
|
|
458
|
+
it('should not warn for integer values', async () => {
|
|
459
|
+
const analysis = makePrecisionAnalysis({
|
|
460
|
+
wholesale: {
|
|
461
|
+
slug: 'wholesale',
|
|
462
|
+
label: 'Wholesale',
|
|
463
|
+
propertyType: 'currency',
|
|
464
|
+
numberFormat: { format: 'currency', precision: 2 },
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
const rows = [{ federatedId: '1', name: 'A', wholesale: 100 }];
|
|
468
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
469
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
470
|
+
expect(precisionIssues).toHaveLength(0);
|
|
471
|
+
});
|
|
472
|
+
it('should produce separate issues for multiple columns', async () => {
|
|
473
|
+
const analysis = makePrecisionAnalysis({
|
|
474
|
+
wholesale: {
|
|
475
|
+
slug: 'wholesale',
|
|
476
|
+
label: 'Wholesale',
|
|
477
|
+
propertyType: 'currency',
|
|
478
|
+
numberFormat: { format: 'currency', precision: 2 },
|
|
479
|
+
},
|
|
480
|
+
margin: {
|
|
481
|
+
slug: 'margin',
|
|
482
|
+
label: 'Margin',
|
|
483
|
+
propertyType: 'percent',
|
|
484
|
+
numberFormat: { format: 'percent', precision: 1 },
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
const rows = [{ federatedId: '1', name: 'A', wholesale: 1.333, margin: 0.555 }];
|
|
488
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
489
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
490
|
+
expect(precisionIssues).toHaveLength(2);
|
|
491
|
+
const columns = precisionIssues.map((i) => i.columnName).sort();
|
|
492
|
+
expect(columns).toEqual(['margin', 'wholesale']);
|
|
493
|
+
});
|
|
494
|
+
it('should skip non-numeric property types', async () => {
|
|
495
|
+
const analysis = makePrecisionAnalysis({
|
|
496
|
+
description: {
|
|
497
|
+
slug: 'description',
|
|
498
|
+
label: 'Description',
|
|
499
|
+
propertyType: 'string',
|
|
500
|
+
numberFormat: { format: 'decimal', precision: 2 },
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
const rows = [{ federatedId: '1', name: 'A', description: 1.333 }];
|
|
504
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, analysis);
|
|
505
|
+
const precisionIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.FORMAT_NUMBER_PRECISION);
|
|
506
|
+
expect(precisionIssues).toHaveLength(0);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
describe('validateStaticIdentifierConflicts', () => {
|
|
510
|
+
it('should error when assortmentId is set in config AND in conditionalColumns', async () => {
|
|
511
|
+
const config = {
|
|
512
|
+
loadType: [types_1.LoadType.ASSORTMENT],
|
|
513
|
+
assortmentId: 'assort-1',
|
|
514
|
+
conditionalColumns: [{ toProperty: 'assortmentId', default: 'assort-2' }],
|
|
515
|
+
};
|
|
516
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'assort-1' }];
|
|
517
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
518
|
+
const conflict = result.issues.find((i) => i.message.includes('static config value and also as a conditionalColumns target'));
|
|
519
|
+
expect(conflict).toBeDefined();
|
|
520
|
+
expect(conflict.columnName).toBe('assortmentId');
|
|
521
|
+
});
|
|
522
|
+
it('should not error when static value set but no matching conditionalColumn', async () => {
|
|
523
|
+
const config = {
|
|
524
|
+
loadType: [types_1.LoadType.ASSORTMENT],
|
|
525
|
+
assortmentId: 'assort-1',
|
|
526
|
+
conditionalColumns: [{ toProperty: 'someOtherField', default: 'val' }],
|
|
527
|
+
};
|
|
528
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'assort-1' }];
|
|
529
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
530
|
+
const conflict = result.issues.find((i) => i.message.includes('static config value'));
|
|
531
|
+
expect(conflict).toBeUndefined();
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
describe('validateAssortmentColumns', () => {
|
|
535
|
+
it('should skip for non-ASSORTMENT loads', async () => {
|
|
536
|
+
const config = { loadType: [types_1.LoadType.ITEM] };
|
|
537
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A' }];
|
|
538
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
539
|
+
const assortmentIssue = result.issues.find((i) => i.columnName?.includes('assortmentId'));
|
|
540
|
+
expect(assortmentIssue).toBeUndefined();
|
|
541
|
+
});
|
|
542
|
+
it('should error when no rows have assortmentId or assortmentIdentifier', async () => {
|
|
543
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT] };
|
|
544
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A' }];
|
|
545
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
546
|
+
const issue = result.issues.find((i) => i.message.includes('ASSORTMENT loads require'));
|
|
547
|
+
expect(issue).toBeDefined();
|
|
548
|
+
expect(result.valid).toBe(false);
|
|
549
|
+
});
|
|
550
|
+
it('should error when rows have both assortmentId and assortmentIdentifier', async () => {
|
|
551
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT] };
|
|
552
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'id-1', assortmentIdentifier: 'ident-1' }];
|
|
553
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
554
|
+
const issue = result.issues.find((i) => i.message.includes('both "assortmentId" and "assortmentIdentifier"'));
|
|
555
|
+
expect(issue).toBeDefined();
|
|
556
|
+
});
|
|
557
|
+
it('should error when assortmentId values are empty', async () => {
|
|
558
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT] };
|
|
559
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: '' }];
|
|
560
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
561
|
+
const issue = result.issues.find((i) => i.message.includes('"assortmentId" cannot be empty'));
|
|
562
|
+
expect(issue).toBeDefined();
|
|
563
|
+
});
|
|
564
|
+
it('should not error when rows have valid assortmentId', async () => {
|
|
565
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT] };
|
|
566
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'assort-1' }];
|
|
567
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
568
|
+
const columnIssue = result.issues.find((i) => i.message.includes('ASSORTMENT loads require'));
|
|
569
|
+
expect(columnIssue).toBeUndefined();
|
|
570
|
+
});
|
|
571
|
+
it('should not error on rows missing assortmentId when derived from conditional columns with conditions', async () => {
|
|
572
|
+
const config = {
|
|
573
|
+
loadType: [types_1.LoadType.ASSORTMENT],
|
|
574
|
+
conditionalColumns: [
|
|
575
|
+
{ toProperty: 'assortmentId', conditions: [{ conditional: "{gender} === 'mens'", value: 'assort-1' }] },
|
|
576
|
+
],
|
|
577
|
+
};
|
|
578
|
+
const rows = [
|
|
579
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'assort-1' },
|
|
580
|
+
{ itemFamilyFederatedId: 'fam-2', name: 'B' },
|
|
581
|
+
];
|
|
582
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
583
|
+
const emptyIssue = result.issues.find((i) => i.message.includes('"assortmentId" cannot be empty'));
|
|
584
|
+
expect(emptyIssue).toBeUndefined();
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
describe('validatePartialAssortmentConfig', () => {
|
|
588
|
+
it('should skip for non-ASSORTMENT loads', async () => {
|
|
589
|
+
const config = { loadType: [types_1.LoadType.ITEM], partialAssortmentUpdate: true };
|
|
590
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A' }];
|
|
591
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
592
|
+
const issue = result.issues.find((i) => i.message.includes('partialAssortmentUpdate'));
|
|
593
|
+
expect(issue).toBeUndefined();
|
|
594
|
+
});
|
|
595
|
+
it('should skip when partialAssortmentUpdate is false', async () => {
|
|
596
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT], assortmentId: 'a' };
|
|
597
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'a' }];
|
|
598
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
599
|
+
const issue = result.issues.find((i) => i.message.includes('partialAssortmentUpdate'));
|
|
600
|
+
expect(issue).toBeUndefined();
|
|
601
|
+
});
|
|
602
|
+
it('should error when partialAssortmentUpdate is true but assortmentItemDropField not set', async () => {
|
|
603
|
+
const config = { loadType: [types_1.LoadType.ASSORTMENT], partialAssortmentUpdate: true, assortmentId: 'a' };
|
|
604
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'a' }];
|
|
605
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
606
|
+
const issue = result.issues.find((i) => i.message.includes('assortmentItemDropField is not set'));
|
|
607
|
+
expect(issue).toBeDefined();
|
|
608
|
+
});
|
|
609
|
+
it('should error when drop field column not present in data', async () => {
|
|
610
|
+
const config = {
|
|
611
|
+
loadType: [types_1.LoadType.ASSORTMENT],
|
|
612
|
+
partialAssortmentUpdate: true,
|
|
613
|
+
assortmentItemDropField: 'toDrop',
|
|
614
|
+
assortmentId: 'a',
|
|
615
|
+
};
|
|
616
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'a' }];
|
|
617
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
618
|
+
const issue = result.issues.find((i) => i.message.includes('drop field column'));
|
|
619
|
+
expect(issue).toBeDefined();
|
|
620
|
+
});
|
|
621
|
+
it('should not error when drop field is set and present in data', async () => {
|
|
622
|
+
const config = {
|
|
623
|
+
loadType: [types_1.LoadType.ASSORTMENT],
|
|
624
|
+
partialAssortmentUpdate: true,
|
|
625
|
+
assortmentItemDropField: 'toDrop',
|
|
626
|
+
assortmentId: 'a',
|
|
627
|
+
};
|
|
628
|
+
const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A', assortmentId: 'a', toDrop: '' }];
|
|
629
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis());
|
|
630
|
+
const issue = result.issues.find((i) => i.message.includes('drop field'));
|
|
631
|
+
expect(issue).toBeUndefined();
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
describe('typePath existence validation', () => {
|
|
635
|
+
it('should error when typesByPath contains entries with errors (non-existent type)', async () => {
|
|
636
|
+
const config = {
|
|
637
|
+
loadType: [types_1.LoadType.ITEM],
|
|
638
|
+
conditionalColumns: [{ default: 'item:product:test', toProperty: 'typePath' }],
|
|
639
|
+
federatedMappings: { itemFamilyFederatedId: 'family_federated_id', name: 'family_name' },
|
|
640
|
+
};
|
|
641
|
+
const rows = [
|
|
642
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'A', typePath: 'item:product:test' },
|
|
643
|
+
{ itemFamilyFederatedId: 'fam-2', name: 'B', typePath: 'item:product:test' },
|
|
644
|
+
];
|
|
645
|
+
const typesByPath = {
|
|
646
|
+
'item:product:test': {
|
|
647
|
+
type: null,
|
|
648
|
+
allPropertiesSlugs: [],
|
|
649
|
+
typePropertyToValueType: {},
|
|
650
|
+
objectReferenceProperties: [],
|
|
651
|
+
userListProperties: [],
|
|
652
|
+
error: { message: 'Invalid Type: item:product:test', issueType: 'INVALID_DATA' },
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis({}, typesByPath));
|
|
656
|
+
expect(result.valid).toBe(false);
|
|
657
|
+
const typeIssue = result.issues.find((i) => i.severity === types_3.PreValidationSeverity.ERROR && i.message.includes('item:product:test'));
|
|
658
|
+
expect(typeIssue).toBeDefined();
|
|
659
|
+
});
|
|
660
|
+
it('should not error when typesByPath entries have no errors', async () => {
|
|
661
|
+
const config = {
|
|
662
|
+
loadType: [types_1.LoadType.ITEM],
|
|
663
|
+
conditionalColumns: [{ default: 'item:product', toProperty: 'typePath' }],
|
|
664
|
+
federatedMappings: { itemFamilyFederatedId: 'family_federated_id', name: 'family_name' },
|
|
665
|
+
};
|
|
666
|
+
const rows = [
|
|
667
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'A', typePath: 'item:product' },
|
|
668
|
+
];
|
|
669
|
+
const typesByPath = {
|
|
670
|
+
'item:product': {
|
|
671
|
+
type: { typeProperties: [] },
|
|
672
|
+
allPropertiesSlugs: [],
|
|
673
|
+
typePropertyToValueType: {},
|
|
674
|
+
objectReferenceProperties: [],
|
|
675
|
+
userListProperties: [],
|
|
676
|
+
},
|
|
677
|
+
};
|
|
678
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis({}, typesByPath));
|
|
679
|
+
const typeIssue = result.issues.find((i) => i.severity === types_3.PreValidationSeverity.ERROR && i.message.includes('item:product'));
|
|
680
|
+
expect(typeIssue).toBeUndefined();
|
|
681
|
+
});
|
|
682
|
+
it('should error for each invalid typePath when multiple types have errors', async () => {
|
|
683
|
+
const config = {
|
|
684
|
+
loadType: [types_1.LoadType.ITEM],
|
|
685
|
+
federatedMappings: { itemFamilyFederatedId: 'family_federated_id', name: 'family_name' },
|
|
686
|
+
};
|
|
687
|
+
const rows = [
|
|
688
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'A', typePath: 'item:foo' },
|
|
689
|
+
{ itemFamilyFederatedId: 'fam-2', name: 'B', typePath: 'item:bar' },
|
|
690
|
+
];
|
|
691
|
+
const typesByPath = {
|
|
692
|
+
'item:foo': {
|
|
693
|
+
type: null,
|
|
694
|
+
allPropertiesSlugs: [],
|
|
695
|
+
typePropertyToValueType: {},
|
|
696
|
+
objectReferenceProperties: [],
|
|
697
|
+
userListProperties: [],
|
|
698
|
+
error: { message: 'Invalid Type: item:foo', issueType: 'INVALID_DATA' },
|
|
699
|
+
},
|
|
700
|
+
'item:bar': {
|
|
701
|
+
type: null,
|
|
702
|
+
allPropertiesSlugs: [],
|
|
703
|
+
typePropertyToValueType: {},
|
|
704
|
+
objectReferenceProperties: [],
|
|
705
|
+
userListProperties: [],
|
|
706
|
+
error: { message: 'Invalid Type: item:bar', issueType: 'INVALID_DATA' },
|
|
707
|
+
},
|
|
708
|
+
};
|
|
709
|
+
const result = await (0, validate_1.validate)(rows, config, makeAnalysis({}, typesByPath));
|
|
710
|
+
expect(result.valid).toBe(false);
|
|
711
|
+
const fooIssue = result.issues.find((i) => i.message.includes('item:foo'));
|
|
712
|
+
const barIssue = result.issues.find((i) => i.message.includes('item:bar'));
|
|
713
|
+
expect(fooIssue).toBeDefined();
|
|
714
|
+
expect(barIssue).toBeDefined();
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
describe('ALL/OVERRIDABLE suffix validation', () => {
|
|
718
|
+
const makeTypesByPathWithLevels = () => ({
|
|
719
|
+
'item:item': {
|
|
720
|
+
type: {
|
|
721
|
+
typeProperties: [
|
|
722
|
+
{ slug: 'allProp', propertyLevel: types_2.PropertyLevel.ALL, propertyType: 'string' },
|
|
723
|
+
{ slug: 'overrideProp', propertyLevel: types_2.PropertyLevel.OVERRIDABLE, propertyType: 'string' },
|
|
724
|
+
{ slug: 'familyProp', propertyLevel: types_2.PropertyLevel.FAMILY, propertyType: 'string' },
|
|
725
|
+
{ slug: 'optionProp', propertyLevel: types_2.PropertyLevel.OPTION, propertyType: 'string' },
|
|
726
|
+
],
|
|
727
|
+
},
|
|
728
|
+
allPropertiesSlugs: ['allProp', 'overrideProp', 'familyProp', 'optionProp'],
|
|
729
|
+
typePropertyToValueType: {},
|
|
730
|
+
objectReferenceProperties: [],
|
|
731
|
+
userListProperties: [],
|
|
732
|
+
},
|
|
733
|
+
});
|
|
734
|
+
it('should reject unsuffixed ALL property column', async () => {
|
|
735
|
+
const rows = [
|
|
736
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', allProp: 'value1' },
|
|
737
|
+
];
|
|
738
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
739
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
740
|
+
expect(result.valid).toBe(false);
|
|
741
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'allProp');
|
|
742
|
+
expect(suffixIssues).toHaveLength(1);
|
|
743
|
+
expect(suffixIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
744
|
+
expect(suffixIssues[0].message).toContain('"allPropFamily"');
|
|
745
|
+
expect(suffixIssues[0].message).toContain('"allPropOption"');
|
|
746
|
+
});
|
|
747
|
+
it('should reject unsuffixed OVERRIDABLE property column', async () => {
|
|
748
|
+
const rows = [
|
|
749
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', overrideProp: 'value1' },
|
|
750
|
+
];
|
|
751
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
752
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
753
|
+
expect(result.valid).toBe(false);
|
|
754
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'overrideProp');
|
|
755
|
+
expect(suffixIssues).toHaveLength(1);
|
|
756
|
+
expect(suffixIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
757
|
+
expect(suffixIssues[0].message).toContain('"overridePropFamily"');
|
|
758
|
+
expect(suffixIssues[0].message).toContain('"overridePropOption"');
|
|
759
|
+
});
|
|
760
|
+
it('should allow suffixed Family/Option columns for ALL properties', async () => {
|
|
761
|
+
const rows = [
|
|
762
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', allPropFamily: 'famVal', allPropOption: 'optVal' },
|
|
763
|
+
];
|
|
764
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
765
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
766
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && (i.columnName === 'allProp' || i.columnName === 'allPropFamily' || i.columnName === 'allPropOption'));
|
|
767
|
+
expect(suffixIssues).toHaveLength(0);
|
|
768
|
+
});
|
|
769
|
+
it('should allow suffixed Family/Option columns for OVERRIDABLE properties', async () => {
|
|
770
|
+
const rows = [
|
|
771
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', overridePropFamily: 'famVal', overridePropOption: 'optVal' },
|
|
772
|
+
];
|
|
773
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
774
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
775
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && (i.columnName === 'overrideProp' || i.columnName === 'overridePropFamily' || i.columnName === 'overridePropOption'));
|
|
776
|
+
expect(suffixIssues).toHaveLength(0);
|
|
777
|
+
});
|
|
778
|
+
it('should allow only Family suffix without Option', async () => {
|
|
779
|
+
const rows = [
|
|
780
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', allPropFamily: 'famVal' },
|
|
781
|
+
];
|
|
782
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
783
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
784
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'allProp');
|
|
785
|
+
expect(suffixIssues).toHaveLength(0);
|
|
786
|
+
});
|
|
787
|
+
it('should not flag FAMILY-level properties', async () => {
|
|
788
|
+
const rows = [
|
|
789
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', familyProp: 'value1' },
|
|
790
|
+
];
|
|
791
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
792
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
793
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'familyProp');
|
|
794
|
+
expect(suffixIssues).toHaveLength(0);
|
|
795
|
+
});
|
|
796
|
+
it('should not flag OPTION-level properties', async () => {
|
|
797
|
+
const rows = [
|
|
798
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', optionProp: 'value1' },
|
|
799
|
+
];
|
|
800
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
801
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
802
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'optionProp');
|
|
803
|
+
expect(suffixIssues).toHaveLength(0);
|
|
804
|
+
});
|
|
805
|
+
it('should not run for non-item loads', async () => {
|
|
806
|
+
const colorConfig = {
|
|
807
|
+
loadType: [types_1.LoadType.COLOR],
|
|
808
|
+
federatedMappings: { federatedId: 'federatedId', name: 'name' },
|
|
809
|
+
};
|
|
810
|
+
const rows = [
|
|
811
|
+
{ federatedId: 'color-1', name: 'Red', allProp: 'value1' },
|
|
812
|
+
];
|
|
813
|
+
const typesByPath = {
|
|
814
|
+
'color': {
|
|
815
|
+
type: {
|
|
816
|
+
typeProperties: [
|
|
817
|
+
{ slug: 'allProp', propertyLevel: types_2.PropertyLevel.ALL, propertyType: 'string' },
|
|
818
|
+
],
|
|
819
|
+
},
|
|
820
|
+
allPropertiesSlugs: ['allProp'],
|
|
821
|
+
typePropertyToValueType: {},
|
|
822
|
+
objectReferenceProperties: [],
|
|
823
|
+
userListProperties: [],
|
|
824
|
+
},
|
|
825
|
+
};
|
|
826
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, makeAnalysis({}, typesByPath));
|
|
827
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'allProp');
|
|
828
|
+
expect(suffixIssues).toHaveLength(0);
|
|
829
|
+
});
|
|
830
|
+
it('should include affected rows with values', async () => {
|
|
831
|
+
const rows = [
|
|
832
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', allProp: 'val1' },
|
|
833
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', allProp: 'val2' },
|
|
834
|
+
];
|
|
835
|
+
const typesByPath = makeTypesByPathWithLevels();
|
|
836
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
837
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'allProp');
|
|
838
|
+
expect(suffixIssues).toHaveLength(1);
|
|
839
|
+
expect(suffixIssues[0].affectedRows).toHaveLength(2);
|
|
840
|
+
expect(suffixIssues[0].affectedRows[0]).toEqual({ row: 2, value: 'val1' });
|
|
841
|
+
expect(suffixIssues[0].affectedRows[1]).toEqual({ row: 3, value: 'val2' });
|
|
842
|
+
});
|
|
843
|
+
it('should reject columns matching by property label (not slug)', async () => {
|
|
844
|
+
const typesByPath = {
|
|
845
|
+
'item:item': {
|
|
846
|
+
type: {
|
|
847
|
+
typeProperties: [
|
|
848
|
+
{ slug: 'allProp', label: 'All Property', propertyLevel: types_2.PropertyLevel.ALL, propertyType: 'string' },
|
|
849
|
+
],
|
|
850
|
+
},
|
|
851
|
+
allPropertiesSlugs: ['allProp'],
|
|
852
|
+
typePropertyToValueType: {},
|
|
853
|
+
objectReferenceProperties: [],
|
|
854
|
+
userListProperties: [],
|
|
855
|
+
},
|
|
856
|
+
};
|
|
857
|
+
const rows = [
|
|
858
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', 'All Property': 'value1' },
|
|
859
|
+
];
|
|
860
|
+
const result = await (0, validate_1.validate)(rows, baseConfig, makeAnalysis({}, typesByPath));
|
|
861
|
+
const suffixIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.CONFIG && i.columnName === 'All Property');
|
|
862
|
+
expect(suffixIssues).toHaveLength(1);
|
|
863
|
+
expect(suffixIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
864
|
+
expect(suffixIssues[0].message).toContain('"allPropFamily"');
|
|
865
|
+
expect(suffixIssues[0].message).toContain('"allPropOption"');
|
|
866
|
+
expect(suffixIssues[0].propertySlug).toBe('allProp');
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
describe('self-reference validation', () => {
|
|
870
|
+
const colorConfig = {
|
|
871
|
+
loadType: [types_1.LoadType.COLOR],
|
|
872
|
+
federatedMappings: { federatedId: 'federatedId', name: 'name' },
|
|
873
|
+
};
|
|
874
|
+
const typesByPathWithObjectRef = {
|
|
875
|
+
color: {
|
|
876
|
+
type: {
|
|
877
|
+
typeProperties: [
|
|
878
|
+
{ slug: 'relatedColor', propertyType: 'object_reference' },
|
|
879
|
+
],
|
|
880
|
+
},
|
|
881
|
+
allPropertiesSlugs: ['relatedColor'],
|
|
882
|
+
typePropertyToValueType: {},
|
|
883
|
+
objectReferenceProperties: [
|
|
884
|
+
{ slug: 'relatedColor', propertyType: 'object_reference' },
|
|
885
|
+
],
|
|
886
|
+
userListProperties: [],
|
|
887
|
+
},
|
|
888
|
+
};
|
|
889
|
+
it('should detect self-referencing object reference on color', async () => {
|
|
890
|
+
const rows = [
|
|
891
|
+
{ federatedId: 'color-1', name: 'Color 1', relatedColor: 'color-1' },
|
|
892
|
+
{ federatedId: 'color-2', name: 'Color 2', relatedColor: 'color-1' },
|
|
893
|
+
];
|
|
894
|
+
const analysis = makeAnalysis({}, typesByPathWithObjectRef);
|
|
895
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
896
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
897
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
898
|
+
expect(selfRefIssues[0].severity).toBe(types_3.PreValidationSeverity.ERROR);
|
|
899
|
+
expect(selfRefIssues[0].columnName).toBe('relatedColor');
|
|
900
|
+
expect(selfRefIssues[0].affectedRows).toHaveLength(1);
|
|
901
|
+
expect(selfRefIssues[0].affectedRows[0].row).toBe(2);
|
|
902
|
+
expect(selfRefIssues[0].affectedRows[0].value).toBe('color-1');
|
|
903
|
+
expect(result.valid).toBe(false);
|
|
904
|
+
});
|
|
905
|
+
it('should not flag non-self-referencing object references', async () => {
|
|
906
|
+
const rows = [
|
|
907
|
+
{ federatedId: 'color-1', name: 'Color 1', relatedColor: 'color-2' },
|
|
908
|
+
{ federatedId: 'color-2', name: 'Color 2', relatedColor: 'color-1' },
|
|
909
|
+
];
|
|
910
|
+
const analysis = makeAnalysis({}, typesByPathWithObjectRef);
|
|
911
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
912
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
913
|
+
expect(selfRefIssues).toHaveLength(0);
|
|
914
|
+
});
|
|
915
|
+
it('should detect family-level self-references on item-based loads', async () => {
|
|
916
|
+
const itemConfig = {
|
|
917
|
+
loadType: [types_1.LoadType.ITEM],
|
|
918
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
919
|
+
};
|
|
920
|
+
const typesByPathWithItemRef = {
|
|
921
|
+
item: {
|
|
922
|
+
type: {
|
|
923
|
+
typeProperties: [
|
|
924
|
+
{ slug: 'parentStyleName', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.FAMILY },
|
|
925
|
+
],
|
|
926
|
+
},
|
|
927
|
+
allPropertiesSlugs: ['parentStyleName'],
|
|
928
|
+
typePropertyToValueType: {},
|
|
929
|
+
objectReferenceProperties: [
|
|
930
|
+
{ slug: 'parentStyleName', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.FAMILY },
|
|
931
|
+
],
|
|
932
|
+
userListProperties: [],
|
|
933
|
+
},
|
|
934
|
+
};
|
|
935
|
+
const rows = [
|
|
936
|
+
{ itemFamilyFederatedId: 'item-1', name: 'Item 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', parentStyleName: 'item-1' },
|
|
937
|
+
{ itemFamilyFederatedId: 'item-2', name: 'Item 2', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', parentStyleName: 'item-3' },
|
|
938
|
+
];
|
|
939
|
+
const analysis = makeAnalysis({}, typesByPathWithItemRef);
|
|
940
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
941
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
942
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
943
|
+
expect(selfRefIssues[0].columnName).toBe('parentStyleName');
|
|
944
|
+
expect(selfRefIssues[0].affectedRows).toHaveLength(1);
|
|
945
|
+
expect(selfRefIssues[0].affectedRows[0].value).toBe('item-1');
|
|
946
|
+
});
|
|
947
|
+
it('should detect option-level self-references using itemOptionFederatedId', async () => {
|
|
948
|
+
const itemConfig = {
|
|
949
|
+
loadType: [types_1.LoadType.ITEM],
|
|
950
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
951
|
+
};
|
|
952
|
+
const typesByPathWithOptionRef = {
|
|
953
|
+
item: {
|
|
954
|
+
type: {
|
|
955
|
+
typeProperties: [
|
|
956
|
+
{ slug: 'relatedOption', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OPTION },
|
|
957
|
+
],
|
|
958
|
+
},
|
|
959
|
+
allPropertiesSlugs: ['relatedOption'],
|
|
960
|
+
typePropertyToValueType: {},
|
|
961
|
+
objectReferenceProperties: [
|
|
962
|
+
{ slug: 'relatedOption', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OPTION },
|
|
963
|
+
],
|
|
964
|
+
userListProperties: [],
|
|
965
|
+
},
|
|
966
|
+
};
|
|
967
|
+
const rows = [
|
|
968
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', relatedOption: 'opt-1' },
|
|
969
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', relatedOption: 'opt-1' },
|
|
970
|
+
];
|
|
971
|
+
const analysis = makeAnalysis({}, typesByPathWithOptionRef);
|
|
972
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
973
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
974
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
975
|
+
expect(selfRefIssues[0].affectedRows).toHaveLength(1);
|
|
976
|
+
expect(selfRefIssues[0].affectedRows[0].row).toBe(2);
|
|
977
|
+
});
|
|
978
|
+
it('should not flag option-level ref matching family id', async () => {
|
|
979
|
+
const itemConfig = {
|
|
980
|
+
loadType: [types_1.LoadType.ITEM],
|
|
981
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
982
|
+
};
|
|
983
|
+
const typesByPathWithOptionRef = {
|
|
984
|
+
item: {
|
|
985
|
+
type: {
|
|
986
|
+
typeProperties: [
|
|
987
|
+
{ slug: 'relatedOption', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OPTION },
|
|
988
|
+
],
|
|
989
|
+
},
|
|
990
|
+
allPropertiesSlugs: ['relatedOption'],
|
|
991
|
+
typePropertyToValueType: {},
|
|
992
|
+
objectReferenceProperties: [
|
|
993
|
+
{ slug: 'relatedOption', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OPTION },
|
|
994
|
+
],
|
|
995
|
+
userListProperties: [],
|
|
996
|
+
},
|
|
997
|
+
};
|
|
998
|
+
const rows = [
|
|
999
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', relatedOption: 'fam-1' },
|
|
1000
|
+
];
|
|
1001
|
+
const analysis = makeAnalysis({}, typesByPathWithOptionRef);
|
|
1002
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
1003
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1004
|
+
expect(selfRefIssues).toHaveLength(0);
|
|
1005
|
+
});
|
|
1006
|
+
it('should check overridable Family-suffixed column against itemFamilyFederatedId', async () => {
|
|
1007
|
+
const itemConfig = {
|
|
1008
|
+
loadType: [types_1.LoadType.ITEM],
|
|
1009
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
1010
|
+
};
|
|
1011
|
+
const typesByPathOverridable = {
|
|
1012
|
+
item: {
|
|
1013
|
+
type: {
|
|
1014
|
+
typeProperties: [
|
|
1015
|
+
{ slug: 'parentRef', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OVERRIDABLE },
|
|
1016
|
+
],
|
|
1017
|
+
},
|
|
1018
|
+
allPropertiesSlugs: ['parentRef'],
|
|
1019
|
+
typePropertyToValueType: {},
|
|
1020
|
+
objectReferenceProperties: [
|
|
1021
|
+
{ slug: 'parentRef', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OVERRIDABLE },
|
|
1022
|
+
],
|
|
1023
|
+
userListProperties: [],
|
|
1024
|
+
},
|
|
1025
|
+
};
|
|
1026
|
+
const rows = [
|
|
1027
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', parentRefFamily: 'fam-1' },
|
|
1028
|
+
];
|
|
1029
|
+
const analysis = makeAnalysis({}, typesByPathOverridable);
|
|
1030
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
1031
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1032
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
1033
|
+
expect(selfRefIssues[0].columnName).toBe('parentRefFamily');
|
|
1034
|
+
});
|
|
1035
|
+
it('should check overridable Option-suffixed column against itemOptionFederatedId', async () => {
|
|
1036
|
+
const itemConfig = {
|
|
1037
|
+
loadType: [types_1.LoadType.ITEM],
|
|
1038
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
1039
|
+
};
|
|
1040
|
+
const typesByPathOverridable = {
|
|
1041
|
+
item: {
|
|
1042
|
+
type: {
|
|
1043
|
+
typeProperties: [
|
|
1044
|
+
{ slug: 'parentRef', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OVERRIDABLE },
|
|
1045
|
+
],
|
|
1046
|
+
},
|
|
1047
|
+
allPropertiesSlugs: ['parentRef'],
|
|
1048
|
+
typePropertyToValueType: {},
|
|
1049
|
+
objectReferenceProperties: [
|
|
1050
|
+
{ slug: 'parentRef', propertyType: 'object_reference', propertyLevel: types_2.PropertyLevel.OVERRIDABLE },
|
|
1051
|
+
],
|
|
1052
|
+
userListProperties: [],
|
|
1053
|
+
},
|
|
1054
|
+
};
|
|
1055
|
+
const rows = [
|
|
1056
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', parentRefOption: 'opt-1' },
|
|
1057
|
+
];
|
|
1058
|
+
const analysis = makeAnalysis({}, typesByPathOverridable);
|
|
1059
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
1060
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1061
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
1062
|
+
expect(selfRefIssues[0].columnName).toBe('parentRefOption');
|
|
1063
|
+
});
|
|
1064
|
+
it('should treat undefined property level as family-level for items', async () => {
|
|
1065
|
+
const itemConfig = {
|
|
1066
|
+
loadType: [types_1.LoadType.ITEM],
|
|
1067
|
+
federatedMappings: { federatedId: 'itemFamilyFederatedId', name: 'name' },
|
|
1068
|
+
};
|
|
1069
|
+
const typesByPathNoLevel = {
|
|
1070
|
+
item: {
|
|
1071
|
+
type: {
|
|
1072
|
+
typeProperties: [
|
|
1073
|
+
{ slug: 'parentStyleName', propertyType: 'object_reference' },
|
|
1074
|
+
],
|
|
1075
|
+
},
|
|
1076
|
+
allPropertiesSlugs: ['parentStyleName'],
|
|
1077
|
+
typePropertyToValueType: {},
|
|
1078
|
+
objectReferenceProperties: [
|
|
1079
|
+
{ slug: 'parentStyleName', propertyType: 'object_reference' },
|
|
1080
|
+
],
|
|
1081
|
+
userListProperties: [],
|
|
1082
|
+
},
|
|
1083
|
+
};
|
|
1084
|
+
const rows = [
|
|
1085
|
+
{ itemFamilyFederatedId: 'fam-1', name: 'Fam 1', itemOptionFederatedId: 'opt-1', optionName: 'Opt 1', parentStyleName: 'fam-1' },
|
|
1086
|
+
{ itemFamilyFederatedId: 'fam-2', name: 'Fam 2', itemOptionFederatedId: 'opt-2', optionName: 'Opt 2', parentStyleName: 'opt-2' },
|
|
1087
|
+
];
|
|
1088
|
+
const analysis = makeAnalysis({}, typesByPathNoLevel);
|
|
1089
|
+
const result = await (0, validate_1.validate)(rows, itemConfig, analysis);
|
|
1090
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1091
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
1092
|
+
expect(selfRefIssues[0].affectedRows).toHaveLength(1);
|
|
1093
|
+
expect(selfRefIssues[0].affectedRows[0].value).toBe('fam-1');
|
|
1094
|
+
});
|
|
1095
|
+
it('should detect multiple self-referencing rows on the same property', async () => {
|
|
1096
|
+
const rows = [
|
|
1097
|
+
{ federatedId: 'color-1', name: 'Color 1', relatedColor: 'color-1' },
|
|
1098
|
+
{ federatedId: 'color-2', name: 'Color 2', relatedColor: 'color-2' },
|
|
1099
|
+
{ federatedId: 'color-3', name: 'Color 3', relatedColor: 'color-1' },
|
|
1100
|
+
];
|
|
1101
|
+
const analysis = makeAnalysis({}, typesByPathWithObjectRef);
|
|
1102
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
1103
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1104
|
+
expect(selfRefIssues).toHaveLength(1);
|
|
1105
|
+
expect(selfRefIssues[0].affectedRows).toHaveLength(2);
|
|
1106
|
+
expect(selfRefIssues[0].message).toContain('2 row(s)');
|
|
1107
|
+
});
|
|
1108
|
+
it('should skip empty object reference values', async () => {
|
|
1109
|
+
const rows = [
|
|
1110
|
+
{ federatedId: 'color-1', name: 'Color 1', relatedColor: '' },
|
|
1111
|
+
{ federatedId: 'color-2', name: 'Color 2', relatedColor: null },
|
|
1112
|
+
];
|
|
1113
|
+
const analysis = makeAnalysis({}, typesByPathWithObjectRef);
|
|
1114
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
1115
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1116
|
+
expect(selfRefIssues).toHaveLength(0);
|
|
1117
|
+
});
|
|
1118
|
+
it('should handle multiple object reference properties on the same type', async () => {
|
|
1119
|
+
const typesByPathMultiRef = {
|
|
1120
|
+
color: {
|
|
1121
|
+
type: {
|
|
1122
|
+
typeProperties: [
|
|
1123
|
+
{ slug: 'relatedColor', propertyType: 'object_reference' },
|
|
1124
|
+
{ slug: 'parentColor', propertyType: 'object_reference' },
|
|
1125
|
+
],
|
|
1126
|
+
},
|
|
1127
|
+
allPropertiesSlugs: ['relatedColor', 'parentColor'],
|
|
1128
|
+
typePropertyToValueType: {},
|
|
1129
|
+
objectReferenceProperties: [
|
|
1130
|
+
{ slug: 'relatedColor', propertyType: 'object_reference' },
|
|
1131
|
+
{ slug: 'parentColor', propertyType: 'object_reference' },
|
|
1132
|
+
],
|
|
1133
|
+
userListProperties: [],
|
|
1134
|
+
},
|
|
1135
|
+
};
|
|
1136
|
+
const rows = [
|
|
1137
|
+
{ federatedId: 'color-1', name: 'Color 1', relatedColor: 'color-1', parentColor: 'color-1' },
|
|
1138
|
+
];
|
|
1139
|
+
const analysis = makeAnalysis({}, typesByPathMultiRef);
|
|
1140
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
1141
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1142
|
+
expect(selfRefIssues).toHaveLength(2);
|
|
1143
|
+
const slugs = selfRefIssues.map((i) => i.columnName).sort();
|
|
1144
|
+
expect(slugs).toEqual(['parentColor', 'relatedColor']);
|
|
1145
|
+
});
|
|
1146
|
+
it('should not flag when no object reference properties exist', async () => {
|
|
1147
|
+
const typesByPathNoRef = {
|
|
1148
|
+
color: {
|
|
1149
|
+
type: {
|
|
1150
|
+
typeProperties: [
|
|
1151
|
+
{ slug: 'colorName', propertyType: 'string' },
|
|
1152
|
+
],
|
|
1153
|
+
},
|
|
1154
|
+
allPropertiesSlugs: ['colorName'],
|
|
1155
|
+
typePropertyToValueType: {},
|
|
1156
|
+
objectReferenceProperties: [],
|
|
1157
|
+
userListProperties: [],
|
|
1158
|
+
},
|
|
1159
|
+
};
|
|
1160
|
+
const rows = [
|
|
1161
|
+
{ federatedId: 'color-1', name: 'Color 1', colorName: 'color-1' },
|
|
1162
|
+
];
|
|
1163
|
+
const analysis = makeAnalysis({}, typesByPathNoRef);
|
|
1164
|
+
const result = await (0, validate_1.validate)(rows, colorConfig, analysis);
|
|
1165
|
+
const selfRefIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.SELF_REFERENCE);
|
|
1166
|
+
expect(selfRefIssues).toHaveLength(0);
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
describe('unmapped column and type property warnings', () => {
|
|
1170
|
+
it('should generate WARNING for unmapped CSV columns', async () => {
|
|
1171
|
+
const analysis = makeAnalysis();
|
|
1172
|
+
analysis.columns = [
|
|
1173
|
+
{ csvHeader: 'unknownCol', isMapped: false, isRequired: false, isArchived: false, hasOptionSet: false },
|
|
1174
|
+
];
|
|
1175
|
+
const result = await (0, validate_1.validate)([{ unknownCol: 'val' }], baseConfig, analysis);
|
|
1176
|
+
const unmappedColIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.UNMAPPED_COLUMN);
|
|
1177
|
+
expect(unmappedColIssues).toHaveLength(1);
|
|
1178
|
+
expect(unmappedColIssues[0].severity).toBe(types_3.PreValidationSeverity.WARNING);
|
|
1179
|
+
expect(unmappedColIssues[0].columnName).toBe('unknownCol');
|
|
1180
|
+
expect(unmappedColIssues[0].message).toContain('unknownCol');
|
|
1181
|
+
});
|
|
1182
|
+
it('should generate WARNING for unmapped type properties', async () => {
|
|
1183
|
+
const analysis = makeAnalysis();
|
|
1184
|
+
analysis.unmappedTypeProperties = [
|
|
1185
|
+
{ slug: 'missingProp', label: 'Missing Property', propertyType: 'string', isRequired: false, hasOptionSet: false },
|
|
1186
|
+
];
|
|
1187
|
+
const result = await (0, validate_1.validate)([{ name: 'test' }], baseConfig, analysis);
|
|
1188
|
+
const unmappedPropIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.UNMAPPED_TYPE_PROPERTY);
|
|
1189
|
+
expect(unmappedPropIssues).toHaveLength(1);
|
|
1190
|
+
expect(unmappedPropIssues[0].severity).toBe(types_3.PreValidationSeverity.WARNING);
|
|
1191
|
+
expect(unmappedPropIssues[0].propertySlug).toBe('missingProp');
|
|
1192
|
+
expect(unmappedPropIssues[0].message).toContain('Missing Property');
|
|
1193
|
+
});
|
|
1194
|
+
it('should not generate unmapped issues when all columns and properties are mapped', async () => {
|
|
1195
|
+
const analysis = makeAnalysis();
|
|
1196
|
+
analysis.columns = [
|
|
1197
|
+
{ csvHeader: 'color', isMapped: true, matchedSlug: 'color', isRequired: false, isArchived: false, hasOptionSet: false },
|
|
1198
|
+
];
|
|
1199
|
+
analysis.unmappedTypeProperties = [];
|
|
1200
|
+
const result = await (0, validate_1.validate)([{ color: 'red' }], baseConfig, analysis);
|
|
1201
|
+
const unmappedIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.UNMAPPED_COLUMN || i.category === types_3.PreValidationCategory.UNMAPPED_TYPE_PROPERTY);
|
|
1202
|
+
expect(unmappedIssues).toHaveLength(0);
|
|
1203
|
+
});
|
|
1204
|
+
it('should use label in message when available, fall back to slug', async () => {
|
|
1205
|
+
const analysis = makeAnalysis();
|
|
1206
|
+
analysis.unmappedTypeProperties = [
|
|
1207
|
+
{ slug: 'noLabel', propertyType: 'string', isRequired: false, hasOptionSet: false },
|
|
1208
|
+
];
|
|
1209
|
+
const result = await (0, validate_1.validate)([{ name: 'test' }], baseConfig, analysis);
|
|
1210
|
+
const unmappedPropIssues = result.issues.filter((i) => i.category === types_3.PreValidationCategory.UNMAPPED_TYPE_PROPERTY);
|
|
1211
|
+
expect(unmappedPropIssues[0].message).toContain('noLabel');
|
|
1212
|
+
});
|
|
1213
|
+
});
|
|
1214
|
+
});
|