@contractual/differs.core 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/LICENSE +21 -0
- package/dist/assemble.d.ts +10 -0
- package/dist/assemble.d.ts.map +1 -0
- package/dist/assemble.js +42 -0
- package/dist/assemble.js.map +1 -0
- package/dist/classifiers.d.ts +87 -0
- package/dist/classifiers.d.ts.map +1 -0
- package/dist/classifiers.js +375 -0
- package/dist/classifiers.js.map +1 -0
- package/dist/format.d.ts +12 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +127 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/ref-resolver.d.ts +73 -0
- package/dist/ref-resolver.d.ts.map +1 -0
- package/dist/ref-resolver.js +345 -0
- package/dist/ref-resolver.js.map +1 -0
- package/dist/types.d.ts +170 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +151 -0
- package/dist/types.js.map +1 -0
- package/dist/walker.d.ts +17 -0
- package/dist/walker.d.ts.map +1 -0
- package/dist/walker.js +1195 -0
- package/dist/walker.js.map +1 -0
- package/package.json +56 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core schema types and utilities for Contractual differs
|
|
3
|
+
*/
|
|
4
|
+
export type { ChangeType, ChangeSeverity, RawChange, Change, DiffResult, DiffSummary, SuggestedBump, } from '@contractual/types';
|
|
5
|
+
export { CHANGE_TYPE_SEVERITY } from '@contractual/types';
|
|
6
|
+
/**
|
|
7
|
+
* JSON Schema type values
|
|
8
|
+
*/
|
|
9
|
+
export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
10
|
+
/**
|
|
11
|
+
* Normalized type representation (always an array for comparison)
|
|
12
|
+
*/
|
|
13
|
+
export type NormalizedType = JSONSchemaType[];
|
|
14
|
+
/**
|
|
15
|
+
* JSON Schema constraint keys that can be tightened or loosened
|
|
16
|
+
*/
|
|
17
|
+
export type ConstraintKey = 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minLength' | 'maxLength' | 'minItems' | 'maxItems' | 'minProperties' | 'maxProperties' | 'minContains' | 'maxContains' | 'pattern' | 'multipleOf' | 'uniqueItems';
|
|
18
|
+
/**
|
|
19
|
+
* Constraint comparison direction
|
|
20
|
+
*/
|
|
21
|
+
export type ConstraintDirection = 'min' | 'max' | 'exact';
|
|
22
|
+
/**
|
|
23
|
+
* Constraint metadata for determining tightened vs loosened
|
|
24
|
+
*/
|
|
25
|
+
export interface ConstraintMeta {
|
|
26
|
+
readonly key: ConstraintKey;
|
|
27
|
+
readonly direction: ConstraintDirection;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Map of constraint keys to their comparison direction
|
|
31
|
+
*/
|
|
32
|
+
export declare const CONSTRAINT_DIRECTION: Record<ConstraintKey, ConstraintDirection>;
|
|
33
|
+
/**
|
|
34
|
+
* All constraint keys for iteration
|
|
35
|
+
*/
|
|
36
|
+
export declare const CONSTRAINT_KEYS: ConstraintKey[];
|
|
37
|
+
/**
|
|
38
|
+
* Composition keywords in JSON Schema
|
|
39
|
+
*/
|
|
40
|
+
export type CompositionKeyword = 'anyOf' | 'oneOf' | 'allOf' | 'if' | 'then' | 'else' | 'not';
|
|
41
|
+
/**
|
|
42
|
+
* All composition keywords for iteration
|
|
43
|
+
*/
|
|
44
|
+
export declare const COMPOSITION_KEYWORDS: CompositionKeyword[];
|
|
45
|
+
/**
|
|
46
|
+
* Metadata keys that are compared (patch-level changes)
|
|
47
|
+
*/
|
|
48
|
+
export type MetadataKey = 'description' | 'title' | 'default' | 'examples';
|
|
49
|
+
/**
|
|
50
|
+
* All metadata keys for iteration
|
|
51
|
+
*/
|
|
52
|
+
export declare const METADATA_KEYS: MetadataKey[];
|
|
53
|
+
/**
|
|
54
|
+
* Annotation keys (patch-level changes per Strands API)
|
|
55
|
+
*/
|
|
56
|
+
export type AnnotationKey = 'deprecated' | 'readOnly' | 'writeOnly';
|
|
57
|
+
/**
|
|
58
|
+
* All annotation keys for iteration
|
|
59
|
+
*/
|
|
60
|
+
export declare const ANNOTATION_KEYS: AnnotationKey[];
|
|
61
|
+
/**
|
|
62
|
+
* Content keywords (patch-level changes per Strands API)
|
|
63
|
+
*/
|
|
64
|
+
export type ContentKey = 'contentEncoding' | 'contentMediaType' | 'contentSchema';
|
|
65
|
+
/**
|
|
66
|
+
* All content keys for iteration
|
|
67
|
+
*/
|
|
68
|
+
export declare const CONTENT_KEYS: ContentKey[];
|
|
69
|
+
/**
|
|
70
|
+
* Resolved JSON Schema object (refs already resolved)
|
|
71
|
+
*/
|
|
72
|
+
export interface ResolvedSchema {
|
|
73
|
+
$schema?: string;
|
|
74
|
+
$id?: string;
|
|
75
|
+
$ref?: string;
|
|
76
|
+
$defs?: Record<string, ResolvedSchema>;
|
|
77
|
+
type?: JSONSchemaType | JSONSchemaType[];
|
|
78
|
+
title?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
default?: unknown;
|
|
81
|
+
examples?: unknown[];
|
|
82
|
+
deprecated?: boolean;
|
|
83
|
+
readOnly?: boolean;
|
|
84
|
+
writeOnly?: boolean;
|
|
85
|
+
enum?: unknown[];
|
|
86
|
+
const?: unknown;
|
|
87
|
+
format?: string;
|
|
88
|
+
minimum?: number;
|
|
89
|
+
maximum?: number;
|
|
90
|
+
exclusiveMinimum?: number;
|
|
91
|
+
exclusiveMaximum?: number;
|
|
92
|
+
multipleOf?: number;
|
|
93
|
+
minLength?: number;
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
pattern?: string;
|
|
96
|
+
contentEncoding?: string;
|
|
97
|
+
contentMediaType?: string;
|
|
98
|
+
contentSchema?: ResolvedSchema;
|
|
99
|
+
properties?: Record<string, ResolvedSchema>;
|
|
100
|
+
required?: string[];
|
|
101
|
+
additionalProperties?: boolean | ResolvedSchema;
|
|
102
|
+
minProperties?: number;
|
|
103
|
+
maxProperties?: number;
|
|
104
|
+
propertyNames?: ResolvedSchema;
|
|
105
|
+
patternProperties?: Record<string, ResolvedSchema>;
|
|
106
|
+
dependentRequired?: Record<string, string[]>;
|
|
107
|
+
dependentSchemas?: Record<string, ResolvedSchema>;
|
|
108
|
+
unevaluatedProperties?: boolean | ResolvedSchema;
|
|
109
|
+
items?: ResolvedSchema | ResolvedSchema[];
|
|
110
|
+
prefixItems?: ResolvedSchema[];
|
|
111
|
+
minItems?: number;
|
|
112
|
+
maxItems?: number;
|
|
113
|
+
uniqueItems?: boolean;
|
|
114
|
+
contains?: ResolvedSchema;
|
|
115
|
+
minContains?: number;
|
|
116
|
+
maxContains?: number;
|
|
117
|
+
unevaluatedItems?: boolean | ResolvedSchema;
|
|
118
|
+
anyOf?: ResolvedSchema[];
|
|
119
|
+
oneOf?: ResolvedSchema[];
|
|
120
|
+
allOf?: ResolvedSchema[];
|
|
121
|
+
if?: ResolvedSchema;
|
|
122
|
+
then?: ResolvedSchema;
|
|
123
|
+
else?: ResolvedSchema;
|
|
124
|
+
not?: ResolvedSchema;
|
|
125
|
+
[key: string]: unknown;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Walker context for tracking traversal state
|
|
129
|
+
*/
|
|
130
|
+
export interface WalkerContext {
|
|
131
|
+
/** Current JSON Pointer path */
|
|
132
|
+
readonly path: string;
|
|
133
|
+
/** Depth of recursion (for cycle detection) */
|
|
134
|
+
readonly depth: number;
|
|
135
|
+
/** Maximum allowed depth */
|
|
136
|
+
readonly maxDepth: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Default maximum recursion depth
|
|
140
|
+
*/
|
|
141
|
+
export declare const DEFAULT_MAX_DEPTH = 100;
|
|
142
|
+
/**
|
|
143
|
+
* Type guard to check if value is a schema object
|
|
144
|
+
*/
|
|
145
|
+
export declare function isSchemaObject(value: unknown): value is ResolvedSchema;
|
|
146
|
+
/**
|
|
147
|
+
* Type guard to check if value is an array of schemas
|
|
148
|
+
*/
|
|
149
|
+
export declare function isSchemaArray(value: unknown): value is ResolvedSchema[];
|
|
150
|
+
/**
|
|
151
|
+
* Normalize type to array for consistent comparison
|
|
152
|
+
*/
|
|
153
|
+
export declare function normalizeType(type: JSONSchemaType | JSONSchemaType[] | undefined): NormalizedType;
|
|
154
|
+
/**
|
|
155
|
+
* Check if two arrays have the same elements (order-independent)
|
|
156
|
+
*/
|
|
157
|
+
export declare function arraysEqual<T>(a: T[], b: T[]): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Deep equality check for JSON values
|
|
160
|
+
*/
|
|
161
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Escape JSON Pointer segment according to RFC 6901
|
|
164
|
+
*/
|
|
165
|
+
export declare function escapeJsonPointer(segment: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* Join path segments into a JSON Pointer
|
|
168
|
+
*/
|
|
169
|
+
export declare function joinPath(basePath: string, ...segments: string[]): string;
|
|
170
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM1D;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,EAAE,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,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;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAEtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,EAAE,CAEvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,SAAS,GAAG,cAAc,CAQjG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAKtD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA0BzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMxE"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core schema types and utilities for Contractual differs
|
|
3
|
+
*/
|
|
4
|
+
export { CHANGE_TYPE_SEVERITY } from '@contractual/types';
|
|
5
|
+
/**
|
|
6
|
+
* Map of constraint keys to their comparison direction
|
|
7
|
+
*/
|
|
8
|
+
export const CONSTRAINT_DIRECTION = {
|
|
9
|
+
minimum: 'min',
|
|
10
|
+
maximum: 'max',
|
|
11
|
+
exclusiveMinimum: 'min',
|
|
12
|
+
exclusiveMaximum: 'max',
|
|
13
|
+
minLength: 'min',
|
|
14
|
+
maxLength: 'max',
|
|
15
|
+
minItems: 'min',
|
|
16
|
+
maxItems: 'max',
|
|
17
|
+
minProperties: 'min',
|
|
18
|
+
maxProperties: 'max',
|
|
19
|
+
minContains: 'min',
|
|
20
|
+
maxContains: 'max',
|
|
21
|
+
pattern: 'exact',
|
|
22
|
+
multipleOf: 'exact',
|
|
23
|
+
uniqueItems: 'exact',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* All constraint keys for iteration
|
|
27
|
+
*/
|
|
28
|
+
export const CONSTRAINT_KEYS = [
|
|
29
|
+
'minimum',
|
|
30
|
+
'maximum',
|
|
31
|
+
'exclusiveMinimum',
|
|
32
|
+
'exclusiveMaximum',
|
|
33
|
+
'minLength',
|
|
34
|
+
'maxLength',
|
|
35
|
+
'minItems',
|
|
36
|
+
'maxItems',
|
|
37
|
+
'minProperties',
|
|
38
|
+
'maxProperties',
|
|
39
|
+
'minContains',
|
|
40
|
+
'maxContains',
|
|
41
|
+
'pattern',
|
|
42
|
+
'multipleOf',
|
|
43
|
+
'uniqueItems',
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* All composition keywords for iteration
|
|
47
|
+
*/
|
|
48
|
+
export const COMPOSITION_KEYWORDS = [
|
|
49
|
+
'anyOf',
|
|
50
|
+
'oneOf',
|
|
51
|
+
'allOf',
|
|
52
|
+
'if',
|
|
53
|
+
'then',
|
|
54
|
+
'else',
|
|
55
|
+
'not',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* All metadata keys for iteration
|
|
59
|
+
*/
|
|
60
|
+
export const METADATA_KEYS = ['description', 'title', 'default', 'examples'];
|
|
61
|
+
/**
|
|
62
|
+
* All annotation keys for iteration
|
|
63
|
+
*/
|
|
64
|
+
export const ANNOTATION_KEYS = ['deprecated', 'readOnly', 'writeOnly'];
|
|
65
|
+
/**
|
|
66
|
+
* All content keys for iteration
|
|
67
|
+
*/
|
|
68
|
+
export const CONTENT_KEYS = ['contentEncoding', 'contentMediaType', 'contentSchema'];
|
|
69
|
+
/**
|
|
70
|
+
* Default maximum recursion depth
|
|
71
|
+
*/
|
|
72
|
+
export const DEFAULT_MAX_DEPTH = 100;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if value is a schema object
|
|
75
|
+
*/
|
|
76
|
+
export function isSchemaObject(value) {
|
|
77
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if value is an array of schemas
|
|
81
|
+
*/
|
|
82
|
+
export function isSchemaArray(value) {
|
|
83
|
+
return Array.isArray(value) && value.every(isSchemaObject);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Normalize type to array for consistent comparison
|
|
87
|
+
*/
|
|
88
|
+
export function normalizeType(type) {
|
|
89
|
+
if (type === undefined) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(type)) {
|
|
93
|
+
return [...type].sort();
|
|
94
|
+
}
|
|
95
|
+
return [type];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if two arrays have the same elements (order-independent)
|
|
99
|
+
*/
|
|
100
|
+
export function arraysEqual(a, b) {
|
|
101
|
+
if (a.length !== b.length)
|
|
102
|
+
return false;
|
|
103
|
+
const sortedA = [...a].sort();
|
|
104
|
+
const sortedB = [...b].sort();
|
|
105
|
+
return sortedA.every((val, idx) => val === sortedB[idx]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deep equality check for JSON values
|
|
109
|
+
*/
|
|
110
|
+
export function deepEqual(a, b) {
|
|
111
|
+
if (a === b) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (typeof a !== typeof b) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (a === null || b === null)
|
|
118
|
+
return a === b;
|
|
119
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
120
|
+
if (a.length !== b.length)
|
|
121
|
+
return false;
|
|
122
|
+
return a.every((val, idx) => deepEqual(val, b[idx]));
|
|
123
|
+
}
|
|
124
|
+
if (typeof a === 'object' && typeof b === 'object') {
|
|
125
|
+
const aObj = a;
|
|
126
|
+
const bObj = b;
|
|
127
|
+
const aKeys = Object.keys(aObj);
|
|
128
|
+
const bKeys = Object.keys(bObj);
|
|
129
|
+
if (aKeys.length !== bKeys.length)
|
|
130
|
+
return false;
|
|
131
|
+
return aKeys.every((key) => deepEqual(aObj[key], bObj[key]));
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Escape JSON Pointer segment according to RFC 6901
|
|
137
|
+
*/
|
|
138
|
+
export function escapeJsonPointer(segment) {
|
|
139
|
+
return segment.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Join path segments into a JSON Pointer
|
|
143
|
+
*/
|
|
144
|
+
export function joinPath(basePath, ...segments) {
|
|
145
|
+
const escaped = segments.map(escapeJsonPointer);
|
|
146
|
+
if (basePath === '') {
|
|
147
|
+
return escaped.length > 0 ? '/' + escaped.join('/') : '';
|
|
148
|
+
}
|
|
149
|
+
return basePath + '/' + escaped.join('/');
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAwD1D;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA+C;IAC9E,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,KAAK;IACpB,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;IAClB,WAAW,EAAE,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G,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/walker.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema structural walker
|
|
3
|
+
*
|
|
4
|
+
* Recursively walks two resolved JSON Schemas side-by-side (DFS)
|
|
5
|
+
* and emits RawChange for every structural difference.
|
|
6
|
+
*/
|
|
7
|
+
import type { RawChange } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Walk two resolved JSON Schemas and emit changes
|
|
10
|
+
*
|
|
11
|
+
* @param oldSchema - The original schema (resolved, no $refs)
|
|
12
|
+
* @param newSchema - The new schema (resolved, no $refs)
|
|
13
|
+
* @param basePath - JSON Pointer base path (default: '')
|
|
14
|
+
* @returns Array of raw changes detected
|
|
15
|
+
*/
|
|
16
|
+
export declare function walk(oldSchema: unknown, newSchema: unknown, basePath?: string): RawChange[];
|
|
17
|
+
//# sourceMappingURL=walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walker.d.ts","sourceRoot":"","sources":["../src/walker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAc,SAAS,EAAgB,MAAM,YAAY,CAAC;AAiBtE;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAW,GAAG,SAAS,EAAE,CAE/F"}
|