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