@modulify/validator 0.2.1 → 0.3.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.
- package/CHANGELOG.md +27 -1
- package/README.md +12 -2
- package/dist/assert-BDOtHdLx.cjs +289 -0
- package/dist/assert-CzMg5aO7.mjs +206 -0
- package/dist/assert.cjs +7 -65
- package/dist/assert.d.cts +37 -0
- package/dist/assert.d.mts +37 -0
- package/dist/assert.d.ts +24 -3
- package/dist/assert.mjs +2 -66
- package/dist/assertions-DPYCHREw.mjs +297 -0
- package/dist/assertions-nfOKqcjs.cjs +476 -0
- package/dist/assertions.cjs +34 -206
- package/dist/assertions.d.cts +56 -0
- package/dist/assertions.d.mts +56 -0
- package/dist/assertions.d.ts +43 -45
- package/dist/assertions.mjs +3 -207
- package/dist/checkers.d.cts +8 -0
- package/dist/checkers.d.mts +8 -0
- package/dist/checkers.d.ts +1 -1
- package/dist/combinators.cjs +303 -304
- package/dist/combinators.d.cts +16 -0
- package/dist/combinators.d.mts +16 -0
- package/dist/combinators.d.ts +15 -16
- package/dist/combinators.mjs +304 -315
- package/dist/constraints.d.cts +4 -0
- package/dist/constraints.d.mts +4 -0
- package/dist/constraints.d.ts +2 -2
- package/dist/extractors.d.cts +2 -0
- package/dist/extractors.d.mts +2 -0
- package/dist/index.cjs +210 -213
- package/dist/index.d.cts +12 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +165 -218
- package/dist/json-schema.cjs +364 -489
- package/dist/json-schema.d.cts +14 -0
- package/dist/json-schema.d.mts +14 -0
- package/dist/json-schema.d.ts +3 -3
- package/dist/json-schema.mjs +365 -492
- package/dist/metadata.cjs +6 -7
- package/dist/metadata.d.cts +8 -0
- package/dist/metadata.d.mts +8 -0
- package/dist/metadata.d.ts +2 -2
- package/dist/metadata.mjs +2 -8
- package/dist/predicates.cjs +98 -41
- package/dist/predicates.d.cts +77 -0
- package/dist/predicates.d.mts +77 -0
- package/dist/predicates.d.ts +25 -4
- package/dist/predicates.mjs +92 -66
- package/dist/types/index.d.cts +984 -0
- package/dist/types/index.d.mts +984 -0
- package/dist/types/index.d.ts +984 -0
- package/dist/types/json-schema.d.cts +75 -0
- package/dist/types/json-schema.d.mts +75 -0
- package/dist/types/json-schema.d.ts +75 -0
- package/dist/violations.d.cts +29 -0
- package/dist/violations.d.mts +29 -0
- package/dist/violations.d.ts +1 -1
- package/docs/RELEASING.md +66 -0
- package/docs/en/00-index.md +2 -0
- package/docs/en/01-shape-api.md +35 -10
- package/docs/en/02-metadata-and-introspection.md +2 -1
- package/docs/en/03-violations.md +1 -1
- package/docs/en/04-json-schema-export.md +5 -0
- package/docs/en/05-public-api.md +35 -3
- package/docs/en/06-common-recipes.md +2 -1
- package/docs/en/07-ai-reference.md +5 -2
- package/docs/en/08-violation-code-types.md +28 -2
- package/docs/en/09-migration.md +75 -0
- package/docs/ru/00-index.md +2 -0
- package/docs/ru/01-shape-api.md +35 -10
- package/docs/ru/02-metadata-and-introspection.md +2 -1
- package/docs/ru/03-violations.md +1 -1
- package/docs/ru/04-json-schema-export.md +5 -0
- package/docs/ru/05-public-api.md +35 -3
- package/docs/ru/06-common-recipes.md +2 -1
- package/docs/ru/07-ai-reference.md +5 -2
- package/docs/ru/08-violation-code-types.md +28 -2
- package/docs/ru/09-migration.md +76 -0
- package/docs/ru/README.md +10 -2
- package/package.json +63 -37
- package/types/index.d.ts +275 -115
- package/dist/metadata.cjs.js +0 -130
- package/dist/metadata.es.js +0 -131
package/dist/json-schema.mjs
CHANGED
|
@@ -1,514 +1,387 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { u as describeConstraints } from "./assert-CzMg5aO7.mjs";
|
|
2
|
+
//#region src/json-schema.ts
|
|
3
|
+
var jsonSchemaMetadataKeys = [
|
|
4
|
+
"title",
|
|
5
|
+
"description",
|
|
6
|
+
"format",
|
|
7
|
+
"default",
|
|
8
|
+
"examples",
|
|
9
|
+
"deprecated",
|
|
10
|
+
"readOnly",
|
|
11
|
+
"writeOnly"
|
|
11
12
|
];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var typeOf = (value) => Object.prototype.toString.call(value);
|
|
14
|
+
var isEmptySchema = (schema) => Object.keys(schema).length === 0;
|
|
15
|
+
var isFiniteJsonNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
16
|
+
var isJsonScalar = (value) => {
|
|
17
|
+
return value === null || typeof value === "string" || typeof value === "boolean" || isFiniteJsonNumber(value);
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var isLength = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
20
|
+
var isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
21
|
+
var isPositiveFiniteNumber = (value) => isFiniteNumber(value) && value > 0;
|
|
22
|
+
var withPath = (context, segment) => ({
|
|
23
|
+
...context,
|
|
24
|
+
path: [...context.path, segment]
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
var formatPath = (path) => path.length === 0 ? "<root>" : path.map((segment) => typeof segment === "symbol" ? segment.toString() : String(segment)).join(".");
|
|
27
|
+
var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
|
+
var setSchemaProperty = (schema, key, value) => {
|
|
29
|
+
schema[key] = value;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setSchemaProperty(schemaMetadata, key, value);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (typeof value === "string") {
|
|
55
|
-
setSchemaProperty(schemaMetadata, key, value);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return schemaMetadata;
|
|
31
|
+
var pickMetadata = (metadata) => {
|
|
32
|
+
if (!metadata) return {};
|
|
33
|
+
const schemaMetadata = {};
|
|
34
|
+
jsonSchemaMetadataKeys.forEach((key) => {
|
|
35
|
+
if (!(key in metadata)) return;
|
|
36
|
+
const value = metadata[key];
|
|
37
|
+
if (key === "examples") {
|
|
38
|
+
if (Array.isArray(value)) setSchemaProperty(schemaMetadata, "examples", [...value]);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (key === "default") {
|
|
42
|
+
setSchemaProperty(schemaMetadata, "default", value);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if ((key === "deprecated" || key === "readOnly" || key === "writeOnly") && typeof value === "boolean") {
|
|
46
|
+
setSchemaProperty(schemaMetadata, key, value);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === "string") setSchemaProperty(schemaMetadata, key, value);
|
|
50
|
+
});
|
|
51
|
+
return schemaMetadata;
|
|
59
52
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
return nextSchema;
|
|
53
|
+
var applyMetadata = (schema, metadata) => {
|
|
54
|
+
const schemaMetadata = pickMetadata(metadata);
|
|
55
|
+
const nextSchema = { ...schema };
|
|
56
|
+
jsonSchemaMetadataKeys.forEach((key) => {
|
|
57
|
+
if (!(key in schemaMetadata) || key in nextSchema) return;
|
|
58
|
+
setSchemaProperty(nextSchema, key, schemaMetadata[key]);
|
|
59
|
+
});
|
|
60
|
+
return nextSchema;
|
|
70
61
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.descriptor = descriptor;
|
|
80
|
-
this.reason = reason;
|
|
81
|
-
this.path = [...path];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const unsupported = (descriptor, context, reason) => {
|
|
85
|
-
if (context.mode === "strict") {
|
|
86
|
-
throw new JsonSchemaExportError(
|
|
87
|
-
`Cannot export ${descriptor.kind} at ${formatPath(context.path)}: ${reason}`,
|
|
88
|
-
{ descriptor, path: context.path, reason }
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
return {};
|
|
62
|
+
var JsonSchemaExportError = class extends Error {
|
|
63
|
+
constructor(message, { descriptor, path = [], reason }) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "JsonSchemaExportError";
|
|
66
|
+
this.descriptor = descriptor;
|
|
67
|
+
this.reason = reason;
|
|
68
|
+
this.path = [...path];
|
|
69
|
+
}
|
|
92
70
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
71
|
+
var unsupported = (descriptor, context, reason) => {
|
|
72
|
+
if (context.mode === "strict") throw new JsonSchemaExportError(`Cannot export ${descriptor.kind} at ${formatPath(context.path)}: ${reason}`, {
|
|
73
|
+
descriptor,
|
|
74
|
+
path: context.path,
|
|
75
|
+
reason
|
|
76
|
+
});
|
|
77
|
+
return {};
|
|
100
78
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return String(key);
|
|
79
|
+
var mergeNullable = (schema) => {
|
|
80
|
+
if (isEmptySchema(schema)) return schema;
|
|
81
|
+
return { anyOf: [schema, { type: "null" }] };
|
|
106
82
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
for (const constraint of descriptor.constraints) {
|
|
111
|
-
switch (constraint.code) {
|
|
112
|
-
case "length.exact": {
|
|
113
|
-
const exact = constraint.args[0];
|
|
114
|
-
if (!isLength(exact)) {
|
|
115
|
-
return unsupported(descriptor, context, "hasLength exact bounds must be non-negative integers");
|
|
116
|
-
}
|
|
117
|
-
setSchemaProperty(stringSchema2, "minLength", exact);
|
|
118
|
-
setSchemaProperty(stringSchema2, "maxLength", exact);
|
|
119
|
-
setSchemaProperty(arraySchema, "minItems", exact);
|
|
120
|
-
setSchemaProperty(arraySchema, "maxItems", exact);
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
case "length.min": {
|
|
124
|
-
const min = constraint.args[0];
|
|
125
|
-
if (!isLength(min)) {
|
|
126
|
-
return unsupported(descriptor, context, "hasLength minimum bounds must be non-negative integers");
|
|
127
|
-
}
|
|
128
|
-
setSchemaProperty(stringSchema2, "minLength", min);
|
|
129
|
-
setSchemaProperty(arraySchema, "minItems", min);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case "length.max": {
|
|
133
|
-
const max = constraint.args[0];
|
|
134
|
-
if (!isLength(max)) {
|
|
135
|
-
return unsupported(descriptor, context, "hasLength maximum bounds must be non-negative integers");
|
|
136
|
-
}
|
|
137
|
-
setSchemaProperty(stringSchema2, "maxLength", max);
|
|
138
|
-
setSchemaProperty(arraySchema, "maxItems", max);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
case "length.range": {
|
|
142
|
-
const range = constraint.args[0];
|
|
143
|
-
if (!Array.isArray(range) || range.length !== 2 || !isLength(range[0]) || !isLength(range[1])) {
|
|
144
|
-
return unsupported(descriptor, context, "hasLength ranges must be `[min, max]` integer tuples");
|
|
145
|
-
}
|
|
146
|
-
setSchemaProperty(stringSchema2, "minLength", range[0]);
|
|
147
|
-
setSchemaProperty(stringSchema2, "maxLength", range[1]);
|
|
148
|
-
setSchemaProperty(arraySchema, "minItems", range[0]);
|
|
149
|
-
setSchemaProperty(arraySchema, "maxItems", range[1]);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
default:
|
|
153
|
-
return unsupported(descriptor, context, `unsupported hasLength constraint "${constraint.code}"`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
anyOf: [stringSchema2, arraySchema]
|
|
158
|
-
};
|
|
83
|
+
var toPropertyName = (key, descriptor, context) => {
|
|
84
|
+
if (typeof key === "symbol") return unsupported(descriptor, context, "symbol keys cannot be represented in JSON Schema");
|
|
85
|
+
return String(key);
|
|
159
86
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
87
|
+
var lengthSchema = (descriptor, context) => {
|
|
88
|
+
const stringSchema = { type: "string" };
|
|
89
|
+
const arraySchema = { type: "array" };
|
|
90
|
+
for (const constraint of descriptor.constraints) switch (constraint.code) {
|
|
91
|
+
case "length.exact": {
|
|
92
|
+
const exact = constraint.args[0];
|
|
93
|
+
if (!isLength(exact)) return unsupported(descriptor, context, "hasLength exact bounds must be non-negative integers");
|
|
94
|
+
setSchemaProperty(stringSchema, "minLength", exact);
|
|
95
|
+
setSchemaProperty(stringSchema, "maxLength", exact);
|
|
96
|
+
setSchemaProperty(arraySchema, "minItems", exact);
|
|
97
|
+
setSchemaProperty(arraySchema, "maxItems", exact);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "length.min": {
|
|
101
|
+
const min = constraint.args[0];
|
|
102
|
+
if (!isLength(min)) return unsupported(descriptor, context, "hasLength minimum bounds must be non-negative integers");
|
|
103
|
+
setSchemaProperty(stringSchema, "minLength", min);
|
|
104
|
+
setSchemaProperty(arraySchema, "minItems", min);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "length.max": {
|
|
108
|
+
const max = constraint.args[0];
|
|
109
|
+
if (!isLength(max)) return unsupported(descriptor, context, "hasLength maximum bounds must be non-negative integers");
|
|
110
|
+
setSchemaProperty(stringSchema, "maxLength", max);
|
|
111
|
+
setSchemaProperty(arraySchema, "maxItems", max);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "length.range": {
|
|
115
|
+
const range = constraint.args[0];
|
|
116
|
+
if (!Array.isArray(range) || range.length !== 2 || !isLength(range[0]) || !isLength(range[1])) return unsupported(descriptor, context, "hasLength ranges must be `[min, max]` integer tuples");
|
|
117
|
+
setSchemaProperty(stringSchema, "minLength", range[0]);
|
|
118
|
+
setSchemaProperty(stringSchema, "maxLength", range[1]);
|
|
119
|
+
setSchemaProperty(arraySchema, "minItems", range[0]);
|
|
120
|
+
setSchemaProperty(arraySchema, "maxItems", range[1]);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
default: return unsupported(descriptor, context, `unsupported hasLength constraint "${constraint.code}"`);
|
|
124
|
+
}
|
|
125
|
+
return { anyOf: [stringSchema, arraySchema] };
|
|
170
126
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
descriptor,
|
|
176
|
-
context,
|
|
177
|
-
"oneOf(...) supports only arrays of JSON scalar values"
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
return { enum: [...new Set(values)] };
|
|
127
|
+
var exactSchema = (descriptor, context) => {
|
|
128
|
+
const [value] = descriptor.args ?? [];
|
|
129
|
+
if (!isJsonScalar(value)) return unsupported(descriptor, context, `exact(...) supports only JSON scalar values, got ${typeOf(value)}`);
|
|
130
|
+
return { const: value };
|
|
181
131
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return unsupported(descriptor, context, "hasPattern(...) requires a RegExp pattern");
|
|
187
|
-
}
|
|
188
|
-
if (pattern.flags !== "") {
|
|
189
|
-
return unsupported(descriptor, context, "hasPattern(...) supports only flagless regular expressions in JSON Schema");
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
type: "string",
|
|
193
|
-
pattern: pattern.source
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
if (descriptor.name === "startsWith") {
|
|
197
|
-
const [prefix] = descriptor.constraints[0]?.args ?? [];
|
|
198
|
-
if (typeof prefix !== "string") {
|
|
199
|
-
return unsupported(descriptor, context, "startsWith(...) requires a string prefix");
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
type: "string",
|
|
203
|
-
pattern: `^${escapeRegExp(prefix)}`
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const [suffix] = descriptor.constraints[0]?.args ?? [];
|
|
207
|
-
if (typeof suffix !== "string") {
|
|
208
|
-
return unsupported(descriptor, context, "endsWith(...) requires a string suffix");
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
type: "string",
|
|
212
|
-
pattern: `${escapeRegExp(suffix)}$`
|
|
213
|
-
};
|
|
132
|
+
var enumSchema = (descriptor, context) => {
|
|
133
|
+
const [values] = descriptor.args ?? [];
|
|
134
|
+
if (!Array.isArray(values) || values.some((value) => !isJsonScalar(value))) return unsupported(descriptor, context, "oneOf(...) supports only arrays of JSON scalar values");
|
|
135
|
+
return { enum: [...new Set(values)] };
|
|
214
136
|
};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
setSchemaProperty(schema, "minimum", min);
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
case "number.max": {
|
|
244
|
-
const max = constraint.args[0];
|
|
245
|
-
if (!isFiniteNumber(max)) {
|
|
246
|
-
return unsupported(descriptor, context, "hasValue maximum bounds must be finite numbers");
|
|
247
|
-
}
|
|
248
|
-
setSchemaProperty(schema, "maximum", max);
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
case "number.range": {
|
|
252
|
-
const range = constraint.args[0];
|
|
253
|
-
if (!Array.isArray(range) || range.length !== 2 || !isFiniteNumber(range[0]) || !isFiniteNumber(range[1])) {
|
|
254
|
-
return unsupported(descriptor, context, "hasValue ranges must be `[min, max]` finite number tuples");
|
|
255
|
-
}
|
|
256
|
-
setSchemaProperty(schema, "minimum", range[0]);
|
|
257
|
-
setSchemaProperty(schema, "maximum", range[1]);
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
default:
|
|
261
|
-
return unsupported(descriptor, context, `unsupported number assertion "${descriptor.name}"`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return schema;
|
|
137
|
+
var stringSchema = (descriptor, context) => {
|
|
138
|
+
if (descriptor.name === "hasPattern") {
|
|
139
|
+
const [pattern] = descriptor.constraints[0]?.args ?? [];
|
|
140
|
+
if (!(pattern instanceof RegExp)) return unsupported(descriptor, context, "hasPattern(...) requires a RegExp pattern");
|
|
141
|
+
if (pattern.flags !== "") return unsupported(descriptor, context, "hasPattern(...) supports only flagless regular expressions in JSON Schema");
|
|
142
|
+
return {
|
|
143
|
+
type: "string",
|
|
144
|
+
pattern: pattern.source
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (descriptor.name === "startsWith") {
|
|
148
|
+
const [prefix] = descriptor.constraints[0]?.args ?? [];
|
|
149
|
+
if (typeof prefix !== "string") return unsupported(descriptor, context, "startsWith(...) requires a string prefix");
|
|
150
|
+
return {
|
|
151
|
+
type: "string",
|
|
152
|
+
pattern: `^${escapeRegExp(prefix)}`
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const [suffix] = descriptor.constraints[0]?.args ?? [];
|
|
156
|
+
if (typeof suffix !== "string") return unsupported(descriptor, context, "endsWith(...) requires a string suffix");
|
|
157
|
+
return {
|
|
158
|
+
type: "string",
|
|
159
|
+
pattern: `${escapeRegExp(suffix)}$`
|
|
160
|
+
};
|
|
265
161
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
162
|
+
var numberSchema = (descriptor, context) => {
|
|
163
|
+
const schema = { type: "number" };
|
|
164
|
+
if (descriptor.name === "isInteger") {
|
|
165
|
+
setSchemaProperty(schema, "type", "integer");
|
|
166
|
+
return schema;
|
|
167
|
+
}
|
|
168
|
+
if (descriptor.name === "isSafeInteger") {
|
|
169
|
+
setSchemaProperty(schema, "type", "integer");
|
|
170
|
+
setSchemaProperty(schema, "minimum", Number.MIN_SAFE_INTEGER);
|
|
171
|
+
setSchemaProperty(schema, "maximum", Number.MAX_SAFE_INTEGER);
|
|
172
|
+
return schema;
|
|
173
|
+
}
|
|
174
|
+
if (descriptor.name === "multipleOf") {
|
|
175
|
+
const [step] = descriptor.constraints[0]?.args ?? [];
|
|
176
|
+
if (!isPositiveFiniteNumber(step)) return unsupported(descriptor, context, "multipleOf(...) requires a positive finite divisor");
|
|
177
|
+
setSchemaProperty(schema, "multipleOf", step);
|
|
178
|
+
return schema;
|
|
179
|
+
}
|
|
180
|
+
for (const constraint of descriptor.constraints) switch (constraint.code) {
|
|
181
|
+
case "number.exact": {
|
|
182
|
+
const exact = constraint.args[0];
|
|
183
|
+
if (!isFiniteNumber(exact)) return unsupported(descriptor, context, "hasValue exact bounds must be finite numbers");
|
|
184
|
+
setSchemaProperty(schema, "const", exact);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case "number.min": {
|
|
188
|
+
const min = constraint.args[0];
|
|
189
|
+
if (!isFiniteNumber(min)) return unsupported(descriptor, context, "hasValue minimum bounds must be finite numbers");
|
|
190
|
+
setSchemaProperty(schema, "minimum", min);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "number.max": {
|
|
194
|
+
const max = constraint.args[0];
|
|
195
|
+
if (!isFiniteNumber(max)) return unsupported(descriptor, context, "hasValue maximum bounds must be finite numbers");
|
|
196
|
+
setSchemaProperty(schema, "maximum", max);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case "number.range": {
|
|
200
|
+
const range = constraint.args[0];
|
|
201
|
+
if (!Array.isArray(range) || range.length !== 2 || !isFiniteNumber(range[0]) || !isFiniteNumber(range[1])) return unsupported(descriptor, context, "hasValue ranges must be `[min, max]` finite number tuples");
|
|
202
|
+
setSchemaProperty(schema, "minimum", range[0]);
|
|
203
|
+
setSchemaProperty(schema, "maximum", range[1]);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
default: return unsupported(descriptor, context, `unsupported number assertion "${descriptor.name}"`);
|
|
207
|
+
}
|
|
208
|
+
return schema;
|
|
277
209
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
case "shape":
|
|
288
|
-
case "discriminatedUnion":
|
|
289
|
-
case "validator":
|
|
290
|
-
return false;
|
|
291
|
-
case "allOf":
|
|
292
|
-
return descriptor.constraints.every(acceptsUndefined);
|
|
293
|
-
case "union":
|
|
294
|
-
return descriptor.branches.some(acceptsUndefined);
|
|
295
|
-
case "assertion":
|
|
296
|
-
return assertionAcceptsUndefined(descriptor);
|
|
297
|
-
default:
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
210
|
+
var assertionAcceptsUndefined = (descriptor) => {
|
|
211
|
+
switch (descriptor.name) {
|
|
212
|
+
case "exact": return descriptor.args?.[0] === void 0;
|
|
213
|
+
case "oneOf": {
|
|
214
|
+
const [values] = descriptor.args ?? [];
|
|
215
|
+
return Array.isArray(values) && values.includes(void 0);
|
|
216
|
+
}
|
|
217
|
+
default: return false;
|
|
218
|
+
}
|
|
300
219
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
220
|
+
var acceptsUndefined = (descriptor) => {
|
|
221
|
+
switch (descriptor.kind) {
|
|
222
|
+
case "optional":
|
|
223
|
+
case "nullish": return true;
|
|
224
|
+
case "nullable":
|
|
225
|
+
case "each":
|
|
226
|
+
case "tuple":
|
|
227
|
+
case "record":
|
|
228
|
+
case "shape":
|
|
229
|
+
case "discriminatedUnion":
|
|
230
|
+
case "validator": return false;
|
|
231
|
+
case "allOf": return descriptor.constraints.every(acceptsUndefined);
|
|
232
|
+
case "union": return descriptor.branches.some(acceptsUndefined);
|
|
233
|
+
case "assertion": return assertionAcceptsUndefined(descriptor);
|
|
234
|
+
default: return false;
|
|
235
|
+
}
|
|
314
236
|
};
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
case "isBigInt":
|
|
324
|
-
return unsupported(descriptor, context, "bigint values cannot be represented in JSON Schema");
|
|
325
|
-
case "isBlob":
|
|
326
|
-
return unsupported(descriptor, context, "Blob instances do not have a stable JSON Schema representation");
|
|
327
|
-
case "isNull":
|
|
328
|
-
return { type: "null" };
|
|
329
|
-
case "isEmail":
|
|
330
|
-
return {
|
|
331
|
-
type: "string",
|
|
332
|
-
format: "email"
|
|
333
|
-
};
|
|
334
|
-
case "hasPattern":
|
|
335
|
-
case "startsWith":
|
|
336
|
-
case "endsWith":
|
|
337
|
-
return stringSchema(descriptor, context);
|
|
338
|
-
case "isFile":
|
|
339
|
-
return unsupported(descriptor, context, "File instances do not have a stable JSON Schema representation");
|
|
340
|
-
case "isFunction":
|
|
341
|
-
return unsupported(descriptor, context, "functions cannot be represented in JSON Schema");
|
|
342
|
-
case "isDefined":
|
|
343
|
-
return {};
|
|
344
|
-
case "isMap":
|
|
345
|
-
return unsupported(descriptor, context, "Map instances do not have a stable JSON Schema representation");
|
|
346
|
-
case "isNaN":
|
|
347
|
-
return unsupported(descriptor, context, "NaN cannot be represented in JSON Schema");
|
|
348
|
-
case "hasValue":
|
|
349
|
-
case "multipleOf":
|
|
350
|
-
return numberSchema(descriptor, context);
|
|
351
|
-
case "exact":
|
|
352
|
-
return exactSchema(descriptor, context);
|
|
353
|
-
case "hasSize":
|
|
354
|
-
return unsupported(descriptor, context, "Map and Set sizes do not have a stable JSON Schema representation");
|
|
355
|
-
case "oneOf":
|
|
356
|
-
return enumSchema(descriptor, context);
|
|
357
|
-
case "hasLength":
|
|
358
|
-
return lengthSchema(descriptor, context);
|
|
359
|
-
case "isDate":
|
|
360
|
-
return unsupported(descriptor, context, "Date instances do not have a stable JSON Schema representation");
|
|
361
|
-
case "isSet":
|
|
362
|
-
return unsupported(descriptor, context, "Set instances do not have a stable JSON Schema representation");
|
|
363
|
-
case "isSymbol":
|
|
364
|
-
return unsupported(descriptor, context, "symbols cannot be represented in JSON Schema");
|
|
365
|
-
default:
|
|
366
|
-
return unsupported(descriptor, context, `unsupported assertion "${descriptor.name}"`);
|
|
367
|
-
}
|
|
237
|
+
var exportShapeRules = (descriptor, context) => {
|
|
238
|
+
if (descriptor.rules.length === 0 || context.mode === "bestEffort") return;
|
|
239
|
+
const [rule] = descriptor.rules;
|
|
240
|
+
throw new JsonSchemaExportError(`Cannot export shape at ${formatPath([...context.path, "rules"])}: object-level rule "${rule.kind}" has no JSON Schema mapping`, {
|
|
241
|
+
descriptor,
|
|
242
|
+
path: [...context.path, "rules"],
|
|
243
|
+
reason: `object-level rule "${rule.kind}" has no JSON Schema mapping`
|
|
244
|
+
});
|
|
368
245
|
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
246
|
+
var exportAssertion = (descriptor, context) => {
|
|
247
|
+
switch (descriptor.name) {
|
|
248
|
+
case "isString": return { type: "string" };
|
|
249
|
+
case "isNumber": return { type: "number" };
|
|
250
|
+
case "isFiniteNumber": return { type: "number" };
|
|
251
|
+
case "isInteger":
|
|
252
|
+
case "isSafeInteger": return numberSchema(descriptor, context);
|
|
253
|
+
case "isBoolean": return { type: "boolean" };
|
|
254
|
+
case "isBigInt": return unsupported(descriptor, context, "bigint values cannot be represented in JSON Schema");
|
|
255
|
+
case "isBlob": return unsupported(descriptor, context, "Blob instances do not have a stable JSON Schema representation");
|
|
256
|
+
case "isNull": return { type: "null" };
|
|
257
|
+
case "isEmail": return {
|
|
258
|
+
type: "string",
|
|
259
|
+
format: "email"
|
|
260
|
+
};
|
|
261
|
+
case "hasPattern":
|
|
262
|
+
case "startsWith":
|
|
263
|
+
case "endsWith": return stringSchema(descriptor, context);
|
|
264
|
+
case "isFile": return unsupported(descriptor, context, "File instances do not have a stable JSON Schema representation");
|
|
265
|
+
case "isFunction": return unsupported(descriptor, context, "functions cannot be represented in JSON Schema");
|
|
266
|
+
case "isDefined": return {};
|
|
267
|
+
case "isMap": return unsupported(descriptor, context, "Map instances do not have a stable JSON Schema representation");
|
|
268
|
+
case "isNaN": return unsupported(descriptor, context, "NaN cannot be represented in JSON Schema");
|
|
269
|
+
case "hasValue":
|
|
270
|
+
case "multipleOf": return numberSchema(descriptor, context);
|
|
271
|
+
case "exact": return exactSchema(descriptor, context);
|
|
272
|
+
case "hasSize": return unsupported(descriptor, context, "Map and Set sizes do not have a stable JSON Schema representation");
|
|
273
|
+
case "oneOf": return enumSchema(descriptor, context);
|
|
274
|
+
case "hasLength": return lengthSchema(descriptor, context);
|
|
275
|
+
case "isDate": return unsupported(descriptor, context, "Date instances do not have a stable JSON Schema representation");
|
|
276
|
+
case "isValidDate": return unsupported(descriptor, context, "Date instances do not have a stable JSON Schema representation");
|
|
277
|
+
case "isError": return unsupported(descriptor, context, "Error instances do not have a stable JSON Schema representation");
|
|
278
|
+
case "isPromiseLike": return unsupported(descriptor, context, "promise-like values do not have a stable JSON Schema representation");
|
|
279
|
+
case "isRegExp": return unsupported(descriptor, context, "regular expressions do not have a stable JSON Schema representation");
|
|
280
|
+
case "isSet": return unsupported(descriptor, context, "Set instances do not have a stable JSON Schema representation");
|
|
281
|
+
case "isSymbol": return unsupported(descriptor, context, "symbols cannot be represented in JSON Schema");
|
|
282
|
+
default: return unsupported(descriptor, context, `unsupported assertion "${descriptor.name}"`);
|
|
283
|
+
}
|
|
396
284
|
};
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
};
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
case "optional": {
|
|
415
|
-
const wrapperDescriptor = descriptor;
|
|
416
|
-
schema = exportDescriptor(wrapperDescriptor.child, withPath(context, "optional"));
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
case "nullable":
|
|
420
|
-
case "nullish": {
|
|
421
|
-
const wrapperDescriptor = descriptor;
|
|
422
|
-
schema = mergeNullable(exportDescriptor(wrapperDescriptor.child, withPath(context, descriptor.kind)));
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
case "each": {
|
|
426
|
-
const eachDescriptor = descriptor;
|
|
427
|
-
schema = {
|
|
428
|
-
type: "array",
|
|
429
|
-
items: exportDescriptor(eachDescriptor.item, withPath(context, "items"))
|
|
430
|
-
};
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
case "tuple": {
|
|
434
|
-
const tupleDescriptor = descriptor;
|
|
435
|
-
schema = {
|
|
436
|
-
type: "array",
|
|
437
|
-
prefixItems: tupleDescriptor.items.map((item, index) => exportDescriptor(item, withPath(context, index))),
|
|
438
|
-
minItems: tupleDescriptor.items.length,
|
|
439
|
-
maxItems: tupleDescriptor.items.length
|
|
440
|
-
};
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
case "union": {
|
|
444
|
-
const unionDescriptor = descriptor;
|
|
445
|
-
schema = {
|
|
446
|
-
anyOf: unionDescriptor.branches.map((branch, index) => exportDescriptor(branch, withPath(context, index)))
|
|
447
|
-
};
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case "record": {
|
|
451
|
-
const recordDescriptor = descriptor;
|
|
452
|
-
schema = {
|
|
453
|
-
type: "object",
|
|
454
|
-
additionalProperties: exportDescriptor(recordDescriptor.values, withPath(context, "additionalProperties"))
|
|
455
|
-
};
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
case "shape": {
|
|
459
|
-
const shapeDescriptor = descriptor;
|
|
460
|
-
const fields = shapeDescriptor.fields;
|
|
461
|
-
const rules = shapeDescriptor.rules;
|
|
462
|
-
exportShapeRules(shapeDescriptor, context);
|
|
463
|
-
const properties = {};
|
|
464
|
-
const required = [];
|
|
465
|
-
Reflect.ownKeys(fields).forEach((key) => {
|
|
466
|
-
const childContext = withPath(context, key);
|
|
467
|
-
const propertyName = toPropertyName(key, shapeDescriptor, childContext);
|
|
468
|
-
if (typeof propertyName !== "string") {
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
const child = fields[key];
|
|
472
|
-
properties[propertyName] = exportDescriptor(child, childContext);
|
|
473
|
-
if (!acceptsUndefined(child)) {
|
|
474
|
-
required.push(propertyName);
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
const shapeSchema = {
|
|
478
|
-
type: "object",
|
|
479
|
-
properties,
|
|
480
|
-
additionalProperties: shapeDescriptor.unknownKeys === "strict" ? false : true
|
|
481
|
-
};
|
|
482
|
-
if (required.length > 0) {
|
|
483
|
-
setSchemaProperty(shapeSchema, "required", required);
|
|
484
|
-
}
|
|
485
|
-
schema = shapeSchema;
|
|
486
|
-
if (rules.length > 0 && context.mode === "bestEffort") {
|
|
487
|
-
schema = exportRulesAsComment(rules, schema);
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
case "discriminatedUnion":
|
|
492
|
-
schema = exportDiscriminatedUnion(descriptor, context);
|
|
493
|
-
break;
|
|
494
|
-
case "validator":
|
|
495
|
-
schema = unsupported(descriptor, context, "custom validators need a supported public descriptor");
|
|
496
|
-
break;
|
|
497
|
-
default:
|
|
498
|
-
schema = unsupported(descriptor, context, `unsupported descriptor kind "${descriptor.kind}"`);
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
return applyMetadata(schema, descriptor.metadata);
|
|
285
|
+
var exportDiscriminatedUnion = (descriptor, context) => {
|
|
286
|
+
if (typeof descriptor.key === "symbol") return unsupported(descriptor, context, "symbol discriminators cannot be represented in JSON Schema");
|
|
287
|
+
const key = String(descriptor.key);
|
|
288
|
+
const variants = descriptor.variants;
|
|
289
|
+
return { oneOf: Reflect.ownKeys(variants).map((variantKey) => {
|
|
290
|
+
if (typeof variantKey === "symbol") return unsupported(descriptor, withPath(context, variantKey), "symbol discriminator values cannot be represented in JSON Schema");
|
|
291
|
+
const variant = variants[variantKey];
|
|
292
|
+
const branch = exportDescriptor(variant, withPath(context, variantKey));
|
|
293
|
+
return { allOf: [{
|
|
294
|
+
type: "object",
|
|
295
|
+
properties: { [key]: { const: variantKey } },
|
|
296
|
+
required: [key]
|
|
297
|
+
}, branch] };
|
|
298
|
+
}) };
|
|
502
299
|
};
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
300
|
+
var exportRulesAsComment = (rules, schema) => ({
|
|
301
|
+
...schema,
|
|
302
|
+
$comment: `Dropped ${rules.length} object rule(s) during best-effort JSON Schema export.`
|
|
303
|
+
});
|
|
304
|
+
var exportDescriptor = (descriptor, context) => {
|
|
305
|
+
let schema;
|
|
306
|
+
switch (descriptor.kind) {
|
|
307
|
+
case "assertion":
|
|
308
|
+
schema = exportAssertion(descriptor, context);
|
|
309
|
+
break;
|
|
310
|
+
case "allOf":
|
|
311
|
+
schema = { allOf: descriptor.constraints.map((child, index) => exportDescriptor(child, withPath(context, index))) };
|
|
312
|
+
break;
|
|
313
|
+
case "optional":
|
|
314
|
+
schema = exportDescriptor(descriptor.child, withPath(context, "optional"));
|
|
315
|
+
break;
|
|
316
|
+
case "nullable":
|
|
317
|
+
case "nullish":
|
|
318
|
+
schema = mergeNullable(exportDescriptor(descriptor.child, withPath(context, descriptor.kind)));
|
|
319
|
+
break;
|
|
320
|
+
case "each":
|
|
321
|
+
schema = {
|
|
322
|
+
type: "array",
|
|
323
|
+
items: exportDescriptor(descriptor.item, withPath(context, "items"))
|
|
324
|
+
};
|
|
325
|
+
break;
|
|
326
|
+
case "tuple": {
|
|
327
|
+
const tupleDescriptor = descriptor;
|
|
328
|
+
schema = {
|
|
329
|
+
type: "array",
|
|
330
|
+
prefixItems: tupleDescriptor.items.map((item, index) => exportDescriptor(item, withPath(context, index))),
|
|
331
|
+
minItems: tupleDescriptor.items.length,
|
|
332
|
+
maxItems: tupleDescriptor.items.length
|
|
333
|
+
};
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
case "union":
|
|
337
|
+
schema = { anyOf: descriptor.branches.map((branch, index) => exportDescriptor(branch, withPath(context, index))) };
|
|
338
|
+
break;
|
|
339
|
+
case "record":
|
|
340
|
+
schema = {
|
|
341
|
+
type: "object",
|
|
342
|
+
additionalProperties: exportDescriptor(descriptor.values, withPath(context, "additionalProperties"))
|
|
343
|
+
};
|
|
344
|
+
break;
|
|
345
|
+
case "shape": {
|
|
346
|
+
const shapeDescriptor = descriptor;
|
|
347
|
+
const fields = shapeDescriptor.fields;
|
|
348
|
+
const rules = shapeDescriptor.rules;
|
|
349
|
+
exportShapeRules(shapeDescriptor, context);
|
|
350
|
+
const properties = {};
|
|
351
|
+
const required = [];
|
|
352
|
+
Reflect.ownKeys(fields).forEach((key) => {
|
|
353
|
+
const childContext = withPath(context, key);
|
|
354
|
+
const propertyName = toPropertyName(key, shapeDescriptor, childContext);
|
|
355
|
+
if (typeof propertyName !== "string") return;
|
|
356
|
+
const child = fields[key];
|
|
357
|
+
properties[propertyName] = exportDescriptor(child, childContext);
|
|
358
|
+
if (!acceptsUndefined(child)) required.push(propertyName);
|
|
359
|
+
});
|
|
360
|
+
const shapeSchema = {
|
|
361
|
+
type: "object",
|
|
362
|
+
properties,
|
|
363
|
+
additionalProperties: shapeDescriptor.unknownKeys === "strict" ? false : true
|
|
364
|
+
};
|
|
365
|
+
if (required.length > 0) setSchemaProperty(shapeSchema, "required", required);
|
|
366
|
+
schema = shapeSchema;
|
|
367
|
+
if (rules.length > 0 && context.mode === "bestEffort") schema = exportRulesAsComment(rules, schema);
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case "discriminatedUnion":
|
|
371
|
+
schema = exportDiscriminatedUnion(descriptor, context);
|
|
372
|
+
break;
|
|
373
|
+
case "validator":
|
|
374
|
+
schema = unsupported(descriptor, context, "custom validators need a supported public descriptor");
|
|
375
|
+
break;
|
|
376
|
+
default: schema = unsupported(descriptor, context, `unsupported descriptor kind "${descriptor.kind}"`);
|
|
377
|
+
}
|
|
378
|
+
return applyMetadata(schema, descriptor.metadata);
|
|
510
379
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
380
|
+
var toJsonSchema = (constraints, options = {}) => {
|
|
381
|
+
return exportDescriptor(describeConstraints(constraints), {
|
|
382
|
+
mode: options.mode ?? "bestEffort",
|
|
383
|
+
path: []
|
|
384
|
+
});
|
|
514
385
|
};
|
|
386
|
+
//#endregion
|
|
387
|
+
export { JsonSchemaExportError, toJsonSchema };
|