@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
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSemantic = validateSemantic;
|
|
4
|
-
/**
|
|
5
|
-
* Validate naming conventions across the UniSpec document.
|
|
6
|
-
*/
|
|
7
|
-
function validateNamingConventions(doc, options) {
|
|
8
|
-
const errors = [];
|
|
9
|
-
if (!options.strictNaming)
|
|
10
|
-
return errors;
|
|
11
|
-
// Validate service name
|
|
12
|
-
if (doc.service.name) {
|
|
13
|
-
if (!/^[a-z][a-z0-9-]*$/.test(doc.service.name)) {
|
|
14
|
-
errors.push({
|
|
15
|
-
message: "Service name should use kebab-case starting with lowercase letter",
|
|
16
|
-
path: "/service/name",
|
|
17
|
-
code: "naming_convention",
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// Validate REST route names
|
|
22
|
-
const restRoutes = doc.service?.protocols?.rest?.routes || [];
|
|
23
|
-
for (const route of restRoutes) {
|
|
24
|
-
if (route.name && !/^[a-z][a-zA-Z0-9]*$/.test(route.name)) {
|
|
25
|
-
errors.push({
|
|
26
|
-
message: "REST route name should use camelCase starting with lowercase letter",
|
|
27
|
-
path: `/service/protocols/rest/routes/${route.name}/name`,
|
|
28
|
-
code: "naming_convention",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
// Validate path parameters naming
|
|
32
|
-
if (route.pathParams) {
|
|
33
|
-
for (const param of route.pathParams) {
|
|
34
|
-
if (param.name && !/^[a-z][a-zA-Z0-9]*$/.test(param.name)) {
|
|
35
|
-
errors.push({
|
|
36
|
-
message: "Path parameter name should use camelCase starting with lowercase letter",
|
|
37
|
-
path: `/service/protocols/rest/routes/${route.name}/pathParams/${param.name}/name`,
|
|
38
|
-
code: "naming_convention",
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Validate GraphQL operation names
|
|
45
|
-
const graphql = doc.service?.protocols?.graphql;
|
|
46
|
-
if (graphql) {
|
|
47
|
-
const operations = [
|
|
48
|
-
...(graphql.queries || []),
|
|
49
|
-
...(graphql.mutations || []),
|
|
50
|
-
...(graphql.subscriptions || []),
|
|
51
|
-
];
|
|
52
|
-
for (const op of operations) {
|
|
53
|
-
if (op.name && !/^[A-Z][a-zA-Z]*$/.test(op.name)) {
|
|
54
|
-
errors.push({
|
|
55
|
-
message: "GraphQL operation name should use PascalCase starting with uppercase letter",
|
|
56
|
-
path: `/service/protocols/graphql/${op.name}/name`,
|
|
57
|
-
code: "naming_convention",
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Validate WebSocket channel and message names
|
|
63
|
-
const websocket = doc.service?.protocols?.websocket;
|
|
64
|
-
if (websocket?.channels) {
|
|
65
|
-
for (const channel of websocket.channels) {
|
|
66
|
-
if (channel.name && !/^[a-z][a-zA-Z0-9]*$/.test(channel.name)) {
|
|
67
|
-
errors.push({
|
|
68
|
-
message: "WebSocket channel name should use camelCase starting with lowercase letter",
|
|
69
|
-
path: `/service/protocols/websocket/channels/${channel.name}/name`,
|
|
70
|
-
code: "naming_convention",
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (channel.messages) {
|
|
74
|
-
for (const message of channel.messages) {
|
|
75
|
-
if (message.name && !/^[a-z][a-zA-Z0-9]*$/.test(message.name)) {
|
|
76
|
-
errors.push({
|
|
77
|
-
message: "WebSocket message name should use camelCase starting with lowercase letter",
|
|
78
|
-
path: `/service/protocols/websocket/channels/${channel.name}/messages/${message.name}/name`,
|
|
79
|
-
code: "naming_convention",
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return errors;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Validate URL patterns and formats.
|
|
90
|
-
*/
|
|
91
|
-
function validateUrlPatterns(doc, options) {
|
|
92
|
-
const errors = [];
|
|
93
|
-
if (!options.checkUrlPatterns)
|
|
94
|
-
return errors;
|
|
95
|
-
// Validate baseUrl
|
|
96
|
-
if (doc.service.baseUrl) {
|
|
97
|
-
try {
|
|
98
|
-
new URL(doc.service.baseUrl);
|
|
99
|
-
if (!doc.service.baseUrl.startsWith("http") &&
|
|
100
|
-
!doc.service.baseUrl.startsWith("https")) {
|
|
101
|
-
errors.push({
|
|
102
|
-
message: "baseUrl should start with http:// or https://",
|
|
103
|
-
path: "/service/baseUrl",
|
|
104
|
-
code: "invalid_url",
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
errors.push({
|
|
110
|
-
message: "baseUrl is not a valid URL",
|
|
111
|
-
path: "/service/baseUrl",
|
|
112
|
-
code: "invalid_url",
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Validate REST route paths
|
|
117
|
-
const restRoutes = doc.service?.protocols?.rest?.routes || [];
|
|
118
|
-
for (const route of restRoutes) {
|
|
119
|
-
if (route.path) {
|
|
120
|
-
// Path should start with /
|
|
121
|
-
if (!route.path.startsWith("/")) {
|
|
122
|
-
errors.push({
|
|
123
|
-
message: "REST route path should start with '/'",
|
|
124
|
-
path: `/service/protocols/rest/routes/${route.name}/path`,
|
|
125
|
-
code: "invalid_path",
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// Check for path parameter consistency
|
|
129
|
-
const pathParamMatches = route.path.match(/:\w+/g) || [];
|
|
130
|
-
const declaredParams = route.pathParams?.map((p) => p.name) || [];
|
|
131
|
-
for (const param of pathParamMatches) {
|
|
132
|
-
const paramName = param.slice(1); // Remove ':'
|
|
133
|
-
if (!declaredParams.includes(paramName)) {
|
|
134
|
-
errors.push({
|
|
135
|
-
message: `Path parameter '${paramName}' is used in path but not declared in pathParams`,
|
|
136
|
-
path: `/service/protocols/rest/routes/${route.name}/path`,
|
|
137
|
-
code: "undeclared_parameter",
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// Check for declared parameters not used in path
|
|
142
|
-
for (const declaredParam of declaredParams) {
|
|
143
|
-
if (!pathParamMatches.some((match) => match.slice(1) === declaredParam)) {
|
|
144
|
-
errors.push({
|
|
145
|
-
message: `Path parameter '${declaredParam}' is declared but not used in path`,
|
|
146
|
-
path: `/service/protocols/rest/routes/${route.name}/pathParams/${declaredParam}`,
|
|
147
|
-
code: "unused_parameter",
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return errors;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Check for name conflicts across different components.
|
|
157
|
-
*/
|
|
158
|
-
function validateNameConflicts(doc, options) {
|
|
159
|
-
const errors = [];
|
|
160
|
-
if (!options.checkNameConflicts)
|
|
161
|
-
return errors;
|
|
162
|
-
const allNames = new Map();
|
|
163
|
-
// Collect REST route names
|
|
164
|
-
const restRoutes = doc.service?.protocols?.rest?.routes || [];
|
|
165
|
-
for (const route of restRoutes) {
|
|
166
|
-
if (route.name) {
|
|
167
|
-
const existing = allNames.get(route.name) || [];
|
|
168
|
-
existing.push(`REST route: ${route.path} ${route.method}`);
|
|
169
|
-
allNames.set(route.name, existing);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// Collect GraphQL operation names
|
|
173
|
-
const graphql = doc.service?.protocols?.graphql;
|
|
174
|
-
if (graphql) {
|
|
175
|
-
const operations = [
|
|
176
|
-
...(graphql.queries || []),
|
|
177
|
-
...(graphql.mutations || []),
|
|
178
|
-
...(graphql.subscriptions || []),
|
|
179
|
-
];
|
|
180
|
-
for (const op of operations) {
|
|
181
|
-
if (op.name) {
|
|
182
|
-
const existing = allNames.get(op.name) || [];
|
|
183
|
-
existing.push(`GraphQL operation`);
|
|
184
|
-
allNames.set(op.name, existing);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// Collect WebSocket channel names
|
|
189
|
-
const websocket = doc.service?.protocols?.websocket;
|
|
190
|
-
if (websocket?.channels) {
|
|
191
|
-
for (const channel of websocket.channels) {
|
|
192
|
-
if (channel.name) {
|
|
193
|
-
const existing = allNames.get(channel.name) || [];
|
|
194
|
-
existing.push(`WebSocket channel`);
|
|
195
|
-
allNames.set(channel.name, existing);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// Check for conflicts
|
|
200
|
-
for (const [name, locations] of allNames.entries()) {
|
|
201
|
-
if (locations.length > 1) {
|
|
202
|
-
errors.push({
|
|
203
|
-
message: `Name '${name}' is used in multiple locations: ${locations.join(", ")}`,
|
|
204
|
-
path: "",
|
|
205
|
-
code: "name_conflict",
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return errors;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Check for circular dependencies in schemas.
|
|
213
|
-
*/
|
|
214
|
-
function validateCircularDependencies(doc, options) {
|
|
215
|
-
const errors = [];
|
|
216
|
-
if (!options.checkCircularDependencies)
|
|
217
|
-
return errors;
|
|
218
|
-
const schemas = doc.service?.schemas;
|
|
219
|
-
if (!schemas)
|
|
220
|
-
return errors;
|
|
221
|
-
// Build dependency graph
|
|
222
|
-
const dependencies = new Map();
|
|
223
|
-
for (const [schemaName, schema] of Object.entries(schemas)) {
|
|
224
|
-
const deps = new Set();
|
|
225
|
-
findSchemaReferences(schema.jsonSchema, deps);
|
|
226
|
-
dependencies.set(schemaName, deps);
|
|
227
|
-
}
|
|
228
|
-
// Check for circular dependencies
|
|
229
|
-
const visited = new Set();
|
|
230
|
-
const recursionStack = new Set();
|
|
231
|
-
function hasCycle(schemaName, path) {
|
|
232
|
-
if (recursionStack.has(schemaName)) {
|
|
233
|
-
const cycle = [...path.slice(path.indexOf(schemaName)), schemaName].join(" -> ");
|
|
234
|
-
errors.push({
|
|
235
|
-
message: `Circular dependency detected in schemas: ${cycle}`,
|
|
236
|
-
path: `/service/schemas/${schemaName}`,
|
|
237
|
-
code: "circular_dependency",
|
|
238
|
-
});
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
if (visited.has(schemaName))
|
|
242
|
-
return false;
|
|
243
|
-
visited.add(schemaName);
|
|
244
|
-
recursionStack.add(schemaName);
|
|
245
|
-
const deps = dependencies.get(schemaName) || new Set();
|
|
246
|
-
for (const dep of deps) {
|
|
247
|
-
if (hasCycle(dep, [...path, schemaName])) {
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
recursionStack.delete(schemaName);
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
for (const schemaName of Object.keys(schemas)) {
|
|
255
|
-
if (!visited.has(schemaName)) {
|
|
256
|
-
hasCycle(schemaName, []);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return errors;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Find all schema references in a JSON Schema object.
|
|
263
|
-
*/
|
|
264
|
-
function findSchemaReferences(schema, dependencies) {
|
|
265
|
-
if (!schema || typeof schema !== "object")
|
|
266
|
-
return;
|
|
267
|
-
const schemaRecord = schema;
|
|
268
|
-
// Check for $ref
|
|
269
|
-
if (schemaRecord.$ref && typeof schemaRecord.$ref === "string") {
|
|
270
|
-
const ref = schemaRecord.$ref;
|
|
271
|
-
if (ref.startsWith("#/service/schemas/")) {
|
|
272
|
-
const schemaName = ref.split("/").pop();
|
|
273
|
-
if (schemaName) {
|
|
274
|
-
dependencies.add(schemaName);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
// Check for schemaRef
|
|
279
|
-
if (schemaRecord.schemaRef && typeof schemaRecord.schemaRef === "string") {
|
|
280
|
-
dependencies.add(schemaRecord.schemaRef);
|
|
281
|
-
}
|
|
282
|
-
// Recursively check all properties
|
|
283
|
-
for (const [_key, value] of Object.entries(schemaRecord)) {
|
|
284
|
-
if (Array.isArray(value)) {
|
|
285
|
-
for (const item of value) {
|
|
286
|
-
findSchemaReferences(item, dependencies);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else if (typeof value === "object" && value !== null) {
|
|
290
|
-
findSchemaReferences(value, dependencies);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Perform semantic validation on a UniSpec document.
|
|
296
|
-
*
|
|
297
|
-
* This function goes beyond JSON Schema validation to check:
|
|
298
|
-
* - Naming conventions
|
|
299
|
-
* - URL patterns
|
|
300
|
-
* - Name conflicts
|
|
301
|
-
* - Circular dependencies
|
|
302
|
-
*
|
|
303
|
-
* @param doc - The UniSpec document to validate
|
|
304
|
-
* @param options - Validation options
|
|
305
|
-
* @returns Semantic validation result
|
|
306
|
-
*/
|
|
307
|
-
function validateSemantic(doc, options = {}) {
|
|
308
|
-
const errors = [];
|
|
309
|
-
const warnings = [];
|
|
310
|
-
// Default options
|
|
311
|
-
const opts = {
|
|
312
|
-
strictNaming: true,
|
|
313
|
-
checkUrlPatterns: true,
|
|
314
|
-
checkNameConflicts: true,
|
|
315
|
-
checkCircularDependencies: true,
|
|
316
|
-
...options,
|
|
317
|
-
};
|
|
318
|
-
// Run all semantic validations
|
|
319
|
-
errors.push(...validateNamingConventions(doc, opts));
|
|
320
|
-
errors.push(...validateUrlPatterns(doc, opts));
|
|
321
|
-
errors.push(...validateNameConflicts(doc, opts));
|
|
322
|
-
errors.push(...validateCircularDependencies(doc, opts));
|
|
323
|
-
return {
|
|
324
|
-
valid: errors.length === 0,
|
|
325
|
-
errors,
|
|
326
|
-
warnings,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateUniSpecTests = void 0;
|
|
4
|
-
const ajv_validator_1 = require("./ajv-validator.js");
|
|
5
|
-
const validator_factory_1 = require("./validator-factory.js");
|
|
6
|
-
/**
|
|
7
|
-
* Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
|
|
8
|
-
*
|
|
9
|
-
* @param doc - The UniSpec Tests document to validate
|
|
10
|
-
* @param options - Validation options including custom schemas
|
|
11
|
-
* @returns Validation result with success status and error details
|
|
12
|
-
*/
|
|
13
|
-
exports.validateUniSpecTests = (0, validator_factory_1.createValidator)("unispecTests", async (options) => {
|
|
14
|
-
const { validateUniSpecTestsFn } = await (0, ajv_validator_1.getValidator)(options);
|
|
15
|
-
return validateUniSpecTestsFn;
|
|
16
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateUniSpec = validateUniSpec;
|
|
4
|
-
const errors_1 = require("../errors/index.js");
|
|
5
|
-
const ajv_validator_1 = require("./ajv-validator.js");
|
|
6
|
-
const reference_validator_1 = require("./reference-validator.js");
|
|
7
|
-
const semantic_validator_1 = require("./semantic-validator.js");
|
|
8
|
-
const validator_factory_1 = require("./validator-factory.js");
|
|
9
|
-
/**
|
|
10
|
-
* Validate a UniSpec document with optional extended validation.
|
|
11
|
-
*
|
|
12
|
-
* This function performs:
|
|
13
|
-
* - JSON Schema validation (always)
|
|
14
|
-
* - Semantic validation (optional, when enableExtendedValidation is true)
|
|
15
|
-
* - Reference validation (optional, when enableExtendedValidation is true)
|
|
16
|
-
*
|
|
17
|
-
* @param doc - The UniSpec document to validate
|
|
18
|
-
* @param options - Validation options
|
|
19
|
-
* @returns Validation result with optional extended results
|
|
20
|
-
*/
|
|
21
|
-
async function validateUniSpec(doc, options = {}) {
|
|
22
|
-
// Always perform basic JSON Schema validation
|
|
23
|
-
const basicResult = await validateUniSpecBase(doc, options);
|
|
24
|
-
// If extended validation is disabled, return basic result
|
|
25
|
-
if (!options.enableExtendedValidation) {
|
|
26
|
-
return basicResult;
|
|
27
|
-
}
|
|
28
|
-
// Perform extended validation
|
|
29
|
-
const result = {
|
|
30
|
-
valid: basicResult.valid,
|
|
31
|
-
errors: [...basicResult.errors],
|
|
32
|
-
};
|
|
33
|
-
// Perform semantic validation
|
|
34
|
-
if (options.semanticValidation) {
|
|
35
|
-
const semanticResult = (0, semantic_validator_1.validateSemantic)(doc, options.semanticValidation);
|
|
36
|
-
result.semantic = semanticResult;
|
|
37
|
-
if (!semanticResult.valid) {
|
|
38
|
-
result.valid = false;
|
|
39
|
-
result.errors.push(...semanticResult.errors);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Perform reference validation
|
|
43
|
-
if (options.referenceValidation) {
|
|
44
|
-
const referenceResult = (0, reference_validator_1.validateReferences)(doc, options.referenceValidation);
|
|
45
|
-
result.references = referenceResult;
|
|
46
|
-
if (!referenceResult.valid) {
|
|
47
|
-
result.valid = false;
|
|
48
|
-
result.errors.push(...referenceResult.errors);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Internal function for basic JSON Schema validation.
|
|
55
|
-
*/
|
|
56
|
-
async function validateUniSpecBase(doc, options = {}) {
|
|
57
|
-
try {
|
|
58
|
-
const { validateUniSpecFn } = await (0, ajv_validator_1.getValidator)(options);
|
|
59
|
-
// Ensure the document has required fields for validation
|
|
60
|
-
const docForValidation = {
|
|
61
|
-
unispecVersion: doc.unispecVersion || "1.0.0",
|
|
62
|
-
service: doc.service,
|
|
63
|
-
};
|
|
64
|
-
const valid = validateUniSpecFn(docForValidation);
|
|
65
|
-
const schemaErrors = (0, validator_factory_1.mapAjvErrors)(validateUniSpecFn.errors);
|
|
66
|
-
if (valid) {
|
|
67
|
-
return {
|
|
68
|
-
valid: true,
|
|
69
|
-
errors: [],
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
valid: false,
|
|
74
|
-
errors: schemaErrors,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
const validationError = errors_1.ErrorFactory.fromError(error, "validation_error");
|
|
79
|
-
return {
|
|
80
|
-
valid: false,
|
|
81
|
-
errors: [validationError.toJSON()],
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createValidator = createValidator;
|
|
4
|
-
exports.mapAjvErrors = mapAjvErrors;
|
|
5
|
-
const errors_1 = require("../errors/index.js");
|
|
6
|
-
/**
|
|
7
|
-
* Generic validator factory to reduce code duplication.
|
|
8
|
-
*/
|
|
9
|
-
function createValidator(documentType, getValidatorFn, customValidation) {
|
|
10
|
-
return async function validate(doc, options = {}) {
|
|
11
|
-
try {
|
|
12
|
-
const validateFn = await getValidatorFn(options);
|
|
13
|
-
if (!validateFn) {
|
|
14
|
-
return {
|
|
15
|
-
valid: false,
|
|
16
|
-
errors: [
|
|
17
|
-
{
|
|
18
|
-
message: `${documentType} validation schema is not available. Provide appropriate schema in ValidateOptions.`,
|
|
19
|
-
path: "",
|
|
20
|
-
code: "schema_missing",
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const valid = validateFn(doc);
|
|
26
|
-
// Run custom validation if provided
|
|
27
|
-
const customErrors = customValidation ? customValidation(doc) : [];
|
|
28
|
-
const schemaErrors = valid ? [] : mapAjvErrors(validateFn.errors);
|
|
29
|
-
const allErrors = [...schemaErrors, ...customErrors];
|
|
30
|
-
if (valid && customErrors.length === 0) {
|
|
31
|
-
return {
|
|
32
|
-
valid: true,
|
|
33
|
-
errors: [],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
valid: false,
|
|
38
|
-
errors: allErrors,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
const validationError = errors_1.ErrorFactory.fromError(error, `${documentType}_validation_error`);
|
|
43
|
-
return {
|
|
44
|
-
valid: false,
|
|
45
|
-
errors: [validationError.toJSON()],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Map AJV errors to specific UniSpec validation errors.
|
|
52
|
-
*/
|
|
53
|
-
function mapAjvErrors(errors) {
|
|
54
|
-
if (!errors)
|
|
55
|
-
return [];
|
|
56
|
-
return errors.map((error) => {
|
|
57
|
-
const message = error.message || "UniSpec validation error";
|
|
58
|
-
const path = error.instancePath || error.schemaPath;
|
|
59
|
-
const _code = error.keyword;
|
|
60
|
-
// Create specific error types based on keyword
|
|
61
|
-
switch (error.keyword) {
|
|
62
|
-
case "required":
|
|
63
|
-
return errors_1.ErrorFactory.createSchemaError(`Missing required property: ${message}`, path, { keyword: error.keyword, params: error.params });
|
|
64
|
-
case "type":
|
|
65
|
-
return errors_1.ErrorFactory.createSchemaError(`Invalid type: ${message}`, path, { keyword: error.keyword, params: error.params });
|
|
66
|
-
case "format":
|
|
67
|
-
return errors_1.ErrorFactory.createSchemaError(`Invalid format: ${message}`, path, { keyword: error.keyword, params: error.params });
|
|
68
|
-
case "additionalProperties":
|
|
69
|
-
return errors_1.ErrorFactory.createSchemaError(`Additional property not allowed: ${message}`, path, { keyword: error.keyword, params: error.params });
|
|
70
|
-
default:
|
|
71
|
-
return errors_1.ErrorFactory.createSchemaError(message, path, {
|
|
72
|
-
keyword: error.keyword,
|
|
73
|
-
params: error.params,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
package/dist/cjs/versions.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLatestUniSpecVersion = getLatestUniSpecVersion;
|
|
4
|
-
exports.clearVersionCache = clearVersionCache;
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const node_url_1 = require("node:url");
|
|
8
|
-
let cachedUniSpecVersion = null;
|
|
9
|
-
let cachedSchemaPackagePath = null;
|
|
10
|
-
/**
|
|
11
|
-
* Validate package.json content to ensure it's the correct @unispechq/unispec-schema package
|
|
12
|
-
* @param content Package.json content as string
|
|
13
|
-
* @returns Package info object if valid, null otherwise
|
|
14
|
-
*/
|
|
15
|
-
function validatePackageJson(content) {
|
|
16
|
-
try {
|
|
17
|
-
const packageInfo = JSON.parse(content);
|
|
18
|
-
if (packageInfo.name === "@unispechq/unispec-schema" &&
|
|
19
|
-
packageInfo.version) {
|
|
20
|
-
return packageInfo;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
// Invalid JSON
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get current module directory (supports both ESM and CJS)
|
|
30
|
-
* @returns Current directory path
|
|
31
|
-
*/
|
|
32
|
-
function getCurrentDirectory() {
|
|
33
|
-
if (typeof __dirname !== "undefined") {
|
|
34
|
-
return __dirname;
|
|
35
|
-
}
|
|
36
|
-
// Try ESM import.meta.url
|
|
37
|
-
try {
|
|
38
|
-
if (typeof globalThis !== "undefined" &&
|
|
39
|
-
globalThis.import
|
|
40
|
-
?.meta?.url) {
|
|
41
|
-
return (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(globalThis
|
|
42
|
-
.import.meta.url));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Fallback to current working directory
|
|
47
|
-
}
|
|
48
|
-
return process.cwd();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Find the package.json path for @unispechq/unispec-schema
|
|
52
|
-
* Works in both ESM and CJS contexts with improved reliability
|
|
53
|
-
* @returns Path to package.json file
|
|
54
|
-
*/
|
|
55
|
-
function findSchemaPackagePath() {
|
|
56
|
-
// Return cached path if available
|
|
57
|
-
if (cachedSchemaPackagePath) {
|
|
58
|
-
return cachedSchemaPackagePath;
|
|
59
|
-
}
|
|
60
|
-
const currentDir = getCurrentDirectory();
|
|
61
|
-
// Define all possible paths to check
|
|
62
|
-
const candidatePaths = [
|
|
63
|
-
// Try direct package.json resolution first (most reliable for CJS)
|
|
64
|
-
() => {
|
|
65
|
-
if (typeof require !== "undefined") {
|
|
66
|
-
try {
|
|
67
|
-
return require.resolve("@unispechq/unispec-schema/package.json");
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
},
|
|
75
|
-
// Try require.resolve for main entry point
|
|
76
|
-
() => {
|
|
77
|
-
if (typeof require !== "undefined") {
|
|
78
|
-
try {
|
|
79
|
-
const packageMainPath = require.resolve("@unispechq/unispec-schema");
|
|
80
|
-
return (0, node_path_1.join)((0, node_path_1.dirname)(packageMainPath), "package.json");
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
},
|
|
88
|
-
// Fallback paths
|
|
89
|
-
() => (0, node_path_1.join)(process.cwd(), "node_modules", "@unispechq", "unispec-schema", "package.json"),
|
|
90
|
-
() => (0, node_path_1.join)(currentDir, "..", "node_modules", "@unispechq", "unispec-schema", "package.json"),
|
|
91
|
-
() => (0, node_path_1.join)(currentDir, "..", "..", "node_modules", "@unispechq", "unispec-schema", "package.json"),
|
|
92
|
-
() => (0, node_path_1.join)(currentDir, "..", "..", "..", "node_modules", "@unispechq", "unispec-schema", "package.json"),
|
|
93
|
-
];
|
|
94
|
-
// Try each candidate path
|
|
95
|
-
for (const getPath of candidatePaths) {
|
|
96
|
-
try {
|
|
97
|
-
const path = getPath();
|
|
98
|
-
if (!path)
|
|
99
|
-
continue;
|
|
100
|
-
const content = (0, node_fs_1.readFileSync)(path, "utf-8");
|
|
101
|
-
const packageInfo = validatePackageJson(content);
|
|
102
|
-
if (packageInfo) {
|
|
103
|
-
cachedSchemaPackagePath = path;
|
|
104
|
-
return path;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
// Continue to next path
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
throw new Error(`Could not find @unispechq/unispec-schema package.json. Searched in multiple node_modules locations.`);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get the latest supported UniSpec version from @unispechq/unispec-schema package
|
|
115
|
-
* The version is derived from the package.json version (major.minor.0 format)
|
|
116
|
-
* @returns The latest UniSpec format version (SemVer)
|
|
117
|
-
*/
|
|
118
|
-
function getLatestUniSpecVersion() {
|
|
119
|
-
if (cachedUniSpecVersion) {
|
|
120
|
-
return cachedUniSpecVersion;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
// Find and read package.json from @unispechq/unispec-schema
|
|
124
|
-
const schemaPackagePath = findSchemaPackagePath();
|
|
125
|
-
const packageJson = (0, node_fs_1.readFileSync)(schemaPackagePath, "utf-8");
|
|
126
|
-
const packageInfo = JSON.parse(packageJson);
|
|
127
|
-
// Extract version and convert to major.minor.0 format
|
|
128
|
-
const version = packageInfo.version;
|
|
129
|
-
const [major, minor] = version.split(".");
|
|
130
|
-
// Create UniSpec version in major.minor.0 format
|
|
131
|
-
const unispecVersion = `${major}.${minor}.0`;
|
|
132
|
-
cachedUniSpecVersion = unispecVersion;
|
|
133
|
-
return unispecVersion;
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
// Fallback to default version if package.json is not available
|
|
137
|
-
cachedUniSpecVersion = "1.0.0";
|
|
138
|
-
return cachedUniSpecVersion;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Clear the version cache (useful for testing or dynamic updates)
|
|
143
|
-
*/
|
|
144
|
-
function clearVersionCache() {
|
|
145
|
-
cachedUniSpecVersion = null;
|
|
146
|
-
cachedSchemaPackagePath = null;
|
|
147
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UniSpecChange } from "./types.js";
|
|
2
|
-
export declare function annotateRestChange(change: UniSpecChange): UniSpecChange;
|
|
3
|
-
export declare function annotateWebSocketChange(change: UniSpecChange): UniSpecChange;
|
|
4
|
-
export declare function annotateGraphQLChange(change: UniSpecChange): UniSpecChange;
|