@kevisual/router 0.0.36 → 0.0.38
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 +11 -14
- package/dist/router-browser.js +688 -17
- package/dist/router-sign.js +3 -1
- package/dist/router.d.ts +18 -16
- package/dist/router.js +690 -19
- package/package.json +2 -2
- package/src/app.ts +2 -2
- package/src/route.ts +11 -11
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.map((r) => {
|
|
604
|
+
getList(filter) {
|
|
605
|
+
return this.routes.filter(filter || (() => true)).map((r) => {
|
|
606
606
|
return pick$1(r, pickValue);
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -729,13 +729,13 @@ class QueryRouterServer extends QueryRouter {
|
|
|
729
729
|
* @param param0
|
|
730
730
|
* @returns
|
|
731
731
|
*/
|
|
732
|
-
async run(
|
|
732
|
+
async run(msg, ctx) {
|
|
733
733
|
const handle = this.handle;
|
|
734
734
|
if (handle) {
|
|
735
|
-
const result = await this.call(
|
|
735
|
+
const result = await this.call(msg, ctx);
|
|
736
736
|
return handle(result);
|
|
737
737
|
}
|
|
738
|
-
return super.run(
|
|
738
|
+
return super.run(msg, ctx);
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
class Mini extends QueryRouterServer {
|
|
@@ -2627,8 +2627,8 @@ class Doc {
|
|
|
2627
2627
|
|
|
2628
2628
|
const version = {
|
|
2629
2629
|
major: 4,
|
|
2630
|
-
minor:
|
|
2631
|
-
patch:
|
|
2630
|
+
minor: 2,
|
|
2631
|
+
patch: 1,
|
|
2632
2632
|
};
|
|
2633
2633
|
|
|
2634
2634
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
@@ -2698,16 +2698,6 @@ 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
|
-
// };
|
|
2711
2701
|
const handleCanaryResult = (canary, payload, ctx) => {
|
|
2712
2702
|
// abort if the canary is aborted
|
|
2713
2703
|
if (aborted(canary)) {
|
|
@@ -4345,6 +4335,659 @@ function _check(fn, params) {
|
|
|
4345
4335
|
return ch;
|
|
4346
4336
|
}
|
|
4347
4337
|
|
|
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
|
+
|
|
4348
4991
|
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4349
4992
|
$ZodISODateTime.init(inst, def);
|
|
4350
4993
|
ZodStringFormat.init(inst, def);
|
|
@@ -4436,6 +5079,13 @@ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
4436
5079
|
|
|
4437
5080
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
4438
5081
|
$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, {});
|
|
4439
5089
|
inst.def = def;
|
|
4440
5090
|
inst.type = def.type;
|
|
4441
5091
|
Object.defineProperty(inst, "_def", { value: def });
|
|
@@ -4517,6 +5167,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
4517
5167
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
4518
5168
|
$ZodString.init(inst, def);
|
|
4519
5169
|
ZodType.init(inst, def);
|
|
5170
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
|
|
4520
5171
|
const bag = inst._zod.bag;
|
|
4521
5172
|
inst.format = bag.format ?? null;
|
|
4522
5173
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -4674,6 +5325,7 @@ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
|
4674
5325
|
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
4675
5326
|
$ZodNumber.init(inst, def);
|
|
4676
5327
|
ZodType.init(inst, def);
|
|
5328
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
|
|
4677
5329
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
4678
5330
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
4679
5331
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
@@ -4712,6 +5364,7 @@ function int(params) {
|
|
|
4712
5364
|
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
|
|
4713
5365
|
$ZodBoolean.init(inst, def);
|
|
4714
5366
|
ZodType.init(inst, def);
|
|
5367
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
|
|
4715
5368
|
});
|
|
4716
5369
|
function boolean(params) {
|
|
4717
5370
|
return _boolean(ZodBoolean, params);
|
|
@@ -4719,6 +5372,7 @@ function boolean(params) {
|
|
|
4719
5372
|
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
|
|
4720
5373
|
$ZodAny.init(inst, def);
|
|
4721
5374
|
ZodType.init(inst, def);
|
|
5375
|
+
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor();
|
|
4722
5376
|
});
|
|
4723
5377
|
function any() {
|
|
4724
5378
|
return _any(ZodAny);
|
|
@@ -4726,6 +5380,7 @@ function any() {
|
|
|
4726
5380
|
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
4727
5381
|
$ZodUnknown.init(inst, def);
|
|
4728
5382
|
ZodType.init(inst, def);
|
|
5383
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
|
|
4729
5384
|
});
|
|
4730
5385
|
function unknown() {
|
|
4731
5386
|
return _unknown(ZodUnknown);
|
|
@@ -4733,6 +5388,7 @@ function unknown() {
|
|
|
4733
5388
|
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
4734
5389
|
$ZodNever.init(inst, def);
|
|
4735
5390
|
ZodType.init(inst, def);
|
|
5391
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
|
|
4736
5392
|
});
|
|
4737
5393
|
function never(params) {
|
|
4738
5394
|
return _never(ZodNever, params);
|
|
@@ -4740,6 +5396,7 @@ function never(params) {
|
|
|
4740
5396
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
4741
5397
|
$ZodArray.init(inst, def);
|
|
4742
5398
|
ZodType.init(inst, def);
|
|
5399
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4743
5400
|
inst.element = def.element;
|
|
4744
5401
|
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
4745
5402
|
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
@@ -4753,6 +5410,7 @@ function array(element, params) {
|
|
|
4753
5410
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
4754
5411
|
$ZodObjectJIT.init(inst, def);
|
|
4755
5412
|
ZodType.init(inst, def);
|
|
5413
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4756
5414
|
defineLazy(inst, "shape", () => {
|
|
4757
5415
|
return def.shape;
|
|
4758
5416
|
});
|
|
@@ -4785,6 +5443,7 @@ function object(shape, params) {
|
|
|
4785
5443
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
4786
5444
|
$ZodUnion.init(inst, def);
|
|
4787
5445
|
ZodType.init(inst, def);
|
|
5446
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
4788
5447
|
inst.options = def.options;
|
|
4789
5448
|
});
|
|
4790
5449
|
function union(options, params) {
|
|
@@ -4797,6 +5456,7 @@ function union(options, params) {
|
|
|
4797
5456
|
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
4798
5457
|
$ZodIntersection.init(inst, def);
|
|
4799
5458
|
ZodType.init(inst, def);
|
|
5459
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
4800
5460
|
});
|
|
4801
5461
|
function intersection(left, right) {
|
|
4802
5462
|
return new ZodIntersection({
|
|
@@ -4808,6 +5468,7 @@ function intersection(left, right) {
|
|
|
4808
5468
|
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
4809
5469
|
$ZodEnum.init(inst, def);
|
|
4810
5470
|
ZodType.init(inst, def);
|
|
5471
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
|
|
4811
5472
|
inst.enum = def.entries;
|
|
4812
5473
|
inst.options = Object.values(def.entries);
|
|
4813
5474
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -4855,6 +5516,7 @@ function _enum(values, params) {
|
|
|
4855
5516
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
4856
5517
|
$ZodTransform.init(inst, def);
|
|
4857
5518
|
ZodType.init(inst, def);
|
|
5519
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
|
|
4858
5520
|
inst._zod.parse = (payload, _ctx) => {
|
|
4859
5521
|
if (_ctx.direction === "backward") {
|
|
4860
5522
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -4895,6 +5557,7 @@ function transform(fn) {
|
|
|
4895
5557
|
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
4896
5558
|
$ZodOptional.init(inst, def);
|
|
4897
5559
|
ZodType.init(inst, def);
|
|
5560
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4898
5561
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4899
5562
|
});
|
|
4900
5563
|
function optional(innerType) {
|
|
@@ -4906,6 +5569,7 @@ function optional(innerType) {
|
|
|
4906
5569
|
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
4907
5570
|
$ZodNullable.init(inst, def);
|
|
4908
5571
|
ZodType.init(inst, def);
|
|
5572
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
4909
5573
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4910
5574
|
});
|
|
4911
5575
|
function nullable(innerType) {
|
|
@@ -4917,6 +5581,7 @@ function nullable(innerType) {
|
|
|
4917
5581
|
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
4918
5582
|
$ZodDefault.init(inst, def);
|
|
4919
5583
|
ZodType.init(inst, def);
|
|
5584
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
4920
5585
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4921
5586
|
inst.removeDefault = inst.unwrap;
|
|
4922
5587
|
});
|
|
@@ -4932,6 +5597,7 @@ function _default(innerType, defaultValue) {
|
|
|
4932
5597
|
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
4933
5598
|
$ZodPrefault.init(inst, def);
|
|
4934
5599
|
ZodType.init(inst, def);
|
|
5600
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
4935
5601
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4936
5602
|
});
|
|
4937
5603
|
function prefault(innerType, defaultValue) {
|
|
@@ -4946,6 +5612,7 @@ function prefault(innerType, defaultValue) {
|
|
|
4946
5612
|
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
4947
5613
|
$ZodNonOptional.init(inst, def);
|
|
4948
5614
|
ZodType.init(inst, def);
|
|
5615
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
4949
5616
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4950
5617
|
});
|
|
4951
5618
|
function nonoptional(innerType, params) {
|
|
@@ -4958,6 +5625,7 @@ function nonoptional(innerType, params) {
|
|
|
4958
5625
|
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
4959
5626
|
$ZodCatch.init(inst, def);
|
|
4960
5627
|
ZodType.init(inst, def);
|
|
5628
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
4961
5629
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4962
5630
|
inst.removeCatch = inst.unwrap;
|
|
4963
5631
|
});
|
|
@@ -4971,6 +5639,7 @@ function _catch(innerType, catchValue) {
|
|
|
4971
5639
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
4972
5640
|
$ZodPipe.init(inst, def);
|
|
4973
5641
|
ZodType.init(inst, def);
|
|
5642
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
4974
5643
|
inst.in = def.in;
|
|
4975
5644
|
inst.out = def.out;
|
|
4976
5645
|
});
|
|
@@ -4985,6 +5654,7 @@ function pipe(in_, out) {
|
|
|
4985
5654
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
4986
5655
|
$ZodReadonly.init(inst, def);
|
|
4987
5656
|
ZodType.init(inst, def);
|
|
5657
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
4988
5658
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
4989
5659
|
});
|
|
4990
5660
|
function readonly(innerType) {
|
|
@@ -4996,6 +5666,7 @@ function readonly(innerType) {
|
|
|
4996
5666
|
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
4997
5667
|
$ZodCustom.init(inst, def);
|
|
4998
5668
|
ZodType.init(inst, def);
|
|
5669
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
|
|
4999
5670
|
});
|
|
5000
5671
|
function refine(fn, _params = {}) {
|
|
5001
5672
|
return _refine(ZodCustom, fn, _params);
|
|
@@ -10331,8 +11002,8 @@ class App {
|
|
|
10331
11002
|
async queryRoute(path, key, payload, ctx) {
|
|
10332
11003
|
return await this.router.queryRoute({ path, key, payload }, ctx);
|
|
10333
11004
|
}
|
|
10334
|
-
async run(
|
|
10335
|
-
return await this.router.run(
|
|
11005
|
+
async run(msg, ctx) {
|
|
11006
|
+
return await this.router.run(msg, ctx);
|
|
10336
11007
|
}
|
|
10337
11008
|
exportRoutes() {
|
|
10338
11009
|
return this.router.exportRoutes();
|