@temporary-name/zod 1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93 → 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc

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.
@@ -1,743 +0,0 @@
1
- import { isObject, guard, intercept, toArray } from '@temporary-name/shared';
2
- import { JsonSchemaXNativeType } from '@temporary-name/json-schema';
3
- import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@temporary-name/server/openapi';
4
- import { registry, globalRegistry } from 'zod/v4/core';
5
-
6
- class experimental_ZodSmartCoercionPlugin {
7
- init(options) {
8
- options.clientInterceptors ??= [];
9
- options.clientInterceptors.unshift((options2) => {
10
- const inputSchema = options2.procedure["~orpc"].inputSchema;
11
- if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || !("_zod" in inputSchema)) {
12
- return options2.next();
13
- }
14
- const coercedInput = this.#coerce(inputSchema, options2.input);
15
- return options2.next({ ...options2, input: coercedInput });
16
- });
17
- }
18
- #coerce(schema, value) {
19
- switch (schema._zod.def.type) {
20
- case "number": {
21
- if (typeof value === "string") {
22
- return this.#stringToNumber(value);
23
- }
24
- return value;
25
- }
26
- case "bigint": {
27
- if (typeof value === "string") {
28
- return this.#stringToBigInt(value);
29
- }
30
- return value;
31
- }
32
- case "boolean":
33
- case "success": {
34
- if (typeof value === "string") {
35
- return this.#stringToBoolean(value);
36
- }
37
- return value;
38
- }
39
- case "date": {
40
- if (typeof value === "string") {
41
- return this.#stringToDate(value);
42
- }
43
- return value;
44
- }
45
- case "literal":
46
- case "enum": {
47
- const literal = schema;
48
- if (!literal._zod.values.has(value) && typeof value === "string") {
49
- const num = this.#stringToNumber(value);
50
- if (literal._zod.values.has(num)) {
51
- return num;
52
- }
53
- const bool = this.#stringToBoolean(value);
54
- if (literal._zod.values.has(bool)) {
55
- return bool;
56
- }
57
- const bigint = this.#stringToBigInt(value);
58
- if (literal._zod.values.has(bigint)) {
59
- return bigint;
60
- }
61
- }
62
- return value;
63
- }
64
- case "array": {
65
- const array = schema;
66
- if (value === void 0) {
67
- return [];
68
- }
69
- if (Array.isArray(value)) {
70
- return value.map((v) => this.#coerce(array._zod.def.element, v));
71
- }
72
- return value;
73
- }
74
- case "tuple": {
75
- const tuple = schema;
76
- if (value === void 0) {
77
- return [];
78
- }
79
- if (Array.isArray(value)) {
80
- return value.map((v, i) => {
81
- const s = tuple._zod.def.items[i] ?? tuple._zod.def.rest;
82
- return s ? this.#coerce(s, v) : v;
83
- });
84
- }
85
- return value;
86
- }
87
- case "set": {
88
- const set = schema;
89
- if (value === void 0) {
90
- return /* @__PURE__ */ new Set();
91
- }
92
- if (Array.isArray(value)) {
93
- return new Set(value.map((v) => this.#coerce(set._zod.def.valueType, v)));
94
- }
95
- if (value instanceof Set) {
96
- return new Set(Array.from(value).map((v) => this.#coerce(set._zod.def.valueType, v)));
97
- }
98
- return value;
99
- }
100
- case "object": {
101
- const object = schema;
102
- if (value === void 0) {
103
- return {};
104
- }
105
- if (isObject(value)) {
106
- const newObj = {};
107
- const keys = /* @__PURE__ */ new Set([...Object.keys(value), ...Object.keys(object._zod.def.shape)]);
108
- for (const k of keys) {
109
- const s = object._zod.def.shape[k] ?? object._zod.def.catchall;
110
- newObj[k] = s ? this.#coerce(s, value[k]) : value[k];
111
- }
112
- return newObj;
113
- }
114
- return value;
115
- }
116
- case "record": {
117
- const record = schema;
118
- if (value === void 0) {
119
- return {};
120
- }
121
- if (isObject(value)) {
122
- const newObj = {};
123
- for (const [k, v] of Object.entries(value)) {
124
- const key = this.#coerce(record._zod.def.keyType, k);
125
- const val = this.#coerce(record._zod.def.valueType, v);
126
- newObj[key] = val;
127
- }
128
- return newObj;
129
- }
130
- return value;
131
- }
132
- case "map": {
133
- const map = schema;
134
- if (value === void 0) {
135
- return /* @__PURE__ */ new Map();
136
- }
137
- if (Array.isArray(value) && value.every((i) => Array.isArray(i) && i.length <= 2)) {
138
- return new Map(
139
- value.map(([k, v]) => [
140
- this.#coerce(map._zod.def.keyType, k),
141
- this.#coerce(map._zod.def.valueType, v)
142
- ])
143
- );
144
- }
145
- if (value instanceof Map) {
146
- return new Map(
147
- Array.from(value).map(([k, v]) => [
148
- this.#coerce(map._zod.def.keyType, k),
149
- this.#coerce(map._zod.def.valueType, v)
150
- ])
151
- );
152
- }
153
- return value;
154
- }
155
- case "union": {
156
- const union = schema;
157
- if (union._zod.def.options.length === 1) {
158
- return this.#coerce(union._zod.def.options[0], value);
159
- }
160
- if (isObject(value)) {
161
- const discriminator = "discriminator" in union._zod.def && typeof union._zod.def.discriminator === "string" ? union._zod.def.discriminator : void 0;
162
- for (const option of union._zod.def.options) {
163
- if (!option._zod.propValues) {
164
- continue;
165
- }
166
- if (discriminator !== void 0) {
167
- if (option._zod.propValues[discriminator]?.has(value[discriminator])) {
168
- return this.#coerce(option, value);
169
- }
170
- } else {
171
- for (const key in option._zod.propValues) {
172
- if (option._zod.propValues[key]?.has(value[key])) {
173
- return this.#coerce(option, value);
174
- }
175
- }
176
- }
177
- }
178
- }
179
- return value;
180
- }
181
- case "intersection": {
182
- const intersection = schema;
183
- return this.#coerce(intersection._zod.def.right, this.#coerce(intersection._zod.def.left, value));
184
- }
185
- case "optional": {
186
- const optional = schema;
187
- if (value === void 0) {
188
- return void 0;
189
- }
190
- return this.#coerce(optional._zod.def.innerType, value);
191
- }
192
- case "nonoptional": {
193
- const nonoptional = schema;
194
- return this.#coerce(nonoptional._zod.def.innerType, value);
195
- }
196
- case "nullable": {
197
- const nullable = schema;
198
- if (value === null) {
199
- return null;
200
- }
201
- return this.#coerce(nullable._zod.def.innerType, value);
202
- }
203
- case "readonly": {
204
- const readonly_ = schema;
205
- return this.#coerce(readonly_._zod.def.innerType, value);
206
- }
207
- case "pipe": {
208
- const pipe = schema;
209
- return this.#coerce(pipe._zod.def.in, value);
210
- }
211
- case "default":
212
- case "prefault": {
213
- const default_ = schema;
214
- if (value === void 0) {
215
- return value;
216
- }
217
- return this.#coerce(default_._zod.def.innerType, value);
218
- }
219
- case "catch": {
220
- const catch_ = schema;
221
- return this.#coerce(catch_._zod.def.innerType, value);
222
- }
223
- case "lazy": {
224
- const lazy = schema;
225
- if (value !== void 0) {
226
- return this.#coerce(lazy._zod.def.getter(), value);
227
- }
228
- return value;
229
- }
230
- default: {
231
- schema._zod.def.type;
232
- return value;
233
- }
234
- }
235
- }
236
- #stringToNumber(value) {
237
- const num = Number(value);
238
- return Number.isNaN(num) || num.toString() !== value ? value : num;
239
- }
240
- #stringToBigInt(value) {
241
- return guard(() => BigInt(value)) ?? value;
242
- }
243
- #stringToBoolean(value) {
244
- const lower = value.toLowerCase();
245
- if (lower === "false" || lower === "off" || lower === "f") {
246
- return false;
247
- }
248
- if (lower === "true" || lower === "on" || lower === "t") {
249
- return true;
250
- }
251
- return value;
252
- }
253
- #stringToDate(value) {
254
- const date = new Date(value);
255
- if (!Number.isNaN(date.getTime()) && date.toISOString().startsWith(value)) {
256
- return date;
257
- }
258
- return value;
259
- }
260
- }
261
-
262
- const JSON_SCHEMA_REGISTRY = registry();
263
- const JSON_SCHEMA_INPUT_REGISTRY = registry();
264
- const JSON_SCHEMA_OUTPUT_REGISTRY = registry();
265
-
266
- class ZodToJsonSchemaConverter {
267
- maxLazyDepth;
268
- maxStructureDepth;
269
- anyJsonSchema;
270
- unsupportedJsonSchema;
271
- undefinedJsonSchema;
272
- interceptors;
273
- constructor(options = {}) {
274
- this.maxLazyDepth = options.maxLazyDepth ?? 2;
275
- this.maxStructureDepth = options.maxStructureDepth ?? 10;
276
- this.anyJsonSchema = options.anyJsonSchema ?? {};
277
- this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
278
- this.undefinedJsonSchema = options.undefinedJsonSchema ?? { not: {} };
279
- this.interceptors = options.interceptors ?? [];
280
- }
281
- condition(schema) {
282
- return schema !== void 0 && schema["~standard"].vendor === "zod" && "_zod" in schema;
283
- }
284
- convert(schema, options) {
285
- return this.#convert(schema, options, 0, 0);
286
- }
287
- #convert(schema, options, lazyDepth, structureDepth, isHandledCustomJSONSchema = false) {
288
- return intercept(
289
- this.interceptors,
290
- { schema, options, lazyDepth, isHandledCustomJSONSchema },
291
- ({ schema: schema2, options: options2, lazyDepth: lazyDepth2, isHandledCustomJSONSchema: isHandledCustomJSONSchema2 }) => {
292
- if (structureDepth > this.maxStructureDepth) {
293
- return [false, this.anyJsonSchema];
294
- }
295
- if (!options2.minStructureDepthForRef || options2.minStructureDepthForRef <= structureDepth) {
296
- const components = toArray(options2.components);
297
- for (const component of components) {
298
- if (component.schema === schema2 && component.allowedStrategies.includes(options2.strategy)) {
299
- return [component.required, { $ref: component.ref }];
300
- }
301
- }
302
- }
303
- if (!isHandledCustomJSONSchema2) {
304
- const customJSONSchema = this.#getCustomJsonSchema(schema2, options2);
305
- if (customJSONSchema) {
306
- const [required, json] = this.#convert(schema2, options2, lazyDepth2, structureDepth, true);
307
- return [required, { ...json, ...customJSONSchema }];
308
- }
309
- }
310
- switch (schema2._zod.def.type) {
311
- case "string": {
312
- const string = schema2;
313
- const json = { type: "string" };
314
- const { minimum, maximum, format, patterns, contentEncoding } = string._zod.bag;
315
- if (typeof minimum === "number") {
316
- json.minLength = minimum;
317
- }
318
- if (typeof maximum === "number") {
319
- json.maxLength = maximum;
320
- }
321
- if (typeof contentEncoding === "string") {
322
- json.contentEncoding = this.#handleContentEncoding(contentEncoding);
323
- }
324
- if (typeof format === "string" && format !== "regex" && json.contentEncoding === void 0) {
325
- json.format = this.#handleStringFormat(format);
326
- }
327
- if (patterns instanceof Set && json.contentEncoding === void 0 && json.format === void 0) {
328
- for (const pattern of patterns) {
329
- if (json.pattern === void 0) {
330
- json.pattern = pattern.source;
331
- } else {
332
- json.allOf ??= [];
333
- json.allOf.push({ pattern: pattern.source });
334
- }
335
- }
336
- }
337
- if (format === "jwt" && json.contentEncoding === void 0 && json.format === void 0 && json.pattern === void 0) {
338
- json.pattern = /^[\w-]+\.[\w-]+\.[\w-]+$/.source;
339
- }
340
- return [true, json];
341
- }
342
- case "number": {
343
- const number = schema2;
344
- const json = { type: "number" };
345
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = number._zod.bag;
346
- if (typeof format === "string" && format?.includes("int")) {
347
- json.type = "integer";
348
- }
349
- if (typeof minimum === "number") {
350
- json.minimum = minimum;
351
- }
352
- if (typeof maximum === "number") {
353
- json.maximum = maximum;
354
- }
355
- if (typeof exclusiveMinimum === "number") {
356
- json.exclusiveMinimum = exclusiveMinimum;
357
- }
358
- if (typeof exclusiveMaximum === "number") {
359
- json.exclusiveMaximum = exclusiveMaximum;
360
- }
361
- if (typeof multipleOf === "number") {
362
- json.multipleOf = multipleOf;
363
- }
364
- return [true, json];
365
- }
366
- case "boolean": {
367
- return [true, { type: "boolean" }];
368
- }
369
- case "bigint": {
370
- return [
371
- true,
372
- {
373
- type: "string",
374
- pattern: "^-?[0-9]+$",
375
- "x-native-type": JsonSchemaXNativeType.BigInt
376
- }
377
- ];
378
- }
379
- case "date": {
380
- return [
381
- true,
382
- {
383
- type: "string",
384
- format: JSONSchemaFormat.DateTime,
385
- "x-native-type": JsonSchemaXNativeType.Date
386
- }
387
- ];
388
- }
389
- case "null": {
390
- return [true, { type: "null" }];
391
- }
392
- case "undefined":
393
- case "void": {
394
- return [false, this.undefinedJsonSchema];
395
- }
396
- case "any": {
397
- return [false, this.anyJsonSchema];
398
- }
399
- case "unknown": {
400
- return [false, this.anyJsonSchema];
401
- }
402
- case "never": {
403
- return [true, this.unsupportedJsonSchema];
404
- }
405
- case "array": {
406
- const array = schema2;
407
- const json = { type: "array" };
408
- const { minimum, maximum } = array._zod.bag;
409
- if (typeof minimum === "number") {
410
- json.minItems = minimum;
411
- }
412
- if (typeof maximum === "number") {
413
- json.maxItems = maximum;
414
- }
415
- json.items = this.#handleArrayItemJsonSchema(
416
- this.#convert(array._zod.def.element, options2, lazyDepth2, structureDepth + 1),
417
- options2
418
- );
419
- return [true, json];
420
- }
421
- case "object": {
422
- const object = schema2;
423
- const json = { type: "object" };
424
- for (const [key, value] of Object.entries(object._zod.def.shape)) {
425
- const [itemRequired, itemJson] = this.#convert(value, options2, lazyDepth2, structureDepth + 1);
426
- json.properties ??= {};
427
- json.properties[key] = itemJson;
428
- if (itemRequired) {
429
- json.required ??= [];
430
- json.required.push(key);
431
- }
432
- }
433
- if (object._zod.def.catchall) {
434
- if (object._zod.def.catchall._zod.def.type === "never") {
435
- json.additionalProperties = false;
436
- } else {
437
- const [_, addJson] = this.#convert(
438
- object._zod.def.catchall,
439
- options2,
440
- lazyDepth2,
441
- structureDepth + 1
442
- );
443
- json.additionalProperties = addJson;
444
- }
445
- }
446
- return [true, json];
447
- }
448
- case "union": {
449
- const union = schema2;
450
- const anyOf = [];
451
- let required = true;
452
- for (const item of union._zod.def.options) {
453
- const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth);
454
- if (!itemRequired) {
455
- required = false;
456
- }
457
- if (options2.strategy === "input") {
458
- if (itemJson !== this.undefinedJsonSchema && itemJson !== this.unsupportedJsonSchema) {
459
- anyOf.push(itemJson);
460
- }
461
- } else {
462
- if (itemJson !== this.undefinedJsonSchema) {
463
- anyOf.push(itemJson);
464
- }
465
- }
466
- }
467
- return [required, anyOf.length === 1 ? anyOf[0] : { anyOf }];
468
- }
469
- case "intersection": {
470
- const intersection = schema2;
471
- const json = { allOf: [] };
472
- let required = false;
473
- for (const item of [intersection._zod.def.left, intersection._zod.def.right]) {
474
- const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth);
475
- json.allOf.push(itemJson);
476
- if (itemRequired) {
477
- required = true;
478
- }
479
- }
480
- return [required, json];
481
- }
482
- case "tuple": {
483
- const tuple = schema2;
484
- const json = { type: "array", prefixItems: [] };
485
- for (const item of tuple._zod.def.items) {
486
- json.prefixItems.push(
487
- this.#handleArrayItemJsonSchema(
488
- this.#convert(item, options2, lazyDepth2, structureDepth + 1),
489
- options2
490
- )
491
- );
492
- }
493
- if (tuple._zod.def.rest) {
494
- json.items = this.#handleArrayItemJsonSchema(
495
- this.#convert(tuple._zod.def.rest, options2, lazyDepth2, structureDepth + 1),
496
- options2
497
- );
498
- }
499
- const { minimum, maximum } = tuple._zod.bag;
500
- if (typeof minimum === "number") {
501
- json.minItems = minimum;
502
- }
503
- if (typeof maximum === "number") {
504
- json.maxItems = maximum;
505
- }
506
- return [true, json];
507
- }
508
- case "record": {
509
- const record = schema2;
510
- const json = { type: "object" };
511
- json.propertyNames = this.#convert(
512
- record._zod.def.keyType,
513
- options2,
514
- lazyDepth2,
515
- structureDepth + 1
516
- )[1];
517
- json.additionalProperties = this.#convert(
518
- record._zod.def.valueType,
519
- options2,
520
- lazyDepth2,
521
- structureDepth + 1
522
- )[1];
523
- return [true, json];
524
- }
525
- case "map": {
526
- const map = schema2;
527
- return [
528
- true,
529
- {
530
- type: "array",
531
- items: {
532
- type: "array",
533
- prefixItems: [
534
- this.#handleArrayItemJsonSchema(
535
- this.#convert(map._zod.def.keyType, options2, lazyDepth2, structureDepth + 1),
536
- options2
537
- ),
538
- this.#handleArrayItemJsonSchema(
539
- this.#convert(map._zod.def.valueType, options2, lazyDepth2, structureDepth + 1),
540
- options2
541
- )
542
- ],
543
- maxItems: 2,
544
- minItems: 2
545
- },
546
- "x-native-type": JsonSchemaXNativeType.Map
547
- }
548
- ];
549
- }
550
- case "set": {
551
- const set = schema2;
552
- return [
553
- true,
554
- {
555
- type: "array",
556
- uniqueItems: true,
557
- items: this.#handleArrayItemJsonSchema(
558
- this.#convert(set._zod.def.valueType, options2, lazyDepth2, structureDepth + 1),
559
- options2
560
- ),
561
- "x-native-type": JsonSchemaXNativeType.Set
562
- }
563
- ];
564
- }
565
- case "enum": {
566
- const enum_ = schema2;
567
- return [true, { enum: Object.values(enum_._zod.def.entries) }];
568
- }
569
- case "literal": {
570
- const literal = schema2;
571
- let required = true;
572
- const values = /* @__PURE__ */ new Set();
573
- for (const value of literal._zod.def.values) {
574
- if (value === void 0) {
575
- required = false;
576
- } else {
577
- values.add(typeof value === "bigint" ? value.toString() : value);
578
- }
579
- }
580
- const json = values.size === 0 ? this.undefinedJsonSchema : values.size === 1 ? { const: values.values().next().value } : { enum: Array.from(values) };
581
- return [required, json];
582
- }
583
- case "file": {
584
- const file = schema2;
585
- const oneOf = [];
586
- const { mime } = file._zod.bag;
587
- if (mime === void 0 || Array.isArray(mime) && mime.every((m) => typeof m === "string")) {
588
- for (const type of mime ?? ["*/*"]) {
589
- oneOf.push({
590
- type: "string",
591
- contentMediaType: type
592
- });
593
- }
594
- }
595
- return [true, oneOf.length === 1 ? oneOf[0] : { anyOf: oneOf }];
596
- }
597
- case "transform": {
598
- return [false, this.anyJsonSchema];
599
- }
600
- case "nullable": {
601
- const nullable = schema2;
602
- const [required, json] = this.#convert(
603
- nullable._zod.def.innerType,
604
- options2,
605
- lazyDepth2,
606
- structureDepth
607
- );
608
- return [required, { anyOf: [json, { type: "null" }] }];
609
- }
610
- case "nonoptional": {
611
- const nonoptional = schema2;
612
- const [, json] = this.#convert(
613
- nonoptional._zod.def.innerType,
614
- options2,
615
- lazyDepth2,
616
- structureDepth
617
- );
618
- return [true, json];
619
- }
620
- case "success": {
621
- return [true, { type: "boolean" }];
622
- }
623
- case "default":
624
- case "prefault": {
625
- const default_ = schema2;
626
- const [, json] = this.#convert(default_._zod.def.innerType, options2, lazyDepth2, structureDepth);
627
- return [
628
- false,
629
- {
630
- ...json,
631
- default: default_._zod.def.defaultValue
632
- }
633
- ];
634
- }
635
- case "catch": {
636
- const catch_ = schema2;
637
- return this.#convert(catch_._zod.def.innerType, options2, lazyDepth2, structureDepth);
638
- }
639
- case "nan": {
640
- return [true, options2.strategy === "input" ? this.unsupportedJsonSchema : { type: "null" }];
641
- }
642
- case "pipe": {
643
- const pipe = schema2;
644
- return this.#convert(
645
- options2.strategy === "input" ? pipe._zod.def.in : pipe._zod.def.out,
646
- options2,
647
- lazyDepth2,
648
- structureDepth
649
- );
650
- }
651
- case "readonly": {
652
- const readonly_ = schema2;
653
- const [required, json] = this.#convert(
654
- readonly_._zod.def.innerType,
655
- options2,
656
- lazyDepth2,
657
- structureDepth
658
- );
659
- return [required, { ...json, readOnly: true }];
660
- }
661
- case "template_literal": {
662
- const templateLiteral = schema2;
663
- return [
664
- true,
665
- {
666
- type: "string",
667
- pattern: templateLiteral._zod.pattern.source
668
- }
669
- ];
670
- }
671
- case "optional": {
672
- const optional = schema2;
673
- const [, json] = this.#convert(optional._zod.def.innerType, options2, lazyDepth2, structureDepth);
674
- return [false, json];
675
- }
676
- case "lazy": {
677
- const lazy = schema2;
678
- const currentLazyDepth = lazyDepth2 + 1;
679
- if (currentLazyDepth > this.maxLazyDepth) {
680
- return [false, this.anyJsonSchema];
681
- }
682
- return this.#convert(lazy._zod.def.getter(), options2, currentLazyDepth, structureDepth);
683
- }
684
- default: {
685
- schema2._zod.def.type;
686
- return [true, this.unsupportedJsonSchema];
687
- }
688
- }
689
- }
690
- );
691
- }
692
- #getCustomJsonSchema(schema, options) {
693
- if (options.strategy === "input" && JSON_SCHEMA_INPUT_REGISTRY.has(schema)) {
694
- return JSON_SCHEMA_INPUT_REGISTRY.get(schema);
695
- }
696
- if (options.strategy === "output" && JSON_SCHEMA_OUTPUT_REGISTRY.has(schema)) {
697
- return JSON_SCHEMA_OUTPUT_REGISTRY.get(schema);
698
- }
699
- if (JSON_SCHEMA_REGISTRY.has(schema)) {
700
- return JSON_SCHEMA_REGISTRY.get(schema);
701
- }
702
- const global = globalRegistry.get(schema);
703
- if (global) {
704
- return {
705
- title: global.title,
706
- description: global.description,
707
- examples: Array.isArray(global.examples) ? global.examples : void 0
708
- };
709
- }
710
- }
711
- #handleArrayItemJsonSchema([required, schema], options) {
712
- if (required || options.strategy === "input" || schema.default !== void 0) {
713
- return schema;
714
- }
715
- if (schema === this.undefinedJsonSchema) {
716
- return { type: "null" };
717
- }
718
- return {
719
- anyOf: [
720
- // schema can contain { type: 'null' } so we should use anyOf instead of oneOf
721
- schema,
722
- { type: "null" }
723
- ]
724
- };
725
- }
726
- #handleStringFormat(format) {
727
- if (format === "guid") {
728
- return JSONSchemaFormat.UUID;
729
- }
730
- if (format === "url") {
731
- return JSONSchemaFormat.URI;
732
- }
733
- if (format === "datetime") {
734
- return JSONSchemaFormat.DateTime;
735
- }
736
- return Object.values(JSONSchemaFormat).includes(format) ? format : void 0;
737
- }
738
- #handleContentEncoding(contentEncoding) {
739
- return Object.values(JSONSchemaContentEncoding).includes(contentEncoding) ? contentEncoding : void 0;
740
- }
741
- }
742
-
743
- export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter, experimental_ZodSmartCoercionPlugin };