@magiclabs.ai/magicbook-client 0.7.6-canary → 0.7.7-canary
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/index.cjs +269 -74
- package/index.cjs.map +1 -1
- package/index.d.cts +535 -533
- package/index.d.ts +535 -533
- package/index.js +268 -74
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,7 +15,12 @@ var states = [
|
|
|
15
15
|
"error",
|
|
16
16
|
"cancelled"
|
|
17
17
|
];
|
|
18
|
-
var statesToCloseWS = [
|
|
18
|
+
var statesToCloseWS = [
|
|
19
|
+
"error",
|
|
20
|
+
"timeout",
|
|
21
|
+
"ready",
|
|
22
|
+
"cancelled"
|
|
23
|
+
];
|
|
19
24
|
var statesToReport = ["error", "timeout"];
|
|
20
25
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
21
26
|
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
@@ -228,6 +233,7 @@ var cancelledEventDetail = {
|
|
|
228
233
|
progress: 100,
|
|
229
234
|
message: "Design canceled"
|
|
230
235
|
};
|
|
236
|
+
var formats = ["galleon", "snapfish"];
|
|
231
237
|
|
|
232
238
|
// ../../core/utils/toolbox.ts
|
|
233
239
|
function mergeNestedObject(obj, objToMerge) {
|
|
@@ -301,7 +307,7 @@ function getStyleIdBySlug(slug) {
|
|
|
301
307
|
return void 0;
|
|
302
308
|
}
|
|
303
309
|
|
|
304
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
310
|
+
// ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
|
305
311
|
var util;
|
|
306
312
|
(function(util2) {
|
|
307
313
|
util2.assertEqual = (val) => val;
|
|
@@ -455,7 +461,7 @@ var quotelessJson = (obj) => {
|
|
|
455
461
|
const json = JSON.stringify(obj, null, 2);
|
|
456
462
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
457
463
|
};
|
|
458
|
-
var ZodError = class extends Error {
|
|
464
|
+
var ZodError = class _ZodError extends Error {
|
|
459
465
|
constructor(issues) {
|
|
460
466
|
super();
|
|
461
467
|
this.issues = [];
|
|
@@ -513,6 +519,11 @@ var ZodError = class extends Error {
|
|
|
513
519
|
processError(this);
|
|
514
520
|
return fieldErrors;
|
|
515
521
|
}
|
|
522
|
+
static assert(value) {
|
|
523
|
+
if (!(value instanceof _ZodError)) {
|
|
524
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
516
527
|
toString() {
|
|
517
528
|
return this.message;
|
|
518
529
|
}
|
|
@@ -655,6 +666,13 @@ var makeIssue = (params) => {
|
|
|
655
666
|
...issueData,
|
|
656
667
|
path: fullPath
|
|
657
668
|
};
|
|
669
|
+
if (issueData.message !== void 0) {
|
|
670
|
+
return {
|
|
671
|
+
...issueData,
|
|
672
|
+
path: fullPath,
|
|
673
|
+
message: issueData.message
|
|
674
|
+
};
|
|
675
|
+
}
|
|
658
676
|
let errorMessage = "";
|
|
659
677
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
660
678
|
for (const map of maps) {
|
|
@@ -663,11 +681,12 @@ var makeIssue = (params) => {
|
|
|
663
681
|
return {
|
|
664
682
|
...issueData,
|
|
665
683
|
path: fullPath,
|
|
666
|
-
message:
|
|
684
|
+
message: errorMessage
|
|
667
685
|
};
|
|
668
686
|
};
|
|
669
687
|
var EMPTY_PATH = [];
|
|
670
688
|
function addIssueToContext(ctx, issueData) {
|
|
689
|
+
const overrideMap = getErrorMap();
|
|
671
690
|
const issue = makeIssue({
|
|
672
691
|
issueData,
|
|
673
692
|
data: ctx.data,
|
|
@@ -675,8 +694,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
675
694
|
errorMaps: [
|
|
676
695
|
ctx.common.contextualErrorMap,
|
|
677
696
|
ctx.schemaErrorMap,
|
|
678
|
-
|
|
679
|
-
errorMap
|
|
697
|
+
overrideMap,
|
|
698
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
680
699
|
// then global default map
|
|
681
700
|
].filter((x) => !!x)
|
|
682
701
|
});
|
|
@@ -708,9 +727,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
708
727
|
static async mergeObjectAsync(status, pairs) {
|
|
709
728
|
const syncPairs = [];
|
|
710
729
|
for (const pair of pairs) {
|
|
730
|
+
const key = await pair.key;
|
|
731
|
+
const value = await pair.value;
|
|
711
732
|
syncPairs.push({
|
|
712
|
-
key
|
|
713
|
-
value
|
|
733
|
+
key,
|
|
734
|
+
value
|
|
714
735
|
});
|
|
715
736
|
}
|
|
716
737
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -743,11 +764,29 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
743
764
|
var isDirty = (x) => x.status === "dirty";
|
|
744
765
|
var isValid = (x) => x.status === "valid";
|
|
745
766
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
767
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
768
|
+
if (kind === "a" && !f)
|
|
769
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
770
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
771
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
772
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
773
|
+
}
|
|
774
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
775
|
+
if (kind === "m")
|
|
776
|
+
throw new TypeError("Private method is not writable");
|
|
777
|
+
if (kind === "a" && !f)
|
|
778
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
779
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
780
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
781
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
782
|
+
}
|
|
746
783
|
var errorUtil;
|
|
747
784
|
(function(errorUtil2) {
|
|
748
785
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
749
786
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
750
787
|
})(errorUtil || (errorUtil = {}));
|
|
788
|
+
var _ZodEnum_cache;
|
|
789
|
+
var _ZodNativeEnum_cache;
|
|
751
790
|
var ParseInputLazyPath = class {
|
|
752
791
|
constructor(parent, value, path, key) {
|
|
753
792
|
this._cachedPath = [];
|
|
@@ -796,12 +835,17 @@ function processCreateParams(params) {
|
|
|
796
835
|
if (errorMap2)
|
|
797
836
|
return { errorMap: errorMap2, description };
|
|
798
837
|
const customMap = (iss, ctx) => {
|
|
799
|
-
|
|
800
|
-
|
|
838
|
+
var _a, _b;
|
|
839
|
+
const { message } = params;
|
|
840
|
+
if (iss.code === "invalid_enum_value") {
|
|
841
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
842
|
+
}
|
|
801
843
|
if (typeof ctx.data === "undefined") {
|
|
802
|
-
return { message:
|
|
844
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
803
845
|
}
|
|
804
|
-
|
|
846
|
+
if (iss.code !== "invalid_type")
|
|
847
|
+
return { message: ctx.defaultError };
|
|
848
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
805
849
|
};
|
|
806
850
|
return { errorMap: customMap, description };
|
|
807
851
|
}
|
|
@@ -1049,35 +1093,40 @@ var ZodType = class {
|
|
|
1049
1093
|
}
|
|
1050
1094
|
};
|
|
1051
1095
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1052
|
-
var cuid2Regex = /^[
|
|
1096
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
1053
1097
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1054
1098
|
var 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;
|
|
1055
|
-
var
|
|
1099
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1100
|
+
var 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)?)??$/;
|
|
1101
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1056
1102
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1057
1103
|
var emojiRegex;
|
|
1058
|
-
var ipv4Regex = /^((
|
|
1104
|
+
var 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])$/;
|
|
1059
1105
|
var 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})))$/;
|
|
1060
|
-
var
|
|
1106
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1107
|
+
var 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])))`;
|
|
1108
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1109
|
+
function timeRegexSource(args) {
|
|
1110
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1061
1111
|
if (args.precision) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
1066
|
-
}
|
|
1067
|
-
} else if (args.precision === 0) {
|
|
1068
|
-
if (args.offset) {
|
|
1069
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1070
|
-
} else {
|
|
1071
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
1072
|
-
}
|
|
1073
|
-
} else {
|
|
1074
|
-
if (args.offset) {
|
|
1075
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1076
|
-
} else {
|
|
1077
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
1078
|
-
}
|
|
1112
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1113
|
+
} else if (args.precision == null) {
|
|
1114
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1079
1115
|
}
|
|
1080
|
-
|
|
1116
|
+
return regex;
|
|
1117
|
+
}
|
|
1118
|
+
function timeRegex(args) {
|
|
1119
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1120
|
+
}
|
|
1121
|
+
function datetimeRegex(args) {
|
|
1122
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1123
|
+
const opts = [];
|
|
1124
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1125
|
+
if (args.offset)
|
|
1126
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1127
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1128
|
+
return new RegExp(`^${regex}$`);
|
|
1129
|
+
}
|
|
1081
1130
|
function isValidIP(ip, version) {
|
|
1082
1131
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1083
1132
|
return true;
|
|
@@ -1095,15 +1144,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1095
1144
|
const parsedType = this._getType(input);
|
|
1096
1145
|
if (parsedType !== ZodParsedType.string) {
|
|
1097
1146
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1098
|
-
addIssueToContext(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
received: ctx2.parsedType
|
|
1104
|
-
}
|
|
1105
|
-
//
|
|
1106
|
-
);
|
|
1147
|
+
addIssueToContext(ctx2, {
|
|
1148
|
+
code: ZodIssueCode.invalid_type,
|
|
1149
|
+
expected: ZodParsedType.string,
|
|
1150
|
+
received: ctx2.parsedType
|
|
1151
|
+
});
|
|
1107
1152
|
return INVALID;
|
|
1108
1153
|
}
|
|
1109
1154
|
const status = new ParseStatus();
|
|
@@ -1194,6 +1239,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1194
1239
|
});
|
|
1195
1240
|
status.dirty();
|
|
1196
1241
|
}
|
|
1242
|
+
} else if (check.kind === "nanoid") {
|
|
1243
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1244
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1245
|
+
addIssueToContext(ctx, {
|
|
1246
|
+
validation: "nanoid",
|
|
1247
|
+
code: ZodIssueCode.invalid_string,
|
|
1248
|
+
message: check.message
|
|
1249
|
+
});
|
|
1250
|
+
status.dirty();
|
|
1251
|
+
}
|
|
1197
1252
|
} else if (check.kind === "cuid") {
|
|
1198
1253
|
if (!cuidRegex.test(input.data)) {
|
|
1199
1254
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1295,6 +1350,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1295
1350
|
});
|
|
1296
1351
|
status.dirty();
|
|
1297
1352
|
}
|
|
1353
|
+
} else if (check.kind === "date") {
|
|
1354
|
+
const regex = dateRegex;
|
|
1355
|
+
if (!regex.test(input.data)) {
|
|
1356
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1357
|
+
addIssueToContext(ctx, {
|
|
1358
|
+
code: ZodIssueCode.invalid_string,
|
|
1359
|
+
validation: "date",
|
|
1360
|
+
message: check.message
|
|
1361
|
+
});
|
|
1362
|
+
status.dirty();
|
|
1363
|
+
}
|
|
1364
|
+
} else if (check.kind === "time") {
|
|
1365
|
+
const regex = timeRegex(check);
|
|
1366
|
+
if (!regex.test(input.data)) {
|
|
1367
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1368
|
+
addIssueToContext(ctx, {
|
|
1369
|
+
code: ZodIssueCode.invalid_string,
|
|
1370
|
+
validation: "time",
|
|
1371
|
+
message: check.message
|
|
1372
|
+
});
|
|
1373
|
+
status.dirty();
|
|
1374
|
+
}
|
|
1375
|
+
} else if (check.kind === "duration") {
|
|
1376
|
+
if (!durationRegex.test(input.data)) {
|
|
1377
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1378
|
+
addIssueToContext(ctx, {
|
|
1379
|
+
validation: "duration",
|
|
1380
|
+
code: ZodIssueCode.invalid_string,
|
|
1381
|
+
message: check.message
|
|
1382
|
+
});
|
|
1383
|
+
status.dirty();
|
|
1384
|
+
}
|
|
1298
1385
|
} else if (check.kind === "ip") {
|
|
1299
1386
|
if (!isValidIP(input.data, check.version)) {
|
|
1300
1387
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1305,6 +1392,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1305
1392
|
});
|
|
1306
1393
|
status.dirty();
|
|
1307
1394
|
}
|
|
1395
|
+
} else if (check.kind === "base64") {
|
|
1396
|
+
if (!base64Regex.test(input.data)) {
|
|
1397
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1398
|
+
addIssueToContext(ctx, {
|
|
1399
|
+
validation: "base64",
|
|
1400
|
+
code: ZodIssueCode.invalid_string,
|
|
1401
|
+
message: check.message
|
|
1402
|
+
});
|
|
1403
|
+
status.dirty();
|
|
1404
|
+
}
|
|
1308
1405
|
} else {
|
|
1309
1406
|
util.assertNever(check);
|
|
1310
1407
|
}
|
|
@@ -1336,6 +1433,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1336
1433
|
uuid(message) {
|
|
1337
1434
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1338
1435
|
}
|
|
1436
|
+
nanoid(message) {
|
|
1437
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1438
|
+
}
|
|
1339
1439
|
cuid(message) {
|
|
1340
1440
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1341
1441
|
}
|
|
@@ -1345,16 +1445,20 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1345
1445
|
ulid(message) {
|
|
1346
1446
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1347
1447
|
}
|
|
1448
|
+
base64(message) {
|
|
1449
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1450
|
+
}
|
|
1348
1451
|
ip(options) {
|
|
1349
1452
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1350
1453
|
}
|
|
1351
1454
|
datetime(options) {
|
|
1352
|
-
var _a;
|
|
1455
|
+
var _a, _b;
|
|
1353
1456
|
if (typeof options === "string") {
|
|
1354
1457
|
return this._addCheck({
|
|
1355
1458
|
kind: "datetime",
|
|
1356
1459
|
precision: null,
|
|
1357
1460
|
offset: false,
|
|
1461
|
+
local: false,
|
|
1358
1462
|
message: options
|
|
1359
1463
|
});
|
|
1360
1464
|
}
|
|
@@ -1362,9 +1466,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1362
1466
|
kind: "datetime",
|
|
1363
1467
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1364
1468
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1469
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1470
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
date(message) {
|
|
1474
|
+
return this._addCheck({ kind: "date", message });
|
|
1475
|
+
}
|
|
1476
|
+
time(options) {
|
|
1477
|
+
if (typeof options === "string") {
|
|
1478
|
+
return this._addCheck({
|
|
1479
|
+
kind: "time",
|
|
1480
|
+
precision: null,
|
|
1481
|
+
message: options
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
return this._addCheck({
|
|
1485
|
+
kind: "time",
|
|
1486
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1365
1487
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1366
1488
|
});
|
|
1367
1489
|
}
|
|
1490
|
+
duration(message) {
|
|
1491
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1492
|
+
}
|
|
1368
1493
|
regex(regex, message) {
|
|
1369
1494
|
return this._addCheck({
|
|
1370
1495
|
kind: "regex",
|
|
@@ -1443,6 +1568,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1443
1568
|
get isDatetime() {
|
|
1444
1569
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1445
1570
|
}
|
|
1571
|
+
get isDate() {
|
|
1572
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1573
|
+
}
|
|
1574
|
+
get isTime() {
|
|
1575
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1576
|
+
}
|
|
1577
|
+
get isDuration() {
|
|
1578
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1579
|
+
}
|
|
1446
1580
|
get isEmail() {
|
|
1447
1581
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1448
1582
|
}
|
|
@@ -1455,6 +1589,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1455
1589
|
get isUUID() {
|
|
1456
1590
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1457
1591
|
}
|
|
1592
|
+
get isNANOID() {
|
|
1593
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1594
|
+
}
|
|
1458
1595
|
get isCUID() {
|
|
1459
1596
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1460
1597
|
}
|
|
@@ -1467,6 +1604,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1467
1604
|
get isIP() {
|
|
1468
1605
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1469
1606
|
}
|
|
1607
|
+
get isBase64() {
|
|
1608
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1609
|
+
}
|
|
1470
1610
|
get minLength() {
|
|
1471
1611
|
let min = null;
|
|
1472
1612
|
for (const ch of this._def.checks) {
|
|
@@ -2380,9 +2520,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2380
2520
|
const syncPairs = [];
|
|
2381
2521
|
for (const pair of pairs) {
|
|
2382
2522
|
const key = await pair.key;
|
|
2523
|
+
const value = await pair.value;
|
|
2383
2524
|
syncPairs.push({
|
|
2384
2525
|
key,
|
|
2385
|
-
value
|
|
2526
|
+
value,
|
|
2386
2527
|
alwaysSet: pair.alwaysSet
|
|
2387
2528
|
});
|
|
2388
2529
|
}
|
|
@@ -2733,15 +2874,25 @@ var getDiscriminator = (type) => {
|
|
|
2733
2874
|
} else if (type instanceof ZodEnum) {
|
|
2734
2875
|
return type.options;
|
|
2735
2876
|
} else if (type instanceof ZodNativeEnum) {
|
|
2736
|
-
return
|
|
2877
|
+
return util.objectValues(type.enum);
|
|
2737
2878
|
} else if (type instanceof ZodDefault) {
|
|
2738
2879
|
return getDiscriminator(type._def.innerType);
|
|
2739
2880
|
} else if (type instanceof ZodUndefined) {
|
|
2740
2881
|
return [void 0];
|
|
2741
2882
|
} else if (type instanceof ZodNull) {
|
|
2742
2883
|
return [null];
|
|
2884
|
+
} else if (type instanceof ZodOptional) {
|
|
2885
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
2886
|
+
} else if (type instanceof ZodNullable) {
|
|
2887
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
2888
|
+
} else if (type instanceof ZodBranded) {
|
|
2889
|
+
return getDiscriminator(type.unwrap());
|
|
2890
|
+
} else if (type instanceof ZodReadonly) {
|
|
2891
|
+
return getDiscriminator(type.unwrap());
|
|
2892
|
+
} else if (type instanceof ZodCatch) {
|
|
2893
|
+
return getDiscriminator(type._def.innerType);
|
|
2743
2894
|
} else {
|
|
2744
|
-
return
|
|
2895
|
+
return [];
|
|
2745
2896
|
}
|
|
2746
2897
|
};
|
|
2747
2898
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2801,7 +2952,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2801
2952
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2802
2953
|
for (const type of options) {
|
|
2803
2954
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2804
|
-
if (!discriminatorValues) {
|
|
2955
|
+
if (!discriminatorValues.length) {
|
|
2805
2956
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2806
2957
|
}
|
|
2807
2958
|
for (const value of discriminatorValues) {
|
|
@@ -3001,7 +3152,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3001
3152
|
for (const key in ctx.data) {
|
|
3002
3153
|
pairs.push({
|
|
3003
3154
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3004
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3155
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3156
|
+
alwaysSet: key in ctx.data
|
|
3005
3157
|
});
|
|
3006
3158
|
}
|
|
3007
3159
|
if (ctx.common.async) {
|
|
@@ -3345,6 +3497,10 @@ function createZodEnum(values, params) {
|
|
|
3345
3497
|
});
|
|
3346
3498
|
}
|
|
3347
3499
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3500
|
+
constructor() {
|
|
3501
|
+
super(...arguments);
|
|
3502
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3503
|
+
}
|
|
3348
3504
|
_parse(input) {
|
|
3349
3505
|
if (typeof input.data !== "string") {
|
|
3350
3506
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3356,7 +3512,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3356
3512
|
});
|
|
3357
3513
|
return INVALID;
|
|
3358
3514
|
}
|
|
3359
|
-
if (this
|
|
3515
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3516
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3517
|
+
}
|
|
3518
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3360
3519
|
const ctx = this._getOrReturnCtx(input);
|
|
3361
3520
|
const expectedValues = this._def.values;
|
|
3362
3521
|
addIssueToContext(ctx, {
|
|
@@ -3392,15 +3551,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3392
3551
|
}
|
|
3393
3552
|
return enumValues;
|
|
3394
3553
|
}
|
|
3395
|
-
extract(values) {
|
|
3396
|
-
return _ZodEnum.create(values
|
|
3554
|
+
extract(values, newDef = this._def) {
|
|
3555
|
+
return _ZodEnum.create(values, {
|
|
3556
|
+
...this._def,
|
|
3557
|
+
...newDef
|
|
3558
|
+
});
|
|
3397
3559
|
}
|
|
3398
|
-
exclude(values) {
|
|
3399
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
3560
|
+
exclude(values, newDef = this._def) {
|
|
3561
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3562
|
+
...this._def,
|
|
3563
|
+
...newDef
|
|
3564
|
+
});
|
|
3400
3565
|
}
|
|
3401
3566
|
};
|
|
3567
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3402
3568
|
ZodEnum.create = createZodEnum;
|
|
3403
3569
|
var ZodNativeEnum = class extends ZodType {
|
|
3570
|
+
constructor() {
|
|
3571
|
+
super(...arguments);
|
|
3572
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3573
|
+
}
|
|
3404
3574
|
_parse(input) {
|
|
3405
3575
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3406
3576
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3413,7 +3583,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3413
3583
|
});
|
|
3414
3584
|
return INVALID;
|
|
3415
3585
|
}
|
|
3416
|
-
if (
|
|
3586
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3587
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3588
|
+
}
|
|
3589
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3417
3590
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3418
3591
|
addIssueToContext(ctx, {
|
|
3419
3592
|
received: ctx.data,
|
|
@@ -3428,6 +3601,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3428
3601
|
return this._def.values;
|
|
3429
3602
|
}
|
|
3430
3603
|
};
|
|
3604
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3431
3605
|
ZodNativeEnum.create = (values, params) => {
|
|
3432
3606
|
return new ZodNativeEnum({
|
|
3433
3607
|
values,
|
|
@@ -3491,26 +3665,38 @@ var ZodEffects = class extends ZodType {
|
|
|
3491
3665
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3492
3666
|
if (effect.type === "preprocess") {
|
|
3493
3667
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
3494
|
-
if (ctx.common.issues.length) {
|
|
3495
|
-
return {
|
|
3496
|
-
status: "dirty",
|
|
3497
|
-
value: ctx.data
|
|
3498
|
-
};
|
|
3499
|
-
}
|
|
3500
3668
|
if (ctx.common.async) {
|
|
3501
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3502
|
-
|
|
3669
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3670
|
+
if (status.value === "aborted")
|
|
3671
|
+
return INVALID;
|
|
3672
|
+
const result = await this._def.schema._parseAsync({
|
|
3503
3673
|
data: processed2,
|
|
3504
3674
|
path: ctx.path,
|
|
3505
3675
|
parent: ctx
|
|
3506
3676
|
});
|
|
3677
|
+
if (result.status === "aborted")
|
|
3678
|
+
return INVALID;
|
|
3679
|
+
if (result.status === "dirty")
|
|
3680
|
+
return DIRTY(result.value);
|
|
3681
|
+
if (status.value === "dirty")
|
|
3682
|
+
return DIRTY(result.value);
|
|
3683
|
+
return result;
|
|
3507
3684
|
});
|
|
3508
3685
|
} else {
|
|
3509
|
-
|
|
3686
|
+
if (status.value === "aborted")
|
|
3687
|
+
return INVALID;
|
|
3688
|
+
const result = this._def.schema._parseSync({
|
|
3510
3689
|
data: processed,
|
|
3511
3690
|
path: ctx.path,
|
|
3512
3691
|
parent: ctx
|
|
3513
3692
|
});
|
|
3693
|
+
if (result.status === "aborted")
|
|
3694
|
+
return INVALID;
|
|
3695
|
+
if (result.status === "dirty")
|
|
3696
|
+
return DIRTY(result.value);
|
|
3697
|
+
if (status.value === "dirty")
|
|
3698
|
+
return DIRTY(result.value);
|
|
3699
|
+
return result;
|
|
3514
3700
|
}
|
|
3515
3701
|
}
|
|
3516
3702
|
if (effect.type === "refinement") {
|
|
@@ -3799,10 +3985,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3799
3985
|
var ZodReadonly = class extends ZodType {
|
|
3800
3986
|
_parse(input) {
|
|
3801
3987
|
const result = this._def.innerType._parse(input);
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3988
|
+
const freeze = (data) => {
|
|
3989
|
+
if (isValid(data)) {
|
|
3990
|
+
data.value = Object.freeze(data.value);
|
|
3991
|
+
}
|
|
3992
|
+
return data;
|
|
3993
|
+
};
|
|
3994
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
3995
|
+
}
|
|
3996
|
+
unwrap() {
|
|
3997
|
+
return this._def.innerType;
|
|
3806
3998
|
}
|
|
3807
3999
|
};
|
|
3808
4000
|
ZodReadonly.create = (type, params) => {
|
|
@@ -3812,7 +4004,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
3812
4004
|
...processCreateParams(params)
|
|
3813
4005
|
});
|
|
3814
4006
|
};
|
|
3815
|
-
|
|
4007
|
+
function custom(check, params = {}, fatal) {
|
|
3816
4008
|
if (check)
|
|
3817
4009
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3818
4010
|
var _a, _b;
|
|
@@ -3824,7 +4016,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
3824
4016
|
}
|
|
3825
4017
|
});
|
|
3826
4018
|
return ZodAny.create();
|
|
3827
|
-
}
|
|
4019
|
+
}
|
|
3828
4020
|
var late = {
|
|
3829
4021
|
object: ZodObject.lazycreate
|
|
3830
4022
|
};
|
|
@@ -3943,6 +4135,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3943
4135
|
ZodParsedType,
|
|
3944
4136
|
getParsedType,
|
|
3945
4137
|
ZodType,
|
|
4138
|
+
datetimeRegex,
|
|
3946
4139
|
ZodString,
|
|
3947
4140
|
ZodNumber,
|
|
3948
4141
|
ZodBigInt,
|
|
@@ -4337,9 +4530,9 @@ var DesignRequest = class {
|
|
|
4337
4530
|
return this;
|
|
4338
4531
|
}
|
|
4339
4532
|
}
|
|
4340
|
-
async getJSON() {
|
|
4533
|
+
async getJSON(format) {
|
|
4341
4534
|
if (this.state === "ready") {
|
|
4342
|
-
return await this.client.engineAPI.books.
|
|
4535
|
+
return await this.client.engineAPI.books.format(this.parentId, format);
|
|
4343
4536
|
} else {
|
|
4344
4537
|
throw new Error("Design request not ready");
|
|
4345
4538
|
}
|
|
@@ -4565,10 +4758,10 @@ var BooksEndpoints = class {
|
|
|
4565
4758
|
});
|
|
4566
4759
|
});
|
|
4567
4760
|
}
|
|
4568
|
-
|
|
4761
|
+
format(bookId, format) {
|
|
4569
4762
|
return handleAsyncFunction(async () => {
|
|
4570
4763
|
const res = await this.engineAPI.fetcher.call({
|
|
4571
|
-
path: `/v1/books/${bookId}/format
|
|
4764
|
+
path: `/v1/books/${bookId}/format/${format}`
|
|
4572
4765
|
});
|
|
4573
4766
|
return bookCreationRequestSchema.parse(res);
|
|
4574
4767
|
});
|
|
@@ -5009,6 +5202,7 @@ export {
|
|
|
5009
5202
|
designOptionsSchema,
|
|
5010
5203
|
designOptionsServerSchema,
|
|
5011
5204
|
embellishmentLevels,
|
|
5205
|
+
formats,
|
|
5012
5206
|
imageAssignmentSchema,
|
|
5013
5207
|
imageDensities,
|
|
5014
5208
|
imageDensityOptionSchema,
|