@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,275 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { createTestChange } from "../../tests/utils.js";
|
|
4
|
-
import { annotateGraphQLChange, annotateRestChange, annotateWebSocketChange, } from "../../src/diff/annotators.js";
|
|
5
|
-
describe("diff annotators", () => {
|
|
6
|
-
describe("annotateRestChange", () => {
|
|
7
|
-
it("should annotate REST route additions as non-breaking", () => {
|
|
8
|
-
const change = createTestChange({
|
|
9
|
-
path: "/service/protocols/rest/routes/newRoute",
|
|
10
|
-
description: "Item added",
|
|
11
|
-
});
|
|
12
|
-
const result = annotateRestChange(change);
|
|
13
|
-
assert.strictEqual(result.protocol, "rest");
|
|
14
|
-
assert.strictEqual(result.kind, "rest.route.added");
|
|
15
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
16
|
-
});
|
|
17
|
-
it("should annotate REST route removals as breaking", () => {
|
|
18
|
-
const change = createTestChange({
|
|
19
|
-
path: "/service/protocols/rest/routes/removedRoute",
|
|
20
|
-
description: "Item removed",
|
|
21
|
-
});
|
|
22
|
-
const result = annotateRestChange(change);
|
|
23
|
-
assert.strictEqual(result.protocol, "rest");
|
|
24
|
-
assert.strictEqual(result.kind, "rest.route.removed");
|
|
25
|
-
assert.strictEqual(result.severity, "breaking");
|
|
26
|
-
});
|
|
27
|
-
it("should annotate required field changes as breaking", () => {
|
|
28
|
-
const change = createTestChange({
|
|
29
|
-
path: "/service/protocols/rest/routes/myRoute/requestBody/required",
|
|
30
|
-
description: "Value changed",
|
|
31
|
-
});
|
|
32
|
-
const result = annotateRestChange(change);
|
|
33
|
-
assert.strictEqual(result.protocol, "rest");
|
|
34
|
-
assert.strictEqual(result.kind, "rest.parameter.required_changed");
|
|
35
|
-
assert.strictEqual(result.severity, "breaking");
|
|
36
|
-
});
|
|
37
|
-
it("should not annotate non-REST changes", () => {
|
|
38
|
-
const change = createTestChange({
|
|
39
|
-
path: "/service/protocols/graphql/queries/myQuery",
|
|
40
|
-
description: "Item added",
|
|
41
|
-
});
|
|
42
|
-
const result = annotateRestChange(change);
|
|
43
|
-
assert.strictEqual(result.protocol, undefined);
|
|
44
|
-
assert.strictEqual(result.kind, undefined);
|
|
45
|
-
assert.strictEqual(result.severity, "unknown");
|
|
46
|
-
});
|
|
47
|
-
it("should handle malformed REST paths gracefully", () => {
|
|
48
|
-
const change = createTestChange({
|
|
49
|
-
path: "/service/protocols/rest", // Missing routes segment
|
|
50
|
-
description: "Item added",
|
|
51
|
-
});
|
|
52
|
-
const result = annotateRestChange(change);
|
|
53
|
-
assert.strictEqual(result.protocol, undefined);
|
|
54
|
-
assert.strictEqual(result.kind, undefined);
|
|
55
|
-
assert.strictEqual(result.severity, "unknown");
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe("annotateGraphQLChange", () => {
|
|
59
|
-
it("should annotate GraphQL query additions as non-breaking", () => {
|
|
60
|
-
const change = createTestChange({
|
|
61
|
-
path: "/service/protocols/graphql/queries/newQuery",
|
|
62
|
-
description: "Item added",
|
|
63
|
-
});
|
|
64
|
-
const result = annotateGraphQLChange(change);
|
|
65
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
66
|
-
assert.strictEqual(result.kind, "graphql.query.added");
|
|
67
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
68
|
-
});
|
|
69
|
-
it("should annotate GraphQL query removals as breaking", () => {
|
|
70
|
-
const change = createTestChange({
|
|
71
|
-
path: "/service/protocols/graphql/queries/removedQuery",
|
|
72
|
-
description: "Item removed",
|
|
73
|
-
});
|
|
74
|
-
const result = annotateGraphQLChange(change);
|
|
75
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
76
|
-
assert.strictEqual(result.kind, "graphql.query.removed");
|
|
77
|
-
assert.strictEqual(result.severity, "breaking");
|
|
78
|
-
});
|
|
79
|
-
it("should annotate GraphQL mutation additions as non-breaking", () => {
|
|
80
|
-
const change = createTestChange({
|
|
81
|
-
path: "/service/protocols/graphql/mutations/newMutation",
|
|
82
|
-
description: "Item added",
|
|
83
|
-
});
|
|
84
|
-
const result = annotateGraphQLChange(change);
|
|
85
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
86
|
-
assert.strictEqual(result.kind, "graphql.mutation.added");
|
|
87
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
88
|
-
});
|
|
89
|
-
it("should annotate GraphQL mutation removals as breaking", () => {
|
|
90
|
-
const change = createTestChange({
|
|
91
|
-
path: "/service/protocols/graphql/mutations/removedMutation",
|
|
92
|
-
description: "Item removed",
|
|
93
|
-
});
|
|
94
|
-
const result = annotateGraphQLChange(change);
|
|
95
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
96
|
-
assert.strictEqual(result.kind, "graphql.mutation.removed");
|
|
97
|
-
assert.strictEqual(result.severity, "breaking");
|
|
98
|
-
});
|
|
99
|
-
it("should annotate GraphQL subscription additions as non-breaking", () => {
|
|
100
|
-
const change = createTestChange({
|
|
101
|
-
path: "/service/protocols/graphql/subscriptions/newSubscription",
|
|
102
|
-
description: "Item added",
|
|
103
|
-
});
|
|
104
|
-
const result = annotateGraphQLChange(change);
|
|
105
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
106
|
-
assert.strictEqual(result.kind, "graphql.subscription.added");
|
|
107
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
108
|
-
});
|
|
109
|
-
it("should annotate GraphQL subscription removals as breaking", () => {
|
|
110
|
-
const change = createTestChange({
|
|
111
|
-
path: "/service/protocols/graphql/subscriptions/removedSubscription",
|
|
112
|
-
description: "Item removed",
|
|
113
|
-
});
|
|
114
|
-
const result = annotateGraphQLChange(change);
|
|
115
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
116
|
-
assert.strictEqual(result.kind, "graphql.subscription.removed");
|
|
117
|
-
assert.strictEqual(result.severity, "breaking");
|
|
118
|
-
});
|
|
119
|
-
it("should not annotate non-GraphQL changes", () => {
|
|
120
|
-
const change = createTestChange({
|
|
121
|
-
path: "/service/protocols/rest/routes/myRoute",
|
|
122
|
-
description: "Item added",
|
|
123
|
-
});
|
|
124
|
-
const result = annotateGraphQLChange(change);
|
|
125
|
-
assert.strictEqual(result.protocol, undefined);
|
|
126
|
-
assert.strictEqual(result.kind, undefined);
|
|
127
|
-
assert.strictEqual(result.severity, "unknown");
|
|
128
|
-
});
|
|
129
|
-
it("should annotate GraphQL argument additions as non-breaking", () => {
|
|
130
|
-
const change = createTestChange({
|
|
131
|
-
path: "/service/protocols/graphql/queries/myQuery/args/newArg",
|
|
132
|
-
description: "Item added",
|
|
133
|
-
});
|
|
134
|
-
const result = annotateGraphQLChange(change);
|
|
135
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
136
|
-
assert.strictEqual(result.kind, "graphql.query.argument_added");
|
|
137
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
138
|
-
});
|
|
139
|
-
it("should annotate GraphQL argument removals as breaking", () => {
|
|
140
|
-
const change = createTestChange({
|
|
141
|
-
path: "/service/protocols/graphql/mutations/myMutation/args/oldArg",
|
|
142
|
-
description: "Item removed",
|
|
143
|
-
});
|
|
144
|
-
const result = annotateGraphQLChange(change);
|
|
145
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
146
|
-
assert.strictEqual(result.kind, "graphql.mutation.argument_removed");
|
|
147
|
-
assert.strictEqual(result.severity, "breaking");
|
|
148
|
-
});
|
|
149
|
-
it("should annotate GraphQL return type changes as breaking", () => {
|
|
150
|
-
const change = createTestChange({
|
|
151
|
-
path: "/service/protocols/graphql/subscriptions/mySubscription/returnType",
|
|
152
|
-
description: "Value changed",
|
|
153
|
-
});
|
|
154
|
-
const result = annotateGraphQLChange(change);
|
|
155
|
-
assert.strictEqual(result.protocol, "graphql");
|
|
156
|
-
assert.strictEqual(result.kind, "graphql.subscription.return_type_changed");
|
|
157
|
-
assert.strictEqual(result.severity, "breaking");
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
describe("annotateWebSocketChange", () => {
|
|
161
|
-
it("should annotate WebSocket channel additions as non-breaking", () => {
|
|
162
|
-
const change = createTestChange({
|
|
163
|
-
path: "/service/protocols/websocket/channels/newChannel",
|
|
164
|
-
description: "Item added",
|
|
165
|
-
});
|
|
166
|
-
const result = annotateWebSocketChange(change);
|
|
167
|
-
assert.strictEqual(result.protocol, "websocket");
|
|
168
|
-
assert.strictEqual(result.kind, "websocket.channel.added");
|
|
169
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
170
|
-
});
|
|
171
|
-
it("should annotate WebSocket channel removals as breaking", () => {
|
|
172
|
-
const change = createTestChange({
|
|
173
|
-
path: "/service/protocols/websocket/channels/removedChannel",
|
|
174
|
-
description: "Item removed",
|
|
175
|
-
});
|
|
176
|
-
const result = annotateWebSocketChange(change);
|
|
177
|
-
assert.strictEqual(result.protocol, "websocket");
|
|
178
|
-
assert.strictEqual(result.kind, "websocket.channel.removed");
|
|
179
|
-
assert.strictEqual(result.severity, "breaking");
|
|
180
|
-
});
|
|
181
|
-
it("should annotate WebSocket message additions as non-breaking", () => {
|
|
182
|
-
const change = createTestChange({
|
|
183
|
-
path: "/service/protocols/websocket/channels/myChannel/messages/newMessage",
|
|
184
|
-
description: "Item added",
|
|
185
|
-
});
|
|
186
|
-
const result = annotateWebSocketChange(change);
|
|
187
|
-
assert.strictEqual(result.protocol, "websocket");
|
|
188
|
-
assert.strictEqual(result.kind, "websocket.message.added");
|
|
189
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
190
|
-
});
|
|
191
|
-
it("should annotate WebSocket message removals as breaking", () => {
|
|
192
|
-
const change = createTestChange({
|
|
193
|
-
path: "/service/protocols/websocket/channels/myChannel/messages/removedMessage",
|
|
194
|
-
description: "Item removed",
|
|
195
|
-
});
|
|
196
|
-
const result = annotateWebSocketChange(change);
|
|
197
|
-
assert.strictEqual(result.protocol, "websocket");
|
|
198
|
-
assert.strictEqual(result.kind, "websocket.message.removed");
|
|
199
|
-
assert.strictEqual(result.severity, "breaking");
|
|
200
|
-
});
|
|
201
|
-
it("should not annotate non-WebSocket changes", () => {
|
|
202
|
-
const change = createTestChange({
|
|
203
|
-
path: "/service/protocols/rest/routes/myRoute",
|
|
204
|
-
description: "Item added",
|
|
205
|
-
});
|
|
206
|
-
const result = annotateWebSocketChange(change);
|
|
207
|
-
assert.strictEqual(result.protocol, undefined);
|
|
208
|
-
assert.strictEqual(result.kind, undefined);
|
|
209
|
-
assert.strictEqual(result.severity, "unknown");
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
describe("annotation chaining", () => {
|
|
213
|
-
it("should handle multiple annotations correctly", () => {
|
|
214
|
-
// This simulates what happens in diffUniSpec where changes are chained through all annotators
|
|
215
|
-
const restChange = createTestChange({
|
|
216
|
-
path: "/service/protocols/rest/routes/myRoute",
|
|
217
|
-
description: "Item added",
|
|
218
|
-
});
|
|
219
|
-
const result = annotateWebSocketChange(annotateGraphQLChange(annotateRestChange(restChange)));
|
|
220
|
-
// Should only have REST annotations since it's a REST path
|
|
221
|
-
assert.strictEqual(result.protocol, "rest");
|
|
222
|
-
assert.strictEqual(result.kind, "rest.route.added");
|
|
223
|
-
assert.strictEqual(result.severity, "non-breaking");
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe("edge cases", () => {
|
|
227
|
-
it("should handle empty paths", () => {
|
|
228
|
-
const change = createTestChange({
|
|
229
|
-
path: "",
|
|
230
|
-
description: "Item added",
|
|
231
|
-
});
|
|
232
|
-
const restResult = annotateRestChange(change);
|
|
233
|
-
const graphqlResult = annotateGraphQLChange(change);
|
|
234
|
-
const wsResult = annotateWebSocketChange(change);
|
|
235
|
-
// None should annotate empty path
|
|
236
|
-
assert.strictEqual(restResult.protocol, undefined);
|
|
237
|
-
assert.strictEqual(graphqlResult.protocol, undefined);
|
|
238
|
-
assert.strictEqual(wsResult.protocol, undefined);
|
|
239
|
-
});
|
|
240
|
-
it("should handle undefined paths gracefully", () => {
|
|
241
|
-
const changeWithUndefined = createTestChange({
|
|
242
|
-
path: undefined,
|
|
243
|
-
description: "Item added",
|
|
244
|
-
});
|
|
245
|
-
const restResultUndef = annotateRestChange(changeWithUndefined);
|
|
246
|
-
const graphqlResultUndef = annotateGraphQLChange(changeWithUndefined);
|
|
247
|
-
const wsResultUndef = annotateWebSocketChange(changeWithUndefined);
|
|
248
|
-
assert.strictEqual(restResultUndef.protocol, undefined);
|
|
249
|
-
assert.strictEqual(graphqlResultUndef.protocol, undefined);
|
|
250
|
-
assert.strictEqual(wsResultUndef.protocol, undefined);
|
|
251
|
-
});
|
|
252
|
-
it("should handle malformed paths gracefully", () => {
|
|
253
|
-
const malformedPaths = [
|
|
254
|
-
"/service/protocols", // Incomplete
|
|
255
|
-
"/service/protocols/rest/routes", // Missing route name
|
|
256
|
-
"/service/protocols/graphql", // Missing operation type
|
|
257
|
-
"invalid/path/format",
|
|
258
|
-
"service/protocols/rest/routes/route", // Missing leading slash
|
|
259
|
-
];
|
|
260
|
-
for (const path of malformedPaths) {
|
|
261
|
-
const change = createTestChange({
|
|
262
|
-
path,
|
|
263
|
-
description: "Item added",
|
|
264
|
-
});
|
|
265
|
-
const restResult = annotateRestChange(change);
|
|
266
|
-
const graphqlResult = annotateGraphQLChange(change);
|
|
267
|
-
const wsResult = annotateWebSocketChange(change);
|
|
268
|
-
// Should not crash and should not annotate malformed paths
|
|
269
|
-
assert.strictEqual(restResult.protocol, undefined);
|
|
270
|
-
assert.strictEqual(graphqlResult.protocol, undefined);
|
|
271
|
-
assert.strictEqual(wsResult.protocol, undefined);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,257 +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 - comprehensive schema examples", () => {
|
|
7
|
-
describe("valid spec examples", () => {
|
|
8
|
-
it("should handle rest-simple.json correctly", () => {
|
|
9
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
10
|
-
// Test self-comparison
|
|
11
|
-
const result = diffUniSpec(doc, doc);
|
|
12
|
-
assert.strictEqual(result.changes.length, 0);
|
|
13
|
-
// Test modifications
|
|
14
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
15
|
-
modified.service.protocols.rest.routes.push({
|
|
16
|
-
name: "newRoute",
|
|
17
|
-
method: "DELETE",
|
|
18
|
-
path: "/users/{id}",
|
|
19
|
-
responses: { 204: { description: "No content" } },
|
|
20
|
-
});
|
|
21
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
22
|
-
const newRoute = diffResult.changes.find((change) => change.path.includes("newRoute"));
|
|
23
|
-
assert.ok(newRoute);
|
|
24
|
-
assert.strictEqual(newRoute.protocol, "rest");
|
|
25
|
-
assert.strictEqual(newRoute.severity, "non-breaking");
|
|
26
|
-
});
|
|
27
|
-
it("should handle graphql-simple.json correctly", () => {
|
|
28
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
29
|
-
// Test self-comparison
|
|
30
|
-
const result = diffUniSpec(doc, doc);
|
|
31
|
-
assert.strictEqual(result.changes.length, 0);
|
|
32
|
-
// Test schema change
|
|
33
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
34
|
-
modified.service.protocols.graphql.schema +=
|
|
35
|
-
" type NewType { field: String! }";
|
|
36
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
37
|
-
const schemaChange = diffResult.changes.find((change) => change.path.includes("schema"));
|
|
38
|
-
assert.ok(schemaChange);
|
|
39
|
-
assert.strictEqual(schemaChange.description, "Value changed");
|
|
40
|
-
});
|
|
41
|
-
it("should handle websocket-simple.json correctly", () => {
|
|
42
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "websocket-simple.json"));
|
|
43
|
-
// Test self-comparison
|
|
44
|
-
const result = diffUniSpec(doc, doc);
|
|
45
|
-
assert.strictEqual(result.changes.length, 0);
|
|
46
|
-
// Test channel addition
|
|
47
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
48
|
-
modified.service.protocols.websocket.channels.push({
|
|
49
|
-
name: "newChannel",
|
|
50
|
-
description: "New channel",
|
|
51
|
-
messages: [],
|
|
52
|
-
});
|
|
53
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
54
|
-
const newChannel = diffResult.changes.find((change) => change.path.includes("newChannel"));
|
|
55
|
-
assert.ok(newChannel);
|
|
56
|
-
assert.strictEqual(newChannel.protocol, "websocket");
|
|
57
|
-
assert.strictEqual(newChannel.severity, "non-breaking");
|
|
58
|
-
});
|
|
59
|
-
it("should handle mixed-complete.json correctly", () => {
|
|
60
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "mixed-complete.json"));
|
|
61
|
-
// Test self-comparison
|
|
62
|
-
const result = diffUniSpec(doc, doc);
|
|
63
|
-
assert.strictEqual(result.changes.length, 0);
|
|
64
|
-
// Test multiple protocol changes
|
|
65
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
66
|
-
// Add REST route
|
|
67
|
-
if (modified.service.protocols.rest) {
|
|
68
|
-
modified.service.protocols.rest.routes.push({
|
|
69
|
-
name: "mixedRoute",
|
|
70
|
-
method: "PATCH",
|
|
71
|
-
path: "/mixed",
|
|
72
|
-
responses: { 200: { description: "OK" } },
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
// Add GraphQL query
|
|
76
|
-
if (modified.service.protocols.graphql?.queries) {
|
|
77
|
-
modified.service.protocols.graphql.queries.push({
|
|
78
|
-
name: "mixedQuery",
|
|
79
|
-
description: "Mixed query",
|
|
80
|
-
args: [],
|
|
81
|
-
returnType: "String",
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
85
|
-
// Should have both REST and GraphQL changes
|
|
86
|
-
const restChanges = diffResult.changes.filter((change) => change.protocol === "rest");
|
|
87
|
-
const graphqlChanges = diffResult.changes.filter((change) => change.protocol === "graphql");
|
|
88
|
-
assert.ok(restChanges.length > 0);
|
|
89
|
-
assert.ok(graphqlChanges.length > 0);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
describe("valid config examples", () => {
|
|
93
|
-
it("should handle complete-enterprise.json correctly", () => {
|
|
94
|
-
const doc = loadExample(path.join(examplesDir, "valid", "config", "complete-enterprise.json"));
|
|
95
|
-
// Test self-comparison
|
|
96
|
-
const result = diffUniSpec(doc, doc);
|
|
97
|
-
assert.strictEqual(result.changes.length, 0);
|
|
98
|
-
// Test modification
|
|
99
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
100
|
-
if (Array.isArray(modified.services)) {
|
|
101
|
-
modified.services.push({
|
|
102
|
-
name: "new-service",
|
|
103
|
-
baseUrl: "https://new-service.example.com",
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
107
|
-
assert.ok(diffResult.changes.length > 0);
|
|
108
|
-
});
|
|
109
|
-
it("should handle registry-based.json correctly", () => {
|
|
110
|
-
const doc = loadExample(path.join(examplesDir, "valid", "config", "registry-based.json"));
|
|
111
|
-
// Test self-comparison
|
|
112
|
-
const result = diffUniSpec(doc, doc);
|
|
113
|
-
assert.strictEqual(result.changes.length, 0);
|
|
114
|
-
});
|
|
115
|
-
it("should handle simple-multi-service.json correctly", () => {
|
|
116
|
-
const doc = loadExample(path.join(examplesDir, "valid", "config", "simple-multi-service.json"));
|
|
117
|
-
// Test self-comparison
|
|
118
|
-
const result = diffUniSpec(doc, doc);
|
|
119
|
-
assert.strictEqual(result.changes.length, 0);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
describe("invalid spec examples", () => {
|
|
123
|
-
it("should handle graphql-missing-arg-type.json without crashing", () => {
|
|
124
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "graphql-missing-arg-type.json"));
|
|
125
|
-
// Should not crash on invalid documents
|
|
126
|
-
const result = diffUniSpec(doc, doc);
|
|
127
|
-
assert.strictEqual(result.changes.length, 0);
|
|
128
|
-
// Should handle modifications
|
|
129
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
130
|
-
modified.unispecVersion = "1.0.1";
|
|
131
|
-
const diffResult = diffUniSpec(doc, modified);
|
|
132
|
-
const versionChange = diffResult.changes.find((change) => change.path === "/unispecVersion");
|
|
133
|
-
assert.ok(versionChange);
|
|
134
|
-
});
|
|
135
|
-
it("should handle graphql-missing-name.json without crashing", () => {
|
|
136
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "graphql-missing-name.json"));
|
|
137
|
-
const result = diffUniSpec(doc, doc);
|
|
138
|
-
assert.strictEqual(result.changes.length, 0);
|
|
139
|
-
});
|
|
140
|
-
it("should handle invalid-identifier.json without crashing", () => {
|
|
141
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "invalid-identifier.json"));
|
|
142
|
-
const result = diffUniSpec(doc, doc);
|
|
143
|
-
assert.strictEqual(result.changes.length, 0);
|
|
144
|
-
});
|
|
145
|
-
it("should handle invalid-rest-method.json without crashing", () => {
|
|
146
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "invalid-rest-method.json"));
|
|
147
|
-
const result = diffUniSpec(doc, doc);
|
|
148
|
-
assert.strictEqual(result.changes.length, 0);
|
|
149
|
-
});
|
|
150
|
-
it("should handle missing-service-name.json without crashing", () => {
|
|
151
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "missing-service-name.json"));
|
|
152
|
-
const result = diffUniSpec(doc, doc);
|
|
153
|
-
assert.strictEqual(result.changes.length, 0);
|
|
154
|
-
});
|
|
155
|
-
it("should handle missing-unispec-version.json without crashing", () => {
|
|
156
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "spec", "missing-unispec-version.json"));
|
|
157
|
-
const result = diffUniSpec(doc, doc);
|
|
158
|
-
assert.strictEqual(result.changes.length, 0);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe("invalid config examples", () => {
|
|
162
|
-
it("should handle empty-services-array.json without crashing", () => {
|
|
163
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "config", "empty-services-array.json"));
|
|
164
|
-
const result = diffUniSpec(doc, doc);
|
|
165
|
-
assert.strictEqual(result.changes.length, 0);
|
|
166
|
-
});
|
|
167
|
-
it("should handle invalid-spec-reference.json without crashing", () => {
|
|
168
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "config", "invalid-spec-reference.json"));
|
|
169
|
-
const result = diffUniSpec(doc, doc);
|
|
170
|
-
assert.strictEqual(result.changes.length, 0);
|
|
171
|
-
});
|
|
172
|
-
it("should handle missing-services.json without crashing", () => {
|
|
173
|
-
const doc = loadExample(path.join(examplesDir, "invalid", "config", "missing-services.json"));
|
|
174
|
-
const result = diffUniSpec(doc, doc);
|
|
175
|
-
assert.strictEqual(result.changes.length, 0);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
describe("cross-example comparisons", () => {
|
|
179
|
-
it("should handle comparing different valid specs", () => {
|
|
180
|
-
const restDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
181
|
-
const graphqlDoc = loadExample(path.join(examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
182
|
-
// Should detect many differences between different specs
|
|
183
|
-
const result = diffUniSpec(restDoc, graphqlDoc);
|
|
184
|
-
assert.ok(result.changes.length > 0);
|
|
185
|
-
// Most changes will be structural and not protocol-specific
|
|
186
|
-
// since the documents have completely different structures
|
|
187
|
-
const structuralChanges = result.changes.filter((change) => change.protocol === undefined);
|
|
188
|
-
// Should have some structural changes
|
|
189
|
-
assert.ok(structuralChanges.length > 0);
|
|
190
|
-
// May have some protocol-specific changes if paths overlap
|
|
191
|
-
const restChanges = result.changes.filter((change) => change.protocol === "rest");
|
|
192
|
-
const graphqlChanges = result.changes.filter((change) => change.protocol === "graphql");
|
|
193
|
-
// At least one of them should have changes
|
|
194
|
-
assert.ok(restChanges.length > 0 ||
|
|
195
|
-
graphqlChanges.length > 0 ||
|
|
196
|
-
structuralChanges.length > 0);
|
|
197
|
-
});
|
|
198
|
-
it("should handle comparing valid and invalid specs", () => {
|
|
199
|
-
const validDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
200
|
-
const invalidDoc = loadExample(path.join(examplesDir, "invalid", "spec", "missing-service-name.json"));
|
|
201
|
-
// Should handle comparisons without crashing
|
|
202
|
-
const result = diffUniSpec(validDoc, invalidDoc);
|
|
203
|
-
assert.ok(result.changes.length > 0);
|
|
204
|
-
});
|
|
205
|
-
it("should handle comparing config and spec files", () => {
|
|
206
|
-
const configDoc = loadExample(path.join(examplesDir, "valid", "config", "simple-multi-service.json"));
|
|
207
|
-
const specDoc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
208
|
-
// Should handle completely different structures
|
|
209
|
-
const result = diffUniSpec(configDoc, specDoc);
|
|
210
|
-
assert.ok(result.changes.length > 0);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
describe("edge cases with real examples", () => {
|
|
214
|
-
it("should handle deeply nested changes in complex examples", () => {
|
|
215
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "mixed-complete.json"));
|
|
216
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
217
|
-
// Make a deep nested change - find the first route with requestBody
|
|
218
|
-
if (modified.service?.protocols?.rest?.routes) {
|
|
219
|
-
const routeWithBody = modified.service.protocols.rest.routes.find((route) => route.requestBody?.content?.["application/json"]?.schemaRef);
|
|
220
|
-
if (routeWithBody) {
|
|
221
|
-
routeWithBody.requestBody.content["application/json"].schemaRef =
|
|
222
|
-
"NewSchemaRef";
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const result = diffUniSpec(doc, modified);
|
|
226
|
-
// Should have some changes
|
|
227
|
-
assert.ok(result.changes.length > 0);
|
|
228
|
-
// Look for any schema-related change
|
|
229
|
-
const schemaChange = result.changes.find((change) => change.path.includes("schemaRef"));
|
|
230
|
-
// If we found a route with schemaRef, it should be detected
|
|
231
|
-
if (doc.service?.protocols?.rest?.routes?.some((route) => route.requestBody?.content?.["application/json"]?.schemaRef)) {
|
|
232
|
-
assert.ok(schemaChange);
|
|
233
|
-
assert.strictEqual(schemaChange.description, "Value changed");
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
// If no route had schemaRef, we should still have some changes
|
|
237
|
-
assert.ok(result.changes.length > 0);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
it("should handle array operations in named collections correctly", () => {
|
|
241
|
-
const doc = loadExample(path.join(examplesDir, "valid", "spec", "rest-simple.json"));
|
|
242
|
-
const modified = JSON.parse(JSON.stringify(doc));
|
|
243
|
-
// Reorder routes array
|
|
244
|
-
if (modified.service.protocols.rest.routes.length >= 2) {
|
|
245
|
-
const temp = modified.service.protocols.rest.routes[0];
|
|
246
|
-
modified.service.protocols.rest.routes[0] =
|
|
247
|
-
modified.service.protocols.rest.routes[1];
|
|
248
|
-
modified.service.protocols.rest.routes[1] = temp;
|
|
249
|
-
}
|
|
250
|
-
const result = diffUniSpec(doc, modified);
|
|
251
|
-
// Named collections should compare by name, not index
|
|
252
|
-
// So reordering should not produce changes
|
|
253
|
-
const routeChanges = result.changes.filter((change) => change.path.includes("/routes/"));
|
|
254
|
-
assert.strictEqual(routeChanges.length, 0);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|