drizzle-kit 0.21.2-dd5c3c4 → 0.21.2-dec02d3
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +34569 -26697
- 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 +530 -451
- package/payload.mjs +507 -428
- package/utils-studio.js +934 -246
- package/utils-studio.mjs +908 -220
- package/utils.js +842 -215
- package/utils.mjs +817 -190
package/utils-studio.js
CHANGED
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
33
33
|
));
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
35
35
|
|
36
|
-
// node_modules/.pnpm/chalk@5.
|
36
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
37
37
|
function assembleStyles() {
|
38
38
|
const codes = /* @__PURE__ */ new Map();
|
39
39
|
for (const [groupName, group] of Object.entries(styles)) {
|
@@ -150,7 +150,7 @@ function assembleStyles() {
|
|
150
150
|
}
|
151
151
|
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
152
152
|
var init_ansi_styles = __esm({
|
153
|
-
"node_modules/.pnpm/chalk@5.
|
153
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
154
154
|
ANSI_BACKGROUND_OFFSET = 10;
|
155
155
|
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
156
156
|
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
@@ -224,7 +224,7 @@ var init_ansi_styles = __esm({
|
|
224
224
|
}
|
225
225
|
});
|
226
226
|
|
227
|
-
// node_modules/.pnpm/chalk@5.
|
227
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
|
228
228
|
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
229
229
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
230
230
|
const position = argv.indexOf(prefix + flag);
|
@@ -288,7 +288,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
288
288
|
return 1;
|
289
289
|
}
|
290
290
|
if ("CI" in env) {
|
291
|
-
if ("GITHUB_ACTIONS" in env) {
|
291
|
+
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
|
292
292
|
return 3;
|
293
293
|
}
|
294
294
|
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
@@ -336,7 +336,7 @@ function createSupportsColor(stream, options = {}) {
|
|
336
336
|
}
|
337
337
|
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
338
338
|
var init_supports_color = __esm({
|
339
|
-
"node_modules/.pnpm/chalk@5.
|
339
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
340
340
|
import_node_process = __toESM(require("node:process"), 1);
|
341
341
|
import_node_os = __toESM(require("node:os"), 1);
|
342
342
|
import_node_tty = __toESM(require("node:tty"), 1);
|
@@ -354,7 +354,7 @@ var init_supports_color = __esm({
|
|
354
354
|
}
|
355
355
|
});
|
356
356
|
|
357
|
-
// node_modules/.pnpm/chalk@5.
|
357
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
358
358
|
function stringReplaceAll(string, substring, replacer) {
|
359
359
|
let index4 = string.indexOf(substring);
|
360
360
|
if (index4 === -1) {
|
@@ -384,21 +384,20 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
|
384
384
|
return returnValue;
|
385
385
|
}
|
386
386
|
var init_utilities = __esm({
|
387
|
-
"node_modules/.pnpm/chalk@5.
|
387
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
|
388
388
|
}
|
389
389
|
});
|
390
390
|
|
391
|
-
// node_modules/.pnpm/chalk@5.
|
391
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
|
392
392
|
function createChalk(options) {
|
393
393
|
return chalkFactory(options);
|
394
394
|
}
|
395
|
-
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
|
395
|
+
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
|
396
396
|
var init_source = __esm({
|
397
|
-
"node_modules/.pnpm/chalk@5.
|
397
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js"() {
|
398
398
|
init_ansi_styles();
|
399
399
|
init_supports_color();
|
400
400
|
init_utilities();
|
401
|
-
init_ansi_styles();
|
402
401
|
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
403
402
|
GENERATOR = Symbol("GENERATOR");
|
404
403
|
STYLER = Symbol("STYLER");
|
@@ -540,15 +539,16 @@ var init_source = __esm({
|
|
540
539
|
Object.defineProperties(createChalk.prototype, styles2);
|
541
540
|
chalk = createChalk();
|
542
541
|
chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
542
|
+
source_default = chalk;
|
543
543
|
}
|
544
544
|
});
|
545
545
|
|
546
546
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
|
547
547
|
var require_readline = __commonJS({
|
548
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(
|
548
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) {
|
549
549
|
"use strict";
|
550
|
-
Object.defineProperty(
|
551
|
-
|
550
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
551
|
+
exports2.prepareReadLine = void 0;
|
552
552
|
var prepareReadLine = () => {
|
553
553
|
const stdin = process.stdin;
|
554
554
|
const stdout = process.stdout;
|
@@ -564,13 +564,13 @@ var require_readline = __commonJS({
|
|
564
564
|
closable: rl
|
565
565
|
};
|
566
566
|
};
|
567
|
-
|
567
|
+
exports2.prepareReadLine = prepareReadLine;
|
568
568
|
}
|
569
569
|
});
|
570
570
|
|
571
571
|
// node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
572
572
|
var require_src = __commonJS({
|
573
|
-
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(
|
573
|
+
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
|
574
574
|
"use strict";
|
575
575
|
var ESC = "\x1B";
|
576
576
|
var CSI = `${ESC}[`;
|
@@ -631,10 +631,10 @@ var require_src = __commonJS({
|
|
631
631
|
|
632
632
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
|
633
633
|
var require_utils = __commonJS({
|
634
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(
|
634
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports2) {
|
635
635
|
"use strict";
|
636
|
-
Object.defineProperty(
|
637
|
-
|
636
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
637
|
+
exports2.clear = void 0;
|
638
638
|
var sisteransi_1 = require_src();
|
639
639
|
var strip = (str) => {
|
640
640
|
const pattern = [
|
@@ -655,13 +655,13 @@ var require_utils = __commonJS({
|
|
655
655
|
}
|
656
656
|
return sisteransi_1.erase.lines(rows);
|
657
657
|
};
|
658
|
-
|
658
|
+
exports2.clear = clear;
|
659
659
|
}
|
660
660
|
});
|
661
661
|
|
662
662
|
// node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
|
663
663
|
var require_lodash = __commonJS({
|
664
|
-
"node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(
|
664
|
+
"node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) {
|
665
665
|
var FUNC_ERROR_TEXT = "Expected a function";
|
666
666
|
var NAN = 0 / 0;
|
667
667
|
var symbolTag = "[object Symbol]";
|
@@ -809,9 +809,9 @@ var require_lodash = __commonJS({
|
|
809
809
|
|
810
810
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
|
811
811
|
var require_hanji = __commonJS({
|
812
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(
|
812
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports2) {
|
813
813
|
"use strict";
|
814
|
-
var __awaiter =
|
814
|
+
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
|
815
815
|
function adopt(value) {
|
816
816
|
return value instanceof P ? value : new P(function(resolve) {
|
817
817
|
resolve(value);
|
@@ -838,11 +838,11 @@ var require_hanji = __commonJS({
|
|
838
838
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
839
839
|
});
|
840
840
|
};
|
841
|
-
var __importDefault =
|
841
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
842
842
|
return mod && mod.__esModule ? mod : { "default": mod };
|
843
843
|
};
|
844
|
-
Object.defineProperty(
|
845
|
-
|
844
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
845
|
+
exports2.onTerminate = exports2.renderWithTask = exports2.render = exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0;
|
846
846
|
var readline_1 = require_readline();
|
847
847
|
var sisteransi_1 = require_src();
|
848
848
|
var utils_1 = require_utils();
|
@@ -877,7 +877,7 @@ var require_hanji = __commonJS({
|
|
877
877
|
this.inputCallbacks.forEach((it) => it(str, key));
|
878
878
|
}
|
879
879
|
};
|
880
|
-
|
880
|
+
exports2.Prompt = Prompt2;
|
881
881
|
var SelectState2 = class {
|
882
882
|
constructor(items) {
|
883
883
|
this.items = items;
|
@@ -905,7 +905,7 @@ var require_hanji = __commonJS({
|
|
905
905
|
return false;
|
906
906
|
}
|
907
907
|
};
|
908
|
-
|
908
|
+
exports2.SelectState = SelectState2;
|
909
909
|
var deferred = () => {
|
910
910
|
let resolve;
|
911
911
|
let reject;
|
@@ -919,7 +919,7 @@ var require_hanji = __commonJS({
|
|
919
919
|
promise
|
920
920
|
};
|
921
921
|
};
|
922
|
-
|
922
|
+
exports2.deferred = deferred;
|
923
923
|
var Terminal = class {
|
924
924
|
constructor(view, stdin, stdout, closable) {
|
925
925
|
this.view = view;
|
@@ -964,7 +964,7 @@ var require_hanji = __commonJS({
|
|
964
964
|
};
|
965
965
|
this.stdin.on("keypress", keypress);
|
966
966
|
this.view.attach(this);
|
967
|
-
const { resolve, promise } = (0,
|
967
|
+
const { resolve, promise } = (0, exports2.deferred)();
|
968
968
|
this.resolve = resolve;
|
969
969
|
this.promise = promise;
|
970
970
|
this.renderFunc = (0, lodash_throttle_1.default)((str) => {
|
@@ -995,7 +995,7 @@ var require_hanji = __commonJS({
|
|
995
995
|
this.renderFunc(`${clearPrefix}${string}`);
|
996
996
|
}
|
997
997
|
};
|
998
|
-
|
998
|
+
exports2.Terminal = Terminal;
|
999
999
|
var TaskView2 = class {
|
1000
1000
|
constructor() {
|
1001
1001
|
this.attachCallbacks = [];
|
@@ -1020,7 +1020,7 @@ var require_hanji = __commonJS({
|
|
1020
1020
|
}
|
1021
1021
|
}
|
1022
1022
|
};
|
1023
|
-
|
1023
|
+
exports2.TaskView = TaskView2;
|
1024
1024
|
var TaskTerminal = class {
|
1025
1025
|
constructor(view, stdout) {
|
1026
1026
|
this.view = view;
|
@@ -1041,7 +1041,7 @@ var require_hanji = __commonJS({
|
|
1041
1041
|
this.stdout.write(`${clearPrefix}${string}`);
|
1042
1042
|
}
|
1043
1043
|
};
|
1044
|
-
|
1044
|
+
exports2.TaskTerminal = TaskTerminal;
|
1045
1045
|
function render2(view) {
|
1046
1046
|
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
1047
1047
|
if (view instanceof Prompt2) {
|
@@ -1054,8 +1054,8 @@ var require_hanji = __commonJS({
|
|
1054
1054
|
closable.close();
|
1055
1055
|
return;
|
1056
1056
|
}
|
1057
|
-
|
1058
|
-
function
|
1057
|
+
exports2.render = render2;
|
1058
|
+
function renderWithTask3(view, task) {
|
1059
1059
|
return __awaiter(this, void 0, void 0, function* () {
|
1060
1060
|
const terminal = new TaskTerminal(view, process.stdout);
|
1061
1061
|
terminal.requestLayout();
|
@@ -1064,12 +1064,12 @@ var require_hanji = __commonJS({
|
|
1064
1064
|
return result;
|
1065
1065
|
});
|
1066
1066
|
}
|
1067
|
-
|
1067
|
+
exports2.renderWithTask = renderWithTask3;
|
1068
1068
|
var terminateHandler;
|
1069
1069
|
function onTerminate(callback) {
|
1070
1070
|
terminateHandler = callback;
|
1071
1071
|
}
|
1072
|
-
|
1072
|
+
exports2.onTerminate = onTerminate;
|
1073
1073
|
}
|
1074
1074
|
});
|
1075
1075
|
|
@@ -1083,11 +1083,12 @@ var init_global = __esm({
|
|
1083
1083
|
}
|
1084
1084
|
});
|
1085
1085
|
|
1086
|
-
// node_modules/.pnpm/zod@3.
|
1086
|
+
// node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
1087
1087
|
function getErrorMap() {
|
1088
1088
|
return overrideErrorMap;
|
1089
1089
|
}
|
1090
1090
|
function addIssueToContext(ctx, issueData) {
|
1091
|
+
const overrideMap = getErrorMap();
|
1091
1092
|
const issue = makeIssue({
|
1092
1093
|
issueData,
|
1093
1094
|
data: ctx.data,
|
@@ -1095,13 +1096,29 @@ function addIssueToContext(ctx, issueData) {
|
|
1095
1096
|
errorMaps: [
|
1096
1097
|
ctx.common.contextualErrorMap,
|
1097
1098
|
ctx.schemaErrorMap,
|
1098
|
-
|
1099
|
-
errorMap
|
1099
|
+
overrideMap,
|
1100
|
+
overrideMap === errorMap ? void 0 : errorMap
|
1100
1101
|
// then global default map
|
1101
1102
|
].filter((x) => !!x)
|
1102
1103
|
});
|
1103
1104
|
ctx.common.issues.push(issue);
|
1104
1105
|
}
|
1106
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
1107
|
+
if (kind === "a" && !f)
|
1108
|
+
throw new TypeError("Private accessor was defined without a getter");
|
1109
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
1110
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
1111
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
1112
|
+
}
|
1113
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
1114
|
+
if (kind === "m")
|
1115
|
+
throw new TypeError("Private method is not writable");
|
1116
|
+
if (kind === "a" && !f)
|
1117
|
+
throw new TypeError("Private accessor was defined without a setter");
|
1118
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
1119
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
1120
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
1121
|
+
}
|
1105
1122
|
function processCreateParams(params) {
|
1106
1123
|
if (!params)
|
1107
1124
|
return {};
|
@@ -1112,15 +1129,50 @@ function processCreateParams(params) {
|
|
1112
1129
|
if (errorMap2)
|
1113
1130
|
return { errorMap: errorMap2, description };
|
1114
1131
|
const customMap = (iss, ctx) => {
|
1115
|
-
|
1116
|
-
|
1132
|
+
var _a, _b;
|
1133
|
+
const { message } = params;
|
1134
|
+
if (iss.code === "invalid_enum_value") {
|
1135
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
1136
|
+
}
|
1117
1137
|
if (typeof ctx.data === "undefined") {
|
1118
|
-
return { message:
|
1138
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
1119
1139
|
}
|
1120
|
-
|
1140
|
+
if (iss.code !== "invalid_type")
|
1141
|
+
return { message: ctx.defaultError };
|
1142
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
1121
1143
|
};
|
1122
1144
|
return { errorMap: customMap, description };
|
1123
1145
|
}
|
1146
|
+
function timeRegexSource(args) {
|
1147
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
1148
|
+
if (args.precision) {
|
1149
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
1150
|
+
} else if (args.precision == null) {
|
1151
|
+
regex = `${regex}(\\.\\d+)?`;
|
1152
|
+
}
|
1153
|
+
return regex;
|
1154
|
+
}
|
1155
|
+
function timeRegex(args) {
|
1156
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
1157
|
+
}
|
1158
|
+
function datetimeRegex(args) {
|
1159
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
1160
|
+
const opts = [];
|
1161
|
+
opts.push(args.local ? `Z?` : `Z`);
|
1162
|
+
if (args.offset)
|
1163
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
1164
|
+
regex = `${regex}(${opts.join("|")})`;
|
1165
|
+
return new RegExp(`^${regex}$`);
|
1166
|
+
}
|
1167
|
+
function isValidIP(ip, version) {
|
1168
|
+
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
1169
|
+
return true;
|
1170
|
+
}
|
1171
|
+
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
1172
|
+
return true;
|
1173
|
+
}
|
1174
|
+
return false;
|
1175
|
+
}
|
1124
1176
|
function floatSafeRemainder(val, step) {
|
1125
1177
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
1126
1178
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
@@ -1141,7 +1193,10 @@ function deepPartialify(schema3) {
|
|
1141
1193
|
shape: () => newShape
|
1142
1194
|
});
|
1143
1195
|
} else if (schema3 instanceof ZodArray) {
|
1144
|
-
return ZodArray
|
1196
|
+
return new ZodArray({
|
1197
|
+
...schema3._def,
|
1198
|
+
type: deepPartialify(schema3.element)
|
1199
|
+
});
|
1145
1200
|
} else if (schema3 instanceof ZodOptional) {
|
1146
1201
|
return ZodOptional.create(deepPartialify(schema3.unwrap()));
|
1147
1202
|
} else if (schema3 instanceof ZodNullable) {
|
@@ -1197,9 +1252,9 @@ function createZodEnum(values, params) {
|
|
1197
1252
|
...processCreateParams(params)
|
1198
1253
|
});
|
1199
1254
|
}
|
1200
|
-
var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex,
|
1255
|
+
var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv6Regex, base64Regex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, 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;
|
1201
1256
|
var init_lib = __esm({
|
1202
|
-
"node_modules/.pnpm/zod@3.
|
1257
|
+
"node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs"() {
|
1203
1258
|
(function(util2) {
|
1204
1259
|
util2.assertEqual = (val) => val;
|
1205
1260
|
function assertIs(_arg) {
|
@@ -1257,6 +1312,15 @@ var init_lib = __esm({
|
|
1257
1312
|
return value;
|
1258
1313
|
};
|
1259
1314
|
})(util || (util = {}));
|
1315
|
+
(function(objectUtil2) {
|
1316
|
+
objectUtil2.mergeShapes = (first, second) => {
|
1317
|
+
return {
|
1318
|
+
...first,
|
1319
|
+
...second
|
1320
|
+
// second overwrites first
|
1321
|
+
};
|
1322
|
+
};
|
1323
|
+
})(objectUtil || (objectUtil = {}));
|
1260
1324
|
ZodParsedType = util.arrayToEnum([
|
1261
1325
|
"string",
|
1262
1326
|
"nan",
|
@@ -1338,7 +1402,7 @@ var init_lib = __esm({
|
|
1338
1402
|
"not_multiple_of",
|
1339
1403
|
"not_finite"
|
1340
1404
|
]);
|
1341
|
-
ZodError = class extends Error {
|
1405
|
+
ZodError = class _ZodError extends Error {
|
1342
1406
|
constructor(issues) {
|
1343
1407
|
super();
|
1344
1408
|
this.issues = [];
|
@@ -1396,6 +1460,11 @@ var init_lib = __esm({
|
|
1396
1460
|
processError(this);
|
1397
1461
|
return fieldErrors;
|
1398
1462
|
}
|
1463
|
+
static assert(value) {
|
1464
|
+
if (!(value instanceof _ZodError)) {
|
1465
|
+
throw new Error(`Not a ZodError: ${value}`);
|
1466
|
+
}
|
1467
|
+
}
|
1399
1468
|
toString() {
|
1400
1469
|
return this.message;
|
1401
1470
|
}
|
@@ -1462,7 +1531,12 @@ var init_lib = __esm({
|
|
1462
1531
|
break;
|
1463
1532
|
case ZodIssueCode.invalid_string:
|
1464
1533
|
if (typeof issue.validation === "object") {
|
1465
|
-
if ("
|
1534
|
+
if ("includes" in issue.validation) {
|
1535
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
1536
|
+
if (typeof issue.validation.position === "number") {
|
1537
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
1538
|
+
}
|
1539
|
+
} else if ("startsWith" in issue.validation) {
|
1466
1540
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
1467
1541
|
} else if ("endsWith" in issue.validation) {
|
1468
1542
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
@@ -1483,7 +1557,7 @@ var init_lib = __esm({
|
|
1483
1557
|
else if (issue.type === "number")
|
1484
1558
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
1485
1559
|
else if (issue.type === "date")
|
1486
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
|
1560
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
1487
1561
|
else
|
1488
1562
|
message = "Invalid input";
|
1489
1563
|
break;
|
@@ -1494,8 +1568,10 @@ var init_lib = __esm({
|
|
1494
1568
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
1495
1569
|
else if (issue.type === "number")
|
1496
1570
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1571
|
+
else if (issue.type === "bigint")
|
1572
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1497
1573
|
else if (issue.type === "date")
|
1498
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
|
1574
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
1499
1575
|
else
|
1500
1576
|
message = "Invalid input";
|
1501
1577
|
break;
|
@@ -1525,6 +1601,13 @@ var init_lib = __esm({
|
|
1525
1601
|
...issueData,
|
1526
1602
|
path: fullPath
|
1527
1603
|
};
|
1604
|
+
if (issueData.message !== void 0) {
|
1605
|
+
return {
|
1606
|
+
...issueData,
|
1607
|
+
path: fullPath,
|
1608
|
+
message: issueData.message
|
1609
|
+
};
|
1610
|
+
}
|
1528
1611
|
let errorMessage = "";
|
1529
1612
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
1530
1613
|
for (const map of maps) {
|
@@ -1533,7 +1616,7 @@ var init_lib = __esm({
|
|
1533
1616
|
return {
|
1534
1617
|
...issueData,
|
1535
1618
|
path: fullPath,
|
1536
|
-
message:
|
1619
|
+
message: errorMessage
|
1537
1620
|
};
|
1538
1621
|
};
|
1539
1622
|
ParseStatus = class _ParseStatus {
|
@@ -1562,9 +1645,11 @@ var init_lib = __esm({
|
|
1562
1645
|
static async mergeObjectAsync(status, pairs) {
|
1563
1646
|
const syncPairs = [];
|
1564
1647
|
for (const pair of pairs) {
|
1648
|
+
const key = await pair.key;
|
1649
|
+
const value = await pair.value;
|
1565
1650
|
syncPairs.push({
|
1566
|
-
key
|
1567
|
-
value
|
1651
|
+
key,
|
1652
|
+
value
|
1568
1653
|
});
|
1569
1654
|
}
|
1570
1655
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
@@ -1581,7 +1666,7 @@ var init_lib = __esm({
|
|
1581
1666
|
status.dirty();
|
1582
1667
|
if (value.status === "dirty")
|
1583
1668
|
status.dirty();
|
1584
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
1669
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
1585
1670
|
finalObject[key.value] = value.value;
|
1586
1671
|
}
|
1587
1672
|
}
|
@@ -1596,20 +1681,28 @@ var init_lib = __esm({
|
|
1596
1681
|
isAborted = (x) => x.status === "aborted";
|
1597
1682
|
isDirty = (x) => x.status === "dirty";
|
1598
1683
|
isValid = (x) => x.status === "valid";
|
1599
|
-
isAsync = (x) => typeof Promise !==
|
1684
|
+
isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1600
1685
|
(function(errorUtil2) {
|
1601
1686
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1602
1687
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
1603
1688
|
})(errorUtil || (errorUtil = {}));
|
1604
1689
|
ParseInputLazyPath = class {
|
1605
1690
|
constructor(parent, value, path2, key) {
|
1691
|
+
this._cachedPath = [];
|
1606
1692
|
this.parent = parent;
|
1607
1693
|
this.data = value;
|
1608
1694
|
this._path = path2;
|
1609
1695
|
this._key = key;
|
1610
1696
|
}
|
1611
1697
|
get path() {
|
1612
|
-
|
1698
|
+
if (!this._cachedPath.length) {
|
1699
|
+
if (this._key instanceof Array) {
|
1700
|
+
this._cachedPath.push(...this._path, ...this._key);
|
1701
|
+
} else {
|
1702
|
+
this._cachedPath.push(...this._path, this._key);
|
1703
|
+
}
|
1704
|
+
}
|
1705
|
+
return this._cachedPath;
|
1613
1706
|
}
|
1614
1707
|
};
|
1615
1708
|
handleResult = (ctx, result) => {
|
@@ -1619,8 +1712,16 @@ var init_lib = __esm({
|
|
1619
1712
|
if (!ctx.common.issues.length) {
|
1620
1713
|
throw new Error("Validation failed but no issues detected.");
|
1621
1714
|
}
|
1622
|
-
|
1623
|
-
|
1715
|
+
return {
|
1716
|
+
success: false,
|
1717
|
+
get error() {
|
1718
|
+
if (this._error)
|
1719
|
+
return this._error;
|
1720
|
+
const error2 = new ZodError(ctx.common.issues);
|
1721
|
+
this._error = error2;
|
1722
|
+
return this._error;
|
1723
|
+
}
|
1724
|
+
};
|
1624
1725
|
}
|
1625
1726
|
};
|
1626
1727
|
ZodType = class {
|
@@ -1648,6 +1749,7 @@ var init_lib = __esm({
|
|
1648
1749
|
this.catch = this.catch.bind(this);
|
1649
1750
|
this.describe = this.describe.bind(this);
|
1650
1751
|
this.pipe = this.pipe.bind(this);
|
1752
|
+
this.readonly = this.readonly.bind(this);
|
1651
1753
|
this.isNullable = this.isNullable.bind(this);
|
1652
1754
|
this.isOptional = this.isOptional.bind(this);
|
1653
1755
|
}
|
@@ -1792,28 +1894,29 @@ var init_lib = __esm({
|
|
1792
1894
|
return this._refinement(refinement);
|
1793
1895
|
}
|
1794
1896
|
optional() {
|
1795
|
-
return ZodOptional.create(this);
|
1897
|
+
return ZodOptional.create(this, this._def);
|
1796
1898
|
}
|
1797
1899
|
nullable() {
|
1798
|
-
return ZodNullable.create(this);
|
1900
|
+
return ZodNullable.create(this, this._def);
|
1799
1901
|
}
|
1800
1902
|
nullish() {
|
1801
|
-
return this.
|
1903
|
+
return this.nullable().optional();
|
1802
1904
|
}
|
1803
1905
|
array() {
|
1804
|
-
return ZodArray.create(this);
|
1906
|
+
return ZodArray.create(this, this._def);
|
1805
1907
|
}
|
1806
1908
|
promise() {
|
1807
|
-
return ZodPromise.create(this);
|
1909
|
+
return ZodPromise.create(this, this._def);
|
1808
1910
|
}
|
1809
1911
|
or(option) {
|
1810
|
-
return ZodUnion.create([this, option]);
|
1912
|
+
return ZodUnion.create([this, option], this._def);
|
1811
1913
|
}
|
1812
1914
|
and(incoming) {
|
1813
|
-
return ZodIntersection.create(this, incoming);
|
1915
|
+
return ZodIntersection.create(this, incoming, this._def);
|
1814
1916
|
}
|
1815
1917
|
transform(transform) {
|
1816
1918
|
return new ZodEffects({
|
1919
|
+
...processCreateParams(this._def),
|
1817
1920
|
schema: this,
|
1818
1921
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
1819
1922
|
effect: { type: "transform", transform }
|
@@ -1822,6 +1925,7 @@ var init_lib = __esm({
|
|
1822
1925
|
default(def) {
|
1823
1926
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
1824
1927
|
return new ZodDefault({
|
1928
|
+
...processCreateParams(this._def),
|
1825
1929
|
innerType: this,
|
1826
1930
|
defaultValue: defaultValueFunc,
|
1827
1931
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
@@ -1831,14 +1935,15 @@ var init_lib = __esm({
|
|
1831
1935
|
return new ZodBranded({
|
1832
1936
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
1833
1937
|
type: this,
|
1834
|
-
...processCreateParams(
|
1938
|
+
...processCreateParams(this._def)
|
1835
1939
|
});
|
1836
1940
|
}
|
1837
1941
|
catch(def) {
|
1838
|
-
const
|
1942
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
1839
1943
|
return new ZodCatch({
|
1944
|
+
...processCreateParams(this._def),
|
1840
1945
|
innerType: this,
|
1841
|
-
|
1946
|
+
catchValue: catchValueFunc,
|
1842
1947
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
1843
1948
|
});
|
1844
1949
|
}
|
@@ -1852,6 +1957,9 @@ var init_lib = __esm({
|
|
1852
1957
|
pipe(target) {
|
1853
1958
|
return ZodPipeline.create(this, target);
|
1854
1959
|
}
|
1960
|
+
readonly() {
|
1961
|
+
return ZodReadonly.create(this);
|
1962
|
+
}
|
1855
1963
|
isOptional() {
|
1856
1964
|
return this.safeParse(void 0).success;
|
1857
1965
|
}
|
@@ -1860,43 +1968,19 @@ var init_lib = __esm({
|
|
1860
1968
|
}
|
1861
1969
|
};
|
1862
1970
|
cuidRegex = /^c[^\s-]{8,}$/i;
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
} else {
|
1876
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
1877
|
-
}
|
1878
|
-
} else {
|
1879
|
-
if (args.offset) {
|
1880
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
|
1881
|
-
} else {
|
1882
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
1883
|
-
}
|
1884
|
-
}
|
1885
|
-
};
|
1971
|
+
cuid2Regex = /^[0-9a-z]+$/;
|
1972
|
+
ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
1973
|
+
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;
|
1974
|
+
nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
1975
|
+
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)?)??$/;
|
1976
|
+
emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
1977
|
+
_emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
1978
|
+
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])$/;
|
1979
|
+
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})))$/;
|
1980
|
+
base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
1981
|
+
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])))`;
|
1982
|
+
dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1886
1983
|
ZodString = class _ZodString extends ZodType {
|
1887
|
-
constructor() {
|
1888
|
-
super(...arguments);
|
1889
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
1890
|
-
validation,
|
1891
|
-
code: ZodIssueCode.invalid_string,
|
1892
|
-
...errorUtil.errToObj(message)
|
1893
|
-
});
|
1894
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
1895
|
-
this.trim = () => new _ZodString({
|
1896
|
-
...this._def,
|
1897
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
1898
|
-
});
|
1899
|
-
}
|
1900
1984
|
_parse(input) {
|
1901
1985
|
if (this._def.coerce) {
|
1902
1986
|
input.data = String(input.data);
|
@@ -1904,15 +1988,11 @@ var init_lib = __esm({
|
|
1904
1988
|
const parsedType = this._getType(input);
|
1905
1989
|
if (parsedType !== ZodParsedType.string) {
|
1906
1990
|
const ctx2 = this._getOrReturnCtx(input);
|
1907
|
-
addIssueToContext(
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
received: ctx2.parsedType
|
1913
|
-
}
|
1914
|
-
//
|
1915
|
-
);
|
1991
|
+
addIssueToContext(ctx2, {
|
1992
|
+
code: ZodIssueCode.invalid_type,
|
1993
|
+
expected: ZodParsedType.string,
|
1994
|
+
received: ctx2.parsedType
|
1995
|
+
});
|
1916
1996
|
return INVALID;
|
1917
1997
|
}
|
1918
1998
|
const status = new ParseStatus();
|
@@ -1980,6 +2060,19 @@ var init_lib = __esm({
|
|
1980
2060
|
});
|
1981
2061
|
status.dirty();
|
1982
2062
|
}
|
2063
|
+
} else if (check.kind === "emoji") {
|
2064
|
+
if (!emojiRegex) {
|
2065
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
2066
|
+
}
|
2067
|
+
if (!emojiRegex.test(input.data)) {
|
2068
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2069
|
+
addIssueToContext(ctx, {
|
2070
|
+
validation: "emoji",
|
2071
|
+
code: ZodIssueCode.invalid_string,
|
2072
|
+
message: check.message
|
2073
|
+
});
|
2074
|
+
status.dirty();
|
2075
|
+
}
|
1983
2076
|
} else if (check.kind === "uuid") {
|
1984
2077
|
if (!uuidRegex.test(input.data)) {
|
1985
2078
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1990,6 +2083,16 @@ var init_lib = __esm({
|
|
1990
2083
|
});
|
1991
2084
|
status.dirty();
|
1992
2085
|
}
|
2086
|
+
} else if (check.kind === "nanoid") {
|
2087
|
+
if (!nanoidRegex.test(input.data)) {
|
2088
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2089
|
+
addIssueToContext(ctx, {
|
2090
|
+
validation: "nanoid",
|
2091
|
+
code: ZodIssueCode.invalid_string,
|
2092
|
+
message: check.message
|
2093
|
+
});
|
2094
|
+
status.dirty();
|
2095
|
+
}
|
1993
2096
|
} else if (check.kind === "cuid") {
|
1994
2097
|
if (!cuidRegex.test(input.data)) {
|
1995
2098
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2000,6 +2103,26 @@ var init_lib = __esm({
|
|
2000
2103
|
});
|
2001
2104
|
status.dirty();
|
2002
2105
|
}
|
2106
|
+
} else if (check.kind === "cuid2") {
|
2107
|
+
if (!cuid2Regex.test(input.data)) {
|
2108
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2109
|
+
addIssueToContext(ctx, {
|
2110
|
+
validation: "cuid2",
|
2111
|
+
code: ZodIssueCode.invalid_string,
|
2112
|
+
message: check.message
|
2113
|
+
});
|
2114
|
+
status.dirty();
|
2115
|
+
}
|
2116
|
+
} else if (check.kind === "ulid") {
|
2117
|
+
if (!ulidRegex.test(input.data)) {
|
2118
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2119
|
+
addIssueToContext(ctx, {
|
2120
|
+
validation: "ulid",
|
2121
|
+
code: ZodIssueCode.invalid_string,
|
2122
|
+
message: check.message
|
2123
|
+
});
|
2124
|
+
status.dirty();
|
2125
|
+
}
|
2003
2126
|
} else if (check.kind === "url") {
|
2004
2127
|
try {
|
2005
2128
|
new URL(input.data);
|
@@ -2026,6 +2149,20 @@ var init_lib = __esm({
|
|
2026
2149
|
}
|
2027
2150
|
} else if (check.kind === "trim") {
|
2028
2151
|
input.data = input.data.trim();
|
2152
|
+
} else if (check.kind === "includes") {
|
2153
|
+
if (!input.data.includes(check.value, check.position)) {
|
2154
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2155
|
+
addIssueToContext(ctx, {
|
2156
|
+
code: ZodIssueCode.invalid_string,
|
2157
|
+
validation: { includes: check.value, position: check.position },
|
2158
|
+
message: check.message
|
2159
|
+
});
|
2160
|
+
status.dirty();
|
2161
|
+
}
|
2162
|
+
} else if (check.kind === "toLowerCase") {
|
2163
|
+
input.data = input.data.toLowerCase();
|
2164
|
+
} else if (check.kind === "toUpperCase") {
|
2165
|
+
input.data = input.data.toUpperCase();
|
2029
2166
|
} else if (check.kind === "startsWith") {
|
2030
2167
|
if (!input.data.startsWith(check.value)) {
|
2031
2168
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2057,12 +2194,71 @@ var init_lib = __esm({
|
|
2057
2194
|
});
|
2058
2195
|
status.dirty();
|
2059
2196
|
}
|
2197
|
+
} else if (check.kind === "date") {
|
2198
|
+
const regex = dateRegex;
|
2199
|
+
if (!regex.test(input.data)) {
|
2200
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2201
|
+
addIssueToContext(ctx, {
|
2202
|
+
code: ZodIssueCode.invalid_string,
|
2203
|
+
validation: "date",
|
2204
|
+
message: check.message
|
2205
|
+
});
|
2206
|
+
status.dirty();
|
2207
|
+
}
|
2208
|
+
} else if (check.kind === "time") {
|
2209
|
+
const regex = timeRegex(check);
|
2210
|
+
if (!regex.test(input.data)) {
|
2211
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2212
|
+
addIssueToContext(ctx, {
|
2213
|
+
code: ZodIssueCode.invalid_string,
|
2214
|
+
validation: "time",
|
2215
|
+
message: check.message
|
2216
|
+
});
|
2217
|
+
status.dirty();
|
2218
|
+
}
|
2219
|
+
} else if (check.kind === "duration") {
|
2220
|
+
if (!durationRegex.test(input.data)) {
|
2221
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2222
|
+
addIssueToContext(ctx, {
|
2223
|
+
validation: "duration",
|
2224
|
+
code: ZodIssueCode.invalid_string,
|
2225
|
+
message: check.message
|
2226
|
+
});
|
2227
|
+
status.dirty();
|
2228
|
+
}
|
2229
|
+
} else if (check.kind === "ip") {
|
2230
|
+
if (!isValidIP(input.data, check.version)) {
|
2231
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2232
|
+
addIssueToContext(ctx, {
|
2233
|
+
validation: "ip",
|
2234
|
+
code: ZodIssueCode.invalid_string,
|
2235
|
+
message: check.message
|
2236
|
+
});
|
2237
|
+
status.dirty();
|
2238
|
+
}
|
2239
|
+
} else if (check.kind === "base64") {
|
2240
|
+
if (!base64Regex.test(input.data)) {
|
2241
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2242
|
+
addIssueToContext(ctx, {
|
2243
|
+
validation: "base64",
|
2244
|
+
code: ZodIssueCode.invalid_string,
|
2245
|
+
message: check.message
|
2246
|
+
});
|
2247
|
+
status.dirty();
|
2248
|
+
}
|
2060
2249
|
} else {
|
2061
2250
|
util.assertNever(check);
|
2062
2251
|
}
|
2063
2252
|
}
|
2064
2253
|
return { status: status.value, value: input.data };
|
2065
2254
|
}
|
2255
|
+
_regex(regex, validation, message) {
|
2256
|
+
return this.refinement((data) => regex.test(data), {
|
2257
|
+
validation,
|
2258
|
+
code: ZodIssueCode.invalid_string,
|
2259
|
+
...errorUtil.errToObj(message)
|
2260
|
+
});
|
2261
|
+
}
|
2066
2262
|
_addCheck(check) {
|
2067
2263
|
return new _ZodString({
|
2068
2264
|
...this._def,
|
@@ -2075,19 +2271,38 @@ var init_lib = __esm({
|
|
2075
2271
|
url(message) {
|
2076
2272
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
2077
2273
|
}
|
2274
|
+
emoji(message) {
|
2275
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
2276
|
+
}
|
2078
2277
|
uuid(message) {
|
2079
2278
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
2080
2279
|
}
|
2280
|
+
nanoid(message) {
|
2281
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
2282
|
+
}
|
2081
2283
|
cuid(message) {
|
2082
2284
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
2083
2285
|
}
|
2286
|
+
cuid2(message) {
|
2287
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
2288
|
+
}
|
2289
|
+
ulid(message) {
|
2290
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
2291
|
+
}
|
2292
|
+
base64(message) {
|
2293
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
2294
|
+
}
|
2295
|
+
ip(options) {
|
2296
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
2297
|
+
}
|
2084
2298
|
datetime(options) {
|
2085
|
-
var _a;
|
2299
|
+
var _a, _b;
|
2086
2300
|
if (typeof options === "string") {
|
2087
2301
|
return this._addCheck({
|
2088
2302
|
kind: "datetime",
|
2089
2303
|
precision: null,
|
2090
2304
|
offset: false,
|
2305
|
+
local: false,
|
2091
2306
|
message: options
|
2092
2307
|
});
|
2093
2308
|
}
|
@@ -2095,9 +2310,30 @@ var init_lib = __esm({
|
|
2095
2310
|
kind: "datetime",
|
2096
2311
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2097
2312
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
2313
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
2314
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2315
|
+
});
|
2316
|
+
}
|
2317
|
+
date(message) {
|
2318
|
+
return this._addCheck({ kind: "date", message });
|
2319
|
+
}
|
2320
|
+
time(options) {
|
2321
|
+
if (typeof options === "string") {
|
2322
|
+
return this._addCheck({
|
2323
|
+
kind: "time",
|
2324
|
+
precision: null,
|
2325
|
+
message: options
|
2326
|
+
});
|
2327
|
+
}
|
2328
|
+
return this._addCheck({
|
2329
|
+
kind: "time",
|
2330
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2098
2331
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2099
2332
|
});
|
2100
2333
|
}
|
2334
|
+
duration(message) {
|
2335
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
2336
|
+
}
|
2101
2337
|
regex(regex, message) {
|
2102
2338
|
return this._addCheck({
|
2103
2339
|
kind: "regex",
|
@@ -2105,6 +2341,14 @@ var init_lib = __esm({
|
|
2105
2341
|
...errorUtil.errToObj(message)
|
2106
2342
|
});
|
2107
2343
|
}
|
2344
|
+
includes(value, options) {
|
2345
|
+
return this._addCheck({
|
2346
|
+
kind: "includes",
|
2347
|
+
value,
|
2348
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
2349
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2350
|
+
});
|
2351
|
+
}
|
2108
2352
|
startsWith(value, message) {
|
2109
2353
|
return this._addCheck({
|
2110
2354
|
kind: "startsWith",
|
@@ -2140,21 +2384,73 @@ var init_lib = __esm({
|
|
2140
2384
|
...errorUtil.errToObj(message)
|
2141
2385
|
});
|
2142
2386
|
}
|
2387
|
+
/**
|
2388
|
+
* @deprecated Use z.string().min(1) instead.
|
2389
|
+
* @see {@link ZodString.min}
|
2390
|
+
*/
|
2391
|
+
nonempty(message) {
|
2392
|
+
return this.min(1, errorUtil.errToObj(message));
|
2393
|
+
}
|
2394
|
+
trim() {
|
2395
|
+
return new _ZodString({
|
2396
|
+
...this._def,
|
2397
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
2398
|
+
});
|
2399
|
+
}
|
2400
|
+
toLowerCase() {
|
2401
|
+
return new _ZodString({
|
2402
|
+
...this._def,
|
2403
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
2404
|
+
});
|
2405
|
+
}
|
2406
|
+
toUpperCase() {
|
2407
|
+
return new _ZodString({
|
2408
|
+
...this._def,
|
2409
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
2410
|
+
});
|
2411
|
+
}
|
2143
2412
|
get isDatetime() {
|
2144
2413
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
2145
2414
|
}
|
2415
|
+
get isDate() {
|
2416
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
2417
|
+
}
|
2418
|
+
get isTime() {
|
2419
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
2420
|
+
}
|
2421
|
+
get isDuration() {
|
2422
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
2423
|
+
}
|
2146
2424
|
get isEmail() {
|
2147
2425
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
2148
2426
|
}
|
2149
2427
|
get isURL() {
|
2150
2428
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
2151
2429
|
}
|
2430
|
+
get isEmoji() {
|
2431
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
2432
|
+
}
|
2152
2433
|
get isUUID() {
|
2153
2434
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
2154
2435
|
}
|
2436
|
+
get isNANOID() {
|
2437
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
2438
|
+
}
|
2155
2439
|
get isCUID() {
|
2156
2440
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
2157
2441
|
}
|
2442
|
+
get isCUID2() {
|
2443
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
2444
|
+
}
|
2445
|
+
get isULID() {
|
2446
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
2447
|
+
}
|
2448
|
+
get isIP() {
|
2449
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
2450
|
+
}
|
2451
|
+
get isBase64() {
|
2452
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
2453
|
+
}
|
2158
2454
|
get minLength() {
|
2159
2455
|
let min = null;
|
2160
2456
|
for (const ch of this._def.checks) {
|
@@ -2356,6 +2652,19 @@ var init_lib = __esm({
|
|
2356
2652
|
message: errorUtil.toString(message)
|
2357
2653
|
});
|
2358
2654
|
}
|
2655
|
+
safe(message) {
|
2656
|
+
return this._addCheck({
|
2657
|
+
kind: "min",
|
2658
|
+
inclusive: true,
|
2659
|
+
value: Number.MIN_SAFE_INTEGER,
|
2660
|
+
message: errorUtil.toString(message)
|
2661
|
+
})._addCheck({
|
2662
|
+
kind: "max",
|
2663
|
+
inclusive: true,
|
2664
|
+
value: Number.MAX_SAFE_INTEGER,
|
2665
|
+
message: errorUtil.toString(message)
|
2666
|
+
});
|
2667
|
+
}
|
2359
2668
|
get minValue() {
|
2360
2669
|
let min = null;
|
2361
2670
|
for (const ch of this._def.checks) {
|
@@ -2377,7 +2686,22 @@ var init_lib = __esm({
|
|
2377
2686
|
return max;
|
2378
2687
|
}
|
2379
2688
|
get isInt() {
|
2380
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
2689
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2690
|
+
}
|
2691
|
+
get isFinite() {
|
2692
|
+
let max = null, min = null;
|
2693
|
+
for (const ch of this._def.checks) {
|
2694
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2695
|
+
return true;
|
2696
|
+
} else if (ch.kind === "min") {
|
2697
|
+
if (min === null || ch.value > min)
|
2698
|
+
min = ch.value;
|
2699
|
+
} else if (ch.kind === "max") {
|
2700
|
+
if (max === null || ch.value < max)
|
2701
|
+
max = ch.value;
|
2702
|
+
}
|
2703
|
+
}
|
2704
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
2381
2705
|
}
|
2382
2706
|
};
|
2383
2707
|
ZodNumber.create = (params) => {
|
@@ -2388,27 +2712,167 @@ var init_lib = __esm({
|
|
2388
2712
|
...processCreateParams(params)
|
2389
2713
|
});
|
2390
2714
|
};
|
2391
|
-
ZodBigInt = class extends ZodType {
|
2715
|
+
ZodBigInt = class _ZodBigInt extends ZodType {
|
2716
|
+
constructor() {
|
2717
|
+
super(...arguments);
|
2718
|
+
this.min = this.gte;
|
2719
|
+
this.max = this.lte;
|
2720
|
+
}
|
2392
2721
|
_parse(input) {
|
2393
2722
|
if (this._def.coerce) {
|
2394
2723
|
input.data = BigInt(input.data);
|
2395
2724
|
}
|
2396
2725
|
const parsedType = this._getType(input);
|
2397
2726
|
if (parsedType !== ZodParsedType.bigint) {
|
2398
|
-
const
|
2399
|
-
addIssueToContext(
|
2727
|
+
const ctx2 = this._getOrReturnCtx(input);
|
2728
|
+
addIssueToContext(ctx2, {
|
2400
2729
|
code: ZodIssueCode.invalid_type,
|
2401
2730
|
expected: ZodParsedType.bigint,
|
2402
|
-
received:
|
2731
|
+
received: ctx2.parsedType
|
2403
2732
|
});
|
2404
2733
|
return INVALID;
|
2405
2734
|
}
|
2406
|
-
|
2735
|
+
let ctx = void 0;
|
2736
|
+
const status = new ParseStatus();
|
2737
|
+
for (const check of this._def.checks) {
|
2738
|
+
if (check.kind === "min") {
|
2739
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
2740
|
+
if (tooSmall) {
|
2741
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2742
|
+
addIssueToContext(ctx, {
|
2743
|
+
code: ZodIssueCode.too_small,
|
2744
|
+
type: "bigint",
|
2745
|
+
minimum: check.value,
|
2746
|
+
inclusive: check.inclusive,
|
2747
|
+
message: check.message
|
2748
|
+
});
|
2749
|
+
status.dirty();
|
2750
|
+
}
|
2751
|
+
} else if (check.kind === "max") {
|
2752
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
2753
|
+
if (tooBig) {
|
2754
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2755
|
+
addIssueToContext(ctx, {
|
2756
|
+
code: ZodIssueCode.too_big,
|
2757
|
+
type: "bigint",
|
2758
|
+
maximum: check.value,
|
2759
|
+
inclusive: check.inclusive,
|
2760
|
+
message: check.message
|
2761
|
+
});
|
2762
|
+
status.dirty();
|
2763
|
+
}
|
2764
|
+
} else if (check.kind === "multipleOf") {
|
2765
|
+
if (input.data % check.value !== BigInt(0)) {
|
2766
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2767
|
+
addIssueToContext(ctx, {
|
2768
|
+
code: ZodIssueCode.not_multiple_of,
|
2769
|
+
multipleOf: check.value,
|
2770
|
+
message: check.message
|
2771
|
+
});
|
2772
|
+
status.dirty();
|
2773
|
+
}
|
2774
|
+
} else {
|
2775
|
+
util.assertNever(check);
|
2776
|
+
}
|
2777
|
+
}
|
2778
|
+
return { status: status.value, value: input.data };
|
2779
|
+
}
|
2780
|
+
gte(value, message) {
|
2781
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2782
|
+
}
|
2783
|
+
gt(value, message) {
|
2784
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
2785
|
+
}
|
2786
|
+
lte(value, message) {
|
2787
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
2788
|
+
}
|
2789
|
+
lt(value, message) {
|
2790
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2791
|
+
}
|
2792
|
+
setLimit(kind, value, inclusive, message) {
|
2793
|
+
return new _ZodBigInt({
|
2794
|
+
...this._def,
|
2795
|
+
checks: [
|
2796
|
+
...this._def.checks,
|
2797
|
+
{
|
2798
|
+
kind,
|
2799
|
+
value,
|
2800
|
+
inclusive,
|
2801
|
+
message: errorUtil.toString(message)
|
2802
|
+
}
|
2803
|
+
]
|
2804
|
+
});
|
2805
|
+
}
|
2806
|
+
_addCheck(check) {
|
2807
|
+
return new _ZodBigInt({
|
2808
|
+
...this._def,
|
2809
|
+
checks: [...this._def.checks, check]
|
2810
|
+
});
|
2811
|
+
}
|
2812
|
+
positive(message) {
|
2813
|
+
return this._addCheck({
|
2814
|
+
kind: "min",
|
2815
|
+
value: BigInt(0),
|
2816
|
+
inclusive: false,
|
2817
|
+
message: errorUtil.toString(message)
|
2818
|
+
});
|
2819
|
+
}
|
2820
|
+
negative(message) {
|
2821
|
+
return this._addCheck({
|
2822
|
+
kind: "max",
|
2823
|
+
value: BigInt(0),
|
2824
|
+
inclusive: false,
|
2825
|
+
message: errorUtil.toString(message)
|
2826
|
+
});
|
2827
|
+
}
|
2828
|
+
nonpositive(message) {
|
2829
|
+
return this._addCheck({
|
2830
|
+
kind: "max",
|
2831
|
+
value: BigInt(0),
|
2832
|
+
inclusive: true,
|
2833
|
+
message: errorUtil.toString(message)
|
2834
|
+
});
|
2835
|
+
}
|
2836
|
+
nonnegative(message) {
|
2837
|
+
return this._addCheck({
|
2838
|
+
kind: "min",
|
2839
|
+
value: BigInt(0),
|
2840
|
+
inclusive: true,
|
2841
|
+
message: errorUtil.toString(message)
|
2842
|
+
});
|
2843
|
+
}
|
2844
|
+
multipleOf(value, message) {
|
2845
|
+
return this._addCheck({
|
2846
|
+
kind: "multipleOf",
|
2847
|
+
value,
|
2848
|
+
message: errorUtil.toString(message)
|
2849
|
+
});
|
2850
|
+
}
|
2851
|
+
get minValue() {
|
2852
|
+
let min = null;
|
2853
|
+
for (const ch of this._def.checks) {
|
2854
|
+
if (ch.kind === "min") {
|
2855
|
+
if (min === null || ch.value > min)
|
2856
|
+
min = ch.value;
|
2857
|
+
}
|
2858
|
+
}
|
2859
|
+
return min;
|
2860
|
+
}
|
2861
|
+
get maxValue() {
|
2862
|
+
let max = null;
|
2863
|
+
for (const ch of this._def.checks) {
|
2864
|
+
if (ch.kind === "max") {
|
2865
|
+
if (max === null || ch.value < max)
|
2866
|
+
max = ch.value;
|
2867
|
+
}
|
2868
|
+
}
|
2869
|
+
return max;
|
2407
2870
|
}
|
2408
2871
|
};
|
2409
2872
|
ZodBigInt.create = (params) => {
|
2410
2873
|
var _a;
|
2411
2874
|
return new ZodBigInt({
|
2875
|
+
checks: [],
|
2412
2876
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2413
2877
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
2414
2878
|
...processCreateParams(params)
|
@@ -2734,13 +3198,13 @@ var init_lib = __esm({
|
|
2734
3198
|
}
|
2735
3199
|
}
|
2736
3200
|
if (ctx.common.async) {
|
2737
|
-
return Promise.all(ctx.data.map((item, i) => {
|
3201
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
2738
3202
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2739
3203
|
})).then((result2) => {
|
2740
3204
|
return ParseStatus.mergeArray(status, result2);
|
2741
3205
|
});
|
2742
3206
|
}
|
2743
|
-
const result = ctx.data.map((item, i) => {
|
3207
|
+
const result = [...ctx.data].map((item, i) => {
|
2744
3208
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2745
3209
|
});
|
2746
3210
|
return ParseStatus.mergeArray(status, result);
|
@@ -2780,31 +3244,12 @@ var init_lib = __esm({
|
|
2780
3244
|
...processCreateParams(params)
|
2781
3245
|
});
|
2782
3246
|
};
|
2783
|
-
(function(objectUtil2) {
|
2784
|
-
objectUtil2.mergeShapes = (first, second) => {
|
2785
|
-
return {
|
2786
|
-
...first,
|
2787
|
-
...second
|
2788
|
-
// second overwrites first
|
2789
|
-
};
|
2790
|
-
};
|
2791
|
-
})(objectUtil || (objectUtil = {}));
|
2792
|
-
AugmentFactory = (def) => (augmentation) => {
|
2793
|
-
return new ZodObject({
|
2794
|
-
...def,
|
2795
|
-
shape: () => ({
|
2796
|
-
...def.shape(),
|
2797
|
-
...augmentation
|
2798
|
-
})
|
2799
|
-
});
|
2800
|
-
};
|
2801
3247
|
ZodObject = class _ZodObject extends ZodType {
|
2802
3248
|
constructor() {
|
2803
3249
|
super(...arguments);
|
2804
3250
|
this._cached = null;
|
2805
3251
|
this.nonstrict = this.passthrough;
|
2806
|
-
this.augment =
|
2807
|
-
this.extend = AugmentFactory(this._def);
|
3252
|
+
this.augment = this.extend;
|
2808
3253
|
}
|
2809
3254
|
_getCached() {
|
2810
3255
|
if (this._cached !== null)
|
@@ -2885,9 +3330,10 @@ var init_lib = __esm({
|
|
2885
3330
|
const syncPairs = [];
|
2886
3331
|
for (const pair of pairs) {
|
2887
3332
|
const key = await pair.key;
|
3333
|
+
const value = await pair.value;
|
2888
3334
|
syncPairs.push({
|
2889
3335
|
key,
|
2890
|
-
value
|
3336
|
+
value,
|
2891
3337
|
alwaysSet: pair.alwaysSet
|
2892
3338
|
});
|
2893
3339
|
}
|
@@ -2934,8 +3380,31 @@ var init_lib = __esm({
|
|
2934
3380
|
unknownKeys: "passthrough"
|
2935
3381
|
});
|
2936
3382
|
}
|
2937
|
-
|
2938
|
-
|
3383
|
+
// const AugmentFactory =
|
3384
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
3385
|
+
// <Augmentation extends ZodRawShape>(
|
3386
|
+
// augmentation: Augmentation
|
3387
|
+
// ): ZodObject<
|
3388
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
3389
|
+
// Def["unknownKeys"],
|
3390
|
+
// Def["catchall"]
|
3391
|
+
// > => {
|
3392
|
+
// return new ZodObject({
|
3393
|
+
// ...def,
|
3394
|
+
// shape: () => ({
|
3395
|
+
// ...def.shape(),
|
3396
|
+
// ...augmentation,
|
3397
|
+
// }),
|
3398
|
+
// }) as any;
|
3399
|
+
// };
|
3400
|
+
extend(augmentation) {
|
3401
|
+
return new _ZodObject({
|
3402
|
+
...this._def,
|
3403
|
+
shape: () => ({
|
3404
|
+
...this._def.shape(),
|
3405
|
+
...augmentation
|
3406
|
+
})
|
3407
|
+
});
|
2939
3408
|
}
|
2940
3409
|
/**
|
2941
3410
|
* Prior to zod@1.0.12 there was a bug in the
|
@@ -2946,11 +3415,73 @@ var init_lib = __esm({
|
|
2946
3415
|
const merged = new _ZodObject({
|
2947
3416
|
unknownKeys: merging._def.unknownKeys,
|
2948
3417
|
catchall: merging._def.catchall,
|
2949
|
-
shape: () =>
|
3418
|
+
shape: () => ({
|
3419
|
+
...this._def.shape(),
|
3420
|
+
...merging._def.shape()
|
3421
|
+
}),
|
2950
3422
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
2951
3423
|
});
|
2952
3424
|
return merged;
|
2953
3425
|
}
|
3426
|
+
// merge<
|
3427
|
+
// Incoming extends AnyZodObject,
|
3428
|
+
// Augmentation extends Incoming["shape"],
|
3429
|
+
// NewOutput extends {
|
3430
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
3431
|
+
// ? Augmentation[k]["_output"]
|
3432
|
+
// : k extends keyof Output
|
3433
|
+
// ? Output[k]
|
3434
|
+
// : never;
|
3435
|
+
// },
|
3436
|
+
// NewInput extends {
|
3437
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
3438
|
+
// ? Augmentation[k]["_input"]
|
3439
|
+
// : k extends keyof Input
|
3440
|
+
// ? Input[k]
|
3441
|
+
// : never;
|
3442
|
+
// }
|
3443
|
+
// >(
|
3444
|
+
// merging: Incoming
|
3445
|
+
// ): ZodObject<
|
3446
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
3447
|
+
// Incoming["_def"]["unknownKeys"],
|
3448
|
+
// Incoming["_def"]["catchall"],
|
3449
|
+
// NewOutput,
|
3450
|
+
// NewInput
|
3451
|
+
// > {
|
3452
|
+
// const merged: any = new ZodObject({
|
3453
|
+
// unknownKeys: merging._def.unknownKeys,
|
3454
|
+
// catchall: merging._def.catchall,
|
3455
|
+
// shape: () =>
|
3456
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
3457
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
3458
|
+
// }) as any;
|
3459
|
+
// return merged;
|
3460
|
+
// }
|
3461
|
+
setKey(key, schema3) {
|
3462
|
+
return this.augment({ [key]: schema3 });
|
3463
|
+
}
|
3464
|
+
// merge<Incoming extends AnyZodObject>(
|
3465
|
+
// merging: Incoming
|
3466
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
3467
|
+
// ZodObject<
|
3468
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
3469
|
+
// Incoming["_def"]["unknownKeys"],
|
3470
|
+
// Incoming["_def"]["catchall"]
|
3471
|
+
// > {
|
3472
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
3473
|
+
// // this._def.shape(),
|
3474
|
+
// // merging._def.shape()
|
3475
|
+
// // );
|
3476
|
+
// const merged: any = new ZodObject({
|
3477
|
+
// unknownKeys: merging._def.unknownKeys,
|
3478
|
+
// catchall: merging._def.catchall,
|
3479
|
+
// shape: () =>
|
3480
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
3481
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
3482
|
+
// }) as any;
|
3483
|
+
// return merged;
|
3484
|
+
// }
|
2954
3485
|
catchall(index4) {
|
2955
3486
|
return new _ZodObject({
|
2956
3487
|
...this._def,
|
@@ -2959,9 +3490,10 @@ var init_lib = __esm({
|
|
2959
3490
|
}
|
2960
3491
|
pick(mask) {
|
2961
3492
|
const shape = {};
|
2962
|
-
util.objectKeys(mask).
|
2963
|
-
if (this.shape[key])
|
3493
|
+
util.objectKeys(mask).forEach((key) => {
|
3494
|
+
if (mask[key] && this.shape[key]) {
|
2964
3495
|
shape[key] = this.shape[key];
|
3496
|
+
}
|
2965
3497
|
});
|
2966
3498
|
return new _ZodObject({
|
2967
3499
|
...this._def,
|
@@ -2970,8 +3502,8 @@ var init_lib = __esm({
|
|
2970
3502
|
}
|
2971
3503
|
omit(mask) {
|
2972
3504
|
const shape = {};
|
2973
|
-
util.objectKeys(this.shape).
|
2974
|
-
if (
|
3505
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3506
|
+
if (!mask[key]) {
|
2975
3507
|
shape[key] = this.shape[key];
|
2976
3508
|
}
|
2977
3509
|
});
|
@@ -2980,29 +3512,22 @@ var init_lib = __esm({
|
|
2980
3512
|
shape: () => shape
|
2981
3513
|
});
|
2982
3514
|
}
|
3515
|
+
/**
|
3516
|
+
* @deprecated
|
3517
|
+
*/
|
2983
3518
|
deepPartial() {
|
2984
3519
|
return deepPartialify(this);
|
2985
3520
|
}
|
2986
3521
|
partial(mask) {
|
2987
3522
|
const newShape = {};
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
newShape[key] = this.shape[key].optional();
|
2994
|
-
}
|
2995
|
-
});
|
2996
|
-
return new _ZodObject({
|
2997
|
-
...this._def,
|
2998
|
-
shape: () => newShape
|
2999
|
-
});
|
3000
|
-
} else {
|
3001
|
-
for (const key in this.shape) {
|
3002
|
-
const fieldSchema = this.shape[key];
|
3523
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3524
|
+
const fieldSchema = this.shape[key];
|
3525
|
+
if (mask && !mask[key]) {
|
3526
|
+
newShape[key] = fieldSchema;
|
3527
|
+
} else {
|
3003
3528
|
newShape[key] = fieldSchema.optional();
|
3004
3529
|
}
|
3005
|
-
}
|
3530
|
+
});
|
3006
3531
|
return new _ZodObject({
|
3007
3532
|
...this._def,
|
3008
3533
|
shape: () => newShape
|
@@ -3010,21 +3535,10 @@ var init_lib = __esm({
|
|
3010
3535
|
}
|
3011
3536
|
required(mask) {
|
3012
3537
|
const newShape = {};
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
} else {
|
3018
|
-
const fieldSchema = this.shape[key];
|
3019
|
-
let newField = fieldSchema;
|
3020
|
-
while (newField instanceof ZodOptional) {
|
3021
|
-
newField = newField._def.innerType;
|
3022
|
-
}
|
3023
|
-
newShape[key] = newField;
|
3024
|
-
}
|
3025
|
-
});
|
3026
|
-
} else {
|
3027
|
-
for (const key in this.shape) {
|
3538
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3539
|
+
if (mask && !mask[key]) {
|
3540
|
+
newShape[key] = this.shape[key];
|
3541
|
+
} else {
|
3028
3542
|
const fieldSchema = this.shape[key];
|
3029
3543
|
let newField = fieldSchema;
|
3030
3544
|
while (newField instanceof ZodOptional) {
|
@@ -3032,7 +3546,7 @@ var init_lib = __esm({
|
|
3032
3546
|
}
|
3033
3547
|
newShape[key] = newField;
|
3034
3548
|
}
|
3035
|
-
}
|
3549
|
+
});
|
3036
3550
|
return new _ZodObject({
|
3037
3551
|
...this._def,
|
3038
3552
|
shape: () => newShape
|
@@ -3170,15 +3684,25 @@ var init_lib = __esm({
|
|
3170
3684
|
} else if (type instanceof ZodEnum) {
|
3171
3685
|
return type.options;
|
3172
3686
|
} else if (type instanceof ZodNativeEnum) {
|
3173
|
-
return
|
3687
|
+
return util.objectValues(type.enum);
|
3174
3688
|
} else if (type instanceof ZodDefault) {
|
3175
3689
|
return getDiscriminator(type._def.innerType);
|
3176
3690
|
} else if (type instanceof ZodUndefined) {
|
3177
3691
|
return [void 0];
|
3178
3692
|
} else if (type instanceof ZodNull) {
|
3179
3693
|
return [null];
|
3694
|
+
} else if (type instanceof ZodOptional) {
|
3695
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
3696
|
+
} else if (type instanceof ZodNullable) {
|
3697
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
3698
|
+
} else if (type instanceof ZodBranded) {
|
3699
|
+
return getDiscriminator(type.unwrap());
|
3700
|
+
} else if (type instanceof ZodReadonly) {
|
3701
|
+
return getDiscriminator(type.unwrap());
|
3702
|
+
} else if (type instanceof ZodCatch) {
|
3703
|
+
return getDiscriminator(type._def.innerType);
|
3180
3704
|
} else {
|
3181
|
-
return
|
3705
|
+
return [];
|
3182
3706
|
}
|
3183
3707
|
};
|
3184
3708
|
ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
@@ -3238,7 +3762,7 @@ var init_lib = __esm({
|
|
3238
3762
|
const optionsMap = /* @__PURE__ */ new Map();
|
3239
3763
|
for (const type of options) {
|
3240
3764
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
3241
|
-
if (!discriminatorValues) {
|
3765
|
+
if (!discriminatorValues.length) {
|
3242
3766
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
3243
3767
|
}
|
3244
3768
|
for (const value of discriminatorValues) {
|
@@ -3342,7 +3866,7 @@ var init_lib = __esm({
|
|
3342
3866
|
});
|
3343
3867
|
status.dirty();
|
3344
3868
|
}
|
3345
|
-
const items = ctx.data.map((item, itemIndex) => {
|
3869
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
3346
3870
|
const schema3 = this._def.items[itemIndex] || this._def.rest;
|
3347
3871
|
if (!schema3)
|
3348
3872
|
return null;
|
@@ -3400,7 +3924,8 @@ var init_lib = __esm({
|
|
3400
3924
|
for (const key in ctx.data) {
|
3401
3925
|
pairs.push({
|
3402
3926
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
3403
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
3927
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
3928
|
+
alwaysSet: key in ctx.data
|
3404
3929
|
});
|
3405
3930
|
}
|
3406
3931
|
if (ctx.common.async) {
|
@@ -3430,6 +3955,12 @@ var init_lib = __esm({
|
|
3430
3955
|
}
|
3431
3956
|
};
|
3432
3957
|
ZodMap = class extends ZodType {
|
3958
|
+
get keySchema() {
|
3959
|
+
return this._def.keyType;
|
3960
|
+
}
|
3961
|
+
get valueSchema() {
|
3962
|
+
return this._def.valueType;
|
3963
|
+
}
|
3433
3964
|
_parse(input) {
|
3434
3965
|
const { status, ctx } = this._processInputParams(input);
|
3435
3966
|
if (ctx.parsedType !== ZodParsedType.map) {
|
@@ -3624,27 +4155,29 @@ var init_lib = __esm({
|
|
3624
4155
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
3625
4156
|
const fn = ctx.data;
|
3626
4157
|
if (this._def.returns instanceof ZodPromise) {
|
3627
|
-
|
4158
|
+
const me = this;
|
4159
|
+
return OK(async function(...args) {
|
3628
4160
|
const error2 = new ZodError([]);
|
3629
|
-
const parsedArgs = await
|
4161
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
3630
4162
|
error2.addIssue(makeArgsIssue(args, e));
|
3631
4163
|
throw error2;
|
3632
4164
|
});
|
3633
|
-
const result = await fn
|
3634
|
-
const parsedReturns = await
|
4165
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
4166
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
3635
4167
|
error2.addIssue(makeReturnsIssue(result, e));
|
3636
4168
|
throw error2;
|
3637
4169
|
});
|
3638
4170
|
return parsedReturns;
|
3639
4171
|
});
|
3640
4172
|
} else {
|
3641
|
-
|
3642
|
-
|
4173
|
+
const me = this;
|
4174
|
+
return OK(function(...args) {
|
4175
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
3643
4176
|
if (!parsedArgs.success) {
|
3644
4177
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
3645
4178
|
}
|
3646
|
-
const result = fn
|
3647
|
-
const parsedReturns =
|
4179
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
4180
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
3648
4181
|
if (!parsedReturns.success) {
|
3649
4182
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
3650
4183
|
}
|
@@ -3709,6 +4242,7 @@ var init_lib = __esm({
|
|
3709
4242
|
if (input.data !== this._def.value) {
|
3710
4243
|
const ctx = this._getOrReturnCtx(input);
|
3711
4244
|
addIssueToContext(ctx, {
|
4245
|
+
received: ctx.data,
|
3712
4246
|
code: ZodIssueCode.invalid_literal,
|
3713
4247
|
expected: this._def.value
|
3714
4248
|
});
|
@@ -3727,7 +4261,11 @@ var init_lib = __esm({
|
|
3727
4261
|
...processCreateParams(params)
|
3728
4262
|
});
|
3729
4263
|
};
|
3730
|
-
ZodEnum = class extends ZodType {
|
4264
|
+
ZodEnum = class _ZodEnum extends ZodType {
|
4265
|
+
constructor() {
|
4266
|
+
super(...arguments);
|
4267
|
+
_ZodEnum_cache.set(this, void 0);
|
4268
|
+
}
|
3731
4269
|
_parse(input) {
|
3732
4270
|
if (typeof input.data !== "string") {
|
3733
4271
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3739,7 +4277,10 @@ var init_lib = __esm({
|
|
3739
4277
|
});
|
3740
4278
|
return INVALID;
|
3741
4279
|
}
|
3742
|
-
if (this
|
4280
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
4281
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
4282
|
+
}
|
4283
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
3743
4284
|
const ctx = this._getOrReturnCtx(input);
|
3744
4285
|
const expectedValues = this._def.values;
|
3745
4286
|
addIssueToContext(ctx, {
|
@@ -3775,9 +4316,26 @@ var init_lib = __esm({
|
|
3775
4316
|
}
|
3776
4317
|
return enumValues;
|
3777
4318
|
}
|
4319
|
+
extract(values, newDef = this._def) {
|
4320
|
+
return _ZodEnum.create(values, {
|
4321
|
+
...this._def,
|
4322
|
+
...newDef
|
4323
|
+
});
|
4324
|
+
}
|
4325
|
+
exclude(values, newDef = this._def) {
|
4326
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
4327
|
+
...this._def,
|
4328
|
+
...newDef
|
4329
|
+
});
|
4330
|
+
}
|
3778
4331
|
};
|
4332
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
3779
4333
|
ZodEnum.create = createZodEnum;
|
3780
4334
|
ZodNativeEnum = class extends ZodType {
|
4335
|
+
constructor() {
|
4336
|
+
super(...arguments);
|
4337
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
4338
|
+
}
|
3781
4339
|
_parse(input) {
|
3782
4340
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
3783
4341
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3790,7 +4348,10 @@ var init_lib = __esm({
|
|
3790
4348
|
});
|
3791
4349
|
return INVALID;
|
3792
4350
|
}
|
3793
|
-
if (
|
4351
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
4352
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
4353
|
+
}
|
4354
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
3794
4355
|
const expectedValues = util.objectValues(nativeEnumValues);
|
3795
4356
|
addIssueToContext(ctx, {
|
3796
4357
|
received: ctx.data,
|
@@ -3805,6 +4366,7 @@ var init_lib = __esm({
|
|
3805
4366
|
return this._def.values;
|
3806
4367
|
}
|
3807
4368
|
};
|
4369
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
3808
4370
|
ZodNativeEnum.create = (values, params) => {
|
3809
4371
|
return new ZodNativeEnum({
|
3810
4372
|
values,
|
@@ -3813,6 +4375,9 @@ var init_lib = __esm({
|
|
3813
4375
|
});
|
3814
4376
|
};
|
3815
4377
|
ZodPromise = class extends ZodType {
|
4378
|
+
unwrap() {
|
4379
|
+
return this._def.type;
|
4380
|
+
}
|
3816
4381
|
_parse(input) {
|
3817
4382
|
const { ctx } = this._processInputParams(input);
|
3818
4383
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
@@ -3849,24 +4414,6 @@ var init_lib = __esm({
|
|
3849
4414
|
_parse(input) {
|
3850
4415
|
const { status, ctx } = this._processInputParams(input);
|
3851
4416
|
const effect = this._def.effect || null;
|
3852
|
-
if (effect.type === "preprocess") {
|
3853
|
-
const processed = effect.transform(ctx.data);
|
3854
|
-
if (ctx.common.async) {
|
3855
|
-
return Promise.resolve(processed).then((processed2) => {
|
3856
|
-
return this._def.schema._parseAsync({
|
3857
|
-
data: processed2,
|
3858
|
-
path: ctx.path,
|
3859
|
-
parent: ctx
|
3860
|
-
});
|
3861
|
-
});
|
3862
|
-
} else {
|
3863
|
-
return this._def.schema._parseSync({
|
3864
|
-
data: processed,
|
3865
|
-
path: ctx.path,
|
3866
|
-
parent: ctx
|
3867
|
-
});
|
3868
|
-
}
|
3869
|
-
}
|
3870
4417
|
const checkCtx = {
|
3871
4418
|
addIssue: (arg) => {
|
3872
4419
|
addIssueToContext(ctx, arg);
|
@@ -3881,6 +4428,42 @@ var init_lib = __esm({
|
|
3881
4428
|
}
|
3882
4429
|
};
|
3883
4430
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
4431
|
+
if (effect.type === "preprocess") {
|
4432
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
4433
|
+
if (ctx.common.async) {
|
4434
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
4435
|
+
if (status.value === "aborted")
|
4436
|
+
return INVALID;
|
4437
|
+
const result = await this._def.schema._parseAsync({
|
4438
|
+
data: processed2,
|
4439
|
+
path: ctx.path,
|
4440
|
+
parent: ctx
|
4441
|
+
});
|
4442
|
+
if (result.status === "aborted")
|
4443
|
+
return INVALID;
|
4444
|
+
if (result.status === "dirty")
|
4445
|
+
return DIRTY(result.value);
|
4446
|
+
if (status.value === "dirty")
|
4447
|
+
return DIRTY(result.value);
|
4448
|
+
return result;
|
4449
|
+
});
|
4450
|
+
} else {
|
4451
|
+
if (status.value === "aborted")
|
4452
|
+
return INVALID;
|
4453
|
+
const result = this._def.schema._parseSync({
|
4454
|
+
data: processed,
|
4455
|
+
path: ctx.path,
|
4456
|
+
parent: ctx
|
4457
|
+
});
|
4458
|
+
if (result.status === "aborted")
|
4459
|
+
return INVALID;
|
4460
|
+
if (result.status === "dirty")
|
4461
|
+
return DIRTY(result.value);
|
4462
|
+
if (status.value === "dirty")
|
4463
|
+
return DIRTY(result.value);
|
4464
|
+
return result;
|
4465
|
+
}
|
4466
|
+
}
|
3884
4467
|
if (effect.type === "refinement") {
|
3885
4468
|
const executeRefinement = (acc) => {
|
3886
4469
|
const result = effect.refinement(acc, checkCtx);
|
@@ -4023,26 +4606,45 @@ var init_lib = __esm({
|
|
4023
4606
|
ZodCatch = class extends ZodType {
|
4024
4607
|
_parse(input) {
|
4025
4608
|
const { ctx } = this._processInputParams(input);
|
4609
|
+
const newCtx = {
|
4610
|
+
...ctx,
|
4611
|
+
common: {
|
4612
|
+
...ctx.common,
|
4613
|
+
issues: []
|
4614
|
+
}
|
4615
|
+
};
|
4026
4616
|
const result = this._def.innerType._parse({
|
4027
|
-
data:
|
4028
|
-
path:
|
4029
|
-
parent:
|
4617
|
+
data: newCtx.data,
|
4618
|
+
path: newCtx.path,
|
4619
|
+
parent: {
|
4620
|
+
...newCtx
|
4621
|
+
}
|
4030
4622
|
});
|
4031
4623
|
if (isAsync(result)) {
|
4032
4624
|
return result.then((result2) => {
|
4033
4625
|
return {
|
4034
4626
|
status: "valid",
|
4035
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
4627
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
4628
|
+
get error() {
|
4629
|
+
return new ZodError(newCtx.common.issues);
|
4630
|
+
},
|
4631
|
+
input: newCtx.data
|
4632
|
+
})
|
4036
4633
|
};
|
4037
4634
|
});
|
4038
4635
|
} else {
|
4039
4636
|
return {
|
4040
4637
|
status: "valid",
|
4041
|
-
value: result.status === "valid" ? result.value : this._def.
|
4638
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
4639
|
+
get error() {
|
4640
|
+
return new ZodError(newCtx.common.issues);
|
4641
|
+
},
|
4642
|
+
input: newCtx.data
|
4643
|
+
})
|
4042
4644
|
};
|
4043
4645
|
}
|
4044
4646
|
}
|
4045
|
-
|
4647
|
+
removeCatch() {
|
4046
4648
|
return this._def.innerType;
|
4047
4649
|
}
|
4048
4650
|
};
|
@@ -4050,7 +4652,7 @@ var init_lib = __esm({
|
|
4050
4652
|
return new ZodCatch({
|
4051
4653
|
innerType: type,
|
4052
4654
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
4053
|
-
|
4655
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
4054
4656
|
...processCreateParams(params)
|
4055
4657
|
});
|
4056
4658
|
};
|
@@ -4145,6 +4747,28 @@ var init_lib = __esm({
|
|
4145
4747
|
});
|
4146
4748
|
}
|
4147
4749
|
};
|
4750
|
+
ZodReadonly = class extends ZodType {
|
4751
|
+
_parse(input) {
|
4752
|
+
const result = this._def.innerType._parse(input);
|
4753
|
+
const freeze = (data) => {
|
4754
|
+
if (isValid(data)) {
|
4755
|
+
data.value = Object.freeze(data.value);
|
4756
|
+
}
|
4757
|
+
return data;
|
4758
|
+
};
|
4759
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
4760
|
+
}
|
4761
|
+
unwrap() {
|
4762
|
+
return this._def.innerType;
|
4763
|
+
}
|
4764
|
+
};
|
4765
|
+
ZodReadonly.create = (type, params) => {
|
4766
|
+
return new ZodReadonly({
|
4767
|
+
innerType: type,
|
4768
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
4769
|
+
...processCreateParams(params)
|
4770
|
+
});
|
4771
|
+
};
|
4148
4772
|
late = {
|
4149
4773
|
object: ZodObject.lazycreate
|
4150
4774
|
};
|
@@ -4184,6 +4808,7 @@ var init_lib = __esm({
|
|
4184
4808
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
4185
4809
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
4186
4810
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
4811
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
4187
4812
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
4188
4813
|
stringType = ZodString.create;
|
4189
4814
|
numberType = ZodNumber.create;
|
@@ -4763,19 +5388,54 @@ var init_utils = __esm({
|
|
4763
5388
|
init_mysqlSchema();
|
4764
5389
|
init_pgSchema();
|
4765
5390
|
init_sqliteSchema();
|
4766
|
-
init_source();
|
4767
5391
|
init_global();
|
4768
5392
|
}
|
4769
5393
|
});
|
4770
5394
|
|
4771
5395
|
// src/cli/views.ts
|
4772
|
-
var import_hanji;
|
5396
|
+
var import_hanji, Spinner, ProgressView;
|
4773
5397
|
var init_views = __esm({
|
4774
5398
|
"src/cli/views.ts"() {
|
4775
5399
|
"use strict";
|
4776
5400
|
init_source();
|
4777
5401
|
import_hanji = __toESM(require_hanji());
|
4778
5402
|
init_utils();
|
5403
|
+
Spinner = class {
|
5404
|
+
constructor(frames) {
|
5405
|
+
this.frames = frames;
|
5406
|
+
this.offset = 0;
|
5407
|
+
this.tick = () => {
|
5408
|
+
this.iterator();
|
5409
|
+
};
|
5410
|
+
this.value = () => {
|
5411
|
+
return this.frames[this.offset];
|
5412
|
+
};
|
5413
|
+
this.iterator = () => {
|
5414
|
+
this.offset += 1;
|
5415
|
+
this.offset %= frames.length - 1;
|
5416
|
+
};
|
5417
|
+
}
|
5418
|
+
};
|
5419
|
+
ProgressView = class extends import_hanji.TaskView {
|
5420
|
+
constructor(progressText, successText) {
|
5421
|
+
super();
|
5422
|
+
this.progressText = progressText;
|
5423
|
+
this.successText = successText;
|
5424
|
+
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
5425
|
+
this.timeout = setInterval(() => {
|
5426
|
+
this.spinner.tick();
|
5427
|
+
this.requestLayout();
|
5428
|
+
}, 128);
|
5429
|
+
this.on("detach", () => clearInterval(this.timeout));
|
5430
|
+
}
|
5431
|
+
render(status) {
|
5432
|
+
if (status === "pending") {
|
5433
|
+
const spin = this.spinner.value();
|
5434
|
+
return `[${spin}] ${this.progressText}`;
|
5435
|
+
}
|
5436
|
+
return `[${source_default.green("\u2713")}] ${this.successText}`;
|
5437
|
+
}
|
5438
|
+
};
|
4779
5439
|
}
|
4780
5440
|
});
|
4781
5441
|
|
@@ -4785,7 +5445,6 @@ var init_serializer = __esm({
|
|
4785
5445
|
"src/serializer/index.ts"() {
|
4786
5446
|
"use strict";
|
4787
5447
|
glob = __toESM(require("glob"));
|
4788
|
-
init_source();
|
4789
5448
|
init_views();
|
4790
5449
|
}
|
4791
5450
|
});
|
@@ -4794,7 +5453,6 @@ var init_serializer = __esm({
|
|
4794
5453
|
var init_outputs = __esm({
|
4795
5454
|
"src/cli/validations/outputs.ts"() {
|
4796
5455
|
"use strict";
|
4797
|
-
init_source();
|
4798
5456
|
}
|
4799
5457
|
});
|
4800
5458
|
|
@@ -4848,7 +5506,6 @@ var init_sqliteSerializer = __esm({
|
|
4848
5506
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
4849
5507
|
init_serializer();
|
4850
5508
|
init_outputs();
|
4851
|
-
init_source();
|
4852
5509
|
dialect3 = new import_sqlite_core2.SQLiteSyncDialect();
|
4853
5510
|
fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
4854
5511
|
const result = {};
|
@@ -4856,12 +5513,24 @@ var init_sqliteSerializer = __esm({
|
|
4856
5513
|
`SELECT
|
4857
5514
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
4858
5515
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
4859
|
-
WHERE m.type = 'table'
|
5516
|
+
WHERE m.type = 'table'
|
5517
|
+
and m.tbl_name != 'sqlite_sequence'
|
5518
|
+
and m.tbl_name != 'sqlite_stat1'
|
5519
|
+
and m.tbl_name != '_litestream_seq'
|
5520
|
+
and m.tbl_name != '_litestream_lock'
|
5521
|
+
and m.tbl_name != 'libsql_wasm_func_table'
|
5522
|
+
and m.tbl_name != '__drizzle_migrations'
|
5523
|
+
and m.tbl_name != '_cf_KV';
|
4860
5524
|
`
|
4861
5525
|
);
|
4862
5526
|
const tablesWithSeq = [];
|
4863
5527
|
const seq = await db.query(
|
4864
|
-
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
5528
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
5529
|
+
and name != 'sqlite_stat1'
|
5530
|
+
and name != '_litestream_seq'
|
5531
|
+
and name != '_litestream_lock'
|
5532
|
+
and tbl_name != '_cf_KV'
|
5533
|
+
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
4865
5534
|
);
|
4866
5535
|
for (const s of seq) {
|
4867
5536
|
tablesWithSeq.push(s.name);
|
@@ -4946,7 +5615,8 @@ var init_sqliteSerializer = __esm({
|
|
4946
5615
|
try {
|
4947
5616
|
const fks = await db.query(
|
4948
5617
|
`SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
|
4949
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5618
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5619
|
+
where m.tbl_name != '_cf_KV';`
|
4950
5620
|
);
|
4951
5621
|
const fkByTableName = {};
|
4952
5622
|
for (const fkRow of fks) {
|
@@ -5005,7 +5675,9 @@ FROM sqlite_master AS m,
|
|
5005
5675
|
pragma_index_list(m.name) AS il,
|
5006
5676
|
pragma_index_info(il.name) AS ii
|
5007
5677
|
WHERE
|
5008
|
-
m.type = 'table'
|
5678
|
+
m.type = 'table'
|
5679
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
5680
|
+
and m.tbl_name != '_cf_KV';`
|
5009
5681
|
);
|
5010
5682
|
for (const idxRow of idxs) {
|
5011
5683
|
const tableName = idxRow.tableName;
|
@@ -5049,7 +5721,7 @@ WHERE
|
|
5049
5721
|
|
5050
5722
|
// node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
|
5051
5723
|
var require_balanced_match = __commonJS({
|
5052
|
-
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(
|
5724
|
+
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports2, module2) {
|
5053
5725
|
"use strict";
|
5054
5726
|
module2.exports = balanced;
|
5055
5727
|
function balanced(a, b, str) {
|
@@ -5109,7 +5781,7 @@ var require_balanced_match = __commonJS({
|
|
5109
5781
|
|
5110
5782
|
// node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js
|
5111
5783
|
var require_brace_expansion = __commonJS({
|
5112
|
-
"node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(
|
5784
|
+
"node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports2, module2) {
|
5113
5785
|
var balanced = require_balanced_match();
|
5114
5786
|
module2.exports = expandTop;
|
5115
5787
|
var escSlash = "\0SLASH" + Math.random() + "\0";
|
@@ -5267,7 +5939,6 @@ var init_pgSerializer = __esm({
|
|
5267
5939
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
5268
5940
|
import_drizzle_orm2 = require("drizzle-orm");
|
5269
5941
|
init_serializer();
|
5270
|
-
init_source();
|
5271
5942
|
init_outputs();
|
5272
5943
|
dialect4 = new import_pg_core2.PgDialect();
|
5273
5944
|
trimChar = (str, char) => {
|
@@ -5635,6 +6306,7 @@ var init_pgSerializer = __esm({
|
|
5635
6306
|
"time without time zone": "::time without time zone",
|
5636
6307
|
// "timestamp with time zone": "::timestamp with time zone",
|
5637
6308
|
"timestamp without time zone": "::timestamp without time zone",
|
6309
|
+
"timestamp(": "::timestamp without time zone",
|
5638
6310
|
// date: "::date",
|
5639
6311
|
// interval: "::interval",
|
5640
6312
|
// character: "::bpchar",
|
@@ -5647,15 +6319,15 @@ var init_pgSerializer = __esm({
|
|
5647
6319
|
"character(": "::bpchar"
|
5648
6320
|
};
|
5649
6321
|
defaultForColumn = (column4) => {
|
6322
|
+
if (column4.column_default === null) {
|
6323
|
+
return void 0;
|
6324
|
+
}
|
5650
6325
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
5651
6326
|
return void 0;
|
5652
6327
|
}
|
5653
6328
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
5654
6329
|
(it) => column4.data_type.startsWith(it)
|
5655
6330
|
);
|
5656
|
-
if (column4.column_default === null) {
|
5657
|
-
return void 0;
|
5658
|
-
}
|
5659
6331
|
const columnDefaultAsString = column4.column_default.toString();
|
5660
6332
|
if (columnDefaultAsString.endsWith(
|
5661
6333
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|
@@ -5958,10 +6630,10 @@ Array.prototype.random = function() {
|
|
5958
6630
|
return this[~~(Math.random() * this.length)];
|
5959
6631
|
};
|
5960
6632
|
|
5961
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6633
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
5962
6634
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
5963
6635
|
|
5964
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6636
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
|
5965
6637
|
var posixClasses = {
|
5966
6638
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
5967
6639
|
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
@@ -6071,17 +6743,17 @@ var parseClass = (glob2, position) => {
|
|
6071
6743
|
return [comb, uflag, endPos - pos, true];
|
6072
6744
|
};
|
6073
6745
|
|
6074
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6746
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
|
6075
6747
|
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6076
6748
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
6077
6749
|
};
|
6078
6750
|
|
6079
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6751
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
|
6080
6752
|
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6081
6753
|
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
6082
6754
|
};
|
6083
6755
|
|
6084
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6756
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
6085
6757
|
var minimatch = (p, pattern, options = {}) => {
|
6086
6758
|
assertValidPattern(pattern);
|
6087
6759
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
@@ -7020,7 +7692,14 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
7020
7692
|
}
|
7021
7693
|
return false;
|
7022
7694
|
};
|
7023
|
-
const
|
7695
|
+
const progress = new ProgressView(
|
7696
|
+
"Pulling schema from database...",
|
7697
|
+
"Pulling schema from database..."
|
7698
|
+
);
|
7699
|
+
const res = await (0, import_hanji2.renderWithTask)(
|
7700
|
+
progress,
|
7701
|
+
fromDatabase(db, filter2)
|
7702
|
+
);
|
7024
7703
|
const schema3 = { id: originUUID, prevId: "", ...res };
|
7025
7704
|
return { schema: schema3 };
|
7026
7705
|
};
|
@@ -7028,6 +7707,8 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
7028
7707
|
// src/cli/commands/pgIntrospect.ts
|
7029
7708
|
init_pgSerializer();
|
7030
7709
|
init_global();
|
7710
|
+
init_views();
|
7711
|
+
var import_hanji3 = __toESM(require_hanji());
|
7031
7712
|
var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
7032
7713
|
const matchers = filters.map((it) => {
|
7033
7714
|
return new Minimatch(it);
|
@@ -7042,7 +7723,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
7042
7723
|
}
|
7043
7724
|
return false;
|
7044
7725
|
};
|
7045
|
-
const
|
7726
|
+
const progress = new ProgressView(
|
7727
|
+
"Pulling schema from database...",
|
7728
|
+
"Pulling schema from database..."
|
7729
|
+
);
|
7730
|
+
const res = await (0, import_hanji3.renderWithTask)(
|
7731
|
+
progress,
|
7732
|
+
fromDatabase2(db, filter2, schemaFilters)
|
7733
|
+
);
|
7046
7734
|
const schema3 = { id: originUUID, prevId: "", ...res };
|
7047
7735
|
const { internal, ...schemaWithoutInternals } = schema3;
|
7048
7736
|
return { schema: schemaWithoutInternals };
|