@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
package/dist/src/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./cache/index.js";
|
|
2
|
-
export * from "./diff/index.js";
|
|
3
|
-
export * from "./loader/index.js";
|
|
4
|
-
export * from "./normalizer/index.js";
|
|
5
|
-
export * from "./optimizer/index.js";
|
|
6
|
-
export * from "./schemas/index.js";
|
|
7
|
-
export * from "./types/index.js";
|
|
8
|
-
export * from "./validator/index.js";
|
|
9
|
-
export * from "./validator/object-traversal.js";
|
|
10
|
-
export * from "./validator/reference-validator.js";
|
|
11
|
-
export * from "./validator/schema-references.js";
|
|
12
|
-
export * from "./validator/semantic-validator.js";
|
|
13
|
-
export * from "./versions.js";
|
package/dist/src/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// CORE TYPES AND INTERFACES
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// ============================================================================
|
|
5
|
-
// CACHING SYSTEM
|
|
6
|
-
// ============================================================================
|
|
7
|
-
export * from "./cache/index.js";
|
|
8
|
-
// ============================================================================
|
|
9
|
-
// DIFF AND CHANGE ANALYSIS
|
|
10
|
-
// ============================================================================
|
|
11
|
-
export * from "./diff/index.js";
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// DOCUMENT LOADING AND PARSING
|
|
14
|
-
// ============================================================================
|
|
15
|
-
export * from "./loader/index.js";
|
|
16
|
-
// ============================================================================
|
|
17
|
-
// DOCUMENT NORMALIZATION
|
|
18
|
-
// ============================================================================
|
|
19
|
-
export * from "./normalizer/index.js";
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// DOCUMENT OPTIMIZATION
|
|
22
|
-
// ============================================================================
|
|
23
|
-
export * from "./optimizer/index.js";
|
|
24
|
-
// ============================================================================
|
|
25
|
-
// SCHEMA MANAGEMENT
|
|
26
|
-
// ============================================================================
|
|
27
|
-
export * from "./schemas/index.js";
|
|
28
|
-
export * from "./types/index.js";
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// VALIDATION SYSTEM
|
|
31
|
-
// ============================================================================
|
|
32
|
-
export * from "./validator/index.js";
|
|
33
|
-
// ============================================================================
|
|
34
|
-
// UTILITY FUNCTIONS
|
|
35
|
-
// ============================================================================
|
|
36
|
-
export * from "./validator/object-traversal.js";
|
|
37
|
-
export * from "./validator/reference-validator.js";
|
|
38
|
-
export * from "./validator/schema-references.js";
|
|
39
|
-
export * from "./validator/semantic-validator.js";
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// VERSION INFORMATION
|
|
42
|
-
// ============================================================================
|
|
43
|
-
export * from "./versions.js";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { validateDocumentSecurity } from "./security-validator.js";
|
|
2
|
-
export type { LoadOptions, SecureLoadOptions } from "./types.js";
|
|
3
|
-
export { ALLOWED_YAML_MODULES } from "./types.js";
|
|
4
|
-
export { loadUniSpec } from "./unispec-loader.js";
|
|
5
|
-
export { getYamlModule, validateYamlModule } from "./yaml-loader.js";
|
package/dist/src/loader/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Export all loader functionality
|
|
2
|
-
export { validateDocumentSecurity } from "./security-validator.js";
|
|
3
|
-
export { ALLOWED_YAML_MODULES } from "./types.js";
|
|
4
|
-
export { loadUniSpec } from "./unispec-loader.js";
|
|
5
|
-
export { getYamlModule, validateYamlModule } from "./yaml-loader.js";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ErrorFactory } from "../errors/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Validate document security constraints using iterative approach to prevent stack overflow.
|
|
4
|
-
*/
|
|
5
|
-
export function validateDocumentSecurity(doc, options) {
|
|
6
|
-
let keyCount = 0;
|
|
7
|
-
let maxDepth = 0;
|
|
8
|
-
// Use stack-based iteration instead of recursion
|
|
9
|
-
const stack = [
|
|
10
|
-
{ obj: doc, depth: 0, path: "" },
|
|
11
|
-
];
|
|
12
|
-
while (stack.length > 0) {
|
|
13
|
-
const item = stack.pop();
|
|
14
|
-
if (!item)
|
|
15
|
-
break;
|
|
16
|
-
const { obj, depth, path } = item;
|
|
17
|
-
// Check depth limit
|
|
18
|
-
if (depth > options.maxDepth) {
|
|
19
|
-
throw ErrorFactory.createSecurityError(`Document depth (${depth}) exceeds maximum allowed depth (${options.maxDepth}) at path: ${path}`, path, { currentDepth: depth, maxDepth: options.maxDepth });
|
|
20
|
-
}
|
|
21
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
22
|
-
if (Array.isArray(obj)) {
|
|
23
|
-
// Process array elements
|
|
24
|
-
for (let i = obj.length - 1; i >= 0; i--) {
|
|
25
|
-
stack.push({
|
|
26
|
-
obj: obj[i],
|
|
27
|
-
depth: depth + 1,
|
|
28
|
-
path: `${path}[${i}]`,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else if (obj && typeof obj === "object") {
|
|
33
|
-
// Process object properties
|
|
34
|
-
const objRecord = obj;
|
|
35
|
-
const keys = Object.keys(objRecord);
|
|
36
|
-
for (let i = keys.length - 1; i >= 0; i--) {
|
|
37
|
-
const key = keys[i];
|
|
38
|
-
keyCount++;
|
|
39
|
-
if (keyCount > options.maxKeys) {
|
|
40
|
-
throw ErrorFactory.createSecurityError(`Document key count (${keyCount}) exceeds maximum allowed keys (${options.maxKeys}) at path: ${path}`, path, { keyCount, maxKeys: options.maxKeys });
|
|
41
|
-
}
|
|
42
|
-
stack.push({
|
|
43
|
-
obj: objRecord[key],
|
|
44
|
-
depth: depth + 1,
|
|
45
|
-
path: path ? `${path}.${key}` : key,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface LoadOptions {
|
|
2
|
-
filename?: string;
|
|
3
|
-
maxDepth?: number;
|
|
4
|
-
maxKeys?: number;
|
|
5
|
-
allowedTags?: string[];
|
|
6
|
-
maxDocumentSize?: number;
|
|
7
|
-
strictYamlTags?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface SecureLoadOptions {
|
|
10
|
-
maxDepth: number;
|
|
11
|
-
maxKeys: number;
|
|
12
|
-
allowedTags: string[];
|
|
13
|
-
maxDocumentSize: number;
|
|
14
|
-
strictYamlTags: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Allowed YAML module patterns for security validation.
|
|
18
|
-
*/
|
|
19
|
-
export declare const ALLOWED_YAML_MODULES: readonly ["js-yaml", "@js-yaml/fork", "yaml"];
|
|
20
|
-
export interface YamlSchema {
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
}
|
|
23
|
-
export interface YamlModule {
|
|
24
|
-
load: (input: string, options?: {
|
|
25
|
-
schema?: YamlSchema;
|
|
26
|
-
filename?: string;
|
|
27
|
-
}) => unknown;
|
|
28
|
-
FAILSAFE_SCHEMA: YamlSchema;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
package/dist/src/loader/types.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import type { LoadOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Load a UniSpec document from a raw input value.
|
|
5
|
-
* Supports:
|
|
6
|
-
* - JavaScript objects (treated as already parsed UniSpec)
|
|
7
|
-
* - JSON strings
|
|
8
|
-
* - YAML strings
|
|
9
|
-
*/
|
|
10
|
-
export declare function loadUniSpec(input: string | object, options?: LoadOptions): Promise<UniSpecDocument>;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ErrorFactory } from "../errors/index.js";
|
|
2
|
-
import { validateDocumentSecurity } from "./security-validator.js";
|
|
3
|
-
import { getYamlModule } from "./yaml-loader.js";
|
|
4
|
-
/**
|
|
5
|
-
* Load a UniSpec document from a raw input value.
|
|
6
|
-
* Supports:
|
|
7
|
-
* - JavaScript objects (treated as already parsed UniSpec)
|
|
8
|
-
* - JSON strings
|
|
9
|
-
* - YAML strings
|
|
10
|
-
*/
|
|
11
|
-
export async function loadUniSpec(input, options = {}) {
|
|
12
|
-
// Set default security limits
|
|
13
|
-
const secureOptions = {
|
|
14
|
-
maxDepth: options.maxDepth ?? 100,
|
|
15
|
-
maxKeys: options.maxKeys ?? 10000,
|
|
16
|
-
allowedTags: options.allowedTags ?? [
|
|
17
|
-
"str",
|
|
18
|
-
"int",
|
|
19
|
-
"float",
|
|
20
|
-
"bool",
|
|
21
|
-
"null",
|
|
22
|
-
"seq",
|
|
23
|
-
"map",
|
|
24
|
-
"binary",
|
|
25
|
-
"timestamp",
|
|
26
|
-
"merge",
|
|
27
|
-
"omap",
|
|
28
|
-
"pairs",
|
|
29
|
-
"set",
|
|
30
|
-
],
|
|
31
|
-
maxDocumentSize: options.maxDocumentSize ?? 10 * 1024 * 1024,
|
|
32
|
-
strictYamlTags: options.strictYamlTags ?? false,
|
|
33
|
-
};
|
|
34
|
-
if (typeof input === "string") {
|
|
35
|
-
const trimmed = input.trim();
|
|
36
|
-
if (!trimmed) {
|
|
37
|
-
throw ErrorFactory.createLoaderError("Cannot load UniSpec: input string is empty", "");
|
|
38
|
-
}
|
|
39
|
-
// Check document size limit
|
|
40
|
-
if (trimmed.length > secureOptions.maxDocumentSize) {
|
|
41
|
-
throw ErrorFactory.createSecurityError(`Document size (${trimmed.length} bytes) exceeds maximum allowed size (${secureOptions.maxDocumentSize} bytes)`, "", {
|
|
42
|
-
documentSize: trimmed.length,
|
|
43
|
-
maxSize: secureOptions.maxDocumentSize,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Try JSON first (faster and more common)
|
|
47
|
-
try {
|
|
48
|
-
const parsed = JSON.parse(trimmed);
|
|
49
|
-
validateDocumentSecurity(parsed, secureOptions);
|
|
50
|
-
return parsed;
|
|
51
|
-
}
|
|
52
|
-
catch (jsonError) {
|
|
53
|
-
// If JSON fails, try YAML with security validation
|
|
54
|
-
try {
|
|
55
|
-
// Get validated YAML module
|
|
56
|
-
const yaml = await getYamlModule();
|
|
57
|
-
const doc = yaml.load(trimmed, {
|
|
58
|
-
filename: options.filename,
|
|
59
|
-
// Enhanced security options
|
|
60
|
-
schema: yaml.FAILSAFE_SCHEMA,
|
|
61
|
-
// Additional security constraints would go here if the library supports them
|
|
62
|
-
});
|
|
63
|
-
validateDocumentSecurity(doc, secureOptions);
|
|
64
|
-
return doc;
|
|
65
|
-
}
|
|
66
|
-
catch (yamlError) {
|
|
67
|
-
const jsonMsg = jsonError instanceof Error ? jsonError.message : String(jsonError);
|
|
68
|
-
const yamlMsg = yamlError instanceof Error ? yamlError.message : String(yamlError);
|
|
69
|
-
// Create specific error based on what failed
|
|
70
|
-
if (yamlMsg.includes("not in the allowed list") ||
|
|
71
|
-
yamlMsg.includes("security")) {
|
|
72
|
-
const securityError = ErrorFactory.fromError(yamlError, "yaml_security_error");
|
|
73
|
-
throw securityError;
|
|
74
|
-
}
|
|
75
|
-
throw ErrorFactory.createLoaderError(`Failed to parse input as JSON or YAML. JSON error: ${jsonMsg}. YAML error: ${yamlMsg}`, "", { jsonError: jsonMsg, yamlError: yamlMsg });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
validateDocumentSecurity(input, secureOptions);
|
|
80
|
-
return input;
|
|
81
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { YamlModule } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Securely load YAML module with validation.
|
|
4
|
-
* Uses static import path and validates the module structure.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getYamlModule(): Promise<YamlModule>;
|
|
7
|
-
/**
|
|
8
|
-
* Validate YAML module for security.
|
|
9
|
-
*/
|
|
10
|
-
export declare function validateYamlModule(yamlModule: unknown): asserts yamlModule is YamlModule;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ErrorFactory } from "../errors/index.js";
|
|
2
|
-
// Static import with security validation
|
|
3
|
-
let yamlModule = null;
|
|
4
|
-
/**
|
|
5
|
-
* Securely load YAML module with validation.
|
|
6
|
-
* Uses static import path and validates the module structure.
|
|
7
|
-
*/
|
|
8
|
-
export async function getYamlModule() {
|
|
9
|
-
if (yamlModule) {
|
|
10
|
-
return yamlModule;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
// Use static import path for security
|
|
14
|
-
const importedModule = (await import("js-yaml"));
|
|
15
|
-
validateYamlModule(importedModule);
|
|
16
|
-
yamlModule = importedModule;
|
|
17
|
-
return yamlModule;
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
throw ErrorFactory.createSecurityError("Failed to load and validate YAML module", "", { error: error instanceof Error ? error.message : String(error) });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Validate YAML module for security.
|
|
25
|
-
*/
|
|
26
|
-
export function validateYamlModule(yamlModule) {
|
|
27
|
-
if (!yamlModule || typeof yamlModule !== "object") {
|
|
28
|
-
throw ErrorFactory.createLoaderError("Invalid YAML module: module must be an object", "", { moduleType: typeof yamlModule });
|
|
29
|
-
}
|
|
30
|
-
const module = yamlModule;
|
|
31
|
-
// Check for required functions
|
|
32
|
-
if (!module.load || typeof module.load !== "function") {
|
|
33
|
-
throw ErrorFactory.createLoaderError("Invalid YAML module: missing load function", "", { hasLoad: !!module.load, loadType: typeof module.load });
|
|
34
|
-
}
|
|
35
|
-
// Check for FAILSAFE_SCHEMA
|
|
36
|
-
if (!module.FAILSAFE_SCHEMA) {
|
|
37
|
-
throw ErrorFactory.createSecurityError("YAML module must support FAILSAFE_SCHEMA for security", "", { hasFailsafeSchema: !!module.FAILSAFE_SCHEMA });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import type { NormalizeOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Normalize a UniSpec document into a canonical, deterministic form.
|
|
5
|
-
*
|
|
6
|
-
* This function ensures consistent representation of UniSpec documents
|
|
7
|
-
* by sorting object keys and protocol-specific structures in a predictable order.
|
|
8
|
-
* Useful for:
|
|
9
|
-
* - Generating stable diffs between documents
|
|
10
|
-
* - Creating consistent output for caching
|
|
11
|
-
* - Ensuring reproducible builds
|
|
12
|
-
*
|
|
13
|
-
* Current behavior:
|
|
14
|
-
* - Recursively sorts object keys lexicographically
|
|
15
|
-
* - Sorts REST routes by name or path+method
|
|
16
|
-
* - Sorts GraphQL operations by name within each operation type
|
|
17
|
-
* - Sorts WebSocket channels and messages by name
|
|
18
|
-
* - Preserves all values as-is
|
|
19
|
-
*
|
|
20
|
-
* @param doc - The UniSpec document to normalize
|
|
21
|
-
* @param options - Normalization options (currently unused, reserved for future)
|
|
22
|
-
* @returns The normalized UniSpec document
|
|
23
|
-
*/
|
|
24
|
-
export declare function normalizeUniSpec(doc: UniSpecDocument, _options?: NormalizeOptions): UniSpecDocument;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { normalizeGraphqlOperations } from "./graphql-normalizer.js";
|
|
2
|
-
import { normalizeRestRoutes } from "./rest-normalizer.js";
|
|
3
|
-
import { normalizeValue } from "./utils.js";
|
|
4
|
-
import { normalizeWebSocket } from "./websocket-normalizer.js";
|
|
5
|
-
/**
|
|
6
|
-
* Normalize a UniSpec document into a canonical, deterministic form.
|
|
7
|
-
*
|
|
8
|
-
* This function ensures consistent representation of UniSpec documents
|
|
9
|
-
* by sorting object keys and protocol-specific structures in a predictable order.
|
|
10
|
-
* Useful for:
|
|
11
|
-
* - Generating stable diffs between documents
|
|
12
|
-
* - Creating consistent output for caching
|
|
13
|
-
* - Ensuring reproducible builds
|
|
14
|
-
*
|
|
15
|
-
* Current behavior:
|
|
16
|
-
* - Recursively sorts object keys lexicographically
|
|
17
|
-
* - Sorts REST routes by name or path+method
|
|
18
|
-
* - Sorts GraphQL operations by name within each operation type
|
|
19
|
-
* - Sorts WebSocket channels and messages by name
|
|
20
|
-
* - Preserves all values as-is
|
|
21
|
-
*
|
|
22
|
-
* @param doc - The UniSpec document to normalize
|
|
23
|
-
* @param options - Normalization options (currently unused, reserved for future)
|
|
24
|
-
* @returns The normalized UniSpec document
|
|
25
|
-
*/
|
|
26
|
-
export function normalizeUniSpec(doc, _options = {}) {
|
|
27
|
-
// Apply protocol-specific normalizations first
|
|
28
|
-
const restNormalized = normalizeRestRoutes(doc);
|
|
29
|
-
const graphqlNormalized = normalizeGraphqlOperations(restNormalized);
|
|
30
|
-
const finalNormalized = normalizeWebSocket(graphqlNormalized);
|
|
31
|
-
// Always apply structural normalization to ensure immutability
|
|
32
|
-
// and consistent key sorting, even if no protocol changes were made
|
|
33
|
-
return normalizeValue(finalNormalized);
|
|
34
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Normalize GraphQL operations by sorting them lexicographically by name within each operation type.
|
|
4
|
-
*
|
|
5
|
-
* @param doc - The UniSpec document to normalize
|
|
6
|
-
* @returns The document with normalized GraphQL operations
|
|
7
|
-
*/
|
|
8
|
-
export declare function normalizeGraphqlOperations(doc: UniSpecDocument): UniSpecDocument;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalize GraphQL operations by sorting them lexicographically by name within each operation type.
|
|
3
|
-
*
|
|
4
|
-
* @param doc - The UniSpec document to normalize
|
|
5
|
-
* @returns The document with normalized GraphQL operations
|
|
6
|
-
*/
|
|
7
|
-
export function normalizeGraphqlOperations(doc) {
|
|
8
|
-
if (!doc || !doc.service?.protocols) {
|
|
9
|
-
return doc;
|
|
10
|
-
}
|
|
11
|
-
const protocols = doc.service.protocols;
|
|
12
|
-
const graphql = protocols.graphql;
|
|
13
|
-
if (!graphql) {
|
|
14
|
-
return doc;
|
|
15
|
-
}
|
|
16
|
-
const kinds = ["queries", "mutations", "subscriptions"];
|
|
17
|
-
// Sort operations within each kind only if needed
|
|
18
|
-
const normalizedOperations = {};
|
|
19
|
-
let hasChanges = false;
|
|
20
|
-
for (const kind of kinds) {
|
|
21
|
-
const ops = graphql[kind];
|
|
22
|
-
if (!Array.isArray(ops)) {
|
|
23
|
-
normalizedOperations[kind] = ops;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
// Check if operations are already sorted
|
|
27
|
-
const areOpsSorted = ops.every((op, index, arr) => {
|
|
28
|
-
if (index === 0)
|
|
29
|
-
return true;
|
|
30
|
-
const prevName = arr[index - 1]?.name ?? "";
|
|
31
|
-
const currentName = op?.name ?? "";
|
|
32
|
-
return prevName.localeCompare(currentName) <= 0;
|
|
33
|
-
});
|
|
34
|
-
if (areOpsSorted) {
|
|
35
|
-
normalizedOperations[kind] = ops; // No changes needed
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
const sortedOps = [...ops].sort((a, b) => {
|
|
39
|
-
const aName = a?.name ?? "";
|
|
40
|
-
const bName = b?.name ?? "";
|
|
41
|
-
return aName.localeCompare(bName);
|
|
42
|
-
});
|
|
43
|
-
normalizedOperations[kind] = sortedOps;
|
|
44
|
-
hasChanges = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!hasChanges) {
|
|
48
|
-
return doc; // No changes needed
|
|
49
|
-
}
|
|
50
|
-
// Return new document with sorted operations (immutable)
|
|
51
|
-
return {
|
|
52
|
-
...doc,
|
|
53
|
-
service: {
|
|
54
|
-
...doc.service,
|
|
55
|
-
protocols: {
|
|
56
|
-
...protocols,
|
|
57
|
-
graphql: {
|
|
58
|
-
...graphql,
|
|
59
|
-
...normalizedOperations,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Normalize REST routes by sorting them lexicographically by name or path+method.
|
|
4
|
-
*
|
|
5
|
-
* @param doc - The UniSpec document to normalize
|
|
6
|
-
* @returns The document with normalized REST routes
|
|
7
|
-
*/
|
|
8
|
-
export declare function normalizeRestRoutes(doc: UniSpecDocument): UniSpecDocument;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalize REST routes by sorting them lexicographically by name or path+method.
|
|
3
|
-
*
|
|
4
|
-
* @param doc - The UniSpec document to normalize
|
|
5
|
-
* @returns The document with normalized REST routes
|
|
6
|
-
*/
|
|
7
|
-
export function normalizeRestRoutes(doc) {
|
|
8
|
-
if (!doc || !doc.service?.protocols) {
|
|
9
|
-
return doc;
|
|
10
|
-
}
|
|
11
|
-
const protocols = doc.service.protocols;
|
|
12
|
-
const rest = protocols.rest;
|
|
13
|
-
if (!rest || !Array.isArray(rest.routes)) {
|
|
14
|
-
return doc;
|
|
15
|
-
}
|
|
16
|
-
// Check if routes are already sorted to avoid unnecessary cloning
|
|
17
|
-
const isSorted = rest.routes.every((route, index, arr) => {
|
|
18
|
-
if (index === 0)
|
|
19
|
-
return true;
|
|
20
|
-
const prevKey = arr[index - 1].name ||
|
|
21
|
-
`${arr[index - 1].path} ${arr[index - 1].method}`;
|
|
22
|
-
const currentKey = route.name || `${route.path} ${route.method}`;
|
|
23
|
-
return prevKey.localeCompare(currentKey) <= 0;
|
|
24
|
-
});
|
|
25
|
-
if (isSorted) {
|
|
26
|
-
return doc; // No changes needed
|
|
27
|
-
}
|
|
28
|
-
// Create immutable copy with sorted routes
|
|
29
|
-
const sortedRoutes = [...rest.routes].sort((a, b) => {
|
|
30
|
-
const keyA = a.name || `${a.path} ${a.method}`;
|
|
31
|
-
const keyB = b.name || `${b.path} ${b.method}`;
|
|
32
|
-
return keyA.localeCompare(keyB);
|
|
33
|
-
});
|
|
34
|
-
// Return new document with sorted routes (immutable)
|
|
35
|
-
return {
|
|
36
|
-
...doc,
|
|
37
|
-
service: {
|
|
38
|
-
...doc.service,
|
|
39
|
-
protocols: {
|
|
40
|
-
...protocols,
|
|
41
|
-
rest: {
|
|
42
|
-
...rest,
|
|
43
|
-
routes: sortedRoutes,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UniSpecGraphQLProtocol, UniSpecRestProtocol, UniSpecWebSocketProtocol } from "../types/index.js";
|
|
2
|
-
export type NormalizeOptions = Record<string, never>;
|
|
3
|
-
export interface UniSpecServiceProtocolsLike {
|
|
4
|
-
rest?: UniSpecRestProtocol;
|
|
5
|
-
graphql?: UniSpecGraphQLProtocol;
|
|
6
|
-
websocket?: UniSpecWebSocketProtocol;
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a value is a plain object (not array, null, or other object types).
|
|
3
|
-
*
|
|
4
|
-
* @param value - The value to check
|
|
5
|
-
* @returns true if the value is a plain object, false otherwise
|
|
6
|
-
*/
|
|
7
|
-
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
8
|
-
/**
|
|
9
|
-
* Normalize a value by sorting object keys lexicographically (recursive).
|
|
10
|
-
* Always creates new objects to ensure immutability.
|
|
11
|
-
* Handles circular references gracefully.
|
|
12
|
-
*
|
|
13
|
-
* @param value - The value to normalize
|
|
14
|
-
* @param seen - WeakSet of already seen objects for circular reference detection
|
|
15
|
-
* @returns The normalized value (always a new object for objects/arrays)
|
|
16
|
-
*/
|
|
17
|
-
export declare function normalizeValue(value: unknown, seen?: WeakSet<object>): unknown;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a value is a plain object (not array, null, or other object types).
|
|
3
|
-
*
|
|
4
|
-
* @param value - The value to check
|
|
5
|
-
* @returns true if the value is a plain object, false otherwise
|
|
6
|
-
*/
|
|
7
|
-
export function isPlainObject(value) {
|
|
8
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Normalize a value by sorting object keys lexicographically (recursive).
|
|
12
|
-
* Always creates new objects to ensure immutability.
|
|
13
|
-
* Handles circular references gracefully.
|
|
14
|
-
*
|
|
15
|
-
* @param value - The value to normalize
|
|
16
|
-
* @param seen - WeakSet of already seen objects for circular reference detection
|
|
17
|
-
* @returns The normalized value (always a new object for objects/arrays)
|
|
18
|
-
*/
|
|
19
|
-
export function normalizeValue(value, seen = new WeakSet()) {
|
|
20
|
-
// Handle primitives and null/undefined
|
|
21
|
-
if (value === null || typeof value !== "object") {
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
if (Array.isArray(value)) {
|
|
25
|
-
// Always create new array with recursively normalized items
|
|
26
|
-
return value.map((item) => normalizeValue(item, seen));
|
|
27
|
-
}
|
|
28
|
-
if (isPlainObject(value)) {
|
|
29
|
-
// Check for circular references
|
|
30
|
-
if (seen.has(value)) {
|
|
31
|
-
// Return a placeholder for circular references to avoid infinite recursion
|
|
32
|
-
return "[Circular]";
|
|
33
|
-
}
|
|
34
|
-
seen.add(value);
|
|
35
|
-
const entries = Object.entries(value);
|
|
36
|
-
// Always create new object with sorted keys and recursively normalized values
|
|
37
|
-
const sortedEntries = entries.sort(([a], [b]) => a.localeCompare(b));
|
|
38
|
-
const normalized = {};
|
|
39
|
-
for (const [key, val] of sortedEntries) {
|
|
40
|
-
normalized[key] = normalizeValue(val, seen);
|
|
41
|
-
}
|
|
42
|
-
return normalized;
|
|
43
|
-
}
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Normalize WebSocket channels and messages by sorting them lexicographically by name.
|
|
4
|
-
*
|
|
5
|
-
* @param doc - The UniSpec document to normalize
|
|
6
|
-
* @returns The document with normalized WebSocket channels and messages
|
|
7
|
-
*/
|
|
8
|
-
export declare function normalizeWebSocket(doc: UniSpecDocument): UniSpecDocument;
|