@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,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalize WebSocket channels and messages by sorting them lexicographically by name.
|
|
3
|
-
*
|
|
4
|
-
* @param doc - The UniSpec document to normalize
|
|
5
|
-
* @returns The document with normalized WebSocket channels and messages
|
|
6
|
-
*/
|
|
7
|
-
export function normalizeWebSocket(doc) {
|
|
8
|
-
if (!doc || !doc.service?.protocols) {
|
|
9
|
-
return doc;
|
|
10
|
-
}
|
|
11
|
-
const protocols = doc.service.protocols;
|
|
12
|
-
const websocket = protocols.websocket;
|
|
13
|
-
if (!websocket || !Array.isArray(websocket.channels)) {
|
|
14
|
-
return doc;
|
|
15
|
-
}
|
|
16
|
-
// Check if channels are already sorted
|
|
17
|
-
const areChannelsSorted = websocket.channels.every((channel, index, arr) => {
|
|
18
|
-
if (index === 0)
|
|
19
|
-
return true;
|
|
20
|
-
const prevName = arr[index - 1]?.name ?? "";
|
|
21
|
-
const currentName = channel?.name ?? "";
|
|
22
|
-
return prevName.localeCompare(currentName) <= 0;
|
|
23
|
-
});
|
|
24
|
-
// Sort messages within each channel only if needed
|
|
25
|
-
const normalizedChannels = websocket.channels.map((channel) => {
|
|
26
|
-
if (!channel || !Array.isArray(channel.messages)) {
|
|
27
|
-
return channel;
|
|
28
|
-
}
|
|
29
|
-
// Check if messages are already sorted
|
|
30
|
-
const areMessagesSorted = channel.messages.every((message, index, arr) => {
|
|
31
|
-
if (index === 0)
|
|
32
|
-
return true;
|
|
33
|
-
const prevName = arr[index - 1]?.name ?? "";
|
|
34
|
-
const currentName = message?.name ?? "";
|
|
35
|
-
return prevName.localeCompare(currentName) <= 0;
|
|
36
|
-
});
|
|
37
|
-
if (areMessagesSorted) {
|
|
38
|
-
return channel; // No changes needed
|
|
39
|
-
}
|
|
40
|
-
const sortedMessages = [...channel.messages].sort((a, b) => {
|
|
41
|
-
const aName = a?.name ?? "";
|
|
42
|
-
const bName = b?.name ?? "";
|
|
43
|
-
return aName.localeCompare(bName);
|
|
44
|
-
});
|
|
45
|
-
// Return new channel with sorted messages (immutable)
|
|
46
|
-
return {
|
|
47
|
-
...channel,
|
|
48
|
-
messages: sortedMessages,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
if (areChannelsSorted) {
|
|
52
|
-
// Check if any channels were modified
|
|
53
|
-
const channelsModified = normalizedChannels.some((channel, index) => channel !== websocket.channels?.[index]);
|
|
54
|
-
if (!channelsModified) {
|
|
55
|
-
return doc; // No changes needed
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Sort channels
|
|
59
|
-
const sortedChannels = normalizedChannels.sort((a, b) => {
|
|
60
|
-
const aName = a?.name ?? "";
|
|
61
|
-
const bName = b?.name ?? "";
|
|
62
|
-
return aName.localeCompare(bName);
|
|
63
|
-
});
|
|
64
|
-
// Return new document with sorted channels (immutable)
|
|
65
|
-
return {
|
|
66
|
-
...doc,
|
|
67
|
-
service: {
|
|
68
|
-
...doc.service,
|
|
69
|
-
protocols: {
|
|
70
|
-
...protocols,
|
|
71
|
-
websocket: {
|
|
72
|
-
...websocket,
|
|
73
|
-
channels: sortedChannels,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
package/dist/optimizer/core.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import type { OptimizationOptions, OptimizationReport, OptimizationResult } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Optimize a UniSpec document with various optimization strategies.
|
|
5
|
-
*
|
|
6
|
-
* @param doc - The UniSpec document to optimize
|
|
7
|
-
* @param options - Optimization options
|
|
8
|
-
* @returns Optimization result with statistics and changes
|
|
9
|
-
*/
|
|
10
|
-
export declare function optimizeDocument(doc: UniSpecDocument, options?: OptimizationOptions): OptimizationResult;
|
|
11
|
-
/**
|
|
12
|
-
* Generate optimization report for a UniSpec document.
|
|
13
|
-
*
|
|
14
|
-
* @param doc - The UniSpec document to analyze
|
|
15
|
-
* @returns Optimization recommendations
|
|
16
|
-
*/
|
|
17
|
-
export declare function generateOptimizationReport(doc: UniSpecDocument): OptimizationReport;
|
package/dist/optimizer/core.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions.js";
|
|
2
|
-
/**
|
|
3
|
-
* Optimize a UniSpec document with various optimization strategies.
|
|
4
|
-
*
|
|
5
|
-
* @param doc - The UniSpec document to optimize
|
|
6
|
-
* @param options - Optimization options
|
|
7
|
-
* @returns Optimization result with statistics and changes
|
|
8
|
-
*/
|
|
9
|
-
export function optimizeDocument(doc, options = {}) {
|
|
10
|
-
const changes = [];
|
|
11
|
-
const originalSchemaCount = Object.keys(doc.service?.schemas || {}).length;
|
|
12
|
-
// Create a deep copy to avoid mutating the original
|
|
13
|
-
const optimizedDoc = JSON.parse(JSON.stringify(doc));
|
|
14
|
-
// Ensure service and schemas exist
|
|
15
|
-
if (!optimizedDoc.service) {
|
|
16
|
-
optimizedDoc.service = { name: "" };
|
|
17
|
-
}
|
|
18
|
-
if (!optimizedDoc.service.schemas) {
|
|
19
|
-
optimizedDoc.service.schemas = {};
|
|
20
|
-
}
|
|
21
|
-
let deduplicatedCount = 0;
|
|
22
|
-
// Apply optimizations in order
|
|
23
|
-
if (options.removeUnusedSchemas === true) {
|
|
24
|
-
const removed = removeOrphanedSchemas(optimizedDoc);
|
|
25
|
-
if (removed.length > 0) {
|
|
26
|
-
changes.push(`Removed ${removed.length} orphaned schemas: ${removed.join(", ")}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (options.dedupeSchemas !== false) {
|
|
30
|
-
const dedupResult = deduplicateSchemas(optimizedDoc);
|
|
31
|
-
if (dedupResult.removedSchemas.length > 0) {
|
|
32
|
-
changes.push(`Deduplicated ${dedupResult.removedSchemas.length} schemas: ${dedupResult.removedSchemas.join(", ")}`);
|
|
33
|
-
changes.push(`Updated ${dedupResult.updatedReferences} schema references`);
|
|
34
|
-
deduplicatedCount = dedupResult.removedSchemas.length;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (options.sortSchemas !== false) {
|
|
38
|
-
const sortedCount = sortSchemas(optimizedDoc);
|
|
39
|
-
if (sortedCount > 0) {
|
|
40
|
-
changes.push(`Sorted ${sortedCount} schemas alphabetically`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (options.compressReferences !== false) {
|
|
44
|
-
const compressedCount = compressSchemaReferences(optimizedDoc);
|
|
45
|
-
if (compressedCount > 0) {
|
|
46
|
-
changes.push(`Compressed ${compressedCount} schema references`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const finalSchemaCount = Object.keys(optimizedDoc.service.schemas).length;
|
|
50
|
-
return {
|
|
51
|
-
document: optimizedDoc,
|
|
52
|
-
statistics: {
|
|
53
|
-
originalSchemas: originalSchemaCount,
|
|
54
|
-
optimizedSchemas: finalSchemaCount,
|
|
55
|
-
removedSchemas: originalSchemaCount - finalSchemaCount,
|
|
56
|
-
deduplicatedSchemas: deduplicatedCount,
|
|
57
|
-
},
|
|
58
|
-
changes,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Generate optimization report for a UniSpec document.
|
|
63
|
-
*
|
|
64
|
-
* @param doc - The UniSpec document to analyze
|
|
65
|
-
* @returns Optimization recommendations
|
|
66
|
-
*/
|
|
67
|
-
export function generateOptimizationReport(doc) {
|
|
68
|
-
const recommendations = [];
|
|
69
|
-
// Create copies for analysis to avoid mutating original
|
|
70
|
-
const docForDedup = JSON.parse(JSON.stringify(doc));
|
|
71
|
-
const _docForOrphaned = JSON.parse(JSON.stringify(doc));
|
|
72
|
-
// First find duplicates
|
|
73
|
-
const dedupResult = deduplicateSchemas(docForDedup);
|
|
74
|
-
// Find orphaned schemas that are NOT duplicates
|
|
75
|
-
const allSchemas = Object.keys(doc.service?.schemas || {});
|
|
76
|
-
const duplicateNames = new Set(dedupResult.removedSchemas);
|
|
77
|
-
// Find referenced schemas
|
|
78
|
-
const referencedSchemas = new Set();
|
|
79
|
-
function findReferences(obj) {
|
|
80
|
-
if (!obj || typeof obj !== "object")
|
|
81
|
-
return;
|
|
82
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
83
|
-
if (key === "schemaRef" && typeof value === "string") {
|
|
84
|
-
const schemaName = value.split("/").pop(); // Simple extraction for analysis
|
|
85
|
-
if (schemaName)
|
|
86
|
-
referencedSchemas.add(schemaName);
|
|
87
|
-
}
|
|
88
|
-
else if (typeof value === "object" && value !== null) {
|
|
89
|
-
findReferences(value);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
findReferences(doc);
|
|
94
|
-
// Find orphaned schemas that are not duplicates
|
|
95
|
-
const orphaned = allSchemas.filter((name) => !referencedSchemas.has(name) && !duplicateNames.has(name));
|
|
96
|
-
if (orphaned.length > 0) {
|
|
97
|
-
recommendations.push(`Remove ${orphaned.length} orphaned schemas to reduce document size`);
|
|
98
|
-
}
|
|
99
|
-
if (dedupResult.removedSchemas.length > 0) {
|
|
100
|
-
recommendations.push(`Deduplicate ${dedupResult.removedSchemas.length} identical schemas`);
|
|
101
|
-
}
|
|
102
|
-
const totalSchemas = Object.keys(doc.service?.schemas || {}).length;
|
|
103
|
-
const potentialReduction = orphaned.length + dedupResult.removedSchemas.length;
|
|
104
|
-
return {
|
|
105
|
-
recommendations,
|
|
106
|
-
potentialSavings: {
|
|
107
|
-
schemaReduction: potentialReduction,
|
|
108
|
-
referenceCompression: totalSchemas * 0.1, // Estimate 10% compression
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { generateOptimizationReport, optimizeDocument, } from "./core.js";
|
|
2
|
-
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions.js";
|
|
3
|
-
export type { DeduplicationResult, OptimizationOptions, OptimizationReport, OptimizationResult, } from "./types.js";
|
|
4
|
-
export { compressReference } from "./utils.js";
|
package/dist/optimizer/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Export types
|
|
2
|
-
// Export core functions
|
|
3
|
-
export { generateOptimizationReport, optimizeDocument, } from "./core.js";
|
|
4
|
-
// Export optimization functions
|
|
5
|
-
export { compressSchemaReferences, deduplicateSchemas, removeOrphanedSchemas, sortSchemas, } from "./optimization-functions.js";
|
|
6
|
-
// Export utilities
|
|
7
|
-
export { compressReference } from "./utils.js";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
import type { DeduplicationResult } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Remove duplicate schemas from a UniSpec document.
|
|
5
|
-
* Duplicates are identified by identical JSON Schema content.
|
|
6
|
-
* Updates all schema references to point to the retained schema.
|
|
7
|
-
*
|
|
8
|
-
* @param doc - The UniSpec document to deduplicate
|
|
9
|
-
* @returns Object with deduplication statistics
|
|
10
|
-
*/
|
|
11
|
-
export declare function deduplicateSchemas(doc: UniSpecDocument): DeduplicationResult;
|
|
12
|
-
/**
|
|
13
|
-
* Remove orphaned schemas (not referenced anywhere).
|
|
14
|
-
*
|
|
15
|
-
* @param doc - The UniSpec document to optimize
|
|
16
|
-
* @returns Array of removed schema names
|
|
17
|
-
*/
|
|
18
|
-
export declare function removeOrphanedSchemas(doc: UniSpecDocument): string[];
|
|
19
|
-
/**
|
|
20
|
-
* Sort schemas alphabetically by name for consistent output.
|
|
21
|
-
*
|
|
22
|
-
* @param doc - The UniSpec document to optimize
|
|
23
|
-
* @returns Number of schemas sorted
|
|
24
|
-
*/
|
|
25
|
-
export declare function sortSchemas(doc: UniSpecDocument): number;
|
|
26
|
-
/**
|
|
27
|
-
* Compress schema references by using shortest possible format.
|
|
28
|
-
*
|
|
29
|
-
* @param doc - The UniSpec document to optimize
|
|
30
|
-
* @returns Number of references compressed
|
|
31
|
-
*/
|
|
32
|
-
export declare function compressSchemaReferences(doc: UniSpecDocument): number;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { normalizeSchemaRef, stableStringify } from "../schemas/index.js";
|
|
2
|
-
import { compressReference } from "./utils.js";
|
|
3
|
-
/**
|
|
4
|
-
* Remove duplicate schemas from a UniSpec document.
|
|
5
|
-
* Duplicates are identified by identical JSON Schema content.
|
|
6
|
-
* Updates all schema references to point to the retained schema.
|
|
7
|
-
*
|
|
8
|
-
* @param doc - The UniSpec document to deduplicate
|
|
9
|
-
* @returns Object with deduplication statistics
|
|
10
|
-
*/
|
|
11
|
-
export function deduplicateSchemas(doc) {
|
|
12
|
-
if (!doc.service?.schemas) {
|
|
13
|
-
return { removedSchemas: [], updatedReferences: 0 };
|
|
14
|
-
}
|
|
15
|
-
// First, find all referenced schemas
|
|
16
|
-
const referencedSchemas = new Set();
|
|
17
|
-
function findReferences(obj) {
|
|
18
|
-
if (!obj || typeof obj !== "object")
|
|
19
|
-
return;
|
|
20
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
21
|
-
if (key === "schemaRef" && typeof value === "string") {
|
|
22
|
-
const schemaName = normalizeSchemaRef(value);
|
|
23
|
-
if (schemaName)
|
|
24
|
-
referencedSchemas.add(schemaName);
|
|
25
|
-
}
|
|
26
|
-
else if (typeof value === "object" && value !== null) {
|
|
27
|
-
findReferences(value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
findReferences(doc);
|
|
32
|
-
const names = Object.keys(doc.service.schemas);
|
|
33
|
-
const hashToName = new Map();
|
|
34
|
-
const renameMap = {};
|
|
35
|
-
const removedSchemas = [];
|
|
36
|
-
for (const name of names) {
|
|
37
|
-
const schema = doc.service.schemas[name];
|
|
38
|
-
// Only hash the jsonSchema content, not the name field
|
|
39
|
-
const hash = stableStringify(schema?.jsonSchema ?? null);
|
|
40
|
-
const existing = hashToName.get(hash);
|
|
41
|
-
if (!existing) {
|
|
42
|
-
hashToName.set(hash, name);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
// Found duplicate - prefer referenced schema over unreferenced one
|
|
46
|
-
const existingIsReferenced = referencedSchemas.has(existing);
|
|
47
|
-
const currentIsReferenced = referencedSchemas.has(name);
|
|
48
|
-
if (existingIsReferenced && !currentIsReferenced) {
|
|
49
|
-
// Keep existing, remove current
|
|
50
|
-
renameMap[name] = existing;
|
|
51
|
-
removedSchemas.push(name);
|
|
52
|
-
}
|
|
53
|
-
else if (!existingIsReferenced && currentIsReferenced) {
|
|
54
|
-
// Keep current, remove existing
|
|
55
|
-
renameMap[existing] = name;
|
|
56
|
-
removedSchemas.push(existing);
|
|
57
|
-
hashToName.set(hash, name); // Update to current as preferred
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Both referenced or both unreferenced - keep first encountered
|
|
61
|
-
renameMap[name] = existing;
|
|
62
|
-
removedSchemas.push(name);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (removedSchemas.length === 0) {
|
|
66
|
-
return { removedSchemas: [], updatedReferences: 0 };
|
|
67
|
-
}
|
|
68
|
-
// Update all schema references
|
|
69
|
-
let updatedReferences = 0;
|
|
70
|
-
function updateReferences(obj, path = "") {
|
|
71
|
-
if (!obj || typeof obj !== "object")
|
|
72
|
-
return;
|
|
73
|
-
const objRecord = obj;
|
|
74
|
-
for (const [key, value] of Object.entries(objRecord)) {
|
|
75
|
-
const currentPath = path ? `${path}.${key}` : key;
|
|
76
|
-
if (key === "schemaRef" && typeof value === "string") {
|
|
77
|
-
const schemaName = normalizeSchemaRef(value);
|
|
78
|
-
if (renameMap[schemaName]) {
|
|
79
|
-
objRecord[key] = renameMap[schemaName];
|
|
80
|
-
updatedReferences++;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if (typeof value === "object" && value !== null) {
|
|
84
|
-
updateReferences(value, currentPath);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
updateReferences(doc);
|
|
89
|
-
// Remove duplicate schemas
|
|
90
|
-
for (const dup of removedSchemas) {
|
|
91
|
-
delete doc.service.schemas[dup];
|
|
92
|
-
}
|
|
93
|
-
return { removedSchemas, updatedReferences };
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Remove orphaned schemas (not referenced anywhere).
|
|
97
|
-
*
|
|
98
|
-
* @param doc - The UniSpec document to optimize
|
|
99
|
-
* @returns Array of removed schema names
|
|
100
|
-
*/
|
|
101
|
-
export function removeOrphanedSchemas(doc) {
|
|
102
|
-
if (!doc.service?.schemas)
|
|
103
|
-
return [];
|
|
104
|
-
const referencedSchemas = new Set();
|
|
105
|
-
// Find all referenced schemas
|
|
106
|
-
function findReferences(obj) {
|
|
107
|
-
if (!obj || typeof obj !== "object")
|
|
108
|
-
return;
|
|
109
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
110
|
-
if (key === "schemaRef" && typeof value === "string") {
|
|
111
|
-
const schemaName = normalizeSchemaRef(value);
|
|
112
|
-
if (schemaName)
|
|
113
|
-
referencedSchemas.add(schemaName);
|
|
114
|
-
}
|
|
115
|
-
else if (typeof value === "object" && value !== null) {
|
|
116
|
-
findReferences(value);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
findReferences(doc);
|
|
121
|
-
// Remove orphaned schemas
|
|
122
|
-
const allSchemas = Object.keys(doc.service.schemas);
|
|
123
|
-
const orphaned = allSchemas.filter((schema) => !referencedSchemas.has(schema));
|
|
124
|
-
for (const orphan of orphaned) {
|
|
125
|
-
delete doc.service.schemas[orphan];
|
|
126
|
-
}
|
|
127
|
-
return orphaned;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Sort schemas alphabetically by name for consistent output.
|
|
131
|
-
*
|
|
132
|
-
* @param doc - The UniSpec document to optimize
|
|
133
|
-
* @returns Number of schemas sorted
|
|
134
|
-
*/
|
|
135
|
-
export function sortSchemas(doc) {
|
|
136
|
-
if (!doc.service?.schemas)
|
|
137
|
-
return 0;
|
|
138
|
-
const schemaNames = Object.keys(doc.service.schemas);
|
|
139
|
-
if (schemaNames.length === 0)
|
|
140
|
-
return 0;
|
|
141
|
-
const sortedSchemas = {};
|
|
142
|
-
schemaNames.sort().forEach((name) => {
|
|
143
|
-
const schema = doc.service?.schemas?.[name];
|
|
144
|
-
if (schema) {
|
|
145
|
-
sortedSchemas[name] = schema;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
doc.service.schemas = sortedSchemas;
|
|
149
|
-
return schemaNames.length;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Compress schema references by using shortest possible format.
|
|
153
|
-
*
|
|
154
|
-
* @param doc - The UniSpec document to optimize
|
|
155
|
-
* @returns Number of references compressed
|
|
156
|
-
*/
|
|
157
|
-
export function compressSchemaReferences(doc) {
|
|
158
|
-
let compressedCount = 0;
|
|
159
|
-
function compressReferences(obj) {
|
|
160
|
-
if (!obj || typeof obj !== "object")
|
|
161
|
-
return;
|
|
162
|
-
const objRecord = obj;
|
|
163
|
-
for (const [key, value] of Object.entries(objRecord)) {
|
|
164
|
-
if (key === "schemaRef" && typeof value === "string") {
|
|
165
|
-
const original = value;
|
|
166
|
-
const compressed = compressReference(original);
|
|
167
|
-
if (compressed !== original) {
|
|
168
|
-
objRecord[key] = compressed;
|
|
169
|
-
compressedCount++;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else if (typeof value === "object" && value !== null) {
|
|
173
|
-
compressReferences(value);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
compressReferences(doc);
|
|
178
|
-
return compressedCount;
|
|
179
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
export interface OptimizationOptions {
|
|
3
|
-
dedupeSchemas?: boolean;
|
|
4
|
-
sortSchemas?: boolean;
|
|
5
|
-
removeUnusedSchemas?: boolean;
|
|
6
|
-
compressReferences?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface OptimizationResult {
|
|
9
|
-
document: UniSpecDocument;
|
|
10
|
-
statistics: {
|
|
11
|
-
originalSchemas: number;
|
|
12
|
-
optimizedSchemas: number;
|
|
13
|
-
removedSchemas: number;
|
|
14
|
-
deduplicatedSchemas: number;
|
|
15
|
-
};
|
|
16
|
-
changes: string[];
|
|
17
|
-
}
|
|
18
|
-
export interface DeduplicationResult {
|
|
19
|
-
removedSchemas: string[];
|
|
20
|
-
updatedReferences: number;
|
|
21
|
-
}
|
|
22
|
-
export interface OptimizationReport {
|
|
23
|
-
recommendations: string[];
|
|
24
|
-
potentialSavings: {
|
|
25
|
-
schemaReduction: number;
|
|
26
|
-
referenceCompression: number;
|
|
27
|
-
};
|
|
28
|
-
}
|
package/dist/optimizer/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/optimizer/utils.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compress a single schema reference to its shortest form.
|
|
3
|
-
*
|
|
4
|
-
* @param ref - The schema reference to compress
|
|
5
|
-
* @returns Compressed reference
|
|
6
|
-
*/
|
|
7
|
-
export function compressReference(ref) {
|
|
8
|
-
const trimmed = ref.trim();
|
|
9
|
-
if (trimmed.length === 0)
|
|
10
|
-
return "";
|
|
11
|
-
// If it's already a simple name, keep it
|
|
12
|
-
if (!trimmed.startsWith("#") && !trimmed.includes("/")) {
|
|
13
|
-
return trimmed;
|
|
14
|
-
}
|
|
15
|
-
// Convert JSON Pointer to simple name
|
|
16
|
-
if (trimmed.startsWith("#/service/schemas/")) {
|
|
17
|
-
const parts = trimmed.split("/");
|
|
18
|
-
return parts[parts.length - 1];
|
|
19
|
-
}
|
|
20
|
-
// Convert hash format to simple name
|
|
21
|
-
if (trimmed.startsWith("#")) {
|
|
22
|
-
const withoutHash = trimmed.slice(1);
|
|
23
|
-
const parts = withoutHash.split("/").filter(Boolean);
|
|
24
|
-
return parts.length > 0 ? parts[parts.length - 1] : withoutHash;
|
|
25
|
-
}
|
|
26
|
-
// Convert path format to simple name
|
|
27
|
-
const parts = trimmed.split("/").filter(Boolean);
|
|
28
|
-
return parts.length > 0 ? parts[parts.length - 1] : trimmed;
|
|
29
|
-
}
|
package/dist/schemas/dedupe.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument } from "../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Remove duplicate schemas from a UniSpec document.
|
|
4
|
-
* Duplicates are identified by identical JSON Schema content.
|
|
5
|
-
* Updates all schema references to point to the retained schema.
|
|
6
|
-
*
|
|
7
|
-
* @param doc - The UniSpec document to deduplicate
|
|
8
|
-
*/
|
|
9
|
-
export declare function dedupeSchemas(doc: UniSpecDocument): void;
|
package/dist/schemas/dedupe.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { normalizeSchemaRef, stableStringify } from "./utils.js";
|
|
2
|
-
function updateSchemaRefs(doc, mapping) {
|
|
3
|
-
const rest = doc.service?.protocols?.rest;
|
|
4
|
-
const websocket = doc.service?.protocols?.websocket;
|
|
5
|
-
if (rest?.routes) {
|
|
6
|
-
for (const route of rest.routes) {
|
|
7
|
-
for (const params of [
|
|
8
|
-
route.pathParams,
|
|
9
|
-
route.queryParams,
|
|
10
|
-
route.headers,
|
|
11
|
-
]) {
|
|
12
|
-
if (!params)
|
|
13
|
-
continue;
|
|
14
|
-
for (const p of params) {
|
|
15
|
-
if (!p.schemaRef)
|
|
16
|
-
continue;
|
|
17
|
-
const key = normalizeSchemaRef(p.schemaRef);
|
|
18
|
-
const next = mapping[key];
|
|
19
|
-
if (next && next !== key)
|
|
20
|
-
p.schemaRef = next;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const requestContent = route.requestBody?.content;
|
|
24
|
-
if (requestContent) {
|
|
25
|
-
for (const media of Object.values(requestContent)) {
|
|
26
|
-
if (!media.schemaRef)
|
|
27
|
-
continue;
|
|
28
|
-
const key = normalizeSchemaRef(media.schemaRef);
|
|
29
|
-
const next = mapping[key];
|
|
30
|
-
if (next && next !== key)
|
|
31
|
-
media.schemaRef = next;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const responses = route.responses;
|
|
35
|
-
if (responses) {
|
|
36
|
-
for (const resp of Object.values(responses)) {
|
|
37
|
-
const respContent = resp.content;
|
|
38
|
-
if (!respContent)
|
|
39
|
-
continue;
|
|
40
|
-
for (const media of Object.values(respContent)) {
|
|
41
|
-
if (!media.schemaRef)
|
|
42
|
-
continue;
|
|
43
|
-
const key = normalizeSchemaRef(media.schemaRef);
|
|
44
|
-
const next = mapping[key];
|
|
45
|
-
if (next && next !== key)
|
|
46
|
-
media.schemaRef = next;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (websocket?.channels) {
|
|
53
|
-
for (const channel of websocket.channels) {
|
|
54
|
-
if (!channel.messages)
|
|
55
|
-
continue;
|
|
56
|
-
for (const message of channel.messages) {
|
|
57
|
-
if (!message.schemaRef)
|
|
58
|
-
continue;
|
|
59
|
-
const key = normalizeSchemaRef(message.schemaRef);
|
|
60
|
-
const next = mapping[key];
|
|
61
|
-
if (next && next !== key)
|
|
62
|
-
message.schemaRef = next;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Remove duplicate schemas from a UniSpec document.
|
|
69
|
-
* Duplicates are identified by identical JSON Schema content.
|
|
70
|
-
* Updates all schema references to point to the retained schema.
|
|
71
|
-
*
|
|
72
|
-
* @param doc - The UniSpec document to deduplicate
|
|
73
|
-
*/
|
|
74
|
-
export function dedupeSchemas(doc) {
|
|
75
|
-
if (!doc.service?.schemas)
|
|
76
|
-
return;
|
|
77
|
-
const names = Object.keys(doc.service.schemas);
|
|
78
|
-
const hashToName = new Map();
|
|
79
|
-
const renameMap = {};
|
|
80
|
-
for (const name of names) {
|
|
81
|
-
const schema = doc.service.schemas[name];
|
|
82
|
-
const hash = stableStringify(schema?.jsonSchema ?? null);
|
|
83
|
-
const existing = hashToName.get(hash);
|
|
84
|
-
if (!existing) {
|
|
85
|
-
hashToName.set(hash, name);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
renameMap[name] = existing;
|
|
89
|
-
}
|
|
90
|
-
const duplicates = Object.keys(renameMap);
|
|
91
|
-
if (duplicates.length === 0)
|
|
92
|
-
return;
|
|
93
|
-
updateSchemaRefs(doc, renameMap);
|
|
94
|
-
for (const dup of duplicates) {
|
|
95
|
-
delete doc.service.schemas[dup];
|
|
96
|
-
}
|
|
97
|
-
}
|
package/dist/schemas/index.d.ts
DELETED
package/dist/schemas/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Export utility functions
|
|
2
|
-
// Export deduplication functions
|
|
3
|
-
export { dedupeSchemas } from "./dedupe.js";
|
|
4
|
-
// Export resolver functions
|
|
5
|
-
export { registerSchema, resolveSchemaRef } from "./resolver.js";
|
|
6
|
-
export { normalizeSchemaRef, stableStringify } from "./utils.js";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { UniSpecDocument, UniSpecSchemaDefinition } from "../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a schema reference to its definition in a UniSpec document.
|
|
4
|
-
*
|
|
5
|
-
* @param doc - The UniSpec document containing schemas
|
|
6
|
-
* @param ref - The schema reference to resolve
|
|
7
|
-
* @returns The schema definition or undefined if not found
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveSchemaRef(doc: UniSpecDocument, ref: string): UniSpecSchemaDefinition | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Register a new schema definition in a UniSpec document.
|
|
12
|
-
* Creates the schemas container if it doesn't exist.
|
|
13
|
-
*
|
|
14
|
-
* @param doc - The UniSpec document to modify
|
|
15
|
-
* @param name - The schema name
|
|
16
|
-
* @param jsonSchema - The JSON Schema definition
|
|
17
|
-
* @returns The created schema definition
|
|
18
|
-
*/
|
|
19
|
-
export declare function registerSchema(doc: UniSpecDocument, name: string, jsonSchema: Record<string, unknown>): UniSpecSchemaDefinition;
|