@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,5 +1,5 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "
|
|
2
|
-
import type { NormalizeOptions } from "./types
|
|
1
|
+
import type { UniSpecDocument } from "@/types";
|
|
2
|
+
import type { NormalizeOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Normalize a UniSpec document into a canonical, deterministic form.
|
|
5
5
|
*
|
package/dist/normalizer/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { normalizeGraphqlOperations } from "./graphql-normalizer
|
|
2
|
-
import { normalizeRestRoutes } from "./rest-normalizer
|
|
3
|
-
import { normalizeValue } from "./utils
|
|
4
|
-
import { normalizeWebSocket } from "./websocket-normalizer
|
|
1
|
+
import { normalizeGraphqlOperations } from "./graphql-normalizer";
|
|
2
|
+
import { normalizeRestRoutes } from "./rest-normalizer";
|
|
3
|
+
import { normalizeValue } from "./utils";
|
|
4
|
+
import { normalizeWebSocket } from "./websocket-normalizer";
|
|
5
5
|
/**
|
|
6
6
|
* Normalize a UniSpec document into a canonical, deterministic form.
|
|
7
7
|
*
|
|
@@ -24,6 +24,11 @@ import { normalizeWebSocket } from "./websocket-normalizer.js";
|
|
|
24
24
|
* @returns The normalized UniSpec document
|
|
25
25
|
*/
|
|
26
26
|
export function normalizeUniSpec(doc, _options = {}) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Apply protocol-specific normalizations first
|
|
28
|
+
const restNormalized = normalizeRestRoutes(doc);
|
|
29
|
+
const graphqlNormalized = normalizeGraphqlOperations(restNormalized);
|
|
30
|
+
const finalNormalized = normalizeWebSocket(graphqlNormalized);
|
|
31
|
+
// Always apply structural normalization to ensure immutability
|
|
32
|
+
// and consistent key sorting, even if no protocol changes were made
|
|
33
|
+
return normalizeValue(finalNormalized);
|
|
29
34
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { normalizeUniSpec } from "./core
|
|
2
|
-
export type { NormalizeOptions } from "./types
|
|
1
|
+
export { normalizeUniSpec } from "./core";
|
|
2
|
+
export type { NormalizeOptions } from "./types";
|
package/dist/normalizer/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UniSpecGraphQLProtocol, UniSpecRestProtocol, UniSpecWebSocketProtocol } from "
|
|
1
|
+
import type { UniSpecGraphQLProtocol, UniSpecRestProtocol, UniSpecWebSocketProtocol } from "@/types";
|
|
2
2
|
export type NormalizeOptions = Record<string, never>;
|
|
3
3
|
export interface UniSpecServiceProtocolsLike {
|
|
4
4
|
rest?: UniSpecRestProtocol;
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Normalize a value by sorting object keys lexicographically (recursive).
|
|
10
|
+
* Always creates new objects to ensure immutability.
|
|
11
|
+
* Handles circular references gracefully.
|
|
10
12
|
*
|
|
11
13
|
* @param value - The value to normalize
|
|
12
|
-
* @
|
|
14
|
+
* @param seen - WeakSet of already seen objects for circular reference detection
|
|
15
|
+
* @returns The normalized value (always a new object for objects/arrays)
|
|
13
16
|
*/
|
|
14
|
-
export declare function normalizeValue(value: unknown): unknown;
|
|
17
|
+
export declare function normalizeValue(value: unknown, seen?: WeakSet<object>): unknown;
|
package/dist/normalizer/utils.js
CHANGED
|
@@ -8,20 +8,36 @@ export function isPlainObject(value) {
|
|
|
8
8
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Normalize a value by sorting object keys lexicographically (recursive).
|
|
12
|
+
* Always creates new objects to ensure immutability.
|
|
13
|
+
* Handles circular references gracefully.
|
|
12
14
|
*
|
|
13
15
|
* @param value - The value to normalize
|
|
14
|
-
* @
|
|
16
|
+
* @param seen - WeakSet of already seen objects for circular reference detection
|
|
17
|
+
* @returns The normalized value (always a new object for objects/arrays)
|
|
15
18
|
*/
|
|
16
|
-
export function normalizeValue(value) {
|
|
19
|
+
export function normalizeValue(value, seen = new WeakSet()) {
|
|
20
|
+
// Handle primitives and null/undefined
|
|
21
|
+
if (value === null || typeof value !== "object") {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
17
24
|
if (Array.isArray(value)) {
|
|
18
|
-
|
|
25
|
+
// Always create new array with recursively normalized items
|
|
26
|
+
return value.map((item) => normalizeValue(item, seen));
|
|
19
27
|
}
|
|
20
28
|
if (isPlainObject(value)) {
|
|
21
|
-
|
|
29
|
+
// Check for circular references
|
|
30
|
+
if (seen.has(value)) {
|
|
31
|
+
// Return a placeholder for circular references to avoid infinite recursion
|
|
32
|
+
return "[Circular]";
|
|
33
|
+
}
|
|
34
|
+
seen.add(value);
|
|
35
|
+
const entries = Object.entries(value);
|
|
36
|
+
// Always create new object with sorted keys and recursively normalized values
|
|
37
|
+
const sortedEntries = entries.sort(([a], [b]) => a.localeCompare(b));
|
|
22
38
|
const normalized = {};
|
|
23
|
-
for (const [key, val] of
|
|
24
|
-
normalized[key] = normalizeValue(val);
|
|
39
|
+
for (const [key, val] of sortedEntries) {
|
|
40
|
+
normalized[key] = normalizeValue(val, seen);
|
|
25
41
|
}
|
|
26
42
|
return normalized;
|
|
27
43
|
}
|
package/dist/optimizer/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "
|
|
2
|
-
import type { OptimizationOptions, OptimizationReport, OptimizationResult } from "./types
|
|
1
|
+
import type { UniSpecDocument } from "@/types";
|
|
2
|
+
import type { OptimizationOptions, OptimizationReport, OptimizationResult } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Optimize a UniSpec document with various optimization strategies.
|
|
5
5
|
*
|
package/dist/optimizer/core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeSchemaRef } from "@/schemas";
|
|
2
|
+
import { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions";
|
|
2
3
|
/**
|
|
3
4
|
* Optimize a UniSpec document with various optimization strategies.
|
|
4
5
|
*
|
|
@@ -20,12 +21,6 @@ export function optimizeDocument(doc, options = {}) {
|
|
|
20
21
|
}
|
|
21
22
|
let deduplicatedCount = 0;
|
|
22
23
|
// Apply optimizations in order
|
|
23
|
-
if (options.removeUnusedSchemas === true) {
|
|
24
|
-
const removed = removeOrphanedSchemas(optimizedDoc);
|
|
25
|
-
if (removed.length > 0) {
|
|
26
|
-
changes.push(`Removed ${removed.length} orphaned schemas: ${removed.join(", ")}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
24
|
if (options.dedupeSchemas !== false) {
|
|
30
25
|
const dedupResult = deduplicateSchemas(optimizedDoc);
|
|
31
26
|
if (dedupResult.removedSchemas.length > 0) {
|
|
@@ -34,6 +29,12 @@ export function optimizeDocument(doc, options = {}) {
|
|
|
34
29
|
deduplicatedCount = dedupResult.removedSchemas.length;
|
|
35
30
|
}
|
|
36
31
|
}
|
|
32
|
+
if (options.removeUnusedSchemas === true) {
|
|
33
|
+
const removed = removeOrphanedSchemas(optimizedDoc);
|
|
34
|
+
if (removed.length > 0) {
|
|
35
|
+
changes.push(`Removed ${removed.length} orphaned schemas: ${removed.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
37
38
|
if (options.sortSchemas !== false) {
|
|
38
39
|
const sortedCount = sortSchemas(optimizedDoc);
|
|
39
40
|
if (sortedCount > 0) {
|
|
@@ -81,7 +82,7 @@ export function generateOptimizationReport(doc) {
|
|
|
81
82
|
return;
|
|
82
83
|
for (const [key, value] of Object.entries(obj)) {
|
|
83
84
|
if (key === "schemaRef" && typeof value === "string") {
|
|
84
|
-
const schemaName = value
|
|
85
|
+
const schemaName = normalizeSchemaRef(value);
|
|
85
86
|
if (schemaName)
|
|
86
87
|
referencedSchemas.add(schemaName);
|
|
87
88
|
}
|
|
@@ -101,11 +102,35 @@ export function generateOptimizationReport(doc) {
|
|
|
101
102
|
}
|
|
102
103
|
const totalSchemas = Object.keys(doc.service?.schemas || {}).length;
|
|
103
104
|
const potentialReduction = orphaned.length + dedupResult.removedSchemas.length;
|
|
104
|
-
|
|
105
|
+
// Calculate reference compression savings only if there are schema references
|
|
106
|
+
let referenceCompression = 0;
|
|
107
|
+
if (totalSchemas > 0) {
|
|
108
|
+
// Count actual schema references to estimate compression savings
|
|
109
|
+
let referenceCount = 0;
|
|
110
|
+
function countReferences(obj) {
|
|
111
|
+
if (!obj || typeof obj !== "object")
|
|
112
|
+
return;
|
|
113
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
114
|
+
if (key === "schemaRef" && typeof value === "string") {
|
|
115
|
+
referenceCount++;
|
|
116
|
+
}
|
|
117
|
+
else if (typeof value === "object" && value !== null) {
|
|
118
|
+
countReferences(value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
countReferences(doc);
|
|
123
|
+
// Only estimate compression if there are references to compress
|
|
124
|
+
if (referenceCount > 1) {
|
|
125
|
+
referenceCompression = Math.min(referenceCount * 0.1, totalSchemas * 0.1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const result = {
|
|
105
129
|
recommendations,
|
|
106
130
|
potentialSavings: {
|
|
107
131
|
schemaReduction: potentialReduction,
|
|
108
|
-
referenceCompression
|
|
132
|
+
referenceCompression,
|
|
109
133
|
},
|
|
110
134
|
};
|
|
135
|
+
return result;
|
|
111
136
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateOptimizationReport, optimizeDocument, } from "./core
|
|
2
|
-
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions
|
|
3
|
-
export type { DeduplicationResult, OptimizationOptions, OptimizationReport, OptimizationResult, } from "./types
|
|
4
|
-
export { compressReference } from "./utils
|
|
1
|
+
export { generateOptimizationReport, optimizeDocument, } from "./core";
|
|
2
|
+
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions";
|
|
3
|
+
export type { DeduplicationResult, OptimizationOptions, OptimizationReport, OptimizationResult, } from "./types";
|
|
4
|
+
export { compressReference } from "./utils";
|
package/dist/optimizer/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Export types
|
|
2
2
|
// Export core functions
|
|
3
|
-
export { generateOptimizationReport, optimizeDocument, } from "./core
|
|
3
|
+
export { generateOptimizationReport, optimizeDocument, } from "./core";
|
|
4
4
|
// Export optimization functions
|
|
5
|
-
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions
|
|
5
|
+
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions";
|
|
6
6
|
// Export utilities
|
|
7
|
-
export { compressReference } from "./utils
|
|
7
|
+
export { compressReference } from "./utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "
|
|
2
|
-
import type { DeduplicationResult } from "./types
|
|
1
|
+
import type { UniSpecDocument } from "@/types";
|
|
2
|
+
import type { DeduplicationResult } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Remove duplicate schemas from a UniSpec document.
|
|
5
5
|
* Duplicates are identified by identical JSON Schema content.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeSchemaRef, stableStringify } from "
|
|
2
|
-
import { compressReference } from "./utils
|
|
1
|
+
import { normalizeSchemaRef, stableStringify } from "@/schemas";
|
|
2
|
+
import { compressReference } from "./utils";
|
|
3
3
|
/**
|
|
4
4
|
* Remove duplicate schemas from a UniSpec document.
|
|
5
5
|
* Duplicates are identified by identical JSON Schema content.
|
package/dist/schemas/dedupe.d.ts
CHANGED
package/dist/schemas/dedupe.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeSchemaRef, stableStringify } from "./utils
|
|
1
|
+
import { normalizeSchemaRef, stableStringify } from "./utils";
|
|
2
2
|
function updateSchemaRefs(doc, mapping) {
|
|
3
3
|
const rest = doc.service?.protocols?.rest;
|
|
4
4
|
const websocket = doc.service?.protocols?.websocket;
|
|
@@ -72,26 +72,39 @@ function updateSchemaRefs(doc, mapping) {
|
|
|
72
72
|
* @param doc - The UniSpec document to deduplicate
|
|
73
73
|
*/
|
|
74
74
|
export function dedupeSchemas(doc) {
|
|
75
|
-
if (!doc
|
|
75
|
+
if (!doc?.service?.schemas || typeof doc.service.schemas !== "object")
|
|
76
76
|
return;
|
|
77
|
-
const
|
|
77
|
+
const schemas = doc.service.schemas;
|
|
78
78
|
const hashToName = new Map();
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const toDelete = [];
|
|
80
|
+
// Find duplicates
|
|
81
|
+
for (const name of Object.keys(schemas)) {
|
|
82
|
+
const schema = schemas[name];
|
|
82
83
|
const hash = stableStringify(schema?.jsonSchema ?? null);
|
|
83
84
|
const existing = hashToName.get(hash);
|
|
84
85
|
if (!existing) {
|
|
85
86
|
hashToName.set(hash, name);
|
|
86
|
-
continue;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
else {
|
|
89
|
+
// Mark for deletion - keep the first one encountered
|
|
90
|
+
toDelete.push(name);
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
// Update references before deleting
|
|
94
|
+
if (toDelete.length > 0) {
|
|
95
|
+
const renameMap = {};
|
|
96
|
+
for (const dup of toDelete) {
|
|
97
|
+
const schema = schemas[dup];
|
|
98
|
+
const hash = stableStringify(schema?.jsonSchema ?? null);
|
|
99
|
+
const existing = hashToName.get(hash);
|
|
100
|
+
if (existing) {
|
|
101
|
+
renameMap[dup] = existing;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
updateSchemaRefs(doc, renameMap);
|
|
105
|
+
// Delete duplicates
|
|
106
|
+
for (const dup of toDelete) {
|
|
107
|
+
delete schemas[dup];
|
|
108
|
+
}
|
|
96
109
|
}
|
|
97
110
|
}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { dedupeSchemas } from "./dedupe
|
|
2
|
-
export { registerSchema, resolveSchemaRef } from "./resolver
|
|
3
|
-
export { normalizeSchemaRef, stableStringify } from "./utils
|
|
1
|
+
export { dedupeSchemas } from "./dedupe";
|
|
2
|
+
export { registerSchema, resolveSchemaRef } from "./resolver";
|
|
3
|
+
export { normalizeSchemaRef, stableStringify } from "./utils";
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Export utility functions
|
|
2
2
|
// Export deduplication functions
|
|
3
|
-
export { dedupeSchemas } from "./dedupe
|
|
3
|
+
export { dedupeSchemas } from "./dedupe";
|
|
4
4
|
// Export resolver functions
|
|
5
|
-
export { registerSchema, resolveSchemaRef } from "./resolver
|
|
6
|
-
export { normalizeSchemaRef, stableStringify } from "./utils
|
|
5
|
+
export { registerSchema, resolveSchemaRef } from "./resolver";
|
|
6
|
+
export { normalizeSchemaRef, stableStringify } from "./utils";
|
package/dist/schemas/resolver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeSchemaRef } from "./utils
|
|
1
|
+
import { normalizeSchemaRef } from "./utils";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a schema reference to its definition in a UniSpec document.
|
|
4
4
|
*
|
|
@@ -7,6 +7,8 @@ import { normalizeSchemaRef } from "./utils.js";
|
|
|
7
7
|
* @returns The schema definition or undefined if not found
|
|
8
8
|
*/
|
|
9
9
|
export function resolveSchemaRef(doc, ref) {
|
|
10
|
+
if (!doc)
|
|
11
|
+
return undefined;
|
|
10
12
|
const name = normalizeSchemaRef(ref);
|
|
11
13
|
if (!name)
|
|
12
14
|
return undefined;
|
|
@@ -29,7 +31,6 @@ export function registerSchema(doc, name, jsonSchema) {
|
|
|
29
31
|
doc.service.schemas = {};
|
|
30
32
|
}
|
|
31
33
|
const definition = {
|
|
32
|
-
name,
|
|
33
34
|
jsonSchema,
|
|
34
35
|
};
|
|
35
36
|
doc.service.schemas[name] = definition;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -147,7 +147,8 @@ export interface UniSpecCustomValidator {
|
|
|
147
147
|
rule: string;
|
|
148
148
|
message: string;
|
|
149
149
|
}
|
|
150
|
-
export interface UniSpecSchemaDefinition extends
|
|
150
|
+
export interface UniSpecSchemaDefinition extends UniSpecDeprecatedItem {
|
|
151
|
+
description?: string;
|
|
151
152
|
examples?: unknown[];
|
|
152
153
|
jsonSchema: Record<string, unknown>;
|
|
153
154
|
validation?: UniSpecSchemaValidation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UniSpecConfigDocument, ValidationResult } from "
|
|
2
|
-
import type { ValidateOptions } from "./types
|
|
1
|
+
import type { UniSpecConfigDocument, ValidationResult } from "@/types";
|
|
2
|
+
import type { ValidateOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Validate a UniSpec Config document against the UniSpec Config JSON Schema.
|
|
5
5
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ErrorFactory } from "
|
|
2
|
-
import { getValidator } from "./ajv-validator
|
|
3
|
-
import { validateConfigCustomRules } from "./config-validator
|
|
4
|
-
import { createValidator } from "./validator-factory
|
|
1
|
+
import { ErrorFactory } from "@/errors";
|
|
2
|
+
import { getValidator } from "./ajv-validator";
|
|
3
|
+
import { validateConfigCustomRules } from "./config-validator";
|
|
4
|
+
import { createValidator } from "./validator-factory";
|
|
5
5
|
/**
|
|
6
6
|
* Validate a UniSpec Config document against the UniSpec Config JSON Schema.
|
|
7
7
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { clearValidatorCache, getValidator } from "./ajv-validator
|
|
2
|
-
export { validateUniSpecConfig } from "./config-validator-main
|
|
3
|
-
export type { ReferenceValidationOptions, ReferenceValidationResult, } from "./reference-validator
|
|
4
|
-
export { validateReferences } from "./reference-validator
|
|
5
|
-
export type { SemanticValidationOptions, SemanticValidationResult, } from "./semantic-validator
|
|
6
|
-
export { validateSemantic } from "./semantic-validator
|
|
7
|
-
export { validateUniSpecTests } from "./tests-validator
|
|
8
|
-
export type { Ajv2020, AjvValidateFn, ExtendedValidationResult, SchemaProvider, ValidateOptions, ValidatorSchemas, } from "./types
|
|
9
|
-
export { validateUniSpec } from "./unispec-validator
|
|
10
|
-
export { createValidator, mapAjvErrors } from "./validator-factory
|
|
1
|
+
export { clearValidatorCache, getValidator } from "./ajv-validator";
|
|
2
|
+
export { validateUniSpecConfig } from "./config-validator-main";
|
|
3
|
+
export type { ReferenceValidationOptions, ReferenceValidationResult, } from "./reference-validator";
|
|
4
|
+
export { validateReferences } from "./reference-validator";
|
|
5
|
+
export type { SemanticValidationOptions, SemanticValidationResult, } from "./semantic-validator";
|
|
6
|
+
export { validateSemantic } from "./semantic-validator";
|
|
7
|
+
export { validateUniSpecTests } from "./tests-validator";
|
|
8
|
+
export type { Ajv2020, AjvValidateFn, ExtendedValidationResult, SchemaProvider, ValidateOptions, ValidatorSchemas, } from "./types";
|
|
9
|
+
export { validateUniSpec } from "./unispec-validator";
|
|
10
|
+
export { createValidator, mapAjvErrors } from "./validator-factory";
|
package/dist/validator/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Export all validation functions and types
|
|
2
2
|
// Export AJV utilities
|
|
3
|
-
export { clearValidatorCache, getValidator } from "./ajv-validator
|
|
4
|
-
export { validateUniSpecConfig } from "./config-validator-main
|
|
5
|
-
export { validateReferences } from "./reference-validator
|
|
3
|
+
export { clearValidatorCache, getValidator } from "./ajv-validator";
|
|
4
|
+
export { validateUniSpecConfig } from "./config-validator-main";
|
|
5
|
+
export { validateReferences } from "./reference-validator";
|
|
6
6
|
// Re-export semantic and reference validators
|
|
7
|
-
export { validateSemantic } from "./semantic-validator
|
|
8
|
-
export { validateUniSpecTests } from "./tests-validator
|
|
9
|
-
export { validateUniSpec } from "./unispec-validator
|
|
7
|
+
export { validateSemantic } from "./semantic-validator";
|
|
8
|
+
export { validateUniSpecTests } from "./tests-validator";
|
|
9
|
+
export { validateUniSpec } from "./unispec-validator";
|
|
10
10
|
// Export validator factory for advanced usage
|
|
11
|
-
export { createValidator, mapAjvErrors } from "./validator-factory
|
|
11
|
+
export { createValidator, mapAjvErrors } from "./validator-factory";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ValidateOptions } from "./types
|
|
1
|
+
import type { ValidateOptions } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { ValidateOptions } from "./types.js";
|
|
|
6
6
|
* @param options - Validation options including custom schemas
|
|
7
7
|
* @returns Validation result with success status and error details
|
|
8
8
|
*/
|
|
9
|
-
export declare const validateUniSpecTests: (doc: unknown, options?: ValidateOptions) => Promise<import("
|
|
9
|
+
export declare const validateUniSpecTests: (doc: unknown, options?: ValidateOptions) => Promise<import("..").ValidationResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getValidator } from "./ajv-validator
|
|
2
|
-
import { createValidator } from "./validator-factory
|
|
1
|
+
import { getValidator } from "./ajv-validator";
|
|
2
|
+
import { createValidator } from "./validator-factory";
|
|
3
3
|
/**
|
|
4
4
|
* Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ValidationResult } from "
|
|
2
|
-
import type { ReferenceValidationOptions, ReferenceValidationResult } from "./reference-validator
|
|
3
|
-
import type { SemanticValidationOptions, SemanticValidationResult } from "./semantic-validator
|
|
1
|
+
import type { ValidationResult } from "@/types";
|
|
2
|
+
import type { ReferenceValidationOptions, ReferenceValidationResult } from "./reference-validator";
|
|
3
|
+
import type { SemanticValidationOptions, SemanticValidationResult } from "./semantic-validator";
|
|
4
4
|
export interface SchemaProvider {
|
|
5
5
|
getSchema: (schemaPath: string) => Promise<object>;
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UniSpecDocument, ValidationResult } from "
|
|
2
|
-
import type { ExtendedValidationResult, ValidateOptions } from "./types
|
|
1
|
+
import type { UniSpecDocument, ValidationResult } from "@/types";
|
|
2
|
+
import type { ExtendedValidationResult, ValidateOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Validate a UniSpec document with optional extended validation.
|
|
5
5
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ErrorFactory } from "
|
|
2
|
-
import { getValidator } from "./ajv-validator
|
|
3
|
-
import { validateReferences } from "./reference-validator
|
|
4
|
-
import { validateSemantic } from "./semantic-validator
|
|
5
|
-
import { mapAjvErrors } from "./validator-factory
|
|
1
|
+
import { ErrorFactory } from "@/errors";
|
|
2
|
+
import { getValidator } from "./ajv-validator";
|
|
3
|
+
import { validateReferences } from "./reference-validator";
|
|
4
|
+
import { validateSemantic } from "./semantic-validator";
|
|
5
|
+
import { mapAjvErrors } from "./validator-factory";
|
|
6
6
|
/**
|
|
7
7
|
* Validate a UniSpec document with optional extended validation.
|
|
8
8
|
*
|
|
@@ -53,12 +53,8 @@ export async function validateUniSpec(doc, options = {}) {
|
|
|
53
53
|
async function validateUniSpecBase(doc, options = {}) {
|
|
54
54
|
try {
|
|
55
55
|
const { validateUniSpecFn } = await getValidator(options);
|
|
56
|
-
//
|
|
57
|
-
const
|
|
58
|
-
unispecVersion: doc.unispecVersion || "1.0.0",
|
|
59
|
-
service: doc.service,
|
|
60
|
-
};
|
|
61
|
-
const valid = validateUniSpecFn(docForValidation);
|
|
56
|
+
// Validate the document as-is to ensure all required fields are present
|
|
57
|
+
const valid = validateUniSpecFn(doc);
|
|
62
58
|
const schemaErrors = mapAjvErrors(validateUniSpecFn.errors);
|
|
63
59
|
if (valid) {
|
|
64
60
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ValidationError } from "
|
|
2
|
-
import type { AjvValidateFn, ValidateOptions } from "./types
|
|
1
|
+
import type { ValidationError } from "@/types";
|
|
2
|
+
import type { AjvValidateFn, ValidateOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Generic validator factory to reduce code duplication.
|
|
5
5
|
*/
|
|
6
|
-
export declare function createValidator<T>(documentType: "unispec" | "unispecTests" | "unispecConfig", getValidatorFn: (options: ValidateOptions) => Promise<AjvValidateFn | undefined>, customValidation?: (doc: T) => ValidationError[]): (doc: T, options?: ValidateOptions) => Promise<import("../types
|
|
6
|
+
export declare function createValidator<T>(documentType: "unispec" | "unispecTests" | "unispecConfig", getValidatorFn: (options: ValidateOptions) => Promise<AjvValidateFn | undefined>, customValidation?: (doc: T) => ValidationError[]): (doc: T, options?: ValidateOptions) => Promise<import("../types").ValidationResult>;
|
|
7
7
|
/**
|
|
8
8
|
* Map AJV errors to specific UniSpec validation errors.
|
|
9
9
|
*/
|