@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unispechq/unispec-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Central UniSpec Core Engine providing parsing, validation, normalization, diffing, and conversion of UniSpec specs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "pnpm run schema:generate && pnpm run build:esm && pnpm run build:cjs",
|
|
42
|
-
"build:esm": "tsc -p tsconfig.json
|
|
43
|
-
"build:cjs": "tsc -p tsconfig.cjs.json &&
|
|
42
|
+
"build:esm": "tsc -p tsconfig.json",
|
|
43
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && node scripts/postbuild-cjs.cjs",
|
|
44
44
|
"schema:generate": "node scripts/generate-schemas.mjs",
|
|
45
45
|
"test": "tsx --test tests/**/*.test.ts",
|
|
46
46
|
"lint": "biome check --write --unsafe",
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCacheManager = createCacheManager;
|
|
4
|
-
exports.createNamedCacheManager = createNamedCacheManager;
|
|
5
|
-
exports.getManagersStats = getManagersStats;
|
|
6
|
-
exports.destroyManagers = destroyManagers;
|
|
7
|
-
exports.clearTestRegistry = clearTestRegistry;
|
|
8
|
-
const cache_manager_1 = require("./cache-manager.js");
|
|
9
|
-
/**
|
|
10
|
-
* Simple registry for test cleanup (minimal, not persistent global state)
|
|
11
|
-
*/
|
|
12
|
-
const testRegistry = new Map();
|
|
13
|
-
/**
|
|
14
|
-
* Create a new isolated cache manager instance.
|
|
15
|
-
* @param options - Cache configuration options
|
|
16
|
-
* @returns New cache manager instance
|
|
17
|
-
*/
|
|
18
|
-
function createCacheManager(options) {
|
|
19
|
-
return new cache_manager_1.UniSpecCacheManager(options);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a named cache manager instance with simple registry.
|
|
23
|
-
* @param name - Instance name for identification
|
|
24
|
-
* @param options - Cache configuration options
|
|
25
|
-
* @returns Cache manager instance
|
|
26
|
-
*/
|
|
27
|
-
function createNamedCacheManager(name = "default", options) {
|
|
28
|
-
// For testing, keep simple registry to enable cleanup
|
|
29
|
-
if (testRegistry.has(name)) {
|
|
30
|
-
const existing = testRegistry.get(name);
|
|
31
|
-
if (existing) {
|
|
32
|
-
existing.destroy(); // Cleanup existing instance
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const manager = new cache_manager_1.UniSpecCacheManager(options);
|
|
36
|
-
manager._name = name; // Store name for debugging
|
|
37
|
-
testRegistry.set(name, manager); // Add to registry for cleanup
|
|
38
|
-
return manager;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get cache manager statistics for multiple instances.
|
|
42
|
-
* @param managers - Array of cache manager instances
|
|
43
|
-
* @returns Statistics for all provided managers
|
|
44
|
-
*/
|
|
45
|
-
function getManagersStats(managers) {
|
|
46
|
-
const stats = {};
|
|
47
|
-
for (const [index, manager] of managers.entries()) {
|
|
48
|
-
const name = manager._name ||
|
|
49
|
-
`manager_${index}`;
|
|
50
|
-
stats[name] = manager.getStats();
|
|
51
|
-
}
|
|
52
|
-
return stats;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Destroy multiple cache manager instances.
|
|
56
|
-
* @param managers - Array of cache manager instances to destroy
|
|
57
|
-
*/
|
|
58
|
-
function destroyManagers(managers) {
|
|
59
|
-
for (const manager of managers) {
|
|
60
|
-
manager.destroy();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Clear test registry (for testing only).
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
function clearTestRegistry() {
|
|
68
|
-
for (const manager of testRegistry.values()) {
|
|
69
|
-
manager.destroy();
|
|
70
|
-
}
|
|
71
|
-
testRegistry.clear();
|
|
72
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniSpecCacheManager = void 0;
|
|
4
|
-
const constants_1 = require("./constants.js");
|
|
5
|
-
const lru_cache_1 = require("./lru-cache.js");
|
|
6
|
-
/**
|
|
7
|
-
* Cache manager for UniSpec operations.
|
|
8
|
-
*/
|
|
9
|
-
class UniSpecCacheManager {
|
|
10
|
-
constructor(options = {}) {
|
|
11
|
-
this.cleanupInterval = null;
|
|
12
|
-
this.validationCache = new lru_cache_1.LRUCache({
|
|
13
|
-
...options,
|
|
14
|
-
maxSize: options.maxSize || constants_1.CACHE_CONSTANTS.VALIDATION_MAX_SIZE,
|
|
15
|
-
});
|
|
16
|
-
this.normalizationCache = new lru_cache_1.LRUCache({
|
|
17
|
-
...options,
|
|
18
|
-
maxSize: options.maxSize || constants_1.CACHE_CONSTANTS.NORMALIZATION_MAX_SIZE,
|
|
19
|
-
});
|
|
20
|
-
this.diffCache = new lru_cache_1.LRUCache({
|
|
21
|
-
...options,
|
|
22
|
-
maxSize: options.maxSize || constants_1.CACHE_CONSTANTS.DIFF_MAX_SIZE,
|
|
23
|
-
});
|
|
24
|
-
// Only start cleanup if not in test environment
|
|
25
|
-
if (process.env.NODE_ENV !== "test") {
|
|
26
|
-
this.startCleanup();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get cached validation result asynchronously.
|
|
31
|
-
*/
|
|
32
|
-
async getValidationResult(documentHash) {
|
|
33
|
-
return await this.validationCache.get(documentHash);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Cache validation result asynchronously.
|
|
37
|
-
*/
|
|
38
|
-
async setValidationResult(documentHash, result) {
|
|
39
|
-
await this.validationCache.set(documentHash, result);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get cached normalization result asynchronously.
|
|
43
|
-
*/
|
|
44
|
-
async getNormalizationResult(documentHash) {
|
|
45
|
-
return await this.normalizationCache.get(documentHash);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Cache normalization result asynchronously.
|
|
49
|
-
*/
|
|
50
|
-
async setNormalizationResult(documentHash, result) {
|
|
51
|
-
await this.normalizationCache.set(documentHash, result);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get cached diff result asynchronously.
|
|
55
|
-
*/
|
|
56
|
-
async getDiffResult(docsHash) {
|
|
57
|
-
return await this.diffCache.get(docsHash);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Cache diff result asynchronously.
|
|
61
|
-
*/
|
|
62
|
-
async setDiffResult(docsHash, result) {
|
|
63
|
-
await this.diffCache.set(docsHash, result);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get comprehensive cache statistics.
|
|
67
|
-
*/
|
|
68
|
-
getStats() {
|
|
69
|
-
const validationStats = this.validationCache.getStats();
|
|
70
|
-
const normalizationStats = this.normalizationCache.getStats();
|
|
71
|
-
const diffStats = this.diffCache.getStats();
|
|
72
|
-
const total = {
|
|
73
|
-
size: validationStats.size + normalizationStats.size + diffStats.size,
|
|
74
|
-
hits: validationStats.hits + normalizationStats.hits + diffStats.hits,
|
|
75
|
-
misses: validationStats.misses + normalizationStats.misses + diffStats.misses,
|
|
76
|
-
hitRate: 0,
|
|
77
|
-
};
|
|
78
|
-
const totalRequests = total.hits + total.misses;
|
|
79
|
-
total.hitRate = totalRequests > 0 ? total.hits / totalRequests : 0;
|
|
80
|
-
return {
|
|
81
|
-
validation: validationStats,
|
|
82
|
-
normalization: normalizationStats,
|
|
83
|
-
diff: diffStats,
|
|
84
|
-
total,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Clear all caches.
|
|
89
|
-
*/
|
|
90
|
-
clearAll() {
|
|
91
|
-
this.validationCache.clear();
|
|
92
|
-
this.normalizationCache.clear();
|
|
93
|
-
this.diffCache.clear();
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Start automatic cleanup interval.
|
|
97
|
-
*/
|
|
98
|
-
startCleanup() {
|
|
99
|
-
try {
|
|
100
|
-
this.cleanupInterval = setInterval(() => {
|
|
101
|
-
try {
|
|
102
|
-
this.validationCache.cleanup();
|
|
103
|
-
this.normalizationCache.cleanup();
|
|
104
|
-
this.diffCache.cleanup();
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.error(constants_1.CACHE_MESSAGES.CLEANUP_ERROR, error);
|
|
108
|
-
// Continue running cleanup even if one cache fails
|
|
109
|
-
}
|
|
110
|
-
}, constants_1.CACHE_CONSTANTS.CLEANUP_INTERVAL);
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
console.error(constants_1.CACHE_MESSAGES.CLEANUP_START_ERROR, error);
|
|
114
|
-
// Cache will still work without automatic cleanup
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Stop automatic cleanup.
|
|
119
|
-
*/
|
|
120
|
-
destroy() {
|
|
121
|
-
if (this.cleanupInterval) {
|
|
122
|
-
clearInterval(this.cleanupInterval);
|
|
123
|
-
this.cleanupInterval = null;
|
|
124
|
-
}
|
|
125
|
-
this.clearAll();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.UniSpecCacheManager = UniSpecCacheManager;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Cache configuration constants.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CACHE_MESSAGES = exports.CACHE_CONSTANTS = void 0;
|
|
7
|
-
exports.CACHE_CONSTANTS = {
|
|
8
|
-
// Default cache sizes
|
|
9
|
-
DEFAULT_MAX_SIZE: 100,
|
|
10
|
-
VALIDATION_MAX_SIZE: 50,
|
|
11
|
-
NORMALIZATION_MAX_SIZE: 30,
|
|
12
|
-
DIFF_MAX_SIZE: 20,
|
|
13
|
-
// TTL values (in milliseconds)
|
|
14
|
-
DEFAULT_TTL: 5 * 60 * 1000, // 5 minutes
|
|
15
|
-
CLEANUP_INTERVAL: 60000, // 1 minute
|
|
16
|
-
// Hash configuration
|
|
17
|
-
HASH_GOLDEN_RATIO: 2654435761,
|
|
18
|
-
HASH_BASE: 31,
|
|
19
|
-
HASH_MASK: 0xffffffff,
|
|
20
|
-
};
|
|
21
|
-
exports.CACHE_MESSAGES = {
|
|
22
|
-
CLEANUP_ERROR: "Cache cleanup error",
|
|
23
|
-
CLEANUP_START_ERROR: "Failed to start cleanup interval",
|
|
24
|
-
CACHE_WILL_CONTINUE: "Cache will still work without automatic cleanup",
|
|
25
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateDocumentHash = generateDocumentHash;
|
|
4
|
-
exports.generateDiffHash = generateDiffHash;
|
|
5
|
-
const hashing_1 = require("./hashing.js");
|
|
6
|
-
/**
|
|
7
|
-
* Generate a hash for a UniSpec document for caching purposes.
|
|
8
|
-
* Uses optimized hashing for better performance and collision resistance.
|
|
9
|
-
*/
|
|
10
|
-
async function generateDocumentHash(document) {
|
|
11
|
-
return await (0, hashing_1.generateOptimizedDocumentHash)(document);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Generate a hash for two documents (for diff caching).
|
|
15
|
-
* Uses optimized diff hashing with better collision resistance.
|
|
16
|
-
*/
|
|
17
|
-
async function generateDiffHash(oldDoc, newDoc) {
|
|
18
|
-
return await (0, hashing_1.generateOptimizedDiffHash)(oldDoc, newDoc);
|
|
19
|
-
}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateOptimizedDocumentHash = generateOptimizedDocumentHash;
|
|
37
|
-
exports.generateOptimizedDiffHash = generateOptimizedDiffHash;
|
|
38
|
-
exports.simpleHash = simpleHash;
|
|
39
|
-
exports.stableStringify = stableStringify;
|
|
40
|
-
const constants_1 = require("../cache/constants.js");
|
|
41
|
-
/**
|
|
42
|
-
* Secure document hashing utilities using Web Crypto API.
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* Secure hash using Web Crypto API (SHA-256) or Node.js crypto.
|
|
46
|
-
* Fallback to FNV-1a only if both crypto APIs are unavailable.
|
|
47
|
-
*/
|
|
48
|
-
async function secureHash(str) {
|
|
49
|
-
// Try Web Crypto API first (browser environments)
|
|
50
|
-
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
51
|
-
try {
|
|
52
|
-
const encoder = new TextEncoder();
|
|
53
|
-
const data = encoder.encode(str);
|
|
54
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
55
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
56
|
-
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.warn("Web Crypto API failed, trying Node.js crypto:", error);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Try Node.js crypto API (server environments)
|
|
63
|
-
try {
|
|
64
|
-
// Dynamic import for Node.js crypto to avoid browser compatibility issues
|
|
65
|
-
const crypto = await Promise.resolve().then(() => __importStar(require("node:crypto")));
|
|
66
|
-
const hash = crypto.createHash("sha256");
|
|
67
|
-
hash.update(str, "utf8");
|
|
68
|
-
return hash.digest("hex");
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.warn("Node.js crypto API failed, falling back to FNV-1a:", error);
|
|
72
|
-
}
|
|
73
|
-
// Last resort: FNV-1a algorithm (non-cryptographic, for compatibility only)
|
|
74
|
-
console.warn("Using FNV-1a fallback hash - consider installing crypto support");
|
|
75
|
-
return fnv1aHashFallback(str).toString();
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* FNV-1a fallback hash function (non-cryptographic, for compatibility).
|
|
79
|
-
*/
|
|
80
|
-
function fnv1aHashFallback(str) {
|
|
81
|
-
let hash = 2166136261; // FNV offset basis
|
|
82
|
-
for (let i = 0; i < str.length; i++) {
|
|
83
|
-
hash ^= str.charCodeAt(i);
|
|
84
|
-
hash = (hash * 16777619) & constants_1.CACHE_CONSTANTS.HASH_MASK; // FNV prime
|
|
85
|
-
}
|
|
86
|
-
return hash;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Generate a secure hash for a document using optimized sorting and Web Crypto API.
|
|
90
|
-
*/
|
|
91
|
-
async function generateOptimizedDocumentHash(document) {
|
|
92
|
-
// Use optimized stable stringification
|
|
93
|
-
const str = stableStringify(document);
|
|
94
|
-
// Use secure hash for better distribution and collision resistance
|
|
95
|
-
const hash = await secureHash(str);
|
|
96
|
-
// Add length and type prefix for additional collision resistance
|
|
97
|
-
const typePrefix = getDocumentTypePrefix(document);
|
|
98
|
-
const combined = `${hash}_${str.length}_${typePrefix}`;
|
|
99
|
-
// Create final hash with combined string
|
|
100
|
-
const finalHash = await secureHash(combined);
|
|
101
|
-
return `${finalHash.slice(0, 16)}_${str.length}`;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Default configuration for stable stringification.
|
|
105
|
-
*/
|
|
106
|
-
const DEFAULT_STRINGIFY_CONFIG = {
|
|
107
|
-
maxDepth: 100,
|
|
108
|
-
maxKeys: 10000,
|
|
109
|
-
handleCircular: true,
|
|
110
|
-
handleDeepObjects: true,
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Optimized stable stringification that avoids recursion depth issues.
|
|
114
|
-
*/
|
|
115
|
-
function stableStringify(obj, config = {}, depth = 0, visited = new WeakSet()) {
|
|
116
|
-
const finalConfig = { ...DEFAULT_STRINGIFY_CONFIG, ...config };
|
|
117
|
-
// Prevent infinite recursion
|
|
118
|
-
if (depth > finalConfig.maxDepth) {
|
|
119
|
-
return `"[MAX_DEPTH_REACHED:${depth}]"`;
|
|
120
|
-
}
|
|
121
|
-
// Handle circular references
|
|
122
|
-
if (finalConfig.handleCircular && obj && typeof obj === "object") {
|
|
123
|
-
if (visited.has(obj)) {
|
|
124
|
-
return `"[CIRCULAR_REFERENCE:${obj.constructor?.name || "Object"}]"`;
|
|
125
|
-
}
|
|
126
|
-
visited.add(obj);
|
|
127
|
-
}
|
|
128
|
-
// Handle primitives
|
|
129
|
-
if (obj === null || typeof obj !== "object") {
|
|
130
|
-
return JSON.stringify(obj);
|
|
131
|
-
}
|
|
132
|
-
// Handle special object types
|
|
133
|
-
if (obj instanceof Date) {
|
|
134
|
-
return obj.toISOString();
|
|
135
|
-
}
|
|
136
|
-
if (obj instanceof RegExp) {
|
|
137
|
-
return `"[REGEX:${obj.toString()}]"`;
|
|
138
|
-
}
|
|
139
|
-
if (obj instanceof Error) {
|
|
140
|
-
return `"[ERROR:${obj.name}:${obj.message}]"`;
|
|
141
|
-
}
|
|
142
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer(obj)) {
|
|
143
|
-
return `"[BUFFER:${obj.toString("base64")}]"`;
|
|
144
|
-
}
|
|
145
|
-
// Handle Array
|
|
146
|
-
if (Array.isArray(obj)) {
|
|
147
|
-
if (obj.length > finalConfig.maxKeys) {
|
|
148
|
-
return `"[ARRAY_TOO_LARGE:${obj.length}]"`;
|
|
149
|
-
}
|
|
150
|
-
const elements = obj.map((item, index) => {
|
|
151
|
-
try {
|
|
152
|
-
return stableStringify(item, finalConfig, depth + 1, visited);
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
return `"[ERROR_AT_INDEX_${index}:${error instanceof Error ? error.message : String(error)}]"`;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return `[${elements.join(",")}]`;
|
|
159
|
-
}
|
|
160
|
-
// Handle Object
|
|
161
|
-
if (typeof obj === "object") {
|
|
162
|
-
const objRecord = obj;
|
|
163
|
-
const keys = Object.keys(objRecord);
|
|
164
|
-
if (keys.length > finalConfig.maxKeys) {
|
|
165
|
-
return `"[OBJECT_TOO_LARGE:${keys.length}]"`;
|
|
166
|
-
}
|
|
167
|
-
const sortedKeys = keys.sort();
|
|
168
|
-
const pairs = [];
|
|
169
|
-
for (const key of sortedKeys) {
|
|
170
|
-
try {
|
|
171
|
-
const value = stableStringify(objRecord[key], finalConfig, depth + 1, visited);
|
|
172
|
-
pairs.push(`"${key}":${value}`);
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
pairs.push(`"${key}":"[ERROR:${error instanceof Error ? error.message : String(error)}]"`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return `{${pairs.join(",")}}`;
|
|
179
|
-
}
|
|
180
|
-
return "{}";
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Get a numeric prefix based on document type to reduce collisions.
|
|
184
|
-
*/
|
|
185
|
-
function getDocumentTypePrefix(document) {
|
|
186
|
-
if (!document || typeof document !== "object")
|
|
187
|
-
return 0;
|
|
188
|
-
const doc = document;
|
|
189
|
-
// Check for UniSpec document
|
|
190
|
-
if (doc.unispecVersion)
|
|
191
|
-
return 1;
|
|
192
|
-
if (doc.uniSpecTestsVersion)
|
|
193
|
-
return 2;
|
|
194
|
-
if (doc.version && doc.services)
|
|
195
|
-
return 3;
|
|
196
|
-
// Check for common patterns
|
|
197
|
-
if (Array.isArray(document))
|
|
198
|
-
return 4;
|
|
199
|
-
if (doc.$schema)
|
|
200
|
-
return 5;
|
|
201
|
-
if (doc.type)
|
|
202
|
-
return typeof doc.type === "string" ? doc.type.charCodeAt(0) || 6 : 6;
|
|
203
|
-
return 7;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Generate a secure hash for two documents (for diff caching) with optimized collision resistance.
|
|
207
|
-
*/
|
|
208
|
-
async function generateOptimizedDiffHash(oldDoc, newDoc) {
|
|
209
|
-
const oldHash = await generateOptimizedDocumentHash(oldDoc);
|
|
210
|
-
const newHash = await generateOptimizedDocumentHash(newDoc);
|
|
211
|
-
// Combine hashes using order-sensitive operation
|
|
212
|
-
const combined = `${oldHash}:${newHash}`;
|
|
213
|
-
// Hash the combined string to get final result
|
|
214
|
-
const finalHash = await secureHash(combined);
|
|
215
|
-
return `${finalHash.slice(0, 16)}_${oldHash.length}_${newHash.length}`;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Simple hash for small objects (keys, strings) using built-in hash.
|
|
219
|
-
* Kept for backward compatibility but consider using secureHash for new code.
|
|
220
|
-
*/
|
|
221
|
-
function simpleHash(str) {
|
|
222
|
-
let hash = 5381; // DJB2 hash initial value
|
|
223
|
-
for (let i = 0; i < str.length; i++) {
|
|
224
|
-
const char = str.charCodeAt(i);
|
|
225
|
-
hash = ((hash << 5) + hash + char) & constants_1.CACHE_CONSTANTS.HASH_MASK;
|
|
226
|
-
}
|
|
227
|
-
// Convert to hex and pad to 8 characters
|
|
228
|
-
const hex = hash.toString(16);
|
|
229
|
-
return hex.padStart(8, "0").slice(-8);
|
|
230
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Constants and messages
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.LRUCache = exports.generateDocumentHash = exports.generateDiffHash = exports.CACHE_MESSAGES = exports.CACHE_CONSTANTS = exports.UniSpecCacheManager = exports.getManagersStats = exports.destroyManagers = exports.createNamedCacheManager = exports.createCacheManager = exports.clearTestRegistry = void 0;
|
|
5
|
-
// Cache factory
|
|
6
|
-
var cache_factory_1 = require("./cache-factory.js");
|
|
7
|
-
Object.defineProperty(exports, "clearTestRegistry", { enumerable: true, get: function () { return cache_factory_1.clearTestRegistry; } });
|
|
8
|
-
Object.defineProperty(exports, "createCacheManager", { enumerable: true, get: function () { return cache_factory_1.createCacheManager; } });
|
|
9
|
-
Object.defineProperty(exports, "createNamedCacheManager", { enumerable: true, get: function () { return cache_factory_1.createNamedCacheManager; } });
|
|
10
|
-
Object.defineProperty(exports, "destroyManagers", { enumerable: true, get: function () { return cache_factory_1.destroyManagers; } });
|
|
11
|
-
Object.defineProperty(exports, "getManagersStats", { enumerable: true, get: function () { return cache_factory_1.getManagersStats; } });
|
|
12
|
-
// Cache manager
|
|
13
|
-
var cache_manager_1 = require("./cache-manager.js");
|
|
14
|
-
Object.defineProperty(exports, "UniSpecCacheManager", { enumerable: true, get: function () { return cache_manager_1.UniSpecCacheManager; } });
|
|
15
|
-
var constants_1 = require("./constants.js");
|
|
16
|
-
Object.defineProperty(exports, "CACHE_CONSTANTS", { enumerable: true, get: function () { return constants_1.CACHE_CONSTANTS; } });
|
|
17
|
-
Object.defineProperty(exports, "CACHE_MESSAGES", { enumerable: true, get: function () { return constants_1.CACHE_MESSAGES; } });
|
|
18
|
-
// Hash utilities
|
|
19
|
-
var hash_utils_1 = require("./hash-utils.js");
|
|
20
|
-
Object.defineProperty(exports, "generateDiffHash", { enumerable: true, get: function () { return hash_utils_1.generateDiffHash; } });
|
|
21
|
-
Object.defineProperty(exports, "generateDocumentHash", { enumerable: true, get: function () { return hash_utils_1.generateDocumentHash; } });
|
|
22
|
-
// Core cache implementation
|
|
23
|
-
var lru_cache_1 = require("./lru-cache.js");
|
|
24
|
-
Object.defineProperty(exports, "LRUCache", { enumerable: true, get: function () { return lru_cache_1.LRUCache; } });
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LRUCache = void 0;
|
|
4
|
-
const constants_1 = require("./constants.js");
|
|
5
|
-
/**
|
|
6
|
-
* Simple LRU (Least Recently Used) cache implementation.
|
|
7
|
-
*/
|
|
8
|
-
class LRUCache {
|
|
9
|
-
constructor(options = {}) {
|
|
10
|
-
this.cache = new Map();
|
|
11
|
-
this.maxSize = options.maxSize || constants_1.CACHE_CONSTANTS.DEFAULT_MAX_SIZE;
|
|
12
|
-
this.ttl = options.ttl || constants_1.CACHE_CONSTANTS.DEFAULT_TTL;
|
|
13
|
-
this.enableStats = options.enableStats || false;
|
|
14
|
-
this.stats = {
|
|
15
|
-
hits: 0,
|
|
16
|
-
misses: 0,
|
|
17
|
-
size: 0,
|
|
18
|
-
hitRate: 0,
|
|
19
|
-
evictions: 0,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get a value from the cache asynchronously.
|
|
24
|
-
*/
|
|
25
|
-
async get(key) {
|
|
26
|
-
const entry = this.cache.get(key);
|
|
27
|
-
if (!entry) {
|
|
28
|
-
if (this.enableStats) {
|
|
29
|
-
this.stats.misses++;
|
|
30
|
-
this.updateHitRate();
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
// Check TTL
|
|
35
|
-
if (this.isExpired(entry)) {
|
|
36
|
-
this.cache.delete(key);
|
|
37
|
-
if (this.enableStats) {
|
|
38
|
-
this.stats.misses++;
|
|
39
|
-
this.stats.size--;
|
|
40
|
-
this.updateHitRate();
|
|
41
|
-
}
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
// Update access info
|
|
45
|
-
entry.accessCount++;
|
|
46
|
-
entry.lastAccessed = Date.now();
|
|
47
|
-
// Move to end (most recently used)
|
|
48
|
-
this.cache.delete(key);
|
|
49
|
-
this.cache.set(key, entry);
|
|
50
|
-
if (this.enableStats) {
|
|
51
|
-
this.stats.hits++;
|
|
52
|
-
this.updateHitRate();
|
|
53
|
-
}
|
|
54
|
-
return entry.value;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Set a value in the cache asynchronously.
|
|
58
|
-
*/
|
|
59
|
-
async set(key, value) {
|
|
60
|
-
// Remove existing entry if present
|
|
61
|
-
if (this.cache.has(key)) {
|
|
62
|
-
this.cache.delete(key);
|
|
63
|
-
}
|
|
64
|
-
// Evict oldest entries if cache is full
|
|
65
|
-
while (this.cache.size >= this.maxSize) {
|
|
66
|
-
const oldestKey = this.cache.keys().next().value;
|
|
67
|
-
if (oldestKey) {
|
|
68
|
-
this.cache.delete(oldestKey);
|
|
69
|
-
if (this.enableStats) {
|
|
70
|
-
this.stats.evictions++;
|
|
71
|
-
this.stats.size--;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const entry = {
|
|
79
|
-
value,
|
|
80
|
-
timestamp: Date.now(),
|
|
81
|
-
accessCount: 1,
|
|
82
|
-
lastAccessed: Date.now(),
|
|
83
|
-
};
|
|
84
|
-
this.cache.set(key, entry);
|
|
85
|
-
if (this.enableStats) {
|
|
86
|
-
this.stats.size++;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Delete a value from the cache.
|
|
91
|
-
*/
|
|
92
|
-
delete(key) {
|
|
93
|
-
const deleted = this.cache.delete(key);
|
|
94
|
-
if (deleted && this.enableStats) {
|
|
95
|
-
this.stats.size--;
|
|
96
|
-
}
|
|
97
|
-
return deleted;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Clear all entries from the cache.
|
|
101
|
-
*/
|
|
102
|
-
clear() {
|
|
103
|
-
this.cache.clear();
|
|
104
|
-
if (this.enableStats) {
|
|
105
|
-
this.stats.size = 0;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get cache statistics.
|
|
110
|
-
*/
|
|
111
|
-
getStats() {
|
|
112
|
-
return { ...this.stats };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Check if an entry is expired.
|
|
116
|
-
*/
|
|
117
|
-
isExpired(entry) {
|
|
118
|
-
return Date.now() - entry.timestamp > this.ttl;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Update hit rate statistics.
|
|
122
|
-
*/
|
|
123
|
-
updateHitRate() {
|
|
124
|
-
const total = this.stats.hits + this.stats.misses;
|
|
125
|
-
this.stats.hitRate = total > 0 ? this.stats.hits / total : 0;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Clean up expired entries.
|
|
129
|
-
*/
|
|
130
|
-
cleanup() {
|
|
131
|
-
let cleaned = 0;
|
|
132
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
133
|
-
if (this.isExpired(entry)) {
|
|
134
|
-
this.cache.delete(key);
|
|
135
|
-
cleaned++;
|
|
136
|
-
if (this.enableStats) {
|
|
137
|
-
this.stats.size--;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return cleaned;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
exports.LRUCache = LRUCache;
|