drizzle-kit 0.20.17-a2979a1 → 0.20.17-b08243d
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +25462 -26322
- package/cli/commands/migrate.d.ts +41 -41
- package/cli/commands/mysqlIntrospect.d.ts +8 -8
- package/cli/commands/pgIntrospect.d.ts +8 -8
- package/cli/commands/sqliteIntrospect.d.ts +12 -12
- package/cli/commands/utils.d.ts +2 -2
- package/cli/validations/cli.d.ts +29 -29
- package/cli/validations/common.d.ts +35 -35
- package/cli/validations/mysql.d.ts +4 -4
- package/cli/validations/outputs.d.ts +1 -2
- package/cli/validations/pg.d.ts +4 -4
- package/index.d.mts +2 -48
- package/index.d.ts +2 -48
- package/package.json +1 -1
- package/payload.js +476 -1080
- package/payload.mjs +283 -887
- package/schemaValidator.d.ts +222 -222
- package/serializer/mysqlSchema.d.ts +890 -890
- package/serializer/pgSchema.d.ts +745 -745
- package/serializer/sqliteSchema.d.ts +457 -457
- package/serializer/studio.d.ts +1 -1
- package/snapshotsDiffer.d.ts +315 -316
- package/utils-studio.js +841 -947
- package/utils-studio.mjs +814 -920
- package/utils.js +219 -844
- package/utils.mjs +194 -819
package/utils-studio.js
CHANGED
@@ -33,12 +33,522 @@ 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.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
37
|
+
function assembleStyles() {
|
38
|
+
const codes = /* @__PURE__ */ new Map();
|
39
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
40
|
+
for (const [styleName, style] of Object.entries(group)) {
|
41
|
+
styles[styleName] = {
|
42
|
+
open: `\x1B[${style[0]}m`,
|
43
|
+
close: `\x1B[${style[1]}m`
|
44
|
+
};
|
45
|
+
group[styleName] = styles[styleName];
|
46
|
+
codes.set(style[0], style[1]);
|
47
|
+
}
|
48
|
+
Object.defineProperty(styles, groupName, {
|
49
|
+
value: group,
|
50
|
+
enumerable: false
|
51
|
+
});
|
52
|
+
}
|
53
|
+
Object.defineProperty(styles, "codes", {
|
54
|
+
value: codes,
|
55
|
+
enumerable: false
|
56
|
+
});
|
57
|
+
styles.color.close = "\x1B[39m";
|
58
|
+
styles.bgColor.close = "\x1B[49m";
|
59
|
+
styles.color.ansi = wrapAnsi16();
|
60
|
+
styles.color.ansi256 = wrapAnsi256();
|
61
|
+
styles.color.ansi16m = wrapAnsi16m();
|
62
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
63
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
64
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
65
|
+
Object.defineProperties(styles, {
|
66
|
+
rgbToAnsi256: {
|
67
|
+
value(red, green, blue) {
|
68
|
+
if (red === green && green === blue) {
|
69
|
+
if (red < 8) {
|
70
|
+
return 16;
|
71
|
+
}
|
72
|
+
if (red > 248) {
|
73
|
+
return 231;
|
74
|
+
}
|
75
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
76
|
+
}
|
77
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
78
|
+
},
|
79
|
+
enumerable: false
|
80
|
+
},
|
81
|
+
hexToRgb: {
|
82
|
+
value(hex) {
|
83
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
84
|
+
if (!matches) {
|
85
|
+
return [0, 0, 0];
|
86
|
+
}
|
87
|
+
let [colorString] = matches;
|
88
|
+
if (colorString.length === 3) {
|
89
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
90
|
+
}
|
91
|
+
const integer = Number.parseInt(colorString, 16);
|
92
|
+
return [
|
93
|
+
/* eslint-disable no-bitwise */
|
94
|
+
integer >> 16 & 255,
|
95
|
+
integer >> 8 & 255,
|
96
|
+
integer & 255
|
97
|
+
/* eslint-enable no-bitwise */
|
98
|
+
];
|
99
|
+
},
|
100
|
+
enumerable: false
|
101
|
+
},
|
102
|
+
hexToAnsi256: {
|
103
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
104
|
+
enumerable: false
|
105
|
+
},
|
106
|
+
ansi256ToAnsi: {
|
107
|
+
value(code) {
|
108
|
+
if (code < 8) {
|
109
|
+
return 30 + code;
|
110
|
+
}
|
111
|
+
if (code < 16) {
|
112
|
+
return 90 + (code - 8);
|
113
|
+
}
|
114
|
+
let red;
|
115
|
+
let green;
|
116
|
+
let blue;
|
117
|
+
if (code >= 232) {
|
118
|
+
red = ((code - 232) * 10 + 8) / 255;
|
119
|
+
green = red;
|
120
|
+
blue = red;
|
121
|
+
} else {
|
122
|
+
code -= 16;
|
123
|
+
const remainder = code % 36;
|
124
|
+
red = Math.floor(code / 36) / 5;
|
125
|
+
green = Math.floor(remainder / 6) / 5;
|
126
|
+
blue = remainder % 6 / 5;
|
127
|
+
}
|
128
|
+
const value = Math.max(red, green, blue) * 2;
|
129
|
+
if (value === 0) {
|
130
|
+
return 30;
|
131
|
+
}
|
132
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
133
|
+
if (value === 2) {
|
134
|
+
result += 60;
|
135
|
+
}
|
136
|
+
return result;
|
137
|
+
},
|
138
|
+
enumerable: false
|
139
|
+
},
|
140
|
+
rgbToAnsi: {
|
141
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
142
|
+
enumerable: false
|
143
|
+
},
|
144
|
+
hexToAnsi: {
|
145
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
146
|
+
enumerable: false
|
147
|
+
}
|
148
|
+
});
|
149
|
+
return styles;
|
150
|
+
}
|
151
|
+
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
152
|
+
var init_ansi_styles = __esm({
|
153
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
154
|
+
ANSI_BACKGROUND_OFFSET = 10;
|
155
|
+
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
156
|
+
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
157
|
+
wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
158
|
+
styles = {
|
159
|
+
modifier: {
|
160
|
+
reset: [0, 0],
|
161
|
+
// 21 isn't widely supported and 22 does the same thing
|
162
|
+
bold: [1, 22],
|
163
|
+
dim: [2, 22],
|
164
|
+
italic: [3, 23],
|
165
|
+
underline: [4, 24],
|
166
|
+
overline: [53, 55],
|
167
|
+
inverse: [7, 27],
|
168
|
+
hidden: [8, 28],
|
169
|
+
strikethrough: [9, 29]
|
170
|
+
},
|
171
|
+
color: {
|
172
|
+
black: [30, 39],
|
173
|
+
red: [31, 39],
|
174
|
+
green: [32, 39],
|
175
|
+
yellow: [33, 39],
|
176
|
+
blue: [34, 39],
|
177
|
+
magenta: [35, 39],
|
178
|
+
cyan: [36, 39],
|
179
|
+
white: [37, 39],
|
180
|
+
// Bright color
|
181
|
+
blackBright: [90, 39],
|
182
|
+
gray: [90, 39],
|
183
|
+
// Alias of `blackBright`
|
184
|
+
grey: [90, 39],
|
185
|
+
// Alias of `blackBright`
|
186
|
+
redBright: [91, 39],
|
187
|
+
greenBright: [92, 39],
|
188
|
+
yellowBright: [93, 39],
|
189
|
+
blueBright: [94, 39],
|
190
|
+
magentaBright: [95, 39],
|
191
|
+
cyanBright: [96, 39],
|
192
|
+
whiteBright: [97, 39]
|
193
|
+
},
|
194
|
+
bgColor: {
|
195
|
+
bgBlack: [40, 49],
|
196
|
+
bgRed: [41, 49],
|
197
|
+
bgGreen: [42, 49],
|
198
|
+
bgYellow: [43, 49],
|
199
|
+
bgBlue: [44, 49],
|
200
|
+
bgMagenta: [45, 49],
|
201
|
+
bgCyan: [46, 49],
|
202
|
+
bgWhite: [47, 49],
|
203
|
+
// Bright color
|
204
|
+
bgBlackBright: [100, 49],
|
205
|
+
bgGray: [100, 49],
|
206
|
+
// Alias of `bgBlackBright`
|
207
|
+
bgGrey: [100, 49],
|
208
|
+
// Alias of `bgBlackBright`
|
209
|
+
bgRedBright: [101, 49],
|
210
|
+
bgGreenBright: [102, 49],
|
211
|
+
bgYellowBright: [103, 49],
|
212
|
+
bgBlueBright: [104, 49],
|
213
|
+
bgMagentaBright: [105, 49],
|
214
|
+
bgCyanBright: [106, 49],
|
215
|
+
bgWhiteBright: [107, 49]
|
216
|
+
}
|
217
|
+
};
|
218
|
+
modifierNames = Object.keys(styles.modifier);
|
219
|
+
foregroundColorNames = Object.keys(styles.color);
|
220
|
+
backgroundColorNames = Object.keys(styles.bgColor);
|
221
|
+
colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
222
|
+
ansiStyles = assembleStyles();
|
223
|
+
ansi_styles_default = ansiStyles;
|
224
|
+
}
|
225
|
+
});
|
226
|
+
|
227
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
|
228
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
229
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
230
|
+
const position = argv.indexOf(prefix + flag);
|
231
|
+
const terminatorPosition = argv.indexOf("--");
|
232
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
233
|
+
}
|
234
|
+
function envForceColor() {
|
235
|
+
if ("FORCE_COLOR" in env) {
|
236
|
+
if (env.FORCE_COLOR === "true") {
|
237
|
+
return 1;
|
238
|
+
}
|
239
|
+
if (env.FORCE_COLOR === "false") {
|
240
|
+
return 0;
|
241
|
+
}
|
242
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
function translateLevel(level) {
|
246
|
+
if (level === 0) {
|
247
|
+
return false;
|
248
|
+
}
|
249
|
+
return {
|
250
|
+
level,
|
251
|
+
hasBasic: true,
|
252
|
+
has256: level >= 2,
|
253
|
+
has16m: level >= 3
|
254
|
+
};
|
255
|
+
}
|
256
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
257
|
+
const noFlagForceColor = envForceColor();
|
258
|
+
if (noFlagForceColor !== void 0) {
|
259
|
+
flagForceColor = noFlagForceColor;
|
260
|
+
}
|
261
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
262
|
+
if (forceColor === 0) {
|
263
|
+
return 0;
|
264
|
+
}
|
265
|
+
if (sniffFlags) {
|
266
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
267
|
+
return 3;
|
268
|
+
}
|
269
|
+
if (hasFlag("color=256")) {
|
270
|
+
return 2;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
274
|
+
return 1;
|
275
|
+
}
|
276
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
277
|
+
return 0;
|
278
|
+
}
|
279
|
+
const min = forceColor || 0;
|
280
|
+
if (env.TERM === "dumb") {
|
281
|
+
return min;
|
282
|
+
}
|
283
|
+
if (import_node_process.default.platform === "win32") {
|
284
|
+
const osRelease = import_node_os.default.release().split(".");
|
285
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
286
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
287
|
+
}
|
288
|
+
return 1;
|
289
|
+
}
|
290
|
+
if ("CI" in env) {
|
291
|
+
if ("GITHUB_ACTIONS" in env) {
|
292
|
+
return 3;
|
293
|
+
}
|
294
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
295
|
+
return 1;
|
296
|
+
}
|
297
|
+
return min;
|
298
|
+
}
|
299
|
+
if ("TEAMCITY_VERSION" in env) {
|
300
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
301
|
+
}
|
302
|
+
if (env.COLORTERM === "truecolor") {
|
303
|
+
return 3;
|
304
|
+
}
|
305
|
+
if (env.TERM === "xterm-kitty") {
|
306
|
+
return 3;
|
307
|
+
}
|
308
|
+
if ("TERM_PROGRAM" in env) {
|
309
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
310
|
+
switch (env.TERM_PROGRAM) {
|
311
|
+
case "iTerm.app": {
|
312
|
+
return version >= 3 ? 3 : 2;
|
313
|
+
}
|
314
|
+
case "Apple_Terminal": {
|
315
|
+
return 2;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
}
|
319
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
320
|
+
return 2;
|
321
|
+
}
|
322
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
323
|
+
return 1;
|
324
|
+
}
|
325
|
+
if ("COLORTERM" in env) {
|
326
|
+
return 1;
|
327
|
+
}
|
328
|
+
return min;
|
329
|
+
}
|
330
|
+
function createSupportsColor(stream, options = {}) {
|
331
|
+
const level = _supportsColor(stream, {
|
332
|
+
streamIsTTY: stream && stream.isTTY,
|
333
|
+
...options
|
334
|
+
});
|
335
|
+
return translateLevel(level);
|
336
|
+
}
|
337
|
+
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
338
|
+
var init_supports_color = __esm({
|
339
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
340
|
+
import_node_process = __toESM(require("node:process"), 1);
|
341
|
+
import_node_os = __toESM(require("node:os"), 1);
|
342
|
+
import_node_tty = __toESM(require("node:tty"), 1);
|
343
|
+
({ env } = import_node_process.default);
|
344
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
345
|
+
flagForceColor = 0;
|
346
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
347
|
+
flagForceColor = 1;
|
348
|
+
}
|
349
|
+
supportsColor = {
|
350
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
351
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
352
|
+
};
|
353
|
+
supports_color_default = supportsColor;
|
354
|
+
}
|
355
|
+
});
|
356
|
+
|
357
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
|
358
|
+
function stringReplaceAll(string, substring, replacer) {
|
359
|
+
let index4 = string.indexOf(substring);
|
360
|
+
if (index4 === -1) {
|
361
|
+
return string;
|
362
|
+
}
|
363
|
+
const substringLength = substring.length;
|
364
|
+
let endIndex = 0;
|
365
|
+
let returnValue = "";
|
366
|
+
do {
|
367
|
+
returnValue += string.slice(endIndex, index4) + substring + replacer;
|
368
|
+
endIndex = index4 + substringLength;
|
369
|
+
index4 = string.indexOf(substring, endIndex);
|
370
|
+
} while (index4 !== -1);
|
371
|
+
returnValue += string.slice(endIndex);
|
372
|
+
return returnValue;
|
373
|
+
}
|
374
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
375
|
+
let endIndex = 0;
|
376
|
+
let returnValue = "";
|
377
|
+
do {
|
378
|
+
const gotCR = string[index4 - 1] === "\r";
|
379
|
+
returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
380
|
+
endIndex = index4 + 1;
|
381
|
+
index4 = string.indexOf("\n", endIndex);
|
382
|
+
} while (index4 !== -1);
|
383
|
+
returnValue += string.slice(endIndex);
|
384
|
+
return returnValue;
|
385
|
+
}
|
386
|
+
var init_utilities = __esm({
|
387
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
|
388
|
+
}
|
389
|
+
});
|
390
|
+
|
391
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
|
392
|
+
function createChalk(options) {
|
393
|
+
return chalkFactory(options);
|
394
|
+
}
|
395
|
+
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
|
396
|
+
var init_source = __esm({
|
397
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
|
398
|
+
init_ansi_styles();
|
399
|
+
init_supports_color();
|
400
|
+
init_utilities();
|
401
|
+
init_ansi_styles();
|
402
|
+
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
403
|
+
GENERATOR = Symbol("GENERATOR");
|
404
|
+
STYLER = Symbol("STYLER");
|
405
|
+
IS_EMPTY = Symbol("IS_EMPTY");
|
406
|
+
levelMapping = [
|
407
|
+
"ansi",
|
408
|
+
"ansi",
|
409
|
+
"ansi256",
|
410
|
+
"ansi16m"
|
411
|
+
];
|
412
|
+
styles2 = /* @__PURE__ */ Object.create(null);
|
413
|
+
applyOptions = (object, options = {}) => {
|
414
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
415
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
416
|
+
}
|
417
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
418
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
419
|
+
};
|
420
|
+
chalkFactory = (options) => {
|
421
|
+
const chalk2 = (...strings) => strings.join(" ");
|
422
|
+
applyOptions(chalk2, options);
|
423
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
424
|
+
return chalk2;
|
425
|
+
};
|
426
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
427
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
428
|
+
styles2[styleName] = {
|
429
|
+
get() {
|
430
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
431
|
+
Object.defineProperty(this, styleName, { value: builder });
|
432
|
+
return builder;
|
433
|
+
}
|
434
|
+
};
|
435
|
+
}
|
436
|
+
styles2.visible = {
|
437
|
+
get() {
|
438
|
+
const builder = createBuilder(this, this[STYLER], true);
|
439
|
+
Object.defineProperty(this, "visible", { value: builder });
|
440
|
+
return builder;
|
441
|
+
}
|
442
|
+
};
|
443
|
+
getModelAnsi = (model, level, type, ...arguments_) => {
|
444
|
+
if (model === "rgb") {
|
445
|
+
if (level === "ansi16m") {
|
446
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
447
|
+
}
|
448
|
+
if (level === "ansi256") {
|
449
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
450
|
+
}
|
451
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
452
|
+
}
|
453
|
+
if (model === "hex") {
|
454
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
455
|
+
}
|
456
|
+
return ansi_styles_default[type][model](...arguments_);
|
457
|
+
};
|
458
|
+
usedModels = ["rgb", "hex", "ansi256"];
|
459
|
+
for (const model of usedModels) {
|
460
|
+
styles2[model] = {
|
461
|
+
get() {
|
462
|
+
const { level } = this;
|
463
|
+
return function(...arguments_) {
|
464
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
465
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
466
|
+
};
|
467
|
+
}
|
468
|
+
};
|
469
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
470
|
+
styles2[bgModel] = {
|
471
|
+
get() {
|
472
|
+
const { level } = this;
|
473
|
+
return function(...arguments_) {
|
474
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
475
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
476
|
+
};
|
477
|
+
}
|
478
|
+
};
|
479
|
+
}
|
480
|
+
proto = Object.defineProperties(() => {
|
481
|
+
}, {
|
482
|
+
...styles2,
|
483
|
+
level: {
|
484
|
+
enumerable: true,
|
485
|
+
get() {
|
486
|
+
return this[GENERATOR].level;
|
487
|
+
},
|
488
|
+
set(level) {
|
489
|
+
this[GENERATOR].level = level;
|
490
|
+
}
|
491
|
+
}
|
492
|
+
});
|
493
|
+
createStyler = (open, close, parent) => {
|
494
|
+
let openAll;
|
495
|
+
let closeAll;
|
496
|
+
if (parent === void 0) {
|
497
|
+
openAll = open;
|
498
|
+
closeAll = close;
|
499
|
+
} else {
|
500
|
+
openAll = parent.openAll + open;
|
501
|
+
closeAll = close + parent.closeAll;
|
502
|
+
}
|
503
|
+
return {
|
504
|
+
open,
|
505
|
+
close,
|
506
|
+
openAll,
|
507
|
+
closeAll,
|
508
|
+
parent
|
509
|
+
};
|
510
|
+
};
|
511
|
+
createBuilder = (self2, _styler, _isEmpty) => {
|
512
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
513
|
+
Object.setPrototypeOf(builder, proto);
|
514
|
+
builder[GENERATOR] = self2;
|
515
|
+
builder[STYLER] = _styler;
|
516
|
+
builder[IS_EMPTY] = _isEmpty;
|
517
|
+
return builder;
|
518
|
+
};
|
519
|
+
applyStyle = (self2, string) => {
|
520
|
+
if (self2.level <= 0 || !string) {
|
521
|
+
return self2[IS_EMPTY] ? "" : string;
|
522
|
+
}
|
523
|
+
let styler = self2[STYLER];
|
524
|
+
if (styler === void 0) {
|
525
|
+
return string;
|
526
|
+
}
|
527
|
+
const { openAll, closeAll } = styler;
|
528
|
+
if (string.includes("\x1B")) {
|
529
|
+
while (styler !== void 0) {
|
530
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
531
|
+
styler = styler.parent;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
const lfIndex = string.indexOf("\n");
|
535
|
+
if (lfIndex !== -1) {
|
536
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
537
|
+
}
|
538
|
+
return openAll + string + closeAll;
|
539
|
+
};
|
540
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
541
|
+
chalk = createChalk();
|
542
|
+
chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
543
|
+
}
|
544
|
+
});
|
545
|
+
|
36
546
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
|
37
547
|
var require_readline = __commonJS({
|
38
|
-
"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"(exports) {
|
39
549
|
"use strict";
|
40
|
-
Object.defineProperty(
|
41
|
-
|
550
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
551
|
+
exports.prepareReadLine = void 0;
|
42
552
|
var prepareReadLine = () => {
|
43
553
|
const stdin = process.stdin;
|
44
554
|
const stdout = process.stdout;
|
@@ -54,13 +564,13 @@ var require_readline = __commonJS({
|
|
54
564
|
closable: rl
|
55
565
|
};
|
56
566
|
};
|
57
|
-
|
567
|
+
exports.prepareReadLine = prepareReadLine;
|
58
568
|
}
|
59
569
|
});
|
60
570
|
|
61
571
|
// node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
62
572
|
var require_src = __commonJS({
|
63
|
-
"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"(exports, module2) {
|
64
574
|
"use strict";
|
65
575
|
var ESC = "\x1B";
|
66
576
|
var CSI = `${ESC}[`;
|
@@ -121,10 +631,10 @@ var require_src = __commonJS({
|
|
121
631
|
|
122
632
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
|
123
633
|
var require_utils = __commonJS({
|
124
|
-
"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"(exports) {
|
125
635
|
"use strict";
|
126
|
-
Object.defineProperty(
|
127
|
-
|
636
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
637
|
+
exports.clear = void 0;
|
128
638
|
var sisteransi_1 = require_src();
|
129
639
|
var strip = (str) => {
|
130
640
|
const pattern = [
|
@@ -145,13 +655,13 @@ var require_utils = __commonJS({
|
|
145
655
|
}
|
146
656
|
return sisteransi_1.erase.lines(rows);
|
147
657
|
};
|
148
|
-
|
658
|
+
exports.clear = clear;
|
149
659
|
}
|
150
660
|
});
|
151
661
|
|
152
662
|
// node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
|
153
663
|
var require_lodash = __commonJS({
|
154
|
-
"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"(exports, module2) {
|
155
665
|
var FUNC_ERROR_TEXT = "Expected a function";
|
156
666
|
var NAN = 0 / 0;
|
157
667
|
var symbolTag = "[object Symbol]";
|
@@ -299,9 +809,9 @@ var require_lodash = __commonJS({
|
|
299
809
|
|
300
810
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
|
301
811
|
var require_hanji = __commonJS({
|
302
|
-
"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"(exports) {
|
303
813
|
"use strict";
|
304
|
-
var __awaiter =
|
814
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
305
815
|
function adopt(value) {
|
306
816
|
return value instanceof P ? value : new P(function(resolve) {
|
307
817
|
resolve(value);
|
@@ -328,11 +838,11 @@ var require_hanji = __commonJS({
|
|
328
838
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
329
839
|
});
|
330
840
|
};
|
331
|
-
var __importDefault =
|
841
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
332
842
|
return mod && mod.__esModule ? mod : { "default": mod };
|
333
843
|
};
|
334
|
-
Object.defineProperty(
|
335
|
-
|
844
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
845
|
+
exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
|
336
846
|
var readline_1 = require_readline();
|
337
847
|
var sisteransi_1 = require_src();
|
338
848
|
var utils_1 = require_utils();
|
@@ -367,7 +877,7 @@ var require_hanji = __commonJS({
|
|
367
877
|
this.inputCallbacks.forEach((it) => it(str, key));
|
368
878
|
}
|
369
879
|
};
|
370
|
-
|
880
|
+
exports.Prompt = Prompt2;
|
371
881
|
var SelectState2 = class {
|
372
882
|
constructor(items) {
|
373
883
|
this.items = items;
|
@@ -395,7 +905,7 @@ var require_hanji = __commonJS({
|
|
395
905
|
return false;
|
396
906
|
}
|
397
907
|
};
|
398
|
-
|
908
|
+
exports.SelectState = SelectState2;
|
399
909
|
var deferred = () => {
|
400
910
|
let resolve;
|
401
911
|
let reject;
|
@@ -409,7 +919,7 @@ var require_hanji = __commonJS({
|
|
409
919
|
promise
|
410
920
|
};
|
411
921
|
};
|
412
|
-
|
922
|
+
exports.deferred = deferred;
|
413
923
|
var Terminal = class {
|
414
924
|
constructor(view, stdin, stdout, closable) {
|
415
925
|
this.view = view;
|
@@ -454,7 +964,7 @@ var require_hanji = __commonJS({
|
|
454
964
|
};
|
455
965
|
this.stdin.on("keypress", keypress);
|
456
966
|
this.view.attach(this);
|
457
|
-
const { resolve, promise } = (0,
|
967
|
+
const { resolve, promise } = (0, exports.deferred)();
|
458
968
|
this.resolve = resolve;
|
459
969
|
this.promise = promise;
|
460
970
|
this.renderFunc = (0, lodash_throttle_1.default)((str) => {
|
@@ -485,7 +995,7 @@ var require_hanji = __commonJS({
|
|
485
995
|
this.renderFunc(`${clearPrefix}${string}`);
|
486
996
|
}
|
487
997
|
};
|
488
|
-
|
998
|
+
exports.Terminal = Terminal;
|
489
999
|
var TaskView2 = class {
|
490
1000
|
constructor() {
|
491
1001
|
this.attachCallbacks = [];
|
@@ -510,7 +1020,7 @@ var require_hanji = __commonJS({
|
|
510
1020
|
}
|
511
1021
|
}
|
512
1022
|
};
|
513
|
-
|
1023
|
+
exports.TaskView = TaskView2;
|
514
1024
|
var TaskTerminal = class {
|
515
1025
|
constructor(view, stdout) {
|
516
1026
|
this.view = view;
|
@@ -531,7 +1041,7 @@ var require_hanji = __commonJS({
|
|
531
1041
|
this.stdout.write(`${clearPrefix}${string}`);
|
532
1042
|
}
|
533
1043
|
};
|
534
|
-
|
1044
|
+
exports.TaskTerminal = TaskTerminal;
|
535
1045
|
function render2(view) {
|
536
1046
|
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
537
1047
|
if (view instanceof Prompt2) {
|
@@ -544,7 +1054,7 @@ var require_hanji = __commonJS({
|
|
544
1054
|
closable.close();
|
545
1055
|
return;
|
546
1056
|
}
|
547
|
-
|
1057
|
+
exports.render = render2;
|
548
1058
|
function renderWithTask2(view, task) {
|
549
1059
|
return __awaiter(this, void 0, void 0, function* () {
|
550
1060
|
const terminal = new TaskTerminal(view, process.stdout);
|
@@ -554,12 +1064,12 @@ var require_hanji = __commonJS({
|
|
554
1064
|
return result;
|
555
1065
|
});
|
556
1066
|
}
|
557
|
-
|
1067
|
+
exports.renderWithTask = renderWithTask2;
|
558
1068
|
var terminateHandler;
|
559
1069
|
function onTerminate(callback) {
|
560
1070
|
terminateHandler = callback;
|
561
1071
|
}
|
562
|
-
|
1072
|
+
exports.onTerminate = onTerminate;
|
563
1073
|
}
|
564
1074
|
});
|
565
1075
|
|
@@ -573,12 +1083,11 @@ var init_global = __esm({
|
|
573
1083
|
}
|
574
1084
|
});
|
575
1085
|
|
576
|
-
// node_modules/.pnpm/zod@3.
|
1086
|
+
// node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
|
577
1087
|
function getErrorMap() {
|
578
1088
|
return overrideErrorMap;
|
579
1089
|
}
|
580
1090
|
function addIssueToContext(ctx, issueData) {
|
581
|
-
const overrideMap = getErrorMap();
|
582
1091
|
const issue = makeIssue({
|
583
1092
|
issueData,
|
584
1093
|
data: ctx.data,
|
@@ -586,29 +1095,13 @@ function addIssueToContext(ctx, issueData) {
|
|
586
1095
|
errorMaps: [
|
587
1096
|
ctx.common.contextualErrorMap,
|
588
1097
|
ctx.schemaErrorMap,
|
589
|
-
|
590
|
-
|
1098
|
+
getErrorMap(),
|
1099
|
+
errorMap
|
591
1100
|
// then global default map
|
592
1101
|
].filter((x) => !!x)
|
593
1102
|
});
|
594
1103
|
ctx.common.issues.push(issue);
|
595
1104
|
}
|
596
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
597
|
-
if (kind === "a" && !f)
|
598
|
-
throw new TypeError("Private accessor was defined without a getter");
|
599
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
600
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
601
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
602
|
-
}
|
603
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
604
|
-
if (kind === "m")
|
605
|
-
throw new TypeError("Private method is not writable");
|
606
|
-
if (kind === "a" && !f)
|
607
|
-
throw new TypeError("Private accessor was defined without a setter");
|
608
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
609
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
610
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
611
|
-
}
|
612
1105
|
function processCreateParams(params) {
|
613
1106
|
if (!params)
|
614
1107
|
return {};
|
@@ -619,50 +1112,15 @@ function processCreateParams(params) {
|
|
619
1112
|
if (errorMap2)
|
620
1113
|
return { errorMap: errorMap2, description };
|
621
1114
|
const customMap = (iss, ctx) => {
|
622
|
-
var _a, _b;
|
623
|
-
const { message } = params;
|
624
|
-
if (iss.code === "invalid_enum_value") {
|
625
|
-
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
626
|
-
}
|
627
|
-
if (typeof ctx.data === "undefined") {
|
628
|
-
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
629
|
-
}
|
630
1115
|
if (iss.code !== "invalid_type")
|
631
1116
|
return { message: ctx.defaultError };
|
632
|
-
|
1117
|
+
if (typeof ctx.data === "undefined") {
|
1118
|
+
return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
|
1119
|
+
}
|
1120
|
+
return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
|
633
1121
|
};
|
634
1122
|
return { errorMap: customMap, description };
|
635
1123
|
}
|
636
|
-
function timeRegexSource(args) {
|
637
|
-
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
638
|
-
if (args.precision) {
|
639
|
-
regex = `${regex}\\.\\d{${args.precision}}`;
|
640
|
-
} else if (args.precision == null) {
|
641
|
-
regex = `${regex}(\\.\\d+)?`;
|
642
|
-
}
|
643
|
-
return regex;
|
644
|
-
}
|
645
|
-
function timeRegex(args) {
|
646
|
-
return new RegExp(`^${timeRegexSource(args)}$`);
|
647
|
-
}
|
648
|
-
function datetimeRegex(args) {
|
649
|
-
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
650
|
-
const opts = [];
|
651
|
-
opts.push(args.local ? `Z?` : `Z`);
|
652
|
-
if (args.offset)
|
653
|
-
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
654
|
-
regex = `${regex}(${opts.join("|")})`;
|
655
|
-
return new RegExp(`^${regex}$`);
|
656
|
-
}
|
657
|
-
function isValidIP(ip, version) {
|
658
|
-
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
659
|
-
return true;
|
660
|
-
}
|
661
|
-
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
662
|
-
return true;
|
663
|
-
}
|
664
|
-
return false;
|
665
|
-
}
|
666
1124
|
function floatSafeRemainder(val, step) {
|
667
1125
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
668
1126
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
@@ -683,10 +1141,7 @@ function deepPartialify(schema3) {
|
|
683
1141
|
shape: () => newShape
|
684
1142
|
});
|
685
1143
|
} else if (schema3 instanceof ZodArray) {
|
686
|
-
return
|
687
|
-
...schema3._def,
|
688
|
-
type: deepPartialify(schema3.element)
|
689
|
-
});
|
1144
|
+
return ZodArray.create(deepPartialify(schema3.element));
|
690
1145
|
} else if (schema3 instanceof ZodOptional) {
|
691
1146
|
return ZodOptional.create(deepPartialify(schema3.unwrap()));
|
692
1147
|
} else if (schema3 instanceof ZodNullable) {
|
@@ -742,9 +1197,9 @@ function createZodEnum(values, params) {
|
|
742
1197
|
...processCreateParams(params)
|
743
1198
|
});
|
744
1199
|
}
|
745
|
-
var util,
|
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, datetimeRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, objectUtil, AugmentFactory, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
|
746
1201
|
var init_lib = __esm({
|
747
|
-
"node_modules/.pnpm/zod@3.
|
1202
|
+
"node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs"() {
|
748
1203
|
(function(util2) {
|
749
1204
|
util2.assertEqual = (val) => val;
|
750
1205
|
function assertIs(_arg) {
|
@@ -802,15 +1257,6 @@ var init_lib = __esm({
|
|
802
1257
|
return value;
|
803
1258
|
};
|
804
1259
|
})(util || (util = {}));
|
805
|
-
(function(objectUtil2) {
|
806
|
-
objectUtil2.mergeShapes = (first, second) => {
|
807
|
-
return {
|
808
|
-
...first,
|
809
|
-
...second
|
810
|
-
// second overwrites first
|
811
|
-
};
|
812
|
-
};
|
813
|
-
})(objectUtil || (objectUtil = {}));
|
814
1260
|
ZodParsedType = util.arrayToEnum([
|
815
1261
|
"string",
|
816
1262
|
"nan",
|
@@ -892,7 +1338,7 @@ var init_lib = __esm({
|
|
892
1338
|
"not_multiple_of",
|
893
1339
|
"not_finite"
|
894
1340
|
]);
|
895
|
-
ZodError = class
|
1341
|
+
ZodError = class extends Error {
|
896
1342
|
constructor(issues) {
|
897
1343
|
super();
|
898
1344
|
this.issues = [];
|
@@ -950,11 +1396,6 @@ var init_lib = __esm({
|
|
950
1396
|
processError(this);
|
951
1397
|
return fieldErrors;
|
952
1398
|
}
|
953
|
-
static assert(value) {
|
954
|
-
if (!(value instanceof _ZodError)) {
|
955
|
-
throw new Error(`Not a ZodError: ${value}`);
|
956
|
-
}
|
957
|
-
}
|
958
1399
|
toString() {
|
959
1400
|
return this.message;
|
960
1401
|
}
|
@@ -1021,12 +1462,7 @@ var init_lib = __esm({
|
|
1021
1462
|
break;
|
1022
1463
|
case ZodIssueCode.invalid_string:
|
1023
1464
|
if (typeof issue.validation === "object") {
|
1024
|
-
if ("
|
1025
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
1026
|
-
if (typeof issue.validation.position === "number") {
|
1027
|
-
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
1028
|
-
}
|
1029
|
-
} else if ("startsWith" in issue.validation) {
|
1465
|
+
if ("startsWith" in issue.validation) {
|
1030
1466
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
1031
1467
|
} else if ("endsWith" in issue.validation) {
|
1032
1468
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
@@ -1047,7 +1483,7 @@ var init_lib = __esm({
|
|
1047
1483
|
else if (issue.type === "number")
|
1048
1484
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
1049
1485
|
else if (issue.type === "date")
|
1050
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(
|
1486
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
|
1051
1487
|
else
|
1052
1488
|
message = "Invalid input";
|
1053
1489
|
break;
|
@@ -1058,10 +1494,8 @@ var init_lib = __esm({
|
|
1058
1494
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
1059
1495
|
else if (issue.type === "number")
|
1060
1496
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1061
|
-
else if (issue.type === "bigint")
|
1062
|
-
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1063
1497
|
else if (issue.type === "date")
|
1064
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(
|
1498
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
|
1065
1499
|
else
|
1066
1500
|
message = "Invalid input";
|
1067
1501
|
break;
|
@@ -1091,13 +1525,6 @@ var init_lib = __esm({
|
|
1091
1525
|
...issueData,
|
1092
1526
|
path: fullPath
|
1093
1527
|
};
|
1094
|
-
if (issueData.message !== void 0) {
|
1095
|
-
return {
|
1096
|
-
...issueData,
|
1097
|
-
path: fullPath,
|
1098
|
-
message: issueData.message
|
1099
|
-
};
|
1100
|
-
}
|
1101
1528
|
let errorMessage = "";
|
1102
1529
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
1103
1530
|
for (const map of maps) {
|
@@ -1106,7 +1533,7 @@ var init_lib = __esm({
|
|
1106
1533
|
return {
|
1107
1534
|
...issueData,
|
1108
1535
|
path: fullPath,
|
1109
|
-
message: errorMessage
|
1536
|
+
message: issueData.message || errorMessage
|
1110
1537
|
};
|
1111
1538
|
};
|
1112
1539
|
ParseStatus = class _ParseStatus {
|
@@ -1135,11 +1562,9 @@ var init_lib = __esm({
|
|
1135
1562
|
static async mergeObjectAsync(status, pairs) {
|
1136
1563
|
const syncPairs = [];
|
1137
1564
|
for (const pair of pairs) {
|
1138
|
-
const key = await pair.key;
|
1139
|
-
const value = await pair.value;
|
1140
1565
|
syncPairs.push({
|
1141
|
-
key,
|
1142
|
-
value
|
1566
|
+
key: await pair.key,
|
1567
|
+
value: await pair.value
|
1143
1568
|
});
|
1144
1569
|
}
|
1145
1570
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
@@ -1156,7 +1581,7 @@ var init_lib = __esm({
|
|
1156
1581
|
status.dirty();
|
1157
1582
|
if (value.status === "dirty")
|
1158
1583
|
status.dirty();
|
1159
|
-
if (
|
1584
|
+
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
1160
1585
|
finalObject[key.value] = value.value;
|
1161
1586
|
}
|
1162
1587
|
}
|
@@ -1171,28 +1596,20 @@ var init_lib = __esm({
|
|
1171
1596
|
isAborted = (x) => x.status === "aborted";
|
1172
1597
|
isDirty = (x) => x.status === "dirty";
|
1173
1598
|
isValid = (x) => x.status === "valid";
|
1174
|
-
isAsync = (x) => typeof Promise !==
|
1599
|
+
isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
|
1175
1600
|
(function(errorUtil2) {
|
1176
1601
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1177
1602
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
1178
1603
|
})(errorUtil || (errorUtil = {}));
|
1179
1604
|
ParseInputLazyPath = class {
|
1180
1605
|
constructor(parent, value, path2, key) {
|
1181
|
-
this._cachedPath = [];
|
1182
1606
|
this.parent = parent;
|
1183
1607
|
this.data = value;
|
1184
1608
|
this._path = path2;
|
1185
1609
|
this._key = key;
|
1186
1610
|
}
|
1187
1611
|
get path() {
|
1188
|
-
|
1189
|
-
if (this._key instanceof Array) {
|
1190
|
-
this._cachedPath.push(...this._path, ...this._key);
|
1191
|
-
} else {
|
1192
|
-
this._cachedPath.push(...this._path, this._key);
|
1193
|
-
}
|
1194
|
-
}
|
1195
|
-
return this._cachedPath;
|
1612
|
+
return this._path.concat(this._key);
|
1196
1613
|
}
|
1197
1614
|
};
|
1198
1615
|
handleResult = (ctx, result) => {
|
@@ -1202,16 +1619,8 @@ var init_lib = __esm({
|
|
1202
1619
|
if (!ctx.common.issues.length) {
|
1203
1620
|
throw new Error("Validation failed but no issues detected.");
|
1204
1621
|
}
|
1205
|
-
|
1206
|
-
|
1207
|
-
get error() {
|
1208
|
-
if (this._error)
|
1209
|
-
return this._error;
|
1210
|
-
const error2 = new ZodError(ctx.common.issues);
|
1211
|
-
this._error = error2;
|
1212
|
-
return this._error;
|
1213
|
-
}
|
1214
|
-
};
|
1622
|
+
const error2 = new ZodError(ctx.common.issues);
|
1623
|
+
return { success: false, error: error2 };
|
1215
1624
|
}
|
1216
1625
|
};
|
1217
1626
|
ZodType = class {
|
@@ -1239,7 +1648,6 @@ var init_lib = __esm({
|
|
1239
1648
|
this.catch = this.catch.bind(this);
|
1240
1649
|
this.describe = this.describe.bind(this);
|
1241
1650
|
this.pipe = this.pipe.bind(this);
|
1242
|
-
this.readonly = this.readonly.bind(this);
|
1243
1651
|
this.isNullable = this.isNullable.bind(this);
|
1244
1652
|
this.isOptional = this.isOptional.bind(this);
|
1245
1653
|
}
|
@@ -1384,29 +1792,28 @@ var init_lib = __esm({
|
|
1384
1792
|
return this._refinement(refinement);
|
1385
1793
|
}
|
1386
1794
|
optional() {
|
1387
|
-
return ZodOptional.create(this
|
1795
|
+
return ZodOptional.create(this);
|
1388
1796
|
}
|
1389
1797
|
nullable() {
|
1390
|
-
return ZodNullable.create(this
|
1798
|
+
return ZodNullable.create(this);
|
1391
1799
|
}
|
1392
1800
|
nullish() {
|
1393
|
-
return this.
|
1801
|
+
return this.optional().nullable();
|
1394
1802
|
}
|
1395
1803
|
array() {
|
1396
|
-
return ZodArray.create(this
|
1804
|
+
return ZodArray.create(this);
|
1397
1805
|
}
|
1398
1806
|
promise() {
|
1399
|
-
return ZodPromise.create(this
|
1807
|
+
return ZodPromise.create(this);
|
1400
1808
|
}
|
1401
1809
|
or(option) {
|
1402
|
-
return ZodUnion.create([this, option]
|
1810
|
+
return ZodUnion.create([this, option]);
|
1403
1811
|
}
|
1404
1812
|
and(incoming) {
|
1405
|
-
return ZodIntersection.create(this, incoming
|
1813
|
+
return ZodIntersection.create(this, incoming);
|
1406
1814
|
}
|
1407
1815
|
transform(transform) {
|
1408
1816
|
return new ZodEffects({
|
1409
|
-
...processCreateParams(this._def),
|
1410
1817
|
schema: this,
|
1411
1818
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
1412
1819
|
effect: { type: "transform", transform }
|
@@ -1415,7 +1822,6 @@ var init_lib = __esm({
|
|
1415
1822
|
default(def) {
|
1416
1823
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
1417
1824
|
return new ZodDefault({
|
1418
|
-
...processCreateParams(this._def),
|
1419
1825
|
innerType: this,
|
1420
1826
|
defaultValue: defaultValueFunc,
|
1421
1827
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
@@ -1425,15 +1831,14 @@ var init_lib = __esm({
|
|
1425
1831
|
return new ZodBranded({
|
1426
1832
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
1427
1833
|
type: this,
|
1428
|
-
...processCreateParams(
|
1834
|
+
...processCreateParams(void 0)
|
1429
1835
|
});
|
1430
1836
|
}
|
1431
1837
|
catch(def) {
|
1432
|
-
const
|
1838
|
+
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
1433
1839
|
return new ZodCatch({
|
1434
|
-
...processCreateParams(this._def),
|
1435
1840
|
innerType: this,
|
1436
|
-
|
1841
|
+
defaultValue: defaultValueFunc,
|
1437
1842
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
1438
1843
|
});
|
1439
1844
|
}
|
@@ -1447,9 +1852,6 @@ var init_lib = __esm({
|
|
1447
1852
|
pipe(target) {
|
1448
1853
|
return ZodPipeline.create(this, target);
|
1449
1854
|
}
|
1450
|
-
readonly() {
|
1451
|
-
return ZodReadonly.create(this);
|
1452
|
-
}
|
1453
1855
|
isOptional() {
|
1454
1856
|
return this.safeParse(void 0).success;
|
1455
1857
|
}
|
@@ -1458,19 +1860,43 @@ var init_lib = __esm({
|
|
1458
1860
|
}
|
1459
1861
|
};
|
1460
1862
|
cuidRegex = /^c[^\s-]{8,}$/i;
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1863
|
+
uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
1864
|
+
emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
|
1865
|
+
datetimeRegex = (args) => {
|
1866
|
+
if (args.precision) {
|
1867
|
+
if (args.offset) {
|
1868
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
|
1869
|
+
} else {
|
1870
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
1871
|
+
}
|
1872
|
+
} else if (args.precision === 0) {
|
1873
|
+
if (args.offset) {
|
1874
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
|
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
|
+
};
|
1473
1886
|
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
|
+
}
|
1474
1900
|
_parse(input) {
|
1475
1901
|
if (this._def.coerce) {
|
1476
1902
|
input.data = String(input.data);
|
@@ -1478,11 +1904,15 @@ var init_lib = __esm({
|
|
1478
1904
|
const parsedType = this._getType(input);
|
1479
1905
|
if (parsedType !== ZodParsedType.string) {
|
1480
1906
|
const ctx2 = this._getOrReturnCtx(input);
|
1481
|
-
addIssueToContext(
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1907
|
+
addIssueToContext(
|
1908
|
+
ctx2,
|
1909
|
+
{
|
1910
|
+
code: ZodIssueCode.invalid_type,
|
1911
|
+
expected: ZodParsedType.string,
|
1912
|
+
received: ctx2.parsedType
|
1913
|
+
}
|
1914
|
+
//
|
1915
|
+
);
|
1486
1916
|
return INVALID;
|
1487
1917
|
}
|
1488
1918
|
const status = new ParseStatus();
|
@@ -1550,19 +1980,6 @@ var init_lib = __esm({
|
|
1550
1980
|
});
|
1551
1981
|
status.dirty();
|
1552
1982
|
}
|
1553
|
-
} else if (check.kind === "emoji") {
|
1554
|
-
if (!emojiRegex) {
|
1555
|
-
emojiRegex = new RegExp(_emojiRegex, "u");
|
1556
|
-
}
|
1557
|
-
if (!emojiRegex.test(input.data)) {
|
1558
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1559
|
-
addIssueToContext(ctx, {
|
1560
|
-
validation: "emoji",
|
1561
|
-
code: ZodIssueCode.invalid_string,
|
1562
|
-
message: check.message
|
1563
|
-
});
|
1564
|
-
status.dirty();
|
1565
|
-
}
|
1566
1983
|
} else if (check.kind === "uuid") {
|
1567
1984
|
if (!uuidRegex.test(input.data)) {
|
1568
1985
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1573,16 +1990,6 @@ var init_lib = __esm({
|
|
1573
1990
|
});
|
1574
1991
|
status.dirty();
|
1575
1992
|
}
|
1576
|
-
} else if (check.kind === "nanoid") {
|
1577
|
-
if (!nanoidRegex.test(input.data)) {
|
1578
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1579
|
-
addIssueToContext(ctx, {
|
1580
|
-
validation: "nanoid",
|
1581
|
-
code: ZodIssueCode.invalid_string,
|
1582
|
-
message: check.message
|
1583
|
-
});
|
1584
|
-
status.dirty();
|
1585
|
-
}
|
1586
1993
|
} else if (check.kind === "cuid") {
|
1587
1994
|
if (!cuidRegex.test(input.data)) {
|
1588
1995
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1593,26 +2000,6 @@ var init_lib = __esm({
|
|
1593
2000
|
});
|
1594
2001
|
status.dirty();
|
1595
2002
|
}
|
1596
|
-
} else if (check.kind === "cuid2") {
|
1597
|
-
if (!cuid2Regex.test(input.data)) {
|
1598
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1599
|
-
addIssueToContext(ctx, {
|
1600
|
-
validation: "cuid2",
|
1601
|
-
code: ZodIssueCode.invalid_string,
|
1602
|
-
message: check.message
|
1603
|
-
});
|
1604
|
-
status.dirty();
|
1605
|
-
}
|
1606
|
-
} else if (check.kind === "ulid") {
|
1607
|
-
if (!ulidRegex.test(input.data)) {
|
1608
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1609
|
-
addIssueToContext(ctx, {
|
1610
|
-
validation: "ulid",
|
1611
|
-
code: ZodIssueCode.invalid_string,
|
1612
|
-
message: check.message
|
1613
|
-
});
|
1614
|
-
status.dirty();
|
1615
|
-
}
|
1616
2003
|
} else if (check.kind === "url") {
|
1617
2004
|
try {
|
1618
2005
|
new URL(input.data);
|
@@ -1639,20 +2026,6 @@ var init_lib = __esm({
|
|
1639
2026
|
}
|
1640
2027
|
} else if (check.kind === "trim") {
|
1641
2028
|
input.data = input.data.trim();
|
1642
|
-
} else if (check.kind === "includes") {
|
1643
|
-
if (!input.data.includes(check.value, check.position)) {
|
1644
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1645
|
-
addIssueToContext(ctx, {
|
1646
|
-
code: ZodIssueCode.invalid_string,
|
1647
|
-
validation: { includes: check.value, position: check.position },
|
1648
|
-
message: check.message
|
1649
|
-
});
|
1650
|
-
status.dirty();
|
1651
|
-
}
|
1652
|
-
} else if (check.kind === "toLowerCase") {
|
1653
|
-
input.data = input.data.toLowerCase();
|
1654
|
-
} else if (check.kind === "toUpperCase") {
|
1655
|
-
input.data = input.data.toUpperCase();
|
1656
2029
|
} else if (check.kind === "startsWith") {
|
1657
2030
|
if (!input.data.startsWith(check.value)) {
|
1658
2031
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1684,71 +2057,12 @@ var init_lib = __esm({
|
|
1684
2057
|
});
|
1685
2058
|
status.dirty();
|
1686
2059
|
}
|
1687
|
-
} else if (check.kind === "date") {
|
1688
|
-
const regex = dateRegex;
|
1689
|
-
if (!regex.test(input.data)) {
|
1690
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1691
|
-
addIssueToContext(ctx, {
|
1692
|
-
code: ZodIssueCode.invalid_string,
|
1693
|
-
validation: "date",
|
1694
|
-
message: check.message
|
1695
|
-
});
|
1696
|
-
status.dirty();
|
1697
|
-
}
|
1698
|
-
} else if (check.kind === "time") {
|
1699
|
-
const regex = timeRegex(check);
|
1700
|
-
if (!regex.test(input.data)) {
|
1701
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1702
|
-
addIssueToContext(ctx, {
|
1703
|
-
code: ZodIssueCode.invalid_string,
|
1704
|
-
validation: "time",
|
1705
|
-
message: check.message
|
1706
|
-
});
|
1707
|
-
status.dirty();
|
1708
|
-
}
|
1709
|
-
} else if (check.kind === "duration") {
|
1710
|
-
if (!durationRegex.test(input.data)) {
|
1711
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1712
|
-
addIssueToContext(ctx, {
|
1713
|
-
validation: "duration",
|
1714
|
-
code: ZodIssueCode.invalid_string,
|
1715
|
-
message: check.message
|
1716
|
-
});
|
1717
|
-
status.dirty();
|
1718
|
-
}
|
1719
|
-
} else if (check.kind === "ip") {
|
1720
|
-
if (!isValidIP(input.data, check.version)) {
|
1721
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1722
|
-
addIssueToContext(ctx, {
|
1723
|
-
validation: "ip",
|
1724
|
-
code: ZodIssueCode.invalid_string,
|
1725
|
-
message: check.message
|
1726
|
-
});
|
1727
|
-
status.dirty();
|
1728
|
-
}
|
1729
|
-
} else if (check.kind === "base64") {
|
1730
|
-
if (!base64Regex.test(input.data)) {
|
1731
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
1732
|
-
addIssueToContext(ctx, {
|
1733
|
-
validation: "base64",
|
1734
|
-
code: ZodIssueCode.invalid_string,
|
1735
|
-
message: check.message
|
1736
|
-
});
|
1737
|
-
status.dirty();
|
1738
|
-
}
|
1739
2060
|
} else {
|
1740
2061
|
util.assertNever(check);
|
1741
2062
|
}
|
1742
2063
|
}
|
1743
2064
|
return { status: status.value, value: input.data };
|
1744
2065
|
}
|
1745
|
-
_regex(regex, validation, message) {
|
1746
|
-
return this.refinement((data) => regex.test(data), {
|
1747
|
-
validation,
|
1748
|
-
code: ZodIssueCode.invalid_string,
|
1749
|
-
...errorUtil.errToObj(message)
|
1750
|
-
});
|
1751
|
-
}
|
1752
2066
|
_addCheck(check) {
|
1753
2067
|
return new _ZodString({
|
1754
2068
|
...this._def,
|
@@ -1761,38 +2075,19 @@ var init_lib = __esm({
|
|
1761
2075
|
url(message) {
|
1762
2076
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
1763
2077
|
}
|
1764
|
-
emoji(message) {
|
1765
|
-
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
1766
|
-
}
|
1767
2078
|
uuid(message) {
|
1768
2079
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
1769
2080
|
}
|
1770
|
-
nanoid(message) {
|
1771
|
-
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
1772
|
-
}
|
1773
2081
|
cuid(message) {
|
1774
2082
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
1775
2083
|
}
|
1776
|
-
cuid2(message) {
|
1777
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
1778
|
-
}
|
1779
|
-
ulid(message) {
|
1780
|
-
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
1781
|
-
}
|
1782
|
-
base64(message) {
|
1783
|
-
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
1784
|
-
}
|
1785
|
-
ip(options) {
|
1786
|
-
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
1787
|
-
}
|
1788
2084
|
datetime(options) {
|
1789
|
-
var _a
|
2085
|
+
var _a;
|
1790
2086
|
if (typeof options === "string") {
|
1791
2087
|
return this._addCheck({
|
1792
2088
|
kind: "datetime",
|
1793
2089
|
precision: null,
|
1794
2090
|
offset: false,
|
1795
|
-
local: false,
|
1796
2091
|
message: options
|
1797
2092
|
});
|
1798
2093
|
}
|
@@ -1800,30 +2095,9 @@ var init_lib = __esm({
|
|
1800
2095
|
kind: "datetime",
|
1801
2096
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
1802
2097
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
1803
|
-
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
1804
2098
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
1805
2099
|
});
|
1806
2100
|
}
|
1807
|
-
date(message) {
|
1808
|
-
return this._addCheck({ kind: "date", message });
|
1809
|
-
}
|
1810
|
-
time(options) {
|
1811
|
-
if (typeof options === "string") {
|
1812
|
-
return this._addCheck({
|
1813
|
-
kind: "time",
|
1814
|
-
precision: null,
|
1815
|
-
message: options
|
1816
|
-
});
|
1817
|
-
}
|
1818
|
-
return this._addCheck({
|
1819
|
-
kind: "time",
|
1820
|
-
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
1821
|
-
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
1822
|
-
});
|
1823
|
-
}
|
1824
|
-
duration(message) {
|
1825
|
-
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
1826
|
-
}
|
1827
2101
|
regex(regex, message) {
|
1828
2102
|
return this._addCheck({
|
1829
2103
|
kind: "regex",
|
@@ -1831,14 +2105,6 @@ var init_lib = __esm({
|
|
1831
2105
|
...errorUtil.errToObj(message)
|
1832
2106
|
});
|
1833
2107
|
}
|
1834
|
-
includes(value, options) {
|
1835
|
-
return this._addCheck({
|
1836
|
-
kind: "includes",
|
1837
|
-
value,
|
1838
|
-
position: options === null || options === void 0 ? void 0 : options.position,
|
1839
|
-
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
1840
|
-
});
|
1841
|
-
}
|
1842
2108
|
startsWith(value, message) {
|
1843
2109
|
return this._addCheck({
|
1844
2110
|
kind: "startsWith",
|
@@ -1867,295 +2133,29 @@ var init_lib = __esm({
|
|
1867
2133
|
...errorUtil.errToObj(message)
|
1868
2134
|
});
|
1869
2135
|
}
|
1870
|
-
length(len, message) {
|
1871
|
-
return this._addCheck({
|
1872
|
-
kind: "length",
|
1873
|
-
value: len,
|
1874
|
-
...errorUtil.errToObj(message)
|
1875
|
-
});
|
1876
|
-
}
|
1877
|
-
/**
|
1878
|
-
* @deprecated Use z.string().min(1) instead.
|
1879
|
-
* @see {@link ZodString.min}
|
1880
|
-
*/
|
1881
|
-
nonempty(message) {
|
1882
|
-
return this.min(1, errorUtil.errToObj(message));
|
1883
|
-
}
|
1884
|
-
trim() {
|
1885
|
-
return new _ZodString({
|
1886
|
-
...this._def,
|
1887
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
1888
|
-
});
|
1889
|
-
}
|
1890
|
-
toLowerCase() {
|
1891
|
-
return new _ZodString({
|
1892
|
-
...this._def,
|
1893
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
1894
|
-
});
|
1895
|
-
}
|
1896
|
-
toUpperCase() {
|
1897
|
-
return new _ZodString({
|
1898
|
-
...this._def,
|
1899
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
1900
|
-
});
|
1901
|
-
}
|
1902
|
-
get isDatetime() {
|
1903
|
-
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
1904
|
-
}
|
1905
|
-
get isDate() {
|
1906
|
-
return !!this._def.checks.find((ch) => ch.kind === "date");
|
1907
|
-
}
|
1908
|
-
get isTime() {
|
1909
|
-
return !!this._def.checks.find((ch) => ch.kind === "time");
|
1910
|
-
}
|
1911
|
-
get isDuration() {
|
1912
|
-
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
1913
|
-
}
|
1914
|
-
get isEmail() {
|
1915
|
-
return !!this._def.checks.find((ch) => ch.kind === "email");
|
1916
|
-
}
|
1917
|
-
get isURL() {
|
1918
|
-
return !!this._def.checks.find((ch) => ch.kind === "url");
|
1919
|
-
}
|
1920
|
-
get isEmoji() {
|
1921
|
-
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
1922
|
-
}
|
1923
|
-
get isUUID() {
|
1924
|
-
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
1925
|
-
}
|
1926
|
-
get isNANOID() {
|
1927
|
-
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
1928
|
-
}
|
1929
|
-
get isCUID() {
|
1930
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
1931
|
-
}
|
1932
|
-
get isCUID2() {
|
1933
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
1934
|
-
}
|
1935
|
-
get isULID() {
|
1936
|
-
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
1937
|
-
}
|
1938
|
-
get isIP() {
|
1939
|
-
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
1940
|
-
}
|
1941
|
-
get isBase64() {
|
1942
|
-
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
1943
|
-
}
|
1944
|
-
get minLength() {
|
1945
|
-
let min = null;
|
1946
|
-
for (const ch of this._def.checks) {
|
1947
|
-
if (ch.kind === "min") {
|
1948
|
-
if (min === null || ch.value > min)
|
1949
|
-
min = ch.value;
|
1950
|
-
}
|
1951
|
-
}
|
1952
|
-
return min;
|
1953
|
-
}
|
1954
|
-
get maxLength() {
|
1955
|
-
let max = null;
|
1956
|
-
for (const ch of this._def.checks) {
|
1957
|
-
if (ch.kind === "max") {
|
1958
|
-
if (max === null || ch.value < max)
|
1959
|
-
max = ch.value;
|
1960
|
-
}
|
1961
|
-
}
|
1962
|
-
return max;
|
1963
|
-
}
|
1964
|
-
};
|
1965
|
-
ZodString.create = (params) => {
|
1966
|
-
var _a;
|
1967
|
-
return new ZodString({
|
1968
|
-
checks: [],
|
1969
|
-
typeName: ZodFirstPartyTypeKind.ZodString,
|
1970
|
-
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
1971
|
-
...processCreateParams(params)
|
1972
|
-
});
|
1973
|
-
};
|
1974
|
-
ZodNumber = class _ZodNumber extends ZodType {
|
1975
|
-
constructor() {
|
1976
|
-
super(...arguments);
|
1977
|
-
this.min = this.gte;
|
1978
|
-
this.max = this.lte;
|
1979
|
-
this.step = this.multipleOf;
|
1980
|
-
}
|
1981
|
-
_parse(input) {
|
1982
|
-
if (this._def.coerce) {
|
1983
|
-
input.data = Number(input.data);
|
1984
|
-
}
|
1985
|
-
const parsedType = this._getType(input);
|
1986
|
-
if (parsedType !== ZodParsedType.number) {
|
1987
|
-
const ctx2 = this._getOrReturnCtx(input);
|
1988
|
-
addIssueToContext(ctx2, {
|
1989
|
-
code: ZodIssueCode.invalid_type,
|
1990
|
-
expected: ZodParsedType.number,
|
1991
|
-
received: ctx2.parsedType
|
1992
|
-
});
|
1993
|
-
return INVALID;
|
1994
|
-
}
|
1995
|
-
let ctx = void 0;
|
1996
|
-
const status = new ParseStatus();
|
1997
|
-
for (const check of this._def.checks) {
|
1998
|
-
if (check.kind === "int") {
|
1999
|
-
if (!util.isInteger(input.data)) {
|
2000
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2001
|
-
addIssueToContext(ctx, {
|
2002
|
-
code: ZodIssueCode.invalid_type,
|
2003
|
-
expected: "integer",
|
2004
|
-
received: "float",
|
2005
|
-
message: check.message
|
2006
|
-
});
|
2007
|
-
status.dirty();
|
2008
|
-
}
|
2009
|
-
} else if (check.kind === "min") {
|
2010
|
-
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
2011
|
-
if (tooSmall) {
|
2012
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2013
|
-
addIssueToContext(ctx, {
|
2014
|
-
code: ZodIssueCode.too_small,
|
2015
|
-
minimum: check.value,
|
2016
|
-
type: "number",
|
2017
|
-
inclusive: check.inclusive,
|
2018
|
-
exact: false,
|
2019
|
-
message: check.message
|
2020
|
-
});
|
2021
|
-
status.dirty();
|
2022
|
-
}
|
2023
|
-
} else if (check.kind === "max") {
|
2024
|
-
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
2025
|
-
if (tooBig) {
|
2026
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2027
|
-
addIssueToContext(ctx, {
|
2028
|
-
code: ZodIssueCode.too_big,
|
2029
|
-
maximum: check.value,
|
2030
|
-
type: "number",
|
2031
|
-
inclusive: check.inclusive,
|
2032
|
-
exact: false,
|
2033
|
-
message: check.message
|
2034
|
-
});
|
2035
|
-
status.dirty();
|
2036
|
-
}
|
2037
|
-
} else if (check.kind === "multipleOf") {
|
2038
|
-
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
2039
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2040
|
-
addIssueToContext(ctx, {
|
2041
|
-
code: ZodIssueCode.not_multiple_of,
|
2042
|
-
multipleOf: check.value,
|
2043
|
-
message: check.message
|
2044
|
-
});
|
2045
|
-
status.dirty();
|
2046
|
-
}
|
2047
|
-
} else if (check.kind === "finite") {
|
2048
|
-
if (!Number.isFinite(input.data)) {
|
2049
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2050
|
-
addIssueToContext(ctx, {
|
2051
|
-
code: ZodIssueCode.not_finite,
|
2052
|
-
message: check.message
|
2053
|
-
});
|
2054
|
-
status.dirty();
|
2055
|
-
}
|
2056
|
-
} else {
|
2057
|
-
util.assertNever(check);
|
2058
|
-
}
|
2059
|
-
}
|
2060
|
-
return { status: status.value, value: input.data };
|
2061
|
-
}
|
2062
|
-
gte(value, message) {
|
2063
|
-
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2064
|
-
}
|
2065
|
-
gt(value, message) {
|
2066
|
-
return this.setLimit("min", value, false, errorUtil.toString(message));
|
2067
|
-
}
|
2068
|
-
lte(value, message) {
|
2069
|
-
return this.setLimit("max", value, true, errorUtil.toString(message));
|
2070
|
-
}
|
2071
|
-
lt(value, message) {
|
2072
|
-
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2073
|
-
}
|
2074
|
-
setLimit(kind, value, inclusive, message) {
|
2075
|
-
return new _ZodNumber({
|
2076
|
-
...this._def,
|
2077
|
-
checks: [
|
2078
|
-
...this._def.checks,
|
2079
|
-
{
|
2080
|
-
kind,
|
2081
|
-
value,
|
2082
|
-
inclusive,
|
2083
|
-
message: errorUtil.toString(message)
|
2084
|
-
}
|
2085
|
-
]
|
2086
|
-
});
|
2087
|
-
}
|
2088
|
-
_addCheck(check) {
|
2089
|
-
return new _ZodNumber({
|
2090
|
-
...this._def,
|
2091
|
-
checks: [...this._def.checks, check]
|
2092
|
-
});
|
2093
|
-
}
|
2094
|
-
int(message) {
|
2095
|
-
return this._addCheck({
|
2096
|
-
kind: "int",
|
2097
|
-
message: errorUtil.toString(message)
|
2098
|
-
});
|
2099
|
-
}
|
2100
|
-
positive(message) {
|
2101
|
-
return this._addCheck({
|
2102
|
-
kind: "min",
|
2103
|
-
value: 0,
|
2104
|
-
inclusive: false,
|
2105
|
-
message: errorUtil.toString(message)
|
2106
|
-
});
|
2107
|
-
}
|
2108
|
-
negative(message) {
|
2109
|
-
return this._addCheck({
|
2110
|
-
kind: "max",
|
2111
|
-
value: 0,
|
2112
|
-
inclusive: false,
|
2113
|
-
message: errorUtil.toString(message)
|
2114
|
-
});
|
2115
|
-
}
|
2116
|
-
nonpositive(message) {
|
2117
|
-
return this._addCheck({
|
2118
|
-
kind: "max",
|
2119
|
-
value: 0,
|
2120
|
-
inclusive: true,
|
2121
|
-
message: errorUtil.toString(message)
|
2122
|
-
});
|
2123
|
-
}
|
2124
|
-
nonnegative(message) {
|
2125
|
-
return this._addCheck({
|
2126
|
-
kind: "min",
|
2127
|
-
value: 0,
|
2128
|
-
inclusive: true,
|
2129
|
-
message: errorUtil.toString(message)
|
2130
|
-
});
|
2131
|
-
}
|
2132
|
-
multipleOf(value, message) {
|
2133
|
-
return this._addCheck({
|
2134
|
-
kind: "multipleOf",
|
2135
|
-
value,
|
2136
|
-
message: errorUtil.toString(message)
|
2137
|
-
});
|
2138
|
-
}
|
2139
|
-
finite(message) {
|
2140
|
-
return this._addCheck({
|
2141
|
-
kind: "finite",
|
2142
|
-
message: errorUtil.toString(message)
|
2143
|
-
});
|
2144
|
-
}
|
2145
|
-
safe(message) {
|
2136
|
+
length(len, message) {
|
2146
2137
|
return this._addCheck({
|
2147
|
-
kind: "
|
2148
|
-
|
2149
|
-
|
2150
|
-
message: errorUtil.toString(message)
|
2151
|
-
})._addCheck({
|
2152
|
-
kind: "max",
|
2153
|
-
inclusive: true,
|
2154
|
-
value: Number.MAX_SAFE_INTEGER,
|
2155
|
-
message: errorUtil.toString(message)
|
2138
|
+
kind: "length",
|
2139
|
+
value: len,
|
2140
|
+
...errorUtil.errToObj(message)
|
2156
2141
|
});
|
2157
2142
|
}
|
2158
|
-
get
|
2143
|
+
get isDatetime() {
|
2144
|
+
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
2145
|
+
}
|
2146
|
+
get isEmail() {
|
2147
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
2148
|
+
}
|
2149
|
+
get isURL() {
|
2150
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
2151
|
+
}
|
2152
|
+
get isUUID() {
|
2153
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
2154
|
+
}
|
2155
|
+
get isCUID() {
|
2156
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
2157
|
+
}
|
2158
|
+
get minLength() {
|
2159
2159
|
let min = null;
|
2160
2160
|
for (const ch of this._def.checks) {
|
2161
2161
|
if (ch.kind === "min") {
|
@@ -2165,7 +2165,7 @@ var init_lib = __esm({
|
|
2165
2165
|
}
|
2166
2166
|
return min;
|
2167
2167
|
}
|
2168
|
-
get
|
2168
|
+
get maxLength() {
|
2169
2169
|
let max = null;
|
2170
2170
|
for (const ch of this._def.checks) {
|
2171
2171
|
if (ch.kind === "max") {
|
@@ -2175,49 +2175,33 @@ var init_lib = __esm({
|
|
2175
2175
|
}
|
2176
2176
|
return max;
|
2177
2177
|
}
|
2178
|
-
get isInt() {
|
2179
|
-
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2180
|
-
}
|
2181
|
-
get isFinite() {
|
2182
|
-
let max = null, min = null;
|
2183
|
-
for (const ch of this._def.checks) {
|
2184
|
-
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2185
|
-
return true;
|
2186
|
-
} else if (ch.kind === "min") {
|
2187
|
-
if (min === null || ch.value > min)
|
2188
|
-
min = ch.value;
|
2189
|
-
} else if (ch.kind === "max") {
|
2190
|
-
if (max === null || ch.value < max)
|
2191
|
-
max = ch.value;
|
2192
|
-
}
|
2193
|
-
}
|
2194
|
-
return Number.isFinite(min) && Number.isFinite(max);
|
2195
|
-
}
|
2196
2178
|
};
|
2197
|
-
|
2198
|
-
|
2179
|
+
ZodString.create = (params) => {
|
2180
|
+
var _a;
|
2181
|
+
return new ZodString({
|
2199
2182
|
checks: [],
|
2200
|
-
typeName: ZodFirstPartyTypeKind.
|
2201
|
-
coerce: (params === null || params === void 0 ? void 0 : params.coerce)
|
2183
|
+
typeName: ZodFirstPartyTypeKind.ZodString,
|
2184
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
2202
2185
|
...processCreateParams(params)
|
2203
2186
|
});
|
2204
2187
|
};
|
2205
|
-
|
2188
|
+
ZodNumber = class _ZodNumber extends ZodType {
|
2206
2189
|
constructor() {
|
2207
2190
|
super(...arguments);
|
2208
2191
|
this.min = this.gte;
|
2209
2192
|
this.max = this.lte;
|
2193
|
+
this.step = this.multipleOf;
|
2210
2194
|
}
|
2211
2195
|
_parse(input) {
|
2212
2196
|
if (this._def.coerce) {
|
2213
|
-
input.data =
|
2197
|
+
input.data = Number(input.data);
|
2214
2198
|
}
|
2215
2199
|
const parsedType = this._getType(input);
|
2216
|
-
if (parsedType !== ZodParsedType.
|
2200
|
+
if (parsedType !== ZodParsedType.number) {
|
2217
2201
|
const ctx2 = this._getOrReturnCtx(input);
|
2218
2202
|
addIssueToContext(ctx2, {
|
2219
2203
|
code: ZodIssueCode.invalid_type,
|
2220
|
-
expected: ZodParsedType.
|
2204
|
+
expected: ZodParsedType.number,
|
2221
2205
|
received: ctx2.parsedType
|
2222
2206
|
});
|
2223
2207
|
return INVALID;
|
@@ -2225,15 +2209,27 @@ var init_lib = __esm({
|
|
2225
2209
|
let ctx = void 0;
|
2226
2210
|
const status = new ParseStatus();
|
2227
2211
|
for (const check of this._def.checks) {
|
2228
|
-
if (check.kind === "
|
2212
|
+
if (check.kind === "int") {
|
2213
|
+
if (!util.isInteger(input.data)) {
|
2214
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2215
|
+
addIssueToContext(ctx, {
|
2216
|
+
code: ZodIssueCode.invalid_type,
|
2217
|
+
expected: "integer",
|
2218
|
+
received: "float",
|
2219
|
+
message: check.message
|
2220
|
+
});
|
2221
|
+
status.dirty();
|
2222
|
+
}
|
2223
|
+
} else if (check.kind === "min") {
|
2229
2224
|
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
2230
2225
|
if (tooSmall) {
|
2231
2226
|
ctx = this._getOrReturnCtx(input, ctx);
|
2232
2227
|
addIssueToContext(ctx, {
|
2233
2228
|
code: ZodIssueCode.too_small,
|
2234
|
-
type: "bigint",
|
2235
2229
|
minimum: check.value,
|
2230
|
+
type: "number",
|
2236
2231
|
inclusive: check.inclusive,
|
2232
|
+
exact: false,
|
2237
2233
|
message: check.message
|
2238
2234
|
});
|
2239
2235
|
status.dirty();
|
@@ -2244,15 +2240,16 @@ var init_lib = __esm({
|
|
2244
2240
|
ctx = this._getOrReturnCtx(input, ctx);
|
2245
2241
|
addIssueToContext(ctx, {
|
2246
2242
|
code: ZodIssueCode.too_big,
|
2247
|
-
type: "bigint",
|
2248
2243
|
maximum: check.value,
|
2244
|
+
type: "number",
|
2249
2245
|
inclusive: check.inclusive,
|
2246
|
+
exact: false,
|
2250
2247
|
message: check.message
|
2251
2248
|
});
|
2252
2249
|
status.dirty();
|
2253
2250
|
}
|
2254
2251
|
} else if (check.kind === "multipleOf") {
|
2255
|
-
if (input.data
|
2252
|
+
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
2256
2253
|
ctx = this._getOrReturnCtx(input, ctx);
|
2257
2254
|
addIssueToContext(ctx, {
|
2258
2255
|
code: ZodIssueCode.not_multiple_of,
|
@@ -2261,6 +2258,15 @@ var init_lib = __esm({
|
|
2261
2258
|
});
|
2262
2259
|
status.dirty();
|
2263
2260
|
}
|
2261
|
+
} else if (check.kind === "finite") {
|
2262
|
+
if (!Number.isFinite(input.data)) {
|
2263
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2264
|
+
addIssueToContext(ctx, {
|
2265
|
+
code: ZodIssueCode.not_finite,
|
2266
|
+
message: check.message
|
2267
|
+
});
|
2268
|
+
status.dirty();
|
2269
|
+
}
|
2264
2270
|
} else {
|
2265
2271
|
util.assertNever(check);
|
2266
2272
|
}
|
@@ -2280,7 +2286,7 @@ var init_lib = __esm({
|
|
2280
2286
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2281
2287
|
}
|
2282
2288
|
setLimit(kind, value, inclusive, message) {
|
2283
|
-
return new
|
2289
|
+
return new _ZodNumber({
|
2284
2290
|
...this._def,
|
2285
2291
|
checks: [
|
2286
2292
|
...this._def.checks,
|
@@ -2294,15 +2300,21 @@ var init_lib = __esm({
|
|
2294
2300
|
});
|
2295
2301
|
}
|
2296
2302
|
_addCheck(check) {
|
2297
|
-
return new
|
2303
|
+
return new _ZodNumber({
|
2298
2304
|
...this._def,
|
2299
2305
|
checks: [...this._def.checks, check]
|
2300
2306
|
});
|
2301
2307
|
}
|
2308
|
+
int(message) {
|
2309
|
+
return this._addCheck({
|
2310
|
+
kind: "int",
|
2311
|
+
message: errorUtil.toString(message)
|
2312
|
+
});
|
2313
|
+
}
|
2302
2314
|
positive(message) {
|
2303
2315
|
return this._addCheck({
|
2304
2316
|
kind: "min",
|
2305
|
-
value:
|
2317
|
+
value: 0,
|
2306
2318
|
inclusive: false,
|
2307
2319
|
message: errorUtil.toString(message)
|
2308
2320
|
});
|
@@ -2310,7 +2322,7 @@ var init_lib = __esm({
|
|
2310
2322
|
negative(message) {
|
2311
2323
|
return this._addCheck({
|
2312
2324
|
kind: "max",
|
2313
|
-
value:
|
2325
|
+
value: 0,
|
2314
2326
|
inclusive: false,
|
2315
2327
|
message: errorUtil.toString(message)
|
2316
2328
|
});
|
@@ -2318,7 +2330,7 @@ var init_lib = __esm({
|
|
2318
2330
|
nonpositive(message) {
|
2319
2331
|
return this._addCheck({
|
2320
2332
|
kind: "max",
|
2321
|
-
value:
|
2333
|
+
value: 0,
|
2322
2334
|
inclusive: true,
|
2323
2335
|
message: errorUtil.toString(message)
|
2324
2336
|
});
|
@@ -2326,7 +2338,7 @@ var init_lib = __esm({
|
|
2326
2338
|
nonnegative(message) {
|
2327
2339
|
return this._addCheck({
|
2328
2340
|
kind: "min",
|
2329
|
-
value:
|
2341
|
+
value: 0,
|
2330
2342
|
inclusive: true,
|
2331
2343
|
message: errorUtil.toString(message)
|
2332
2344
|
});
|
@@ -2338,6 +2350,12 @@ var init_lib = __esm({
|
|
2338
2350
|
message: errorUtil.toString(message)
|
2339
2351
|
});
|
2340
2352
|
}
|
2353
|
+
finite(message) {
|
2354
|
+
return this._addCheck({
|
2355
|
+
kind: "finite",
|
2356
|
+
message: errorUtil.toString(message)
|
2357
|
+
});
|
2358
|
+
}
|
2341
2359
|
get minValue() {
|
2342
2360
|
let min = null;
|
2343
2361
|
for (const ch of this._def.checks) {
|
@@ -2358,11 +2376,39 @@ var init_lib = __esm({
|
|
2358
2376
|
}
|
2359
2377
|
return max;
|
2360
2378
|
}
|
2379
|
+
get isInt() {
|
2380
|
+
return !!this._def.checks.find((ch) => ch.kind === "int");
|
2381
|
+
}
|
2382
|
+
};
|
2383
|
+
ZodNumber.create = (params) => {
|
2384
|
+
return new ZodNumber({
|
2385
|
+
checks: [],
|
2386
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
2387
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
2388
|
+
...processCreateParams(params)
|
2389
|
+
});
|
2390
|
+
};
|
2391
|
+
ZodBigInt = class extends ZodType {
|
2392
|
+
_parse(input) {
|
2393
|
+
if (this._def.coerce) {
|
2394
|
+
input.data = BigInt(input.data);
|
2395
|
+
}
|
2396
|
+
const parsedType = this._getType(input);
|
2397
|
+
if (parsedType !== ZodParsedType.bigint) {
|
2398
|
+
const ctx = this._getOrReturnCtx(input);
|
2399
|
+
addIssueToContext(ctx, {
|
2400
|
+
code: ZodIssueCode.invalid_type,
|
2401
|
+
expected: ZodParsedType.bigint,
|
2402
|
+
received: ctx.parsedType
|
2403
|
+
});
|
2404
|
+
return INVALID;
|
2405
|
+
}
|
2406
|
+
return OK(input.data);
|
2407
|
+
}
|
2361
2408
|
};
|
2362
2409
|
ZodBigInt.create = (params) => {
|
2363
2410
|
var _a;
|
2364
2411
|
return new ZodBigInt({
|
2365
|
-
checks: [],
|
2366
2412
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2367
2413
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
2368
2414
|
...processCreateParams(params)
|
@@ -2688,13 +2734,13 @@ var init_lib = __esm({
|
|
2688
2734
|
}
|
2689
2735
|
}
|
2690
2736
|
if (ctx.common.async) {
|
2691
|
-
return Promise.all(
|
2737
|
+
return Promise.all(ctx.data.map((item, i) => {
|
2692
2738
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2693
2739
|
})).then((result2) => {
|
2694
2740
|
return ParseStatus.mergeArray(status, result2);
|
2695
2741
|
});
|
2696
2742
|
}
|
2697
|
-
const result =
|
2743
|
+
const result = ctx.data.map((item, i) => {
|
2698
2744
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2699
2745
|
});
|
2700
2746
|
return ParseStatus.mergeArray(status, result);
|
@@ -2734,12 +2780,31 @@ var init_lib = __esm({
|
|
2734
2780
|
...processCreateParams(params)
|
2735
2781
|
});
|
2736
2782
|
};
|
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
|
+
};
|
2737
2801
|
ZodObject = class _ZodObject extends ZodType {
|
2738
2802
|
constructor() {
|
2739
2803
|
super(...arguments);
|
2740
2804
|
this._cached = null;
|
2741
2805
|
this.nonstrict = this.passthrough;
|
2742
|
-
this.augment = this.
|
2806
|
+
this.augment = AugmentFactory(this._def);
|
2807
|
+
this.extend = AugmentFactory(this._def);
|
2743
2808
|
}
|
2744
2809
|
_getCached() {
|
2745
2810
|
if (this._cached !== null)
|
@@ -2820,10 +2885,9 @@ var init_lib = __esm({
|
|
2820
2885
|
const syncPairs = [];
|
2821
2886
|
for (const pair of pairs) {
|
2822
2887
|
const key = await pair.key;
|
2823
|
-
const value = await pair.value;
|
2824
2888
|
syncPairs.push({
|
2825
2889
|
key,
|
2826
|
-
value,
|
2890
|
+
value: await pair.value,
|
2827
2891
|
alwaysSet: pair.alwaysSet
|
2828
2892
|
});
|
2829
2893
|
}
|
@@ -2870,31 +2934,8 @@ var init_lib = __esm({
|
|
2870
2934
|
unknownKeys: "passthrough"
|
2871
2935
|
});
|
2872
2936
|
}
|
2873
|
-
|
2874
|
-
|
2875
|
-
// <Augmentation extends ZodRawShape>(
|
2876
|
-
// augmentation: Augmentation
|
2877
|
-
// ): ZodObject<
|
2878
|
-
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
2879
|
-
// Def["unknownKeys"],
|
2880
|
-
// Def["catchall"]
|
2881
|
-
// > => {
|
2882
|
-
// return new ZodObject({
|
2883
|
-
// ...def,
|
2884
|
-
// shape: () => ({
|
2885
|
-
// ...def.shape(),
|
2886
|
-
// ...augmentation,
|
2887
|
-
// }),
|
2888
|
-
// }) as any;
|
2889
|
-
// };
|
2890
|
-
extend(augmentation) {
|
2891
|
-
return new _ZodObject({
|
2892
|
-
...this._def,
|
2893
|
-
shape: () => ({
|
2894
|
-
...this._def.shape(),
|
2895
|
-
...augmentation
|
2896
|
-
})
|
2897
|
-
});
|
2937
|
+
setKey(key, schema3) {
|
2938
|
+
return this.augment({ [key]: schema3 });
|
2898
2939
|
}
|
2899
2940
|
/**
|
2900
2941
|
* Prior to zod@1.0.12 there was a bug in the
|
@@ -2905,73 +2946,11 @@ var init_lib = __esm({
|
|
2905
2946
|
const merged = new _ZodObject({
|
2906
2947
|
unknownKeys: merging._def.unknownKeys,
|
2907
2948
|
catchall: merging._def.catchall,
|
2908
|
-
shape: () => (
|
2909
|
-
...this._def.shape(),
|
2910
|
-
...merging._def.shape()
|
2911
|
-
}),
|
2949
|
+
shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
2912
2950
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
2913
2951
|
});
|
2914
2952
|
return merged;
|
2915
2953
|
}
|
2916
|
-
// merge<
|
2917
|
-
// Incoming extends AnyZodObject,
|
2918
|
-
// Augmentation extends Incoming["shape"],
|
2919
|
-
// NewOutput extends {
|
2920
|
-
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
2921
|
-
// ? Augmentation[k]["_output"]
|
2922
|
-
// : k extends keyof Output
|
2923
|
-
// ? Output[k]
|
2924
|
-
// : never;
|
2925
|
-
// },
|
2926
|
-
// NewInput extends {
|
2927
|
-
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
2928
|
-
// ? Augmentation[k]["_input"]
|
2929
|
-
// : k extends keyof Input
|
2930
|
-
// ? Input[k]
|
2931
|
-
// : never;
|
2932
|
-
// }
|
2933
|
-
// >(
|
2934
|
-
// merging: Incoming
|
2935
|
-
// ): ZodObject<
|
2936
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
2937
|
-
// Incoming["_def"]["unknownKeys"],
|
2938
|
-
// Incoming["_def"]["catchall"],
|
2939
|
-
// NewOutput,
|
2940
|
-
// NewInput
|
2941
|
-
// > {
|
2942
|
-
// const merged: any = new ZodObject({
|
2943
|
-
// unknownKeys: merging._def.unknownKeys,
|
2944
|
-
// catchall: merging._def.catchall,
|
2945
|
-
// shape: () =>
|
2946
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
2947
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
2948
|
-
// }) as any;
|
2949
|
-
// return merged;
|
2950
|
-
// }
|
2951
|
-
setKey(key, schema3) {
|
2952
|
-
return this.augment({ [key]: schema3 });
|
2953
|
-
}
|
2954
|
-
// merge<Incoming extends AnyZodObject>(
|
2955
|
-
// merging: Incoming
|
2956
|
-
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
2957
|
-
// ZodObject<
|
2958
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
2959
|
-
// Incoming["_def"]["unknownKeys"],
|
2960
|
-
// Incoming["_def"]["catchall"]
|
2961
|
-
// > {
|
2962
|
-
// // const mergedShape = objectUtil.mergeShapes(
|
2963
|
-
// // this._def.shape(),
|
2964
|
-
// // merging._def.shape()
|
2965
|
-
// // );
|
2966
|
-
// const merged: any = new ZodObject({
|
2967
|
-
// unknownKeys: merging._def.unknownKeys,
|
2968
|
-
// catchall: merging._def.catchall,
|
2969
|
-
// shape: () =>
|
2970
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
2971
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
2972
|
-
// }) as any;
|
2973
|
-
// return merged;
|
2974
|
-
// }
|
2975
2954
|
catchall(index4) {
|
2976
2955
|
return new _ZodObject({
|
2977
2956
|
...this._def,
|
@@ -2980,10 +2959,9 @@ var init_lib = __esm({
|
|
2980
2959
|
}
|
2981
2960
|
pick(mask) {
|
2982
2961
|
const shape = {};
|
2983
|
-
util.objectKeys(mask).
|
2984
|
-
if (
|
2962
|
+
util.objectKeys(mask).map((key) => {
|
2963
|
+
if (this.shape[key])
|
2985
2964
|
shape[key] = this.shape[key];
|
2986
|
-
}
|
2987
2965
|
});
|
2988
2966
|
return new _ZodObject({
|
2989
2967
|
...this._def,
|
@@ -2992,8 +2970,8 @@ var init_lib = __esm({
|
|
2992
2970
|
}
|
2993
2971
|
omit(mask) {
|
2994
2972
|
const shape = {};
|
2995
|
-
util.objectKeys(this.shape).
|
2996
|
-
if (
|
2973
|
+
util.objectKeys(this.shape).map((key) => {
|
2974
|
+
if (util.objectKeys(mask).indexOf(key) === -1) {
|
2997
2975
|
shape[key] = this.shape[key];
|
2998
2976
|
}
|
2999
2977
|
});
|
@@ -3002,22 +2980,29 @@ var init_lib = __esm({
|
|
3002
2980
|
shape: () => shape
|
3003
2981
|
});
|
3004
2982
|
}
|
3005
|
-
/**
|
3006
|
-
* @deprecated
|
3007
|
-
*/
|
3008
2983
|
deepPartial() {
|
3009
2984
|
return deepPartialify(this);
|
3010
2985
|
}
|
3011
2986
|
partial(mask) {
|
3012
2987
|
const newShape = {};
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
2988
|
+
if (mask) {
|
2989
|
+
util.objectKeys(this.shape).map((key) => {
|
2990
|
+
if (util.objectKeys(mask).indexOf(key) === -1) {
|
2991
|
+
newShape[key] = this.shape[key];
|
2992
|
+
} else {
|
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];
|
3018
3003
|
newShape[key] = fieldSchema.optional();
|
3019
3004
|
}
|
3020
|
-
}
|
3005
|
+
}
|
3021
3006
|
return new _ZodObject({
|
3022
3007
|
...this._def,
|
3023
3008
|
shape: () => newShape
|
@@ -3025,10 +3010,21 @@ var init_lib = __esm({
|
|
3025
3010
|
}
|
3026
3011
|
required(mask) {
|
3027
3012
|
const newShape = {};
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3013
|
+
if (mask) {
|
3014
|
+
util.objectKeys(this.shape).map((key) => {
|
3015
|
+
if (util.objectKeys(mask).indexOf(key) === -1) {
|
3016
|
+
newShape[key] = this.shape[key];
|
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) {
|
3032
3028
|
const fieldSchema = this.shape[key];
|
3033
3029
|
let newField = fieldSchema;
|
3034
3030
|
while (newField instanceof ZodOptional) {
|
@@ -3036,7 +3032,7 @@ var init_lib = __esm({
|
|
3036
3032
|
}
|
3037
3033
|
newShape[key] = newField;
|
3038
3034
|
}
|
3039
|
-
}
|
3035
|
+
}
|
3040
3036
|
return new _ZodObject({
|
3041
3037
|
...this._def,
|
3042
3038
|
shape: () => newShape
|
@@ -3174,25 +3170,15 @@ var init_lib = __esm({
|
|
3174
3170
|
} else if (type instanceof ZodEnum) {
|
3175
3171
|
return type.options;
|
3176
3172
|
} else if (type instanceof ZodNativeEnum) {
|
3177
|
-
return
|
3173
|
+
return Object.keys(type.enum);
|
3178
3174
|
} else if (type instanceof ZodDefault) {
|
3179
3175
|
return getDiscriminator(type._def.innerType);
|
3180
3176
|
} else if (type instanceof ZodUndefined) {
|
3181
3177
|
return [void 0];
|
3182
3178
|
} else if (type instanceof ZodNull) {
|
3183
3179
|
return [null];
|
3184
|
-
} else if (type instanceof ZodOptional) {
|
3185
|
-
return [void 0, ...getDiscriminator(type.unwrap())];
|
3186
|
-
} else if (type instanceof ZodNullable) {
|
3187
|
-
return [null, ...getDiscriminator(type.unwrap())];
|
3188
|
-
} else if (type instanceof ZodBranded) {
|
3189
|
-
return getDiscriminator(type.unwrap());
|
3190
|
-
} else if (type instanceof ZodReadonly) {
|
3191
|
-
return getDiscriminator(type.unwrap());
|
3192
|
-
} else if (type instanceof ZodCatch) {
|
3193
|
-
return getDiscriminator(type._def.innerType);
|
3194
3180
|
} else {
|
3195
|
-
return
|
3181
|
+
return null;
|
3196
3182
|
}
|
3197
3183
|
};
|
3198
3184
|
ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
@@ -3252,7 +3238,7 @@ var init_lib = __esm({
|
|
3252
3238
|
const optionsMap = /* @__PURE__ */ new Map();
|
3253
3239
|
for (const type of options) {
|
3254
3240
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
3255
|
-
if (!discriminatorValues
|
3241
|
+
if (!discriminatorValues) {
|
3256
3242
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
3257
3243
|
}
|
3258
3244
|
for (const value of discriminatorValues) {
|
@@ -3356,7 +3342,7 @@ var init_lib = __esm({
|
|
3356
3342
|
});
|
3357
3343
|
status.dirty();
|
3358
3344
|
}
|
3359
|
-
const items =
|
3345
|
+
const items = ctx.data.map((item, itemIndex) => {
|
3360
3346
|
const schema3 = this._def.items[itemIndex] || this._def.rest;
|
3361
3347
|
if (!schema3)
|
3362
3348
|
return null;
|
@@ -3414,8 +3400,7 @@ var init_lib = __esm({
|
|
3414
3400
|
for (const key in ctx.data) {
|
3415
3401
|
pairs.push({
|
3416
3402
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
3417
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
3418
|
-
alwaysSet: key in ctx.data
|
3403
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
3419
3404
|
});
|
3420
3405
|
}
|
3421
3406
|
if (ctx.common.async) {
|
@@ -3445,12 +3430,6 @@ var init_lib = __esm({
|
|
3445
3430
|
}
|
3446
3431
|
};
|
3447
3432
|
ZodMap = class extends ZodType {
|
3448
|
-
get keySchema() {
|
3449
|
-
return this._def.keyType;
|
3450
|
-
}
|
3451
|
-
get valueSchema() {
|
3452
|
-
return this._def.valueType;
|
3453
|
-
}
|
3454
3433
|
_parse(input) {
|
3455
3434
|
const { status, ctx } = this._processInputParams(input);
|
3456
3435
|
if (ctx.parsedType !== ZodParsedType.map) {
|
@@ -3645,29 +3624,27 @@ var init_lib = __esm({
|
|
3645
3624
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
3646
3625
|
const fn = ctx.data;
|
3647
3626
|
if (this._def.returns instanceof ZodPromise) {
|
3648
|
-
|
3649
|
-
return OK(async function(...args) {
|
3627
|
+
return OK(async (...args) => {
|
3650
3628
|
const error2 = new ZodError([]);
|
3651
|
-
const parsedArgs = await
|
3629
|
+
const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
|
3652
3630
|
error2.addIssue(makeArgsIssue(args, e));
|
3653
3631
|
throw error2;
|
3654
3632
|
});
|
3655
|
-
const result = await
|
3656
|
-
const parsedReturns = await
|
3633
|
+
const result = await fn(...parsedArgs);
|
3634
|
+
const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
3657
3635
|
error2.addIssue(makeReturnsIssue(result, e));
|
3658
3636
|
throw error2;
|
3659
3637
|
});
|
3660
3638
|
return parsedReturns;
|
3661
3639
|
});
|
3662
3640
|
} else {
|
3663
|
-
|
3664
|
-
|
3665
|
-
const parsedArgs = me._def.args.safeParse(args, params);
|
3641
|
+
return OK((...args) => {
|
3642
|
+
const parsedArgs = this._def.args.safeParse(args, params);
|
3666
3643
|
if (!parsedArgs.success) {
|
3667
3644
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
3668
3645
|
}
|
3669
|
-
const result =
|
3670
|
-
const parsedReturns =
|
3646
|
+
const result = fn(...parsedArgs.data);
|
3647
|
+
const parsedReturns = this._def.returns.safeParse(result, params);
|
3671
3648
|
if (!parsedReturns.success) {
|
3672
3649
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
3673
3650
|
}
|
@@ -3732,7 +3709,6 @@ var init_lib = __esm({
|
|
3732
3709
|
if (input.data !== this._def.value) {
|
3733
3710
|
const ctx = this._getOrReturnCtx(input);
|
3734
3711
|
addIssueToContext(ctx, {
|
3735
|
-
received: ctx.data,
|
3736
3712
|
code: ZodIssueCode.invalid_literal,
|
3737
3713
|
expected: this._def.value
|
3738
3714
|
});
|
@@ -3751,11 +3727,7 @@ var init_lib = __esm({
|
|
3751
3727
|
...processCreateParams(params)
|
3752
3728
|
});
|
3753
3729
|
};
|
3754
|
-
ZodEnum = class
|
3755
|
-
constructor() {
|
3756
|
-
super(...arguments);
|
3757
|
-
_ZodEnum_cache.set(this, void 0);
|
3758
|
-
}
|
3730
|
+
ZodEnum = class extends ZodType {
|
3759
3731
|
_parse(input) {
|
3760
3732
|
if (typeof input.data !== "string") {
|
3761
3733
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3767,10 +3739,7 @@ var init_lib = __esm({
|
|
3767
3739
|
});
|
3768
3740
|
return INVALID;
|
3769
3741
|
}
|
3770
|
-
if (
|
3771
|
-
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
3772
|
-
}
|
3773
|
-
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
3742
|
+
if (this._def.values.indexOf(input.data) === -1) {
|
3774
3743
|
const ctx = this._getOrReturnCtx(input);
|
3775
3744
|
const expectedValues = this._def.values;
|
3776
3745
|
addIssueToContext(ctx, {
|
@@ -3806,26 +3775,9 @@ var init_lib = __esm({
|
|
3806
3775
|
}
|
3807
3776
|
return enumValues;
|
3808
3777
|
}
|
3809
|
-
extract(values, newDef = this._def) {
|
3810
|
-
return _ZodEnum.create(values, {
|
3811
|
-
...this._def,
|
3812
|
-
...newDef
|
3813
|
-
});
|
3814
|
-
}
|
3815
|
-
exclude(values, newDef = this._def) {
|
3816
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
3817
|
-
...this._def,
|
3818
|
-
...newDef
|
3819
|
-
});
|
3820
|
-
}
|
3821
3778
|
};
|
3822
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
3823
3779
|
ZodEnum.create = createZodEnum;
|
3824
3780
|
ZodNativeEnum = class extends ZodType {
|
3825
|
-
constructor() {
|
3826
|
-
super(...arguments);
|
3827
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
3828
|
-
}
|
3829
3781
|
_parse(input) {
|
3830
3782
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
3831
3783
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3838,10 +3790,7 @@ var init_lib = __esm({
|
|
3838
3790
|
});
|
3839
3791
|
return INVALID;
|
3840
3792
|
}
|
3841
|
-
if (
|
3842
|
-
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
3843
|
-
}
|
3844
|
-
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
3793
|
+
if (nativeEnumValues.indexOf(input.data) === -1) {
|
3845
3794
|
const expectedValues = util.objectValues(nativeEnumValues);
|
3846
3795
|
addIssueToContext(ctx, {
|
3847
3796
|
received: ctx.data,
|
@@ -3856,7 +3805,6 @@ var init_lib = __esm({
|
|
3856
3805
|
return this._def.values;
|
3857
3806
|
}
|
3858
3807
|
};
|
3859
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
3860
3808
|
ZodNativeEnum.create = (values, params) => {
|
3861
3809
|
return new ZodNativeEnum({
|
3862
3810
|
values,
|
@@ -3865,9 +3813,6 @@ var init_lib = __esm({
|
|
3865
3813
|
});
|
3866
3814
|
};
|
3867
3815
|
ZodPromise = class extends ZodType {
|
3868
|
-
unwrap() {
|
3869
|
-
return this._def.type;
|
3870
|
-
}
|
3871
3816
|
_parse(input) {
|
3872
3817
|
const { ctx } = this._processInputParams(input);
|
3873
3818
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
@@ -3904,56 +3849,38 @@ var init_lib = __esm({
|
|
3904
3849
|
_parse(input) {
|
3905
3850
|
const { status, ctx } = this._processInputParams(input);
|
3906
3851
|
const effect = this._def.effect || null;
|
3907
|
-
const checkCtx = {
|
3908
|
-
addIssue: (arg) => {
|
3909
|
-
addIssueToContext(ctx, arg);
|
3910
|
-
if (arg.fatal) {
|
3911
|
-
status.abort();
|
3912
|
-
} else {
|
3913
|
-
status.dirty();
|
3914
|
-
}
|
3915
|
-
},
|
3916
|
-
get path() {
|
3917
|
-
return ctx.path;
|
3918
|
-
}
|
3919
|
-
};
|
3920
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
3921
3852
|
if (effect.type === "preprocess") {
|
3922
|
-
const processed = effect.transform(ctx.data
|
3853
|
+
const processed = effect.transform(ctx.data);
|
3923
3854
|
if (ctx.common.async) {
|
3924
|
-
return Promise.resolve(processed).then(
|
3925
|
-
|
3926
|
-
return INVALID;
|
3927
|
-
const result = await this._def.schema._parseAsync({
|
3855
|
+
return Promise.resolve(processed).then((processed2) => {
|
3856
|
+
return this._def.schema._parseAsync({
|
3928
3857
|
data: processed2,
|
3929
3858
|
path: ctx.path,
|
3930
3859
|
parent: ctx
|
3931
3860
|
});
|
3932
|
-
if (result.status === "aborted")
|
3933
|
-
return INVALID;
|
3934
|
-
if (result.status === "dirty")
|
3935
|
-
return DIRTY(result.value);
|
3936
|
-
if (status.value === "dirty")
|
3937
|
-
return DIRTY(result.value);
|
3938
|
-
return result;
|
3939
3861
|
});
|
3940
3862
|
} else {
|
3941
|
-
|
3942
|
-
return INVALID;
|
3943
|
-
const result = this._def.schema._parseSync({
|
3863
|
+
return this._def.schema._parseSync({
|
3944
3864
|
data: processed,
|
3945
3865
|
path: ctx.path,
|
3946
3866
|
parent: ctx
|
3947
3867
|
});
|
3948
|
-
if (result.status === "aborted")
|
3949
|
-
return INVALID;
|
3950
|
-
if (result.status === "dirty")
|
3951
|
-
return DIRTY(result.value);
|
3952
|
-
if (status.value === "dirty")
|
3953
|
-
return DIRTY(result.value);
|
3954
|
-
return result;
|
3955
3868
|
}
|
3956
3869
|
}
|
3870
|
+
const checkCtx = {
|
3871
|
+
addIssue: (arg) => {
|
3872
|
+
addIssueToContext(ctx, arg);
|
3873
|
+
if (arg.fatal) {
|
3874
|
+
status.abort();
|
3875
|
+
} else {
|
3876
|
+
status.dirty();
|
3877
|
+
}
|
3878
|
+
},
|
3879
|
+
get path() {
|
3880
|
+
return ctx.path;
|
3881
|
+
}
|
3882
|
+
};
|
3883
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
3957
3884
|
if (effect.type === "refinement") {
|
3958
3885
|
const executeRefinement = (acc) => {
|
3959
3886
|
const result = effect.refinement(acc, checkCtx);
|
@@ -4096,45 +4023,26 @@ var init_lib = __esm({
|
|
4096
4023
|
ZodCatch = class extends ZodType {
|
4097
4024
|
_parse(input) {
|
4098
4025
|
const { ctx } = this._processInputParams(input);
|
4099
|
-
const newCtx = {
|
4100
|
-
...ctx,
|
4101
|
-
common: {
|
4102
|
-
...ctx.common,
|
4103
|
-
issues: []
|
4104
|
-
}
|
4105
|
-
};
|
4106
4026
|
const result = this._def.innerType._parse({
|
4107
|
-
data:
|
4108
|
-
path:
|
4109
|
-
parent:
|
4110
|
-
...newCtx
|
4111
|
-
}
|
4027
|
+
data: ctx.data,
|
4028
|
+
path: ctx.path,
|
4029
|
+
parent: ctx
|
4112
4030
|
});
|
4113
4031
|
if (isAsync(result)) {
|
4114
4032
|
return result.then((result2) => {
|
4115
4033
|
return {
|
4116
4034
|
status: "valid",
|
4117
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
4118
|
-
get error() {
|
4119
|
-
return new ZodError(newCtx.common.issues);
|
4120
|
-
},
|
4121
|
-
input: newCtx.data
|
4122
|
-
})
|
4035
|
+
value: result2.status === "valid" ? result2.value : this._def.defaultValue()
|
4123
4036
|
};
|
4124
4037
|
});
|
4125
4038
|
} else {
|
4126
4039
|
return {
|
4127
4040
|
status: "valid",
|
4128
|
-
value: result.status === "valid" ? result.value : this._def.
|
4129
|
-
get error() {
|
4130
|
-
return new ZodError(newCtx.common.issues);
|
4131
|
-
},
|
4132
|
-
input: newCtx.data
|
4133
|
-
})
|
4041
|
+
value: result.status === "valid" ? result.value : this._def.defaultValue()
|
4134
4042
|
};
|
4135
4043
|
}
|
4136
4044
|
}
|
4137
|
-
|
4045
|
+
removeDefault() {
|
4138
4046
|
return this._def.innerType;
|
4139
4047
|
}
|
4140
4048
|
};
|
@@ -4142,7 +4050,7 @@ var init_lib = __esm({
|
|
4142
4050
|
return new ZodCatch({
|
4143
4051
|
innerType: type,
|
4144
4052
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
4145
|
-
|
4053
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
4146
4054
|
...processCreateParams(params)
|
4147
4055
|
});
|
4148
4056
|
};
|
@@ -4237,25 +4145,6 @@ var init_lib = __esm({
|
|
4237
4145
|
});
|
4238
4146
|
}
|
4239
4147
|
};
|
4240
|
-
ZodReadonly = class extends ZodType {
|
4241
|
-
_parse(input) {
|
4242
|
-
const result = this._def.innerType._parse(input);
|
4243
|
-
if (isValid(result)) {
|
4244
|
-
result.value = Object.freeze(result.value);
|
4245
|
-
}
|
4246
|
-
return result;
|
4247
|
-
}
|
4248
|
-
unwrap() {
|
4249
|
-
return this._def.innerType;
|
4250
|
-
}
|
4251
|
-
};
|
4252
|
-
ZodReadonly.create = (type, params) => {
|
4253
|
-
return new ZodReadonly({
|
4254
|
-
innerType: type,
|
4255
|
-
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
4256
|
-
...processCreateParams(params)
|
4257
|
-
});
|
4258
|
-
};
|
4259
4148
|
late = {
|
4260
4149
|
object: ZodObject.lazycreate
|
4261
4150
|
};
|
@@ -4295,7 +4184,6 @@ var init_lib = __esm({
|
|
4295
4184
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
4296
4185
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
4297
4186
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
4298
|
-
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
4299
4187
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
4300
4188
|
stringType = ZodString.create;
|
4301
4189
|
numberType = ZodNumber.create;
|
@@ -4679,7 +4567,7 @@ var init_pgSchema = __esm({
|
|
4679
4567
|
}).strict();
|
4680
4568
|
pgSchemaInternal = objectType({
|
4681
4569
|
version: literalType("6"),
|
4682
|
-
dialect: literalType("
|
4570
|
+
dialect: literalType("postgresql"),
|
4683
4571
|
tables: recordType(stringType(), table2),
|
4684
4572
|
enums: recordType(stringType(), enumSchema),
|
4685
4573
|
schemas: recordType(stringType(), stringType()),
|
@@ -4708,14 +4596,14 @@ var init_pgSchema = __esm({
|
|
4708
4596
|
}).strict();
|
4709
4597
|
pgSchemaSquashedV4 = objectType({
|
4710
4598
|
version: literalType("4"),
|
4711
|
-
dialect:
|
4599
|
+
dialect: literalType("pg"),
|
4712
4600
|
tables: recordType(stringType(), tableSquashedV42),
|
4713
4601
|
enums: recordType(stringType(), enumSchemaV1),
|
4714
4602
|
schemas: recordType(stringType(), stringType())
|
4715
4603
|
}).strict();
|
4716
4604
|
pgSchemaSquashed = objectType({
|
4717
4605
|
version: literalType("6"),
|
4718
|
-
dialect:
|
4606
|
+
dialect: literalType("postgresql"),
|
4719
4607
|
tables: recordType(stringType(), tableSquashed2),
|
4720
4608
|
enums: recordType(stringType(), enumSchema),
|
4721
4609
|
schemas: recordType(stringType(), stringType())
|
@@ -4727,7 +4615,7 @@ var init_pgSchema = __esm({
|
|
4727
4615
|
backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
|
4728
4616
|
dryPg = pgSchema2.parse({
|
4729
4617
|
version: snapshotVersion,
|
4730
|
-
dialect: "
|
4618
|
+
dialect: "postgresql",
|
4731
4619
|
id: originUUID,
|
4732
4620
|
prevId: "",
|
4733
4621
|
tables: {},
|
@@ -4862,6 +4750,7 @@ var init_utils = __esm({
|
|
4862
4750
|
init_mysqlSchema();
|
4863
4751
|
init_pgSchema();
|
4864
4752
|
init_sqliteSchema();
|
4753
|
+
init_source();
|
4865
4754
|
init_global();
|
4866
4755
|
}
|
4867
4756
|
});
|
@@ -4871,6 +4760,7 @@ var import_hanji;
|
|
4871
4760
|
var init_views = __esm({
|
4872
4761
|
"src/cli/views.ts"() {
|
4873
4762
|
"use strict";
|
4763
|
+
init_source();
|
4874
4764
|
import_hanji = __toESM(require_hanji());
|
4875
4765
|
init_utils();
|
4876
4766
|
}
|
@@ -4882,6 +4772,7 @@ var init_serializer = __esm({
|
|
4882
4772
|
"src/serializer/index.ts"() {
|
4883
4773
|
"use strict";
|
4884
4774
|
glob = __toESM(require("glob"));
|
4775
|
+
init_source();
|
4885
4776
|
init_views();
|
4886
4777
|
}
|
4887
4778
|
});
|
@@ -4890,6 +4781,7 @@ var init_serializer = __esm({
|
|
4890
4781
|
var init_outputs = __esm({
|
4891
4782
|
"src/cli/validations/outputs.ts"() {
|
4892
4783
|
"use strict";
|
4784
|
+
init_source();
|
4893
4785
|
}
|
4894
4786
|
});
|
4895
4787
|
|
@@ -4941,6 +4833,7 @@ var init_sqliteSerializer = __esm({
|
|
4941
4833
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
4942
4834
|
init_serializer();
|
4943
4835
|
init_outputs();
|
4836
|
+
init_source();
|
4944
4837
|
dialect3 = new import_sqlite_core2.SQLiteSyncDialect();
|
4945
4838
|
fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
4946
4839
|
const result = {};
|
@@ -5141,7 +5034,7 @@ WHERE
|
|
5141
5034
|
|
5142
5035
|
// node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
|
5143
5036
|
var require_balanced_match = __commonJS({
|
5144
|
-
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(
|
5037
|
+
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
|
5145
5038
|
"use strict";
|
5146
5039
|
module2.exports = balanced;
|
5147
5040
|
function balanced(a, b, str) {
|
@@ -5201,7 +5094,7 @@ var require_balanced_match = __commonJS({
|
|
5201
5094
|
|
5202
5095
|
// node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js
|
5203
5096
|
var require_brace_expansion = __commonJS({
|
5204
|
-
"node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(
|
5097
|
+
"node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
|
5205
5098
|
var balanced = require_balanced_match();
|
5206
5099
|
module2.exports = expandTop;
|
5207
5100
|
var escSlash = "\0SLASH" + Math.random() + "\0";
|
@@ -5359,6 +5252,7 @@ var init_pgSerializer = __esm({
|
|
5359
5252
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
5360
5253
|
import_drizzle_orm2 = require("drizzle-orm");
|
5361
5254
|
init_serializer();
|
5255
|
+
init_source();
|
5362
5256
|
init_outputs();
|
5363
5257
|
dialect4 = new import_pg_core2.PgDialect();
|
5364
5258
|
trimChar = (str, char) => {
|
@@ -5557,7 +5451,7 @@ var init_pgSerializer = __esm({
|
|
5557
5451
|
const columnName = columnResponse.attname;
|
5558
5452
|
const columnAdditionalDT = columnResponse.additional_dt;
|
5559
5453
|
const columnDimensions = columnResponse.array_dimensions;
|
5560
|
-
const
|
5454
|
+
const enumType3 = columnResponse.enum_name;
|
5561
5455
|
let columnType = columnResponse.data_type;
|
5562
5456
|
const primaryKey = tableConstraints.filter(
|
5563
5457
|
(mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
|
@@ -5621,8 +5515,8 @@ var init_pgSerializer = __esm({
|
|
5621
5515
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5622
5516
|
columnToReturn[columnName] = {
|
5623
5517
|
name: columnName,
|
5624
|
-
type: columnAdditionalDT === "USER-DEFINED" ?
|
5625
|
-
typeSchema: enumsToReturn[`${tableSchema}.${
|
5518
|
+
type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
|
5519
|
+
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5626
5520
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5627
5521
|
// default: isSerial ? undefined : defaultValue,
|
5628
5522
|
notNull: columnResponse.is_nullable === "NO"
|
@@ -5705,7 +5599,7 @@ var init_pgSerializer = __esm({
|
|
5705
5599
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
5706
5600
|
return {
|
5707
5601
|
version: "6",
|
5708
|
-
dialect: "
|
5602
|
+
dialect: "postgresql",
|
5709
5603
|
tables: result,
|
5710
5604
|
enums: enumsToReturn,
|
5711
5605
|
schemas: schemasObject,
|
@@ -6046,10 +5940,10 @@ Array.prototype.random = function() {
|
|
6046
5940
|
return this[~~(Math.random() * this.length)];
|
6047
5941
|
};
|
6048
5942
|
|
6049
|
-
// node_modules/.pnpm/minimatch@7.4.
|
5943
|
+
// node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
|
6050
5944
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
6051
5945
|
|
6052
|
-
// node_modules/.pnpm/minimatch@7.4.
|
5946
|
+
// node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
|
6053
5947
|
var posixClasses = {
|
6054
5948
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
6055
5949
|
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
@@ -6159,17 +6053,17 @@ var parseClass = (glob2, position) => {
|
|
6159
6053
|
return [comb, uflag, endPos - pos, true];
|
6160
6054
|
};
|
6161
6055
|
|
6162
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6056
|
+
// node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
|
6163
6057
|
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6164
6058
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
6165
6059
|
};
|
6166
6060
|
|
6167
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6061
|
+
// node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
|
6168
6062
|
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6169
6063
|
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
6170
6064
|
};
|
6171
6065
|
|
6172
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6066
|
+
// node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
|
6173
6067
|
var minimatch = (p, pattern, options = {}) => {
|
6174
6068
|
assertValidPattern(pattern);
|
6175
6069
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|