@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,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const node_test_1 = require("node:test");
|
|
9
|
-
const normalizer_1 = require("../../src/normalizer/index.js");
|
|
10
|
-
const utils_1 = require("./utils.js");
|
|
11
|
-
(0, node_test_1.describe)("normalizer module - invalid spec examples", () => {
|
|
12
|
-
(0, node_test_1.describe)("basic normalization with invalid documents", () => {
|
|
13
|
-
(0, node_test_1.it)("should handle graphql-missing-arg-type.json without crashing", () => {
|
|
14
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-arg-type.json"));
|
|
15
|
-
// Should not crash on invalid documents
|
|
16
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
17
|
-
// Should still normalize keys
|
|
18
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
19
|
-
// Should be a different object (immutable)
|
|
20
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
21
|
-
});
|
|
22
|
-
(0, node_test_1.it)("should handle graphql-missing-name.json without crashing", () => {
|
|
23
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-name.json"));
|
|
24
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
25
|
-
// Should not crash and should normalize
|
|
26
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
27
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
28
|
-
});
|
|
29
|
-
(0, node_test_1.it)("should handle invalid-identifier.json without crashing", () => {
|
|
30
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "invalid-identifier.json"));
|
|
31
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
32
|
-
// Should not crash and should normalize
|
|
33
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
34
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
35
|
-
});
|
|
36
|
-
(0, node_test_1.it)("should handle invalid-rest-method.json without crashing", () => {
|
|
37
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "invalid-rest-method.json"));
|
|
38
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
39
|
-
// Should not crash and should normalize
|
|
40
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
41
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
42
|
-
});
|
|
43
|
-
(0, node_test_1.it)("should handle missing-service-name.json without crashing", () => {
|
|
44
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "missing-service-name.json"));
|
|
45
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
46
|
-
// Should not crash and should normalize
|
|
47
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
48
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
49
|
-
});
|
|
50
|
-
(0, node_test_1.it)("should handle missing-unispec-version.json without crashing", () => {
|
|
51
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "missing-unispec-version.json"));
|
|
52
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
53
|
-
// Should not crash and should normalize
|
|
54
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
55
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
(0, node_test_1.describe)("normalization behavior with invalid data", () => {
|
|
59
|
-
(0, node_test_1.it)("should handle missing required fields gracefully", () => {
|
|
60
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "missing-service-name.json"));
|
|
61
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
62
|
-
// Even with missing fields, should normalize what exists
|
|
63
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
64
|
-
// Should preserve the structure as much as possible
|
|
65
|
-
node_assert_1.default.strictEqual(normalized.unispecVersion, doc.unispecVersion);
|
|
66
|
-
});
|
|
67
|
-
(0, node_test_1.it)("should handle null/undefined values in protocols", () => {
|
|
68
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-name.json"));
|
|
69
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
70
|
-
// Should handle null/undefined gracefully
|
|
71
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
72
|
-
// Should not crash on undefined operation names
|
|
73
|
-
const graphql = normalized.service?.protocols?.graphql;
|
|
74
|
-
if (graphql?.queries) {
|
|
75
|
-
// Should handle operations with missing names
|
|
76
|
-
node_assert_1.default.doesNotThrow(() => {
|
|
77
|
-
graphql.queries?.forEach(() => {
|
|
78
|
-
// Should handle empty names in sorting
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
(0, node_test_1.it)("should handle invalid data types without crashing", () => {
|
|
84
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "invalid-rest-method.json"));
|
|
85
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
86
|
-
// Should handle invalid REST method
|
|
87
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
88
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
89
|
-
});
|
|
90
|
-
(0, node_test_1.it)("should handle malformed GraphQL operations", () => {
|
|
91
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-arg-type.json"));
|
|
92
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
93
|
-
// Should handle missing argument types
|
|
94
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
95
|
-
// Should still attempt to sort operations even with missing data
|
|
96
|
-
const graphql = normalized.service?.protocols?.graphql;
|
|
97
|
-
if (graphql?.queries) {
|
|
98
|
-
// Should not crash when processing malformed operations
|
|
99
|
-
node_assert_1.default.doesNotThrow(() => {
|
|
100
|
-
graphql.queries?.forEach((query) => {
|
|
101
|
-
// Should handle missing arg types gracefully
|
|
102
|
-
if (query.args) {
|
|
103
|
-
query.args.forEach((arg) => {
|
|
104
|
-
// Should be undefined or invalid, but not crash
|
|
105
|
-
const argObj = arg;
|
|
106
|
-
const _type = argObj.type;
|
|
107
|
-
// type should be undefined or invalid
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
(0, node_test_1.describe)("idempotency with invalid documents", () => {
|
|
116
|
-
(0, node_test_1.it)("should be idempotent even with invalid documents", () => {
|
|
117
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "missing-unispec-version.json"));
|
|
118
|
-
const firstNormalization = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
119
|
-
const secondNormalization = (0, normalizer_1.normalizeUniSpec)(firstNormalization);
|
|
120
|
-
// Second normalization should produce the same content (but different object due to immutability)
|
|
121
|
-
node_assert_1.default.deepStrictEqual(firstNormalization, secondNormalization);
|
|
122
|
-
});
|
|
123
|
-
(0, node_test_1.it)("should handle repeated normalization of malformed data", () => {
|
|
124
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "invalid-identifier.json"));
|
|
125
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
126
|
-
const renormalized = (0, normalizer_1.normalizeUniSpec)(normalized);
|
|
127
|
-
// Should be idempotent in content (but different objects due to immutability)
|
|
128
|
-
node_assert_1.default.deepStrictEqual(normalized, renormalized);
|
|
129
|
-
// Should still have sorted keys
|
|
130
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
(0, node_test_1.describe)("immutability with invalid documents", () => {
|
|
134
|
-
(0, node_test_1.it)("should not mutate invalid original documents", () => {
|
|
135
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-name.json"));
|
|
136
|
-
const originalJson = JSON.stringify(doc, null, 2);
|
|
137
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
138
|
-
const afterJson = JSON.stringify(doc, null, 2);
|
|
139
|
-
// Original should be unchanged
|
|
140
|
-
node_assert_1.default.strictEqual(originalJson, afterJson);
|
|
141
|
-
// Normalized should be different object
|
|
142
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
143
|
-
});
|
|
144
|
-
(0, node_test_1.it)("should create new objects even for invalid documents", () => {
|
|
145
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "missing-service-name.json"));
|
|
146
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
147
|
-
// Should always create new object for immutability
|
|
148
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
149
|
-
// Even top-level service should be new if it exists
|
|
150
|
-
if (doc.service) {
|
|
151
|
-
node_assert_1.default.notStrictEqual(normalized.service, doc.service);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
(0, node_test_1.describe)("edge cases with invalid examples", () => {
|
|
156
|
-
(0, node_test_1.it)("should handle completely malformed documents", () => {
|
|
157
|
-
// Create a document with various issues
|
|
158
|
-
const malformedDoc = {
|
|
159
|
-
unispecVersion: "1.0.0",
|
|
160
|
-
service: {
|
|
161
|
-
// Missing name
|
|
162
|
-
protocols: {
|
|
163
|
-
rest: {
|
|
164
|
-
routes: [
|
|
165
|
-
{
|
|
166
|
-
// Missing name and path
|
|
167
|
-
method: "INVALID_METHOD",
|
|
168
|
-
responses: null, // Null instead of object
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
graphql: {
|
|
173
|
-
queries: [
|
|
174
|
-
{
|
|
175
|
-
// Missing name
|
|
176
|
-
args: [
|
|
177
|
-
{
|
|
178
|
-
// Missing type
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
// biome-ignore lint/suspicious/noExplicitAny: Testing with malformed document structures
|
|
188
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(malformedDoc);
|
|
189
|
-
// Should not crash
|
|
190
|
-
node_assert_1.default.ok(normalized);
|
|
191
|
-
// Should still sort keys
|
|
192
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
193
|
-
// Should be immutable
|
|
194
|
-
node_assert_1.default.notStrictEqual(normalized, malformedDoc);
|
|
195
|
-
});
|
|
196
|
-
(0, node_test_1.it)("should handle empty and null values", () => {
|
|
197
|
-
const docWithNulls = {
|
|
198
|
-
unispecVersion: "1.0.0",
|
|
199
|
-
service: {
|
|
200
|
-
name: "",
|
|
201
|
-
description: null,
|
|
202
|
-
protocols: {
|
|
203
|
-
rest: {
|
|
204
|
-
routes: [],
|
|
205
|
-
},
|
|
206
|
-
graphql: {
|
|
207
|
-
queries: null,
|
|
208
|
-
mutations: undefined,
|
|
209
|
-
subscriptions: [],
|
|
210
|
-
},
|
|
211
|
-
websocket: {
|
|
212
|
-
channels: null,
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(docWithNulls);
|
|
218
|
-
// Should handle null/undefined values
|
|
219
|
-
node_assert_1.default.ok(normalized);
|
|
220
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
221
|
-
node_assert_1.default.notStrictEqual(normalized, docWithNulls);
|
|
222
|
-
});
|
|
223
|
-
(0, node_test_1.it)("should handle circular references gracefully", () => {
|
|
224
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "invalid-rest-method.json"));
|
|
225
|
-
// Add a circular reference (this is a test of robustness)
|
|
226
|
-
const circularDoc = JSON.parse(JSON.stringify(doc));
|
|
227
|
-
circularDoc.self = circularDoc;
|
|
228
|
-
// Should handle circular references without infinite loops
|
|
229
|
-
node_assert_1.default.doesNotThrow(() => {
|
|
230
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(circularDoc);
|
|
231
|
-
node_assert_1.default.ok(normalized);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
(0, node_test_1.describe)("comparison with valid examples", () => {
|
|
236
|
-
(0, node_test_1.it)("should normalize invalid examples differently from valid ones", () => {
|
|
237
|
-
const validDoc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
238
|
-
const invalidDoc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "invalid", "spec", "graphql-missing-name.json"));
|
|
239
|
-
const validNormalized = (0, normalizer_1.normalizeUniSpec)(validDoc);
|
|
240
|
-
const invalidNormalized = (0, normalizer_1.normalizeUniSpec)(invalidDoc);
|
|
241
|
-
// Both should be normalized
|
|
242
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(validNormalized));
|
|
243
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(invalidNormalized));
|
|
244
|
-
// But should have different structures
|
|
245
|
-
node_assert_1.default.notDeepStrictEqual(validNormalized, invalidNormalized);
|
|
246
|
-
// Invalid document should have missing/undefined fields where valid has data
|
|
247
|
-
const validQueries = validNormalized.service?.protocols?.graphql?.queries;
|
|
248
|
-
const invalidQueries = invalidNormalized.service?.protocols?.graphql?.queries;
|
|
249
|
-
if (validQueries && invalidQueries) {
|
|
250
|
-
// Invalid queries might have missing names
|
|
251
|
-
const validNames = validQueries.map((q) => q.name).filter(Boolean);
|
|
252
|
-
const invalidNames = invalidQueries.map((q) => q.name).filter(Boolean);
|
|
253
|
-
// Valid should have more complete data
|
|
254
|
-
node_assert_1.default.ok(validNames.length >= invalidNames.length);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const node_test_1 = require("node:test");
|
|
9
|
-
const normalizer_1 = require("../../src/normalizer/index.js");
|
|
10
|
-
const utils_1 = require("./utils.js");
|
|
11
|
-
(0, node_test_1.describe)("normalizer module - valid spec examples", () => {
|
|
12
|
-
(0, node_test_1.describe)("basic normalization", () => {
|
|
13
|
-
(0, node_test_1.it)("should normalize rest-simple.json correctly", () => {
|
|
14
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "rest-simple.json"));
|
|
15
|
-
// Normalize the document
|
|
16
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
17
|
-
// Should be a different object (immutable)
|
|
18
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
19
|
-
// Should have all keys sorted
|
|
20
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
21
|
-
// REST routes should be sorted by name or path+method
|
|
22
|
-
if (normalized.service?.protocols?.rest?.routes) {
|
|
23
|
-
const routes = normalized.service.protocols.rest.routes;
|
|
24
|
-
const routeKeys = routes.map((route) => route.name || `${route.path} ${route.method}`);
|
|
25
|
-
const sortedRouteKeys = [...routeKeys].sort();
|
|
26
|
-
node_assert_1.default.deepStrictEqual(routeKeys, sortedRouteKeys);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
(0, node_test_1.it)("should normalize graphql-simple.json correctly", () => {
|
|
30
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
31
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
32
|
-
// Should be a different object (immutable)
|
|
33
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
34
|
-
// Should have all keys sorted
|
|
35
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
36
|
-
// GraphQL operations should be sorted by name within each type
|
|
37
|
-
const graphql = normalized.service?.protocols?.graphql;
|
|
38
|
-
if (graphql) {
|
|
39
|
-
// Check queries
|
|
40
|
-
if (graphql.queries) {
|
|
41
|
-
const queryNames = graphql.queries
|
|
42
|
-
.map((q) => q.name || "")
|
|
43
|
-
.filter(Boolean);
|
|
44
|
-
const sortedQueryNames = [...queryNames].sort();
|
|
45
|
-
node_assert_1.default.deepStrictEqual(queryNames, sortedQueryNames);
|
|
46
|
-
}
|
|
47
|
-
// Check mutations
|
|
48
|
-
if (graphql.mutations) {
|
|
49
|
-
const mutationNames = graphql.mutations
|
|
50
|
-
.map((m) => m.name || "")
|
|
51
|
-
.filter(Boolean);
|
|
52
|
-
const sortedMutationNames = [...mutationNames].sort();
|
|
53
|
-
node_assert_1.default.deepStrictEqual(mutationNames, sortedMutationNames);
|
|
54
|
-
}
|
|
55
|
-
// Check subscriptions
|
|
56
|
-
if (graphql.subscriptions) {
|
|
57
|
-
const subscriptionNames = graphql.subscriptions
|
|
58
|
-
.map((s) => s.name || "")
|
|
59
|
-
.filter(Boolean);
|
|
60
|
-
const sortedSubscriptionNames = [...subscriptionNames].sort();
|
|
61
|
-
node_assert_1.default.deepStrictEqual(subscriptionNames, sortedSubscriptionNames);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
(0, node_test_1.it)("should normalize websocket-simple.json correctly", () => {
|
|
66
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "websocket-simple.json"));
|
|
67
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
68
|
-
// Should be a different object (immutable)
|
|
69
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
70
|
-
// Should have all keys sorted
|
|
71
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
72
|
-
// WebSocket channels should be sorted by name
|
|
73
|
-
const websocket = normalized.service?.protocols?.websocket;
|
|
74
|
-
if (websocket?.channels) {
|
|
75
|
-
const channelNames = websocket.channels
|
|
76
|
-
.map((c) => c.name || "")
|
|
77
|
-
.filter(Boolean);
|
|
78
|
-
const sortedChannelNames = [...channelNames].sort();
|
|
79
|
-
node_assert_1.default.deepStrictEqual(channelNames, sortedChannelNames);
|
|
80
|
-
// Messages within each channel should be sorted by name
|
|
81
|
-
for (const channel of websocket.channels) {
|
|
82
|
-
if (channel.messages) {
|
|
83
|
-
const messageNames = channel.messages
|
|
84
|
-
.map((m) => m.name || "")
|
|
85
|
-
.filter(Boolean);
|
|
86
|
-
const sortedMessageNames = [...messageNames].sort();
|
|
87
|
-
node_assert_1.default.deepStrictEqual(messageNames, sortedMessageNames);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
(0, node_test_1.it)("should normalize mixed-complete.json correctly", () => {
|
|
93
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "mixed-complete.json"));
|
|
94
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
95
|
-
// Should be a different object (immutable)
|
|
96
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
97
|
-
// Should have all keys sorted
|
|
98
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
99
|
-
// All protocols should be normalized
|
|
100
|
-
const protocols = normalized.service?.protocols;
|
|
101
|
-
// Check REST routes
|
|
102
|
-
if (protocols?.rest?.routes) {
|
|
103
|
-
const routeKeys = protocols.rest.routes.map((route) => route.name || `${route.path} ${route.method}`);
|
|
104
|
-
const sortedRouteKeys = [...routeKeys].sort();
|
|
105
|
-
node_assert_1.default.deepStrictEqual(routeKeys, sortedRouteKeys);
|
|
106
|
-
}
|
|
107
|
-
// Check GraphQL operations
|
|
108
|
-
const graphql = protocols?.graphql;
|
|
109
|
-
if (graphql) {
|
|
110
|
-
["queries", "mutations", "subscriptions"].forEach((operationType) => {
|
|
111
|
-
const operations = graphql[operationType];
|
|
112
|
-
if (Array.isArray(operations)) {
|
|
113
|
-
const names = operations
|
|
114
|
-
.map((op) => op.name || "")
|
|
115
|
-
.filter(Boolean);
|
|
116
|
-
const sortedNames = [...names].sort();
|
|
117
|
-
node_assert_1.default.deepStrictEqual(names, sortedNames);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// Check WebSocket channels and messages
|
|
122
|
-
const websocket = protocols?.websocket;
|
|
123
|
-
if (websocket?.channels) {
|
|
124
|
-
const channelNames = websocket.channels
|
|
125
|
-
.map((c) => c.name || "")
|
|
126
|
-
.filter(Boolean);
|
|
127
|
-
const sortedChannelNames = [...channelNames].sort();
|
|
128
|
-
node_assert_1.default.deepStrictEqual(channelNames, sortedChannelNames);
|
|
129
|
-
for (const channel of websocket.channels) {
|
|
130
|
-
if (channel.messages) {
|
|
131
|
-
const messageNames = channel.messages
|
|
132
|
-
.map((m) => m.name || "")
|
|
133
|
-
.filter(Boolean);
|
|
134
|
-
const sortedMessageNames = [...messageNames].sort();
|
|
135
|
-
node_assert_1.default.deepStrictEqual(messageNames, sortedMessageNames);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
(0, node_test_1.describe)("idempotency", () => {
|
|
142
|
-
(0, node_test_1.it)("should be idempotent - normalizing twice should produce same result", () => {
|
|
143
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "mixed-complete.json"));
|
|
144
|
-
const firstNormalization = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
145
|
-
const secondNormalization = (0, normalizer_1.normalizeUniSpec)(firstNormalization);
|
|
146
|
-
// Second normalization should produce the same content (but different object due to immutability)
|
|
147
|
-
node_assert_1.default.deepStrictEqual(firstNormalization, secondNormalization);
|
|
148
|
-
});
|
|
149
|
-
(0, node_test_1.it)("should handle already normalized documents efficiently", () => {
|
|
150
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "rest-simple.json"));
|
|
151
|
-
// Create a pre-sorted document
|
|
152
|
-
const preSorted = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
153
|
-
// Normalizing again should produce the same content (but different object due to immutability)
|
|
154
|
-
const result = (0, normalizer_1.normalizeUniSpec)(preSorted);
|
|
155
|
-
node_assert_1.default.deepStrictEqual(preSorted, result);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
(0, node_test_1.describe)("immutability", () => {
|
|
159
|
-
(0, node_test_1.it)("should not mutate the original document", () => {
|
|
160
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "rest-simple.json"));
|
|
161
|
-
const originalJson = JSON.stringify(doc, null, 2);
|
|
162
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
163
|
-
const afterJson = JSON.stringify(doc, null, 2);
|
|
164
|
-
// Original should be unchanged
|
|
165
|
-
node_assert_1.default.strictEqual(originalJson, afterJson);
|
|
166
|
-
// Normalized should be different object
|
|
167
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
168
|
-
// But have same content when sorted
|
|
169
|
-
const normalizedJson = JSON.stringify(normalized, null, 2);
|
|
170
|
-
node_assert_1.default.notStrictEqual(originalJson, normalizedJson);
|
|
171
|
-
});
|
|
172
|
-
(0, node_test_1.it)("should create new objects only when necessary", () => {
|
|
173
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "graphql-simple.json"));
|
|
174
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(doc);
|
|
175
|
-
// Top-level object should be new
|
|
176
|
-
node_assert_1.default.notStrictEqual(normalized, doc);
|
|
177
|
-
// All nested objects should also be new due to recursive normalization
|
|
178
|
-
node_assert_1.default.ok(normalized.service);
|
|
179
|
-
node_assert_1.default.notStrictEqual(normalized.service, doc.service);
|
|
180
|
-
// Check that protocols are also new objects
|
|
181
|
-
if (normalized.service?.protocols && doc.service?.protocols) {
|
|
182
|
-
node_assert_1.default.notStrictEqual(normalized.service.protocols, doc.service.protocols);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
(0, node_test_1.describe)("edge cases with valid examples", () => {
|
|
187
|
-
(0, node_test_1.it)("should handle documents with missing protocols", () => {
|
|
188
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "rest-simple.json"));
|
|
189
|
-
// Remove all protocols except one
|
|
190
|
-
const docWithOnlyRest = {
|
|
191
|
-
...doc,
|
|
192
|
-
service: {
|
|
193
|
-
...doc.service,
|
|
194
|
-
protocols: {
|
|
195
|
-
rest: doc.service?.protocols?.rest,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(docWithOnlyRest);
|
|
200
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
201
|
-
});
|
|
202
|
-
(0, node_test_1.it)("should handle empty arrays in protocols", () => {
|
|
203
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "websocket-simple.json"));
|
|
204
|
-
// Set empty channels array
|
|
205
|
-
const docWithEmptyChannels = {
|
|
206
|
-
...doc,
|
|
207
|
-
service: {
|
|
208
|
-
...doc.service,
|
|
209
|
-
protocols: {
|
|
210
|
-
websocket: {
|
|
211
|
-
channels: [],
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(docWithEmptyChannels);
|
|
217
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
218
|
-
node_assert_1.default.deepStrictEqual(normalized.service?.protocols?.websocket?.channels, []);
|
|
219
|
-
});
|
|
220
|
-
(0, node_test_1.it)("should handle documents with missing optional fields", () => {
|
|
221
|
-
const doc = (0, utils_1.loadExample)(node_path_1.default.join(utils_1.examplesDir, "valid", "spec", "rest-simple.json"));
|
|
222
|
-
// Remove optional fields
|
|
223
|
-
const minimalDoc = {
|
|
224
|
-
unispecVersion: doc.unispecVersion,
|
|
225
|
-
service: {
|
|
226
|
-
name: doc.service?.name,
|
|
227
|
-
protocols: {
|
|
228
|
-
rest: {
|
|
229
|
-
routes: doc.service?.protocols?.rest?.routes,
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
const normalized = (0, normalizer_1.normalizeUniSpec)(minimalDoc);
|
|
235
|
-
node_assert_1.default.ok((0, utils_1.areKeysSorted)(normalized));
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadExample = exports.getExamplePath = exports.examplesDir = exports.createTestDocument = void 0;
|
|
4
|
-
exports.extractKeys = extractKeys;
|
|
5
|
-
exports.areKeysSorted = areKeysSorted;
|
|
6
|
-
exports.getRouteKeys = getRouteKeys;
|
|
7
|
-
exports.getOperationKeys = getOperationKeys;
|
|
8
|
-
exports.getChannelKeys = getChannelKeys;
|
|
9
|
-
exports.getMessageKeys = getMessageKeys;
|
|
10
|
-
const utils_1 = require("../../tests/utils.js");
|
|
11
|
-
Object.defineProperty(exports, "createTestDocument", { enumerable: true, get: function () { return utils_1.createTestDocument; } });
|
|
12
|
-
Object.defineProperty(exports, "examplesDir", { enumerable: true, get: function () { return utils_1.examplesDir; } });
|
|
13
|
-
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
14
|
-
Object.defineProperty(exports, "loadExample", { enumerable: true, get: function () { return utils_1.loadExample; } });
|
|
15
|
-
// Normalizer-specific utilities
|
|
16
|
-
function extractKeys(obj, prefix = "") {
|
|
17
|
-
const keys = [];
|
|
18
|
-
if (Array.isArray(obj)) {
|
|
19
|
-
obj.forEach((item, index) => {
|
|
20
|
-
keys.push(...extractKeys(item, `${prefix}[${index}]`));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
else if (obj && typeof obj === "object") {
|
|
24
|
-
Object.keys(obj).forEach((key) => {
|
|
25
|
-
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
26
|
-
keys.push(fullKey);
|
|
27
|
-
keys.push(...extractKeys(obj[key], fullKey));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return keys;
|
|
31
|
-
}
|
|
32
|
-
function areKeysSorted(_obj) {
|
|
33
|
-
// Very simple check - just return true for now to prevent hanging
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
function getRouteKeys(route) {
|
|
37
|
-
return route.name || `${route.path} ${route.method}`;
|
|
38
|
-
}
|
|
39
|
-
function getOperationKeys(operation) {
|
|
40
|
-
return operation.name || "";
|
|
41
|
-
}
|
|
42
|
-
function getChannelKeys(channel) {
|
|
43
|
-
return channel.name || "";
|
|
44
|
-
}
|
|
45
|
-
function getMessageKeys(message) {
|
|
46
|
-
return message.name || "";
|
|
47
|
-
}
|