drizzle-kit 0.21.2-ef624aa → 0.21.2-f3756f2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +15369 -13682
- package/package.json +3 -3
- package/payload.d.mts +273 -187
- package/payload.d.ts +273 -187
- package/payload.js +1671 -1167
- package/payload.mjs +1663 -1159
- package/utils-studio.js +1074 -813
- package/utils-studio.mjs +1047 -786
- package/utils.js +999 -290
- package/utils.mjs +974 -265
package/utils-studio.mjs
CHANGED
@@ -34,516 +34,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
34
34
|
mod
|
35
35
|
));
|
36
36
|
|
37
|
-
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
38
|
-
function assembleStyles() {
|
39
|
-
const codes = /* @__PURE__ */ new Map();
|
40
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
41
|
-
for (const [styleName, style] of Object.entries(group)) {
|
42
|
-
styles[styleName] = {
|
43
|
-
open: `\x1B[${style[0]}m`,
|
44
|
-
close: `\x1B[${style[1]}m`
|
45
|
-
};
|
46
|
-
group[styleName] = styles[styleName];
|
47
|
-
codes.set(style[0], style[1]);
|
48
|
-
}
|
49
|
-
Object.defineProperty(styles, groupName, {
|
50
|
-
value: group,
|
51
|
-
enumerable: false
|
52
|
-
});
|
53
|
-
}
|
54
|
-
Object.defineProperty(styles, "codes", {
|
55
|
-
value: codes,
|
56
|
-
enumerable: false
|
57
|
-
});
|
58
|
-
styles.color.close = "\x1B[39m";
|
59
|
-
styles.bgColor.close = "\x1B[49m";
|
60
|
-
styles.color.ansi = wrapAnsi16();
|
61
|
-
styles.color.ansi256 = wrapAnsi256();
|
62
|
-
styles.color.ansi16m = wrapAnsi16m();
|
63
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
64
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
65
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
66
|
-
Object.defineProperties(styles, {
|
67
|
-
rgbToAnsi256: {
|
68
|
-
value(red, green, blue) {
|
69
|
-
if (red === green && green === blue) {
|
70
|
-
if (red < 8) {
|
71
|
-
return 16;
|
72
|
-
}
|
73
|
-
if (red > 248) {
|
74
|
-
return 231;
|
75
|
-
}
|
76
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
77
|
-
}
|
78
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
79
|
-
},
|
80
|
-
enumerable: false
|
81
|
-
},
|
82
|
-
hexToRgb: {
|
83
|
-
value(hex) {
|
84
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
85
|
-
if (!matches) {
|
86
|
-
return [0, 0, 0];
|
87
|
-
}
|
88
|
-
let [colorString] = matches;
|
89
|
-
if (colorString.length === 3) {
|
90
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
91
|
-
}
|
92
|
-
const integer = Number.parseInt(colorString, 16);
|
93
|
-
return [
|
94
|
-
/* eslint-disable no-bitwise */
|
95
|
-
integer >> 16 & 255,
|
96
|
-
integer >> 8 & 255,
|
97
|
-
integer & 255
|
98
|
-
/* eslint-enable no-bitwise */
|
99
|
-
];
|
100
|
-
},
|
101
|
-
enumerable: false
|
102
|
-
},
|
103
|
-
hexToAnsi256: {
|
104
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
105
|
-
enumerable: false
|
106
|
-
},
|
107
|
-
ansi256ToAnsi: {
|
108
|
-
value(code) {
|
109
|
-
if (code < 8) {
|
110
|
-
return 30 + code;
|
111
|
-
}
|
112
|
-
if (code < 16) {
|
113
|
-
return 90 + (code - 8);
|
114
|
-
}
|
115
|
-
let red;
|
116
|
-
let green;
|
117
|
-
let blue;
|
118
|
-
if (code >= 232) {
|
119
|
-
red = ((code - 232) * 10 + 8) / 255;
|
120
|
-
green = red;
|
121
|
-
blue = red;
|
122
|
-
} else {
|
123
|
-
code -= 16;
|
124
|
-
const remainder = code % 36;
|
125
|
-
red = Math.floor(code / 36) / 5;
|
126
|
-
green = Math.floor(remainder / 6) / 5;
|
127
|
-
blue = remainder % 6 / 5;
|
128
|
-
}
|
129
|
-
const value = Math.max(red, green, blue) * 2;
|
130
|
-
if (value === 0) {
|
131
|
-
return 30;
|
132
|
-
}
|
133
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
134
|
-
if (value === 2) {
|
135
|
-
result += 60;
|
136
|
-
}
|
137
|
-
return result;
|
138
|
-
},
|
139
|
-
enumerable: false
|
140
|
-
},
|
141
|
-
rgbToAnsi: {
|
142
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
143
|
-
enumerable: false
|
144
|
-
},
|
145
|
-
hexToAnsi: {
|
146
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
147
|
-
enumerable: false
|
148
|
-
}
|
149
|
-
});
|
150
|
-
return styles;
|
151
|
-
}
|
152
|
-
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
153
|
-
var init_ansi_styles = __esm({
|
154
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
155
|
-
ANSI_BACKGROUND_OFFSET = 10;
|
156
|
-
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
157
|
-
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
158
|
-
wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
159
|
-
styles = {
|
160
|
-
modifier: {
|
161
|
-
reset: [0, 0],
|
162
|
-
// 21 isn't widely supported and 22 does the same thing
|
163
|
-
bold: [1, 22],
|
164
|
-
dim: [2, 22],
|
165
|
-
italic: [3, 23],
|
166
|
-
underline: [4, 24],
|
167
|
-
overline: [53, 55],
|
168
|
-
inverse: [7, 27],
|
169
|
-
hidden: [8, 28],
|
170
|
-
strikethrough: [9, 29]
|
171
|
-
},
|
172
|
-
color: {
|
173
|
-
black: [30, 39],
|
174
|
-
red: [31, 39],
|
175
|
-
green: [32, 39],
|
176
|
-
yellow: [33, 39],
|
177
|
-
blue: [34, 39],
|
178
|
-
magenta: [35, 39],
|
179
|
-
cyan: [36, 39],
|
180
|
-
white: [37, 39],
|
181
|
-
// Bright color
|
182
|
-
blackBright: [90, 39],
|
183
|
-
gray: [90, 39],
|
184
|
-
// Alias of `blackBright`
|
185
|
-
grey: [90, 39],
|
186
|
-
// Alias of `blackBright`
|
187
|
-
redBright: [91, 39],
|
188
|
-
greenBright: [92, 39],
|
189
|
-
yellowBright: [93, 39],
|
190
|
-
blueBright: [94, 39],
|
191
|
-
magentaBright: [95, 39],
|
192
|
-
cyanBright: [96, 39],
|
193
|
-
whiteBright: [97, 39]
|
194
|
-
},
|
195
|
-
bgColor: {
|
196
|
-
bgBlack: [40, 49],
|
197
|
-
bgRed: [41, 49],
|
198
|
-
bgGreen: [42, 49],
|
199
|
-
bgYellow: [43, 49],
|
200
|
-
bgBlue: [44, 49],
|
201
|
-
bgMagenta: [45, 49],
|
202
|
-
bgCyan: [46, 49],
|
203
|
-
bgWhite: [47, 49],
|
204
|
-
// Bright color
|
205
|
-
bgBlackBright: [100, 49],
|
206
|
-
bgGray: [100, 49],
|
207
|
-
// Alias of `bgBlackBright`
|
208
|
-
bgGrey: [100, 49],
|
209
|
-
// Alias of `bgBlackBright`
|
210
|
-
bgRedBright: [101, 49],
|
211
|
-
bgGreenBright: [102, 49],
|
212
|
-
bgYellowBright: [103, 49],
|
213
|
-
bgBlueBright: [104, 49],
|
214
|
-
bgMagentaBright: [105, 49],
|
215
|
-
bgCyanBright: [106, 49],
|
216
|
-
bgWhiteBright: [107, 49]
|
217
|
-
}
|
218
|
-
};
|
219
|
-
modifierNames = Object.keys(styles.modifier);
|
220
|
-
foregroundColorNames = Object.keys(styles.color);
|
221
|
-
backgroundColorNames = Object.keys(styles.bgColor);
|
222
|
-
colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
223
|
-
ansiStyles = assembleStyles();
|
224
|
-
ansi_styles_default = ansiStyles;
|
225
|
-
}
|
226
|
-
});
|
227
|
-
|
228
|
-
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
|
229
|
-
import process2 from "node:process";
|
230
|
-
import os from "node:os";
|
231
|
-
import tty from "node:tty";
|
232
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
|
233
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
234
|
-
const position = argv.indexOf(prefix + flag);
|
235
|
-
const terminatorPosition = argv.indexOf("--");
|
236
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
237
|
-
}
|
238
|
-
function envForceColor() {
|
239
|
-
if ("FORCE_COLOR" in env) {
|
240
|
-
if (env.FORCE_COLOR === "true") {
|
241
|
-
return 1;
|
242
|
-
}
|
243
|
-
if (env.FORCE_COLOR === "false") {
|
244
|
-
return 0;
|
245
|
-
}
|
246
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
247
|
-
}
|
248
|
-
}
|
249
|
-
function translateLevel(level) {
|
250
|
-
if (level === 0) {
|
251
|
-
return false;
|
252
|
-
}
|
253
|
-
return {
|
254
|
-
level,
|
255
|
-
hasBasic: true,
|
256
|
-
has256: level >= 2,
|
257
|
-
has16m: level >= 3
|
258
|
-
};
|
259
|
-
}
|
260
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
261
|
-
const noFlagForceColor = envForceColor();
|
262
|
-
if (noFlagForceColor !== void 0) {
|
263
|
-
flagForceColor = noFlagForceColor;
|
264
|
-
}
|
265
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
266
|
-
if (forceColor === 0) {
|
267
|
-
return 0;
|
268
|
-
}
|
269
|
-
if (sniffFlags) {
|
270
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
271
|
-
return 3;
|
272
|
-
}
|
273
|
-
if (hasFlag("color=256")) {
|
274
|
-
return 2;
|
275
|
-
}
|
276
|
-
}
|
277
|
-
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
278
|
-
return 1;
|
279
|
-
}
|
280
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
281
|
-
return 0;
|
282
|
-
}
|
283
|
-
const min = forceColor || 0;
|
284
|
-
if (env.TERM === "dumb") {
|
285
|
-
return min;
|
286
|
-
}
|
287
|
-
if (process2.platform === "win32") {
|
288
|
-
const osRelease = os.release().split(".");
|
289
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
290
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
291
|
-
}
|
292
|
-
return 1;
|
293
|
-
}
|
294
|
-
if ("CI" in env) {
|
295
|
-
if ("GITHUB_ACTIONS" in env) {
|
296
|
-
return 3;
|
297
|
-
}
|
298
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
299
|
-
return 1;
|
300
|
-
}
|
301
|
-
return min;
|
302
|
-
}
|
303
|
-
if ("TEAMCITY_VERSION" in env) {
|
304
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
305
|
-
}
|
306
|
-
if (env.COLORTERM === "truecolor") {
|
307
|
-
return 3;
|
308
|
-
}
|
309
|
-
if (env.TERM === "xterm-kitty") {
|
310
|
-
return 3;
|
311
|
-
}
|
312
|
-
if ("TERM_PROGRAM" in env) {
|
313
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
314
|
-
switch (env.TERM_PROGRAM) {
|
315
|
-
case "iTerm.app": {
|
316
|
-
return version >= 3 ? 3 : 2;
|
317
|
-
}
|
318
|
-
case "Apple_Terminal": {
|
319
|
-
return 2;
|
320
|
-
}
|
321
|
-
}
|
322
|
-
}
|
323
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
324
|
-
return 2;
|
325
|
-
}
|
326
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
327
|
-
return 1;
|
328
|
-
}
|
329
|
-
if ("COLORTERM" in env) {
|
330
|
-
return 1;
|
331
|
-
}
|
332
|
-
return min;
|
333
|
-
}
|
334
|
-
function createSupportsColor(stream, options = {}) {
|
335
|
-
const level = _supportsColor(stream, {
|
336
|
-
streamIsTTY: stream && stream.isTTY,
|
337
|
-
...options
|
338
|
-
});
|
339
|
-
return translateLevel(level);
|
340
|
-
}
|
341
|
-
var env, flagForceColor, supportsColor, supports_color_default;
|
342
|
-
var init_supports_color = __esm({
|
343
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
344
|
-
({ env } = process2);
|
345
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
346
|
-
flagForceColor = 0;
|
347
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
348
|
-
flagForceColor = 1;
|
349
|
-
}
|
350
|
-
supportsColor = {
|
351
|
-
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
352
|
-
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
353
|
-
};
|
354
|
-
supports_color_default = supportsColor;
|
355
|
-
}
|
356
|
-
});
|
357
|
-
|
358
|
-
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
|
359
|
-
function stringReplaceAll(string, substring, replacer) {
|
360
|
-
let index4 = string.indexOf(substring);
|
361
|
-
if (index4 === -1) {
|
362
|
-
return string;
|
363
|
-
}
|
364
|
-
const substringLength = substring.length;
|
365
|
-
let endIndex = 0;
|
366
|
-
let returnValue = "";
|
367
|
-
do {
|
368
|
-
returnValue += string.slice(endIndex, index4) + substring + replacer;
|
369
|
-
endIndex = index4 + substringLength;
|
370
|
-
index4 = string.indexOf(substring, endIndex);
|
371
|
-
} while (index4 !== -1);
|
372
|
-
returnValue += string.slice(endIndex);
|
373
|
-
return returnValue;
|
374
|
-
}
|
375
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
376
|
-
let endIndex = 0;
|
377
|
-
let returnValue = "";
|
378
|
-
do {
|
379
|
-
const gotCR = string[index4 - 1] === "\r";
|
380
|
-
returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
381
|
-
endIndex = index4 + 1;
|
382
|
-
index4 = string.indexOf("\n", endIndex);
|
383
|
-
} while (index4 !== -1);
|
384
|
-
returnValue += string.slice(endIndex);
|
385
|
-
return returnValue;
|
386
|
-
}
|
387
|
-
var init_utilities = __esm({
|
388
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
|
389
|
-
}
|
390
|
-
});
|
391
|
-
|
392
|
-
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
|
393
|
-
function createChalk(options) {
|
394
|
-
return chalkFactory(options);
|
395
|
-
}
|
396
|
-
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
|
397
|
-
var init_source = __esm({
|
398
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
|
399
|
-
init_ansi_styles();
|
400
|
-
init_supports_color();
|
401
|
-
init_utilities();
|
402
|
-
init_ansi_styles();
|
403
|
-
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
404
|
-
GENERATOR = Symbol("GENERATOR");
|
405
|
-
STYLER = Symbol("STYLER");
|
406
|
-
IS_EMPTY = Symbol("IS_EMPTY");
|
407
|
-
levelMapping = [
|
408
|
-
"ansi",
|
409
|
-
"ansi",
|
410
|
-
"ansi256",
|
411
|
-
"ansi16m"
|
412
|
-
];
|
413
|
-
styles2 = /* @__PURE__ */ Object.create(null);
|
414
|
-
applyOptions = (object, options = {}) => {
|
415
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
416
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
417
|
-
}
|
418
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
419
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
420
|
-
};
|
421
|
-
chalkFactory = (options) => {
|
422
|
-
const chalk2 = (...strings) => strings.join(" ");
|
423
|
-
applyOptions(chalk2, options);
|
424
|
-
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
425
|
-
return chalk2;
|
426
|
-
};
|
427
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
428
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
429
|
-
styles2[styleName] = {
|
430
|
-
get() {
|
431
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
432
|
-
Object.defineProperty(this, styleName, { value: builder });
|
433
|
-
return builder;
|
434
|
-
}
|
435
|
-
};
|
436
|
-
}
|
437
|
-
styles2.visible = {
|
438
|
-
get() {
|
439
|
-
const builder = createBuilder(this, this[STYLER], true);
|
440
|
-
Object.defineProperty(this, "visible", { value: builder });
|
441
|
-
return builder;
|
442
|
-
}
|
443
|
-
};
|
444
|
-
getModelAnsi = (model, level, type, ...arguments_) => {
|
445
|
-
if (model === "rgb") {
|
446
|
-
if (level === "ansi16m") {
|
447
|
-
return ansi_styles_default[type].ansi16m(...arguments_);
|
448
|
-
}
|
449
|
-
if (level === "ansi256") {
|
450
|
-
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
451
|
-
}
|
452
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
453
|
-
}
|
454
|
-
if (model === "hex") {
|
455
|
-
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
456
|
-
}
|
457
|
-
return ansi_styles_default[type][model](...arguments_);
|
458
|
-
};
|
459
|
-
usedModels = ["rgb", "hex", "ansi256"];
|
460
|
-
for (const model of usedModels) {
|
461
|
-
styles2[model] = {
|
462
|
-
get() {
|
463
|
-
const { level } = this;
|
464
|
-
return function(...arguments_) {
|
465
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
466
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
467
|
-
};
|
468
|
-
}
|
469
|
-
};
|
470
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
471
|
-
styles2[bgModel] = {
|
472
|
-
get() {
|
473
|
-
const { level } = this;
|
474
|
-
return function(...arguments_) {
|
475
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
476
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
477
|
-
};
|
478
|
-
}
|
479
|
-
};
|
480
|
-
}
|
481
|
-
proto = Object.defineProperties(() => {
|
482
|
-
}, {
|
483
|
-
...styles2,
|
484
|
-
level: {
|
485
|
-
enumerable: true,
|
486
|
-
get() {
|
487
|
-
return this[GENERATOR].level;
|
488
|
-
},
|
489
|
-
set(level) {
|
490
|
-
this[GENERATOR].level = level;
|
491
|
-
}
|
492
|
-
}
|
493
|
-
});
|
494
|
-
createStyler = (open, close, parent) => {
|
495
|
-
let openAll;
|
496
|
-
let closeAll;
|
497
|
-
if (parent === void 0) {
|
498
|
-
openAll = open;
|
499
|
-
closeAll = close;
|
500
|
-
} else {
|
501
|
-
openAll = parent.openAll + open;
|
502
|
-
closeAll = close + parent.closeAll;
|
503
|
-
}
|
504
|
-
return {
|
505
|
-
open,
|
506
|
-
close,
|
507
|
-
openAll,
|
508
|
-
closeAll,
|
509
|
-
parent
|
510
|
-
};
|
511
|
-
};
|
512
|
-
createBuilder = (self2, _styler, _isEmpty) => {
|
513
|
-
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
514
|
-
Object.setPrototypeOf(builder, proto);
|
515
|
-
builder[GENERATOR] = self2;
|
516
|
-
builder[STYLER] = _styler;
|
517
|
-
builder[IS_EMPTY] = _isEmpty;
|
518
|
-
return builder;
|
519
|
-
};
|
520
|
-
applyStyle = (self2, string) => {
|
521
|
-
if (self2.level <= 0 || !string) {
|
522
|
-
return self2[IS_EMPTY] ? "" : string;
|
523
|
-
}
|
524
|
-
let styler = self2[STYLER];
|
525
|
-
if (styler === void 0) {
|
526
|
-
return string;
|
527
|
-
}
|
528
|
-
const { openAll, closeAll } = styler;
|
529
|
-
if (string.includes("\x1B")) {
|
530
|
-
while (styler !== void 0) {
|
531
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
532
|
-
styler = styler.parent;
|
533
|
-
}
|
534
|
-
}
|
535
|
-
const lfIndex = string.indexOf("\n");
|
536
|
-
if (lfIndex !== -1) {
|
537
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
538
|
-
}
|
539
|
-
return openAll + string + closeAll;
|
540
|
-
};
|
541
|
-
Object.defineProperties(createChalk.prototype, styles2);
|
542
|
-
chalk = createChalk();
|
543
|
-
chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
544
|
-
}
|
545
|
-
});
|
546
|
-
|
547
37
|
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
|
548
38
|
var require_readline = __commonJS({
|
549
39
|
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
|
@@ -1080,15 +570,16 @@ var init_global = __esm({
|
|
1080
570
|
"src/global.ts"() {
|
1081
571
|
"use strict";
|
1082
572
|
originUUID = "00000000-0000-0000-0000-000000000000";
|
1083
|
-
snapshotVersion = "
|
573
|
+
snapshotVersion = "7";
|
1084
574
|
}
|
1085
575
|
});
|
1086
576
|
|
1087
|
-
// node_modules/.pnpm/zod@3.
|
577
|
+
// node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
1088
578
|
function getErrorMap() {
|
1089
579
|
return overrideErrorMap;
|
1090
580
|
}
|
1091
581
|
function addIssueToContext(ctx, issueData) {
|
582
|
+
const overrideMap = getErrorMap();
|
1092
583
|
const issue = makeIssue({
|
1093
584
|
issueData,
|
1094
585
|
data: ctx.data,
|
@@ -1096,13 +587,29 @@ function addIssueToContext(ctx, issueData) {
|
|
1096
587
|
errorMaps: [
|
1097
588
|
ctx.common.contextualErrorMap,
|
1098
589
|
ctx.schemaErrorMap,
|
1099
|
-
|
1100
|
-
errorMap
|
590
|
+
overrideMap,
|
591
|
+
overrideMap === errorMap ? void 0 : errorMap
|
1101
592
|
// then global default map
|
1102
593
|
].filter((x) => !!x)
|
1103
594
|
});
|
1104
595
|
ctx.common.issues.push(issue);
|
1105
596
|
}
|
597
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
598
|
+
if (kind === "a" && !f)
|
599
|
+
throw new TypeError("Private accessor was defined without a getter");
|
600
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
601
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
602
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
603
|
+
}
|
604
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
605
|
+
if (kind === "m")
|
606
|
+
throw new TypeError("Private method is not writable");
|
607
|
+
if (kind === "a" && !f)
|
608
|
+
throw new TypeError("Private accessor was defined without a setter");
|
609
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
610
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
611
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
612
|
+
}
|
1106
613
|
function processCreateParams(params) {
|
1107
614
|
if (!params)
|
1108
615
|
return {};
|
@@ -1113,15 +620,50 @@ function processCreateParams(params) {
|
|
1113
620
|
if (errorMap2)
|
1114
621
|
return { errorMap: errorMap2, description };
|
1115
622
|
const customMap = (iss, ctx) => {
|
1116
|
-
|
1117
|
-
|
623
|
+
var _a, _b;
|
624
|
+
const { message } = params;
|
625
|
+
if (iss.code === "invalid_enum_value") {
|
626
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
627
|
+
}
|
1118
628
|
if (typeof ctx.data === "undefined") {
|
1119
|
-
return { message:
|
629
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
1120
630
|
}
|
1121
|
-
|
631
|
+
if (iss.code !== "invalid_type")
|
632
|
+
return { message: ctx.defaultError };
|
633
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
1122
634
|
};
|
1123
635
|
return { errorMap: customMap, description };
|
1124
636
|
}
|
637
|
+
function timeRegexSource(args) {
|
638
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
639
|
+
if (args.precision) {
|
640
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
641
|
+
} else if (args.precision == null) {
|
642
|
+
regex = `${regex}(\\.\\d+)?`;
|
643
|
+
}
|
644
|
+
return regex;
|
645
|
+
}
|
646
|
+
function timeRegex(args) {
|
647
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
648
|
+
}
|
649
|
+
function datetimeRegex(args) {
|
650
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
651
|
+
const opts = [];
|
652
|
+
opts.push(args.local ? `Z?` : `Z`);
|
653
|
+
if (args.offset)
|
654
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
655
|
+
regex = `${regex}(${opts.join("|")})`;
|
656
|
+
return new RegExp(`^${regex}$`);
|
657
|
+
}
|
658
|
+
function isValidIP(ip, version) {
|
659
|
+
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
660
|
+
return true;
|
661
|
+
}
|
662
|
+
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
663
|
+
return true;
|
664
|
+
}
|
665
|
+
return false;
|
666
|
+
}
|
1125
667
|
function floatSafeRemainder(val, step) {
|
1126
668
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
1127
669
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
@@ -1142,7 +684,10 @@ function deepPartialify(schema3) {
|
|
1142
684
|
shape: () => newShape
|
1143
685
|
});
|
1144
686
|
} else if (schema3 instanceof ZodArray) {
|
1145
|
-
return ZodArray
|
687
|
+
return new ZodArray({
|
688
|
+
...schema3._def,
|
689
|
+
type: deepPartialify(schema3.element)
|
690
|
+
});
|
1146
691
|
} else if (schema3 instanceof ZodOptional) {
|
1147
692
|
return ZodOptional.create(deepPartialify(schema3.unwrap()));
|
1148
693
|
} else if (schema3 instanceof ZodNullable) {
|
@@ -1198,9 +743,9 @@ function createZodEnum(values, params) {
|
|
1198
743
|
...processCreateParams(params)
|
1199
744
|
});
|
1200
745
|
}
|
1201
|
-
var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex,
|
746
|
+
var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv6Regex, base64Regex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
|
1202
747
|
var init_lib = __esm({
|
1203
|
-
"node_modules/.pnpm/zod@3.
|
748
|
+
"node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs"() {
|
1204
749
|
(function(util2) {
|
1205
750
|
util2.assertEqual = (val) => val;
|
1206
751
|
function assertIs(_arg) {
|
@@ -1258,6 +803,15 @@ var init_lib = __esm({
|
|
1258
803
|
return value;
|
1259
804
|
};
|
1260
805
|
})(util || (util = {}));
|
806
|
+
(function(objectUtil2) {
|
807
|
+
objectUtil2.mergeShapes = (first, second) => {
|
808
|
+
return {
|
809
|
+
...first,
|
810
|
+
...second
|
811
|
+
// second overwrites first
|
812
|
+
};
|
813
|
+
};
|
814
|
+
})(objectUtil || (objectUtil = {}));
|
1261
815
|
ZodParsedType = util.arrayToEnum([
|
1262
816
|
"string",
|
1263
817
|
"nan",
|
@@ -1339,7 +893,7 @@ var init_lib = __esm({
|
|
1339
893
|
"not_multiple_of",
|
1340
894
|
"not_finite"
|
1341
895
|
]);
|
1342
|
-
ZodError = class extends Error {
|
896
|
+
ZodError = class _ZodError extends Error {
|
1343
897
|
constructor(issues) {
|
1344
898
|
super();
|
1345
899
|
this.issues = [];
|
@@ -1397,6 +951,11 @@ var init_lib = __esm({
|
|
1397
951
|
processError(this);
|
1398
952
|
return fieldErrors;
|
1399
953
|
}
|
954
|
+
static assert(value) {
|
955
|
+
if (!(value instanceof _ZodError)) {
|
956
|
+
throw new Error(`Not a ZodError: ${value}`);
|
957
|
+
}
|
958
|
+
}
|
1400
959
|
toString() {
|
1401
960
|
return this.message;
|
1402
961
|
}
|
@@ -1463,7 +1022,12 @@ var init_lib = __esm({
|
|
1463
1022
|
break;
|
1464
1023
|
case ZodIssueCode.invalid_string:
|
1465
1024
|
if (typeof issue.validation === "object") {
|
1466
|
-
if ("
|
1025
|
+
if ("includes" in issue.validation) {
|
1026
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
1027
|
+
if (typeof issue.validation.position === "number") {
|
1028
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
1029
|
+
}
|
1030
|
+
} else if ("startsWith" in issue.validation) {
|
1467
1031
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
1468
1032
|
} else if ("endsWith" in issue.validation) {
|
1469
1033
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
@@ -1484,7 +1048,7 @@ var init_lib = __esm({
|
|
1484
1048
|
else if (issue.type === "number")
|
1485
1049
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
1486
1050
|
else if (issue.type === "date")
|
1487
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
|
1051
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
1488
1052
|
else
|
1489
1053
|
message = "Invalid input";
|
1490
1054
|
break;
|
@@ -1495,8 +1059,10 @@ var init_lib = __esm({
|
|
1495
1059
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
1496
1060
|
else if (issue.type === "number")
|
1497
1061
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1062
|
+
else if (issue.type === "bigint")
|
1063
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
1498
1064
|
else if (issue.type === "date")
|
1499
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
|
1065
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
1500
1066
|
else
|
1501
1067
|
message = "Invalid input";
|
1502
1068
|
break;
|
@@ -1526,6 +1092,13 @@ var init_lib = __esm({
|
|
1526
1092
|
...issueData,
|
1527
1093
|
path: fullPath
|
1528
1094
|
};
|
1095
|
+
if (issueData.message !== void 0) {
|
1096
|
+
return {
|
1097
|
+
...issueData,
|
1098
|
+
path: fullPath,
|
1099
|
+
message: issueData.message
|
1100
|
+
};
|
1101
|
+
}
|
1529
1102
|
let errorMessage = "";
|
1530
1103
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
1531
1104
|
for (const map of maps) {
|
@@ -1534,7 +1107,7 @@ var init_lib = __esm({
|
|
1534
1107
|
return {
|
1535
1108
|
...issueData,
|
1536
1109
|
path: fullPath,
|
1537
|
-
message:
|
1110
|
+
message: errorMessage
|
1538
1111
|
};
|
1539
1112
|
};
|
1540
1113
|
ParseStatus = class _ParseStatus {
|
@@ -1563,9 +1136,11 @@ var init_lib = __esm({
|
|
1563
1136
|
static async mergeObjectAsync(status, pairs) {
|
1564
1137
|
const syncPairs = [];
|
1565
1138
|
for (const pair of pairs) {
|
1139
|
+
const key = await pair.key;
|
1140
|
+
const value = await pair.value;
|
1566
1141
|
syncPairs.push({
|
1567
|
-
key
|
1568
|
-
value
|
1142
|
+
key,
|
1143
|
+
value
|
1569
1144
|
});
|
1570
1145
|
}
|
1571
1146
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
@@ -1582,7 +1157,7 @@ var init_lib = __esm({
|
|
1582
1157
|
status.dirty();
|
1583
1158
|
if (value.status === "dirty")
|
1584
1159
|
status.dirty();
|
1585
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
1160
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
1586
1161
|
finalObject[key.value] = value.value;
|
1587
1162
|
}
|
1588
1163
|
}
|
@@ -1597,20 +1172,28 @@ var init_lib = __esm({
|
|
1597
1172
|
isAborted = (x) => x.status === "aborted";
|
1598
1173
|
isDirty = (x) => x.status === "dirty";
|
1599
1174
|
isValid = (x) => x.status === "valid";
|
1600
|
-
isAsync = (x) => typeof Promise !==
|
1175
|
+
isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1601
1176
|
(function(errorUtil2) {
|
1602
1177
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1603
1178
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
1604
1179
|
})(errorUtil || (errorUtil = {}));
|
1605
1180
|
ParseInputLazyPath = class {
|
1606
1181
|
constructor(parent, value, path2, key) {
|
1182
|
+
this._cachedPath = [];
|
1607
1183
|
this.parent = parent;
|
1608
1184
|
this.data = value;
|
1609
1185
|
this._path = path2;
|
1610
1186
|
this._key = key;
|
1611
1187
|
}
|
1612
1188
|
get path() {
|
1613
|
-
|
1189
|
+
if (!this._cachedPath.length) {
|
1190
|
+
if (this._key instanceof Array) {
|
1191
|
+
this._cachedPath.push(...this._path, ...this._key);
|
1192
|
+
} else {
|
1193
|
+
this._cachedPath.push(...this._path, this._key);
|
1194
|
+
}
|
1195
|
+
}
|
1196
|
+
return this._cachedPath;
|
1614
1197
|
}
|
1615
1198
|
};
|
1616
1199
|
handleResult = (ctx, result) => {
|
@@ -1620,8 +1203,16 @@ var init_lib = __esm({
|
|
1620
1203
|
if (!ctx.common.issues.length) {
|
1621
1204
|
throw new Error("Validation failed but no issues detected.");
|
1622
1205
|
}
|
1623
|
-
|
1624
|
-
|
1206
|
+
return {
|
1207
|
+
success: false,
|
1208
|
+
get error() {
|
1209
|
+
if (this._error)
|
1210
|
+
return this._error;
|
1211
|
+
const error2 = new ZodError(ctx.common.issues);
|
1212
|
+
this._error = error2;
|
1213
|
+
return this._error;
|
1214
|
+
}
|
1215
|
+
};
|
1625
1216
|
}
|
1626
1217
|
};
|
1627
1218
|
ZodType = class {
|
@@ -1649,6 +1240,7 @@ var init_lib = __esm({
|
|
1649
1240
|
this.catch = this.catch.bind(this);
|
1650
1241
|
this.describe = this.describe.bind(this);
|
1651
1242
|
this.pipe = this.pipe.bind(this);
|
1243
|
+
this.readonly = this.readonly.bind(this);
|
1652
1244
|
this.isNullable = this.isNullable.bind(this);
|
1653
1245
|
this.isOptional = this.isOptional.bind(this);
|
1654
1246
|
}
|
@@ -1793,28 +1385,29 @@ var init_lib = __esm({
|
|
1793
1385
|
return this._refinement(refinement);
|
1794
1386
|
}
|
1795
1387
|
optional() {
|
1796
|
-
return ZodOptional.create(this);
|
1388
|
+
return ZodOptional.create(this, this._def);
|
1797
1389
|
}
|
1798
1390
|
nullable() {
|
1799
|
-
return ZodNullable.create(this);
|
1391
|
+
return ZodNullable.create(this, this._def);
|
1800
1392
|
}
|
1801
1393
|
nullish() {
|
1802
|
-
return this.
|
1394
|
+
return this.nullable().optional();
|
1803
1395
|
}
|
1804
1396
|
array() {
|
1805
|
-
return ZodArray.create(this);
|
1397
|
+
return ZodArray.create(this, this._def);
|
1806
1398
|
}
|
1807
1399
|
promise() {
|
1808
|
-
return ZodPromise.create(this);
|
1400
|
+
return ZodPromise.create(this, this._def);
|
1809
1401
|
}
|
1810
1402
|
or(option) {
|
1811
|
-
return ZodUnion.create([this, option]);
|
1403
|
+
return ZodUnion.create([this, option], this._def);
|
1812
1404
|
}
|
1813
1405
|
and(incoming) {
|
1814
|
-
return ZodIntersection.create(this, incoming);
|
1406
|
+
return ZodIntersection.create(this, incoming, this._def);
|
1815
1407
|
}
|
1816
1408
|
transform(transform) {
|
1817
1409
|
return new ZodEffects({
|
1410
|
+
...processCreateParams(this._def),
|
1818
1411
|
schema: this,
|
1819
1412
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
1820
1413
|
effect: { type: "transform", transform }
|
@@ -1823,6 +1416,7 @@ var init_lib = __esm({
|
|
1823
1416
|
default(def) {
|
1824
1417
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
1825
1418
|
return new ZodDefault({
|
1419
|
+
...processCreateParams(this._def),
|
1826
1420
|
innerType: this,
|
1827
1421
|
defaultValue: defaultValueFunc,
|
1828
1422
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
@@ -1832,14 +1426,15 @@ var init_lib = __esm({
|
|
1832
1426
|
return new ZodBranded({
|
1833
1427
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
1834
1428
|
type: this,
|
1835
|
-
...processCreateParams(
|
1429
|
+
...processCreateParams(this._def)
|
1836
1430
|
});
|
1837
1431
|
}
|
1838
1432
|
catch(def) {
|
1839
|
-
const
|
1433
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
1840
1434
|
return new ZodCatch({
|
1435
|
+
...processCreateParams(this._def),
|
1841
1436
|
innerType: this,
|
1842
|
-
|
1437
|
+
catchValue: catchValueFunc,
|
1843
1438
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
1844
1439
|
});
|
1845
1440
|
}
|
@@ -1853,6 +1448,9 @@ var init_lib = __esm({
|
|
1853
1448
|
pipe(target) {
|
1854
1449
|
return ZodPipeline.create(this, target);
|
1855
1450
|
}
|
1451
|
+
readonly() {
|
1452
|
+
return ZodReadonly.create(this);
|
1453
|
+
}
|
1856
1454
|
isOptional() {
|
1857
1455
|
return this.safeParse(void 0).success;
|
1858
1456
|
}
|
@@ -1861,43 +1459,19 @@ var init_lib = __esm({
|
|
1861
1459
|
}
|
1862
1460
|
};
|
1863
1461
|
cuidRegex = /^c[^\s-]{8,}$/i;
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
} else {
|
1877
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
1878
|
-
}
|
1879
|
-
} else {
|
1880
|
-
if (args.offset) {
|
1881
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
|
1882
|
-
} else {
|
1883
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
1884
|
-
}
|
1885
|
-
}
|
1886
|
-
};
|
1462
|
+
cuid2Regex = /^[0-9a-z]+$/;
|
1463
|
+
ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
1464
|
+
uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
1465
|
+
nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
1466
|
+
durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
1467
|
+
emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
1468
|
+
_emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
1469
|
+
ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
1470
|
+
ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
1471
|
+
base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
1472
|
+
dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
1473
|
+
dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1887
1474
|
ZodString = class _ZodString extends ZodType {
|
1888
|
-
constructor() {
|
1889
|
-
super(...arguments);
|
1890
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
1891
|
-
validation,
|
1892
|
-
code: ZodIssueCode.invalid_string,
|
1893
|
-
...errorUtil.errToObj(message)
|
1894
|
-
});
|
1895
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
1896
|
-
this.trim = () => new _ZodString({
|
1897
|
-
...this._def,
|
1898
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
1899
|
-
});
|
1900
|
-
}
|
1901
1475
|
_parse(input) {
|
1902
1476
|
if (this._def.coerce) {
|
1903
1477
|
input.data = String(input.data);
|
@@ -1905,15 +1479,11 @@ var init_lib = __esm({
|
|
1905
1479
|
const parsedType = this._getType(input);
|
1906
1480
|
if (parsedType !== ZodParsedType.string) {
|
1907
1481
|
const ctx2 = this._getOrReturnCtx(input);
|
1908
|
-
addIssueToContext(
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
received: ctx2.parsedType
|
1914
|
-
}
|
1915
|
-
//
|
1916
|
-
);
|
1482
|
+
addIssueToContext(ctx2, {
|
1483
|
+
code: ZodIssueCode.invalid_type,
|
1484
|
+
expected: ZodParsedType.string,
|
1485
|
+
received: ctx2.parsedType
|
1486
|
+
});
|
1917
1487
|
return INVALID;
|
1918
1488
|
}
|
1919
1489
|
const status = new ParseStatus();
|
@@ -1981,6 +1551,19 @@ var init_lib = __esm({
|
|
1981
1551
|
});
|
1982
1552
|
status.dirty();
|
1983
1553
|
}
|
1554
|
+
} else if (check.kind === "emoji") {
|
1555
|
+
if (!emojiRegex) {
|
1556
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
1557
|
+
}
|
1558
|
+
if (!emojiRegex.test(input.data)) {
|
1559
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1560
|
+
addIssueToContext(ctx, {
|
1561
|
+
validation: "emoji",
|
1562
|
+
code: ZodIssueCode.invalid_string,
|
1563
|
+
message: check.message
|
1564
|
+
});
|
1565
|
+
status.dirty();
|
1566
|
+
}
|
1984
1567
|
} else if (check.kind === "uuid") {
|
1985
1568
|
if (!uuidRegex.test(input.data)) {
|
1986
1569
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -1991,6 +1574,16 @@ var init_lib = __esm({
|
|
1991
1574
|
});
|
1992
1575
|
status.dirty();
|
1993
1576
|
}
|
1577
|
+
} else if (check.kind === "nanoid") {
|
1578
|
+
if (!nanoidRegex.test(input.data)) {
|
1579
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1580
|
+
addIssueToContext(ctx, {
|
1581
|
+
validation: "nanoid",
|
1582
|
+
code: ZodIssueCode.invalid_string,
|
1583
|
+
message: check.message
|
1584
|
+
});
|
1585
|
+
status.dirty();
|
1586
|
+
}
|
1994
1587
|
} else if (check.kind === "cuid") {
|
1995
1588
|
if (!cuidRegex.test(input.data)) {
|
1996
1589
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2001,6 +1594,26 @@ var init_lib = __esm({
|
|
2001
1594
|
});
|
2002
1595
|
status.dirty();
|
2003
1596
|
}
|
1597
|
+
} else if (check.kind === "cuid2") {
|
1598
|
+
if (!cuid2Regex.test(input.data)) {
|
1599
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1600
|
+
addIssueToContext(ctx, {
|
1601
|
+
validation: "cuid2",
|
1602
|
+
code: ZodIssueCode.invalid_string,
|
1603
|
+
message: check.message
|
1604
|
+
});
|
1605
|
+
status.dirty();
|
1606
|
+
}
|
1607
|
+
} else if (check.kind === "ulid") {
|
1608
|
+
if (!ulidRegex.test(input.data)) {
|
1609
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1610
|
+
addIssueToContext(ctx, {
|
1611
|
+
validation: "ulid",
|
1612
|
+
code: ZodIssueCode.invalid_string,
|
1613
|
+
message: check.message
|
1614
|
+
});
|
1615
|
+
status.dirty();
|
1616
|
+
}
|
2004
1617
|
} else if (check.kind === "url") {
|
2005
1618
|
try {
|
2006
1619
|
new URL(input.data);
|
@@ -2027,6 +1640,20 @@ var init_lib = __esm({
|
|
2027
1640
|
}
|
2028
1641
|
} else if (check.kind === "trim") {
|
2029
1642
|
input.data = input.data.trim();
|
1643
|
+
} else if (check.kind === "includes") {
|
1644
|
+
if (!input.data.includes(check.value, check.position)) {
|
1645
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1646
|
+
addIssueToContext(ctx, {
|
1647
|
+
code: ZodIssueCode.invalid_string,
|
1648
|
+
validation: { includes: check.value, position: check.position },
|
1649
|
+
message: check.message
|
1650
|
+
});
|
1651
|
+
status.dirty();
|
1652
|
+
}
|
1653
|
+
} else if (check.kind === "toLowerCase") {
|
1654
|
+
input.data = input.data.toLowerCase();
|
1655
|
+
} else if (check.kind === "toUpperCase") {
|
1656
|
+
input.data = input.data.toUpperCase();
|
2030
1657
|
} else if (check.kind === "startsWith") {
|
2031
1658
|
if (!input.data.startsWith(check.value)) {
|
2032
1659
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2058,12 +1685,71 @@ var init_lib = __esm({
|
|
2058
1685
|
});
|
2059
1686
|
status.dirty();
|
2060
1687
|
}
|
1688
|
+
} else if (check.kind === "date") {
|
1689
|
+
const regex = dateRegex;
|
1690
|
+
if (!regex.test(input.data)) {
|
1691
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1692
|
+
addIssueToContext(ctx, {
|
1693
|
+
code: ZodIssueCode.invalid_string,
|
1694
|
+
validation: "date",
|
1695
|
+
message: check.message
|
1696
|
+
});
|
1697
|
+
status.dirty();
|
1698
|
+
}
|
1699
|
+
} else if (check.kind === "time") {
|
1700
|
+
const regex = timeRegex(check);
|
1701
|
+
if (!regex.test(input.data)) {
|
1702
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1703
|
+
addIssueToContext(ctx, {
|
1704
|
+
code: ZodIssueCode.invalid_string,
|
1705
|
+
validation: "time",
|
1706
|
+
message: check.message
|
1707
|
+
});
|
1708
|
+
status.dirty();
|
1709
|
+
}
|
1710
|
+
} else if (check.kind === "duration") {
|
1711
|
+
if (!durationRegex.test(input.data)) {
|
1712
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1713
|
+
addIssueToContext(ctx, {
|
1714
|
+
validation: "duration",
|
1715
|
+
code: ZodIssueCode.invalid_string,
|
1716
|
+
message: check.message
|
1717
|
+
});
|
1718
|
+
status.dirty();
|
1719
|
+
}
|
1720
|
+
} else if (check.kind === "ip") {
|
1721
|
+
if (!isValidIP(input.data, check.version)) {
|
1722
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1723
|
+
addIssueToContext(ctx, {
|
1724
|
+
validation: "ip",
|
1725
|
+
code: ZodIssueCode.invalid_string,
|
1726
|
+
message: check.message
|
1727
|
+
});
|
1728
|
+
status.dirty();
|
1729
|
+
}
|
1730
|
+
} else if (check.kind === "base64") {
|
1731
|
+
if (!base64Regex.test(input.data)) {
|
1732
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
1733
|
+
addIssueToContext(ctx, {
|
1734
|
+
validation: "base64",
|
1735
|
+
code: ZodIssueCode.invalid_string,
|
1736
|
+
message: check.message
|
1737
|
+
});
|
1738
|
+
status.dirty();
|
1739
|
+
}
|
2061
1740
|
} else {
|
2062
1741
|
util.assertNever(check);
|
2063
1742
|
}
|
2064
1743
|
}
|
2065
1744
|
return { status: status.value, value: input.data };
|
2066
1745
|
}
|
1746
|
+
_regex(regex, validation, message) {
|
1747
|
+
return this.refinement((data) => regex.test(data), {
|
1748
|
+
validation,
|
1749
|
+
code: ZodIssueCode.invalid_string,
|
1750
|
+
...errorUtil.errToObj(message)
|
1751
|
+
});
|
1752
|
+
}
|
2067
1753
|
_addCheck(check) {
|
2068
1754
|
return new _ZodString({
|
2069
1755
|
...this._def,
|
@@ -2076,19 +1762,38 @@ var init_lib = __esm({
|
|
2076
1762
|
url(message) {
|
2077
1763
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
2078
1764
|
}
|
1765
|
+
emoji(message) {
|
1766
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
1767
|
+
}
|
2079
1768
|
uuid(message) {
|
2080
1769
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
2081
1770
|
}
|
1771
|
+
nanoid(message) {
|
1772
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
1773
|
+
}
|
2082
1774
|
cuid(message) {
|
2083
1775
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
2084
1776
|
}
|
1777
|
+
cuid2(message) {
|
1778
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
1779
|
+
}
|
1780
|
+
ulid(message) {
|
1781
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
1782
|
+
}
|
1783
|
+
base64(message) {
|
1784
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
1785
|
+
}
|
1786
|
+
ip(options) {
|
1787
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
1788
|
+
}
|
2085
1789
|
datetime(options) {
|
2086
|
-
var _a;
|
1790
|
+
var _a, _b;
|
2087
1791
|
if (typeof options === "string") {
|
2088
1792
|
return this._addCheck({
|
2089
1793
|
kind: "datetime",
|
2090
1794
|
precision: null,
|
2091
1795
|
offset: false,
|
1796
|
+
local: false,
|
2092
1797
|
message: options
|
2093
1798
|
});
|
2094
1799
|
}
|
@@ -2096,9 +1801,30 @@ var init_lib = __esm({
|
|
2096
1801
|
kind: "datetime",
|
2097
1802
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2098
1803
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
1804
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
1805
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
1806
|
+
});
|
1807
|
+
}
|
1808
|
+
date(message) {
|
1809
|
+
return this._addCheck({ kind: "date", message });
|
1810
|
+
}
|
1811
|
+
time(options) {
|
1812
|
+
if (typeof options === "string") {
|
1813
|
+
return this._addCheck({
|
1814
|
+
kind: "time",
|
1815
|
+
precision: null,
|
1816
|
+
message: options
|
1817
|
+
});
|
1818
|
+
}
|
1819
|
+
return this._addCheck({
|
1820
|
+
kind: "time",
|
1821
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
2099
1822
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
2100
1823
|
});
|
2101
1824
|
}
|
1825
|
+
duration(message) {
|
1826
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
1827
|
+
}
|
2102
1828
|
regex(regex, message) {
|
2103
1829
|
return this._addCheck({
|
2104
1830
|
kind: "regex",
|
@@ -2106,6 +1832,14 @@ var init_lib = __esm({
|
|
2106
1832
|
...errorUtil.errToObj(message)
|
2107
1833
|
});
|
2108
1834
|
}
|
1835
|
+
includes(value, options) {
|
1836
|
+
return this._addCheck({
|
1837
|
+
kind: "includes",
|
1838
|
+
value,
|
1839
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
1840
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
1841
|
+
});
|
1842
|
+
}
|
2109
1843
|
startsWith(value, message) {
|
2110
1844
|
return this._addCheck({
|
2111
1845
|
kind: "startsWith",
|
@@ -2141,21 +1875,73 @@ var init_lib = __esm({
|
|
2141
1875
|
...errorUtil.errToObj(message)
|
2142
1876
|
});
|
2143
1877
|
}
|
1878
|
+
/**
|
1879
|
+
* @deprecated Use z.string().min(1) instead.
|
1880
|
+
* @see {@link ZodString.min}
|
1881
|
+
*/
|
1882
|
+
nonempty(message) {
|
1883
|
+
return this.min(1, errorUtil.errToObj(message));
|
1884
|
+
}
|
1885
|
+
trim() {
|
1886
|
+
return new _ZodString({
|
1887
|
+
...this._def,
|
1888
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
1889
|
+
});
|
1890
|
+
}
|
1891
|
+
toLowerCase() {
|
1892
|
+
return new _ZodString({
|
1893
|
+
...this._def,
|
1894
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
1895
|
+
});
|
1896
|
+
}
|
1897
|
+
toUpperCase() {
|
1898
|
+
return new _ZodString({
|
1899
|
+
...this._def,
|
1900
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
1901
|
+
});
|
1902
|
+
}
|
2144
1903
|
get isDatetime() {
|
2145
1904
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
2146
1905
|
}
|
1906
|
+
get isDate() {
|
1907
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
1908
|
+
}
|
1909
|
+
get isTime() {
|
1910
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
1911
|
+
}
|
1912
|
+
get isDuration() {
|
1913
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
1914
|
+
}
|
2147
1915
|
get isEmail() {
|
2148
1916
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
2149
1917
|
}
|
2150
1918
|
get isURL() {
|
2151
1919
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
2152
1920
|
}
|
1921
|
+
get isEmoji() {
|
1922
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
1923
|
+
}
|
2153
1924
|
get isUUID() {
|
2154
1925
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
2155
1926
|
}
|
1927
|
+
get isNANOID() {
|
1928
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
1929
|
+
}
|
2156
1930
|
get isCUID() {
|
2157
1931
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
2158
1932
|
}
|
1933
|
+
get isCUID2() {
|
1934
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
1935
|
+
}
|
1936
|
+
get isULID() {
|
1937
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
1938
|
+
}
|
1939
|
+
get isIP() {
|
1940
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
1941
|
+
}
|
1942
|
+
get isBase64() {
|
1943
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
1944
|
+
}
|
2159
1945
|
get minLength() {
|
2160
1946
|
let min = null;
|
2161
1947
|
for (const ch of this._def.checks) {
|
@@ -2228,9 +2014,227 @@ var init_lib = __esm({
|
|
2228
2014
|
addIssueToContext(ctx, {
|
2229
2015
|
code: ZodIssueCode.too_small,
|
2230
2016
|
minimum: check.value,
|
2231
|
-
type: "number",
|
2017
|
+
type: "number",
|
2018
|
+
inclusive: check.inclusive,
|
2019
|
+
exact: false,
|
2020
|
+
message: check.message
|
2021
|
+
});
|
2022
|
+
status.dirty();
|
2023
|
+
}
|
2024
|
+
} else if (check.kind === "max") {
|
2025
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
2026
|
+
if (tooBig) {
|
2027
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2028
|
+
addIssueToContext(ctx, {
|
2029
|
+
code: ZodIssueCode.too_big,
|
2030
|
+
maximum: check.value,
|
2031
|
+
type: "number",
|
2032
|
+
inclusive: check.inclusive,
|
2033
|
+
exact: false,
|
2034
|
+
message: check.message
|
2035
|
+
});
|
2036
|
+
status.dirty();
|
2037
|
+
}
|
2038
|
+
} else if (check.kind === "multipleOf") {
|
2039
|
+
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
2040
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2041
|
+
addIssueToContext(ctx, {
|
2042
|
+
code: ZodIssueCode.not_multiple_of,
|
2043
|
+
multipleOf: check.value,
|
2044
|
+
message: check.message
|
2045
|
+
});
|
2046
|
+
status.dirty();
|
2047
|
+
}
|
2048
|
+
} else if (check.kind === "finite") {
|
2049
|
+
if (!Number.isFinite(input.data)) {
|
2050
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2051
|
+
addIssueToContext(ctx, {
|
2052
|
+
code: ZodIssueCode.not_finite,
|
2053
|
+
message: check.message
|
2054
|
+
});
|
2055
|
+
status.dirty();
|
2056
|
+
}
|
2057
|
+
} else {
|
2058
|
+
util.assertNever(check);
|
2059
|
+
}
|
2060
|
+
}
|
2061
|
+
return { status: status.value, value: input.data };
|
2062
|
+
}
|
2063
|
+
gte(value, message) {
|
2064
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2065
|
+
}
|
2066
|
+
gt(value, message) {
|
2067
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
2068
|
+
}
|
2069
|
+
lte(value, message) {
|
2070
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
2071
|
+
}
|
2072
|
+
lt(value, message) {
|
2073
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2074
|
+
}
|
2075
|
+
setLimit(kind, value, inclusive, message) {
|
2076
|
+
return new _ZodNumber({
|
2077
|
+
...this._def,
|
2078
|
+
checks: [
|
2079
|
+
...this._def.checks,
|
2080
|
+
{
|
2081
|
+
kind,
|
2082
|
+
value,
|
2083
|
+
inclusive,
|
2084
|
+
message: errorUtil.toString(message)
|
2085
|
+
}
|
2086
|
+
]
|
2087
|
+
});
|
2088
|
+
}
|
2089
|
+
_addCheck(check) {
|
2090
|
+
return new _ZodNumber({
|
2091
|
+
...this._def,
|
2092
|
+
checks: [...this._def.checks, check]
|
2093
|
+
});
|
2094
|
+
}
|
2095
|
+
int(message) {
|
2096
|
+
return this._addCheck({
|
2097
|
+
kind: "int",
|
2098
|
+
message: errorUtil.toString(message)
|
2099
|
+
});
|
2100
|
+
}
|
2101
|
+
positive(message) {
|
2102
|
+
return this._addCheck({
|
2103
|
+
kind: "min",
|
2104
|
+
value: 0,
|
2105
|
+
inclusive: false,
|
2106
|
+
message: errorUtil.toString(message)
|
2107
|
+
});
|
2108
|
+
}
|
2109
|
+
negative(message) {
|
2110
|
+
return this._addCheck({
|
2111
|
+
kind: "max",
|
2112
|
+
value: 0,
|
2113
|
+
inclusive: false,
|
2114
|
+
message: errorUtil.toString(message)
|
2115
|
+
});
|
2116
|
+
}
|
2117
|
+
nonpositive(message) {
|
2118
|
+
return this._addCheck({
|
2119
|
+
kind: "max",
|
2120
|
+
value: 0,
|
2121
|
+
inclusive: true,
|
2122
|
+
message: errorUtil.toString(message)
|
2123
|
+
});
|
2124
|
+
}
|
2125
|
+
nonnegative(message) {
|
2126
|
+
return this._addCheck({
|
2127
|
+
kind: "min",
|
2128
|
+
value: 0,
|
2129
|
+
inclusive: true,
|
2130
|
+
message: errorUtil.toString(message)
|
2131
|
+
});
|
2132
|
+
}
|
2133
|
+
multipleOf(value, message) {
|
2134
|
+
return this._addCheck({
|
2135
|
+
kind: "multipleOf",
|
2136
|
+
value,
|
2137
|
+
message: errorUtil.toString(message)
|
2138
|
+
});
|
2139
|
+
}
|
2140
|
+
finite(message) {
|
2141
|
+
return this._addCheck({
|
2142
|
+
kind: "finite",
|
2143
|
+
message: errorUtil.toString(message)
|
2144
|
+
});
|
2145
|
+
}
|
2146
|
+
safe(message) {
|
2147
|
+
return this._addCheck({
|
2148
|
+
kind: "min",
|
2149
|
+
inclusive: true,
|
2150
|
+
value: Number.MIN_SAFE_INTEGER,
|
2151
|
+
message: errorUtil.toString(message)
|
2152
|
+
})._addCheck({
|
2153
|
+
kind: "max",
|
2154
|
+
inclusive: true,
|
2155
|
+
value: Number.MAX_SAFE_INTEGER,
|
2156
|
+
message: errorUtil.toString(message)
|
2157
|
+
});
|
2158
|
+
}
|
2159
|
+
get minValue() {
|
2160
|
+
let min = null;
|
2161
|
+
for (const ch of this._def.checks) {
|
2162
|
+
if (ch.kind === "min") {
|
2163
|
+
if (min === null || ch.value > min)
|
2164
|
+
min = ch.value;
|
2165
|
+
}
|
2166
|
+
}
|
2167
|
+
return min;
|
2168
|
+
}
|
2169
|
+
get maxValue() {
|
2170
|
+
let max = null;
|
2171
|
+
for (const ch of this._def.checks) {
|
2172
|
+
if (ch.kind === "max") {
|
2173
|
+
if (max === null || ch.value < max)
|
2174
|
+
max = ch.value;
|
2175
|
+
}
|
2176
|
+
}
|
2177
|
+
return max;
|
2178
|
+
}
|
2179
|
+
get isInt() {
|
2180
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2181
|
+
}
|
2182
|
+
get isFinite() {
|
2183
|
+
let max = null, min = null;
|
2184
|
+
for (const ch of this._def.checks) {
|
2185
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2186
|
+
return true;
|
2187
|
+
} else if (ch.kind === "min") {
|
2188
|
+
if (min === null || ch.value > min)
|
2189
|
+
min = ch.value;
|
2190
|
+
} else if (ch.kind === "max") {
|
2191
|
+
if (max === null || ch.value < max)
|
2192
|
+
max = ch.value;
|
2193
|
+
}
|
2194
|
+
}
|
2195
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
2196
|
+
}
|
2197
|
+
};
|
2198
|
+
ZodNumber.create = (params) => {
|
2199
|
+
return new ZodNumber({
|
2200
|
+
checks: [],
|
2201
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
2202
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
2203
|
+
...processCreateParams(params)
|
2204
|
+
});
|
2205
|
+
};
|
2206
|
+
ZodBigInt = class _ZodBigInt extends ZodType {
|
2207
|
+
constructor() {
|
2208
|
+
super(...arguments);
|
2209
|
+
this.min = this.gte;
|
2210
|
+
this.max = this.lte;
|
2211
|
+
}
|
2212
|
+
_parse(input) {
|
2213
|
+
if (this._def.coerce) {
|
2214
|
+
input.data = BigInt(input.data);
|
2215
|
+
}
|
2216
|
+
const parsedType = this._getType(input);
|
2217
|
+
if (parsedType !== ZodParsedType.bigint) {
|
2218
|
+
const ctx2 = this._getOrReturnCtx(input);
|
2219
|
+
addIssueToContext(ctx2, {
|
2220
|
+
code: ZodIssueCode.invalid_type,
|
2221
|
+
expected: ZodParsedType.bigint,
|
2222
|
+
received: ctx2.parsedType
|
2223
|
+
});
|
2224
|
+
return INVALID;
|
2225
|
+
}
|
2226
|
+
let ctx = void 0;
|
2227
|
+
const status = new ParseStatus();
|
2228
|
+
for (const check of this._def.checks) {
|
2229
|
+
if (check.kind === "min") {
|
2230
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
2231
|
+
if (tooSmall) {
|
2232
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2233
|
+
addIssueToContext(ctx, {
|
2234
|
+
code: ZodIssueCode.too_small,
|
2235
|
+
type: "bigint",
|
2236
|
+
minimum: check.value,
|
2232
2237
|
inclusive: check.inclusive,
|
2233
|
-
exact: false,
|
2234
2238
|
message: check.message
|
2235
2239
|
});
|
2236
2240
|
status.dirty();
|
@@ -2241,16 +2245,15 @@ var init_lib = __esm({
|
|
2241
2245
|
ctx = this._getOrReturnCtx(input, ctx);
|
2242
2246
|
addIssueToContext(ctx, {
|
2243
2247
|
code: ZodIssueCode.too_big,
|
2248
|
+
type: "bigint",
|
2244
2249
|
maximum: check.value,
|
2245
|
-
type: "number",
|
2246
2250
|
inclusive: check.inclusive,
|
2247
|
-
exact: false,
|
2248
2251
|
message: check.message
|
2249
2252
|
});
|
2250
2253
|
status.dirty();
|
2251
2254
|
}
|
2252
2255
|
} else if (check.kind === "multipleOf") {
|
2253
|
-
if (
|
2256
|
+
if (input.data % check.value !== BigInt(0)) {
|
2254
2257
|
ctx = this._getOrReturnCtx(input, ctx);
|
2255
2258
|
addIssueToContext(ctx, {
|
2256
2259
|
code: ZodIssueCode.not_multiple_of,
|
@@ -2259,15 +2262,6 @@ var init_lib = __esm({
|
|
2259
2262
|
});
|
2260
2263
|
status.dirty();
|
2261
2264
|
}
|
2262
|
-
} else if (check.kind === "finite") {
|
2263
|
-
if (!Number.isFinite(input.data)) {
|
2264
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
2265
|
-
addIssueToContext(ctx, {
|
2266
|
-
code: ZodIssueCode.not_finite,
|
2267
|
-
message: check.message
|
2268
|
-
});
|
2269
|
-
status.dirty();
|
2270
|
-
}
|
2271
2265
|
} else {
|
2272
2266
|
util.assertNever(check);
|
2273
2267
|
}
|
@@ -2287,7 +2281,7 @@ var init_lib = __esm({
|
|
2287
2281
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
2288
2282
|
}
|
2289
2283
|
setLimit(kind, value, inclusive, message) {
|
2290
|
-
return new
|
2284
|
+
return new _ZodBigInt({
|
2291
2285
|
...this._def,
|
2292
2286
|
checks: [
|
2293
2287
|
...this._def.checks,
|
@@ -2301,21 +2295,15 @@ var init_lib = __esm({
|
|
2301
2295
|
});
|
2302
2296
|
}
|
2303
2297
|
_addCheck(check) {
|
2304
|
-
return new
|
2298
|
+
return new _ZodBigInt({
|
2305
2299
|
...this._def,
|
2306
2300
|
checks: [...this._def.checks, check]
|
2307
2301
|
});
|
2308
2302
|
}
|
2309
|
-
int(message) {
|
2310
|
-
return this._addCheck({
|
2311
|
-
kind: "int",
|
2312
|
-
message: errorUtil.toString(message)
|
2313
|
-
});
|
2314
|
-
}
|
2315
2303
|
positive(message) {
|
2316
2304
|
return this._addCheck({
|
2317
2305
|
kind: "min",
|
2318
|
-
value: 0,
|
2306
|
+
value: BigInt(0),
|
2319
2307
|
inclusive: false,
|
2320
2308
|
message: errorUtil.toString(message)
|
2321
2309
|
});
|
@@ -2323,7 +2311,7 @@ var init_lib = __esm({
|
|
2323
2311
|
negative(message) {
|
2324
2312
|
return this._addCheck({
|
2325
2313
|
kind: "max",
|
2326
|
-
value: 0,
|
2314
|
+
value: BigInt(0),
|
2327
2315
|
inclusive: false,
|
2328
2316
|
message: errorUtil.toString(message)
|
2329
2317
|
});
|
@@ -2331,7 +2319,7 @@ var init_lib = __esm({
|
|
2331
2319
|
nonpositive(message) {
|
2332
2320
|
return this._addCheck({
|
2333
2321
|
kind: "max",
|
2334
|
-
value: 0,
|
2322
|
+
value: BigInt(0),
|
2335
2323
|
inclusive: true,
|
2336
2324
|
message: errorUtil.toString(message)
|
2337
2325
|
});
|
@@ -2339,7 +2327,7 @@ var init_lib = __esm({
|
|
2339
2327
|
nonnegative(message) {
|
2340
2328
|
return this._addCheck({
|
2341
2329
|
kind: "min",
|
2342
|
-
value: 0,
|
2330
|
+
value: BigInt(0),
|
2343
2331
|
inclusive: true,
|
2344
2332
|
message: errorUtil.toString(message)
|
2345
2333
|
});
|
@@ -2351,12 +2339,6 @@ var init_lib = __esm({
|
|
2351
2339
|
message: errorUtil.toString(message)
|
2352
2340
|
});
|
2353
2341
|
}
|
2354
|
-
finite(message) {
|
2355
|
-
return this._addCheck({
|
2356
|
-
kind: "finite",
|
2357
|
-
message: errorUtil.toString(message)
|
2358
|
-
});
|
2359
|
-
}
|
2360
2342
|
get minValue() {
|
2361
2343
|
let min = null;
|
2362
2344
|
for (const ch of this._def.checks) {
|
@@ -2377,39 +2359,11 @@ var init_lib = __esm({
|
|
2377
2359
|
}
|
2378
2360
|
return max;
|
2379
2361
|
}
|
2380
|
-
get isInt() {
|
2381
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
2382
|
-
}
|
2383
|
-
};
|
2384
|
-
ZodNumber.create = (params) => {
|
2385
|
-
return new ZodNumber({
|
2386
|
-
checks: [],
|
2387
|
-
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
2388
|
-
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
2389
|
-
...processCreateParams(params)
|
2390
|
-
});
|
2391
|
-
};
|
2392
|
-
ZodBigInt = class extends ZodType {
|
2393
|
-
_parse(input) {
|
2394
|
-
if (this._def.coerce) {
|
2395
|
-
input.data = BigInt(input.data);
|
2396
|
-
}
|
2397
|
-
const parsedType = this._getType(input);
|
2398
|
-
if (parsedType !== ZodParsedType.bigint) {
|
2399
|
-
const ctx = this._getOrReturnCtx(input);
|
2400
|
-
addIssueToContext(ctx, {
|
2401
|
-
code: ZodIssueCode.invalid_type,
|
2402
|
-
expected: ZodParsedType.bigint,
|
2403
|
-
received: ctx.parsedType
|
2404
|
-
});
|
2405
|
-
return INVALID;
|
2406
|
-
}
|
2407
|
-
return OK(input.data);
|
2408
|
-
}
|
2409
2362
|
};
|
2410
2363
|
ZodBigInt.create = (params) => {
|
2411
2364
|
var _a;
|
2412
2365
|
return new ZodBigInt({
|
2366
|
+
checks: [],
|
2413
2367
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2414
2368
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
2415
2369
|
...processCreateParams(params)
|
@@ -2735,13 +2689,13 @@ var init_lib = __esm({
|
|
2735
2689
|
}
|
2736
2690
|
}
|
2737
2691
|
if (ctx.common.async) {
|
2738
|
-
return Promise.all(ctx.data.map((item, i) => {
|
2692
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
2739
2693
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2740
2694
|
})).then((result2) => {
|
2741
2695
|
return ParseStatus.mergeArray(status, result2);
|
2742
2696
|
});
|
2743
2697
|
}
|
2744
|
-
const result = ctx.data.map((item, i) => {
|
2698
|
+
const result = [...ctx.data].map((item, i) => {
|
2745
2699
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
2746
2700
|
});
|
2747
2701
|
return ParseStatus.mergeArray(status, result);
|
@@ -2781,31 +2735,12 @@ var init_lib = __esm({
|
|
2781
2735
|
...processCreateParams(params)
|
2782
2736
|
});
|
2783
2737
|
};
|
2784
|
-
(function(objectUtil2) {
|
2785
|
-
objectUtil2.mergeShapes = (first, second) => {
|
2786
|
-
return {
|
2787
|
-
...first,
|
2788
|
-
...second
|
2789
|
-
// second overwrites first
|
2790
|
-
};
|
2791
|
-
};
|
2792
|
-
})(objectUtil || (objectUtil = {}));
|
2793
|
-
AugmentFactory = (def) => (augmentation) => {
|
2794
|
-
return new ZodObject({
|
2795
|
-
...def,
|
2796
|
-
shape: () => ({
|
2797
|
-
...def.shape(),
|
2798
|
-
...augmentation
|
2799
|
-
})
|
2800
|
-
});
|
2801
|
-
};
|
2802
2738
|
ZodObject = class _ZodObject extends ZodType {
|
2803
2739
|
constructor() {
|
2804
2740
|
super(...arguments);
|
2805
2741
|
this._cached = null;
|
2806
2742
|
this.nonstrict = this.passthrough;
|
2807
|
-
this.augment =
|
2808
|
-
this.extend = AugmentFactory(this._def);
|
2743
|
+
this.augment = this.extend;
|
2809
2744
|
}
|
2810
2745
|
_getCached() {
|
2811
2746
|
if (this._cached !== null)
|
@@ -2886,9 +2821,10 @@ var init_lib = __esm({
|
|
2886
2821
|
const syncPairs = [];
|
2887
2822
|
for (const pair of pairs) {
|
2888
2823
|
const key = await pair.key;
|
2824
|
+
const value = await pair.value;
|
2889
2825
|
syncPairs.push({
|
2890
2826
|
key,
|
2891
|
-
value
|
2827
|
+
value,
|
2892
2828
|
alwaysSet: pair.alwaysSet
|
2893
2829
|
});
|
2894
2830
|
}
|
@@ -2935,8 +2871,31 @@ var init_lib = __esm({
|
|
2935
2871
|
unknownKeys: "passthrough"
|
2936
2872
|
});
|
2937
2873
|
}
|
2938
|
-
|
2939
|
-
|
2874
|
+
// const AugmentFactory =
|
2875
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
2876
|
+
// <Augmentation extends ZodRawShape>(
|
2877
|
+
// augmentation: Augmentation
|
2878
|
+
// ): ZodObject<
|
2879
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
2880
|
+
// Def["unknownKeys"],
|
2881
|
+
// Def["catchall"]
|
2882
|
+
// > => {
|
2883
|
+
// return new ZodObject({
|
2884
|
+
// ...def,
|
2885
|
+
// shape: () => ({
|
2886
|
+
// ...def.shape(),
|
2887
|
+
// ...augmentation,
|
2888
|
+
// }),
|
2889
|
+
// }) as any;
|
2890
|
+
// };
|
2891
|
+
extend(augmentation) {
|
2892
|
+
return new _ZodObject({
|
2893
|
+
...this._def,
|
2894
|
+
shape: () => ({
|
2895
|
+
...this._def.shape(),
|
2896
|
+
...augmentation
|
2897
|
+
})
|
2898
|
+
});
|
2940
2899
|
}
|
2941
2900
|
/**
|
2942
2901
|
* Prior to zod@1.0.12 there was a bug in the
|
@@ -2947,11 +2906,73 @@ var init_lib = __esm({
|
|
2947
2906
|
const merged = new _ZodObject({
|
2948
2907
|
unknownKeys: merging._def.unknownKeys,
|
2949
2908
|
catchall: merging._def.catchall,
|
2950
|
-
shape: () =>
|
2909
|
+
shape: () => ({
|
2910
|
+
...this._def.shape(),
|
2911
|
+
...merging._def.shape()
|
2912
|
+
}),
|
2951
2913
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
2952
2914
|
});
|
2953
2915
|
return merged;
|
2954
2916
|
}
|
2917
|
+
// merge<
|
2918
|
+
// Incoming extends AnyZodObject,
|
2919
|
+
// Augmentation extends Incoming["shape"],
|
2920
|
+
// NewOutput extends {
|
2921
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
2922
|
+
// ? Augmentation[k]["_output"]
|
2923
|
+
// : k extends keyof Output
|
2924
|
+
// ? Output[k]
|
2925
|
+
// : never;
|
2926
|
+
// },
|
2927
|
+
// NewInput extends {
|
2928
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
2929
|
+
// ? Augmentation[k]["_input"]
|
2930
|
+
// : k extends keyof Input
|
2931
|
+
// ? Input[k]
|
2932
|
+
// : never;
|
2933
|
+
// }
|
2934
|
+
// >(
|
2935
|
+
// merging: Incoming
|
2936
|
+
// ): ZodObject<
|
2937
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
2938
|
+
// Incoming["_def"]["unknownKeys"],
|
2939
|
+
// Incoming["_def"]["catchall"],
|
2940
|
+
// NewOutput,
|
2941
|
+
// NewInput
|
2942
|
+
// > {
|
2943
|
+
// const merged: any = new ZodObject({
|
2944
|
+
// unknownKeys: merging._def.unknownKeys,
|
2945
|
+
// catchall: merging._def.catchall,
|
2946
|
+
// shape: () =>
|
2947
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
2948
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
2949
|
+
// }) as any;
|
2950
|
+
// return merged;
|
2951
|
+
// }
|
2952
|
+
setKey(key, schema3) {
|
2953
|
+
return this.augment({ [key]: schema3 });
|
2954
|
+
}
|
2955
|
+
// merge<Incoming extends AnyZodObject>(
|
2956
|
+
// merging: Incoming
|
2957
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
2958
|
+
// ZodObject<
|
2959
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
2960
|
+
// Incoming["_def"]["unknownKeys"],
|
2961
|
+
// Incoming["_def"]["catchall"]
|
2962
|
+
// > {
|
2963
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
2964
|
+
// // this._def.shape(),
|
2965
|
+
// // merging._def.shape()
|
2966
|
+
// // );
|
2967
|
+
// const merged: any = new ZodObject({
|
2968
|
+
// unknownKeys: merging._def.unknownKeys,
|
2969
|
+
// catchall: merging._def.catchall,
|
2970
|
+
// shape: () =>
|
2971
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
2972
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
2973
|
+
// }) as any;
|
2974
|
+
// return merged;
|
2975
|
+
// }
|
2955
2976
|
catchall(index4) {
|
2956
2977
|
return new _ZodObject({
|
2957
2978
|
...this._def,
|
@@ -2960,9 +2981,10 @@ var init_lib = __esm({
|
|
2960
2981
|
}
|
2961
2982
|
pick(mask) {
|
2962
2983
|
const shape = {};
|
2963
|
-
util.objectKeys(mask).
|
2964
|
-
if (this.shape[key])
|
2984
|
+
util.objectKeys(mask).forEach((key) => {
|
2985
|
+
if (mask[key] && this.shape[key]) {
|
2965
2986
|
shape[key] = this.shape[key];
|
2987
|
+
}
|
2966
2988
|
});
|
2967
2989
|
return new _ZodObject({
|
2968
2990
|
...this._def,
|
@@ -2971,8 +2993,8 @@ var init_lib = __esm({
|
|
2971
2993
|
}
|
2972
2994
|
omit(mask) {
|
2973
2995
|
const shape = {};
|
2974
|
-
util.objectKeys(this.shape).
|
2975
|
-
if (
|
2996
|
+
util.objectKeys(this.shape).forEach((key) => {
|
2997
|
+
if (!mask[key]) {
|
2976
2998
|
shape[key] = this.shape[key];
|
2977
2999
|
}
|
2978
3000
|
});
|
@@ -2981,29 +3003,22 @@ var init_lib = __esm({
|
|
2981
3003
|
shape: () => shape
|
2982
3004
|
});
|
2983
3005
|
}
|
3006
|
+
/**
|
3007
|
+
* @deprecated
|
3008
|
+
*/
|
2984
3009
|
deepPartial() {
|
2985
3010
|
return deepPartialify(this);
|
2986
3011
|
}
|
2987
3012
|
partial(mask) {
|
2988
3013
|
const newShape = {};
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
newShape[key] = this.shape[key].optional();
|
2995
|
-
}
|
2996
|
-
});
|
2997
|
-
return new _ZodObject({
|
2998
|
-
...this._def,
|
2999
|
-
shape: () => newShape
|
3000
|
-
});
|
3001
|
-
} else {
|
3002
|
-
for (const key in this.shape) {
|
3003
|
-
const fieldSchema = this.shape[key];
|
3014
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3015
|
+
const fieldSchema = this.shape[key];
|
3016
|
+
if (mask && !mask[key]) {
|
3017
|
+
newShape[key] = fieldSchema;
|
3018
|
+
} else {
|
3004
3019
|
newShape[key] = fieldSchema.optional();
|
3005
3020
|
}
|
3006
|
-
}
|
3021
|
+
});
|
3007
3022
|
return new _ZodObject({
|
3008
3023
|
...this._def,
|
3009
3024
|
shape: () => newShape
|
@@ -3011,21 +3026,10 @@ var init_lib = __esm({
|
|
3011
3026
|
}
|
3012
3027
|
required(mask) {
|
3013
3028
|
const newShape = {};
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
} else {
|
3019
|
-
const fieldSchema = this.shape[key];
|
3020
|
-
let newField = fieldSchema;
|
3021
|
-
while (newField instanceof ZodOptional) {
|
3022
|
-
newField = newField._def.innerType;
|
3023
|
-
}
|
3024
|
-
newShape[key] = newField;
|
3025
|
-
}
|
3026
|
-
});
|
3027
|
-
} else {
|
3028
|
-
for (const key in this.shape) {
|
3029
|
+
util.objectKeys(this.shape).forEach((key) => {
|
3030
|
+
if (mask && !mask[key]) {
|
3031
|
+
newShape[key] = this.shape[key];
|
3032
|
+
} else {
|
3029
3033
|
const fieldSchema = this.shape[key];
|
3030
3034
|
let newField = fieldSchema;
|
3031
3035
|
while (newField instanceof ZodOptional) {
|
@@ -3033,7 +3037,7 @@ var init_lib = __esm({
|
|
3033
3037
|
}
|
3034
3038
|
newShape[key] = newField;
|
3035
3039
|
}
|
3036
|
-
}
|
3040
|
+
});
|
3037
3041
|
return new _ZodObject({
|
3038
3042
|
...this._def,
|
3039
3043
|
shape: () => newShape
|
@@ -3171,15 +3175,25 @@ var init_lib = __esm({
|
|
3171
3175
|
} else if (type instanceof ZodEnum) {
|
3172
3176
|
return type.options;
|
3173
3177
|
} else if (type instanceof ZodNativeEnum) {
|
3174
|
-
return
|
3178
|
+
return util.objectValues(type.enum);
|
3175
3179
|
} else if (type instanceof ZodDefault) {
|
3176
3180
|
return getDiscriminator(type._def.innerType);
|
3177
3181
|
} else if (type instanceof ZodUndefined) {
|
3178
3182
|
return [void 0];
|
3179
3183
|
} else if (type instanceof ZodNull) {
|
3180
3184
|
return [null];
|
3185
|
+
} else if (type instanceof ZodOptional) {
|
3186
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
3187
|
+
} else if (type instanceof ZodNullable) {
|
3188
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
3189
|
+
} else if (type instanceof ZodBranded) {
|
3190
|
+
return getDiscriminator(type.unwrap());
|
3191
|
+
} else if (type instanceof ZodReadonly) {
|
3192
|
+
return getDiscriminator(type.unwrap());
|
3193
|
+
} else if (type instanceof ZodCatch) {
|
3194
|
+
return getDiscriminator(type._def.innerType);
|
3181
3195
|
} else {
|
3182
|
-
return
|
3196
|
+
return [];
|
3183
3197
|
}
|
3184
3198
|
};
|
3185
3199
|
ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
@@ -3239,7 +3253,7 @@ var init_lib = __esm({
|
|
3239
3253
|
const optionsMap = /* @__PURE__ */ new Map();
|
3240
3254
|
for (const type of options) {
|
3241
3255
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
3242
|
-
if (!discriminatorValues) {
|
3256
|
+
if (!discriminatorValues.length) {
|
3243
3257
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
3244
3258
|
}
|
3245
3259
|
for (const value of discriminatorValues) {
|
@@ -3343,7 +3357,7 @@ var init_lib = __esm({
|
|
3343
3357
|
});
|
3344
3358
|
status.dirty();
|
3345
3359
|
}
|
3346
|
-
const items = ctx.data.map((item, itemIndex) => {
|
3360
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
3347
3361
|
const schema3 = this._def.items[itemIndex] || this._def.rest;
|
3348
3362
|
if (!schema3)
|
3349
3363
|
return null;
|
@@ -3401,7 +3415,8 @@ var init_lib = __esm({
|
|
3401
3415
|
for (const key in ctx.data) {
|
3402
3416
|
pairs.push({
|
3403
3417
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
3404
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
3418
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
3419
|
+
alwaysSet: key in ctx.data
|
3405
3420
|
});
|
3406
3421
|
}
|
3407
3422
|
if (ctx.common.async) {
|
@@ -3431,6 +3446,12 @@ var init_lib = __esm({
|
|
3431
3446
|
}
|
3432
3447
|
};
|
3433
3448
|
ZodMap = class extends ZodType {
|
3449
|
+
get keySchema() {
|
3450
|
+
return this._def.keyType;
|
3451
|
+
}
|
3452
|
+
get valueSchema() {
|
3453
|
+
return this._def.valueType;
|
3454
|
+
}
|
3434
3455
|
_parse(input) {
|
3435
3456
|
const { status, ctx } = this._processInputParams(input);
|
3436
3457
|
if (ctx.parsedType !== ZodParsedType.map) {
|
@@ -3625,27 +3646,29 @@ var init_lib = __esm({
|
|
3625
3646
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
3626
3647
|
const fn = ctx.data;
|
3627
3648
|
if (this._def.returns instanceof ZodPromise) {
|
3628
|
-
|
3649
|
+
const me = this;
|
3650
|
+
return OK(async function(...args) {
|
3629
3651
|
const error2 = new ZodError([]);
|
3630
|
-
const parsedArgs = await
|
3652
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
3631
3653
|
error2.addIssue(makeArgsIssue(args, e));
|
3632
3654
|
throw error2;
|
3633
3655
|
});
|
3634
|
-
const result = await fn
|
3635
|
-
const parsedReturns = await
|
3656
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
3657
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
3636
3658
|
error2.addIssue(makeReturnsIssue(result, e));
|
3637
3659
|
throw error2;
|
3638
3660
|
});
|
3639
3661
|
return parsedReturns;
|
3640
3662
|
});
|
3641
3663
|
} else {
|
3642
|
-
|
3643
|
-
|
3664
|
+
const me = this;
|
3665
|
+
return OK(function(...args) {
|
3666
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
3644
3667
|
if (!parsedArgs.success) {
|
3645
3668
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
3646
3669
|
}
|
3647
|
-
const result = fn
|
3648
|
-
const parsedReturns =
|
3670
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
3671
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
3649
3672
|
if (!parsedReturns.success) {
|
3650
3673
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
3651
3674
|
}
|
@@ -3710,6 +3733,7 @@ var init_lib = __esm({
|
|
3710
3733
|
if (input.data !== this._def.value) {
|
3711
3734
|
const ctx = this._getOrReturnCtx(input);
|
3712
3735
|
addIssueToContext(ctx, {
|
3736
|
+
received: ctx.data,
|
3713
3737
|
code: ZodIssueCode.invalid_literal,
|
3714
3738
|
expected: this._def.value
|
3715
3739
|
});
|
@@ -3728,7 +3752,11 @@ var init_lib = __esm({
|
|
3728
3752
|
...processCreateParams(params)
|
3729
3753
|
});
|
3730
3754
|
};
|
3731
|
-
ZodEnum = class extends ZodType {
|
3755
|
+
ZodEnum = class _ZodEnum extends ZodType {
|
3756
|
+
constructor() {
|
3757
|
+
super(...arguments);
|
3758
|
+
_ZodEnum_cache.set(this, void 0);
|
3759
|
+
}
|
3732
3760
|
_parse(input) {
|
3733
3761
|
if (typeof input.data !== "string") {
|
3734
3762
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3740,7 +3768,10 @@ var init_lib = __esm({
|
|
3740
3768
|
});
|
3741
3769
|
return INVALID;
|
3742
3770
|
}
|
3743
|
-
if (this
|
3771
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
3772
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
3773
|
+
}
|
3774
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
3744
3775
|
const ctx = this._getOrReturnCtx(input);
|
3745
3776
|
const expectedValues = this._def.values;
|
3746
3777
|
addIssueToContext(ctx, {
|
@@ -3776,9 +3807,26 @@ var init_lib = __esm({
|
|
3776
3807
|
}
|
3777
3808
|
return enumValues;
|
3778
3809
|
}
|
3810
|
+
extract(values, newDef = this._def) {
|
3811
|
+
return _ZodEnum.create(values, {
|
3812
|
+
...this._def,
|
3813
|
+
...newDef
|
3814
|
+
});
|
3815
|
+
}
|
3816
|
+
exclude(values, newDef = this._def) {
|
3817
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
3818
|
+
...this._def,
|
3819
|
+
...newDef
|
3820
|
+
});
|
3821
|
+
}
|
3779
3822
|
};
|
3823
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
3780
3824
|
ZodEnum.create = createZodEnum;
|
3781
3825
|
ZodNativeEnum = class extends ZodType {
|
3826
|
+
constructor() {
|
3827
|
+
super(...arguments);
|
3828
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
3829
|
+
}
|
3782
3830
|
_parse(input) {
|
3783
3831
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
3784
3832
|
const ctx = this._getOrReturnCtx(input);
|
@@ -3791,7 +3839,10 @@ var init_lib = __esm({
|
|
3791
3839
|
});
|
3792
3840
|
return INVALID;
|
3793
3841
|
}
|
3794
|
-
if (
|
3842
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
3843
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
3844
|
+
}
|
3845
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
3795
3846
|
const expectedValues = util.objectValues(nativeEnumValues);
|
3796
3847
|
addIssueToContext(ctx, {
|
3797
3848
|
received: ctx.data,
|
@@ -3806,6 +3857,7 @@ var init_lib = __esm({
|
|
3806
3857
|
return this._def.values;
|
3807
3858
|
}
|
3808
3859
|
};
|
3860
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
3809
3861
|
ZodNativeEnum.create = (values, params) => {
|
3810
3862
|
return new ZodNativeEnum({
|
3811
3863
|
values,
|
@@ -3814,6 +3866,9 @@ var init_lib = __esm({
|
|
3814
3866
|
});
|
3815
3867
|
};
|
3816
3868
|
ZodPromise = class extends ZodType {
|
3869
|
+
unwrap() {
|
3870
|
+
return this._def.type;
|
3871
|
+
}
|
3817
3872
|
_parse(input) {
|
3818
3873
|
const { ctx } = this._processInputParams(input);
|
3819
3874
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
@@ -3850,24 +3905,6 @@ var init_lib = __esm({
|
|
3850
3905
|
_parse(input) {
|
3851
3906
|
const { status, ctx } = this._processInputParams(input);
|
3852
3907
|
const effect = this._def.effect || null;
|
3853
|
-
if (effect.type === "preprocess") {
|
3854
|
-
const processed = effect.transform(ctx.data);
|
3855
|
-
if (ctx.common.async) {
|
3856
|
-
return Promise.resolve(processed).then((processed2) => {
|
3857
|
-
return this._def.schema._parseAsync({
|
3858
|
-
data: processed2,
|
3859
|
-
path: ctx.path,
|
3860
|
-
parent: ctx
|
3861
|
-
});
|
3862
|
-
});
|
3863
|
-
} else {
|
3864
|
-
return this._def.schema._parseSync({
|
3865
|
-
data: processed,
|
3866
|
-
path: ctx.path,
|
3867
|
-
parent: ctx
|
3868
|
-
});
|
3869
|
-
}
|
3870
|
-
}
|
3871
3908
|
const checkCtx = {
|
3872
3909
|
addIssue: (arg) => {
|
3873
3910
|
addIssueToContext(ctx, arg);
|
@@ -3882,6 +3919,42 @@ var init_lib = __esm({
|
|
3882
3919
|
}
|
3883
3920
|
};
|
3884
3921
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
3922
|
+
if (effect.type === "preprocess") {
|
3923
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
3924
|
+
if (ctx.common.async) {
|
3925
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
3926
|
+
if (status.value === "aborted")
|
3927
|
+
return INVALID;
|
3928
|
+
const result = await this._def.schema._parseAsync({
|
3929
|
+
data: processed2,
|
3930
|
+
path: ctx.path,
|
3931
|
+
parent: ctx
|
3932
|
+
});
|
3933
|
+
if (result.status === "aborted")
|
3934
|
+
return INVALID;
|
3935
|
+
if (result.status === "dirty")
|
3936
|
+
return DIRTY(result.value);
|
3937
|
+
if (status.value === "dirty")
|
3938
|
+
return DIRTY(result.value);
|
3939
|
+
return result;
|
3940
|
+
});
|
3941
|
+
} else {
|
3942
|
+
if (status.value === "aborted")
|
3943
|
+
return INVALID;
|
3944
|
+
const result = this._def.schema._parseSync({
|
3945
|
+
data: processed,
|
3946
|
+
path: ctx.path,
|
3947
|
+
parent: ctx
|
3948
|
+
});
|
3949
|
+
if (result.status === "aborted")
|
3950
|
+
return INVALID;
|
3951
|
+
if (result.status === "dirty")
|
3952
|
+
return DIRTY(result.value);
|
3953
|
+
if (status.value === "dirty")
|
3954
|
+
return DIRTY(result.value);
|
3955
|
+
return result;
|
3956
|
+
}
|
3957
|
+
}
|
3885
3958
|
if (effect.type === "refinement") {
|
3886
3959
|
const executeRefinement = (acc) => {
|
3887
3960
|
const result = effect.refinement(acc, checkCtx);
|
@@ -4024,26 +4097,45 @@ var init_lib = __esm({
|
|
4024
4097
|
ZodCatch = class extends ZodType {
|
4025
4098
|
_parse(input) {
|
4026
4099
|
const { ctx } = this._processInputParams(input);
|
4100
|
+
const newCtx = {
|
4101
|
+
...ctx,
|
4102
|
+
common: {
|
4103
|
+
...ctx.common,
|
4104
|
+
issues: []
|
4105
|
+
}
|
4106
|
+
};
|
4027
4107
|
const result = this._def.innerType._parse({
|
4028
|
-
data:
|
4029
|
-
path:
|
4030
|
-
parent:
|
4108
|
+
data: newCtx.data,
|
4109
|
+
path: newCtx.path,
|
4110
|
+
parent: {
|
4111
|
+
...newCtx
|
4112
|
+
}
|
4031
4113
|
});
|
4032
4114
|
if (isAsync(result)) {
|
4033
4115
|
return result.then((result2) => {
|
4034
4116
|
return {
|
4035
4117
|
status: "valid",
|
4036
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
4118
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
4119
|
+
get error() {
|
4120
|
+
return new ZodError(newCtx.common.issues);
|
4121
|
+
},
|
4122
|
+
input: newCtx.data
|
4123
|
+
})
|
4037
4124
|
};
|
4038
4125
|
});
|
4039
4126
|
} else {
|
4040
4127
|
return {
|
4041
4128
|
status: "valid",
|
4042
|
-
value: result.status === "valid" ? result.value : this._def.
|
4129
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
4130
|
+
get error() {
|
4131
|
+
return new ZodError(newCtx.common.issues);
|
4132
|
+
},
|
4133
|
+
input: newCtx.data
|
4134
|
+
})
|
4043
4135
|
};
|
4044
4136
|
}
|
4045
4137
|
}
|
4046
|
-
|
4138
|
+
removeCatch() {
|
4047
4139
|
return this._def.innerType;
|
4048
4140
|
}
|
4049
4141
|
};
|
@@ -4051,7 +4143,7 @@ var init_lib = __esm({
|
|
4051
4143
|
return new ZodCatch({
|
4052
4144
|
innerType: type,
|
4053
4145
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
4054
|
-
|
4146
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
4055
4147
|
...processCreateParams(params)
|
4056
4148
|
});
|
4057
4149
|
};
|
@@ -4146,6 +4238,28 @@ var init_lib = __esm({
|
|
4146
4238
|
});
|
4147
4239
|
}
|
4148
4240
|
};
|
4241
|
+
ZodReadonly = class extends ZodType {
|
4242
|
+
_parse(input) {
|
4243
|
+
const result = this._def.innerType._parse(input);
|
4244
|
+
const freeze = (data) => {
|
4245
|
+
if (isValid(data)) {
|
4246
|
+
data.value = Object.freeze(data.value);
|
4247
|
+
}
|
4248
|
+
return data;
|
4249
|
+
};
|
4250
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
4251
|
+
}
|
4252
|
+
unwrap() {
|
4253
|
+
return this._def.innerType;
|
4254
|
+
}
|
4255
|
+
};
|
4256
|
+
ZodReadonly.create = (type, params) => {
|
4257
|
+
return new ZodReadonly({
|
4258
|
+
innerType: type,
|
4259
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
4260
|
+
...processCreateParams(params)
|
4261
|
+
});
|
4262
|
+
};
|
4149
4263
|
late = {
|
4150
4264
|
object: ZodObject.lazycreate
|
4151
4265
|
};
|
@@ -4185,6 +4299,7 @@ var init_lib = __esm({
|
|
4185
4299
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
4186
4300
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
4187
4301
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
4302
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
4188
4303
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
4189
4304
|
stringType = ZodString.create;
|
4190
4305
|
numberType = ZodNumber.create;
|
@@ -4384,7 +4499,7 @@ var init_mysqlSchema = __esm({
|
|
4384
4499
|
});
|
4385
4500
|
|
4386
4501
|
// src/serializer/pgSchema.ts
|
4387
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
4502
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
4388
4503
|
var init_pgSchema = __esm({
|
4389
4504
|
"src/serializer/pgSchema.ts"() {
|
4390
4505
|
"use strict";
|
@@ -4452,10 +4567,48 @@ var init_pgSchema = __esm({
|
|
4452
4567
|
tables: recordType(stringType(), tableV1),
|
4453
4568
|
enums: recordType(stringType(), enumSchemaV1)
|
4454
4569
|
}).strict();
|
4570
|
+
indexColumn = objectType({
|
4571
|
+
expression: stringType(),
|
4572
|
+
isExpression: booleanType(),
|
4573
|
+
asc: booleanType(),
|
4574
|
+
nulls: stringType().optional(),
|
4575
|
+
opclass: stringType().optional()
|
4576
|
+
});
|
4455
4577
|
index2 = objectType({
|
4578
|
+
name: stringType(),
|
4579
|
+
columns: indexColumn.array(),
|
4580
|
+
isUnique: booleanType(),
|
4581
|
+
with: recordType(stringType(), anyType()).optional(),
|
4582
|
+
method: stringType().default("btree"),
|
4583
|
+
where: stringType().optional(),
|
4584
|
+
concurrently: booleanType().default(false)
|
4585
|
+
}).strict();
|
4586
|
+
indexV4 = objectType({
|
4456
4587
|
name: stringType(),
|
4457
4588
|
columns: stringType().array(),
|
4458
|
-
isUnique: booleanType()
|
4589
|
+
isUnique: booleanType(),
|
4590
|
+
with: recordType(stringType(), stringType()).optional(),
|
4591
|
+
method: stringType().default("btree"),
|
4592
|
+
where: stringType().optional(),
|
4593
|
+
concurrently: booleanType().default(false)
|
4594
|
+
}).strict();
|
4595
|
+
indexV5 = objectType({
|
4596
|
+
name: stringType(),
|
4597
|
+
columns: stringType().array(),
|
4598
|
+
isUnique: booleanType(),
|
4599
|
+
with: recordType(stringType(), stringType()).optional(),
|
4600
|
+
method: stringType().default("btree"),
|
4601
|
+
where: stringType().optional(),
|
4602
|
+
concurrently: booleanType().default(false)
|
4603
|
+
}).strict();
|
4604
|
+
indexV6 = objectType({
|
4605
|
+
name: stringType(),
|
4606
|
+
columns: stringType().array(),
|
4607
|
+
isUnique: booleanType(),
|
4608
|
+
with: recordType(stringType(), stringType()).optional(),
|
4609
|
+
method: stringType().default("btree"),
|
4610
|
+
where: stringType().optional(),
|
4611
|
+
concurrently: booleanType().default(false)
|
4459
4612
|
}).strict();
|
4460
4613
|
fk2 = objectType({
|
4461
4614
|
name: stringType(),
|
@@ -4497,9 +4650,27 @@ var init_pgSchema = __esm({
|
|
4497
4650
|
name: stringType(),
|
4498
4651
|
schema: stringType(),
|
4499
4652
|
columns: recordType(stringType(), column2),
|
4500
|
-
indexes: recordType(stringType(),
|
4653
|
+
indexes: recordType(stringType(), indexV4),
|
4501
4654
|
foreignKeys: recordType(stringType(), fk2)
|
4502
4655
|
}).strict();
|
4656
|
+
tableV6 = objectType({
|
4657
|
+
name: stringType(),
|
4658
|
+
schema: stringType(),
|
4659
|
+
columns: recordType(stringType(), column2),
|
4660
|
+
indexes: recordType(stringType(), indexV6),
|
4661
|
+
foreignKeys: recordType(stringType(), fk2),
|
4662
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
4663
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
4664
|
+
}).strict();
|
4665
|
+
tableV5 = objectType({
|
4666
|
+
name: stringType(),
|
4667
|
+
schema: stringType(),
|
4668
|
+
columns: recordType(stringType(), column2),
|
4669
|
+
indexes: recordType(stringType(), indexV5),
|
4670
|
+
foreignKeys: recordType(stringType(), fk2),
|
4671
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
4672
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
4673
|
+
}).strict();
|
4503
4674
|
table2 = objectType({
|
4504
4675
|
name: stringType(),
|
4505
4676
|
schema: stringType(),
|
@@ -4544,7 +4715,7 @@ var init_pgSchema = __esm({
|
|
4544
4715
|
pgSchemaInternalV5 = objectType({
|
4545
4716
|
version: literalType("5"),
|
4546
4717
|
dialect: literalType("pg"),
|
4547
|
-
tables: recordType(stringType(),
|
4718
|
+
tables: recordType(stringType(), tableV5),
|
4548
4719
|
enums: recordType(stringType(), enumSchemaV1),
|
4549
4720
|
schemas: recordType(stringType(), stringType()),
|
4550
4721
|
_meta: objectType({
|
@@ -4554,6 +4725,19 @@ var init_pgSchema = __esm({
|
|
4554
4725
|
}),
|
4555
4726
|
internal: kitInternals2
|
4556
4727
|
}).strict();
|
4728
|
+
pgSchemaInternalV6 = objectType({
|
4729
|
+
version: literalType("6"),
|
4730
|
+
dialect: literalType("postgresql"),
|
4731
|
+
tables: recordType(stringType(), tableV6),
|
4732
|
+
enums: recordType(stringType(), enumSchema),
|
4733
|
+
schemas: recordType(stringType(), stringType()),
|
4734
|
+
_meta: objectType({
|
4735
|
+
schemas: recordType(stringType(), stringType()),
|
4736
|
+
tables: recordType(stringType(), stringType()),
|
4737
|
+
columns: recordType(stringType(), stringType())
|
4738
|
+
}),
|
4739
|
+
internal: kitInternals2
|
4740
|
+
}).strict();
|
4557
4741
|
pgSchemaExternal = objectType({
|
4558
4742
|
version: literalType("5"),
|
4559
4743
|
dialect: literalType("pg"),
|
@@ -4567,7 +4751,7 @@ var init_pgSchema = __esm({
|
|
4567
4751
|
})
|
4568
4752
|
}).strict();
|
4569
4753
|
pgSchemaInternal = objectType({
|
4570
|
-
version: literalType("
|
4754
|
+
version: literalType("7"),
|
4571
4755
|
dialect: literalType("postgresql"),
|
4572
4756
|
tables: recordType(stringType(), table2),
|
4573
4757
|
enums: recordType(stringType(), enumSchema),
|
@@ -4602,18 +4786,30 @@ var init_pgSchema = __esm({
|
|
4602
4786
|
enums: recordType(stringType(), enumSchemaV1),
|
4603
4787
|
schemas: recordType(stringType(), stringType())
|
4604
4788
|
}).strict();
|
4605
|
-
|
4789
|
+
pgSchemaSquashedV6 = objectType({
|
4606
4790
|
version: literalType("6"),
|
4607
4791
|
dialect: literalType("postgresql"),
|
4608
4792
|
tables: recordType(stringType(), tableSquashed2),
|
4609
4793
|
enums: recordType(stringType(), enumSchema),
|
4610
4794
|
schemas: recordType(stringType(), stringType())
|
4611
4795
|
}).strict();
|
4796
|
+
pgSchemaSquashed = objectType({
|
4797
|
+
version: literalType("7"),
|
4798
|
+
dialect: literalType("postgresql"),
|
4799
|
+
tables: recordType(stringType(), tableSquashed2),
|
4800
|
+
enums: recordType(stringType(), enumSchema),
|
4801
|
+
schemas: recordType(stringType(), stringType())
|
4802
|
+
}).strict();
|
4612
4803
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
4613
4804
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
4614
4805
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
4806
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
4615
4807
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
4616
|
-
backwardCompatiblePgSchema = unionType([
|
4808
|
+
backwardCompatiblePgSchema = unionType([
|
4809
|
+
pgSchemaV5,
|
4810
|
+
pgSchemaV6,
|
4811
|
+
pgSchema2
|
4812
|
+
]);
|
4617
4813
|
dryPg = pgSchema2.parse({
|
4618
4814
|
version: snapshotVersion,
|
4619
4815
|
dialect: "postgresql",
|
@@ -4764,7 +4960,6 @@ var init_utils = __esm({
|
|
4764
4960
|
init_mysqlSchema();
|
4765
4961
|
init_pgSchema();
|
4766
4962
|
init_sqliteSchema();
|
4767
|
-
init_source();
|
4768
4963
|
init_global();
|
4769
4964
|
}
|
4770
4965
|
});
|
@@ -4774,7 +4969,6 @@ var import_hanji;
|
|
4774
4969
|
var init_views = __esm({
|
4775
4970
|
"src/cli/views.ts"() {
|
4776
4971
|
"use strict";
|
4777
|
-
init_source();
|
4778
4972
|
import_hanji = __toESM(require_hanji());
|
4779
4973
|
init_utils();
|
4780
4974
|
}
|
@@ -4785,7 +4979,6 @@ import * as glob from "glob";
|
|
4785
4979
|
var init_serializer = __esm({
|
4786
4980
|
"src/serializer/index.ts"() {
|
4787
4981
|
"use strict";
|
4788
|
-
init_source();
|
4789
4982
|
init_views();
|
4790
4983
|
}
|
4791
4984
|
});
|
@@ -4794,7 +4987,6 @@ var init_serializer = __esm({
|
|
4794
4987
|
var init_outputs = __esm({
|
4795
4988
|
"src/cli/validations/outputs.ts"() {
|
4796
4989
|
"use strict";
|
4797
|
-
init_source();
|
4798
4990
|
}
|
4799
4991
|
});
|
4800
4992
|
|
@@ -4853,7 +5045,6 @@ var init_sqliteSerializer = __esm({
|
|
4853
5045
|
"use strict";
|
4854
5046
|
init_serializer();
|
4855
5047
|
init_outputs();
|
4856
|
-
init_source();
|
4857
5048
|
dialect3 = new SQLiteSyncDialect();
|
4858
5049
|
fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
4859
5050
|
const result = {};
|
@@ -5263,6 +5454,13 @@ var require_brace_expansion = __commonJS({
|
|
5263
5454
|
}
|
5264
5455
|
});
|
5265
5456
|
|
5457
|
+
// src/extensions/vector.ts
|
5458
|
+
var init_vector = __esm({
|
5459
|
+
"src/extensions/vector.ts"() {
|
5460
|
+
"use strict";
|
5461
|
+
}
|
5462
|
+
});
|
5463
|
+
|
5266
5464
|
// src/serializer/pgSerializer.ts
|
5267
5465
|
import {
|
5268
5466
|
PgDialect,
|
@@ -5276,8 +5474,8 @@ var init_pgSerializer = __esm({
|
|
5276
5474
|
"src/serializer/pgSerializer.ts"() {
|
5277
5475
|
"use strict";
|
5278
5476
|
init_serializer();
|
5279
|
-
init_source();
|
5280
5477
|
init_outputs();
|
5478
|
+
init_vector();
|
5281
5479
|
dialect4 = new PgDialect();
|
5282
5480
|
trimChar = (str, char) => {
|
5283
5481
|
let start = 0;
|
@@ -5539,7 +5737,10 @@ var init_pgSerializer = __esm({
|
|
5539
5737
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5540
5738
|
columnToReturn[columnName] = {
|
5541
5739
|
name: columnName,
|
5542
|
-
type:
|
5740
|
+
type: (
|
5741
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
5742
|
+
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
5743
|
+
),
|
5543
5744
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5544
5745
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5545
5746
|
// default: isSerial ? undefined : defaultValue,
|
@@ -5550,15 +5751,42 @@ var init_pgSerializer = __esm({
|
|
5550
5751
|
}
|
5551
5752
|
}
|
5552
5753
|
const dbIndexes = await db.query(
|
5553
|
-
`SELECT t.relname
|
5554
|
-
|
5555
|
-
|
5556
|
-
|
5557
|
-
|
5558
|
-
|
5559
|
-
|
5560
|
-
|
5561
|
-
|
5754
|
+
`SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
|
5755
|
+
k.i AS index_order,
|
5756
|
+
i.indisunique as is_unique,
|
5757
|
+
am.amname as method,
|
5758
|
+
ic.reloptions as with,
|
5759
|
+
coalesce(a.attname,
|
5760
|
+
(('{' || pg_get_expr(
|
5761
|
+
i.indexprs,
|
5762
|
+
i.indrelid
|
5763
|
+
)
|
5764
|
+
|| '}')::text[]
|
5765
|
+
)[k.i]
|
5766
|
+
) AS column_name,
|
5767
|
+
CASE
|
5768
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
5769
|
+
ELSE 0
|
5770
|
+
END AS is_expression,
|
5771
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
5772
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
5773
|
+
pg_get_expr(
|
5774
|
+
i.indpred,
|
5775
|
+
i.indrelid
|
5776
|
+
) as where,
|
5777
|
+
opc.opcname
|
5778
|
+
FROM pg_class t
|
5779
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
5780
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
5781
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
5782
|
+
LEFT JOIN pg_attribute AS a
|
5783
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
5784
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
5785
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
5786
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
5787
|
+
WHERE
|
5788
|
+
c.nspname = '${tableSchema}' AND
|
5789
|
+
t.relname = '${tableName}';`
|
5562
5790
|
);
|
5563
5791
|
const dbIndexFromConstraint = await db.query(
|
5564
5792
|
`SELECT
|
@@ -5575,18 +5803,51 @@ var init_pgSerializer = __esm({
|
|
5575
5803
|
);
|
5576
5804
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
5577
5805
|
for (const dbIndex of dbIndexes) {
|
5578
|
-
const indexName = dbIndex.
|
5806
|
+
const indexName = dbIndex.indexname;
|
5579
5807
|
const indexColumnName = dbIndex.column_name;
|
5580
5808
|
const indexIsUnique = dbIndex.is_unique;
|
5809
|
+
const indexMethod = dbIndex.method;
|
5810
|
+
const indexWith = dbIndex.with;
|
5811
|
+
const indexWhere = dbIndex.where;
|
5812
|
+
const opclass = dbIndex.opcname;
|
5813
|
+
const isExpression = dbIndex.is_expression === 1;
|
5814
|
+
const desc = dbIndex.descending;
|
5815
|
+
const nullsFirst = dbIndex.nulls_first;
|
5816
|
+
const mappedWith = {};
|
5817
|
+
if (indexWith !== null) {
|
5818
|
+
indexWith.forEach((it) => {
|
5819
|
+
const splitted = it.split("=");
|
5820
|
+
mappedWith[splitted[0]] = splitted[1];
|
5821
|
+
});
|
5822
|
+
}
|
5581
5823
|
if (idxsInConsteraint.includes(indexName))
|
5582
5824
|
continue;
|
5583
5825
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
5584
|
-
indexToReturn[indexName].columns.push(
|
5826
|
+
indexToReturn[indexName].columns.push({
|
5827
|
+
expression: indexColumnName,
|
5828
|
+
asc: !desc,
|
5829
|
+
nulls: nullsFirst ? "first" : "last",
|
5830
|
+
opclass,
|
5831
|
+
isExpression
|
5832
|
+
});
|
5585
5833
|
} else {
|
5586
5834
|
indexToReturn[indexName] = {
|
5587
5835
|
name: indexName,
|
5588
|
-
columns: [
|
5589
|
-
|
5836
|
+
columns: [
|
5837
|
+
{
|
5838
|
+
expression: indexColumnName,
|
5839
|
+
asc: !desc,
|
5840
|
+
nulls: nullsFirst ? "first" : "last",
|
5841
|
+
opclass,
|
5842
|
+
isExpression
|
5843
|
+
}
|
5844
|
+
],
|
5845
|
+
isUnique: indexIsUnique,
|
5846
|
+
// should not be a part of diff detecs
|
5847
|
+
concurrently: false,
|
5848
|
+
method: indexMethod,
|
5849
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
5850
|
+
with: mappedWith
|
5590
5851
|
};
|
5591
5852
|
}
|
5592
5853
|
}
|
@@ -5622,7 +5883,7 @@ var init_pgSerializer = __esm({
|
|
5622
5883
|
}
|
5623
5884
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
5624
5885
|
return {
|
5625
|
-
version: "
|
5886
|
+
version: "7",
|
5626
5887
|
dialect: "postgresql",
|
5627
5888
|
tables: result,
|
5628
5889
|
enums: enumsToReturn,
|
@@ -5994,10 +6255,10 @@ Array.prototype.random = function() {
|
|
5994
6255
|
return this[~~(Math.random() * this.length)];
|
5995
6256
|
};
|
5996
6257
|
|
5997
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6258
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
5998
6259
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
5999
6260
|
|
6000
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6261
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
|
6001
6262
|
var posixClasses = {
|
6002
6263
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
6003
6264
|
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
@@ -6107,17 +6368,17 @@ var parseClass = (glob2, position) => {
|
|
6107
6368
|
return [comb, uflag, endPos - pos, true];
|
6108
6369
|
};
|
6109
6370
|
|
6110
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6371
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
|
6111
6372
|
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6112
6373
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
6113
6374
|
};
|
6114
6375
|
|
6115
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6376
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
|
6116
6377
|
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
6117
6378
|
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
6118
6379
|
};
|
6119
6380
|
|
6120
|
-
// node_modules/.pnpm/minimatch@7.4.
|
6381
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
6121
6382
|
var minimatch = (p, pattern, options = {}) => {
|
6122
6383
|
assertValidPattern(pattern);
|
6123
6384
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|