@kevisual/router 0.0.38 → 0.0.39
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/dist/router-browser.d.ts +12 -8
- package/dist/router-browser.js +14 -685
- package/dist/router-sign.js +1 -3
- package/dist/router.d.ts +13 -9
- package/dist/router.js +14 -685
- package/package.json +1 -1
package/dist/router.js
CHANGED
|
@@ -601,8 +601,8 @@ class QueryRouter {
|
|
|
601
601
|
setContext(ctx) {
|
|
602
602
|
this.context = ctx;
|
|
603
603
|
}
|
|
604
|
-
getList(
|
|
605
|
-
return this.routes.
|
|
604
|
+
getList() {
|
|
605
|
+
return this.routes.map((r) => {
|
|
606
606
|
return pick$1(r, pickValue);
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -2627,8 +2627,8 @@ class Doc {
|
|
|
2627
2627
|
|
|
2628
2628
|
const version = {
|
|
2629
2629
|
major: 4,
|
|
2630
|
-
minor:
|
|
2631
|
-
patch:
|
|
2630
|
+
minor: 1,
|
|
2631
|
+
patch: 13,
|
|
2632
2632
|
};
|
|
2633
2633
|
|
|
2634
2634
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
@@ -2698,6 +2698,16 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
2698
2698
|
}
|
|
2699
2699
|
return payload;
|
|
2700
2700
|
};
|
|
2701
|
+
// const handleChecksResult = (
|
|
2702
|
+
// checkResult: ParsePayload,
|
|
2703
|
+
// originalResult: ParsePayload,
|
|
2704
|
+
// ctx: ParseContextInternal
|
|
2705
|
+
// ): util.MaybeAsync<ParsePayload> => {
|
|
2706
|
+
// // if the checks mutated the value && there are no issues, re-parse the result
|
|
2707
|
+
// if (checkResult.value !== originalResult.value && !checkResult.issues.length)
|
|
2708
|
+
// return inst._zod.parse(checkResult, ctx);
|
|
2709
|
+
// return originalResult;
|
|
2710
|
+
// };
|
|
2701
2711
|
const handleCanaryResult = (canary, payload, ctx) => {
|
|
2702
2712
|
// abort if the canary is aborted
|
|
2703
2713
|
if (aborted(canary)) {
|
|
@@ -4335,659 +4345,6 @@ function _check(fn, params) {
|
|
|
4335
4345
|
return ch;
|
|
4336
4346
|
}
|
|
4337
4347
|
|
|
4338
|
-
// function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
|
|
4339
|
-
// return {
|
|
4340
|
-
// processor: inputs.processor,
|
|
4341
|
-
// metadataRegistry: inputs.metadata ?? globalRegistry,
|
|
4342
|
-
// target: inputs.target ?? "draft-2020-12",
|
|
4343
|
-
// unrepresentable: inputs.unrepresentable ?? "throw",
|
|
4344
|
-
// };
|
|
4345
|
-
// }
|
|
4346
|
-
function initializeContext(params) {
|
|
4347
|
-
// Normalize target: convert old non-hyphenated versions to hyphenated versions
|
|
4348
|
-
let target = params?.target ?? "draft-2020-12";
|
|
4349
|
-
if (target === "draft-4")
|
|
4350
|
-
target = "draft-04";
|
|
4351
|
-
if (target === "draft-7")
|
|
4352
|
-
target = "draft-07";
|
|
4353
|
-
return {
|
|
4354
|
-
processors: params.processors ?? {},
|
|
4355
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
4356
|
-
target,
|
|
4357
|
-
unrepresentable: params?.unrepresentable ?? "throw",
|
|
4358
|
-
override: params?.override ?? (() => { }),
|
|
4359
|
-
io: params?.io ?? "output",
|
|
4360
|
-
counter: 0,
|
|
4361
|
-
seen: new Map(),
|
|
4362
|
-
cycles: params?.cycles ?? "ref",
|
|
4363
|
-
reused: params?.reused ?? "inline",
|
|
4364
|
-
external: params?.external ?? undefined,
|
|
4365
|
-
};
|
|
4366
|
-
}
|
|
4367
|
-
function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
4368
|
-
var _a;
|
|
4369
|
-
const def = schema._zod.def;
|
|
4370
|
-
// check for schema in seens
|
|
4371
|
-
const seen = ctx.seen.get(schema);
|
|
4372
|
-
if (seen) {
|
|
4373
|
-
seen.count++;
|
|
4374
|
-
// check if cycle
|
|
4375
|
-
const isCycle = _params.schemaPath.includes(schema);
|
|
4376
|
-
if (isCycle) {
|
|
4377
|
-
seen.cycle = _params.path;
|
|
4378
|
-
}
|
|
4379
|
-
return seen.schema;
|
|
4380
|
-
}
|
|
4381
|
-
// initialize
|
|
4382
|
-
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
4383
|
-
ctx.seen.set(schema, result);
|
|
4384
|
-
// custom method overrides default behavior
|
|
4385
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
4386
|
-
if (overrideSchema) {
|
|
4387
|
-
result.schema = overrideSchema;
|
|
4388
|
-
}
|
|
4389
|
-
else {
|
|
4390
|
-
const params = {
|
|
4391
|
-
..._params,
|
|
4392
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
4393
|
-
path: _params.path,
|
|
4394
|
-
};
|
|
4395
|
-
const parent = schema._zod.parent;
|
|
4396
|
-
if (parent) {
|
|
4397
|
-
// schema was cloned from another schema
|
|
4398
|
-
result.ref = parent;
|
|
4399
|
-
process$1(parent, ctx, params);
|
|
4400
|
-
ctx.seen.get(parent).isParent = true;
|
|
4401
|
-
}
|
|
4402
|
-
else if (schema._zod.processJSONSchema) {
|
|
4403
|
-
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
4404
|
-
}
|
|
4405
|
-
else {
|
|
4406
|
-
const _json = result.schema;
|
|
4407
|
-
const processor = ctx.processors[def.type];
|
|
4408
|
-
if (!processor) {
|
|
4409
|
-
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
4410
|
-
}
|
|
4411
|
-
processor(schema, ctx, _json, params);
|
|
4412
|
-
}
|
|
4413
|
-
}
|
|
4414
|
-
// metadata
|
|
4415
|
-
const meta = ctx.metadataRegistry.get(schema);
|
|
4416
|
-
if (meta)
|
|
4417
|
-
Object.assign(result.schema, meta);
|
|
4418
|
-
if (ctx.io === "input" && isTransforming(schema)) {
|
|
4419
|
-
// examples/defaults only apply to output type of pipe
|
|
4420
|
-
delete result.schema.examples;
|
|
4421
|
-
delete result.schema.default;
|
|
4422
|
-
}
|
|
4423
|
-
// set prefault as default
|
|
4424
|
-
if (ctx.io === "input" && result.schema._prefault)
|
|
4425
|
-
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
4426
|
-
delete result.schema._prefault;
|
|
4427
|
-
// pulling fresh from ctx.seen in case it was overwritten
|
|
4428
|
-
const _result = ctx.seen.get(schema);
|
|
4429
|
-
return _result.schema;
|
|
4430
|
-
}
|
|
4431
|
-
function extractDefs(ctx, schema
|
|
4432
|
-
// params: EmitParams
|
|
4433
|
-
) {
|
|
4434
|
-
// iterate over seen map;
|
|
4435
|
-
const root = ctx.seen.get(schema);
|
|
4436
|
-
if (!root)
|
|
4437
|
-
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
4438
|
-
// returns a ref to the schema
|
|
4439
|
-
// defId will be empty if the ref points to an external schema (or #)
|
|
4440
|
-
const makeURI = (entry) => {
|
|
4441
|
-
// comparing the seen objects because sometimes
|
|
4442
|
-
// multiple schemas map to the same seen object.
|
|
4443
|
-
// e.g. lazy
|
|
4444
|
-
// external is configured
|
|
4445
|
-
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
4446
|
-
if (ctx.external) {
|
|
4447
|
-
const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
|
|
4448
|
-
// check if schema is in the external registry
|
|
4449
|
-
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
4450
|
-
if (externalId) {
|
|
4451
|
-
return { ref: uriGenerator(externalId) };
|
|
4452
|
-
}
|
|
4453
|
-
// otherwise, add to __shared
|
|
4454
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
4455
|
-
entry[1].defId = id; // set defId so it will be reused if needed
|
|
4456
|
-
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
4457
|
-
}
|
|
4458
|
-
if (entry[1] === root) {
|
|
4459
|
-
return { ref: "#" };
|
|
4460
|
-
}
|
|
4461
|
-
// self-contained schema
|
|
4462
|
-
const uriPrefix = `#`;
|
|
4463
|
-
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
4464
|
-
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
4465
|
-
return { defId, ref: defUriPrefix + defId };
|
|
4466
|
-
};
|
|
4467
|
-
// stored cached version in `def` property
|
|
4468
|
-
// remove all properties, set $ref
|
|
4469
|
-
const extractToDef = (entry) => {
|
|
4470
|
-
// if the schema is already a reference, do not extract it
|
|
4471
|
-
if (entry[1].schema.$ref) {
|
|
4472
|
-
return;
|
|
4473
|
-
}
|
|
4474
|
-
const seen = entry[1];
|
|
4475
|
-
const { ref, defId } = makeURI(entry);
|
|
4476
|
-
seen.def = { ...seen.schema };
|
|
4477
|
-
// defId won't be set if the schema is a reference to an external schema
|
|
4478
|
-
// or if the schema is the root schema
|
|
4479
|
-
if (defId)
|
|
4480
|
-
seen.defId = defId;
|
|
4481
|
-
// wipe away all properties except $ref
|
|
4482
|
-
const schema = seen.schema;
|
|
4483
|
-
for (const key in schema) {
|
|
4484
|
-
delete schema[key];
|
|
4485
|
-
}
|
|
4486
|
-
schema.$ref = ref;
|
|
4487
|
-
};
|
|
4488
|
-
// throw on cycles
|
|
4489
|
-
// break cycles
|
|
4490
|
-
if (ctx.cycles === "throw") {
|
|
4491
|
-
for (const entry of ctx.seen.entries()) {
|
|
4492
|
-
const seen = entry[1];
|
|
4493
|
-
if (seen.cycle) {
|
|
4494
|
-
throw new Error("Cycle detected: " +
|
|
4495
|
-
`#/${seen.cycle?.join("/")}/<root>` +
|
|
4496
|
-
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
|
4497
|
-
}
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
// extract schemas into $defs
|
|
4501
|
-
for (const entry of ctx.seen.entries()) {
|
|
4502
|
-
const seen = entry[1];
|
|
4503
|
-
// convert root schema to # $ref
|
|
4504
|
-
if (schema === entry[0]) {
|
|
4505
|
-
extractToDef(entry); // this has special handling for the root schema
|
|
4506
|
-
continue;
|
|
4507
|
-
}
|
|
4508
|
-
// extract schemas that are in the external registry
|
|
4509
|
-
if (ctx.external) {
|
|
4510
|
-
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
4511
|
-
if (schema !== entry[0] && ext) {
|
|
4512
|
-
extractToDef(entry);
|
|
4513
|
-
continue;
|
|
4514
|
-
}
|
|
4515
|
-
}
|
|
4516
|
-
// extract schemas with `id` meta
|
|
4517
|
-
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
4518
|
-
if (id) {
|
|
4519
|
-
extractToDef(entry);
|
|
4520
|
-
continue;
|
|
4521
|
-
}
|
|
4522
|
-
// break cycles
|
|
4523
|
-
if (seen.cycle) {
|
|
4524
|
-
// any
|
|
4525
|
-
extractToDef(entry);
|
|
4526
|
-
continue;
|
|
4527
|
-
}
|
|
4528
|
-
// extract reused schemas
|
|
4529
|
-
if (seen.count > 1) {
|
|
4530
|
-
if (ctx.reused === "ref") {
|
|
4531
|
-
extractToDef(entry);
|
|
4532
|
-
// biome-ignore lint:
|
|
4533
|
-
continue;
|
|
4534
|
-
}
|
|
4535
|
-
}
|
|
4536
|
-
}
|
|
4537
|
-
}
|
|
4538
|
-
function finalize(ctx, schema) {
|
|
4539
|
-
//
|
|
4540
|
-
// iterate over seen map;
|
|
4541
|
-
const root = ctx.seen.get(schema);
|
|
4542
|
-
if (!root)
|
|
4543
|
-
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
4544
|
-
// flatten _refs
|
|
4545
|
-
const flattenRef = (zodSchema) => {
|
|
4546
|
-
const seen = ctx.seen.get(zodSchema);
|
|
4547
|
-
const schema = seen.def ?? seen.schema;
|
|
4548
|
-
const _cached = { ...schema };
|
|
4549
|
-
// already seen
|
|
4550
|
-
if (seen.ref === null) {
|
|
4551
|
-
return;
|
|
4552
|
-
}
|
|
4553
|
-
// flatten ref if defined
|
|
4554
|
-
const ref = seen.ref;
|
|
4555
|
-
seen.ref = null; // prevent recursion
|
|
4556
|
-
if (ref) {
|
|
4557
|
-
flattenRef(ref);
|
|
4558
|
-
// merge referenced schema into current
|
|
4559
|
-
const refSchema = ctx.seen.get(ref).schema;
|
|
4560
|
-
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
4561
|
-
schema.allOf = schema.allOf ?? [];
|
|
4562
|
-
schema.allOf.push(refSchema);
|
|
4563
|
-
}
|
|
4564
|
-
else {
|
|
4565
|
-
Object.assign(schema, refSchema);
|
|
4566
|
-
Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
|
|
4567
|
-
}
|
|
4568
|
-
}
|
|
4569
|
-
// execute overrides
|
|
4570
|
-
if (!seen.isParent)
|
|
4571
|
-
ctx.override({
|
|
4572
|
-
zodSchema: zodSchema,
|
|
4573
|
-
jsonSchema: schema,
|
|
4574
|
-
path: seen.path ?? [],
|
|
4575
|
-
});
|
|
4576
|
-
};
|
|
4577
|
-
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
4578
|
-
flattenRef(entry[0]);
|
|
4579
|
-
}
|
|
4580
|
-
const result = {};
|
|
4581
|
-
if (ctx.target === "draft-2020-12") {
|
|
4582
|
-
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
4583
|
-
}
|
|
4584
|
-
else if (ctx.target === "draft-07") {
|
|
4585
|
-
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
4586
|
-
}
|
|
4587
|
-
else if (ctx.target === "draft-04") {
|
|
4588
|
-
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
4589
|
-
}
|
|
4590
|
-
else if (ctx.target === "openapi-3.0") ;
|
|
4591
|
-
else ;
|
|
4592
|
-
if (ctx.external?.uri) {
|
|
4593
|
-
const id = ctx.external.registry.get(schema)?.id;
|
|
4594
|
-
if (!id)
|
|
4595
|
-
throw new Error("Schema is missing an `id` property");
|
|
4596
|
-
result.$id = ctx.external.uri(id);
|
|
4597
|
-
}
|
|
4598
|
-
Object.assign(result, root.def ?? root.schema);
|
|
4599
|
-
// build defs object
|
|
4600
|
-
const defs = ctx.external?.defs ?? {};
|
|
4601
|
-
for (const entry of ctx.seen.entries()) {
|
|
4602
|
-
const seen = entry[1];
|
|
4603
|
-
if (seen.def && seen.defId) {
|
|
4604
|
-
defs[seen.defId] = seen.def;
|
|
4605
|
-
}
|
|
4606
|
-
}
|
|
4607
|
-
// set definitions in result
|
|
4608
|
-
if (ctx.external) ;
|
|
4609
|
-
else {
|
|
4610
|
-
if (Object.keys(defs).length > 0) {
|
|
4611
|
-
if (ctx.target === "draft-2020-12") {
|
|
4612
|
-
result.$defs = defs;
|
|
4613
|
-
}
|
|
4614
|
-
else {
|
|
4615
|
-
result.definitions = defs;
|
|
4616
|
-
}
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
4619
|
-
try {
|
|
4620
|
-
// this "finalizes" this schema and ensures all cycles are removed
|
|
4621
|
-
// each call to finalize() is functionally independent
|
|
4622
|
-
// though the seen map is shared
|
|
4623
|
-
const finalized = JSON.parse(JSON.stringify(result));
|
|
4624
|
-
Object.defineProperty(finalized, "~standard", {
|
|
4625
|
-
value: {
|
|
4626
|
-
...schema["~standard"],
|
|
4627
|
-
jsonSchema: {
|
|
4628
|
-
input: createStandardJSONSchemaMethod(schema, "input"),
|
|
4629
|
-
output: createStandardJSONSchemaMethod(schema, "output"),
|
|
4630
|
-
},
|
|
4631
|
-
},
|
|
4632
|
-
enumerable: false,
|
|
4633
|
-
writable: false,
|
|
4634
|
-
});
|
|
4635
|
-
return finalized;
|
|
4636
|
-
}
|
|
4637
|
-
catch (_err) {
|
|
4638
|
-
throw new Error("Error converting schema to JSON.");
|
|
4639
|
-
}
|
|
4640
|
-
}
|
|
4641
|
-
function isTransforming(_schema, _ctx) {
|
|
4642
|
-
const ctx = _ctx ?? { seen: new Set() };
|
|
4643
|
-
if (ctx.seen.has(_schema))
|
|
4644
|
-
return false;
|
|
4645
|
-
ctx.seen.add(_schema);
|
|
4646
|
-
const def = _schema._zod.def;
|
|
4647
|
-
if (def.type === "transform")
|
|
4648
|
-
return true;
|
|
4649
|
-
if (def.type === "array")
|
|
4650
|
-
return isTransforming(def.element, ctx);
|
|
4651
|
-
if (def.type === "set")
|
|
4652
|
-
return isTransforming(def.valueType, ctx);
|
|
4653
|
-
if (def.type === "lazy")
|
|
4654
|
-
return isTransforming(def.getter(), ctx);
|
|
4655
|
-
if (def.type === "promise" ||
|
|
4656
|
-
def.type === "optional" ||
|
|
4657
|
-
def.type === "nonoptional" ||
|
|
4658
|
-
def.type === "nullable" ||
|
|
4659
|
-
def.type === "readonly" ||
|
|
4660
|
-
def.type === "default" ||
|
|
4661
|
-
def.type === "prefault") {
|
|
4662
|
-
return isTransforming(def.innerType, ctx);
|
|
4663
|
-
}
|
|
4664
|
-
if (def.type === "intersection") {
|
|
4665
|
-
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
4666
|
-
}
|
|
4667
|
-
if (def.type === "record" || def.type === "map") {
|
|
4668
|
-
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
4669
|
-
}
|
|
4670
|
-
if (def.type === "pipe") {
|
|
4671
|
-
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
4672
|
-
}
|
|
4673
|
-
if (def.type === "object") {
|
|
4674
|
-
for (const key in def.shape) {
|
|
4675
|
-
if (isTransforming(def.shape[key], ctx))
|
|
4676
|
-
return true;
|
|
4677
|
-
}
|
|
4678
|
-
return false;
|
|
4679
|
-
}
|
|
4680
|
-
if (def.type === "union") {
|
|
4681
|
-
for (const option of def.options) {
|
|
4682
|
-
if (isTransforming(option, ctx))
|
|
4683
|
-
return true;
|
|
4684
|
-
}
|
|
4685
|
-
return false;
|
|
4686
|
-
}
|
|
4687
|
-
if (def.type === "tuple") {
|
|
4688
|
-
for (const item of def.items) {
|
|
4689
|
-
if (isTransforming(item, ctx))
|
|
4690
|
-
return true;
|
|
4691
|
-
}
|
|
4692
|
-
if (def.rest && isTransforming(def.rest, ctx))
|
|
4693
|
-
return true;
|
|
4694
|
-
return false;
|
|
4695
|
-
}
|
|
4696
|
-
return false;
|
|
4697
|
-
}
|
|
4698
|
-
/**
|
|
4699
|
-
* Creates a toJSONSchema method for a schema instance.
|
|
4700
|
-
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
4701
|
-
*/
|
|
4702
|
-
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
4703
|
-
const ctx = initializeContext({ ...params, processors });
|
|
4704
|
-
process$1(schema, ctx);
|
|
4705
|
-
extractDefs(ctx, schema);
|
|
4706
|
-
return finalize(ctx, schema);
|
|
4707
|
-
};
|
|
4708
|
-
const createStandardJSONSchemaMethod = (schema, io) => (params) => {
|
|
4709
|
-
const { libraryOptions, target } = params ?? {};
|
|
4710
|
-
const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
|
|
4711
|
-
process$1(schema, ctx);
|
|
4712
|
-
extractDefs(ctx, schema);
|
|
4713
|
-
return finalize(ctx, schema);
|
|
4714
|
-
};
|
|
4715
|
-
|
|
4716
|
-
const formatMap = {
|
|
4717
|
-
guid: "uuid",
|
|
4718
|
-
url: "uri",
|
|
4719
|
-
datetime: "date-time",
|
|
4720
|
-
json_string: "json-string",
|
|
4721
|
-
regex: "", // do not set
|
|
4722
|
-
};
|
|
4723
|
-
// ==================== SIMPLE TYPE PROCESSORS ====================
|
|
4724
|
-
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
4725
|
-
const json = _json;
|
|
4726
|
-
json.type = "string";
|
|
4727
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
|
|
4728
|
-
.bag;
|
|
4729
|
-
if (typeof minimum === "number")
|
|
4730
|
-
json.minLength = minimum;
|
|
4731
|
-
if (typeof maximum === "number")
|
|
4732
|
-
json.maxLength = maximum;
|
|
4733
|
-
// custom pattern overrides format
|
|
4734
|
-
if (format) {
|
|
4735
|
-
json.format = formatMap[format] ?? format;
|
|
4736
|
-
if (json.format === "")
|
|
4737
|
-
delete json.format; // empty format is not valid
|
|
4738
|
-
}
|
|
4739
|
-
if (contentEncoding)
|
|
4740
|
-
json.contentEncoding = contentEncoding;
|
|
4741
|
-
if (patterns && patterns.size > 0) {
|
|
4742
|
-
const regexes = [...patterns];
|
|
4743
|
-
if (regexes.length === 1)
|
|
4744
|
-
json.pattern = regexes[0].source;
|
|
4745
|
-
else if (regexes.length > 1) {
|
|
4746
|
-
json.allOf = [
|
|
4747
|
-
...regexes.map((regex) => ({
|
|
4748
|
-
...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
|
|
4749
|
-
? { type: "string" }
|
|
4750
|
-
: {}),
|
|
4751
|
-
pattern: regex.source,
|
|
4752
|
-
})),
|
|
4753
|
-
];
|
|
4754
|
-
}
|
|
4755
|
-
}
|
|
4756
|
-
};
|
|
4757
|
-
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
4758
|
-
const json = _json;
|
|
4759
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
4760
|
-
if (typeof format === "string" && format.includes("int"))
|
|
4761
|
-
json.type = "integer";
|
|
4762
|
-
else
|
|
4763
|
-
json.type = "number";
|
|
4764
|
-
if (typeof exclusiveMinimum === "number") {
|
|
4765
|
-
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
4766
|
-
json.minimum = exclusiveMinimum;
|
|
4767
|
-
json.exclusiveMinimum = true;
|
|
4768
|
-
}
|
|
4769
|
-
else {
|
|
4770
|
-
json.exclusiveMinimum = exclusiveMinimum;
|
|
4771
|
-
}
|
|
4772
|
-
}
|
|
4773
|
-
if (typeof minimum === "number") {
|
|
4774
|
-
json.minimum = minimum;
|
|
4775
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
4776
|
-
if (exclusiveMinimum >= minimum)
|
|
4777
|
-
delete json.minimum;
|
|
4778
|
-
else
|
|
4779
|
-
delete json.exclusiveMinimum;
|
|
4780
|
-
}
|
|
4781
|
-
}
|
|
4782
|
-
if (typeof exclusiveMaximum === "number") {
|
|
4783
|
-
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
4784
|
-
json.maximum = exclusiveMaximum;
|
|
4785
|
-
json.exclusiveMaximum = true;
|
|
4786
|
-
}
|
|
4787
|
-
else {
|
|
4788
|
-
json.exclusiveMaximum = exclusiveMaximum;
|
|
4789
|
-
}
|
|
4790
|
-
}
|
|
4791
|
-
if (typeof maximum === "number") {
|
|
4792
|
-
json.maximum = maximum;
|
|
4793
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
4794
|
-
if (exclusiveMaximum <= maximum)
|
|
4795
|
-
delete json.maximum;
|
|
4796
|
-
else
|
|
4797
|
-
delete json.exclusiveMaximum;
|
|
4798
|
-
}
|
|
4799
|
-
}
|
|
4800
|
-
if (typeof multipleOf === "number")
|
|
4801
|
-
json.multipleOf = multipleOf;
|
|
4802
|
-
};
|
|
4803
|
-
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4804
|
-
json.type = "boolean";
|
|
4805
|
-
};
|
|
4806
|
-
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4807
|
-
json.not = {};
|
|
4808
|
-
};
|
|
4809
|
-
const anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
4810
|
-
// empty schema accepts anything
|
|
4811
|
-
};
|
|
4812
|
-
const unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
4813
|
-
// empty schema accepts anything
|
|
4814
|
-
};
|
|
4815
|
-
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
4816
|
-
const def = schema._zod.def;
|
|
4817
|
-
const values = getEnumValues(def.entries);
|
|
4818
|
-
// Number enums can have both string and number values
|
|
4819
|
-
if (values.every((v) => typeof v === "number"))
|
|
4820
|
-
json.type = "number";
|
|
4821
|
-
if (values.every((v) => typeof v === "string"))
|
|
4822
|
-
json.type = "string";
|
|
4823
|
-
json.enum = values;
|
|
4824
|
-
};
|
|
4825
|
-
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
4826
|
-
if (ctx.unrepresentable === "throw") {
|
|
4827
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4828
|
-
}
|
|
4829
|
-
};
|
|
4830
|
-
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4831
|
-
if (ctx.unrepresentable === "throw") {
|
|
4832
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4833
|
-
}
|
|
4834
|
-
};
|
|
4835
|
-
// ==================== COMPOSITE TYPE PROCESSORS ====================
|
|
4836
|
-
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
4837
|
-
const json = _json;
|
|
4838
|
-
const def = schema._zod.def;
|
|
4839
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
4840
|
-
if (typeof minimum === "number")
|
|
4841
|
-
json.minItems = minimum;
|
|
4842
|
-
if (typeof maximum === "number")
|
|
4843
|
-
json.maxItems = maximum;
|
|
4844
|
-
json.type = "array";
|
|
4845
|
-
json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
4846
|
-
};
|
|
4847
|
-
const objectProcessor = (schema, ctx, _json, params) => {
|
|
4848
|
-
const json = _json;
|
|
4849
|
-
const def = schema._zod.def;
|
|
4850
|
-
json.type = "object";
|
|
4851
|
-
json.properties = {};
|
|
4852
|
-
const shape = def.shape;
|
|
4853
|
-
for (const key in shape) {
|
|
4854
|
-
json.properties[key] = process$1(shape[key], ctx, {
|
|
4855
|
-
...params,
|
|
4856
|
-
path: [...params.path, "properties", key],
|
|
4857
|
-
});
|
|
4858
|
-
}
|
|
4859
|
-
// required keys
|
|
4860
|
-
const allKeys = new Set(Object.keys(shape));
|
|
4861
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
4862
|
-
const v = def.shape[key]._zod;
|
|
4863
|
-
if (ctx.io === "input") {
|
|
4864
|
-
return v.optin === undefined;
|
|
4865
|
-
}
|
|
4866
|
-
else {
|
|
4867
|
-
return v.optout === undefined;
|
|
4868
|
-
}
|
|
4869
|
-
}));
|
|
4870
|
-
if (requiredKeys.size > 0) {
|
|
4871
|
-
json.required = Array.from(requiredKeys);
|
|
4872
|
-
}
|
|
4873
|
-
// catchall
|
|
4874
|
-
if (def.catchall?._zod.def.type === "never") {
|
|
4875
|
-
// strict
|
|
4876
|
-
json.additionalProperties = false;
|
|
4877
|
-
}
|
|
4878
|
-
else if (!def.catchall) {
|
|
4879
|
-
// regular
|
|
4880
|
-
if (ctx.io === "output")
|
|
4881
|
-
json.additionalProperties = false;
|
|
4882
|
-
}
|
|
4883
|
-
else if (def.catchall) {
|
|
4884
|
-
json.additionalProperties = process$1(def.catchall, ctx, {
|
|
4885
|
-
...params,
|
|
4886
|
-
path: [...params.path, "additionalProperties"],
|
|
4887
|
-
});
|
|
4888
|
-
}
|
|
4889
|
-
};
|
|
4890
|
-
const unionProcessor = (schema, ctx, json, params) => {
|
|
4891
|
-
const def = schema._zod.def;
|
|
4892
|
-
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)
|
|
4893
|
-
// This includes both z.xor() and discriminated unions
|
|
4894
|
-
const isExclusive = def.inclusive === false;
|
|
4895
|
-
const options = def.options.map((x, i) => process$1(x, ctx, {
|
|
4896
|
-
...params,
|
|
4897
|
-
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
|
|
4898
|
-
}));
|
|
4899
|
-
if (isExclusive) {
|
|
4900
|
-
json.oneOf = options;
|
|
4901
|
-
}
|
|
4902
|
-
else {
|
|
4903
|
-
json.anyOf = options;
|
|
4904
|
-
}
|
|
4905
|
-
};
|
|
4906
|
-
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
4907
|
-
const def = schema._zod.def;
|
|
4908
|
-
const a = process$1(def.left, ctx, {
|
|
4909
|
-
...params,
|
|
4910
|
-
path: [...params.path, "allOf", 0],
|
|
4911
|
-
});
|
|
4912
|
-
const b = process$1(def.right, ctx, {
|
|
4913
|
-
...params,
|
|
4914
|
-
path: [...params.path, "allOf", 1],
|
|
4915
|
-
});
|
|
4916
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
4917
|
-
const allOf = [
|
|
4918
|
-
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
|
4919
|
-
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
4920
|
-
];
|
|
4921
|
-
json.allOf = allOf;
|
|
4922
|
-
};
|
|
4923
|
-
const nullableProcessor = (schema, ctx, json, params) => {
|
|
4924
|
-
const def = schema._zod.def;
|
|
4925
|
-
const inner = process$1(def.innerType, ctx, params);
|
|
4926
|
-
const seen = ctx.seen.get(schema);
|
|
4927
|
-
if (ctx.target === "openapi-3.0") {
|
|
4928
|
-
seen.ref = def.innerType;
|
|
4929
|
-
json.nullable = true;
|
|
4930
|
-
}
|
|
4931
|
-
else {
|
|
4932
|
-
json.anyOf = [inner, { type: "null" }];
|
|
4933
|
-
}
|
|
4934
|
-
};
|
|
4935
|
-
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
4936
|
-
const def = schema._zod.def;
|
|
4937
|
-
process$1(def.innerType, ctx, params);
|
|
4938
|
-
const seen = ctx.seen.get(schema);
|
|
4939
|
-
seen.ref = def.innerType;
|
|
4940
|
-
};
|
|
4941
|
-
const defaultProcessor = (schema, ctx, json, params) => {
|
|
4942
|
-
const def = schema._zod.def;
|
|
4943
|
-
process$1(def.innerType, ctx, params);
|
|
4944
|
-
const seen = ctx.seen.get(schema);
|
|
4945
|
-
seen.ref = def.innerType;
|
|
4946
|
-
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
4947
|
-
};
|
|
4948
|
-
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
4949
|
-
const def = schema._zod.def;
|
|
4950
|
-
process$1(def.innerType, ctx, params);
|
|
4951
|
-
const seen = ctx.seen.get(schema);
|
|
4952
|
-
seen.ref = def.innerType;
|
|
4953
|
-
if (ctx.io === "input")
|
|
4954
|
-
json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
4955
|
-
};
|
|
4956
|
-
const catchProcessor = (schema, ctx, json, params) => {
|
|
4957
|
-
const def = schema._zod.def;
|
|
4958
|
-
process$1(def.innerType, ctx, params);
|
|
4959
|
-
const seen = ctx.seen.get(schema);
|
|
4960
|
-
seen.ref = def.innerType;
|
|
4961
|
-
let catchValue;
|
|
4962
|
-
try {
|
|
4963
|
-
catchValue = def.catchValue(undefined);
|
|
4964
|
-
}
|
|
4965
|
-
catch {
|
|
4966
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
4967
|
-
}
|
|
4968
|
-
json.default = catchValue;
|
|
4969
|
-
};
|
|
4970
|
-
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
4971
|
-
const def = schema._zod.def;
|
|
4972
|
-
const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
|
|
4973
|
-
process$1(innerType, ctx, params);
|
|
4974
|
-
const seen = ctx.seen.get(schema);
|
|
4975
|
-
seen.ref = innerType;
|
|
4976
|
-
};
|
|
4977
|
-
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
4978
|
-
const def = schema._zod.def;
|
|
4979
|
-
process$1(def.innerType, ctx, params);
|
|
4980
|
-
const seen = ctx.seen.get(schema);
|
|
4981
|
-
seen.ref = def.innerType;
|
|
4982
|
-
json.readOnly = true;
|
|
4983
|
-
};
|
|
4984
|
-
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
4985
|
-
const def = schema._zod.def;
|
|
4986
|
-
process$1(def.innerType, ctx, params);
|
|
4987
|
-
const seen = ctx.seen.get(schema);
|
|
4988
|
-
seen.ref = def.innerType;
|
|
4989
|
-
};
|
|
4990
|
-
|
|
4991
4348
|
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4992
4349
|
$ZodISODateTime.init(inst, def);
|
|
4993
4350
|
ZodStringFormat.init(inst, def);
|
|
@@ -5079,13 +4436,6 @@ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
5079
4436
|
|
|
5080
4437
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
5081
4438
|
$ZodType.init(inst, def);
|
|
5082
|
-
Object.assign(inst["~standard"], {
|
|
5083
|
-
jsonSchema: {
|
|
5084
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
5085
|
-
output: createStandardJSONSchemaMethod(inst, "output"),
|
|
5086
|
-
},
|
|
5087
|
-
});
|
|
5088
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
5089
4439
|
inst.def = def;
|
|
5090
4440
|
inst.type = def.type;
|
|
5091
4441
|
Object.defineProperty(inst, "_def", { value: def });
|
|
@@ -5167,7 +4517,6 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
5167
4517
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
5168
4518
|
$ZodString.init(inst, def);
|
|
5169
4519
|
ZodType.init(inst, def);
|
|
5170
|
-
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
|
|
5171
4520
|
const bag = inst._zod.bag;
|
|
5172
4521
|
inst.format = bag.format ?? null;
|
|
5173
4522
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -5325,7 +4674,6 @@ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
|
5325
4674
|
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
5326
4675
|
$ZodNumber.init(inst, def);
|
|
5327
4676
|
ZodType.init(inst, def);
|
|
5328
|
-
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
|
|
5329
4677
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
5330
4678
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
5331
4679
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
@@ -5364,7 +4712,6 @@ function int(params) {
|
|
|
5364
4712
|
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
|
|
5365
4713
|
$ZodBoolean.init(inst, def);
|
|
5366
4714
|
ZodType.init(inst, def);
|
|
5367
|
-
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
|
|
5368
4715
|
});
|
|
5369
4716
|
function boolean(params) {
|
|
5370
4717
|
return _boolean(ZodBoolean, params);
|
|
@@ -5372,7 +4719,6 @@ function boolean(params) {
|
|
|
5372
4719
|
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
|
|
5373
4720
|
$ZodAny.init(inst, def);
|
|
5374
4721
|
ZodType.init(inst, def);
|
|
5375
|
-
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor();
|
|
5376
4722
|
});
|
|
5377
4723
|
function any() {
|
|
5378
4724
|
return _any(ZodAny);
|
|
@@ -5380,7 +4726,6 @@ function any() {
|
|
|
5380
4726
|
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
5381
4727
|
$ZodUnknown.init(inst, def);
|
|
5382
4728
|
ZodType.init(inst, def);
|
|
5383
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
|
|
5384
4729
|
});
|
|
5385
4730
|
function unknown() {
|
|
5386
4731
|
return _unknown(ZodUnknown);
|
|
@@ -5388,7 +4733,6 @@ function unknown() {
|
|
|
5388
4733
|
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
5389
4734
|
$ZodNever.init(inst, def);
|
|
5390
4735
|
ZodType.init(inst, def);
|
|
5391
|
-
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
|
|
5392
4736
|
});
|
|
5393
4737
|
function never(params) {
|
|
5394
4738
|
return _never(ZodNever, params);
|
|
@@ -5396,7 +4740,6 @@ function never(params) {
|
|
|
5396
4740
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
5397
4741
|
$ZodArray.init(inst, def);
|
|
5398
4742
|
ZodType.init(inst, def);
|
|
5399
|
-
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
5400
4743
|
inst.element = def.element;
|
|
5401
4744
|
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
5402
4745
|
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
@@ -5410,7 +4753,6 @@ function array(element, params) {
|
|
|
5410
4753
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
5411
4754
|
$ZodObjectJIT.init(inst, def);
|
|
5412
4755
|
ZodType.init(inst, def);
|
|
5413
|
-
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
5414
4756
|
defineLazy(inst, "shape", () => {
|
|
5415
4757
|
return def.shape;
|
|
5416
4758
|
});
|
|
@@ -5443,7 +4785,6 @@ function object(shape, params) {
|
|
|
5443
4785
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
5444
4786
|
$ZodUnion.init(inst, def);
|
|
5445
4787
|
ZodType.init(inst, def);
|
|
5446
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
5447
4788
|
inst.options = def.options;
|
|
5448
4789
|
});
|
|
5449
4790
|
function union(options, params) {
|
|
@@ -5456,7 +4797,6 @@ function union(options, params) {
|
|
|
5456
4797
|
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
5457
4798
|
$ZodIntersection.init(inst, def);
|
|
5458
4799
|
ZodType.init(inst, def);
|
|
5459
|
-
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
5460
4800
|
});
|
|
5461
4801
|
function intersection(left, right) {
|
|
5462
4802
|
return new ZodIntersection({
|
|
@@ -5468,7 +4808,6 @@ function intersection(left, right) {
|
|
|
5468
4808
|
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
5469
4809
|
$ZodEnum.init(inst, def);
|
|
5470
4810
|
ZodType.init(inst, def);
|
|
5471
|
-
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
|
|
5472
4811
|
inst.enum = def.entries;
|
|
5473
4812
|
inst.options = Object.values(def.entries);
|
|
5474
4813
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -5516,7 +4855,6 @@ function _enum(values, params) {
|
|
|
5516
4855
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
5517
4856
|
$ZodTransform.init(inst, def);
|
|
5518
4857
|
ZodType.init(inst, def);
|
|
5519
|
-
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
|
|
5520
4858
|
inst._zod.parse = (payload, _ctx) => {
|
|
5521
4859
|
if (_ctx.direction === "backward") {
|
|
5522
4860
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -5557,7 +4895,6 @@ function transform(fn) {
|
|
|
5557
4895
|
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
5558
4896
|
$ZodOptional.init(inst, def);
|
|
5559
4897
|
ZodType.init(inst, def);
|
|
5560
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
5561
4898
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5562
4899
|
});
|
|
5563
4900
|
function optional(innerType) {
|
|
@@ -5569,7 +4906,6 @@ function optional(innerType) {
|
|
|
5569
4906
|
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
5570
4907
|
$ZodNullable.init(inst, def);
|
|
5571
4908
|
ZodType.init(inst, def);
|
|
5572
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
5573
4909
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5574
4910
|
});
|
|
5575
4911
|
function nullable(innerType) {
|
|
@@ -5581,7 +4917,6 @@ function nullable(innerType) {
|
|
|
5581
4917
|
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
5582
4918
|
$ZodDefault.init(inst, def);
|
|
5583
4919
|
ZodType.init(inst, def);
|
|
5584
|
-
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
5585
4920
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5586
4921
|
inst.removeDefault = inst.unwrap;
|
|
5587
4922
|
});
|
|
@@ -5597,7 +4932,6 @@ function _default(innerType, defaultValue) {
|
|
|
5597
4932
|
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
5598
4933
|
$ZodPrefault.init(inst, def);
|
|
5599
4934
|
ZodType.init(inst, def);
|
|
5600
|
-
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
5601
4935
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5602
4936
|
});
|
|
5603
4937
|
function prefault(innerType, defaultValue) {
|
|
@@ -5612,7 +4946,6 @@ function prefault(innerType, defaultValue) {
|
|
|
5612
4946
|
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
5613
4947
|
$ZodNonOptional.init(inst, def);
|
|
5614
4948
|
ZodType.init(inst, def);
|
|
5615
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
5616
4949
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5617
4950
|
});
|
|
5618
4951
|
function nonoptional(innerType, params) {
|
|
@@ -5625,7 +4958,6 @@ function nonoptional(innerType, params) {
|
|
|
5625
4958
|
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
5626
4959
|
$ZodCatch.init(inst, def);
|
|
5627
4960
|
ZodType.init(inst, def);
|
|
5628
|
-
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
5629
4961
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5630
4962
|
inst.removeCatch = inst.unwrap;
|
|
5631
4963
|
});
|
|
@@ -5639,7 +4971,6 @@ function _catch(innerType, catchValue) {
|
|
|
5639
4971
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
5640
4972
|
$ZodPipe.init(inst, def);
|
|
5641
4973
|
ZodType.init(inst, def);
|
|
5642
|
-
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
5643
4974
|
inst.in = def.in;
|
|
5644
4975
|
inst.out = def.out;
|
|
5645
4976
|
});
|
|
@@ -5654,7 +4985,6 @@ function pipe(in_, out) {
|
|
|
5654
4985
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
5655
4986
|
$ZodReadonly.init(inst, def);
|
|
5656
4987
|
ZodType.init(inst, def);
|
|
5657
|
-
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
5658
4988
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
5659
4989
|
});
|
|
5660
4990
|
function readonly(innerType) {
|
|
@@ -5666,7 +4996,6 @@ function readonly(innerType) {
|
|
|
5666
4996
|
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
5667
4997
|
$ZodCustom.init(inst, def);
|
|
5668
4998
|
ZodType.init(inst, def);
|
|
5669
|
-
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
|
|
5670
4999
|
});
|
|
5671
5000
|
function refine(fn, _params = {}) {
|
|
5672
5001
|
return _refine(ZodCustom, fn, _params);
|