@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,973 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entity_processor_v2_1 = require("./entity-processor-v2");
|
|
4
|
+
const entities_helper_1 = require("../common/entities-helper");
|
|
5
|
+
const entity_builder_helpers_1 = require("../common/entity-builder-helpers");
|
|
6
|
+
const types_1 = require("@contrail/types");
|
|
7
|
+
const entity_types_1 = require("@contrail/entity-types");
|
|
8
|
+
const processor_registry_1 = require("../processor-registry");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const util_1 = require("../common/util");
|
|
11
|
+
const color_processor_v2_1 = require("./colors-v2/color-processor-v2");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
jest.mock('../common/entity-builder-helpers');
|
|
14
|
+
jest.mock('../processor-registry');
|
|
15
|
+
jest.mock('@contrail/entity-types');
|
|
16
|
+
jest.mock('../common/entities-helper');
|
|
17
|
+
jest.mock('../common/type-helper');
|
|
18
|
+
jest.mock('lodash', () => ({
|
|
19
|
+
chunk: jest.fn(),
|
|
20
|
+
}));
|
|
21
|
+
describe('EntityProcessorV2', () => {
|
|
22
|
+
const mockTypesByPath = {
|
|
23
|
+
color: {
|
|
24
|
+
type: {
|
|
25
|
+
typeProperties: [{ slug: 'federatedId' }, { slug: 'typePath' }, { slug: 'hex' }, { slug: 'name' }],
|
|
26
|
+
},
|
|
27
|
+
allPropertiesSlugs: ['federatedId', 'typePath', 'hex', 'name'],
|
|
28
|
+
typePropertyToValueType: {
|
|
29
|
+
federatedId: types_1.PropertyType.String,
|
|
30
|
+
typePath: types_1.PropertyType.String,
|
|
31
|
+
hex: types_1.PropertyType.String,
|
|
32
|
+
name: types_1.PropertyType.String,
|
|
33
|
+
},
|
|
34
|
+
objectReferenceProperties: [],
|
|
35
|
+
userListProperties: [],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const mockData = [
|
|
39
|
+
{ federatedId: '1', typePath: 'color', hex: '#ff0000', name: 'Red' },
|
|
40
|
+
{ federatedId: '2', typePath: 'color', hex: '#00ff00', name: 'Green' },
|
|
41
|
+
];
|
|
42
|
+
const mockProcessor = {
|
|
43
|
+
processFederatedId: jest.fn().mockImplementation((entity) => entity.federatedId),
|
|
44
|
+
getTypePath: jest.fn().mockImplementation((row, entityType) => row?.typePath || entityType),
|
|
45
|
+
validateRow: jest.fn().mockImplementation((entity) => (entity.federatedId ? true : false)),
|
|
46
|
+
setExtraProperties: jest.fn(),
|
|
47
|
+
canAddProperty: jest.fn().mockReturnValue(true),
|
|
48
|
+
processEntitiesProperties: jest.fn().mockReturnValue({ projectId: null }),
|
|
49
|
+
assignExtraItems: jest.fn().mockReturnValue({
|
|
50
|
+
itemsByFamilyId: null,
|
|
51
|
+
sizeRangeWarningsAsStringList: null,
|
|
52
|
+
}),
|
|
53
|
+
getFederatedIdKeys: jest.fn().mockReturnValue(['federatedId']),
|
|
54
|
+
canExtractFederatedIds: jest.fn().mockReturnValue(true),
|
|
55
|
+
logIncommingEntities: jest.fn(),
|
|
56
|
+
getEntityTypeForFederatedId: jest.fn(),
|
|
57
|
+
};
|
|
58
|
+
let client;
|
|
59
|
+
let consoleSpy;
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
client = {
|
|
62
|
+
create: jest.fn(),
|
|
63
|
+
update: jest.fn(),
|
|
64
|
+
getAllReferences: jest.fn(),
|
|
65
|
+
get: jest.fn(),
|
|
66
|
+
delete: jest.fn(),
|
|
67
|
+
batchCreate: jest.fn(),
|
|
68
|
+
batchUpdate: jest.fn(),
|
|
69
|
+
batchDelete: jest.fn(),
|
|
70
|
+
};
|
|
71
|
+
consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
72
|
+
jest.spyOn(console, 'info').mockImplementation();
|
|
73
|
+
jest.spyOn(console, 'debug').mockImplementation();
|
|
74
|
+
jest.spyOn(console, 'error').mockImplementation();
|
|
75
|
+
});
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
consoleSpy.mockRestore();
|
|
78
|
+
jest.clearAllMocks();
|
|
79
|
+
});
|
|
80
|
+
describe('extractFederatedIds', () => {
|
|
81
|
+
const mockProcessor = {
|
|
82
|
+
processFederatedId: jest.fn().mockImplementation((federatedId, typePath) => federatedId),
|
|
83
|
+
};
|
|
84
|
+
const mockProcessorWithTypePath = {
|
|
85
|
+
processFederatedId: jest.fn().mockImplementation((federatedId, typePath) => {
|
|
86
|
+
if (!federatedId.startsWith('custom-entity:')) {
|
|
87
|
+
federatedId = typePath + ':' + federatedId;
|
|
88
|
+
}
|
|
89
|
+
return federatedId;
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
const federatedIdkeys = ['federatedId'];
|
|
93
|
+
it('should extract unique and duplicate federatedIds', () => {
|
|
94
|
+
const incomingEntities = [{ federatedId: '1/abc' }, { federatedId: '2/def' }, { federatedId: '1/abc' }];
|
|
95
|
+
const result = entity_processor_v2_1.EntityProcessorV2.extractFederatedIds(incomingEntities, mockProcessor, federatedIdkeys);
|
|
96
|
+
expect(result).toEqual(['1%2Fabc', '2%2Fdef']);
|
|
97
|
+
});
|
|
98
|
+
it('should handle entities with no duplicates', () => {
|
|
99
|
+
const incomingEntities = [{ federatedId: '1/abc' }, { federatedId: '2/def' }, { federatedId: '3/ghi' }];
|
|
100
|
+
const result = entity_processor_v2_1.EntityProcessorV2.extractFederatedIds(incomingEntities, mockProcessor, federatedIdkeys);
|
|
101
|
+
expect(result).toEqual(['1%2Fabc', '2%2Fdef', '3%2Fghi']);
|
|
102
|
+
});
|
|
103
|
+
it('should handle entities with all duplicates', () => {
|
|
104
|
+
const incomingEntities = [{ federatedId: '1/abc' }, { federatedId: '1/abc' }, { federatedId: '1/abc' }];
|
|
105
|
+
const result = entity_processor_v2_1.EntityProcessorV2.extractFederatedIds(incomingEntities, mockProcessor, federatedIdkeys);
|
|
106
|
+
expect(result).toEqual(['1%2Fabc']);
|
|
107
|
+
});
|
|
108
|
+
it('should handle an empty array', () => {
|
|
109
|
+
const incomingEntities = [];
|
|
110
|
+
const result = entity_processor_v2_1.EntityProcessorV2.extractFederatedIds(incomingEntities);
|
|
111
|
+
expect(result).toEqual([]);
|
|
112
|
+
});
|
|
113
|
+
it('should handle entities with typePath', () => {
|
|
114
|
+
const incomingEntities = [{ federatedId: '1/abc', typePath: 'customEntity:material' }];
|
|
115
|
+
const result = entity_processor_v2_1.EntityProcessorV2.extractFederatedIds(incomingEntities, mockProcessorWithTypePath, federatedIdkeys);
|
|
116
|
+
expect(result).toEqual(['customEntity:material:1%2Fabc']);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('getTypePaths', () => {
|
|
120
|
+
it('should return unique type paths', () => {
|
|
121
|
+
const data = [{ typePath: 'color' }, { typePath: 'color' }, { typePath: 'shape' }];
|
|
122
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getTypePaths(data, 'defaultType', mockProcessor);
|
|
123
|
+
expect(result).toEqual(['color', 'shape']);
|
|
124
|
+
});
|
|
125
|
+
it('should return default type if typePath is missing', () => {
|
|
126
|
+
const data = [{ typePath: 'color' }, { typePath: 'shape' }, { someProperty: 'value' }];
|
|
127
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getTypePaths(data, 'defaultType', mockProcessor);
|
|
128
|
+
expect(result).toEqual(['color', 'shape', 'defaultType']);
|
|
129
|
+
});
|
|
130
|
+
it('should handle an empty array', () => {
|
|
131
|
+
const data = [];
|
|
132
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getTypePaths(data, 'defaultType', mockProcessor);
|
|
133
|
+
expect(result).toEqual([]);
|
|
134
|
+
});
|
|
135
|
+
it('should handle an array with one element', () => {
|
|
136
|
+
const data = [{ typePath: 'color' }];
|
|
137
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getTypePaths(data, 'defaultType', mockProcessor);
|
|
138
|
+
expect(result).toEqual(['color']);
|
|
139
|
+
});
|
|
140
|
+
it('should handle an array with all elements missing typePath', () => {
|
|
141
|
+
const data = [{ someProperty: 'value1' }, { someProperty: 'value2' }, { someProperty: 'value3' }];
|
|
142
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getTypePaths(data, 'defaultType', mockProcessor);
|
|
143
|
+
expect(result).toEqual(['defaultType']);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('buildIncomingEntities', () => {
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
entity_builder_helpers_1.addProperty.mockImplementation((propertyName, allPropertiesSlugs, valueType, entity, value) => {
|
|
149
|
+
entity[propertyName] = value;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
it('should build incoming entities', () => {
|
|
153
|
+
const result = entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities(mockProcessor, mockData, mockTypesByPath, 'color');
|
|
154
|
+
const returnData = {
|
|
155
|
+
badEntities: [],
|
|
156
|
+
incomingEntities: [
|
|
157
|
+
{
|
|
158
|
+
federatedId: '1',
|
|
159
|
+
hex: '#ff0000',
|
|
160
|
+
name: 'Red',
|
|
161
|
+
typePath: 'color',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
federatedId: '2',
|
|
165
|
+
hex: '#00ff00',
|
|
166
|
+
name: 'Green',
|
|
167
|
+
typePath: 'color',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
expect(result).toEqual(returnData);
|
|
172
|
+
expect(entity_builder_helpers_1.addProperty).toHaveBeenCalledWith('federatedId', ['federatedId', 'typePath', 'hex', 'name'], types_1.PropertyType.String, { federatedId: '1', typePath: 'color', hex: '#ff0000', name: 'Red' }, '1');
|
|
173
|
+
expect(entity_builder_helpers_1.addProperty).toHaveBeenCalledWith('typePath', ['federatedId', 'typePath', 'hex', 'name'], types_1.PropertyType.String, { federatedId: '1', typePath: 'color', hex: '#ff0000', name: 'Red' }, 'color');
|
|
174
|
+
expect(entity_builder_helpers_1.addProperty).toHaveBeenCalledWith('hex', ['federatedId', 'typePath', 'hex', 'name'], types_1.PropertyType.String, { federatedId: '1', typePath: 'color', hex: '#ff0000', name: 'Red' }, '#ff0000');
|
|
175
|
+
expect(entity_builder_helpers_1.addProperty).toHaveBeenCalledWith('name', ['federatedId', 'typePath', 'hex', 'name'], types_1.PropertyType.String, { federatedId: '1', typePath: 'color', hex: '#ff0000', name: 'Red' }, 'Red');
|
|
176
|
+
});
|
|
177
|
+
it('should skip rows without federatedId', () => {
|
|
178
|
+
const data = [
|
|
179
|
+
{ typePath: 'color', hex: '#ff0000', name: 'Red' },
|
|
180
|
+
{ federatedId: '2', typePath: 'color', hex: '#00ff00', name: 'Green' },
|
|
181
|
+
];
|
|
182
|
+
const result = entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities(mockProcessor, data, mockTypesByPath, 'color');
|
|
183
|
+
const returnData = {
|
|
184
|
+
badEntities: [
|
|
185
|
+
{
|
|
186
|
+
hex: '#ff0000',
|
|
187
|
+
name: 'Red',
|
|
188
|
+
typePath: 'color',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
incomingEntities: [
|
|
192
|
+
{
|
|
193
|
+
federatedId: '2',
|
|
194
|
+
typePath: 'color',
|
|
195
|
+
hex: '#00ff00',
|
|
196
|
+
name: 'Green',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
expect(result).toEqual(returnData);
|
|
201
|
+
expect(console.error).toHaveBeenCalledWith('Invalid data found for this row color:', {
|
|
202
|
+
typePath: 'color',
|
|
203
|
+
hex: '#ff0000',
|
|
204
|
+
name: 'Red',
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('should handle an empty array', () => {
|
|
208
|
+
const data = [];
|
|
209
|
+
const result = entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities(mockProcessor, data, mockTypesByPath, 'color');
|
|
210
|
+
expect(result).toEqual({ badEntities: [], incomingEntities: [] });
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe('fetchCurrentEntities', () => {
|
|
214
|
+
it('should fetch and process entities in chunks', async () => {
|
|
215
|
+
const federatedIds = ['1', '2', '3', '4'];
|
|
216
|
+
const chunks = [
|
|
217
|
+
['1', '2'],
|
|
218
|
+
['3', '4'],
|
|
219
|
+
];
|
|
220
|
+
lodash_1.chunk.mockReturnValue(chunks);
|
|
221
|
+
const mockEntities = [
|
|
222
|
+
{ federatedId: '1', name: 'Entity 1' },
|
|
223
|
+
{ federatedId: '2', name: 'Entity 2' },
|
|
224
|
+
];
|
|
225
|
+
entities_helper_1.retryOnTimeout.mockResolvedValue(mockEntities);
|
|
226
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities(client, entity_types_1.EntityType.COLOR, federatedIds);
|
|
227
|
+
expect(result).toEqual({
|
|
228
|
+
'1': { federatedId: '1', name: 'Entity 1' },
|
|
229
|
+
'2': { federatedId: '2', name: 'Entity 2' },
|
|
230
|
+
});
|
|
231
|
+
expect(lodash_1.chunk).toHaveBeenCalledWith(federatedIds, 200);
|
|
232
|
+
expect(entities_helper_1.retryOnTimeout).toHaveBeenCalledTimes(2);
|
|
233
|
+
});
|
|
234
|
+
it('should handle empty federatedIds array', async () => {
|
|
235
|
+
const federatedIds = [];
|
|
236
|
+
lodash_1.chunk.mockReturnValue([]);
|
|
237
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities(client, entity_types_1.EntityType.COLOR, federatedIds);
|
|
238
|
+
expect(result).toEqual({});
|
|
239
|
+
expect(entities_helper_1.retryOnTimeout).not.toHaveBeenCalled();
|
|
240
|
+
});
|
|
241
|
+
it('should handle API errors and rethrow', async () => {
|
|
242
|
+
const federatedIds = ['1'];
|
|
243
|
+
const chunks = [['1']];
|
|
244
|
+
lodash_1.chunk.mockReturnValue(chunks);
|
|
245
|
+
const error = new Error('API Error');
|
|
246
|
+
entities_helper_1.retryOnTimeout.mockRejectedValue(error);
|
|
247
|
+
await expect(entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities(client, entity_types_1.EntityType.COLOR, federatedIds)).rejects.toThrow('API Error');
|
|
248
|
+
expect(console.error).toHaveBeenCalledWith('Failed to fetch color by federatedIds:', error);
|
|
249
|
+
});
|
|
250
|
+
it('should handle empty response from API', async () => {
|
|
251
|
+
const federatedIds = ['1'];
|
|
252
|
+
const chunks = [['1']];
|
|
253
|
+
lodash_1.chunk.mockReturnValue(chunks);
|
|
254
|
+
entities_helper_1.retryOnTimeout.mockResolvedValue([]);
|
|
255
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities(client, entity_types_1.EntityType.COLOR, federatedIds);
|
|
256
|
+
expect(result).toEqual({});
|
|
257
|
+
});
|
|
258
|
+
it('should process multiple chunks correctly', async () => {
|
|
259
|
+
const federatedIds = ['1', '2', '3', '4'];
|
|
260
|
+
const chunks = [
|
|
261
|
+
['1', '2'],
|
|
262
|
+
['3', '4'],
|
|
263
|
+
];
|
|
264
|
+
lodash_1.chunk.mockReturnValue(chunks);
|
|
265
|
+
const mockEntities1 = [
|
|
266
|
+
{ federatedId: '1', name: 'Entity 1' },
|
|
267
|
+
{ federatedId: '2', name: 'Entity 2' },
|
|
268
|
+
];
|
|
269
|
+
const mockEntities2 = [
|
|
270
|
+
{ federatedId: '3', name: 'Entity 3' },
|
|
271
|
+
{ federatedId: '4', name: 'Entity 4' },
|
|
272
|
+
];
|
|
273
|
+
entities_helper_1.retryOnTimeout.mockResolvedValueOnce(mockEntities1).mockResolvedValueOnce(mockEntities2);
|
|
274
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities(client, entity_types_1.EntityType.COLOR, federatedIds);
|
|
275
|
+
expect(result).toEqual({
|
|
276
|
+
'1': { federatedId: '1', name: 'Entity 1' },
|
|
277
|
+
'2': { federatedId: '2', name: 'Entity 2' },
|
|
278
|
+
'3': { federatedId: '3', name: 'Entity 3' },
|
|
279
|
+
'4': { federatedId: '4', name: 'Entity 4' },
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
describe('constructEntities', () => {
|
|
284
|
+
const loaderProcess = {
|
|
285
|
+
id: 'mock-loader-process-id',
|
|
286
|
+
loadFileId: 'mock-load-file-id',
|
|
287
|
+
loadType: [entity_types_1.LoadType.COLOR],
|
|
288
|
+
status: entity_types_1.LoadStatus.COMPLETE,
|
|
289
|
+
federatedMappings: {
|
|
290
|
+
federatedId: 'name',
|
|
291
|
+
name: 'name',
|
|
292
|
+
},
|
|
293
|
+
conditionalColumns: [
|
|
294
|
+
{
|
|
295
|
+
toProperty: 'typePath',
|
|
296
|
+
default: 'color',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
};
|
|
300
|
+
it('should handle empty data', async () => {
|
|
301
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.constructEntities({
|
|
302
|
+
client,
|
|
303
|
+
processor: mockProcessor,
|
|
304
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
305
|
+
requiredProperties: [],
|
|
306
|
+
data: [],
|
|
307
|
+
entitySpecificProperties: null,
|
|
308
|
+
itemsByFederatedId: {},
|
|
309
|
+
typesByTypePath: {},
|
|
310
|
+
});
|
|
311
|
+
expect(result).toEqual({
|
|
312
|
+
incomingEntities: [],
|
|
313
|
+
badEntities: [],
|
|
314
|
+
allCurrentEntitiesByFederatedId: {},
|
|
315
|
+
projectId: null,
|
|
316
|
+
typesByPath: [],
|
|
317
|
+
});
|
|
318
|
+
expect(console.debug).toHaveBeenCalledWith('No data to upload');
|
|
319
|
+
});
|
|
320
|
+
it('should process and load objects successfully', async () => {
|
|
321
|
+
const data = [{ federatedId: '1', typePath: 'color', hex: '#ff0000' }];
|
|
322
|
+
const typesByPath = {
|
|
323
|
+
color: {
|
|
324
|
+
type: {
|
|
325
|
+
typeProperties: [{ slug: 'federatedId' }, { slug: 'typePath' }, { slug: 'hex' }],
|
|
326
|
+
},
|
|
327
|
+
allPropertiesSlugs: ['federatedId', 'typePath', 'hex'],
|
|
328
|
+
typePropertyToValueType: { hex: types_1.PropertyType.String },
|
|
329
|
+
objectReferenceProperties: [],
|
|
330
|
+
userListProperties: [],
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
entity_processor_v2_1.EntityProcessorV2.getTypePaths = jest.fn().mockReturnValue(['color']);
|
|
334
|
+
entity_processor_v2_1.EntityProcessorV2.fetchTypesByPath = jest.fn().mockResolvedValue(typesByPath);
|
|
335
|
+
entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities = jest
|
|
336
|
+
.fn()
|
|
337
|
+
.mockReturnValue({ incomingEntities: data, badEntities: [] });
|
|
338
|
+
entity_processor_v2_1.EntityProcessorV2.extractFederatedIds = jest.fn().mockReturnValue(['1']);
|
|
339
|
+
entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities = jest.fn().mockResolvedValue({
|
|
340
|
+
'1': { federatedId: '1', hex: '#ff0000' },
|
|
341
|
+
});
|
|
342
|
+
entity_processor_v2_1.EntityProcessorV2.getEntityTypeForFederatedId = jest.fn().mockReturnValue(entity_types_1.EntityType.COLOR);
|
|
343
|
+
entities_helper_1.assignObjectReferences.mockResolvedValue(undefined);
|
|
344
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.constructEntities({
|
|
345
|
+
client,
|
|
346
|
+
processor: mockProcessor,
|
|
347
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
348
|
+
requiredProperties: ['federatedId', 'hex'],
|
|
349
|
+
data,
|
|
350
|
+
entitySpecificProperties: null,
|
|
351
|
+
itemsByFederatedId: {},
|
|
352
|
+
typesByTypePath: undefined,
|
|
353
|
+
});
|
|
354
|
+
expect(result).toEqual({
|
|
355
|
+
incomingEntities: data,
|
|
356
|
+
badEntities: [],
|
|
357
|
+
allCurrentEntitiesByFederatedId: {
|
|
358
|
+
'1': { federatedId: '1', hex: '#ff0000' },
|
|
359
|
+
},
|
|
360
|
+
typesByPath: typesByPath,
|
|
361
|
+
projectId: null,
|
|
362
|
+
generalWarnings: undefined,
|
|
363
|
+
itemsByFamilyId: null,
|
|
364
|
+
sizeRangeWarningsAsStringList: null,
|
|
365
|
+
});
|
|
366
|
+
expect(entity_processor_v2_1.EntityProcessorV2.getTypePaths).toHaveBeenCalledWith(data, entity_types_1.EntityType.COLOR, mockProcessor);
|
|
367
|
+
expect(entity_processor_v2_1.EntityProcessorV2.fetchTypesByPath).toHaveBeenCalledWith({
|
|
368
|
+
client,
|
|
369
|
+
typePaths: ['color'],
|
|
370
|
+
requiredProperties: ['federatedId', 'hex'],
|
|
371
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
372
|
+
typesByTypePath: undefined,
|
|
373
|
+
});
|
|
374
|
+
expect(entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities).toHaveBeenCalledWith(mockProcessor, data, typesByPath, entity_types_1.EntityType.COLOR);
|
|
375
|
+
expect(entities_helper_1.assignObjectReferences).toHaveBeenCalledWith(client, ['color'], typesByPath, data);
|
|
376
|
+
expect(entity_processor_v2_1.EntityProcessorV2.extractFederatedIds).toHaveBeenCalledWith(data, mockProcessor, ['federatedId']);
|
|
377
|
+
expect(entity_processor_v2_1.EntityProcessorV2.fetchCurrentEntities).toHaveBeenCalled();
|
|
378
|
+
});
|
|
379
|
+
it('should return empty result when buildIncomingEntities returns empty array', async () => {
|
|
380
|
+
const data = [{ federatedId: '1', typePath: 'color', hex: '#ff0000' }];
|
|
381
|
+
const typesByPath = {
|
|
382
|
+
color: {
|
|
383
|
+
type: {
|
|
384
|
+
typeProperties: [{ slug: 'federatedId' }, { slug: 'typePath' }, { slug: 'hex' }],
|
|
385
|
+
},
|
|
386
|
+
allPropertiesSlugs: ['federatedId', 'typePath', 'hex'],
|
|
387
|
+
typePropertyToValueType: { hex: types_1.PropertyType.String },
|
|
388
|
+
objectReferenceProperties: [],
|
|
389
|
+
userListProperties: [],
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
entity_processor_v2_1.EntityProcessorV2.getTypePaths = jest.fn().mockReturnValue(['color']);
|
|
393
|
+
entity_processor_v2_1.EntityProcessorV2.fetchTypesByPath = jest.fn().mockResolvedValue(typesByPath);
|
|
394
|
+
entity_processor_v2_1.EntityProcessorV2.buildIncomingEntities = jest
|
|
395
|
+
.fn()
|
|
396
|
+
.mockReturnValue({ badEntities: [], incomingEntities: [] });
|
|
397
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.constructEntities({
|
|
398
|
+
client,
|
|
399
|
+
processor: mockProcessor,
|
|
400
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
401
|
+
requiredProperties: ['federatedId', 'hex'],
|
|
402
|
+
data,
|
|
403
|
+
});
|
|
404
|
+
expect(result).toEqual({
|
|
405
|
+
incomingEntities: [],
|
|
406
|
+
badEntities: [],
|
|
407
|
+
allCurrentEntitiesByFederatedId: {},
|
|
408
|
+
projectId: null,
|
|
409
|
+
typesByPath: [],
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
it('should handle undefined data parameter', async () => {
|
|
413
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.constructEntities({
|
|
414
|
+
client,
|
|
415
|
+
processor: mockProcessor,
|
|
416
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
417
|
+
requiredProperties: [],
|
|
418
|
+
});
|
|
419
|
+
expect(result).toEqual({
|
|
420
|
+
incomingEntities: [],
|
|
421
|
+
badEntities: [],
|
|
422
|
+
allCurrentEntitiesByFederatedId: {},
|
|
423
|
+
projectId: null,
|
|
424
|
+
typesByPath: [],
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
describe('setupEntities', () => {
|
|
429
|
+
it('should process and load objects successfully', async () => {
|
|
430
|
+
const rawData = [{ id: 1, name: 'test' }];
|
|
431
|
+
const mockProcessor = {
|
|
432
|
+
transformData: jest.fn().mockReturnValue(rawData),
|
|
433
|
+
requiredProperties: ['id', 'name'],
|
|
434
|
+
};
|
|
435
|
+
processor_registry_1.getProcessorForEntityType.mockReturnValue(mockProcessor);
|
|
436
|
+
entity_processor_v2_1.EntityProcessorV2.constructEntities = jest.fn().mockResolvedValue({
|
|
437
|
+
incomingEntities: rawData,
|
|
438
|
+
badEntities: [],
|
|
439
|
+
allCurrentEntitiesByFederatedId: {},
|
|
440
|
+
});
|
|
441
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.setupEntities(client, entity_types_1.EntityType.COLOR, rawData);
|
|
442
|
+
expect(result).toEqual({
|
|
443
|
+
incomingEntities: rawData,
|
|
444
|
+
badEntities: [],
|
|
445
|
+
allCurrentEntitiesByFederatedId: {},
|
|
446
|
+
});
|
|
447
|
+
expect(mockProcessor.transformData).toHaveBeenCalledWith(rawData);
|
|
448
|
+
expect(entity_processor_v2_1.EntityProcessorV2.constructEntities).toHaveBeenCalledWith({
|
|
449
|
+
client,
|
|
450
|
+
processor: mockProcessor,
|
|
451
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
452
|
+
requiredProperties: ['id', 'name'],
|
|
453
|
+
data: rawData,
|
|
454
|
+
entitySpecificProperties: undefined,
|
|
455
|
+
itemsByFederatedId: {},
|
|
456
|
+
typesByTypePath: undefined,
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
it('should handle errors and return raw data', async () => {
|
|
460
|
+
const rawData = [{ id: 1, name: 'test' }];
|
|
461
|
+
const error = new Error('Test error');
|
|
462
|
+
processor_registry_1.getProcessorForEntityType.mockImplementation(() => {
|
|
463
|
+
throw error;
|
|
464
|
+
});
|
|
465
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.setupEntities(client, entity_types_1.EntityType.COLOR, rawData);
|
|
466
|
+
expect(result).toEqual({
|
|
467
|
+
incomingEntities: rawData,
|
|
468
|
+
badEntities: [],
|
|
469
|
+
allCurrentEntitiesByFederatedId: {},
|
|
470
|
+
projectId: null,
|
|
471
|
+
typesByPath: [],
|
|
472
|
+
});
|
|
473
|
+
expect(console.error).toHaveBeenCalledWith('Error processing and loading objects for color:', error);
|
|
474
|
+
});
|
|
475
|
+
it('should handle undefined required properties', async () => {
|
|
476
|
+
const rawData = [{ id: 1, name: 'test' }];
|
|
477
|
+
const mockProcessor = {
|
|
478
|
+
transformData: jest.fn().mockReturnValue(rawData),
|
|
479
|
+
requiredProperties: undefined,
|
|
480
|
+
};
|
|
481
|
+
processor_registry_1.getProcessorForEntityType.mockReturnValue(mockProcessor);
|
|
482
|
+
entity_processor_v2_1.EntityProcessorV2.constructEntities = jest.fn().mockResolvedValue({
|
|
483
|
+
incomingEntities: rawData,
|
|
484
|
+
badEntities: [],
|
|
485
|
+
allCurrentEntitiesByFederatedId: {},
|
|
486
|
+
});
|
|
487
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.setupEntities(client, entity_types_1.EntityType.COLOR, rawData);
|
|
488
|
+
expect(result).toEqual({
|
|
489
|
+
incomingEntities: rawData,
|
|
490
|
+
badEntities: [],
|
|
491
|
+
allCurrentEntitiesByFederatedId: {},
|
|
492
|
+
});
|
|
493
|
+
expect(entity_processor_v2_1.EntityProcessorV2.constructEntities).toHaveBeenCalledWith({
|
|
494
|
+
client,
|
|
495
|
+
processor: mockProcessor,
|
|
496
|
+
entityType: entity_types_1.EntityType.COLOR,
|
|
497
|
+
requiredProperties: [],
|
|
498
|
+
data: rawData,
|
|
499
|
+
entitySpecificProperties: undefined,
|
|
500
|
+
itemsByFederatedId: {},
|
|
501
|
+
typesByTypePath: undefined,
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
it('should handle empty raw data', async () => {
|
|
505
|
+
const rawData = [];
|
|
506
|
+
const mockProcessor = {
|
|
507
|
+
transformData: jest.fn().mockReturnValue([]),
|
|
508
|
+
requiredProperties: ['id', 'name'],
|
|
509
|
+
};
|
|
510
|
+
processor_registry_1.getProcessorForEntityType.mockReturnValue(mockProcessor);
|
|
511
|
+
entity_processor_v2_1.EntityProcessorV2.constructEntities = jest.fn().mockResolvedValue({
|
|
512
|
+
incomingEntities: [],
|
|
513
|
+
badEntities: [],
|
|
514
|
+
allCurrentEntitiesByFederatedId: {},
|
|
515
|
+
});
|
|
516
|
+
const result = await entity_processor_v2_1.EntityProcessorV2.setupEntities(client, entity_types_1.EntityType.COLOR, rawData);
|
|
517
|
+
expect(result).toEqual({
|
|
518
|
+
incomingEntities: [],
|
|
519
|
+
badEntities: [],
|
|
520
|
+
allCurrentEntitiesByFederatedId: {},
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
describe('getUniqueAndDuplicateEntries', () => {
|
|
525
|
+
it('should return unique and duplicate entries', () => {
|
|
526
|
+
const strings = ['1', '2', '1', '3', '2'];
|
|
527
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getUniqueAndDuplicateEntries(strings);
|
|
528
|
+
expect(result).toEqual({
|
|
529
|
+
uniqueFedIds: ['1', '2', '3'],
|
|
530
|
+
nonUniqueFedIds: ['1', '2'],
|
|
531
|
+
});
|
|
532
|
+
});
|
|
533
|
+
it('should return all unique entries when there are no duplicates', () => {
|
|
534
|
+
const strings = ['1', '2', '3'];
|
|
535
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getUniqueAndDuplicateEntries(strings);
|
|
536
|
+
expect(result).toEqual({
|
|
537
|
+
uniqueFedIds: ['1', '2', '3'],
|
|
538
|
+
nonUniqueFedIds: [],
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
it('should return all duplicate entries when all are duplicates', () => {
|
|
542
|
+
const strings = ['1', '1', '1'];
|
|
543
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getUniqueAndDuplicateEntries(strings);
|
|
544
|
+
expect(result).toEqual({
|
|
545
|
+
uniqueFedIds: ['1'],
|
|
546
|
+
nonUniqueFedIds: ['1'],
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
it('should handle an empty array', () => {
|
|
550
|
+
const strings = [];
|
|
551
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getUniqueAndDuplicateEntries(strings);
|
|
552
|
+
expect(result).toEqual({
|
|
553
|
+
uniqueFedIds: [],
|
|
554
|
+
nonUniqueFedIds: [],
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
it('should handle an array with one element', () => {
|
|
558
|
+
const strings = ['1'];
|
|
559
|
+
const result = entity_processor_v2_1.EntityProcessorV2.getUniqueAndDuplicateEntries(strings);
|
|
560
|
+
expect(result).toEqual({
|
|
561
|
+
uniqueFedIds: ['1'],
|
|
562
|
+
nonUniqueFedIds: [],
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
describe('validateLoadFile', () => {
|
|
567
|
+
const loaderProcess = {
|
|
568
|
+
id: 'mock-loader-process-id',
|
|
569
|
+
loadFileId: 'mock-load-file-id',
|
|
570
|
+
loadType: [entity_types_1.LoadType.COLOR],
|
|
571
|
+
status: entity_types_1.LoadStatus.COMPLETE,
|
|
572
|
+
federatedMappings: {
|
|
573
|
+
federatedId: 'name',
|
|
574
|
+
name: 'name',
|
|
575
|
+
},
|
|
576
|
+
conditionalColumns: [
|
|
577
|
+
{
|
|
578
|
+
toProperty: 'typePath',
|
|
579
|
+
default: 'color',
|
|
580
|
+
},
|
|
581
|
+
],
|
|
582
|
+
};
|
|
583
|
+
it('should return error if no config file provided', () => {
|
|
584
|
+
const data = [{ name: 'color1' }];
|
|
585
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, null, entity_types_1.LoadType.COLOR);
|
|
586
|
+
expect(result.generalErrors).toEqual([
|
|
587
|
+
{
|
|
588
|
+
message: 'Config file is empty',
|
|
589
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
590
|
+
},
|
|
591
|
+
]);
|
|
592
|
+
});
|
|
593
|
+
it('should return error if loadType is missing', () => {
|
|
594
|
+
const data = [{ name: 'color1' }];
|
|
595
|
+
const config = {
|
|
596
|
+
...loaderProcess,
|
|
597
|
+
loadType: [],
|
|
598
|
+
};
|
|
599
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
600
|
+
expect(result.generalErrors).toEqual([
|
|
601
|
+
{
|
|
602
|
+
message: '"loadType" is required in the config file',
|
|
603
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
604
|
+
},
|
|
605
|
+
]);
|
|
606
|
+
});
|
|
607
|
+
it('should throw error if loadType is invalid', () => {
|
|
608
|
+
const data = [{ name: 'color1' }];
|
|
609
|
+
const config = {
|
|
610
|
+
...loaderProcess,
|
|
611
|
+
loadType: ['COLOR1'],
|
|
612
|
+
};
|
|
613
|
+
const result = color_processor_v2_1.ColorProcessorV2.validateLoadFile(data, config);
|
|
614
|
+
expect(result.generalErrors).toEqual([
|
|
615
|
+
{
|
|
616
|
+
message: '"loadType" must be single value "COLOR" in the config file',
|
|
617
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
618
|
+
},
|
|
619
|
+
]);
|
|
620
|
+
});
|
|
621
|
+
describe('federatedId validation', () => {
|
|
622
|
+
it('should validate federatedId in conditional columns', () => {
|
|
623
|
+
const data = [{ name: 'test1' }];
|
|
624
|
+
const config = {
|
|
625
|
+
...loaderProcess,
|
|
626
|
+
conditionalColumns: [
|
|
627
|
+
{
|
|
628
|
+
toProperty: 'federatedId',
|
|
629
|
+
default: 'test-{name}',
|
|
630
|
+
},
|
|
631
|
+
],
|
|
632
|
+
};
|
|
633
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
634
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
635
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
636
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
it('should validate federatedId in CSV data', () => {
|
|
640
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
641
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, loaderProcess);
|
|
642
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
643
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
644
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
it('should validate federatedId in federatedMapping', () => {
|
|
648
|
+
const data = [{ code: 'test1', name: 'Test 1' }];
|
|
649
|
+
const config = {
|
|
650
|
+
...loaderProcess,
|
|
651
|
+
federatedMappings: {
|
|
652
|
+
federatedId: 'code',
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
656
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
657
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
658
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
it('should return error if federated id is missing in federatedmapping config, csv header and conditional column', () => {
|
|
662
|
+
const data = [{ name: 'color1' }];
|
|
663
|
+
const config = {
|
|
664
|
+
id: 'mock-loader-process-id',
|
|
665
|
+
loadFileId: 'mock-load-file-id',
|
|
666
|
+
loadType: [entity_types_1.LoadType.COLOR],
|
|
667
|
+
status: entity_types_1.LoadStatus.COMPLETE,
|
|
668
|
+
conditionalColumns: [
|
|
669
|
+
{
|
|
670
|
+
toProperty: 'typePath',
|
|
671
|
+
default: 'color',
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
federatedMapping: {
|
|
675
|
+
name: 'name',
|
|
676
|
+
},
|
|
677
|
+
ignoreParameters: { ignoreFamilyNameOnUpdate: false, ignoreOptionNameOnUpdate: false },
|
|
678
|
+
shouldSkipAssortmentPublish: false,
|
|
679
|
+
};
|
|
680
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
681
|
+
expect(result.generalErrors).toEqual([
|
|
682
|
+
{
|
|
683
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
684
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
685
|
+
},
|
|
686
|
+
]);
|
|
687
|
+
});
|
|
688
|
+
it('should return error if federatedmapping object is missing', () => {
|
|
689
|
+
const data = [{ name: 'color1' }];
|
|
690
|
+
const config = {
|
|
691
|
+
id: 'mock-loader-process-id',
|
|
692
|
+
loadFileId: 'mock-load-file-id',
|
|
693
|
+
loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
|
|
694
|
+
status: entity_types_1.LoadStatus.COMPLETE,
|
|
695
|
+
conditionalColumns: [
|
|
696
|
+
{
|
|
697
|
+
toProperty: 'typePath',
|
|
698
|
+
default: 'color',
|
|
699
|
+
},
|
|
700
|
+
],
|
|
701
|
+
ignoreParameters: { ignoreFamilyNameOnUpdate: false, ignoreOptionNameOnUpdate: false },
|
|
702
|
+
shouldSkipAssortmentPublish: false,
|
|
703
|
+
};
|
|
704
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
705
|
+
expect(result.generalErrors).toEqual([
|
|
706
|
+
{
|
|
707
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
708
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
709
|
+
},
|
|
710
|
+
]);
|
|
711
|
+
});
|
|
712
|
+
it('should return error if federatedId column is not found in the CSV file', () => {
|
|
713
|
+
const data = [{ name: 'custom-entity1' }];
|
|
714
|
+
const config = {
|
|
715
|
+
...loaderProcess,
|
|
716
|
+
loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
|
|
717
|
+
federatedMappings: { federatedId: 'missingId', name: 'name' },
|
|
718
|
+
};
|
|
719
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
720
|
+
expect(result.generalErrors).toEqual([
|
|
721
|
+
{
|
|
722
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.FEDERATED_ID_REQUIRED,
|
|
723
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
724
|
+
},
|
|
725
|
+
]);
|
|
726
|
+
});
|
|
727
|
+
it('should not return error if federatedId is present in CSV headers but missing in config and conditional column', () => {
|
|
728
|
+
const data = [{ federatedId: 'custom-entity1', name: 'custom-entity1' }];
|
|
729
|
+
const config = {
|
|
730
|
+
...loaderProcess,
|
|
731
|
+
loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
|
|
732
|
+
federatedMappings: { name: 'name' },
|
|
733
|
+
};
|
|
734
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
735
|
+
expect(result.generalErrors).toEqual([]);
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
describe('name validation', () => {
|
|
739
|
+
it('should validate name in conditional columns', () => {
|
|
740
|
+
const data = [{ federatedId: 'test1' }];
|
|
741
|
+
const config = {
|
|
742
|
+
...loaderProcess,
|
|
743
|
+
federatedMappings: {},
|
|
744
|
+
conditionalColumns: [
|
|
745
|
+
{
|
|
746
|
+
toProperty: 'name',
|
|
747
|
+
default: 'Test {federatedId}',
|
|
748
|
+
},
|
|
749
|
+
],
|
|
750
|
+
};
|
|
751
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
752
|
+
console.log(JSON.stringify(result, null, 2));
|
|
753
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
754
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.NAME_REQUIRED,
|
|
755
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
756
|
+
});
|
|
757
|
+
});
|
|
758
|
+
it('should validate name in CSV data', () => {
|
|
759
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
760
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, loaderProcess);
|
|
761
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
762
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.NAME_REQUIRED,
|
|
763
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
it('should validate name in federatedMapping', () => {
|
|
767
|
+
const data = [{ federatedId: 'test1', display_name: 'Test 1' }];
|
|
768
|
+
const config = {
|
|
769
|
+
...loaderProcess,
|
|
770
|
+
federatedMappings: {
|
|
771
|
+
name: 'display_name',
|
|
772
|
+
},
|
|
773
|
+
};
|
|
774
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
775
|
+
expect(result.generalErrors).not.toContainEqual({
|
|
776
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.NAME_REQUIRED,
|
|
777
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
it('should return error if name is missing in federatedMappings, config and conditional column', () => {
|
|
781
|
+
const data = [{ id: 'custom-entity1' }];
|
|
782
|
+
const config = {
|
|
783
|
+
...loaderProcess,
|
|
784
|
+
loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
|
|
785
|
+
federatedMappings: { federatedId: 'id' },
|
|
786
|
+
};
|
|
787
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
788
|
+
expect(result.generalErrors).toEqual([
|
|
789
|
+
{
|
|
790
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.NAME_REQUIRED,
|
|
791
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
792
|
+
},
|
|
793
|
+
]);
|
|
794
|
+
});
|
|
795
|
+
it('should return error if name column is not found in the CSV file', () => {
|
|
796
|
+
const data = [{ federatedId: 'color1' }];
|
|
797
|
+
const config = {
|
|
798
|
+
...loaderProcess,
|
|
799
|
+
federatedMappings: {
|
|
800
|
+
federatedId: 'federatedId',
|
|
801
|
+
name: 'missingName',
|
|
802
|
+
},
|
|
803
|
+
};
|
|
804
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
805
|
+
expect(result.generalErrors).toEqual([
|
|
806
|
+
{
|
|
807
|
+
message: constants_1.ENTITY_PROCESSOR_ERRORS.NAME_REQUIRED,
|
|
808
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
809
|
+
},
|
|
810
|
+
]);
|
|
811
|
+
});
|
|
812
|
+
it('should not return error if name is present in CSV headers but missing in config and conditional column', () => {
|
|
813
|
+
const data = [{ federatedId: 'id1', name: 'color1' }];
|
|
814
|
+
const config = {
|
|
815
|
+
...loaderProcess,
|
|
816
|
+
federatedMappings: { federatedId: 'federatedId' },
|
|
817
|
+
};
|
|
818
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
819
|
+
expect(result.generalErrors).toEqual([]);
|
|
820
|
+
});
|
|
821
|
+
it('should handle mixed validation scenarios', () => {
|
|
822
|
+
const data = [{ code: 'test1', display_name: 'Test 1' }];
|
|
823
|
+
const config = {
|
|
824
|
+
...loaderProcess,
|
|
825
|
+
federatedMappings: {
|
|
826
|
+
federatedId: 'code',
|
|
827
|
+
},
|
|
828
|
+
conditionalColumns: [
|
|
829
|
+
{
|
|
830
|
+
toProperty: 'name',
|
|
831
|
+
default: '{display_name}',
|
|
832
|
+
},
|
|
833
|
+
],
|
|
834
|
+
};
|
|
835
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
836
|
+
expect(result.generalErrors).toHaveLength(0);
|
|
837
|
+
});
|
|
838
|
+
});
|
|
839
|
+
describe('skipStaleUpdatesUsing validation', () => {
|
|
840
|
+
it('should not return error when skipStaleUpdatesUsing is not specified', () => {
|
|
841
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
842
|
+
const config = {
|
|
843
|
+
...loaderProcess,
|
|
844
|
+
};
|
|
845
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
846
|
+
expect(result.generalErrors).not.toContainEqual(expect.objectContaining({
|
|
847
|
+
message: expect.stringContaining('skipStaleUpdatesUsing'),
|
|
848
|
+
}));
|
|
849
|
+
expect(result.returnImmediately).toBe(false);
|
|
850
|
+
});
|
|
851
|
+
it('should validate skipStaleUpdatesUsing column exists in CSV', () => {
|
|
852
|
+
const data = [{ federatedId: 'test1', name: 'Test 1', lastModified: '2024-01-01' }];
|
|
853
|
+
const config = {
|
|
854
|
+
...loaderProcess,
|
|
855
|
+
skipStaleUpdatesUsing: 'lastModified',
|
|
856
|
+
};
|
|
857
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
858
|
+
expect(result.generalErrors).not.toContainEqual(expect.objectContaining({
|
|
859
|
+
message: expect.stringContaining('skipStaleUpdatesUsing'),
|
|
860
|
+
}));
|
|
861
|
+
expect(result.returnImmediately).toBe(false);
|
|
862
|
+
});
|
|
863
|
+
it('should validate skipStaleUpdatesUsing column exists in federatedMappings', () => {
|
|
864
|
+
const data = [{ federatedId: 'test1', name: 'Test 1', modified_date: '2024-01-01' }];
|
|
865
|
+
const config = {
|
|
866
|
+
...loaderProcess,
|
|
867
|
+
skipStaleUpdatesUsing: 'lastModified',
|
|
868
|
+
federatedMappings: {
|
|
869
|
+
lastModified: 'modified_date',
|
|
870
|
+
},
|
|
871
|
+
};
|
|
872
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
873
|
+
expect(result.generalErrors).not.toContainEqual(expect.objectContaining({
|
|
874
|
+
message: expect.stringContaining('skipStaleUpdatesUsing'),
|
|
875
|
+
}));
|
|
876
|
+
});
|
|
877
|
+
it('should validate skipStaleUpdatesUsing column exists in conditionalColumns', () => {
|
|
878
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
879
|
+
const config = {
|
|
880
|
+
...loaderProcess,
|
|
881
|
+
skipStaleUpdatesUsing: 'lastModified',
|
|
882
|
+
conditionalColumns: [
|
|
883
|
+
{
|
|
884
|
+
toProperty: 'lastModified',
|
|
885
|
+
default: '2024-01-01',
|
|
886
|
+
},
|
|
887
|
+
],
|
|
888
|
+
};
|
|
889
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
890
|
+
expect(result.generalErrors).not.toContainEqual(expect.objectContaining({
|
|
891
|
+
message: expect.stringContaining('skipStaleUpdatesUsing'),
|
|
892
|
+
}));
|
|
893
|
+
});
|
|
894
|
+
it('should return error when skipStaleUpdatesUsing column not found', () => {
|
|
895
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
896
|
+
const config = {
|
|
897
|
+
...loaderProcess,
|
|
898
|
+
skipStaleUpdatesUsing: 'lastModified',
|
|
899
|
+
};
|
|
900
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
901
|
+
expect(result.generalErrors).toContainEqual({
|
|
902
|
+
message: "skipStaleUpdatesUsing column 'lastModified' not found in CSV headers, federated mappings, or conditional columns",
|
|
903
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
904
|
+
});
|
|
905
|
+
expect(result.returnImmediately).toBe(true);
|
|
906
|
+
});
|
|
907
|
+
it('should return error when skipStaleUpdatesUsing is not a string', () => {
|
|
908
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
909
|
+
const config = {
|
|
910
|
+
...loaderProcess,
|
|
911
|
+
skipStaleUpdatesUsing: ['lastModified'],
|
|
912
|
+
};
|
|
913
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
914
|
+
expect(result.generalErrors).toContainEqual({
|
|
915
|
+
message: 'skipStaleUpdatesUsing must be a string column name, received: object',
|
|
916
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
917
|
+
});
|
|
918
|
+
expect(result.returnImmediately).toBe(true);
|
|
919
|
+
});
|
|
920
|
+
it('should return error when skipStaleUpdatesUsing mapped column not in CSV', () => {
|
|
921
|
+
const data = [{ federatedId: 'test1', name: 'Test 1' }];
|
|
922
|
+
const config = {
|
|
923
|
+
...loaderProcess,
|
|
924
|
+
skipStaleUpdatesUsing: 'lastModified',
|
|
925
|
+
federatedMappings: {
|
|
926
|
+
lastModified: 'missing_column',
|
|
927
|
+
},
|
|
928
|
+
};
|
|
929
|
+
const result = entity_processor_v2_1.EntityProcessorV2.validateLoadFile(data, config);
|
|
930
|
+
expect(result.generalErrors).toContainEqual({
|
|
931
|
+
message: "skipStaleUpdatesUsing column 'lastModified' is mapped to 'missing_column' but that column is not in the CSV",
|
|
932
|
+
issueType: entity_types_1.IssueType.CONFIG,
|
|
933
|
+
});
|
|
934
|
+
expect(result.returnImmediately).toBe(true);
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
describe('getDuplicateFederatedIds', () => {
|
|
939
|
+
it('should return duplicate federated IDs', () => {
|
|
940
|
+
const data = [{ name: 'color1' }, { name: 'color2' }, { name: 'color1' }];
|
|
941
|
+
const result = (0, util_1.getDuplicateFederatedIds)(data, 'name');
|
|
942
|
+
expect(result).toEqual([
|
|
943
|
+
{
|
|
944
|
+
rowNumber: 2,
|
|
945
|
+
columnIssues: [
|
|
946
|
+
{
|
|
947
|
+
columnName: 'name',
|
|
948
|
+
message: 'Duplicate federatedId found: color1',
|
|
949
|
+
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
950
|
+
data: '{"name":"color1"}',
|
|
951
|
+
},
|
|
952
|
+
],
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
rowNumber: 4,
|
|
956
|
+
columnIssues: [
|
|
957
|
+
{
|
|
958
|
+
columnName: 'name',
|
|
959
|
+
message: 'Duplicate federatedId found: color1',
|
|
960
|
+
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
961
|
+
data: '{"name":"color1"}',
|
|
962
|
+
},
|
|
963
|
+
],
|
|
964
|
+
},
|
|
965
|
+
]);
|
|
966
|
+
});
|
|
967
|
+
it('should handle no duplicate federated IDs', () => {
|
|
968
|
+
const data = [{ name: 'color1' }, { name: 'color2' }, { name: 'color3' }];
|
|
969
|
+
const result = (0, util_1.getDuplicateFederatedIds)(data, 'name');
|
|
970
|
+
expect(result).toEqual([]);
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
});
|