@rpcbase/auth 0.76.0 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{handler-DFSQG3-U.js → handler-CUtZEFQm.js} +1 -1
- package/dist/{handler-BIDgXiiq.js → handler-DJwOgqtP.js} +1 -1
- package/dist/{handler-Bmcd9YmA.js → handler-DvUXoOYN.js} +1 -1
- package/dist/{handler-Bs__eoKT.js → handler-DyqylA1h.js} +1 -1
- package/dist/{handler-BEAVSu5T.js → handler-Zcu5rM1_.js} +1 -1
- package/dist/{handler-BmlInQbc.js → handler-sUCM6Ee3.js} +1 -1
- package/dist/{index-V5AZ3kmZ.js → index-BCacnRCE.js} +1 -1
- package/dist/{index-FbCE80yc.js → index-DdTRbuS-.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/routes.js +1 -1
- package/dist/{schemas-BfVe_QYZ.js → schemas-BCQJ62HD.js} +301 -111
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { models } from "@rpcbase/db";
|
|
2
2
|
import { verifyPasswordFromStorage } from "@rpcbase/server";
|
|
3
|
-
import { R as Route, r as requestSchema } from "./index-
|
|
3
|
+
import { R as Route, r as requestSchema } from "./index-BCacnRCE.js";
|
|
4
4
|
const signIn = async (payload, ctx) => {
|
|
5
5
|
const User = await models.getGlobal("RBUser", ctx);
|
|
6
6
|
const parsed = requestSchema.safeParse(payload);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from "crypto";
|
|
2
2
|
import { models } from "@rpcbase/db";
|
|
3
3
|
import { sendEmail } from "@rpcbase/server";
|
|
4
|
-
import { o as object, s as string, b as boolean } from "./schemas-
|
|
4
|
+
import { o as object, s as string, b as boolean } from "./schemas-BCQJ62HD.js";
|
|
5
5
|
const Route = "/api/rb/auth/resend-otp";
|
|
6
6
|
const requestSchema = object({
|
|
7
7
|
email: string().email()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { models } from "@rpcbase/db";
|
|
2
2
|
import { r as restrictSessionMiddleware } from "./middleware-BiMXO6Dq.js";
|
|
3
|
-
import { o as object, s as string, a as array } from "./schemas-
|
|
3
|
+
import { o as object, s as string, a as array } from "./schemas-BCQJ62HD.js";
|
|
4
4
|
const Route = "/api/rb/auth/me";
|
|
5
5
|
object({});
|
|
6
6
|
object({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { models } from "@rpcbase/db";
|
|
2
|
-
import { o as object, b as boolean, s as string } from "./schemas-
|
|
2
|
+
import { o as object, b as boolean, s as string } from "./schemas-BCQJ62HD.js";
|
|
3
3
|
const Route = "/api/rb/auth/verify-otp";
|
|
4
4
|
const requestSchema = object({
|
|
5
5
|
email: string().email(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from "crypto";
|
|
2
2
|
import { models } from "@rpcbase/db";
|
|
3
3
|
import { hashPasswordForStorage, sendEmail } from "@rpcbase/server";
|
|
4
|
-
import { R as Route, r as requestSchema } from "./index-
|
|
4
|
+
import { R as Route, r as requestSchema } from "./index-DdTRbuS-.js";
|
|
5
5
|
const signUp = async (payload, ctx) => {
|
|
6
6
|
const User = await models.getGlobal("RBUser", ctx);
|
|
7
7
|
const Tenant = await models.getGlobal("RBTenant", ctx);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as object, b as boolean, s as string } from "./schemas-
|
|
1
|
+
import { o as object, b as boolean, s as string } from "./schemas-BCQJ62HD.js";
|
|
2
2
|
const Route = "/api/rb/auth/sign-in";
|
|
3
3
|
const requestSchema = object({
|
|
4
4
|
email: string().nonempty("Email is required").email("Please enter a valid email address"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as object, b as boolean, s as string } from "./schemas-
|
|
1
|
+
import { o as object, b as boolean, s as string } from "./schemas-BCQJ62HD.js";
|
|
2
2
|
const Route = "/api/rb/auth/sign-up";
|
|
3
3
|
const requestSchema = object({
|
|
4
4
|
email: string().nonempty("Email is required").email("Please enter a valid email address"),
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
|
|
5
|
-
import { r as requestSchema } from "./index-
|
|
5
|
+
import { r as requestSchema } from "./index-BCacnRCE.js";
|
|
6
6
|
import { useState, forwardRef, createElement, useEffect, useCallback, useMemo } from "react";
|
|
7
|
-
import { r as requestSchema$1 } from "./index-
|
|
7
|
+
import { r as requestSchema$1 } from "./index-DdTRbuS-.js";
|
|
8
8
|
import { b, a, r } from "./middleware-BiMXO6Dq.js";
|
|
9
9
|
const LINKS_REDIRECTION_MAP = {
|
|
10
10
|
"/auth/sign-in": {
|
package/dist/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const routes = Object.entries({
|
|
2
|
-
.../* @__PURE__ */ Object.assign({ "./api/me/handler.ts": () => import("./handler-
|
|
2
|
+
.../* @__PURE__ */ Object.assign({ "./api/me/handler.ts": () => import("./handler-DvUXoOYN.js"), "./api/resend-otp/handler.ts": () => import("./handler-DJwOgqtP.js"), "./api/sign-in/handler.ts": () => import("./handler-CUtZEFQm.js"), "./api/sign-out/handler.ts": () => import("./handler-Zcu5rM1_.js"), "./api/sign-up/handler.ts": () => import("./handler-sUCM6Ee3.js"), "./api/verify-otp/handler.ts": () => import("./handler-DyqylA1h.js") })
|
|
3
3
|
}).reduce((acc, [path, mod]) => {
|
|
4
4
|
acc[path.replace("./api/", "@rpcbase/auth/api/")] = mod;
|
|
5
5
|
return acc;
|
|
@@ -211,6 +211,11 @@ function optionalKeys(shape) {
|
|
|
211
211
|
}
|
|
212
212
|
function pick(schema, mask) {
|
|
213
213
|
const currDef = schema._zod.def;
|
|
214
|
+
const checks = currDef.checks;
|
|
215
|
+
const hasChecks = checks && checks.length > 0;
|
|
216
|
+
if (hasChecks) {
|
|
217
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
218
|
+
}
|
|
214
219
|
const def = mergeDefs(schema._zod.def, {
|
|
215
220
|
get shape() {
|
|
216
221
|
const newShape = {};
|
|
@@ -231,6 +236,11 @@ function pick(schema, mask) {
|
|
|
231
236
|
}
|
|
232
237
|
function omit(schema, mask) {
|
|
233
238
|
const currDef = schema._zod.def;
|
|
239
|
+
const checks = currDef.checks;
|
|
240
|
+
const hasChecks = checks && checks.length > 0;
|
|
241
|
+
if (hasChecks) {
|
|
242
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
243
|
+
}
|
|
234
244
|
const def = mergeDefs(schema._zod.def, {
|
|
235
245
|
get shape() {
|
|
236
246
|
const newShape = { ...schema._zod.def.shape };
|
|
@@ -256,15 +266,19 @@ function extend(schema, shape) {
|
|
|
256
266
|
const checks = schema._zod.def.checks;
|
|
257
267
|
const hasChecks = checks && checks.length > 0;
|
|
258
268
|
if (hasChecks) {
|
|
259
|
-
|
|
269
|
+
const existingShape = schema._zod.def.shape;
|
|
270
|
+
for (const key in shape) {
|
|
271
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
272
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
260
275
|
}
|
|
261
276
|
const def = mergeDefs(schema._zod.def, {
|
|
262
277
|
get shape() {
|
|
263
278
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
264
279
|
assignProp(this, "shape", _shape);
|
|
265
280
|
return _shape;
|
|
266
|
-
}
|
|
267
|
-
checks: []
|
|
281
|
+
}
|
|
268
282
|
});
|
|
269
283
|
return clone(schema, def);
|
|
270
284
|
}
|
|
@@ -272,15 +286,13 @@ function safeExtend(schema, shape) {
|
|
|
272
286
|
if (!isPlainObject(shape)) {
|
|
273
287
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
274
288
|
}
|
|
275
|
-
const def = {
|
|
276
|
-
...schema._zod.def,
|
|
289
|
+
const def = mergeDefs(schema._zod.def, {
|
|
277
290
|
get shape() {
|
|
278
291
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
279
292
|
assignProp(this, "shape", _shape);
|
|
280
293
|
return _shape;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
};
|
|
294
|
+
}
|
|
295
|
+
});
|
|
284
296
|
return clone(schema, def);
|
|
285
297
|
}
|
|
286
298
|
function merge(a, b) {
|
|
@@ -299,6 +311,12 @@ function merge(a, b) {
|
|
|
299
311
|
return clone(a, def);
|
|
300
312
|
}
|
|
301
313
|
function partial(Class, schema, mask) {
|
|
314
|
+
const currDef = schema._zod.def;
|
|
315
|
+
const checks = currDef.checks;
|
|
316
|
+
const hasChecks = checks && checks.length > 0;
|
|
317
|
+
if (hasChecks) {
|
|
318
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
319
|
+
}
|
|
302
320
|
const def = mergeDefs(schema._zod.def, {
|
|
303
321
|
get shape() {
|
|
304
322
|
const oldShape = schema._zod.def.shape;
|
|
@@ -357,8 +375,7 @@ function required(Class, schema, mask) {
|
|
|
357
375
|
}
|
|
358
376
|
assignProp(this, "shape", shape);
|
|
359
377
|
return shape;
|
|
360
|
-
}
|
|
361
|
-
checks: []
|
|
378
|
+
}
|
|
362
379
|
});
|
|
363
380
|
return clone(schema, def);
|
|
364
381
|
}
|
|
@@ -579,7 +596,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
|
|
|
579
596
|
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
580
597
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
581
598
|
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
582
|
-
const e164 = /^\+
|
|
599
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
583
600
|
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
584
601
|
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
585
602
|
function timeSource(args) {
|
|
@@ -869,8 +886,8 @@ class Doc {
|
|
|
869
886
|
}
|
|
870
887
|
const version = {
|
|
871
888
|
major: 4,
|
|
872
|
-
minor:
|
|
873
|
-
patch:
|
|
889
|
+
minor: 3,
|
|
890
|
+
patch: 5
|
|
874
891
|
};
|
|
875
892
|
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
876
893
|
var _a2;
|
|
@@ -968,7 +985,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
968
985
|
return runChecks(result, checks, ctx);
|
|
969
986
|
};
|
|
970
987
|
}
|
|
971
|
-
inst
|
|
988
|
+
defineLazy(inst, "~standard", () => ({
|
|
972
989
|
validate: (value) => {
|
|
973
990
|
try {
|
|
974
991
|
const r = safeParse$1(inst, value);
|
|
@@ -979,7 +996,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
979
996
|
},
|
|
980
997
|
vendor: "zod",
|
|
981
998
|
version: 1
|
|
982
|
-
};
|
|
999
|
+
}));
|
|
983
1000
|
});
|
|
984
1001
|
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
985
1002
|
$ZodType.init(inst, def);
|
|
@@ -1348,8 +1365,11 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1348
1365
|
return payload;
|
|
1349
1366
|
};
|
|
1350
1367
|
});
|
|
1351
|
-
function handlePropertyResult(result, final, key, input) {
|
|
1368
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
1352
1369
|
if (result.issues.length) {
|
|
1370
|
+
if (isOptionalOut && !(key in input)) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1353
1373
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1354
1374
|
}
|
|
1355
1375
|
if (result.value === void 0) {
|
|
@@ -1381,6 +1401,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1381
1401
|
const keySet = def.keySet;
|
|
1382
1402
|
const _catchall = def.catchall._zod;
|
|
1383
1403
|
const t = _catchall.def.type;
|
|
1404
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
1384
1405
|
for (const key in input) {
|
|
1385
1406
|
if (keySet.has(key))
|
|
1386
1407
|
continue;
|
|
@@ -1390,9 +1411,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1390
1411
|
}
|
|
1391
1412
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1392
1413
|
if (r instanceof Promise) {
|
|
1393
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
1414
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
1394
1415
|
} else {
|
|
1395
|
-
handlePropertyResult(r, payload, key, input);
|
|
1416
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1396
1417
|
}
|
|
1397
1418
|
}
|
|
1398
1419
|
if (unrecognized.length) {
|
|
@@ -1458,11 +1479,12 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1458
1479
|
const shape = value.shape;
|
|
1459
1480
|
for (const key of value.keys) {
|
|
1460
1481
|
const el = shape[key];
|
|
1482
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
1461
1483
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1462
1484
|
if (r instanceof Promise) {
|
|
1463
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
1485
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
1464
1486
|
} else {
|
|
1465
|
-
handlePropertyResult(r, payload, key, input);
|
|
1487
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1466
1488
|
}
|
|
1467
1489
|
}
|
|
1468
1490
|
if (!catchall) {
|
|
@@ -1492,8 +1514,31 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1492
1514
|
for (const key of normalized.keys) {
|
|
1493
1515
|
const id = ids[key];
|
|
1494
1516
|
const k = esc(key);
|
|
1517
|
+
const schema = shape[key];
|
|
1518
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1495
1519
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1496
|
-
|
|
1520
|
+
if (isOptionalOut) {
|
|
1521
|
+
doc.write(`
|
|
1522
|
+
if (${id}.issues.length) {
|
|
1523
|
+
if (${k} in input) {
|
|
1524
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1525
|
+
...iss,
|
|
1526
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1527
|
+
})));
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
if (${id}.value === undefined) {
|
|
1532
|
+
if (${k} in input) {
|
|
1533
|
+
newResult[${k}] = undefined;
|
|
1534
|
+
}
|
|
1535
|
+
} else {
|
|
1536
|
+
newResult[${k}] = ${id}.value;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
`);
|
|
1540
|
+
} else {
|
|
1541
|
+
doc.write(`
|
|
1497
1542
|
if (${id}.issues.length) {
|
|
1498
1543
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1499
1544
|
...iss,
|
|
@@ -1501,7 +1546,6 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1501
1546
|
})));
|
|
1502
1547
|
}
|
|
1503
1548
|
|
|
1504
|
-
|
|
1505
1549
|
if (${id}.value === undefined) {
|
|
1506
1550
|
if (${k} in input) {
|
|
1507
1551
|
newResult[${k}] = undefined;
|
|
@@ -1511,6 +1555,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1511
1555
|
}
|
|
1512
1556
|
|
|
1513
1557
|
`);
|
|
1558
|
+
}
|
|
1514
1559
|
}
|
|
1515
1560
|
doc.write(`payload.value = newResult;`);
|
|
1516
1561
|
doc.write(`return payload;`);
|
|
@@ -1673,11 +1718,34 @@ function mergeValues(a, b) {
|
|
|
1673
1718
|
return { valid: false, mergeErrorPath: [] };
|
|
1674
1719
|
}
|
|
1675
1720
|
function handleIntersectionResults(result, left, right) {
|
|
1676
|
-
|
|
1677
|
-
|
|
1721
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1722
|
+
let unrecIssue;
|
|
1723
|
+
for (const iss of left.issues) {
|
|
1724
|
+
if (iss.code === "unrecognized_keys") {
|
|
1725
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
1726
|
+
for (const k of iss.keys) {
|
|
1727
|
+
if (!unrecKeys.has(k))
|
|
1728
|
+
unrecKeys.set(k, {});
|
|
1729
|
+
unrecKeys.get(k).l = true;
|
|
1730
|
+
}
|
|
1731
|
+
} else {
|
|
1732
|
+
result.issues.push(iss);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
for (const iss of right.issues) {
|
|
1736
|
+
if (iss.code === "unrecognized_keys") {
|
|
1737
|
+
for (const k of iss.keys) {
|
|
1738
|
+
if (!unrecKeys.has(k))
|
|
1739
|
+
unrecKeys.set(k, {});
|
|
1740
|
+
unrecKeys.get(k).r = true;
|
|
1741
|
+
}
|
|
1742
|
+
} else {
|
|
1743
|
+
result.issues.push(iss);
|
|
1744
|
+
}
|
|
1678
1745
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1746
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1747
|
+
if (bothKeys.length && unrecIssue) {
|
|
1748
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
1681
1749
|
}
|
|
1682
1750
|
if (aborted(result))
|
|
1683
1751
|
return result;
|
|
@@ -1759,6 +1827,14 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
|
|
|
1759
1827
|
return def.innerType._zod.run(payload, ctx);
|
|
1760
1828
|
};
|
|
1761
1829
|
});
|
|
1830
|
+
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1831
|
+
$ZodOptional.init(inst, def);
|
|
1832
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1833
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
1834
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1835
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1836
|
+
};
|
|
1837
|
+
});
|
|
1762
1838
|
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1763
1839
|
$ZodType.init(inst, def);
|
|
1764
1840
|
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
@@ -1972,9 +2048,6 @@ class $ZodRegistry {
|
|
|
1972
2048
|
const meta = _meta[0];
|
|
1973
2049
|
this._map.set(schema, meta);
|
|
1974
2050
|
if (meta && typeof meta === "object" && "id" in meta) {
|
|
1975
|
-
if (this._idmap.has(meta.id)) {
|
|
1976
|
-
throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
1977
|
-
}
|
|
1978
2051
|
this._idmap.set(meta.id, schema);
|
|
1979
2052
|
}
|
|
1980
2053
|
return this;
|
|
@@ -2011,12 +2084,14 @@ function registry() {
|
|
|
2011
2084
|
}
|
|
2012
2085
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2013
2086
|
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2087
|
+
// @__NO_SIDE_EFFECTS__
|
|
2014
2088
|
function _string(Class, params) {
|
|
2015
2089
|
return new Class({
|
|
2016
2090
|
type: "string",
|
|
2017
2091
|
...normalizeParams(params)
|
|
2018
2092
|
});
|
|
2019
2093
|
}
|
|
2094
|
+
// @__NO_SIDE_EFFECTS__
|
|
2020
2095
|
function _email(Class, params) {
|
|
2021
2096
|
return new Class({
|
|
2022
2097
|
type: "string",
|
|
@@ -2026,6 +2101,7 @@ function _email(Class, params) {
|
|
|
2026
2101
|
...normalizeParams(params)
|
|
2027
2102
|
});
|
|
2028
2103
|
}
|
|
2104
|
+
// @__NO_SIDE_EFFECTS__
|
|
2029
2105
|
function _guid(Class, params) {
|
|
2030
2106
|
return new Class({
|
|
2031
2107
|
type: "string",
|
|
@@ -2035,6 +2111,7 @@ function _guid(Class, params) {
|
|
|
2035
2111
|
...normalizeParams(params)
|
|
2036
2112
|
});
|
|
2037
2113
|
}
|
|
2114
|
+
// @__NO_SIDE_EFFECTS__
|
|
2038
2115
|
function _uuid(Class, params) {
|
|
2039
2116
|
return new Class({
|
|
2040
2117
|
type: "string",
|
|
@@ -2044,6 +2121,7 @@ function _uuid(Class, params) {
|
|
|
2044
2121
|
...normalizeParams(params)
|
|
2045
2122
|
});
|
|
2046
2123
|
}
|
|
2124
|
+
// @__NO_SIDE_EFFECTS__
|
|
2047
2125
|
function _uuidv4(Class, params) {
|
|
2048
2126
|
return new Class({
|
|
2049
2127
|
type: "string",
|
|
@@ -2054,6 +2132,7 @@ function _uuidv4(Class, params) {
|
|
|
2054
2132
|
...normalizeParams(params)
|
|
2055
2133
|
});
|
|
2056
2134
|
}
|
|
2135
|
+
// @__NO_SIDE_EFFECTS__
|
|
2057
2136
|
function _uuidv6(Class, params) {
|
|
2058
2137
|
return new Class({
|
|
2059
2138
|
type: "string",
|
|
@@ -2064,6 +2143,7 @@ function _uuidv6(Class, params) {
|
|
|
2064
2143
|
...normalizeParams(params)
|
|
2065
2144
|
});
|
|
2066
2145
|
}
|
|
2146
|
+
// @__NO_SIDE_EFFECTS__
|
|
2067
2147
|
function _uuidv7(Class, params) {
|
|
2068
2148
|
return new Class({
|
|
2069
2149
|
type: "string",
|
|
@@ -2074,6 +2154,7 @@ function _uuidv7(Class, params) {
|
|
|
2074
2154
|
...normalizeParams(params)
|
|
2075
2155
|
});
|
|
2076
2156
|
}
|
|
2157
|
+
// @__NO_SIDE_EFFECTS__
|
|
2077
2158
|
function _url(Class, params) {
|
|
2078
2159
|
return new Class({
|
|
2079
2160
|
type: "string",
|
|
@@ -2083,6 +2164,7 @@ function _url(Class, params) {
|
|
|
2083
2164
|
...normalizeParams(params)
|
|
2084
2165
|
});
|
|
2085
2166
|
}
|
|
2167
|
+
// @__NO_SIDE_EFFECTS__
|
|
2086
2168
|
function _emoji(Class, params) {
|
|
2087
2169
|
return new Class({
|
|
2088
2170
|
type: "string",
|
|
@@ -2092,6 +2174,7 @@ function _emoji(Class, params) {
|
|
|
2092
2174
|
...normalizeParams(params)
|
|
2093
2175
|
});
|
|
2094
2176
|
}
|
|
2177
|
+
// @__NO_SIDE_EFFECTS__
|
|
2095
2178
|
function _nanoid(Class, params) {
|
|
2096
2179
|
return new Class({
|
|
2097
2180
|
type: "string",
|
|
@@ -2101,6 +2184,7 @@ function _nanoid(Class, params) {
|
|
|
2101
2184
|
...normalizeParams(params)
|
|
2102
2185
|
});
|
|
2103
2186
|
}
|
|
2187
|
+
// @__NO_SIDE_EFFECTS__
|
|
2104
2188
|
function _cuid(Class, params) {
|
|
2105
2189
|
return new Class({
|
|
2106
2190
|
type: "string",
|
|
@@ -2110,6 +2194,7 @@ function _cuid(Class, params) {
|
|
|
2110
2194
|
...normalizeParams(params)
|
|
2111
2195
|
});
|
|
2112
2196
|
}
|
|
2197
|
+
// @__NO_SIDE_EFFECTS__
|
|
2113
2198
|
function _cuid2(Class, params) {
|
|
2114
2199
|
return new Class({
|
|
2115
2200
|
type: "string",
|
|
@@ -2119,6 +2204,7 @@ function _cuid2(Class, params) {
|
|
|
2119
2204
|
...normalizeParams(params)
|
|
2120
2205
|
});
|
|
2121
2206
|
}
|
|
2207
|
+
// @__NO_SIDE_EFFECTS__
|
|
2122
2208
|
function _ulid(Class, params) {
|
|
2123
2209
|
return new Class({
|
|
2124
2210
|
type: "string",
|
|
@@ -2128,6 +2214,7 @@ function _ulid(Class, params) {
|
|
|
2128
2214
|
...normalizeParams(params)
|
|
2129
2215
|
});
|
|
2130
2216
|
}
|
|
2217
|
+
// @__NO_SIDE_EFFECTS__
|
|
2131
2218
|
function _xid(Class, params) {
|
|
2132
2219
|
return new Class({
|
|
2133
2220
|
type: "string",
|
|
@@ -2137,6 +2224,7 @@ function _xid(Class, params) {
|
|
|
2137
2224
|
...normalizeParams(params)
|
|
2138
2225
|
});
|
|
2139
2226
|
}
|
|
2227
|
+
// @__NO_SIDE_EFFECTS__
|
|
2140
2228
|
function _ksuid(Class, params) {
|
|
2141
2229
|
return new Class({
|
|
2142
2230
|
type: "string",
|
|
@@ -2146,6 +2234,7 @@ function _ksuid(Class, params) {
|
|
|
2146
2234
|
...normalizeParams(params)
|
|
2147
2235
|
});
|
|
2148
2236
|
}
|
|
2237
|
+
// @__NO_SIDE_EFFECTS__
|
|
2149
2238
|
function _ipv4(Class, params) {
|
|
2150
2239
|
return new Class({
|
|
2151
2240
|
type: "string",
|
|
@@ -2155,6 +2244,7 @@ function _ipv4(Class, params) {
|
|
|
2155
2244
|
...normalizeParams(params)
|
|
2156
2245
|
});
|
|
2157
2246
|
}
|
|
2247
|
+
// @__NO_SIDE_EFFECTS__
|
|
2158
2248
|
function _ipv6(Class, params) {
|
|
2159
2249
|
return new Class({
|
|
2160
2250
|
type: "string",
|
|
@@ -2164,6 +2254,7 @@ function _ipv6(Class, params) {
|
|
|
2164
2254
|
...normalizeParams(params)
|
|
2165
2255
|
});
|
|
2166
2256
|
}
|
|
2257
|
+
// @__NO_SIDE_EFFECTS__
|
|
2167
2258
|
function _cidrv4(Class, params) {
|
|
2168
2259
|
return new Class({
|
|
2169
2260
|
type: "string",
|
|
@@ -2173,6 +2264,7 @@ function _cidrv4(Class, params) {
|
|
|
2173
2264
|
...normalizeParams(params)
|
|
2174
2265
|
});
|
|
2175
2266
|
}
|
|
2267
|
+
// @__NO_SIDE_EFFECTS__
|
|
2176
2268
|
function _cidrv6(Class, params) {
|
|
2177
2269
|
return new Class({
|
|
2178
2270
|
type: "string",
|
|
@@ -2182,6 +2274,7 @@ function _cidrv6(Class, params) {
|
|
|
2182
2274
|
...normalizeParams(params)
|
|
2183
2275
|
});
|
|
2184
2276
|
}
|
|
2277
|
+
// @__NO_SIDE_EFFECTS__
|
|
2185
2278
|
function _base64(Class, params) {
|
|
2186
2279
|
return new Class({
|
|
2187
2280
|
type: "string",
|
|
@@ -2191,6 +2284,7 @@ function _base64(Class, params) {
|
|
|
2191
2284
|
...normalizeParams(params)
|
|
2192
2285
|
});
|
|
2193
2286
|
}
|
|
2287
|
+
// @__NO_SIDE_EFFECTS__
|
|
2194
2288
|
function _base64url(Class, params) {
|
|
2195
2289
|
return new Class({
|
|
2196
2290
|
type: "string",
|
|
@@ -2200,6 +2294,7 @@ function _base64url(Class, params) {
|
|
|
2200
2294
|
...normalizeParams(params)
|
|
2201
2295
|
});
|
|
2202
2296
|
}
|
|
2297
|
+
// @__NO_SIDE_EFFECTS__
|
|
2203
2298
|
function _e164(Class, params) {
|
|
2204
2299
|
return new Class({
|
|
2205
2300
|
type: "string",
|
|
@@ -2209,6 +2304,7 @@ function _e164(Class, params) {
|
|
|
2209
2304
|
...normalizeParams(params)
|
|
2210
2305
|
});
|
|
2211
2306
|
}
|
|
2307
|
+
// @__NO_SIDE_EFFECTS__
|
|
2212
2308
|
function _jwt(Class, params) {
|
|
2213
2309
|
return new Class({
|
|
2214
2310
|
type: "string",
|
|
@@ -2218,6 +2314,7 @@ function _jwt(Class, params) {
|
|
|
2218
2314
|
...normalizeParams(params)
|
|
2219
2315
|
});
|
|
2220
2316
|
}
|
|
2317
|
+
// @__NO_SIDE_EFFECTS__
|
|
2221
2318
|
function _isoDateTime(Class, params) {
|
|
2222
2319
|
return new Class({
|
|
2223
2320
|
type: "string",
|
|
@@ -2229,6 +2326,7 @@ function _isoDateTime(Class, params) {
|
|
|
2229
2326
|
...normalizeParams(params)
|
|
2230
2327
|
});
|
|
2231
2328
|
}
|
|
2329
|
+
// @__NO_SIDE_EFFECTS__
|
|
2232
2330
|
function _isoDate(Class, params) {
|
|
2233
2331
|
return new Class({
|
|
2234
2332
|
type: "string",
|
|
@@ -2237,6 +2335,7 @@ function _isoDate(Class, params) {
|
|
|
2237
2335
|
...normalizeParams(params)
|
|
2238
2336
|
});
|
|
2239
2337
|
}
|
|
2338
|
+
// @__NO_SIDE_EFFECTS__
|
|
2240
2339
|
function _isoTime(Class, params) {
|
|
2241
2340
|
return new Class({
|
|
2242
2341
|
type: "string",
|
|
@@ -2246,6 +2345,7 @@ function _isoTime(Class, params) {
|
|
|
2246
2345
|
...normalizeParams(params)
|
|
2247
2346
|
});
|
|
2248
2347
|
}
|
|
2348
|
+
// @__NO_SIDE_EFFECTS__
|
|
2249
2349
|
function _isoDuration(Class, params) {
|
|
2250
2350
|
return new Class({
|
|
2251
2351
|
type: "string",
|
|
@@ -2254,23 +2354,27 @@ function _isoDuration(Class, params) {
|
|
|
2254
2354
|
...normalizeParams(params)
|
|
2255
2355
|
});
|
|
2256
2356
|
}
|
|
2357
|
+
// @__NO_SIDE_EFFECTS__
|
|
2257
2358
|
function _boolean(Class, params) {
|
|
2258
2359
|
return new Class({
|
|
2259
2360
|
type: "boolean",
|
|
2260
2361
|
...normalizeParams(params)
|
|
2261
2362
|
});
|
|
2262
2363
|
}
|
|
2364
|
+
// @__NO_SIDE_EFFECTS__
|
|
2263
2365
|
function _unknown(Class) {
|
|
2264
2366
|
return new Class({
|
|
2265
2367
|
type: "unknown"
|
|
2266
2368
|
});
|
|
2267
2369
|
}
|
|
2370
|
+
// @__NO_SIDE_EFFECTS__
|
|
2268
2371
|
function _never(Class, params) {
|
|
2269
2372
|
return new Class({
|
|
2270
2373
|
type: "never",
|
|
2271
2374
|
...normalizeParams(params)
|
|
2272
2375
|
});
|
|
2273
2376
|
}
|
|
2377
|
+
// @__NO_SIDE_EFFECTS__
|
|
2274
2378
|
function _maxLength(maximum, params) {
|
|
2275
2379
|
const ch = new $ZodCheckMaxLength({
|
|
2276
2380
|
check: "max_length",
|
|
@@ -2279,6 +2383,7 @@ function _maxLength(maximum, params) {
|
|
|
2279
2383
|
});
|
|
2280
2384
|
return ch;
|
|
2281
2385
|
}
|
|
2386
|
+
// @__NO_SIDE_EFFECTS__
|
|
2282
2387
|
function _minLength(minimum, params) {
|
|
2283
2388
|
return new $ZodCheckMinLength({
|
|
2284
2389
|
check: "min_length",
|
|
@@ -2286,6 +2391,7 @@ function _minLength(minimum, params) {
|
|
|
2286
2391
|
minimum
|
|
2287
2392
|
});
|
|
2288
2393
|
}
|
|
2394
|
+
// @__NO_SIDE_EFFECTS__
|
|
2289
2395
|
function _length(length, params) {
|
|
2290
2396
|
return new $ZodCheckLengthEquals({
|
|
2291
2397
|
check: "length_equals",
|
|
@@ -2293,6 +2399,7 @@ function _length(length, params) {
|
|
|
2293
2399
|
length
|
|
2294
2400
|
});
|
|
2295
2401
|
}
|
|
2402
|
+
// @__NO_SIDE_EFFECTS__
|
|
2296
2403
|
function _regex(pattern, params) {
|
|
2297
2404
|
return new $ZodCheckRegex({
|
|
2298
2405
|
check: "string_format",
|
|
@@ -2301,6 +2408,7 @@ function _regex(pattern, params) {
|
|
|
2301
2408
|
pattern
|
|
2302
2409
|
});
|
|
2303
2410
|
}
|
|
2411
|
+
// @__NO_SIDE_EFFECTS__
|
|
2304
2412
|
function _lowercase(params) {
|
|
2305
2413
|
return new $ZodCheckLowerCase({
|
|
2306
2414
|
check: "string_format",
|
|
@@ -2308,6 +2416,7 @@ function _lowercase(params) {
|
|
|
2308
2416
|
...normalizeParams(params)
|
|
2309
2417
|
});
|
|
2310
2418
|
}
|
|
2419
|
+
// @__NO_SIDE_EFFECTS__
|
|
2311
2420
|
function _uppercase(params) {
|
|
2312
2421
|
return new $ZodCheckUpperCase({
|
|
2313
2422
|
check: "string_format",
|
|
@@ -2315,6 +2424,7 @@ function _uppercase(params) {
|
|
|
2315
2424
|
...normalizeParams(params)
|
|
2316
2425
|
});
|
|
2317
2426
|
}
|
|
2427
|
+
// @__NO_SIDE_EFFECTS__
|
|
2318
2428
|
function _includes(includes, params) {
|
|
2319
2429
|
return new $ZodCheckIncludes({
|
|
2320
2430
|
check: "string_format",
|
|
@@ -2323,6 +2433,7 @@ function _includes(includes, params) {
|
|
|
2323
2433
|
includes
|
|
2324
2434
|
});
|
|
2325
2435
|
}
|
|
2436
|
+
// @__NO_SIDE_EFFECTS__
|
|
2326
2437
|
function _startsWith(prefix, params) {
|
|
2327
2438
|
return new $ZodCheckStartsWith({
|
|
2328
2439
|
check: "string_format",
|
|
@@ -2331,6 +2442,7 @@ function _startsWith(prefix, params) {
|
|
|
2331
2442
|
prefix
|
|
2332
2443
|
});
|
|
2333
2444
|
}
|
|
2445
|
+
// @__NO_SIDE_EFFECTS__
|
|
2334
2446
|
function _endsWith(suffix, params) {
|
|
2335
2447
|
return new $ZodCheckEndsWith({
|
|
2336
2448
|
check: "string_format",
|
|
@@ -2339,27 +2451,34 @@ function _endsWith(suffix, params) {
|
|
|
2339
2451
|
suffix
|
|
2340
2452
|
});
|
|
2341
2453
|
}
|
|
2454
|
+
// @__NO_SIDE_EFFECTS__
|
|
2342
2455
|
function _overwrite(tx) {
|
|
2343
2456
|
return new $ZodCheckOverwrite({
|
|
2344
2457
|
check: "overwrite",
|
|
2345
2458
|
tx
|
|
2346
2459
|
});
|
|
2347
2460
|
}
|
|
2461
|
+
// @__NO_SIDE_EFFECTS__
|
|
2348
2462
|
function _normalize(form) {
|
|
2349
|
-
return _overwrite((input) => input.normalize(form));
|
|
2463
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
2350
2464
|
}
|
|
2465
|
+
// @__NO_SIDE_EFFECTS__
|
|
2351
2466
|
function _trim() {
|
|
2352
|
-
return _overwrite((input) => input.trim());
|
|
2467
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
2353
2468
|
}
|
|
2469
|
+
// @__NO_SIDE_EFFECTS__
|
|
2354
2470
|
function _toLowerCase() {
|
|
2355
|
-
return _overwrite((input) => input.toLowerCase());
|
|
2471
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
2356
2472
|
}
|
|
2473
|
+
// @__NO_SIDE_EFFECTS__
|
|
2357
2474
|
function _toUpperCase() {
|
|
2358
|
-
return _overwrite((input) => input.toUpperCase());
|
|
2475
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
2359
2476
|
}
|
|
2477
|
+
// @__NO_SIDE_EFFECTS__
|
|
2360
2478
|
function _slugify() {
|
|
2361
|
-
return _overwrite((input) => slugify(input));
|
|
2479
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
2362
2480
|
}
|
|
2481
|
+
// @__NO_SIDE_EFFECTS__
|
|
2363
2482
|
function _array(Class, element, params) {
|
|
2364
2483
|
return new Class({
|
|
2365
2484
|
type: "array",
|
|
@@ -2370,6 +2489,7 @@ function _array(Class, element, params) {
|
|
|
2370
2489
|
...normalizeParams(params)
|
|
2371
2490
|
});
|
|
2372
2491
|
}
|
|
2492
|
+
// @__NO_SIDE_EFFECTS__
|
|
2373
2493
|
function _refine(Class, fn, _params) {
|
|
2374
2494
|
const schema = new Class({
|
|
2375
2495
|
type: "custom",
|
|
@@ -2379,8 +2499,9 @@ function _refine(Class, fn, _params) {
|
|
|
2379
2499
|
});
|
|
2380
2500
|
return schema;
|
|
2381
2501
|
}
|
|
2502
|
+
// @__NO_SIDE_EFFECTS__
|
|
2382
2503
|
function _superRefine(fn) {
|
|
2383
|
-
const ch = _check((payload) => {
|
|
2504
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
2384
2505
|
payload.addIssue = (issue$1) => {
|
|
2385
2506
|
if (typeof issue$1 === "string") {
|
|
2386
2507
|
payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
@@ -2399,6 +2520,7 @@ function _superRefine(fn) {
|
|
|
2399
2520
|
});
|
|
2400
2521
|
return ch;
|
|
2401
2522
|
}
|
|
2523
|
+
// @__NO_SIDE_EFFECTS__
|
|
2402
2524
|
function _check(fn, params) {
|
|
2403
2525
|
const ch = new $ZodCheck({
|
|
2404
2526
|
check: "custom",
|
|
@@ -2451,12 +2573,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
2451
2573
|
schemaPath: [..._params.schemaPath, schema],
|
|
2452
2574
|
path: _params.path
|
|
2453
2575
|
};
|
|
2454
|
-
|
|
2455
|
-
if (parent) {
|
|
2456
|
-
result.ref = parent;
|
|
2457
|
-
process(parent, ctx, params);
|
|
2458
|
-
ctx.seen.get(parent).isParent = true;
|
|
2459
|
-
} else if (schema._zod.processJSONSchema) {
|
|
2576
|
+
if (schema._zod.processJSONSchema) {
|
|
2460
2577
|
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
2461
2578
|
} else {
|
|
2462
2579
|
const _json = result.schema;
|
|
@@ -2466,6 +2583,13 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
2466
2583
|
}
|
|
2467
2584
|
processor(schema, ctx, _json, params);
|
|
2468
2585
|
}
|
|
2586
|
+
const parent = schema._zod.parent;
|
|
2587
|
+
if (parent) {
|
|
2588
|
+
if (!result.ref)
|
|
2589
|
+
result.ref = parent;
|
|
2590
|
+
process(parent, ctx, params);
|
|
2591
|
+
ctx.seen.get(parent).isParent = true;
|
|
2592
|
+
}
|
|
2469
2593
|
}
|
|
2470
2594
|
const meta = ctx.metadataRegistry.get(schema);
|
|
2471
2595
|
if (meta)
|
|
@@ -2484,6 +2608,17 @@ function extractDefs(ctx, schema) {
|
|
|
2484
2608
|
const root = ctx.seen.get(schema);
|
|
2485
2609
|
if (!root)
|
|
2486
2610
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2611
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
2612
|
+
for (const entry of ctx.seen.entries()) {
|
|
2613
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
2614
|
+
if (id) {
|
|
2615
|
+
const existing = idToSchema.get(id);
|
|
2616
|
+
if (existing && existing !== entry[0]) {
|
|
2617
|
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
2618
|
+
}
|
|
2619
|
+
idToSchema.set(id, entry[0]);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2487
2622
|
const makeURI = (entry) => {
|
|
2488
2623
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2489
2624
|
if (ctx.external) {
|
|
@@ -2565,30 +2700,65 @@ function finalize(ctx, schema) {
|
|
|
2565
2700
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2566
2701
|
const flattenRef = (zodSchema) => {
|
|
2567
2702
|
const seen = ctx.seen.get(zodSchema);
|
|
2703
|
+
if (seen.ref === null)
|
|
2704
|
+
return;
|
|
2568
2705
|
const schema2 = seen.def ?? seen.schema;
|
|
2569
2706
|
const _cached = { ...schema2 };
|
|
2570
|
-
if (seen.ref === null) {
|
|
2571
|
-
return;
|
|
2572
|
-
}
|
|
2573
2707
|
const ref = seen.ref;
|
|
2574
2708
|
seen.ref = null;
|
|
2575
2709
|
if (ref) {
|
|
2576
2710
|
flattenRef(ref);
|
|
2577
|
-
const
|
|
2711
|
+
const refSeen = ctx.seen.get(ref);
|
|
2712
|
+
const refSchema = refSeen.schema;
|
|
2578
2713
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2579
2714
|
schema2.allOf = schema2.allOf ?? [];
|
|
2580
2715
|
schema2.allOf.push(refSchema);
|
|
2581
2716
|
} else {
|
|
2582
2717
|
Object.assign(schema2, refSchema);
|
|
2583
|
-
|
|
2718
|
+
}
|
|
2719
|
+
Object.assign(schema2, _cached);
|
|
2720
|
+
const isParentRef = zodSchema._zod.parent === ref;
|
|
2721
|
+
if (isParentRef) {
|
|
2722
|
+
for (const key in schema2) {
|
|
2723
|
+
if (key === "$ref" || key === "allOf")
|
|
2724
|
+
continue;
|
|
2725
|
+
if (!(key in _cached)) {
|
|
2726
|
+
delete schema2[key];
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
if (refSchema.$ref) {
|
|
2731
|
+
for (const key in schema2) {
|
|
2732
|
+
if (key === "$ref" || key === "allOf")
|
|
2733
|
+
continue;
|
|
2734
|
+
if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
|
|
2735
|
+
delete schema2[key];
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2584
2738
|
}
|
|
2585
2739
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2740
|
+
const parent = zodSchema._zod.parent;
|
|
2741
|
+
if (parent && parent !== ref) {
|
|
2742
|
+
flattenRef(parent);
|
|
2743
|
+
const parentSeen = ctx.seen.get(parent);
|
|
2744
|
+
if (parentSeen?.schema.$ref) {
|
|
2745
|
+
schema2.$ref = parentSeen.schema.$ref;
|
|
2746
|
+
if (parentSeen.def) {
|
|
2747
|
+
for (const key in schema2) {
|
|
2748
|
+
if (key === "$ref" || key === "allOf")
|
|
2749
|
+
continue;
|
|
2750
|
+
if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
2751
|
+
delete schema2[key];
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
ctx.override({
|
|
2758
|
+
zodSchema,
|
|
2759
|
+
jsonSchema: schema2,
|
|
2760
|
+
path: seen.path ?? []
|
|
2761
|
+
});
|
|
2592
2762
|
};
|
|
2593
2763
|
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
2594
2764
|
flattenRef(entry[0]);
|
|
@@ -2632,8 +2802,8 @@ function finalize(ctx, schema) {
|
|
|
2632
2802
|
value: {
|
|
2633
2803
|
...schema["~standard"],
|
|
2634
2804
|
jsonSchema: {
|
|
2635
|
-
input: createStandardJSONSchemaMethod(schema, "input"),
|
|
2636
|
-
output: createStandardJSONSchemaMethod(schema, "output")
|
|
2805
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
2806
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
2637
2807
|
}
|
|
2638
2808
|
},
|
|
2639
2809
|
enumerable: false,
|
|
@@ -2701,9 +2871,9 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
2701
2871
|
extractDefs(ctx, schema);
|
|
2702
2872
|
return finalize(ctx, schema);
|
|
2703
2873
|
};
|
|
2704
|
-
const createStandardJSONSchemaMethod = (schema, io) => (params) => {
|
|
2874
|
+
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
2705
2875
|
const { libraryOptions, target } = params ?? {};
|
|
2706
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors
|
|
2876
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
2707
2877
|
process(schema, ctx);
|
|
2708
2878
|
extractDefs(ctx, schema);
|
|
2709
2879
|
return finalize(ctx, schema);
|
|
@@ -2728,6 +2898,9 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
2728
2898
|
json.format = formatMap[format] ?? format;
|
|
2729
2899
|
if (json.format === "")
|
|
2730
2900
|
delete json.format;
|
|
2901
|
+
if (format === "time") {
|
|
2902
|
+
delete json.format;
|
|
2903
|
+
}
|
|
2731
2904
|
}
|
|
2732
2905
|
if (contentEncoding)
|
|
2733
2906
|
json.contentEncoding = contentEncoding;
|
|
@@ -2919,28 +3092,28 @@ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def
|
|
|
2919
3092
|
ZodStringFormat.init(inst, def);
|
|
2920
3093
|
});
|
|
2921
3094
|
function datetime(params) {
|
|
2922
|
-
return _isoDateTime(ZodISODateTime, params);
|
|
3095
|
+
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
2923
3096
|
}
|
|
2924
3097
|
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
2925
3098
|
$ZodISODate.init(inst, def);
|
|
2926
3099
|
ZodStringFormat.init(inst, def);
|
|
2927
3100
|
});
|
|
2928
3101
|
function date(params) {
|
|
2929
|
-
return _isoDate(ZodISODate, params);
|
|
3102
|
+
return /* @__PURE__ */ _isoDate(ZodISODate, params);
|
|
2930
3103
|
}
|
|
2931
3104
|
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
2932
3105
|
$ZodISOTime.init(inst, def);
|
|
2933
3106
|
ZodStringFormat.init(inst, def);
|
|
2934
3107
|
});
|
|
2935
3108
|
function time(params) {
|
|
2936
|
-
return _isoTime(ZodISOTime, params);
|
|
3109
|
+
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
2937
3110
|
}
|
|
2938
3111
|
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
2939
3112
|
$ZodISODuration.init(inst, def);
|
|
2940
3113
|
ZodStringFormat.init(inst, def);
|
|
2941
3114
|
});
|
|
2942
3115
|
function duration(params) {
|
|
2943
|
-
return _isoDuration(ZodISODuration, params);
|
|
3116
|
+
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
2944
3117
|
}
|
|
2945
3118
|
const initializer = (inst, issues) => {
|
|
2946
3119
|
$ZodError.init(inst, issues);
|
|
@@ -3009,8 +3182,11 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
3009
3182
|
...def.checks ?? [],
|
|
3010
3183
|
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
3011
3184
|
]
|
|
3012
|
-
})
|
|
3185
|
+
}), {
|
|
3186
|
+
parent: true
|
|
3187
|
+
});
|
|
3013
3188
|
};
|
|
3189
|
+
inst.with = inst.check;
|
|
3014
3190
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
3015
3191
|
inst.brand = () => inst;
|
|
3016
3192
|
inst.register = ((reg, meta) => {
|
|
@@ -3032,8 +3208,9 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
3032
3208
|
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3033
3209
|
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
3034
3210
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
3035
|
-
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
3211
|
+
inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
|
|
3036
3212
|
inst.optional = () => optional(inst);
|
|
3213
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
3037
3214
|
inst.nullable = () => nullable(inst);
|
|
3038
3215
|
inst.nullish = () => optional(nullable(inst));
|
|
3039
3216
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
@@ -3067,6 +3244,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
3067
3244
|
};
|
|
3068
3245
|
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
3069
3246
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
3247
|
+
inst.apply = (fn) => fn(inst);
|
|
3070
3248
|
return inst;
|
|
3071
3249
|
});
|
|
3072
3250
|
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
@@ -3077,55 +3255,55 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
3077
3255
|
inst.format = bag.format ?? null;
|
|
3078
3256
|
inst.minLength = bag.minimum ?? null;
|
|
3079
3257
|
inst.maxLength = bag.maximum ?? null;
|
|
3080
|
-
inst.regex = (...args) => inst.check(_regex(...args));
|
|
3081
|
-
inst.includes = (...args) => inst.check(_includes(...args));
|
|
3082
|
-
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
3083
|
-
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
3084
|
-
inst.min = (...args) => inst.check(_minLength(...args));
|
|
3085
|
-
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
3086
|
-
inst.length = (...args) => inst.check(_length(...args));
|
|
3087
|
-
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
3088
|
-
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
3089
|
-
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
3090
|
-
inst.trim = () => inst.check(_trim());
|
|
3091
|
-
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
3092
|
-
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
3093
|
-
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
3094
|
-
inst.slugify = () => inst.check(_slugify());
|
|
3258
|
+
inst.regex = (...args) => inst.check(/* @__PURE__ */ _regex(...args));
|
|
3259
|
+
inst.includes = (...args) => inst.check(/* @__PURE__ */ _includes(...args));
|
|
3260
|
+
inst.startsWith = (...args) => inst.check(/* @__PURE__ */ _startsWith(...args));
|
|
3261
|
+
inst.endsWith = (...args) => inst.check(/* @__PURE__ */ _endsWith(...args));
|
|
3262
|
+
inst.min = (...args) => inst.check(/* @__PURE__ */ _minLength(...args));
|
|
3263
|
+
inst.max = (...args) => inst.check(/* @__PURE__ */ _maxLength(...args));
|
|
3264
|
+
inst.length = (...args) => inst.check(/* @__PURE__ */ _length(...args));
|
|
3265
|
+
inst.nonempty = (...args) => inst.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
3266
|
+
inst.lowercase = (params) => inst.check(/* @__PURE__ */ _lowercase(params));
|
|
3267
|
+
inst.uppercase = (params) => inst.check(/* @__PURE__ */ _uppercase(params));
|
|
3268
|
+
inst.trim = () => inst.check(/* @__PURE__ */ _trim());
|
|
3269
|
+
inst.normalize = (...args) => inst.check(/* @__PURE__ */ _normalize(...args));
|
|
3270
|
+
inst.toLowerCase = () => inst.check(/* @__PURE__ */ _toLowerCase());
|
|
3271
|
+
inst.toUpperCase = () => inst.check(/* @__PURE__ */ _toUpperCase());
|
|
3272
|
+
inst.slugify = () => inst.check(/* @__PURE__ */ _slugify());
|
|
3095
3273
|
});
|
|
3096
3274
|
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
3097
3275
|
$ZodString.init(inst, def);
|
|
3098
3276
|
_ZodString.init(inst, def);
|
|
3099
|
-
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
3100
|
-
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
3101
|
-
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
3102
|
-
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
3103
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
3104
|
-
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
3105
|
-
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
3106
|
-
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
3107
|
-
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
3108
|
-
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
3109
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
3110
|
-
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
3111
|
-
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
3112
|
-
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
3113
|
-
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
3114
|
-
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
3115
|
-
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
3116
|
-
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
3117
|
-
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
3118
|
-
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
3119
|
-
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
3120
|
-
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
3121
|
-
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
3277
|
+
inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
3278
|
+
inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
3279
|
+
inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
3280
|
+
inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
3281
|
+
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
3282
|
+
inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
3283
|
+
inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
3284
|
+
inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
3285
|
+
inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
3286
|
+
inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
3287
|
+
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
3288
|
+
inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
3289
|
+
inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
3290
|
+
inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
3291
|
+
inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
3292
|
+
inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
3293
|
+
inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
3294
|
+
inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
3295
|
+
inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
3296
|
+
inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
3297
|
+
inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
3298
|
+
inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
3299
|
+
inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
3122
3300
|
inst.datetime = (params) => inst.check(datetime(params));
|
|
3123
3301
|
inst.date = (params) => inst.check(date(params));
|
|
3124
3302
|
inst.time = (params) => inst.check(time(params));
|
|
3125
3303
|
inst.duration = (params) => inst.check(duration(params));
|
|
3126
3304
|
});
|
|
3127
3305
|
function string(params) {
|
|
3128
|
-
return _string(ZodString, params);
|
|
3306
|
+
return /* @__PURE__ */ _string(ZodString, params);
|
|
3129
3307
|
}
|
|
3130
3308
|
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
3131
3309
|
$ZodStringFormat.init(inst, def);
|
|
@@ -3213,7 +3391,7 @@ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
|
3213
3391
|
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
|
|
3214
3392
|
});
|
|
3215
3393
|
function boolean(params) {
|
|
3216
|
-
return _boolean(ZodBoolean, params);
|
|
3394
|
+
return /* @__PURE__ */ _boolean(ZodBoolean, params);
|
|
3217
3395
|
}
|
|
3218
3396
|
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
3219
3397
|
$ZodUnknown.init(inst, def);
|
|
@@ -3221,7 +3399,7 @@ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
|
3221
3399
|
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
|
|
3222
3400
|
});
|
|
3223
3401
|
function unknown() {
|
|
3224
|
-
return _unknown(ZodUnknown);
|
|
3402
|
+
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
3225
3403
|
}
|
|
3226
3404
|
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
3227
3405
|
$ZodNever.init(inst, def);
|
|
@@ -3229,21 +3407,21 @@ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
|
3229
3407
|
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
|
|
3230
3408
|
});
|
|
3231
3409
|
function never(params) {
|
|
3232
|
-
return _never(ZodNever, params);
|
|
3410
|
+
return /* @__PURE__ */ _never(ZodNever, params);
|
|
3233
3411
|
}
|
|
3234
3412
|
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
3235
3413
|
$ZodArray.init(inst, def);
|
|
3236
3414
|
ZodType.init(inst, def);
|
|
3237
3415
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3238
3416
|
inst.element = def.element;
|
|
3239
|
-
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
3240
|
-
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
3241
|
-
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
3242
|
-
inst.length = (len, params) => inst.check(_length(len, params));
|
|
3417
|
+
inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
|
|
3418
|
+
inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
|
|
3419
|
+
inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
|
|
3420
|
+
inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
|
|
3243
3421
|
inst.unwrap = () => inst.element;
|
|
3244
3422
|
});
|
|
3245
3423
|
function array(element, params) {
|
|
3246
|
-
return _array(ZodArray, element, params);
|
|
3424
|
+
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
3247
3425
|
}
|
|
3248
3426
|
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
3249
3427
|
$ZodObjectJIT.init(inst, def);
|
|
@@ -3399,6 +3577,18 @@ function optional(innerType) {
|
|
|
3399
3577
|
innerType
|
|
3400
3578
|
});
|
|
3401
3579
|
}
|
|
3580
|
+
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
3581
|
+
$ZodExactOptional.init(inst, def);
|
|
3582
|
+
ZodType.init(inst, def);
|
|
3583
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3584
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3585
|
+
});
|
|
3586
|
+
function exactOptional(innerType) {
|
|
3587
|
+
return new ZodExactOptional({
|
|
3588
|
+
type: "optional",
|
|
3589
|
+
innerType
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3402
3592
|
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3403
3593
|
$ZodNullable.init(inst, def);
|
|
3404
3594
|
ZodType.init(inst, def);
|
|
@@ -3502,10 +3692,10 @@ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
|
3502
3692
|
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
|
|
3503
3693
|
});
|
|
3504
3694
|
function refine(fn, _params = {}) {
|
|
3505
|
-
return _refine(ZodCustom, fn, _params);
|
|
3695
|
+
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
3506
3696
|
}
|
|
3507
3697
|
function superRefine(fn) {
|
|
3508
|
-
return _superRefine(fn);
|
|
3698
|
+
return /* @__PURE__ */ _superRefine(fn);
|
|
3509
3699
|
}
|
|
3510
3700
|
export {
|
|
3511
3701
|
array as a,
|