@squiz/dx-json-schema-lib 1.87.0 → 1.88.0

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/formatted-text/v1/resolveFormattedTextNodes.d.ts +5 -2
  3. package/lib/formatted-text/v1/resolveFormattedTextNodes.js +9 -3
  4. package/lib/formatted-text/v1/resolveFormattedTextNodes.js.map +1 -1
  5. package/lib/formatted-text/v1/resolveFormattedTextNodes.spec.js +58 -0
  6. package/lib/formatted-text/v1/resolveFormattedTextNodes.spec.js.map +1 -1
  7. package/lib/index.d.ts +1 -0
  8. package/lib/index.js +1 -0
  9. package/lib/index.js.map +1 -1
  10. package/lib/utils/jsonBreakDetector/checks/findArrayConstraintNarrowing.d.ts +6 -0
  11. package/lib/utils/jsonBreakDetector/checks/findArrayConstraintNarrowing.js +93 -0
  12. package/lib/utils/jsonBreakDetector/checks/findArrayConstraintNarrowing.js.map +1 -0
  13. package/lib/utils/jsonBreakDetector/checks/findConstChanges.d.ts +6 -0
  14. package/lib/utils/jsonBreakDetector/checks/findConstChanges.js +75 -0
  15. package/lib/utils/jsonBreakDetector/checks/findConstChanges.js.map +1 -0
  16. package/lib/utils/jsonBreakDetector/checks/findEnumNarrowing.d.ts +6 -0
  17. package/lib/utils/jsonBreakDetector/checks/findEnumNarrowing.js +90 -0
  18. package/lib/utils/jsonBreakDetector/checks/findEnumNarrowing.js.map +1 -0
  19. package/lib/utils/jsonBreakDetector/checks/findFieldTypeChanges.d.ts +8 -0
  20. package/lib/utils/jsonBreakDetector/checks/findFieldTypeChanges.js +86 -0
  21. package/lib/utils/jsonBreakDetector/checks/findFieldTypeChanges.js.map +1 -0
  22. package/lib/utils/jsonBreakDetector/checks/findNewRequiredFields.d.ts +6 -0
  23. package/lib/utils/jsonBreakDetector/checks/findNewRequiredFields.js +68 -0
  24. package/lib/utils/jsonBreakDetector/checks/findNewRequiredFields.js.map +1 -0
  25. package/lib/utils/jsonBreakDetector/checks/findNumericConstraintNarrowing.d.ts +6 -0
  26. package/lib/utils/jsonBreakDetector/checks/findNumericConstraintNarrowing.js +179 -0
  27. package/lib/utils/jsonBreakDetector/checks/findNumericConstraintNarrowing.js.map +1 -0
  28. package/lib/utils/jsonBreakDetector/checks/findStringConstraintNarrowing.d.ts +6 -0
  29. package/lib/utils/jsonBreakDetector/checks/findStringConstraintNarrowing.js +106 -0
  30. package/lib/utils/jsonBreakDetector/checks/findStringConstraintNarrowing.js.map +1 -0
  31. package/lib/utils/jsonBreakDetector/compareSubschemas.d.ts +9 -0
  32. package/lib/utils/jsonBreakDetector/compareSubschemas.js +49 -0
  33. package/lib/utils/jsonBreakDetector/compareSubschemas.js.map +1 -0
  34. package/lib/utils/jsonBreakDetector/dereference/dereference.d.ts +6 -0
  35. package/lib/utils/jsonBreakDetector/dereference/dereference.js +52 -0
  36. package/lib/utils/jsonBreakDetector/dereference/dereference.js.map +1 -0
  37. package/lib/utils/jsonBreakDetector/dereference/dereference.spec.d.ts +1 -0
  38. package/lib/utils/jsonBreakDetector/dereference/dereference.spec.js +225 -0
  39. package/lib/utils/jsonBreakDetector/dereference/dereference.spec.js.map +1 -0
  40. package/lib/utils/jsonBreakDetector/jsonBreakDetector.d.ts +8 -0
  41. package/lib/utils/jsonBreakDetector/jsonBreakDetector.js +35 -0
  42. package/lib/utils/jsonBreakDetector/jsonBreakDetector.js.map +1 -0
  43. package/lib/utils/jsonBreakDetector/jsonBreakDetector.spec.d.ts +1 -0
  44. package/lib/utils/jsonBreakDetector/jsonBreakDetector.spec.js +2761 -0
  45. package/lib/utils/jsonBreakDetector/jsonBreakDetector.spec.js.map +1 -0
  46. package/lib/utils/jsonBreakDetector/types.d.ts +25 -0
  47. package/lib/utils/jsonBreakDetector/types.js +28 -0
  48. package/lib/utils/jsonBreakDetector/types.js.map +1 -0
  49. package/package.json +1 -1
  50. package/src/formatted-text/v1/resolveFormattedTextNodes.spec.ts +70 -0
  51. package/src/formatted-text/v1/resolveFormattedTextNodes.ts +18 -3
  52. package/src/index.ts +2 -0
  53. package/src/utils/jsonBreakDetector/checks/findArrayConstraintNarrowing.ts +121 -0
  54. package/src/utils/jsonBreakDetector/checks/findConstChanges.ts +97 -0
  55. package/src/utils/jsonBreakDetector/checks/findEnumNarrowing.ts +124 -0
  56. package/src/utils/jsonBreakDetector/checks/findFieldTypeChanges.ts +105 -0
  57. package/src/utils/jsonBreakDetector/checks/findNewRequiredFields.ts +97 -0
  58. package/src/utils/jsonBreakDetector/checks/findNumericConstraintNarrowing.ts +243 -0
  59. package/src/utils/jsonBreakDetector/checks/findStringConstraintNarrowing.ts +139 -0
  60. package/src/utils/jsonBreakDetector/compareSubschemas.ts +67 -0
  61. package/src/utils/jsonBreakDetector/dereference/dereference.spec.ts +245 -0
  62. package/src/utils/jsonBreakDetector/dereference/dereference.ts +65 -0
  63. package/src/utils/jsonBreakDetector/jsonBreakDetector.spec.ts +3041 -0
  64. package/src/utils/jsonBreakDetector/jsonBreakDetector.ts +36 -0
  65. package/src/utils/jsonBreakDetector/types.ts +29 -0
  66. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dereference_1 = require("./dereference");
4
+ describe('dereferenceLocal', () => {
5
+ describe('JSON Schema Draft 7', () => {
6
+ it('dereferences a top-level $ref to a definition', () => {
7
+ const schema = {
8
+ $schema: 'http://json-schema.org/draft-07/schema#',
9
+ $ref: '#/definitions/Person',
10
+ definitions: {
11
+ Person: {
12
+ type: 'object',
13
+ properties: {
14
+ name: { type: 'string' },
15
+ },
16
+ required: ['name'],
17
+ },
18
+ },
19
+ };
20
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
21
+ $schema: 'http://json-schema.org/draft-07/schema#',
22
+ definitions: {
23
+ Person: {
24
+ type: 'object',
25
+ properties: {
26
+ name: { type: 'string' },
27
+ },
28
+ required: ['name'],
29
+ },
30
+ },
31
+ type: 'object',
32
+ properties: {
33
+ name: { type: 'string' },
34
+ },
35
+ required: ['name'],
36
+ });
37
+ });
38
+ it('dereferences nested $refs in properties', () => {
39
+ const schema = {
40
+ $schema: 'http://json-schema.org/draft-07/schema#',
41
+ type: 'object',
42
+ properties: {
43
+ address: { $ref: '#/definitions/Address' },
44
+ },
45
+ definitions: {
46
+ Address: {
47
+ type: 'object',
48
+ properties: {
49
+ city: { $ref: '#/definitions/City' },
50
+ },
51
+ },
52
+ City: {
53
+ type: 'string',
54
+ minLength: 1,
55
+ },
56
+ },
57
+ };
58
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
59
+ $schema: 'http://json-schema.org/draft-07/schema#',
60
+ type: 'object',
61
+ properties: {
62
+ address: {
63
+ type: 'object',
64
+ properties: {
65
+ city: {
66
+ type: 'string',
67
+ minLength: 1,
68
+ },
69
+ },
70
+ },
71
+ },
72
+ definitions: {
73
+ Address: {
74
+ type: 'object',
75
+ properties: {
76
+ city: { $ref: '#/definitions/City' },
77
+ },
78
+ },
79
+ City: {
80
+ type: 'string',
81
+ minLength: 1,
82
+ },
83
+ },
84
+ });
85
+ });
86
+ it('dereferences $refs inside combinators', () => {
87
+ const schema = {
88
+ $schema: 'http://json-schema.org/draft-07/schema#',
89
+ oneOf: [{ $ref: '#/definitions/StringValue' }, { $ref: '#/definitions/NumberValue' }],
90
+ definitions: {
91
+ StringValue: { type: 'string' },
92
+ NumberValue: { type: 'number' },
93
+ },
94
+ };
95
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
96
+ $schema: 'http://json-schema.org/draft-07/schema#',
97
+ oneOf: [{ type: 'string' }, { type: 'number' }],
98
+ definitions: {
99
+ StringValue: { type: 'string' },
100
+ NumberValue: { type: 'number' },
101
+ },
102
+ });
103
+ });
104
+ it('dereferences chained $refs', () => {
105
+ const schema = {
106
+ $schema: 'http://json-schema.org/draft-07/schema#',
107
+ $ref: '#/definitions/Outer',
108
+ definitions: {
109
+ Outer: { $ref: '#/definitions/Inner' },
110
+ Inner: {
111
+ type: 'boolean',
112
+ },
113
+ },
114
+ };
115
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
116
+ $schema: 'http://json-schema.org/draft-07/schema#',
117
+ definitions: {
118
+ Outer: { $ref: '#/definitions/Inner' },
119
+ Inner: {
120
+ type: 'boolean',
121
+ },
122
+ },
123
+ type: 'boolean',
124
+ });
125
+ });
126
+ it('merges sibling properties alongside a $ref', () => {
127
+ const schema = {
128
+ $schema: 'http://json-schema.org/draft-07/schema#',
129
+ properties: {
130
+ title: {
131
+ $ref: '#/definitions/NonEmptyString',
132
+ description: 'A human-readable title',
133
+ },
134
+ },
135
+ definitions: {
136
+ NonEmptyString: {
137
+ type: 'string',
138
+ minLength: 1,
139
+ },
140
+ },
141
+ };
142
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
143
+ $schema: 'http://json-schema.org/draft-07/schema#',
144
+ properties: {
145
+ title: {
146
+ type: 'string',
147
+ minLength: 1,
148
+ description: 'A human-readable title',
149
+ },
150
+ },
151
+ definitions: {
152
+ NonEmptyString: {
153
+ type: 'string',
154
+ minLength: 1,
155
+ },
156
+ },
157
+ });
158
+ });
159
+ it('resolves JSON pointer escaped property names', () => {
160
+ const schema = {
161
+ $schema: 'http://json-schema.org/draft-07/schema#',
162
+ properties: {
163
+ 'foo/bar': { $ref: '#/definitions/foo~1bar' },
164
+ },
165
+ definitions: {
166
+ 'foo/bar': {
167
+ type: 'string',
168
+ },
169
+ },
170
+ };
171
+ expect((0, dereference_1.dereferenceLocal)(schema)).toEqual({
172
+ $schema: 'http://json-schema.org/draft-07/schema#',
173
+ properties: {
174
+ 'foo/bar': {
175
+ type: 'string',
176
+ },
177
+ },
178
+ definitions: {
179
+ 'foo/bar': {
180
+ type: 'string',
181
+ },
182
+ },
183
+ });
184
+ });
185
+ it('does not infinitely recurse on circular definitions', () => {
186
+ const schema = {
187
+ $schema: 'http://json-schema.org/draft-07/schema#',
188
+ $ref: '#/definitions/Node',
189
+ definitions: {
190
+ Node: {
191
+ type: 'object',
192
+ properties: {
193
+ child: { $ref: '#/definitions/Node' },
194
+ },
195
+ },
196
+ },
197
+ };
198
+ const result = (0, dereference_1.dereferenceLocal)(schema);
199
+ expect(result.type).toBe('object');
200
+ expect(result.properties.child).toEqual({
201
+ type: 'object',
202
+ properties: {
203
+ child: { $ref: '#/definitions/Node' },
204
+ },
205
+ });
206
+ });
207
+ it('throws when a reference is not internal', () => {
208
+ const schema = {
209
+ $schema: 'http://json-schema.org/draft-07/schema#',
210
+ $ref: 'https://example.com/schema.json',
211
+ };
212
+ expect(() => (0, dereference_1.dereferenceLocal)(schema)).toThrow('Only internal references starting with "#/" are supported. Received: "https://example.com/schema.json"');
213
+ });
214
+ it('throws when a JSON pointer cannot be resolved', () => {
215
+ const schema = {
216
+ $schema: 'http://json-schema.org/draft-07/schema#',
217
+ properties: {
218
+ missing: { $ref: '#/definitions/DoesNotExist' },
219
+ },
220
+ };
221
+ expect(() => (0, dereference_1.dereferenceLocal)(schema)).toThrow('Could not resolve JSON pointer reference: "#/definitions/DoesNotExist" at segment "definitions"');
222
+ });
223
+ });
224
+ });
225
+ //# sourceMappingURL=dereference.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dereference.spec.js","sourceRoot":"","sources":["../../../../src/utils/jsonBreakDetector/dereference/dereference.spec.ts"],"names":[],"mappings":";;AAAA,+CAAiD;AAEjD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,MAAM,GAAG;gBACb,OAAO,EAAE,yCAAyC;gBAClD,IAAI,EAAE,sBAAsB;gBAC5B,WAAW,EAAE;oBACX,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,IAAI,EAAE,EAAE,IAAI,E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AAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,MAAM,GAAG;gBACb,OAAO,EAAE,yCAAyC;gBAClD,UAAU,EAAE;oBACV,OAAO,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE;iBAChD;aACF,CAAC;YAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,8BAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAC5C,iGAAiG,CAClG,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { JSONSchema } from '@squiz/json-schema-library';
2
+ import { JsonBreak } from './types';
3
+ /**
4
+ * Detects breaking schema changes between beforeSchema and afterSchema.
5
+ * Returns each break with a dotted path location, e.g. `subtitle`, `image.width`, `tags[]`,
6
+ * `tags.{contains}`, and a message identifying the kind of break.
7
+ */
8
+ export default function jsonBreakDetector(beforeSchema: JSONSchema, afterSchema: JSONSchema): JsonBreak[];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = jsonBreakDetector;
4
+ const dereference_1 = require("./dereference/dereference");
5
+ const compareSubschemas_1 = require("./compareSubschemas");
6
+ const types_1 = require("./types");
7
+ /**
8
+ * Detects breaking schema changes between beforeSchema and afterSchema.
9
+ * Returns each break with a dotted path location, e.g. `subtitle`, `image.width`, `tags[]`,
10
+ * `tags.{contains}`, and a message identifying the kind of break.
11
+ */
12
+ function jsonBreakDetector(beforeSchema, afterSchema) {
13
+ const breaks = [];
14
+ // Unfold $refs so inline schemas and $defs references can be compared on equal footing.
15
+ let processedBeforeSchema;
16
+ try {
17
+ processedBeforeSchema = (0, dereference_1.dereferenceLocal)(beforeSchema);
18
+ }
19
+ catch (error) {
20
+ (0, types_1.pushBreak)(breaks, '', error instanceof Error ? error.message : 'Could not dereference schema');
21
+ }
22
+ let processedAfterSchema;
23
+ try {
24
+ processedAfterSchema = (0, dereference_1.dereferenceLocal)(afterSchema);
25
+ }
26
+ catch (error) {
27
+ (0, types_1.pushBreak)(breaks, '', error instanceof Error ? error.message : 'Could not dereference schema');
28
+ }
29
+ if (processedBeforeSchema === undefined || processedAfterSchema === undefined) {
30
+ return breaks;
31
+ }
32
+ (0, compareSubschemas_1.compareSubschemas)(processedBeforeSchema, processedAfterSchema, '', breaks);
33
+ return breaks;
34
+ }
35
+ //# sourceMappingURL=jsonBreakDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonBreakDetector.js","sourceRoot":"","sources":["../../../src/utils/jsonBreakDetector/jsonBreakDetector.ts"],"names":[],"mappings":";;AAWA,oCAwBC;AAjCD,2DAA6D;AAC7D,2DAAwD;AACxD,mCAA+C;AAE/C;;;;GAIG;AACH,SAAwB,iBAAiB,CAAC,YAAwB,EAAE,WAAuB;IACzF,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,wFAAwF;IACxF,IAAI,qBAA6C,CAAC;IAClD,IAAI,CAAC;QACH,qBAAqB,GAAG,IAAA,8BAAgB,EAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,iBAAS,EAAC,MAAM,EAAE,EAAE,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC;IACjG,CAAC;IAED,IAAI,oBAA4C,CAAC;IACjD,IAAI,CAAC;QACH,oBAAoB,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,iBAAS,EAAC,MAAM,EAAE,EAAE,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC;IACjG,CAAC;IAED,IAAI,qBAAqB,KAAK,SAAS,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC9E,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAA,qCAAiB,EAAC,qBAAqB,EAAE,oBAAoB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC;AAChB,CAAC"}