@unispechq/unispec-core 0.3.2 → 0.3.3
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/cjs/src/cache/cache-factory.js +1 -1
- package/dist/cjs/src/cache/cache-manager.js +2 -2
- package/dist/cjs/src/cache/hash-utils.js +1 -1
- package/dist/cjs/src/cache/hashing.js +1 -1
- package/dist/cjs/src/cache/index.js +5 -5
- package/dist/cjs/src/cache/lru-cache.js +1 -1
- package/dist/cjs/src/diff/core.js +2 -2
- package/dist/cjs/src/diff/enhanced-diff.js +5 -5
- package/dist/cjs/src/diff/index.js +8 -8
- package/dist/cjs/src/errors/config-error.js +1 -1
- package/dist/cjs/src/errors/error-factory.js +7 -7
- package/dist/cjs/src/errors/index.js +8 -8
- package/dist/cjs/src/errors/loader-error.js +1 -1
- package/dist/cjs/src/errors/reference-error.js +1 -1
- package/dist/cjs/src/errors/schema-error.js +1 -1
- package/dist/cjs/src/errors/security-error.js +1 -1
- package/dist/cjs/src/errors/semantic-error.js +1 -1
- package/dist/cjs/src/index.js +13 -13
- package/dist/cjs/src/loader/index.js +4 -4
- package/dist/cjs/src/loader/security-validator.js +1 -1
- package/dist/cjs/src/loader/unispec-loader.js +3 -3
- package/dist/cjs/src/loader/yaml-loader.js +1 -1
- package/dist/cjs/src/normalizer/core.js +4 -4
- package/dist/cjs/src/normalizer/index.js +1 -1
- package/dist/cjs/src/optimizer/core.js +2 -2
- package/dist/cjs/src/optimizer/index.js +3 -3
- package/dist/cjs/src/optimizer/optimization-functions.js +2 -2
- package/dist/cjs/src/schemas/dedupe.js +1 -1
- package/dist/cjs/src/schemas/index.js +3 -3
- package/dist/cjs/src/schemas/resolver.js +1 -1
- package/dist/cjs/src/validator/ajv-validator.js +1 -1
- package/dist/cjs/src/validator/config-validator-main.js +4 -4
- package/dist/cjs/src/validator/config-validator.js +1 -1
- package/dist/cjs/src/validator/index.js +7 -7
- package/dist/cjs/src/validator/reference-validator.js +1 -1
- package/dist/cjs/src/validator/tests-validator.js +2 -2
- package/dist/cjs/src/validator/unispec-validator.js +5 -5
- package/dist/cjs/src/validator/validator-factory.js +1 -1
- package/dist/cjs/tests/cache/cache.test.js +4 -4
- package/dist/cjs/tests/cache/utils.js +1 -1
- package/dist/cjs/tests/diff/diff-annotators.test.js +2 -2
- package/dist/cjs/tests/diff/diff-comprehensive.test.js +2 -2
- package/dist/cjs/tests/diff/diff-extended.test.js +2 -2
- package/dist/cjs/tests/diff/diff.test.js +2 -2
- package/dist/cjs/tests/diff/utils.js +1 -1
- package/dist/cjs/tests/errors/errors-integration.test.js +3 -3
- package/dist/cjs/tests/errors/errors.test.js +2 -2
- package/dist/cjs/tests/errors/utils.js +1 -1
- package/dist/cjs/tests/loader/integration.test.js +2 -2
- package/dist/cjs/tests/loader/loader.test.js +2 -2
- package/dist/cjs/tests/normalizer/normalizer-comprehensive.test.js +2 -2
- package/dist/cjs/tests/normalizer/normalizer-invalid.test.js +2 -2
- package/dist/cjs/tests/normalizer/normalizer-valid.test.js +2 -2
- package/dist/cjs/tests/normalizer/utils.js +1 -1
- package/dist/cjs/tests/optimizer/compress-references.test.js +2 -2
- package/dist/cjs/tests/optimizer/deduplication.test.js +2 -2
- package/dist/cjs/tests/optimizer/integration.test.js +3 -3
- package/dist/cjs/tests/optimizer/optimization-report.test.js +2 -2
- package/dist/cjs/tests/optimizer/optimize-document.test.js +2 -2
- package/dist/cjs/tests/optimizer/orphaned-schemas.test.js +2 -2
- package/dist/cjs/tests/optimizer/sort-schemas.test.js +2 -2
- package/dist/cjs/tests/optimizer/utils.js +1 -1
- package/dist/cjs/tests/schemas/schemas-edge-cases.test.js +3 -3
- package/dist/cjs/tests/schemas/schemas.test.js +3 -3
- package/dist/cjs/tests/schemas/utils.js +1 -1
- package/dist/cjs/tests/validator/config-validator.test.js +2 -2
- package/dist/cjs/tests/validator/unispec-validator.test.js +2 -2
- package/dist/cjs/tests/validator/utils.js +1 -1
- package/package.json +1 -1
- package/dist/cache/cache-factory.d.ts +0 -31
- package/dist/cache/cache-factory.js +0 -65
- package/dist/cache/cache-manager.d.ts +0 -62
- package/dist/cache/cache-manager.js +0 -122
- package/dist/cache/constants.d.ts +0 -21
- package/dist/cache/constants.js +0 -22
- package/dist/cache/hash-utils.d.ts +0 -21
- package/dist/cache/hash-utils.js +0 -35
- package/dist/cache/hashing.d.ts +0 -19
- package/dist/cache/hashing.js +0 -197
- package/dist/cache/index.d.ts +0 -6
- package/dist/cache/index.js +0 -10
- package/dist/cache/lru-cache.d.ts +0 -56
- package/dist/cache/lru-cache.js +0 -161
- package/dist/cache/types.d.ts +0 -24
- package/dist/cache/types.js +0 -4
- package/dist/cjs/cache/cache-factory.js +0 -72
- package/dist/cjs/cache/cache-manager.js +0 -126
- package/dist/cjs/cache/constants.js +0 -25
- package/dist/cjs/cache/hash-utils.js +0 -41
- package/dist/cjs/cache/hashing.js +0 -236
- package/dist/cjs/cache/index.js +0 -26
- package/dist/cjs/cache/lru-cache.js +0 -165
- package/dist/cjs/cache/types.js +0 -5
- package/dist/cjs/diff/annotators.js +0 -159
- package/dist/cjs/diff/change-reports.js +0 -369
- package/dist/cjs/diff/core.js +0 -158
- package/dist/cjs/diff/enhanced-diff.js +0 -79
- package/dist/cjs/diff/impact-strategies-refactored.js +0 -230
- package/dist/cjs/diff/impact-strategies.js +0 -219
- package/dist/cjs/diff/index.js +0 -27
- package/dist/cjs/diff/metrics-calculator.js +0 -69
- package/dist/cjs/diff/risk-calculator.js +0 -58
- package/dist/cjs/diff/suggestion-generator.js +0 -78
- package/dist/cjs/diff/types.js +0 -11
- package/dist/cjs/errors/base-error.js +0 -33
- package/dist/cjs/errors/config-error.js +0 -11
- package/dist/cjs/errors/error-factory.js +0 -48
- package/dist/cjs/errors/index.js +0 -19
- package/dist/cjs/errors/loader-error.js +0 -11
- package/dist/cjs/errors/reference-error.js +0 -11
- package/dist/cjs/errors/schema-error.js +0 -11
- package/dist/cjs/errors/security-error.js +0 -11
- package/dist/cjs/errors/semantic-error.js +0 -11
- package/dist/cjs/generated-schemas.js +0 -2100
- package/dist/cjs/index.js +0 -59
- package/dist/cjs/loader/index.js +0 -13
- package/dist/cjs/loader/security-validator.js +0 -53
- package/dist/cjs/loader/types.js +0 -11
- package/dist/cjs/loader/unispec-loader.js +0 -84
- package/dist/cjs/loader/yaml-loader.js +0 -76
- package/dist/cjs/normalizer/core.js +0 -32
- package/dist/cjs/normalizer/graphql-normalizer.js +0 -67
- package/dist/cjs/normalizer/index.js +0 -7
- package/dist/cjs/normalizer/rest-normalizer.js +0 -51
- package/dist/cjs/normalizer/types.js +0 -2
- package/dist/cjs/normalizer/utils.js +0 -33
- package/dist/cjs/normalizer/websocket-normalizer.js +0 -81
- package/dist/cjs/optimizer/core.js +0 -115
- package/dist/cjs/optimizer/index.js +0 -17
- package/dist/cjs/optimizer/optimization-functions.js +0 -185
- package/dist/cjs/optimizer/types.js +0 -2
- package/dist/cjs/optimizer/utils.js +0 -32
- package/dist/cjs/schemas/dedupe.js +0 -100
- package/dist/cjs/schemas/index.js +0 -14
- package/dist/cjs/schemas/resolver.js +0 -41
- package/dist/cjs/schemas/utils.js +0 -53
- package/dist/cjs/types/index.js +0 -2
- package/dist/cjs/validator/ajv-validator.js +0 -82
- package/dist/cjs/validator/config-validator-main.js +0 -34
- package/dist/cjs/validator/config-validator.js +0 -17
- package/dist/cjs/validator/index.js +0 -23
- package/dist/cjs/validator/object-traversal.js +0 -112
- package/dist/cjs/validator/reference-validator.js +0 -233
- package/dist/cjs/validator/schema-references.js +0 -116
- package/dist/cjs/validator/semantic-validator.js +0 -328
- package/dist/cjs/validator/tests-validator.js +0 -16
- package/dist/cjs/validator/types.js +0 -2
- package/dist/cjs/validator/unispec-validator.js +0 -84
- package/dist/cjs/validator/validator-factory.js +0 -77
- package/dist/cjs/versions.js +0 -147
- package/dist/diff/annotators.d.ts +0 -4
- package/dist/diff/annotators.js +0 -154
- package/dist/diff/change-reports.d.ts +0 -37
- package/dist/diff/change-reports.js +0 -366
- package/dist/diff/core.d.ts +0 -26
- package/dist/diff/core.js +0 -155
- package/dist/diff/enhanced-diff.d.ts +0 -51
- package/dist/diff/enhanced-diff.js +0 -76
- package/dist/diff/impact-strategies-refactored.d.ts +0 -69
- package/dist/diff/impact-strategies-refactored.js +0 -223
- package/dist/diff/impact-strategies.d.ts +0 -41
- package/dist/diff/impact-strategies.js +0 -212
- package/dist/diff/index.d.ts +0 -8
- package/dist/diff/index.js +0 -11
- package/dist/diff/metrics-calculator.d.ts +0 -23
- package/dist/diff/metrics-calculator.js +0 -65
- package/dist/diff/risk-calculator.d.ts +0 -23
- package/dist/diff/risk-calculator.js +0 -55
- package/dist/diff/suggestion-generator.d.ts +0 -18
- package/dist/diff/suggestion-generator.js +0 -74
- package/dist/diff/types.d.ts +0 -24
- package/dist/diff/types.js +0 -8
- package/dist/errors/base-error.d.ts +0 -20
- package/dist/errors/base-error.js +0 -29
- package/dist/errors/config-error.d.ts +0 -4
- package/dist/errors/config-error.js +0 -7
- package/dist/errors/error-factory.d.ts +0 -22
- package/dist/errors/error-factory.js +0 -45
- package/dist/errors/index.d.ts +0 -8
- package/dist/errors/index.js +0 -8
- package/dist/errors/loader-error.d.ts +0 -4
- package/dist/errors/loader-error.js +0 -7
- package/dist/errors/reference-error.d.ts +0 -4
- package/dist/errors/reference-error.js +0 -7
- package/dist/errors/schema-error.d.ts +0 -4
- package/dist/errors/schema-error.js +0 -7
- package/dist/errors/security-error.d.ts +0 -4
- package/dist/errors/security-error.js +0 -7
- package/dist/errors/semantic-error.d.ts +0 -4
- package/dist/errors/semantic-error.js +0 -7
- package/dist/generated-schemas.d.ts +0 -2073
- package/dist/generated-schemas.js +0 -2097
- package/dist/index.cjs +0 -59
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -43
- package/dist/loader/index.d.ts +0 -5
- package/dist/loader/index.js +0 -5
- package/dist/loader/security-validator.d.ts +0 -5
- package/dist/loader/security-validator.js +0 -50
- package/dist/loader/types.d.ts +0 -30
- package/dist/loader/types.js +0 -8
- package/dist/loader/unispec-loader.d.ts +0 -10
- package/dist/loader/unispec-loader.js +0 -81
- package/dist/loader/yaml-loader.d.ts +0 -10
- package/dist/loader/yaml-loader.js +0 -39
- package/dist/normalizer/core.d.ts +0 -24
- package/dist/normalizer/core.js +0 -29
- package/dist/normalizer/graphql-normalizer.d.ts +0 -8
- package/dist/normalizer/graphql-normalizer.js +0 -64
- package/dist/normalizer/index.d.ts +0 -2
- package/dist/normalizer/index.js +0 -3
- package/dist/normalizer/rest-normalizer.d.ts +0 -8
- package/dist/normalizer/rest-normalizer.js +0 -48
- package/dist/normalizer/types.d.ts +0 -7
- package/dist/normalizer/types.js +0 -1
- package/dist/normalizer/utils.d.ts +0 -14
- package/dist/normalizer/utils.js +0 -29
- package/dist/normalizer/websocket-normalizer.d.ts +0 -8
- package/dist/normalizer/websocket-normalizer.js +0 -78
- package/dist/optimizer/core.d.ts +0 -17
- package/dist/optimizer/core.js +0 -111
- package/dist/optimizer/index.d.ts +0 -4
- package/dist/optimizer/index.js +0 -7
- package/dist/optimizer/optimization-functions.d.ts +0 -32
- package/dist/optimizer/optimization-functions.js +0 -179
- package/dist/optimizer/types.d.ts +0 -28
- package/dist/optimizer/types.js +0 -1
- package/dist/optimizer/utils.d.ts +0 -7
- package/dist/optimizer/utils.js +0 -29
- package/dist/schemas/dedupe.d.ts +0 -9
- package/dist/schemas/dedupe.js +0 -97
- package/dist/schemas/index.d.ts +0 -3
- package/dist/schemas/index.js +0 -6
- package/dist/schemas/resolver.d.ts +0 -19
- package/dist/schemas/resolver.js +0 -37
- package/dist/schemas/utils.d.ts +0 -20
- package/dist/schemas/utils.js +0 -49
- package/dist/types/index.d.ts +0 -433
- package/dist/types/index.js +0 -1
- package/dist/validator/ajv-validator.d.ts +0 -15
- package/dist/validator/ajv-validator.js +0 -75
- package/dist/validator/config-validator-main.d.ts +0 -10
- package/dist/validator/config-validator-main.js +0 -31
- package/dist/validator/config-validator.d.ts +0 -5
- package/dist/validator/config-validator.js +0 -14
- package/dist/validator/index.d.ts +0 -10
- package/dist/validator/index.js +0 -11
- package/dist/validator/object-traversal.d.ts +0 -52
- package/dist/validator/object-traversal.js +0 -104
- package/dist/validator/reference-validator.d.ts +0 -31
- package/dist/validator/reference-validator.js +0 -230
- package/dist/validator/schema-references.d.ts +0 -23
- package/dist/validator/schema-references.js +0 -111
- package/dist/validator/semantic-validator.d.ts +0 -26
- package/dist/validator/semantic-validator.js +0 -325
- package/dist/validator/tests-validator.d.ts +0 -9
- package/dist/validator/tests-validator.js +0 -13
- package/dist/validator/types.d.ts +0 -29
- package/dist/validator/types.js +0 -1
- package/dist/validator/unispec-validator.d.ts +0 -15
- package/dist/validator/unispec-validator.js +0 -81
- package/dist/validator/validator-factory.d.ts +0 -10
- package/dist/validator/validator-factory.js +0 -73
- package/dist/versions.d.ts +0 -10
- package/dist/versions.js +0 -143
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const utils_1 = require("
|
|
9
|
-
const annotators_1 = require("
|
|
8
|
+
const utils_1 = require("tests/utils");
|
|
9
|
+
const annotators_1 = require("@/diff/annotators");
|
|
10
10
|
(0, node_test_1.describe)("diff annotators", () => {
|
|
11
11
|
(0, node_test_1.describe)("annotateRestChange", () => {
|
|
12
12
|
(0, node_test_1.it)("should annotate REST route additions as non-breaking", () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const core_1 = require("
|
|
9
|
+
const utils_1 = require("tests/utils");
|
|
10
|
+
const core_1 = require("@/diff/core");
|
|
11
11
|
(0, node_test_1.describe)("diff module - comprehensive schema examples", () => {
|
|
12
12
|
(0, node_test_1.describe)("valid spec examples", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle rest-simple.json correctly", () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const core_1 = require("
|
|
9
|
+
const utils_1 = require("tests/utils");
|
|
10
|
+
const core_1 = require("@/diff/core");
|
|
11
11
|
(0, node_test_1.describe)("diff module - extended tests", () => {
|
|
12
12
|
(0, node_test_1.describe)("handling of invalid examples", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle empty services array without crashing", () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const core_1 = require("
|
|
9
|
+
const utils_1 = require("tests/utils");
|
|
10
|
+
const core_1 = require("@/diff/core");
|
|
11
11
|
(0, node_test_1.describe)("diff module", () => {
|
|
12
12
|
(0, node_test_1.describe)("diffUniSpec", () => {
|
|
13
13
|
(0, node_test_1.it)("should detect no changes in identical documents", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadExample = exports.getExamplePath = exports.examplesDir = exports.createTestChange = void 0;
|
|
4
|
-
const utils_1 = require("
|
|
4
|
+
const utils_1 = require("tests/utils");
|
|
5
5
|
Object.defineProperty(exports, "createTestChange", { enumerable: true, get: function () { return utils_1.createTestChange; } });
|
|
6
6
|
Object.defineProperty(exports, "examplesDir", { enumerable: true, get: function () { return utils_1.examplesDir; } });
|
|
7
7
|
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const errors_1 = require("
|
|
9
|
-
const validator_1 = require("
|
|
10
|
-
const utils_1 = require("./utils
|
|
8
|
+
const errors_1 = require("@/errors");
|
|
9
|
+
const validator_1 = require("@/validator");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("errors module integration", () => {
|
|
12
12
|
(0, node_test_1.describe)("with validator module", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle validation errors from valid specs", async () => {
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const errors_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const errors_1 = require("@/errors");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("errors module", () => {
|
|
11
11
|
(0, node_test_1.describe)("UniSpecValidationError", () => {
|
|
12
12
|
(0, node_test_1.it)("should create basic validation error", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadInvalidExample = exports.loadExample = exports.getExamplePath = void 0;
|
|
4
|
-
const utils_1 = require("
|
|
4
|
+
const utils_1 = require("tests/utils");
|
|
5
5
|
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
6
6
|
Object.defineProperty(exports, "loadExample", { enumerable: true, get: function () { return utils_1.loadExample; } });
|
|
7
7
|
Object.defineProperty(exports, "loadInvalidExample", { enumerable: true, get: function () { return utils_1.loadInvalidExample; } });
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const loader_1 = require("
|
|
10
|
-
const utils_1 = require("../diff/utils
|
|
9
|
+
const loader_1 = require("@/loader");
|
|
10
|
+
const utils_1 = require("../diff/utils");
|
|
11
11
|
(0, node_test_1.describe)("loader integration tests", () => {
|
|
12
12
|
(0, node_test_1.describe)("real examples from @unispechq/unispec-schema", () => {
|
|
13
13
|
(0, node_test_1.it)("should load all valid spec examples", async () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const loader_1 = require("
|
|
9
|
+
const utils_1 = require("tests/utils");
|
|
10
|
+
const loader_1 = require("@/loader");
|
|
11
11
|
(0, node_test_1.describe)("loader", () => {
|
|
12
12
|
(0, node_test_1.describe)("loadUniSpec", () => {
|
|
13
13
|
(0, node_test_1.it)("should load valid JSON UniSpec document", async () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const normalizer_1 = require("
|
|
10
|
-
const utils_1 = require("./utils
|
|
9
|
+
const normalizer_1 = require("@/normalizer");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("normalizer module - comprehensive protocol tests", () => {
|
|
12
12
|
(0, node_test_1.describe)("REST protocol normalization", () => {
|
|
13
13
|
(0, node_test_1.it)("should sort REST routes by name when available", () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const normalizer_1 = require("
|
|
10
|
-
const utils_1 = require("./utils
|
|
9
|
+
const normalizer_1 = require("@/normalizer");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("normalizer module - invalid spec examples", () => {
|
|
12
12
|
(0, node_test_1.describe)("basic normalization with invalid documents", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle graphql-missing-arg-type.json without crashing", () => {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const node_test_1 = require("node:test");
|
|
9
|
-
const normalizer_1 = require("
|
|
10
|
-
const utils_1 = require("./utils
|
|
9
|
+
const normalizer_1 = require("@/normalizer");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("normalizer module - valid spec examples", () => {
|
|
12
12
|
(0, node_test_1.describe)("basic normalization", () => {
|
|
13
13
|
(0, node_test_1.it)("should normalize rest-simple.json correctly", () => {
|
|
@@ -7,7 +7,7 @@ exports.getRouteKeys = getRouteKeys;
|
|
|
7
7
|
exports.getOperationKeys = getOperationKeys;
|
|
8
8
|
exports.getChannelKeys = getChannelKeys;
|
|
9
9
|
exports.getMessageKeys = getMessageKeys;
|
|
10
|
-
const utils_1 = require("
|
|
10
|
+
const utils_1 = require("tests/utils");
|
|
11
11
|
Object.defineProperty(exports, "createTestDocument", { enumerable: true, get: function () { return utils_1.createTestDocument; } });
|
|
12
12
|
Object.defineProperty(exports, "examplesDir", { enumerable: true, get: function () { return utils_1.examplesDir; } });
|
|
13
13
|
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const optimization_functions_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const optimization_functions_1 = require("@/optimizer/optimization-functions");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("compressSchemaReferences", () => {
|
|
11
11
|
(0, node_test_1.it)("should compress JSON Pointer references", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithLongReferences)();
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const optimization_functions_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const optimization_functions_1 = require("@/optimizer/optimization-functions");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("deduplicateSchemas", () => {
|
|
11
11
|
(0, node_test_1.it)("should remove duplicate schemas and update references", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithDuplicateSchemas)();
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const core_1 = require("
|
|
9
|
-
const optimization_functions_1 = require("
|
|
10
|
-
const utils_1 = require("./utils
|
|
8
|
+
const core_1 = require("@/optimizer/core");
|
|
9
|
+
const optimization_functions_1 = require("@/optimizer/optimization-functions");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("Optimizer Integration Tests", () => {
|
|
12
12
|
(0, node_test_1.it)("should work with real examples from node_modules", () => {
|
|
13
13
|
const doc = (0, utils_1.loadExample)((0, utils_1.getExamplePath)("valid", "spec", "mixed-complete.json"));
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const core_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const core_1 = require("@/optimizer/core");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("generateOptimizationReport", () => {
|
|
11
11
|
(0, node_test_1.it)("should generate report for document with duplicates", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithDuplicateSchemas)();
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const core_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const core_1 = require("@/optimizer/core");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("optimizeDocument", () => {
|
|
11
11
|
(0, node_test_1.it)("should apply all optimizations by default", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithDuplicateSchemas)();
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const optimization_functions_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const optimization_functions_1 = require("@/optimizer/optimization-functions");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("removeOrphanedSchemas", () => {
|
|
11
11
|
(0, node_test_1.it)("should remove orphaned schemas", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithOrphanedSchemas)();
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const optimization_functions_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const optimization_functions_1 = require("@/optimizer/optimization-functions");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("sortSchemas", () => {
|
|
11
11
|
(0, node_test_1.it)("should sort schemas alphabetically", () => {
|
|
12
12
|
const doc = (0, utils_1.createDocumentWithUnsortedSchemas)();
|
|
@@ -6,7 +6,7 @@ exports.createDocumentWithDuplicateSchemas = createDocumentWithDuplicateSchemas;
|
|
|
6
6
|
exports.createDocumentWithOrphanedSchemas = createDocumentWithOrphanedSchemas;
|
|
7
7
|
exports.createDocumentWithUnsortedSchemas = createDocumentWithUnsortedSchemas;
|
|
8
8
|
exports.createDocumentWithLongReferences = createDocumentWithLongReferences;
|
|
9
|
-
const utils_1 = require("
|
|
9
|
+
const utils_1 = require("tests/utils");
|
|
10
10
|
Object.defineProperty(exports, "createTestDocument", { enumerable: true, get: function () { return utils_1.createTestDocument; } });
|
|
11
11
|
Object.defineProperty(exports, "examplesDir", { enumerable: true, get: function () { return utils_1.examplesDir; } });
|
|
12
12
|
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const schemas_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const utils_2 = require("./utils
|
|
8
|
+
const schemas_1 = require("@/schemas");
|
|
9
|
+
const utils_1 = require("@/schemas/utils");
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("schemas module - edge cases and invalid examples", () => {
|
|
12
12
|
(0, node_test_1.describe)("resolveSchemaRef with invalid examples", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle documents without schemas gracefully", () => {
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const schemas_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const utils_2 = require("./utils
|
|
8
|
+
const schemas_1 = require("@/schemas");
|
|
9
|
+
const utils_1 = require("@/schemas/utils");
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
11
|
(0, node_test_1.describe)("schemas module", () => {
|
|
12
12
|
(0, node_test_1.describe)("normalizeSchemaRef", () => {
|
|
13
13
|
(0, node_test_1.it)("should handle simple name format", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadExample = exports.getExamplePath = exports.examplesDir = void 0;
|
|
4
|
-
const utils_1 = require("
|
|
4
|
+
const utils_1 = require("tests/utils");
|
|
5
5
|
Object.defineProperty(exports, "examplesDir", { enumerable: true, get: function () { return utils_1.examplesDir; } });
|
|
6
6
|
Object.defineProperty(exports, "getExamplePath", { enumerable: true, get: function () { return utils_1.getExamplePath; } });
|
|
7
7
|
Object.defineProperty(exports, "loadExample", { enumerable: true, get: function () { return utils_1.loadExample; } });
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const validator_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const validator_1 = require("@/validator");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("validateUniSpecConfig", () => {
|
|
11
11
|
(0, node_test_1.describe)("valid examples", () => {
|
|
12
12
|
(0, node_test_1.it)("should validate simple multi-service config", async () => {
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const validator_1 = require("
|
|
9
|
-
const utils_1 = require("./utils
|
|
8
|
+
const validator_1 = require("@/validator");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
(0, node_test_1.describe)("validateUniSpec", () => {
|
|
11
11
|
(0, node_test_1.describe)("valid examples", () => {
|
|
12
12
|
(0, node_test_1.it)("should validate simple REST spec", async () => {
|
|
@@ -5,7 +5,7 @@ exports.loadInvalidSpecExample = loadInvalidSpecExample;
|
|
|
5
5
|
exports.loadValidConfigExample = loadValidConfigExample;
|
|
6
6
|
exports.loadInvalidConfigExample = loadInvalidConfigExample;
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const utils_1 = require("
|
|
8
|
+
const utils_1 = require("tests/utils");
|
|
9
9
|
// Validator-specific utilities
|
|
10
10
|
function loadValidSpecExample(name) {
|
|
11
11
|
const path = (0, node_path_1.join)(utils_1.examplesDir, "valid/spec", `${name}.json`);
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { UniSpecCacheManager } from "./cache-manager.js";
|
|
2
|
-
import type { CacheOptions } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Create a new isolated cache manager instance.
|
|
5
|
-
* @param options - Cache configuration options
|
|
6
|
-
* @returns New cache manager instance
|
|
7
|
-
*/
|
|
8
|
-
export declare function createCacheManager(options?: CacheOptions): UniSpecCacheManager;
|
|
9
|
-
/**
|
|
10
|
-
* Create a named cache manager instance with simple registry.
|
|
11
|
-
* @param name - Instance name for identification
|
|
12
|
-
* @param options - Cache configuration options
|
|
13
|
-
* @returns Cache manager instance
|
|
14
|
-
*/
|
|
15
|
-
export declare function createNamedCacheManager(name?: string, options?: CacheOptions): UniSpecCacheManager;
|
|
16
|
-
/**
|
|
17
|
-
* Get cache manager statistics for multiple instances.
|
|
18
|
-
* @param managers - Array of cache manager instances
|
|
19
|
-
* @returns Statistics for all provided managers
|
|
20
|
-
*/
|
|
21
|
-
export declare function getManagersStats(managers: UniSpecCacheManager[]): Record<string, ReturnType<UniSpecCacheManager["getStats"]>>;
|
|
22
|
-
/**
|
|
23
|
-
* Destroy multiple cache manager instances.
|
|
24
|
-
* @param managers - Array of cache manager instances to destroy
|
|
25
|
-
*/
|
|
26
|
-
export declare function destroyManagers(managers: UniSpecCacheManager[]): void;
|
|
27
|
-
/**
|
|
28
|
-
* Clear test registry (for testing only).
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export declare function clearTestRegistry(): void;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { UniSpecCacheManager } from "./cache-manager.js";
|
|
2
|
-
/**
|
|
3
|
-
* Simple registry for test cleanup (minimal, not persistent global state)
|
|
4
|
-
*/
|
|
5
|
-
const testRegistry = new Map();
|
|
6
|
-
/**
|
|
7
|
-
* Create a new isolated cache manager instance.
|
|
8
|
-
* @param options - Cache configuration options
|
|
9
|
-
* @returns New cache manager instance
|
|
10
|
-
*/
|
|
11
|
-
export function createCacheManager(options) {
|
|
12
|
-
return new UniSpecCacheManager(options);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Create a named cache manager instance with simple registry.
|
|
16
|
-
* @param name - Instance name for identification
|
|
17
|
-
* @param options - Cache configuration options
|
|
18
|
-
* @returns Cache manager instance
|
|
19
|
-
*/
|
|
20
|
-
export function createNamedCacheManager(name = "default", options) {
|
|
21
|
-
// For testing, keep simple registry to enable cleanup
|
|
22
|
-
if (testRegistry.has(name)) {
|
|
23
|
-
const existing = testRegistry.get(name);
|
|
24
|
-
if (existing) {
|
|
25
|
-
existing.destroy(); // Cleanup existing instance
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const manager = new UniSpecCacheManager(options);
|
|
29
|
-
manager._name = name; // Store name for debugging
|
|
30
|
-
testRegistry.set(name, manager); // Add to registry for cleanup
|
|
31
|
-
return manager;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get cache manager statistics for multiple instances.
|
|
35
|
-
* @param managers - Array of cache manager instances
|
|
36
|
-
* @returns Statistics for all provided managers
|
|
37
|
-
*/
|
|
38
|
-
export function getManagersStats(managers) {
|
|
39
|
-
const stats = {};
|
|
40
|
-
for (const [index, manager] of managers.entries()) {
|
|
41
|
-
const name = manager._name ||
|
|
42
|
-
`manager_${index}`;
|
|
43
|
-
stats[name] = manager.getStats();
|
|
44
|
-
}
|
|
45
|
-
return stats;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Destroy multiple cache manager instances.
|
|
49
|
-
* @param managers - Array of cache manager instances to destroy
|
|
50
|
-
*/
|
|
51
|
-
export function destroyManagers(managers) {
|
|
52
|
-
for (const manager of managers) {
|
|
53
|
-
manager.destroy();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Clear test registry (for testing only).
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export function clearTestRegistry() {
|
|
61
|
-
for (const manager of testRegistry.values()) {
|
|
62
|
-
manager.destroy();
|
|
63
|
-
}
|
|
64
|
-
testRegistry.clear();
|
|
65
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ValidationResult } from "../types/index.js";
|
|
2
|
-
import type { CacheOptions, CacheStats } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cache manager for UniSpec operations.
|
|
5
|
-
*/
|
|
6
|
-
export declare class UniSpecCacheManager {
|
|
7
|
-
private validationCache;
|
|
8
|
-
private normalizationCache;
|
|
9
|
-
private diffCache;
|
|
10
|
-
private cleanupInterval;
|
|
11
|
-
constructor(options?: CacheOptions);
|
|
12
|
-
/**
|
|
13
|
-
* Get cached validation result asynchronously.
|
|
14
|
-
*/
|
|
15
|
-
getValidationResult(documentHash: string): Promise<ValidationResult | undefined>;
|
|
16
|
-
/**
|
|
17
|
-
* Cache validation result asynchronously.
|
|
18
|
-
*/
|
|
19
|
-
setValidationResult(documentHash: string, result: ValidationResult): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Get cached normalization result asynchronously.
|
|
22
|
-
*/
|
|
23
|
-
getNormalizationResult(documentHash: string): Promise<unknown>;
|
|
24
|
-
/**
|
|
25
|
-
* Cache normalization result asynchronously.
|
|
26
|
-
*/
|
|
27
|
-
setNormalizationResult(documentHash: string, result: unknown): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Get cached diff result asynchronously.
|
|
30
|
-
*/
|
|
31
|
-
getDiffResult(docsHash: string): Promise<unknown>;
|
|
32
|
-
/**
|
|
33
|
-
* Cache diff result asynchronously.
|
|
34
|
-
*/
|
|
35
|
-
setDiffResult(docsHash: string, result: unknown): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Get comprehensive cache statistics.
|
|
38
|
-
*/
|
|
39
|
-
getStats(): {
|
|
40
|
-
validation: CacheStats;
|
|
41
|
-
normalization: CacheStats;
|
|
42
|
-
diff: CacheStats;
|
|
43
|
-
total: {
|
|
44
|
-
size: number;
|
|
45
|
-
hits: number;
|
|
46
|
-
misses: number;
|
|
47
|
-
hitRate: number;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Clear all caches.
|
|
52
|
-
*/
|
|
53
|
-
clearAll(): void;
|
|
54
|
-
/**
|
|
55
|
-
* Start automatic cleanup interval.
|
|
56
|
-
*/
|
|
57
|
-
private startCleanup;
|
|
58
|
-
/**
|
|
59
|
-
* Stop automatic cleanup.
|
|
60
|
-
*/
|
|
61
|
-
destroy(): void;
|
|
62
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { CACHE_CONSTANTS, CACHE_MESSAGES } from "./constants.js";
|
|
2
|
-
import { LRUCache } from "./lru-cache.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cache manager for UniSpec operations.
|
|
5
|
-
*/
|
|
6
|
-
export class UniSpecCacheManager {
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
this.cleanupInterval = null;
|
|
9
|
-
this.validationCache = new LRUCache({
|
|
10
|
-
...options,
|
|
11
|
-
maxSize: CACHE_CONSTANTS.VALIDATION_MAX_SIZE,
|
|
12
|
-
});
|
|
13
|
-
this.normalizationCache = new LRUCache({
|
|
14
|
-
...options,
|
|
15
|
-
maxSize: CACHE_CONSTANTS.NORMALIZATION_MAX_SIZE,
|
|
16
|
-
});
|
|
17
|
-
this.diffCache = new LRUCache({
|
|
18
|
-
...options,
|
|
19
|
-
maxSize: CACHE_CONSTANTS.DIFF_MAX_SIZE,
|
|
20
|
-
});
|
|
21
|
-
// Start cleanup interval
|
|
22
|
-
this.startCleanup();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get cached validation result asynchronously.
|
|
26
|
-
*/
|
|
27
|
-
async getValidationResult(documentHash) {
|
|
28
|
-
return await this.validationCache.get(documentHash);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Cache validation result asynchronously.
|
|
32
|
-
*/
|
|
33
|
-
async setValidationResult(documentHash, result) {
|
|
34
|
-
await this.validationCache.set(documentHash, result);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get cached normalization result asynchronously.
|
|
38
|
-
*/
|
|
39
|
-
async getNormalizationResult(documentHash) {
|
|
40
|
-
return await this.normalizationCache.get(documentHash);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Cache normalization result asynchronously.
|
|
44
|
-
*/
|
|
45
|
-
async setNormalizationResult(documentHash, result) {
|
|
46
|
-
await this.normalizationCache.set(documentHash, result);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get cached diff result asynchronously.
|
|
50
|
-
*/
|
|
51
|
-
async getDiffResult(docsHash) {
|
|
52
|
-
return await this.diffCache.get(docsHash);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Cache diff result asynchronously.
|
|
56
|
-
*/
|
|
57
|
-
async setDiffResult(docsHash, result) {
|
|
58
|
-
await this.diffCache.set(docsHash, result);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get comprehensive cache statistics.
|
|
62
|
-
*/
|
|
63
|
-
getStats() {
|
|
64
|
-
const validationStats = this.validationCache.getStats();
|
|
65
|
-
const normalizationStats = this.normalizationCache.getStats();
|
|
66
|
-
const diffStats = this.diffCache.getStats();
|
|
67
|
-
const total = {
|
|
68
|
-
size: validationStats.size + normalizationStats.size + diffStats.size,
|
|
69
|
-
hits: validationStats.hits + normalizationStats.hits + diffStats.hits,
|
|
70
|
-
misses: validationStats.misses + normalizationStats.misses + diffStats.misses,
|
|
71
|
-
hitRate: 0,
|
|
72
|
-
};
|
|
73
|
-
const totalRequests = total.hits + total.misses;
|
|
74
|
-
total.hitRate = totalRequests > 0 ? total.hits / totalRequests : 0;
|
|
75
|
-
return {
|
|
76
|
-
validation: validationStats,
|
|
77
|
-
normalization: normalizationStats,
|
|
78
|
-
diff: diffStats,
|
|
79
|
-
total,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Clear all caches.
|
|
84
|
-
*/
|
|
85
|
-
clearAll() {
|
|
86
|
-
this.validationCache.clear();
|
|
87
|
-
this.normalizationCache.clear();
|
|
88
|
-
this.diffCache.clear();
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Start automatic cleanup interval.
|
|
92
|
-
*/
|
|
93
|
-
startCleanup() {
|
|
94
|
-
try {
|
|
95
|
-
this.cleanupInterval = setInterval(() => {
|
|
96
|
-
try {
|
|
97
|
-
this.validationCache.cleanup();
|
|
98
|
-
this.normalizationCache.cleanup();
|
|
99
|
-
this.diffCache.cleanup();
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
console.error(CACHE_MESSAGES.CLEANUP_ERROR, error);
|
|
103
|
-
// Continue running cleanup even if one cache fails
|
|
104
|
-
}
|
|
105
|
-
}, CACHE_CONSTANTS.CLEANUP_INTERVAL);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
console.error(CACHE_MESSAGES.CLEANUP_START_ERROR, error);
|
|
109
|
-
// Cache will still work without automatic cleanup
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Stop automatic cleanup.
|
|
114
|
-
*/
|
|
115
|
-
destroy() {
|
|
116
|
-
if (this.cleanupInterval) {
|
|
117
|
-
clearInterval(this.cleanupInterval);
|
|
118
|
-
this.cleanupInterval = null;
|
|
119
|
-
}
|
|
120
|
-
this.clearAll();
|
|
121
|
-
}
|
|
122
|
-
}
|