drizzle-kit 0.21.2 → 0.21.4-b5744a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.cjs +34668 -26774
- package/index.d.mts +9 -1
- package/index.d.ts +9 -1
- package/package.json +2 -1
- package/payload.d.mts +177 -177
- package/payload.d.ts +177 -177
- package/payload.js +547 -467
- package/payload.mjs +524 -444
- package/utils-studio.js +934 -246
- package/utils-studio.mjs +908 -220
- package/utils.js +871 -215
- package/utils.mjs +845 -190
package/utils.js
CHANGED
@@ -33,10 +33,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
33
33
|
|
34
34
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
|
35
35
|
var require_readline = __commonJS({
|
36
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(
|
36
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) {
|
37
37
|
"use strict";
|
38
|
-
Object.defineProperty(
|
39
|
-
|
38
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
39
|
+
exports2.prepareReadLine = void 0;
|
40
40
|
var prepareReadLine = () => {
|
41
41
|
const stdin = process.stdin;
|
42
42
|
const stdout = process.stdout;
|
@@ -52,13 +52,13 @@ var require_readline = __commonJS({
|
|
52
52
|
closable: rl
|
53
53
|
};
|
54
54
|
};
|
55
|
-
|
55
|
+
exports2.prepareReadLine = prepareReadLine;
|
56
56
|
}
|
57
57
|
});
|
58
58
|
|
59
59
|
// node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
60
60
|
var require_src = __commonJS({
|
61
|
-
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(
|
61
|
+
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
|
62
62
|
"use strict";
|
63
63
|
var ESC = "\x1B";
|
64
64
|
var CSI = `${ESC}[`;
|
@@ -119,10 +119,10 @@ var require_src = __commonJS({
|
|
119
119
|
|
120
120
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
|
121
121
|
var require_utils = __commonJS({
|
122
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(
|
122
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports2) {
|
123
123
|
"use strict";
|
124
|
-
Object.defineProperty(
|
125
|
-
|
124
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
125
|
+
exports2.clear = void 0;
|
126
126
|
var sisteransi_1 = require_src();
|
127
127
|
var strip = (str) => {
|
128
128
|
const pattern = [
|
@@ -143,13 +143,13 @@ var require_utils = __commonJS({
|
|
143
143
|
}
|
144
144
|
return sisteransi_1.erase.lines(rows);
|
145
145
|
};
|
146
|
-
|
146
|
+
exports2.clear = clear;
|
147
147
|
}
|
148
148
|
});
|
149
149
|
|
150
150
|
// node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
|
151
151
|
var require_lodash = __commonJS({
|
152
|
-
"node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(
|
152
|
+
"node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) {
|
153
153
|
var FUNC_ERROR_TEXT = "Expected a function";
|
154
154
|
var NAN = 0 / 0;
|
155
155
|
var symbolTag = "[object Symbol]";
|
@@ -297,9 +297,9 @@ var require_lodash = __commonJS({
|
|
297
297
|
|
298
298
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
|
299
299
|
var require_hanji = __commonJS({
|
300
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(
|
300
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports2) {
|
301
301
|
"use strict";
|
302
|
-
var __awaiter =
|
302
|
+
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
|
303
303
|
function adopt(value) {
|
304
304
|
return value instanceof P ? value : new P(function(resolve) {
|
305
305
|
resolve(value);
|
@@ -326,11 +326,11 @@ var require_hanji = __commonJS({
|
|
326
326
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
327
327
|
});
|
328
328
|
};
|
329
|
-
var __importDefault =
|
329
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
330
330
|
return mod && mod.__esModule ? mod : { "default": mod };
|
331
331
|
};
|
332
|
-
Object.defineProperty(
|
333
|
-
|
332
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
333
|
+
exports2.onTerminate = exports2.renderWithTask = exports2.render = exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0;
|
334
334
|
var readline_1 = require_readline();
|
335
335
|
var sisteransi_1 = require_src();
|
336
336
|
var utils_1 = require_utils();
|
@@ -365,7 +365,7 @@ var require_hanji = __commonJS({
|
|
365
365
|
this.inputCallbacks.forEach((it) => it(str, key));
|
366
366
|
}
|
367
367
|
};
|
368
|
-
|
368
|
+
exports2.Prompt = Prompt2;
|
369
369
|
var SelectState2 = class {
|
370
370
|
constructor(items) {
|
371
371
|
this.items = items;
|
@@ -393,7 +393,7 @@ var require_hanji = __commonJS({
|
|
393
393
|
return false;
|
394
394
|
}
|
395
395
|
};
|
396
|
-
|
396
|
+
exports2.SelectState = SelectState2;
|
397
397
|
var deferred = () => {
|
398
398
|
let resolve;
|
399
399
|
let reject;
|
@@ -407,7 +407,7 @@ var require_hanji = __commonJS({
|
|
407
407
|
promise
|
408
408
|
};
|
409
409
|
};
|
410
|
-
|
410
|
+
exports2.deferred = deferred;
|
411
411
|
var Terminal = class {
|
412
412
|
constructor(view, stdin, stdout, closable) {
|
413
413
|
this.view = view;
|
@@ -452,7 +452,7 @@ var require_hanji = __commonJS({
|
|
452
452
|
};
|
453
453
|
this.stdin.on("keypress", keypress);
|
454
454
|
this.view.attach(this);
|
455
|
-
const { resolve, promise } = (0,
|
455
|
+
const { resolve, promise } = (0, exports2.deferred)();
|
456
456
|
this.resolve = resolve;
|
457
457
|
this.promise = promise;
|
458
458
|
this.renderFunc = (0, lodash_throttle_1.default)((str) => {
|
@@ -483,7 +483,7 @@ var require_hanji = __commonJS({
|
|
483
483
|
this.renderFunc(`${clearPrefix}${string}`);
|
484
484
|
}
|
485
485
|
};
|
486
|
-
|
486
|
+
exports2.Terminal = Terminal;
|
487
487
|
var TaskView2 = class {
|
488
488
|
constructor() {
|
489
489
|
this.attachCallbacks = [];
|
@@ -508,7 +508,7 @@ var require_hanji = __commonJS({
|
|
508
508
|
}
|
509
509
|
}
|
510
510
|
};
|
511
|
-
|
511
|
+
exports2.TaskView = TaskView2;
|
512
512
|
var TaskTerminal = class {
|
513
513
|
constructor(view, stdout) {
|
514
514
|
this.view = view;
|
@@ -529,7 +529,7 @@ var require_hanji = __commonJS({
|
|
529
529
|
this.stdout.write(`${clearPrefix}${string}`);
|
530
530
|
}
|
531
531
|
};
|
532
|
-
|
532
|
+
exports2.TaskTerminal = TaskTerminal;
|
533
533
|
function render2(view) {
|
534
534
|
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
535
535
|
if (view instanceof Prompt2) {
|
@@ -542,7 +542,7 @@ var require_hanji = __commonJS({
|
|
542
542
|
closable.close();
|
543
543
|
return;
|
544
544
|
}
|
545
|
-
|
545
|
+
exports2.render = render2;
|
546
546
|
function renderWithTask(view, task) {
|
547
547
|
return __awaiter(this, void 0, void 0, function* () {
|
548
548
|
const terminal = new TaskTerminal(view, process.stdout);
|
@@ -552,12 +552,12 @@ var require_hanji = __commonJS({
|
|
552
552
|
return result;
|
553
553
|
});
|
554
554
|
}
|
555
|
-
|
555
|
+
exports2.renderWithTask = renderWithTask;
|
556
556
|
var terminateHandler;
|
557
557
|
function onTerminate(callback) {
|
558
558
|
terminateHandler = callback;
|
559
559
|
}
|
560
|
-
|
560
|
+
exports2.onTerminate = onTerminate;
|
561
561
|
}
|
562
562
|
});
|
563
563
|
|
@@ -569,6 +569,7 @@ __export(utils_exports, {
|
|
569
569
|
copy: () => copy,
|
570
570
|
dryJournal: () => dryJournal,
|
571
571
|
kloudMeta: () => kloudMeta,
|
572
|
+
normaliseSQLiteUrl: () => normaliseSQLiteUrl,
|
572
573
|
objectValues: () => objectValues,
|
573
574
|
prepareMigrationFolder: () => prepareMigrationFolder,
|
574
575
|
prepareMigrationMeta: () => prepareMigrationMeta,
|
@@ -580,7 +581,7 @@ __export(utils_exports, {
|
|
580
581
|
module.exports = __toCommonJS(utils_exports);
|
581
582
|
var import_fs = require("fs");
|
582
583
|
|
583
|
-
// node_modules/.pnpm/chalk@5.
|
584
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
584
585
|
var ANSI_BACKGROUND_OFFSET = 10;
|
585
586
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
586
587
|
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
@@ -766,7 +767,7 @@ function assembleStyles() {
|
|
766
767
|
var ansiStyles = assembleStyles();
|
767
768
|
var ansi_styles_default = ansiStyles;
|
768
769
|
|
769
|
-
// node_modules/.pnpm/chalk@5.
|
770
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
|
770
771
|
var import_node_process = __toESM(require("node:process"), 1);
|
771
772
|
var import_node_os = __toESM(require("node:os"), 1);
|
772
773
|
var import_node_tty = __toESM(require("node:tty"), 1);
|
@@ -840,7 +841,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
840
841
|
return 1;
|
841
842
|
}
|
842
843
|
if ("CI" in env) {
|
843
|
-
if ("GITHUB_ACTIONS" in env) {
|
844
|
+
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
|
844
845
|
return 3;
|
845
846
|
}
|
846
847
|
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
@@ -892,7 +893,7 @@ var supportsColor = {
|
|
892
893
|
};
|
893
894
|
var supports_color_default = supportsColor;
|
894
895
|
|
895
|
-
// node_modules/.pnpm/chalk@5.
|
896
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
896
897
|
function stringReplaceAll(string, substring, replacer) {
|
897
898
|
let index4 = string.indexOf(substring);
|
898
899
|
if (index4 === -1) {
|
@@ -922,7 +923,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
|
922
923
|
return returnValue;
|
923
924
|
}
|
924
925
|
|
925
|
-
// node_modules/.pnpm/chalk@5.
|
926
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
|
926
927
|
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
927
928
|
var GENERATOR = Symbol("GENERATOR");
|
928
929
|
var STYLER = Symbol("STYLER");
|
@@ -1078,8 +1079,11 @@ var info = (msg, greyMsg = "") => {
|
|
1078
1079
|
// src/global.ts
|
1079
1080
|
var originUUID = "00000000-0000-0000-0000-000000000000";
|
1080
1081
|
var snapshotVersion = "6";
|
1082
|
+
function assertUnreachable(x) {
|
1083
|
+
throw new Error("Didn't expect to get here");
|
1084
|
+
}
|
1081
1085
|
|
1082
|
-
// node_modules/.pnpm/zod@3.
|
1086
|
+
// node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
1083
1087
|
var util;
|
1084
1088
|
(function(util2) {
|
1085
1089
|
util2.assertEqual = (val) => val;
|
@@ -1138,6 +1142,16 @@ var util;
|
|
1138
1142
|
return value;
|
1139
1143
|
};
|
1140
1144
|
})(util || (util = {}));
|
1145
|
+
var objectUtil;
|
1146
|
+
(function(objectUtil2) {
|
1147
|
+
objectUtil2.mergeShapes = (first, second) => {
|
1148
|
+
return {
|
1149
|
+
...first,
|
1150
|
+
...second
|
1151
|
+
// second overwrites first
|
1152
|
+
};
|
1153
|
+
};
|
1154
|
+
})(objectUtil || (objectUtil = {}));
|
1141
1155
|
var ZodParsedType = util.arrayToEnum([
|
1142
1156
|
"string",
|
1143
1157
|
"nan",
|
@@ -1219,7 +1233,7 @@ var ZodIssueCode = util.arrayToEnum([
|
|
1219
1233
|
"not_multiple_of",
|
1220
1234
|
"not_finite"
|
1221
1235
|
]);
|
1222
|
-
var ZodError = class extends Error {
|
1236
|
+
var ZodError = class _ZodError extends Error {
|
1223
1237
|
constructor(issues) {
|
1224
1238
|
super();
|
1225
1239
|
this.issues = [];
|
@@ -1277,6 +1291,11 @@ var ZodError = class extends Error {
|
|
1277
1291
|
processError(this);
|
1278
1292
|
return fieldErrors;
|
1279
1293
|
}
|
1294
|
+
static assert(value) {
|
1295
|
+
if (!(value instanceof _ZodError)) {
|
1296
|
+
throw new Error(`Not a ZodError: ${value}`);
|
1297
|
+
}
|
1298
|
+
}
|
1280
1299
|
toString() {
|
1281
1300
|
return this.message;
|
1282
1301
|
}
|
@@ -1343,7 +1362,12 @@ var errorMap = (issue, _ctx) => {
|
|
1343
1362
|
break;
|
1344
1363
|
case ZodIssueCode.invalid_string:
|
1345
1364
|
if (typeof issue.validation === "object") {
|
1346
|
-
if ("
|
1365
|
+
if ("includes" in issue.validation) {
|
1366
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
1367
|
+
if (typeof issue.validation.position === "number") {
|
1368
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
1369
|
+
}
|
1370
|
+
} else if ("startsWith" in issue.validation) {
|
1347
1371
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
1348
1372
|
} else if ("endsWith" in issue.validation) {
|
1349
1373
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
@@ -1364,7 +1388,7 @@ var errorMap = (issue, _ctx) => {
|
|
1364
1388
|
else if (issue.type === "number")
|
1365
1389
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
1366
1390
|
else if (issue.type === "date")
|
1367
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
|
1391
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
1368
1392
|
else
|
1369
1393
|
message = "Invalid input";
|
1370
1394
|
break;
|
@@ -1375,8 +1399,10 @@ var errorMap = (issue, _ctx) => {
|
|
1375
1399
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
1376
1400
|
else if (issue.type === "number")
|
1377
1401
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1402
|
+
else if (issue.type === "bigint")
|
1403
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1378
1404
|
else if (issue.type === "date")
|
1379
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
|
1405
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
1380
1406
|
else
|
1381
1407
|
message = "Invalid input";
|
1382
1408
|
break;
|
@@ -1409,6 +1435,13 @@ var makeIssue = (params) => {
|
|
1409
1435
|
...issueData,
|
1410
1436
|
path: fullPath
|
1411
1437
|
};
|
1438
|
+
if (issueData.message !== void 0) {
|
1439
|
+
return {
|
1440
|
+
...issueData,
|
1441
|
+
path: fullPath,
|
1442
|
+
message: issueData.message
|
1443
|
+
};
|
1444
|
+
}
|
1412
1445
|
let errorMessage = "";
|
1413
1446
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
1414
1447
|
for (const map of maps) {
|
@@ -1417,10 +1450,11 @@ var makeIssue = (params) => {
|
|
1417
1450
|
return {
|
1418
1451
|
...issueData,
|
1419
1452
|
path: fullPath,
|
1420
|
-
message:
|
1453
|
+
message: errorMessage
|
1421
1454
|
};
|
1422
1455
|
};
|
1423
1456
|
function addIssueToContext(ctx, issueData) {
|
1457
|
+
const overrideMap = getErrorMap();
|
1424
1458
|
const issue = makeIssue({
|
1425
1459
|
issueData,
|
1426
1460
|
data: ctx.data,
|
@@ -1428,8 +1462,8 @@ function addIssueToContext(ctx, issueData) {
|
|
1428
1462
|
errorMaps: [
|
1429
1463
|
ctx.common.contextualErrorMap,
|
1430
1464
|
ctx.schemaErrorMap,
|
1431
|
-
|
1432
|
-
errorMap
|
1465
|
+
overrideMap,
|
1466
|
+
overrideMap === errorMap ? void 0 : errorMap
|
1433
1467
|
// then global default map
|
1434
1468
|
].filter((x) => !!x)
|
1435
1469
|
});
|
@@ -1461,9 +1495,11 @@ var ParseStatus = class _ParseStatus {
|
|
1461
1495
|
static async mergeObjectAsync(status, pairs) {
|
1462
1496
|
const syncPairs = [];
|
1463
1497
|
for (const pair of pairs) {
|
1498
|
+
const key = await pair.key;
|
1499
|
+
const value = await pair.value;
|
1464
1500
|
syncPairs.push({
|
1465
|
-
key
|
1466
|
-
value
|
1501
|
+
key,
|
1502
|
+
value
|
1467
1503
|
});
|
1468
1504
|
}
|
1469
1505
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
@@ -1480,7 +1516,7 @@ var ParseStatus = class _ParseStatus {
|
|
1480
1516
|
status.dirty();
|
1481
1517
|
if (value.status === "dirty")
|
1482
1518
|
status.dirty();
|
1483
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
1519
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
1484
1520
|
finalObject[key.value] = value.value;
|
1485
1521
|
}
|
1486
1522
|
}
|
@@ -1495,21 +1531,47 @@ var OK = (value) => ({ status: "valid", value });
|
|
1495
1531
|
var isAborted = (x) => x.status === "aborted";
|
1496
1532
|
var isDirty = (x) => x.status === "dirty";
|
1497
1533
|
var isValid = (x) => x.status === "valid";
|
1498
|
-
var isAsync = (x) => typeof Promise !==
|
1534
|
+
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1535
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
1536
|
+
if (kind === "a" && !f)
|
1537
|
+
throw new TypeError("Private accessor was defined without a getter");
|
1538
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
1539
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
1540
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
1541
|
+
}
|
1542
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
1543
|
+
if (kind === "m")
|
1544
|
+
throw new TypeError("Private method is not writable");
|
1545
|
+
if (kind === "a" && !f)
|
1546
|
+
throw new TypeError("Private accessor was defined without a setter");
|
1547
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
1548
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
1549
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
1550
|
+
}
|
1499
1551
|
var errorUtil;
|
1500
1552
|
(function(errorUtil2) {
|
1501
1553
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1502
1554
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
1503
1555
|
})(errorUtil || (errorUtil = {}));
|
1556
|
+
var _ZodEnum_cache;
|
1557
|
+
var _ZodNativeEnum_cache;
|
1504
1558
|
var ParseInputLazyPath = class {
|
1505
1559
|
constructor(parent, value, path, key) {
|
1560
|
+
this._cachedPath = [];
|
1506
1561
|
this.parent = parent;
|
1507
1562
|
this.data = value;
|
1508
1563
|
this._path = path;
|
1509
1564
|
this._key = key;
|
1510
1565
|
}
|
1511
1566
|
get path() {
|
1512
|
-
|
1567
|
+
if (!this._cachedPath.length) {
|
1568
|
+
if (this._key instanceof Array) {
|
1569
|
+
this._cachedPath.push(...this._path, ...this._key);
|
1570
|
+
} else {
|
1571
|
+
this._cachedPath.push(...this._path, this._key);
|
1572
|
+
}
|
1573
|
+
}
|
1574
|
+
return this._cachedPath;
|
1513
1575
|
}
|
1514
1576
|
};
|
1515
1577
|
var handleResult = (ctx, result) => {
|
@@ -1519,8 +1581,16 @@ var handleResult = (ctx, result) => {
|
|
1519
1581
|
if (!ctx.common.issues.length) {
|
1520
1582
|
throw new Error("Validation failed but no issues detected.");
|
1521
1583
|
}
|
1522
|
-
|
1523
|
-
|
1584
|
+
return {
|
1585
|
+
success: false,
|
1586
|
+
get error() {
|
1587
|
+
if (this._error)
|
1588
|
+
return this._error;
|
1589
|
+
const error = new ZodError(ctx.common.issues);
|
1590
|
+
this._error = error;
|
1591
|
+
return this._error;
|
1592
|
+
}
|
1593
|
+
};
|
1524
1594
|
}
|
1525
1595
|
};
|
1526
1596
|
function processCreateParams(params) {
|
@@ -1533,12 +1603,17 @@ function processCreateParams(params) {
|
|
1533
1603
|
if (errorMap2)
|
1534
1604
|
return { errorMap: errorMap2, description };
|
1535
1605
|
const customMap = (iss, ctx) => {
|
1536
|
-
|
1537
|
-
|
1606
|
+
var _a, _b;
|
1607
|
+
const { message } = params;
|
1608
|
+
if (iss.code === "invalid_enum_value") {
|
1609
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
1610
|
+
}
|
1538
1611
|
if (typeof ctx.data === "undefined") {
|
1539
|
-
return { message:
|
1612
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
1540
1613
|
}
|
1541
|
-
|
1614
|
+
if (iss.code !== "invalid_type")
|
1615
|
+
return { message: ctx.defaultError };
|
1616
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
1542
1617
|
};
|
1543
1618
|
return { errorMap: customMap, description };
|
1544
1619
|
}
|
@@ -1567,6 +1642,7 @@ var ZodType = class {
|
|
1567
1642
|
this.catch = this.catch.bind(this);
|
1568
1643
|
this.describe = this.describe.bind(this);
|
1569
1644
|
this.pipe = this.pipe.bind(this);
|
1645
|
+
this.readonly = this.readonly.bind(this);
|
1570
1646
|
this.isNullable = this.isNullable.bind(this);
|
1571
1647
|
this.isOptional = this.isOptional.bind(this);
|
1572
1648
|
}
|
@@ -1711,28 +1787,29 @@ var ZodType = class {
|
|
1711
1787
|
return this._refinement(refinement);
|
1712
1788
|
}
|
1713
1789
|
optional() {
|
1714
|
-
return ZodOptional.create(this);
|
1790
|
+
return ZodOptional.create(this, this._def);
|
1715
1791
|
}
|
1716
1792
|
nullable() {
|
1717
|
-
return ZodNullable.create(this);
|
1793
|
+
return ZodNullable.create(this, this._def);
|
1718
1794
|
}
|
1719
1795
|
nullish() {
|
1720
|
-
return this.
|
1796
|
+
return this.nullable().optional();
|
1721
1797
|
}
|
1722
1798
|
array() {
|
1723
|
-
return ZodArray.create(this);
|
1799
|
+
return ZodArray.create(this, this._def);
|
1724
1800
|
}
|
1725
1801
|
promise() {
|
1726
|
-
return ZodPromise.create(this);
|
1802
|
+
return ZodPromise.create(this, this._def);
|
1727
1803
|
}
|
1728
1804
|
or(option) {
|
1729
|
-
return ZodUnion.create([this, option]);
|
1805
|
+
return ZodUnion.create([this, option], this._def);
|
1730
1806
|
}
|
1731
1807
|
and(incoming) {
|
1732
|
-
return ZodIntersection.create(this, incoming);
|
1808
|
+
return ZodIntersection.create(this, incoming, this._def);
|
1733
1809
|
}
|
1734
1810
|
transform(transform) {
|
1735
1811
|
return new ZodEffects({
|
1812
|
+
...processCreateParams(this._def),
|
1736
1813
|
schema: this,
|
1737
1814
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
1738
1815
|
effect: { type: "transform", transform }
|
@@ -1741,6 +1818,7 @@ var ZodType = class {
|
|
1741
1818
|
default(def) {
|
1742
1819
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
1743
1820
|
return new ZodDefault({
|
1821
|
+
...processCreateParams(this._def),
|
1744
1822
|
innerType: this,
|
1745
1823
|
defaultValue: defaultValueFunc,
|
1746
1824
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
@@ -1750,14 +1828,15 @@ var ZodType = class {
|
|
1750
1828
|
return new ZodBranded({
|
1751
1829
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
1752
1830
|
type: this,
|
1753
|
-
...processCreateParams(
|
1831
|
+
...processCreateParams(this._def)
|
1754
1832
|
});
|
1755
1833
|
}
|
1756
1834
|
catch(def) {
|
1757
|
-
const
|
1835
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
1758
1836
|
return new ZodCatch({
|
1837
|
+
...processCreateParams(this._def),
|
1759
1838
|
innerType: this,
|
1760
|
-
|
1839
|
+
catchValue: catchValueFunc,
|
1761
1840
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
1762
1841
|
});
|
1763
1842
|
}
|
@@ -1771,6 +1850,9 @@ var ZodType = class {
|
|
1771
1850
|
pipe(target) {
|
1772
1851
|
return ZodPipeline.create(this, target);
|
1773
1852
|
}
|
1853
|
+
readonly() {
|
1854
|
+
return ZodReadonly.create(this);
|
1855
|
+
}
|
1774
1856
|
isOptional() {
|
1775
1857
|
return this.safeParse(void 0).success;
|
1776
1858
|
}
|
@@ -1779,43 +1861,50 @@ var ZodType = class {
|
|
1779
1861
|
}
|
1780
1862
|
};
|
1781
1863
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
1782
|
-
var
|
1783
|
-
var
|
1784
|
-
var
|
1864
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
1865
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
1866
|
+
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
1867
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
1868
|
+
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
1869
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
1870
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
1871
|
+
var emojiRegex;
|
1872
|
+
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
1873
|
+
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
1874
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
1875
|
+
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
1876
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1877
|
+
function timeRegexSource(args) {
|
1878
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
1785
1879
|
if (args.precision) {
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
1790
|
-
}
|
1791
|
-
} else if (args.precision === 0) {
|
1792
|
-
if (args.offset) {
|
1793
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
|
1794
|
-
} else {
|
1795
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
1796
|
-
}
|
1797
|
-
} else {
|
1798
|
-
if (args.offset) {
|
1799
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
|
1800
|
-
} else {
|
1801
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
1802
|
-
}
|
1880
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
1881
|
+
} else if (args.precision == null) {
|
1882
|
+
regex = `${regex}(\\.\\d+)?`;
|
1803
1883
|
}
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1884
|
+
return regex;
|
1885
|
+
}
|
1886
|
+
function timeRegex(args) {
|
1887
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
1888
|
+
}
|
1889
|
+
function datetimeRegex(args) {
|
1890
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
1891
|
+
const opts = [];
|
1892
|
+
opts.push(args.local ? `Z?` : `Z`);
|
1893
|
+
if (args.offset)
|
1894
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
1895
|
+
regex = `${regex}(${opts.join("|")})`;
|
1896
|
+
return new RegExp(`^${regex}$`);
|
1897
|
+
}
|
1898
|
+
function isValidIP(ip, version) {
|
1899
|
+
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
1900
|
+
return true;
|
1818
1901
|
}
|
1902
|
+
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
1903
|
+
return true;
|
1904
|
+
}
|
1905
|
+
return false;
|
1906
|
+
}
|
1907
|
+
var ZodString = class _ZodString extends ZodType {
|
1819
1908
|
_parse(input) {
|
1820
1909
|
if (this._def.coerce) {
|
1821
1910
|
input.data = String(input.data);
|
@@ -1823,15 +1912,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
1823
1912
|
const parsedType = this._getType(input);
|
1824
1913
|
if (parsedType !== ZodParsedType.string) {
|
1825
1914
|
const ctx2 = this._getOrReturnCtx(input);
|
1826
|
-
addIssueToContext(
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
received: ctx2.parsedType
|
1832
|
-
}
|
1833
|
-
//
|
1834
|
-
);
|
1915
|
+
addIssueToContext(ctx2, {
|
1916
|
+
code: ZodIssueCode.invalid_type,
|
1917
|
+
expected: ZodParsedType.string,
|
1918
|
+
received: ctx2.parsedType
|
1919
|
+
});
|
1835
1920
|
return INVALID;
|
1836
1921
|
}
|
1837
1922
|
const status = new ParseStatus();
|
@@ -1899,6 +1984,19 @@ var ZodString = class _ZodString extends ZodType {
|
|
1899
1984
|
});
|
1900
1985
|
status.dirty();
|
1901
1986
|
}
|
1987
|
+
} else if (check.kind === "emoji") {
|
1988
|
+
if (!emojiRegex) {
|
1989
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
1990
|
+
}
|
1991
|
+
if (!emojiRegex.test(input.data)) {
|
1992
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1993
|
+
addIssueToContext(ctx, {
|
1994
|
+
validation: "emoji",
|
1995
|
+
code: ZodIssueCode.invalid_string,
|
1996
|
+
message: check.message
|
1997
|
+
});
|
1998
|
+
status.dirty();
|
1999
|
+
}
|
1902
2000
|
} else if (check.kind === "uuid") {
|
1903
2001
|
if (!uuidRegex.test(input.data)) {
|
1904
2002
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1909,6 +2007,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
1909
2007
|
});
|
1910
2008
|
status.dirty();
|
1911
2009
|
}
|
2010
|
+
} else if (check.kind === "nanoid") {
|
2011
|
+
if (!nanoidRegex.test(input.data)) {
|
2012
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2013
|
+
addIssueToContext(ctx, {
|
2014
|
+
validation: "nanoid",
|
2015
|
+
code: ZodIssueCode.invalid_string,
|
2016
|
+
message: check.message
|
2017
|
+
});
|
2018
|
+
status.dirty();
|
2019
|
+
}
|
1912
2020
|
} else if (check.kind === "cuid") {
|
1913
2021
|
if (!cuidRegex.test(input.data)) {
|
1914
2022
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1919,6 +2027,26 @@ var ZodString = class _ZodString extends ZodType {
|
|
1919
2027
|
});
|
1920
2028
|
status.dirty();
|
1921
2029
|
}
|
2030
|
+
} else if (check.kind === "cuid2") {
|
2031
|
+
if (!cuid2Regex.test(input.data)) {
|
2032
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2033
|
+
addIssueToContext(ctx, {
|
2034
|
+
validation: "cuid2",
|
2035
|
+
code: ZodIssueCode.invalid_string,
|
2036
|
+
message: check.message
|
2037
|
+
});
|
2038
|
+
status.dirty();
|
2039
|
+
}
|
2040
|
+
} else if (check.kind === "ulid") {
|
2041
|
+
if (!ulidRegex.test(input.data)) {
|
2042
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2043
|
+
addIssueToContext(ctx, {
|
2044
|
+
validation: "ulid",
|
2045
|
+
code: ZodIssueCode.invalid_string,
|
2046
|
+
message: check.message
|
2047
|
+
});
|
2048
|
+
status.dirty();
|
2049
|
+
}
|
1922
2050
|
} else if (check.kind === "url") {
|
1923
2051
|
try {
|
1924
2052
|
new URL(input.data);
|
@@ -1945,6 +2073,20 @@ var ZodString = class _ZodString extends ZodType {
|
|
1945
2073
|
}
|
1946
2074
|
} else if (check.kind === "trim") {
|
1947
2075
|
input.data = input.data.trim();
|
2076
|
+
} else if (check.kind === "includes") {
|
2077
|
+
if (!input.data.includes(check.value, check.position)) {
|
2078
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2079
|
+
addIssueToContext(ctx, {
|
2080
|
+
code: ZodIssueCode.invalid_string,
|
2081
|
+
validation: { includes: check.value, position: check.position },
|
2082
|
+
message: check.message
|
2083
|
+
});
|
2084
|
+
status.dirty();
|
2085
|
+
}
|
2086
|
+
} else if (check.kind === "toLowerCase") {
|
2087
|
+
input.data = input.data.toLowerCase();
|
2088
|
+
} else if (check.kind === "toUpperCase") {
|
2089
|
+
input.data = input.data.toUpperCase();
|
1948
2090
|
} else if (check.kind === "startsWith") {
|
1949
2091
|
if (!input.data.startsWith(check.value)) {
|
1950
2092
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1976,12 +2118,71 @@ var ZodString = class _ZodString extends ZodType {
|
|
1976
2118
|
});
|
1977
2119
|
status.dirty();
|
1978
2120
|
}
|
2121
|
+
} else if (check.kind === "date") {
|
2122
|
+
const regex = dateRegex;
|
2123
|
+
if (!regex.test(input.data)) {
|
2124
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2125
|
+
addIssueToContext(ctx, {
|
2126
|
+
code: ZodIssueCode.invalid_string,
|
2127
|
+
validation: "date",
|
2128
|
+
message: check.message
|
2129
|
+
});
|
2130
|
+
status.dirty();
|
2131
|
+
}
|
2132
|
+
} else if (check.kind === "time") {
|
2133
|
+
const regex = timeRegex(check);
|
2134
|
+
if (!regex.test(input.data)) {
|
2135
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2136
|
+
addIssueToContext(ctx, {
|
2137
|
+
code: ZodIssueCode.invalid_string,
|
2138
|
+
validation: "time",
|
2139
|
+
message: check.message
|
2140
|
+
});
|
2141
|
+
status.dirty();
|
2142
|
+
}
|
2143
|
+
} else if (check.kind === "duration") {
|
2144
|
+
if (!durationRegex.test(input.data)) {
|
2145
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2146
|
+
addIssueToContext(ctx, {
|
2147
|
+
validation: "duration",
|
2148
|
+
code: ZodIssueCode.invalid_string,
|
2149
|
+
message: check.message
|
2150
|
+
});
|
2151
|
+
status.dirty();
|
2152
|
+
}
|
2153
|
+
} else if (check.kind === "ip") {
|
2154
|
+
if (!isValidIP(input.data, check.version)) {
|
2155
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2156
|
+
addIssueToContext(ctx, {
|
2157
|
+
validation: "ip",
|
2158
|
+
code: ZodIssueCode.invalid_string,
|
2159
|
+
message: check.message
|
2160
|
+
});
|
2161
|
+
status.dirty();
|
2162
|
+
}
|
2163
|
+
} else if (check.kind === "base64") {
|
2164
|
+
if (!base64Regex.test(input.data)) {
|
2165
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2166
|
+
addIssueToContext(ctx, {
|
2167
|
+
validation: "base64",
|
2168
|
+
code: ZodIssueCode.invalid_string,
|
2169
|
+
message: check.message
|
2170
|
+
});
|
2171
|
+
status.dirty();
|
2172
|
+
}
|
1979
2173
|
} else {
|
1980
2174
|
util.assertNever(check);
|
1981
2175
|
}
|
1982
2176
|
}
|
1983
2177
|
return { status: status.value, value: input.data };
|
1984
2178
|
}
|
2179
|
+
_regex(regex, validation, message) {
|
2180
|
+
return this.refinement((data) => regex.test(data), {
|
2181
|
+
validation,
|
2182
|
+
code: ZodIssueCode.invalid_string,
|
2183
|
+
...errorUtil.errToObj(message)
|
2184
|
+
});
|
2185
|
+
}
|
1985
2186
|
_addCheck(check) {
|
1986
2187
|
return new _ZodString({
|
1987
2188
|
...this._def,
|
@@ -1994,19 +2195,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
1994
2195
|
url(message) {
|
1995
2196
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
1996
2197
|
}
|
2198
|
+
emoji(message) {
|
2199
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
2200
|
+
}
|
1997
2201
|
uuid(message) {
|
1998
2202
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
1999
2203
|
}
|
2204
|
+
nanoid(message) {
|
2205
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
2206
|
+
}
|
2000
2207
|
cuid(message) {
|
2001
2208
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
2002
2209
|
}
|
2210
|
+
cuid2(message) {
|
2211
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
2212
|
+
}
|
2213
|
+
ulid(message) {
|
2214
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
2215
|
+
}
|
2216
|
+
base64(message) {
|
2217
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
2218
|
+
}
|
2219
|
+
ip(options) {
|
2220
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
2221
|
+
}
|
2003
2222
|
datetime(options) {
|
2004
|
-
var _a;
|
2223
|
+
var _a, _b;
|
2005
2224
|
if (typeof options === "string") {
|
2006
2225
|
return this._addCheck({
|
2007
2226
|
kind: "datetime",
|
2008
2227
|
precision: null,
|
2009
2228
|
offset: false,
|
2229
|
+
local: false,
|
2010
2230
|
message: options
|
2011
2231
|
});
|
2012
2232
|
}
|
@@ -2014,9 +2234,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
2014
2234
|
kind: "datetime",
|
2015
2235
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2016
2236
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
2237
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
2238
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2239
|
+
});
|
2240
|
+
}
|
2241
|
+
date(message) {
|
2242
|
+
return this._addCheck({ kind: "date", message });
|
2243
|
+
}
|
2244
|
+
time(options) {
|
2245
|
+
if (typeof options === "string") {
|
2246
|
+
return this._addCheck({
|
2247
|
+
kind: "time",
|
2248
|
+
precision: null,
|
2249
|
+
message: options
|
2250
|
+
});
|
2251
|
+
}
|
2252
|
+
return this._addCheck({
|
2253
|
+
kind: "time",
|
2254
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2017
2255
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2018
2256
|
});
|
2019
2257
|
}
|
2258
|
+
duration(message) {
|
2259
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
2260
|
+
}
|
2020
2261
|
regex(regex, message) {
|
2021
2262
|
return this._addCheck({
|
2022
2263
|
kind: "regex",
|
@@ -2024,6 +2265,14 @@ var ZodString = class _ZodString extends ZodType {
|
|
2024
2265
|
...errorUtil.errToObj(message)
|
2025
2266
|
});
|
2026
2267
|
}
|
2268
|
+
includes(value, options) {
|
2269
|
+
return this._addCheck({
|
2270
|
+
kind: "includes",
|
2271
|
+
value,
|
2272
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
2273
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2274
|
+
});
|
2275
|
+
}
|
2027
2276
|
startsWith(value, message) {
|
2028
2277
|
return this._addCheck({
|
2029
2278
|
kind: "startsWith",
|
@@ -2059,21 +2308,73 @@ var ZodString = class _ZodString extends ZodType {
|
|
2059
2308
|
...errorUtil.errToObj(message)
|
2060
2309
|
});
|
2061
2310
|
}
|
2311
|
+
/**
|
2312
|
+
* @deprecated Use z.string().min(1) instead.
|
2313
|
+
* @see {@link ZodString.min}
|
2314
|
+
*/
|
2315
|
+
nonempty(message) {
|
2316
|
+
return this.min(1, errorUtil.errToObj(message));
|
2317
|
+
}
|
2318
|
+
trim() {
|
2319
|
+
return new _ZodString({
|
2320
|
+
...this._def,
|
2321
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
2322
|
+
});
|
2323
|
+
}
|
2324
|
+
toLowerCase() {
|
2325
|
+
return new _ZodString({
|
2326
|
+
...this._def,
|
2327
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
2328
|
+
});
|
2329
|
+
}
|
2330
|
+
toUpperCase() {
|
2331
|
+
return new _ZodString({
|
2332
|
+
...this._def,
|
2333
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
2334
|
+
});
|
2335
|
+
}
|
2062
2336
|
get isDatetime() {
|
2063
2337
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
2064
2338
|
}
|
2339
|
+
get isDate() {
|
2340
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
2341
|
+
}
|
2342
|
+
get isTime() {
|
2343
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
2344
|
+
}
|
2345
|
+
get isDuration() {
|
2346
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
2347
|
+
}
|
2065
2348
|
get isEmail() {
|
2066
2349
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
2067
2350
|
}
|
2068
2351
|
get isURL() {
|
2069
2352
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
2070
2353
|
}
|
2354
|
+
get isEmoji() {
|
2355
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
2356
|
+
}
|
2071
2357
|
get isUUID() {
|
2072
2358
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
2073
2359
|
}
|
2360
|
+
get isNANOID() {
|
2361
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
2362
|
+
}
|
2074
2363
|
get isCUID() {
|
2075
2364
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
2076
2365
|
}
|
2366
|
+
get isCUID2() {
|
2367
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
2368
|
+
}
|
2369
|
+
get isULID() {
|
2370
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
2371
|
+
}
|
2372
|
+
get isIP() {
|
2373
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
2374
|
+
}
|
2375
|
+
get isBase64() {
|
2376
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
2377
|
+
}
|
2077
2378
|
get minLength() {
|
2078
2379
|
let min = null;
|
2079
2380
|
for (const ch of this._def.checks) {
|
@@ -2283,6 +2584,19 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
2283
2584
|
message: errorUtil.toString(message)
|
2284
2585
|
});
|
2285
2586
|
}
|
2587
|
+
safe(message) {
|
2588
|
+
return this._addCheck({
|
2589
|
+
kind: "min",
|
2590
|
+
inclusive: true,
|
2591
|
+
value: Number.MIN_SAFE_INTEGER,
|
2592
|
+
message: errorUtil.toString(message)
|
2593
|
+
})._addCheck({
|
2594
|
+
kind: "max",
|
2595
|
+
inclusive: true,
|
2596
|
+
value: Number.MAX_SAFE_INTEGER,
|
2597
|
+
message: errorUtil.toString(message)
|
2598
|
+
});
|
2599
|
+
}
|
2286
2600
|
get minValue() {
|
2287
2601
|
let min = null;
|
2288
2602
|
for (const ch of this._def.checks) {
|
@@ -2304,7 +2618,22 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
2304
2618
|
return max;
|
2305
2619
|
}
|
2306
2620
|
get isInt() {
|
2307
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
2621
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2622
|
+
}
|
2623
|
+
get isFinite() {
|
2624
|
+
let max = null, min = null;
|
2625
|
+
for (const ch of this._def.checks) {
|
2626
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2627
|
+
return true;
|
2628
|
+
} else if (ch.kind === "min") {
|
2629
|
+
if (min === null || ch.value > min)
|
2630
|
+
min = ch.value;
|
2631
|
+
} else if (ch.kind === "max") {
|
2632
|
+
if (max === null || ch.value < max)
|
2633
|
+
max = ch.value;
|
2634
|
+
}
|
2635
|
+
}
|
2636
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
2308
2637
|
}
|
2309
2638
|
};
|
2310
2639
|
ZodNumber.create = (params) => {
|
@@ -2315,27 +2644,167 @@ ZodNumber.create = (params) => {
|
|
2315
2644
|
...processCreateParams(params)
|
2316
2645
|
});
|
2317
2646
|
};
|
2318
|
-
var ZodBigInt = class extends ZodType {
|
2647
|
+
var ZodBigInt = class _ZodBigInt extends ZodType {
|
2648
|
+
constructor() {
|
2649
|
+
super(...arguments);
|
2650
|
+
this.min = this.gte;
|
2651
|
+
this.max = this.lte;
|
2652
|
+
}
|
2319
2653
|
_parse(input) {
|
2320
2654
|
if (this._def.coerce) {
|
2321
2655
|
input.data = BigInt(input.data);
|
2322
2656
|
}
|
2323
2657
|
const parsedType = this._getType(input);
|
2324
2658
|
if (parsedType !== ZodParsedType.bigint) {
|
2325
|
-
const
|
2326
|
-
addIssueToContext(
|
2659
|
+
const ctx2 = this._getOrReturnCtx(input);
|
2660
|
+
addIssueToContext(ctx2, {
|
2327
2661
|
code: ZodIssueCode.invalid_type,
|
2328
2662
|
expected: ZodParsedType.bigint,
|
2329
|
-
received:
|
2663
|
+
received: ctx2.parsedType
|
2330
2664
|
});
|
2331
2665
|
return INVALID;
|
2332
2666
|
}
|
2333
|
-
|
2667
|
+
let ctx = void 0;
|
2668
|
+
const status = new ParseStatus();
|
2669
|
+
for (const check of this._def.checks) {
|
2670
|
+
if (check.kind === "min") {
|
2671
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
2672
|
+
if (tooSmall) {
|
2673
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2674
|
+
addIssueToContext(ctx, {
|
2675
|
+
code: ZodIssueCode.too_small,
|
2676
|
+
type: "bigint",
|
2677
|
+
minimum: check.value,
|
2678
|
+
inclusive: check.inclusive,
|
2679
|
+
message: check.message
|
2680
|
+
});
|
2681
|
+
status.dirty();
|
2682
|
+
}
|
2683
|
+
} else if (check.kind === "max") {
|
2684
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
2685
|
+
if (tooBig) {
|
2686
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2687
|
+
addIssueToContext(ctx, {
|
2688
|
+
code: ZodIssueCode.too_big,
|
2689
|
+
type: "bigint",
|
2690
|
+
maximum: check.value,
|
2691
|
+
inclusive: check.inclusive,
|
2692
|
+
message: check.message
|
2693
|
+
});
|
2694
|
+
status.dirty();
|
2695
|
+
}
|
2696
|
+
} else if (check.kind === "multipleOf") {
|
2697
|
+
if (input.data % check.value !== BigInt(0)) {
|
2698
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2699
|
+
addIssueToContext(ctx, {
|
2700
|
+
code: ZodIssueCode.not_multiple_of,
|
2701
|
+
multipleOf: check.value,
|
2702
|
+
message: check.message
|
2703
|
+
});
|
2704
|
+
status.dirty();
|
2705
|
+
}
|
2706
|
+
} else {
|
2707
|
+
util.assertNever(check);
|
2708
|
+
}
|
2709
|
+
}
|
2710
|
+
return { status: status.value, value: input.data };
|
2711
|
+
}
|
2712
|
+
gte(value, message) {
|
2713
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2714
|
+
}
|
2715
|
+
gt(value, message) {
|
2716
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
2717
|
+
}
|
2718
|
+
lte(value, message) {
|
2719
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
2720
|
+
}
|
2721
|
+
lt(value, message) {
|
2722
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2723
|
+
}
|
2724
|
+
setLimit(kind, value, inclusive, message) {
|
2725
|
+
return new _ZodBigInt({
|
2726
|
+
...this._def,
|
2727
|
+
checks: [
|
2728
|
+
...this._def.checks,
|
2729
|
+
{
|
2730
|
+
kind,
|
2731
|
+
value,
|
2732
|
+
inclusive,
|
2733
|
+
message: errorUtil.toString(message)
|
2734
|
+
}
|
2735
|
+
]
|
2736
|
+
});
|
2737
|
+
}
|
2738
|
+
_addCheck(check) {
|
2739
|
+
return new _ZodBigInt({
|
2740
|
+
...this._def,
|
2741
|
+
checks: [...this._def.checks, check]
|
2742
|
+
});
|
2743
|
+
}
|
2744
|
+
positive(message) {
|
2745
|
+
return this._addCheck({
|
2746
|
+
kind: "min",
|
2747
|
+
value: BigInt(0),
|
2748
|
+
inclusive: false,
|
2749
|
+
message: errorUtil.toString(message)
|
2750
|
+
});
|
2751
|
+
}
|
2752
|
+
negative(message) {
|
2753
|
+
return this._addCheck({
|
2754
|
+
kind: "max",
|
2755
|
+
value: BigInt(0),
|
2756
|
+
inclusive: false,
|
2757
|
+
message: errorUtil.toString(message)
|
2758
|
+
});
|
2759
|
+
}
|
2760
|
+
nonpositive(message) {
|
2761
|
+
return this._addCheck({
|
2762
|
+
kind: "max",
|
2763
|
+
value: BigInt(0),
|
2764
|
+
inclusive: true,
|
2765
|
+
message: errorUtil.toString(message)
|
2766
|
+
});
|
2767
|
+
}
|
2768
|
+
nonnegative(message) {
|
2769
|
+
return this._addCheck({
|
2770
|
+
kind: "min",
|
2771
|
+
value: BigInt(0),
|
2772
|
+
inclusive: true,
|
2773
|
+
message: errorUtil.toString(message)
|
2774
|
+
});
|
2775
|
+
}
|
2776
|
+
multipleOf(value, message) {
|
2777
|
+
return this._addCheck({
|
2778
|
+
kind: "multipleOf",
|
2779
|
+
value,
|
2780
|
+
message: errorUtil.toString(message)
|
2781
|
+
});
|
2782
|
+
}
|
2783
|
+
get minValue() {
|
2784
|
+
let min = null;
|
2785
|
+
for (const ch of this._def.checks) {
|
2786
|
+
if (ch.kind === "min") {
|
2787
|
+
if (min === null || ch.value > min)
|
2788
|
+
min = ch.value;
|
2789
|
+
}
|
2790
|
+
}
|
2791
|
+
return min;
|
2792
|
+
}
|
2793
|
+
get maxValue() {
|
2794
|
+
let max = null;
|
2795
|
+
for (const ch of this._def.checks) {
|
2796
|
+
if (ch.kind === "max") {
|
2797
|
+
if (max === null || ch.value < max)
|
2798
|
+
max = ch.value;
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
return max;
|
2334
2802
|
}
|
2335
2803
|
};
|
2336
2804
|
ZodBigInt.create = (params) => {
|
2337
2805
|
var _a;
|
2338
2806
|
return new ZodBigInt({
|
2807
|
+
checks: [],
|
2339
2808
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2340
2809
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
2341
2810
|
...processCreateParams(params)
|
@@ -2661,13 +3130,13 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
2661
3130
|
}
|
2662
3131
|
}
|
2663
3132
|
if (ctx.common.async) {
|
2664
|
-
return Promise.all(ctx.data.map((item, i) => {
|
3133
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
2665
3134
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2666
3135
|
})).then((result2) => {
|
2667
3136
|
return ParseStatus.mergeArray(status, result2);
|
2668
3137
|
});
|
2669
3138
|
}
|
2670
|
-
const result = ctx.data.map((item, i) => {
|
3139
|
+
const result = [...ctx.data].map((item, i) => {
|
2671
3140
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2672
3141
|
});
|
2673
3142
|
return ParseStatus.mergeArray(status, result);
|
@@ -2707,25 +3176,6 @@ ZodArray.create = (schema3, params) => {
|
|
2707
3176
|
...processCreateParams(params)
|
2708
3177
|
});
|
2709
3178
|
};
|
2710
|
-
var objectUtil;
|
2711
|
-
(function(objectUtil2) {
|
2712
|
-
objectUtil2.mergeShapes = (first, second) => {
|
2713
|
-
return {
|
2714
|
-
...first,
|
2715
|
-
...second
|
2716
|
-
// second overwrites first
|
2717
|
-
};
|
2718
|
-
};
|
2719
|
-
})(objectUtil || (objectUtil = {}));
|
2720
|
-
var AugmentFactory = (def) => (augmentation) => {
|
2721
|
-
return new ZodObject({
|
2722
|
-
...def,
|
2723
|
-
shape: () => ({
|
2724
|
-
...def.shape(),
|
2725
|
-
...augmentation
|
2726
|
-
})
|
2727
|
-
});
|
2728
|
-
};
|
2729
3179
|
function deepPartialify(schema3) {
|
2730
3180
|
if (schema3 instanceof ZodObject) {
|
2731
3181
|
const newShape = {};
|
@@ -2738,7 +3188,10 @@ function deepPartialify(schema3) {
|
|
2738
3188
|
shape: () => newShape
|
2739
3189
|
});
|
2740
3190
|
} else if (schema3 instanceof ZodArray) {
|
2741
|
-
return ZodArray
|
3191
|
+
return new ZodArray({
|
3192
|
+
...schema3._def,
|
3193
|
+
type: deepPartialify(schema3.element)
|
3194
|
+
});
|
2742
3195
|
} else if (schema3 instanceof ZodOptional) {
|
2743
3196
|
return ZodOptional.create(deepPartialify(schema3.unwrap()));
|
2744
3197
|
} else if (schema3 instanceof ZodNullable) {
|
@@ -2754,8 +3207,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2754
3207
|
super(...arguments);
|
2755
3208
|
this._cached = null;
|
2756
3209
|
this.nonstrict = this.passthrough;
|
2757
|
-
this.augment =
|
2758
|
-
this.extend = AugmentFactory(this._def);
|
3210
|
+
this.augment = this.extend;
|
2759
3211
|
}
|
2760
3212
|
_getCached() {
|
2761
3213
|
if (this._cached !== null)
|
@@ -2836,9 +3288,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2836
3288
|
const syncPairs = [];
|
2837
3289
|
for (const pair of pairs) {
|
2838
3290
|
const key = await pair.key;
|
3291
|
+
const value = await pair.value;
|
2839
3292
|
syncPairs.push({
|
2840
3293
|
key,
|
2841
|
-
value
|
3294
|
+
value,
|
2842
3295
|
alwaysSet: pair.alwaysSet
|
2843
3296
|
});
|
2844
3297
|
}
|
@@ -2885,8 +3338,31 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2885
3338
|
unknownKeys: "passthrough"
|
2886
3339
|
});
|
2887
3340
|
}
|
2888
|
-
|
2889
|
-
|
3341
|
+
// const AugmentFactory =
|
3342
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
3343
|
+
// <Augmentation extends ZodRawShape>(
|
3344
|
+
// augmentation: Augmentation
|
3345
|
+
// ): ZodObject<
|
3346
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
3347
|
+
// Def["unknownKeys"],
|
3348
|
+
// Def["catchall"]
|
3349
|
+
// > => {
|
3350
|
+
// return new ZodObject({
|
3351
|
+
// ...def,
|
3352
|
+
// shape: () => ({
|
3353
|
+
// ...def.shape(),
|
3354
|
+
// ...augmentation,
|
3355
|
+
// }),
|
3356
|
+
// }) as any;
|
3357
|
+
// };
|
3358
|
+
extend(augmentation) {
|
3359
|
+
return new _ZodObject({
|
3360
|
+
...this._def,
|
3361
|
+
shape: () => ({
|
3362
|
+
...this._def.shape(),
|
3363
|
+
...augmentation
|
3364
|
+
})
|
3365
|
+
});
|
2890
3366
|
}
|
2891
3367
|
/**
|
2892
3368
|
* Prior to zod@1.0.12 there was a bug in the
|
@@ -2897,11 +3373,73 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2897
3373
|
const merged = new _ZodObject({
|
2898
3374
|
unknownKeys: merging._def.unknownKeys,
|
2899
3375
|
catchall: merging._def.catchall,
|
2900
|
-
shape: () =>
|
3376
|
+
shape: () => ({
|
3377
|
+
...this._def.shape(),
|
3378
|
+
...merging._def.shape()
|
3379
|
+
}),
|
2901
3380
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
2902
3381
|
});
|
2903
3382
|
return merged;
|
2904
3383
|
}
|
3384
|
+
// merge<
|
3385
|
+
// Incoming extends AnyZodObject,
|
3386
|
+
// Augmentation extends Incoming["shape"],
|
3387
|
+
// NewOutput extends {
|
3388
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
3389
|
+
// ? Augmentation[k]["_output"]
|
3390
|
+
// : k extends keyof Output
|
3391
|
+
// ? Output[k]
|
3392
|
+
// : never;
|
3393
|
+
// },
|
3394
|
+
// NewInput extends {
|
3395
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
3396
|
+
// ? Augmentation[k]["_input"]
|
3397
|
+
// : k extends keyof Input
|
3398
|
+
// ? Input[k]
|
3399
|
+
// : never;
|
3400
|
+
// }
|
3401
|
+
// >(
|
3402
|
+
// merging: Incoming
|
3403
|
+
// ): ZodObject<
|
3404
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
3405
|
+
// Incoming["_def"]["unknownKeys"],
|
3406
|
+
// Incoming["_def"]["catchall"],
|
3407
|
+
// NewOutput,
|
3408
|
+
// NewInput
|
3409
|
+
// > {
|
3410
|
+
// const merged: any = new ZodObject({
|
3411
|
+
// unknownKeys: merging._def.unknownKeys,
|
3412
|
+
// catchall: merging._def.catchall,
|
3413
|
+
// shape: () =>
|
3414
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
3415
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
3416
|
+
// }) as any;
|
3417
|
+
// return merged;
|
3418
|
+
// }
|
3419
|
+
setKey(key, schema3) {
|
3420
|
+
return this.augment({ [key]: schema3 });
|
3421
|
+
}
|
3422
|
+
// merge<Incoming extends AnyZodObject>(
|
3423
|
+
// merging: Incoming
|
3424
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
3425
|
+
// ZodObject<
|
3426
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
3427
|
+
// Incoming["_def"]["unknownKeys"],
|
3428
|
+
// Incoming["_def"]["catchall"]
|
3429
|
+
// > {
|
3430
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
3431
|
+
// // this._def.shape(),
|
3432
|
+
// // merging._def.shape()
|
3433
|
+
// // );
|
3434
|
+
// const merged: any = new ZodObject({
|
3435
|
+
// unknownKeys: merging._def.unknownKeys,
|
3436
|
+
// catchall: merging._def.catchall,
|
3437
|
+
// shape: () =>
|
3438
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
3439
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
3440
|
+
// }) as any;
|
3441
|
+
// return merged;
|
3442
|
+
// }
|
2905
3443
|
catchall(index4) {
|
2906
3444
|
return new _ZodObject({
|
2907
3445
|
...this._def,
|
@@ -2910,9 +3448,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2910
3448
|
}
|
2911
3449
|
pick(mask) {
|
2912
3450
|
const shape = {};
|
2913
|
-
util.objectKeys(mask).
|
2914
|
-
if (this.shape[key])
|
3451
|
+
util.objectKeys(mask).forEach((key) => {
|
3452
|
+
if (mask[key] && this.shape[key]) {
|
2915
3453
|
shape[key] = this.shape[key];
|
3454
|
+
}
|
2916
3455
|
});
|
2917
3456
|
return new _ZodObject({
|
2918
3457
|
...this._def,
|
@@ -2921,8 +3460,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2921
3460
|
}
|
2922
3461
|
omit(mask) {
|
2923
3462
|
const shape = {};
|
2924
|
-
util.objectKeys(this.shape).
|
2925
|
-
if (
|
3463
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3464
|
+
if (!mask[key]) {
|
2926
3465
|
shape[key] = this.shape[key];
|
2927
3466
|
}
|
2928
3467
|
});
|
@@ -2931,29 +3470,22 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2931
3470
|
shape: () => shape
|
2932
3471
|
});
|
2933
3472
|
}
|
3473
|
+
/**
|
3474
|
+
* @deprecated
|
3475
|
+
*/
|
2934
3476
|
deepPartial() {
|
2935
3477
|
return deepPartialify(this);
|
2936
3478
|
}
|
2937
3479
|
partial(mask) {
|
2938
3480
|
const newShape = {};
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
newShape[key] = this.shape[key].optional();
|
2945
|
-
}
|
2946
|
-
});
|
2947
|
-
return new _ZodObject({
|
2948
|
-
...this._def,
|
2949
|
-
shape: () => newShape
|
2950
|
-
});
|
2951
|
-
} else {
|
2952
|
-
for (const key in this.shape) {
|
2953
|
-
const fieldSchema = this.shape[key];
|
3481
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3482
|
+
const fieldSchema = this.shape[key];
|
3483
|
+
if (mask && !mask[key]) {
|
3484
|
+
newShape[key] = fieldSchema;
|
3485
|
+
} else {
|
2954
3486
|
newShape[key] = fieldSchema.optional();
|
2955
3487
|
}
|
2956
|
-
}
|
3488
|
+
});
|
2957
3489
|
return new _ZodObject({
|
2958
3490
|
...this._def,
|
2959
3491
|
shape: () => newShape
|
@@ -2961,21 +3493,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2961
3493
|
}
|
2962
3494
|
required(mask) {
|
2963
3495
|
const newShape = {};
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
} else {
|
2969
|
-
const fieldSchema = this.shape[key];
|
2970
|
-
let newField = fieldSchema;
|
2971
|
-
while (newField instanceof ZodOptional) {
|
2972
|
-
newField = newField._def.innerType;
|
2973
|
-
}
|
2974
|
-
newShape[key] = newField;
|
2975
|
-
}
|
2976
|
-
});
|
2977
|
-
} else {
|
2978
|
-
for (const key in this.shape) {
|
3496
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3497
|
+
if (mask && !mask[key]) {
|
3498
|
+
newShape[key] = this.shape[key];
|
3499
|
+
} else {
|
2979
3500
|
const fieldSchema = this.shape[key];
|
2980
3501
|
let newField = fieldSchema;
|
2981
3502
|
while (newField instanceof ZodOptional) {
|
@@ -2983,7 +3504,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
2983
3504
|
}
|
2984
3505
|
newShape[key] = newField;
|
2985
3506
|
}
|
2986
|
-
}
|
3507
|
+
});
|
2987
3508
|
return new _ZodObject({
|
2988
3509
|
...this._def,
|
2989
3510
|
shape: () => newShape
|
@@ -3121,15 +3642,25 @@ var getDiscriminator = (type) => {
|
|
3121
3642
|
} else if (type instanceof ZodEnum) {
|
3122
3643
|
return type.options;
|
3123
3644
|
} else if (type instanceof ZodNativeEnum) {
|
3124
|
-
return
|
3645
|
+
return util.objectValues(type.enum);
|
3125
3646
|
} else if (type instanceof ZodDefault) {
|
3126
3647
|
return getDiscriminator(type._def.innerType);
|
3127
3648
|
} else if (type instanceof ZodUndefined) {
|
3128
3649
|
return [void 0];
|
3129
3650
|
} else if (type instanceof ZodNull) {
|
3130
3651
|
return [null];
|
3652
|
+
} else if (type instanceof ZodOptional) {
|
3653
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
3654
|
+
} else if (type instanceof ZodNullable) {
|
3655
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
3656
|
+
} else if (type instanceof ZodBranded) {
|
3657
|
+
return getDiscriminator(type.unwrap());
|
3658
|
+
} else if (type instanceof ZodReadonly) {
|
3659
|
+
return getDiscriminator(type.unwrap());
|
3660
|
+
} else if (type instanceof ZodCatch) {
|
3661
|
+
return getDiscriminator(type._def.innerType);
|
3131
3662
|
} else {
|
3132
|
-
return
|
3663
|
+
return [];
|
3133
3664
|
}
|
3134
3665
|
};
|
3135
3666
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
@@ -3189,7 +3720,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
3189
3720
|
const optionsMap = /* @__PURE__ */ new Map();
|
3190
3721
|
for (const type of options) {
|
3191
3722
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
3192
|
-
if (!discriminatorValues) {
|
3723
|
+
if (!discriminatorValues.length) {
|
3193
3724
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
3194
3725
|
}
|
3195
3726
|
for (const value of discriminatorValues) {
|
@@ -3331,7 +3862,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
|
|
3331
3862
|
});
|
3332
3863
|
status.dirty();
|
3333
3864
|
}
|
3334
|
-
const items = ctx.data.map((item, itemIndex) => {
|
3865
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
3335
3866
|
const schema3 = this._def.items[itemIndex] || this._def.rest;
|
3336
3867
|
if (!schema3)
|
3337
3868
|
return null;
|
@@ -3389,7 +3920,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
3389
3920
|
for (const key in ctx.data) {
|
3390
3921
|
pairs.push({
|
3391
3922
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
3392
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
3923
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
3924
|
+
alwaysSet: key in ctx.data
|
3393
3925
|
});
|
3394
3926
|
}
|
3395
3927
|
if (ctx.common.async) {
|
@@ -3419,6 +3951,12 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
3419
3951
|
}
|
3420
3952
|
};
|
3421
3953
|
var ZodMap = class extends ZodType {
|
3954
|
+
get keySchema() {
|
3955
|
+
return this._def.keyType;
|
3956
|
+
}
|
3957
|
+
get valueSchema() {
|
3958
|
+
return this._def.valueType;
|
3959
|
+
}
|
3422
3960
|
_parse(input) {
|
3423
3961
|
const { status, ctx } = this._processInputParams(input);
|
3424
3962
|
if (ctx.parsedType !== ZodParsedType.map) {
|
@@ -3613,27 +4151,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
3613
4151
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
3614
4152
|
const fn = ctx.data;
|
3615
4153
|
if (this._def.returns instanceof ZodPromise) {
|
3616
|
-
|
4154
|
+
const me = this;
|
4155
|
+
return OK(async function(...args) {
|
3617
4156
|
const error = new ZodError([]);
|
3618
|
-
const parsedArgs = await
|
4157
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
3619
4158
|
error.addIssue(makeArgsIssue(args, e));
|
3620
4159
|
throw error;
|
3621
4160
|
});
|
3622
|
-
const result = await fn
|
3623
|
-
const parsedReturns = await
|
4161
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
4162
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
3624
4163
|
error.addIssue(makeReturnsIssue(result, e));
|
3625
4164
|
throw error;
|
3626
4165
|
});
|
3627
4166
|
return parsedReturns;
|
3628
4167
|
});
|
3629
4168
|
} else {
|
3630
|
-
|
3631
|
-
|
4169
|
+
const me = this;
|
4170
|
+
return OK(function(...args) {
|
4171
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
3632
4172
|
if (!parsedArgs.success) {
|
3633
4173
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
3634
4174
|
}
|
3635
|
-
const result = fn
|
3636
|
-
const parsedReturns =
|
4175
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
4176
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
3637
4177
|
if (!parsedReturns.success) {
|
3638
4178
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
3639
4179
|
}
|
@@ -3698,6 +4238,7 @@ var ZodLiteral = class extends ZodType {
|
|
3698
4238
|
if (input.data !== this._def.value) {
|
3699
4239
|
const ctx = this._getOrReturnCtx(input);
|
3700
4240
|
addIssueToContext(ctx, {
|
4241
|
+
received: ctx.data,
|
3701
4242
|
code: ZodIssueCode.invalid_literal,
|
3702
4243
|
expected: this._def.value
|
3703
4244
|
});
|
@@ -3723,7 +4264,11 @@ function createZodEnum(values, params) {
|
|
3723
4264
|
...processCreateParams(params)
|
3724
4265
|
});
|
3725
4266
|
}
|
3726
|
-
var ZodEnum = class extends ZodType {
|
4267
|
+
var ZodEnum = class _ZodEnum extends ZodType {
|
4268
|
+
constructor() {
|
4269
|
+
super(...arguments);
|
4270
|
+
_ZodEnum_cache.set(this, void 0);
|
4271
|
+
}
|
3727
4272
|
_parse(input) {
|
3728
4273
|
if (typeof input.data !== "string") {
|
3729
4274
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3735,7 +4280,10 @@ var ZodEnum = class extends ZodType {
|
|
3735
4280
|
});
|
3736
4281
|
return INVALID;
|
3737
4282
|
}
|
3738
|
-
if (this
|
4283
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
4284
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
4285
|
+
}
|
4286
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
3739
4287
|
const ctx = this._getOrReturnCtx(input);
|
3740
4288
|
const expectedValues = this._def.values;
|
3741
4289
|
addIssueToContext(ctx, {
|
@@ -3771,9 +4319,26 @@ var ZodEnum = class extends ZodType {
|
|
3771
4319
|
}
|
3772
4320
|
return enumValues;
|
3773
4321
|
}
|
4322
|
+
extract(values, newDef = this._def) {
|
4323
|
+
return _ZodEnum.create(values, {
|
4324
|
+
...this._def,
|
4325
|
+
...newDef
|
4326
|
+
});
|
4327
|
+
}
|
4328
|
+
exclude(values, newDef = this._def) {
|
4329
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
4330
|
+
...this._def,
|
4331
|
+
...newDef
|
4332
|
+
});
|
4333
|
+
}
|
3774
4334
|
};
|
4335
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
3775
4336
|
ZodEnum.create = createZodEnum;
|
3776
4337
|
var ZodNativeEnum = class extends ZodType {
|
4338
|
+
constructor() {
|
4339
|
+
super(...arguments);
|
4340
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
4341
|
+
}
|
3777
4342
|
_parse(input) {
|
3778
4343
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
3779
4344
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3786,7 +4351,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
3786
4351
|
});
|
3787
4352
|
return INVALID;
|
3788
4353
|
}
|
3789
|
-
if (
|
4354
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
4355
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
4356
|
+
}
|
4357
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
3790
4358
|
const expectedValues = util.objectValues(nativeEnumValues);
|
3791
4359
|
addIssueToContext(ctx, {
|
3792
4360
|
received: ctx.data,
|
@@ -3801,6 +4369,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
3801
4369
|
return this._def.values;
|
3802
4370
|
}
|
3803
4371
|
};
|
4372
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
3804
4373
|
ZodNativeEnum.create = (values, params) => {
|
3805
4374
|
return new ZodNativeEnum({
|
3806
4375
|
values,
|
@@ -3809,6 +4378,9 @@ ZodNativeEnum.create = (values, params) => {
|
|
3809
4378
|
});
|
3810
4379
|
};
|
3811
4380
|
var ZodPromise = class extends ZodType {
|
4381
|
+
unwrap() {
|
4382
|
+
return this._def.type;
|
4383
|
+
}
|
3812
4384
|
_parse(input) {
|
3813
4385
|
const { ctx } = this._processInputParams(input);
|
3814
4386
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
@@ -3845,24 +4417,6 @@ var ZodEffects = class extends ZodType {
|
|
3845
4417
|
_parse(input) {
|
3846
4418
|
const { status, ctx } = this._processInputParams(input);
|
3847
4419
|
const effect = this._def.effect || null;
|
3848
|
-
if (effect.type === "preprocess") {
|
3849
|
-
const processed = effect.transform(ctx.data);
|
3850
|
-
if (ctx.common.async) {
|
3851
|
-
return Promise.resolve(processed).then((processed2) => {
|
3852
|
-
return this._def.schema._parseAsync({
|
3853
|
-
data: processed2,
|
3854
|
-
path: ctx.path,
|
3855
|
-
parent: ctx
|
3856
|
-
});
|
3857
|
-
});
|
3858
|
-
} else {
|
3859
|
-
return this._def.schema._parseSync({
|
3860
|
-
data: processed,
|
3861
|
-
path: ctx.path,
|
3862
|
-
parent: ctx
|
3863
|
-
});
|
3864
|
-
}
|
3865
|
-
}
|
3866
4420
|
const checkCtx = {
|
3867
4421
|
addIssue: (arg) => {
|
3868
4422
|
addIssueToContext(ctx, arg);
|
@@ -3877,6 +4431,42 @@ var ZodEffects = class extends ZodType {
|
|
3877
4431
|
}
|
3878
4432
|
};
|
3879
4433
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
4434
|
+
if (effect.type === "preprocess") {
|
4435
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
4436
|
+
if (ctx.common.async) {
|
4437
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
4438
|
+
if (status.value === "aborted")
|
4439
|
+
return INVALID;
|
4440
|
+
const result = await this._def.schema._parseAsync({
|
4441
|
+
data: processed2,
|
4442
|
+
path: ctx.path,
|
4443
|
+
parent: ctx
|
4444
|
+
});
|
4445
|
+
if (result.status === "aborted")
|
4446
|
+
return INVALID;
|
4447
|
+
if (result.status === "dirty")
|
4448
|
+
return DIRTY(result.value);
|
4449
|
+
if (status.value === "dirty")
|
4450
|
+
return DIRTY(result.value);
|
4451
|
+
return result;
|
4452
|
+
});
|
4453
|
+
} else {
|
4454
|
+
if (status.value === "aborted")
|
4455
|
+
return INVALID;
|
4456
|
+
const result = this._def.schema._parseSync({
|
4457
|
+
data: processed,
|
4458
|
+
path: ctx.path,
|
4459
|
+
parent: ctx
|
4460
|
+
});
|
4461
|
+
if (result.status === "aborted")
|
4462
|
+
return INVALID;
|
4463
|
+
if (result.status === "dirty")
|
4464
|
+
return DIRTY(result.value);
|
4465
|
+
if (status.value === "dirty")
|
4466
|
+
return DIRTY(result.value);
|
4467
|
+
return result;
|
4468
|
+
}
|
4469
|
+
}
|
3880
4470
|
if (effect.type === "refinement") {
|
3881
4471
|
const executeRefinement = (acc) => {
|
3882
4472
|
const result = effect.refinement(acc, checkCtx);
|
@@ -4019,26 +4609,45 @@ ZodDefault.create = (type, params) => {
|
|
4019
4609
|
var ZodCatch = class extends ZodType {
|
4020
4610
|
_parse(input) {
|
4021
4611
|
const { ctx } = this._processInputParams(input);
|
4612
|
+
const newCtx = {
|
4613
|
+
...ctx,
|
4614
|
+
common: {
|
4615
|
+
...ctx.common,
|
4616
|
+
issues: []
|
4617
|
+
}
|
4618
|
+
};
|
4022
4619
|
const result = this._def.innerType._parse({
|
4023
|
-
data:
|
4024
|
-
path:
|
4025
|
-
parent:
|
4620
|
+
data: newCtx.data,
|
4621
|
+
path: newCtx.path,
|
4622
|
+
parent: {
|
4623
|
+
...newCtx
|
4624
|
+
}
|
4026
4625
|
});
|
4027
4626
|
if (isAsync(result)) {
|
4028
4627
|
return result.then((result2) => {
|
4029
4628
|
return {
|
4030
4629
|
status: "valid",
|
4031
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
4630
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
4631
|
+
get error() {
|
4632
|
+
return new ZodError(newCtx.common.issues);
|
4633
|
+
},
|
4634
|
+
input: newCtx.data
|
4635
|
+
})
|
4032
4636
|
};
|
4033
4637
|
});
|
4034
4638
|
} else {
|
4035
4639
|
return {
|
4036
4640
|
status: "valid",
|
4037
|
-
value: result.status === "valid" ? result.value : this._def.
|
4641
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
4642
|
+
get error() {
|
4643
|
+
return new ZodError(newCtx.common.issues);
|
4644
|
+
},
|
4645
|
+
input: newCtx.data
|
4646
|
+
})
|
4038
4647
|
};
|
4039
4648
|
}
|
4040
4649
|
}
|
4041
|
-
|
4650
|
+
removeCatch() {
|
4042
4651
|
return this._def.innerType;
|
4043
4652
|
}
|
4044
4653
|
};
|
@@ -4046,7 +4655,7 @@ ZodCatch.create = (type, params) => {
|
|
4046
4655
|
return new ZodCatch({
|
4047
4656
|
innerType: type,
|
4048
4657
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
4049
|
-
|
4658
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
4050
4659
|
...processCreateParams(params)
|
4051
4660
|
});
|
4052
4661
|
};
|
@@ -4141,6 +4750,28 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
4141
4750
|
});
|
4142
4751
|
}
|
4143
4752
|
};
|
4753
|
+
var ZodReadonly = class extends ZodType {
|
4754
|
+
_parse(input) {
|
4755
|
+
const result = this._def.innerType._parse(input);
|
4756
|
+
const freeze = (data) => {
|
4757
|
+
if (isValid(data)) {
|
4758
|
+
data.value = Object.freeze(data.value);
|
4759
|
+
}
|
4760
|
+
return data;
|
4761
|
+
};
|
4762
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
4763
|
+
}
|
4764
|
+
unwrap() {
|
4765
|
+
return this._def.innerType;
|
4766
|
+
}
|
4767
|
+
};
|
4768
|
+
ZodReadonly.create = (type, params) => {
|
4769
|
+
return new ZodReadonly({
|
4770
|
+
innerType: type,
|
4771
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
4772
|
+
...processCreateParams(params)
|
4773
|
+
});
|
4774
|
+
};
|
4144
4775
|
var late = {
|
4145
4776
|
object: ZodObject.lazycreate
|
4146
4777
|
};
|
@@ -4181,6 +4812,7 @@ var ZodFirstPartyTypeKind;
|
|
4181
4812
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
4182
4813
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
4183
4814
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
4815
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
4184
4816
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
4185
4817
|
var stringType = ZodString.create;
|
4186
4818
|
var numberType = ZodNumber.create;
|
@@ -4728,6 +5360,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
|
|
4728
5360
|
|
4729
5361
|
// src/utils.ts
|
4730
5362
|
var import_path = require("path");
|
5363
|
+
var import_url = require("url");
|
4731
5364
|
var copy = (it) => {
|
4732
5365
|
return JSON.parse(JSON.stringify(it));
|
4733
5366
|
};
|
@@ -4794,7 +5427,6 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
4794
5427
|
}
|
4795
5428
|
const result2 = validator.safeParse(raw);
|
4796
5429
|
if (!result2.success) {
|
4797
|
-
console.error(result2.error);
|
4798
5430
|
accum.malformed.push(it);
|
4799
5431
|
return accum;
|
4800
5432
|
}
|
@@ -4897,6 +5529,29 @@ var kloudMeta = () => {
|
|
4897
5529
|
sqlite: []
|
4898
5530
|
};
|
4899
5531
|
};
|
5532
|
+
var normaliseSQLiteUrl = (it, type) => {
|
5533
|
+
if (type === "libsql") {
|
5534
|
+
if (it.startsWith("file:")) {
|
5535
|
+
return it;
|
5536
|
+
}
|
5537
|
+
try {
|
5538
|
+
const url = (0, import_url.parse)(it);
|
5539
|
+
if (url.protocol === null) {
|
5540
|
+
return `file:${it}`;
|
5541
|
+
}
|
5542
|
+
return it;
|
5543
|
+
} catch (e) {
|
5544
|
+
return `file:${it}`;
|
5545
|
+
}
|
5546
|
+
}
|
5547
|
+
if (type === "better-sqlite") {
|
5548
|
+
if (it.startsWith("file:")) {
|
5549
|
+
return it.substring(5);
|
5550
|
+
}
|
5551
|
+
return it;
|
5552
|
+
}
|
5553
|
+
assertUnreachable(type);
|
5554
|
+
};
|
4900
5555
|
// Annotate the CommonJS export names for ESM import in node:
|
4901
5556
|
0 && (module.exports = {
|
4902
5557
|
assertV1OutFolder,
|
@@ -4904,6 +5559,7 @@ var kloudMeta = () => {
|
|
4904
5559
|
copy,
|
4905
5560
|
dryJournal,
|
4906
5561
|
kloudMeta,
|
5562
|
+
normaliseSQLiteUrl,
|
4907
5563
|
objectValues,
|
4908
5564
|
prepareMigrationFolder,
|
4909
5565
|
prepareMigrationMeta,
|