@magiclabs.ai/magicbook-client 0.7.6 → 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.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
designOptionsSchema: () => designOptionsSchema,
|
|
40
40
|
designOptionsServerSchema: () => designOptionsServerSchema,
|
|
41
41
|
embellishmentLevels: () => embellishmentLevels,
|
|
42
|
+
formats: () => formats,
|
|
42
43
|
imageAssignmentSchema: () => imageAssignmentSchema,
|
|
43
44
|
imageDensities: () => imageDensities,
|
|
44
45
|
imageDensityOptionSchema: () => imageDensityOptionSchema,
|
|
@@ -84,7 +85,12 @@ var states = [
|
|
|
84
85
|
"error",
|
|
85
86
|
"cancelled"
|
|
86
87
|
];
|
|
87
|
-
var statesToCloseWS = [
|
|
88
|
+
var statesToCloseWS = [
|
|
89
|
+
"error",
|
|
90
|
+
"timeout",
|
|
91
|
+
"ready",
|
|
92
|
+
"cancelled"
|
|
93
|
+
];
|
|
88
94
|
var statesToReport = ["error", "timeout"];
|
|
89
95
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
90
96
|
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
@@ -297,6 +303,7 @@ var cancelledEventDetail = {
|
|
|
297
303
|
progress: 100,
|
|
298
304
|
message: "Design canceled"
|
|
299
305
|
};
|
|
306
|
+
var formats = ["galleon", "snapfish"];
|
|
300
307
|
|
|
301
308
|
// ../../core/utils/toolbox.ts
|
|
302
309
|
function mergeNestedObject(obj, objToMerge) {
|
|
@@ -370,7 +377,7 @@ function getStyleIdBySlug(slug) {
|
|
|
370
377
|
return void 0;
|
|
371
378
|
}
|
|
372
379
|
|
|
373
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
380
|
+
// ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
|
374
381
|
var util;
|
|
375
382
|
(function(util2) {
|
|
376
383
|
util2.assertEqual = (val) => val;
|
|
@@ -524,7 +531,7 @@ var quotelessJson = (obj) => {
|
|
|
524
531
|
const json = JSON.stringify(obj, null, 2);
|
|
525
532
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
526
533
|
};
|
|
527
|
-
var ZodError = class extends Error {
|
|
534
|
+
var ZodError = class _ZodError extends Error {
|
|
528
535
|
constructor(issues) {
|
|
529
536
|
super();
|
|
530
537
|
this.issues = [];
|
|
@@ -582,6 +589,11 @@ var ZodError = class extends Error {
|
|
|
582
589
|
processError(this);
|
|
583
590
|
return fieldErrors;
|
|
584
591
|
}
|
|
592
|
+
static assert(value) {
|
|
593
|
+
if (!(value instanceof _ZodError)) {
|
|
594
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
585
597
|
toString() {
|
|
586
598
|
return this.message;
|
|
587
599
|
}
|
|
@@ -724,6 +736,13 @@ var makeIssue = (params) => {
|
|
|
724
736
|
...issueData,
|
|
725
737
|
path: fullPath
|
|
726
738
|
};
|
|
739
|
+
if (issueData.message !== void 0) {
|
|
740
|
+
return {
|
|
741
|
+
...issueData,
|
|
742
|
+
path: fullPath,
|
|
743
|
+
message: issueData.message
|
|
744
|
+
};
|
|
745
|
+
}
|
|
727
746
|
let errorMessage = "";
|
|
728
747
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
729
748
|
for (const map of maps) {
|
|
@@ -732,11 +751,12 @@ var makeIssue = (params) => {
|
|
|
732
751
|
return {
|
|
733
752
|
...issueData,
|
|
734
753
|
path: fullPath,
|
|
735
|
-
message:
|
|
754
|
+
message: errorMessage
|
|
736
755
|
};
|
|
737
756
|
};
|
|
738
757
|
var EMPTY_PATH = [];
|
|
739
758
|
function addIssueToContext(ctx, issueData) {
|
|
759
|
+
const overrideMap = getErrorMap();
|
|
740
760
|
const issue = makeIssue({
|
|
741
761
|
issueData,
|
|
742
762
|
data: ctx.data,
|
|
@@ -744,8 +764,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
744
764
|
errorMaps: [
|
|
745
765
|
ctx.common.contextualErrorMap,
|
|
746
766
|
ctx.schemaErrorMap,
|
|
747
|
-
|
|
748
|
-
errorMap
|
|
767
|
+
overrideMap,
|
|
768
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
749
769
|
// then global default map
|
|
750
770
|
].filter((x) => !!x)
|
|
751
771
|
});
|
|
@@ -777,9 +797,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
777
797
|
static async mergeObjectAsync(status, pairs) {
|
|
778
798
|
const syncPairs = [];
|
|
779
799
|
for (const pair of pairs) {
|
|
800
|
+
const key = await pair.key;
|
|
801
|
+
const value = await pair.value;
|
|
780
802
|
syncPairs.push({
|
|
781
|
-
key
|
|
782
|
-
value
|
|
803
|
+
key,
|
|
804
|
+
value
|
|
783
805
|
});
|
|
784
806
|
}
|
|
785
807
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -812,11 +834,29 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
812
834
|
var isDirty = (x) => x.status === "dirty";
|
|
813
835
|
var isValid = (x) => x.status === "valid";
|
|
814
836
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
837
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
838
|
+
if (kind === "a" && !f)
|
|
839
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
840
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
841
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
842
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
843
|
+
}
|
|
844
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
845
|
+
if (kind === "m")
|
|
846
|
+
throw new TypeError("Private method is not writable");
|
|
847
|
+
if (kind === "a" && !f)
|
|
848
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
849
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
850
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
851
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
852
|
+
}
|
|
815
853
|
var errorUtil;
|
|
816
854
|
(function(errorUtil2) {
|
|
817
855
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
818
856
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
819
857
|
})(errorUtil || (errorUtil = {}));
|
|
858
|
+
var _ZodEnum_cache;
|
|
859
|
+
var _ZodNativeEnum_cache;
|
|
820
860
|
var ParseInputLazyPath = class {
|
|
821
861
|
constructor(parent, value, path, key) {
|
|
822
862
|
this._cachedPath = [];
|
|
@@ -865,12 +905,17 @@ function processCreateParams(params) {
|
|
|
865
905
|
if (errorMap2)
|
|
866
906
|
return { errorMap: errorMap2, description };
|
|
867
907
|
const customMap = (iss, ctx) => {
|
|
868
|
-
|
|
869
|
-
|
|
908
|
+
var _a, _b;
|
|
909
|
+
const { message } = params;
|
|
910
|
+
if (iss.code === "invalid_enum_value") {
|
|
911
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
912
|
+
}
|
|
870
913
|
if (typeof ctx.data === "undefined") {
|
|
871
|
-
return { message:
|
|
914
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
872
915
|
}
|
|
873
|
-
|
|
916
|
+
if (iss.code !== "invalid_type")
|
|
917
|
+
return { message: ctx.defaultError };
|
|
918
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
874
919
|
};
|
|
875
920
|
return { errorMap: customMap, description };
|
|
876
921
|
}
|
|
@@ -1118,35 +1163,40 @@ var ZodType = class {
|
|
|
1118
1163
|
}
|
|
1119
1164
|
};
|
|
1120
1165
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1121
|
-
var cuid2Regex = /^[
|
|
1166
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
1122
1167
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1123
1168
|
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;
|
|
1124
|
-
var
|
|
1169
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1170
|
+
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)?)??$/;
|
|
1171
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1125
1172
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1126
1173
|
var emojiRegex;
|
|
1127
|
-
var ipv4Regex = /^((
|
|
1174
|
+
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])$/;
|
|
1128
1175
|
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})))$/;
|
|
1129
|
-
var
|
|
1176
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1177
|
+
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])))`;
|
|
1178
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1179
|
+
function timeRegexSource(args) {
|
|
1180
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1130
1181
|
if (args.precision) {
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
1135
|
-
}
|
|
1136
|
-
} else if (args.precision === 0) {
|
|
1137
|
-
if (args.offset) {
|
|
1138
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1139
|
-
} else {
|
|
1140
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
1141
|
-
}
|
|
1142
|
-
} else {
|
|
1143
|
-
if (args.offset) {
|
|
1144
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1145
|
-
} else {
|
|
1146
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
1147
|
-
}
|
|
1182
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1183
|
+
} else if (args.precision == null) {
|
|
1184
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1148
1185
|
}
|
|
1149
|
-
|
|
1186
|
+
return regex;
|
|
1187
|
+
}
|
|
1188
|
+
function timeRegex(args) {
|
|
1189
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1190
|
+
}
|
|
1191
|
+
function datetimeRegex(args) {
|
|
1192
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1193
|
+
const opts = [];
|
|
1194
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1195
|
+
if (args.offset)
|
|
1196
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1197
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1198
|
+
return new RegExp(`^${regex}$`);
|
|
1199
|
+
}
|
|
1150
1200
|
function isValidIP(ip, version) {
|
|
1151
1201
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1152
1202
|
return true;
|
|
@@ -1164,15 +1214,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1164
1214
|
const parsedType = this._getType(input);
|
|
1165
1215
|
if (parsedType !== ZodParsedType.string) {
|
|
1166
1216
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1167
|
-
addIssueToContext(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
received: ctx2.parsedType
|
|
1173
|
-
}
|
|
1174
|
-
//
|
|
1175
|
-
);
|
|
1217
|
+
addIssueToContext(ctx2, {
|
|
1218
|
+
code: ZodIssueCode.invalid_type,
|
|
1219
|
+
expected: ZodParsedType.string,
|
|
1220
|
+
received: ctx2.parsedType
|
|
1221
|
+
});
|
|
1176
1222
|
return INVALID;
|
|
1177
1223
|
}
|
|
1178
1224
|
const status = new ParseStatus();
|
|
@@ -1263,6 +1309,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1263
1309
|
});
|
|
1264
1310
|
status.dirty();
|
|
1265
1311
|
}
|
|
1312
|
+
} else if (check.kind === "nanoid") {
|
|
1313
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1314
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1315
|
+
addIssueToContext(ctx, {
|
|
1316
|
+
validation: "nanoid",
|
|
1317
|
+
code: ZodIssueCode.invalid_string,
|
|
1318
|
+
message: check.message
|
|
1319
|
+
});
|
|
1320
|
+
status.dirty();
|
|
1321
|
+
}
|
|
1266
1322
|
} else if (check.kind === "cuid") {
|
|
1267
1323
|
if (!cuidRegex.test(input.data)) {
|
|
1268
1324
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1364,6 +1420,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1364
1420
|
});
|
|
1365
1421
|
status.dirty();
|
|
1366
1422
|
}
|
|
1423
|
+
} else if (check.kind === "date") {
|
|
1424
|
+
const regex = dateRegex;
|
|
1425
|
+
if (!regex.test(input.data)) {
|
|
1426
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1427
|
+
addIssueToContext(ctx, {
|
|
1428
|
+
code: ZodIssueCode.invalid_string,
|
|
1429
|
+
validation: "date",
|
|
1430
|
+
message: check.message
|
|
1431
|
+
});
|
|
1432
|
+
status.dirty();
|
|
1433
|
+
}
|
|
1434
|
+
} else if (check.kind === "time") {
|
|
1435
|
+
const regex = timeRegex(check);
|
|
1436
|
+
if (!regex.test(input.data)) {
|
|
1437
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1438
|
+
addIssueToContext(ctx, {
|
|
1439
|
+
code: ZodIssueCode.invalid_string,
|
|
1440
|
+
validation: "time",
|
|
1441
|
+
message: check.message
|
|
1442
|
+
});
|
|
1443
|
+
status.dirty();
|
|
1444
|
+
}
|
|
1445
|
+
} else if (check.kind === "duration") {
|
|
1446
|
+
if (!durationRegex.test(input.data)) {
|
|
1447
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1448
|
+
addIssueToContext(ctx, {
|
|
1449
|
+
validation: "duration",
|
|
1450
|
+
code: ZodIssueCode.invalid_string,
|
|
1451
|
+
message: check.message
|
|
1452
|
+
});
|
|
1453
|
+
status.dirty();
|
|
1454
|
+
}
|
|
1367
1455
|
} else if (check.kind === "ip") {
|
|
1368
1456
|
if (!isValidIP(input.data, check.version)) {
|
|
1369
1457
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1374,6 +1462,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1374
1462
|
});
|
|
1375
1463
|
status.dirty();
|
|
1376
1464
|
}
|
|
1465
|
+
} else if (check.kind === "base64") {
|
|
1466
|
+
if (!base64Regex.test(input.data)) {
|
|
1467
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1468
|
+
addIssueToContext(ctx, {
|
|
1469
|
+
validation: "base64",
|
|
1470
|
+
code: ZodIssueCode.invalid_string,
|
|
1471
|
+
message: check.message
|
|
1472
|
+
});
|
|
1473
|
+
status.dirty();
|
|
1474
|
+
}
|
|
1377
1475
|
} else {
|
|
1378
1476
|
util.assertNever(check);
|
|
1379
1477
|
}
|
|
@@ -1405,6 +1503,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1405
1503
|
uuid(message) {
|
|
1406
1504
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1407
1505
|
}
|
|
1506
|
+
nanoid(message) {
|
|
1507
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1508
|
+
}
|
|
1408
1509
|
cuid(message) {
|
|
1409
1510
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1410
1511
|
}
|
|
@@ -1414,16 +1515,20 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1414
1515
|
ulid(message) {
|
|
1415
1516
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1416
1517
|
}
|
|
1518
|
+
base64(message) {
|
|
1519
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1520
|
+
}
|
|
1417
1521
|
ip(options) {
|
|
1418
1522
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1419
1523
|
}
|
|
1420
1524
|
datetime(options) {
|
|
1421
|
-
var _a;
|
|
1525
|
+
var _a, _b;
|
|
1422
1526
|
if (typeof options === "string") {
|
|
1423
1527
|
return this._addCheck({
|
|
1424
1528
|
kind: "datetime",
|
|
1425
1529
|
precision: null,
|
|
1426
1530
|
offset: false,
|
|
1531
|
+
local: false,
|
|
1427
1532
|
message: options
|
|
1428
1533
|
});
|
|
1429
1534
|
}
|
|
@@ -1431,9 +1536,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1431
1536
|
kind: "datetime",
|
|
1432
1537
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1433
1538
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1539
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1540
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
date(message) {
|
|
1544
|
+
return this._addCheck({ kind: "date", message });
|
|
1545
|
+
}
|
|
1546
|
+
time(options) {
|
|
1547
|
+
if (typeof options === "string") {
|
|
1548
|
+
return this._addCheck({
|
|
1549
|
+
kind: "time",
|
|
1550
|
+
precision: null,
|
|
1551
|
+
message: options
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
return this._addCheck({
|
|
1555
|
+
kind: "time",
|
|
1556
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1434
1557
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1435
1558
|
});
|
|
1436
1559
|
}
|
|
1560
|
+
duration(message) {
|
|
1561
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1562
|
+
}
|
|
1437
1563
|
regex(regex, message) {
|
|
1438
1564
|
return this._addCheck({
|
|
1439
1565
|
kind: "regex",
|
|
@@ -1512,6 +1638,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1512
1638
|
get isDatetime() {
|
|
1513
1639
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1514
1640
|
}
|
|
1641
|
+
get isDate() {
|
|
1642
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1643
|
+
}
|
|
1644
|
+
get isTime() {
|
|
1645
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1646
|
+
}
|
|
1647
|
+
get isDuration() {
|
|
1648
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1649
|
+
}
|
|
1515
1650
|
get isEmail() {
|
|
1516
1651
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1517
1652
|
}
|
|
@@ -1524,6 +1659,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1524
1659
|
get isUUID() {
|
|
1525
1660
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1526
1661
|
}
|
|
1662
|
+
get isNANOID() {
|
|
1663
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1664
|
+
}
|
|
1527
1665
|
get isCUID() {
|
|
1528
1666
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1529
1667
|
}
|
|
@@ -1536,6 +1674,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1536
1674
|
get isIP() {
|
|
1537
1675
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1538
1676
|
}
|
|
1677
|
+
get isBase64() {
|
|
1678
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1679
|
+
}
|
|
1539
1680
|
get minLength() {
|
|
1540
1681
|
let min = null;
|
|
1541
1682
|
for (const ch of this._def.checks) {
|
|
@@ -2449,9 +2590,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2449
2590
|
const syncPairs = [];
|
|
2450
2591
|
for (const pair of pairs) {
|
|
2451
2592
|
const key = await pair.key;
|
|
2593
|
+
const value = await pair.value;
|
|
2452
2594
|
syncPairs.push({
|
|
2453
2595
|
key,
|
|
2454
|
-
value
|
|
2596
|
+
value,
|
|
2455
2597
|
alwaysSet: pair.alwaysSet
|
|
2456
2598
|
});
|
|
2457
2599
|
}
|
|
@@ -2802,15 +2944,25 @@ var getDiscriminator = (type) => {
|
|
|
2802
2944
|
} else if (type instanceof ZodEnum) {
|
|
2803
2945
|
return type.options;
|
|
2804
2946
|
} else if (type instanceof ZodNativeEnum) {
|
|
2805
|
-
return
|
|
2947
|
+
return util.objectValues(type.enum);
|
|
2806
2948
|
} else if (type instanceof ZodDefault) {
|
|
2807
2949
|
return getDiscriminator(type._def.innerType);
|
|
2808
2950
|
} else if (type instanceof ZodUndefined) {
|
|
2809
2951
|
return [void 0];
|
|
2810
2952
|
} else if (type instanceof ZodNull) {
|
|
2811
2953
|
return [null];
|
|
2954
|
+
} else if (type instanceof ZodOptional) {
|
|
2955
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
2956
|
+
} else if (type instanceof ZodNullable) {
|
|
2957
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
2958
|
+
} else if (type instanceof ZodBranded) {
|
|
2959
|
+
return getDiscriminator(type.unwrap());
|
|
2960
|
+
} else if (type instanceof ZodReadonly) {
|
|
2961
|
+
return getDiscriminator(type.unwrap());
|
|
2962
|
+
} else if (type instanceof ZodCatch) {
|
|
2963
|
+
return getDiscriminator(type._def.innerType);
|
|
2812
2964
|
} else {
|
|
2813
|
-
return
|
|
2965
|
+
return [];
|
|
2814
2966
|
}
|
|
2815
2967
|
};
|
|
2816
2968
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2870,7 +3022,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2870
3022
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2871
3023
|
for (const type of options) {
|
|
2872
3024
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2873
|
-
if (!discriminatorValues) {
|
|
3025
|
+
if (!discriminatorValues.length) {
|
|
2874
3026
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2875
3027
|
}
|
|
2876
3028
|
for (const value of discriminatorValues) {
|
|
@@ -3070,7 +3222,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3070
3222
|
for (const key in ctx.data) {
|
|
3071
3223
|
pairs.push({
|
|
3072
3224
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3073
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3225
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3226
|
+
alwaysSet: key in ctx.data
|
|
3074
3227
|
});
|
|
3075
3228
|
}
|
|
3076
3229
|
if (ctx.common.async) {
|
|
@@ -3414,6 +3567,10 @@ function createZodEnum(values, params) {
|
|
|
3414
3567
|
});
|
|
3415
3568
|
}
|
|
3416
3569
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3570
|
+
constructor() {
|
|
3571
|
+
super(...arguments);
|
|
3572
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3573
|
+
}
|
|
3417
3574
|
_parse(input) {
|
|
3418
3575
|
if (typeof input.data !== "string") {
|
|
3419
3576
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3425,7 +3582,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3425
3582
|
});
|
|
3426
3583
|
return INVALID;
|
|
3427
3584
|
}
|
|
3428
|
-
if (this
|
|
3585
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3586
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3587
|
+
}
|
|
3588
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3429
3589
|
const ctx = this._getOrReturnCtx(input);
|
|
3430
3590
|
const expectedValues = this._def.values;
|
|
3431
3591
|
addIssueToContext(ctx, {
|
|
@@ -3461,15 +3621,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3461
3621
|
}
|
|
3462
3622
|
return enumValues;
|
|
3463
3623
|
}
|
|
3464
|
-
extract(values) {
|
|
3465
|
-
return _ZodEnum.create(values
|
|
3624
|
+
extract(values, newDef = this._def) {
|
|
3625
|
+
return _ZodEnum.create(values, {
|
|
3626
|
+
...this._def,
|
|
3627
|
+
...newDef
|
|
3628
|
+
});
|
|
3466
3629
|
}
|
|
3467
|
-
exclude(values) {
|
|
3468
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
3630
|
+
exclude(values, newDef = this._def) {
|
|
3631
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3632
|
+
...this._def,
|
|
3633
|
+
...newDef
|
|
3634
|
+
});
|
|
3469
3635
|
}
|
|
3470
3636
|
};
|
|
3637
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3471
3638
|
ZodEnum.create = createZodEnum;
|
|
3472
3639
|
var ZodNativeEnum = class extends ZodType {
|
|
3640
|
+
constructor() {
|
|
3641
|
+
super(...arguments);
|
|
3642
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3643
|
+
}
|
|
3473
3644
|
_parse(input) {
|
|
3474
3645
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3475
3646
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3482,7 +3653,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3482
3653
|
});
|
|
3483
3654
|
return INVALID;
|
|
3484
3655
|
}
|
|
3485
|
-
if (
|
|
3656
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3657
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3658
|
+
}
|
|
3659
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3486
3660
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3487
3661
|
addIssueToContext(ctx, {
|
|
3488
3662
|
received: ctx.data,
|
|
@@ -3497,6 +3671,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3497
3671
|
return this._def.values;
|
|
3498
3672
|
}
|
|
3499
3673
|
};
|
|
3674
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3500
3675
|
ZodNativeEnum.create = (values, params) => {
|
|
3501
3676
|
return new ZodNativeEnum({
|
|
3502
3677
|
values,
|
|
@@ -3560,26 +3735,38 @@ var ZodEffects = class extends ZodType {
|
|
|
3560
3735
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3561
3736
|
if (effect.type === "preprocess") {
|
|
3562
3737
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
3563
|
-
if (ctx.common.issues.length) {
|
|
3564
|
-
return {
|
|
3565
|
-
status: "dirty",
|
|
3566
|
-
value: ctx.data
|
|
3567
|
-
};
|
|
3568
|
-
}
|
|
3569
3738
|
if (ctx.common.async) {
|
|
3570
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3571
|
-
|
|
3739
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3740
|
+
if (status.value === "aborted")
|
|
3741
|
+
return INVALID;
|
|
3742
|
+
const result = await this._def.schema._parseAsync({
|
|
3572
3743
|
data: processed2,
|
|
3573
3744
|
path: ctx.path,
|
|
3574
3745
|
parent: ctx
|
|
3575
3746
|
});
|
|
3747
|
+
if (result.status === "aborted")
|
|
3748
|
+
return INVALID;
|
|
3749
|
+
if (result.status === "dirty")
|
|
3750
|
+
return DIRTY(result.value);
|
|
3751
|
+
if (status.value === "dirty")
|
|
3752
|
+
return DIRTY(result.value);
|
|
3753
|
+
return result;
|
|
3576
3754
|
});
|
|
3577
3755
|
} else {
|
|
3578
|
-
|
|
3756
|
+
if (status.value === "aborted")
|
|
3757
|
+
return INVALID;
|
|
3758
|
+
const result = this._def.schema._parseSync({
|
|
3579
3759
|
data: processed,
|
|
3580
3760
|
path: ctx.path,
|
|
3581
3761
|
parent: ctx
|
|
3582
3762
|
});
|
|
3763
|
+
if (result.status === "aborted")
|
|
3764
|
+
return INVALID;
|
|
3765
|
+
if (result.status === "dirty")
|
|
3766
|
+
return DIRTY(result.value);
|
|
3767
|
+
if (status.value === "dirty")
|
|
3768
|
+
return DIRTY(result.value);
|
|
3769
|
+
return result;
|
|
3583
3770
|
}
|
|
3584
3771
|
}
|
|
3585
3772
|
if (effect.type === "refinement") {
|
|
@@ -3868,10 +4055,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3868
4055
|
var ZodReadonly = class extends ZodType {
|
|
3869
4056
|
_parse(input) {
|
|
3870
4057
|
const result = this._def.innerType._parse(input);
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
4058
|
+
const freeze = (data) => {
|
|
4059
|
+
if (isValid(data)) {
|
|
4060
|
+
data.value = Object.freeze(data.value);
|
|
4061
|
+
}
|
|
4062
|
+
return data;
|
|
4063
|
+
};
|
|
4064
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
4065
|
+
}
|
|
4066
|
+
unwrap() {
|
|
4067
|
+
return this._def.innerType;
|
|
3875
4068
|
}
|
|
3876
4069
|
};
|
|
3877
4070
|
ZodReadonly.create = (type, params) => {
|
|
@@ -3881,7 +4074,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
3881
4074
|
...processCreateParams(params)
|
|
3882
4075
|
});
|
|
3883
4076
|
};
|
|
3884
|
-
|
|
4077
|
+
function custom(check, params = {}, fatal) {
|
|
3885
4078
|
if (check)
|
|
3886
4079
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3887
4080
|
var _a, _b;
|
|
@@ -3893,7 +4086,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
3893
4086
|
}
|
|
3894
4087
|
});
|
|
3895
4088
|
return ZodAny.create();
|
|
3896
|
-
}
|
|
4089
|
+
}
|
|
3897
4090
|
var late = {
|
|
3898
4091
|
object: ZodObject.lazycreate
|
|
3899
4092
|
};
|
|
@@ -4012,6 +4205,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4012
4205
|
ZodParsedType,
|
|
4013
4206
|
getParsedType,
|
|
4014
4207
|
ZodType,
|
|
4208
|
+
datetimeRegex,
|
|
4015
4209
|
ZodString,
|
|
4016
4210
|
ZodNumber,
|
|
4017
4211
|
ZodBigInt,
|
|
@@ -4406,9 +4600,9 @@ var DesignRequest = class {
|
|
|
4406
4600
|
return this;
|
|
4407
4601
|
}
|
|
4408
4602
|
}
|
|
4409
|
-
async getJSON() {
|
|
4603
|
+
async getJSON(format) {
|
|
4410
4604
|
if (this.state === "ready") {
|
|
4411
|
-
return await this.client.engineAPI.books.
|
|
4605
|
+
return await this.client.engineAPI.books.format(this.parentId, format);
|
|
4412
4606
|
} else {
|
|
4413
4607
|
throw new Error("Design request not ready");
|
|
4414
4608
|
}
|
|
@@ -4634,10 +4828,10 @@ var BooksEndpoints = class {
|
|
|
4634
4828
|
});
|
|
4635
4829
|
});
|
|
4636
4830
|
}
|
|
4637
|
-
|
|
4831
|
+
format(bookId, format) {
|
|
4638
4832
|
return handleAsyncFunction(async () => {
|
|
4639
4833
|
const res = await this.engineAPI.fetcher.call({
|
|
4640
|
-
path: `/v1/books/${bookId}/format
|
|
4834
|
+
path: `/v1/books/${bookId}/format/${format}`
|
|
4641
4835
|
});
|
|
4642
4836
|
return bookCreationRequestSchema.parse(res);
|
|
4643
4837
|
});
|
|
@@ -5079,6 +5273,7 @@ var MagicBookClient = class {
|
|
|
5079
5273
|
designOptionsSchema,
|
|
5080
5274
|
designOptionsServerSchema,
|
|
5081
5275
|
embellishmentLevels,
|
|
5276
|
+
formats,
|
|
5082
5277
|
imageAssignmentSchema,
|
|
5083
5278
|
imageDensities,
|
|
5084
5279
|
imageDensityOptionSchema,
|