@istarry/dsh-assistant-profile 0.4.3 → 0.4.5
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/lib/client.js +1031 -2235
- package/lib/client.js.map +1 -1
- package/package.json +1 -16
package/lib/client.js
CHANGED
|
@@ -1159,34 +1159,83 @@ window.__ModuleLoader__.load({
|
|
|
1159
1159
|
return options;
|
|
1160
1160
|
}
|
|
1161
1161
|
//#endregion
|
|
1162
|
+
//#region ../src/node_modules/zod/v4/core/core.js
|
|
1163
|
+
var _a$1;
|
|
1164
|
+
function $constructor(name, initializer, params) {
|
|
1165
|
+
function init(inst, def) {
|
|
1166
|
+
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
1167
|
+
value: {
|
|
1168
|
+
def,
|
|
1169
|
+
constr: _,
|
|
1170
|
+
traits: /* @__PURE__ */ new Set()
|
|
1171
|
+
},
|
|
1172
|
+
enumerable: false
|
|
1173
|
+
});
|
|
1174
|
+
if (inst._zod.traits.has(name)) return;
|
|
1175
|
+
inst._zod.traits.add(name);
|
|
1176
|
+
initializer(inst, def);
|
|
1177
|
+
const proto = _.prototype;
|
|
1178
|
+
const keys = Object.keys(proto);
|
|
1179
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1180
|
+
const k = keys[i];
|
|
1181
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
const Parent = params?.Parent ?? Object;
|
|
1185
|
+
class Definition extends Parent {}
|
|
1186
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
1187
|
+
function _(def) {
|
|
1188
|
+
var _a;
|
|
1189
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
1190
|
+
init(inst, def);
|
|
1191
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1192
|
+
for (const fn of inst._zod.deferred) fn();
|
|
1193
|
+
return inst;
|
|
1194
|
+
}
|
|
1195
|
+
Object.defineProperty(_, "init", { value: init });
|
|
1196
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
1197
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
1198
|
+
return inst?._zod?.traits?.has(name);
|
|
1199
|
+
} });
|
|
1200
|
+
Object.defineProperty(_, "name", { value: name });
|
|
1201
|
+
return _;
|
|
1202
|
+
}
|
|
1203
|
+
var $ZodAsyncError = class extends Error {
|
|
1204
|
+
constructor() {
|
|
1205
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
var $ZodEncodeError = class extends Error {
|
|
1209
|
+
constructor(name) {
|
|
1210
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
1211
|
+
this.name = "ZodEncodeError";
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
1215
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
1216
|
+
function config(newConfig) {
|
|
1217
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
1218
|
+
return globalConfig;
|
|
1219
|
+
}
|
|
1220
|
+
//#endregion
|
|
1162
1221
|
//#region ../src/node_modules/zod/v4/core/util.js
|
|
1163
1222
|
function getEnumValues(entries) {
|
|
1164
1223
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
1165
1224
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
1166
1225
|
}
|
|
1167
|
-
function joinValues(array, separator = "|") {
|
|
1168
|
-
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
1169
|
-
}
|
|
1170
1226
|
function jsonStringifyReplacer(_, value) {
|
|
1171
1227
|
if (typeof value === "bigint") return value.toString();
|
|
1172
1228
|
return value;
|
|
1173
1229
|
}
|
|
1174
|
-
var Cached = class {
|
|
1175
|
-
constructor(getter) {
|
|
1176
|
-
this._getter = getter;
|
|
1177
|
-
this._value = void 0;
|
|
1178
|
-
}
|
|
1179
|
-
get value() {
|
|
1180
|
-
const getter = this._getter;
|
|
1181
|
-
if (getter !== void 0) {
|
|
1182
|
-
this._value = getter();
|
|
1183
|
-
this._getter = void 0;
|
|
1184
|
-
}
|
|
1185
|
-
return this._value;
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
1230
|
function cached(getter) {
|
|
1189
|
-
return
|
|
1231
|
+
return { get value() {
|
|
1232
|
+
{
|
|
1233
|
+
const value = getter();
|
|
1234
|
+
Object.defineProperty(this, "value", { value });
|
|
1235
|
+
return value;
|
|
1236
|
+
}
|
|
1237
|
+
throw new Error("cached value already set");
|
|
1238
|
+
} };
|
|
1190
1239
|
}
|
|
1191
1240
|
function nullish(input) {
|
|
1192
1241
|
return input === null || input === void 0;
|
|
@@ -1196,6 +1245,24 @@ window.__ModuleLoader__.load({
|
|
|
1196
1245
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1197
1246
|
return source.slice(start, end);
|
|
1198
1247
|
}
|
|
1248
|
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
1249
|
+
function defineLazy(object, key, getter) {
|
|
1250
|
+
let value = void 0;
|
|
1251
|
+
Object.defineProperty(object, key, {
|
|
1252
|
+
get() {
|
|
1253
|
+
if (value === EVALUATING) return;
|
|
1254
|
+
if (value === void 0) {
|
|
1255
|
+
value = EVALUATING;
|
|
1256
|
+
value = getter();
|
|
1257
|
+
}
|
|
1258
|
+
return value;
|
|
1259
|
+
},
|
|
1260
|
+
set(v) {
|
|
1261
|
+
Object.defineProperty(object, key, { value: v });
|
|
1262
|
+
},
|
|
1263
|
+
configurable: true
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1199
1266
|
function assignProp(target, prop, value) {
|
|
1200
1267
|
Object.defineProperty(target, prop, {
|
|
1201
1268
|
value,
|
|
@@ -1204,58 +1271,6 @@ window.__ModuleLoader__.load({
|
|
|
1204
1271
|
configurable: true
|
|
1205
1272
|
});
|
|
1206
1273
|
}
|
|
1207
|
-
/**
|
|
1208
|
-
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
1209
|
-
*
|
|
1210
|
-
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
|
|
1211
|
-
*/
|
|
1212
|
-
function rawShape(def) {
|
|
1213
|
-
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1214
|
-
return desc?.get ? desc.get.raw : desc?.value;
|
|
1215
|
-
}
|
|
1216
|
-
function sourceShape(schema) {
|
|
1217
|
-
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
1218
|
-
}
|
|
1219
|
-
function deferProp(target, key, getter) {
|
|
1220
|
-
Object.defineProperty(target, key, {
|
|
1221
|
-
get() {
|
|
1222
|
-
const value = getter();
|
|
1223
|
-
assignProp(this, key, value);
|
|
1224
|
-
return value;
|
|
1225
|
-
},
|
|
1226
|
-
enumerable: true,
|
|
1227
|
-
configurable: true
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
function putProp(target, key, value) {
|
|
1231
|
-
if (key in target) assignProp(target, key, value);
|
|
1232
|
-
else target[key] = value;
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
1236
|
-
*
|
|
1237
|
-
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
|
|
1238
|
-
*/
|
|
1239
|
-
function mirrorShape(target, source, keys, wrap) {
|
|
1240
|
-
const raw = sourceShape(source);
|
|
1241
|
-
for (const key of keys) {
|
|
1242
|
-
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
1243
|
-
if (!desc.enumerable) continue;
|
|
1244
|
-
if (desc.get) deferProp(target, key, () => {
|
|
1245
|
-
const value = source._zod.def.shape[key];
|
|
1246
|
-
return wrap ? wrap(value, key) : value;
|
|
1247
|
-
});
|
|
1248
|
-
else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
function mirrorProps(target, source) {
|
|
1252
|
-
for (const key of Reflect.ownKeys(source)) {
|
|
1253
|
-
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1254
|
-
if (!desc.enumerable) continue;
|
|
1255
|
-
if (desc.get) deferProp(target, key, () => source[key]);
|
|
1256
|
-
else putProp(target, key, desc.value);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
1274
|
function mergeDefs(...defs) {
|
|
1260
1275
|
const mergedDescriptors = {};
|
|
1261
1276
|
for (const def of defs) {
|
|
@@ -1329,56 +1344,45 @@ window.__ModuleLoader__.load({
|
|
|
1329
1344
|
};
|
|
1330
1345
|
return params;
|
|
1331
1346
|
}
|
|
1332
|
-
function stringifyPrimitive(value) {
|
|
1333
|
-
if (typeof value === "bigint") return value.toString() + "n";
|
|
1334
|
-
if (typeof value === "string") return `"${value}"`;
|
|
1335
|
-
return `${value}`;
|
|
1336
|
-
}
|
|
1337
1347
|
function optionalKeys(shape) {
|
|
1338
1348
|
return Object.keys(shape).filter((k) => {
|
|
1339
|
-
return shape[k]._zod.optin
|
|
1349
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
1340
1350
|
});
|
|
1341
1351
|
}
|
|
1342
|
-
|
|
1343
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
1344
|
-
int32: [-2147483648, 2147483647],
|
|
1345
|
-
uint32: [0, 4294967295],
|
|
1346
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
1347
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
1348
|
-
}))();
|
|
1349
|
-
const BIGINT_FORMAT_RANGES = {
|
|
1350
|
-
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
1351
|
-
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
|
|
1352
|
-
};
|
|
1352
|
+
Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
|
|
1353
1353
|
function pick(schema, mask) {
|
|
1354
1354
|
const currDef = schema._zod.def;
|
|
1355
1355
|
const checks = currDef.checks;
|
|
1356
1356
|
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1357
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1358
|
+
get shape() {
|
|
1359
|
+
const newShape = {};
|
|
1360
|
+
for (const key in mask) {
|
|
1361
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1362
|
+
if (!mask[key]) continue;
|
|
1363
|
+
newShape[key] = currDef.shape[key];
|
|
1364
|
+
}
|
|
1365
|
+
assignProp(this, "shape", newShape);
|
|
1366
|
+
return newShape;
|
|
1367
|
+
},
|
|
1361
1368
|
checks: []
|
|
1362
1369
|
}));
|
|
1363
1370
|
}
|
|
1364
|
-
function maskedKeys(schema, mask) {
|
|
1365
|
-
const raw = sourceShape(schema);
|
|
1366
|
-
const keys = [];
|
|
1367
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
1368
|
-
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
1369
|
-
if (mask[key]) keys.push(key);
|
|
1370
|
-
}
|
|
1371
|
-
return keys;
|
|
1372
|
-
}
|
|
1373
1371
|
function omit(schema, mask) {
|
|
1374
1372
|
const currDef = schema._zod.def;
|
|
1375
1373
|
const checks = currDef.checks;
|
|
1376
1374
|
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1375
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1376
|
+
get shape() {
|
|
1377
|
+
const newShape = { ...schema._zod.def.shape };
|
|
1378
|
+
for (const key in mask) {
|
|
1379
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1380
|
+
if (!mask[key]) continue;
|
|
1381
|
+
delete newShape[key];
|
|
1382
|
+
}
|
|
1383
|
+
assignProp(this, "shape", newShape);
|
|
1384
|
+
return newShape;
|
|
1385
|
+
},
|
|
1382
1386
|
checks: []
|
|
1383
1387
|
}));
|
|
1384
1388
|
}
|
|
@@ -1386,57 +1390,90 @@ window.__ModuleLoader__.load({
|
|
|
1386
1390
|
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
1387
1391
|
const checks = schema._zod.def.checks;
|
|
1388
1392
|
if (checks && checks.length > 0) {
|
|
1389
|
-
const existingShape =
|
|
1390
|
-
for (const key
|
|
1393
|
+
const existingShape = schema._zod.def.shape;
|
|
1394
|
+
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1391
1395
|
}
|
|
1392
|
-
return clone(schema, mergeDefs(schema._zod.def, { shape
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1396
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1397
|
+
const _shape = {
|
|
1398
|
+
...schema._zod.def.shape,
|
|
1399
|
+
...shape
|
|
1400
|
+
};
|
|
1401
|
+
assignProp(this, "shape", _shape);
|
|
1402
|
+
return _shape;
|
|
1403
|
+
} }));
|
|
1399
1404
|
}
|
|
1400
1405
|
function safeExtend(schema, shape) {
|
|
1401
1406
|
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1402
|
-
return clone(schema, mergeDefs(schema._zod.def, { shape
|
|
1407
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1408
|
+
const _shape = {
|
|
1409
|
+
...schema._zod.def.shape,
|
|
1410
|
+
...shape
|
|
1411
|
+
};
|
|
1412
|
+
assignProp(this, "shape", _shape);
|
|
1413
|
+
return _shape;
|
|
1414
|
+
} }));
|
|
1403
1415
|
}
|
|
1404
1416
|
function merge(a, b) {
|
|
1405
|
-
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
1406
1417
|
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
1407
|
-
const newShape = {};
|
|
1408
|
-
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
1409
|
-
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
1410
1418
|
return clone(a, mergeDefs(a._zod.def, {
|
|
1411
|
-
shape
|
|
1419
|
+
get shape() {
|
|
1420
|
+
const _shape = {
|
|
1421
|
+
...a._zod.def.shape,
|
|
1422
|
+
...b._zod.def.shape
|
|
1423
|
+
};
|
|
1424
|
+
assignProp(this, "shape", _shape);
|
|
1425
|
+
return _shape;
|
|
1426
|
+
},
|
|
1412
1427
|
get catchall() {
|
|
1413
1428
|
return b._zod.def.catchall;
|
|
1414
1429
|
},
|
|
1415
1430
|
checks: b._zod.def.checks ?? []
|
|
1416
1431
|
}));
|
|
1417
1432
|
}
|
|
1418
|
-
function partial(Class, schema, mask
|
|
1433
|
+
function partial(Class, schema, mask) {
|
|
1419
1434
|
const checks = schema._zod.def.checks;
|
|
1420
|
-
if (checks && checks.length > 0) throw new Error(
|
|
1421
|
-
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
1422
|
-
const newShape = {};
|
|
1423
|
-
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
|
|
1424
|
-
type: "optional",
|
|
1425
|
-
innerType: value
|
|
1426
|
-
})));
|
|
1435
|
+
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1427
1436
|
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1428
|
-
shape
|
|
1437
|
+
get shape() {
|
|
1438
|
+
const oldShape = schema._zod.def.shape;
|
|
1439
|
+
const shape = { ...oldShape };
|
|
1440
|
+
if (mask) for (const key in mask) {
|
|
1441
|
+
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1442
|
+
if (!mask[key]) continue;
|
|
1443
|
+
shape[key] = Class ? new Class({
|
|
1444
|
+
type: "optional",
|
|
1445
|
+
innerType: oldShape[key]
|
|
1446
|
+
}) : oldShape[key];
|
|
1447
|
+
}
|
|
1448
|
+
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
1449
|
+
type: "optional",
|
|
1450
|
+
innerType: oldShape[key]
|
|
1451
|
+
}) : oldShape[key];
|
|
1452
|
+
assignProp(this, "shape", shape);
|
|
1453
|
+
return shape;
|
|
1454
|
+
},
|
|
1429
1455
|
checks: []
|
|
1430
1456
|
}));
|
|
1431
1457
|
}
|
|
1432
1458
|
function required(Class, schema, mask) {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1459
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1460
|
+
const oldShape = schema._zod.def.shape;
|
|
1461
|
+
const shape = { ...oldShape };
|
|
1462
|
+
if (mask) for (const key in mask) {
|
|
1463
|
+
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1464
|
+
if (!mask[key]) continue;
|
|
1465
|
+
shape[key] = new Class({
|
|
1466
|
+
type: "nonoptional",
|
|
1467
|
+
innerType: oldShape[key]
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
else for (const key in oldShape) shape[key] = new Class({
|
|
1471
|
+
type: "nonoptional",
|
|
1472
|
+
innerType: oldShape[key]
|
|
1473
|
+
});
|
|
1474
|
+
assignProp(this, "shape", shape);
|
|
1475
|
+
return shape;
|
|
1476
|
+
} }));
|
|
1440
1477
|
}
|
|
1441
1478
|
function aborted(x, startIndex = 0) {
|
|
1442
1479
|
if (x.aborted === true) return true;
|
|
@@ -1459,67 +1496,19 @@ window.__ModuleLoader__.load({
|
|
|
1459
1496
|
function unwrapMessage(message) {
|
|
1460
1497
|
return typeof message === "string" ? message : message?.message;
|
|
1461
1498
|
}
|
|
1462
|
-
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
1463
|
-
function sizeCaps(defChecks) {
|
|
1464
|
-
const caps = [];
|
|
1465
|
-
for (const ch of defChecks ?? []) {
|
|
1466
|
-
const d = ch._zod.def;
|
|
1467
|
-
if (!/_(length|size)$|_equals$/.test(d.check)) break;
|
|
1468
|
-
const max = d.maximum ?? d.length ?? d.size;
|
|
1469
|
-
if (max >= 0) caps.push([max, ch]);
|
|
1470
|
-
}
|
|
1471
|
-
return caps;
|
|
1472
|
-
}
|
|
1473
|
-
function attachSchema(issues, start, inst) {
|
|
1474
|
-
var _a;
|
|
1475
|
-
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
|
|
1476
|
-
}
|
|
1477
1499
|
function finalizeIssue(iss, ctx, config) {
|
|
1478
|
-
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
const full = {};
|
|
1485
|
-
for (const k of Object.keys(iss)) {
|
|
1486
|
-
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
|
|
1487
|
-
full[k] = iss[k];
|
|
1488
|
-
}
|
|
1489
|
-
full.path ?? (full.path = []);
|
|
1490
|
-
full.message = message;
|
|
1491
|
-
if (ctx?.reportInput) full.input = iss.input;
|
|
1492
|
-
return full;
|
|
1493
|
-
}
|
|
1494
|
-
const highSurrogate = /[\uD800-\uDBFF]/;
|
|
1495
|
-
function codePointLength(str) {
|
|
1496
|
-
const units = str.length;
|
|
1497
|
-
if (!highSurrogate.test(str)) return units;
|
|
1498
|
-
let count = units;
|
|
1499
|
-
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
1500
|
-
count--;
|
|
1501
|
-
i++;
|
|
1502
|
-
}
|
|
1503
|
-
return count;
|
|
1500
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
1501
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
1502
|
+
rest.path ?? (rest.path = []);
|
|
1503
|
+
rest.message = message;
|
|
1504
|
+
if (ctx?.reportInput) rest.input = _input;
|
|
1505
|
+
return rest;
|
|
1504
1506
|
}
|
|
1505
1507
|
function getLengthableOrigin(input) {
|
|
1506
1508
|
if (Array.isArray(input)) return "array";
|
|
1507
1509
|
if (typeof input === "string") return "string";
|
|
1508
1510
|
return "unknown";
|
|
1509
1511
|
}
|
|
1510
|
-
function parsedType(data) {
|
|
1511
|
-
const t = typeof data;
|
|
1512
|
-
switch (t) {
|
|
1513
|
-
case "number": return Number.isNaN(data) ? "nan" : "number";
|
|
1514
|
-
case "object": {
|
|
1515
|
-
if (data === null) return "null";
|
|
1516
|
-
if (Array.isArray(data)) return "array";
|
|
1517
|
-
const obj = data;
|
|
1518
|
-
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
return t;
|
|
1522
|
-
}
|
|
1523
1512
|
function issue(...args) {
|
|
1524
1513
|
const [iss, input, inst] = args;
|
|
1525
1514
|
if (typeof iss === "string") return {
|
|
@@ -1530,337 +1519,33 @@ window.__ModuleLoader__.load({
|
|
|
1530
1519
|
};
|
|
1531
1520
|
return { ...iss };
|
|
1532
1521
|
}
|
|
1533
|
-
/**
|
|
1534
|
-
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
|
|
1535
|
-
*
|
|
1536
|
-
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
|
|
1537
|
-
*/
|
|
1538
|
-
function members(proto, table) {
|
|
1539
|
-
for (const key in table) {
|
|
1540
|
-
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
1541
|
-
if (desc.get) Object.defineProperty(proto, key, {
|
|
1542
|
-
...desc,
|
|
1543
|
-
enumerable: false
|
|
1544
|
-
});
|
|
1545
|
-
else defineBound(proto, key, desc.value);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
1549
|
-
function own(inst, key, value, enumerable = true) {
|
|
1550
|
-
Object.defineProperty(inst, key, {
|
|
1551
|
-
configurable: true,
|
|
1552
|
-
writable: true,
|
|
1553
|
-
enumerable,
|
|
1554
|
-
value
|
|
1555
|
-
});
|
|
1556
|
-
return value;
|
|
1557
|
-
}
|
|
1558
|
-
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
|
|
1559
|
-
function hide(inst, key, value) {
|
|
1560
|
-
return own(inst, key, value, false);
|
|
1561
|
-
}
|
|
1562
|
-
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
|
|
1563
|
-
function derived(computes, table) {
|
|
1564
|
-
for (const key in computes) {
|
|
1565
|
-
const compute = computes[key];
|
|
1566
|
-
Object.defineProperty(table, key, {
|
|
1567
|
-
configurable: true,
|
|
1568
|
-
enumerable: true,
|
|
1569
|
-
get() {
|
|
1570
|
-
return own(this, key, compute(this));
|
|
1571
|
-
},
|
|
1572
|
-
set(value) {
|
|
1573
|
-
own(this, key, value);
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
return table;
|
|
1578
|
-
}
|
|
1579
|
-
function defineBound(proto, key, fn) {
|
|
1580
|
-
Object.defineProperty(proto, key, {
|
|
1581
|
-
configurable: true,
|
|
1582
|
-
get() {
|
|
1583
|
-
return this == null ? fn : own(this, key, fn.bind(this));
|
|
1584
|
-
},
|
|
1585
|
-
set(value) {
|
|
1586
|
-
own(this, key, value);
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
|
|
1591
|
-
function claim(inst, sentinel) {
|
|
1592
|
-
const proto = Object.getPrototypeOf(inst);
|
|
1593
|
-
return sentinel in proto ? void 0 : proto;
|
|
1594
|
-
}
|
|
1595
|
-
let installing;
|
|
1596
|
-
let broke = false;
|
|
1597
|
-
const breaker = {
|
|
1598
|
-
configurable: true,
|
|
1599
|
-
get() {
|
|
1600
|
-
broke = true;
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
|
-
/**
|
|
1604
|
-
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
|
|
1605
|
-
* constructor, computed from the internals object itself and cached there on
|
|
1606
|
-
* first read. One accessor per constructor rather than one per instance.
|
|
1607
|
-
*/
|
|
1608
|
-
function defineLazyInternal(inst, key, compute) {
|
|
1609
|
-
const proto = Object.getPrototypeOf(inst._zod);
|
|
1610
|
-
if (key in proto && installing !== inst._zod) {
|
|
1611
|
-
installing = void 0;
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
installing = inst._zod;
|
|
1615
|
-
Object.defineProperty(proto, key, {
|
|
1616
|
-
configurable: true,
|
|
1617
|
-
get() {
|
|
1618
|
-
Object.defineProperty(this, key, breaker);
|
|
1619
|
-
const outer = broke;
|
|
1620
|
-
broke = false;
|
|
1621
|
-
try {
|
|
1622
|
-
const value = compute(this);
|
|
1623
|
-
if (broke) delete this[key];
|
|
1624
|
-
else Object.defineProperty(this, key, {
|
|
1625
|
-
configurable: true,
|
|
1626
|
-
writable: true,
|
|
1627
|
-
value
|
|
1628
|
-
});
|
|
1629
|
-
broke = broke || outer;
|
|
1630
|
-
return value;
|
|
1631
|
-
} catch (err) {
|
|
1632
|
-
delete this[key];
|
|
1633
|
-
broke = broke || outer;
|
|
1634
|
-
throw err;
|
|
1635
|
-
}
|
|
1636
|
-
},
|
|
1637
|
-
set(value) {
|
|
1638
|
-
Object.defineProperty(this, key, {
|
|
1639
|
-
configurable: true,
|
|
1640
|
-
writable: true,
|
|
1641
|
-
value
|
|
1642
|
-
});
|
|
1643
|
-
}
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
/**
|
|
1647
|
-
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
|
|
1648
|
-
* data property. One accessor per constructor rather than one per instance, because an own accessor
|
|
1649
|
-
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
|
|
1650
|
-
*/
|
|
1651
|
-
function installLazyProp(inst, key, make, enumerable) {
|
|
1652
|
-
const proto = claim(inst, key);
|
|
1653
|
-
if (!proto) return;
|
|
1654
|
-
Object.defineProperty(proto, key, {
|
|
1655
|
-
configurable: true,
|
|
1656
|
-
get() {
|
|
1657
|
-
const desc = {
|
|
1658
|
-
configurable: true,
|
|
1659
|
-
writable: true,
|
|
1660
|
-
enumerable,
|
|
1661
|
-
value: void 0
|
|
1662
|
-
};
|
|
1663
|
-
Object.defineProperty(this, key, desc);
|
|
1664
|
-
desc.value = make(this);
|
|
1665
|
-
Object.defineProperty(this, key, desc);
|
|
1666
|
-
return desc.value;
|
|
1667
|
-
},
|
|
1668
|
-
set(value) {
|
|
1669
|
-
Object.defineProperty(this, key, {
|
|
1670
|
-
configurable: true,
|
|
1671
|
-
writable: true,
|
|
1672
|
-
enumerable,
|
|
1673
|
-
value
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
|
|
1679
|
-
const CONSTANT_CATCH = "~constantCatch";
|
|
1680
|
-
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
|
|
1681
|
-
function constantCatch(value) {
|
|
1682
|
-
const fn = () => value;
|
|
1683
|
-
fn[CONSTANT_CATCH] = true;
|
|
1684
|
-
return fn;
|
|
1685
|
-
}
|
|
1686
|
-
//#endregion
|
|
1687
|
-
//#region ../src/node_modules/zod/v4/core/core.js
|
|
1688
|
-
var _a$1;
|
|
1689
|
-
const _zodDesc = {
|
|
1690
|
-
value: void 0,
|
|
1691
|
-
enumerable: false
|
|
1692
|
-
};
|
|
1693
|
-
let _E = "captureStackTrace" in Error ? Error : null;
|
|
1694
|
-
function newError(Definition) {
|
|
1695
|
-
const E = _E;
|
|
1696
|
-
if (E) {
|
|
1697
|
-
const saved = E.stackTraceLimit;
|
|
1698
|
-
if (typeof saved === "number") {
|
|
1699
|
-
try {
|
|
1700
|
-
E.stackTraceLimit = 0;
|
|
1701
|
-
} catch {
|
|
1702
|
-
_E = null;
|
|
1703
|
-
return new Definition();
|
|
1704
|
-
}
|
|
1705
|
-
try {
|
|
1706
|
-
return new Definition();
|
|
1707
|
-
} finally {
|
|
1708
|
-
E.stackTraceLimit = saved;
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
return new Definition();
|
|
1713
|
-
}
|
|
1714
|
-
function $constructor(name, initializer, proto, params) {
|
|
1715
|
-
const zodProto = {};
|
|
1716
|
-
function Internals(def) {
|
|
1717
|
-
this.def = def;
|
|
1718
|
-
this.constr = _;
|
|
1719
|
-
this.traits = /* @__PURE__ */ new Set();
|
|
1720
|
-
}
|
|
1721
|
-
Internals.prototype = zodProto;
|
|
1722
|
-
const protoMembers = proto;
|
|
1723
|
-
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
1724
|
-
function init(inst, def) {
|
|
1725
|
-
if (!inst._zod) {
|
|
1726
|
-
_zodDesc.value = new Internals(def);
|
|
1727
|
-
try {
|
|
1728
|
-
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
1729
|
-
} finally {
|
|
1730
|
-
_zodDesc.value = void 0;
|
|
1731
|
-
}
|
|
1732
|
-
} else if (inst._zod.traits.has(name)) return;
|
|
1733
|
-
inst._zod.traits.add(name);
|
|
1734
|
-
initializer(inst, def);
|
|
1735
|
-
if (initialized) {
|
|
1736
|
-
const own = Object.getPrototypeOf(inst);
|
|
1737
|
-
const ctorProto = inst._zod.constr.prototype;
|
|
1738
|
-
let up = own;
|
|
1739
|
-
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
1740
|
-
const target = up ?? own;
|
|
1741
|
-
if (!initialized.has(target)) {
|
|
1742
|
-
initialized.add(target);
|
|
1743
|
-
members(target, protoMembers);
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
const proto = _.prototype;
|
|
1747
|
-
for (const k in proto) {
|
|
1748
|
-
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
1749
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
const Parent = params?.Parent ?? Object;
|
|
1753
|
-
class Definition extends Parent {}
|
|
1754
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
1755
|
-
function _(def) {
|
|
1756
|
-
const inst = params?.Parent ? newError(Definition) : this;
|
|
1757
|
-
init(inst, def);
|
|
1758
|
-
const deferred = inst._zod.deferred;
|
|
1759
|
-
if (deferred) {
|
|
1760
|
-
for (const fn of deferred) fn();
|
|
1761
|
-
inst._zod.deferred = void 0;
|
|
1762
|
-
}
|
|
1763
|
-
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
1764
|
-
if (pp) pp(inst);
|
|
1765
|
-
return inst;
|
|
1766
|
-
}
|
|
1767
|
-
Object.defineProperty(_, "init", { value: init });
|
|
1768
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
1769
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
1770
|
-
return inst?._zod?.traits?.has(name);
|
|
1771
|
-
} });
|
|
1772
|
-
Object.defineProperty(_, "name", { value: name });
|
|
1773
|
-
return _;
|
|
1774
|
-
}
|
|
1775
|
-
var $ZodAsyncError = class extends Error {
|
|
1776
|
-
constructor() {
|
|
1777
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
1778
|
-
}
|
|
1779
|
-
};
|
|
1780
|
-
var $ZodEncodeError = class extends Error {
|
|
1781
|
-
constructor(name) {
|
|
1782
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
1783
|
-
this.name = "ZodEncodeError";
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
1787
|
-
const globalConfig = globalThis.__zod_globalConfig;
|
|
1788
|
-
function config(newConfig) {
|
|
1789
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
1790
|
-
return globalConfig;
|
|
1791
|
-
}
|
|
1792
1522
|
//#endregion
|
|
1793
1523
|
//#region ../src/node_modules/zod/v4/core/errors.js
|
|
1794
|
-
function _getMessage() {
|
|
1795
|
-
const internals = this._zod;
|
|
1796
|
-
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
1797
|
-
return internals.message;
|
|
1798
|
-
}
|
|
1799
|
-
function _setMessage(value) {
|
|
1800
|
-
this._zod.message = value;
|
|
1801
|
-
}
|
|
1802
|
-
const _messageDesc = {
|
|
1803
|
-
get: _getMessage,
|
|
1804
|
-
set: _setMessage,
|
|
1805
|
-
enumerable: true,
|
|
1806
|
-
configurable: true
|
|
1807
|
-
};
|
|
1808
|
-
const _issuesDesc = {
|
|
1809
|
-
value: void 0,
|
|
1810
|
-
enumerable: false
|
|
1811
|
-
};
|
|
1812
|
-
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
1813
1524
|
const initializer$1 = (inst, def) => {
|
|
1814
1525
|
inst.name = "$ZodError";
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
value,
|
|
1829
|
-
configurable: true,
|
|
1830
|
-
writable: true
|
|
1831
|
-
});
|
|
1832
|
-
return value;
|
|
1833
|
-
},
|
|
1834
|
-
set(value) {
|
|
1835
|
-
Object.defineProperty(this, "toString", {
|
|
1836
|
-
value,
|
|
1837
|
-
configurable: true,
|
|
1838
|
-
writable: true
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1526
|
+
Object.defineProperty(inst, "_zod", {
|
|
1527
|
+
value: inst._zod,
|
|
1528
|
+
enumerable: false
|
|
1529
|
+
});
|
|
1530
|
+
Object.defineProperty(inst, "issues", {
|
|
1531
|
+
value: def,
|
|
1532
|
+
enumerable: false
|
|
1533
|
+
});
|
|
1534
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
1535
|
+
Object.defineProperty(inst, "toString", {
|
|
1536
|
+
value: () => inst.message,
|
|
1537
|
+
enumerable: false
|
|
1538
|
+
});
|
|
1843
1539
|
};
|
|
1844
1540
|
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
1845
|
-
$constructor("$ZodError", initializer$1,
|
|
1846
|
-
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
1847
|
-
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
1848
|
-
* "__proto__" would hit the setter instead of creating a key. */
|
|
1849
|
-
function node(obj, key, make) {
|
|
1850
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
1851
|
-
value: make(),
|
|
1852
|
-
writable: true,
|
|
1853
|
-
enumerable: true,
|
|
1854
|
-
configurable: true
|
|
1855
|
-
});
|
|
1856
|
-
else obj[key] = make();
|
|
1857
|
-
return obj[key];
|
|
1858
|
-
}
|
|
1541
|
+
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
1859
1542
|
function flattenError(error, mapper = (issue) => issue.message) {
|
|
1860
1543
|
const fieldErrors = {};
|
|
1861
1544
|
const formErrors = [];
|
|
1862
|
-
for (const sub of error.issues) if (sub.path.length > 0)
|
|
1863
|
-
|
|
1545
|
+
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
1546
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
1547
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
1548
|
+
} else formErrors.push(mapper(sub));
|
|
1864
1549
|
return {
|
|
1865
1550
|
formErrors,
|
|
1866
1551
|
fieldErrors
|
|
@@ -1880,21 +1565,12 @@ window.__ModuleLoader__.load({
|
|
|
1880
1565
|
let i = 0;
|
|
1881
1566
|
while (i < fullpath.length) {
|
|
1882
1567
|
const el = fullpath[i];
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
continue;
|
|
1568
|
+
if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
1569
|
+
else {
|
|
1570
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
1571
|
+
curr[el]._errors.push(mapper(issue));
|
|
1888
1572
|
}
|
|
1889
|
-
|
|
1890
|
-
value: { _errors: [] },
|
|
1891
|
-
enumerable: true,
|
|
1892
|
-
writable: true,
|
|
1893
|
-
configurable: true
|
|
1894
|
-
});
|
|
1895
|
-
const node = curr[el];
|
|
1896
|
-
if (terminal) node._errors.push(mapper(issue));
|
|
1897
|
-
curr = node;
|
|
1573
|
+
curr = curr[el];
|
|
1898
1574
|
i++;
|
|
1899
1575
|
}
|
|
1900
1576
|
}
|
|
@@ -1905,53 +1581,7 @@ window.__ModuleLoader__.load({
|
|
|
1905
1581
|
}
|
|
1906
1582
|
//#endregion
|
|
1907
1583
|
//#region ../src/node_modules/zod/v4/core/parse.js
|
|
1908
|
-
|
|
1909
|
-
return {
|
|
1910
|
-
callee: params?.callee ?? callee,
|
|
1911
|
-
Err: params?.Err
|
|
1912
|
-
};
|
|
1913
|
-
}
|
|
1914
|
-
const _parse = (_Err) => {
|
|
1915
|
-
const fn = (schema, value, _ctx, _params) => {
|
|
1916
|
-
const ctx = _ctx ? {
|
|
1917
|
-
..._ctx,
|
|
1918
|
-
async: false
|
|
1919
|
-
} : { async: false };
|
|
1920
|
-
const result = schema._zod.run({
|
|
1921
|
-
value,
|
|
1922
|
-
issues: []
|
|
1923
|
-
}, ctx);
|
|
1924
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1925
|
-
if (result.issues.length) {
|
|
1926
|
-
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1927
|
-
captureStackTrace(e, _params?.callee ?? fn);
|
|
1928
|
-
throw e;
|
|
1929
|
-
}
|
|
1930
|
-
return result.value;
|
|
1931
|
-
};
|
|
1932
|
-
return fn;
|
|
1933
|
-
};
|
|
1934
|
-
const _parseAsync = (_Err) => {
|
|
1935
|
-
const fn = async (schema, value, _ctx, params) => {
|
|
1936
|
-
const ctx = _ctx ? {
|
|
1937
|
-
..._ctx,
|
|
1938
|
-
async: true
|
|
1939
|
-
} : { async: true };
|
|
1940
|
-
let result = schema._zod.run({
|
|
1941
|
-
value,
|
|
1942
|
-
issues: []
|
|
1943
|
-
}, ctx);
|
|
1944
|
-
if (result instanceof Promise) result = await result;
|
|
1945
|
-
if (result.issues.length) {
|
|
1946
|
-
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1947
|
-
captureStackTrace(e, params?.callee ?? fn);
|
|
1948
|
-
throw e;
|
|
1949
|
-
}
|
|
1950
|
-
return result.value;
|
|
1951
|
-
};
|
|
1952
|
-
return fn;
|
|
1953
|
-
};
|
|
1954
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
1584
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
1955
1585
|
const ctx = _ctx ? {
|
|
1956
1586
|
..._ctx,
|
|
1957
1587
|
async: false
|
|
@@ -1961,31 +1591,14 @@ window.__ModuleLoader__.load({
|
|
|
1961
1591
|
issues: []
|
|
1962
1592
|
}, ctx);
|
|
1963
1593
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1594
|
+
if (result.issues.length) {
|
|
1595
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1596
|
+
captureStackTrace(e, _params?.callee);
|
|
1597
|
+
throw e;
|
|
1598
|
+
}
|
|
1599
|
+
return result.value;
|
|
1968
1600
|
};
|
|
1969
|
-
|
|
1970
|
-
let error;
|
|
1971
|
-
return {
|
|
1972
|
-
success: false,
|
|
1973
|
-
get error() {
|
|
1974
|
-
if (!error) {
|
|
1975
|
-
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1976
|
-
issues = void 0;
|
|
1977
|
-
ctx = void 0;
|
|
1978
|
-
}
|
|
1979
|
-
return error;
|
|
1980
|
-
},
|
|
1981
|
-
set error(e) {
|
|
1982
|
-
error = e;
|
|
1983
|
-
issues = void 0;
|
|
1984
|
-
ctx = void 0;
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
}
|
|
1988
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1601
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
1989
1602
|
const ctx = _ctx ? {
|
|
1990
1603
|
..._ctx,
|
|
1991
1604
|
async: true
|
|
@@ -1995,96 +1608,70 @@ window.__ModuleLoader__.load({
|
|
|
1995
1608
|
issues: []
|
|
1996
1609
|
}, ctx);
|
|
1997
1610
|
if (result instanceof Promise) result = await result;
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
};
|
|
2003
|
-
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
2004
|
-
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
2005
|
-
const validate = ((schema, value, _ctx) => {
|
|
2006
|
-
const validator = schema._zod.bag.validator;
|
|
2007
|
-
if (validator !== void 0) {
|
|
2008
|
-
if (validator(value) !== COMPILE_INVALID) return true;
|
|
2009
|
-
if (validator.definite === true && _ctx === void 0) return false;
|
|
1611
|
+
if (result.issues.length) {
|
|
1612
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1613
|
+
captureStackTrace(e, params?.callee);
|
|
1614
|
+
throw e;
|
|
2010
1615
|
}
|
|
2011
|
-
return
|
|
2012
|
-
}
|
|
2013
|
-
|
|
1616
|
+
return result.value;
|
|
1617
|
+
};
|
|
1618
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
2014
1619
|
const ctx = _ctx ? {
|
|
2015
1620
|
..._ctx,
|
|
2016
|
-
async: false
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
async: false,
|
|
2020
|
-
abortEarly: true
|
|
2021
|
-
};
|
|
2022
|
-
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
2023
|
-
let result;
|
|
2024
|
-
if (fallbackRun) {
|
|
2025
|
-
ctx[COMPILE_FALLBACK] = true;
|
|
2026
|
-
result = fallbackRun({
|
|
2027
|
-
value,
|
|
2028
|
-
issues: []
|
|
2029
|
-
}, ctx);
|
|
2030
|
-
} else result = schema._zod.run({
|
|
1621
|
+
async: false
|
|
1622
|
+
} : { async: false };
|
|
1623
|
+
const result = schema._zod.run({
|
|
2031
1624
|
value,
|
|
2032
1625
|
issues: []
|
|
2033
1626
|
}, ctx);
|
|
2034
1627
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
2035
|
-
return result.issues.length
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
const ctx = _ctx ? {
|
|
2039
|
-
..._ctx,
|
|
2040
|
-
async: true,
|
|
2041
|
-
abortEarly: true
|
|
1628
|
+
return result.issues.length ? {
|
|
1629
|
+
success: false,
|
|
1630
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
2042
1631
|
} : {
|
|
2043
|
-
|
|
2044
|
-
|
|
1632
|
+
success: true,
|
|
1633
|
+
data: result.value
|
|
2045
1634
|
};
|
|
1635
|
+
};
|
|
1636
|
+
const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
1637
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1638
|
+
const ctx = _ctx ? {
|
|
1639
|
+
..._ctx,
|
|
1640
|
+
async: true
|
|
1641
|
+
} : { async: true };
|
|
2046
1642
|
let result = schema._zod.run({
|
|
2047
1643
|
value,
|
|
2048
1644
|
issues: []
|
|
2049
1645
|
}, ctx);
|
|
2050
1646
|
if (result instanceof Promise) result = await result;
|
|
2051
|
-
return result.issues.length
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
..._ctx,
|
|
2058
|
-
direction: "backward"
|
|
2059
|
-
} : { direction: "backward" };
|
|
2060
|
-
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
1647
|
+
return result.issues.length ? {
|
|
1648
|
+
success: false,
|
|
1649
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1650
|
+
} : {
|
|
1651
|
+
success: true,
|
|
1652
|
+
data: result.value
|
|
2061
1653
|
};
|
|
2062
|
-
return fn;
|
|
2063
1654
|
};
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1655
|
+
const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
1656
|
+
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
1657
|
+
const ctx = _ctx ? {
|
|
1658
|
+
..._ctx,
|
|
1659
|
+
direction: "backward"
|
|
1660
|
+
} : { direction: "backward" };
|
|
1661
|
+
return _parse(_Err)(schema, value, ctx);
|
|
2070
1662
|
};
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
const fn = async (schema, value, _ctx, _params) => {
|
|
2074
|
-
const ctx = _ctx ? {
|
|
2075
|
-
..._ctx,
|
|
2076
|
-
direction: "backward"
|
|
2077
|
-
} : { direction: "backward" };
|
|
2078
|
-
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
2079
|
-
};
|
|
2080
|
-
return fn;
|
|
1663
|
+
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
1664
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
2081
1665
|
};
|
|
2082
|
-
const
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
};
|
|
2087
|
-
return
|
|
1666
|
+
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1667
|
+
const ctx = _ctx ? {
|
|
1668
|
+
..._ctx,
|
|
1669
|
+
direction: "backward"
|
|
1670
|
+
} : { direction: "backward" };
|
|
1671
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
1672
|
+
};
|
|
1673
|
+
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1674
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
2088
1675
|
};
|
|
2089
1676
|
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
2090
1677
|
const ctx = _ctx ? {
|
|
@@ -2115,15 +1702,12 @@ window.__ModuleLoader__.load({
|
|
|
2115
1702
|
*/
|
|
2116
1703
|
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
2117
1704
|
const cuid2 = /^[0-9a-z]+$/;
|
|
2118
|
-
const ulid = /^[0-
|
|
1705
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
2119
1706
|
const xid = /^[0-9a-vA-V]{20}$/;
|
|
2120
1707
|
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
2121
1708
|
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
2122
|
-
function nanoidOfLength(length) {
|
|
2123
|
-
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
2124
|
-
}
|
|
2125
1709
|
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
2126
|
-
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
1710
|
+
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
2127
1711
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
2128
1712
|
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
2129
1713
|
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
@@ -2134,45 +1718,40 @@ window.__ModuleLoader__.load({
|
|
|
2134
1718
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
2135
1719
|
};
|
|
2136
1720
|
/** Practical email validation */
|
|
2137
|
-
const email = /^(
|
|
2138
|
-
const _emoji$1 = `^(
|
|
1721
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1722
|
+
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
2139
1723
|
function emoji() {
|
|
2140
1724
|
return new RegExp(_emoji$1, "u");
|
|
2141
1725
|
}
|
|
2142
1726
|
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
2143
1727
|
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
2144
1728
|
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
2145
|
-
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
1729
|
+
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])$/;
|
|
2146
1730
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
2147
|
-
const base64url = /^
|
|
1731
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
2148
1732
|
const httpProtocol = /^https?$/;
|
|
2149
1733
|
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
2150
1734
|
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])))`;
|
|
2151
|
-
|
|
2152
|
-
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
2153
|
-
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
|
|
2154
|
-
function anchor(source) {
|
|
2155
|
-
return new RegExp(`^${source}$`);
|
|
2156
|
-
}
|
|
2157
|
-
const date = /*@__PURE__*/ anchor(dateSource);
|
|
1735
|
+
const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
2158
1736
|
function timeSource(args) {
|
|
2159
1737
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
2160
|
-
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` :
|
|
1738
|
+
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
2161
1739
|
}
|
|
2162
|
-
function time(args) {
|
|
1740
|
+
function time$1(args) {
|
|
2163
1741
|
return new RegExp(`^${timeSource(args)}$`);
|
|
2164
1742
|
}
|
|
2165
|
-
function datetime(args) {
|
|
1743
|
+
function datetime$1(args) {
|
|
1744
|
+
const time = timeSource({ precision: args.precision });
|
|
2166
1745
|
const opts = ["Z"];
|
|
1746
|
+
if (args.local) opts.push("");
|
|
2167
1747
|
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
2168
|
-
const
|
|
2169
|
-
precision: args.precision,
|
|
2170
|
-
seconds: true
|
|
2171
|
-
})}(?:${opts.join("|")})`;
|
|
2172
|
-
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
1748
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
2173
1749
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
2174
1750
|
}
|
|
2175
|
-
const
|
|
1751
|
+
const string$1 = (params) => {
|
|
1752
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
1753
|
+
return new RegExp(`^${regex}$`);
|
|
1754
|
+
};
|
|
2176
1755
|
const boolean$1 = /^(?:true|false)$/i;
|
|
2177
1756
|
const lowercase = /^[^A-Z]*$/;
|
|
2178
1757
|
const uppercase = /^[^a-z]*$/;
|
|
@@ -2184,19 +1763,20 @@ window.__ModuleLoader__.load({
|
|
|
2184
1763
|
inst._zod.def = def;
|
|
2185
1764
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
2186
1765
|
});
|
|
2187
|
-
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
|
|
2188
|
-
const _whenHasLength = (payload) => {
|
|
2189
|
-
const val = payload.value;
|
|
2190
|
-
return !nullish(val) && val.length !== void 0;
|
|
2191
|
-
};
|
|
2192
1766
|
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
2193
1767
|
var _a;
|
|
2194
1768
|
$ZodCheck.init(inst, def);
|
|
2195
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
1769
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1770
|
+
const val = payload.value;
|
|
1771
|
+
return !nullish(val) && val.length !== void 0;
|
|
1772
|
+
});
|
|
1773
|
+
inst._zod.onattach.push((inst) => {
|
|
1774
|
+
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1775
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
1776
|
+
});
|
|
2196
1777
|
inst._zod.check = (payload) => {
|
|
2197
1778
|
const input = payload.value;
|
|
2198
|
-
|
|
2199
|
-
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
1779
|
+
if (input.length <= def.maximum) return;
|
|
2200
1780
|
const origin = getLengthableOrigin(input);
|
|
2201
1781
|
payload.issues.push({
|
|
2202
1782
|
origin,
|
|
@@ -2212,11 +1792,17 @@ window.__ModuleLoader__.load({
|
|
|
2212
1792
|
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
2213
1793
|
var _a;
|
|
2214
1794
|
$ZodCheck.init(inst, def);
|
|
2215
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
1795
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1796
|
+
const val = payload.value;
|
|
1797
|
+
return !nullish(val) && val.length !== void 0;
|
|
1798
|
+
});
|
|
1799
|
+
inst._zod.onattach.push((inst) => {
|
|
1800
|
+
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1801
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
1802
|
+
});
|
|
2216
1803
|
inst._zod.check = (payload) => {
|
|
2217
1804
|
const input = payload.value;
|
|
2218
|
-
|
|
2219
|
-
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
1805
|
+
if (input.length >= def.minimum) return;
|
|
2220
1806
|
const origin = getLengthableOrigin(input);
|
|
2221
1807
|
payload.issues.push({
|
|
2222
1808
|
origin,
|
|
@@ -2232,11 +1818,19 @@ window.__ModuleLoader__.load({
|
|
|
2232
1818
|
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
2233
1819
|
var _a;
|
|
2234
1820
|
$ZodCheck.init(inst, def);
|
|
2235
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
1821
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1822
|
+
const val = payload.value;
|
|
1823
|
+
return !nullish(val) && val.length !== void 0;
|
|
1824
|
+
});
|
|
1825
|
+
inst._zod.onattach.push((inst) => {
|
|
1826
|
+
const bag = inst._zod.bag;
|
|
1827
|
+
bag.minimum = def.length;
|
|
1828
|
+
bag.maximum = def.length;
|
|
1829
|
+
bag.length = def.length;
|
|
1830
|
+
});
|
|
2236
1831
|
inst._zod.check = (payload) => {
|
|
2237
1832
|
const input = payload.value;
|
|
2238
|
-
const
|
|
2239
|
-
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
1833
|
+
const length = input.length;
|
|
2240
1834
|
if (length === def.length) return;
|
|
2241
1835
|
const origin = getLengthableOrigin(input);
|
|
2242
1836
|
const tooBig = length > def.length;
|
|
@@ -2260,6 +1854,14 @@ window.__ModuleLoader__.load({
|
|
|
2260
1854
|
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
2261
1855
|
var _a, _b;
|
|
2262
1856
|
$ZodCheck.init(inst, def);
|
|
1857
|
+
inst._zod.onattach.push((inst) => {
|
|
1858
|
+
const bag = inst._zod.bag;
|
|
1859
|
+
bag.format = def.format;
|
|
1860
|
+
if (def.pattern) {
|
|
1861
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1862
|
+
bag.patterns.add(def.pattern);
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
2263
1865
|
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
2264
1866
|
def.pattern.lastIndex = 0;
|
|
2265
1867
|
if (def.pattern.test(payload.value)) return;
|
|
@@ -2302,7 +1904,13 @@ window.__ModuleLoader__.load({
|
|
|
2302
1904
|
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
2303
1905
|
$ZodCheck.init(inst, def);
|
|
2304
1906
|
const escapedRegex = escapeRegex(def.includes);
|
|
2305
|
-
|
|
1907
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1908
|
+
def.pattern = pattern;
|
|
1909
|
+
inst._zod.onattach.push((inst) => {
|
|
1910
|
+
const bag = inst._zod.bag;
|
|
1911
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1912
|
+
bag.patterns.add(pattern);
|
|
1913
|
+
});
|
|
2306
1914
|
inst._zod.check = (payload) => {
|
|
2307
1915
|
if (payload.value.includes(def.includes, def.position)) return;
|
|
2308
1916
|
payload.issues.push({
|
|
@@ -2320,6 +1928,11 @@ window.__ModuleLoader__.load({
|
|
|
2320
1928
|
$ZodCheck.init(inst, def);
|
|
2321
1929
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
2322
1930
|
def.pattern ?? (def.pattern = pattern);
|
|
1931
|
+
inst._zod.onattach.push((inst) => {
|
|
1932
|
+
const bag = inst._zod.bag;
|
|
1933
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1934
|
+
bag.patterns.add(pattern);
|
|
1935
|
+
});
|
|
2323
1936
|
inst._zod.check = (payload) => {
|
|
2324
1937
|
if (payload.value.startsWith(def.prefix)) return;
|
|
2325
1938
|
payload.issues.push({
|
|
@@ -2337,6 +1950,11 @@ window.__ModuleLoader__.load({
|
|
|
2337
1950
|
$ZodCheck.init(inst, def);
|
|
2338
1951
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
2339
1952
|
def.pattern ?? (def.pattern = pattern);
|
|
1953
|
+
inst._zod.onattach.push((inst) => {
|
|
1954
|
+
const bag = inst._zod.bag;
|
|
1955
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1956
|
+
bag.patterns.add(pattern);
|
|
1957
|
+
});
|
|
2340
1958
|
inst._zod.check = (payload) => {
|
|
2341
1959
|
if (payload.value.endsWith(def.suffix)) return;
|
|
2342
1960
|
payload.issues.push({
|
|
@@ -2359,19 +1977,15 @@ window.__ModuleLoader__.load({
|
|
|
2359
1977
|
//#endregion
|
|
2360
1978
|
//#region ../src/node_modules/zod/v4/core/doc.js
|
|
2361
1979
|
var Doc = class {
|
|
2362
|
-
constructor(args = []
|
|
1980
|
+
constructor(args = []) {
|
|
2363
1981
|
this.content = [];
|
|
2364
1982
|
this.indent = 0;
|
|
2365
|
-
this.args = args;
|
|
2366
|
-
this.closed = closed;
|
|
1983
|
+
if (this) this.args = args;
|
|
2367
1984
|
}
|
|
2368
1985
|
indented(fn) {
|
|
2369
1986
|
this.indent += 1;
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
} finally {
|
|
2373
|
-
this.indent -= 1;
|
|
2374
|
-
}
|
|
1987
|
+
fn(this);
|
|
1988
|
+
this.indent -= 1;
|
|
2375
1989
|
}
|
|
2376
1990
|
write(arg) {
|
|
2377
1991
|
if (typeof arg === "function") {
|
|
@@ -2386,16 +2000,17 @@ window.__ModuleLoader__.load({
|
|
|
2386
2000
|
}
|
|
2387
2001
|
compile() {
|
|
2388
2002
|
const F = Function;
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2003
|
+
const args = this?.args;
|
|
2004
|
+
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
|
|
2005
|
+
return new F(...args, lines.join("\n"));
|
|
2391
2006
|
}
|
|
2392
2007
|
};
|
|
2393
2008
|
//#endregion
|
|
2394
2009
|
//#region ../src/node_modules/zod/v4/core/versions.js
|
|
2395
2010
|
const version = {
|
|
2396
2011
|
major: 4,
|
|
2397
|
-
minor:
|
|
2398
|
-
patch:
|
|
2012
|
+
minor: 4,
|
|
2013
|
+
patch: 3
|
|
2399
2014
|
};
|
|
2400
2015
|
//#endregion
|
|
2401
2016
|
//#region ../src/node_modules/zod/v4/core/schemas.js
|
|
@@ -2405,8 +2020,8 @@ window.__ModuleLoader__.load({
|
|
|
2405
2020
|
inst._zod.def = def;
|
|
2406
2021
|
inst._zod.bag = inst._zod.bag || {};
|
|
2407
2022
|
inst._zod.version = version;
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2023
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
2024
|
+
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
2410
2025
|
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
2411
2026
|
if (checks.length === 0) {
|
|
2412
2027
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
@@ -2415,7 +2030,6 @@ window.__ModuleLoader__.load({
|
|
|
2415
2030
|
});
|
|
2416
2031
|
} else {
|
|
2417
2032
|
const runChecks = (payload, checks, ctx) => {
|
|
2418
|
-
if (payload.memo) return payload;
|
|
2419
2033
|
let isAborted = aborted(payload);
|
|
2420
2034
|
let asyncResult;
|
|
2421
2035
|
for (const ch of checks) {
|
|
@@ -2429,12 +2043,10 @@ window.__ModuleLoader__.load({
|
|
|
2429
2043
|
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
2430
2044
|
await _;
|
|
2431
2045
|
if (payload.issues.length === currLen) return;
|
|
2432
|
-
attachSchema(payload.issues, currLen, inst);
|
|
2433
2046
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
2434
2047
|
});
|
|
2435
2048
|
else {
|
|
2436
2049
|
if (payload.issues.length === currLen) continue;
|
|
2437
|
-
attachSchema(payload.issues, currLen, inst);
|
|
2438
2050
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
2439
2051
|
}
|
|
2440
2052
|
}
|
|
@@ -2478,43 +2090,22 @@ window.__ModuleLoader__.load({
|
|
|
2478
2090
|
return runChecks(result, checks, ctx);
|
|
2479
2091
|
};
|
|
2480
2092
|
}
|
|
2481
|
-
|
|
2482
|
-
get "~standard"() {
|
|
2483
|
-
return hide(this, "~standard", standardProps(this));
|
|
2484
|
-
},
|
|
2485
|
-
set "~standard"(value) {
|
|
2486
|
-
own(this, "~standard", value);
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
2490
|
-
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
2491
|
-
async function validateAsync(inst, value) {
|
|
2492
|
-
const ctx = { async: true };
|
|
2493
|
-
return toStandardResult(await inst._zod.run({
|
|
2494
|
-
value,
|
|
2495
|
-
issues: []
|
|
2496
|
-
}, ctx), ctx);
|
|
2497
|
-
}
|
|
2498
|
-
function standardProps(inst) {
|
|
2499
|
-
return {
|
|
2093
|
+
defineLazy(inst, "~standard", () => ({
|
|
2500
2094
|
validate: (value) => {
|
|
2501
|
-
const ctx = { async: false };
|
|
2502
2095
|
try {
|
|
2503
|
-
const r = inst
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
} catch (_) {}
|
|
2509
|
-
return validateAsync(inst, value);
|
|
2096
|
+
const r = safeParse$1(inst, value);
|
|
2097
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
2098
|
+
} catch (_) {
|
|
2099
|
+
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
2100
|
+
}
|
|
2510
2101
|
},
|
|
2511
2102
|
vendor: "zod",
|
|
2512
2103
|
version: 1
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2104
|
+
}));
|
|
2105
|
+
});
|
|
2515
2106
|
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
2516
2107
|
$ZodType.init(inst, def);
|
|
2517
|
-
inst._zod.pattern =
|
|
2108
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
2518
2109
|
inst._zod.parse = (payload, _) => {
|
|
2519
2110
|
if (def.coerce) try {
|
|
2520
2111
|
payload.value = String(payload.value);
|
|
@@ -2558,95 +2149,51 @@ window.__ModuleLoader__.load({
|
|
|
2558
2149
|
def.pattern ?? (def.pattern = email);
|
|
2559
2150
|
$ZodStringFormat.init(inst, def);
|
|
2560
2151
|
});
|
|
2561
|
-
function canParseURL(input) {
|
|
2562
|
-
try {
|
|
2563
|
-
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
2564
|
-
new URL(input);
|
|
2565
|
-
return true;
|
|
2566
|
-
} catch {
|
|
2567
|
-
return false;
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
function validateURL(trimmed, def) {
|
|
2571
|
-
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
|
|
2572
|
-
return parseURLObject(trimmed, def);
|
|
2573
|
-
}
|
|
2574
|
-
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
2575
|
-
function parseURLObject(trimmed, def) {
|
|
2576
|
-
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
|
|
2577
|
-
try {
|
|
2578
|
-
if (typeof URL !== "undefined") {
|
|
2579
|
-
const URLStatic = URL;
|
|
2580
|
-
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
|
|
2581
|
-
}
|
|
2582
|
-
return new URL(trimmed);
|
|
2583
|
-
} catch {
|
|
2584
|
-
return 2;
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
2588
|
-
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
2589
|
-
function stripTabAndNewline(value) {
|
|
2590
|
-
return value.replace(asciiTabOrNewline, "");
|
|
2591
|
-
}
|
|
2592
|
-
function urlHostnameOk(url, hostname) {
|
|
2593
|
-
hostname.lastIndex = 0;
|
|
2594
|
-
return hostname.test(url.hostname);
|
|
2595
|
-
}
|
|
2596
|
-
function urlProtocolOk(url, protocol) {
|
|
2597
|
-
protocol.lastIndex = 0;
|
|
2598
|
-
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
2599
|
-
}
|
|
2600
2152
|
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
2601
2153
|
$ZodStringFormat.init(inst, def);
|
|
2602
2154
|
inst._zod.check = (payload) => {
|
|
2603
2155
|
try {
|
|
2604
2156
|
const trimmed = payload.value.trim();
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2157
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
2158
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
2159
|
+
payload.issues.push({
|
|
2160
|
+
code: "invalid_format",
|
|
2161
|
+
format: "url",
|
|
2162
|
+
note: "Invalid URL format",
|
|
2163
|
+
input: payload.value,
|
|
2164
|
+
inst,
|
|
2165
|
+
continue: !def.abort
|
|
2166
|
+
});
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
const url = new URL(trimmed);
|
|
2171
|
+
if (def.hostname) {
|
|
2172
|
+
def.hostname.lastIndex = 0;
|
|
2173
|
+
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
2608
2174
|
code: "invalid_format",
|
|
2609
2175
|
format: "url",
|
|
2610
|
-
note: "Invalid
|
|
2176
|
+
note: "Invalid hostname",
|
|
2177
|
+
pattern: def.hostname.source,
|
|
2611
2178
|
input: payload.value,
|
|
2612
2179
|
inst,
|
|
2613
2180
|
continue: !def.abort
|
|
2614
2181
|
});
|
|
2615
|
-
return;
|
|
2616
2182
|
}
|
|
2617
|
-
if (
|
|
2618
|
-
|
|
2183
|
+
if (def.protocol) {
|
|
2184
|
+
def.protocol.lastIndex = 0;
|
|
2185
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
2619
2186
|
code: "invalid_format",
|
|
2620
2187
|
format: "url",
|
|
2188
|
+
note: "Invalid protocol",
|
|
2189
|
+
pattern: def.protocol.source,
|
|
2621
2190
|
input: payload.value,
|
|
2622
2191
|
inst,
|
|
2623
2192
|
continue: !def.abort
|
|
2624
2193
|
});
|
|
2625
|
-
return;
|
|
2626
2194
|
}
|
|
2627
|
-
if (
|
|
2628
|
-
|
|
2629
|
-
return;
|
|
2630
|
-
}
|
|
2631
|
-
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
|
|
2632
|
-
code: "invalid_format",
|
|
2633
|
-
format: "url",
|
|
2634
|
-
note: "Invalid hostname",
|
|
2635
|
-
pattern: def.hostname.source,
|
|
2636
|
-
input: payload.value,
|
|
2637
|
-
inst,
|
|
2638
|
-
continue: !def.abort
|
|
2639
|
-
});
|
|
2640
|
-
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
|
|
2641
|
-
code: "invalid_format",
|
|
2642
|
-
format: "url",
|
|
2643
|
-
note: "Invalid protocol",
|
|
2644
|
-
pattern: def.protocol.source,
|
|
2645
|
-
input: payload.value,
|
|
2646
|
-
inst,
|
|
2647
|
-
continue: !def.abort
|
|
2648
|
-
});
|
|
2649
|
-
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
2195
|
+
if (def.normalize) payload.value = url.href;
|
|
2196
|
+
else payload.value = trimmed;
|
|
2650
2197
|
return;
|
|
2651
2198
|
} catch (_) {
|
|
2652
2199
|
payload.issues.push({
|
|
@@ -2664,8 +2211,7 @@ window.__ModuleLoader__.load({
|
|
|
2664
2211
|
$ZodStringFormat.init(inst, def);
|
|
2665
2212
|
});
|
|
2666
2213
|
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
2667
|
-
|
|
2668
|
-
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
2214
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
2669
2215
|
$ZodStringFormat.init(inst, def);
|
|
2670
2216
|
});
|
|
2671
2217
|
/**
|
|
@@ -2694,69 +2240,70 @@ window.__ModuleLoader__.load({
|
|
|
2694
2240
|
$ZodStringFormat.init(inst, def);
|
|
2695
2241
|
});
|
|
2696
2242
|
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
2697
|
-
def.pattern ?? (def.pattern = datetime(def));
|
|
2243
|
+
def.pattern ?? (def.pattern = datetime$1(def));
|
|
2698
2244
|
$ZodStringFormat.init(inst, def);
|
|
2699
2245
|
});
|
|
2700
2246
|
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
2701
|
-
def.pattern ?? (def.pattern = date);
|
|
2247
|
+
def.pattern ?? (def.pattern = date$1);
|
|
2702
2248
|
$ZodStringFormat.init(inst, def);
|
|
2703
2249
|
});
|
|
2704
2250
|
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
2705
|
-
def.pattern ?? (def.pattern = time(def));
|
|
2251
|
+
def.pattern ?? (def.pattern = time$1(def));
|
|
2706
2252
|
$ZodStringFormat.init(inst, def);
|
|
2707
2253
|
});
|
|
2708
2254
|
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
2709
|
-
def.pattern ?? (def.pattern = duration);
|
|
2255
|
+
def.pattern ?? (def.pattern = duration$1);
|
|
2710
2256
|
$ZodStringFormat.init(inst, def);
|
|
2711
2257
|
});
|
|
2712
2258
|
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
2713
2259
|
def.pattern ?? (def.pattern = ipv4);
|
|
2714
2260
|
$ZodStringFormat.init(inst, def);
|
|
2261
|
+
inst._zod.bag.format = `ipv4`;
|
|
2715
2262
|
});
|
|
2716
|
-
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
2717
|
-
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
2718
|
-
function isValidIPv6(value) {
|
|
2719
|
-
if (!ipv6Alphabet.test(value)) return false;
|
|
2720
|
-
return canParseURL(`http://[${value}]`);
|
|
2721
|
-
}
|
|
2722
2263
|
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
2723
2264
|
def.pattern ?? (def.pattern = ipv6);
|
|
2724
2265
|
$ZodStringFormat.init(inst, def);
|
|
2266
|
+
inst._zod.bag.format = `ipv6`;
|
|
2725
2267
|
inst._zod.check = (payload) => {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2268
|
+
try {
|
|
2269
|
+
new URL(`http://[${payload.value}]`);
|
|
2270
|
+
} catch {
|
|
2271
|
+
payload.issues.push({
|
|
2272
|
+
code: "invalid_format",
|
|
2273
|
+
format: "ipv6",
|
|
2274
|
+
input: payload.value,
|
|
2275
|
+
inst,
|
|
2276
|
+
continue: !def.abort
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2733
2279
|
};
|
|
2734
2280
|
});
|
|
2735
2281
|
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
2736
2282
|
def.pattern ?? (def.pattern = cidrv4);
|
|
2737
2283
|
$ZodStringFormat.init(inst, def);
|
|
2738
2284
|
});
|
|
2739
|
-
function isValidCIDRv6(value) {
|
|
2740
|
-
const parts = value.split("/");
|
|
2741
|
-
if (parts.length !== 2) return false;
|
|
2742
|
-
const [address, prefix] = parts;
|
|
2743
|
-
if (!prefix) return false;
|
|
2744
|
-
const prefixNum = Number(prefix);
|
|
2745
|
-
if (`${prefixNum}` !== prefix) return false;
|
|
2746
|
-
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
2747
|
-
return isValidIPv6(address);
|
|
2748
|
-
}
|
|
2749
2285
|
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
2750
2286
|
def.pattern ?? (def.pattern = cidrv6);
|
|
2751
2287
|
$ZodStringFormat.init(inst, def);
|
|
2752
2288
|
inst._zod.check = (payload) => {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2289
|
+
const parts = payload.value.split("/");
|
|
2290
|
+
try {
|
|
2291
|
+
if (parts.length !== 2) throw new Error();
|
|
2292
|
+
const [address, prefix] = parts;
|
|
2293
|
+
if (!prefix) throw new Error();
|
|
2294
|
+
const prefixNum = Number(prefix);
|
|
2295
|
+
if (`${prefixNum}` !== prefix) throw new Error();
|
|
2296
|
+
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
2297
|
+
new URL(`http://[${address}]`);
|
|
2298
|
+
} catch {
|
|
2299
|
+
payload.issues.push({
|
|
2300
|
+
code: "invalid_format",
|
|
2301
|
+
format: "cidrv6",
|
|
2302
|
+
input: payload.value,
|
|
2303
|
+
inst,
|
|
2304
|
+
continue: !def.abort
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2760
2307
|
};
|
|
2761
2308
|
});
|
|
2762
2309
|
function isValidBase64(data) {
|
|
@@ -2770,10 +2317,10 @@ window.__ModuleLoader__.load({
|
|
|
2770
2317
|
return false;
|
|
2771
2318
|
}
|
|
2772
2319
|
}
|
|
2773
|
-
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
2774
2320
|
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
2775
|
-
def.pattern ?? (def.pattern =
|
|
2321
|
+
def.pattern ?? (def.pattern = base64);
|
|
2776
2322
|
$ZodStringFormat.init(inst, def);
|
|
2323
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
2777
2324
|
inst._zod.check = (payload) => {
|
|
2778
2325
|
if (isValidBase64(payload.value)) return;
|
|
2779
2326
|
payload.issues.push({
|
|
@@ -2785,15 +2332,15 @@ window.__ModuleLoader__.load({
|
|
|
2785
2332
|
});
|
|
2786
2333
|
};
|
|
2787
2334
|
});
|
|
2788
|
-
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
2789
2335
|
function isValidBase64URL(data) {
|
|
2790
|
-
if (!
|
|
2336
|
+
if (!base64url.test(data)) return false;
|
|
2791
2337
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
2792
2338
|
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
2793
2339
|
}
|
|
2794
2340
|
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
2795
|
-
def.pattern ?? (def.pattern =
|
|
2341
|
+
def.pattern ?? (def.pattern = base64url);
|
|
2796
2342
|
$ZodStringFormat.init(inst, def);
|
|
2343
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
2797
2344
|
inst._zod.check = (payload) => {
|
|
2798
2345
|
if (isValidBase64URL(payload.value)) return;
|
|
2799
2346
|
payload.issues.push({
|
|
@@ -2885,34 +2432,12 @@ window.__ModuleLoader__.load({
|
|
|
2885
2432
|
return payload;
|
|
2886
2433
|
};
|
|
2887
2434
|
});
|
|
2888
|
-
function capSize(inst, size) {
|
|
2889
|
-
const caps = sizeCaps(inst._zod.def.checks);
|
|
2890
|
-
if (!caps.length) return;
|
|
2891
|
-
const cap = Math.min(...caps.map((c) => c[0]));
|
|
2892
|
-
const parse = inst._zod.parse;
|
|
2893
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2894
|
-
const n = size(payload.value);
|
|
2895
|
-
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
2896
|
-
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
|
|
2897
|
-
const start = payload.issues.length;
|
|
2898
|
-
ch._zod.check(payload);
|
|
2899
|
-
payload.issues[start].continue = false;
|
|
2900
|
-
attachSchema(payload.issues, start, inst);
|
|
2901
|
-
return payload;
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
return parse(payload, ctx);
|
|
2905
|
-
};
|
|
2906
|
-
}
|
|
2907
|
-
const arraySize = (input) => Array.isArray(input) ? input.length : -1;
|
|
2908
2435
|
function handleArrayResult(result, final, index) {
|
|
2909
2436
|
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
2910
2437
|
final.value[index] = result.value;
|
|
2911
2438
|
}
|
|
2912
2439
|
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
2913
2440
|
$ZodType.init(inst, def);
|
|
2914
|
-
const memo = globalConfig.memoizer;
|
|
2915
|
-
memo?.attach(inst);
|
|
2916
2441
|
inst._zod.parse = (payload, ctx) => {
|
|
2917
2442
|
const input = payload.value;
|
|
2918
2443
|
if (!Array.isArray(input)) {
|
|
@@ -2924,9 +2449,8 @@ window.__ModuleLoader__.load({
|
|
|
2924
2449
|
});
|
|
2925
2450
|
return payload;
|
|
2926
2451
|
}
|
|
2927
|
-
payload.value =
|
|
2452
|
+
payload.value = Array(input.length);
|
|
2928
2453
|
const proms = [];
|
|
2929
|
-
const abortEarly = ctx?.abortEarly;
|
|
2930
2454
|
for (let i = 0; i < input.length; i++) {
|
|
2931
2455
|
const item = input[i];
|
|
2932
2456
|
const result = def.element._zod.run({
|
|
@@ -2934,25 +2458,19 @@ window.__ModuleLoader__.load({
|
|
|
2934
2458
|
issues: []
|
|
2935
2459
|
}, ctx);
|
|
2936
2460
|
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
2937
|
-
else
|
|
2938
|
-
handleArrayResult(result, payload, i);
|
|
2939
|
-
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
|
|
2940
|
-
}
|
|
2461
|
+
else handleArrayResult(result, payload, i);
|
|
2941
2462
|
}
|
|
2942
2463
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
2943
2464
|
return payload;
|
|
2944
2465
|
};
|
|
2945
|
-
capSize(inst, arraySize);
|
|
2946
2466
|
});
|
|
2947
|
-
function handlePropertyResult(result, final, key, input,
|
|
2467
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
2948
2468
|
const isPresent = key in input;
|
|
2949
|
-
const isOptionalOut = optout === "optional";
|
|
2950
|
-
if (!isPresent && isOptionalOut && optin === "optional") return;
|
|
2951
2469
|
if (result.issues.length) {
|
|
2952
|
-
if (
|
|
2470
|
+
if (isOptionalIn && isOptionalOut && !isPresent) return;
|
|
2953
2471
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
2954
2472
|
}
|
|
2955
|
-
if (!isPresent &&
|
|
2473
|
+
if (!isPresent && !isOptionalIn) {
|
|
2956
2474
|
if (!result.issues.length) final.issues.push({
|
|
2957
2475
|
code: "invalid_type",
|
|
2958
2476
|
expected: "nonoptional",
|
|
@@ -2962,44 +2480,31 @@ window.__ModuleLoader__.load({
|
|
|
2962
2480
|
return;
|
|
2963
2481
|
}
|
|
2964
2482
|
if (result.value === void 0) {
|
|
2965
|
-
if (isPresent
|
|
2483
|
+
if (isPresent) final.value[key] = void 0;
|
|
2966
2484
|
} else final.value[key] = result.value;
|
|
2967
2485
|
}
|
|
2968
|
-
const NO_SYMBOL_KEYS = [];
|
|
2969
2486
|
function normalizeDef(def) {
|
|
2970
2487
|
const keys = Object.keys(def.shape);
|
|
2971
|
-
const
|
|
2972
|
-
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
2973
|
-
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
2974
|
-
for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
2488
|
+
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
2975
2489
|
const okeys = optionalKeys(def.shape);
|
|
2976
2490
|
return {
|
|
2977
2491
|
...def,
|
|
2978
|
-
|
|
2979
|
-
symbolKeys,
|
|
2492
|
+
keys,
|
|
2980
2493
|
keySet: new Set(keys),
|
|
2981
2494
|
numKeys: keys.length,
|
|
2982
2495
|
optionalKeys: new Set(okeys)
|
|
2983
2496
|
};
|
|
2984
2497
|
}
|
|
2985
|
-
function handleCatchall(proms, input, payload, ctx, def, inst
|
|
2498
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
2986
2499
|
const unrecognized = [];
|
|
2987
2500
|
const keySet = def.keySet;
|
|
2988
2501
|
const _catchall = def.catchall._zod;
|
|
2989
2502
|
const t = _catchall.def.type;
|
|
2990
|
-
const
|
|
2991
|
-
const
|
|
2992
|
-
let seen = 0;
|
|
2503
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
2504
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
2993
2505
|
for (const key in input) {
|
|
2994
|
-
if (
|
|
2995
|
-
if (aborted(payload, seen)) break;
|
|
2996
|
-
seen = payload.issues.length;
|
|
2997
|
-
}
|
|
2506
|
+
if (key === "__proto__") continue;
|
|
2998
2507
|
if (keySet.has(key)) continue;
|
|
2999
|
-
if (key === "__proto__") {
|
|
3000
|
-
if (t === "never") unrecognized.push(key);
|
|
3001
|
-
continue;
|
|
3002
|
-
}
|
|
3003
2508
|
if (t === "never") {
|
|
3004
2509
|
unrecognized.push(key);
|
|
3005
2510
|
continue;
|
|
@@ -3008,15 +2513,14 @@ window.__ModuleLoader__.load({
|
|
|
3008
2513
|
value: input[key],
|
|
3009
2514
|
issues: []
|
|
3010
2515
|
}, ctx);
|
|
3011
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
3012
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2516
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
2517
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
3013
2518
|
}
|
|
3014
2519
|
if (unrecognized.length) payload.issues.push({
|
|
3015
2520
|
code: "unrecognized_keys",
|
|
3016
2521
|
keys: unrecognized,
|
|
3017
2522
|
input,
|
|
3018
|
-
inst
|
|
3019
|
-
continue: true
|
|
2523
|
+
inst
|
|
3020
2524
|
});
|
|
3021
2525
|
if (!proms.length) return payload;
|
|
3022
2526
|
return Promise.all(proms).then(() => {
|
|
@@ -3025,41 +2529,34 @@ window.__ModuleLoader__.load({
|
|
|
3025
2529
|
}
|
|
3026
2530
|
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
3027
2531
|
$ZodType.init(inst, def);
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
const get = () => {
|
|
2532
|
+
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
|
|
2533
|
+
const sh = def.shape;
|
|
2534
|
+
Object.defineProperty(def, "shape", { get: () => {
|
|
3032
2535
|
const newSh = { ...sh };
|
|
3033
2536
|
Object.defineProperty(def, "shape", { value: newSh });
|
|
3034
|
-
get.raw = newSh;
|
|
3035
2537
|
return newSh;
|
|
3036
|
-
};
|
|
3037
|
-
get.raw = sh;
|
|
3038
|
-
Object.defineProperty(def, "shape", { get });
|
|
2538
|
+
} });
|
|
3039
2539
|
}
|
|
3040
2540
|
const _normalized = cached(() => normalizeDef(def));
|
|
3041
|
-
|
|
3042
|
-
const shape =
|
|
2541
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
2542
|
+
const shape = def.shape;
|
|
3043
2543
|
const propValues = {};
|
|
3044
2544
|
for (const key in shape) {
|
|
3045
2545
|
const field = shape[key]._zod;
|
|
3046
2546
|
if (field.values) {
|
|
3047
|
-
|
|
2547
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3048
2548
|
for (const v of field.values) propValues[key].add(v);
|
|
3049
|
-
if (field.optin !== void 0) propValues[key].add(void 0);
|
|
3050
2549
|
}
|
|
3051
2550
|
}
|
|
3052
2551
|
return propValues;
|
|
3053
2552
|
});
|
|
3054
|
-
const isObject$
|
|
2553
|
+
const isObject$2 = isObject;
|
|
3055
2554
|
const catchall = def.catchall;
|
|
3056
2555
|
let value;
|
|
3057
|
-
const memo = globalConfig.memoizer;
|
|
3058
|
-
memo?.attach(inst);
|
|
3059
2556
|
inst._zod.parse = (payload, ctx) => {
|
|
3060
2557
|
value ?? (value = _normalized.value);
|
|
3061
2558
|
const input = payload.value;
|
|
3062
|
-
if (!isObject$
|
|
2559
|
+
if (!isObject$2(input)) {
|
|
3063
2560
|
payload.issues.push({
|
|
3064
2561
|
expected: "object",
|
|
3065
2562
|
code: "invalid_type",
|
|
@@ -3068,90 +2565,77 @@ window.__ModuleLoader__.load({
|
|
|
3068
2565
|
});
|
|
3069
2566
|
return payload;
|
|
3070
2567
|
}
|
|
3071
|
-
payload.value =
|
|
2568
|
+
payload.value = {};
|
|
3072
2569
|
const proms = [];
|
|
3073
2570
|
const shape = value.shape;
|
|
3074
|
-
const
|
|
3075
|
-
let seen = payload.issues.length;
|
|
3076
|
-
for (const key of value.allKeys) {
|
|
3077
|
-
if (abortEarly && payload.issues.length !== seen) {
|
|
3078
|
-
if (aborted(payload, seen)) break;
|
|
3079
|
-
seen = payload.issues.length;
|
|
3080
|
-
}
|
|
3081
|
-
if (key === "__proto__") continue;
|
|
2571
|
+
for (const key of value.keys) {
|
|
3082
2572
|
const el = shape[key];
|
|
3083
|
-
const
|
|
3084
|
-
const
|
|
2573
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
2574
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
3085
2575
|
const r = el._zod.run({
|
|
3086
2576
|
value: input[key],
|
|
3087
2577
|
issues: []
|
|
3088
2578
|
}, ctx);
|
|
3089
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
3090
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2579
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
2580
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
3091
2581
|
}
|
|
3092
2582
|
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
3093
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst
|
|
2583
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
3094
2584
|
};
|
|
3095
2585
|
});
|
|
3096
2586
|
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
3097
2587
|
$ZodObject.init(inst, def);
|
|
3098
2588
|
const superParse = inst._zod.parse;
|
|
3099
2589
|
const _normalized = cached(() => normalizeDef(def));
|
|
3100
|
-
const memo = globalConfig.memoizer;
|
|
3101
2590
|
const generateFastpass = (shape) => {
|
|
2591
|
+
const doc = new Doc([
|
|
2592
|
+
"shape",
|
|
2593
|
+
"payload",
|
|
2594
|
+
"ctx"
|
|
2595
|
+
]);
|
|
3102
2596
|
const normalized = _normalized.value;
|
|
3103
|
-
const
|
|
3104
|
-
|
|
3105
|
-
shape,
|
|
3106
|
-
|
|
3107
|
-
memo,
|
|
3108
|
-
syms
|
|
3109
|
-
});
|
|
3110
|
-
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
3111
|
-
const prefixStr = (id, k) => `
|
|
3112
|
-
let ${id}_ab = false;
|
|
3113
|
-
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
3114
|
-
const iss = ${id}.issues[i];
|
|
3115
|
-
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
3116
|
-
payload.issues.push(iss);
|
|
3117
|
-
if (iss.continue !== true) ${id}_ab = true;
|
|
3118
|
-
}
|
|
3119
|
-
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
3120
|
-
payload.value = newResult;
|
|
3121
|
-
return payload;
|
|
3122
|
-
}`;
|
|
2597
|
+
const parseStr = (key) => {
|
|
2598
|
+
const k = esc(key);
|
|
2599
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2600
|
+
};
|
|
3123
2601
|
doc.write(`const input = payload.value;`);
|
|
3124
2602
|
const ids = Object.create(null);
|
|
3125
2603
|
let counter = 0;
|
|
3126
|
-
for (const key of normalized.
|
|
3127
|
-
doc.write(
|
|
3128
|
-
for (const key of normalized.
|
|
3129
|
-
if (key === "__proto__") continue;
|
|
2604
|
+
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
2605
|
+
doc.write(`const newResult = {};`);
|
|
2606
|
+
for (const key of normalized.keys) {
|
|
3130
2607
|
const id = ids[key];
|
|
3131
|
-
const k =
|
|
3132
|
-
const isPresent = `${k} in input`;
|
|
2608
|
+
const k = esc(key);
|
|
3133
2609
|
const schema = shape[key];
|
|
3134
|
-
const
|
|
3135
|
-
const isOptionalIn = optin !== void 0;
|
|
2610
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3136
2611
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3137
|
-
doc.write(`const ${id} = ${parseStr(
|
|
3138
|
-
if (isOptionalIn && isOptionalOut)
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
2612
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2613
|
+
if (isOptionalIn && isOptionalOut) doc.write(`
|
|
2614
|
+
if (${id}.issues.length) {
|
|
2615
|
+
if (${k} in input) {
|
|
2616
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2617
|
+
...iss,
|
|
2618
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2619
|
+
})));
|
|
3144
2620
|
}
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
if (${id}.value === undefined) {
|
|
2624
|
+
if (${k} in input) {
|
|
2625
|
+
newResult[${k}] = undefined;
|
|
3148
2626
|
}
|
|
2627
|
+
} else {
|
|
2628
|
+
newResult[${k}] = ${id}.value;
|
|
3149
2629
|
}
|
|
3150
|
-
|
|
2630
|
+
|
|
3151
2631
|
`);
|
|
3152
|
-
|
|
3153
|
-
const ${id}_present = ${
|
|
3154
|
-
if (${id}.issues.length) {
|
|
2632
|
+
else if (!isOptionalIn) doc.write(`
|
|
2633
|
+
const ${id}_present = ${k} in input;
|
|
2634
|
+
if (${id}.issues.length) {
|
|
2635
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2636
|
+
...iss,
|
|
2637
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2638
|
+
})));
|
|
3155
2639
|
}
|
|
3156
2640
|
if (!${id}_present && !${id}.issues.length) {
|
|
3157
2641
|
payload.issues.push({
|
|
@@ -3160,36 +2644,42 @@ window.__ModuleLoader__.load({
|
|
|
3160
2644
|
input: undefined,
|
|
3161
2645
|
path: [${k}]
|
|
3162
2646
|
});
|
|
3163
|
-
if (ctx && ctx.abortEarly) {
|
|
3164
|
-
payload.value = newResult;
|
|
3165
|
-
return payload;
|
|
3166
|
-
}
|
|
3167
2647
|
}
|
|
3168
2648
|
|
|
3169
2649
|
if (${id}_present) {
|
|
3170
|
-
|
|
2650
|
+
if (${id}.value === undefined) {
|
|
2651
|
+
newResult[${k}] = undefined;
|
|
2652
|
+
} else {
|
|
2653
|
+
newResult[${k}] = ${id}.value;
|
|
2654
|
+
}
|
|
3171
2655
|
}
|
|
3172
2656
|
|
|
3173
2657
|
`);
|
|
3174
|
-
else
|
|
3175
|
-
|
|
3176
|
-
|
|
2658
|
+
else doc.write(`
|
|
2659
|
+
if (${id}.issues.length) {
|
|
2660
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2661
|
+
...iss,
|
|
2662
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2663
|
+
})));
|
|
3177
2664
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
2665
|
+
|
|
2666
|
+
if (${id}.value === undefined) {
|
|
2667
|
+
if (${k} in input) {
|
|
2668
|
+
newResult[${k}] = undefined;
|
|
2669
|
+
}
|
|
2670
|
+
} else {
|
|
3182
2671
|
newResult[${k}] = ${id}.value;
|
|
3183
2672
|
}
|
|
2673
|
+
|
|
3184
2674
|
`);
|
|
3185
|
-
}
|
|
3186
2675
|
}
|
|
3187
2676
|
doc.write(`payload.value = newResult;`);
|
|
3188
2677
|
doc.write(`return payload;`);
|
|
3189
|
-
|
|
2678
|
+
const fn = doc.compile();
|
|
2679
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
3190
2680
|
};
|
|
3191
2681
|
let fastpass;
|
|
3192
|
-
const isObject$
|
|
2682
|
+
const isObject$1 = isObject;
|
|
3193
2683
|
const jit = !globalConfig.jitless;
|
|
3194
2684
|
const fastEnabled = jit && allowsEval.value;
|
|
3195
2685
|
const catchall = def.catchall;
|
|
@@ -3197,7 +2687,7 @@ window.__ModuleLoader__.load({
|
|
|
3197
2687
|
inst._zod.parse = (payload, ctx) => {
|
|
3198
2688
|
value ?? (value = _normalized.value);
|
|
3199
2689
|
const input = payload.value;
|
|
3200
|
-
if (!isObject$
|
|
2690
|
+
if (!isObject$1(input)) {
|
|
3201
2691
|
payload.issues.push({
|
|
3202
2692
|
expected: "object",
|
|
3203
2693
|
code: "invalid_type",
|
|
@@ -3210,7 +2700,7 @@ window.__ModuleLoader__.load({
|
|
|
3210
2700
|
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
3211
2701
|
payload = fastpass(payload, ctx);
|
|
3212
2702
|
if (!catchall) return payload;
|
|
3213
|
-
return handleCatchall([], input, payload, ctx, value, inst
|
|
2703
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
3214
2704
|
}
|
|
3215
2705
|
return superParse(payload, ctx);
|
|
3216
2706
|
};
|
|
@@ -3235,14 +2725,14 @@ window.__ModuleLoader__.load({
|
|
|
3235
2725
|
}
|
|
3236
2726
|
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
3237
2727
|
$ZodType.init(inst, def);
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
if (
|
|
2728
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
2729
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2730
|
+
defineLazy(inst._zod, "values", () => {
|
|
2731
|
+
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
3242
2732
|
});
|
|
3243
|
-
|
|
3244
|
-
if (
|
|
3245
|
-
const patterns =
|
|
2733
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2734
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
2735
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
3246
2736
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
3247
2737
|
}
|
|
3248
2738
|
});
|
|
@@ -3304,9 +2794,7 @@ window.__ModuleLoader__.load({
|
|
|
3304
2794
|
...a,
|
|
3305
2795
|
...b
|
|
3306
2796
|
};
|
|
3307
|
-
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
3308
2797
|
for (const key of sharedKeys) {
|
|
3309
|
-
if (key === "__proto__") continue;
|
|
3310
2798
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
3311
2799
|
if (!sharedValue.valid) return {
|
|
3312
2800
|
valid: false,
|
|
@@ -3348,39 +2836,26 @@ window.__ModuleLoader__.load({
|
|
|
3348
2836
|
function handleIntersectionResults(result, left, right) {
|
|
3349
2837
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
3350
2838
|
let unrecIssue;
|
|
3351
|
-
const
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
3355
|
-
unrecIssue ?? (unrecIssue = iss);
|
|
3356
|
-
keys = iss.keys;
|
|
3357
|
-
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
3358
|
-
const k = String(iss.path[0]);
|
|
3359
|
-
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
3360
|
-
keys = [k];
|
|
3361
|
-
} else return false;
|
|
3362
|
-
for (const k of keys) {
|
|
2839
|
+
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
2840
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2841
|
+
for (const k of iss.keys) {
|
|
3363
2842
|
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
3364
|
-
unrecKeys.get(k)
|
|
2843
|
+
unrecKeys.get(k).l = true;
|
|
3365
2844
|
}
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
3371
|
-
if (bothKeys.length) {
|
|
3372
|
-
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
3373
|
-
if (aggregated.length) result.issues.push({
|
|
3374
|
-
...unrecIssue,
|
|
3375
|
-
keys: aggregated
|
|
3376
|
-
});
|
|
3377
|
-
for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
|
|
2845
|
+
} else result.issues.push(iss);
|
|
2846
|
+
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
2847
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2848
|
+
unrecKeys.get(k).r = true;
|
|
3378
2849
|
}
|
|
2850
|
+
else result.issues.push(iss);
|
|
2851
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2852
|
+
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
2853
|
+
...unrecIssue,
|
|
2854
|
+
keys: bothKeys
|
|
2855
|
+
});
|
|
2856
|
+
if (aborted(result)) return result;
|
|
3379
2857
|
const merged = mergeValues(left.value, right.value);
|
|
3380
|
-
if (!merged.valid) {
|
|
3381
|
-
if (aborted(result)) return result;
|
|
3382
|
-
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
3383
|
-
}
|
|
2858
|
+
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
3384
2859
|
result.value = merged.data;
|
|
3385
2860
|
return result;
|
|
3386
2861
|
}
|
|
@@ -3389,10 +2864,7 @@ window.__ModuleLoader__.load({
|
|
|
3389
2864
|
const values = getEnumValues(def.entries);
|
|
3390
2865
|
const valuesSet = new Set(values);
|
|
3391
2866
|
inst._zod.values = valuesSet;
|
|
3392
|
-
|
|
3393
|
-
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
3394
|
-
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
3395
|
-
});
|
|
2867
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
3396
2868
|
inst._zod.parse = (payload, _ctx) => {
|
|
3397
2869
|
const input = payload.value;
|
|
3398
2870
|
if (valuesSet.has(input)) return payload;
|
|
@@ -3408,66 +2880,67 @@ window.__ModuleLoader__.load({
|
|
|
3408
2880
|
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
3409
2881
|
$ZodType.init(inst, def);
|
|
3410
2882
|
inst._zod.optin = "optional";
|
|
3411
|
-
globalConfig.memoizer?.guard(inst);
|
|
3412
2883
|
inst._zod.parse = (payload, ctx) => {
|
|
3413
2884
|
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
3414
2885
|
const _out = def.transform(payload.value, payload);
|
|
3415
2886
|
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
3416
2887
|
payload.value = output;
|
|
2888
|
+
payload.fallback = true;
|
|
3417
2889
|
return payload;
|
|
3418
2890
|
});
|
|
3419
2891
|
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
3420
2892
|
payload.value = _out;
|
|
2893
|
+
payload.fallback = true;
|
|
3421
2894
|
return payload;
|
|
3422
2895
|
};
|
|
3423
2896
|
});
|
|
3424
|
-
function handleOptionalResult(
|
|
3425
|
-
|
|
3426
|
-
|
|
2897
|
+
function handleOptionalResult(result, input) {
|
|
2898
|
+
if (input === void 0 && (result.issues.length || result.fallback)) return {
|
|
2899
|
+
issues: [],
|
|
2900
|
+
value: void 0
|
|
2901
|
+
};
|
|
2902
|
+
return result;
|
|
3427
2903
|
}
|
|
3428
2904
|
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
3429
2905
|
$ZodType.init(inst, def);
|
|
3430
|
-
|
|
2906
|
+
inst._zod.optin = "optional";
|
|
3431
2907
|
inst._zod.optout = "optional";
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
|
|
2908
|
+
defineLazy(inst._zod, "values", () => {
|
|
2909
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
3435
2910
|
});
|
|
3436
|
-
|
|
3437
|
-
const pattern =
|
|
2911
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2912
|
+
const pattern = def.innerType._zod.pattern;
|
|
3438
2913
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
3439
2914
|
});
|
|
3440
2915
|
inst._zod.parse = (payload, ctx) => {
|
|
3441
|
-
if (
|
|
3442
|
-
|
|
3443
|
-
const result = def.innerType._zod.run(
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
}, ctx);
|
|
3447
|
-
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
3448
|
-
return handleOptionalResult(payload, result);
|
|
2916
|
+
if (def.innerType._zod.optin === "optional") {
|
|
2917
|
+
const input = payload.value;
|
|
2918
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2919
|
+
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
|
|
2920
|
+
return handleOptionalResult(result, input);
|
|
3449
2921
|
}
|
|
2922
|
+
if (payload.value === void 0) return payload;
|
|
3450
2923
|
return def.innerType._zod.run(payload, ctx);
|
|
3451
2924
|
};
|
|
3452
2925
|
});
|
|
3453
2926
|
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
|
|
3454
2927
|
$ZodOptional.init(inst, def);
|
|
3455
|
-
|
|
3456
|
-
|
|
2928
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2929
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
3457
2930
|
inst._zod.parse = (payload, ctx) => {
|
|
3458
2931
|
return def.innerType._zod.run(payload, ctx);
|
|
3459
2932
|
};
|
|
3460
2933
|
});
|
|
3461
2934
|
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
3462
2935
|
$ZodType.init(inst, def);
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
const pattern =
|
|
2936
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2937
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2938
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2939
|
+
const pattern = def.innerType._zod.pattern;
|
|
3467
2940
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
3468
2941
|
});
|
|
3469
|
-
|
|
3470
|
-
return
|
|
2942
|
+
defineLazy(inst._zod, "values", () => {
|
|
2943
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
3471
2944
|
});
|
|
3472
2945
|
inst._zod.parse = (payload, ctx) => {
|
|
3473
2946
|
if (payload.value === null) return payload;
|
|
@@ -3476,8 +2949,8 @@ window.__ModuleLoader__.load({
|
|
|
3476
2949
|
});
|
|
3477
2950
|
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
3478
2951
|
$ZodType.init(inst, def);
|
|
3479
|
-
inst._zod.optin = "
|
|
3480
|
-
|
|
2952
|
+
inst._zod.optin = "optional";
|
|
2953
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3481
2954
|
inst._zod.parse = (payload, ctx) => {
|
|
3482
2955
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3483
2956
|
if (payload.value === void 0) {
|
|
@@ -3498,8 +2971,8 @@ window.__ModuleLoader__.load({
|
|
|
3498
2971
|
}
|
|
3499
2972
|
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
3500
2973
|
$ZodType.init(inst, def);
|
|
3501
|
-
inst._zod.optin = "
|
|
3502
|
-
|
|
2974
|
+
inst._zod.optin = "optional";
|
|
2975
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3503
2976
|
inst._zod.parse = (payload, ctx) => {
|
|
3504
2977
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3505
2978
|
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
@@ -3508,8 +2981,8 @@ window.__ModuleLoader__.load({
|
|
|
3508
2981
|
});
|
|
3509
2982
|
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
3510
2983
|
$ZodType.init(inst, def);
|
|
3511
|
-
|
|
3512
|
-
const v =
|
|
2984
|
+
defineLazy(inst._zod, "values", () => {
|
|
2985
|
+
const v = def.innerType._zod.values;
|
|
3513
2986
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
3514
2987
|
});
|
|
3515
2988
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3527,41 +3000,46 @@ window.__ModuleLoader__.load({
|
|
|
3527
3000
|
});
|
|
3528
3001
|
return payload;
|
|
3529
3002
|
}
|
|
3530
|
-
function handleCatchResult(payload, result, def, ctx) {
|
|
3531
|
-
if (!result.issues.length) {
|
|
3532
|
-
payload.value = result.value;
|
|
3533
|
-
if (result.memo) payload.memo = true;
|
|
3534
|
-
return payload;
|
|
3535
|
-
}
|
|
3536
|
-
payload.value = def.catchValue({
|
|
3537
|
-
...result,
|
|
3538
|
-
value: payload.value,
|
|
3539
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
3540
|
-
input: payload.value
|
|
3541
|
-
});
|
|
3542
|
-
return payload;
|
|
3543
|
-
}
|
|
3544
3003
|
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
3545
3004
|
$ZodType.init(inst, def);
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3005
|
+
inst._zod.optin = "optional";
|
|
3006
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
3007
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3549
3008
|
inst._zod.parse = (payload, ctx) => {
|
|
3550
3009
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3551
|
-
const result = def.innerType._zod.run(
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3010
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
3011
|
+
if (result instanceof Promise) return result.then((result) => {
|
|
3012
|
+
payload.value = result.value;
|
|
3013
|
+
if (result.issues.length) {
|
|
3014
|
+
payload.value = def.catchValue({
|
|
3015
|
+
...payload,
|
|
3016
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
3017
|
+
input: payload.value
|
|
3018
|
+
});
|
|
3019
|
+
payload.issues = [];
|
|
3020
|
+
payload.fallback = true;
|
|
3021
|
+
}
|
|
3022
|
+
return payload;
|
|
3023
|
+
});
|
|
3024
|
+
payload.value = result.value;
|
|
3025
|
+
if (result.issues.length) {
|
|
3026
|
+
payload.value = def.catchValue({
|
|
3027
|
+
...payload,
|
|
3028
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
3029
|
+
input: payload.value
|
|
3030
|
+
});
|
|
3031
|
+
payload.issues = [];
|
|
3032
|
+
payload.fallback = true;
|
|
3033
|
+
}
|
|
3034
|
+
return payload;
|
|
3557
3035
|
};
|
|
3558
3036
|
});
|
|
3559
3037
|
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
3560
3038
|
$ZodType.init(inst, def);
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3039
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
3040
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
3041
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
3042
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
3565
3043
|
inst._zod.parse = (payload, ctx) => {
|
|
3566
3044
|
if (ctx.direction === "backward") {
|
|
3567
3045
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -3574,21 +3052,22 @@ window.__ModuleLoader__.load({
|
|
|
3574
3052
|
};
|
|
3575
3053
|
});
|
|
3576
3054
|
function handlePipeResult(left, next, ctx) {
|
|
3577
|
-
if (left.issues.
|
|
3055
|
+
if (left.issues.length) {
|
|
3578
3056
|
left.aborted = true;
|
|
3579
3057
|
return left;
|
|
3580
3058
|
}
|
|
3581
3059
|
return next._zod.run({
|
|
3582
3060
|
value: left.value,
|
|
3583
|
-
issues: left.issues
|
|
3061
|
+
issues: left.issues,
|
|
3062
|
+
fallback: left.fallback
|
|
3584
3063
|
}, ctx);
|
|
3585
3064
|
}
|
|
3586
3065
|
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
3587
3066
|
$ZodType.init(inst, def);
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3067
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
3068
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3069
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
3070
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
3592
3071
|
inst._zod.parse = (payload, ctx) => {
|
|
3593
3072
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3594
3073
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -3597,7 +3076,7 @@ window.__ModuleLoader__.load({
|
|
|
3597
3076
|
};
|
|
3598
3077
|
});
|
|
3599
3078
|
function handleReadonlyResult(payload) {
|
|
3600
|
-
|
|
3079
|
+
payload.value = Object.freeze(payload.value);
|
|
3601
3080
|
return payload;
|
|
3602
3081
|
}
|
|
3603
3082
|
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -3627,379 +3106,18 @@ window.__ModuleLoader__.load({
|
|
|
3627
3106
|
}
|
|
3628
3107
|
}
|
|
3629
3108
|
//#endregion
|
|
3630
|
-
//#region ../src/node_modules/zod/v4/core/
|
|
3631
|
-
var
|
|
3109
|
+
//#region ../src/node_modules/zod/v4/core/registries.js
|
|
3110
|
+
var _a;
|
|
3111
|
+
var $ZodRegistry = class {
|
|
3632
3112
|
constructor() {
|
|
3633
|
-
|
|
3634
|
-
this.
|
|
3635
|
-
}
|
|
3636
|
-
};
|
|
3637
|
-
/** Keyed off the context object every schema in one parse call already shares. */
|
|
3638
|
-
const STATE = "~memo";
|
|
3639
|
-
const NO_ISSUES = [];
|
|
3640
|
-
function isRef(value) {
|
|
3641
|
-
return value !== null && typeof value === "object";
|
|
3642
|
-
}
|
|
3643
|
-
function cloneIssues(issues) {
|
|
3644
|
-
return issues.map((iss) => iss.path ? {
|
|
3645
|
-
...iss,
|
|
3646
|
-
path: iss.path.slice()
|
|
3647
|
-
} : { ...iss });
|
|
3648
|
-
}
|
|
3649
|
-
const recursive = /*@__PURE__*/ new WeakMap();
|
|
3650
|
-
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
|
|
3651
|
-
const NONE = 0;
|
|
3652
|
-
const ASSUMED = 1;
|
|
3653
|
-
const PROVEN = 2;
|
|
3654
|
-
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
|
|
3655
|
-
function isRecursive(inst, stack, resolve) {
|
|
3656
|
-
const cached = recursive.get(inst);
|
|
3657
|
-
if (cached !== void 0) return cached ? PROVEN : NONE;
|
|
3658
|
-
if (stack.has(inst)) return PROVEN;
|
|
3659
|
-
stack.add(inst);
|
|
3660
|
-
let result = NONE;
|
|
3661
|
-
const check = (child) => {
|
|
3662
|
-
if (result !== PROVEN && child?._zod) {
|
|
3663
|
-
const answer = isRecursive(child, stack, resolve);
|
|
3664
|
-
if (answer > result) result = answer;
|
|
3665
|
-
}
|
|
3666
|
-
};
|
|
3667
|
-
const shape = (sh, spread) => {
|
|
3668
|
-
let answer = NONE;
|
|
3669
|
-
for (const key of Reflect.ownKeys(sh)) {
|
|
3670
|
-
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3671
|
-
if (spread && !desc.enumerable) continue;
|
|
3672
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
3673
|
-
if (child > answer) answer = child;
|
|
3674
|
-
}
|
|
3675
|
-
return answer;
|
|
3676
|
-
};
|
|
3677
|
-
const merge = (answer) => {
|
|
3678
|
-
if (answer > result) result = answer;
|
|
3679
|
-
};
|
|
3680
|
-
const def = inst._zod.def;
|
|
3681
|
-
switch (def.type) {
|
|
3682
|
-
case "object": {
|
|
3683
|
-
const raw = rawShape(def);
|
|
3684
|
-
merge(raw ? shape(raw, true) : ASSUMED);
|
|
3685
|
-
check(def.catchall);
|
|
3686
|
-
break;
|
|
3687
|
-
}
|
|
3688
|
-
case "array":
|
|
3689
|
-
check(def.element);
|
|
3690
|
-
break;
|
|
3691
|
-
case "tuple":
|
|
3692
|
-
for (const el of def.items) check(el);
|
|
3693
|
-
check(def.rest);
|
|
3694
|
-
break;
|
|
3695
|
-
case "record":
|
|
3696
|
-
case "map":
|
|
3697
|
-
check(def.keyType);
|
|
3698
|
-
check(def.valueType);
|
|
3699
|
-
break;
|
|
3700
|
-
case "set":
|
|
3701
|
-
check(def.valueType);
|
|
3702
|
-
break;
|
|
3703
|
-
case "union":
|
|
3704
|
-
for (const el of def.options) check(el);
|
|
3705
|
-
break;
|
|
3706
|
-
case "intersection":
|
|
3707
|
-
check(def.left);
|
|
3708
|
-
check(def.right);
|
|
3709
|
-
break;
|
|
3710
|
-
case "optional":
|
|
3711
|
-
case "nullable":
|
|
3712
|
-
case "default":
|
|
3713
|
-
case "prefault":
|
|
3714
|
-
case "catch":
|
|
3715
|
-
case "readonly":
|
|
3716
|
-
case "nonoptional":
|
|
3717
|
-
case "promise":
|
|
3718
|
-
case "success":
|
|
3719
|
-
check(def.innerType);
|
|
3720
|
-
break;
|
|
3721
|
-
case "pipe":
|
|
3722
|
-
check(def.in);
|
|
3723
|
-
check(def.out);
|
|
3724
|
-
break;
|
|
3725
|
-
case "function":
|
|
3726
|
-
check(def.input);
|
|
3727
|
-
check(def.output);
|
|
3728
|
-
break;
|
|
3729
|
-
case "lazy": {
|
|
3730
|
-
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
3731
|
-
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
3732
|
-
break;
|
|
3733
|
-
}
|
|
3734
|
-
case "template_literal":
|
|
3735
|
-
case "string":
|
|
3736
|
-
case "number":
|
|
3737
|
-
case "int":
|
|
3738
|
-
case "boolean":
|
|
3739
|
-
case "bigint":
|
|
3740
|
-
case "symbol":
|
|
3741
|
-
case "undefined":
|
|
3742
|
-
case "null":
|
|
3743
|
-
case "void":
|
|
3744
|
-
case "never":
|
|
3745
|
-
case "any":
|
|
3746
|
-
case "unknown":
|
|
3747
|
-
case "date":
|
|
3748
|
-
case "nan":
|
|
3749
|
-
case "enum":
|
|
3750
|
-
case "literal":
|
|
3751
|
-
case "file":
|
|
3752
|
-
case "transform":
|
|
3753
|
-
case "custom": break;
|
|
3754
|
-
default: for (const key in def) {
|
|
3755
|
-
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
3756
|
-
if (!desc || desc.get) continue;
|
|
3757
|
-
const value = desc.value;
|
|
3758
|
-
if (!value || typeof value !== "object") continue;
|
|
3759
|
-
if (value._zod) check(value);
|
|
3760
|
-
else if (Array.isArray(value)) for (const el of value) check(el);
|
|
3761
|
-
}
|
|
3113
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
3114
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
3762
3115
|
}
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
|
|
3769
|
-
return answer;
|
|
3770
|
-
}
|
|
3771
|
-
function bucketFor(state, inst) {
|
|
3772
|
-
let bucket = state.buckets.get(inst);
|
|
3773
|
-
if (!bucket) {
|
|
3774
|
-
bucket = /* @__PURE__ */ new WeakMap();
|
|
3775
|
-
state.buckets.set(inst, bucket);
|
|
3776
|
-
}
|
|
3777
|
-
return bucket;
|
|
3778
|
-
}
|
|
3779
|
-
let handoff;
|
|
3780
|
-
const open = [];
|
|
3781
|
-
const memo = {
|
|
3782
|
-
alloc(_inst, payload, empty) {
|
|
3783
|
-
const bucket = handoff;
|
|
3784
|
-
if (!bucket) return empty;
|
|
3785
|
-
handoff = void 0;
|
|
3786
|
-
const entry = {
|
|
3787
|
-
value: empty,
|
|
3788
|
-
issues: null
|
|
3789
|
-
};
|
|
3790
|
-
bucket.set(payload.value, entry);
|
|
3791
|
-
open.push(entry);
|
|
3792
|
-
return empty;
|
|
3793
|
-
},
|
|
3794
|
-
guard(inst) {
|
|
3795
|
-
var _a;
|
|
3796
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
3797
|
-
inst._zod.deferred.push(() => {
|
|
3798
|
-
const base = inst._zod.parse;
|
|
3799
|
-
const wrapped = (payload, ctx) => {
|
|
3800
|
-
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
|
|
3801
|
-
return base(payload, ctx);
|
|
3802
|
-
};
|
|
3803
|
-
inst._zod.parse = wrapped;
|
|
3804
|
-
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
3805
|
-
});
|
|
3806
|
-
},
|
|
3807
|
-
attach(inst) {
|
|
3808
|
-
var _a;
|
|
3809
|
-
let isRecursiveInst;
|
|
3810
|
-
let rechecked = false;
|
|
3811
|
-
let lastCtx;
|
|
3812
|
-
let lastBucket;
|
|
3813
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
3814
|
-
inst._zod.deferred.push(() => {
|
|
3815
|
-
const base = inst._zod.parse;
|
|
3816
|
-
const wrapped = (payload, ctx) => {
|
|
3817
|
-
if (isRecursiveInst === void 0) {
|
|
3818
|
-
const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
|
|
3819
|
-
if (walked === NONE) {
|
|
3820
|
-
inst._zod.parse = base;
|
|
3821
|
-
if (inst._zod.run === wrapped) inst._zod.run = base;
|
|
3822
|
-
return base(payload, ctx);
|
|
3823
|
-
}
|
|
3824
|
-
if (walked === PROVEN || rechecked) isRecursiveInst = true;
|
|
3825
|
-
else rechecked = true;
|
|
3826
|
-
}
|
|
3827
|
-
const input = payload.value;
|
|
3828
|
-
if (!isRef(input)) return base(payload, ctx);
|
|
3829
|
-
let state = ctx[STATE];
|
|
3830
|
-
if (!state) {
|
|
3831
|
-
state = {
|
|
3832
|
-
buckets: /* @__PURE__ */ new WeakMap(),
|
|
3833
|
-
backEdges: void 0
|
|
3834
|
-
};
|
|
3835
|
-
ctx[STATE] = state;
|
|
3836
|
-
}
|
|
3837
|
-
let bucket;
|
|
3838
|
-
if (lastCtx === ctx) bucket = lastBucket;
|
|
3839
|
-
else {
|
|
3840
|
-
bucket = bucketFor(state, inst);
|
|
3841
|
-
lastCtx = ctx;
|
|
3842
|
-
lastBucket = bucket;
|
|
3843
|
-
}
|
|
3844
|
-
const hit = bucket.get(input);
|
|
3845
|
-
if (hit) {
|
|
3846
|
-
payload.value = hit.value;
|
|
3847
|
-
if (hit.issues) {
|
|
3848
|
-
if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
|
|
3849
|
-
} else {
|
|
3850
|
-
payload.memo = true;
|
|
3851
|
-
state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
|
|
3852
|
-
state.backEdges.add(hit.value);
|
|
3853
|
-
}
|
|
3854
|
-
return payload;
|
|
3855
|
-
}
|
|
3856
|
-
handoff = bucket;
|
|
3857
|
-
const depth = open.length;
|
|
3858
|
-
const result = base(payload, ctx);
|
|
3859
|
-
handoff = void 0;
|
|
3860
|
-
const entry = open.length > depth ? open.pop() : void 0;
|
|
3861
|
-
if (result instanceof Promise) return result.then((r) => {
|
|
3862
|
-
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
3863
|
-
return r;
|
|
3864
|
-
});
|
|
3865
|
-
if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
3866
|
-
return result;
|
|
3867
|
-
};
|
|
3868
|
-
inst._zod.parse = wrapped;
|
|
3869
|
-
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
3870
|
-
});
|
|
3871
|
-
}
|
|
3872
|
-
};
|
|
3873
|
-
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
|
|
3874
|
-
function memoizer() {
|
|
3875
|
-
return memo;
|
|
3876
|
-
}
|
|
3877
|
-
/** Whether this value is a node a back-edge resolved to before it finished. */
|
|
3878
|
-
function isBackEdge(ctx, value) {
|
|
3879
|
-
const backEdges = ctx[STATE]?.backEdges;
|
|
3880
|
-
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
3881
|
-
}
|
|
3882
|
-
//#endregion
|
|
3883
|
-
//#region ../src/node_modules/zod/v4/locales/en.js
|
|
3884
|
-
const error = () => {
|
|
3885
|
-
const Sizable = {
|
|
3886
|
-
string: {
|
|
3887
|
-
unit: "characters",
|
|
3888
|
-
verb: "to have"
|
|
3889
|
-
},
|
|
3890
|
-
file: {
|
|
3891
|
-
unit: "bytes",
|
|
3892
|
-
verb: "to have"
|
|
3893
|
-
},
|
|
3894
|
-
array: {
|
|
3895
|
-
unit: "items",
|
|
3896
|
-
verb: "to have"
|
|
3897
|
-
},
|
|
3898
|
-
set: {
|
|
3899
|
-
unit: "items",
|
|
3900
|
-
verb: "to have"
|
|
3901
|
-
},
|
|
3902
|
-
map: {
|
|
3903
|
-
unit: "entries",
|
|
3904
|
-
verb: "to have"
|
|
3905
|
-
}
|
|
3906
|
-
};
|
|
3907
|
-
function getSizing(origin) {
|
|
3908
|
-
return Sizable[origin] ?? null;
|
|
3909
|
-
}
|
|
3910
|
-
const FormatDictionary = {
|
|
3911
|
-
regex: "input",
|
|
3912
|
-
email: "email address",
|
|
3913
|
-
url: "URL",
|
|
3914
|
-
emoji: "emoji",
|
|
3915
|
-
uuid: "UUID",
|
|
3916
|
-
uuidv4: "UUIDv4",
|
|
3917
|
-
uuidv6: "UUIDv6",
|
|
3918
|
-
nanoid: "nanoid",
|
|
3919
|
-
guid: "GUID",
|
|
3920
|
-
cuid: "cuid",
|
|
3921
|
-
cuid2: "cuid2",
|
|
3922
|
-
ulid: "ULID",
|
|
3923
|
-
xid: "XID",
|
|
3924
|
-
ksuid: "KSUID",
|
|
3925
|
-
datetime: "ISO datetime",
|
|
3926
|
-
date: "ISO date",
|
|
3927
|
-
time: "ISO time",
|
|
3928
|
-
duration: "ISO duration",
|
|
3929
|
-
ipv4: "IPv4 address",
|
|
3930
|
-
ipv6: "IPv6 address",
|
|
3931
|
-
mac: "MAC address",
|
|
3932
|
-
cidrv4: "IPv4 range",
|
|
3933
|
-
cidrv6: "IPv6 range",
|
|
3934
|
-
base64: "base64-encoded string",
|
|
3935
|
-
base64url: "base64url-encoded string",
|
|
3936
|
-
json_string: "JSON string",
|
|
3937
|
-
e164: "E.164 number",
|
|
3938
|
-
currency_code: "currency code",
|
|
3939
|
-
credit_card: "credit card number",
|
|
3940
|
-
iban: "IBAN",
|
|
3941
|
-
jwt: "JWT",
|
|
3942
|
-
template_literal: "input"
|
|
3943
|
-
};
|
|
3944
|
-
const TypeDictionary = { nan: "NaN" };
|
|
3945
|
-
function getTypeName(type, input) {
|
|
3946
|
-
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
|
|
3947
|
-
return TypeDictionary[type] ?? type;
|
|
3948
|
-
}
|
|
3949
|
-
return (issue) => {
|
|
3950
|
-
switch (issue.code) {
|
|
3951
|
-
case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
|
|
3952
|
-
case "invalid_value":
|
|
3953
|
-
if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
3954
|
-
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
3955
|
-
case "too_big": {
|
|
3956
|
-
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
3957
|
-
const sizing = getSizing(issue.origin);
|
|
3958
|
-
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3959
|
-
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
3960
|
-
}
|
|
3961
|
-
case "too_small": {
|
|
3962
|
-
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
3963
|
-
const sizing = getSizing(issue.origin);
|
|
3964
|
-
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
3965
|
-
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
3966
|
-
}
|
|
3967
|
-
case "invalid_format": {
|
|
3968
|
-
const _issue = issue;
|
|
3969
|
-
if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3970
|
-
if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3971
|
-
if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
|
|
3972
|
-
if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3973
|
-
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
3974
|
-
}
|
|
3975
|
-
case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
3976
|
-
case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
3977
|
-
case "invalid_key": return `Invalid key in ${issue.origin}`;
|
|
3978
|
-
case "invalid_union":
|
|
3979
|
-
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
|
|
3980
|
-
if (issue.inclusive === false) return "Invalid input: more than one option matched";
|
|
3981
|
-
return "Invalid input";
|
|
3982
|
-
case "invalid_element": return `Invalid value in ${issue.origin}`;
|
|
3983
|
-
default: return `Invalid input`;
|
|
3984
|
-
}
|
|
3985
|
-
};
|
|
3986
|
-
};
|
|
3987
|
-
function en_default() {
|
|
3988
|
-
return { localeError: error() };
|
|
3989
|
-
}
|
|
3990
|
-
//#endregion
|
|
3991
|
-
//#region ../src/node_modules/zod/v4/core/registries.js
|
|
3992
|
-
var _a;
|
|
3993
|
-
var $ZodRegistry = class {
|
|
3994
|
-
constructor() {
|
|
3995
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
3996
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
3997
|
-
}
|
|
3998
|
-
add(schema, ..._meta) {
|
|
3999
|
-
const meta = _meta[0];
|
|
4000
|
-
this._map.set(schema, meta);
|
|
4001
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
4002
|
-
return this;
|
|
3116
|
+
add(schema, ..._meta) {
|
|
3117
|
+
const meta = _meta[0];
|
|
3118
|
+
this._map.set(schema, meta);
|
|
3119
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
3120
|
+
return this;
|
|
4003
3121
|
}
|
|
4004
3122
|
clear() {
|
|
4005
3123
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
@@ -4036,16 +3154,12 @@ window.__ModuleLoader__.load({
|
|
|
4036
3154
|
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
4037
3155
|
//#endregion
|
|
4038
3156
|
//#region ../src/node_modules/zod/v4/core/api.js
|
|
4039
|
-
function snapshotChecks(def) {
|
|
4040
|
-
if (def.checks) def.checks = [...def.checks];
|
|
4041
|
-
return def;
|
|
4042
|
-
}
|
|
4043
3157
|
// @__NO_SIDE_EFFECTS__
|
|
4044
3158
|
function _string(Class, params) {
|
|
4045
|
-
return new Class(
|
|
3159
|
+
return new Class({
|
|
4046
3160
|
type: "string",
|
|
4047
3161
|
...normalizeParams(params)
|
|
4048
|
-
})
|
|
3162
|
+
});
|
|
4049
3163
|
}
|
|
4050
3164
|
// @__NO_SIDE_EFFECTS__
|
|
4051
3165
|
function _email(Class, params) {
|
|
@@ -4469,7 +3583,7 @@ window.__ModuleLoader__.load({
|
|
|
4469
3583
|
const _issue = issue$2;
|
|
4470
3584
|
if (_issue.fatal) _issue.continue = false;
|
|
4471
3585
|
_issue.code ?? (_issue.code = "custom");
|
|
4472
|
-
|
|
3586
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
4473
3587
|
_issue.inst ?? (_issue.inst = ch);
|
|
4474
3588
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
4475
3589
|
payload.issues.push(issue(_issue));
|
|
@@ -4490,10 +3604,6 @@ window.__ModuleLoader__.load({
|
|
|
4490
3604
|
}
|
|
4491
3605
|
//#endregion
|
|
4492
3606
|
//#region ../src/node_modules/zod/v4/core/to-json-schema.js
|
|
4493
|
-
function assignProps(target, ...sources) {
|
|
4494
|
-
for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
|
|
4495
|
-
return target;
|
|
4496
|
-
}
|
|
4497
3607
|
function initializeContext(params) {
|
|
4498
3608
|
let target = params?.target ?? "draft-2020-12";
|
|
4499
3609
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -4507,32 +3617,12 @@ window.__ModuleLoader__.load({
|
|
|
4507
3617
|
io: params?.io ?? "output",
|
|
4508
3618
|
counter: 0,
|
|
4509
3619
|
seen: /* @__PURE__ */ new Map(),
|
|
4510
|
-
sharedDefsExtractedFor: void 0,
|
|
4511
|
-
sharedEmitDoneFor: void 0,
|
|
4512
3620
|
cycles: params?.cycles ?? "ref",
|
|
4513
3621
|
reused: params?.reused ?? "inline",
|
|
4514
|
-
intersections: [],
|
|
4515
|
-
deferred: [],
|
|
4516
3622
|
external: params?.external ?? void 0
|
|
4517
3623
|
};
|
|
4518
3624
|
}
|
|
4519
|
-
|
|
4520
|
-
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
|
|
4521
|
-
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
|
|
4522
|
-
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
|
|
4523
|
-
*/
|
|
4524
|
-
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
4525
|
-
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
|
|
4526
|
-
zodSchema: schema,
|
|
4527
|
-
path: params.path,
|
|
4528
|
-
message
|
|
4529
|
-
}) : ctx.unrepresentable;
|
|
4530
|
-
if (result === "any") return false;
|
|
4531
|
-
if (result === void 0 || result === "throw") throw new Error(message);
|
|
4532
|
-
Object.assign(json, result);
|
|
4533
|
-
return true;
|
|
4534
|
-
}
|
|
4535
|
-
function processSchema(schema, ctx, _params = {
|
|
3625
|
+
function process(schema, ctx, _params = {
|
|
4536
3626
|
path: [],
|
|
4537
3627
|
schemaPath: []
|
|
4538
3628
|
}) {
|
|
@@ -4551,8 +3641,6 @@ window.__ModuleLoader__.load({
|
|
|
4551
3641
|
path: _params.path
|
|
4552
3642
|
};
|
|
4553
3643
|
ctx.seen.set(schema, result);
|
|
4554
|
-
ctx.sharedDefsExtractedFor = void 0;
|
|
4555
|
-
ctx.sharedEmitDoneFor = void 0;
|
|
4556
3644
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
4557
3645
|
if (overrideSchema) result.schema = overrideSchema;
|
|
4558
3646
|
else {
|
|
@@ -4571,12 +3659,12 @@ window.__ModuleLoader__.load({
|
|
|
4571
3659
|
const parent = schema._zod.parent;
|
|
4572
3660
|
if (parent) {
|
|
4573
3661
|
if (!result.ref) result.ref = parent;
|
|
4574
|
-
|
|
3662
|
+
process(parent, ctx, params);
|
|
4575
3663
|
ctx.seen.get(parent).isParent = true;
|
|
4576
3664
|
}
|
|
4577
3665
|
}
|
|
4578
3666
|
const meta = ctx.metadataRegistry.get(schema);
|
|
4579
|
-
if (meta)
|
|
3667
|
+
if (meta) Object.assign(result.schema, meta);
|
|
4580
3668
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
4581
3669
|
delete result.schema.examples;
|
|
4582
3670
|
delete result.schema.default;
|
|
@@ -4585,13 +3673,9 @@ window.__ModuleLoader__.load({
|
|
|
4585
3673
|
delete result.schema._prefault;
|
|
4586
3674
|
return ctx.seen.get(schema).schema;
|
|
4587
3675
|
}
|
|
4588
|
-
function encodeJSONPointerSegment(segment) {
|
|
4589
|
-
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
4590
|
-
}
|
|
4591
3676
|
function extractDefs(ctx, schema) {
|
|
4592
3677
|
const root = ctx.seen.get(schema);
|
|
4593
3678
|
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
4594
|
-
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
|
|
4595
3679
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
4596
3680
|
for (const entry of ctx.seen.entries()) {
|
|
4597
3681
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -4611,16 +3695,15 @@ window.__ModuleLoader__.load({
|
|
|
4611
3695
|
entry[1].defId = id;
|
|
4612
3696
|
return {
|
|
4613
3697
|
defId: id,
|
|
4614
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${
|
|
3698
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
4615
3699
|
};
|
|
4616
3700
|
}
|
|
4617
|
-
|
|
4618
|
-
const defUriPrefix =
|
|
4619
|
-
if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
|
|
3701
|
+
if (entry[1] === root) return { ref: "#" };
|
|
3702
|
+
const defUriPrefix = `#/${defsSegment}/`;
|
|
4620
3703
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
4621
3704
|
return {
|
|
4622
3705
|
defId,
|
|
4623
|
-
ref: defUriPrefix +
|
|
3706
|
+
ref: defUriPrefix + defId
|
|
4624
3707
|
};
|
|
4625
3708
|
};
|
|
4626
3709
|
const extractToDef = (entry) => {
|
|
@@ -4661,114 +3744,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4661
3744
|
continue;
|
|
4662
3745
|
}
|
|
4663
3746
|
if (seen.count > 1) {
|
|
4664
|
-
if (ctx.reused === "ref")
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
|
|
4668
|
-
}
|
|
4669
|
-
/** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
|
|
4670
|
-
function compactTypeUnion(schema) {
|
|
4671
|
-
const options = schema.anyOf;
|
|
4672
|
-
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
|
|
4673
|
-
const types = [];
|
|
4674
|
-
for (const option of options) {
|
|
4675
|
-
if (!option || typeof option !== "object") return;
|
|
4676
|
-
compactTypeUnion(option);
|
|
4677
|
-
const keys = Object.keys(option);
|
|
4678
|
-
if (keys.length !== 1 || keys[0] !== "type") return;
|
|
4679
|
-
const type = option.type;
|
|
4680
|
-
for (const member of Array.isArray(type) ? type : [type]) {
|
|
4681
|
-
if (typeof member !== "string") return;
|
|
4682
|
-
if (!types.includes(member)) types.push(member);
|
|
4683
|
-
}
|
|
4684
|
-
}
|
|
4685
|
-
delete schema.anyOf;
|
|
4686
|
-
schema.type = types.length === 1 ? types[0] : types;
|
|
4687
|
-
}
|
|
4688
|
-
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
|
|
4689
|
-
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
|
|
4690
|
-
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
|
|
4691
|
-
const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
|
|
4692
|
-
"type",
|
|
4693
|
-
"properties",
|
|
4694
|
-
"required",
|
|
4695
|
-
"additionalProperties"
|
|
4696
|
-
]);
|
|
4697
|
-
const UNION_KEYS = ["oneOf", "anyOf"];
|
|
4698
|
-
/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
|
|
4699
|
-
function undeclaredConstraint(member) {
|
|
4700
|
-
const extra = member.additionalProperties;
|
|
4701
|
-
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
|
|
4702
|
-
return Object.keys(extra).length ? extra : null;
|
|
4703
|
-
}
|
|
4704
|
-
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
|
|
4705
|
-
function foldObjects(members) {
|
|
4706
|
-
const objects = [];
|
|
4707
|
-
for (const member of members) {
|
|
4708
|
-
if (typeof member !== "object" || member.type !== "object") return null;
|
|
4709
|
-
for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
|
|
4710
|
-
objects.push(member);
|
|
4711
|
-
}
|
|
4712
|
-
const properties = {};
|
|
4713
|
-
const required = /* @__PURE__ */ new Set();
|
|
4714
|
-
for (const object of objects) {
|
|
4715
|
-
for (const key in object.properties) {
|
|
4716
|
-
if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
|
|
4717
|
-
const parts = [];
|
|
4718
|
-
for (const other of objects) {
|
|
4719
|
-
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
4720
|
-
if (part === null || part === void 0) continue;
|
|
4721
|
-
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
|
|
3747
|
+
if (ctx.reused === "ref") {
|
|
3748
|
+
extractToDef(entry);
|
|
3749
|
+
continue;
|
|
4722
3750
|
}
|
|
4723
|
-
assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
|
|
4724
|
-
}
|
|
4725
|
-
for (const key of object.required ?? []) required.add(key);
|
|
4726
|
-
}
|
|
4727
|
-
const folded = {
|
|
4728
|
-
type: "object",
|
|
4729
|
-
properties
|
|
4730
|
-
};
|
|
4731
|
-
if (required.size) folded.required = [...required];
|
|
4732
|
-
if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
|
|
4733
|
-
else {
|
|
4734
|
-
const constraints = [];
|
|
4735
|
-
for (const object of objects) {
|
|
4736
|
-
const constraint = undeclaredConstraint(object);
|
|
4737
|
-
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
|
|
4738
3751
|
}
|
|
4739
|
-
if (constraints.length === 1) folded.additionalProperties = constraints[0];
|
|
4740
|
-
else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
|
|
4741
3752
|
}
|
|
4742
|
-
return folded;
|
|
4743
|
-
}
|
|
4744
|
-
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
|
|
4745
|
-
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
|
|
4746
|
-
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
|
|
4747
|
-
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
|
|
4748
|
-
* into one object is the encoding that says so on every target.
|
|
4749
|
-
*
|
|
4750
|
-
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
|
|
4751
|
-
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
|
|
4752
|
-
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
|
|
4753
|
-
function foldIntersection(json) {
|
|
4754
|
-
const allOf = json.allOf;
|
|
4755
|
-
if (!Array.isArray(allOf) || allOf.length < 2) return;
|
|
4756
|
-
for (const key of FOLDABLE_KEYS) if (key in json) return;
|
|
4757
|
-
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
4758
|
-
let folded = null;
|
|
4759
|
-
if (!unions.length) folded = foldObjects(allOf);
|
|
4760
|
-
else {
|
|
4761
|
-
const union = unions[0];
|
|
4762
|
-
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
4763
|
-
if (Object.keys(union).length !== 1) return;
|
|
4764
|
-
const rest = allOf.filter((m) => m !== union);
|
|
4765
|
-
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
4766
|
-
if (branches.some((b) => !b)) return;
|
|
4767
|
-
folded = { [keyword]: branches };
|
|
4768
|
-
}
|
|
4769
|
-
if (!folded) return;
|
|
4770
|
-
delete json.allOf;
|
|
4771
|
-
assignProps(json, folded);
|
|
4772
3753
|
}
|
|
4773
3754
|
function finalize(ctx, schema) {
|
|
4774
3755
|
const root = ctx.seen.get(schema);
|
|
@@ -4787,8 +3768,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4787
3768
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
4788
3769
|
schema.allOf = schema.allOf ?? [];
|
|
4789
3770
|
schema.allOf.push(refSchema);
|
|
4790
|
-
} else
|
|
4791
|
-
|
|
3771
|
+
} else Object.assign(schema, refSchema);
|
|
3772
|
+
Object.assign(schema, _cached);
|
|
4792
3773
|
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
4793
3774
|
if (key === "$ref" || key === "allOf") continue;
|
|
4794
3775
|
if (!(key in _cached)) delete schema[key];
|
|
@@ -4816,22 +3797,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4816
3797
|
path: seen.path ?? []
|
|
4817
3798
|
});
|
|
4818
3799
|
};
|
|
4819
|
-
|
|
4820
|
-
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
4821
|
-
if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
4822
|
-
for (const rewrite of ctx.deferred) rewrite();
|
|
4823
|
-
if (ctx.intersections.length) {
|
|
4824
|
-
const carriers = /* @__PURE__ */ new Map();
|
|
4825
|
-
for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
|
|
4826
|
-
const allOf = json?.allOf;
|
|
4827
|
-
if (!Array.isArray(allOf)) continue;
|
|
4828
|
-
const existing = carriers.get(allOf);
|
|
4829
|
-
if (existing) existing.push(json);
|
|
4830
|
-
else carriers.set(allOf, [json]);
|
|
4831
|
-
}
|
|
4832
|
-
for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
|
|
4833
|
-
}
|
|
4834
|
-
}
|
|
3800
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
4835
3801
|
const result = {};
|
|
4836
3802
|
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
4837
3803
|
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -4842,18 +3808,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4842
3808
|
if (!id) throw new Error("Schema is missing an `id` property");
|
|
4843
3809
|
result.$id = ctx.external.uri(id);
|
|
4844
3810
|
}
|
|
4845
|
-
|
|
3811
|
+
Object.assign(result, root.def ?? root.schema);
|
|
4846
3812
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
4847
3813
|
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
4848
3814
|
const defs = ctx.external?.defs ?? {};
|
|
4849
|
-
|
|
3815
|
+
for (const entry of ctx.seen.entries()) {
|
|
4850
3816
|
const seen = entry[1];
|
|
4851
3817
|
if (seen.def && seen.defId) {
|
|
4852
3818
|
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
4853
|
-
|
|
3819
|
+
defs[seen.defId] = seen.def;
|
|
4854
3820
|
}
|
|
4855
3821
|
}
|
|
4856
|
-
if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
|
|
4857
3822
|
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
4858
3823
|
else result.definitions = defs;
|
|
4859
3824
|
try {
|
|
@@ -4883,7 +3848,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4883
3848
|
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
4884
3849
|
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
4885
3850
|
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
4886
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault"
|
|
3851
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
4887
3852
|
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
4888
3853
|
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
4889
3854
|
if (def.type === "pipe") {
|
|
@@ -4914,7 +3879,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4914
3879
|
...params,
|
|
4915
3880
|
processors
|
|
4916
3881
|
});
|
|
4917
|
-
|
|
3882
|
+
process(schema, ctx);
|
|
4918
3883
|
extractDefs(ctx, schema);
|
|
4919
3884
|
return finalize(ctx, schema);
|
|
4920
3885
|
};
|
|
@@ -4926,84 +3891,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4926
3891
|
io,
|
|
4927
3892
|
processors
|
|
4928
3893
|
});
|
|
4929
|
-
|
|
3894
|
+
process(schema, ctx);
|
|
4930
3895
|
extractDefs(ctx, schema);
|
|
4931
3896
|
return finalize(ctx, schema);
|
|
4932
3897
|
};
|
|
4933
3898
|
//#endregion
|
|
4934
3899
|
//#region ../src/node_modules/zod/v4/core/json-schema-processors.js
|
|
4935
|
-
const narrowMin = (agg, key, value) => {
|
|
4936
|
-
if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
|
|
4937
|
-
};
|
|
4938
|
-
const narrowMax = (agg, key, value) => {
|
|
4939
|
-
if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
|
|
4940
|
-
};
|
|
4941
|
-
const narrowBoth = (agg, value) => {
|
|
4942
|
-
narrowMin(agg, "minimum", value);
|
|
4943
|
-
narrowMax(agg, "maximum", value);
|
|
4944
|
-
};
|
|
4945
|
-
const addDivisor = (agg, value) => {
|
|
4946
|
-
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4947
|
-
if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
|
|
4948
|
-
};
|
|
4949
|
-
const addPattern = (agg, pattern) => {
|
|
4950
|
-
agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
|
|
4951
|
-
agg.patterns.add(pattern);
|
|
4952
|
-
};
|
|
4953
|
-
const intersectMime = (agg, mime) => {
|
|
4954
|
-
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4955
|
-
};
|
|
4956
|
-
const setFormat = (agg, format) => {
|
|
4957
|
-
agg.format = format;
|
|
4958
|
-
if (format.includes("int")) agg.isInt = true;
|
|
4959
|
-
};
|
|
4960
|
-
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4961
|
-
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4962
|
-
const formatContributor = (ranges) => (agg, def) => {
|
|
4963
|
-
setFormat(agg, def.format);
|
|
4964
|
-
const [minimum, maximum] = ranges[def.format];
|
|
4965
|
-
narrowMin(agg, "minimum", minimum);
|
|
4966
|
-
narrowMax(agg, "maximum", maximum);
|
|
4967
|
-
};
|
|
4968
|
-
const contributors = {
|
|
4969
|
-
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4970
|
-
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4971
|
-
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4972
|
-
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4973
|
-
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4974
|
-
min_length: minContributor,
|
|
4975
|
-
max_length: maxContributor,
|
|
4976
|
-
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4977
|
-
min_size: minContributor,
|
|
4978
|
-
max_size: maxContributor,
|
|
4979
|
-
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4980
|
-
string_format: (agg, def) => {
|
|
4981
|
-
setFormat(agg, def.format);
|
|
4982
|
-
if (def.pattern) addPattern(agg, def.pattern);
|
|
4983
|
-
if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
|
|
4984
|
-
if (def.local || def.precision === -1) agg.laxFormat = true;
|
|
4985
|
-
},
|
|
4986
|
-
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4987
|
-
};
|
|
4988
|
-
function aggregateChecks(schema) {
|
|
4989
|
-
const agg = {};
|
|
4990
|
-
const def = schema._zod.def;
|
|
4991
|
-
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4992
|
-
for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4993
|
-
const bag = schema._zod.bag;
|
|
4994
|
-
if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
|
|
4995
|
-
if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4996
|
-
if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
|
|
4997
|
-
if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4998
|
-
if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
|
|
4999
|
-
if (bag.format !== void 0) {
|
|
5000
|
-
agg.format ?? (agg.format = bag.format);
|
|
5001
|
-
if (bag.format.includes("int")) agg.isInt = true;
|
|
5002
|
-
}
|
|
5003
|
-
if (bag.mime) intersectMime(agg, bag.mime);
|
|
5004
|
-
for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
|
|
5005
|
-
return agg;
|
|
5006
|
-
}
|
|
5007
3900
|
const formatMap = {
|
|
5008
3901
|
guid: "uuid",
|
|
5009
3902
|
url: "uri",
|
|
@@ -5011,24 +3904,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5011
3904
|
json_string: "json-string",
|
|
5012
3905
|
regex: ""
|
|
5013
3906
|
};
|
|
5014
|
-
const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
|
|
5015
|
-
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
5016
3907
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
5017
3908
|
const json = _json;
|
|
5018
3909
|
json.type = "string";
|
|
5019
|
-
const { minimum, maximum, format, patterns, contentEncoding
|
|
3910
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
5020
3911
|
if (typeof minimum === "number") json.minLength = minimum;
|
|
5021
3912
|
if (typeof maximum === "number") json.maxLength = maximum;
|
|
5022
3913
|
if (format) {
|
|
5023
3914
|
json.format = formatMap[format] ?? format;
|
|
5024
3915
|
if (json.format === "") delete json.format;
|
|
5025
|
-
if (format === "time"
|
|
3916
|
+
if (format === "time") delete json.format;
|
|
5026
3917
|
}
|
|
5027
3918
|
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
5028
3919
|
if (patterns && patterns.size > 0) {
|
|
5029
|
-
const
|
|
5030
|
-
if (
|
|
5031
|
-
else if (
|
|
3920
|
+
const regexes = [...patterns];
|
|
3921
|
+
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
3922
|
+
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
|
|
5032
3923
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
5033
3924
|
pattern: regex.source
|
|
5034
3925
|
}))];
|
|
@@ -5037,8 +3928,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5037
3928
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
5038
3929
|
json.type = "boolean";
|
|
5039
3930
|
};
|
|
5040
|
-
const voidProcessor = (
|
|
5041
|
-
|
|
3931
|
+
const voidProcessor = (_schema, ctx, _json, _params) => {
|
|
3932
|
+
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
5042
3933
|
};
|
|
5043
3934
|
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
5044
3935
|
json.not = {};
|
|
@@ -5046,63 +3937,53 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5046
3937
|
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
5047
3938
|
const def = schema._zod.def;
|
|
5048
3939
|
const values = getEnumValues(def.entries);
|
|
5049
|
-
if (values.length === 0) {
|
|
5050
|
-
json.not = {};
|
|
5051
|
-
return;
|
|
5052
|
-
}
|
|
5053
3940
|
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
5054
3941
|
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
5055
3942
|
json.enum = values;
|
|
5056
3943
|
};
|
|
5057
|
-
const customProcessor = (
|
|
5058
|
-
|
|
3944
|
+
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
3945
|
+
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
5059
3946
|
};
|
|
5060
|
-
const transformProcessor = (
|
|
5061
|
-
|
|
3947
|
+
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
3948
|
+
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
5062
3949
|
};
|
|
5063
3950
|
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
5064
3951
|
const json = _json;
|
|
5065
3952
|
const def = schema._zod.def;
|
|
5066
|
-
const { minimum, maximum } =
|
|
3953
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
5067
3954
|
if (typeof minimum === "number") json.minItems = minimum;
|
|
5068
3955
|
if (typeof maximum === "number") json.maxItems = maximum;
|
|
5069
3956
|
json.type = "array";
|
|
5070
|
-
json.items =
|
|
3957
|
+
json.items = process(def.element, ctx, {
|
|
5071
3958
|
...params,
|
|
5072
3959
|
path: [...params.path, "items"]
|
|
5073
3960
|
});
|
|
5074
3961
|
};
|
|
5075
|
-
function inputOptin(schema) {
|
|
5076
|
-
const def = schema._zod.def;
|
|
5077
|
-
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
|
|
5078
|
-
if (def.type === "catch") return inputOptin(def.innerType);
|
|
5079
|
-
return schema._zod.optin;
|
|
5080
|
-
}
|
|
5081
3962
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
5082
3963
|
const json = _json;
|
|
5083
3964
|
const def = schema._zod.def;
|
|
5084
|
-
const shape = def.shape;
|
|
5085
|
-
if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
|
|
5086
3965
|
json.type = "object";
|
|
5087
3966
|
json.properties = {};
|
|
5088
|
-
|
|
3967
|
+
const shape = def.shape;
|
|
3968
|
+
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
5089
3969
|
...params,
|
|
5090
3970
|
path: [
|
|
5091
3971
|
...params.path,
|
|
5092
3972
|
"properties",
|
|
5093
3973
|
key
|
|
5094
3974
|
]
|
|
3975
|
+
});
|
|
3976
|
+
const allKeys = new Set(Object.keys(shape));
|
|
3977
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3978
|
+
const v = def.shape[key]._zod;
|
|
3979
|
+
if (ctx.io === "input") return v.optin === void 0;
|
|
3980
|
+
else return v.optout === void 0;
|
|
5095
3981
|
}));
|
|
5096
|
-
|
|
5097
|
-
for (const key of Object.keys(shape)) {
|
|
5098
|
-
const field = def.shape[key];
|
|
5099
|
-
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
|
|
5100
|
-
}
|
|
5101
|
-
if (requiredKeys.length > 0) json.required = requiredKeys;
|
|
3982
|
+
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
5102
3983
|
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
5103
3984
|
else if (!def.catchall) {
|
|
5104
3985
|
if (ctx.io === "output") json.additionalProperties = false;
|
|
5105
|
-
} else if (def.catchall) json.additionalProperties =
|
|
3986
|
+
} else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
|
|
5106
3987
|
...params,
|
|
5107
3988
|
path: [...params.path, "additionalProperties"]
|
|
5108
3989
|
});
|
|
@@ -5110,7 +3991,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5110
3991
|
const unionProcessor = (schema, ctx, json, params) => {
|
|
5111
3992
|
const def = schema._zod.def;
|
|
5112
3993
|
const isExclusive = def.inclusive === false;
|
|
5113
|
-
const options = def.options.map((x, i) =>
|
|
3994
|
+
const options = def.options.map((x, i) => process(x, ctx, {
|
|
5114
3995
|
...params,
|
|
5115
3996
|
path: [
|
|
5116
3997
|
...params.path,
|
|
@@ -5123,7 +4004,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5123
4004
|
};
|
|
5124
4005
|
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
5125
4006
|
const def = schema._zod.def;
|
|
5126
|
-
const a =
|
|
4007
|
+
const a = process(def.left, ctx, {
|
|
5127
4008
|
...params,
|
|
5128
4009
|
path: [
|
|
5129
4010
|
...params.path,
|
|
@@ -5131,7 +4012,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5131
4012
|
0
|
|
5132
4013
|
]
|
|
5133
4014
|
});
|
|
5134
|
-
const b =
|
|
4015
|
+
const b = process(def.right, ctx, {
|
|
5135
4016
|
...params,
|
|
5136
4017
|
path: [
|
|
5137
4018
|
...params.path,
|
|
@@ -5140,13 +4021,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5140
4021
|
]
|
|
5141
4022
|
});
|
|
5142
4023
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
5143
|
-
|
|
5144
|
-
json.allOf = allOf;
|
|
5145
|
-
ctx.intersections.push(allOf);
|
|
4024
|
+
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
5146
4025
|
};
|
|
5147
4026
|
const nullableProcessor = (schema, ctx, json, params) => {
|
|
5148
4027
|
const def = schema._zod.def;
|
|
5149
|
-
const inner =
|
|
4028
|
+
const inner = process(def.innerType, ctx, params);
|
|
5150
4029
|
const seen = ctx.seen.get(schema);
|
|
5151
4030
|
if (ctx.target === "openapi-3.0") {
|
|
5152
4031
|
seen.ref = def.innerType;
|
|
@@ -5155,53 +4034,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5155
4034
|
};
|
|
5156
4035
|
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
5157
4036
|
const def = schema._zod.def;
|
|
5158
|
-
|
|
4037
|
+
process(def.innerType, ctx, params);
|
|
5159
4038
|
const seen = ctx.seen.get(schema);
|
|
5160
4039
|
seen.ref = def.innerType;
|
|
5161
4040
|
};
|
|
5162
|
-
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
|
|
5163
|
-
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
|
|
5164
|
-
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
|
|
5165
|
-
const UNREPRESENTABLE_DEFAULT = Symbol();
|
|
5166
|
-
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
5167
|
-
let unrepresentable = false;
|
|
5168
|
-
const serialized = JSON.stringify(value, (_, val) => {
|
|
5169
|
-
if (typeof val !== "bigint") return val;
|
|
5170
|
-
unrepresentable = true;
|
|
5171
|
-
return null;
|
|
5172
|
-
});
|
|
5173
|
-
if (!unrepresentable) return JSON.parse(serialized);
|
|
5174
|
-
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
5175
|
-
return UNREPRESENTABLE_DEFAULT;
|
|
5176
|
-
}
|
|
5177
4041
|
const defaultProcessor = (schema, ctx, json, params) => {
|
|
5178
4042
|
const def = schema._zod.def;
|
|
5179
|
-
|
|
4043
|
+
process(def.innerType, ctx, params);
|
|
5180
4044
|
const seen = ctx.seen.get(schema);
|
|
5181
4045
|
seen.ref = def.innerType;
|
|
5182
|
-
|
|
5183
|
-
if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
|
|
4046
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
5184
4047
|
};
|
|
5185
4048
|
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
5186
4049
|
const def = schema._zod.def;
|
|
5187
|
-
|
|
4050
|
+
process(def.innerType, ctx, params);
|
|
5188
4051
|
const seen = ctx.seen.get(schema);
|
|
5189
4052
|
seen.ref = def.innerType;
|
|
5190
|
-
if (ctx.io
|
|
5191
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
5192
|
-
if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
|
|
4053
|
+
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
5193
4054
|
};
|
|
5194
4055
|
const catchProcessor = (schema, ctx, json, params) => {
|
|
5195
4056
|
const def = schema._zod.def;
|
|
5196
|
-
|
|
4057
|
+
process(def.innerType, ctx, params);
|
|
5197
4058
|
const seen = ctx.seen.get(schema);
|
|
5198
4059
|
seen.ref = def.innerType;
|
|
5199
4060
|
let catchValue;
|
|
5200
4061
|
try {
|
|
5201
4062
|
catchValue = def.catchValue(void 0);
|
|
5202
4063
|
} catch {
|
|
5203
|
-
|
|
5204
|
-
return;
|
|
4064
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
5205
4065
|
}
|
|
5206
4066
|
json.default = catchValue;
|
|
5207
4067
|
};
|
|
@@ -5209,73 +4069,75 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5209
4069
|
const def = schema._zod.def;
|
|
5210
4070
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
5211
4071
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
5212
|
-
|
|
4072
|
+
process(innerType, ctx, params);
|
|
5213
4073
|
const seen = ctx.seen.get(schema);
|
|
5214
4074
|
seen.ref = innerType;
|
|
5215
4075
|
};
|
|
5216
4076
|
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
5217
4077
|
const def = schema._zod.def;
|
|
5218
|
-
|
|
4078
|
+
process(def.innerType, ctx, params);
|
|
5219
4079
|
const seen = ctx.seen.get(schema);
|
|
5220
4080
|
seen.ref = def.innerType;
|
|
5221
4081
|
json.readOnly = true;
|
|
5222
4082
|
};
|
|
5223
4083
|
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
5224
4084
|
const def = schema._zod.def;
|
|
5225
|
-
|
|
4085
|
+
process(def.innerType, ctx, params);
|
|
5226
4086
|
const seen = ctx.seen.get(schema);
|
|
5227
4087
|
seen.ref = def.innerType;
|
|
5228
4088
|
};
|
|
5229
4089
|
//#endregion
|
|
5230
|
-
//#region ../src/node_modules/zod/v4/classic/
|
|
5231
|
-
const
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
}
|
|
5252
|
-
});
|
|
4090
|
+
//#region ../src/node_modules/zod/v4/classic/iso.js
|
|
4091
|
+
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4092
|
+
$ZodISODateTime.init(inst, def);
|
|
4093
|
+
ZodStringFormat.init(inst, def);
|
|
4094
|
+
});
|
|
4095
|
+
function datetime(params) {
|
|
4096
|
+
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
4097
|
+
}
|
|
4098
|
+
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
4099
|
+
$ZodISODate.init(inst, def);
|
|
4100
|
+
ZodStringFormat.init(inst, def);
|
|
4101
|
+
});
|
|
4102
|
+
function date(params) {
|
|
4103
|
+
return /* @__PURE__ */ _isoDate(ZodISODate, params);
|
|
4104
|
+
}
|
|
4105
|
+
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
4106
|
+
$ZodISOTime.init(inst, def);
|
|
4107
|
+
ZodStringFormat.init(inst, def);
|
|
4108
|
+
});
|
|
4109
|
+
function time(params) {
|
|
4110
|
+
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
5253
4111
|
}
|
|
4112
|
+
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
4113
|
+
$ZodISODuration.init(inst, def);
|
|
4114
|
+
ZodStringFormat.init(inst, def);
|
|
4115
|
+
});
|
|
4116
|
+
function duration(params) {
|
|
4117
|
+
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
4118
|
+
}
|
|
4119
|
+
//#endregion
|
|
4120
|
+
//#region ../src/node_modules/zod/v4/classic/errors.js
|
|
5254
4121
|
const initializer = (inst, issues) => {
|
|
5255
4122
|
$ZodError.init(inst, issues);
|
|
5256
4123
|
inst.name = "ZodError";
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
configurable: true,
|
|
5272
|
-
enumerable: false,
|
|
5273
|
-
get() {
|
|
5274
|
-
return this.issues.length === 0;
|
|
5275
|
-
}
|
|
4124
|
+
Object.defineProperties(inst, {
|
|
4125
|
+
format: { value: (mapper) => formatError(inst, mapper) },
|
|
4126
|
+
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
4127
|
+
addIssue: { value: (issue) => {
|
|
4128
|
+
inst.issues.push(issue);
|
|
4129
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
4130
|
+
} },
|
|
4131
|
+
addIssues: { value: (issues) => {
|
|
4132
|
+
inst.issues.push(...issues);
|
|
4133
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
4134
|
+
} },
|
|
4135
|
+
isEmpty: { get() {
|
|
4136
|
+
return inst.issues.length === 0;
|
|
4137
|
+
} }
|
|
5276
4138
|
});
|
|
5277
4139
|
};
|
|
5278
|
-
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer,
|
|
4140
|
+
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
|
|
5279
4141
|
//#endregion
|
|
5280
4142
|
//#region ../src/node_modules/zod/v4/classic/parse.js
|
|
5281
4143
|
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
@@ -5292,319 +4154,254 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5292
4154
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
5293
4155
|
//#endregion
|
|
5294
4156
|
//#region ../src/node_modules/zod/v4/classic/schemas.js
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
if (!
|
|
4157
|
+
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
4158
|
+
function _installLazyMethods(inst, group, methods) {
|
|
4159
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4160
|
+
let installed = _installedGroups.get(proto);
|
|
4161
|
+
if (!installed) {
|
|
4162
|
+
installed = /* @__PURE__ */ new Set();
|
|
4163
|
+
_installedGroups.set(proto, installed);
|
|
4164
|
+
}
|
|
4165
|
+
if (installed.has(group)) return;
|
|
4166
|
+
installed.add(group);
|
|
4167
|
+
for (const key in methods) {
|
|
4168
|
+
const fn = methods[key];
|
|
4169
|
+
Object.defineProperty(proto, key, {
|
|
4170
|
+
configurable: true,
|
|
4171
|
+
enumerable: false,
|
|
4172
|
+
get() {
|
|
4173
|
+
const bound = fn.bind(this);
|
|
4174
|
+
Object.defineProperty(this, key, {
|
|
4175
|
+
configurable: true,
|
|
4176
|
+
writable: true,
|
|
4177
|
+
enumerable: true,
|
|
4178
|
+
value: bound
|
|
4179
|
+
});
|
|
4180
|
+
return bound;
|
|
4181
|
+
},
|
|
4182
|
+
set(v) {
|
|
4183
|
+
Object.defineProperty(this, key, {
|
|
4184
|
+
configurable: true,
|
|
4185
|
+
writable: true,
|
|
4186
|
+
enumerable: true,
|
|
4187
|
+
value: v
|
|
4188
|
+
});
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
}
|
|
5300
4192
|
}
|
|
5301
4193
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
5302
|
-
_ensureDefaultLocale();
|
|
5303
4194
|
$ZodType.init(inst, def);
|
|
4195
|
+
Object.assign(inst["~standard"], { jsonSchema: {
|
|
4196
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
4197
|
+
output: createStandardJSONSchemaMethod(inst, "output")
|
|
4198
|
+
} });
|
|
4199
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
5304
4200
|
inst.def = def;
|
|
5305
4201
|
inst.type = def.type;
|
|
4202
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
4203
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
4204
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
4205
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
4206
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
4207
|
+
inst.spa = inst.safeParseAsync;
|
|
4208
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
4209
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
4210
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
4211
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
4212
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
4213
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
4214
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
4215
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
4216
|
+
_installLazyMethods(inst, "ZodType", {
|
|
4217
|
+
check(...chks) {
|
|
4218
|
+
const def = this.def;
|
|
4219
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
4220
|
+
check: ch,
|
|
4221
|
+
def: { check: "custom" },
|
|
4222
|
+
onattach: []
|
|
4223
|
+
} } : ch)] }), { parent: true });
|
|
4224
|
+
},
|
|
4225
|
+
with(...chks) {
|
|
4226
|
+
return this.check(...chks);
|
|
4227
|
+
},
|
|
4228
|
+
clone(def, params) {
|
|
4229
|
+
return clone(this, def, params);
|
|
4230
|
+
},
|
|
4231
|
+
brand() {
|
|
4232
|
+
return this;
|
|
4233
|
+
},
|
|
4234
|
+
register(reg, meta) {
|
|
4235
|
+
reg.add(this, meta);
|
|
4236
|
+
return this;
|
|
4237
|
+
},
|
|
4238
|
+
refine(check, params) {
|
|
4239
|
+
return this.check(refine(check, params));
|
|
4240
|
+
},
|
|
4241
|
+
superRefine(refinement, params) {
|
|
4242
|
+
return this.check(superRefine(refinement, params));
|
|
4243
|
+
},
|
|
4244
|
+
overwrite(fn) {
|
|
4245
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4246
|
+
},
|
|
4247
|
+
optional() {
|
|
4248
|
+
return optional(this);
|
|
4249
|
+
},
|
|
4250
|
+
exactOptional() {
|
|
4251
|
+
return exactOptional(this);
|
|
4252
|
+
},
|
|
4253
|
+
nullable() {
|
|
4254
|
+
return nullable(this);
|
|
4255
|
+
},
|
|
4256
|
+
nullish() {
|
|
4257
|
+
return optional(nullable(this));
|
|
4258
|
+
},
|
|
4259
|
+
nonoptional(params) {
|
|
4260
|
+
return nonoptional(this, params);
|
|
4261
|
+
},
|
|
4262
|
+
array() {
|
|
4263
|
+
return array(this);
|
|
4264
|
+
},
|
|
4265
|
+
or(arg) {
|
|
4266
|
+
return union([this, arg]);
|
|
4267
|
+
},
|
|
4268
|
+
and(arg) {
|
|
4269
|
+
return intersection(this, arg);
|
|
4270
|
+
},
|
|
4271
|
+
transform(tx) {
|
|
4272
|
+
return pipe(this, transform(tx));
|
|
4273
|
+
},
|
|
4274
|
+
default(d) {
|
|
4275
|
+
return _default(this, d);
|
|
4276
|
+
},
|
|
4277
|
+
prefault(d) {
|
|
4278
|
+
return prefault(this, d);
|
|
4279
|
+
},
|
|
4280
|
+
catch(params) {
|
|
4281
|
+
return _catch(this, params);
|
|
4282
|
+
},
|
|
4283
|
+
pipe(target) {
|
|
4284
|
+
return pipe(this, target);
|
|
4285
|
+
},
|
|
4286
|
+
readonly() {
|
|
4287
|
+
return readonly(this);
|
|
4288
|
+
},
|
|
4289
|
+
describe(description) {
|
|
4290
|
+
const cl = this.clone();
|
|
4291
|
+
globalRegistry.add(cl, { description });
|
|
4292
|
+
return cl;
|
|
4293
|
+
},
|
|
4294
|
+
meta(...args) {
|
|
4295
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
4296
|
+
const cl = this.clone();
|
|
4297
|
+
globalRegistry.add(cl, args[0]);
|
|
4298
|
+
return cl;
|
|
4299
|
+
},
|
|
4300
|
+
isOptional() {
|
|
4301
|
+
return this.safeParse(void 0).success;
|
|
4302
|
+
},
|
|
4303
|
+
isNullable() {
|
|
4304
|
+
return this.safeParse(null).success;
|
|
4305
|
+
},
|
|
4306
|
+
apply(fn) {
|
|
4307
|
+
return fn(this);
|
|
4308
|
+
}
|
|
4309
|
+
});
|
|
4310
|
+
Object.defineProperty(inst, "description", {
|
|
4311
|
+
get() {
|
|
4312
|
+
return globalRegistry.get(inst)?.description;
|
|
4313
|
+
},
|
|
4314
|
+
configurable: true
|
|
4315
|
+
});
|
|
5306
4316
|
return inst;
|
|
5307
|
-
}, {
|
|
5308
|
-
check(...chks) {
|
|
5309
|
-
const def = this.def;
|
|
5310
|
-
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
5311
|
-
check: ch,
|
|
5312
|
-
def: { check: "custom" },
|
|
5313
|
-
onattach: []
|
|
5314
|
-
} } : ch)] }), { parent: true });
|
|
5315
|
-
},
|
|
5316
|
-
with(...chks) {
|
|
5317
|
-
return this.check(...chks);
|
|
5318
|
-
},
|
|
5319
|
-
clone(def, params) {
|
|
5320
|
-
return clone(this, def, params);
|
|
5321
|
-
},
|
|
5322
|
-
brand() {
|
|
5323
|
-
return this;
|
|
5324
|
-
},
|
|
5325
|
-
register(reg, meta) {
|
|
5326
|
-
reg.add(this, meta);
|
|
5327
|
-
return this;
|
|
5328
|
-
},
|
|
5329
|
-
refine(check, params) {
|
|
5330
|
-
return this.check(refine(check, params));
|
|
5331
|
-
},
|
|
5332
|
-
superRefine(refinement, params) {
|
|
5333
|
-
return this.check(superRefine(refinement, params));
|
|
5334
|
-
},
|
|
5335
|
-
overwrite(fn) {
|
|
5336
|
-
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
5337
|
-
},
|
|
5338
|
-
optional() {
|
|
5339
|
-
return optional(this);
|
|
5340
|
-
},
|
|
5341
|
-
exactOptional() {
|
|
5342
|
-
return exactOptional(this);
|
|
5343
|
-
},
|
|
5344
|
-
nullable() {
|
|
5345
|
-
return nullable(this);
|
|
5346
|
-
},
|
|
5347
|
-
nullish() {
|
|
5348
|
-
return optional(nullable(this));
|
|
5349
|
-
},
|
|
5350
|
-
nonoptional(params) {
|
|
5351
|
-
return nonoptional(this, params);
|
|
5352
|
-
},
|
|
5353
|
-
array() {
|
|
5354
|
-
return array(this);
|
|
5355
|
-
},
|
|
5356
|
-
or(arg) {
|
|
5357
|
-
return union([this, arg]);
|
|
5358
|
-
},
|
|
5359
|
-
and(arg) {
|
|
5360
|
-
return intersection(this, arg);
|
|
5361
|
-
},
|
|
5362
|
-
transform(tx) {
|
|
5363
|
-
return pipe(this, transform(tx));
|
|
5364
|
-
},
|
|
5365
|
-
default(d) {
|
|
5366
|
-
return _default(this, d);
|
|
5367
|
-
},
|
|
5368
|
-
prefault(d) {
|
|
5369
|
-
return prefault(this, d);
|
|
5370
|
-
},
|
|
5371
|
-
catch(params) {
|
|
5372
|
-
return _catch(this, params);
|
|
5373
|
-
},
|
|
5374
|
-
pipe(target) {
|
|
5375
|
-
return pipe(this, target);
|
|
5376
|
-
},
|
|
5377
|
-
readonly() {
|
|
5378
|
-
return readonly(this);
|
|
5379
|
-
},
|
|
5380
|
-
describe(description) {
|
|
5381
|
-
const cl = this.clone();
|
|
5382
|
-
globalRegistry.add(cl, { description });
|
|
5383
|
-
return cl;
|
|
5384
|
-
},
|
|
5385
|
-
meta(...args) {
|
|
5386
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
5387
|
-
const cl = this.clone();
|
|
5388
|
-
globalRegistry.add(cl, args[0]);
|
|
5389
|
-
return cl;
|
|
5390
|
-
},
|
|
5391
|
-
isOptional() {
|
|
5392
|
-
return this.safeParse(void 0).success;
|
|
5393
|
-
},
|
|
5394
|
-
isNullable() {
|
|
5395
|
-
return this.safeParse(null).success;
|
|
5396
|
-
},
|
|
5397
|
-
apply(fn, ...args) {
|
|
5398
|
-
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
5399
|
-
},
|
|
5400
|
-
get "~standard"() {
|
|
5401
|
-
return hide(this, "~standard", {
|
|
5402
|
-
...standardProps(this),
|
|
5403
|
-
jsonSchema: {
|
|
5404
|
-
input: createStandardJSONSchemaMethod(this, "input"),
|
|
5405
|
-
output: createStandardJSONSchemaMethod(this, "output")
|
|
5406
|
-
}
|
|
5407
|
-
});
|
|
5408
|
-
},
|
|
5409
|
-
set "~standard"(value) {
|
|
5410
|
-
own(this, "~standard", value);
|
|
5411
|
-
},
|
|
5412
|
-
parse: function _parse(data, params) {
|
|
5413
|
-
return parse(this, data, params, { callee: _parse });
|
|
5414
|
-
},
|
|
5415
|
-
parseAsync: async function _parseAsync(data, params) {
|
|
5416
|
-
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
5417
|
-
},
|
|
5418
|
-
safeParse(data, params) {
|
|
5419
|
-
return safeParse(this, data, params);
|
|
5420
|
-
},
|
|
5421
|
-
async safeParseAsync(data, params) {
|
|
5422
|
-
return safeParseAsync(this, data, params);
|
|
5423
|
-
},
|
|
5424
|
-
get spa() {
|
|
5425
|
-
return this?.safeParseAsync;
|
|
5426
|
-
},
|
|
5427
|
-
set spa(value) {
|
|
5428
|
-
own(this, "spa", value);
|
|
5429
|
-
},
|
|
5430
|
-
validate(data, params) {
|
|
5431
|
-
return validate(this, data, params);
|
|
5432
|
-
},
|
|
5433
|
-
validateAsync(data, params) {
|
|
5434
|
-
return validateAsync$1(this, data, params);
|
|
5435
|
-
},
|
|
5436
|
-
encode: function _encode(data, params) {
|
|
5437
|
-
return encode(this, data, params, { callee: _encode });
|
|
5438
|
-
},
|
|
5439
|
-
decode: function _decode(data, params) {
|
|
5440
|
-
return decode(this, data, params, { callee: _decode });
|
|
5441
|
-
},
|
|
5442
|
-
encodeAsync: async function _encodeAsync(data, params) {
|
|
5443
|
-
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
5444
|
-
},
|
|
5445
|
-
decodeAsync: async function _decodeAsync(data, params) {
|
|
5446
|
-
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
5447
|
-
},
|
|
5448
|
-
safeEncode(data, params) {
|
|
5449
|
-
return safeEncode(this, data, params);
|
|
5450
|
-
},
|
|
5451
|
-
safeDecode(data, params) {
|
|
5452
|
-
return safeDecode(this, data, params);
|
|
5453
|
-
},
|
|
5454
|
-
async safeEncodeAsync(data, params) {
|
|
5455
|
-
return safeEncodeAsync(this, data, params);
|
|
5456
|
-
},
|
|
5457
|
-
async safeDecodeAsync(data, params) {
|
|
5458
|
-
return safeDecodeAsync(this, data, params);
|
|
5459
|
-
},
|
|
5460
|
-
toJSONSchema(params) {
|
|
5461
|
-
return createToJSONSchemaMethod(this, {})(params);
|
|
5462
|
-
},
|
|
5463
|
-
get description() {
|
|
5464
|
-
return globalRegistry.get(this)?.description;
|
|
5465
|
-
},
|
|
5466
|
-
get _def() {
|
|
5467
|
-
return this._zod.def;
|
|
5468
|
-
}
|
|
5469
4317
|
});
|
|
5470
4318
|
/** @internal */
|
|
5471
4319
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
5472
4320
|
$ZodString.init(inst, def);
|
|
5473
4321
|
ZodType.init(inst, def);
|
|
5474
4322
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
5475
|
-
|
|
5476
|
-
format
|
|
5477
|
-
minLength
|
|
5478
|
-
maxLength
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
4323
|
+
const bag = inst._zod.bag;
|
|
4324
|
+
inst.format = bag.format ?? null;
|
|
4325
|
+
inst.minLength = bag.minimum ?? null;
|
|
4326
|
+
inst.maxLength = bag.maximum ?? null;
|
|
4327
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
4328
|
+
regex(...args) {
|
|
4329
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4330
|
+
},
|
|
4331
|
+
includes(...args) {
|
|
4332
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4333
|
+
},
|
|
4334
|
+
startsWith(...args) {
|
|
4335
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4336
|
+
},
|
|
4337
|
+
endsWith(...args) {
|
|
4338
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4339
|
+
},
|
|
4340
|
+
min(...args) {
|
|
4341
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4342
|
+
},
|
|
4343
|
+
max(...args) {
|
|
4344
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4345
|
+
},
|
|
4346
|
+
length(...args) {
|
|
4347
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
4348
|
+
},
|
|
4349
|
+
nonempty(...args) {
|
|
4350
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4351
|
+
},
|
|
4352
|
+
lowercase(params) {
|
|
4353
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4354
|
+
},
|
|
4355
|
+
uppercase(params) {
|
|
4356
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4357
|
+
},
|
|
4358
|
+
trim() {
|
|
4359
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
4360
|
+
},
|
|
4361
|
+
normalize(...args) {
|
|
4362
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4363
|
+
},
|
|
4364
|
+
toLowerCase() {
|
|
4365
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4366
|
+
},
|
|
4367
|
+
toUpperCase() {
|
|
4368
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4369
|
+
},
|
|
4370
|
+
slugify() {
|
|
4371
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
4372
|
+
}
|
|
4373
|
+
});
|
|
4374
|
+
});
|
|
5526
4375
|
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
5527
4376
|
$ZodString.init(inst, def);
|
|
5528
4377
|
_ZodString.init(inst, def);
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
},
|
|
5557
|
-
nanoid(params) {
|
|
5558
|
-
return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
5559
|
-
},
|
|
5560
|
-
cuid(params) {
|
|
5561
|
-
return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
5562
|
-
},
|
|
5563
|
-
cuid2(params) {
|
|
5564
|
-
return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
5565
|
-
},
|
|
5566
|
-
ulid(params) {
|
|
5567
|
-
return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
5568
|
-
},
|
|
5569
|
-
base64(params) {
|
|
5570
|
-
return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
5571
|
-
},
|
|
5572
|
-
base64url(params) {
|
|
5573
|
-
return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
5574
|
-
},
|
|
5575
|
-
xid(params) {
|
|
5576
|
-
return this.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
5577
|
-
},
|
|
5578
|
-
ksuid(params) {
|
|
5579
|
-
return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
5580
|
-
},
|
|
5581
|
-
ipv4(params) {
|
|
5582
|
-
return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
5583
|
-
},
|
|
5584
|
-
ipv6(params) {
|
|
5585
|
-
return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
5586
|
-
},
|
|
5587
|
-
cidrv4(params) {
|
|
5588
|
-
return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
5589
|
-
},
|
|
5590
|
-
cidrv6(params) {
|
|
5591
|
-
return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
5592
|
-
},
|
|
5593
|
-
e164(params) {
|
|
5594
|
-
return this.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
5595
|
-
},
|
|
5596
|
-
datetime(params) {
|
|
5597
|
-
return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
|
|
5598
|
-
},
|
|
5599
|
-
date(params) {
|
|
5600
|
-
return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
|
|
5601
|
-
},
|
|
5602
|
-
time(params) {
|
|
5603
|
-
return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
|
|
5604
|
-
},
|
|
5605
|
-
duration(params) {
|
|
5606
|
-
return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
|
|
5607
|
-
}
|
|
4378
|
+
inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4379
|
+
inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4380
|
+
inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4381
|
+
inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4382
|
+
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4383
|
+
inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4384
|
+
inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4385
|
+
inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4386
|
+
inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4387
|
+
inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4388
|
+
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4389
|
+
inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4390
|
+
inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4391
|
+
inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4392
|
+
inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4393
|
+
inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4394
|
+
inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4395
|
+
inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4396
|
+
inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4397
|
+
inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4398
|
+
inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4399
|
+
inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4400
|
+
inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4401
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
4402
|
+
inst.date = (params) => inst.check(date(params));
|
|
4403
|
+
inst.time = (params) => inst.check(time(params));
|
|
4404
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
5608
4405
|
});
|
|
5609
4406
|
function string(params) {
|
|
5610
4407
|
return /* @__PURE__ */ _string(ZodString, params);
|
|
@@ -5613,22 +4410,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5613
4410
|
$ZodStringFormat.init(inst, def);
|
|
5614
4411
|
_ZodString.init(inst, def);
|
|
5615
4412
|
});
|
|
5616
|
-
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
5617
|
-
$ZodISODateTime.init(inst, def);
|
|
5618
|
-
ZodStringFormat.init(inst, def);
|
|
5619
|
-
});
|
|
5620
|
-
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
5621
|
-
$ZodISODate.init(inst, def);
|
|
5622
|
-
ZodStringFormat.init(inst, def);
|
|
5623
|
-
});
|
|
5624
|
-
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
5625
|
-
$ZodISOTime.init(inst, def);
|
|
5626
|
-
ZodStringFormat.init(inst, def);
|
|
5627
|
-
});
|
|
5628
|
-
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
5629
|
-
$ZodISODuration.init(inst, def);
|
|
5630
|
-
ZodStringFormat.init(inst, def);
|
|
5631
|
-
});
|
|
5632
4413
|
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
5633
4414
|
$ZodEmail.init(inst, def);
|
|
5634
4415
|
ZodStringFormat.init(inst, def);
|
|
@@ -5743,80 +4524,94 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5743
4524
|
return /* @__PURE__ */ _void$1(ZodVoid, params);
|
|
5744
4525
|
}
|
|
5745
4526
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
5746
|
-
_ensureDefaultMemoizer();
|
|
5747
4527
|
$ZodArray.init(inst, def);
|
|
5748
4528
|
ZodType.init(inst, def);
|
|
5749
4529
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
5750
4530
|
inst.element = def.element;
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
4531
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
4532
|
+
min(n, params) {
|
|
4533
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
4534
|
+
},
|
|
4535
|
+
nonempty(params) {
|
|
4536
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
4537
|
+
},
|
|
4538
|
+
max(n, params) {
|
|
4539
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
4540
|
+
},
|
|
4541
|
+
length(n, params) {
|
|
4542
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
4543
|
+
},
|
|
4544
|
+
unwrap() {
|
|
4545
|
+
return this.element;
|
|
4546
|
+
}
|
|
4547
|
+
});
|
|
5767
4548
|
});
|
|
5768
4549
|
function array(element, params) {
|
|
5769
4550
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
5770
4551
|
}
|
|
5771
4552
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
5772
|
-
_ensureDefaultMemoizer();
|
|
5773
4553
|
$ZodObjectJIT.init(inst, def);
|
|
5774
4554
|
ZodType.init(inst, def);
|
|
5775
4555
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
4556
|
+
defineLazy(inst, "shape", () => {
|
|
4557
|
+
return def.shape;
|
|
4558
|
+
});
|
|
4559
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
4560
|
+
keyof() {
|
|
4561
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
4562
|
+
},
|
|
4563
|
+
catchall(catchall) {
|
|
4564
|
+
return this.clone({
|
|
4565
|
+
...this._zod.def,
|
|
4566
|
+
catchall
|
|
4567
|
+
});
|
|
4568
|
+
},
|
|
4569
|
+
passthrough() {
|
|
4570
|
+
return this.clone({
|
|
4571
|
+
...this._zod.def,
|
|
4572
|
+
catchall: unknown()
|
|
4573
|
+
});
|
|
4574
|
+
},
|
|
4575
|
+
loose() {
|
|
4576
|
+
return this.clone({
|
|
4577
|
+
...this._zod.def,
|
|
4578
|
+
catchall: unknown()
|
|
4579
|
+
});
|
|
4580
|
+
},
|
|
4581
|
+
strict() {
|
|
4582
|
+
return this.clone({
|
|
4583
|
+
...this._zod.def,
|
|
4584
|
+
catchall: never()
|
|
4585
|
+
});
|
|
4586
|
+
},
|
|
4587
|
+
strip() {
|
|
4588
|
+
return this.clone({
|
|
4589
|
+
...this._zod.def,
|
|
4590
|
+
catchall: void 0
|
|
4591
|
+
});
|
|
4592
|
+
},
|
|
4593
|
+
extend(incoming) {
|
|
4594
|
+
return extend(this, incoming);
|
|
4595
|
+
},
|
|
4596
|
+
safeExtend(incoming) {
|
|
4597
|
+
return safeExtend(this, incoming);
|
|
4598
|
+
},
|
|
4599
|
+
merge(other) {
|
|
4600
|
+
return merge(this, other);
|
|
4601
|
+
},
|
|
4602
|
+
pick(mask) {
|
|
4603
|
+
return pick(this, mask);
|
|
4604
|
+
},
|
|
4605
|
+
omit(mask) {
|
|
4606
|
+
return omit(this, mask);
|
|
4607
|
+
},
|
|
4608
|
+
partial(...args) {
|
|
4609
|
+
return partial(ZodOptional, this, args[0]);
|
|
4610
|
+
},
|
|
4611
|
+
required(...args) {
|
|
4612
|
+
return required(ZodNonOptional, this, args[0]);
|
|
4613
|
+
}
|
|
4614
|
+
});
|
|
5820
4615
|
});
|
|
5821
4616
|
function object(shape, params) {
|
|
5822
4617
|
const def = {
|
|
@@ -5856,7 +4651,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5856
4651
|
ZodType.init(inst, def);
|
|
5857
4652
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
5858
4653
|
inst.enum = def.entries;
|
|
5859
|
-
inst.options =
|
|
4654
|
+
inst.options = Object.values(def.entries);
|
|
5860
4655
|
const keys = new Set(Object.keys(def.entries));
|
|
5861
4656
|
inst.extract = (values, params) => {
|
|
5862
4657
|
const newEntries = {};
|
|
@@ -5890,7 +4685,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5890
4685
|
});
|
|
5891
4686
|
}
|
|
5892
4687
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
5893
|
-
_ensureDefaultMemoizer();
|
|
5894
4688
|
$ZodTransform.init(inst, def);
|
|
5895
4689
|
ZodType.init(inst, def);
|
|
5896
4690
|
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
@@ -5902,7 +4696,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5902
4696
|
const _issue = issue$1;
|
|
5903
4697
|
if (_issue.fatal) _issue.continue = false;
|
|
5904
4698
|
_issue.code ?? (_issue.code = "custom");
|
|
5905
|
-
|
|
4699
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
5906
4700
|
_issue.inst ?? (_issue.inst = inst);
|
|
5907
4701
|
payload.issues.push(issue(_issue));
|
|
5908
4702
|
}
|
|
@@ -5910,9 +4704,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5910
4704
|
const output = def.transform(payload.value, payload);
|
|
5911
4705
|
if (output instanceof Promise) return output.then((output) => {
|
|
5912
4706
|
payload.value = output;
|
|
4707
|
+
payload.fallback = true;
|
|
5913
4708
|
return payload;
|
|
5914
4709
|
});
|
|
5915
4710
|
payload.value = output;
|
|
4711
|
+
payload.fallback = true;
|
|
5916
4712
|
return payload;
|
|
5917
4713
|
};
|
|
5918
4714
|
});
|
|
@@ -6013,7 +4809,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6013
4809
|
return new ZodCatch({
|
|
6014
4810
|
type: "catch",
|
|
6015
4811
|
innerType,
|
|
6016
|
-
catchValue: typeof catchValue === "function" ? catchValue :
|
|
4812
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
6017
4813
|
});
|
|
6018
4814
|
}
|
|
6019
4815
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|