@unispechq/unispec-core 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/cache-factory.d.ts +2 -2
- package/dist/cache/cache-factory.js +1 -1
- package/dist/cache/cache-manager.d.ts +2 -2
- package/dist/cache/cache-manager.js +9 -7
- package/dist/cache/hash-utils.d.ts +1 -11
- package/dist/cache/hash-utils.js +1 -21
- package/dist/cache/hashing.d.ts +15 -6
- package/dist/cache/hashing.js +8 -12
- package/dist/cache/index.d.ts +6 -6
- package/dist/cache/index.js +5 -5
- package/dist/cache/lru-cache.d.ts +1 -13
- package/dist/cache/lru-cache.js +3 -24
- package/dist/cjs/cache/cache-factory.js +1 -1
- package/dist/cjs/cache/cache-manager.js +9 -7
- package/dist/cjs/cache/hash-utils.js +1 -23
- package/dist/cjs/cache/hashing.js +7 -13
- package/dist/cjs/cache/index.js +6 -8
- package/dist/cjs/cache/lru-cache.js +3 -24
- package/dist/cjs/diff/annotators.js +3 -2
- package/dist/cjs/diff/core.js +2 -2
- package/dist/cjs/diff/enhanced-diff.js +7 -21
- package/dist/cjs/diff/index.js +8 -8
- package/dist/cjs/errors/config-error.js +1 -1
- package/dist/cjs/errors/error-factory.js +7 -7
- package/dist/cjs/errors/index.js +8 -8
- package/dist/cjs/errors/loader-error.js +1 -1
- package/dist/cjs/errors/reference-error.js +1 -1
- package/dist/cjs/errors/schema-error.js +1 -1
- package/dist/cjs/errors/security-error.js +1 -1
- package/dist/cjs/errors/semantic-error.js +1 -1
- package/dist/cjs/index.js +13 -13
- package/dist/cjs/loader/index.js +4 -4
- package/dist/cjs/loader/security-validator.js +1 -1
- package/dist/cjs/loader/unispec-loader.js +3 -3
- package/dist/cjs/loader/yaml-loader.js +1 -1
- package/dist/cjs/normalizer/core.js +11 -6
- package/dist/cjs/normalizer/index.js +1 -1
- package/dist/cjs/normalizer/utils.js +23 -7
- package/dist/cjs/optimizer/core.js +35 -10
- package/dist/cjs/optimizer/index.js +3 -3
- package/dist/cjs/optimizer/optimization-functions.js +2 -2
- package/dist/cjs/schemas/dedupe.js +27 -14
- package/dist/cjs/schemas/index.js +3 -3
- package/dist/cjs/schemas/resolver.js +3 -2
- package/dist/cjs/validator/ajv-validator.js +1 -1
- package/dist/cjs/validator/config-validator-main.js +4 -4
- package/dist/cjs/validator/config-validator.js +1 -1
- package/dist/cjs/validator/index.js +7 -7
- package/dist/cjs/validator/reference-validator.js +1 -1
- package/dist/cjs/validator/tests-validator.js +2 -2
- package/dist/cjs/validator/unispec-validator.js +7 -11
- package/dist/cjs/validator/validator-factory.js +1 -1
- package/dist/diff/annotators.d.ts +1 -1
- package/dist/diff/annotators.js +3 -2
- package/dist/diff/change-reports.d.ts +1 -1
- package/dist/diff/core.d.ts +2 -2
- package/dist/diff/core.js +2 -2
- package/dist/diff/enhanced-diff.d.ts +3 -3
- package/dist/diff/enhanced-diff.js +7 -21
- package/dist/diff/impact-strategies-refactored.d.ts +2 -2
- package/dist/diff/impact-strategies.d.ts +2 -2
- package/dist/diff/index.d.ts +8 -8
- package/dist/diff/index.js +8 -8
- package/dist/diff/metrics-calculator.d.ts +1 -1
- package/dist/diff/risk-calculator.d.ts +1 -1
- package/dist/diff/suggestion-generator.d.ts +2 -2
- package/dist/errors/config-error.d.ts +1 -1
- package/dist/errors/config-error.js +1 -1
- package/dist/errors/error-factory.d.ts +7 -7
- package/dist/errors/error-factory.js +7 -7
- package/dist/errors/index.d.ts +8 -8
- package/dist/errors/index.js +8 -8
- package/dist/errors/loader-error.d.ts +1 -1
- package/dist/errors/loader-error.js +1 -1
- package/dist/errors/reference-error.d.ts +1 -1
- package/dist/errors/reference-error.js +1 -1
- package/dist/errors/schema-error.d.ts +1 -1
- package/dist/errors/schema-error.js +1 -1
- package/dist/errors/security-error.d.ts +1 -1
- package/dist/errors/security-error.js +1 -1
- package/dist/errors/semantic-error.d.ts +1 -1
- package/dist/errors/semantic-error.js +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -13
- package/dist/loader/index.d.ts +5 -5
- package/dist/loader/index.js +4 -4
- package/dist/loader/security-validator.d.ts +1 -1
- package/dist/loader/security-validator.js +1 -1
- package/dist/loader/unispec-loader.d.ts +2 -2
- package/dist/loader/unispec-loader.js +3 -3
- package/dist/loader/yaml-loader.d.ts +1 -1
- package/dist/loader/yaml-loader.js +1 -1
- package/dist/normalizer/core.d.ts +2 -2
- package/dist/normalizer/core.js +11 -6
- package/dist/normalizer/graphql-normalizer.d.ts +1 -1
- package/dist/normalizer/index.d.ts +2 -2
- package/dist/normalizer/index.js +1 -1
- package/dist/normalizer/rest-normalizer.d.ts +1 -1
- package/dist/normalizer/types.d.ts +1 -1
- package/dist/normalizer/utils.d.ts +6 -3
- package/dist/normalizer/utils.js +23 -7
- package/dist/normalizer/websocket-normalizer.d.ts +1 -1
- package/dist/optimizer/core.d.ts +2 -2
- package/dist/optimizer/core.js +35 -10
- package/dist/optimizer/index.d.ts +4 -4
- package/dist/optimizer/index.js +3 -3
- package/dist/optimizer/optimization-functions.d.ts +2 -2
- package/dist/optimizer/optimization-functions.js +2 -2
- package/dist/optimizer/types.d.ts +1 -1
- package/dist/schemas/dedupe.d.ts +1 -1
- package/dist/schemas/dedupe.js +27 -14
- package/dist/schemas/index.d.ts +3 -3
- package/dist/schemas/index.js +3 -3
- package/dist/schemas/resolver.d.ts +1 -1
- package/dist/schemas/resolver.js +3 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/validator/ajv-validator.d.ts +1 -1
- package/dist/validator/ajv-validator.js +1 -1
- package/dist/validator/config-validator-main.d.ts +2 -2
- package/dist/validator/config-validator-main.js +4 -4
- package/dist/validator/config-validator.d.ts +1 -1
- package/dist/validator/config-validator.js +1 -1
- package/dist/validator/index.d.ts +10 -10
- package/dist/validator/index.js +7 -7
- package/dist/validator/reference-validator.d.ts +1 -1
- package/dist/validator/reference-validator.js +1 -1
- package/dist/validator/schema-references.d.ts +1 -1
- package/dist/validator/semantic-validator.d.ts +1 -1
- package/dist/validator/tests-validator.d.ts +2 -2
- package/dist/validator/tests-validator.js +2 -2
- package/dist/validator/types.d.ts +3 -3
- package/dist/validator/unispec-validator.d.ts +2 -2
- package/dist/validator/unispec-validator.js +7 -11
- package/dist/validator/validator-factory.d.ts +3 -3
- package/dist/validator/validator-factory.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/src/cache/cache-factory.js +0 -72
- package/dist/cjs/src/cache/cache-manager.js +0 -128
- package/dist/cjs/src/cache/constants.js +0 -25
- package/dist/cjs/src/cache/hash-utils.js +0 -19
- package/dist/cjs/src/cache/hashing.js +0 -230
- package/dist/cjs/src/cache/index.js +0 -24
- package/dist/cjs/src/cache/lru-cache.js +0 -144
- package/dist/cjs/src/cache/types.js +0 -5
- package/dist/cjs/src/diff/annotators.js +0 -160
- package/dist/cjs/src/diff/change-reports.js +0 -369
- package/dist/cjs/src/diff/core.js +0 -158
- package/dist/cjs/src/diff/enhanced-diff.js +0 -65
- package/dist/cjs/src/diff/impact-strategies-refactored.js +0 -230
- package/dist/cjs/src/diff/impact-strategies.js +0 -219
- package/dist/cjs/src/diff/index.js +0 -27
- package/dist/cjs/src/diff/metrics-calculator.js +0 -69
- package/dist/cjs/src/diff/risk-calculator.js +0 -58
- package/dist/cjs/src/diff/suggestion-generator.js +0 -78
- package/dist/cjs/src/diff/types.js +0 -11
- package/dist/cjs/src/errors/base-error.js +0 -33
- package/dist/cjs/src/errors/config-error.js +0 -11
- package/dist/cjs/src/errors/error-factory.js +0 -48
- package/dist/cjs/src/errors/index.js +0 -19
- package/dist/cjs/src/errors/loader-error.js +0 -11
- package/dist/cjs/src/errors/reference-error.js +0 -11
- package/dist/cjs/src/errors/schema-error.js +0 -11
- package/dist/cjs/src/errors/security-error.js +0 -11
- package/dist/cjs/src/errors/semantic-error.js +0 -11
- package/dist/cjs/src/generated-schemas.js +0 -2100
- package/dist/cjs/src/index.js +0 -59
- package/dist/cjs/src/loader/index.js +0 -13
- package/dist/cjs/src/loader/security-validator.js +0 -53
- package/dist/cjs/src/loader/types.js +0 -11
- package/dist/cjs/src/loader/unispec-loader.js +0 -84
- package/dist/cjs/src/loader/yaml-loader.js +0 -76
- package/dist/cjs/src/normalizer/core.js +0 -37
- package/dist/cjs/src/normalizer/graphql-normalizer.js +0 -67
- package/dist/cjs/src/normalizer/index.js +0 -7
- package/dist/cjs/src/normalizer/rest-normalizer.js +0 -51
- package/dist/cjs/src/normalizer/types.js +0 -2
- package/dist/cjs/src/normalizer/utils.js +0 -49
- package/dist/cjs/src/normalizer/websocket-normalizer.js +0 -81
- package/dist/cjs/src/optimizer/core.js +0 -140
- package/dist/cjs/src/optimizer/index.js +0 -17
- package/dist/cjs/src/optimizer/optimization-functions.js +0 -185
- package/dist/cjs/src/optimizer/types.js +0 -2
- package/dist/cjs/src/optimizer/utils.js +0 -32
- package/dist/cjs/src/schemas/dedupe.js +0 -113
- package/dist/cjs/src/schemas/index.js +0 -14
- package/dist/cjs/src/schemas/resolver.js +0 -42
- package/dist/cjs/src/schemas/utils.js +0 -53
- package/dist/cjs/src/types/index.js +0 -2
- package/dist/cjs/src/validator/ajv-validator.js +0 -82
- package/dist/cjs/src/validator/config-validator-main.js +0 -34
- package/dist/cjs/src/validator/config-validator.js +0 -17
- package/dist/cjs/src/validator/index.js +0 -23
- package/dist/cjs/src/validator/object-traversal.js +0 -112
- package/dist/cjs/src/validator/reference-validator.js +0 -233
- package/dist/cjs/src/validator/schema-references.js +0 -116
- package/dist/cjs/src/validator/semantic-validator.js +0 -328
- package/dist/cjs/src/validator/tests-validator.js +0 -16
- package/dist/cjs/src/validator/types.js +0 -2
- package/dist/cjs/src/validator/unispec-validator.js +0 -80
- package/dist/cjs/src/validator/validator-factory.js +0 -77
- package/dist/cjs/src/versions.js +0 -147
- package/dist/cjs/tests/cache/cache.test.js +0 -274
- package/dist/cjs/tests/cache/utils.js +0 -32
- package/dist/cjs/tests/concurrency-normalizer-optimizer.test.js +0 -1
- package/dist/cjs/tests/diff/diff-annotators.test.js +0 -280
- package/dist/cjs/tests/diff/diff-comprehensive.test.js +0 -262
- package/dist/cjs/tests/diff/diff-extended.test.js +0 -235
- package/dist/cjs/tests/diff/diff.test.js +0 -189
- package/dist/cjs/tests/diff/utils.js +0 -8
- package/dist/cjs/tests/errors/errors-integration.test.js +0 -173
- package/dist/cjs/tests/errors/errors.test.js +0 -280
- package/dist/cjs/tests/errors/utils.js +0 -7
- package/dist/cjs/tests/loader/integration.test.js +0 -216
- package/dist/cjs/tests/loader/loader.test.js +0 -341
- package/dist/cjs/tests/normalizer/normalizer-comprehensive.test.js +0 -648
- package/dist/cjs/tests/normalizer/normalizer-invalid.test.js +0 -258
- package/dist/cjs/tests/normalizer/normalizer-valid.test.js +0 -238
- package/dist/cjs/tests/normalizer/utils.js +0 -47
- package/dist/cjs/tests/optimizer/compress-references.test.js +0 -304
- package/dist/cjs/tests/optimizer/deduplication.test.js +0 -132
- package/dist/cjs/tests/optimizer/integration.test.js +0 -131
- package/dist/cjs/tests/optimizer/optimization-report.test.js +0 -222
- package/dist/cjs/tests/optimizer/optimize-document.test.js +0 -187
- package/dist/cjs/tests/optimizer/orphaned-schemas.test.js +0 -194
- package/dist/cjs/tests/optimizer/sort-schemas.test.js +0 -131
- package/dist/cjs/tests/optimizer/utils.js +0 -209
- package/dist/cjs/tests/schemas/schemas-edge-cases.test.js +0 -223
- package/dist/cjs/tests/schemas/schemas.test.js +0 -400
- package/dist/cjs/tests/schemas/utils.js +0 -7
- package/dist/cjs/tests/utils.js +0 -131
- package/dist/cjs/tests/validator/config-validator.test.js +0 -78
- package/dist/cjs/tests/validator/debug-config.js +0 -1
- package/dist/cjs/tests/validator/debug-missing-service.js +0 -1
- package/dist/cjs/tests/validator/debug-other-configs.js +0 -1
- package/dist/cjs/tests/validator/debug-references.js +0 -1
- package/dist/cjs/tests/validator/unispec-validator.test.js +0 -103
- package/dist/cjs/tests/validator/utils.js +0 -25
- package/dist/src/cache/cache-factory.d.ts +0 -31
- package/dist/src/cache/cache-factory.js +0 -65
- package/dist/src/cache/cache-manager.d.ts +0 -62
- package/dist/src/cache/cache-manager.js +0 -124
- package/dist/src/cache/constants.d.ts +0 -21
- package/dist/src/cache/constants.js +0 -22
- package/dist/src/cache/hash-utils.d.ts +0 -11
- package/dist/src/cache/hash-utils.js +0 -15
- package/dist/src/cache/hashing.d.ts +0 -28
- package/dist/src/cache/hashing.js +0 -193
- package/dist/src/cache/index.d.ts +0 -6
- package/dist/src/cache/index.js +0 -10
- package/dist/src/cache/lru-cache.d.ts +0 -44
- package/dist/src/cache/lru-cache.js +0 -140
- package/dist/src/cache/types.d.ts +0 -24
- package/dist/src/cache/types.js +0 -4
- package/dist/src/diff/annotators.d.ts +0 -4
- package/dist/src/diff/annotators.js +0 -155
- package/dist/src/diff/change-reports.d.ts +0 -37
- package/dist/src/diff/change-reports.js +0 -366
- package/dist/src/diff/core.d.ts +0 -26
- package/dist/src/diff/core.js +0 -155
- package/dist/src/diff/enhanced-diff.d.ts +0 -51
- package/dist/src/diff/enhanced-diff.js +0 -62
- package/dist/src/diff/impact-strategies-refactored.d.ts +0 -69
- package/dist/src/diff/impact-strategies-refactored.js +0 -223
- package/dist/src/diff/impact-strategies.d.ts +0 -41
- package/dist/src/diff/impact-strategies.js +0 -212
- package/dist/src/diff/index.d.ts +0 -8
- package/dist/src/diff/index.js +0 -11
- package/dist/src/diff/metrics-calculator.d.ts +0 -23
- package/dist/src/diff/metrics-calculator.js +0 -65
- package/dist/src/diff/risk-calculator.d.ts +0 -23
- package/dist/src/diff/risk-calculator.js +0 -55
- package/dist/src/diff/suggestion-generator.d.ts +0 -18
- package/dist/src/diff/suggestion-generator.js +0 -74
- package/dist/src/diff/types.d.ts +0 -24
- package/dist/src/diff/types.js +0 -8
- package/dist/src/errors/base-error.d.ts +0 -20
- package/dist/src/errors/base-error.js +0 -29
- package/dist/src/errors/config-error.d.ts +0 -4
- package/dist/src/errors/config-error.js +0 -7
- package/dist/src/errors/error-factory.d.ts +0 -22
- package/dist/src/errors/error-factory.js +0 -45
- package/dist/src/errors/index.d.ts +0 -8
- package/dist/src/errors/index.js +0 -8
- package/dist/src/errors/loader-error.d.ts +0 -4
- package/dist/src/errors/loader-error.js +0 -7
- package/dist/src/errors/reference-error.d.ts +0 -4
- package/dist/src/errors/reference-error.js +0 -7
- package/dist/src/errors/schema-error.d.ts +0 -4
- package/dist/src/errors/schema-error.js +0 -7
- package/dist/src/errors/security-error.d.ts +0 -4
- package/dist/src/errors/security-error.js +0 -7
- package/dist/src/errors/semantic-error.d.ts +0 -4
- package/dist/src/errors/semantic-error.js +0 -7
- package/dist/src/generated-schemas.d.ts +0 -2073
- package/dist/src/generated-schemas.js +0 -2097
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -43
- package/dist/src/loader/index.d.ts +0 -5
- package/dist/src/loader/index.js +0 -5
- package/dist/src/loader/security-validator.d.ts +0 -5
- package/dist/src/loader/security-validator.js +0 -50
- package/dist/src/loader/types.d.ts +0 -30
- package/dist/src/loader/types.js +0 -8
- package/dist/src/loader/unispec-loader.d.ts +0 -10
- package/dist/src/loader/unispec-loader.js +0 -81
- package/dist/src/loader/yaml-loader.d.ts +0 -10
- package/dist/src/loader/yaml-loader.js +0 -39
- package/dist/src/normalizer/core.d.ts +0 -24
- package/dist/src/normalizer/core.js +0 -34
- package/dist/src/normalizer/graphql-normalizer.d.ts +0 -8
- package/dist/src/normalizer/graphql-normalizer.js +0 -64
- package/dist/src/normalizer/index.d.ts +0 -2
- package/dist/src/normalizer/index.js +0 -3
- package/dist/src/normalizer/rest-normalizer.d.ts +0 -8
- package/dist/src/normalizer/rest-normalizer.js +0 -48
- package/dist/src/normalizer/types.d.ts +0 -7
- package/dist/src/normalizer/types.js +0 -1
- package/dist/src/normalizer/utils.d.ts +0 -17
- package/dist/src/normalizer/utils.js +0 -45
- package/dist/src/normalizer/websocket-normalizer.d.ts +0 -8
- package/dist/src/normalizer/websocket-normalizer.js +0 -78
- package/dist/src/optimizer/core.d.ts +0 -17
- package/dist/src/optimizer/core.js +0 -136
- package/dist/src/optimizer/index.d.ts +0 -4
- package/dist/src/optimizer/index.js +0 -7
- package/dist/src/optimizer/optimization-functions.d.ts +0 -32
- package/dist/src/optimizer/optimization-functions.js +0 -179
- package/dist/src/optimizer/types.d.ts +0 -28
- package/dist/src/optimizer/types.js +0 -1
- package/dist/src/optimizer/utils.d.ts +0 -7
- package/dist/src/optimizer/utils.js +0 -29
- package/dist/src/schemas/dedupe.d.ts +0 -9
- package/dist/src/schemas/dedupe.js +0 -110
- package/dist/src/schemas/index.d.ts +0 -3
- package/dist/src/schemas/index.js +0 -6
- package/dist/src/schemas/resolver.d.ts +0 -19
- package/dist/src/schemas/resolver.js +0 -38
- package/dist/src/schemas/utils.d.ts +0 -20
- package/dist/src/schemas/utils.js +0 -49
- package/dist/src/types/index.d.ts +0 -434
- package/dist/src/types/index.js +0 -1
- package/dist/src/validator/ajv-validator.d.ts +0 -15
- package/dist/src/validator/ajv-validator.js +0 -75
- package/dist/src/validator/config-validator-main.d.ts +0 -10
- package/dist/src/validator/config-validator-main.js +0 -31
- package/dist/src/validator/config-validator.d.ts +0 -5
- package/dist/src/validator/config-validator.js +0 -14
- package/dist/src/validator/index.d.ts +0 -10
- package/dist/src/validator/index.js +0 -11
- package/dist/src/validator/object-traversal.d.ts +0 -52
- package/dist/src/validator/object-traversal.js +0 -104
- package/dist/src/validator/reference-validator.d.ts +0 -31
- package/dist/src/validator/reference-validator.js +0 -230
- package/dist/src/validator/schema-references.d.ts +0 -23
- package/dist/src/validator/schema-references.js +0 -111
- package/dist/src/validator/semantic-validator.d.ts +0 -26
- package/dist/src/validator/semantic-validator.js +0 -325
- package/dist/src/validator/tests-validator.d.ts +0 -9
- package/dist/src/validator/tests-validator.js +0 -13
- package/dist/src/validator/types.d.ts +0 -29
- package/dist/src/validator/types.js +0 -1
- package/dist/src/validator/unispec-validator.d.ts +0 -15
- package/dist/src/validator/unispec-validator.js +0 -77
- package/dist/src/validator/validator-factory.d.ts +0 -10
- package/dist/src/validator/validator-factory.js +0 -73
- package/dist/src/versions.d.ts +0 -10
- package/dist/src/versions.js +0 -143
- package/dist/tests/cache/cache.test.d.ts +0 -1
- package/dist/tests/cache/cache.test.js +0 -269
- package/dist/tests/cache/utils.d.ts +0 -4
- package/dist/tests/cache/utils.js +0 -24
- package/dist/tests/concurrency-normalizer-optimizer.test.d.ts +0 -0
- package/dist/tests/concurrency-normalizer-optimizer.test.js +0 -1
- package/dist/tests/diff/diff-annotators.test.d.ts +0 -1
- package/dist/tests/diff/diff-annotators.test.js +0 -275
- package/dist/tests/diff/diff-comprehensive.test.d.ts +0 -1
- package/dist/tests/diff/diff-comprehensive.test.js +0 -257
- package/dist/tests/diff/diff-extended.test.d.ts +0 -1
- package/dist/tests/diff/diff-extended.test.js +0 -230
- package/dist/tests/diff/diff.test.d.ts +0 -1
- package/dist/tests/diff/diff.test.js +0 -184
- package/dist/tests/diff/utils.d.ts +0 -2
- package/dist/tests/diff/utils.js +0 -3
- package/dist/tests/errors/errors-integration.test.d.ts +0 -1
- package/dist/tests/errors/errors-integration.test.js +0 -168
- package/dist/tests/errors/errors.test.d.ts +0 -1
- package/dist/tests/errors/errors.test.js +0 -275
- package/dist/tests/errors/utils.d.ts +0 -2
- package/dist/tests/errors/utils.js +0 -3
- package/dist/tests/loader/integration.test.d.ts +0 -1
- package/dist/tests/loader/integration.test.js +0 -211
- package/dist/tests/loader/loader.test.d.ts +0 -1
- package/dist/tests/loader/loader.test.js +0 -336
- package/dist/tests/normalizer/normalizer-comprehensive.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-comprehensive.test.js +0 -643
- package/dist/tests/normalizer/normalizer-invalid.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-invalid.test.js +0 -253
- package/dist/tests/normalizer/normalizer-valid.test.d.ts +0 -1
- package/dist/tests/normalizer/normalizer-valid.test.js +0 -233
- package/dist/tests/normalizer/utils.d.ts +0 -18
- package/dist/tests/normalizer/utils.js +0 -36
- package/dist/tests/optimizer/compress-references.test.d.ts +0 -1
- package/dist/tests/optimizer/compress-references.test.js +0 -299
- package/dist/tests/optimizer/deduplication.test.d.ts +0 -1
- package/dist/tests/optimizer/deduplication.test.js +0 -127
- package/dist/tests/optimizer/integration.test.d.ts +0 -1
- package/dist/tests/optimizer/integration.test.js +0 -126
- package/dist/tests/optimizer/optimization-report.test.d.ts +0 -1
- package/dist/tests/optimizer/optimization-report.test.js +0 -217
- package/dist/tests/optimizer/optimize-document.test.d.ts +0 -1
- package/dist/tests/optimizer/optimize-document.test.js +0 -182
- package/dist/tests/optimizer/orphaned-schemas.test.d.ts +0 -1
- package/dist/tests/optimizer/orphaned-schemas.test.js +0 -189
- package/dist/tests/optimizer/sort-schemas.test.d.ts +0 -1
- package/dist/tests/optimizer/sort-schemas.test.js +0 -126
- package/dist/tests/optimizer/utils.d.ts +0 -8
- package/dist/tests/optimizer/utils.js +0 -199
- package/dist/tests/schemas/schemas-edge-cases.test.d.ts +0 -1
- package/dist/tests/schemas/schemas-edge-cases.test.js +0 -218
- package/dist/tests/schemas/schemas.test.d.ts +0 -1
- package/dist/tests/schemas/schemas.test.js +0 -395
- package/dist/tests/schemas/utils.d.ts +0 -2
- package/dist/tests/schemas/utils.js +0 -3
- package/dist/tests/utils.d.ts +0 -10
- package/dist/tests/utils.js +0 -118
- package/dist/tests/validator/config-validator.test.d.ts +0 -1
- package/dist/tests/validator/config-validator.test.js +0 -73
- package/dist/tests/validator/debug-config.d.ts +0 -0
- package/dist/tests/validator/debug-config.js +0 -1
- package/dist/tests/validator/debug-missing-service.d.ts +0 -0
- package/dist/tests/validator/debug-missing-service.js +0 -1
- package/dist/tests/validator/debug-other-configs.d.ts +0 -0
- package/dist/tests/validator/debug-other-configs.js +0 -1
- package/dist/tests/validator/debug-references.d.ts +0 -0
- package/dist/tests/validator/debug-references.js +0 -1
- package/dist/tests/validator/unispec-validator.test.d.ts +0 -1
- package/dist/tests/validator/unispec-validator.test.js +0 -98
- package/dist/tests/validator/utils.d.ts +0 -6
- package/dist/tests/validator/utils.js +0 -20
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { ErrorFactory, UniSpecConfigError, UniSpecLoaderError, UniSpecReferenceError, UniSpecSchemaError, UniSpecSecurityError, UniSpecSemanticError, UniSpecValidationError, } from "../../src/errors/index.js";
|
|
4
|
-
import { getExamplePath, loadExample, loadInvalidExample } from "./utils.js";
|
|
5
|
-
describe("errors module", () => {
|
|
6
|
-
describe("UniSpecValidationError", () => {
|
|
7
|
-
it("should create basic validation error", () => {
|
|
8
|
-
const error = new UniSpecValidationError("Test error message", "test_code", "/test/path", "error", { detail: "test detail" });
|
|
9
|
-
assert.strictEqual(error.message, "Test error message");
|
|
10
|
-
assert.strictEqual(error.code, "test_code");
|
|
11
|
-
assert.strictEqual(error.path, "/test/path");
|
|
12
|
-
assert.strictEqual(error.severity, "error");
|
|
13
|
-
assert.deepStrictEqual(error.details, { detail: "test detail" });
|
|
14
|
-
assert.strictEqual(error.name, "UniSpecValidationError");
|
|
15
|
-
});
|
|
16
|
-
it("should create error with default values", () => {
|
|
17
|
-
const error = new UniSpecValidationError("Test message", "test_code");
|
|
18
|
-
assert.strictEqual(error.message, "Test message");
|
|
19
|
-
assert.strictEqual(error.code, "test_code");
|
|
20
|
-
assert.strictEqual(error.path, "");
|
|
21
|
-
assert.strictEqual(error.severity, "error");
|
|
22
|
-
assert.strictEqual(error.details, undefined);
|
|
23
|
-
});
|
|
24
|
-
it("should serialize to JSON correctly", () => {
|
|
25
|
-
const error = new UniSpecValidationError("Test message", "test_code", "/path", "warning", { test: "value" });
|
|
26
|
-
const json = error.toJSON();
|
|
27
|
-
assert.strictEqual(json.name, "UniSpecValidationError");
|
|
28
|
-
assert.strictEqual(json.message, "Test message");
|
|
29
|
-
assert.strictEqual(json.code, "test_code");
|
|
30
|
-
assert.strictEqual(json.path, "/path");
|
|
31
|
-
assert.strictEqual(json.severity, "warning");
|
|
32
|
-
assert.deepStrictEqual(json.details, { test: "value" });
|
|
33
|
-
assert.ok(json.stack);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("Specific error types", () => {
|
|
37
|
-
it("should create UniSpecConfigError", () => {
|
|
38
|
-
const error = new UniSpecConfigError("Configuration error", "/config/path", { configKey: "test" });
|
|
39
|
-
assert.strictEqual(error.name, "UniSpecConfigError");
|
|
40
|
-
assert.strictEqual(error.code, "config_error");
|
|
41
|
-
assert.strictEqual(error.message, "Configuration error");
|
|
42
|
-
assert.strictEqual(error.path, "/config/path");
|
|
43
|
-
assert.deepStrictEqual(error.details, { configKey: "test" });
|
|
44
|
-
});
|
|
45
|
-
it("should create UniSpecLoaderError", () => {
|
|
46
|
-
const error = new UniSpecLoaderError("Loader error", "/loader/path", {
|
|
47
|
-
fileType: "yaml",
|
|
48
|
-
});
|
|
49
|
-
assert.strictEqual(error.name, "UniSpecLoaderError");
|
|
50
|
-
assert.strictEqual(error.code, "loader_error");
|
|
51
|
-
assert.strictEqual(error.message, "Loader error");
|
|
52
|
-
assert.strictEqual(error.path, "/loader/path");
|
|
53
|
-
assert.deepStrictEqual(error.details, { fileType: "yaml" });
|
|
54
|
-
});
|
|
55
|
-
it("should create UniSpecReferenceError", () => {
|
|
56
|
-
const error = new UniSpecReferenceError("Reference error", "/ref/path", {
|
|
57
|
-
reference: "invalid-ref",
|
|
58
|
-
});
|
|
59
|
-
assert.strictEqual(error.name, "UniSpecReferenceError");
|
|
60
|
-
assert.strictEqual(error.code, "reference_error");
|
|
61
|
-
assert.strictEqual(error.message, "Reference error");
|
|
62
|
-
assert.strictEqual(error.path, "/ref/path");
|
|
63
|
-
assert.deepStrictEqual(error.details, { reference: "invalid-ref" });
|
|
64
|
-
});
|
|
65
|
-
it("should create UniSpecSchemaError", () => {
|
|
66
|
-
const error = new UniSpecSchemaError("Schema validation error", "/schema/path", { schemaPath: "service.name" });
|
|
67
|
-
assert.strictEqual(error.name, "UniSpecSchemaError");
|
|
68
|
-
assert.strictEqual(error.code, "schema_error");
|
|
69
|
-
assert.strictEqual(error.message, "Schema validation error");
|
|
70
|
-
assert.strictEqual(error.path, "/schema/path");
|
|
71
|
-
assert.deepStrictEqual(error.details, { schemaPath: "service.name" });
|
|
72
|
-
});
|
|
73
|
-
it("should create UniSpecSecurityError", () => {
|
|
74
|
-
const error = new UniSpecSecurityError("Security violation", "/security/path", { violation: "insecure_protocol" });
|
|
75
|
-
assert.strictEqual(error.name, "UniSpecSecurityError");
|
|
76
|
-
assert.strictEqual(error.code, "security_error");
|
|
77
|
-
assert.strictEqual(error.message, "Security violation");
|
|
78
|
-
assert.strictEqual(error.path, "/security/path");
|
|
79
|
-
assert.deepStrictEqual(error.details, { violation: "insecure_protocol" });
|
|
80
|
-
});
|
|
81
|
-
it("should create UniSpecSemanticError", () => {
|
|
82
|
-
const error = new UniSpecSemanticError("Semantic error", "/semantic/path", { semanticIssue: "duplicate_name" });
|
|
83
|
-
assert.strictEqual(error.name, "UniSpecSemanticError");
|
|
84
|
-
assert.strictEqual(error.code, "semantic_error");
|
|
85
|
-
assert.strictEqual(error.message, "Semantic error");
|
|
86
|
-
assert.strictEqual(error.path, "/semantic/path");
|
|
87
|
-
assert.deepStrictEqual(error.details, {
|
|
88
|
-
semanticIssue: "duplicate_name",
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
describe("ErrorFactory", () => {
|
|
93
|
-
it("should create schema error via factory", () => {
|
|
94
|
-
const error = ErrorFactory.createSchemaError("Schema error", "/path", {
|
|
95
|
-
detail: "test",
|
|
96
|
-
});
|
|
97
|
-
assert.ok(error instanceof UniSpecSchemaError);
|
|
98
|
-
assert.strictEqual(error.message, "Schema error");
|
|
99
|
-
assert.strictEqual(error.path, "/path");
|
|
100
|
-
assert.deepStrictEqual(error.details, { detail: "test" });
|
|
101
|
-
});
|
|
102
|
-
it("should create semantic error via factory", () => {
|
|
103
|
-
const error = ErrorFactory.createSemanticError("Semantic error", "/path", { detail: "test" });
|
|
104
|
-
assert.ok(error instanceof UniSpecSemanticError);
|
|
105
|
-
assert.strictEqual(error.message, "Semantic error");
|
|
106
|
-
assert.strictEqual(error.path, "/path");
|
|
107
|
-
});
|
|
108
|
-
it("should create reference error via factory", () => {
|
|
109
|
-
const error = ErrorFactory.createReferenceError("Reference error", "/path", { detail: "test" });
|
|
110
|
-
assert.ok(error instanceof UniSpecReferenceError);
|
|
111
|
-
assert.strictEqual(error.message, "Reference error");
|
|
112
|
-
assert.strictEqual(error.path, "/path");
|
|
113
|
-
});
|
|
114
|
-
it("should create config error via factory", () => {
|
|
115
|
-
const error = ErrorFactory.createConfigError("Config error", "/path", {
|
|
116
|
-
detail: "test",
|
|
117
|
-
});
|
|
118
|
-
assert.ok(error instanceof UniSpecConfigError);
|
|
119
|
-
assert.strictEqual(error.message, "Config error");
|
|
120
|
-
assert.strictEqual(error.path, "/path");
|
|
121
|
-
});
|
|
122
|
-
it("should create security error via factory", () => {
|
|
123
|
-
const error = ErrorFactory.createSecurityError("Security error", "/path", { detail: "test" });
|
|
124
|
-
assert.ok(error instanceof UniSpecSecurityError);
|
|
125
|
-
assert.strictEqual(error.message, "Security error");
|
|
126
|
-
assert.strictEqual(error.path, "/path");
|
|
127
|
-
});
|
|
128
|
-
it("should create loader error via factory", () => {
|
|
129
|
-
const error = ErrorFactory.createLoaderError("Loader error", "/path", {
|
|
130
|
-
detail: "test",
|
|
131
|
-
});
|
|
132
|
-
assert.ok(error instanceof UniSpecLoaderError);
|
|
133
|
-
assert.strictEqual(error.message, "Loader error");
|
|
134
|
-
assert.strictEqual(error.path, "/path");
|
|
135
|
-
});
|
|
136
|
-
describe("fromError method", () => {
|
|
137
|
-
it("should return UniSpecValidationError as-is", () => {
|
|
138
|
-
const originalError = new UniSpecValidationError("Original error", "original_code");
|
|
139
|
-
const converted = ErrorFactory.fromError(originalError);
|
|
140
|
-
assert.strictEqual(converted, originalError);
|
|
141
|
-
});
|
|
142
|
-
it("should convert Error to UniSpecValidationError", () => {
|
|
143
|
-
const originalError = new Error("Original error");
|
|
144
|
-
const converted = ErrorFactory.fromError(originalError);
|
|
145
|
-
assert.ok(converted instanceof UniSpecValidationError);
|
|
146
|
-
assert.strictEqual(converted.message, "Original error");
|
|
147
|
-
assert.strictEqual(converted.code, "validation_error");
|
|
148
|
-
assert.deepStrictEqual(converted.details, {
|
|
149
|
-
originalError: "Error",
|
|
150
|
-
stack: originalError.stack,
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
it("should convert string to UniSpecValidationError", () => {
|
|
154
|
-
const originalError = "String error";
|
|
155
|
-
const converted = ErrorFactory.fromError(originalError);
|
|
156
|
-
assert.ok(converted instanceof UniSpecValidationError);
|
|
157
|
-
assert.strictEqual(converted.message, "String error");
|
|
158
|
-
assert.strictEqual(converted.code, "validation_error");
|
|
159
|
-
});
|
|
160
|
-
it("should convert unknown object to UniSpecValidationError", () => {
|
|
161
|
-
const originalError = { some: "object" };
|
|
162
|
-
const converted = ErrorFactory.fromError(originalError);
|
|
163
|
-
assert.ok(converted instanceof UniSpecValidationError);
|
|
164
|
-
assert.strictEqual(converted.message, "Unknown validation error: [object Object]");
|
|
165
|
-
assert.strictEqual(converted.code, "validation_error");
|
|
166
|
-
assert.deepStrictEqual(converted.details, { originalError });
|
|
167
|
-
});
|
|
168
|
-
it("should use custom default code", () => {
|
|
169
|
-
const originalError = new Error("Custom error");
|
|
170
|
-
const converted = ErrorFactory.fromError(originalError, "custom_code");
|
|
171
|
-
assert.strictEqual(converted.code, "custom_code");
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
describe("Error handling with schema examples", () => {
|
|
176
|
-
it("should handle valid examples without errors", () => {
|
|
177
|
-
const validDoc = loadExample(getExamplePath("valid", "spec", "rest-simple.json"));
|
|
178
|
-
// This should not throw - valid document should load successfully
|
|
179
|
-
assert.ok(validDoc);
|
|
180
|
-
assert.ok(validDoc.unispecVersion);
|
|
181
|
-
assert.ok(validDoc.service);
|
|
182
|
-
});
|
|
183
|
-
it("should create appropriate errors for invalid examples", () => {
|
|
184
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-service-name.json"));
|
|
185
|
-
// Invalid document should be missing required fields
|
|
186
|
-
assert.ok(invalidDoc);
|
|
187
|
-
assert.ok(!invalidDoc.service?.name);
|
|
188
|
-
// Test creating appropriate error for this case
|
|
189
|
-
const error = ErrorFactory.createSchemaError("Missing required service name", "service.name", { required: true, found: undefined });
|
|
190
|
-
assert.ok(error instanceof UniSpecSchemaError);
|
|
191
|
-
assert.strictEqual(error.path, "service.name");
|
|
192
|
-
assert.deepStrictEqual(error.details, {
|
|
193
|
-
required: true,
|
|
194
|
-
found: undefined,
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
it("should handle missing version errors", () => {
|
|
198
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "missing-unispec-version.json"));
|
|
199
|
-
assert.ok(invalidDoc);
|
|
200
|
-
assert.ok(!invalidDoc.unispecVersion);
|
|
201
|
-
const error = ErrorFactory.createSchemaError("Missing required unispecVersion", "unispecVersion", { required: true, found: undefined });
|
|
202
|
-
assert.ok(error instanceof UniSpecSchemaError);
|
|
203
|
-
assert.strictEqual(error.path, "unispecVersion");
|
|
204
|
-
});
|
|
205
|
-
it("should handle invalid REST method errors", () => {
|
|
206
|
-
const invalidDoc = loadInvalidExample(getExamplePath("invalid", "spec", "invalid-rest-method.json"));
|
|
207
|
-
assert.ok(invalidDoc);
|
|
208
|
-
// Extract method value safely for testing
|
|
209
|
-
const doc = invalidDoc;
|
|
210
|
-
const service = doc.service;
|
|
211
|
-
const protocols = service?.protocols;
|
|
212
|
-
const rest = protocols?.rest;
|
|
213
|
-
const routes = rest?.routes;
|
|
214
|
-
const firstRoute = routes?.[0];
|
|
215
|
-
const error = ErrorFactory.createSemanticError("Invalid HTTP method", "service.protocols.rest.routes[0].method", { method: firstRoute?.method });
|
|
216
|
-
assert.ok(error instanceof UniSpecSemanticError);
|
|
217
|
-
assert.strictEqual(error.path, "service.protocols.rest.routes[0].method");
|
|
218
|
-
});
|
|
219
|
-
it("should handle config errors", () => {
|
|
220
|
-
const invalidConfig = loadInvalidExample(getExamplePath("invalid", "config", "missing-version.json"));
|
|
221
|
-
assert.ok(invalidConfig);
|
|
222
|
-
assert.ok(!invalidConfig.version);
|
|
223
|
-
const error = ErrorFactory.createConfigError("Missing required version in config", "version", { required: true });
|
|
224
|
-
assert.ok(error instanceof UniSpecConfigError);
|
|
225
|
-
assert.strictEqual(error.path, "version");
|
|
226
|
-
});
|
|
227
|
-
it("should handle loader errors for malformed examples", () => {
|
|
228
|
-
// Simulate a loader error
|
|
229
|
-
const error = ErrorFactory.createLoaderError("Failed to parse YAML file", "/path/to/file.yaml", { line: 5, column: 10, reason: "invalid indentation" });
|
|
230
|
-
assert.ok(error instanceof UniSpecLoaderError);
|
|
231
|
-
assert.strictEqual(error.path, "/path/to/file.yaml");
|
|
232
|
-
assert.deepStrictEqual(error.details, {
|
|
233
|
-
line: 5,
|
|
234
|
-
column: 10,
|
|
235
|
-
reason: "invalid indentation",
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
it("should handle security errors", () => {
|
|
239
|
-
const error = ErrorFactory.createSecurityError("Insecure protocol detected", "service.protocols.rest.routes[0].scheme", { protocol: "http", recommended: "https" });
|
|
240
|
-
assert.ok(error instanceof UniSpecSecurityError);
|
|
241
|
-
assert.strictEqual(error.path, "service.protocols.rest.routes[0].scheme");
|
|
242
|
-
assert.deepStrictEqual(error.details, {
|
|
243
|
-
protocol: "http",
|
|
244
|
-
recommended: "https",
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
it("should handle reference errors", () => {
|
|
248
|
-
const error = ErrorFactory.createReferenceError("Undefined type reference", "service.protocols.rest.routes[0].responses[200].schema", { reference: "NonExistentType", availableTypes: ["User", "Post"] });
|
|
249
|
-
assert.ok(error instanceof UniSpecReferenceError);
|
|
250
|
-
assert.strictEqual(error.path, "service.protocols.rest.routes[0].responses[200].schema");
|
|
251
|
-
assert.deepStrictEqual(error.details, {
|
|
252
|
-
reference: "NonExistentType",
|
|
253
|
-
availableTypes: ["User", "Post"],
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
describe("Error edge cases", () => {
|
|
258
|
-
it("should handle errors with empty paths", () => {
|
|
259
|
-
const error = new UniSpecValidationError("Test", "test");
|
|
260
|
-
assert.strictEqual(error.path, "");
|
|
261
|
-
});
|
|
262
|
-
it("should handle errors with no details", () => {
|
|
263
|
-
const error = new UniSpecValidationError("Test", "test", "/path");
|
|
264
|
-
assert.strictEqual(error.details, undefined);
|
|
265
|
-
});
|
|
266
|
-
it("should handle warning severity", () => {
|
|
267
|
-
const error = new UniSpecValidationError("Warning message", "warning_code", "/path", "warning");
|
|
268
|
-
assert.strictEqual(error.severity, "warning");
|
|
269
|
-
});
|
|
270
|
-
it("should handle info severity", () => {
|
|
271
|
-
const error = new UniSpecValidationError("Info message", "info_code", "/path", "info");
|
|
272
|
-
assert.strictEqual(error.severity, "info");
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { describe, it } from "node:test";
|
|
4
|
-
import { loadUniSpec, validateDocumentSecurity } from "../../src/loader/index.js";
|
|
5
|
-
import { getExamplePath } from "../diff/utils.js";
|
|
6
|
-
describe("loader integration tests", () => {
|
|
7
|
-
describe("real examples from @unispechq/unispec-schema", () => {
|
|
8
|
-
it("should load all valid spec examples", async () => {
|
|
9
|
-
const validExamples = [
|
|
10
|
-
"valid/spec/rest-simple.json",
|
|
11
|
-
"valid/spec/graphql-simple.json",
|
|
12
|
-
"valid/spec/websocket-simple.json",
|
|
13
|
-
"valid/spec/mixed-complete.json",
|
|
14
|
-
];
|
|
15
|
-
for (const example of validExamples) {
|
|
16
|
-
const examplePath = getExamplePath(...example.split("/"));
|
|
17
|
-
const content = fs.readFileSync(examplePath, "utf-8");
|
|
18
|
-
const result = await loadUniSpec(content);
|
|
19
|
-
// Basic structure validation
|
|
20
|
-
assert.ok(result.unispecVersion, `Missing unispecVersion in ${example}`);
|
|
21
|
-
assert.ok(result.service, `Missing service in ${example}`);
|
|
22
|
-
assert.ok(result.service.name, `Missing service.name in ${example}`);
|
|
23
|
-
assert.ok(result.service.protocols, `Missing service.protocols in ${example}`);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
it("should parse invalid examples but not validate them", async () => {
|
|
27
|
-
const invalidExamples = [
|
|
28
|
-
"invalid/spec/missing-service-name.json",
|
|
29
|
-
"invalid/spec/missing-unispec-version.json",
|
|
30
|
-
"invalid/spec/invalid-identifier.json",
|
|
31
|
-
"invalid/spec/invalid-rest-method.json",
|
|
32
|
-
"invalid/spec/graphql-missing-arg-type.json",
|
|
33
|
-
"invalid/spec/graphql-missing-name.json",
|
|
34
|
-
];
|
|
35
|
-
for (const example of invalidExamples) {
|
|
36
|
-
const examplePath = getExamplePath(...example.split("/"));
|
|
37
|
-
const content = fs.readFileSync(examplePath, "utf-8");
|
|
38
|
-
// Should parse successfully (loader only handles parsing)
|
|
39
|
-
const result = await loadUniSpec(content);
|
|
40
|
-
// Should be an object
|
|
41
|
-
assert.ok(typeof result === "object", `Failed to parse ${example}`);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
it("should handle config examples", async () => {
|
|
45
|
-
const configExamples = [
|
|
46
|
-
"valid/config/complete-enterprise.json",
|
|
47
|
-
"valid/config/registry-based.json",
|
|
48
|
-
"valid/config/simple-multi-service.json",
|
|
49
|
-
];
|
|
50
|
-
for (const example of configExamples) {
|
|
51
|
-
const examplePath = getExamplePath(...example.split("/"));
|
|
52
|
-
const content = fs.readFileSync(examplePath, "utf-8");
|
|
53
|
-
const result = await loadUniSpec(content);
|
|
54
|
-
// Config examples should have version
|
|
55
|
-
assert.ok(result.version, `Missing version in config ${example}`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
it("should handle invalid config examples", async () => {
|
|
59
|
-
const invalidConfigExamples = [
|
|
60
|
-
"invalid/config/empty-services-array.json",
|
|
61
|
-
"invalid/config/invalid-spec-reference.json",
|
|
62
|
-
"invalid/config/missing-service-name.json",
|
|
63
|
-
"invalid/config/missing-services.json",
|
|
64
|
-
"invalid/config/missing-version.json",
|
|
65
|
-
];
|
|
66
|
-
for (const example of invalidConfigExamples) {
|
|
67
|
-
const examplePath = getExamplePath(...example.split("/"));
|
|
68
|
-
const content = fs.readFileSync(examplePath, "utf-8");
|
|
69
|
-
// Should parse successfully
|
|
70
|
-
const result = await loadUniSpec(content);
|
|
71
|
-
assert.ok(typeof result === "object", `Failed to parse ${example}`);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe("security validation with real examples", () => {
|
|
76
|
-
it("should validate security of complex examples", () => {
|
|
77
|
-
const complexExamplePath = getExamplePath("valid", "spec", "mixed-complete.json");
|
|
78
|
-
const content = fs.readFileSync(complexExamplePath, "utf-8");
|
|
79
|
-
const parsed = JSON.parse(content);
|
|
80
|
-
// Should pass default security validation
|
|
81
|
-
validateDocumentSecurity(parsed, {
|
|
82
|
-
maxDepth: 100,
|
|
83
|
-
maxKeys: 10000,
|
|
84
|
-
allowedTags: ["str", "int", "float", "bool", "null", "seq", "map"],
|
|
85
|
-
maxDocumentSize: 10 * 1024 * 1024,
|
|
86
|
-
strictYamlTags: false,
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
it("should detect depth violations in nested examples", () => {
|
|
90
|
-
// Create a deeply nested version of a valid example
|
|
91
|
-
const deepExample = {
|
|
92
|
-
unispecVersion: "1.0.0",
|
|
93
|
-
service: {
|
|
94
|
-
name: "test",
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
let current = deepExample;
|
|
98
|
-
for (let i = 0; i < 105; i++) {
|
|
99
|
-
current.nested = {};
|
|
100
|
-
current = current.nested;
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
validateDocumentSecurity(deepExample, {
|
|
104
|
-
maxDepth: 100,
|
|
105
|
-
maxKeys: 10000,
|
|
106
|
-
allowedTags: ["str", "int", "float", "bool", "null", "seq", "map"],
|
|
107
|
-
maxDocumentSize: 10 * 1024 * 1024,
|
|
108
|
-
strictYamlTags: false,
|
|
109
|
-
});
|
|
110
|
-
assert.fail("Should have thrown depth error");
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
assert.ok(error instanceof Error);
|
|
114
|
-
assert.ok(error.message.includes("depth"));
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe("yaml parsing edge cases", () => {
|
|
119
|
-
it("should handle YAML with special characters", async () => {
|
|
120
|
-
const yamlWithSpecialChars = `
|
|
121
|
-
unispecVersion: "1.0.0"
|
|
122
|
-
service:
|
|
123
|
-
name: "测试服务"
|
|
124
|
-
description: "Service with emojis 🚀 and special chars"
|
|
125
|
-
protocols:
|
|
126
|
-
rest:
|
|
127
|
-
routes:
|
|
128
|
-
- name: "getUser"
|
|
129
|
-
path: "/users/{id}"
|
|
130
|
-
method: "GET"
|
|
131
|
-
responses:
|
|
132
|
-
"200":
|
|
133
|
-
description: "Success ✅"
|
|
134
|
-
`;
|
|
135
|
-
const result = await loadUniSpec(yamlWithSpecialChars);
|
|
136
|
-
assert.strictEqual(result.service.name, "测试服务");
|
|
137
|
-
assert.ok(result.service.description?.includes("🚀"));
|
|
138
|
-
});
|
|
139
|
-
it("should handle YAML with anchors and references", async () => {
|
|
140
|
-
const yamlWithAnchors = `
|
|
141
|
-
unispecVersion: "1.0.0"
|
|
142
|
-
service:
|
|
143
|
-
name: "test-service"
|
|
144
|
-
protocols:
|
|
145
|
-
rest:
|
|
146
|
-
routes:
|
|
147
|
-
- name: "route1"
|
|
148
|
-
method: "GET"
|
|
149
|
-
path: "/path1"
|
|
150
|
-
responses: &common-responses
|
|
151
|
-
"200":
|
|
152
|
-
description: "Success"
|
|
153
|
-
- name: "route2"
|
|
154
|
-
method: "POST"
|
|
155
|
-
path: "/path2"
|
|
156
|
-
responses: *common-responses
|
|
157
|
-
`;
|
|
158
|
-
const result = await loadUniSpec(yamlWithAnchors);
|
|
159
|
-
assert.strictEqual(result.service.protocols?.rest?.routes?.length, 2);
|
|
160
|
-
});
|
|
161
|
-
it("should reject YAML with security issues", async () => {
|
|
162
|
-
const yamlWithSecurityIssue = `
|
|
163
|
-
unispecVersion: "1.0.0"
|
|
164
|
-
service:
|
|
165
|
-
name: "test"
|
|
166
|
-
protocols: !!js/function >
|
|
167
|
-
function() { return require('fs').readFileSync('/etc/passwd') }
|
|
168
|
-
`;
|
|
169
|
-
try {
|
|
170
|
-
await loadUniSpec(yamlWithSecurityIssue);
|
|
171
|
-
// If it doesn't throw, that's actually fine - the FAILSAFE_SCHEMA should block this
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
// Should either parse safely or throw a security-related error
|
|
175
|
-
assert.ok(error instanceof Error);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
describe("performance with large examples", () => {
|
|
180
|
-
it("should handle large documents efficiently", async () => {
|
|
181
|
-
// Create a large UniSpec document
|
|
182
|
-
const largeDoc = {
|
|
183
|
-
unispecVersion: "1.0.0",
|
|
184
|
-
service: {
|
|
185
|
-
name: "large-service",
|
|
186
|
-
protocols: {
|
|
187
|
-
rest: {
|
|
188
|
-
routes: [],
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
// Add many routes
|
|
194
|
-
for (let i = 0; i < 1000; i++) {
|
|
195
|
-
largeDoc.service.protocols.rest.routes.push({
|
|
196
|
-
name: `route${i}`,
|
|
197
|
-
path: `/route${i}`,
|
|
198
|
-
method: "GET",
|
|
199
|
-
responses: {
|
|
200
|
-
"200": { description: `Response ${i}` },
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
const startTime = Date.now();
|
|
205
|
-
const result = await loadUniSpec(largeDoc);
|
|
206
|
-
const endTime = Date.now();
|
|
207
|
-
assert.strictEqual(result.service.protocols?.rest?.routes?.length, 1000);
|
|
208
|
-
assert.ok(endTime - startTime < 1000, "Loading should complete within 1 second");
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|