@unispechq/unispec-core 0.3.2 → 0.3.4
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/dist/cache/cache-factory.d.ts +2 -2
- package/dist/cache/cache-factory.js +1 -1
- package/dist/cache/cache-manager.d.ts +2 -2
- package/dist/cache/cache-manager.js +9 -7
- package/dist/cache/hash-utils.d.ts +1 -11
- package/dist/cache/hash-utils.js +1 -21
- package/dist/cache/hashing.d.ts +15 -6
- package/dist/cache/hashing.js +8 -12
- package/dist/cache/index.d.ts +6 -6
- package/dist/cache/index.js +5 -5
- package/dist/cache/lru-cache.d.ts +1 -13
- package/dist/cache/lru-cache.js +3 -24
- package/dist/cjs/cache/cache-factory.js +1 -1
- package/dist/cjs/cache/cache-manager.js +9 -7
- package/dist/cjs/cache/hash-utils.js +1 -23
- package/dist/cjs/cache/hashing.js +7 -13
- package/dist/cjs/cache/index.js +6 -8
- package/dist/cjs/cache/lru-cache.js +3 -24
- package/dist/cjs/diff/annotators.js +3 -2
- package/dist/cjs/diff/core.js +2 -2
- package/dist/cjs/diff/enhanced-diff.js +7 -21
- package/dist/cjs/diff/index.js +8 -8
- package/dist/cjs/errors/config-error.js +1 -1
- package/dist/cjs/errors/error-factory.js +7 -7
- package/dist/cjs/errors/index.js +8 -8
- package/dist/cjs/errors/loader-error.js +1 -1
- package/dist/cjs/errors/reference-error.js +1 -1
- package/dist/cjs/errors/schema-error.js +1 -1
- package/dist/cjs/errors/security-error.js +1 -1
- package/dist/cjs/errors/semantic-error.js +1 -1
- package/dist/cjs/index.js +13 -13
- package/dist/cjs/loader/index.js +4 -4
- package/dist/cjs/loader/security-validator.js +1 -1
- package/dist/cjs/loader/unispec-loader.js +3 -3
- package/dist/cjs/loader/yaml-loader.js +1 -1
- package/dist/cjs/normalizer/core.js +11 -6
- package/dist/cjs/normalizer/index.js +1 -1
- package/dist/cjs/normalizer/utils.js +23 -7
- package/dist/cjs/optimizer/core.js +35 -10
- package/dist/cjs/optimizer/index.js +3 -3
- package/dist/cjs/optimizer/optimization-functions.js +2 -2
- package/dist/cjs/schemas/dedupe.js +27 -14
- package/dist/cjs/schemas/index.js +3 -3
- package/dist/cjs/schemas/resolver.js +3 -2
- package/dist/cjs/validator/ajv-validator.js +1 -1
- package/dist/cjs/validator/config-validator-main.js +4 -4
- package/dist/cjs/validator/config-validator.js +1 -1
- package/dist/cjs/validator/index.js +7 -7
- package/dist/cjs/validator/reference-validator.js +1 -1
- package/dist/cjs/validator/tests-validator.js +2 -2
- package/dist/cjs/validator/unispec-validator.js +7 -11
- package/dist/cjs/validator/validator-factory.js +1 -1
- package/dist/diff/annotators.d.ts +1 -1
- package/dist/diff/annotators.js +3 -2
- package/dist/diff/change-reports.d.ts +1 -1
- package/dist/diff/core.d.ts +2 -2
- package/dist/diff/core.js +2 -2
- package/dist/diff/enhanced-diff.d.ts +3 -3
- package/dist/diff/enhanced-diff.js +7 -21
- package/dist/diff/impact-strategies-refactored.d.ts +2 -2
- package/dist/diff/impact-strategies.d.ts +2 -2
- package/dist/diff/index.d.ts +8 -8
- package/dist/diff/index.js +8 -8
- package/dist/diff/metrics-calculator.d.ts +1 -1
- package/dist/diff/risk-calculator.d.ts +1 -1
- package/dist/diff/suggestion-generator.d.ts +2 -2
- package/dist/errors/config-error.d.ts +1 -1
- package/dist/errors/config-error.js +1 -1
- package/dist/errors/error-factory.d.ts +7 -7
- package/dist/errors/error-factory.js +7 -7
- package/dist/errors/index.d.ts +8 -8
- package/dist/errors/index.js +8 -8
- package/dist/errors/loader-error.d.ts +1 -1
- package/dist/errors/loader-error.js +1 -1
- package/dist/errors/reference-error.d.ts +1 -1
- package/dist/errors/reference-error.js +1 -1
- package/dist/errors/schema-error.d.ts +1 -1
- package/dist/errors/schema-error.js +1 -1
- package/dist/errors/security-error.d.ts +1 -1
- package/dist/errors/security-error.js +1 -1
- package/dist/errors/semantic-error.d.ts +1 -1
- package/dist/errors/semantic-error.js +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -13
- package/dist/loader/index.d.ts +5 -5
- package/dist/loader/index.js +4 -4
- package/dist/loader/security-validator.d.ts +1 -1
- package/dist/loader/security-validator.js +1 -1
- package/dist/loader/unispec-loader.d.ts +2 -2
- package/dist/loader/unispec-loader.js +3 -3
- package/dist/loader/yaml-loader.d.ts +1 -1
- package/dist/loader/yaml-loader.js +1 -1
- package/dist/normalizer/core.d.ts +2 -2
- package/dist/normalizer/core.js +11 -6
- package/dist/normalizer/graphql-normalizer.d.ts +1 -1
- package/dist/normalizer/index.d.ts +2 -2
- package/dist/normalizer/index.js +1 -1
- package/dist/normalizer/rest-normalizer.d.ts +1 -1
- package/dist/normalizer/types.d.ts +1 -1
- package/dist/normalizer/utils.d.ts +6 -3
- package/dist/normalizer/utils.js +23 -7
- package/dist/normalizer/websocket-normalizer.d.ts +1 -1
- package/dist/optimizer/core.d.ts +2 -2
- package/dist/optimizer/core.js +35 -10
- package/dist/optimizer/index.d.ts +4 -4
- package/dist/optimizer/index.js +3 -3
- package/dist/optimizer/optimization-functions.d.ts +2 -2
- package/dist/optimizer/optimization-functions.js +2 -2
- package/dist/optimizer/types.d.ts +1 -1
- package/dist/schemas/dedupe.d.ts +1 -1
- package/dist/schemas/dedupe.js +27 -14
- package/dist/schemas/index.d.ts +3 -3
- package/dist/schemas/index.js +3 -3
- package/dist/schemas/resolver.d.ts +1 -1
- package/dist/schemas/resolver.js +3 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/validator/ajv-validator.d.ts +1 -1
- package/dist/validator/ajv-validator.js +1 -1
- package/dist/validator/config-validator-main.d.ts +2 -2
- package/dist/validator/config-validator-main.js +4 -4
- package/dist/validator/config-validator.d.ts +1 -1
- package/dist/validator/config-validator.js +1 -1
- package/dist/validator/index.d.ts +10 -10
- package/dist/validator/index.js +7 -7
- package/dist/validator/reference-validator.d.ts +1 -1
- package/dist/validator/reference-validator.js +1 -1
- package/dist/validator/schema-references.d.ts +1 -1
- package/dist/validator/semantic-validator.d.ts +1 -1
- package/dist/validator/tests-validator.d.ts +2 -2
- package/dist/validator/tests-validator.js +2 -2
- package/dist/validator/types.d.ts +3 -3
- package/dist/validator/unispec-validator.d.ts +2 -2
- package/dist/validator/unispec-validator.js +7 -11
- package/dist/validator/validator-factory.d.ts +3 -3
- package/dist/validator/validator-factory.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/src/cache/cache-factory.js +0 -72
- package/dist/cjs/src/cache/cache-manager.js +0 -128
- package/dist/cjs/src/cache/constants.js +0 -25
- package/dist/cjs/src/cache/hash-utils.js +0 -19
- package/dist/cjs/src/cache/hashing.js +0 -230
- package/dist/cjs/src/cache/index.js +0 -24
- package/dist/cjs/src/cache/lru-cache.js +0 -144
- package/dist/cjs/src/cache/types.js +0 -5
- package/dist/cjs/src/diff/annotators.js +0 -160
- package/dist/cjs/src/diff/change-reports.js +0 -369
- package/dist/cjs/src/diff/core.js +0 -158
- package/dist/cjs/src/diff/enhanced-diff.js +0 -65
- package/dist/cjs/src/diff/impact-strategies-refactored.js +0 -230
- package/dist/cjs/src/diff/impact-strategies.js +0 -219
- package/dist/cjs/src/diff/index.js +0 -27
- package/dist/cjs/src/diff/metrics-calculator.js +0 -69
- package/dist/cjs/src/diff/risk-calculator.js +0 -58
- package/dist/cjs/src/diff/suggestion-generator.js +0 -78
- package/dist/cjs/src/diff/types.js +0 -11
- package/dist/cjs/src/errors/base-error.js +0 -33
- package/dist/cjs/src/errors/config-error.js +0 -11
- package/dist/cjs/src/errors/error-factory.js +0 -48
- package/dist/cjs/src/errors/index.js +0 -19
- package/dist/cjs/src/errors/loader-error.js +0 -11
- package/dist/cjs/src/errors/reference-error.js +0 -11
- package/dist/cjs/src/errors/schema-error.js +0 -11
- package/dist/cjs/src/errors/security-error.js +0 -11
- package/dist/cjs/src/errors/semantic-error.js +0 -11
- package/dist/cjs/src/generated-schemas.js +0 -2100
- package/dist/cjs/src/index.js +0 -59
- package/dist/cjs/src/loader/index.js +0 -13
- package/dist/cjs/src/loader/security-validator.js +0 -53
- package/dist/cjs/src/loader/types.js +0 -11
- package/dist/cjs/src/loader/unispec-loader.js +0 -84
- package/dist/cjs/src/loader/yaml-loader.js +0 -76
- package/dist/cjs/src/normalizer/core.js +0 -37
- package/dist/cjs/src/normalizer/graphql-normalizer.js +0 -67
- package/dist/cjs/src/normalizer/index.js +0 -7
- package/dist/cjs/src/normalizer/rest-normalizer.js +0 -51
- package/dist/cjs/src/normalizer/types.js +0 -2
- package/dist/cjs/src/normalizer/utils.js +0 -49
- package/dist/cjs/src/normalizer/websocket-normalizer.js +0 -81
- package/dist/cjs/src/optimizer/core.js +0 -140
- package/dist/cjs/src/optimizer/index.js +0 -17
- package/dist/cjs/src/optimizer/optimization-functions.js +0 -185
- package/dist/cjs/src/optimizer/types.js +0 -2
- package/dist/cjs/src/optimizer/utils.js +0 -32
- package/dist/cjs/src/schemas/dedupe.js +0 -113
- package/dist/cjs/src/schemas/index.js +0 -14
- package/dist/cjs/src/schemas/resolver.js +0 -42
- package/dist/cjs/src/schemas/utils.js +0 -53
- package/dist/cjs/src/types/index.js +0 -2
- package/dist/cjs/src/validator/ajv-validator.js +0 -82
- package/dist/cjs/src/validator/config-validator-main.js +0 -34
- package/dist/cjs/src/validator/config-validator.js +0 -17
- package/dist/cjs/src/validator/index.js +0 -23
- package/dist/cjs/src/validator/object-traversal.js +0 -112
- package/dist/cjs/src/validator/reference-validator.js +0 -233
- package/dist/cjs/src/validator/schema-references.js +0 -116
- package/dist/cjs/src/validator/semantic-validator.js +0 -328
- package/dist/cjs/src/validator/tests-validator.js +0 -16
- package/dist/cjs/src/validator/types.js +0 -2
- package/dist/cjs/src/validator/unispec-validator.js +0 -80
- package/dist/cjs/src/validator/validator-factory.js +0 -77
- package/dist/cjs/src/versions.js +0 -147
- package/dist/cjs/tests/cache/cache.test.js +0 -274
- package/dist/cjs/tests/cache/utils.js +0 -32
- package/dist/cjs/tests/concurrency-normalizer-optimizer.test.js +0 -1
- package/dist/cjs/tests/diff/diff-annotators.test.js +0 -280
- package/dist/cjs/tests/diff/diff-comprehensive.test.js +0 -262
- package/dist/cjs/tests/diff/diff-extended.test.js +0 -235
- package/dist/cjs/tests/diff/diff.test.js +0 -189
- package/dist/cjs/tests/diff/utils.js +0 -8
- package/dist/cjs/tests/errors/errors-integration.test.js +0 -173
- package/dist/cjs/tests/errors/errors.test.js +0 -280
- package/dist/cjs/tests/errors/utils.js +0 -7
- package/dist/cjs/tests/loader/integration.test.js +0 -216
- package/dist/cjs/tests/loader/loader.test.js +0 -341
- package/dist/cjs/tests/normalizer/normalizer-comprehensive.test.js +0 -648
- package/dist/cjs/tests/normalizer/normalizer-invalid.test.js +0 -258
- package/dist/cjs/tests/normalizer/normalizer-valid.test.js +0 -238
- package/dist/cjs/tests/normalizer/utils.js +0 -47
- package/dist/cjs/tests/optimizer/compress-references.test.js +0 -304
- package/dist/cjs/tests/optimizer/deduplication.test.js +0 -132
- package/dist/cjs/tests/optimizer/integration.test.js +0 -131
- package/dist/cjs/tests/optimizer/optimization-report.test.js +0 -222
- package/dist/cjs/tests/optimizer/optimize-document.test.js +0 -187
- package/dist/cjs/tests/optimizer/orphaned-schemas.test.js +0 -194
- package/dist/cjs/tests/optimizer/sort-schemas.test.js +0 -131
- package/dist/cjs/tests/optimizer/utils.js +0 -209
- package/dist/cjs/tests/schemas/schemas-edge-cases.test.js +0 -223
- package/dist/cjs/tests/schemas/schemas.test.js +0 -400
- package/dist/cjs/tests/schemas/utils.js +0 -7
- package/dist/cjs/tests/utils.js +0 -131
- package/dist/cjs/tests/validator/config-validator.test.js +0 -78
- package/dist/cjs/tests/validator/debug-config.js +0 -1
- package/dist/cjs/tests/validator/debug-missing-service.js +0 -1
- package/dist/cjs/tests/validator/debug-other-configs.js +0 -1
- package/dist/cjs/tests/validator/debug-references.js +0 -1
- package/dist/cjs/tests/validator/unispec-validator.test.js +0 -103
- package/dist/cjs/tests/validator/utils.js +0 -25
- package/dist/src/cache/cache-factory.d.ts +0 -31
- package/dist/src/cache/cache-factory.js +0 -65
- package/dist/src/cache/cache-manager.d.ts +0 -62
- package/dist/src/cache/cache-manager.js +0 -124
- package/dist/src/cache/constants.d.ts +0 -21
- package/dist/src/cache/constants.js +0 -22
- package/dist/src/cache/hash-utils.d.ts +0 -11
- package/dist/src/cache/hash-utils.js +0 -15
- package/dist/src/cache/hashing.d.ts +0 -28
- package/dist/src/cache/hashing.js +0 -193
- package/dist/src/cache/index.d.ts +0 -6
- package/dist/src/cache/index.js +0 -10
- package/dist/src/cache/lru-cache.d.ts +0 -44
- package/dist/src/cache/lru-cache.js +0 -140
- package/dist/src/cache/types.d.ts +0 -24
- package/dist/src/cache/types.js +0 -4
- package/dist/src/diff/annotators.d.ts +0 -4
- package/dist/src/diff/annotators.js +0 -155
- package/dist/src/diff/change-reports.d.ts +0 -37
- package/dist/src/diff/change-reports.js +0 -366
- package/dist/src/diff/core.d.ts +0 -26
- package/dist/src/diff/core.js +0 -155
- package/dist/src/diff/enhanced-diff.d.ts +0 -51
- package/dist/src/diff/enhanced-diff.js +0 -62
- package/dist/src/diff/impact-strategies-refactored.d.ts +0 -69
- package/dist/src/diff/impact-strategies-refactored.js +0 -223
- package/dist/src/diff/impact-strategies.d.ts +0 -41
- package/dist/src/diff/impact-strategies.js +0 -212
- package/dist/src/diff/index.d.ts +0 -8
- package/dist/src/diff/index.js +0 -11
- package/dist/src/diff/metrics-calculator.d.ts +0 -23
- package/dist/src/diff/metrics-calculator.js +0 -65
- package/dist/src/diff/risk-calculator.d.ts +0 -23
- package/dist/src/diff/risk-calculator.js +0 -55
- package/dist/src/diff/suggestion-generator.d.ts +0 -18
- package/dist/src/diff/suggestion-generator.js +0 -74
- package/dist/src/diff/types.d.ts +0 -24
- package/dist/src/diff/types.js +0 -8
- package/dist/src/errors/base-error.d.ts +0 -20
- package/dist/src/errors/base-error.js +0 -29
- package/dist/src/errors/config-error.d.ts +0 -4
- package/dist/src/errors/config-error.js +0 -7
- package/dist/src/errors/error-factory.d.ts +0 -22
- package/dist/src/errors/error-factory.js +0 -45
- package/dist/src/errors/index.d.ts +0 -8
- package/dist/src/errors/index.js +0 -8
- package/dist/src/errors/loader-error.d.ts +0 -4
- package/dist/src/errors/loader-error.js +0 -7
- package/dist/src/errors/reference-error.d.ts +0 -4
- package/dist/src/errors/reference-error.js +0 -7
- package/dist/src/errors/schema-error.d.ts +0 -4
- package/dist/src/errors/schema-error.js +0 -7
- package/dist/src/errors/security-error.d.ts +0 -4
- package/dist/src/errors/security-error.js +0 -7
- package/dist/src/errors/semantic-error.d.ts +0 -4
- package/dist/src/errors/semantic-error.js +0 -7
- package/dist/src/generated-schemas.d.ts +0 -2073
- package/dist/src/generated-schemas.js +0 -2097
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -43
- package/dist/src/loader/index.d.ts +0 -5
- package/dist/src/loader/index.js +0 -5
- package/dist/src/loader/security-validator.d.ts +0 -5
- package/dist/src/loader/security-validator.js +0 -50
- package/dist/src/loader/types.d.ts +0 -30
- package/dist/src/loader/types.js +0 -8
- package/dist/src/loader/unispec-loader.d.ts +0 -10
- package/dist/src/loader/unispec-loader.js +0 -81
- package/dist/src/loader/yaml-loader.d.ts +0 -10
- package/dist/src/loader/yaml-loader.js +0 -39
- package/dist/src/normalizer/core.d.ts +0 -24
- package/dist/src/normalizer/core.js +0 -34
- package/dist/src/normalizer/graphql-normalizer.d.ts +0 -8
- package/dist/src/normalizer/graphql-normalizer.js +0 -64
- package/dist/src/normalizer/index.d.ts +0 -2
- package/dist/src/normalizer/index.js +0 -3
- package/dist/src/normalizer/rest-normalizer.d.ts +0 -8
- package/dist/src/normalizer/rest-normalizer.js +0 -48
- package/dist/src/normalizer/types.d.ts +0 -7
- package/dist/src/normalizer/types.js +0 -1
- package/dist/src/normalizer/utils.d.ts +0 -17
- package/dist/src/normalizer/utils.js +0 -45
- package/dist/src/normalizer/websocket-normalizer.d.ts +0 -8
- package/dist/src/normalizer/websocket-normalizer.js +0 -78
- package/dist/src/optimizer/core.d.ts +0 -17
- package/dist/src/optimizer/core.js +0 -136
- package/dist/src/optimizer/index.d.ts +0 -4
- package/dist/src/optimizer/index.js +0 -7
- package/dist/src/optimizer/optimization-functions.d.ts +0 -32
- package/dist/src/optimizer/optimization-functions.js +0 -179
- package/dist/src/optimizer/types.d.ts +0 -28
- package/dist/src/optimizer/types.js +0 -1
- package/dist/src/optimizer/utils.d.ts +0 -7
- package/dist/src/optimizer/utils.js +0 -29
- package/dist/src/schemas/dedupe.d.ts +0 -9
- package/dist/src/schemas/dedupe.js +0 -110
- package/dist/src/schemas/index.d.ts +0 -3
- package/dist/src/schemas/index.js +0 -6
- package/dist/src/schemas/resolver.d.ts +0 -19
- package/dist/src/schemas/resolver.js +0 -38
- package/dist/src/schemas/utils.d.ts +0 -20
- package/dist/src/schemas/utils.js +0 -49
- package/dist/src/types/index.d.ts +0 -434
- package/dist/src/types/index.js +0 -1
- package/dist/src/validator/ajv-validator.d.ts +0 -15
- package/dist/src/validator/ajv-validator.js +0 -75
- package/dist/src/validator/config-validator-main.d.ts +0 -10
- package/dist/src/validator/config-validator-main.js +0 -31
- package/dist/src/validator/config-validator.d.ts +0 -5
- package/dist/src/validator/config-validator.js +0 -14
- package/dist/src/validator/index.d.ts +0 -10
- package/dist/src/validator/index.js +0 -11
- package/dist/src/validator/object-traversal.d.ts +0 -52
- package/dist/src/validator/object-traversal.js +0 -104
- package/dist/src/validator/reference-validator.d.ts +0 -31
- package/dist/src/validator/reference-validator.js +0 -230
- package/dist/src/validator/schema-references.d.ts +0 -23
- package/dist/src/validator/schema-references.js +0 -111
- package/dist/src/validator/semantic-validator.d.ts +0 -26
- package/dist/src/validator/semantic-validator.js +0 -325
- package/dist/src/validator/tests-validator.d.ts +0 -9
- package/dist/src/validator/tests-validator.js +0 -13
- package/dist/src/validator/types.d.ts +0 -29
- package/dist/src/validator/types.js +0 -1
- package/dist/src/validator/unispec-validator.d.ts +0 -15
- package/dist/src/validator/unispec-validator.js +0 -77
- package/dist/src/validator/validator-factory.d.ts +0 -10
- package/dist/src/validator/validator-factory.js +0 -73
- package/dist/src/versions.d.ts +0 -10
- package/dist/src/versions.js +0 -143
- package/dist/tests/cache/cache.test.d.ts +0 -1
- package/dist/tests/cache/cache.test.js +0 -269
- package/dist/tests/cache/utils.d.ts +0 -4
- package/dist/tests/cache/utils.js +0 -24
- package/dist/tests/concurrency-normalizer-optimizer.test.d.ts +0 -0
- package/dist/tests/concurrency-normalizer-optimizer.test.js +0 -1
- package/dist/tests/diff/diff-annotators.test.d.ts +0 -1
- package/dist/tests/diff/diff-annotators.test.js +0 -275
- package/dist/tests/diff/diff-comprehensive.test.d.ts +0 -1
- package/dist/tests/diff/diff-comprehensive.test.js +0 -257
- package/dist/tests/diff/diff-extended.test.d.ts +0 -1
- package/dist/tests/diff/diff-extended.test.js +0 -230
- package/dist/tests/diff/diff.test.d.ts +0 -1
- package/dist/tests/diff/diff.test.js +0 -184
- package/dist/tests/diff/utils.d.ts +0 -2
- package/dist/tests/diff/utils.js +0 -3
- package/dist/tests/errors/errors-integration.test.d.ts +0 -1
- package/dist/tests/errors/errors-integration.test.js +0 -168
- package/dist/tests/errors/errors.test.d.ts +0 -1
- package/dist/tests/errors/errors.test.js +0 -275
- package/dist/tests/errors/utils.d.ts +0 -2
- package/dist/tests/errors/utils.js +0 -3
- package/dist/tests/loader/integration.test.d.ts +0 -1
- package/dist/tests/loader/integration.test.js +0 -211
- package/dist/tests/loader/loader.test.d.ts +0 -1
- package/dist/tests/loader/loader.test.js +0 -336
- package/dist/tests/normalizer/normalizer-comprehensive.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-comprehensive.test.js +0 -643
- package/dist/tests/normalizer/normalizer-invalid.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-invalid.test.js +0 -253
- package/dist/tests/normalizer/normalizer-valid.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-valid.test.js +0 -233
- package/dist/tests/normalizer/utils.d.ts +0 -18
- package/dist/tests/normalizer/utils.js +0 -36
- package/dist/tests/optimizer/compress-references.test.d.ts +0 -1
- package/dist/tests/optimizer/compress-references.test.js +0 -299
- package/dist/tests/optimizer/deduplication.test.d.ts +0 -1
- package/dist/tests/optimizer/deduplication.test.js +0 -127
- package/dist/tests/optimizer/integration.test.d.ts +0 -1
- package/dist/tests/optimizer/integration.test.js +0 -126
- package/dist/tests/optimizer/optimization-report.test.d.ts +0 -1
- package/dist/tests/optimizer/optimization-report.test.js +0 -217
- package/dist/tests/optimizer/optimize-document.test.d.ts +0 -1
- package/dist/tests/optimizer/optimize-document.test.js +0 -182
- package/dist/tests/optimizer/orphaned-schemas.test.d.ts +0 -1
- package/dist/tests/optimizer/orphaned-schemas.test.js +0 -189
- package/dist/tests/optimizer/sort-schemas.test.d.ts +0 -1
- package/dist/tests/optimizer/sort-schemas.test.js +0 -126
- package/dist/tests/optimizer/utils.d.ts +0 -8
- package/dist/tests/optimizer/utils.js +0 -199
- package/dist/tests/schemas/schemas-edge-cases.test.d.ts +0 -1
- package/dist/tests/schemas/schemas-edge-cases.test.js +0 -218
- package/dist/tests/schemas/schemas.test.d.ts +0 -1
- package/dist/tests/schemas/schemas.test.js +0 -395
- package/dist/tests/schemas/utils.d.ts +0 -2
- package/dist/tests/schemas/utils.js +0 -3
- package/dist/tests/utils.d.ts +0 -10
- package/dist/tests/utils.js +0 -118
- package/dist/tests/validator/config-validator.test.d.ts +0 -1
- package/dist/tests/validator/config-validator.test.js +0 -73
- package/dist/tests/validator/debug-config.d.ts +0 -0
- package/dist/tests/validator/debug-config.js +0 -1
- package/dist/tests/validator/debug-missing-service.d.ts +0 -0
- package/dist/tests/validator/debug-missing-service.js +0 -1
- package/dist/tests/validator/debug-other-configs.d.ts +0 -0
- package/dist/tests/validator/debug-other-configs.js +0 -1
- package/dist/tests/validator/debug-references.d.ts +0 -0
- package/dist/tests/validator/debug-references.js +0 -1
- package/dist/tests/validator/unispec-validator.test.d.ts +0 -1
- package/dist/tests/validator/unispec-validator.test.js +0 -98
- package/dist/tests/validator/utils.d.ts +0 -6
- package/dist/tests/validator/utils.js +0 -20
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { describe, it } from "node:test";
|
|
4
|
-
import { examplesDir, loadExample } from "../../tests/utils.js";
|
|
5
|
-
import { diffUniSpec } from "../../src/diff/core.js";
|
|
6
|
-
describe("diff module - extended tests", () => {
|
|
7
|
-
describe("handling of invalid examples", () => {
|
|
8
|
-
it("should handle empty services array without crashing", () => {
|
|
9
|
-
const invalidDoc = loadExample(path.join(examplesDir, "invalid", "config", "empty-services-array.json"));
|
|
10
|
-
// Should not crash when processing invalid documents
|
|
11
|
-
const result = diffUniSpec(invalidDoc, invalidDoc);
|
|
12
|
-
assert.strictEqual(result.changes.length, 0);
|
|
13
|
-
});
|
|
14
|
-
it("should handle missing service name", () => {
|
|
15
|
-
const invalidDoc = loadExample(path.join(examplesDir, "invalid", "config", "missing-service-name.json"));
|
|
16
|
-
const modifiedDoc = JSON.parse(JSON.stringify(invalidDoc));
|
|
17
|
-
// This is a config file, not a spec, so it has different structure
|
|
18
|
-
modifiedDoc.version = 2;
|
|
19
|
-
const result = diffUniSpec(invalidDoc, modifiedDoc);
|
|
20
|
-
assert.ok(result.changes.length > 0);
|
|
21
|
-
const versionChange = result.changes.find((change) => change.path === "/version");
|
|
22
|
-
assert.ok(versionChange);
|
|
23
|
-
assert.strictEqual(versionChange.description, "Value changed");
|
|
24
|
-
});
|
|
25
|
-
it("should handle missing version", () => {
|
|
26
|
-
const invalidDoc = loadExample(path.join(examplesDir, "invalid", "config", "missing-version.json"));
|
|
27
|
-
const modifiedDoc = JSON.parse(JSON.stringify(invalidDoc));
|
|
28
|
-
modifiedDoc.service = {
|
|
29
|
-
...modifiedDoc.service,
|
|
30
|
-
description: "Added description",
|
|
31
|
-
};
|
|
32
|
-
const result = diffUniSpec(invalidDoc, modifiedDoc);
|
|
33
|
-
assert.ok(result.changes.length > 0);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("complex scenarios with valid examples", () => {
|
|
37
|
-
it("should handle mixed protocol changes", () => {
|
|
38
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "mixed-complete.json"));
|
|
39
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
40
|
-
// Add REST route
|
|
41
|
-
modifiedDoc.service.protocols.rest.routes.push({
|
|
42
|
-
name: "newRoute",
|
|
43
|
-
summary: "New route",
|
|
44
|
-
path: "/new",
|
|
45
|
-
method: "GET",
|
|
46
|
-
responses: { 200: { description: "Success" } },
|
|
47
|
-
});
|
|
48
|
-
// Add GraphQL query
|
|
49
|
-
if (modifiedDoc.service.protocols.graphql) {
|
|
50
|
-
modifiedDoc.service.protocols.graphql.queries.push({
|
|
51
|
-
name: "newQuery",
|
|
52
|
-
description: "New query",
|
|
53
|
-
args: [],
|
|
54
|
-
returnType: "String",
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
58
|
-
const restChange = result.changes.find((change) => change.path.includes("newRoute") && change.protocol === "rest");
|
|
59
|
-
assert.ok(restChange);
|
|
60
|
-
assert.strictEqual(restChange.severity, "non-breaking");
|
|
61
|
-
if (modifiedDoc.service.protocols.graphql) {
|
|
62
|
-
const graphqlChange = result.changes.find((change) => change.path.includes("newQuery") && change.protocol === "graphql");
|
|
63
|
-
assert.ok(graphqlChange);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
it("should detect breaking changes in REST", () => {
|
|
67
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
68
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
69
|
-
// Remove a route (breaking change)
|
|
70
|
-
modifiedDoc.service.protocols.rest.routes =
|
|
71
|
-
modifiedDoc.service.protocols.rest.routes.filter((route) => route.name !== "getUsers");
|
|
72
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
73
|
-
const removedRoute = result.changes.find((change) => change.path === "/service/protocols/rest/routes/getUsers");
|
|
74
|
-
assert.ok(removedRoute);
|
|
75
|
-
assert.strictEqual(removedRoute.severity, "breaking");
|
|
76
|
-
assert.strictEqual(removedRoute.kind, "rest.route.removed");
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe("edge cases and boundary conditions", () => {
|
|
80
|
-
it("should handle null vs undefined values", () => {
|
|
81
|
-
const baseDoc = {
|
|
82
|
-
unispecVersion: "1.0.0",
|
|
83
|
-
service: {
|
|
84
|
-
name: "test-service",
|
|
85
|
-
description: undefined,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
const modifiedDoc = {
|
|
89
|
-
unispecVersion: "1.0.0",
|
|
90
|
-
service: {
|
|
91
|
-
name: "test-service",
|
|
92
|
-
description: "A description",
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
96
|
-
const descriptionChange = result.changes.find((change) => change.path === "/service/description");
|
|
97
|
-
assert.ok(descriptionChange);
|
|
98
|
-
assert.strictEqual(descriptionChange.description, "Value changed");
|
|
99
|
-
});
|
|
100
|
-
it("should handle empty objects and arrays", () => {
|
|
101
|
-
const baseDoc = {
|
|
102
|
-
unispecVersion: "1.0.0",
|
|
103
|
-
service: {
|
|
104
|
-
name: "test-service",
|
|
105
|
-
protocols: {
|
|
106
|
-
rest: {
|
|
107
|
-
routes: [],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
const modifiedDoc = {
|
|
113
|
-
unispecVersion: "1.0.0",
|
|
114
|
-
service: {
|
|
115
|
-
name: "test-service",
|
|
116
|
-
protocols: {
|
|
117
|
-
rest: {
|
|
118
|
-
routes: [
|
|
119
|
-
{
|
|
120
|
-
name: "newRoute",
|
|
121
|
-
method: "GET",
|
|
122
|
-
path: "/test",
|
|
123
|
-
responses: { 200: { description: "OK" } },
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
131
|
-
const routeChange = result.changes.find((change) => change.path === "/service/protocols/rest/routes/newRoute");
|
|
132
|
-
assert.ok(routeChange);
|
|
133
|
-
assert.strictEqual(routeChange.description, "Item added");
|
|
134
|
-
assert.strictEqual(routeChange.protocol, "rest");
|
|
135
|
-
});
|
|
136
|
-
it("should handle deeply nested structures", () => {
|
|
137
|
-
const baseDoc = {
|
|
138
|
-
unispecVersion: "1.0.0",
|
|
139
|
-
service: {
|
|
140
|
-
name: "test-service",
|
|
141
|
-
metadata: {
|
|
142
|
-
tags: [{ name: "api", version: "1.0" }],
|
|
143
|
-
info: {
|
|
144
|
-
contact: {
|
|
145
|
-
email: "test@example.com",
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
152
|
-
modifiedDoc.service.metadata.tags[0].version = "2.0";
|
|
153
|
-
modifiedDoc.service.metadata.info.contact.phone = "+1234567890";
|
|
154
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
155
|
-
const versionChange = result.changes.find((change) => change.path === "/service/metadata/tags/0/version");
|
|
156
|
-
assert.ok(versionChange);
|
|
157
|
-
assert.strictEqual(versionChange.description, "Value changed");
|
|
158
|
-
const phoneChange = result.changes.find((change) => change.path === "/service/metadata/info/contact/phone");
|
|
159
|
-
assert.ok(phoneChange);
|
|
160
|
-
assert.strictEqual(phoneChange.description, "Field added");
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
describe("array handling", () => {
|
|
164
|
-
it("should handle regular arrays (non-named collections)", () => {
|
|
165
|
-
const baseDoc = {
|
|
166
|
-
unispecVersion: "1.0.0",
|
|
167
|
-
service: {
|
|
168
|
-
name: "test-service",
|
|
169
|
-
tags: ["api", "v1"],
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
173
|
-
modifiedDoc.service.tags = ["api", "v2", "production"];
|
|
174
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
175
|
-
// Should detect changes at index level for regular arrays
|
|
176
|
-
const indexChange = result.changes.find((change) => change.path === "/service/tags/1");
|
|
177
|
-
assert.ok(indexChange);
|
|
178
|
-
assert.strictEqual(indexChange.description, "Value changed");
|
|
179
|
-
const addedChange = result.changes.find((change) => change.path === "/service/tags/2");
|
|
180
|
-
assert.ok(addedChange);
|
|
181
|
-
assert.strictEqual(addedChange.description, "Item added");
|
|
182
|
-
});
|
|
183
|
-
it("should handle arrays without name property", () => {
|
|
184
|
-
const baseDoc = {
|
|
185
|
-
unispecVersion: "1.0.0",
|
|
186
|
-
service: {
|
|
187
|
-
name: "test-service",
|
|
188
|
-
items: [
|
|
189
|
-
{ id: 1, value: "first" },
|
|
190
|
-
{ id: 2, value: "second" },
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
195
|
-
modifiedDoc.service.items[0].value = "updated";
|
|
196
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
197
|
-
// Should use index-based comparison for arrays without name property
|
|
198
|
-
const itemChange = result.changes.find((change) => change.path === "/service/items/0/value");
|
|
199
|
-
assert.ok(itemChange);
|
|
200
|
-
assert.strictEqual(itemChange.description, "Value changed");
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
describe("protocol-specific behavior", () => {
|
|
204
|
-
it("should handle WebSocket messages correctly", () => {
|
|
205
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "websocket-simple.json"));
|
|
206
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
207
|
-
// Add message to existing channel
|
|
208
|
-
if (modifiedDoc.service.protocols.websocket.channels[0]) {
|
|
209
|
-
modifiedDoc.service.protocols.websocket.channels[0].messages.push({
|
|
210
|
-
name: "newMessage",
|
|
211
|
-
description: "New message type",
|
|
212
|
-
direction: "publish",
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
216
|
-
const messageChange = result.changes.find((change) => change.path.includes("newMessage") && change.protocol === "websocket");
|
|
217
|
-
assert.ok(messageChange);
|
|
218
|
-
});
|
|
219
|
-
it("should handle GraphQL schema changes", () => {
|
|
220
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
221
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
222
|
-
// Change schema string
|
|
223
|
-
modifiedDoc.service.protocols.graphql.schema = `${baseDoc.service.protocols?.graphql?.schema} type NewType { field: String! }`;
|
|
224
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
225
|
-
const schemaChange = result.changes.find((change) => change.path === "/service/protocols/graphql/schema");
|
|
226
|
-
assert.ok(schemaChange);
|
|
227
|
-
assert.strictEqual(schemaChange.description, "Value changed");
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { describe, it } from "node:test";
|
|
4
|
-
import { examplesDir, loadExample } from "../../tests/utils.js";
|
|
5
|
-
import { diffUniSpec } from "../../src/diff/core.js";
|
|
6
|
-
describe("diff module", () => {
|
|
7
|
-
describe("diffUniSpec", () => {
|
|
8
|
-
it("should detect no changes in identical documents", () => {
|
|
9
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
10
|
-
const result = diffUniSpec(doc, doc);
|
|
11
|
-
assert.strictEqual(result.changes.length, 0);
|
|
12
|
-
});
|
|
13
|
-
it("should detect added fields", () => {
|
|
14
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
15
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
16
|
-
// Add a new field that doesn't exist
|
|
17
|
-
modifiedDoc.service.contact = {
|
|
18
|
-
name: "API Support",
|
|
19
|
-
email: "support@example.com",
|
|
20
|
-
};
|
|
21
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
22
|
-
const contactChange = result.changes.find((change) => change.path === "/service/contact");
|
|
23
|
-
assert.ok(contactChange);
|
|
24
|
-
assert.strictEqual(contactChange.description, "Field added");
|
|
25
|
-
assert.strictEqual(contactChange.severity, "unknown");
|
|
26
|
-
});
|
|
27
|
-
it("should detect removed fields", () => {
|
|
28
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
29
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
30
|
-
// Remove a field
|
|
31
|
-
delete modifiedDoc.service.description;
|
|
32
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
33
|
-
const descriptionChange = result.changes.find((change) => change.path === "/service/description");
|
|
34
|
-
assert.ok(descriptionChange);
|
|
35
|
-
assert.strictEqual(descriptionChange.description, "Field removed");
|
|
36
|
-
assert.strictEqual(descriptionChange.severity, "unknown");
|
|
37
|
-
});
|
|
38
|
-
it("should detect changed values", () => {
|
|
39
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
40
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
41
|
-
// Change a value
|
|
42
|
-
modifiedDoc.service.description = "Updated description";
|
|
43
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
44
|
-
const descriptionChange = result.changes.find((change) => change.path === "/service/description");
|
|
45
|
-
assert.ok(descriptionChange);
|
|
46
|
-
assert.strictEqual(descriptionChange.description, "Value changed");
|
|
47
|
-
assert.strictEqual(descriptionChange.severity, "unknown");
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe("named collections handling", () => {
|
|
51
|
-
it("should detect added routes by name", () => {
|
|
52
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
53
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
54
|
-
// Add a new route
|
|
55
|
-
modifiedDoc.service.protocols.rest.routes.push({
|
|
56
|
-
name: "updateUser",
|
|
57
|
-
summary: "Update user",
|
|
58
|
-
path: "/users/{id}",
|
|
59
|
-
method: "PUT",
|
|
60
|
-
responses: {
|
|
61
|
-
200: {
|
|
62
|
-
description: "User updated successfully",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
67
|
-
const routeChange = result.changes.find((change) => change.path === "/service/protocols/rest/routes/updateUser");
|
|
68
|
-
assert.ok(routeChange);
|
|
69
|
-
assert.strictEqual(routeChange.description, "Item added");
|
|
70
|
-
assert.strictEqual(routeChange.severity, "non-breaking");
|
|
71
|
-
assert.strictEqual(routeChange.protocol, "rest");
|
|
72
|
-
assert.strictEqual(routeChange.kind, "rest.route.added");
|
|
73
|
-
});
|
|
74
|
-
it("should detect removed routes by name", () => {
|
|
75
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
76
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
77
|
-
// Remove a route
|
|
78
|
-
modifiedDoc.service.protocols.rest.routes =
|
|
79
|
-
modifiedDoc.service.protocols.rest.routes.filter((route) => route.name !== "createUser");
|
|
80
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
81
|
-
const routeChange = result.changes.find((change) => change.path === "/service/protocols/rest/routes/createUser");
|
|
82
|
-
assert.ok(routeChange);
|
|
83
|
-
assert.strictEqual(routeChange.description, "Item removed");
|
|
84
|
-
assert.strictEqual(routeChange.severity, "breaking");
|
|
85
|
-
assert.strictEqual(routeChange.protocol, "rest");
|
|
86
|
-
assert.strictEqual(routeChange.kind, "rest.route.removed");
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
describe("GraphQL protocol handling", () => {
|
|
90
|
-
it("should detect added queries", () => {
|
|
91
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
92
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
93
|
-
// Add a new query
|
|
94
|
-
modifiedDoc.service.protocols.graphql.queries.push({
|
|
95
|
-
name: "posts",
|
|
96
|
-
description: "Get all posts",
|
|
97
|
-
args: [],
|
|
98
|
-
returnType: "[Post!]!",
|
|
99
|
-
});
|
|
100
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
101
|
-
const queryChange = result.changes.find((change) => change.path === "/service/protocols/graphql/queries/posts");
|
|
102
|
-
assert.ok(queryChange);
|
|
103
|
-
assert.strictEqual(queryChange.description, "Item added");
|
|
104
|
-
assert.strictEqual(queryChange.protocol, "graphql");
|
|
105
|
-
});
|
|
106
|
-
it("should detect removed mutations", () => {
|
|
107
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
108
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
109
|
-
// Remove a mutation
|
|
110
|
-
modifiedDoc.service.protocols.graphql.mutations = [];
|
|
111
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
112
|
-
const mutationChange = result.changes.find((change) => change.path === "/service/protocols/graphql/mutations/createPost");
|
|
113
|
-
assert.ok(mutationChange);
|
|
114
|
-
assert.strictEqual(mutationChange.description, "Item removed");
|
|
115
|
-
assert.strictEqual(mutationChange.protocol, "graphql");
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe("WebSocket protocol handling", () => {
|
|
119
|
-
it("should detect added channels", () => {
|
|
120
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "websocket-simple.json"));
|
|
121
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
122
|
-
// Add a new channel
|
|
123
|
-
modifiedDoc.service.protocols.websocket.channels.push({
|
|
124
|
-
name: "notifications",
|
|
125
|
-
description: "Real-time notifications",
|
|
126
|
-
messages: [
|
|
127
|
-
{
|
|
128
|
-
name: "notification",
|
|
129
|
-
description: "Notification message",
|
|
130
|
-
direction: "subscribe",
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
});
|
|
134
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
135
|
-
const channelChange = result.changes.find((change) => change.path === "/service/protocols/websocket/channels/notifications");
|
|
136
|
-
assert.ok(channelChange);
|
|
137
|
-
assert.strictEqual(channelChange.description, "Item added");
|
|
138
|
-
assert.strictEqual(channelChange.protocol, "websocket");
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe("deep comparison options", () => {
|
|
142
|
-
it("should respect deepComparison: false option", () => {
|
|
143
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
144
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
145
|
-
// Change nested value in a named collection (route)
|
|
146
|
-
modifiedDoc.service.protocols.rest.routes[0].summary = "Updated summary";
|
|
147
|
-
const result = diffUniSpec(baseDoc, modifiedDoc, {
|
|
148
|
-
deepComparison: false,
|
|
149
|
-
});
|
|
150
|
-
// With deepComparison: false, named collections don't do deep comparison
|
|
151
|
-
// Since the route name stays the same, no changes are detected
|
|
152
|
-
assert.strictEqual(result.changes.length, 0);
|
|
153
|
-
});
|
|
154
|
-
it("should perform deep comparison by default", () => {
|
|
155
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
156
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
157
|
-
// Change nested value
|
|
158
|
-
modifiedDoc.service.protocols.rest.routes[0].summary = "Updated summary";
|
|
159
|
-
const result = diffUniSpec(baseDoc, modifiedDoc);
|
|
160
|
-
// With deep comparison, the specific field should be marked as changed
|
|
161
|
-
const summaryChange = result.changes.find((change) => change.path === "/service/protocols/rest/routes/getUsers/summary");
|
|
162
|
-
assert.ok(summaryChange);
|
|
163
|
-
assert.strictEqual(summaryChange.description, "Value changed");
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
describe("custom named collection paths", () => {
|
|
167
|
-
it("should respect custom namedCollectionPaths", () => {
|
|
168
|
-
const baseDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
169
|
-
const modifiedDoc = JSON.parse(JSON.stringify(baseDoc));
|
|
170
|
-
// Add custom data to test
|
|
171
|
-
modifiedDoc.service.customItems = [
|
|
172
|
-
{ name: "item1", value: "value1" },
|
|
173
|
-
{ name: "item2", value: "value2" },
|
|
174
|
-
];
|
|
175
|
-
const result = diffUniSpec(baseDoc, modifiedDoc, {
|
|
176
|
-
namedCollectionPaths: ["/service/customItems"],
|
|
177
|
-
});
|
|
178
|
-
// Should detect the customItems field as added
|
|
179
|
-
const customItemsChange = result.changes.find((change) => change.path === "/service/customItems");
|
|
180
|
-
assert.ok(customItemsChange);
|
|
181
|
-
assert.strictEqual(customItemsChange.description, "Field added");
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|
package/dist/tests/diff/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { ErrorFactory } from "../../src/errors/index.js";
|
|
4
|
-
import { validateUniSpec } from "../../src/validator/index.js";
|
|
5
|
-
import { getExamplePath, loadExample, loadInvalidExample } from "./utils.js";
|
|
6
|
-
describe("errors module integration", () => {
|
|
7
|
-
describe("with validator module", () => {
|
|
8
|
-
it("should handle validation errors from valid specs", async () => {
|
|
9
|
-
const validDoc = loadExample(getExamplePath("valid", "spec", "rest-simple.json"));
|
|
10
|
-
const result = await validateUniSpec(validDoc);
|
|
11
|
-
assert.ok(result.valid);
|
|
12
|
-
assert.strictEqual(result.errors.length, 0);
|
|
13
|
-
});
|
|
14
|
-
it("should create appropriate errors for invalid specs", async () => {
|
|
15
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
16
|
-
const result = await validateUniSpec(invalidDoc);
|
|
17
|
-
assert.ok(!result.valid);
|
|
18
|
-
assert.ok(result.errors.length > 0);
|
|
19
|
-
// Check that errors have proper structure
|
|
20
|
-
for (const error of result.errors) {
|
|
21
|
-
assert.ok(error.message);
|
|
22
|
-
assert.ok(error.code);
|
|
23
|
-
assert.ok(error.path);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
it("should handle schema validation errors", async () => {
|
|
27
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-unispec-version.json"));
|
|
28
|
-
const _result = await validateUniSpec(invalidDoc);
|
|
29
|
-
// Note: This document might be considered valid without unispecVersion
|
|
30
|
-
// Let's test with a document that actually has schema errors
|
|
31
|
-
const invalidDoc2 = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
32
|
-
const result2 = await validateUniSpec(invalidDoc2);
|
|
33
|
-
assert.ok(!result2.valid);
|
|
34
|
-
// Should have schema errors
|
|
35
|
-
const schemaErrors = result2.errors.filter((e) => e.code === "schema_error");
|
|
36
|
-
assert.ok(schemaErrors.length > 0);
|
|
37
|
-
// Verify error structure
|
|
38
|
-
const schemaError = schemaErrors[0];
|
|
39
|
-
assert.strictEqual(schemaError.code, "schema_error");
|
|
40
|
-
assert.ok(schemaError.path);
|
|
41
|
-
assert.ok(schemaError.message);
|
|
42
|
-
});
|
|
43
|
-
it("should handle semantic validation errors", async () => {
|
|
44
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "invalid-rest-method.json"));
|
|
45
|
-
const result = await validateUniSpec(invalidDoc);
|
|
46
|
-
assert.ok(!result.valid);
|
|
47
|
-
// Should have schema errors (invalid REST method is caught by schema validation)
|
|
48
|
-
const schemaErrors = result.errors.filter((e) => e.code === "schema_error");
|
|
49
|
-
assert.ok(schemaErrors.length > 0);
|
|
50
|
-
// Verify error structure
|
|
51
|
-
const schemaError = schemaErrors[0];
|
|
52
|
-
assert.strictEqual(schemaError.code, "schema_error");
|
|
53
|
-
assert.ok(schemaError.path?.includes("method"));
|
|
54
|
-
assert.ok(schemaError.message);
|
|
55
|
-
});
|
|
56
|
-
it("should handle config validation errors", async () => {
|
|
57
|
-
const invalidConfig = loadInvalidExample(getExamplePath("invalid", "config", "missing-version.json"));
|
|
58
|
-
const result = await validateUniSpec(invalidConfig);
|
|
59
|
-
assert.ok(!result.valid);
|
|
60
|
-
// Should have schema errors for config validation
|
|
61
|
-
const configErrors = result.errors.filter((e) => e.code === "schema_error");
|
|
62
|
-
assert.ok(configErrors.length > 0);
|
|
63
|
-
// Verify error structure
|
|
64
|
-
const configError = configErrors[0];
|
|
65
|
-
assert.strictEqual(configError.code, "schema_error");
|
|
66
|
-
assert.ok(configError.path);
|
|
67
|
-
assert.ok(configError.message);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("error conversion and handling", () => {
|
|
71
|
-
it("should convert AJV errors to UniSpecValidationErrors", async () => {
|
|
72
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
73
|
-
const result = await validateUniSpec(invalidDoc);
|
|
74
|
-
assert.ok(!result.valid);
|
|
75
|
-
// All errors should be ValidationError type
|
|
76
|
-
for (const error of result.errors) {
|
|
77
|
-
assert.ok(error.message);
|
|
78
|
-
assert.ok(error.code);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
it("should handle error factory with validation context", async () => {
|
|
82
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "invalid-identifier.json"));
|
|
83
|
-
const result = await validateUniSpec(invalidDoc);
|
|
84
|
-
assert.ok(!result.valid);
|
|
85
|
-
// Create custom error based on validation result
|
|
86
|
-
if (result.errors.length > 0) {
|
|
87
|
-
const customError = ErrorFactory.createSemanticError("Custom semantic error based on validation", result.errors[0].path || "", { originalErrors: result.errors.map((e) => e.message) });
|
|
88
|
-
assert.ok(customError instanceof Error);
|
|
89
|
-
assert.strictEqual(customError.code, "semantic_error");
|
|
90
|
-
assert.ok(customError.details?.originalErrors);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
it("should preserve error details through validation chain", async () => {
|
|
94
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "graphql-missing-arg-type.json"));
|
|
95
|
-
const result = await validateUniSpec(invalidDoc);
|
|
96
|
-
assert.ok(!result.valid);
|
|
97
|
-
// Find GraphQL-related errors
|
|
98
|
-
const graphqlErrors = result.errors.filter((e) => e.path?.includes("graphql") ||
|
|
99
|
-
e.message.toLowerCase().includes("graphql"));
|
|
100
|
-
if (graphqlErrors.length > 0) {
|
|
101
|
-
const error = graphqlErrors[0];
|
|
102
|
-
// Error should have proper structure
|
|
103
|
-
assert.ok(error.message);
|
|
104
|
-
assert.ok(error.code);
|
|
105
|
-
assert.ok(error.path);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
describe("error severity levels", () => {
|
|
110
|
-
it("should handle different severity levels in validation", async () => {
|
|
111
|
-
// Test with a document that might have different severity levels
|
|
112
|
-
const validDoc = loadExample(getExamplePath("valid", "spec", "mixed-complete.json"));
|
|
113
|
-
const result = await validateUniSpec(validDoc);
|
|
114
|
-
// Valid document should have no errors
|
|
115
|
-
if (result.errors.length > 0) {
|
|
116
|
-
// All errors should have proper structure
|
|
117
|
-
for (const error of result.errors) {
|
|
118
|
-
assert.ok(error.message);
|
|
119
|
-
assert.ok(error.code);
|
|
120
|
-
assert.ok(typeof error.path === "string");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
it("should properly classify error types", async () => {
|
|
125
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
126
|
-
const result = await validateUniSpec(invalidDoc);
|
|
127
|
-
assert.ok(!result.valid);
|
|
128
|
-
// Check that errors are properly classified
|
|
129
|
-
const errorCodes = result.errors.map((e) => e.code);
|
|
130
|
-
const expectedCodes = [
|
|
131
|
-
"schema_error",
|
|
132
|
-
"semantic_error",
|
|
133
|
-
"reference_error",
|
|
134
|
-
];
|
|
135
|
-
// At least one of the expected error codes should be present
|
|
136
|
-
const hasExpectedCode = expectedCodes.some((code) => errorCodes.includes(code));
|
|
137
|
-
assert.ok(hasExpectedCode, `Expected one of ${expectedCodes}, got ${errorCodes}`);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe("complex error scenarios", () => {
|
|
141
|
-
it("should handle multiple errors in single document", async () => {
|
|
142
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
143
|
-
const result = await validateUniSpec(invalidDoc);
|
|
144
|
-
assert.ok(!result.valid);
|
|
145
|
-
// Should potentially have multiple errors
|
|
146
|
-
if (result.errors.length > 1) {
|
|
147
|
-
// Check that each error has unique path or code
|
|
148
|
-
const uniquePaths = new Set(result.errors.map((e) => e.path));
|
|
149
|
-
const uniqueCodes = new Set(result.errors.map((e) => e.code));
|
|
150
|
-
// Should have some diversity in errors
|
|
151
|
-
assert.ok(uniquePaths.size > 0 || uniqueCodes.size > 0);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
it("should handle nested error paths", async () => {
|
|
155
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "invalid-rest-method.json"));
|
|
156
|
-
const result = await validateUniSpec(invalidDoc);
|
|
157
|
-
assert.ok(!result.valid);
|
|
158
|
-
// Should have errors with nested paths
|
|
159
|
-
const nestedErrors = result.errors.filter((e) => e.path?.includes("/"));
|
|
160
|
-
assert.ok(nestedErrors.length > 0);
|
|
161
|
-
// Paths should be properly formatted
|
|
162
|
-
for (const error of nestedErrors) {
|
|
163
|
-
assert.ok(error.path?.includes("/service/"));
|
|
164
|
-
assert.ok(!error.path?.endsWith("."));
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|