@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,366 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a markdown report from enhanced diff result.
|
|
3
|
-
*/
|
|
4
|
-
function generateMarkdownReport(diff, options) {
|
|
5
|
-
const lines = [];
|
|
6
|
-
// Title and metadata
|
|
7
|
-
lines.push(`# ${options.title || "UniSpec Changes Report"}`);
|
|
8
|
-
lines.push("");
|
|
9
|
-
if (options.versionInfo) {
|
|
10
|
-
lines.push("## Version Information");
|
|
11
|
-
if (options.versionInfo.oldVersion) {
|
|
12
|
-
lines.push(`- **From:** ${options.versionInfo.oldVersion}`);
|
|
13
|
-
}
|
|
14
|
-
if (options.versionInfo.newVersion) {
|
|
15
|
-
lines.push(`- **To:** ${options.versionInfo.newVersion}`);
|
|
16
|
-
}
|
|
17
|
-
if (options.versionInfo.comparisonDate) {
|
|
18
|
-
lines.push(`- **Date:** ${options.versionInfo.comparisonDate}`);
|
|
19
|
-
}
|
|
20
|
-
lines.push("");
|
|
21
|
-
}
|
|
22
|
-
// Executive summary
|
|
23
|
-
lines.push("## Executive Summary");
|
|
24
|
-
lines.push("");
|
|
25
|
-
lines.push(`- **Total Changes:** ${diff.summary.totalChanges}`);
|
|
26
|
-
lines.push(`- **Critical Changes:** ${diff.summary.criticalChanges}`);
|
|
27
|
-
lines.push(`- **High Risk Changes:** ${diff.summary.highRiskChanges}`);
|
|
28
|
-
lines.push(`- **Compatibility Score:** ${diff.metrics.overallCompatibility}%`);
|
|
29
|
-
lines.push(`- **Migration Effort:** ${diff.metrics.migrationEffort}`);
|
|
30
|
-
lines.push("");
|
|
31
|
-
// Compatibility metrics
|
|
32
|
-
lines.push("## Compatibility Metrics");
|
|
33
|
-
lines.push("");
|
|
34
|
-
lines.push("| Metric | Score | Status |");
|
|
35
|
-
lines.push("|--------|-------|--------|");
|
|
36
|
-
const overallStatus = diff.metrics.overallCompatibility >= 80
|
|
37
|
-
? "✅ Good"
|
|
38
|
-
: diff.metrics.overallCompatibility >= 60
|
|
39
|
-
? "⚠️ Moderate"
|
|
40
|
-
: "❌ Poor";
|
|
41
|
-
lines.push(`| Overall Compatibility | ${diff.metrics.overallCompatibility}% | ${overallStatus} |`);
|
|
42
|
-
const clientStatus = diff.metrics.clientCompatibilityScore >= 80
|
|
43
|
-
? "✅ Good"
|
|
44
|
-
: diff.metrics.clientCompatibilityScore >= 60
|
|
45
|
-
? "⚠️ Moderate"
|
|
46
|
-
: "❌ Poor";
|
|
47
|
-
lines.push(`| Client Compatibility | ${diff.metrics.clientCompatibilityScore}% | ${clientStatus} |`);
|
|
48
|
-
const serverStatus = diff.metrics.serverCompatibilityScore >= 80
|
|
49
|
-
? "✅ Good"
|
|
50
|
-
: diff.metrics.serverCompatibilityScore >= 60
|
|
51
|
-
? "⚠️ Moderate"
|
|
52
|
-
: "❌ Poor";
|
|
53
|
-
lines.push(`| Server Compatibility | ${diff.metrics.serverCompatibilityScore}% | ${serverStatus} |`);
|
|
54
|
-
lines.push("");
|
|
55
|
-
// Group changes
|
|
56
|
-
const groupedChanges = groupChanges(diff.changes, options);
|
|
57
|
-
for (const section of groupedChanges) {
|
|
58
|
-
lines.push(`## ${section.title}`);
|
|
59
|
-
lines.push("");
|
|
60
|
-
lines.push(section.summary);
|
|
61
|
-
lines.push("");
|
|
62
|
-
if (section.changes.length === 0) {
|
|
63
|
-
lines.push("No changes in this category.");
|
|
64
|
-
lines.push("");
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
for (const change of section.changes) {
|
|
68
|
-
lines.push(`### ${getChangeIcon(change.riskLevel)} ${getChangeTitle(change)}`);
|
|
69
|
-
lines.push("");
|
|
70
|
-
lines.push(`- **Path:** \`${change.path}\``);
|
|
71
|
-
lines.push(`- **Protocol:** ${change.protocol || "Unknown"}`);
|
|
72
|
-
lines.push(`- **Risk Level:** ${change.riskLevel.toUpperCase()}`);
|
|
73
|
-
lines.push(`- **Impact:** ${formatImpact(change.impact)}`);
|
|
74
|
-
lines.push("");
|
|
75
|
-
if (change.description) {
|
|
76
|
-
lines.push(`**Description:** ${change.description}`);
|
|
77
|
-
lines.push("");
|
|
78
|
-
}
|
|
79
|
-
if (options.includeSuggestions && change.suggestions.length > 0) {
|
|
80
|
-
lines.push("**Migration Suggestions:**");
|
|
81
|
-
for (const suggestion of change.suggestions) {
|
|
82
|
-
lines.push(`- ${suggestion}`);
|
|
83
|
-
}
|
|
84
|
-
lines.push("");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Migration recommendations
|
|
89
|
-
if (diff.summary.criticalChanges > 0 || diff.summary.highRiskChanges > 0) {
|
|
90
|
-
lines.push("## Migration Recommendations");
|
|
91
|
-
lines.push("");
|
|
92
|
-
if (diff.summary.criticalChanges > 0) {
|
|
93
|
-
lines.push("⚠️ **Critical Changes Detected**");
|
|
94
|
-
lines.push("");
|
|
95
|
-
lines.push("Immediate action required:");
|
|
96
|
-
lines.push("- Review all critical changes");
|
|
97
|
-
lines.push("- Plan migration strategy");
|
|
98
|
-
lines.push("- Communicate changes to all stakeholders");
|
|
99
|
-
lines.push("- Consider feature flags for gradual rollout");
|
|
100
|
-
lines.push("");
|
|
101
|
-
}
|
|
102
|
-
if (diff.metrics.migrationEffort === "major") {
|
|
103
|
-
lines.push("🔧 **Major Migration Effort**");
|
|
104
|
-
lines.push("");
|
|
105
|
-
lines.push("Recommended approach:");
|
|
106
|
-
lines.push("- Break migration into phases");
|
|
107
|
-
lines.push("- Use parallel development");
|
|
108
|
-
lines.push("- Implement comprehensive testing");
|
|
109
|
-
lines.push("- Provide detailed migration guides");
|
|
110
|
-
lines.push("");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return lines.join("\n");
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Generate an HTML report from enhanced diff result.
|
|
117
|
-
*/
|
|
118
|
-
function generateHtmlReport(diff, options) {
|
|
119
|
-
const styles = `
|
|
120
|
-
<style>
|
|
121
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 40px; }
|
|
122
|
-
.header { border-bottom: 2px solid #e1e5e9; padding-bottom: 20px; margin-bottom: 30px; }
|
|
123
|
-
.metric { display: inline-block; margin: 10px 20px 10px 0; text-align: center; }
|
|
124
|
-
.metric-value { font-size: 2em; font-weight: bold; display: block; }
|
|
125
|
-
.metric-label { color: #666; font-size: 0.9em; }
|
|
126
|
-
.critical { color: #dc3545; }
|
|
127
|
-
.high { color: #fd7e14; }
|
|
128
|
-
.medium { color: #ffc107; }
|
|
129
|
-
.low { color: #28a745; }
|
|
130
|
-
.change { border: 1px solid #e1e5e9; border-radius: 8px; padding: 20px; margin: 20px 0; }
|
|
131
|
-
.change-header { font-weight: bold; margin-bottom: 10px; }
|
|
132
|
-
.suggestions { background: #f8f9fa; padding: 15px; border-radius: 5px; margin-top: 10px; }
|
|
133
|
-
.compatibility-bar { height: 20px; background: #e9ecef; border-radius: 10px; overflow: hidden; margin: 10px 0; }
|
|
134
|
-
.compatibility-fill { height: 100%; transition: width 0.3s ease; }
|
|
135
|
-
</style>
|
|
136
|
-
`;
|
|
137
|
-
const groupedChanges = groupChanges(diff.changes, options);
|
|
138
|
-
let html = `
|
|
139
|
-
<!DOCTYPE html>
|
|
140
|
-
<html>
|
|
141
|
-
<head>
|
|
142
|
-
<title>${options.title || "UniSpec Changes Report"}</title>
|
|
143
|
-
${styles}
|
|
144
|
-
</head>
|
|
145
|
-
<body>
|
|
146
|
-
<div class="header">
|
|
147
|
-
<h1>${options.title || "UniSpec Changes Report"}</h1>
|
|
148
|
-
<p>Generated on ${new Date().toLocaleDateString()}</p>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
<div class="summary">
|
|
152
|
-
<h2>Executive Summary</h2>
|
|
153
|
-
<div class="metric">
|
|
154
|
-
<span class="metric-value">${diff.summary.totalChanges}</span>
|
|
155
|
-
<span class="metric-label">Total Changes</span>
|
|
156
|
-
</div>
|
|
157
|
-
<div class="metric">
|
|
158
|
-
<span class="metric-value critical">${diff.summary.criticalChanges}</span>
|
|
159
|
-
<span class="metric-label">Critical</span>
|
|
160
|
-
</div>
|
|
161
|
-
<div class="metric">
|
|
162
|
-
<span class="metric-value high">${diff.summary.highRiskChanges}</span>
|
|
163
|
-
<span class="metric-label">High Risk</span>
|
|
164
|
-
</div>
|
|
165
|
-
<div class="metric">
|
|
166
|
-
<span class="metric-value">${diff.metrics.overallCompatibility}%</span>
|
|
167
|
-
<span class="metric-label">Compatibility</span>
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
<div class="compatibility">
|
|
172
|
-
<h2>Compatibility Metrics</h2>
|
|
173
|
-
<div>
|
|
174
|
-
<strong>Overall Compatibility: ${diff.metrics.overallCompatibility}%</strong>
|
|
175
|
-
<div class="compatibility-bar">
|
|
176
|
-
<div class="compatibility-fill ${getCompatibilityClass(diff.metrics.overallCompatibility)}"
|
|
177
|
-
style="width: ${diff.metrics.overallCompatibility}%"></div>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
<div>
|
|
181
|
-
<strong>Client Compatibility: ${diff.metrics.clientCompatibilityScore}%</strong>
|
|
182
|
-
<div class="compatibility-bar">
|
|
183
|
-
<div class="compatibility-fill ${getCompatibilityClass(diff.metrics.clientCompatibilityScore)}"
|
|
184
|
-
style="width: ${diff.metrics.clientCompatibilityScore}%"></div>
|
|
185
|
-
</div>
|
|
186
|
-
</div>
|
|
187
|
-
<div>
|
|
188
|
-
<strong>Server Compatibility: ${diff.metrics.serverCompatibilityScore}%</strong>
|
|
189
|
-
<div class="compatibility-bar">
|
|
190
|
-
<div class="compatibility-fill ${getCompatibilityClass(diff.metrics.serverCompatibilityScore)}"
|
|
191
|
-
style="width: ${diff.metrics.serverCompatibilityScore}%"></div>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
`;
|
|
196
|
-
for (const section of groupedChanges) {
|
|
197
|
-
html += `
|
|
198
|
-
<div class="section">
|
|
199
|
-
<h2>${section.title}</h2>
|
|
200
|
-
<p>${section.summary}</p>
|
|
201
|
-
`;
|
|
202
|
-
for (const change of section.changes) {
|
|
203
|
-
html += `
|
|
204
|
-
<div class="change ${change.riskLevel}">
|
|
205
|
-
<div class="change-header">
|
|
206
|
-
${getChangeIcon(change.riskLevel)} ${getChangeTitle(change)}
|
|
207
|
-
</div>
|
|
208
|
-
<p><strong>Path:</strong> <code>${change.path}</code></p>
|
|
209
|
-
<p><strong>Protocol:</strong> ${change.protocol || "Unknown"}</p>
|
|
210
|
-
<p><strong>Risk Level:</strong> <span class="${change.riskLevel}">${change.riskLevel.toUpperCase()}</span></p>
|
|
211
|
-
<p><strong>Description:</strong> ${change.description}</p>
|
|
212
|
-
<p><strong>Impact:</strong> ${formatImpact(change.impact)}</p>
|
|
213
|
-
`;
|
|
214
|
-
if (options.includeSuggestions && change.suggestions.length > 0) {
|
|
215
|
-
html += `
|
|
216
|
-
<div class="suggestions">
|
|
217
|
-
<strong>Migration Suggestions:</strong>
|
|
218
|
-
<ul>
|
|
219
|
-
`;
|
|
220
|
-
for (const suggestion of change.suggestions) {
|
|
221
|
-
html += `<li>${suggestion}</li>`;
|
|
222
|
-
}
|
|
223
|
-
html += `
|
|
224
|
-
</ul>
|
|
225
|
-
</div>
|
|
226
|
-
`;
|
|
227
|
-
}
|
|
228
|
-
html += `
|
|
229
|
-
</div>
|
|
230
|
-
`;
|
|
231
|
-
}
|
|
232
|
-
html += `
|
|
233
|
-
</div>
|
|
234
|
-
`;
|
|
235
|
-
}
|
|
236
|
-
html += `
|
|
237
|
-
</body>
|
|
238
|
-
</html>
|
|
239
|
-
`;
|
|
240
|
-
return html;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Group changes by risk level or protocol.
|
|
244
|
-
*/
|
|
245
|
-
function groupChanges(changes, options) {
|
|
246
|
-
const sections = [];
|
|
247
|
-
if (options.groupByRisk) {
|
|
248
|
-
const riskGroups = {
|
|
249
|
-
critical: changes.filter((c) => c.riskLevel === "critical"),
|
|
250
|
-
high: changes.filter((c) => c.riskLevel === "high"),
|
|
251
|
-
medium: changes.filter((c) => c.riskLevel === "medium"),
|
|
252
|
-
low: changes.filter((c) => c.riskLevel === "low"),
|
|
253
|
-
};
|
|
254
|
-
for (const [risk, riskChanges] of Object.entries(riskGroups)) {
|
|
255
|
-
sections.push({
|
|
256
|
-
title: `${risk.charAt(0).toUpperCase() + risk.slice(1)} Risk Changes`,
|
|
257
|
-
changes: riskChanges,
|
|
258
|
-
summary: `${riskChanges.length} ${risk} risk changes that ${getRiskDescription(risk)}.`,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (options.groupByProtocol) {
|
|
263
|
-
const protocolGroups = {
|
|
264
|
-
rest: changes.filter((c) => c.protocol === "rest"),
|
|
265
|
-
graphql: changes.filter((c) => c.protocol === "graphql"),
|
|
266
|
-
websocket: changes.filter((c) => c.protocol === "websocket"),
|
|
267
|
-
other: changes.filter((c) => !c.protocol || !["rest", "graphql", "websocket"].includes(c.protocol)),
|
|
268
|
-
};
|
|
269
|
-
for (const [protocol, protocolChanges] of Object.entries(protocolGroups)) {
|
|
270
|
-
if (protocolChanges.length > 0) {
|
|
271
|
-
sections.push({
|
|
272
|
-
title: `${protocol.charAt(0).toUpperCase() + protocol.slice(1)} Protocol Changes`,
|
|
273
|
-
changes: protocolChanges,
|
|
274
|
-
summary: `${protocolChanges.length} changes affecting ${protocol} protocol.`,
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// If no grouping, create a single section
|
|
280
|
-
if (sections.length === 0) {
|
|
281
|
-
sections.push({
|
|
282
|
-
title: "All Changes",
|
|
283
|
-
changes,
|
|
284
|
-
summary: `${changes.length} total changes detected.`,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
return sections;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Helper functions for formatting.
|
|
291
|
-
*/
|
|
292
|
-
function getChangeIcon(riskLevel) {
|
|
293
|
-
switch (riskLevel) {
|
|
294
|
-
case "critical":
|
|
295
|
-
return "🚨";
|
|
296
|
-
case "high":
|
|
297
|
-
return "⚠️";
|
|
298
|
-
case "medium":
|
|
299
|
-
return "⚡";
|
|
300
|
-
case "low":
|
|
301
|
-
return "✅";
|
|
302
|
-
default:
|
|
303
|
-
return "📝";
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function getChangeTitle(change) {
|
|
307
|
-
const parts = change.path.split("/").filter(Boolean);
|
|
308
|
-
const lastPart = parts[parts.length - 1];
|
|
309
|
-
if (change.kind) {
|
|
310
|
-
return `${change.kind.replace(/\./g, " ").toUpperCase()} - ${lastPart}`;
|
|
311
|
-
}
|
|
312
|
-
return `${change.description} - ${lastPart}`;
|
|
313
|
-
}
|
|
314
|
-
function formatImpact(impact) {
|
|
315
|
-
const parts = [];
|
|
316
|
-
if (impact.backwardCompatibility !== "unknown") {
|
|
317
|
-
parts.push(`Compatibility: ${impact.backwardCompatibility}`);
|
|
318
|
-
}
|
|
319
|
-
if (impact.clientImpact !== "none") {
|
|
320
|
-
parts.push(`Client: ${impact.clientImpact}`);
|
|
321
|
-
}
|
|
322
|
-
if (impact.serverImpact !== "none") {
|
|
323
|
-
parts.push(`Server: ${impact.serverImpact}`);
|
|
324
|
-
}
|
|
325
|
-
return parts.join(", ");
|
|
326
|
-
}
|
|
327
|
-
function getRiskDescription(risk) {
|
|
328
|
-
switch (risk) {
|
|
329
|
-
case "critical":
|
|
330
|
-
return "require immediate attention and breaking changes";
|
|
331
|
-
case "high":
|
|
332
|
-
return "involve breaking changes or significant impact";
|
|
333
|
-
case "medium":
|
|
334
|
-
return "require attention but are manageable";
|
|
335
|
-
case "low":
|
|
336
|
-
return "are minor and easily handled";
|
|
337
|
-
default:
|
|
338
|
-
return "have unknown impact";
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
function getCompatibilityClass(score) {
|
|
342
|
-
if (score >= 80)
|
|
343
|
-
return "low";
|
|
344
|
-
if (score >= 60)
|
|
345
|
-
return "medium";
|
|
346
|
-
return "high";
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Generate a comprehensive change report.
|
|
350
|
-
*
|
|
351
|
-
* @param diff - Enhanced diff result
|
|
352
|
-
* @param options - Report generation options
|
|
353
|
-
* @returns Formatted report in the specified format
|
|
354
|
-
*/
|
|
355
|
-
export function generateChangeReport(diff, options) {
|
|
356
|
-
switch (options.format) {
|
|
357
|
-
case "markdown":
|
|
358
|
-
return generateMarkdownReport(diff, options);
|
|
359
|
-
case "html":
|
|
360
|
-
return generateHtmlReport(diff, options);
|
|
361
|
-
case "json":
|
|
362
|
-
return JSON.stringify(diff, null, 2);
|
|
363
|
-
default:
|
|
364
|
-
throw new Error(`Unsupported format: ${options.format}`);
|
|
365
|
-
}
|
|
366
|
-
}
|
package/dist/src/diff/core.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import { type DiffOptions, type DiffResult } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Compare two UniSpec documents and return detected changes.
|
|
5
|
-
*
|
|
6
|
-
* This function performs a deep comparison between two UniSpec documents
|
|
7
|
-
* and categorizes changes by severity and protocol. Useful for:
|
|
8
|
-
* - API change detection in CI/CD pipelines
|
|
9
|
-
* - Breaking change analysis
|
|
10
|
-
* - Version compatibility checks
|
|
11
|
-
* - Audit trails for API evolution
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Detects added/removed fields at any depth
|
|
15
|
-
* - Special handling for named collections (routes, operations, channels)
|
|
16
|
-
* - Severity classification: "breaking" | "non-breaking" | "unknown"
|
|
17
|
-
* - Protocol categorization: "rest" | "graphql" | "websocket"
|
|
18
|
-
* - Detailed change descriptions with JSON paths
|
|
19
|
-
* - Configurable named collection paths and comparison depth
|
|
20
|
-
*
|
|
21
|
-
* @param oldDoc - The previous version of the UniSpec document
|
|
22
|
-
* @param newDoc - The current version of the UniSpec document
|
|
23
|
-
* @param options - Configuration options for diff behavior
|
|
24
|
-
* @returns Object containing all detected changes
|
|
25
|
-
*/
|
|
26
|
-
export declare function diffUniSpec(oldDoc: UniSpecDocument, newDoc: UniSpecDocument, options?: DiffOptions): DiffResult;
|
package/dist/src/diff/core.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { annotateGraphQLChange, annotateRestChange, annotateWebSocketChange, } from "./annotators.js";
|
|
2
|
-
import { DEFAULT_NAMED_COLLECTION_PATHS, } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Check if a value is a plain object (not array, null, or other object types).
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to check
|
|
7
|
-
* @returns true if the value is a plain object, false otherwise
|
|
8
|
-
*/
|
|
9
|
-
function isPlainObject(value) {
|
|
10
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
11
|
-
}
|
|
12
|
-
function diffValues(oldVal, newVal, basePath, out, options = {}) {
|
|
13
|
-
if (oldVal === newVal) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// Both plain objects → recurse by keys
|
|
17
|
-
if (isPlainObject(oldVal) && isPlainObject(newVal)) {
|
|
18
|
-
const oldKeys = new Set(Object.keys(oldVal));
|
|
19
|
-
const newKeys = new Set(Object.keys(newVal));
|
|
20
|
-
// Removed keys
|
|
21
|
-
for (const key of oldKeys) {
|
|
22
|
-
if (!newKeys.has(key)) {
|
|
23
|
-
out.push({
|
|
24
|
-
path: `${basePath}/${key}`,
|
|
25
|
-
description: "Field removed",
|
|
26
|
-
severity: "unknown",
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Added / changed keys
|
|
31
|
-
for (const key of newKeys) {
|
|
32
|
-
const childPath = `${basePath}/${key}`;
|
|
33
|
-
if (!oldKeys.has(key)) {
|
|
34
|
-
out.push({
|
|
35
|
-
path: childPath,
|
|
36
|
-
description: "Field added",
|
|
37
|
-
severity: "unknown",
|
|
38
|
-
});
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const shouldRecurse = options.deepComparison !== false;
|
|
42
|
-
if (shouldRecurse) {
|
|
43
|
-
diffValues(oldVal[key], newVal[key], childPath, out, options);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// Arrays
|
|
49
|
-
if (Array.isArray(oldVal) && Array.isArray(newVal)) {
|
|
50
|
-
// Special handling for UniSpec collections identified by "name"
|
|
51
|
-
const _namedCollectionPaths = options.namedCollectionPaths || DEFAULT_NAMED_COLLECTION_PATHS;
|
|
52
|
-
const isNamedCollection = (options.namedCollectionPaths || [...DEFAULT_NAMED_COLLECTION_PATHS]).includes(basePath) || basePath.endsWith("/messages"); // Handle messages in channels
|
|
53
|
-
if (isNamedCollection) {
|
|
54
|
-
const oldByName = new Map();
|
|
55
|
-
const newByName = new Map();
|
|
56
|
-
for (const item of oldVal) {
|
|
57
|
-
if (item && typeof item === "object" && typeof item.name === "string") {
|
|
58
|
-
oldByName.set(item.name, item);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
for (const item of newVal) {
|
|
62
|
-
if (item && typeof item === "object" && typeof item.name === "string") {
|
|
63
|
-
newByName.set(item.name, item);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Removed
|
|
67
|
-
for (const [name, oldItem] of oldByName.entries()) {
|
|
68
|
-
if (!newByName.has(name)) {
|
|
69
|
-
out.push({
|
|
70
|
-
path: `${basePath}/${name}`,
|
|
71
|
-
description: "Item removed",
|
|
72
|
-
severity: "unknown",
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
const newItem = newByName.get(name);
|
|
77
|
-
const shouldRecurse = options.deepComparison !== false;
|
|
78
|
-
if (shouldRecurse) {
|
|
79
|
-
diffValues(oldItem, newItem, `${basePath}/${name}`, out, options);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Added
|
|
84
|
-
for (const [name, _newItem] of newByName.entries()) {
|
|
85
|
-
if (!oldByName.has(name)) {
|
|
86
|
-
out.push({
|
|
87
|
-
path: `${basePath}/${name}`,
|
|
88
|
-
description: "Item added",
|
|
89
|
-
severity: "unknown",
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// Regular array comparison
|
|
96
|
-
const maxLength = Math.max(oldVal.length, newVal.length);
|
|
97
|
-
for (let i = 0; i < maxLength; i++) {
|
|
98
|
-
if (i >= oldVal.length) {
|
|
99
|
-
out.push({
|
|
100
|
-
path: `${basePath}/${i}`,
|
|
101
|
-
description: "Item added",
|
|
102
|
-
severity: "unknown",
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else if (i >= newVal.length) {
|
|
106
|
-
out.push({
|
|
107
|
-
path: `${basePath}/${i}`,
|
|
108
|
-
description: "Item removed",
|
|
109
|
-
severity: "unknown",
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
const shouldRecurse = options.deepComparison !== false;
|
|
114
|
-
if (shouldRecurse) {
|
|
115
|
-
diffValues(oldVal[i], newVal[i], `${basePath}/${i}`, out, options);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// Primitive values or different types
|
|
121
|
-
out.push({
|
|
122
|
-
path: basePath,
|
|
123
|
-
description: "Value changed",
|
|
124
|
-
severity: "unknown",
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Compare two UniSpec documents and return detected changes.
|
|
129
|
-
*
|
|
130
|
-
* This function performs a deep comparison between two UniSpec documents
|
|
131
|
-
* and categorizes changes by severity and protocol. Useful for:
|
|
132
|
-
* - API change detection in CI/CD pipelines
|
|
133
|
-
* - Breaking change analysis
|
|
134
|
-
* - Version compatibility checks
|
|
135
|
-
* - Audit trails for API evolution
|
|
136
|
-
*
|
|
137
|
-
* Features:
|
|
138
|
-
* - Detects added/removed fields at any depth
|
|
139
|
-
* - Special handling for named collections (routes, operations, channels)
|
|
140
|
-
* - Severity classification: "breaking" | "non-breaking" | "unknown"
|
|
141
|
-
* - Protocol categorization: "rest" | "graphql" | "websocket"
|
|
142
|
-
* - Detailed change descriptions with JSON paths
|
|
143
|
-
* - Configurable named collection paths and comparison depth
|
|
144
|
-
*
|
|
145
|
-
* @param oldDoc - The previous version of the UniSpec document
|
|
146
|
-
* @param newDoc - The current version of the UniSpec document
|
|
147
|
-
* @param options - Configuration options for diff behavior
|
|
148
|
-
* @returns Object containing all detected changes
|
|
149
|
-
*/
|
|
150
|
-
export function diffUniSpec(oldDoc, newDoc, options = {}) {
|
|
151
|
-
const changes = [];
|
|
152
|
-
diffValues(oldDoc, newDoc, "", changes, options);
|
|
153
|
-
const annotated = changes.map((change) => annotateWebSocketChange(annotateGraphQLChange(annotateRestChange(change))));
|
|
154
|
-
return { changes: annotated };
|
|
155
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import { type RiskLevel } from "./risk-calculator.js";
|
|
3
|
-
import type { UniSpecChange } from "./types.js";
|
|
4
|
-
export interface ChangeImpact {
|
|
5
|
-
backwardCompatibility: "compatible" | "incompatible" | "unknown";
|
|
6
|
-
clientImpact: "none" | "low" | "medium" | "high";
|
|
7
|
-
serverImpact: "none" | "low" | "medium" | "high";
|
|
8
|
-
migrationComplexity: "none" | "simple" | "moderate" | "complex";
|
|
9
|
-
}
|
|
10
|
-
export interface EnhancedUniSpecChange extends UniSpecChange {
|
|
11
|
-
impact: ChangeImpact;
|
|
12
|
-
suggestions: string[];
|
|
13
|
-
examples?: {
|
|
14
|
-
before: UniSpecDocument;
|
|
15
|
-
after: UniSpecDocument;
|
|
16
|
-
};
|
|
17
|
-
riskLevel: RiskLevel;
|
|
18
|
-
}
|
|
19
|
-
export interface CompatibilityMetrics {
|
|
20
|
-
overallCompatibility: number;
|
|
21
|
-
breakingChangesCount: number;
|
|
22
|
-
nonBreakingChangesCount: number;
|
|
23
|
-
clientCompatibilityScore: number;
|
|
24
|
-
serverCompatibilityScore: number;
|
|
25
|
-
migrationEffort: "minimal" | "moderate" | "significant" | "major";
|
|
26
|
-
}
|
|
27
|
-
export interface EnhancedDiffResult {
|
|
28
|
-
changes: EnhancedUniSpecChange[];
|
|
29
|
-
metrics: CompatibilityMetrics;
|
|
30
|
-
summary: {
|
|
31
|
-
totalChanges: number;
|
|
32
|
-
criticalChanges: number;
|
|
33
|
-
highRiskChanges: number;
|
|
34
|
-
mediumRiskChanges: number;
|
|
35
|
-
lowRiskChanges: number;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Perform enhanced diff analysis with impact assessment and compatibility metrics.
|
|
40
|
-
*
|
|
41
|
-
* This function extends the basic diff functionality with:
|
|
42
|
-
* - Detailed impact analysis for each change
|
|
43
|
-
* - Compatibility metrics
|
|
44
|
-
* - Migration suggestions
|
|
45
|
-
* - Risk assessment
|
|
46
|
-
*
|
|
47
|
-
* @param oldDoc - The previous version of the UniSpec document
|
|
48
|
-
* @param newDoc - The current version of the UniSpec document
|
|
49
|
-
* @returns Enhanced diff result with comprehensive analysis
|
|
50
|
-
*/
|
|
51
|
-
export declare function diffUniSpecEnhanced(oldDoc: UniSpecDocument, newDoc: UniSpecDocument): EnhancedDiffResult;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { diffUniSpec } from "./core.js";
|
|
2
|
-
import { ImpactAnalysisStrategyFactory } from "./impact-strategies-refactored.js";
|
|
3
|
-
import { MetricsCalculatorService } from "./metrics-calculator.js";
|
|
4
|
-
import { RiskLevelCalculator } from "./risk-calculator.js";
|
|
5
|
-
import { SuggestionGeneratorService } from "./suggestion-generator.js";
|
|
6
|
-
/**
|
|
7
|
-
* Service instances for better separation of concerns.
|
|
8
|
-
*/
|
|
9
|
-
const suggestionGenerator = new SuggestionGeneratorService();
|
|
10
|
-
const metricsCalculator = new MetricsCalculatorService();
|
|
11
|
-
/**
|
|
12
|
-
* Perform enhanced diff analysis with impact assessment and compatibility metrics.
|
|
13
|
-
*
|
|
14
|
-
* This function extends the basic diff functionality with:
|
|
15
|
-
* - Detailed impact analysis for each change
|
|
16
|
-
* - Compatibility metrics
|
|
17
|
-
* - Migration suggestions
|
|
18
|
-
* - Risk assessment
|
|
19
|
-
*
|
|
20
|
-
* @param oldDoc - The previous version of the UniSpec document
|
|
21
|
-
* @param newDoc - The current version of the UniSpec document
|
|
22
|
-
* @returns Enhanced diff result with comprehensive analysis
|
|
23
|
-
*/
|
|
24
|
-
export function diffUniSpecEnhanced(oldDoc, newDoc) {
|
|
25
|
-
// Get basic diff
|
|
26
|
-
const basicDiff = diffUniSpec(oldDoc, newDoc);
|
|
27
|
-
// Enhance each change with impact analysis using strategy pattern
|
|
28
|
-
const enhancedChanges = basicDiff.changes.map((change) => {
|
|
29
|
-
// Get appropriate strategy for the protocol
|
|
30
|
-
const strategy = ImpactAnalysisStrategyFactory.getStrategy(change.protocol);
|
|
31
|
-
// Analyze impact using strategy
|
|
32
|
-
const impact = strategy.analyze(change);
|
|
33
|
-
// Generate suggestions
|
|
34
|
-
const suggestions = suggestionGenerator.generateSuggestions(change, impact);
|
|
35
|
-
// Calculate risk level using calculator
|
|
36
|
-
const riskLevel = RiskLevelCalculator.calculate(impact);
|
|
37
|
-
return {
|
|
38
|
-
...change,
|
|
39
|
-
impact,
|
|
40
|
-
suggestions,
|
|
41
|
-
riskLevel,
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
// Calculate metrics
|
|
45
|
-
const metrics = metricsCalculator.calculateMetrics(enhancedChanges);
|
|
46
|
-
// Generate summary
|
|
47
|
-
const summary = {
|
|
48
|
-
totalChanges: enhancedChanges.length,
|
|
49
|
-
criticalChanges: enhancedChanges.filter((c) => c.riskLevel === "critical")
|
|
50
|
-
.length,
|
|
51
|
-
highRiskChanges: enhancedChanges.filter((c) => c.riskLevel === "high")
|
|
52
|
-
.length,
|
|
53
|
-
mediumRiskChanges: enhancedChanges.filter((c) => c.riskLevel === "medium")
|
|
54
|
-
.length,
|
|
55
|
-
lowRiskChanges: enhancedChanges.filter((c) => c.riskLevel === "low").length,
|
|
56
|
-
};
|
|
57
|
-
return {
|
|
58
|
-
changes: enhancedChanges,
|
|
59
|
-
metrics,
|
|
60
|
-
summary,
|
|
61
|
-
};
|
|
62
|
-
}
|