drizzle-kit 0.20.17-615c551 → 0.20.17-76a18b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/utils.d.ts +0 -1
- package/bin.cjs +18632 -45491
- package/cli/commands/migrate.d.ts +41 -41
- package/cli/commands/mysqlIntrospect.d.ts +8 -8
- package/cli/commands/pgIntrospect.d.ts +8 -8
- package/cli/commands/sqliteIntrospect.d.ts +12 -12
- package/cli/commands/utils.d.ts +2 -2
- package/cli/validations/cli.d.ts +31 -31
- package/cli/validations/common.d.ts +35 -35
- package/cli/validations/mysql.d.ts +4 -4
- package/cli/validations/outputs.d.ts +2 -2
- package/cli/validations/pg.d.ts +4 -19
- package/cli/views.d.ts +0 -1
- package/index.d.mts +51 -5
- package/index.d.ts +51 -5
- package/package.json +1 -3
- package/payload.js +1090 -494
- package/payload.mjs +897 -301
- package/schemaValidator.d.ts +222 -222
- package/serializer/mysqlSchema.d.ts +892 -892
- package/serializer/pgSchema.d.ts +749 -749
- package/serializer/sqliteSchema.d.ts +457 -457
- package/serializer/studio.d.ts +1 -1
- package/snapshotsDiffer.d.ts +316 -315
- package/utils-studio.js +932 -829
- package/utils-studio.mjs +905 -802
- package/utils.js +844 -219
- package/utils.mjs +819 -194
package/payload.mjs
CHANGED
|
@@ -40,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
40
|
));
|
|
41
41
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
42
|
|
|
43
|
-
// node_modules/.pnpm/chalk@5.
|
|
43
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
44
44
|
function assembleStyles() {
|
|
45
45
|
const codes = /* @__PURE__ */ new Map();
|
|
46
46
|
for (const [groupName, group] of Object.entries(styles)) {
|
|
@@ -157,7 +157,7 @@ function assembleStyles() {
|
|
|
157
157
|
}
|
|
158
158
|
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
|
159
159
|
var init_ansi_styles = __esm({
|
|
160
|
-
"node_modules/.pnpm/chalk@5.
|
|
160
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
|
161
161
|
ANSI_BACKGROUND_OFFSET = 10;
|
|
162
162
|
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
163
163
|
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
@@ -231,7 +231,7 @@ var init_ansi_styles = __esm({
|
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
// node_modules/.pnpm/chalk@5.
|
|
234
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
|
|
235
235
|
import process2 from "node:process";
|
|
236
236
|
import os from "node:os";
|
|
237
237
|
import tty from "node:tty";
|
|
@@ -298,7 +298,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
298
298
|
return 1;
|
|
299
299
|
}
|
|
300
300
|
if ("CI" in env) {
|
|
301
|
-
if ("GITHUB_ACTIONS" in env) {
|
|
301
|
+
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
|
|
302
302
|
return 3;
|
|
303
303
|
}
|
|
304
304
|
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
@@ -346,7 +346,7 @@ function createSupportsColor(stream, options = {}) {
|
|
|
346
346
|
}
|
|
347
347
|
var env, flagForceColor, supportsColor, supports_color_default;
|
|
348
348
|
var init_supports_color = __esm({
|
|
349
|
-
"node_modules/.pnpm/chalk@5.
|
|
349
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
|
350
350
|
({ env } = process2);
|
|
351
351
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
352
352
|
flagForceColor = 0;
|
|
@@ -361,7 +361,7 @@ var init_supports_color = __esm({
|
|
|
361
361
|
}
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
-
// node_modules/.pnpm/chalk@5.
|
|
364
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
|
365
365
|
function stringReplaceAll(string, substring, replacer) {
|
|
366
366
|
let index4 = string.indexOf(substring);
|
|
367
367
|
if (index4 === -1) {
|
|
@@ -391,21 +391,20 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
|
|
391
391
|
return returnValue;
|
|
392
392
|
}
|
|
393
393
|
var init_utilities = __esm({
|
|
394
|
-
"node_modules/.pnpm/chalk@5.
|
|
394
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
|
|
395
395
|
}
|
|
396
396
|
});
|
|
397
397
|
|
|
398
|
-
// node_modules/.pnpm/chalk@5.
|
|
398
|
+
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
|
|
399
399
|
function createChalk(options) {
|
|
400
400
|
return chalkFactory(options);
|
|
401
401
|
}
|
|
402
402
|
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
|
|
403
403
|
var init_source = __esm({
|
|
404
|
-
"node_modules/.pnpm/chalk@5.
|
|
404
|
+
"node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js"() {
|
|
405
405
|
init_ansi_styles();
|
|
406
406
|
init_supports_color();
|
|
407
407
|
init_utilities();
|
|
408
|
-
init_ansi_styles();
|
|
409
408
|
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
|
410
409
|
GENERATOR = Symbol("GENERATOR");
|
|
411
410
|
STYLER = Symbol("STYLER");
|
|
@@ -1116,11 +1115,12 @@ var init_global = __esm({
|
|
|
1116
1115
|
}
|
|
1117
1116
|
});
|
|
1118
1117
|
|
|
1119
|
-
// node_modules/.pnpm/zod@3.
|
|
1118
|
+
// node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs
|
|
1120
1119
|
function getErrorMap() {
|
|
1121
1120
|
return overrideErrorMap;
|
|
1122
1121
|
}
|
|
1123
1122
|
function addIssueToContext(ctx, issueData) {
|
|
1123
|
+
const overrideMap = getErrorMap();
|
|
1124
1124
|
const issue = makeIssue({
|
|
1125
1125
|
issueData,
|
|
1126
1126
|
data: ctx.data,
|
|
@@ -1128,13 +1128,29 @@ function addIssueToContext(ctx, issueData) {
|
|
|
1128
1128
|
errorMaps: [
|
|
1129
1129
|
ctx.common.contextualErrorMap,
|
|
1130
1130
|
ctx.schemaErrorMap,
|
|
1131
|
-
|
|
1132
|
-
errorMap
|
|
1131
|
+
overrideMap,
|
|
1132
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
1133
1133
|
// then global default map
|
|
1134
1134
|
].filter((x) => !!x)
|
|
1135
1135
|
});
|
|
1136
1136
|
ctx.common.issues.push(issue);
|
|
1137
1137
|
}
|
|
1138
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
1139
|
+
if (kind === "a" && !f)
|
|
1140
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
1141
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1142
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1143
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1144
|
+
}
|
|
1145
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
1146
|
+
if (kind === "m")
|
|
1147
|
+
throw new TypeError("Private method is not writable");
|
|
1148
|
+
if (kind === "a" && !f)
|
|
1149
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
1150
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1151
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1152
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1153
|
+
}
|
|
1138
1154
|
function processCreateParams(params) {
|
|
1139
1155
|
if (!params)
|
|
1140
1156
|
return {};
|
|
@@ -1145,15 +1161,50 @@ function processCreateParams(params) {
|
|
|
1145
1161
|
if (errorMap2)
|
|
1146
1162
|
return { errorMap: errorMap2, description };
|
|
1147
1163
|
const customMap = (iss, ctx) => {
|
|
1148
|
-
|
|
1149
|
-
|
|
1164
|
+
var _a, _b;
|
|
1165
|
+
const { message } = params;
|
|
1166
|
+
if (iss.code === "invalid_enum_value") {
|
|
1167
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
1168
|
+
}
|
|
1150
1169
|
if (typeof ctx.data === "undefined") {
|
|
1151
|
-
return { message:
|
|
1170
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
1152
1171
|
}
|
|
1153
|
-
|
|
1172
|
+
if (iss.code !== "invalid_type")
|
|
1173
|
+
return { message: ctx.defaultError };
|
|
1174
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
1154
1175
|
};
|
|
1155
1176
|
return { errorMap: customMap, description };
|
|
1156
1177
|
}
|
|
1178
|
+
function timeRegexSource(args) {
|
|
1179
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1180
|
+
if (args.precision) {
|
|
1181
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1182
|
+
} else if (args.precision == null) {
|
|
1183
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1184
|
+
}
|
|
1185
|
+
return regex;
|
|
1186
|
+
}
|
|
1187
|
+
function timeRegex(args) {
|
|
1188
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1189
|
+
}
|
|
1190
|
+
function datetimeRegex(args) {
|
|
1191
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1192
|
+
const opts = [];
|
|
1193
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1194
|
+
if (args.offset)
|
|
1195
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1196
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1197
|
+
return new RegExp(`^${regex}$`);
|
|
1198
|
+
}
|
|
1199
|
+
function isValidIP(ip, version) {
|
|
1200
|
+
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1201
|
+
return true;
|
|
1202
|
+
}
|
|
1203
|
+
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
|
1204
|
+
return true;
|
|
1205
|
+
}
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1157
1208
|
function floatSafeRemainder(val, step) {
|
|
1158
1209
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1159
1210
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
@@ -1174,7 +1225,10 @@ function deepPartialify(schema4) {
|
|
|
1174
1225
|
shape: () => newShape
|
|
1175
1226
|
});
|
|
1176
1227
|
} else if (schema4 instanceof ZodArray) {
|
|
1177
|
-
return ZodArray
|
|
1228
|
+
return new ZodArray({
|
|
1229
|
+
...schema4._def,
|
|
1230
|
+
type: deepPartialify(schema4.element)
|
|
1231
|
+
});
|
|
1178
1232
|
} else if (schema4 instanceof ZodOptional) {
|
|
1179
1233
|
return ZodOptional.create(deepPartialify(schema4.unwrap()));
|
|
1180
1234
|
} else if (schema4 instanceof ZodNullable) {
|
|
@@ -1230,9 +1284,9 @@ function createZodEnum(values, params) {
|
|
|
1230
1284
|
...processCreateParams(params)
|
|
1231
1285
|
});
|
|
1232
1286
|
}
|
|
1233
|
-
var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex,
|
|
1287
|
+
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, coerce;
|
|
1234
1288
|
var init_lib = __esm({
|
|
1235
|
-
"node_modules/.pnpm/zod@3.
|
|
1289
|
+
"node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs"() {
|
|
1236
1290
|
(function(util2) {
|
|
1237
1291
|
util2.assertEqual = (val) => val;
|
|
1238
1292
|
function assertIs(_arg) {
|
|
@@ -1290,6 +1344,15 @@ var init_lib = __esm({
|
|
|
1290
1344
|
return value;
|
|
1291
1345
|
};
|
|
1292
1346
|
})(util || (util = {}));
|
|
1347
|
+
(function(objectUtil2) {
|
|
1348
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
1349
|
+
return {
|
|
1350
|
+
...first,
|
|
1351
|
+
...second
|
|
1352
|
+
// second overwrites first
|
|
1353
|
+
};
|
|
1354
|
+
};
|
|
1355
|
+
})(objectUtil || (objectUtil = {}));
|
|
1293
1356
|
ZodParsedType = util.arrayToEnum([
|
|
1294
1357
|
"string",
|
|
1295
1358
|
"nan",
|
|
@@ -1371,7 +1434,7 @@ var init_lib = __esm({
|
|
|
1371
1434
|
"not_multiple_of",
|
|
1372
1435
|
"not_finite"
|
|
1373
1436
|
]);
|
|
1374
|
-
ZodError = class extends Error {
|
|
1437
|
+
ZodError = class _ZodError extends Error {
|
|
1375
1438
|
constructor(issues) {
|
|
1376
1439
|
super();
|
|
1377
1440
|
this.issues = [];
|
|
@@ -1429,6 +1492,11 @@ var init_lib = __esm({
|
|
|
1429
1492
|
processError(this);
|
|
1430
1493
|
return fieldErrors;
|
|
1431
1494
|
}
|
|
1495
|
+
static assert(value) {
|
|
1496
|
+
if (!(value instanceof _ZodError)) {
|
|
1497
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1432
1500
|
toString() {
|
|
1433
1501
|
return this.message;
|
|
1434
1502
|
}
|
|
@@ -1495,7 +1563,12 @@ var init_lib = __esm({
|
|
|
1495
1563
|
break;
|
|
1496
1564
|
case ZodIssueCode.invalid_string:
|
|
1497
1565
|
if (typeof issue.validation === "object") {
|
|
1498
|
-
if ("
|
|
1566
|
+
if ("includes" in issue.validation) {
|
|
1567
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
1568
|
+
if (typeof issue.validation.position === "number") {
|
|
1569
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
1570
|
+
}
|
|
1571
|
+
} else if ("startsWith" in issue.validation) {
|
|
1499
1572
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
1500
1573
|
} else if ("endsWith" in issue.validation) {
|
|
1501
1574
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
@@ -1516,7 +1589,7 @@ var init_lib = __esm({
|
|
|
1516
1589
|
else if (issue.type === "number")
|
|
1517
1590
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
1518
1591
|
else if (issue.type === "date")
|
|
1519
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
|
|
1592
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
1520
1593
|
else
|
|
1521
1594
|
message = "Invalid input";
|
|
1522
1595
|
break;
|
|
@@ -1527,8 +1600,10 @@ var init_lib = __esm({
|
|
|
1527
1600
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
1528
1601
|
else if (issue.type === "number")
|
|
1529
1602
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
1603
|
+
else if (issue.type === "bigint")
|
|
1604
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
1530
1605
|
else if (issue.type === "date")
|
|
1531
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
|
|
1606
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
1532
1607
|
else
|
|
1533
1608
|
message = "Invalid input";
|
|
1534
1609
|
break;
|
|
@@ -1558,6 +1633,13 @@ var init_lib = __esm({
|
|
|
1558
1633
|
...issueData,
|
|
1559
1634
|
path: fullPath
|
|
1560
1635
|
};
|
|
1636
|
+
if (issueData.message !== void 0) {
|
|
1637
|
+
return {
|
|
1638
|
+
...issueData,
|
|
1639
|
+
path: fullPath,
|
|
1640
|
+
message: issueData.message
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1561
1643
|
let errorMessage = "";
|
|
1562
1644
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
1563
1645
|
for (const map of maps) {
|
|
@@ -1566,7 +1648,7 @@ var init_lib = __esm({
|
|
|
1566
1648
|
return {
|
|
1567
1649
|
...issueData,
|
|
1568
1650
|
path: fullPath,
|
|
1569
|
-
message:
|
|
1651
|
+
message: errorMessage
|
|
1570
1652
|
};
|
|
1571
1653
|
};
|
|
1572
1654
|
ParseStatus = class _ParseStatus {
|
|
@@ -1595,9 +1677,11 @@ var init_lib = __esm({
|
|
|
1595
1677
|
static async mergeObjectAsync(status, pairs) {
|
|
1596
1678
|
const syncPairs = [];
|
|
1597
1679
|
for (const pair of pairs) {
|
|
1680
|
+
const key = await pair.key;
|
|
1681
|
+
const value = await pair.value;
|
|
1598
1682
|
syncPairs.push({
|
|
1599
|
-
key
|
|
1600
|
-
value
|
|
1683
|
+
key,
|
|
1684
|
+
value
|
|
1601
1685
|
});
|
|
1602
1686
|
}
|
|
1603
1687
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -1614,7 +1698,7 @@ var init_lib = __esm({
|
|
|
1614
1698
|
status.dirty();
|
|
1615
1699
|
if (value.status === "dirty")
|
|
1616
1700
|
status.dirty();
|
|
1617
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
1701
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
1618
1702
|
finalObject[key.value] = value.value;
|
|
1619
1703
|
}
|
|
1620
1704
|
}
|
|
@@ -1629,20 +1713,28 @@ var init_lib = __esm({
|
|
|
1629
1713
|
isAborted = (x) => x.status === "aborted";
|
|
1630
1714
|
isDirty = (x) => x.status === "dirty";
|
|
1631
1715
|
isValid = (x) => x.status === "valid";
|
|
1632
|
-
isAsync = (x) => typeof Promise !==
|
|
1716
|
+
isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
1633
1717
|
(function(errorUtil2) {
|
|
1634
1718
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
1635
1719
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
1636
1720
|
})(errorUtil || (errorUtil = {}));
|
|
1637
1721
|
ParseInputLazyPath = class {
|
|
1638
1722
|
constructor(parent, value, path2, key) {
|
|
1723
|
+
this._cachedPath = [];
|
|
1639
1724
|
this.parent = parent;
|
|
1640
1725
|
this.data = value;
|
|
1641
1726
|
this._path = path2;
|
|
1642
1727
|
this._key = key;
|
|
1643
1728
|
}
|
|
1644
1729
|
get path() {
|
|
1645
|
-
|
|
1730
|
+
if (!this._cachedPath.length) {
|
|
1731
|
+
if (this._key instanceof Array) {
|
|
1732
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
1733
|
+
} else {
|
|
1734
|
+
this._cachedPath.push(...this._path, this._key);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return this._cachedPath;
|
|
1646
1738
|
}
|
|
1647
1739
|
};
|
|
1648
1740
|
handleResult = (ctx, result) => {
|
|
@@ -1652,8 +1744,16 @@ var init_lib = __esm({
|
|
|
1652
1744
|
if (!ctx.common.issues.length) {
|
|
1653
1745
|
throw new Error("Validation failed but no issues detected.");
|
|
1654
1746
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1747
|
+
return {
|
|
1748
|
+
success: false,
|
|
1749
|
+
get error() {
|
|
1750
|
+
if (this._error)
|
|
1751
|
+
return this._error;
|
|
1752
|
+
const error2 = new ZodError(ctx.common.issues);
|
|
1753
|
+
this._error = error2;
|
|
1754
|
+
return this._error;
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1657
1757
|
}
|
|
1658
1758
|
};
|
|
1659
1759
|
ZodType = class {
|
|
@@ -1681,6 +1781,7 @@ var init_lib = __esm({
|
|
|
1681
1781
|
this.catch = this.catch.bind(this);
|
|
1682
1782
|
this.describe = this.describe.bind(this);
|
|
1683
1783
|
this.pipe = this.pipe.bind(this);
|
|
1784
|
+
this.readonly = this.readonly.bind(this);
|
|
1684
1785
|
this.isNullable = this.isNullable.bind(this);
|
|
1685
1786
|
this.isOptional = this.isOptional.bind(this);
|
|
1686
1787
|
}
|
|
@@ -1825,28 +1926,29 @@ var init_lib = __esm({
|
|
|
1825
1926
|
return this._refinement(refinement);
|
|
1826
1927
|
}
|
|
1827
1928
|
optional() {
|
|
1828
|
-
return ZodOptional.create(this);
|
|
1929
|
+
return ZodOptional.create(this, this._def);
|
|
1829
1930
|
}
|
|
1830
1931
|
nullable() {
|
|
1831
|
-
return ZodNullable.create(this);
|
|
1932
|
+
return ZodNullable.create(this, this._def);
|
|
1832
1933
|
}
|
|
1833
1934
|
nullish() {
|
|
1834
|
-
return this.
|
|
1935
|
+
return this.nullable().optional();
|
|
1835
1936
|
}
|
|
1836
1937
|
array() {
|
|
1837
|
-
return ZodArray.create(this);
|
|
1938
|
+
return ZodArray.create(this, this._def);
|
|
1838
1939
|
}
|
|
1839
1940
|
promise() {
|
|
1840
|
-
return ZodPromise.create(this);
|
|
1941
|
+
return ZodPromise.create(this, this._def);
|
|
1841
1942
|
}
|
|
1842
1943
|
or(option) {
|
|
1843
|
-
return ZodUnion.create([this, option]);
|
|
1944
|
+
return ZodUnion.create([this, option], this._def);
|
|
1844
1945
|
}
|
|
1845
1946
|
and(incoming) {
|
|
1846
|
-
return ZodIntersection.create(this, incoming);
|
|
1947
|
+
return ZodIntersection.create(this, incoming, this._def);
|
|
1847
1948
|
}
|
|
1848
1949
|
transform(transform) {
|
|
1849
1950
|
return new ZodEffects({
|
|
1951
|
+
...processCreateParams(this._def),
|
|
1850
1952
|
schema: this,
|
|
1851
1953
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
1852
1954
|
effect: { type: "transform", transform }
|
|
@@ -1855,6 +1957,7 @@ var init_lib = __esm({
|
|
|
1855
1957
|
default(def) {
|
|
1856
1958
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
1857
1959
|
return new ZodDefault({
|
|
1960
|
+
...processCreateParams(this._def),
|
|
1858
1961
|
innerType: this,
|
|
1859
1962
|
defaultValue: defaultValueFunc,
|
|
1860
1963
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
@@ -1864,14 +1967,15 @@ var init_lib = __esm({
|
|
|
1864
1967
|
return new ZodBranded({
|
|
1865
1968
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
1866
1969
|
type: this,
|
|
1867
|
-
...processCreateParams(
|
|
1970
|
+
...processCreateParams(this._def)
|
|
1868
1971
|
});
|
|
1869
1972
|
}
|
|
1870
1973
|
catch(def) {
|
|
1871
|
-
const
|
|
1974
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
1872
1975
|
return new ZodCatch({
|
|
1976
|
+
...processCreateParams(this._def),
|
|
1873
1977
|
innerType: this,
|
|
1874
|
-
|
|
1978
|
+
catchValue: catchValueFunc,
|
|
1875
1979
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
1876
1980
|
});
|
|
1877
1981
|
}
|
|
@@ -1885,6 +1989,9 @@ var init_lib = __esm({
|
|
|
1885
1989
|
pipe(target) {
|
|
1886
1990
|
return ZodPipeline.create(this, target);
|
|
1887
1991
|
}
|
|
1992
|
+
readonly() {
|
|
1993
|
+
return ZodReadonly.create(this);
|
|
1994
|
+
}
|
|
1888
1995
|
isOptional() {
|
|
1889
1996
|
return this.safeParse(void 0).success;
|
|
1890
1997
|
}
|
|
@@ -1893,43 +2000,19 @@ var init_lib = __esm({
|
|
|
1893
2000
|
}
|
|
1894
2001
|
};
|
|
1895
2002
|
cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
} else {
|
|
1909
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
1910
|
-
}
|
|
1911
|
-
} else {
|
|
1912
|
-
if (args.offset) {
|
|
1913
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
|
|
1914
|
-
} else {
|
|
1915
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
};
|
|
2003
|
+
cuid2Regex = /^[0-9a-z]+$/;
|
|
2004
|
+
ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
2005
|
+
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;
|
|
2006
|
+
nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
2007
|
+
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)?)??$/;
|
|
2008
|
+
emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
2009
|
+
_emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
2010
|
+
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])$/;
|
|
2011
|
+
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})))$/;
|
|
2012
|
+
base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
2013
|
+
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])))`;
|
|
2014
|
+
dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1919
2015
|
ZodString = class _ZodString extends ZodType {
|
|
1920
|
-
constructor() {
|
|
1921
|
-
super(...arguments);
|
|
1922
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
1923
|
-
validation,
|
|
1924
|
-
code: ZodIssueCode.invalid_string,
|
|
1925
|
-
...errorUtil.errToObj(message)
|
|
1926
|
-
});
|
|
1927
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
1928
|
-
this.trim = () => new _ZodString({
|
|
1929
|
-
...this._def,
|
|
1930
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
2016
|
_parse(input) {
|
|
1934
2017
|
if (this._def.coerce) {
|
|
1935
2018
|
input.data = String(input.data);
|
|
@@ -1937,15 +2020,11 @@ var init_lib = __esm({
|
|
|
1937
2020
|
const parsedType = this._getType(input);
|
|
1938
2021
|
if (parsedType !== ZodParsedType.string) {
|
|
1939
2022
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1940
|
-
addIssueToContext(
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
received: ctx2.parsedType
|
|
1946
|
-
}
|
|
1947
|
-
//
|
|
1948
|
-
);
|
|
2023
|
+
addIssueToContext(ctx2, {
|
|
2024
|
+
code: ZodIssueCode.invalid_type,
|
|
2025
|
+
expected: ZodParsedType.string,
|
|
2026
|
+
received: ctx2.parsedType
|
|
2027
|
+
});
|
|
1949
2028
|
return INVALID;
|
|
1950
2029
|
}
|
|
1951
2030
|
const status = new ParseStatus();
|
|
@@ -2013,6 +2092,19 @@ var init_lib = __esm({
|
|
|
2013
2092
|
});
|
|
2014
2093
|
status.dirty();
|
|
2015
2094
|
}
|
|
2095
|
+
} else if (check.kind === "emoji") {
|
|
2096
|
+
if (!emojiRegex) {
|
|
2097
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
2098
|
+
}
|
|
2099
|
+
if (!emojiRegex.test(input.data)) {
|
|
2100
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2101
|
+
addIssueToContext(ctx, {
|
|
2102
|
+
validation: "emoji",
|
|
2103
|
+
code: ZodIssueCode.invalid_string,
|
|
2104
|
+
message: check.message
|
|
2105
|
+
});
|
|
2106
|
+
status.dirty();
|
|
2107
|
+
}
|
|
2016
2108
|
} else if (check.kind === "uuid") {
|
|
2017
2109
|
if (!uuidRegex.test(input.data)) {
|
|
2018
2110
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2023,6 +2115,16 @@ var init_lib = __esm({
|
|
|
2023
2115
|
});
|
|
2024
2116
|
status.dirty();
|
|
2025
2117
|
}
|
|
2118
|
+
} else if (check.kind === "nanoid") {
|
|
2119
|
+
if (!nanoidRegex.test(input.data)) {
|
|
2120
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2121
|
+
addIssueToContext(ctx, {
|
|
2122
|
+
validation: "nanoid",
|
|
2123
|
+
code: ZodIssueCode.invalid_string,
|
|
2124
|
+
message: check.message
|
|
2125
|
+
});
|
|
2126
|
+
status.dirty();
|
|
2127
|
+
}
|
|
2026
2128
|
} else if (check.kind === "cuid") {
|
|
2027
2129
|
if (!cuidRegex.test(input.data)) {
|
|
2028
2130
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2033,6 +2135,26 @@ var init_lib = __esm({
|
|
|
2033
2135
|
});
|
|
2034
2136
|
status.dirty();
|
|
2035
2137
|
}
|
|
2138
|
+
} else if (check.kind === "cuid2") {
|
|
2139
|
+
if (!cuid2Regex.test(input.data)) {
|
|
2140
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2141
|
+
addIssueToContext(ctx, {
|
|
2142
|
+
validation: "cuid2",
|
|
2143
|
+
code: ZodIssueCode.invalid_string,
|
|
2144
|
+
message: check.message
|
|
2145
|
+
});
|
|
2146
|
+
status.dirty();
|
|
2147
|
+
}
|
|
2148
|
+
} else if (check.kind === "ulid") {
|
|
2149
|
+
if (!ulidRegex.test(input.data)) {
|
|
2150
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2151
|
+
addIssueToContext(ctx, {
|
|
2152
|
+
validation: "ulid",
|
|
2153
|
+
code: ZodIssueCode.invalid_string,
|
|
2154
|
+
message: check.message
|
|
2155
|
+
});
|
|
2156
|
+
status.dirty();
|
|
2157
|
+
}
|
|
2036
2158
|
} else if (check.kind === "url") {
|
|
2037
2159
|
try {
|
|
2038
2160
|
new URL(input.data);
|
|
@@ -2059,6 +2181,20 @@ var init_lib = __esm({
|
|
|
2059
2181
|
}
|
|
2060
2182
|
} else if (check.kind === "trim") {
|
|
2061
2183
|
input.data = input.data.trim();
|
|
2184
|
+
} else if (check.kind === "includes") {
|
|
2185
|
+
if (!input.data.includes(check.value, check.position)) {
|
|
2186
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2187
|
+
addIssueToContext(ctx, {
|
|
2188
|
+
code: ZodIssueCode.invalid_string,
|
|
2189
|
+
validation: { includes: check.value, position: check.position },
|
|
2190
|
+
message: check.message
|
|
2191
|
+
});
|
|
2192
|
+
status.dirty();
|
|
2193
|
+
}
|
|
2194
|
+
} else if (check.kind === "toLowerCase") {
|
|
2195
|
+
input.data = input.data.toLowerCase();
|
|
2196
|
+
} else if (check.kind === "toUpperCase") {
|
|
2197
|
+
input.data = input.data.toUpperCase();
|
|
2062
2198
|
} else if (check.kind === "startsWith") {
|
|
2063
2199
|
if (!input.data.startsWith(check.value)) {
|
|
2064
2200
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2090,12 +2226,71 @@ var init_lib = __esm({
|
|
|
2090
2226
|
});
|
|
2091
2227
|
status.dirty();
|
|
2092
2228
|
}
|
|
2229
|
+
} else if (check.kind === "date") {
|
|
2230
|
+
const regex = dateRegex;
|
|
2231
|
+
if (!regex.test(input.data)) {
|
|
2232
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2233
|
+
addIssueToContext(ctx, {
|
|
2234
|
+
code: ZodIssueCode.invalid_string,
|
|
2235
|
+
validation: "date",
|
|
2236
|
+
message: check.message
|
|
2237
|
+
});
|
|
2238
|
+
status.dirty();
|
|
2239
|
+
}
|
|
2240
|
+
} else if (check.kind === "time") {
|
|
2241
|
+
const regex = timeRegex(check);
|
|
2242
|
+
if (!regex.test(input.data)) {
|
|
2243
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2244
|
+
addIssueToContext(ctx, {
|
|
2245
|
+
code: ZodIssueCode.invalid_string,
|
|
2246
|
+
validation: "time",
|
|
2247
|
+
message: check.message
|
|
2248
|
+
});
|
|
2249
|
+
status.dirty();
|
|
2250
|
+
}
|
|
2251
|
+
} else if (check.kind === "duration") {
|
|
2252
|
+
if (!durationRegex.test(input.data)) {
|
|
2253
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2254
|
+
addIssueToContext(ctx, {
|
|
2255
|
+
validation: "duration",
|
|
2256
|
+
code: ZodIssueCode.invalid_string,
|
|
2257
|
+
message: check.message
|
|
2258
|
+
});
|
|
2259
|
+
status.dirty();
|
|
2260
|
+
}
|
|
2261
|
+
} else if (check.kind === "ip") {
|
|
2262
|
+
if (!isValidIP(input.data, check.version)) {
|
|
2263
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2264
|
+
addIssueToContext(ctx, {
|
|
2265
|
+
validation: "ip",
|
|
2266
|
+
code: ZodIssueCode.invalid_string,
|
|
2267
|
+
message: check.message
|
|
2268
|
+
});
|
|
2269
|
+
status.dirty();
|
|
2270
|
+
}
|
|
2271
|
+
} else if (check.kind === "base64") {
|
|
2272
|
+
if (!base64Regex.test(input.data)) {
|
|
2273
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2274
|
+
addIssueToContext(ctx, {
|
|
2275
|
+
validation: "base64",
|
|
2276
|
+
code: ZodIssueCode.invalid_string,
|
|
2277
|
+
message: check.message
|
|
2278
|
+
});
|
|
2279
|
+
status.dirty();
|
|
2280
|
+
}
|
|
2093
2281
|
} else {
|
|
2094
2282
|
util.assertNever(check);
|
|
2095
2283
|
}
|
|
2096
2284
|
}
|
|
2097
2285
|
return { status: status.value, value: input.data };
|
|
2098
2286
|
}
|
|
2287
|
+
_regex(regex, validation, message) {
|
|
2288
|
+
return this.refinement((data) => regex.test(data), {
|
|
2289
|
+
validation,
|
|
2290
|
+
code: ZodIssueCode.invalid_string,
|
|
2291
|
+
...errorUtil.errToObj(message)
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2099
2294
|
_addCheck(check) {
|
|
2100
2295
|
return new _ZodString({
|
|
2101
2296
|
...this._def,
|
|
@@ -2108,19 +2303,38 @@ var init_lib = __esm({
|
|
|
2108
2303
|
url(message) {
|
|
2109
2304
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
2110
2305
|
}
|
|
2306
|
+
emoji(message) {
|
|
2307
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
2308
|
+
}
|
|
2111
2309
|
uuid(message) {
|
|
2112
2310
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
2113
2311
|
}
|
|
2312
|
+
nanoid(message) {
|
|
2313
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
2314
|
+
}
|
|
2114
2315
|
cuid(message) {
|
|
2115
2316
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
2116
2317
|
}
|
|
2318
|
+
cuid2(message) {
|
|
2319
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
2320
|
+
}
|
|
2321
|
+
ulid(message) {
|
|
2322
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
2323
|
+
}
|
|
2324
|
+
base64(message) {
|
|
2325
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
2326
|
+
}
|
|
2327
|
+
ip(options) {
|
|
2328
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
2329
|
+
}
|
|
2117
2330
|
datetime(options) {
|
|
2118
|
-
var _a;
|
|
2331
|
+
var _a, _b;
|
|
2119
2332
|
if (typeof options === "string") {
|
|
2120
2333
|
return this._addCheck({
|
|
2121
2334
|
kind: "datetime",
|
|
2122
2335
|
precision: null,
|
|
2123
2336
|
offset: false,
|
|
2337
|
+
local: false,
|
|
2124
2338
|
message: options
|
|
2125
2339
|
});
|
|
2126
2340
|
}
|
|
@@ -2128,9 +2342,30 @@ var init_lib = __esm({
|
|
|
2128
2342
|
kind: "datetime",
|
|
2129
2343
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
2130
2344
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
2345
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
2346
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
date(message) {
|
|
2350
|
+
return this._addCheck({ kind: "date", message });
|
|
2351
|
+
}
|
|
2352
|
+
time(options) {
|
|
2353
|
+
if (typeof options === "string") {
|
|
2354
|
+
return this._addCheck({
|
|
2355
|
+
kind: "time",
|
|
2356
|
+
precision: null,
|
|
2357
|
+
message: options
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
return this._addCheck({
|
|
2361
|
+
kind: "time",
|
|
2362
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
2131
2363
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
2132
2364
|
});
|
|
2133
2365
|
}
|
|
2366
|
+
duration(message) {
|
|
2367
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
2368
|
+
}
|
|
2134
2369
|
regex(regex, message) {
|
|
2135
2370
|
return this._addCheck({
|
|
2136
2371
|
kind: "regex",
|
|
@@ -2138,6 +2373,14 @@ var init_lib = __esm({
|
|
|
2138
2373
|
...errorUtil.errToObj(message)
|
|
2139
2374
|
});
|
|
2140
2375
|
}
|
|
2376
|
+
includes(value, options) {
|
|
2377
|
+
return this._addCheck({
|
|
2378
|
+
kind: "includes",
|
|
2379
|
+
value,
|
|
2380
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
|
2381
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2141
2384
|
startsWith(value, message) {
|
|
2142
2385
|
return this._addCheck({
|
|
2143
2386
|
kind: "startsWith",
|
|
@@ -2173,21 +2416,73 @@ var init_lib = __esm({
|
|
|
2173
2416
|
...errorUtil.errToObj(message)
|
|
2174
2417
|
});
|
|
2175
2418
|
}
|
|
2419
|
+
/**
|
|
2420
|
+
* @deprecated Use z.string().min(1) instead.
|
|
2421
|
+
* @see {@link ZodString.min}
|
|
2422
|
+
*/
|
|
2423
|
+
nonempty(message) {
|
|
2424
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
2425
|
+
}
|
|
2426
|
+
trim() {
|
|
2427
|
+
return new _ZodString({
|
|
2428
|
+
...this._def,
|
|
2429
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
toLowerCase() {
|
|
2433
|
+
return new _ZodString({
|
|
2434
|
+
...this._def,
|
|
2435
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
toUpperCase() {
|
|
2439
|
+
return new _ZodString({
|
|
2440
|
+
...this._def,
|
|
2441
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2176
2444
|
get isDatetime() {
|
|
2177
2445
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
2178
2446
|
}
|
|
2447
|
+
get isDate() {
|
|
2448
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
2449
|
+
}
|
|
2450
|
+
get isTime() {
|
|
2451
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
2452
|
+
}
|
|
2453
|
+
get isDuration() {
|
|
2454
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
2455
|
+
}
|
|
2179
2456
|
get isEmail() {
|
|
2180
2457
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
2181
2458
|
}
|
|
2182
2459
|
get isURL() {
|
|
2183
2460
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
2184
2461
|
}
|
|
2462
|
+
get isEmoji() {
|
|
2463
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
2464
|
+
}
|
|
2185
2465
|
get isUUID() {
|
|
2186
2466
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
2187
2467
|
}
|
|
2468
|
+
get isNANOID() {
|
|
2469
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
2470
|
+
}
|
|
2188
2471
|
get isCUID() {
|
|
2189
2472
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
2190
2473
|
}
|
|
2474
|
+
get isCUID2() {
|
|
2475
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
2476
|
+
}
|
|
2477
|
+
get isULID() {
|
|
2478
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
2479
|
+
}
|
|
2480
|
+
get isIP() {
|
|
2481
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
2482
|
+
}
|
|
2483
|
+
get isBase64() {
|
|
2484
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
2485
|
+
}
|
|
2191
2486
|
get minLength() {
|
|
2192
2487
|
let min = null;
|
|
2193
2488
|
for (const ch of this._def.checks) {
|
|
@@ -2389,6 +2684,19 @@ var init_lib = __esm({
|
|
|
2389
2684
|
message: errorUtil.toString(message)
|
|
2390
2685
|
});
|
|
2391
2686
|
}
|
|
2687
|
+
safe(message) {
|
|
2688
|
+
return this._addCheck({
|
|
2689
|
+
kind: "min",
|
|
2690
|
+
inclusive: true,
|
|
2691
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
2692
|
+
message: errorUtil.toString(message)
|
|
2693
|
+
})._addCheck({
|
|
2694
|
+
kind: "max",
|
|
2695
|
+
inclusive: true,
|
|
2696
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
2697
|
+
message: errorUtil.toString(message)
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2392
2700
|
get minValue() {
|
|
2393
2701
|
let min = null;
|
|
2394
2702
|
for (const ch of this._def.checks) {
|
|
@@ -2410,7 +2718,22 @@ var init_lib = __esm({
|
|
|
2410
2718
|
return max;
|
|
2411
2719
|
}
|
|
2412
2720
|
get isInt() {
|
|
2413
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
|
2721
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
2722
|
+
}
|
|
2723
|
+
get isFinite() {
|
|
2724
|
+
let max = null, min = null;
|
|
2725
|
+
for (const ch of this._def.checks) {
|
|
2726
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
2727
|
+
return true;
|
|
2728
|
+
} else if (ch.kind === "min") {
|
|
2729
|
+
if (min === null || ch.value > min)
|
|
2730
|
+
min = ch.value;
|
|
2731
|
+
} else if (ch.kind === "max") {
|
|
2732
|
+
if (max === null || ch.value < max)
|
|
2733
|
+
max = ch.value;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
2414
2737
|
}
|
|
2415
2738
|
};
|
|
2416
2739
|
ZodNumber.create = (params) => {
|
|
@@ -2421,27 +2744,167 @@ var init_lib = __esm({
|
|
|
2421
2744
|
...processCreateParams(params)
|
|
2422
2745
|
});
|
|
2423
2746
|
};
|
|
2424
|
-
ZodBigInt = class extends ZodType {
|
|
2747
|
+
ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2748
|
+
constructor() {
|
|
2749
|
+
super(...arguments);
|
|
2750
|
+
this.min = this.gte;
|
|
2751
|
+
this.max = this.lte;
|
|
2752
|
+
}
|
|
2425
2753
|
_parse(input) {
|
|
2426
2754
|
if (this._def.coerce) {
|
|
2427
2755
|
input.data = BigInt(input.data);
|
|
2428
2756
|
}
|
|
2429
2757
|
const parsedType = this._getType(input);
|
|
2430
2758
|
if (parsedType !== ZodParsedType.bigint) {
|
|
2431
|
-
const
|
|
2432
|
-
addIssueToContext(
|
|
2759
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
2760
|
+
addIssueToContext(ctx2, {
|
|
2433
2761
|
code: ZodIssueCode.invalid_type,
|
|
2434
2762
|
expected: ZodParsedType.bigint,
|
|
2435
|
-
received:
|
|
2763
|
+
received: ctx2.parsedType
|
|
2436
2764
|
});
|
|
2437
2765
|
return INVALID;
|
|
2438
2766
|
}
|
|
2439
|
-
|
|
2767
|
+
let ctx = void 0;
|
|
2768
|
+
const status = new ParseStatus();
|
|
2769
|
+
for (const check of this._def.checks) {
|
|
2770
|
+
if (check.kind === "min") {
|
|
2771
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
2772
|
+
if (tooSmall) {
|
|
2773
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2774
|
+
addIssueToContext(ctx, {
|
|
2775
|
+
code: ZodIssueCode.too_small,
|
|
2776
|
+
type: "bigint",
|
|
2777
|
+
minimum: check.value,
|
|
2778
|
+
inclusive: check.inclusive,
|
|
2779
|
+
message: check.message
|
|
2780
|
+
});
|
|
2781
|
+
status.dirty();
|
|
2782
|
+
}
|
|
2783
|
+
} else if (check.kind === "max") {
|
|
2784
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
2785
|
+
if (tooBig) {
|
|
2786
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2787
|
+
addIssueToContext(ctx, {
|
|
2788
|
+
code: ZodIssueCode.too_big,
|
|
2789
|
+
type: "bigint",
|
|
2790
|
+
maximum: check.value,
|
|
2791
|
+
inclusive: check.inclusive,
|
|
2792
|
+
message: check.message
|
|
2793
|
+
});
|
|
2794
|
+
status.dirty();
|
|
2795
|
+
}
|
|
2796
|
+
} else if (check.kind === "multipleOf") {
|
|
2797
|
+
if (input.data % check.value !== BigInt(0)) {
|
|
2798
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2799
|
+
addIssueToContext(ctx, {
|
|
2800
|
+
code: ZodIssueCode.not_multiple_of,
|
|
2801
|
+
multipleOf: check.value,
|
|
2802
|
+
message: check.message
|
|
2803
|
+
});
|
|
2804
|
+
status.dirty();
|
|
2805
|
+
}
|
|
2806
|
+
} else {
|
|
2807
|
+
util.assertNever(check);
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
return { status: status.value, value: input.data };
|
|
2811
|
+
}
|
|
2812
|
+
gte(value, message) {
|
|
2813
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
2814
|
+
}
|
|
2815
|
+
gt(value, message) {
|
|
2816
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
2817
|
+
}
|
|
2818
|
+
lte(value, message) {
|
|
2819
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
2820
|
+
}
|
|
2821
|
+
lt(value, message) {
|
|
2822
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
2823
|
+
}
|
|
2824
|
+
setLimit(kind, value, inclusive, message) {
|
|
2825
|
+
return new _ZodBigInt({
|
|
2826
|
+
...this._def,
|
|
2827
|
+
checks: [
|
|
2828
|
+
...this._def.checks,
|
|
2829
|
+
{
|
|
2830
|
+
kind,
|
|
2831
|
+
value,
|
|
2832
|
+
inclusive,
|
|
2833
|
+
message: errorUtil.toString(message)
|
|
2834
|
+
}
|
|
2835
|
+
]
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
_addCheck(check) {
|
|
2839
|
+
return new _ZodBigInt({
|
|
2840
|
+
...this._def,
|
|
2841
|
+
checks: [...this._def.checks, check]
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2844
|
+
positive(message) {
|
|
2845
|
+
return this._addCheck({
|
|
2846
|
+
kind: "min",
|
|
2847
|
+
value: BigInt(0),
|
|
2848
|
+
inclusive: false,
|
|
2849
|
+
message: errorUtil.toString(message)
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
negative(message) {
|
|
2853
|
+
return this._addCheck({
|
|
2854
|
+
kind: "max",
|
|
2855
|
+
value: BigInt(0),
|
|
2856
|
+
inclusive: false,
|
|
2857
|
+
message: errorUtil.toString(message)
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
nonpositive(message) {
|
|
2861
|
+
return this._addCheck({
|
|
2862
|
+
kind: "max",
|
|
2863
|
+
value: BigInt(0),
|
|
2864
|
+
inclusive: true,
|
|
2865
|
+
message: errorUtil.toString(message)
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
nonnegative(message) {
|
|
2869
|
+
return this._addCheck({
|
|
2870
|
+
kind: "min",
|
|
2871
|
+
value: BigInt(0),
|
|
2872
|
+
inclusive: true,
|
|
2873
|
+
message: errorUtil.toString(message)
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
multipleOf(value, message) {
|
|
2877
|
+
return this._addCheck({
|
|
2878
|
+
kind: "multipleOf",
|
|
2879
|
+
value,
|
|
2880
|
+
message: errorUtil.toString(message)
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
get minValue() {
|
|
2884
|
+
let min = null;
|
|
2885
|
+
for (const ch of this._def.checks) {
|
|
2886
|
+
if (ch.kind === "min") {
|
|
2887
|
+
if (min === null || ch.value > min)
|
|
2888
|
+
min = ch.value;
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
return min;
|
|
2892
|
+
}
|
|
2893
|
+
get maxValue() {
|
|
2894
|
+
let max = null;
|
|
2895
|
+
for (const ch of this._def.checks) {
|
|
2896
|
+
if (ch.kind === "max") {
|
|
2897
|
+
if (max === null || ch.value < max)
|
|
2898
|
+
max = ch.value;
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
return max;
|
|
2440
2902
|
}
|
|
2441
2903
|
};
|
|
2442
2904
|
ZodBigInt.create = (params) => {
|
|
2443
2905
|
var _a;
|
|
2444
2906
|
return new ZodBigInt({
|
|
2907
|
+
checks: [],
|
|
2445
2908
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
2446
2909
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
2447
2910
|
...processCreateParams(params)
|
|
@@ -2767,13 +3230,13 @@ var init_lib = __esm({
|
|
|
2767
3230
|
}
|
|
2768
3231
|
}
|
|
2769
3232
|
if (ctx.common.async) {
|
|
2770
|
-
return Promise.all(ctx.data.map((item, i) => {
|
|
3233
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
2771
3234
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
2772
3235
|
})).then((result2) => {
|
|
2773
3236
|
return ParseStatus.mergeArray(status, result2);
|
|
2774
3237
|
});
|
|
2775
3238
|
}
|
|
2776
|
-
const result = ctx.data.map((item, i) => {
|
|
3239
|
+
const result = [...ctx.data].map((item, i) => {
|
|
2777
3240
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
2778
3241
|
});
|
|
2779
3242
|
return ParseStatus.mergeArray(status, result);
|
|
@@ -2813,31 +3276,12 @@ var init_lib = __esm({
|
|
|
2813
3276
|
...processCreateParams(params)
|
|
2814
3277
|
});
|
|
2815
3278
|
};
|
|
2816
|
-
(function(objectUtil2) {
|
|
2817
|
-
objectUtil2.mergeShapes = (first, second) => {
|
|
2818
|
-
return {
|
|
2819
|
-
...first,
|
|
2820
|
-
...second
|
|
2821
|
-
// second overwrites first
|
|
2822
|
-
};
|
|
2823
|
-
};
|
|
2824
|
-
})(objectUtil || (objectUtil = {}));
|
|
2825
|
-
AugmentFactory = (def) => (augmentation) => {
|
|
2826
|
-
return new ZodObject({
|
|
2827
|
-
...def,
|
|
2828
|
-
shape: () => ({
|
|
2829
|
-
...def.shape(),
|
|
2830
|
-
...augmentation
|
|
2831
|
-
})
|
|
2832
|
-
});
|
|
2833
|
-
};
|
|
2834
3279
|
ZodObject = class _ZodObject extends ZodType {
|
|
2835
3280
|
constructor() {
|
|
2836
3281
|
super(...arguments);
|
|
2837
3282
|
this._cached = null;
|
|
2838
3283
|
this.nonstrict = this.passthrough;
|
|
2839
|
-
this.augment =
|
|
2840
|
-
this.extend = AugmentFactory(this._def);
|
|
3284
|
+
this.augment = this.extend;
|
|
2841
3285
|
}
|
|
2842
3286
|
_getCached() {
|
|
2843
3287
|
if (this._cached !== null)
|
|
@@ -2918,9 +3362,10 @@ var init_lib = __esm({
|
|
|
2918
3362
|
const syncPairs = [];
|
|
2919
3363
|
for (const pair of pairs) {
|
|
2920
3364
|
const key = await pair.key;
|
|
3365
|
+
const value = await pair.value;
|
|
2921
3366
|
syncPairs.push({
|
|
2922
3367
|
key,
|
|
2923
|
-
value
|
|
3368
|
+
value,
|
|
2924
3369
|
alwaysSet: pair.alwaysSet
|
|
2925
3370
|
});
|
|
2926
3371
|
}
|
|
@@ -2967,8 +3412,31 @@ var init_lib = __esm({
|
|
|
2967
3412
|
unknownKeys: "passthrough"
|
|
2968
3413
|
});
|
|
2969
3414
|
}
|
|
2970
|
-
|
|
2971
|
-
|
|
3415
|
+
// const AugmentFactory =
|
|
3416
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
3417
|
+
// <Augmentation extends ZodRawShape>(
|
|
3418
|
+
// augmentation: Augmentation
|
|
3419
|
+
// ): ZodObject<
|
|
3420
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
3421
|
+
// Def["unknownKeys"],
|
|
3422
|
+
// Def["catchall"]
|
|
3423
|
+
// > => {
|
|
3424
|
+
// return new ZodObject({
|
|
3425
|
+
// ...def,
|
|
3426
|
+
// shape: () => ({
|
|
3427
|
+
// ...def.shape(),
|
|
3428
|
+
// ...augmentation,
|
|
3429
|
+
// }),
|
|
3430
|
+
// }) as any;
|
|
3431
|
+
// };
|
|
3432
|
+
extend(augmentation) {
|
|
3433
|
+
return new _ZodObject({
|
|
3434
|
+
...this._def,
|
|
3435
|
+
shape: () => ({
|
|
3436
|
+
...this._def.shape(),
|
|
3437
|
+
...augmentation
|
|
3438
|
+
})
|
|
3439
|
+
});
|
|
2972
3440
|
}
|
|
2973
3441
|
/**
|
|
2974
3442
|
* Prior to zod@1.0.12 there was a bug in the
|
|
@@ -2979,11 +3447,73 @@ var init_lib = __esm({
|
|
|
2979
3447
|
const merged = new _ZodObject({
|
|
2980
3448
|
unknownKeys: merging._def.unknownKeys,
|
|
2981
3449
|
catchall: merging._def.catchall,
|
|
2982
|
-
shape: () =>
|
|
3450
|
+
shape: () => ({
|
|
3451
|
+
...this._def.shape(),
|
|
3452
|
+
...merging._def.shape()
|
|
3453
|
+
}),
|
|
2983
3454
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
2984
3455
|
});
|
|
2985
3456
|
return merged;
|
|
2986
3457
|
}
|
|
3458
|
+
// merge<
|
|
3459
|
+
// Incoming extends AnyZodObject,
|
|
3460
|
+
// Augmentation extends Incoming["shape"],
|
|
3461
|
+
// NewOutput extends {
|
|
3462
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
3463
|
+
// ? Augmentation[k]["_output"]
|
|
3464
|
+
// : k extends keyof Output
|
|
3465
|
+
// ? Output[k]
|
|
3466
|
+
// : never;
|
|
3467
|
+
// },
|
|
3468
|
+
// NewInput extends {
|
|
3469
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
3470
|
+
// ? Augmentation[k]["_input"]
|
|
3471
|
+
// : k extends keyof Input
|
|
3472
|
+
// ? Input[k]
|
|
3473
|
+
// : never;
|
|
3474
|
+
// }
|
|
3475
|
+
// >(
|
|
3476
|
+
// merging: Incoming
|
|
3477
|
+
// ): ZodObject<
|
|
3478
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3479
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3480
|
+
// Incoming["_def"]["catchall"],
|
|
3481
|
+
// NewOutput,
|
|
3482
|
+
// NewInput
|
|
3483
|
+
// > {
|
|
3484
|
+
// const merged: any = new ZodObject({
|
|
3485
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3486
|
+
// catchall: merging._def.catchall,
|
|
3487
|
+
// shape: () =>
|
|
3488
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3489
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3490
|
+
// }) as any;
|
|
3491
|
+
// return merged;
|
|
3492
|
+
// }
|
|
3493
|
+
setKey(key, schema4) {
|
|
3494
|
+
return this.augment({ [key]: schema4 });
|
|
3495
|
+
}
|
|
3496
|
+
// merge<Incoming extends AnyZodObject>(
|
|
3497
|
+
// merging: Incoming
|
|
3498
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
3499
|
+
// ZodObject<
|
|
3500
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3501
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3502
|
+
// Incoming["_def"]["catchall"]
|
|
3503
|
+
// > {
|
|
3504
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
3505
|
+
// // this._def.shape(),
|
|
3506
|
+
// // merging._def.shape()
|
|
3507
|
+
// // );
|
|
3508
|
+
// const merged: any = new ZodObject({
|
|
3509
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3510
|
+
// catchall: merging._def.catchall,
|
|
3511
|
+
// shape: () =>
|
|
3512
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3513
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3514
|
+
// }) as any;
|
|
3515
|
+
// return merged;
|
|
3516
|
+
// }
|
|
2987
3517
|
catchall(index4) {
|
|
2988
3518
|
return new _ZodObject({
|
|
2989
3519
|
...this._def,
|
|
@@ -2992,9 +3522,10 @@ var init_lib = __esm({
|
|
|
2992
3522
|
}
|
|
2993
3523
|
pick(mask) {
|
|
2994
3524
|
const shape = {};
|
|
2995
|
-
util.objectKeys(mask).
|
|
2996
|
-
if (this.shape[key])
|
|
3525
|
+
util.objectKeys(mask).forEach((key) => {
|
|
3526
|
+
if (mask[key] && this.shape[key]) {
|
|
2997
3527
|
shape[key] = this.shape[key];
|
|
3528
|
+
}
|
|
2998
3529
|
});
|
|
2999
3530
|
return new _ZodObject({
|
|
3000
3531
|
...this._def,
|
|
@@ -3003,8 +3534,8 @@ var init_lib = __esm({
|
|
|
3003
3534
|
}
|
|
3004
3535
|
omit(mask) {
|
|
3005
3536
|
const shape = {};
|
|
3006
|
-
util.objectKeys(this.shape).
|
|
3007
|
-
if (
|
|
3537
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
3538
|
+
if (!mask[key]) {
|
|
3008
3539
|
shape[key] = this.shape[key];
|
|
3009
3540
|
}
|
|
3010
3541
|
});
|
|
@@ -3013,29 +3544,22 @@ var init_lib = __esm({
|
|
|
3013
3544
|
shape: () => shape
|
|
3014
3545
|
});
|
|
3015
3546
|
}
|
|
3547
|
+
/**
|
|
3548
|
+
* @deprecated
|
|
3549
|
+
*/
|
|
3016
3550
|
deepPartial() {
|
|
3017
3551
|
return deepPartialify(this);
|
|
3018
3552
|
}
|
|
3019
3553
|
partial(mask) {
|
|
3020
3554
|
const newShape = {};
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
newShape[key] = this.shape[key].optional();
|
|
3027
|
-
}
|
|
3028
|
-
});
|
|
3029
|
-
return new _ZodObject({
|
|
3030
|
-
...this._def,
|
|
3031
|
-
shape: () => newShape
|
|
3032
|
-
});
|
|
3033
|
-
} else {
|
|
3034
|
-
for (const key in this.shape) {
|
|
3035
|
-
const fieldSchema = this.shape[key];
|
|
3555
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
3556
|
+
const fieldSchema = this.shape[key];
|
|
3557
|
+
if (mask && !mask[key]) {
|
|
3558
|
+
newShape[key] = fieldSchema;
|
|
3559
|
+
} else {
|
|
3036
3560
|
newShape[key] = fieldSchema.optional();
|
|
3037
3561
|
}
|
|
3038
|
-
}
|
|
3562
|
+
});
|
|
3039
3563
|
return new _ZodObject({
|
|
3040
3564
|
...this._def,
|
|
3041
3565
|
shape: () => newShape
|
|
@@ -3043,21 +3567,10 @@ var init_lib = __esm({
|
|
|
3043
3567
|
}
|
|
3044
3568
|
required(mask) {
|
|
3045
3569
|
const newShape = {};
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
} else {
|
|
3051
|
-
const fieldSchema = this.shape[key];
|
|
3052
|
-
let newField = fieldSchema;
|
|
3053
|
-
while (newField instanceof ZodOptional) {
|
|
3054
|
-
newField = newField._def.innerType;
|
|
3055
|
-
}
|
|
3056
|
-
newShape[key] = newField;
|
|
3057
|
-
}
|
|
3058
|
-
});
|
|
3059
|
-
} else {
|
|
3060
|
-
for (const key in this.shape) {
|
|
3570
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
3571
|
+
if (mask && !mask[key]) {
|
|
3572
|
+
newShape[key] = this.shape[key];
|
|
3573
|
+
} else {
|
|
3061
3574
|
const fieldSchema = this.shape[key];
|
|
3062
3575
|
let newField = fieldSchema;
|
|
3063
3576
|
while (newField instanceof ZodOptional) {
|
|
@@ -3065,7 +3578,7 @@ var init_lib = __esm({
|
|
|
3065
3578
|
}
|
|
3066
3579
|
newShape[key] = newField;
|
|
3067
3580
|
}
|
|
3068
|
-
}
|
|
3581
|
+
});
|
|
3069
3582
|
return new _ZodObject({
|
|
3070
3583
|
...this._def,
|
|
3071
3584
|
shape: () => newShape
|
|
@@ -3203,15 +3716,25 @@ var init_lib = __esm({
|
|
|
3203
3716
|
} else if (type instanceof ZodEnum) {
|
|
3204
3717
|
return type.options;
|
|
3205
3718
|
} else if (type instanceof ZodNativeEnum) {
|
|
3206
|
-
return
|
|
3719
|
+
return util.objectValues(type.enum);
|
|
3207
3720
|
} else if (type instanceof ZodDefault) {
|
|
3208
3721
|
return getDiscriminator(type._def.innerType);
|
|
3209
3722
|
} else if (type instanceof ZodUndefined) {
|
|
3210
3723
|
return [void 0];
|
|
3211
3724
|
} else if (type instanceof ZodNull) {
|
|
3212
3725
|
return [null];
|
|
3726
|
+
} else if (type instanceof ZodOptional) {
|
|
3727
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
3728
|
+
} else if (type instanceof ZodNullable) {
|
|
3729
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
3730
|
+
} else if (type instanceof ZodBranded) {
|
|
3731
|
+
return getDiscriminator(type.unwrap());
|
|
3732
|
+
} else if (type instanceof ZodReadonly) {
|
|
3733
|
+
return getDiscriminator(type.unwrap());
|
|
3734
|
+
} else if (type instanceof ZodCatch) {
|
|
3735
|
+
return getDiscriminator(type._def.innerType);
|
|
3213
3736
|
} else {
|
|
3214
|
-
return
|
|
3737
|
+
return [];
|
|
3215
3738
|
}
|
|
3216
3739
|
};
|
|
3217
3740
|
ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -3271,7 +3794,7 @@ var init_lib = __esm({
|
|
|
3271
3794
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
3272
3795
|
for (const type of options) {
|
|
3273
3796
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
3274
|
-
if (!discriminatorValues) {
|
|
3797
|
+
if (!discriminatorValues.length) {
|
|
3275
3798
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
3276
3799
|
}
|
|
3277
3800
|
for (const value of discriminatorValues) {
|
|
@@ -3375,7 +3898,7 @@ var init_lib = __esm({
|
|
|
3375
3898
|
});
|
|
3376
3899
|
status.dirty();
|
|
3377
3900
|
}
|
|
3378
|
-
const items = ctx.data.map((item, itemIndex) => {
|
|
3901
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
|
3379
3902
|
const schema4 = this._def.items[itemIndex] || this._def.rest;
|
|
3380
3903
|
if (!schema4)
|
|
3381
3904
|
return null;
|
|
@@ -3433,7 +3956,8 @@ var init_lib = __esm({
|
|
|
3433
3956
|
for (const key in ctx.data) {
|
|
3434
3957
|
pairs.push({
|
|
3435
3958
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3436
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3959
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3960
|
+
alwaysSet: key in ctx.data
|
|
3437
3961
|
});
|
|
3438
3962
|
}
|
|
3439
3963
|
if (ctx.common.async) {
|
|
@@ -3463,6 +3987,12 @@ var init_lib = __esm({
|
|
|
3463
3987
|
}
|
|
3464
3988
|
};
|
|
3465
3989
|
ZodMap = class extends ZodType {
|
|
3990
|
+
get keySchema() {
|
|
3991
|
+
return this._def.keyType;
|
|
3992
|
+
}
|
|
3993
|
+
get valueSchema() {
|
|
3994
|
+
return this._def.valueType;
|
|
3995
|
+
}
|
|
3466
3996
|
_parse(input) {
|
|
3467
3997
|
const { status, ctx } = this._processInputParams(input);
|
|
3468
3998
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -3657,27 +4187,29 @@ var init_lib = __esm({
|
|
|
3657
4187
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
3658
4188
|
const fn = ctx.data;
|
|
3659
4189
|
if (this._def.returns instanceof ZodPromise) {
|
|
3660
|
-
|
|
4190
|
+
const me = this;
|
|
4191
|
+
return OK(async function(...args) {
|
|
3661
4192
|
const error2 = new ZodError([]);
|
|
3662
|
-
const parsedArgs = await
|
|
4193
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
3663
4194
|
error2.addIssue(makeArgsIssue(args, e));
|
|
3664
4195
|
throw error2;
|
|
3665
4196
|
});
|
|
3666
|
-
const result = await fn
|
|
3667
|
-
const parsedReturns = await
|
|
4197
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
4198
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
3668
4199
|
error2.addIssue(makeReturnsIssue(result, e));
|
|
3669
4200
|
throw error2;
|
|
3670
4201
|
});
|
|
3671
4202
|
return parsedReturns;
|
|
3672
4203
|
});
|
|
3673
4204
|
} else {
|
|
3674
|
-
|
|
3675
|
-
|
|
4205
|
+
const me = this;
|
|
4206
|
+
return OK(function(...args) {
|
|
4207
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
3676
4208
|
if (!parsedArgs.success) {
|
|
3677
4209
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3678
4210
|
}
|
|
3679
|
-
const result = fn
|
|
3680
|
-
const parsedReturns =
|
|
4211
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
4212
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
3681
4213
|
if (!parsedReturns.success) {
|
|
3682
4214
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3683
4215
|
}
|
|
@@ -3742,6 +4274,7 @@ var init_lib = __esm({
|
|
|
3742
4274
|
if (input.data !== this._def.value) {
|
|
3743
4275
|
const ctx = this._getOrReturnCtx(input);
|
|
3744
4276
|
addIssueToContext(ctx, {
|
|
4277
|
+
received: ctx.data,
|
|
3745
4278
|
code: ZodIssueCode.invalid_literal,
|
|
3746
4279
|
expected: this._def.value
|
|
3747
4280
|
});
|
|
@@ -3760,7 +4293,11 @@ var init_lib = __esm({
|
|
|
3760
4293
|
...processCreateParams(params)
|
|
3761
4294
|
});
|
|
3762
4295
|
};
|
|
3763
|
-
ZodEnum = class extends ZodType {
|
|
4296
|
+
ZodEnum = class _ZodEnum extends ZodType {
|
|
4297
|
+
constructor() {
|
|
4298
|
+
super(...arguments);
|
|
4299
|
+
_ZodEnum_cache.set(this, void 0);
|
|
4300
|
+
}
|
|
3764
4301
|
_parse(input) {
|
|
3765
4302
|
if (typeof input.data !== "string") {
|
|
3766
4303
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3772,7 +4309,10 @@ var init_lib = __esm({
|
|
|
3772
4309
|
});
|
|
3773
4310
|
return INVALID;
|
|
3774
4311
|
}
|
|
3775
|
-
if (this
|
|
4312
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
4313
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
4314
|
+
}
|
|
4315
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3776
4316
|
const ctx = this._getOrReturnCtx(input);
|
|
3777
4317
|
const expectedValues = this._def.values;
|
|
3778
4318
|
addIssueToContext(ctx, {
|
|
@@ -3808,9 +4348,26 @@ var init_lib = __esm({
|
|
|
3808
4348
|
}
|
|
3809
4349
|
return enumValues;
|
|
3810
4350
|
}
|
|
4351
|
+
extract(values, newDef = this._def) {
|
|
4352
|
+
return _ZodEnum.create(values, {
|
|
4353
|
+
...this._def,
|
|
4354
|
+
...newDef
|
|
4355
|
+
});
|
|
4356
|
+
}
|
|
4357
|
+
exclude(values, newDef = this._def) {
|
|
4358
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
4359
|
+
...this._def,
|
|
4360
|
+
...newDef
|
|
4361
|
+
});
|
|
4362
|
+
}
|
|
3811
4363
|
};
|
|
4364
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3812
4365
|
ZodEnum.create = createZodEnum;
|
|
3813
4366
|
ZodNativeEnum = class extends ZodType {
|
|
4367
|
+
constructor() {
|
|
4368
|
+
super(...arguments);
|
|
4369
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
4370
|
+
}
|
|
3814
4371
|
_parse(input) {
|
|
3815
4372
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3816
4373
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3823,7 +4380,10 @@ var init_lib = __esm({
|
|
|
3823
4380
|
});
|
|
3824
4381
|
return INVALID;
|
|
3825
4382
|
}
|
|
3826
|
-
if (
|
|
4383
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
4384
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
4385
|
+
}
|
|
4386
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3827
4387
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3828
4388
|
addIssueToContext(ctx, {
|
|
3829
4389
|
received: ctx.data,
|
|
@@ -3838,6 +4398,7 @@ var init_lib = __esm({
|
|
|
3838
4398
|
return this._def.values;
|
|
3839
4399
|
}
|
|
3840
4400
|
};
|
|
4401
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3841
4402
|
ZodNativeEnum.create = (values, params) => {
|
|
3842
4403
|
return new ZodNativeEnum({
|
|
3843
4404
|
values,
|
|
@@ -3846,6 +4407,9 @@ var init_lib = __esm({
|
|
|
3846
4407
|
});
|
|
3847
4408
|
};
|
|
3848
4409
|
ZodPromise = class extends ZodType {
|
|
4410
|
+
unwrap() {
|
|
4411
|
+
return this._def.type;
|
|
4412
|
+
}
|
|
3849
4413
|
_parse(input) {
|
|
3850
4414
|
const { ctx } = this._processInputParams(input);
|
|
3851
4415
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
@@ -3882,24 +4446,6 @@ var init_lib = __esm({
|
|
|
3882
4446
|
_parse(input) {
|
|
3883
4447
|
const { status, ctx } = this._processInputParams(input);
|
|
3884
4448
|
const effect = this._def.effect || null;
|
|
3885
|
-
if (effect.type === "preprocess") {
|
|
3886
|
-
const processed = effect.transform(ctx.data);
|
|
3887
|
-
if (ctx.common.async) {
|
|
3888
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3889
|
-
return this._def.schema._parseAsync({
|
|
3890
|
-
data: processed2,
|
|
3891
|
-
path: ctx.path,
|
|
3892
|
-
parent: ctx
|
|
3893
|
-
});
|
|
3894
|
-
});
|
|
3895
|
-
} else {
|
|
3896
|
-
return this._def.schema._parseSync({
|
|
3897
|
-
data: processed,
|
|
3898
|
-
path: ctx.path,
|
|
3899
|
-
parent: ctx
|
|
3900
|
-
});
|
|
3901
|
-
}
|
|
3902
|
-
}
|
|
3903
4449
|
const checkCtx = {
|
|
3904
4450
|
addIssue: (arg) => {
|
|
3905
4451
|
addIssueToContext(ctx, arg);
|
|
@@ -3914,6 +4460,42 @@ var init_lib = __esm({
|
|
|
3914
4460
|
}
|
|
3915
4461
|
};
|
|
3916
4462
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
4463
|
+
if (effect.type === "preprocess") {
|
|
4464
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
4465
|
+
if (ctx.common.async) {
|
|
4466
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
4467
|
+
if (status.value === "aborted")
|
|
4468
|
+
return INVALID;
|
|
4469
|
+
const result = await this._def.schema._parseAsync({
|
|
4470
|
+
data: processed2,
|
|
4471
|
+
path: ctx.path,
|
|
4472
|
+
parent: ctx
|
|
4473
|
+
});
|
|
4474
|
+
if (result.status === "aborted")
|
|
4475
|
+
return INVALID;
|
|
4476
|
+
if (result.status === "dirty")
|
|
4477
|
+
return DIRTY(result.value);
|
|
4478
|
+
if (status.value === "dirty")
|
|
4479
|
+
return DIRTY(result.value);
|
|
4480
|
+
return result;
|
|
4481
|
+
});
|
|
4482
|
+
} else {
|
|
4483
|
+
if (status.value === "aborted")
|
|
4484
|
+
return INVALID;
|
|
4485
|
+
const result = this._def.schema._parseSync({
|
|
4486
|
+
data: processed,
|
|
4487
|
+
path: ctx.path,
|
|
4488
|
+
parent: ctx
|
|
4489
|
+
});
|
|
4490
|
+
if (result.status === "aborted")
|
|
4491
|
+
return INVALID;
|
|
4492
|
+
if (result.status === "dirty")
|
|
4493
|
+
return DIRTY(result.value);
|
|
4494
|
+
if (status.value === "dirty")
|
|
4495
|
+
return DIRTY(result.value);
|
|
4496
|
+
return result;
|
|
4497
|
+
}
|
|
4498
|
+
}
|
|
3917
4499
|
if (effect.type === "refinement") {
|
|
3918
4500
|
const executeRefinement = (acc) => {
|
|
3919
4501
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -4056,26 +4638,45 @@ var init_lib = __esm({
|
|
|
4056
4638
|
ZodCatch = class extends ZodType {
|
|
4057
4639
|
_parse(input) {
|
|
4058
4640
|
const { ctx } = this._processInputParams(input);
|
|
4641
|
+
const newCtx = {
|
|
4642
|
+
...ctx,
|
|
4643
|
+
common: {
|
|
4644
|
+
...ctx.common,
|
|
4645
|
+
issues: []
|
|
4646
|
+
}
|
|
4647
|
+
};
|
|
4059
4648
|
const result = this._def.innerType._parse({
|
|
4060
|
-
data:
|
|
4061
|
-
path:
|
|
4062
|
-
parent:
|
|
4649
|
+
data: newCtx.data,
|
|
4650
|
+
path: newCtx.path,
|
|
4651
|
+
parent: {
|
|
4652
|
+
...newCtx
|
|
4653
|
+
}
|
|
4063
4654
|
});
|
|
4064
4655
|
if (isAsync(result)) {
|
|
4065
4656
|
return result.then((result2) => {
|
|
4066
4657
|
return {
|
|
4067
4658
|
status: "valid",
|
|
4068
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
|
4659
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
4660
|
+
get error() {
|
|
4661
|
+
return new ZodError(newCtx.common.issues);
|
|
4662
|
+
},
|
|
4663
|
+
input: newCtx.data
|
|
4664
|
+
})
|
|
4069
4665
|
};
|
|
4070
4666
|
});
|
|
4071
4667
|
} else {
|
|
4072
4668
|
return {
|
|
4073
4669
|
status: "valid",
|
|
4074
|
-
value: result.status === "valid" ? result.value : this._def.
|
|
4670
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
4671
|
+
get error() {
|
|
4672
|
+
return new ZodError(newCtx.common.issues);
|
|
4673
|
+
},
|
|
4674
|
+
input: newCtx.data
|
|
4675
|
+
})
|
|
4075
4676
|
};
|
|
4076
4677
|
}
|
|
4077
4678
|
}
|
|
4078
|
-
|
|
4679
|
+
removeCatch() {
|
|
4079
4680
|
return this._def.innerType;
|
|
4080
4681
|
}
|
|
4081
4682
|
};
|
|
@@ -4083,7 +4684,7 @@ var init_lib = __esm({
|
|
|
4083
4684
|
return new ZodCatch({
|
|
4084
4685
|
innerType: type,
|
|
4085
4686
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
4086
|
-
|
|
4687
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
4087
4688
|
...processCreateParams(params)
|
|
4088
4689
|
});
|
|
4089
4690
|
};
|
|
@@ -4178,6 +4779,25 @@ var init_lib = __esm({
|
|
|
4178
4779
|
});
|
|
4179
4780
|
}
|
|
4180
4781
|
};
|
|
4782
|
+
ZodReadonly = class extends ZodType {
|
|
4783
|
+
_parse(input) {
|
|
4784
|
+
const result = this._def.innerType._parse(input);
|
|
4785
|
+
if (isValid(result)) {
|
|
4786
|
+
result.value = Object.freeze(result.value);
|
|
4787
|
+
}
|
|
4788
|
+
return result;
|
|
4789
|
+
}
|
|
4790
|
+
unwrap() {
|
|
4791
|
+
return this._def.innerType;
|
|
4792
|
+
}
|
|
4793
|
+
};
|
|
4794
|
+
ZodReadonly.create = (type, params) => {
|
|
4795
|
+
return new ZodReadonly({
|
|
4796
|
+
innerType: type,
|
|
4797
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
4798
|
+
...processCreateParams(params)
|
|
4799
|
+
});
|
|
4800
|
+
};
|
|
4181
4801
|
late = {
|
|
4182
4802
|
object: ZodObject.lazycreate
|
|
4183
4803
|
};
|
|
@@ -4217,6 +4837,7 @@ var init_lib = __esm({
|
|
|
4217
4837
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
4218
4838
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
4219
4839
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
4840
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
4220
4841
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
4221
4842
|
stringType = ZodString.create;
|
|
4222
4843
|
numberType = ZodNumber.create;
|
|
@@ -4255,7 +4876,10 @@ var init_lib = __esm({
|
|
|
4255
4876
|
coerce = {
|
|
4256
4877
|
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
4257
4878
|
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
4258
|
-
boolean: (arg) => ZodBoolean.create({
|
|
4879
|
+
boolean: (arg) => ZodBoolean.create({
|
|
4880
|
+
...arg,
|
|
4881
|
+
coerce: true
|
|
4882
|
+
}),
|
|
4259
4883
|
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
4260
4884
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
4261
4885
|
};
|
|
@@ -4701,7 +5325,7 @@ var init_pgSchema = __esm({
|
|
|
4701
5325
|
}).strict();
|
|
4702
5326
|
pgSchemaInternal = objectType({
|
|
4703
5327
|
version: literalType("6"),
|
|
4704
|
-
dialect: literalType("
|
|
5328
|
+
dialect: literalType("pg"),
|
|
4705
5329
|
tables: recordType(stringType(), table2),
|
|
4706
5330
|
enums: recordType(stringType(), enumSchema),
|
|
4707
5331
|
schemas: recordType(stringType(), stringType()),
|
|
@@ -4730,14 +5354,14 @@ var init_pgSchema = __esm({
|
|
|
4730
5354
|
}).strict();
|
|
4731
5355
|
pgSchemaSquashedV4 = objectType({
|
|
4732
5356
|
version: literalType("4"),
|
|
4733
|
-
dialect:
|
|
5357
|
+
dialect: enumType(["pg"]),
|
|
4734
5358
|
tables: recordType(stringType(), tableSquashedV42),
|
|
4735
5359
|
enums: recordType(stringType(), enumSchemaV1),
|
|
4736
5360
|
schemas: recordType(stringType(), stringType())
|
|
4737
5361
|
}).strict();
|
|
4738
5362
|
pgSchemaSquashed = objectType({
|
|
4739
5363
|
version: literalType("6"),
|
|
4740
|
-
dialect:
|
|
5364
|
+
dialect: enumType(["pg"]),
|
|
4741
5365
|
tables: recordType(stringType(), tableSquashed2),
|
|
4742
5366
|
enums: recordType(stringType(), enumSchema),
|
|
4743
5367
|
schemas: recordType(stringType(), stringType())
|
|
@@ -4848,7 +5472,7 @@ var init_pgSchema = __esm({
|
|
|
4848
5472
|
};
|
|
4849
5473
|
dryPg = pgSchema.parse({
|
|
4850
5474
|
version: snapshotVersion,
|
|
4851
|
-
dialect: "
|
|
5475
|
+
dialect: "pg",
|
|
4852
5476
|
id: originUUID,
|
|
4853
5477
|
prevId: "",
|
|
4854
5478
|
tables: {},
|
|
@@ -5077,7 +5701,6 @@ var init_utils = __esm({
|
|
|
5077
5701
|
init_mysqlSchema();
|
|
5078
5702
|
init_pgSchema();
|
|
5079
5703
|
init_sqliteSchema();
|
|
5080
|
-
init_source();
|
|
5081
5704
|
init_global();
|
|
5082
5705
|
copy = (it) => {
|
|
5083
5706
|
return JSON.parse(JSON.stringify(it));
|
|
@@ -5282,7 +5905,6 @@ var sqlToStr;
|
|
|
5282
5905
|
var init_serializer = __esm({
|
|
5283
5906
|
"src/serializer/index.ts"() {
|
|
5284
5907
|
"use strict";
|
|
5285
|
-
init_source();
|
|
5286
5908
|
init_views();
|
|
5287
5909
|
sqlToStr = (sql2) => {
|
|
5288
5910
|
return sql2.toQuery({
|
|
@@ -5311,8 +5933,7 @@ var init_outputs = __esm({
|
|
|
5311
5933
|
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
|
5312
5934
|
errorWarning: (str) => `${source_default.red(`${source_default.white.bgRed(" Warning ")} ${str}`)}`,
|
|
5313
5935
|
fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`,
|
|
5314
|
-
suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}
|
|
5315
|
-
info: (str) => `${source_default.grey(str)}`
|
|
5936
|
+
suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`
|
|
5316
5937
|
};
|
|
5317
5938
|
}
|
|
5318
5939
|
});
|
|
@@ -5334,6 +5955,7 @@ var init_mysql = __esm({
|
|
|
5334
5955
|
}),
|
|
5335
5956
|
objectType({
|
|
5336
5957
|
url: stringType()
|
|
5958
|
+
// TODO: change docs
|
|
5337
5959
|
})
|
|
5338
5960
|
]);
|
|
5339
5961
|
}
|
|
@@ -5357,12 +5979,6 @@ var init_pg = __esm({
|
|
|
5357
5979
|
}),
|
|
5358
5980
|
objectType({
|
|
5359
5981
|
url: stringType()
|
|
5360
|
-
}),
|
|
5361
|
-
objectType({
|
|
5362
|
-
driver: literalType("aws-data-api"),
|
|
5363
|
-
database: stringType(),
|
|
5364
|
-
secretArn: stringType(),
|
|
5365
|
-
resourceArn: stringType()
|
|
5366
5982
|
})
|
|
5367
5983
|
]);
|
|
5368
5984
|
}
|
|
@@ -5397,7 +6013,7 @@ var init_schemaValidator = __esm({
|
|
|
5397
6013
|
init_mysqlSchema();
|
|
5398
6014
|
init_pgSchema();
|
|
5399
6015
|
init_sqliteSchema();
|
|
5400
|
-
dialect3 = enumType(["
|
|
6016
|
+
dialect3 = enumType(["pg", "mysql", "sqlite"]);
|
|
5401
6017
|
commonSquashedSchema = unionType([
|
|
5402
6018
|
pgSchemaSquashed,
|
|
5403
6019
|
mysqlSchemaSquashed,
|
|
@@ -5517,8 +6133,8 @@ var init_cli = __esm({
|
|
|
5517
6133
|
dialect: dialect3,
|
|
5518
6134
|
schema: unionType([stringType(), stringType().array()]).optional(),
|
|
5519
6135
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
|
5520
|
-
|
|
5521
|
-
driver: stringType()
|
|
6136
|
+
schemaFilters: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
|
6137
|
+
driver: stringType(),
|
|
5522
6138
|
// pg
|
|
5523
6139
|
connectionString: stringType().optional(),
|
|
5524
6140
|
// mysql
|
|
@@ -5554,9 +6170,9 @@ var init_cli = __esm({
|
|
|
5554
6170
|
ssl: stringType().optional(),
|
|
5555
6171
|
url: stringType().optional(),
|
|
5556
6172
|
authToken: stringType().optional(),
|
|
5557
|
-
|
|
6173
|
+
"introspect-casing": casing,
|
|
5558
6174
|
breakpoints: booleanType().optional().default(true)
|
|
5559
|
-
})
|
|
6175
|
+
});
|
|
5560
6176
|
configCheck = objectType({
|
|
5561
6177
|
dialect: dialect3.optional(),
|
|
5562
6178
|
out: stringType().optional()
|
|
@@ -6332,9 +6948,9 @@ var require_src2 = __commonJS({
|
|
|
6332
6948
|
}
|
|
6333
6949
|
});
|
|
6334
6950
|
|
|
6335
|
-
// node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.
|
|
6951
|
+
// node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js
|
|
6336
6952
|
var require_node2 = __commonJS({
|
|
6337
|
-
"node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.
|
|
6953
|
+
"node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js"(exports) {
|
|
6338
6954
|
"use strict";
|
|
6339
6955
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6340
6956
|
function _interopRequireDefault2(obj) {
|
|
@@ -9507,15 +10123,15 @@ var require_node2 = __commonJS({
|
|
|
9507
10123
|
return newToken("punctuator", read());
|
|
9508
10124
|
case "n":
|
|
9509
10125
|
read();
|
|
9510
|
-
|
|
10126
|
+
literal2("ull");
|
|
9511
10127
|
return newToken("null", null);
|
|
9512
10128
|
case "t":
|
|
9513
10129
|
read();
|
|
9514
|
-
|
|
10130
|
+
literal2("rue");
|
|
9515
10131
|
return newToken("boolean", true);
|
|
9516
10132
|
case "f":
|
|
9517
10133
|
read();
|
|
9518
|
-
|
|
10134
|
+
literal2("alse");
|
|
9519
10135
|
return newToken("boolean", false);
|
|
9520
10136
|
case "-":
|
|
9521
10137
|
case "+":
|
|
@@ -9546,11 +10162,11 @@ var require_node2 = __commonJS({
|
|
|
9546
10162
|
return;
|
|
9547
10163
|
case "I":
|
|
9548
10164
|
read();
|
|
9549
|
-
|
|
10165
|
+
literal2("nfinity");
|
|
9550
10166
|
return newToken("numeric", Infinity);
|
|
9551
10167
|
case "N":
|
|
9552
10168
|
read();
|
|
9553
|
-
|
|
10169
|
+
literal2("aN");
|
|
9554
10170
|
return newToken("numeric", NaN);
|
|
9555
10171
|
case '"':
|
|
9556
10172
|
case "'":
|
|
@@ -9644,11 +10260,11 @@ var require_node2 = __commonJS({
|
|
|
9644
10260
|
return;
|
|
9645
10261
|
case "I":
|
|
9646
10262
|
read();
|
|
9647
|
-
|
|
10263
|
+
literal2("nfinity");
|
|
9648
10264
|
return newToken("numeric", sign * Infinity);
|
|
9649
10265
|
case "N":
|
|
9650
10266
|
read();
|
|
9651
|
-
|
|
10267
|
+
literal2("aN");
|
|
9652
10268
|
return newToken("numeric", NaN);
|
|
9653
10269
|
}
|
|
9654
10270
|
throw invalidChar(read());
|
|
@@ -9881,7 +10497,7 @@ var require_node2 = __commonJS({
|
|
|
9881
10497
|
column: column4
|
|
9882
10498
|
};
|
|
9883
10499
|
}
|
|
9884
|
-
function
|
|
10500
|
+
function literal2(s) {
|
|
9885
10501
|
for (const c2 of s) {
|
|
9886
10502
|
const p = peek();
|
|
9887
10503
|
if (p !== c2) {
|
|
@@ -11195,7 +11811,6 @@ var init_utils2 = __esm({
|
|
|
11195
11811
|
"src/cli/commands/utils.ts"() {
|
|
11196
11812
|
"use strict";
|
|
11197
11813
|
init_serializer();
|
|
11198
|
-
init_source();
|
|
11199
11814
|
init_views();
|
|
11200
11815
|
import_hanji2 = __toESM(require_hanji());
|
|
11201
11816
|
init_global();
|
|
@@ -11516,7 +12131,7 @@ ${withStyle.errorWarning(
|
|
|
11516
12131
|
);
|
|
11517
12132
|
return {
|
|
11518
12133
|
version: "6",
|
|
11519
|
-
dialect: "
|
|
12134
|
+
dialect: "pg",
|
|
11520
12135
|
tables: result,
|
|
11521
12136
|
enums: enumsToReturn,
|
|
11522
12137
|
schemas: schemasObject,
|
|
@@ -11723,7 +12338,7 @@ ${withStyle.errorWarning(
|
|
|
11723
12338
|
const columnName = columnResponse.attname;
|
|
11724
12339
|
const columnAdditionalDT = columnResponse.additional_dt;
|
|
11725
12340
|
const columnDimensions = columnResponse.array_dimensions;
|
|
11726
|
-
const
|
|
12341
|
+
const enumType2 = columnResponse.enum_name;
|
|
11727
12342
|
let columnType = columnResponse.data_type;
|
|
11728
12343
|
const primaryKey = tableConstraints.filter(
|
|
11729
12344
|
(mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
|
|
@@ -11787,8 +12402,8 @@ ${withStyle.errorWarning(
|
|
|
11787
12402
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
|
11788
12403
|
columnToReturn[columnName] = {
|
|
11789
12404
|
name: columnName,
|
|
11790
|
-
type: columnAdditionalDT === "USER-DEFINED" ?
|
|
11791
|
-
typeSchema: enumsToReturn[`${tableSchema}.${
|
|
12405
|
+
type: columnAdditionalDT === "USER-DEFINED" ? enumType2 : columnTypeMapped,
|
|
12406
|
+
typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
|
|
11792
12407
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
|
11793
12408
|
// default: isSerial ? undefined : defaultValue,
|
|
11794
12409
|
notNull: columnResponse.is_nullable === "NO"
|
|
@@ -11871,7 +12486,7 @@ ${withStyle.errorWarning(
|
|
|
11871
12486
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
|
11872
12487
|
return {
|
|
11873
12488
|
version: "6",
|
|
11874
|
-
dialect: "
|
|
12489
|
+
dialect: "pg",
|
|
11875
12490
|
tables: result,
|
|
11876
12491
|
enums: enumsToReturn,
|
|
11877
12492
|
schemas: schemasObject,
|
|
@@ -12172,10 +12787,10 @@ var require_brace_expansion = __commonJS({
|
|
|
12172
12787
|
}
|
|
12173
12788
|
});
|
|
12174
12789
|
|
|
12175
|
-
// node_modules/.pnpm/minimatch@7.4.
|
|
12790
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
|
|
12176
12791
|
var posixClasses, braceEscape, regexpEscape, rangesToString, parseClass;
|
|
12177
12792
|
var init_brace_expressions = __esm({
|
|
12178
|
-
"node_modules/.pnpm/minimatch@7.4.
|
|
12793
|
+
"node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js"() {
|
|
12179
12794
|
posixClasses = {
|
|
12180
12795
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
12181
12796
|
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
@@ -12287,30 +12902,30 @@ var init_brace_expressions = __esm({
|
|
|
12287
12902
|
}
|
|
12288
12903
|
});
|
|
12289
12904
|
|
|
12290
|
-
// node_modules/.pnpm/minimatch@7.4.
|
|
12905
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
|
|
12291
12906
|
var escape;
|
|
12292
12907
|
var init_escape = __esm({
|
|
12293
|
-
"node_modules/.pnpm/minimatch@7.4.
|
|
12908
|
+
"node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js"() {
|
|
12294
12909
|
escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
12295
12910
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
12296
12911
|
};
|
|
12297
12912
|
}
|
|
12298
12913
|
});
|
|
12299
12914
|
|
|
12300
|
-
// node_modules/.pnpm/minimatch@7.4.
|
|
12915
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
|
|
12301
12916
|
var unescape;
|
|
12302
12917
|
var init_unescape = __esm({
|
|
12303
|
-
"node_modules/.pnpm/minimatch@7.4.
|
|
12918
|
+
"node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js"() {
|
|
12304
12919
|
unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
12305
12920
|
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
12306
12921
|
};
|
|
12307
12922
|
}
|
|
12308
12923
|
});
|
|
12309
12924
|
|
|
12310
|
-
// node_modules/.pnpm/minimatch@7.4.
|
|
12925
|
+
// node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
|
12311
12926
|
var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match, globUnescape, globMagic, regExpEscape, Minimatch;
|
|
12312
12927
|
var init_mjs = __esm({
|
|
12313
|
-
"node_modules/.pnpm/minimatch@7.4.
|
|
12928
|
+
"node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js"() {
|
|
12314
12929
|
import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
12315
12930
|
init_brace_expressions();
|
|
12316
12931
|
init_escape();
|
|
@@ -15102,7 +15717,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15102
15717
|
const jsonTableAlternations = alteredTables.map((it) => {
|
|
15103
15718
|
return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
|
|
15104
15719
|
}).flat();
|
|
15105
|
-
const
|
|
15720
|
+
const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
|
|
15106
15721
|
return prepareCreateIndexesJson(
|
|
15107
15722
|
it.name,
|
|
15108
15723
|
it.schema,
|
|
@@ -15131,21 +15746,14 @@ var init_snapshotsDiffer = __esm({
|
|
|
15131
15746
|
},
|
|
15132
15747
|
{}
|
|
15133
15748
|
);
|
|
15134
|
-
|
|
15749
|
+
jsonCreateIndexesForAllAlteredTables.push(
|
|
15135
15750
|
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
|
15136
15751
|
);
|
|
15137
15752
|
jsonDropIndexesForAllAlteredTables.push(
|
|
15138
15753
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15139
15754
|
);
|
|
15140
15755
|
});
|
|
15141
|
-
const
|
|
15142
|
-
return prepareCreateReferencesJson(
|
|
15143
|
-
it.name,
|
|
15144
|
-
it.schema,
|
|
15145
|
-
it.foreignKeys
|
|
15146
|
-
);
|
|
15147
|
-
}).flat();
|
|
15148
|
-
const jsonReferencesForAlteredTables = alteredTables.map((it) => {
|
|
15756
|
+
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
15149
15757
|
const forAdded = prepareCreateReferencesJson(
|
|
15150
15758
|
it.name,
|
|
15151
15759
|
it.schema,
|
|
@@ -15163,10 +15771,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15163
15771
|
);
|
|
15164
15772
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
15165
15773
|
}).flat();
|
|
15166
|
-
const jsonCreatedReferencesForAlteredTables =
|
|
15774
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
|
15167
15775
|
(t) => t.type === "create_reference"
|
|
15168
15776
|
);
|
|
15169
|
-
const jsonDroppedReferencesForAlteredTables =
|
|
15777
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
|
15170
15778
|
(t) => t.type === "delete_reference"
|
|
15171
15779
|
);
|
|
15172
15780
|
const createEnums = createdEnums.map((it) => {
|
|
@@ -15193,7 +15801,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15193
15801
|
const dropSchemas = prepareDeleteSchemasJson(
|
|
15194
15802
|
deletedSchemas.map((it) => it.name)
|
|
15195
15803
|
);
|
|
15196
|
-
const
|
|
15804
|
+
const jsonPgCreateTables = createdTables.map((it) => {
|
|
15197
15805
|
return preparePgCreateTableJson(it, curFull);
|
|
15198
15806
|
});
|
|
15199
15807
|
jsonStatements.push(...createSchemas);
|
|
@@ -15202,7 +15810,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15202
15810
|
jsonStatements.push(...moveEnums);
|
|
15203
15811
|
jsonStatements.push(...renameEnums);
|
|
15204
15812
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
15205
|
-
jsonStatements.push(...
|
|
15813
|
+
jsonStatements.push(...jsonPgCreateTables);
|
|
15206
15814
|
jsonStatements.push(...jsonDropTables);
|
|
15207
15815
|
jsonStatements.push(...jsonSetTableSchemas);
|
|
15208
15816
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -15213,16 +15821,15 @@ var init_snapshotsDiffer = __esm({
|
|
|
15213
15821
|
jsonStatements.push(...jsonTableAlternations);
|
|
15214
15822
|
jsonStatements.push(...jsonAddedCompositePKs);
|
|
15215
15823
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15216
|
-
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15217
15824
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15825
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15218
15826
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15219
|
-
jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
|
|
15220
15827
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15221
15828
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15222
15829
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
|
15223
15830
|
jsonStatements.push(...dropEnums);
|
|
15224
15831
|
jsonStatements.push(...dropSchemas);
|
|
15225
|
-
const sqlStatements = fromJson(jsonStatements, "
|
|
15832
|
+
const sqlStatements = fromJson(jsonStatements, "pg");
|
|
15226
15833
|
const uniqueSqlStatements = [];
|
|
15227
15834
|
sqlStatements.forEach((ss) => {
|
|
15228
15835
|
if (!uniqueSqlStatements.includes(ss)) {
|
|
@@ -15360,8 +15967,8 @@ var init_snapshotsDiffer = __esm({
|
|
|
15360
15967
|
const jsonDeletedUniqueConstraints = [];
|
|
15361
15968
|
const jsonAlteredUniqueConstraints = [];
|
|
15362
15969
|
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
|
15363
|
-
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
|
15364
15970
|
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
|
15971
|
+
const jsonAddColumnsStatemets = columnDeletes.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
|
15365
15972
|
alteredTables.forEach((it) => {
|
|
15366
15973
|
let addedColumns = [];
|
|
15367
15974
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
|
@@ -15475,13 +16082,6 @@ var init_snapshotsDiffer = __esm({
|
|
|
15475
16082
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15476
16083
|
);
|
|
15477
16084
|
});
|
|
15478
|
-
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15479
|
-
return prepareCreateReferencesJson(
|
|
15480
|
-
it.name,
|
|
15481
|
-
it.schema,
|
|
15482
|
-
it.foreignKeys
|
|
15483
|
-
);
|
|
15484
|
-
}).flat();
|
|
15485
16085
|
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
15486
16086
|
const forAdded = prepareCreateReferencesJson(
|
|
15487
16087
|
it.name,
|
|
@@ -15522,10 +16122,9 @@ var init_snapshotsDiffer = __esm({
|
|
|
15522
16122
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
15523
16123
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
15524
16124
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15525
|
-
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15526
16125
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15527
|
-
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15528
16126
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
16127
|
+
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15529
16128
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15530
16129
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15531
16130
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
@@ -16110,7 +16709,7 @@ var init_sqlgenerator = __esm({
|
|
|
16110
16709
|
};
|
|
16111
16710
|
PgCreateTableConvertor = class extends Convertor {
|
|
16112
16711
|
can(statement, dialect7) {
|
|
16113
|
-
return statement.type === "create_table" && dialect7 === "
|
|
16712
|
+
return statement.type === "create_table" && dialect7 === "pg";
|
|
16114
16713
|
}
|
|
16115
16714
|
convert(st) {
|
|
16116
16715
|
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
|
@@ -16252,7 +16851,7 @@ var init_sqlgenerator = __esm({
|
|
|
16252
16851
|
};
|
|
16253
16852
|
PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
|
16254
16853
|
can(statement, dialect7) {
|
|
16255
|
-
return statement.type === "create_unique_constraint" && dialect7 === "
|
|
16854
|
+
return statement.type === "create_unique_constraint" && dialect7 === "pg";
|
|
16256
16855
|
}
|
|
16257
16856
|
convert(statement) {
|
|
16258
16857
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
|
@@ -16262,7 +16861,7 @@ var init_sqlgenerator = __esm({
|
|
|
16262
16861
|
};
|
|
16263
16862
|
PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
|
16264
16863
|
can(statement, dialect7) {
|
|
16265
|
-
return statement.type === "delete_unique_constraint" && dialect7 === "
|
|
16864
|
+
return statement.type === "delete_unique_constraint" && dialect7 === "pg";
|
|
16266
16865
|
}
|
|
16267
16866
|
convert(statement) {
|
|
16268
16867
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
|
@@ -16351,7 +16950,7 @@ var init_sqlgenerator = __esm({
|
|
|
16351
16950
|
};
|
|
16352
16951
|
PgDropTableConvertor = class extends Convertor {
|
|
16353
16952
|
can(statement, dialect7) {
|
|
16354
|
-
return statement.type === "drop_table" && dialect7 === "
|
|
16953
|
+
return statement.type === "drop_table" && dialect7 === "pg";
|
|
16355
16954
|
}
|
|
16356
16955
|
convert(statement) {
|
|
16357
16956
|
const { tableName, schema: schema4 } = statement;
|
|
@@ -16379,7 +16978,7 @@ var init_sqlgenerator = __esm({
|
|
|
16379
16978
|
};
|
|
16380
16979
|
PgRenameTableConvertor = class extends Convertor {
|
|
16381
16980
|
can(statement, dialect7) {
|
|
16382
|
-
return statement.type === "rename_table" && dialect7 === "
|
|
16981
|
+
return statement.type === "rename_table" && dialect7 === "pg";
|
|
16383
16982
|
}
|
|
16384
16983
|
convert(statement) {
|
|
16385
16984
|
const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
|
|
@@ -16410,7 +17009,7 @@ var init_sqlgenerator = __esm({
|
|
|
16410
17009
|
};
|
|
16411
17010
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
|
16412
17011
|
can(statement, dialect7) {
|
|
16413
|
-
return statement.type === "alter_table_rename_column" && dialect7 === "
|
|
17012
|
+
return statement.type === "alter_table_rename_column" && dialect7 === "pg";
|
|
16414
17013
|
}
|
|
16415
17014
|
convert(statement) {
|
|
16416
17015
|
const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
|
|
@@ -16438,7 +17037,7 @@ var init_sqlgenerator = __esm({
|
|
|
16438
17037
|
};
|
|
16439
17038
|
PgAlterTableDropColumnConvertor = class extends Convertor {
|
|
16440
17039
|
can(statement, dialect7) {
|
|
16441
|
-
return statement.type === "alter_table_drop_column" && dialect7 === "
|
|
17040
|
+
return statement.type === "alter_table_drop_column" && dialect7 === "pg";
|
|
16442
17041
|
}
|
|
16443
17042
|
convert(statement) {
|
|
16444
17043
|
const { tableName, columnName, schema: schema4 } = statement;
|
|
@@ -16466,7 +17065,7 @@ var init_sqlgenerator = __esm({
|
|
|
16466
17065
|
};
|
|
16467
17066
|
PgAlterTableAddColumnConvertor = class extends Convertor {
|
|
16468
17067
|
can(statement, dialect7) {
|
|
16469
|
-
return statement.type === "alter_table_add_column" && dialect7 === "
|
|
17068
|
+
return statement.type === "alter_table_add_column" && dialect7 === "pg";
|
|
16470
17069
|
}
|
|
16471
17070
|
convert(statement) {
|
|
16472
17071
|
const { tableName, column: column4, schema: schema4 } = statement;
|
|
@@ -16511,7 +17110,7 @@ var init_sqlgenerator = __esm({
|
|
|
16511
17110
|
};
|
|
16512
17111
|
PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
|
16513
17112
|
can(statement, dialect7) {
|
|
16514
|
-
return statement.type === "alter_table_alter_column_set_type" && dialect7 === "
|
|
17113
|
+
return statement.type === "alter_table_alter_column_set_type" && dialect7 === "pg";
|
|
16515
17114
|
}
|
|
16516
17115
|
convert(statement) {
|
|
16517
17116
|
const { tableName, columnName, newDataType, schema: schema4 } = statement;
|
|
@@ -16536,7 +17135,7 @@ var init_sqlgenerator = __esm({
|
|
|
16536
17135
|
};
|
|
16537
17136
|
PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
|
16538
17137
|
can(statement, dialect7) {
|
|
16539
|
-
return statement.type === "alter_table_alter_column_set_default" && dialect7 === "
|
|
17138
|
+
return statement.type === "alter_table_alter_column_set_default" && dialect7 === "pg";
|
|
16540
17139
|
}
|
|
16541
17140
|
convert(statement) {
|
|
16542
17141
|
const { tableName, columnName, schema: schema4 } = statement;
|
|
@@ -16561,7 +17160,7 @@ var init_sqlgenerator = __esm({
|
|
|
16561
17160
|
};
|
|
16562
17161
|
PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
|
16563
17162
|
can(statement, dialect7) {
|
|
16564
|
-
return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "
|
|
17163
|
+
return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "pg";
|
|
16565
17164
|
}
|
|
16566
17165
|
convert(statement) {
|
|
16567
17166
|
const { tableName, columnName, schema: schema4 } = statement;
|
|
@@ -16673,7 +17272,7 @@ var init_sqlgenerator = __esm({
|
|
|
16673
17272
|
};
|
|
16674
17273
|
PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
|
16675
17274
|
can(statement, dialect7) {
|
|
16676
|
-
return statement.type === "create_composite_pk" && dialect7 === "
|
|
17275
|
+
return statement.type === "create_composite_pk" && dialect7 === "pg";
|
|
16677
17276
|
}
|
|
16678
17277
|
convert(statement) {
|
|
16679
17278
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
|
@@ -16683,7 +17282,7 @@ var init_sqlgenerator = __esm({
|
|
|
16683
17282
|
};
|
|
16684
17283
|
PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
|
16685
17284
|
can(statement, dialect7) {
|
|
16686
|
-
return statement.type === "delete_composite_pk" && dialect7 === "
|
|
17285
|
+
return statement.type === "delete_composite_pk" && dialect7 === "pg";
|
|
16687
17286
|
}
|
|
16688
17287
|
convert(statement) {
|
|
16689
17288
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
|
@@ -16693,7 +17292,7 @@ var init_sqlgenerator = __esm({
|
|
|
16693
17292
|
};
|
|
16694
17293
|
PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
|
16695
17294
|
can(statement, dialect7) {
|
|
16696
|
-
return statement.type === "alter_composite_pk" && dialect7 === "
|
|
17295
|
+
return statement.type === "alter_composite_pk" && dialect7 === "pg";
|
|
16697
17296
|
}
|
|
16698
17297
|
convert(statement) {
|
|
16699
17298
|
const { name, columns } = PgSquasher.unsquashPK(statement.old);
|
|
@@ -16816,7 +17415,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16816
17415
|
};
|
|
16817
17416
|
PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
|
16818
17417
|
can(statement, dialect7) {
|
|
16819
|
-
return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "
|
|
17418
|
+
return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "pg";
|
|
16820
17419
|
}
|
|
16821
17420
|
convert(statement) {
|
|
16822
17421
|
const { tableName, columnName } = statement;
|
|
@@ -16826,7 +17425,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16826
17425
|
};
|
|
16827
17426
|
PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
|
|
16828
17427
|
can(statement, dialect7) {
|
|
16829
|
-
return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "
|
|
17428
|
+
return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "pg";
|
|
16830
17429
|
}
|
|
16831
17430
|
convert(statement) {
|
|
16832
17431
|
const { tableName, columnName, schema: schema4 } = statement;
|
|
@@ -16850,7 +17449,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16850
17449
|
};
|
|
16851
17450
|
PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
|
16852
17451
|
can(statement, dialect7) {
|
|
16853
|
-
return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "
|
|
17452
|
+
return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "pg";
|
|
16854
17453
|
}
|
|
16855
17454
|
convert(statement) {
|
|
16856
17455
|
const { tableName, columnName } = statement;
|
|
@@ -16905,7 +17504,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16905
17504
|
};
|
|
16906
17505
|
PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
|
16907
17506
|
can(statement, dialect7) {
|
|
16908
|
-
return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "
|
|
17507
|
+
return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "pg";
|
|
16909
17508
|
}
|
|
16910
17509
|
convert(statement) {
|
|
16911
17510
|
const { tableName, columnName } = statement;
|
|
@@ -16930,7 +17529,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16930
17529
|
};
|
|
16931
17530
|
PgCreateForeignKeyConvertor = class extends Convertor {
|
|
16932
17531
|
can(statement, dialect7) {
|
|
16933
|
-
return statement.type === "create_reference" && dialect7 === "
|
|
17532
|
+
return statement.type === "create_reference" && dialect7 === "pg";
|
|
16934
17533
|
}
|
|
16935
17534
|
convert(statement) {
|
|
16936
17535
|
const {
|
|
@@ -16995,7 +17594,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16995
17594
|
};
|
|
16996
17595
|
PgAlterForeignKeyConvertor = class extends Convertor {
|
|
16997
17596
|
can(statement, dialect7) {
|
|
16998
|
-
return statement.type === "alter_reference" && dialect7 === "
|
|
17597
|
+
return statement.type === "alter_reference" && dialect7 === "pg";
|
|
16999
17598
|
}
|
|
17000
17599
|
convert(statement) {
|
|
17001
17600
|
const newFk = PgSquasher.unsquashFK(statement.data);
|
|
@@ -17034,7 +17633,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17034
17633
|
};
|
|
17035
17634
|
PgDeleteForeignKeyConvertor = class extends Convertor {
|
|
17036
17635
|
can(statement, dialect7) {
|
|
17037
|
-
return statement.type === "delete_reference" && dialect7 === "
|
|
17636
|
+
return statement.type === "delete_reference" && dialect7 === "pg";
|
|
17038
17637
|
}
|
|
17039
17638
|
convert(statement) {
|
|
17040
17639
|
const tableFrom = statement.tableName;
|
|
@@ -17071,7 +17670,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17071
17670
|
};
|
|
17072
17671
|
CreatePgIndexConvertor = class extends Convertor {
|
|
17073
17672
|
can(statement, dialect7) {
|
|
17074
|
-
return statement.type === "create_index" && dialect7 === "
|
|
17673
|
+
return statement.type === "create_index" && dialect7 === "pg";
|
|
17075
17674
|
}
|
|
17076
17675
|
convert(statement) {
|
|
17077
17676
|
const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
|
|
@@ -17110,7 +17709,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17110
17709
|
};
|
|
17111
17710
|
PgDropIndexConvertor = class extends Convertor {
|
|
17112
17711
|
can(statement, dialect7) {
|
|
17113
|
-
return statement.type === "drop_index" && dialect7 === "
|
|
17712
|
+
return statement.type === "drop_index" && dialect7 === "pg";
|
|
17114
17713
|
}
|
|
17115
17714
|
convert(statement) {
|
|
17116
17715
|
const { name } = PgSquasher.unsquashIdx(statement.data);
|
|
@@ -17119,7 +17718,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17119
17718
|
};
|
|
17120
17719
|
PgCreateSchemaConvertor = class extends Convertor {
|
|
17121
17720
|
can(statement, dialect7) {
|
|
17122
|
-
return statement.type === "create_schema" && dialect7 === "
|
|
17721
|
+
return statement.type === "create_schema" && dialect7 === "pg";
|
|
17123
17722
|
}
|
|
17124
17723
|
convert(statement) {
|
|
17125
17724
|
const { name } = statement;
|
|
@@ -17129,7 +17728,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17129
17728
|
};
|
|
17130
17729
|
PgRenameSchemaConvertor = class extends Convertor {
|
|
17131
17730
|
can(statement, dialect7) {
|
|
17132
|
-
return statement.type === "rename_schema" && dialect7 === "
|
|
17731
|
+
return statement.type === "rename_schema" && dialect7 === "pg";
|
|
17133
17732
|
}
|
|
17134
17733
|
convert(statement) {
|
|
17135
17734
|
const { from, to } = statement;
|
|
@@ -17139,7 +17738,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17139
17738
|
};
|
|
17140
17739
|
PgDropSchemaConvertor = class extends Convertor {
|
|
17141
17740
|
can(statement, dialect7) {
|
|
17142
|
-
return statement.type === "drop_schema" && dialect7 === "
|
|
17741
|
+
return statement.type === "drop_schema" && dialect7 === "pg";
|
|
17143
17742
|
}
|
|
17144
17743
|
convert(statement) {
|
|
17145
17744
|
const { name } = statement;
|
|
@@ -17149,7 +17748,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17149
17748
|
};
|
|
17150
17749
|
PgAlterTableSetSchemaConvertor = class extends Convertor {
|
|
17151
17750
|
can(statement, dialect7) {
|
|
17152
|
-
return statement.type === "alter_table_set_schema" && dialect7 === "
|
|
17751
|
+
return statement.type === "alter_table_set_schema" && dialect7 === "pg";
|
|
17153
17752
|
}
|
|
17154
17753
|
convert(statement) {
|
|
17155
17754
|
const { tableName, schemaFrom, schemaTo } = statement;
|
|
@@ -17159,7 +17758,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17159
17758
|
};
|
|
17160
17759
|
PgAlterTableSetNewSchemaConvertor = class extends Convertor {
|
|
17161
17760
|
can(statement, dialect7) {
|
|
17162
|
-
return statement.type === "alter_table_set_new_schema" && dialect7 === "
|
|
17761
|
+
return statement.type === "alter_table_set_new_schema" && dialect7 === "pg";
|
|
17163
17762
|
}
|
|
17164
17763
|
convert(statement) {
|
|
17165
17764
|
const { tableName, to, from } = statement;
|
|
@@ -17170,7 +17769,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
17170
17769
|
};
|
|
17171
17770
|
PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
|
17172
17771
|
can(statement, dialect7) {
|
|
17173
|
-
return statement.type === "alter_table_remove_from_schema" && dialect7 === "
|
|
17772
|
+
return statement.type === "alter_table_remove_from_schema" && dialect7 === "pg";
|
|
17174
17773
|
}
|
|
17175
17774
|
convert(statement) {
|
|
17176
17775
|
const { tableName, schema: schema4 } = statement;
|
|
@@ -18945,7 +19544,7 @@ var pgSuggestions = async (db, statements) => {
|
|
|
18945
19544
|
}
|
|
18946
19545
|
}
|
|
18947
19546
|
}
|
|
18948
|
-
const stmnt = fromJson([statement], "
|
|
19547
|
+
const stmnt = fromJson([statement], "pg")[0];
|
|
18949
19548
|
if (typeof stmnt !== "undefined") {
|
|
18950
19549
|
if (statement.type === "drop_table") {
|
|
18951
19550
|
statementsToExecute.push(
|
|
@@ -19073,9 +19672,6 @@ String.prototype.squashSpaces = function() {
|
|
|
19073
19672
|
String.prototype.camelCase = function() {
|
|
19074
19673
|
return camelCase(String(this));
|
|
19075
19674
|
};
|
|
19076
|
-
String.prototype.capitalise = function() {
|
|
19077
|
-
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
19078
|
-
};
|
|
19079
19675
|
String.prototype.concatIf = function(it, condition) {
|
|
19080
19676
|
return condition ? `${this}${it}` : String(this);
|
|
19081
19677
|
};
|