@temporary-name/zod 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e
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/README.md +1 -1
- package/dist/index.d.mts +741 -78
- package/dist/index.d.ts +741 -78
- package/dist/index.mjs +1479 -860
- package/dist/zod4/index.d.mts +1 -303
- package/dist/zod4/index.d.ts +1 -303
- package/dist/zod4/index.mjs +2 -486
- package/package.json +7 -11
package/dist/zod4/index.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { isObject, guard
|
|
2
|
-
import { JsonSchemaXNativeType } from '@temporary-name/json-schema';
|
|
3
|
-
import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@temporary-name/openapi';
|
|
4
|
-
import { registry, globalRegistry } from 'zod/v4/core';
|
|
1
|
+
import { isObject, guard } from '@temporary-name/shared';
|
|
5
2
|
|
|
6
3
|
class experimental_ZodSmartCoercionPlugin {
|
|
7
4
|
init(options) {
|
|
@@ -259,485 +256,4 @@ class experimental_ZodSmartCoercionPlugin {
|
|
|
259
256
|
}
|
|
260
257
|
}
|
|
261
258
|
|
|
262
|
-
|
|
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 };
|
|
259
|
+
export { experimental_ZodSmartCoercionPlugin };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/zod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/stainless-api/krusty.git",
|
|
10
10
|
"directory": "packages/zod"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -28,20 +28,16 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"@temporary-name/
|
|
33
|
-
"@temporary-name/server": "1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d"
|
|
31
|
+
"@temporary-name/contract": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
32
|
+
"@temporary-name/server": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"escape-string-regexp": "^5.0.0",
|
|
37
36
|
"wildcard-match": "^5.1.3",
|
|
38
|
-
"
|
|
39
|
-
"@temporary-name/
|
|
40
|
-
"@temporary-name/shared": "1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"zod": "^4.1.11"
|
|
37
|
+
"zod": "^4.1.11",
|
|
38
|
+
"@temporary-name/shared": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e"
|
|
44
39
|
},
|
|
40
|
+
"devDependencies": {},
|
|
45
41
|
"scripts": {
|
|
46
42
|
"build": "unbuild",
|
|
47
43
|
"build:watch": "pnpm run build --watch",
|