@contractual/differs.json-schema 0.1.0-dev.0 → 0.1.0-dev.1
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/compare.d.ts +1 -1
- package/dist/compare.d.ts.map +1 -1
- package/dist/compare.js +1 -3
- package/dist/compare.js.map +1 -1
- package/dist/differ.d.ts +3 -34
- package/dist/differ.d.ts.map +1 -1
- package/dist/differ.js +7 -249
- package/dist/differ.js.map +1 -1
- package/dist/index.d.ts +1 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -43
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -219
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -207
- package/dist/types.js.map +1 -1
- package/package.json +6 -2
- package/dist/classifiers.d.ts +0 -87
- package/dist/classifiers.d.ts.map +0 -1
- package/dist/classifiers.js +0 -357
- package/dist/classifiers.js.map +0 -1
- package/dist/ref-resolver.d.ts +0 -73
- package/dist/ref-resolver.d.ts.map +0 -1
- package/dist/ref-resolver.js +0 -345
- package/dist/ref-resolver.js.map +0 -1
- package/dist/walker.d.ts +0 -17
- package/dist/walker.d.ts.map +0 -1
- package/dist/walker.js +0 -1195
- package/dist/walker.js.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Strands API types for JSON Schema comparison
|
|
3
|
+
*
|
|
4
|
+
* These types are specific to the Strands-compatible comparison API.
|
|
5
|
+
* Core schema diffing types are in @contractual/differs.core.
|
|
3
6
|
*/
|
|
4
7
|
/**
|
|
5
8
|
* Strands compatibility classification for a trace
|
|
@@ -55,222 +58,4 @@ export interface CompareOptions {
|
|
|
55
58
|
* Supported JSON Schema drafts
|
|
56
59
|
*/
|
|
57
60
|
export type JsonSchemaDraft = 'draft-07' | 'draft-2019-09' | 'draft-2020-12';
|
|
58
|
-
/**
|
|
59
|
-
* JSON Schema type values
|
|
60
|
-
*/
|
|
61
|
-
export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
62
|
-
/**
|
|
63
|
-
* Normalized type representation (always an array for comparison)
|
|
64
|
-
*/
|
|
65
|
-
export type NormalizedType = JSONSchemaType[];
|
|
66
|
-
/**
|
|
67
|
-
* JSON Schema constraint keys that can be tightened or loosened
|
|
68
|
-
*/
|
|
69
|
-
export type ConstraintKey = 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minLength' | 'maxLength' | 'minItems' | 'maxItems' | 'minProperties' | 'maxProperties' | 'minContains' | 'maxContains' | 'pattern' | 'multipleOf' | 'uniqueItems';
|
|
70
|
-
/**
|
|
71
|
-
* Constraint comparison direction
|
|
72
|
-
*/
|
|
73
|
-
export type ConstraintDirection = 'min' | 'max' | 'exact';
|
|
74
|
-
/**
|
|
75
|
-
* Constraint metadata for determining tightened vs loosened
|
|
76
|
-
*/
|
|
77
|
-
export interface ConstraintMeta {
|
|
78
|
-
readonly key: ConstraintKey;
|
|
79
|
-
readonly direction: ConstraintDirection;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Map of constraint keys to their comparison direction
|
|
83
|
-
*/
|
|
84
|
-
export declare const CONSTRAINT_DIRECTION: Record<ConstraintKey, ConstraintDirection>;
|
|
85
|
-
/**
|
|
86
|
-
* All constraint keys for iteration
|
|
87
|
-
*/
|
|
88
|
-
export declare const CONSTRAINT_KEYS: ConstraintKey[];
|
|
89
|
-
/**
|
|
90
|
-
* Composition keywords in JSON Schema
|
|
91
|
-
*/
|
|
92
|
-
export type CompositionKeyword = 'anyOf' | 'oneOf' | 'allOf' | 'if' | 'then' | 'else' | 'not';
|
|
93
|
-
/**
|
|
94
|
-
* All composition keywords for iteration
|
|
95
|
-
*/
|
|
96
|
-
export declare const COMPOSITION_KEYWORDS: CompositionKeyword[];
|
|
97
|
-
/**
|
|
98
|
-
* Metadata keys that are compared (patch-level changes)
|
|
99
|
-
*/
|
|
100
|
-
export type MetadataKey = 'description' | 'title' | 'default' | 'examples';
|
|
101
|
-
/**
|
|
102
|
-
* All metadata keys for iteration
|
|
103
|
-
*/
|
|
104
|
-
export declare const METADATA_KEYS: MetadataKey[];
|
|
105
|
-
/**
|
|
106
|
-
* Annotation keys (patch-level changes per Strands API)
|
|
107
|
-
*/
|
|
108
|
-
export type AnnotationKey = 'deprecated' | 'readOnly' | 'writeOnly';
|
|
109
|
-
/**
|
|
110
|
-
* All annotation keys for iteration
|
|
111
|
-
*/
|
|
112
|
-
export declare const ANNOTATION_KEYS: AnnotationKey[];
|
|
113
|
-
/**
|
|
114
|
-
* Content keywords (patch-level changes per Strands API)
|
|
115
|
-
*/
|
|
116
|
-
export type ContentKey = 'contentEncoding' | 'contentMediaType' | 'contentSchema';
|
|
117
|
-
/**
|
|
118
|
-
* All content keys for iteration
|
|
119
|
-
*/
|
|
120
|
-
export declare const CONTENT_KEYS: ContentKey[];
|
|
121
|
-
/**
|
|
122
|
-
* Resolved JSON Schema object (refs already resolved)
|
|
123
|
-
*/
|
|
124
|
-
export interface ResolvedSchema {
|
|
125
|
-
$schema?: string;
|
|
126
|
-
$id?: string;
|
|
127
|
-
$ref?: string;
|
|
128
|
-
$defs?: Record<string, ResolvedSchema>;
|
|
129
|
-
type?: JSONSchemaType | JSONSchemaType[];
|
|
130
|
-
title?: string;
|
|
131
|
-
description?: string;
|
|
132
|
-
default?: unknown;
|
|
133
|
-
examples?: unknown[];
|
|
134
|
-
deprecated?: boolean;
|
|
135
|
-
readOnly?: boolean;
|
|
136
|
-
writeOnly?: boolean;
|
|
137
|
-
enum?: unknown[];
|
|
138
|
-
const?: unknown;
|
|
139
|
-
format?: string;
|
|
140
|
-
minimum?: number;
|
|
141
|
-
maximum?: number;
|
|
142
|
-
exclusiveMinimum?: number;
|
|
143
|
-
exclusiveMaximum?: number;
|
|
144
|
-
multipleOf?: number;
|
|
145
|
-
minLength?: number;
|
|
146
|
-
maxLength?: number;
|
|
147
|
-
pattern?: string;
|
|
148
|
-
contentEncoding?: string;
|
|
149
|
-
contentMediaType?: string;
|
|
150
|
-
contentSchema?: ResolvedSchema;
|
|
151
|
-
properties?: Record<string, ResolvedSchema>;
|
|
152
|
-
required?: string[];
|
|
153
|
-
additionalProperties?: boolean | ResolvedSchema;
|
|
154
|
-
minProperties?: number;
|
|
155
|
-
maxProperties?: number;
|
|
156
|
-
propertyNames?: ResolvedSchema;
|
|
157
|
-
patternProperties?: Record<string, ResolvedSchema>;
|
|
158
|
-
dependentRequired?: Record<string, string[]>;
|
|
159
|
-
dependentSchemas?: Record<string, ResolvedSchema>;
|
|
160
|
-
unevaluatedProperties?: boolean | ResolvedSchema;
|
|
161
|
-
items?: ResolvedSchema | ResolvedSchema[];
|
|
162
|
-
prefixItems?: ResolvedSchema[];
|
|
163
|
-
minItems?: number;
|
|
164
|
-
maxItems?: number;
|
|
165
|
-
uniqueItems?: boolean;
|
|
166
|
-
contains?: ResolvedSchema;
|
|
167
|
-
minContains?: number;
|
|
168
|
-
maxContains?: number;
|
|
169
|
-
unevaluatedItems?: boolean | ResolvedSchema;
|
|
170
|
-
anyOf?: ResolvedSchema[];
|
|
171
|
-
oneOf?: ResolvedSchema[];
|
|
172
|
-
allOf?: ResolvedSchema[];
|
|
173
|
-
if?: ResolvedSchema;
|
|
174
|
-
then?: ResolvedSchema;
|
|
175
|
-
else?: ResolvedSchema;
|
|
176
|
-
not?: ResolvedSchema;
|
|
177
|
-
[key: string]: unknown;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Walker context for tracking traversal state
|
|
181
|
-
*/
|
|
182
|
-
export interface WalkerContext {
|
|
183
|
-
/** Current JSON Pointer path */
|
|
184
|
-
readonly path: string;
|
|
185
|
-
/** Depth of recursion (for cycle detection) */
|
|
186
|
-
readonly depth: number;
|
|
187
|
-
/** Maximum allowed depth */
|
|
188
|
-
readonly maxDepth: number;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Default maximum recursion depth
|
|
192
|
-
*/
|
|
193
|
-
export declare const DEFAULT_MAX_DEPTH = 100;
|
|
194
|
-
/**
|
|
195
|
-
* Type guard to check if value is a schema object
|
|
196
|
-
*/
|
|
197
|
-
export declare function isSchemaObject(value: unknown): value is ResolvedSchema;
|
|
198
|
-
/**
|
|
199
|
-
* Type guard to check if value is an array of schemas
|
|
200
|
-
*/
|
|
201
|
-
export declare function isSchemaArray(value: unknown): value is ResolvedSchema[];
|
|
202
|
-
/**
|
|
203
|
-
* Normalize type to array for consistent comparison
|
|
204
|
-
*/
|
|
205
|
-
export declare function normalizeType(type: JSONSchemaType | JSONSchemaType[] | undefined): NormalizedType;
|
|
206
|
-
/**
|
|
207
|
-
* Check if two arrays have the same elements (order-independent)
|
|
208
|
-
*/
|
|
209
|
-
export declare function arraysEqual<T>(a: T[], b: T[]): boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Deep equality check for JSON values
|
|
212
|
-
*/
|
|
213
|
-
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
214
|
-
/**
|
|
215
|
-
* Escape JSON Pointer segment according to RFC 6901
|
|
216
|
-
*/
|
|
217
|
-
export declare function escapeJsonPointer(segment: string): string;
|
|
218
|
-
/**
|
|
219
|
-
* Join path segments into a JSON Pointer
|
|
220
|
-
*/
|
|
221
|
-
export declare function joinPath(basePath: string, ...segments: string[]): string;
|
|
222
|
-
/**
|
|
223
|
-
* Severity classification for detected changes
|
|
224
|
-
*/
|
|
225
|
-
export type ChangeSeverity = 'breaking' | 'non-breaking' | 'patch' | 'unknown';
|
|
226
|
-
/**
|
|
227
|
-
* Suggested semver bump based on detected changes
|
|
228
|
-
*/
|
|
229
|
-
export type SuggestedBump = 'major' | 'minor' | 'patch' | 'none';
|
|
230
|
-
/**
|
|
231
|
-
* A single change detected between two spec versions
|
|
232
|
-
*/
|
|
233
|
-
export interface Change {
|
|
234
|
-
path: string;
|
|
235
|
-
severity: ChangeSeverity;
|
|
236
|
-
category: string;
|
|
237
|
-
message: string;
|
|
238
|
-
oldValue?: unknown;
|
|
239
|
-
newValue?: unknown;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Summary counts of changes by severity
|
|
243
|
-
*/
|
|
244
|
-
export interface DiffSummary {
|
|
245
|
-
breaking: number;
|
|
246
|
-
nonBreaking: number;
|
|
247
|
-
patch: number;
|
|
248
|
-
unknown: number;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Result of comparing two spec versions
|
|
252
|
-
*/
|
|
253
|
-
export interface DiffResult {
|
|
254
|
-
contract: string;
|
|
255
|
-
changes: Change[];
|
|
256
|
-
summary: DiffSummary;
|
|
257
|
-
suggestedBump: SuggestedBump;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* All possible structural change types for classification
|
|
261
|
-
*/
|
|
262
|
-
export type ChangeType = 'property-added' | 'property-removed' | 'required-added' | 'required-removed' | 'type-changed' | 'type-narrowed' | 'type-widened' | 'enum-value-added' | 'enum-value-removed' | 'enum-added' | 'enum-removed' | 'constraint-tightened' | 'constraint-loosened' | 'format-changed' | 'format-added' | 'format-removed' | 'additional-properties-denied' | 'additional-properties-allowed' | 'additional-properties-changed' | 'property-names-changed' | 'dependent-required-added' | 'dependent-required-removed' | 'dependent-schemas-changed' | 'unevaluated-properties-changed' | 'items-changed' | 'min-items-increased' | 'max-items-decreased' | 'min-contains-changed' | 'max-contains-changed' | 'unevaluated-items-changed' | 'ref-target-changed' | 'description-changed' | 'title-changed' | 'default-changed' | 'examples-changed' | 'deprecated-changed' | 'read-only-changed' | 'write-only-changed' | 'content-encoding-changed' | 'content-media-type-changed' | 'content-schema-changed' | 'anyof-option-added' | 'anyof-option-removed' | 'oneof-option-added' | 'oneof-option-removed' | 'allof-member-added' | 'allof-member-removed' | 'not-schema-changed' | 'if-then-else-changed' | 'composition-changed' | 'unknown-change';
|
|
263
|
-
/**
|
|
264
|
-
* Raw change detected by a differ before severity classification
|
|
265
|
-
*/
|
|
266
|
-
export interface RawChange {
|
|
267
|
-
path: string;
|
|
268
|
-
type: ChangeType;
|
|
269
|
-
oldValue?: unknown;
|
|
270
|
-
newValue?: unknown;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Mapping from change types to their severity classification
|
|
274
|
-
*/
|
|
275
|
-
export declare const CHANGE_TYPE_SEVERITY: Record<ChangeType, ChangeSeverity>;
|
|
276
61
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAC7C,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IAC5C,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,yCAAyC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,eAAe,GAAG,eAAe,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,210 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Strands API types for JSON Schema comparison
|
|
3
|
+
*
|
|
4
|
+
* These types are specific to the Strands-compatible comparison API.
|
|
5
|
+
* Core schema diffing types are in @contractual/differs.core.
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
* Map of constraint keys to their comparison direction
|
|
6
|
-
*/
|
|
7
|
-
export const CONSTRAINT_DIRECTION = {
|
|
8
|
-
minimum: 'min',
|
|
9
|
-
maximum: 'max',
|
|
10
|
-
exclusiveMinimum: 'min',
|
|
11
|
-
exclusiveMaximum: 'max',
|
|
12
|
-
minLength: 'min',
|
|
13
|
-
maxLength: 'max',
|
|
14
|
-
minItems: 'min',
|
|
15
|
-
maxItems: 'max',
|
|
16
|
-
minProperties: 'min',
|
|
17
|
-
maxProperties: 'max',
|
|
18
|
-
minContains: 'min',
|
|
19
|
-
maxContains: 'max',
|
|
20
|
-
pattern: 'exact',
|
|
21
|
-
multipleOf: 'exact',
|
|
22
|
-
uniqueItems: 'exact',
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* All constraint keys for iteration
|
|
26
|
-
*/
|
|
27
|
-
export const CONSTRAINT_KEYS = [
|
|
28
|
-
'minimum',
|
|
29
|
-
'maximum',
|
|
30
|
-
'exclusiveMinimum',
|
|
31
|
-
'exclusiveMaximum',
|
|
32
|
-
'minLength',
|
|
33
|
-
'maxLength',
|
|
34
|
-
'minItems',
|
|
35
|
-
'maxItems',
|
|
36
|
-
'minProperties',
|
|
37
|
-
'maxProperties',
|
|
38
|
-
'minContains',
|
|
39
|
-
'maxContains',
|
|
40
|
-
'pattern',
|
|
41
|
-
'multipleOf',
|
|
42
|
-
'uniqueItems',
|
|
43
|
-
];
|
|
44
|
-
/**
|
|
45
|
-
* All composition keywords for iteration
|
|
46
|
-
*/
|
|
47
|
-
export const COMPOSITION_KEYWORDS = [
|
|
48
|
-
'anyOf',
|
|
49
|
-
'oneOf',
|
|
50
|
-
'allOf',
|
|
51
|
-
'if',
|
|
52
|
-
'then',
|
|
53
|
-
'else',
|
|
54
|
-
'not',
|
|
55
|
-
];
|
|
56
|
-
/**
|
|
57
|
-
* All metadata keys for iteration
|
|
58
|
-
*/
|
|
59
|
-
export const METADATA_KEYS = ['description', 'title', 'default', 'examples'];
|
|
60
|
-
/**
|
|
61
|
-
* All annotation keys for iteration
|
|
62
|
-
*/
|
|
63
|
-
export const ANNOTATION_KEYS = ['deprecated', 'readOnly', 'writeOnly'];
|
|
64
|
-
/**
|
|
65
|
-
* All content keys for iteration
|
|
66
|
-
*/
|
|
67
|
-
export const CONTENT_KEYS = ['contentEncoding', 'contentMediaType', 'contentSchema'];
|
|
68
|
-
/**
|
|
69
|
-
* Default maximum recursion depth
|
|
70
|
-
*/
|
|
71
|
-
export const DEFAULT_MAX_DEPTH = 100;
|
|
72
|
-
/**
|
|
73
|
-
* Type guard to check if value is a schema object
|
|
74
|
-
*/
|
|
75
|
-
export function isSchemaObject(value) {
|
|
76
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Type guard to check if value is an array of schemas
|
|
80
|
-
*/
|
|
81
|
-
export function isSchemaArray(value) {
|
|
82
|
-
return Array.isArray(value) && value.every(isSchemaObject);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Normalize type to array for consistent comparison
|
|
86
|
-
*/
|
|
87
|
-
export function normalizeType(type) {
|
|
88
|
-
if (type === undefined) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
if (Array.isArray(type)) {
|
|
92
|
-
return [...type].sort();
|
|
93
|
-
}
|
|
94
|
-
return [type];
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Check if two arrays have the same elements (order-independent)
|
|
98
|
-
*/
|
|
99
|
-
export function arraysEqual(a, b) {
|
|
100
|
-
if (a.length !== b.length)
|
|
101
|
-
return false;
|
|
102
|
-
const sortedA = [...a].sort();
|
|
103
|
-
const sortedB = [...b].sort();
|
|
104
|
-
return sortedA.every((val, idx) => val === sortedB[idx]);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Deep equality check for JSON values
|
|
108
|
-
*/
|
|
109
|
-
export function deepEqual(a, b) {
|
|
110
|
-
if (a === b) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
if (typeof a !== typeof b) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
if (a === null || b === null)
|
|
117
|
-
return a === b;
|
|
118
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
119
|
-
if (a.length !== b.length)
|
|
120
|
-
return false;
|
|
121
|
-
return a.every((val, idx) => deepEqual(val, b[idx]));
|
|
122
|
-
}
|
|
123
|
-
if (typeof a === 'object' && typeof b === 'object') {
|
|
124
|
-
const aObj = a;
|
|
125
|
-
const bObj = b;
|
|
126
|
-
const aKeys = Object.keys(aObj);
|
|
127
|
-
const bKeys = Object.keys(bObj);
|
|
128
|
-
if (aKeys.length !== bKeys.length)
|
|
129
|
-
return false;
|
|
130
|
-
return aKeys.every((key) => deepEqual(aObj[key], bObj[key]));
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Escape JSON Pointer segment according to RFC 6901
|
|
136
|
-
*/
|
|
137
|
-
export function escapeJsonPointer(segment) {
|
|
138
|
-
return segment.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Join path segments into a JSON Pointer
|
|
142
|
-
*/
|
|
143
|
-
export function joinPath(basePath, ...segments) {
|
|
144
|
-
const escaped = segments.map(escapeJsonPointer);
|
|
145
|
-
if (basePath === '') {
|
|
146
|
-
return escaped.length > 0 ? '/' + escaped.join('/') : '';
|
|
147
|
-
}
|
|
148
|
-
return basePath + '/' + escaped.join('/');
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Mapping from change types to their severity classification
|
|
152
|
-
*/
|
|
153
|
-
export const CHANGE_TYPE_SEVERITY = {
|
|
154
|
-
// Breaking changes (major)
|
|
155
|
-
'property-removed': 'breaking',
|
|
156
|
-
'required-added': 'breaking',
|
|
157
|
-
'type-changed': 'breaking',
|
|
158
|
-
'type-narrowed': 'breaking',
|
|
159
|
-
'enum-value-removed': 'breaking',
|
|
160
|
-
'enum-added': 'breaking',
|
|
161
|
-
'constraint-tightened': 'breaking',
|
|
162
|
-
'additional-properties-denied': 'breaking',
|
|
163
|
-
'items-changed': 'breaking',
|
|
164
|
-
'min-items-increased': 'breaking',
|
|
165
|
-
'max-items-decreased': 'breaking',
|
|
166
|
-
'ref-target-changed': 'breaking',
|
|
167
|
-
'dependent-required-added': 'breaking',
|
|
168
|
-
'anyof-option-added': 'breaking',
|
|
169
|
-
'oneof-option-added': 'breaking',
|
|
170
|
-
'allof-member-added': 'breaking',
|
|
171
|
-
'not-schema-changed': 'breaking',
|
|
172
|
-
// Non-breaking changes (minor)
|
|
173
|
-
'property-added': 'non-breaking',
|
|
174
|
-
'required-removed': 'non-breaking',
|
|
175
|
-
'type-widened': 'non-breaking',
|
|
176
|
-
'enum-value-added': 'non-breaking',
|
|
177
|
-
'enum-removed': 'non-breaking',
|
|
178
|
-
'constraint-loosened': 'non-breaking',
|
|
179
|
-
'additional-properties-allowed': 'non-breaking',
|
|
180
|
-
'additional-properties-changed': 'non-breaking',
|
|
181
|
-
'dependent-required-removed': 'non-breaking',
|
|
182
|
-
'anyof-option-removed': 'non-breaking',
|
|
183
|
-
'oneof-option-removed': 'non-breaking',
|
|
184
|
-
'allof-member-removed': 'non-breaking',
|
|
185
|
-
// Patch-level changes
|
|
186
|
-
'format-added': 'patch',
|
|
187
|
-
'format-removed': 'patch',
|
|
188
|
-
'format-changed': 'patch',
|
|
189
|
-
'description-changed': 'patch',
|
|
190
|
-
'title-changed': 'patch',
|
|
191
|
-
'default-changed': 'patch',
|
|
192
|
-
'examples-changed': 'patch',
|
|
193
|
-
'deprecated-changed': 'patch',
|
|
194
|
-
'read-only-changed': 'patch',
|
|
195
|
-
'write-only-changed': 'patch',
|
|
196
|
-
'content-encoding-changed': 'patch',
|
|
197
|
-
'content-media-type-changed': 'patch',
|
|
198
|
-
'content-schema-changed': 'patch',
|
|
199
|
-
// Unknown (manual review)
|
|
200
|
-
'property-names-changed': 'unknown',
|
|
201
|
-
'dependent-schemas-changed': 'unknown',
|
|
202
|
-
'unevaluated-properties-changed': 'unknown',
|
|
203
|
-
'unevaluated-items-changed': 'unknown',
|
|
204
|
-
'min-contains-changed': 'unknown',
|
|
205
|
-
'max-contains-changed': 'unknown',
|
|
206
|
-
'if-then-else-changed': 'unknown',
|
|
207
|
-
'composition-changed': 'unknown',
|
|
208
|
-
'unknown-change': 'unknown',
|
|
209
|
-
};
|
|
7
|
+
export {};
|
|
210
8
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractual/differs.json-schema",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.1",
|
|
4
4
|
"description": "Detect breaking changes between JSON Schema versions with semantic classification",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"dist",
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@contractual/differs.core": "0.1.0-dev.1",
|
|
52
|
+
"@contractual/types": "0.1.0-dev.1"
|
|
53
|
+
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"rimraf": "^5.0.5",
|
|
52
56
|
"vitest": "^3.0.3"
|
|
@@ -55,5 +59,5 @@
|
|
|
55
59
|
"access": "public",
|
|
56
60
|
"provenance": true
|
|
57
61
|
},
|
|
58
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "9370397e0aa15062baf62aa5ce07d93329339165"
|
|
59
63
|
}
|
package/dist/classifiers.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON Schema Change Classifiers
|
|
3
|
-
*
|
|
4
|
-
* Classifies raw structural changes into severity levels for semantic versioning.
|
|
5
|
-
* Follows API compatibility principles where breaking changes require major bumps,
|
|
6
|
-
* additive changes require minor bumps, and metadata changes are patches.
|
|
7
|
-
*/
|
|
8
|
-
import type { RawChange, ChangeType, ChangeSeverity } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* Export classification sets for external analysis
|
|
11
|
-
*/
|
|
12
|
-
export declare const CLASSIFICATION_SETS: {
|
|
13
|
-
readonly breaking: ReadonlySet<ChangeType>;
|
|
14
|
-
readonly nonBreaking: ReadonlySet<ChangeType>;
|
|
15
|
-
readonly patch: ReadonlySet<ChangeType>;
|
|
16
|
-
readonly unknown: ReadonlySet<ChangeType>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Classify a raw change into a severity level
|
|
20
|
-
*
|
|
21
|
-
* Uses the Strands API classification rules where:
|
|
22
|
-
* - Breaking changes require major version bump
|
|
23
|
-
* - Non-breaking changes require minor version bump
|
|
24
|
-
* - Patch changes are metadata/annotation only
|
|
25
|
-
* - Unknown changes require manual review
|
|
26
|
-
*
|
|
27
|
-
* @param change - The raw change to classify
|
|
28
|
-
* @returns The severity classification
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const change: RawChange = {
|
|
33
|
-
* path: '/properties/name',
|
|
34
|
-
* type: 'property-removed',
|
|
35
|
-
* oldValue: { type: 'string' },
|
|
36
|
-
* };
|
|
37
|
-
* const severity = classify(change);
|
|
38
|
-
* // severity === 'breaking'
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare function classify(change: RawChange): ChangeSeverity;
|
|
42
|
-
/**
|
|
43
|
-
* Classify a property-added change with schema context
|
|
44
|
-
*
|
|
45
|
-
* Property additions are breaking if the property is required,
|
|
46
|
-
* otherwise they are non-breaking (additive).
|
|
47
|
-
*
|
|
48
|
-
* @param change - The property-added change
|
|
49
|
-
* @param newSchema - The new schema for context (to check required array)
|
|
50
|
-
* @returns The severity classification
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const change: RawChange = {
|
|
55
|
-
* path: '/properties/email',
|
|
56
|
-
* type: 'property-added',
|
|
57
|
-
* newValue: { type: 'string', format: 'email' },
|
|
58
|
-
* };
|
|
59
|
-
*
|
|
60
|
-
* const schema = {
|
|
61
|
-
* type: 'object',
|
|
62
|
-
* properties: { email: { type: 'string', format: 'email' } },
|
|
63
|
-
* required: ['email'], // email is required!
|
|
64
|
-
* };
|
|
65
|
-
*
|
|
66
|
-
* const severity = classifyPropertyAdded(change, schema);
|
|
67
|
-
* // severity === 'breaking' (because email is in required[])
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare function classifyPropertyAdded(change: RawChange, newSchema: unknown): ChangeSeverity;
|
|
71
|
-
/**
|
|
72
|
-
* Batch classify multiple changes
|
|
73
|
-
*
|
|
74
|
-
* @param changes - Array of raw changes
|
|
75
|
-
* @param newSchema - Optional schema for context-aware classification
|
|
76
|
-
* @returns Map of change to severity
|
|
77
|
-
*/
|
|
78
|
-
export declare function classifyAll(changes: readonly RawChange[], newSchema?: unknown): Map<RawChange, ChangeSeverity>;
|
|
79
|
-
/**
|
|
80
|
-
* Get a human-readable message for a classified change
|
|
81
|
-
*
|
|
82
|
-
* @param change - The raw change
|
|
83
|
-
* @param severity - The classified severity
|
|
84
|
-
* @returns Human-readable description
|
|
85
|
-
*/
|
|
86
|
-
export declare function getChangeMessage(change: RawChange, severity: ChangeSeverity): string;
|
|
87
|
-
//# sourceMappingURL=classifiers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classifiers.d.ts","sourceRoot":"","sources":["../src/classifiers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA6HxE;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CAsB1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,cAAc,CA6B3F;AAgGD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,SAAS,CAAC,EAAE,OAAO,GAClB,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAYhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,CAapF"}
|