drizzle-kit 0.20.14-d8f1e46 → 0.20.14-e8e7ed6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/bin.cjs +21878 -21519
  2. package/cli/commands/migrate.d.ts +121 -97
  3. package/cli/commands/mysqlIntrospect.d.ts +8 -14
  4. package/cli/commands/mysqlPushUtils.d.ts +2 -2
  5. package/cli/commands/pgConnect.d.ts +1 -1
  6. package/cli/commands/pgIntrospect.d.ts +18 -11
  7. package/cli/commands/pgPushUtils.d.ts +2 -2
  8. package/cli/commands/sqliteIntrospect.d.ts +9 -9
  9. package/cli/commands/sqlitePushUtils.d.ts +3 -3
  10. package/cli/commands/utils.d.ts +15 -259
  11. package/cli/validations/cli.d.ts +107 -0
  12. package/cli/validations/common.d.ts +205 -7
  13. package/cli/validations/mysql.d.ts +6 -1
  14. package/cli/validations/pg.d.ts +6 -1
  15. package/cli/validations/sqlite.d.ts +382 -0
  16. package/cli/views.d.ts +7 -5
  17. package/global.d.ts +3 -1
  18. package/index.d.mts +8 -6
  19. package/index.d.ts +8 -6
  20. package/index.js +1 -0
  21. package/introspect-mysql.d.ts +1 -1
  22. package/introspect-pg.d.ts +5 -2
  23. package/introspect-sqlite.d.ts +1 -1
  24. package/jsonDiffer.d.ts +14 -29
  25. package/jsonStatements.d.ts +38 -11
  26. package/package.json +18 -51
  27. package/payload.d.mts +18 -988
  28. package/payload.d.ts +18 -988
  29. package/payload.js +18030 -7175
  30. package/payload.mjs +9020 -9305
  31. package/schemaValidator.d.ts +73 -70
  32. package/serializer/mysqlImports.d.ts +3 -7
  33. package/serializer/mysqlSchema.d.ts +1624 -493
  34. package/serializer/mysqlSerializer.d.ts +4 -4
  35. package/serializer/pgImports.d.ts +2 -2
  36. package/serializer/pgSchema.d.ts +1260 -801
  37. package/serializer/sqliteImports.d.ts +2 -4
  38. package/serializer/sqliteSchema.d.ts +144 -570
  39. package/serializer/sqliteSerializer.d.ts +3 -3
  40. package/snapshotsDiffer.d.ts +1908 -1050
  41. package/utils/words.d.ts +1 -1
  42. package/utils-studio.js +4147 -83
  43. package/utils-studio.mjs +4147 -83
  44. package/utils.d.ts +6 -140
  45. package/utils.js +3903 -7064
  46. package/utils.mjs +3982 -7143
  47. package/cli/commands/mysqlUp.d.ts +0 -4
  48. package/cli/commands/pgUp.d.ts +0 -4
  49. package/cli/commands/sqliteUtils.d.ts +0 -162
  50. package/cli/commands/upFolders.d.ts +0 -27
package/utils-studio.mjs CHANGED
@@ -357,30 +357,30 @@ var init_supports_color = __esm({
357
357
 
358
358
  // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
359
359
  function stringReplaceAll(string, substring, replacer) {
360
- let index = string.indexOf(substring);
361
- if (index === -1) {
360
+ let index4 = string.indexOf(substring);
361
+ if (index4 === -1) {
362
362
  return string;
363
363
  }
364
364
  const substringLength = substring.length;
365
365
  let endIndex = 0;
366
366
  let returnValue = "";
367
367
  do {
368
- returnValue += string.slice(endIndex, index) + substring + replacer;
369
- endIndex = index + substringLength;
370
- index = string.indexOf(substring, endIndex);
371
- } while (index !== -1);
368
+ returnValue += string.slice(endIndex, index4) + substring + replacer;
369
+ endIndex = index4 + substringLength;
370
+ index4 = string.indexOf(substring, endIndex);
371
+ } while (index4 !== -1);
372
372
  returnValue += string.slice(endIndex);
373
373
  return returnValue;
374
374
  }
375
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
375
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
376
376
  let endIndex = 0;
377
377
  let returnValue = "";
378
378
  do {
379
- const gotCR = string[index - 1] === "\r";
380
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
381
- endIndex = index + 1;
382
- index = string.indexOf("\n", endIndex);
383
- } while (index !== -1);
379
+ const gotCR = string[index4 - 1] === "\r";
380
+ returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
381
+ endIndex = index4 + 1;
382
+ index4 = string.indexOf("\n", endIndex);
383
+ } while (index4 !== -1);
384
384
  returnValue += string.slice(endIndex);
385
385
  return returnValue;
386
386
  }
@@ -1074,12 +1074,3706 @@ var require_hanji = __commonJS({
1074
1074
  }
1075
1075
  });
1076
1076
 
1077
+ // src/global.ts
1078
+ var originUUID, snapshotVersion;
1079
+ var init_global = __esm({
1080
+ "src/global.ts"() {
1081
+ "use strict";
1082
+ originUUID = "00000000-0000-0000-0000-000000000000";
1083
+ snapshotVersion = "6";
1084
+ }
1085
+ });
1086
+
1087
+ // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
1088
+ function getErrorMap() {
1089
+ return overrideErrorMap;
1090
+ }
1091
+ function addIssueToContext(ctx, issueData) {
1092
+ const issue = makeIssue({
1093
+ issueData,
1094
+ data: ctx.data,
1095
+ path: ctx.path,
1096
+ errorMaps: [
1097
+ ctx.common.contextualErrorMap,
1098
+ ctx.schemaErrorMap,
1099
+ getErrorMap(),
1100
+ errorMap
1101
+ // then global default map
1102
+ ].filter((x) => !!x)
1103
+ });
1104
+ ctx.common.issues.push(issue);
1105
+ }
1106
+ function processCreateParams(params) {
1107
+ if (!params)
1108
+ return {};
1109
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
1110
+ if (errorMap2 && (invalid_type_error || required_error)) {
1111
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1112
+ }
1113
+ if (errorMap2)
1114
+ return { errorMap: errorMap2, description };
1115
+ const customMap = (iss, ctx) => {
1116
+ if (iss.code !== "invalid_type")
1117
+ return { message: ctx.defaultError };
1118
+ if (typeof ctx.data === "undefined") {
1119
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1120
+ }
1121
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1122
+ };
1123
+ return { errorMap: customMap, description };
1124
+ }
1125
+ function floatSafeRemainder(val, step) {
1126
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1127
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1128
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1129
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1130
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1131
+ return valInt % stepInt / Math.pow(10, decCount);
1132
+ }
1133
+ function deepPartialify(schema3) {
1134
+ if (schema3 instanceof ZodObject) {
1135
+ const newShape = {};
1136
+ for (const key in schema3.shape) {
1137
+ const fieldSchema = schema3.shape[key];
1138
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1139
+ }
1140
+ return new ZodObject({
1141
+ ...schema3._def,
1142
+ shape: () => newShape
1143
+ });
1144
+ } else if (schema3 instanceof ZodArray) {
1145
+ return ZodArray.create(deepPartialify(schema3.element));
1146
+ } else if (schema3 instanceof ZodOptional) {
1147
+ return ZodOptional.create(deepPartialify(schema3.unwrap()));
1148
+ } else if (schema3 instanceof ZodNullable) {
1149
+ return ZodNullable.create(deepPartialify(schema3.unwrap()));
1150
+ } else if (schema3 instanceof ZodTuple) {
1151
+ return ZodTuple.create(schema3.items.map((item) => deepPartialify(item)));
1152
+ } else {
1153
+ return schema3;
1154
+ }
1155
+ }
1156
+ function mergeValues(a, b) {
1157
+ const aType = getParsedType(a);
1158
+ const bType = getParsedType(b);
1159
+ if (a === b) {
1160
+ return { valid: true, data: a };
1161
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
1162
+ const bKeys = util.objectKeys(b);
1163
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
1164
+ const newObj = { ...a, ...b };
1165
+ for (const key of sharedKeys) {
1166
+ const sharedValue = mergeValues(a[key], b[key]);
1167
+ if (!sharedValue.valid) {
1168
+ return { valid: false };
1169
+ }
1170
+ newObj[key] = sharedValue.data;
1171
+ }
1172
+ return { valid: true, data: newObj };
1173
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
1174
+ if (a.length !== b.length) {
1175
+ return { valid: false };
1176
+ }
1177
+ const newArray = [];
1178
+ for (let index4 = 0; index4 < a.length; index4++) {
1179
+ const itemA = a[index4];
1180
+ const itemB = b[index4];
1181
+ const sharedValue = mergeValues(itemA, itemB);
1182
+ if (!sharedValue.valid) {
1183
+ return { valid: false };
1184
+ }
1185
+ newArray.push(sharedValue.data);
1186
+ }
1187
+ return { valid: true, data: newArray };
1188
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
1189
+ return { valid: true, data: a };
1190
+ } else {
1191
+ return { valid: false };
1192
+ }
1193
+ }
1194
+ function createZodEnum(values, params) {
1195
+ return new ZodEnum({
1196
+ values,
1197
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
1198
+ ...processCreateParams(params)
1199
+ });
1200
+ }
1201
+ var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex, datetimeRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, objectUtil, AugmentFactory, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
1202
+ var init_lib = __esm({
1203
+ "node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs"() {
1204
+ (function(util2) {
1205
+ util2.assertEqual = (val) => val;
1206
+ function assertIs(_arg) {
1207
+ }
1208
+ util2.assertIs = assertIs;
1209
+ function assertNever(_x) {
1210
+ throw new Error();
1211
+ }
1212
+ util2.assertNever = assertNever;
1213
+ util2.arrayToEnum = (items) => {
1214
+ const obj = {};
1215
+ for (const item of items) {
1216
+ obj[item] = item;
1217
+ }
1218
+ return obj;
1219
+ };
1220
+ util2.getValidEnumValues = (obj) => {
1221
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
1222
+ const filtered = {};
1223
+ for (const k of validKeys) {
1224
+ filtered[k] = obj[k];
1225
+ }
1226
+ return util2.objectValues(filtered);
1227
+ };
1228
+ util2.objectValues = (obj) => {
1229
+ return util2.objectKeys(obj).map(function(e) {
1230
+ return obj[e];
1231
+ });
1232
+ };
1233
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
1234
+ const keys = [];
1235
+ for (const key in object) {
1236
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
1237
+ keys.push(key);
1238
+ }
1239
+ }
1240
+ return keys;
1241
+ };
1242
+ util2.find = (arr, checker) => {
1243
+ for (const item of arr) {
1244
+ if (checker(item))
1245
+ return item;
1246
+ }
1247
+ return void 0;
1248
+ };
1249
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
1250
+ function joinValues(array, separator = " | ") {
1251
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
1252
+ }
1253
+ util2.joinValues = joinValues;
1254
+ util2.jsonStringifyReplacer = (_, value) => {
1255
+ if (typeof value === "bigint") {
1256
+ return value.toString();
1257
+ }
1258
+ return value;
1259
+ };
1260
+ })(util || (util = {}));
1261
+ ZodParsedType = util.arrayToEnum([
1262
+ "string",
1263
+ "nan",
1264
+ "number",
1265
+ "integer",
1266
+ "float",
1267
+ "boolean",
1268
+ "date",
1269
+ "bigint",
1270
+ "symbol",
1271
+ "function",
1272
+ "undefined",
1273
+ "null",
1274
+ "array",
1275
+ "object",
1276
+ "unknown",
1277
+ "promise",
1278
+ "void",
1279
+ "never",
1280
+ "map",
1281
+ "set"
1282
+ ]);
1283
+ getParsedType = (data) => {
1284
+ const t = typeof data;
1285
+ switch (t) {
1286
+ case "undefined":
1287
+ return ZodParsedType.undefined;
1288
+ case "string":
1289
+ return ZodParsedType.string;
1290
+ case "number":
1291
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1292
+ case "boolean":
1293
+ return ZodParsedType.boolean;
1294
+ case "function":
1295
+ return ZodParsedType.function;
1296
+ case "bigint":
1297
+ return ZodParsedType.bigint;
1298
+ case "symbol":
1299
+ return ZodParsedType.symbol;
1300
+ case "object":
1301
+ if (Array.isArray(data)) {
1302
+ return ZodParsedType.array;
1303
+ }
1304
+ if (data === null) {
1305
+ return ZodParsedType.null;
1306
+ }
1307
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1308
+ return ZodParsedType.promise;
1309
+ }
1310
+ if (typeof Map !== "undefined" && data instanceof Map) {
1311
+ return ZodParsedType.map;
1312
+ }
1313
+ if (typeof Set !== "undefined" && data instanceof Set) {
1314
+ return ZodParsedType.set;
1315
+ }
1316
+ if (typeof Date !== "undefined" && data instanceof Date) {
1317
+ return ZodParsedType.date;
1318
+ }
1319
+ return ZodParsedType.object;
1320
+ default:
1321
+ return ZodParsedType.unknown;
1322
+ }
1323
+ };
1324
+ ZodIssueCode = util.arrayToEnum([
1325
+ "invalid_type",
1326
+ "invalid_literal",
1327
+ "custom",
1328
+ "invalid_union",
1329
+ "invalid_union_discriminator",
1330
+ "invalid_enum_value",
1331
+ "unrecognized_keys",
1332
+ "invalid_arguments",
1333
+ "invalid_return_type",
1334
+ "invalid_date",
1335
+ "invalid_string",
1336
+ "too_small",
1337
+ "too_big",
1338
+ "invalid_intersection_types",
1339
+ "not_multiple_of",
1340
+ "not_finite"
1341
+ ]);
1342
+ ZodError = class extends Error {
1343
+ constructor(issues) {
1344
+ super();
1345
+ this.issues = [];
1346
+ this.addIssue = (sub) => {
1347
+ this.issues = [...this.issues, sub];
1348
+ };
1349
+ this.addIssues = (subs = []) => {
1350
+ this.issues = [...this.issues, ...subs];
1351
+ };
1352
+ const actualProto = new.target.prototype;
1353
+ if (Object.setPrototypeOf) {
1354
+ Object.setPrototypeOf(this, actualProto);
1355
+ } else {
1356
+ this.__proto__ = actualProto;
1357
+ }
1358
+ this.name = "ZodError";
1359
+ this.issues = issues;
1360
+ }
1361
+ get errors() {
1362
+ return this.issues;
1363
+ }
1364
+ format(_mapper) {
1365
+ const mapper = _mapper || function(issue) {
1366
+ return issue.message;
1367
+ };
1368
+ const fieldErrors = { _errors: [] };
1369
+ const processError = (error2) => {
1370
+ for (const issue of error2.issues) {
1371
+ if (issue.code === "invalid_union") {
1372
+ issue.unionErrors.map(processError);
1373
+ } else if (issue.code === "invalid_return_type") {
1374
+ processError(issue.returnTypeError);
1375
+ } else if (issue.code === "invalid_arguments") {
1376
+ processError(issue.argumentsError);
1377
+ } else if (issue.path.length === 0) {
1378
+ fieldErrors._errors.push(mapper(issue));
1379
+ } else {
1380
+ let curr = fieldErrors;
1381
+ let i = 0;
1382
+ while (i < issue.path.length) {
1383
+ const el = issue.path[i];
1384
+ const terminal = i === issue.path.length - 1;
1385
+ if (!terminal) {
1386
+ curr[el] = curr[el] || { _errors: [] };
1387
+ } else {
1388
+ curr[el] = curr[el] || { _errors: [] };
1389
+ curr[el]._errors.push(mapper(issue));
1390
+ }
1391
+ curr = curr[el];
1392
+ i++;
1393
+ }
1394
+ }
1395
+ }
1396
+ };
1397
+ processError(this);
1398
+ return fieldErrors;
1399
+ }
1400
+ toString() {
1401
+ return this.message;
1402
+ }
1403
+ get message() {
1404
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1405
+ }
1406
+ get isEmpty() {
1407
+ return this.issues.length === 0;
1408
+ }
1409
+ flatten(mapper = (issue) => issue.message) {
1410
+ const fieldErrors = {};
1411
+ const formErrors = [];
1412
+ for (const sub of this.issues) {
1413
+ if (sub.path.length > 0) {
1414
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1415
+ fieldErrors[sub.path[0]].push(mapper(sub));
1416
+ } else {
1417
+ formErrors.push(mapper(sub));
1418
+ }
1419
+ }
1420
+ return { formErrors, fieldErrors };
1421
+ }
1422
+ get formErrors() {
1423
+ return this.flatten();
1424
+ }
1425
+ };
1426
+ ZodError.create = (issues) => {
1427
+ const error2 = new ZodError(issues);
1428
+ return error2;
1429
+ };
1430
+ errorMap = (issue, _ctx) => {
1431
+ let message;
1432
+ switch (issue.code) {
1433
+ case ZodIssueCode.invalid_type:
1434
+ if (issue.received === ZodParsedType.undefined) {
1435
+ message = "Required";
1436
+ } else {
1437
+ message = `Expected ${issue.expected}, received ${issue.received}`;
1438
+ }
1439
+ break;
1440
+ case ZodIssueCode.invalid_literal:
1441
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
1442
+ break;
1443
+ case ZodIssueCode.unrecognized_keys:
1444
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
1445
+ break;
1446
+ case ZodIssueCode.invalid_union:
1447
+ message = `Invalid input`;
1448
+ break;
1449
+ case ZodIssueCode.invalid_union_discriminator:
1450
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
1451
+ break;
1452
+ case ZodIssueCode.invalid_enum_value:
1453
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
1454
+ break;
1455
+ case ZodIssueCode.invalid_arguments:
1456
+ message = `Invalid function arguments`;
1457
+ break;
1458
+ case ZodIssueCode.invalid_return_type:
1459
+ message = `Invalid function return type`;
1460
+ break;
1461
+ case ZodIssueCode.invalid_date:
1462
+ message = `Invalid date`;
1463
+ break;
1464
+ case ZodIssueCode.invalid_string:
1465
+ if (typeof issue.validation === "object") {
1466
+ if ("startsWith" in issue.validation) {
1467
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1468
+ } else if ("endsWith" in issue.validation) {
1469
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1470
+ } else {
1471
+ util.assertNever(issue.validation);
1472
+ }
1473
+ } else if (issue.validation !== "regex") {
1474
+ message = `Invalid ${issue.validation}`;
1475
+ } else {
1476
+ message = "Invalid";
1477
+ }
1478
+ break;
1479
+ case ZodIssueCode.too_small:
1480
+ if (issue.type === "array")
1481
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1482
+ else if (issue.type === "string")
1483
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1484
+ else if (issue.type === "number")
1485
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1486
+ else if (issue.type === "date")
1487
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1488
+ else
1489
+ message = "Invalid input";
1490
+ break;
1491
+ case ZodIssueCode.too_big:
1492
+ if (issue.type === "array")
1493
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1494
+ else if (issue.type === "string")
1495
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1496
+ else if (issue.type === "number")
1497
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1498
+ else if (issue.type === "date")
1499
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1500
+ else
1501
+ message = "Invalid input";
1502
+ break;
1503
+ case ZodIssueCode.custom:
1504
+ message = `Invalid input`;
1505
+ break;
1506
+ case ZodIssueCode.invalid_intersection_types:
1507
+ message = `Intersection results could not be merged`;
1508
+ break;
1509
+ case ZodIssueCode.not_multiple_of:
1510
+ message = `Number must be a multiple of ${issue.multipleOf}`;
1511
+ break;
1512
+ case ZodIssueCode.not_finite:
1513
+ message = "Number must be finite";
1514
+ break;
1515
+ default:
1516
+ message = _ctx.defaultError;
1517
+ util.assertNever(issue);
1518
+ }
1519
+ return { message };
1520
+ };
1521
+ overrideErrorMap = errorMap;
1522
+ makeIssue = (params) => {
1523
+ const { data, path: path2, errorMaps, issueData } = params;
1524
+ const fullPath = [...path2, ...issueData.path || []];
1525
+ const fullIssue = {
1526
+ ...issueData,
1527
+ path: fullPath
1528
+ };
1529
+ let errorMessage = "";
1530
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
1531
+ for (const map of maps) {
1532
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1533
+ }
1534
+ return {
1535
+ ...issueData,
1536
+ path: fullPath,
1537
+ message: issueData.message || errorMessage
1538
+ };
1539
+ };
1540
+ ParseStatus = class _ParseStatus {
1541
+ constructor() {
1542
+ this.value = "valid";
1543
+ }
1544
+ dirty() {
1545
+ if (this.value === "valid")
1546
+ this.value = "dirty";
1547
+ }
1548
+ abort() {
1549
+ if (this.value !== "aborted")
1550
+ this.value = "aborted";
1551
+ }
1552
+ static mergeArray(status, results) {
1553
+ const arrayValue = [];
1554
+ for (const s of results) {
1555
+ if (s.status === "aborted")
1556
+ return INVALID;
1557
+ if (s.status === "dirty")
1558
+ status.dirty();
1559
+ arrayValue.push(s.value);
1560
+ }
1561
+ return { status: status.value, value: arrayValue };
1562
+ }
1563
+ static async mergeObjectAsync(status, pairs) {
1564
+ const syncPairs = [];
1565
+ for (const pair of pairs) {
1566
+ syncPairs.push({
1567
+ key: await pair.key,
1568
+ value: await pair.value
1569
+ });
1570
+ }
1571
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
1572
+ }
1573
+ static mergeObjectSync(status, pairs) {
1574
+ const finalObject = {};
1575
+ for (const pair of pairs) {
1576
+ const { key, value } = pair;
1577
+ if (key.status === "aborted")
1578
+ return INVALID;
1579
+ if (value.status === "aborted")
1580
+ return INVALID;
1581
+ if (key.status === "dirty")
1582
+ status.dirty();
1583
+ if (value.status === "dirty")
1584
+ status.dirty();
1585
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
1586
+ finalObject[key.value] = value.value;
1587
+ }
1588
+ }
1589
+ return { status: status.value, value: finalObject };
1590
+ }
1591
+ };
1592
+ INVALID = Object.freeze({
1593
+ status: "aborted"
1594
+ });
1595
+ DIRTY = (value) => ({ status: "dirty", value });
1596
+ OK = (value) => ({ status: "valid", value });
1597
+ isAborted = (x) => x.status === "aborted";
1598
+ isDirty = (x) => x.status === "dirty";
1599
+ isValid = (x) => x.status === "valid";
1600
+ isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
1601
+ (function(errorUtil2) {
1602
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1603
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1604
+ })(errorUtil || (errorUtil = {}));
1605
+ ParseInputLazyPath = class {
1606
+ constructor(parent, value, path2, key) {
1607
+ this.parent = parent;
1608
+ this.data = value;
1609
+ this._path = path2;
1610
+ this._key = key;
1611
+ }
1612
+ get path() {
1613
+ return this._path.concat(this._key);
1614
+ }
1615
+ };
1616
+ handleResult = (ctx, result) => {
1617
+ if (isValid(result)) {
1618
+ return { success: true, data: result.value };
1619
+ } else {
1620
+ if (!ctx.common.issues.length) {
1621
+ throw new Error("Validation failed but no issues detected.");
1622
+ }
1623
+ const error2 = new ZodError(ctx.common.issues);
1624
+ return { success: false, error: error2 };
1625
+ }
1626
+ };
1627
+ ZodType = class {
1628
+ constructor(def) {
1629
+ this.spa = this.safeParseAsync;
1630
+ this._def = def;
1631
+ this.parse = this.parse.bind(this);
1632
+ this.safeParse = this.safeParse.bind(this);
1633
+ this.parseAsync = this.parseAsync.bind(this);
1634
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1635
+ this.spa = this.spa.bind(this);
1636
+ this.refine = this.refine.bind(this);
1637
+ this.refinement = this.refinement.bind(this);
1638
+ this.superRefine = this.superRefine.bind(this);
1639
+ this.optional = this.optional.bind(this);
1640
+ this.nullable = this.nullable.bind(this);
1641
+ this.nullish = this.nullish.bind(this);
1642
+ this.array = this.array.bind(this);
1643
+ this.promise = this.promise.bind(this);
1644
+ this.or = this.or.bind(this);
1645
+ this.and = this.and.bind(this);
1646
+ this.transform = this.transform.bind(this);
1647
+ this.brand = this.brand.bind(this);
1648
+ this.default = this.default.bind(this);
1649
+ this.catch = this.catch.bind(this);
1650
+ this.describe = this.describe.bind(this);
1651
+ this.pipe = this.pipe.bind(this);
1652
+ this.isNullable = this.isNullable.bind(this);
1653
+ this.isOptional = this.isOptional.bind(this);
1654
+ }
1655
+ get description() {
1656
+ return this._def.description;
1657
+ }
1658
+ _getType(input) {
1659
+ return getParsedType(input.data);
1660
+ }
1661
+ _getOrReturnCtx(input, ctx) {
1662
+ return ctx || {
1663
+ common: input.parent.common,
1664
+ data: input.data,
1665
+ parsedType: getParsedType(input.data),
1666
+ schemaErrorMap: this._def.errorMap,
1667
+ path: input.path,
1668
+ parent: input.parent
1669
+ };
1670
+ }
1671
+ _processInputParams(input) {
1672
+ return {
1673
+ status: new ParseStatus(),
1674
+ ctx: {
1675
+ common: input.parent.common,
1676
+ data: input.data,
1677
+ parsedType: getParsedType(input.data),
1678
+ schemaErrorMap: this._def.errorMap,
1679
+ path: input.path,
1680
+ parent: input.parent
1681
+ }
1682
+ };
1683
+ }
1684
+ _parseSync(input) {
1685
+ const result = this._parse(input);
1686
+ if (isAsync(result)) {
1687
+ throw new Error("Synchronous parse encountered promise.");
1688
+ }
1689
+ return result;
1690
+ }
1691
+ _parseAsync(input) {
1692
+ const result = this._parse(input);
1693
+ return Promise.resolve(result);
1694
+ }
1695
+ parse(data, params) {
1696
+ const result = this.safeParse(data, params);
1697
+ if (result.success)
1698
+ return result.data;
1699
+ throw result.error;
1700
+ }
1701
+ safeParse(data, params) {
1702
+ var _a;
1703
+ const ctx = {
1704
+ common: {
1705
+ issues: [],
1706
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
1707
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
1708
+ },
1709
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1710
+ schemaErrorMap: this._def.errorMap,
1711
+ parent: null,
1712
+ data,
1713
+ parsedType: getParsedType(data)
1714
+ };
1715
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1716
+ return handleResult(ctx, result);
1717
+ }
1718
+ async parseAsync(data, params) {
1719
+ const result = await this.safeParseAsync(data, params);
1720
+ if (result.success)
1721
+ return result.data;
1722
+ throw result.error;
1723
+ }
1724
+ async safeParseAsync(data, params) {
1725
+ const ctx = {
1726
+ common: {
1727
+ issues: [],
1728
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
1729
+ async: true
1730
+ },
1731
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1732
+ schemaErrorMap: this._def.errorMap,
1733
+ parent: null,
1734
+ data,
1735
+ parsedType: getParsedType(data)
1736
+ };
1737
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1738
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1739
+ return handleResult(ctx, result);
1740
+ }
1741
+ refine(check, message) {
1742
+ const getIssueProperties = (val) => {
1743
+ if (typeof message === "string" || typeof message === "undefined") {
1744
+ return { message };
1745
+ } else if (typeof message === "function") {
1746
+ return message(val);
1747
+ } else {
1748
+ return message;
1749
+ }
1750
+ };
1751
+ return this._refinement((val, ctx) => {
1752
+ const result = check(val);
1753
+ const setError = () => ctx.addIssue({
1754
+ code: ZodIssueCode.custom,
1755
+ ...getIssueProperties(val)
1756
+ });
1757
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
1758
+ return result.then((data) => {
1759
+ if (!data) {
1760
+ setError();
1761
+ return false;
1762
+ } else {
1763
+ return true;
1764
+ }
1765
+ });
1766
+ }
1767
+ if (!result) {
1768
+ setError();
1769
+ return false;
1770
+ } else {
1771
+ return true;
1772
+ }
1773
+ });
1774
+ }
1775
+ refinement(check, refinementData) {
1776
+ return this._refinement((val, ctx) => {
1777
+ if (!check(val)) {
1778
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1779
+ return false;
1780
+ } else {
1781
+ return true;
1782
+ }
1783
+ });
1784
+ }
1785
+ _refinement(refinement) {
1786
+ return new ZodEffects({
1787
+ schema: this,
1788
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1789
+ effect: { type: "refinement", refinement }
1790
+ });
1791
+ }
1792
+ superRefine(refinement) {
1793
+ return this._refinement(refinement);
1794
+ }
1795
+ optional() {
1796
+ return ZodOptional.create(this);
1797
+ }
1798
+ nullable() {
1799
+ return ZodNullable.create(this);
1800
+ }
1801
+ nullish() {
1802
+ return this.optional().nullable();
1803
+ }
1804
+ array() {
1805
+ return ZodArray.create(this);
1806
+ }
1807
+ promise() {
1808
+ return ZodPromise.create(this);
1809
+ }
1810
+ or(option) {
1811
+ return ZodUnion.create([this, option]);
1812
+ }
1813
+ and(incoming) {
1814
+ return ZodIntersection.create(this, incoming);
1815
+ }
1816
+ transform(transform) {
1817
+ return new ZodEffects({
1818
+ schema: this,
1819
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1820
+ effect: { type: "transform", transform }
1821
+ });
1822
+ }
1823
+ default(def) {
1824
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1825
+ return new ZodDefault({
1826
+ innerType: this,
1827
+ defaultValue: defaultValueFunc,
1828
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1829
+ });
1830
+ }
1831
+ brand() {
1832
+ return new ZodBranded({
1833
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1834
+ type: this,
1835
+ ...processCreateParams(void 0)
1836
+ });
1837
+ }
1838
+ catch(def) {
1839
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1840
+ return new ZodCatch({
1841
+ innerType: this,
1842
+ defaultValue: defaultValueFunc,
1843
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1844
+ });
1845
+ }
1846
+ describe(description) {
1847
+ const This = this.constructor;
1848
+ return new This({
1849
+ ...this._def,
1850
+ description
1851
+ });
1852
+ }
1853
+ pipe(target) {
1854
+ return ZodPipeline.create(this, target);
1855
+ }
1856
+ isOptional() {
1857
+ return this.safeParse(void 0).success;
1858
+ }
1859
+ isNullable() {
1860
+ return this.safeParse(null).success;
1861
+ }
1862
+ };
1863
+ cuidRegex = /^c[^\s-]{8,}$/i;
1864
+ uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
1865
+ emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1866
+ datetimeRegex = (args) => {
1867
+ if (args.precision) {
1868
+ if (args.offset) {
1869
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
1870
+ } else {
1871
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1872
+ }
1873
+ } else if (args.precision === 0) {
1874
+ if (args.offset) {
1875
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
1876
+ } else {
1877
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1878
+ }
1879
+ } else {
1880
+ if (args.offset) {
1881
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
1882
+ } else {
1883
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1884
+ }
1885
+ }
1886
+ };
1887
+ ZodString = class _ZodString extends ZodType {
1888
+ constructor() {
1889
+ super(...arguments);
1890
+ this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
1891
+ validation,
1892
+ code: ZodIssueCode.invalid_string,
1893
+ ...errorUtil.errToObj(message)
1894
+ });
1895
+ this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
1896
+ this.trim = () => new _ZodString({
1897
+ ...this._def,
1898
+ checks: [...this._def.checks, { kind: "trim" }]
1899
+ });
1900
+ }
1901
+ _parse(input) {
1902
+ if (this._def.coerce) {
1903
+ input.data = String(input.data);
1904
+ }
1905
+ const parsedType = this._getType(input);
1906
+ if (parsedType !== ZodParsedType.string) {
1907
+ const ctx2 = this._getOrReturnCtx(input);
1908
+ addIssueToContext(
1909
+ ctx2,
1910
+ {
1911
+ code: ZodIssueCode.invalid_type,
1912
+ expected: ZodParsedType.string,
1913
+ received: ctx2.parsedType
1914
+ }
1915
+ //
1916
+ );
1917
+ return INVALID;
1918
+ }
1919
+ const status = new ParseStatus();
1920
+ let ctx = void 0;
1921
+ for (const check of this._def.checks) {
1922
+ if (check.kind === "min") {
1923
+ if (input.data.length < check.value) {
1924
+ ctx = this._getOrReturnCtx(input, ctx);
1925
+ addIssueToContext(ctx, {
1926
+ code: ZodIssueCode.too_small,
1927
+ minimum: check.value,
1928
+ type: "string",
1929
+ inclusive: true,
1930
+ exact: false,
1931
+ message: check.message
1932
+ });
1933
+ status.dirty();
1934
+ }
1935
+ } else if (check.kind === "max") {
1936
+ if (input.data.length > check.value) {
1937
+ ctx = this._getOrReturnCtx(input, ctx);
1938
+ addIssueToContext(ctx, {
1939
+ code: ZodIssueCode.too_big,
1940
+ maximum: check.value,
1941
+ type: "string",
1942
+ inclusive: true,
1943
+ exact: false,
1944
+ message: check.message
1945
+ });
1946
+ status.dirty();
1947
+ }
1948
+ } else if (check.kind === "length") {
1949
+ const tooBig = input.data.length > check.value;
1950
+ const tooSmall = input.data.length < check.value;
1951
+ if (tooBig || tooSmall) {
1952
+ ctx = this._getOrReturnCtx(input, ctx);
1953
+ if (tooBig) {
1954
+ addIssueToContext(ctx, {
1955
+ code: ZodIssueCode.too_big,
1956
+ maximum: check.value,
1957
+ type: "string",
1958
+ inclusive: true,
1959
+ exact: true,
1960
+ message: check.message
1961
+ });
1962
+ } else if (tooSmall) {
1963
+ addIssueToContext(ctx, {
1964
+ code: ZodIssueCode.too_small,
1965
+ minimum: check.value,
1966
+ type: "string",
1967
+ inclusive: true,
1968
+ exact: true,
1969
+ message: check.message
1970
+ });
1971
+ }
1972
+ status.dirty();
1973
+ }
1974
+ } else if (check.kind === "email") {
1975
+ if (!emailRegex.test(input.data)) {
1976
+ ctx = this._getOrReturnCtx(input, ctx);
1977
+ addIssueToContext(ctx, {
1978
+ validation: "email",
1979
+ code: ZodIssueCode.invalid_string,
1980
+ message: check.message
1981
+ });
1982
+ status.dirty();
1983
+ }
1984
+ } else if (check.kind === "uuid") {
1985
+ if (!uuidRegex.test(input.data)) {
1986
+ ctx = this._getOrReturnCtx(input, ctx);
1987
+ addIssueToContext(ctx, {
1988
+ validation: "uuid",
1989
+ code: ZodIssueCode.invalid_string,
1990
+ message: check.message
1991
+ });
1992
+ status.dirty();
1993
+ }
1994
+ } else if (check.kind === "cuid") {
1995
+ if (!cuidRegex.test(input.data)) {
1996
+ ctx = this._getOrReturnCtx(input, ctx);
1997
+ addIssueToContext(ctx, {
1998
+ validation: "cuid",
1999
+ code: ZodIssueCode.invalid_string,
2000
+ message: check.message
2001
+ });
2002
+ status.dirty();
2003
+ }
2004
+ } else if (check.kind === "url") {
2005
+ try {
2006
+ new URL(input.data);
2007
+ } catch (_a) {
2008
+ ctx = this._getOrReturnCtx(input, ctx);
2009
+ addIssueToContext(ctx, {
2010
+ validation: "url",
2011
+ code: ZodIssueCode.invalid_string,
2012
+ message: check.message
2013
+ });
2014
+ status.dirty();
2015
+ }
2016
+ } else if (check.kind === "regex") {
2017
+ check.regex.lastIndex = 0;
2018
+ const testResult = check.regex.test(input.data);
2019
+ if (!testResult) {
2020
+ ctx = this._getOrReturnCtx(input, ctx);
2021
+ addIssueToContext(ctx, {
2022
+ validation: "regex",
2023
+ code: ZodIssueCode.invalid_string,
2024
+ message: check.message
2025
+ });
2026
+ status.dirty();
2027
+ }
2028
+ } else if (check.kind === "trim") {
2029
+ input.data = input.data.trim();
2030
+ } else if (check.kind === "startsWith") {
2031
+ if (!input.data.startsWith(check.value)) {
2032
+ ctx = this._getOrReturnCtx(input, ctx);
2033
+ addIssueToContext(ctx, {
2034
+ code: ZodIssueCode.invalid_string,
2035
+ validation: { startsWith: check.value },
2036
+ message: check.message
2037
+ });
2038
+ status.dirty();
2039
+ }
2040
+ } else if (check.kind === "endsWith") {
2041
+ if (!input.data.endsWith(check.value)) {
2042
+ ctx = this._getOrReturnCtx(input, ctx);
2043
+ addIssueToContext(ctx, {
2044
+ code: ZodIssueCode.invalid_string,
2045
+ validation: { endsWith: check.value },
2046
+ message: check.message
2047
+ });
2048
+ status.dirty();
2049
+ }
2050
+ } else if (check.kind === "datetime") {
2051
+ const regex = datetimeRegex(check);
2052
+ if (!regex.test(input.data)) {
2053
+ ctx = this._getOrReturnCtx(input, ctx);
2054
+ addIssueToContext(ctx, {
2055
+ code: ZodIssueCode.invalid_string,
2056
+ validation: "datetime",
2057
+ message: check.message
2058
+ });
2059
+ status.dirty();
2060
+ }
2061
+ } else {
2062
+ util.assertNever(check);
2063
+ }
2064
+ }
2065
+ return { status: status.value, value: input.data };
2066
+ }
2067
+ _addCheck(check) {
2068
+ return new _ZodString({
2069
+ ...this._def,
2070
+ checks: [...this._def.checks, check]
2071
+ });
2072
+ }
2073
+ email(message) {
2074
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
2075
+ }
2076
+ url(message) {
2077
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2078
+ }
2079
+ uuid(message) {
2080
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2081
+ }
2082
+ cuid(message) {
2083
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2084
+ }
2085
+ datetime(options) {
2086
+ var _a;
2087
+ if (typeof options === "string") {
2088
+ return this._addCheck({
2089
+ kind: "datetime",
2090
+ precision: null,
2091
+ offset: false,
2092
+ message: options
2093
+ });
2094
+ }
2095
+ return this._addCheck({
2096
+ kind: "datetime",
2097
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2098
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2099
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2100
+ });
2101
+ }
2102
+ regex(regex, message) {
2103
+ return this._addCheck({
2104
+ kind: "regex",
2105
+ regex,
2106
+ ...errorUtil.errToObj(message)
2107
+ });
2108
+ }
2109
+ startsWith(value, message) {
2110
+ return this._addCheck({
2111
+ kind: "startsWith",
2112
+ value,
2113
+ ...errorUtil.errToObj(message)
2114
+ });
2115
+ }
2116
+ endsWith(value, message) {
2117
+ return this._addCheck({
2118
+ kind: "endsWith",
2119
+ value,
2120
+ ...errorUtil.errToObj(message)
2121
+ });
2122
+ }
2123
+ min(minLength, message) {
2124
+ return this._addCheck({
2125
+ kind: "min",
2126
+ value: minLength,
2127
+ ...errorUtil.errToObj(message)
2128
+ });
2129
+ }
2130
+ max(maxLength, message) {
2131
+ return this._addCheck({
2132
+ kind: "max",
2133
+ value: maxLength,
2134
+ ...errorUtil.errToObj(message)
2135
+ });
2136
+ }
2137
+ length(len, message) {
2138
+ return this._addCheck({
2139
+ kind: "length",
2140
+ value: len,
2141
+ ...errorUtil.errToObj(message)
2142
+ });
2143
+ }
2144
+ get isDatetime() {
2145
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
2146
+ }
2147
+ get isEmail() {
2148
+ return !!this._def.checks.find((ch) => ch.kind === "email");
2149
+ }
2150
+ get isURL() {
2151
+ return !!this._def.checks.find((ch) => ch.kind === "url");
2152
+ }
2153
+ get isUUID() {
2154
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
2155
+ }
2156
+ get isCUID() {
2157
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
2158
+ }
2159
+ get minLength() {
2160
+ let min = null;
2161
+ for (const ch of this._def.checks) {
2162
+ if (ch.kind === "min") {
2163
+ if (min === null || ch.value > min)
2164
+ min = ch.value;
2165
+ }
2166
+ }
2167
+ return min;
2168
+ }
2169
+ get maxLength() {
2170
+ let max = null;
2171
+ for (const ch of this._def.checks) {
2172
+ if (ch.kind === "max") {
2173
+ if (max === null || ch.value < max)
2174
+ max = ch.value;
2175
+ }
2176
+ }
2177
+ return max;
2178
+ }
2179
+ };
2180
+ ZodString.create = (params) => {
2181
+ var _a;
2182
+ return new ZodString({
2183
+ checks: [],
2184
+ typeName: ZodFirstPartyTypeKind.ZodString,
2185
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2186
+ ...processCreateParams(params)
2187
+ });
2188
+ };
2189
+ ZodNumber = class _ZodNumber extends ZodType {
2190
+ constructor() {
2191
+ super(...arguments);
2192
+ this.min = this.gte;
2193
+ this.max = this.lte;
2194
+ this.step = this.multipleOf;
2195
+ }
2196
+ _parse(input) {
2197
+ if (this._def.coerce) {
2198
+ input.data = Number(input.data);
2199
+ }
2200
+ const parsedType = this._getType(input);
2201
+ if (parsedType !== ZodParsedType.number) {
2202
+ const ctx2 = this._getOrReturnCtx(input);
2203
+ addIssueToContext(ctx2, {
2204
+ code: ZodIssueCode.invalid_type,
2205
+ expected: ZodParsedType.number,
2206
+ received: ctx2.parsedType
2207
+ });
2208
+ return INVALID;
2209
+ }
2210
+ let ctx = void 0;
2211
+ const status = new ParseStatus();
2212
+ for (const check of this._def.checks) {
2213
+ if (check.kind === "int") {
2214
+ if (!util.isInteger(input.data)) {
2215
+ ctx = this._getOrReturnCtx(input, ctx);
2216
+ addIssueToContext(ctx, {
2217
+ code: ZodIssueCode.invalid_type,
2218
+ expected: "integer",
2219
+ received: "float",
2220
+ message: check.message
2221
+ });
2222
+ status.dirty();
2223
+ }
2224
+ } else if (check.kind === "min") {
2225
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2226
+ if (tooSmall) {
2227
+ ctx = this._getOrReturnCtx(input, ctx);
2228
+ addIssueToContext(ctx, {
2229
+ code: ZodIssueCode.too_small,
2230
+ minimum: check.value,
2231
+ type: "number",
2232
+ inclusive: check.inclusive,
2233
+ exact: false,
2234
+ message: check.message
2235
+ });
2236
+ status.dirty();
2237
+ }
2238
+ } else if (check.kind === "max") {
2239
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2240
+ if (tooBig) {
2241
+ ctx = this._getOrReturnCtx(input, ctx);
2242
+ addIssueToContext(ctx, {
2243
+ code: ZodIssueCode.too_big,
2244
+ maximum: check.value,
2245
+ type: "number",
2246
+ inclusive: check.inclusive,
2247
+ exact: false,
2248
+ message: check.message
2249
+ });
2250
+ status.dirty();
2251
+ }
2252
+ } else if (check.kind === "multipleOf") {
2253
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2254
+ ctx = this._getOrReturnCtx(input, ctx);
2255
+ addIssueToContext(ctx, {
2256
+ code: ZodIssueCode.not_multiple_of,
2257
+ multipleOf: check.value,
2258
+ message: check.message
2259
+ });
2260
+ status.dirty();
2261
+ }
2262
+ } else if (check.kind === "finite") {
2263
+ if (!Number.isFinite(input.data)) {
2264
+ ctx = this._getOrReturnCtx(input, ctx);
2265
+ addIssueToContext(ctx, {
2266
+ code: ZodIssueCode.not_finite,
2267
+ message: check.message
2268
+ });
2269
+ status.dirty();
2270
+ }
2271
+ } else {
2272
+ util.assertNever(check);
2273
+ }
2274
+ }
2275
+ return { status: status.value, value: input.data };
2276
+ }
2277
+ gte(value, message) {
2278
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2279
+ }
2280
+ gt(value, message) {
2281
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2282
+ }
2283
+ lte(value, message) {
2284
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2285
+ }
2286
+ lt(value, message) {
2287
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2288
+ }
2289
+ setLimit(kind, value, inclusive, message) {
2290
+ return new _ZodNumber({
2291
+ ...this._def,
2292
+ checks: [
2293
+ ...this._def.checks,
2294
+ {
2295
+ kind,
2296
+ value,
2297
+ inclusive,
2298
+ message: errorUtil.toString(message)
2299
+ }
2300
+ ]
2301
+ });
2302
+ }
2303
+ _addCheck(check) {
2304
+ return new _ZodNumber({
2305
+ ...this._def,
2306
+ checks: [...this._def.checks, check]
2307
+ });
2308
+ }
2309
+ int(message) {
2310
+ return this._addCheck({
2311
+ kind: "int",
2312
+ message: errorUtil.toString(message)
2313
+ });
2314
+ }
2315
+ positive(message) {
2316
+ return this._addCheck({
2317
+ kind: "min",
2318
+ value: 0,
2319
+ inclusive: false,
2320
+ message: errorUtil.toString(message)
2321
+ });
2322
+ }
2323
+ negative(message) {
2324
+ return this._addCheck({
2325
+ kind: "max",
2326
+ value: 0,
2327
+ inclusive: false,
2328
+ message: errorUtil.toString(message)
2329
+ });
2330
+ }
2331
+ nonpositive(message) {
2332
+ return this._addCheck({
2333
+ kind: "max",
2334
+ value: 0,
2335
+ inclusive: true,
2336
+ message: errorUtil.toString(message)
2337
+ });
2338
+ }
2339
+ nonnegative(message) {
2340
+ return this._addCheck({
2341
+ kind: "min",
2342
+ value: 0,
2343
+ inclusive: true,
2344
+ message: errorUtil.toString(message)
2345
+ });
2346
+ }
2347
+ multipleOf(value, message) {
2348
+ return this._addCheck({
2349
+ kind: "multipleOf",
2350
+ value,
2351
+ message: errorUtil.toString(message)
2352
+ });
2353
+ }
2354
+ finite(message) {
2355
+ return this._addCheck({
2356
+ kind: "finite",
2357
+ message: errorUtil.toString(message)
2358
+ });
2359
+ }
2360
+ get minValue() {
2361
+ let min = null;
2362
+ for (const ch of this._def.checks) {
2363
+ if (ch.kind === "min") {
2364
+ if (min === null || ch.value > min)
2365
+ min = ch.value;
2366
+ }
2367
+ }
2368
+ return min;
2369
+ }
2370
+ get maxValue() {
2371
+ let max = null;
2372
+ for (const ch of this._def.checks) {
2373
+ if (ch.kind === "max") {
2374
+ if (max === null || ch.value < max)
2375
+ max = ch.value;
2376
+ }
2377
+ }
2378
+ return max;
2379
+ }
2380
+ get isInt() {
2381
+ return !!this._def.checks.find((ch) => ch.kind === "int");
2382
+ }
2383
+ };
2384
+ ZodNumber.create = (params) => {
2385
+ return new ZodNumber({
2386
+ checks: [],
2387
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2388
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2389
+ ...processCreateParams(params)
2390
+ });
2391
+ };
2392
+ ZodBigInt = class extends ZodType {
2393
+ _parse(input) {
2394
+ if (this._def.coerce) {
2395
+ input.data = BigInt(input.data);
2396
+ }
2397
+ const parsedType = this._getType(input);
2398
+ if (parsedType !== ZodParsedType.bigint) {
2399
+ const ctx = this._getOrReturnCtx(input);
2400
+ addIssueToContext(ctx, {
2401
+ code: ZodIssueCode.invalid_type,
2402
+ expected: ZodParsedType.bigint,
2403
+ received: ctx.parsedType
2404
+ });
2405
+ return INVALID;
2406
+ }
2407
+ return OK(input.data);
2408
+ }
2409
+ };
2410
+ ZodBigInt.create = (params) => {
2411
+ var _a;
2412
+ return new ZodBigInt({
2413
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2414
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2415
+ ...processCreateParams(params)
2416
+ });
2417
+ };
2418
+ ZodBoolean = class extends ZodType {
2419
+ _parse(input) {
2420
+ if (this._def.coerce) {
2421
+ input.data = Boolean(input.data);
2422
+ }
2423
+ const parsedType = this._getType(input);
2424
+ if (parsedType !== ZodParsedType.boolean) {
2425
+ const ctx = this._getOrReturnCtx(input);
2426
+ addIssueToContext(ctx, {
2427
+ code: ZodIssueCode.invalid_type,
2428
+ expected: ZodParsedType.boolean,
2429
+ received: ctx.parsedType
2430
+ });
2431
+ return INVALID;
2432
+ }
2433
+ return OK(input.data);
2434
+ }
2435
+ };
2436
+ ZodBoolean.create = (params) => {
2437
+ return new ZodBoolean({
2438
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2439
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2440
+ ...processCreateParams(params)
2441
+ });
2442
+ };
2443
+ ZodDate = class _ZodDate extends ZodType {
2444
+ _parse(input) {
2445
+ if (this._def.coerce) {
2446
+ input.data = new Date(input.data);
2447
+ }
2448
+ const parsedType = this._getType(input);
2449
+ if (parsedType !== ZodParsedType.date) {
2450
+ const ctx2 = this._getOrReturnCtx(input);
2451
+ addIssueToContext(ctx2, {
2452
+ code: ZodIssueCode.invalid_type,
2453
+ expected: ZodParsedType.date,
2454
+ received: ctx2.parsedType
2455
+ });
2456
+ return INVALID;
2457
+ }
2458
+ if (isNaN(input.data.getTime())) {
2459
+ const ctx2 = this._getOrReturnCtx(input);
2460
+ addIssueToContext(ctx2, {
2461
+ code: ZodIssueCode.invalid_date
2462
+ });
2463
+ return INVALID;
2464
+ }
2465
+ const status = new ParseStatus();
2466
+ let ctx = void 0;
2467
+ for (const check of this._def.checks) {
2468
+ if (check.kind === "min") {
2469
+ if (input.data.getTime() < check.value) {
2470
+ ctx = this._getOrReturnCtx(input, ctx);
2471
+ addIssueToContext(ctx, {
2472
+ code: ZodIssueCode.too_small,
2473
+ message: check.message,
2474
+ inclusive: true,
2475
+ exact: false,
2476
+ minimum: check.value,
2477
+ type: "date"
2478
+ });
2479
+ status.dirty();
2480
+ }
2481
+ } else if (check.kind === "max") {
2482
+ if (input.data.getTime() > check.value) {
2483
+ ctx = this._getOrReturnCtx(input, ctx);
2484
+ addIssueToContext(ctx, {
2485
+ code: ZodIssueCode.too_big,
2486
+ message: check.message,
2487
+ inclusive: true,
2488
+ exact: false,
2489
+ maximum: check.value,
2490
+ type: "date"
2491
+ });
2492
+ status.dirty();
2493
+ }
2494
+ } else {
2495
+ util.assertNever(check);
2496
+ }
2497
+ }
2498
+ return {
2499
+ status: status.value,
2500
+ value: new Date(input.data.getTime())
2501
+ };
2502
+ }
2503
+ _addCheck(check) {
2504
+ return new _ZodDate({
2505
+ ...this._def,
2506
+ checks: [...this._def.checks, check]
2507
+ });
2508
+ }
2509
+ min(minDate, message) {
2510
+ return this._addCheck({
2511
+ kind: "min",
2512
+ value: minDate.getTime(),
2513
+ message: errorUtil.toString(message)
2514
+ });
2515
+ }
2516
+ max(maxDate, message) {
2517
+ return this._addCheck({
2518
+ kind: "max",
2519
+ value: maxDate.getTime(),
2520
+ message: errorUtil.toString(message)
2521
+ });
2522
+ }
2523
+ get minDate() {
2524
+ let min = null;
2525
+ for (const ch of this._def.checks) {
2526
+ if (ch.kind === "min") {
2527
+ if (min === null || ch.value > min)
2528
+ min = ch.value;
2529
+ }
2530
+ }
2531
+ return min != null ? new Date(min) : null;
2532
+ }
2533
+ get maxDate() {
2534
+ let max = null;
2535
+ for (const ch of this._def.checks) {
2536
+ if (ch.kind === "max") {
2537
+ if (max === null || ch.value < max)
2538
+ max = ch.value;
2539
+ }
2540
+ }
2541
+ return max != null ? new Date(max) : null;
2542
+ }
2543
+ };
2544
+ ZodDate.create = (params) => {
2545
+ return new ZodDate({
2546
+ checks: [],
2547
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2548
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2549
+ ...processCreateParams(params)
2550
+ });
2551
+ };
2552
+ ZodSymbol = class extends ZodType {
2553
+ _parse(input) {
2554
+ const parsedType = this._getType(input);
2555
+ if (parsedType !== ZodParsedType.symbol) {
2556
+ const ctx = this._getOrReturnCtx(input);
2557
+ addIssueToContext(ctx, {
2558
+ code: ZodIssueCode.invalid_type,
2559
+ expected: ZodParsedType.symbol,
2560
+ received: ctx.parsedType
2561
+ });
2562
+ return INVALID;
2563
+ }
2564
+ return OK(input.data);
2565
+ }
2566
+ };
2567
+ ZodSymbol.create = (params) => {
2568
+ return new ZodSymbol({
2569
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2570
+ ...processCreateParams(params)
2571
+ });
2572
+ };
2573
+ ZodUndefined = class extends ZodType {
2574
+ _parse(input) {
2575
+ const parsedType = this._getType(input);
2576
+ if (parsedType !== ZodParsedType.undefined) {
2577
+ const ctx = this._getOrReturnCtx(input);
2578
+ addIssueToContext(ctx, {
2579
+ code: ZodIssueCode.invalid_type,
2580
+ expected: ZodParsedType.undefined,
2581
+ received: ctx.parsedType
2582
+ });
2583
+ return INVALID;
2584
+ }
2585
+ return OK(input.data);
2586
+ }
2587
+ };
2588
+ ZodUndefined.create = (params) => {
2589
+ return new ZodUndefined({
2590
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2591
+ ...processCreateParams(params)
2592
+ });
2593
+ };
2594
+ ZodNull = class extends ZodType {
2595
+ _parse(input) {
2596
+ const parsedType = this._getType(input);
2597
+ if (parsedType !== ZodParsedType.null) {
2598
+ const ctx = this._getOrReturnCtx(input);
2599
+ addIssueToContext(ctx, {
2600
+ code: ZodIssueCode.invalid_type,
2601
+ expected: ZodParsedType.null,
2602
+ received: ctx.parsedType
2603
+ });
2604
+ return INVALID;
2605
+ }
2606
+ return OK(input.data);
2607
+ }
2608
+ };
2609
+ ZodNull.create = (params) => {
2610
+ return new ZodNull({
2611
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2612
+ ...processCreateParams(params)
2613
+ });
2614
+ };
2615
+ ZodAny = class extends ZodType {
2616
+ constructor() {
2617
+ super(...arguments);
2618
+ this._any = true;
2619
+ }
2620
+ _parse(input) {
2621
+ return OK(input.data);
2622
+ }
2623
+ };
2624
+ ZodAny.create = (params) => {
2625
+ return new ZodAny({
2626
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2627
+ ...processCreateParams(params)
2628
+ });
2629
+ };
2630
+ ZodUnknown = class extends ZodType {
2631
+ constructor() {
2632
+ super(...arguments);
2633
+ this._unknown = true;
2634
+ }
2635
+ _parse(input) {
2636
+ return OK(input.data);
2637
+ }
2638
+ };
2639
+ ZodUnknown.create = (params) => {
2640
+ return new ZodUnknown({
2641
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2642
+ ...processCreateParams(params)
2643
+ });
2644
+ };
2645
+ ZodNever = class extends ZodType {
2646
+ _parse(input) {
2647
+ const ctx = this._getOrReturnCtx(input);
2648
+ addIssueToContext(ctx, {
2649
+ code: ZodIssueCode.invalid_type,
2650
+ expected: ZodParsedType.never,
2651
+ received: ctx.parsedType
2652
+ });
2653
+ return INVALID;
2654
+ }
2655
+ };
2656
+ ZodNever.create = (params) => {
2657
+ return new ZodNever({
2658
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2659
+ ...processCreateParams(params)
2660
+ });
2661
+ };
2662
+ ZodVoid = class extends ZodType {
2663
+ _parse(input) {
2664
+ const parsedType = this._getType(input);
2665
+ if (parsedType !== ZodParsedType.undefined) {
2666
+ const ctx = this._getOrReturnCtx(input);
2667
+ addIssueToContext(ctx, {
2668
+ code: ZodIssueCode.invalid_type,
2669
+ expected: ZodParsedType.void,
2670
+ received: ctx.parsedType
2671
+ });
2672
+ return INVALID;
2673
+ }
2674
+ return OK(input.data);
2675
+ }
2676
+ };
2677
+ ZodVoid.create = (params) => {
2678
+ return new ZodVoid({
2679
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2680
+ ...processCreateParams(params)
2681
+ });
2682
+ };
2683
+ ZodArray = class _ZodArray extends ZodType {
2684
+ _parse(input) {
2685
+ const { ctx, status } = this._processInputParams(input);
2686
+ const def = this._def;
2687
+ if (ctx.parsedType !== ZodParsedType.array) {
2688
+ addIssueToContext(ctx, {
2689
+ code: ZodIssueCode.invalid_type,
2690
+ expected: ZodParsedType.array,
2691
+ received: ctx.parsedType
2692
+ });
2693
+ return INVALID;
2694
+ }
2695
+ if (def.exactLength !== null) {
2696
+ const tooBig = ctx.data.length > def.exactLength.value;
2697
+ const tooSmall = ctx.data.length < def.exactLength.value;
2698
+ if (tooBig || tooSmall) {
2699
+ addIssueToContext(ctx, {
2700
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2701
+ minimum: tooSmall ? def.exactLength.value : void 0,
2702
+ maximum: tooBig ? def.exactLength.value : void 0,
2703
+ type: "array",
2704
+ inclusive: true,
2705
+ exact: true,
2706
+ message: def.exactLength.message
2707
+ });
2708
+ status.dirty();
2709
+ }
2710
+ }
2711
+ if (def.minLength !== null) {
2712
+ if (ctx.data.length < def.minLength.value) {
2713
+ addIssueToContext(ctx, {
2714
+ code: ZodIssueCode.too_small,
2715
+ minimum: def.minLength.value,
2716
+ type: "array",
2717
+ inclusive: true,
2718
+ exact: false,
2719
+ message: def.minLength.message
2720
+ });
2721
+ status.dirty();
2722
+ }
2723
+ }
2724
+ if (def.maxLength !== null) {
2725
+ if (ctx.data.length > def.maxLength.value) {
2726
+ addIssueToContext(ctx, {
2727
+ code: ZodIssueCode.too_big,
2728
+ maximum: def.maxLength.value,
2729
+ type: "array",
2730
+ inclusive: true,
2731
+ exact: false,
2732
+ message: def.maxLength.message
2733
+ });
2734
+ status.dirty();
2735
+ }
2736
+ }
2737
+ if (ctx.common.async) {
2738
+ return Promise.all(ctx.data.map((item, i) => {
2739
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2740
+ })).then((result2) => {
2741
+ return ParseStatus.mergeArray(status, result2);
2742
+ });
2743
+ }
2744
+ const result = ctx.data.map((item, i) => {
2745
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2746
+ });
2747
+ return ParseStatus.mergeArray(status, result);
2748
+ }
2749
+ get element() {
2750
+ return this._def.type;
2751
+ }
2752
+ min(minLength, message) {
2753
+ return new _ZodArray({
2754
+ ...this._def,
2755
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2756
+ });
2757
+ }
2758
+ max(maxLength, message) {
2759
+ return new _ZodArray({
2760
+ ...this._def,
2761
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2762
+ });
2763
+ }
2764
+ length(len, message) {
2765
+ return new _ZodArray({
2766
+ ...this._def,
2767
+ exactLength: { value: len, message: errorUtil.toString(message) }
2768
+ });
2769
+ }
2770
+ nonempty(message) {
2771
+ return this.min(1, message);
2772
+ }
2773
+ };
2774
+ ZodArray.create = (schema3, params) => {
2775
+ return new ZodArray({
2776
+ type: schema3,
2777
+ minLength: null,
2778
+ maxLength: null,
2779
+ exactLength: null,
2780
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2781
+ ...processCreateParams(params)
2782
+ });
2783
+ };
2784
+ (function(objectUtil2) {
2785
+ objectUtil2.mergeShapes = (first, second) => {
2786
+ return {
2787
+ ...first,
2788
+ ...second
2789
+ // second overwrites first
2790
+ };
2791
+ };
2792
+ })(objectUtil || (objectUtil = {}));
2793
+ AugmentFactory = (def) => (augmentation) => {
2794
+ return new ZodObject({
2795
+ ...def,
2796
+ shape: () => ({
2797
+ ...def.shape(),
2798
+ ...augmentation
2799
+ })
2800
+ });
2801
+ };
2802
+ ZodObject = class _ZodObject extends ZodType {
2803
+ constructor() {
2804
+ super(...arguments);
2805
+ this._cached = null;
2806
+ this.nonstrict = this.passthrough;
2807
+ this.augment = AugmentFactory(this._def);
2808
+ this.extend = AugmentFactory(this._def);
2809
+ }
2810
+ _getCached() {
2811
+ if (this._cached !== null)
2812
+ return this._cached;
2813
+ const shape = this._def.shape();
2814
+ const keys = util.objectKeys(shape);
2815
+ return this._cached = { shape, keys };
2816
+ }
2817
+ _parse(input) {
2818
+ const parsedType = this._getType(input);
2819
+ if (parsedType !== ZodParsedType.object) {
2820
+ const ctx2 = this._getOrReturnCtx(input);
2821
+ addIssueToContext(ctx2, {
2822
+ code: ZodIssueCode.invalid_type,
2823
+ expected: ZodParsedType.object,
2824
+ received: ctx2.parsedType
2825
+ });
2826
+ return INVALID;
2827
+ }
2828
+ const { status, ctx } = this._processInputParams(input);
2829
+ const { shape, keys: shapeKeys } = this._getCached();
2830
+ const extraKeys = [];
2831
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2832
+ for (const key in ctx.data) {
2833
+ if (!shapeKeys.includes(key)) {
2834
+ extraKeys.push(key);
2835
+ }
2836
+ }
2837
+ }
2838
+ const pairs = [];
2839
+ for (const key of shapeKeys) {
2840
+ const keyValidator = shape[key];
2841
+ const value = ctx.data[key];
2842
+ pairs.push({
2843
+ key: { status: "valid", value: key },
2844
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2845
+ alwaysSet: key in ctx.data
2846
+ });
2847
+ }
2848
+ if (this._def.catchall instanceof ZodNever) {
2849
+ const unknownKeys = this._def.unknownKeys;
2850
+ if (unknownKeys === "passthrough") {
2851
+ for (const key of extraKeys) {
2852
+ pairs.push({
2853
+ key: { status: "valid", value: key },
2854
+ value: { status: "valid", value: ctx.data[key] }
2855
+ });
2856
+ }
2857
+ } else if (unknownKeys === "strict") {
2858
+ if (extraKeys.length > 0) {
2859
+ addIssueToContext(ctx, {
2860
+ code: ZodIssueCode.unrecognized_keys,
2861
+ keys: extraKeys
2862
+ });
2863
+ status.dirty();
2864
+ }
2865
+ } else if (unknownKeys === "strip")
2866
+ ;
2867
+ else {
2868
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2869
+ }
2870
+ } else {
2871
+ const catchall = this._def.catchall;
2872
+ for (const key of extraKeys) {
2873
+ const value = ctx.data[key];
2874
+ pairs.push({
2875
+ key: { status: "valid", value: key },
2876
+ value: catchall._parse(
2877
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2878
+ //, ctx.child(key), value, getParsedType(value)
2879
+ ),
2880
+ alwaysSet: key in ctx.data
2881
+ });
2882
+ }
2883
+ }
2884
+ if (ctx.common.async) {
2885
+ return Promise.resolve().then(async () => {
2886
+ const syncPairs = [];
2887
+ for (const pair of pairs) {
2888
+ const key = await pair.key;
2889
+ syncPairs.push({
2890
+ key,
2891
+ value: await pair.value,
2892
+ alwaysSet: pair.alwaysSet
2893
+ });
2894
+ }
2895
+ return syncPairs;
2896
+ }).then((syncPairs) => {
2897
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2898
+ });
2899
+ } else {
2900
+ return ParseStatus.mergeObjectSync(status, pairs);
2901
+ }
2902
+ }
2903
+ get shape() {
2904
+ return this._def.shape();
2905
+ }
2906
+ strict(message) {
2907
+ errorUtil.errToObj;
2908
+ return new _ZodObject({
2909
+ ...this._def,
2910
+ unknownKeys: "strict",
2911
+ ...message !== void 0 ? {
2912
+ errorMap: (issue, ctx) => {
2913
+ var _a, _b, _c, _d;
2914
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2915
+ if (issue.code === "unrecognized_keys")
2916
+ return {
2917
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
2918
+ };
2919
+ return {
2920
+ message: defaultError
2921
+ };
2922
+ }
2923
+ } : {}
2924
+ });
2925
+ }
2926
+ strip() {
2927
+ return new _ZodObject({
2928
+ ...this._def,
2929
+ unknownKeys: "strip"
2930
+ });
2931
+ }
2932
+ passthrough() {
2933
+ return new _ZodObject({
2934
+ ...this._def,
2935
+ unknownKeys: "passthrough"
2936
+ });
2937
+ }
2938
+ setKey(key, schema3) {
2939
+ return this.augment({ [key]: schema3 });
2940
+ }
2941
+ /**
2942
+ * Prior to zod@1.0.12 there was a bug in the
2943
+ * inferred type of merged objects. Please
2944
+ * upgrade if you are experiencing issues.
2945
+ */
2946
+ merge(merging) {
2947
+ const merged = new _ZodObject({
2948
+ unknownKeys: merging._def.unknownKeys,
2949
+ catchall: merging._def.catchall,
2950
+ shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2951
+ typeName: ZodFirstPartyTypeKind.ZodObject
2952
+ });
2953
+ return merged;
2954
+ }
2955
+ catchall(index4) {
2956
+ return new _ZodObject({
2957
+ ...this._def,
2958
+ catchall: index4
2959
+ });
2960
+ }
2961
+ pick(mask) {
2962
+ const shape = {};
2963
+ util.objectKeys(mask).map((key) => {
2964
+ if (this.shape[key])
2965
+ shape[key] = this.shape[key];
2966
+ });
2967
+ return new _ZodObject({
2968
+ ...this._def,
2969
+ shape: () => shape
2970
+ });
2971
+ }
2972
+ omit(mask) {
2973
+ const shape = {};
2974
+ util.objectKeys(this.shape).map((key) => {
2975
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2976
+ shape[key] = this.shape[key];
2977
+ }
2978
+ });
2979
+ return new _ZodObject({
2980
+ ...this._def,
2981
+ shape: () => shape
2982
+ });
2983
+ }
2984
+ deepPartial() {
2985
+ return deepPartialify(this);
2986
+ }
2987
+ partial(mask) {
2988
+ const newShape = {};
2989
+ if (mask) {
2990
+ util.objectKeys(this.shape).map((key) => {
2991
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2992
+ newShape[key] = this.shape[key];
2993
+ } else {
2994
+ newShape[key] = this.shape[key].optional();
2995
+ }
2996
+ });
2997
+ return new _ZodObject({
2998
+ ...this._def,
2999
+ shape: () => newShape
3000
+ });
3001
+ } else {
3002
+ for (const key in this.shape) {
3003
+ const fieldSchema = this.shape[key];
3004
+ newShape[key] = fieldSchema.optional();
3005
+ }
3006
+ }
3007
+ return new _ZodObject({
3008
+ ...this._def,
3009
+ shape: () => newShape
3010
+ });
3011
+ }
3012
+ required(mask) {
3013
+ const newShape = {};
3014
+ if (mask) {
3015
+ util.objectKeys(this.shape).map((key) => {
3016
+ if (util.objectKeys(mask).indexOf(key) === -1) {
3017
+ newShape[key] = this.shape[key];
3018
+ } else {
3019
+ const fieldSchema = this.shape[key];
3020
+ let newField = fieldSchema;
3021
+ while (newField instanceof ZodOptional) {
3022
+ newField = newField._def.innerType;
3023
+ }
3024
+ newShape[key] = newField;
3025
+ }
3026
+ });
3027
+ } else {
3028
+ for (const key in this.shape) {
3029
+ const fieldSchema = this.shape[key];
3030
+ let newField = fieldSchema;
3031
+ while (newField instanceof ZodOptional) {
3032
+ newField = newField._def.innerType;
3033
+ }
3034
+ newShape[key] = newField;
3035
+ }
3036
+ }
3037
+ return new _ZodObject({
3038
+ ...this._def,
3039
+ shape: () => newShape
3040
+ });
3041
+ }
3042
+ keyof() {
3043
+ return createZodEnum(util.objectKeys(this.shape));
3044
+ }
3045
+ };
3046
+ ZodObject.create = (shape, params) => {
3047
+ return new ZodObject({
3048
+ shape: () => shape,
3049
+ unknownKeys: "strip",
3050
+ catchall: ZodNever.create(),
3051
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3052
+ ...processCreateParams(params)
3053
+ });
3054
+ };
3055
+ ZodObject.strictCreate = (shape, params) => {
3056
+ return new ZodObject({
3057
+ shape: () => shape,
3058
+ unknownKeys: "strict",
3059
+ catchall: ZodNever.create(),
3060
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3061
+ ...processCreateParams(params)
3062
+ });
3063
+ };
3064
+ ZodObject.lazycreate = (shape, params) => {
3065
+ return new ZodObject({
3066
+ shape,
3067
+ unknownKeys: "strip",
3068
+ catchall: ZodNever.create(),
3069
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3070
+ ...processCreateParams(params)
3071
+ });
3072
+ };
3073
+ ZodUnion = class extends ZodType {
3074
+ _parse(input) {
3075
+ const { ctx } = this._processInputParams(input);
3076
+ const options = this._def.options;
3077
+ function handleResults(results) {
3078
+ for (const result of results) {
3079
+ if (result.result.status === "valid") {
3080
+ return result.result;
3081
+ }
3082
+ }
3083
+ for (const result of results) {
3084
+ if (result.result.status === "dirty") {
3085
+ ctx.common.issues.push(...result.ctx.common.issues);
3086
+ return result.result;
3087
+ }
3088
+ }
3089
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3090
+ addIssueToContext(ctx, {
3091
+ code: ZodIssueCode.invalid_union,
3092
+ unionErrors
3093
+ });
3094
+ return INVALID;
3095
+ }
3096
+ if (ctx.common.async) {
3097
+ return Promise.all(options.map(async (option) => {
3098
+ const childCtx = {
3099
+ ...ctx,
3100
+ common: {
3101
+ ...ctx.common,
3102
+ issues: []
3103
+ },
3104
+ parent: null
3105
+ };
3106
+ return {
3107
+ result: await option._parseAsync({
3108
+ data: ctx.data,
3109
+ path: ctx.path,
3110
+ parent: childCtx
3111
+ }),
3112
+ ctx: childCtx
3113
+ };
3114
+ })).then(handleResults);
3115
+ } else {
3116
+ let dirty = void 0;
3117
+ const issues = [];
3118
+ for (const option of options) {
3119
+ const childCtx = {
3120
+ ...ctx,
3121
+ common: {
3122
+ ...ctx.common,
3123
+ issues: []
3124
+ },
3125
+ parent: null
3126
+ };
3127
+ const result = option._parseSync({
3128
+ data: ctx.data,
3129
+ path: ctx.path,
3130
+ parent: childCtx
3131
+ });
3132
+ if (result.status === "valid") {
3133
+ return result;
3134
+ } else if (result.status === "dirty" && !dirty) {
3135
+ dirty = { result, ctx: childCtx };
3136
+ }
3137
+ if (childCtx.common.issues.length) {
3138
+ issues.push(childCtx.common.issues);
3139
+ }
3140
+ }
3141
+ if (dirty) {
3142
+ ctx.common.issues.push(...dirty.ctx.common.issues);
3143
+ return dirty.result;
3144
+ }
3145
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
3146
+ addIssueToContext(ctx, {
3147
+ code: ZodIssueCode.invalid_union,
3148
+ unionErrors
3149
+ });
3150
+ return INVALID;
3151
+ }
3152
+ }
3153
+ get options() {
3154
+ return this._def.options;
3155
+ }
3156
+ };
3157
+ ZodUnion.create = (types, params) => {
3158
+ return new ZodUnion({
3159
+ options: types,
3160
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
3161
+ ...processCreateParams(params)
3162
+ });
3163
+ };
3164
+ getDiscriminator = (type) => {
3165
+ if (type instanceof ZodLazy) {
3166
+ return getDiscriminator(type.schema);
3167
+ } else if (type instanceof ZodEffects) {
3168
+ return getDiscriminator(type.innerType());
3169
+ } else if (type instanceof ZodLiteral) {
3170
+ return [type.value];
3171
+ } else if (type instanceof ZodEnum) {
3172
+ return type.options;
3173
+ } else if (type instanceof ZodNativeEnum) {
3174
+ return Object.keys(type.enum);
3175
+ } else if (type instanceof ZodDefault) {
3176
+ return getDiscriminator(type._def.innerType);
3177
+ } else if (type instanceof ZodUndefined) {
3178
+ return [void 0];
3179
+ } else if (type instanceof ZodNull) {
3180
+ return [null];
3181
+ } else {
3182
+ return null;
3183
+ }
3184
+ };
3185
+ ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3186
+ _parse(input) {
3187
+ const { ctx } = this._processInputParams(input);
3188
+ if (ctx.parsedType !== ZodParsedType.object) {
3189
+ addIssueToContext(ctx, {
3190
+ code: ZodIssueCode.invalid_type,
3191
+ expected: ZodParsedType.object,
3192
+ received: ctx.parsedType
3193
+ });
3194
+ return INVALID;
3195
+ }
3196
+ const discriminator = this.discriminator;
3197
+ const discriminatorValue = ctx.data[discriminator];
3198
+ const option = this.optionsMap.get(discriminatorValue);
3199
+ if (!option) {
3200
+ addIssueToContext(ctx, {
3201
+ code: ZodIssueCode.invalid_union_discriminator,
3202
+ options: Array.from(this.optionsMap.keys()),
3203
+ path: [discriminator]
3204
+ });
3205
+ return INVALID;
3206
+ }
3207
+ if (ctx.common.async) {
3208
+ return option._parseAsync({
3209
+ data: ctx.data,
3210
+ path: ctx.path,
3211
+ parent: ctx
3212
+ });
3213
+ } else {
3214
+ return option._parseSync({
3215
+ data: ctx.data,
3216
+ path: ctx.path,
3217
+ parent: ctx
3218
+ });
3219
+ }
3220
+ }
3221
+ get discriminator() {
3222
+ return this._def.discriminator;
3223
+ }
3224
+ get options() {
3225
+ return this._def.options;
3226
+ }
3227
+ get optionsMap() {
3228
+ return this._def.optionsMap;
3229
+ }
3230
+ /**
3231
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3232
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3233
+ * have a different value for each object in the union.
3234
+ * @param discriminator the name of the discriminator property
3235
+ * @param types an array of object schemas
3236
+ * @param params
3237
+ */
3238
+ static create(discriminator, options, params) {
3239
+ const optionsMap = /* @__PURE__ */ new Map();
3240
+ for (const type of options) {
3241
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3242
+ if (!discriminatorValues) {
3243
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3244
+ }
3245
+ for (const value of discriminatorValues) {
3246
+ if (optionsMap.has(value)) {
3247
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3248
+ }
3249
+ optionsMap.set(value, type);
3250
+ }
3251
+ }
3252
+ return new _ZodDiscriminatedUnion({
3253
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3254
+ discriminator,
3255
+ options,
3256
+ optionsMap,
3257
+ ...processCreateParams(params)
3258
+ });
3259
+ }
3260
+ };
3261
+ ZodIntersection = class extends ZodType {
3262
+ _parse(input) {
3263
+ const { status, ctx } = this._processInputParams(input);
3264
+ const handleParsed = (parsedLeft, parsedRight) => {
3265
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3266
+ return INVALID;
3267
+ }
3268
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3269
+ if (!merged.valid) {
3270
+ addIssueToContext(ctx, {
3271
+ code: ZodIssueCode.invalid_intersection_types
3272
+ });
3273
+ return INVALID;
3274
+ }
3275
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3276
+ status.dirty();
3277
+ }
3278
+ return { status: status.value, value: merged.data };
3279
+ };
3280
+ if (ctx.common.async) {
3281
+ return Promise.all([
3282
+ this._def.left._parseAsync({
3283
+ data: ctx.data,
3284
+ path: ctx.path,
3285
+ parent: ctx
3286
+ }),
3287
+ this._def.right._parseAsync({
3288
+ data: ctx.data,
3289
+ path: ctx.path,
3290
+ parent: ctx
3291
+ })
3292
+ ]).then(([left, right]) => handleParsed(left, right));
3293
+ } else {
3294
+ return handleParsed(this._def.left._parseSync({
3295
+ data: ctx.data,
3296
+ path: ctx.path,
3297
+ parent: ctx
3298
+ }), this._def.right._parseSync({
3299
+ data: ctx.data,
3300
+ path: ctx.path,
3301
+ parent: ctx
3302
+ }));
3303
+ }
3304
+ }
3305
+ };
3306
+ ZodIntersection.create = (left, right, params) => {
3307
+ return new ZodIntersection({
3308
+ left,
3309
+ right,
3310
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3311
+ ...processCreateParams(params)
3312
+ });
3313
+ };
3314
+ ZodTuple = class _ZodTuple extends ZodType {
3315
+ _parse(input) {
3316
+ const { status, ctx } = this._processInputParams(input);
3317
+ if (ctx.parsedType !== ZodParsedType.array) {
3318
+ addIssueToContext(ctx, {
3319
+ code: ZodIssueCode.invalid_type,
3320
+ expected: ZodParsedType.array,
3321
+ received: ctx.parsedType
3322
+ });
3323
+ return INVALID;
3324
+ }
3325
+ if (ctx.data.length < this._def.items.length) {
3326
+ addIssueToContext(ctx, {
3327
+ code: ZodIssueCode.too_small,
3328
+ minimum: this._def.items.length,
3329
+ inclusive: true,
3330
+ exact: false,
3331
+ type: "array"
3332
+ });
3333
+ return INVALID;
3334
+ }
3335
+ const rest = this._def.rest;
3336
+ if (!rest && ctx.data.length > this._def.items.length) {
3337
+ addIssueToContext(ctx, {
3338
+ code: ZodIssueCode.too_big,
3339
+ maximum: this._def.items.length,
3340
+ inclusive: true,
3341
+ exact: false,
3342
+ type: "array"
3343
+ });
3344
+ status.dirty();
3345
+ }
3346
+ const items = ctx.data.map((item, itemIndex) => {
3347
+ const schema3 = this._def.items[itemIndex] || this._def.rest;
3348
+ if (!schema3)
3349
+ return null;
3350
+ return schema3._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3351
+ }).filter((x) => !!x);
3352
+ if (ctx.common.async) {
3353
+ return Promise.all(items).then((results) => {
3354
+ return ParseStatus.mergeArray(status, results);
3355
+ });
3356
+ } else {
3357
+ return ParseStatus.mergeArray(status, items);
3358
+ }
3359
+ }
3360
+ get items() {
3361
+ return this._def.items;
3362
+ }
3363
+ rest(rest) {
3364
+ return new _ZodTuple({
3365
+ ...this._def,
3366
+ rest
3367
+ });
3368
+ }
3369
+ };
3370
+ ZodTuple.create = (schemas, params) => {
3371
+ if (!Array.isArray(schemas)) {
3372
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3373
+ }
3374
+ return new ZodTuple({
3375
+ items: schemas,
3376
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3377
+ rest: null,
3378
+ ...processCreateParams(params)
3379
+ });
3380
+ };
3381
+ ZodRecord = class _ZodRecord extends ZodType {
3382
+ get keySchema() {
3383
+ return this._def.keyType;
3384
+ }
3385
+ get valueSchema() {
3386
+ return this._def.valueType;
3387
+ }
3388
+ _parse(input) {
3389
+ const { status, ctx } = this._processInputParams(input);
3390
+ if (ctx.parsedType !== ZodParsedType.object) {
3391
+ addIssueToContext(ctx, {
3392
+ code: ZodIssueCode.invalid_type,
3393
+ expected: ZodParsedType.object,
3394
+ received: ctx.parsedType
3395
+ });
3396
+ return INVALID;
3397
+ }
3398
+ const pairs = [];
3399
+ const keyType = this._def.keyType;
3400
+ const valueType = this._def.valueType;
3401
+ for (const key in ctx.data) {
3402
+ pairs.push({
3403
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3404
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3405
+ });
3406
+ }
3407
+ if (ctx.common.async) {
3408
+ return ParseStatus.mergeObjectAsync(status, pairs);
3409
+ } else {
3410
+ return ParseStatus.mergeObjectSync(status, pairs);
3411
+ }
3412
+ }
3413
+ get element() {
3414
+ return this._def.valueType;
3415
+ }
3416
+ static create(first, second, third) {
3417
+ if (second instanceof ZodType) {
3418
+ return new _ZodRecord({
3419
+ keyType: first,
3420
+ valueType: second,
3421
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3422
+ ...processCreateParams(third)
3423
+ });
3424
+ }
3425
+ return new _ZodRecord({
3426
+ keyType: ZodString.create(),
3427
+ valueType: first,
3428
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3429
+ ...processCreateParams(second)
3430
+ });
3431
+ }
3432
+ };
3433
+ ZodMap = class extends ZodType {
3434
+ _parse(input) {
3435
+ const { status, ctx } = this._processInputParams(input);
3436
+ if (ctx.parsedType !== ZodParsedType.map) {
3437
+ addIssueToContext(ctx, {
3438
+ code: ZodIssueCode.invalid_type,
3439
+ expected: ZodParsedType.map,
3440
+ received: ctx.parsedType
3441
+ });
3442
+ return INVALID;
3443
+ }
3444
+ const keyType = this._def.keyType;
3445
+ const valueType = this._def.valueType;
3446
+ const pairs = [...ctx.data.entries()].map(([key, value], index4) => {
3447
+ return {
3448
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index4, "key"])),
3449
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index4, "value"]))
3450
+ };
3451
+ });
3452
+ if (ctx.common.async) {
3453
+ const finalMap = /* @__PURE__ */ new Map();
3454
+ return Promise.resolve().then(async () => {
3455
+ for (const pair of pairs) {
3456
+ const key = await pair.key;
3457
+ const value = await pair.value;
3458
+ if (key.status === "aborted" || value.status === "aborted") {
3459
+ return INVALID;
3460
+ }
3461
+ if (key.status === "dirty" || value.status === "dirty") {
3462
+ status.dirty();
3463
+ }
3464
+ finalMap.set(key.value, value.value);
3465
+ }
3466
+ return { status: status.value, value: finalMap };
3467
+ });
3468
+ } else {
3469
+ const finalMap = /* @__PURE__ */ new Map();
3470
+ for (const pair of pairs) {
3471
+ const key = pair.key;
3472
+ const value = pair.value;
3473
+ if (key.status === "aborted" || value.status === "aborted") {
3474
+ return INVALID;
3475
+ }
3476
+ if (key.status === "dirty" || value.status === "dirty") {
3477
+ status.dirty();
3478
+ }
3479
+ finalMap.set(key.value, value.value);
3480
+ }
3481
+ return { status: status.value, value: finalMap };
3482
+ }
3483
+ }
3484
+ };
3485
+ ZodMap.create = (keyType, valueType, params) => {
3486
+ return new ZodMap({
3487
+ valueType,
3488
+ keyType,
3489
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3490
+ ...processCreateParams(params)
3491
+ });
3492
+ };
3493
+ ZodSet = class _ZodSet extends ZodType {
3494
+ _parse(input) {
3495
+ const { status, ctx } = this._processInputParams(input);
3496
+ if (ctx.parsedType !== ZodParsedType.set) {
3497
+ addIssueToContext(ctx, {
3498
+ code: ZodIssueCode.invalid_type,
3499
+ expected: ZodParsedType.set,
3500
+ received: ctx.parsedType
3501
+ });
3502
+ return INVALID;
3503
+ }
3504
+ const def = this._def;
3505
+ if (def.minSize !== null) {
3506
+ if (ctx.data.size < def.minSize.value) {
3507
+ addIssueToContext(ctx, {
3508
+ code: ZodIssueCode.too_small,
3509
+ minimum: def.minSize.value,
3510
+ type: "set",
3511
+ inclusive: true,
3512
+ exact: false,
3513
+ message: def.minSize.message
3514
+ });
3515
+ status.dirty();
3516
+ }
3517
+ }
3518
+ if (def.maxSize !== null) {
3519
+ if (ctx.data.size > def.maxSize.value) {
3520
+ addIssueToContext(ctx, {
3521
+ code: ZodIssueCode.too_big,
3522
+ maximum: def.maxSize.value,
3523
+ type: "set",
3524
+ inclusive: true,
3525
+ exact: false,
3526
+ message: def.maxSize.message
3527
+ });
3528
+ status.dirty();
3529
+ }
3530
+ }
3531
+ const valueType = this._def.valueType;
3532
+ function finalizeSet(elements2) {
3533
+ const parsedSet = /* @__PURE__ */ new Set();
3534
+ for (const element of elements2) {
3535
+ if (element.status === "aborted")
3536
+ return INVALID;
3537
+ if (element.status === "dirty")
3538
+ status.dirty();
3539
+ parsedSet.add(element.value);
3540
+ }
3541
+ return { status: status.value, value: parsedSet };
3542
+ }
3543
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3544
+ if (ctx.common.async) {
3545
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3546
+ } else {
3547
+ return finalizeSet(elements);
3548
+ }
3549
+ }
3550
+ min(minSize, message) {
3551
+ return new _ZodSet({
3552
+ ...this._def,
3553
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3554
+ });
3555
+ }
3556
+ max(maxSize, message) {
3557
+ return new _ZodSet({
3558
+ ...this._def,
3559
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3560
+ });
3561
+ }
3562
+ size(size, message) {
3563
+ return this.min(size, message).max(size, message);
3564
+ }
3565
+ nonempty(message) {
3566
+ return this.min(1, message);
3567
+ }
3568
+ };
3569
+ ZodSet.create = (valueType, params) => {
3570
+ return new ZodSet({
3571
+ valueType,
3572
+ minSize: null,
3573
+ maxSize: null,
3574
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3575
+ ...processCreateParams(params)
3576
+ });
3577
+ };
3578
+ ZodFunction = class _ZodFunction extends ZodType {
3579
+ constructor() {
3580
+ super(...arguments);
3581
+ this.validate = this.implement;
3582
+ }
3583
+ _parse(input) {
3584
+ const { ctx } = this._processInputParams(input);
3585
+ if (ctx.parsedType !== ZodParsedType.function) {
3586
+ addIssueToContext(ctx, {
3587
+ code: ZodIssueCode.invalid_type,
3588
+ expected: ZodParsedType.function,
3589
+ received: ctx.parsedType
3590
+ });
3591
+ return INVALID;
3592
+ }
3593
+ function makeArgsIssue(args, error2) {
3594
+ return makeIssue({
3595
+ data: args,
3596
+ path: ctx.path,
3597
+ errorMaps: [
3598
+ ctx.common.contextualErrorMap,
3599
+ ctx.schemaErrorMap,
3600
+ getErrorMap(),
3601
+ errorMap
3602
+ ].filter((x) => !!x),
3603
+ issueData: {
3604
+ code: ZodIssueCode.invalid_arguments,
3605
+ argumentsError: error2
3606
+ }
3607
+ });
3608
+ }
3609
+ function makeReturnsIssue(returns, error2) {
3610
+ return makeIssue({
3611
+ data: returns,
3612
+ path: ctx.path,
3613
+ errorMaps: [
3614
+ ctx.common.contextualErrorMap,
3615
+ ctx.schemaErrorMap,
3616
+ getErrorMap(),
3617
+ errorMap
3618
+ ].filter((x) => !!x),
3619
+ issueData: {
3620
+ code: ZodIssueCode.invalid_return_type,
3621
+ returnTypeError: error2
3622
+ }
3623
+ });
3624
+ }
3625
+ const params = { errorMap: ctx.common.contextualErrorMap };
3626
+ const fn = ctx.data;
3627
+ if (this._def.returns instanceof ZodPromise) {
3628
+ return OK(async (...args) => {
3629
+ const error2 = new ZodError([]);
3630
+ const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3631
+ error2.addIssue(makeArgsIssue(args, e));
3632
+ throw error2;
3633
+ });
3634
+ const result = await fn(...parsedArgs);
3635
+ const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3636
+ error2.addIssue(makeReturnsIssue(result, e));
3637
+ throw error2;
3638
+ });
3639
+ return parsedReturns;
3640
+ });
3641
+ } else {
3642
+ return OK((...args) => {
3643
+ const parsedArgs = this._def.args.safeParse(args, params);
3644
+ if (!parsedArgs.success) {
3645
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3646
+ }
3647
+ const result = fn(...parsedArgs.data);
3648
+ const parsedReturns = this._def.returns.safeParse(result, params);
3649
+ if (!parsedReturns.success) {
3650
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3651
+ }
3652
+ return parsedReturns.data;
3653
+ });
3654
+ }
3655
+ }
3656
+ parameters() {
3657
+ return this._def.args;
3658
+ }
3659
+ returnType() {
3660
+ return this._def.returns;
3661
+ }
3662
+ args(...items) {
3663
+ return new _ZodFunction({
3664
+ ...this._def,
3665
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3666
+ });
3667
+ }
3668
+ returns(returnType) {
3669
+ return new _ZodFunction({
3670
+ ...this._def,
3671
+ returns: returnType
3672
+ });
3673
+ }
3674
+ implement(func) {
3675
+ const validatedFunc = this.parse(func);
3676
+ return validatedFunc;
3677
+ }
3678
+ strictImplement(func) {
3679
+ const validatedFunc = this.parse(func);
3680
+ return validatedFunc;
3681
+ }
3682
+ static create(args, returns, params) {
3683
+ return new _ZodFunction({
3684
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3685
+ returns: returns || ZodUnknown.create(),
3686
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3687
+ ...processCreateParams(params)
3688
+ });
3689
+ }
3690
+ };
3691
+ ZodLazy = class extends ZodType {
3692
+ get schema() {
3693
+ return this._def.getter();
3694
+ }
3695
+ _parse(input) {
3696
+ const { ctx } = this._processInputParams(input);
3697
+ const lazySchema = this._def.getter();
3698
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3699
+ }
3700
+ };
3701
+ ZodLazy.create = (getter, params) => {
3702
+ return new ZodLazy({
3703
+ getter,
3704
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3705
+ ...processCreateParams(params)
3706
+ });
3707
+ };
3708
+ ZodLiteral = class extends ZodType {
3709
+ _parse(input) {
3710
+ if (input.data !== this._def.value) {
3711
+ const ctx = this._getOrReturnCtx(input);
3712
+ addIssueToContext(ctx, {
3713
+ code: ZodIssueCode.invalid_literal,
3714
+ expected: this._def.value
3715
+ });
3716
+ return INVALID;
3717
+ }
3718
+ return { status: "valid", value: input.data };
3719
+ }
3720
+ get value() {
3721
+ return this._def.value;
3722
+ }
3723
+ };
3724
+ ZodLiteral.create = (value, params) => {
3725
+ return new ZodLiteral({
3726
+ value,
3727
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3728
+ ...processCreateParams(params)
3729
+ });
3730
+ };
3731
+ ZodEnum = class extends ZodType {
3732
+ _parse(input) {
3733
+ if (typeof input.data !== "string") {
3734
+ const ctx = this._getOrReturnCtx(input);
3735
+ const expectedValues = this._def.values;
3736
+ addIssueToContext(ctx, {
3737
+ expected: util.joinValues(expectedValues),
3738
+ received: ctx.parsedType,
3739
+ code: ZodIssueCode.invalid_type
3740
+ });
3741
+ return INVALID;
3742
+ }
3743
+ if (this._def.values.indexOf(input.data) === -1) {
3744
+ const ctx = this._getOrReturnCtx(input);
3745
+ const expectedValues = this._def.values;
3746
+ addIssueToContext(ctx, {
3747
+ received: ctx.data,
3748
+ code: ZodIssueCode.invalid_enum_value,
3749
+ options: expectedValues
3750
+ });
3751
+ return INVALID;
3752
+ }
3753
+ return OK(input.data);
3754
+ }
3755
+ get options() {
3756
+ return this._def.values;
3757
+ }
3758
+ get enum() {
3759
+ const enumValues = {};
3760
+ for (const val of this._def.values) {
3761
+ enumValues[val] = val;
3762
+ }
3763
+ return enumValues;
3764
+ }
3765
+ get Values() {
3766
+ const enumValues = {};
3767
+ for (const val of this._def.values) {
3768
+ enumValues[val] = val;
3769
+ }
3770
+ return enumValues;
3771
+ }
3772
+ get Enum() {
3773
+ const enumValues = {};
3774
+ for (const val of this._def.values) {
3775
+ enumValues[val] = val;
3776
+ }
3777
+ return enumValues;
3778
+ }
3779
+ };
3780
+ ZodEnum.create = createZodEnum;
3781
+ ZodNativeEnum = class extends ZodType {
3782
+ _parse(input) {
3783
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3784
+ const ctx = this._getOrReturnCtx(input);
3785
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3786
+ const expectedValues = util.objectValues(nativeEnumValues);
3787
+ addIssueToContext(ctx, {
3788
+ expected: util.joinValues(expectedValues),
3789
+ received: ctx.parsedType,
3790
+ code: ZodIssueCode.invalid_type
3791
+ });
3792
+ return INVALID;
3793
+ }
3794
+ if (nativeEnumValues.indexOf(input.data) === -1) {
3795
+ const expectedValues = util.objectValues(nativeEnumValues);
3796
+ addIssueToContext(ctx, {
3797
+ received: ctx.data,
3798
+ code: ZodIssueCode.invalid_enum_value,
3799
+ options: expectedValues
3800
+ });
3801
+ return INVALID;
3802
+ }
3803
+ return OK(input.data);
3804
+ }
3805
+ get enum() {
3806
+ return this._def.values;
3807
+ }
3808
+ };
3809
+ ZodNativeEnum.create = (values, params) => {
3810
+ return new ZodNativeEnum({
3811
+ values,
3812
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3813
+ ...processCreateParams(params)
3814
+ });
3815
+ };
3816
+ ZodPromise = class extends ZodType {
3817
+ _parse(input) {
3818
+ const { ctx } = this._processInputParams(input);
3819
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3820
+ addIssueToContext(ctx, {
3821
+ code: ZodIssueCode.invalid_type,
3822
+ expected: ZodParsedType.promise,
3823
+ received: ctx.parsedType
3824
+ });
3825
+ return INVALID;
3826
+ }
3827
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3828
+ return OK(promisified.then((data) => {
3829
+ return this._def.type.parseAsync(data, {
3830
+ path: ctx.path,
3831
+ errorMap: ctx.common.contextualErrorMap
3832
+ });
3833
+ }));
3834
+ }
3835
+ };
3836
+ ZodPromise.create = (schema3, params) => {
3837
+ return new ZodPromise({
3838
+ type: schema3,
3839
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3840
+ ...processCreateParams(params)
3841
+ });
3842
+ };
3843
+ ZodEffects = class extends ZodType {
3844
+ innerType() {
3845
+ return this._def.schema;
3846
+ }
3847
+ sourceType() {
3848
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3849
+ }
3850
+ _parse(input) {
3851
+ const { status, ctx } = this._processInputParams(input);
3852
+ const effect = this._def.effect || null;
3853
+ if (effect.type === "preprocess") {
3854
+ const processed = effect.transform(ctx.data);
3855
+ if (ctx.common.async) {
3856
+ return Promise.resolve(processed).then((processed2) => {
3857
+ return this._def.schema._parseAsync({
3858
+ data: processed2,
3859
+ path: ctx.path,
3860
+ parent: ctx
3861
+ });
3862
+ });
3863
+ } else {
3864
+ return this._def.schema._parseSync({
3865
+ data: processed,
3866
+ path: ctx.path,
3867
+ parent: ctx
3868
+ });
3869
+ }
3870
+ }
3871
+ const checkCtx = {
3872
+ addIssue: (arg) => {
3873
+ addIssueToContext(ctx, arg);
3874
+ if (arg.fatal) {
3875
+ status.abort();
3876
+ } else {
3877
+ status.dirty();
3878
+ }
3879
+ },
3880
+ get path() {
3881
+ return ctx.path;
3882
+ }
3883
+ };
3884
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3885
+ if (effect.type === "refinement") {
3886
+ const executeRefinement = (acc) => {
3887
+ const result = effect.refinement(acc, checkCtx);
3888
+ if (ctx.common.async) {
3889
+ return Promise.resolve(result);
3890
+ }
3891
+ if (result instanceof Promise) {
3892
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3893
+ }
3894
+ return acc;
3895
+ };
3896
+ if (ctx.common.async === false) {
3897
+ const inner = this._def.schema._parseSync({
3898
+ data: ctx.data,
3899
+ path: ctx.path,
3900
+ parent: ctx
3901
+ });
3902
+ if (inner.status === "aborted")
3903
+ return INVALID;
3904
+ if (inner.status === "dirty")
3905
+ status.dirty();
3906
+ executeRefinement(inner.value);
3907
+ return { status: status.value, value: inner.value };
3908
+ } else {
3909
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3910
+ if (inner.status === "aborted")
3911
+ return INVALID;
3912
+ if (inner.status === "dirty")
3913
+ status.dirty();
3914
+ return executeRefinement(inner.value).then(() => {
3915
+ return { status: status.value, value: inner.value };
3916
+ });
3917
+ });
3918
+ }
3919
+ }
3920
+ if (effect.type === "transform") {
3921
+ if (ctx.common.async === false) {
3922
+ const base = this._def.schema._parseSync({
3923
+ data: ctx.data,
3924
+ path: ctx.path,
3925
+ parent: ctx
3926
+ });
3927
+ if (!isValid(base))
3928
+ return base;
3929
+ const result = effect.transform(base.value, checkCtx);
3930
+ if (result instanceof Promise) {
3931
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3932
+ }
3933
+ return { status: status.value, value: result };
3934
+ } else {
3935
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3936
+ if (!isValid(base))
3937
+ return base;
3938
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3939
+ });
3940
+ }
3941
+ }
3942
+ util.assertNever(effect);
3943
+ }
3944
+ };
3945
+ ZodEffects.create = (schema3, effect, params) => {
3946
+ return new ZodEffects({
3947
+ schema: schema3,
3948
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3949
+ effect,
3950
+ ...processCreateParams(params)
3951
+ });
3952
+ };
3953
+ ZodEffects.createWithPreprocess = (preprocess, schema3, params) => {
3954
+ return new ZodEffects({
3955
+ schema: schema3,
3956
+ effect: { type: "preprocess", transform: preprocess },
3957
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3958
+ ...processCreateParams(params)
3959
+ });
3960
+ };
3961
+ ZodOptional = class extends ZodType {
3962
+ _parse(input) {
3963
+ const parsedType = this._getType(input);
3964
+ if (parsedType === ZodParsedType.undefined) {
3965
+ return OK(void 0);
3966
+ }
3967
+ return this._def.innerType._parse(input);
3968
+ }
3969
+ unwrap() {
3970
+ return this._def.innerType;
3971
+ }
3972
+ };
3973
+ ZodOptional.create = (type, params) => {
3974
+ return new ZodOptional({
3975
+ innerType: type,
3976
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3977
+ ...processCreateParams(params)
3978
+ });
3979
+ };
3980
+ ZodNullable = class extends ZodType {
3981
+ _parse(input) {
3982
+ const parsedType = this._getType(input);
3983
+ if (parsedType === ZodParsedType.null) {
3984
+ return OK(null);
3985
+ }
3986
+ return this._def.innerType._parse(input);
3987
+ }
3988
+ unwrap() {
3989
+ return this._def.innerType;
3990
+ }
3991
+ };
3992
+ ZodNullable.create = (type, params) => {
3993
+ return new ZodNullable({
3994
+ innerType: type,
3995
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3996
+ ...processCreateParams(params)
3997
+ });
3998
+ };
3999
+ ZodDefault = class extends ZodType {
4000
+ _parse(input) {
4001
+ const { ctx } = this._processInputParams(input);
4002
+ let data = ctx.data;
4003
+ if (ctx.parsedType === ZodParsedType.undefined) {
4004
+ data = this._def.defaultValue();
4005
+ }
4006
+ return this._def.innerType._parse({
4007
+ data,
4008
+ path: ctx.path,
4009
+ parent: ctx
4010
+ });
4011
+ }
4012
+ removeDefault() {
4013
+ return this._def.innerType;
4014
+ }
4015
+ };
4016
+ ZodDefault.create = (type, params) => {
4017
+ return new ZodDefault({
4018
+ innerType: type,
4019
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
4020
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4021
+ ...processCreateParams(params)
4022
+ });
4023
+ };
4024
+ ZodCatch = class extends ZodType {
4025
+ _parse(input) {
4026
+ const { ctx } = this._processInputParams(input);
4027
+ const result = this._def.innerType._parse({
4028
+ data: ctx.data,
4029
+ path: ctx.path,
4030
+ parent: ctx
4031
+ });
4032
+ if (isAsync(result)) {
4033
+ return result.then((result2) => {
4034
+ return {
4035
+ status: "valid",
4036
+ value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4037
+ };
4038
+ });
4039
+ } else {
4040
+ return {
4041
+ status: "valid",
4042
+ value: result.status === "valid" ? result.value : this._def.defaultValue()
4043
+ };
4044
+ }
4045
+ }
4046
+ removeDefault() {
4047
+ return this._def.innerType;
4048
+ }
4049
+ };
4050
+ ZodCatch.create = (type, params) => {
4051
+ return new ZodCatch({
4052
+ innerType: type,
4053
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
4054
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4055
+ ...processCreateParams(params)
4056
+ });
4057
+ };
4058
+ ZodNaN = class extends ZodType {
4059
+ _parse(input) {
4060
+ const parsedType = this._getType(input);
4061
+ if (parsedType !== ZodParsedType.nan) {
4062
+ const ctx = this._getOrReturnCtx(input);
4063
+ addIssueToContext(ctx, {
4064
+ code: ZodIssueCode.invalid_type,
4065
+ expected: ZodParsedType.nan,
4066
+ received: ctx.parsedType
4067
+ });
4068
+ return INVALID;
4069
+ }
4070
+ return { status: "valid", value: input.data };
4071
+ }
4072
+ };
4073
+ ZodNaN.create = (params) => {
4074
+ return new ZodNaN({
4075
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
4076
+ ...processCreateParams(params)
4077
+ });
4078
+ };
4079
+ BRAND = Symbol("zod_brand");
4080
+ ZodBranded = class extends ZodType {
4081
+ _parse(input) {
4082
+ const { ctx } = this._processInputParams(input);
4083
+ const data = ctx.data;
4084
+ return this._def.type._parse({
4085
+ data,
4086
+ path: ctx.path,
4087
+ parent: ctx
4088
+ });
4089
+ }
4090
+ unwrap() {
4091
+ return this._def.type;
4092
+ }
4093
+ };
4094
+ ZodPipeline = class _ZodPipeline extends ZodType {
4095
+ _parse(input) {
4096
+ const { status, ctx } = this._processInputParams(input);
4097
+ if (ctx.common.async) {
4098
+ const handleAsync = async () => {
4099
+ const inResult = await this._def.in._parseAsync({
4100
+ data: ctx.data,
4101
+ path: ctx.path,
4102
+ parent: ctx
4103
+ });
4104
+ if (inResult.status === "aborted")
4105
+ return INVALID;
4106
+ if (inResult.status === "dirty") {
4107
+ status.dirty();
4108
+ return DIRTY(inResult.value);
4109
+ } else {
4110
+ return this._def.out._parseAsync({
4111
+ data: inResult.value,
4112
+ path: ctx.path,
4113
+ parent: ctx
4114
+ });
4115
+ }
4116
+ };
4117
+ return handleAsync();
4118
+ } else {
4119
+ const inResult = this._def.in._parseSync({
4120
+ data: ctx.data,
4121
+ path: ctx.path,
4122
+ parent: ctx
4123
+ });
4124
+ if (inResult.status === "aborted")
4125
+ return INVALID;
4126
+ if (inResult.status === "dirty") {
4127
+ status.dirty();
4128
+ return {
4129
+ status: "dirty",
4130
+ value: inResult.value
4131
+ };
4132
+ } else {
4133
+ return this._def.out._parseSync({
4134
+ data: inResult.value,
4135
+ path: ctx.path,
4136
+ parent: ctx
4137
+ });
4138
+ }
4139
+ }
4140
+ }
4141
+ static create(a, b) {
4142
+ return new _ZodPipeline({
4143
+ in: a,
4144
+ out: b,
4145
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4146
+ });
4147
+ }
4148
+ };
4149
+ late = {
4150
+ object: ZodObject.lazycreate
4151
+ };
4152
+ (function(ZodFirstPartyTypeKind2) {
4153
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4154
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4155
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4156
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4157
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4158
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4159
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4160
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4161
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4162
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4163
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4164
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4165
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4166
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4167
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4168
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4169
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4170
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4171
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4172
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4173
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4174
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4175
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4176
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4177
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4178
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4179
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4180
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4181
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4182
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4183
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4184
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4185
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4186
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4187
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4188
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4189
+ stringType = ZodString.create;
4190
+ numberType = ZodNumber.create;
4191
+ nanType = ZodNaN.create;
4192
+ bigIntType = ZodBigInt.create;
4193
+ booleanType = ZodBoolean.create;
4194
+ dateType = ZodDate.create;
4195
+ symbolType = ZodSymbol.create;
4196
+ undefinedType = ZodUndefined.create;
4197
+ nullType = ZodNull.create;
4198
+ anyType = ZodAny.create;
4199
+ unknownType = ZodUnknown.create;
4200
+ neverType = ZodNever.create;
4201
+ voidType = ZodVoid.create;
4202
+ arrayType = ZodArray.create;
4203
+ objectType = ZodObject.create;
4204
+ strictObjectType = ZodObject.strictCreate;
4205
+ unionType = ZodUnion.create;
4206
+ discriminatedUnionType = ZodDiscriminatedUnion.create;
4207
+ intersectionType = ZodIntersection.create;
4208
+ tupleType = ZodTuple.create;
4209
+ recordType = ZodRecord.create;
4210
+ mapType = ZodMap.create;
4211
+ setType = ZodSet.create;
4212
+ functionType = ZodFunction.create;
4213
+ lazyType = ZodLazy.create;
4214
+ literalType = ZodLiteral.create;
4215
+ enumType = ZodEnum.create;
4216
+ nativeEnumType = ZodNativeEnum.create;
4217
+ promiseType = ZodPromise.create;
4218
+ effectsType = ZodEffects.create;
4219
+ optionalType = ZodOptional.create;
4220
+ nullableType = ZodNullable.create;
4221
+ preprocessType = ZodEffects.createWithPreprocess;
4222
+ pipelineType = ZodPipeline.create;
4223
+ }
4224
+ });
4225
+
4226
+ // src/serializer/mysqlSchema.ts
4227
+ var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternalV6, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, mysqlSchema, mysqlSchemaV5, backwardCompatibleMysqlSchema, dryMySql;
4228
+ var init_mysqlSchema = __esm({
4229
+ "src/serializer/mysqlSchema.ts"() {
4230
+ "use strict";
4231
+ init_global();
4232
+ init_lib();
4233
+ index = objectType({
4234
+ name: stringType(),
4235
+ columns: stringType().array(),
4236
+ isUnique: booleanType(),
4237
+ using: enumType(["btree", "hash"]).optional(),
4238
+ algorithm: enumType(["default", "inplace", "copy"]).optional(),
4239
+ lock: enumType(["default", "none", "shared", "exclusive"]).optional()
4240
+ }).strict();
4241
+ fk = objectType({
4242
+ name: stringType(),
4243
+ tableFrom: stringType(),
4244
+ columnsFrom: stringType().array(),
4245
+ tableTo: stringType(),
4246
+ columnsTo: stringType().array(),
4247
+ onUpdate: stringType().optional(),
4248
+ onDelete: stringType().optional()
4249
+ }).strict();
4250
+ column = objectType({
4251
+ name: stringType(),
4252
+ type: stringType(),
4253
+ primaryKey: booleanType(),
4254
+ notNull: booleanType(),
4255
+ autoincrement: booleanType().optional(),
4256
+ default: anyType().optional(),
4257
+ onUpdate: anyType().optional()
4258
+ }).strict();
4259
+ tableV3 = objectType({
4260
+ name: stringType(),
4261
+ columns: recordType(stringType(), column),
4262
+ indexes: recordType(stringType(), index),
4263
+ foreignKeys: recordType(stringType(), fk)
4264
+ }).strict();
4265
+ compositePK = objectType({
4266
+ name: stringType(),
4267
+ columns: stringType().array()
4268
+ }).strict();
4269
+ uniqueConstraint = objectType({
4270
+ name: stringType(),
4271
+ columns: stringType().array()
4272
+ }).strict();
4273
+ tableV4 = objectType({
4274
+ name: stringType(),
4275
+ schema: stringType().optional(),
4276
+ columns: recordType(stringType(), column),
4277
+ indexes: recordType(stringType(), index),
4278
+ foreignKeys: recordType(stringType(), fk)
4279
+ }).strict();
4280
+ table = objectType({
4281
+ name: stringType(),
4282
+ columns: recordType(stringType(), column),
4283
+ indexes: recordType(stringType(), index),
4284
+ foreignKeys: recordType(stringType(), fk),
4285
+ compositePrimaryKeys: recordType(stringType(), compositePK),
4286
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4287
+ }).strict();
4288
+ kitInternals = objectType({
4289
+ tables: recordType(
4290
+ stringType(),
4291
+ objectType({
4292
+ columns: recordType(
4293
+ stringType(),
4294
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4295
+ )
4296
+ }).optional()
4297
+ )
4298
+ }).optional();
4299
+ dialect = literalType("mysql");
4300
+ schemaHash = objectType({
4301
+ id: stringType(),
4302
+ prevId: stringType()
4303
+ });
4304
+ schemaInternalV3 = objectType({
4305
+ version: literalType("3"),
4306
+ dialect,
4307
+ tables: recordType(stringType(), tableV3)
4308
+ }).strict();
4309
+ schemaInternalV4 = objectType({
4310
+ version: literalType("4"),
4311
+ dialect,
4312
+ tables: recordType(stringType(), tableV4),
4313
+ schemas: recordType(stringType(), stringType())
4314
+ }).strict();
4315
+ schemaInternalV5 = objectType({
4316
+ version: literalType("5"),
4317
+ dialect,
4318
+ tables: recordType(stringType(), table),
4319
+ schemas: recordType(stringType(), stringType()),
4320
+ _meta: objectType({
4321
+ schemas: recordType(stringType(), stringType()),
4322
+ tables: recordType(stringType(), stringType()),
4323
+ columns: recordType(stringType(), stringType())
4324
+ }),
4325
+ internal: kitInternals
4326
+ }).strict();
4327
+ schemaInternalV6 = objectType({
4328
+ version: literalType("6"),
4329
+ dialect,
4330
+ tables: recordType(stringType(), table),
4331
+ _meta: objectType({
4332
+ tables: recordType(stringType(), stringType()),
4333
+ columns: recordType(stringType(), stringType())
4334
+ }),
4335
+ internal: kitInternals
4336
+ }).strict();
4337
+ schemaInternal = objectType({
4338
+ version: literalType("6"),
4339
+ dialect,
4340
+ tables: recordType(stringType(), table),
4341
+ _meta: objectType({
4342
+ tables: recordType(stringType(), stringType()),
4343
+ columns: recordType(stringType(), stringType())
4344
+ }),
4345
+ internal: kitInternals
4346
+ }).strict();
4347
+ schemaV3 = schemaInternalV3.merge(schemaHash);
4348
+ schemaV4 = schemaInternalV4.merge(schemaHash);
4349
+ schemaV5 = schemaInternalV5.merge(schemaHash);
4350
+ schema = schemaInternal.merge(schemaHash);
4351
+ tableSquashedV4 = objectType({
4352
+ name: stringType(),
4353
+ schema: stringType().optional(),
4354
+ columns: recordType(stringType(), column),
4355
+ indexes: recordType(stringType(), stringType()),
4356
+ foreignKeys: recordType(stringType(), stringType())
4357
+ }).strict();
4358
+ tableSquashed = objectType({
4359
+ name: stringType(),
4360
+ columns: recordType(stringType(), column),
4361
+ indexes: recordType(stringType(), stringType()),
4362
+ foreignKeys: recordType(stringType(), stringType()),
4363
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4364
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4365
+ }).strict();
4366
+ schemaSquashed = objectType({
4367
+ version: literalType("5"),
4368
+ dialect,
4369
+ tables: recordType(stringType(), tableSquashed)
4370
+ }).strict();
4371
+ schemaSquashedV4 = objectType({
4372
+ version: literalType("4"),
4373
+ dialect,
4374
+ tables: recordType(stringType(), tableSquashedV4),
4375
+ schemas: recordType(stringType(), stringType())
4376
+ }).strict();
4377
+ mysqlSchema = schema;
4378
+ mysqlSchemaV5 = schemaV5;
4379
+ backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema]);
4380
+ dryMySql = mysqlSchema.parse({
4381
+ version: snapshotVersion,
4382
+ dialect: "mysql",
4383
+ id: originUUID,
4384
+ prevId: "",
4385
+ tables: {},
4386
+ schemas: {},
4387
+ _meta: {
4388
+ schemas: {},
4389
+ tables: {},
4390
+ columns: {}
4391
+ }
4392
+ });
4393
+ }
4394
+ });
4395
+
4396
+ // src/serializer/pgSchema.ts
4397
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
4398
+ var init_pgSchema = __esm({
4399
+ "src/serializer/pgSchema.ts"() {
4400
+ "use strict";
4401
+ init_global();
4402
+ init_lib();
4403
+ indexV2 = objectType({
4404
+ name: stringType(),
4405
+ columns: recordType(
4406
+ stringType(),
4407
+ objectType({
4408
+ name: stringType()
4409
+ })
4410
+ ),
4411
+ isUnique: booleanType()
4412
+ }).strict();
4413
+ columnV2 = objectType({
4414
+ name: stringType(),
4415
+ type: stringType(),
4416
+ primaryKey: booleanType(),
4417
+ notNull: booleanType(),
4418
+ default: anyType().optional(),
4419
+ references: stringType().optional()
4420
+ }).strict();
4421
+ tableV2 = objectType({
4422
+ name: stringType(),
4423
+ columns: recordType(stringType(), columnV2),
4424
+ indexes: recordType(stringType(), indexV2)
4425
+ }).strict();
4426
+ enumSchemaV1 = objectType({
4427
+ name: stringType(),
4428
+ values: recordType(stringType(), stringType())
4429
+ }).strict();
4430
+ enumSchema = objectType({
4431
+ name: stringType(),
4432
+ schema: stringType(),
4433
+ values: stringType().array()
4434
+ }).strict();
4435
+ pgSchemaV2 = objectType({
4436
+ version: literalType("2"),
4437
+ tables: recordType(stringType(), tableV2),
4438
+ enums: recordType(stringType(), enumSchemaV1)
4439
+ }).strict();
4440
+ references = objectType({
4441
+ foreignKeyName: stringType(),
4442
+ table: stringType(),
4443
+ column: stringType(),
4444
+ onDelete: stringType().optional(),
4445
+ onUpdate: stringType().optional()
4446
+ }).strict();
4447
+ columnV1 = objectType({
4448
+ name: stringType(),
4449
+ type: stringType(),
4450
+ primaryKey: booleanType(),
4451
+ notNull: booleanType(),
4452
+ default: anyType().optional(),
4453
+ references: references.optional()
4454
+ }).strict();
4455
+ tableV1 = objectType({
4456
+ name: stringType(),
4457
+ columns: recordType(stringType(), columnV1),
4458
+ indexes: recordType(stringType(), indexV2)
4459
+ }).strict();
4460
+ pgSchemaV1 = objectType({
4461
+ version: literalType("1"),
4462
+ tables: recordType(stringType(), tableV1),
4463
+ enums: recordType(stringType(), enumSchemaV1)
4464
+ }).strict();
4465
+ index2 = objectType({
4466
+ name: stringType(),
4467
+ columns: stringType().array(),
4468
+ isUnique: booleanType()
4469
+ }).strict();
4470
+ fk2 = objectType({
4471
+ name: stringType(),
4472
+ tableFrom: stringType(),
4473
+ columnsFrom: stringType().array(),
4474
+ tableTo: stringType(),
4475
+ schemaTo: stringType().optional(),
4476
+ columnsTo: stringType().array(),
4477
+ onUpdate: stringType().optional(),
4478
+ onDelete: stringType().optional()
4479
+ }).strict();
4480
+ column2 = objectType({
4481
+ name: stringType(),
4482
+ type: stringType(),
4483
+ typeSchema: stringType().optional(),
4484
+ primaryKey: booleanType(),
4485
+ notNull: booleanType(),
4486
+ default: anyType().optional(),
4487
+ isUnique: anyType().optional(),
4488
+ uniqueName: stringType().optional(),
4489
+ nullsNotDistinct: booleanType().optional()
4490
+ }).strict();
4491
+ tableV32 = objectType({
4492
+ name: stringType(),
4493
+ columns: recordType(stringType(), column2),
4494
+ indexes: recordType(stringType(), index2),
4495
+ foreignKeys: recordType(stringType(), fk2)
4496
+ }).strict();
4497
+ compositePK2 = objectType({
4498
+ name: stringType(),
4499
+ columns: stringType().array()
4500
+ }).strict();
4501
+ uniqueConstraint2 = objectType({
4502
+ name: stringType(),
4503
+ columns: stringType().array(),
4504
+ nullsNotDistinct: booleanType()
4505
+ }).strict();
4506
+ tableV42 = objectType({
4507
+ name: stringType(),
4508
+ schema: stringType(),
4509
+ columns: recordType(stringType(), column2),
4510
+ indexes: recordType(stringType(), index2),
4511
+ foreignKeys: recordType(stringType(), fk2)
4512
+ }).strict();
4513
+ table2 = objectType({
4514
+ name: stringType(),
4515
+ schema: stringType(),
4516
+ columns: recordType(stringType(), column2),
4517
+ indexes: recordType(stringType(), index2),
4518
+ foreignKeys: recordType(stringType(), fk2),
4519
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4520
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4521
+ }).strict();
4522
+ schemaHash2 = objectType({
4523
+ id: stringType(),
4524
+ prevId: stringType()
4525
+ });
4526
+ kitInternals2 = objectType({
4527
+ tables: recordType(
4528
+ stringType(),
4529
+ objectType({
4530
+ columns: recordType(
4531
+ stringType(),
4532
+ objectType({
4533
+ isArray: booleanType().optional(),
4534
+ dimensions: numberType().optional(),
4535
+ rawType: stringType().optional()
4536
+ }).optional()
4537
+ )
4538
+ }).optional()
4539
+ )
4540
+ }).optional();
4541
+ pgSchemaInternalV3 = objectType({
4542
+ version: literalType("3"),
4543
+ dialect: literalType("pg"),
4544
+ tables: recordType(stringType(), tableV32),
4545
+ enums: recordType(stringType(), enumSchemaV1)
4546
+ }).strict();
4547
+ pgSchemaInternalV4 = objectType({
4548
+ version: literalType("4"),
4549
+ dialect: literalType("pg"),
4550
+ tables: recordType(stringType(), tableV42),
4551
+ enums: recordType(stringType(), enumSchemaV1),
4552
+ schemas: recordType(stringType(), stringType())
4553
+ }).strict();
4554
+ pgSchemaInternalV5 = objectType({
4555
+ version: literalType("5"),
4556
+ dialect: literalType("pg"),
4557
+ tables: recordType(stringType(), table2),
4558
+ enums: recordType(stringType(), enumSchemaV1),
4559
+ schemas: recordType(stringType(), stringType()),
4560
+ _meta: objectType({
4561
+ schemas: recordType(stringType(), stringType()),
4562
+ tables: recordType(stringType(), stringType()),
4563
+ columns: recordType(stringType(), stringType())
4564
+ }),
4565
+ internal: kitInternals2
4566
+ }).strict();
4567
+ pgSchemaExternal = objectType({
4568
+ version: literalType("5"),
4569
+ dialect: literalType("pg"),
4570
+ tables: arrayType(table2),
4571
+ enums: arrayType(enumSchemaV1),
4572
+ schemas: arrayType(objectType({ name: stringType() })),
4573
+ _meta: objectType({
4574
+ schemas: recordType(stringType(), stringType()),
4575
+ tables: recordType(stringType(), stringType()),
4576
+ columns: recordType(stringType(), stringType())
4577
+ })
4578
+ }).strict();
4579
+ pgSchemaInternal = objectType({
4580
+ version: literalType("6"),
4581
+ dialect: literalType("pg"),
4582
+ tables: recordType(stringType(), table2),
4583
+ enums: recordType(stringType(), enumSchema),
4584
+ schemas: recordType(stringType(), stringType()),
4585
+ _meta: objectType({
4586
+ schemas: recordType(stringType(), stringType()),
4587
+ tables: recordType(stringType(), stringType()),
4588
+ columns: recordType(stringType(), stringType())
4589
+ }),
4590
+ internal: kitInternals2
4591
+ }).strict();
4592
+ tableSquashed2 = objectType({
4593
+ name: stringType(),
4594
+ schema: stringType(),
4595
+ columns: recordType(stringType(), column2),
4596
+ indexes: recordType(stringType(), stringType()),
4597
+ foreignKeys: recordType(stringType(), stringType()),
4598
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4599
+ uniqueConstraints: recordType(stringType(), stringType())
4600
+ }).strict();
4601
+ tableSquashedV42 = objectType({
4602
+ name: stringType(),
4603
+ schema: stringType(),
4604
+ columns: recordType(stringType(), column2),
4605
+ indexes: recordType(stringType(), stringType()),
4606
+ foreignKeys: recordType(stringType(), stringType())
4607
+ }).strict();
4608
+ pgSchemaSquashedV4 = objectType({
4609
+ version: literalType("4"),
4610
+ dialect: enumType(["pg"]),
4611
+ tables: recordType(stringType(), tableSquashedV42),
4612
+ enums: recordType(stringType(), enumSchemaV1),
4613
+ schemas: recordType(stringType(), stringType())
4614
+ }).strict();
4615
+ pgSchemaSquashed = objectType({
4616
+ version: literalType("6"),
4617
+ dialect: enumType(["pg"]),
4618
+ tables: recordType(stringType(), tableSquashed2),
4619
+ enums: recordType(stringType(), enumSchema),
4620
+ schemas: recordType(stringType(), stringType())
4621
+ }).strict();
4622
+ pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4623
+ pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4624
+ pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4625
+ pgSchema2 = pgSchemaInternal.merge(schemaHash2);
4626
+ backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4627
+ dryPg = pgSchema2.parse({
4628
+ version: snapshotVersion,
4629
+ dialect: "pg",
4630
+ id: originUUID,
4631
+ prevId: "",
4632
+ tables: {},
4633
+ enums: {},
4634
+ schemas: {},
4635
+ _meta: {
4636
+ schemas: {},
4637
+ tables: {},
4638
+ columns: {}
4639
+ }
4640
+ });
4641
+ }
4642
+ });
4643
+
4644
+ // src/serializer/sqliteSchema.ts
4645
+ var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema2, tableSquashed3, schemaSquashed2, drySQLite;
4646
+ var init_sqliteSchema = __esm({
4647
+ "src/serializer/sqliteSchema.ts"() {
4648
+ "use strict";
4649
+ init_global();
4650
+ init_lib();
4651
+ index3 = objectType({
4652
+ name: stringType(),
4653
+ columns: stringType().array(),
4654
+ where: stringType().optional(),
4655
+ isUnique: booleanType()
4656
+ }).strict();
4657
+ fk3 = objectType({
4658
+ name: stringType(),
4659
+ tableFrom: stringType(),
4660
+ columnsFrom: stringType().array(),
4661
+ tableTo: stringType(),
4662
+ columnsTo: stringType().array(),
4663
+ onUpdate: stringType().optional(),
4664
+ onDelete: stringType().optional()
4665
+ }).strict();
4666
+ compositePK3 = objectType({
4667
+ columns: stringType().array(),
4668
+ name: stringType().optional()
4669
+ }).strict();
4670
+ column3 = objectType({
4671
+ name: stringType(),
4672
+ type: stringType(),
4673
+ primaryKey: booleanType(),
4674
+ notNull: booleanType(),
4675
+ autoincrement: booleanType().optional(),
4676
+ default: anyType().optional()
4677
+ }).strict();
4678
+ tableV33 = objectType({
4679
+ name: stringType(),
4680
+ columns: recordType(stringType(), column3),
4681
+ indexes: recordType(stringType(), index3),
4682
+ foreignKeys: recordType(stringType(), fk3)
4683
+ }).strict();
4684
+ uniqueConstraint3 = objectType({
4685
+ name: stringType(),
4686
+ columns: stringType().array()
4687
+ }).strict();
4688
+ table3 = objectType({
4689
+ name: stringType(),
4690
+ columns: recordType(stringType(), column3),
4691
+ indexes: recordType(stringType(), index3),
4692
+ foreignKeys: recordType(stringType(), fk3),
4693
+ compositePrimaryKeys: recordType(stringType(), compositePK3),
4694
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
4695
+ }).strict();
4696
+ dialect2 = enumType(["sqlite"]);
4697
+ schemaHash3 = objectType({
4698
+ id: stringType(),
4699
+ prevId: stringType()
4700
+ }).strict();
4701
+ schemaInternalV32 = objectType({
4702
+ version: literalType("3"),
4703
+ dialect: dialect2,
4704
+ tables: recordType(stringType(), tableV33),
4705
+ enums: objectType({})
4706
+ }).strict();
4707
+ schemaInternalV42 = objectType({
4708
+ version: literalType("4"),
4709
+ dialect: dialect2,
4710
+ tables: recordType(stringType(), table3),
4711
+ enums: objectType({})
4712
+ }).strict();
4713
+ latestVersion = literalType("5");
4714
+ schemaInternal2 = objectType({
4715
+ version: latestVersion,
4716
+ dialect: dialect2,
4717
+ tables: recordType(stringType(), table3),
4718
+ enums: objectType({}),
4719
+ _meta: objectType({
4720
+ tables: recordType(stringType(), stringType()),
4721
+ columns: recordType(stringType(), stringType())
4722
+ })
4723
+ }).strict();
4724
+ schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
4725
+ schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
4726
+ schema2 = schemaInternal2.merge(schemaHash3).strict();
4727
+ tableSquashed3 = objectType({
4728
+ name: stringType(),
4729
+ columns: recordType(stringType(), column3),
4730
+ indexes: recordType(stringType(), stringType()),
4731
+ foreignKeys: recordType(stringType(), stringType()),
4732
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4733
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4734
+ }).strict();
4735
+ schemaSquashed2 = objectType({
4736
+ version: latestVersion,
4737
+ dialect: dialect2,
4738
+ tables: recordType(stringType(), tableSquashed3),
4739
+ enums: anyType()
4740
+ }).strict();
4741
+ drySQLite = schema2.parse({
4742
+ version: "5",
4743
+ dialect: "sqlite",
4744
+ id: originUUID,
4745
+ prevId: "",
4746
+ tables: {},
4747
+ enums: {},
4748
+ _meta: {
4749
+ tables: {},
4750
+ columns: {}
4751
+ }
4752
+ });
4753
+ }
4754
+ });
4755
+
4756
+ // src/utils.ts
4757
+ var init_utils = __esm({
4758
+ "src/utils.ts"() {
4759
+ "use strict";
4760
+ init_views();
4761
+ init_mysqlSchema();
4762
+ init_pgSchema();
4763
+ init_sqliteSchema();
4764
+ init_source();
4765
+ init_global();
4766
+ }
4767
+ });
4768
+
1077
4769
  // src/cli/views.ts
1078
4770
  var import_hanji;
1079
4771
  var init_views = __esm({
1080
4772
  "src/cli/views.ts"() {
4773
+ "use strict";
1081
4774
  init_source();
1082
4775
  import_hanji = __toESM(require_hanji());
4776
+ init_utils();
1083
4777
  }
1084
4778
  });
1085
4779
 
@@ -1087,6 +4781,7 @@ var init_views = __esm({
1087
4781
  import * as glob from "glob";
1088
4782
  var init_serializer = __esm({
1089
4783
  "src/serializer/index.ts"() {
4784
+ "use strict";
1090
4785
  init_source();
1091
4786
  init_views();
1092
4787
  }
@@ -1095,6 +4790,7 @@ var init_serializer = __esm({
1095
4790
  // src/cli/validations/outputs.ts
1096
4791
  var init_outputs = __esm({
1097
4792
  "src/cli/validations/outputs.ts"() {
4793
+ "use strict";
1098
4794
  init_source();
1099
4795
  }
1100
4796
  });
@@ -1108,6 +4804,7 @@ import {
1108
4804
  uniqueKeyName
1109
4805
  } from "drizzle-orm/sqlite-core";
1110
4806
  function mapSqlToSqliteType(sqlType) {
4807
+ const lowered = sqlType.toLowerCase();
1111
4808
  if ([
1112
4809
  "int",
1113
4810
  "integer",
@@ -1119,37 +4816,41 @@ function mapSqlToSqliteType(sqlType) {
1119
4816
  "unsigned big int",
1120
4817
  "int2",
1121
4818
  "int8"
1122
- ].includes(sqlType.toLowerCase())) {
4819
+ ].some((it) => lowered.startsWith(it))) {
1123
4820
  return "integer";
1124
4821
  } else if ([
1125
4822
  "character",
1126
4823
  "varchar",
1127
- "vatying character",
4824
+ "varying character",
4825
+ "national varying character",
1128
4826
  "nchar",
1129
4827
  "native character",
1130
4828
  "nvarchar",
1131
4829
  "text",
1132
4830
  "clob"
1133
- ].some((it) => it.startsWith(sqlType.toLowerCase()))) {
4831
+ ].some((it) => lowered.startsWith(it))) {
4832
+ const match2 = lowered.match(/\d+/);
4833
+ if (match2) {
4834
+ return `text(${match2[0]})`;
4835
+ }
1134
4836
  return "text";
1135
- } else if (sqlType.toLowerCase() === "blob") {
4837
+ } else if (lowered.startsWith("blob")) {
1136
4838
  return "blob";
1137
- } else if (["real", "double", "double precision", "float"].includes(
1138
- sqlType.toLowerCase()
1139
- )) {
4839
+ } else if (["real", "double", "double precision", "float"].some((it) => lowered.startsWith(it))) {
1140
4840
  return "real";
1141
4841
  } else {
1142
4842
  return "numeric";
1143
4843
  }
1144
4844
  }
1145
- var dialect, fromDatabase;
4845
+ var dialect3, fromDatabase;
1146
4846
  var init_sqliteSerializer = __esm({
1147
4847
  "src/serializer/sqliteSerializer.ts"() {
4848
+ "use strict";
1148
4849
  init_serializer();
1149
4850
  init_outputs();
1150
4851
  init_source();
1151
- dialect = new SQLiteSyncDialect();
1152
- fromDatabase = async (db, tablesFilter = (table) => true, progressCallback) => {
4852
+ dialect3 = new SQLiteSyncDialect();
4853
+ fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
1153
4854
  const result = {};
1154
4855
  const columns = await db.query(
1155
4856
  `SELECT
@@ -1170,23 +4871,23 @@ var init_sqliteSerializer = __esm({
1170
4871
  let indexesCount = 0;
1171
4872
  let foreignKeysCount = 0;
1172
4873
  const tableToPk = {};
1173
- for (const column of columns) {
1174
- if (!tablesFilter(column.tableName))
4874
+ for (const column4 of columns) {
4875
+ if (!tablesFilter(column4.tableName))
1175
4876
  continue;
1176
4877
  columnsCount += 1;
1177
4878
  if (progressCallback) {
1178
4879
  progressCallback("columns", columnsCount, "fetching");
1179
4880
  }
1180
- const tableName = column.tableName;
4881
+ const tableName = column4.tableName;
1181
4882
  tablesCount.add(tableName);
1182
4883
  if (progressCallback) {
1183
4884
  progressCallback("tables", tablesCount.size, "fetching");
1184
4885
  }
1185
- const columnName = column.columnName;
1186
- const isNotNull = column.notNull === 1;
1187
- const columnType = column.columnType;
1188
- const isPrimary = column.pk !== 0;
1189
- const columnDefault = column.defaultValue;
4886
+ const columnName = column4.columnName;
4887
+ const isNotNull = column4.notNull === 1;
4888
+ const columnType = column4.columnType;
4889
+ const isPrimary = column4.pk !== 0;
4890
+ const columnDefault = column4.defaultValue;
1190
4891
  const isAutoincrement = isPrimary && tablesWithSeq.includes(tableName);
1191
4892
  if (isPrimary) {
1192
4893
  if (typeof tableToPk[tableName] === "undefined") {
@@ -1195,7 +4896,7 @@ var init_sqliteSerializer = __esm({
1195
4896
  tableToPk[tableName].push(columnName);
1196
4897
  }
1197
4898
  }
1198
- const table = result[tableName];
4899
+ const table4 = result[tableName];
1199
4900
  const newColumn = {
1200
4901
  default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) ? Number(columnDefault) : ["CURRENT_TIME", "CURRENT_DATE", "CURRENT_TIMESTAMP"].includes(
1201
4902
  columnDefault
@@ -1209,7 +4910,7 @@ var init_sqliteSerializer = __esm({
1209
4910
  primaryKey: false,
1210
4911
  notNull: isNotNull
1211
4912
  };
1212
- if (!table) {
4913
+ if (!table4) {
1213
4914
  result[tableName] = {
1214
4915
  name: tableName,
1215
4916
  columns: {
@@ -1560,17 +5261,19 @@ var require_brace_expansion = __commonJS({
1560
5261
  // src/serializer/pgSerializer.ts
1561
5262
  import {
1562
5263
  PgDialect,
5264
+ PgEnumColumn,
1563
5265
  uniqueKeyName as uniqueKeyName2
1564
5266
  } from "drizzle-orm/pg-core";
1565
5267
  import { getTableConfig as getTableConfig2 } from "drizzle-orm/pg-core";
1566
5268
  import { is as is2, SQL as SQL2, getTableName as getTableName2 } from "drizzle-orm";
1567
- var dialect2, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
5269
+ var dialect4, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1568
5270
  var init_pgSerializer = __esm({
1569
5271
  "src/serializer/pgSerializer.ts"() {
5272
+ "use strict";
1570
5273
  init_serializer();
1571
5274
  init_source();
1572
5275
  init_outputs();
1573
- dialect2 = new PgDialect();
5276
+ dialect4 = new PgDialect();
1574
5277
  trimChar = (str, char) => {
1575
5278
  let start = 0;
1576
5279
  let end = str.length;
@@ -1580,7 +5283,7 @@ var init_pgSerializer = __esm({
1580
5283
  --end;
1581
5284
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
1582
5285
  };
1583
- fromDatabase2 = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
5286
+ fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
1584
5287
  const result = {};
1585
5288
  const internals = { tables: {} };
1586
5289
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -1688,14 +5391,14 @@ var init_pgSerializer = __esm({
1688
5391
  if (progressCallback) {
1689
5392
  progressCallback("fks", foreignKeysCount, "fetching");
1690
5393
  }
1691
- for (const fk of tableForeignKeys) {
1692
- const columnFrom = fk.column_name;
1693
- const tableTo = fk.foreign_table_name;
1694
- const columnTo = fk.foreign_column_name;
1695
- const schemaTo = fk.foreign_table_schema;
1696
- const foreignKeyName = fk.constraint_name;
1697
- const onUpdate = fk.update_rule.toLowerCase();
1698
- const onDelete = fk.delete_rule.toLowerCase();
5394
+ for (const fk4 of tableForeignKeys) {
5395
+ const columnFrom = fk4.column_name;
5396
+ const tableTo = fk4.foreign_table_name;
5397
+ const columnTo = fk4.foreign_column_name;
5398
+ const schemaTo = fk4.foreign_table_schema;
5399
+ const foreignKeyName = fk4.constraint_name;
5400
+ const onUpdate = fk4.update_rule.toLowerCase();
5401
+ const onDelete = fk4.delete_rule.toLowerCase();
1699
5402
  if (typeof foreignKeysToReturn[foreignKeyName] !== "undefined") {
1700
5403
  foreignKeysToReturn[foreignKeyName].columnsFrom.push(columnFrom);
1701
5404
  foreignKeysToReturn[foreignKeyName].columnsTo.push(columnTo);
@@ -1802,6 +5505,8 @@ var init_pgSerializer = __esm({
1802
5505
  columnToReturn[columnName] = {
1803
5506
  name: columnName,
1804
5507
  type: columnTypeMapped,
5508
+ typeSchema: "...",
5509
+ // TODO: add schema when type is enum
1805
5510
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
1806
5511
  // default: isSerial ? undefined : defaultValue,
1807
5512
  notNull: columnResponse.is_nullable === "NO"
@@ -1893,12 +5598,15 @@ var init_pgSerializer = __esm({
1893
5598
  for (const dbEnum of allEnums) {
1894
5599
  const enumName = dbEnum.enum_name;
1895
5600
  const enumValue = dbEnum.enum_value;
1896
- if (enumsToReturn[enumName] !== void 0 && enumsToReturn[enumName] !== null) {
1897
- enumsToReturn[enumName].values[enumValue] = enumValue;
5601
+ const enumSchema2 = dbEnum.enum_schema || "public";
5602
+ const key = `${enumSchema2}.${enumName}`;
5603
+ if (enumsToReturn[key] !== void 0 && enumsToReturn[key] !== null) {
5604
+ enumsToReturn[enumName].values.push(enumValue);
1898
5605
  } else {
1899
5606
  enumsToReturn[enumName] = {
1900
5607
  name: enumName,
1901
- values: { [enumValue]: enumValue }
5608
+ values: [enumValue],
5609
+ schema: enumSchema2
1902
5610
  };
1903
5611
  }
1904
5612
  }
@@ -1907,7 +5615,7 @@ var init_pgSerializer = __esm({
1907
5615
  }
1908
5616
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1909
5617
  return {
1910
- version: "5",
5618
+ version: "6",
1911
5619
  dialect: "pg",
1912
5620
  tables: result,
1913
5621
  enums: enumsToReturn,
@@ -1940,37 +5648,37 @@ var init_pgSerializer = __esm({
1940
5648
  // json: "::json",
1941
5649
  "character(": "::bpchar"
1942
5650
  };
1943
- defaultForColumn = (column) => {
1944
- if (column.data_type === "serial" || column.data_type === "smallserial" || column.data_type === "bigserial") {
5651
+ defaultForColumn = (column4) => {
5652
+ if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
1945
5653
  return void 0;
1946
5654
  }
1947
5655
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
1948
- (it) => column.data_type.startsWith(it)
5656
+ (it) => column4.data_type.startsWith(it)
1949
5657
  );
1950
- if (column.column_default === null) {
5658
+ if (column4.column_default === null) {
1951
5659
  return void 0;
1952
5660
  }
1953
- const columnDefaultAsString = column.column_default.toString();
5661
+ const columnDefaultAsString = column4.column_default.toString();
1954
5662
  if (columnDefaultAsString.endsWith(
1955
- hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column.data_type
5663
+ hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
1956
5664
  )) {
1957
- const nonPrefixPart = column.column_default.length - (hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column.data_type}`).length - 1;
1958
- const rt = column.column_default.toString().substring(1, nonPrefixPart);
1959
- if (/^-?[\d.]+(?:e-?\d+)?$/.test(rt) && !column.data_type.startsWith("numeric")) {
5665
+ const nonPrefixPart = column4.column_default.length - (hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`).length - 1;
5666
+ const rt = column4.column_default.toString().substring(1, nonPrefixPart);
5667
+ if (/^-?[\d.]+(?:e-?\d+)?$/.test(rt) && !column4.data_type.startsWith("numeric")) {
1960
5668
  return Number(rt);
1961
- } else if (column.data_type === "json" || column.data_type === "jsonb") {
5669
+ } else if (column4.data_type === "json" || column4.data_type === "jsonb") {
1962
5670
  const jsonWithoutSpaces = JSON.stringify(JSON.parse(rt));
1963
- return `'${jsonWithoutSpaces}'${hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column.data_type}`}`;
1964
- } else if (column.data_type === "boolean") {
1965
- return column.column_default === "true";
5671
+ return `'${jsonWithoutSpaces}'${hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`}`;
5672
+ } else if (column4.data_type === "boolean") {
5673
+ return column4.column_default === "true";
1966
5674
  } else {
1967
5675
  return `'${rt}'`;
1968
5676
  }
1969
5677
  } else {
1970
- if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString) && !column.data_type.startsWith("numeric")) {
5678
+ if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString) && !column4.data_type.startsWith("numeric")) {
1971
5679
  return Number(columnDefaultAsString);
1972
- } else if (column.data_type === "boolean") {
1973
- return column.column_default === "true";
5680
+ } else if (column4.data_type === "boolean") {
5681
+ return column4.column_default === "true";
1974
5682
  } else {
1975
5683
  return `${columnDefaultAsString}`;
1976
5684
  }
@@ -1979,11 +5687,369 @@ var init_pgSerializer = __esm({
1979
5687
  }
1980
5688
  });
1981
5689
 
5690
+ // node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js
5691
+ var require_pluralize = __commonJS({
5692
+ "node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js"(exports, module) {
5693
+ (function(root, pluralize) {
5694
+ if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
5695
+ module.exports = pluralize();
5696
+ } else if (typeof define === "function" && define.amd) {
5697
+ define(function() {
5698
+ return pluralize();
5699
+ });
5700
+ } else {
5701
+ root.pluralize = pluralize();
5702
+ }
5703
+ })(exports, function() {
5704
+ var pluralRules = [];
5705
+ var singularRules = [];
5706
+ var uncountables = {};
5707
+ var irregularPlurals = {};
5708
+ var irregularSingles = {};
5709
+ function sanitizeRule(rule) {
5710
+ if (typeof rule === "string") {
5711
+ return new RegExp("^" + rule + "$", "i");
5712
+ }
5713
+ return rule;
5714
+ }
5715
+ function restoreCase(word, token) {
5716
+ if (word === token)
5717
+ return token;
5718
+ if (word === word.toLowerCase())
5719
+ return token.toLowerCase();
5720
+ if (word === word.toUpperCase())
5721
+ return token.toUpperCase();
5722
+ if (word[0] === word[0].toUpperCase()) {
5723
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
5724
+ }
5725
+ return token.toLowerCase();
5726
+ }
5727
+ function interpolate(str, args) {
5728
+ return str.replace(/\$(\d{1,2})/g, function(match2, index4) {
5729
+ return args[index4] || "";
5730
+ });
5731
+ }
5732
+ function replace(word, rule) {
5733
+ return word.replace(rule[0], function(match2, index4) {
5734
+ var result = interpolate(rule[1], arguments);
5735
+ if (match2 === "") {
5736
+ return restoreCase(word[index4 - 1], result);
5737
+ }
5738
+ return restoreCase(match2, result);
5739
+ });
5740
+ }
5741
+ function sanitizeWord(token, word, rules) {
5742
+ if (!token.length || uncountables.hasOwnProperty(token)) {
5743
+ return word;
5744
+ }
5745
+ var len = rules.length;
5746
+ while (len--) {
5747
+ var rule = rules[len];
5748
+ if (rule[0].test(word))
5749
+ return replace(word, rule);
5750
+ }
5751
+ return word;
5752
+ }
5753
+ function replaceWord(replaceMap, keepMap, rules) {
5754
+ return function(word) {
5755
+ var token = word.toLowerCase();
5756
+ if (keepMap.hasOwnProperty(token)) {
5757
+ return restoreCase(word, token);
5758
+ }
5759
+ if (replaceMap.hasOwnProperty(token)) {
5760
+ return restoreCase(word, replaceMap[token]);
5761
+ }
5762
+ return sanitizeWord(token, word, rules);
5763
+ };
5764
+ }
5765
+ function checkWord(replaceMap, keepMap, rules, bool) {
5766
+ return function(word) {
5767
+ var token = word.toLowerCase();
5768
+ if (keepMap.hasOwnProperty(token))
5769
+ return true;
5770
+ if (replaceMap.hasOwnProperty(token))
5771
+ return false;
5772
+ return sanitizeWord(token, token, rules) === token;
5773
+ };
5774
+ }
5775
+ function pluralize(word, count, inclusive) {
5776
+ var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
5777
+ return (inclusive ? count + " " : "") + pluralized;
5778
+ }
5779
+ pluralize.plural = replaceWord(
5780
+ irregularSingles,
5781
+ irregularPlurals,
5782
+ pluralRules
5783
+ );
5784
+ pluralize.isPlural = checkWord(
5785
+ irregularSingles,
5786
+ irregularPlurals,
5787
+ pluralRules
5788
+ );
5789
+ pluralize.singular = replaceWord(
5790
+ irregularPlurals,
5791
+ irregularSingles,
5792
+ singularRules
5793
+ );
5794
+ pluralize.isSingular = checkWord(
5795
+ irregularPlurals,
5796
+ irregularSingles,
5797
+ singularRules
5798
+ );
5799
+ pluralize.addPluralRule = function(rule, replacement) {
5800
+ pluralRules.push([sanitizeRule(rule), replacement]);
5801
+ };
5802
+ pluralize.addSingularRule = function(rule, replacement) {
5803
+ singularRules.push([sanitizeRule(rule), replacement]);
5804
+ };
5805
+ pluralize.addUncountableRule = function(word) {
5806
+ if (typeof word === "string") {
5807
+ uncountables[word.toLowerCase()] = true;
5808
+ return;
5809
+ }
5810
+ pluralize.addPluralRule(word, "$0");
5811
+ pluralize.addSingularRule(word, "$0");
5812
+ };
5813
+ pluralize.addIrregularRule = function(single, plural2) {
5814
+ plural2 = plural2.toLowerCase();
5815
+ single = single.toLowerCase();
5816
+ irregularSingles[single] = plural2;
5817
+ irregularPlurals[plural2] = single;
5818
+ };
5819
+ [
5820
+ // Pronouns.
5821
+ ["I", "we"],
5822
+ ["me", "us"],
5823
+ ["he", "they"],
5824
+ ["she", "they"],
5825
+ ["them", "them"],
5826
+ ["myself", "ourselves"],
5827
+ ["yourself", "yourselves"],
5828
+ ["itself", "themselves"],
5829
+ ["herself", "themselves"],
5830
+ ["himself", "themselves"],
5831
+ ["themself", "themselves"],
5832
+ ["is", "are"],
5833
+ ["was", "were"],
5834
+ ["has", "have"],
5835
+ ["this", "these"],
5836
+ ["that", "those"],
5837
+ // Words ending in with a consonant and `o`.
5838
+ ["echo", "echoes"],
5839
+ ["dingo", "dingoes"],
5840
+ ["volcano", "volcanoes"],
5841
+ ["tornado", "tornadoes"],
5842
+ ["torpedo", "torpedoes"],
5843
+ // Ends with `us`.
5844
+ ["genus", "genera"],
5845
+ ["viscus", "viscera"],
5846
+ // Ends with `ma`.
5847
+ ["stigma", "stigmata"],
5848
+ ["stoma", "stomata"],
5849
+ ["dogma", "dogmata"],
5850
+ ["lemma", "lemmata"],
5851
+ ["schema", "schemata"],
5852
+ ["anathema", "anathemata"],
5853
+ // Other irregular rules.
5854
+ ["ox", "oxen"],
5855
+ ["axe", "axes"],
5856
+ ["die", "dice"],
5857
+ ["yes", "yeses"],
5858
+ ["foot", "feet"],
5859
+ ["eave", "eaves"],
5860
+ ["goose", "geese"],
5861
+ ["tooth", "teeth"],
5862
+ ["quiz", "quizzes"],
5863
+ ["human", "humans"],
5864
+ ["proof", "proofs"],
5865
+ ["carve", "carves"],
5866
+ ["valve", "valves"],
5867
+ ["looey", "looies"],
5868
+ ["thief", "thieves"],
5869
+ ["groove", "grooves"],
5870
+ ["pickaxe", "pickaxes"],
5871
+ ["passerby", "passersby"]
5872
+ ].forEach(function(rule) {
5873
+ return pluralize.addIrregularRule(rule[0], rule[1]);
5874
+ });
5875
+ [
5876
+ [/s?$/i, "s"],
5877
+ [/[^\u0000-\u007F]$/i, "$0"],
5878
+ [/([^aeiou]ese)$/i, "$1"],
5879
+ [/(ax|test)is$/i, "$1es"],
5880
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
5881
+ [/(e[mn]u)s?$/i, "$1s"],
5882
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
5883
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
5884
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
5885
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
5886
+ [/(her|at|gr)o$/i, "$1oes"],
5887
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
5888
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
5889
+ [/sis$/i, "ses"],
5890
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
5891
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
5892
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
5893
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
5894
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
5895
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
5896
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
5897
+ [/(child)(?:ren)?$/i, "$1ren"],
5898
+ [/eaux$/i, "$0"],
5899
+ [/m[ae]n$/i, "men"],
5900
+ ["thou", "you"]
5901
+ ].forEach(function(rule) {
5902
+ return pluralize.addPluralRule(rule[0], rule[1]);
5903
+ });
5904
+ [
5905
+ [/s$/i, ""],
5906
+ [/(ss)$/i, "$1"],
5907
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
5908
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
5909
+ [/ies$/i, "y"],
5910
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
5911
+ [/\b(mon|smil)ies$/i, "$1ey"],
5912
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
5913
+ [/(seraph|cherub)im$/i, "$1"],
5914
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
5915
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
5916
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
5917
+ [/(test)(?:is|es)$/i, "$1is"],
5918
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
5919
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
5920
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
5921
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
5922
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
5923
+ [/(matr|append)ices$/i, "$1ix"],
5924
+ [/(pe)(rson|ople)$/i, "$1rson"],
5925
+ [/(child)ren$/i, "$1"],
5926
+ [/(eau)x?$/i, "$1"],
5927
+ [/men$/i, "man"]
5928
+ ].forEach(function(rule) {
5929
+ return pluralize.addSingularRule(rule[0], rule[1]);
5930
+ });
5931
+ [
5932
+ // Singular words with no plurals.
5933
+ "adulthood",
5934
+ "advice",
5935
+ "agenda",
5936
+ "aid",
5937
+ "aircraft",
5938
+ "alcohol",
5939
+ "ammo",
5940
+ "analytics",
5941
+ "anime",
5942
+ "athletics",
5943
+ "audio",
5944
+ "bison",
5945
+ "blood",
5946
+ "bream",
5947
+ "buffalo",
5948
+ "butter",
5949
+ "carp",
5950
+ "cash",
5951
+ "chassis",
5952
+ "chess",
5953
+ "clothing",
5954
+ "cod",
5955
+ "commerce",
5956
+ "cooperation",
5957
+ "corps",
5958
+ "debris",
5959
+ "diabetes",
5960
+ "digestion",
5961
+ "elk",
5962
+ "energy",
5963
+ "equipment",
5964
+ "excretion",
5965
+ "expertise",
5966
+ "firmware",
5967
+ "flounder",
5968
+ "fun",
5969
+ "gallows",
5970
+ "garbage",
5971
+ "graffiti",
5972
+ "hardware",
5973
+ "headquarters",
5974
+ "health",
5975
+ "herpes",
5976
+ "highjinks",
5977
+ "homework",
5978
+ "housework",
5979
+ "information",
5980
+ "jeans",
5981
+ "justice",
5982
+ "kudos",
5983
+ "labour",
5984
+ "literature",
5985
+ "machinery",
5986
+ "mackerel",
5987
+ "mail",
5988
+ "media",
5989
+ "mews",
5990
+ "moose",
5991
+ "music",
5992
+ "mud",
5993
+ "manga",
5994
+ "news",
5995
+ "only",
5996
+ "personnel",
5997
+ "pike",
5998
+ "plankton",
5999
+ "pliers",
6000
+ "police",
6001
+ "pollution",
6002
+ "premises",
6003
+ "rain",
6004
+ "research",
6005
+ "rice",
6006
+ "salmon",
6007
+ "scissors",
6008
+ "series",
6009
+ "sewage",
6010
+ "shambles",
6011
+ "shrimp",
6012
+ "software",
6013
+ "species",
6014
+ "staff",
6015
+ "swine",
6016
+ "tennis",
6017
+ "traffic",
6018
+ "transportation",
6019
+ "trout",
6020
+ "tuna",
6021
+ "wealth",
6022
+ "welfare",
6023
+ "whiting",
6024
+ "wildebeest",
6025
+ "wildlife",
6026
+ "you",
6027
+ /pok[eé]mon$/i,
6028
+ // Regexes.
6029
+ /[^aeiou]ese$/i,
6030
+ // "chinese", "japanese"
6031
+ /deer$/i,
6032
+ // "deer", "reindeer"
6033
+ /fish$/i,
6034
+ // "fish", "blowfish", "angelfish"
6035
+ /measles$/i,
6036
+ /o[iu]s$/i,
6037
+ // "carnivorous"
6038
+ /pox$/i,
6039
+ // "chickpox", "smallpox"
6040
+ /sheep$/i
6041
+ ].forEach(pluralize.addUncountableRule);
6042
+ return pluralize;
6043
+ });
6044
+ }
6045
+ });
6046
+
1982
6047
  // src/drivers/index.ts
1983
6048
  import { sql } from "drizzle-orm";
1984
6049
  var DrizzleDbClient, DrizzleORMPgClient, TursoSqlite;
1985
6050
  var init_drivers = __esm({
1986
6051
  "src/drivers/index.ts"() {
6052
+ "use strict";
1987
6053
  DrizzleDbClient = class {
1988
6054
  constructor(db) {
1989
6055
  this.db = db;
@@ -2051,9 +6117,9 @@ import {
2051
6117
  sqliteTable,
2052
6118
  PrimaryKeyBuilder as SQLitePrimaryKeyBuilder
2053
6119
  } from "drizzle-orm/sqlite-core";
2054
- var pgSchemaToDrizzle = (schema, schemaName) => {
6120
+ var pgSchemaToDrizzle = (schema3, schemaName) => {
2055
6121
  const tables = {};
2056
- Object.values(schema.tables).forEach((t) => {
6122
+ Object.values(schema3.tables).forEach((t) => {
2057
6123
  const columns = {};
2058
6124
  Object.values(t.columns).forEach((c) => {
2059
6125
  const columnName = c.name;
@@ -2153,9 +6219,9 @@ var pgSchemaToDrizzle = (schema, schemaName) => {
2153
6219
  });
2154
6220
  return tables;
2155
6221
  };
2156
- var sqliteSchemaToDrizzle = (schema) => {
6222
+ var sqliteSchemaToDrizzle = (schema3) => {
2157
6223
  const tables = {};
2158
- Object.values(schema.tables).forEach((t) => {
6224
+ Object.values(schema3.tables).forEach((t) => {
2159
6225
  const columns = {};
2160
6226
  Object.values(t.columns).forEach((c) => {
2161
6227
  const columnName = c.name;
@@ -2200,11 +6266,7 @@ var sqliteSchemaToDrizzle = (schema) => {
2200
6266
 
2201
6267
  // src/cli/commands/sqliteIntrospect.ts
2202
6268
  init_views();
2203
-
2204
- // src/global.ts
2205
- var originUUID = "00000000-0000-0000-0000-000000000000";
2206
-
2207
- // src/cli/commands/sqliteIntrospect.ts
6269
+ init_global();
2208
6270
  init_sqliteSerializer();
2209
6271
 
2210
6272
  // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
@@ -2221,17 +6283,17 @@ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUp
2221
6283
  let isLastCharUpper = false;
2222
6284
  let isLastLastCharUpper = false;
2223
6285
  let isLastLastCharPreserved = false;
2224
- for (let index = 0; index < string.length; index++) {
2225
- const character = string[index];
2226
- isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
6286
+ for (let index4 = 0; index4 < string.length; index4++) {
6287
+ const character = string[index4];
6288
+ isLastLastCharPreserved = index4 > 2 ? string[index4 - 3] === "-" : true;
2227
6289
  if (isLastCharLower && UPPERCASE.test(character)) {
2228
- string = string.slice(0, index) + "-" + string.slice(index);
6290
+ string = string.slice(0, index4) + "-" + string.slice(index4);
2229
6291
  isLastCharLower = false;
2230
6292
  isLastLastCharUpper = isLastCharUpper;
2231
6293
  isLastCharUpper = true;
2232
- index++;
6294
+ index4++;
2233
6295
  } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
2234
- string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
6296
+ string = string.slice(0, index4 - 1) + "-" + string.slice(index4 - 1);
2235
6297
  isLastLastCharUpper = isLastCharUpper;
2236
6298
  isLastCharUpper = false;
2237
6299
  isLastCharLower = true;
@@ -2306,7 +6368,7 @@ String.prototype.camelCase = function() {
2306
6368
  return camelCase(String(this));
2307
6369
  };
2308
6370
  String.prototype.concatIf = function(it, condition) {
2309
- return condition ? `${this}${it}` : this;
6371
+ return condition ? `${this}${it}` : String(this);
2310
6372
  };
2311
6373
  Array.prototype.random = function() {
2312
6374
  return this[~~(Math.random() * this.length)];
@@ -3375,8 +7437,8 @@ var sqlitePushIntrospect = async (client, filters) => {
3375
7437
  return false;
3376
7438
  };
3377
7439
  const res = await fromDatabase(client, filter2);
3378
- const schema = { id: originUUID, prevId: "", ...res };
3379
- return { schema };
7440
+ const schema3 = { id: originUUID, prevId: "", ...res };
7441
+ return { schema: schema3 };
3380
7442
  };
3381
7443
 
3382
7444
  // src/cli/commands/pgIntrospect.ts
@@ -3385,6 +7447,7 @@ init_views();
3385
7447
  init_pgSerializer();
3386
7448
 
3387
7449
  // src/introspect-pg.ts
7450
+ var import_pluralize = __toESM(require_pluralize());
3388
7451
  import { getTableName as getTableName3, is as is3 } from "drizzle-orm";
3389
7452
  import {
3390
7453
  createTableRelationsHelpers,
@@ -3395,6 +7458,7 @@ import {
3395
7458
  init_pgSerializer();
3396
7459
 
3397
7460
  // src/cli/commands/pgIntrospect.ts
7461
+ init_global();
3398
7462
  var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3399
7463
  const { client } = connection;
3400
7464
  const matchers = filters.map((it) => {
@@ -3411,8 +7475,8 @@ var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3411
7475
  return false;
3412
7476
  };
3413
7477
  const res = await fromDatabase2(client, filter2, schemaFilters);
3414
- const schema = { id: originUUID, prevId: "", ...res };
3415
- const { internal, ...schemaWithoutInternals } = schema;
7478
+ const schema3 = { id: originUUID, prevId: "", ...res };
7479
+ const { internal, ...schemaWithoutInternals } = schema3;
3416
7480
  return { schema: schemaWithoutInternals };
3417
7481
  };
3418
7482