@magiclabs.ai/magicbook-client 0.7.6 → 0.7.8-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/README.md +2 -1
- package/index.cjs +394 -80
- package/index.cjs.map +1 -1
- package/index.d.cts +1023 -712
- package/index.d.ts +1023 -712
- package/index.js +393 -80
- 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);
|
|
@@ -37,6 +42,7 @@ var occasions = [
|
|
|
37
42
|
"year-in-review"
|
|
38
43
|
];
|
|
39
44
|
var styles = {
|
|
45
|
+
//shutterfly styles
|
|
40
46
|
1005: { slug: "modern-black-sfly" },
|
|
41
47
|
1101: { slug: "bon-voyage-sfly" },
|
|
42
48
|
1103: { slug: "fun-in-the-sun-sfly" },
|
|
@@ -207,9 +213,120 @@ var styles = {
|
|
|
207
213
|
6098: { slug: "black-and-white-rustic-sfly" },
|
|
208
214
|
6099: { slug: "bright-color-pop-sfly" },
|
|
209
215
|
6159: { slug: "grateful-for-you-sfly" },
|
|
210
|
-
6156: { slug: "europe-mementos-sfly" }
|
|
216
|
+
6156: { slug: "europe-mementos-sfly" },
|
|
217
|
+
//snapfish styles
|
|
218
|
+
be5f79d7525f4717844db77a2f1b5e50: { slug: "abstract-baby-first-year-snap" },
|
|
219
|
+
"519bf5f2b6734103a9a359469be4961b": { slug: "album-snap" },
|
|
220
|
+
"029a2ebd65b448bf93753c813b7b7363": { slug: "all-about-love-snap" },
|
|
221
|
+
"16d0d436594b4171bd9688876a85c9c1": { slug: "alphabet-book-snap" },
|
|
222
|
+
"5b95e1d678584558b2c3397ab996da7b": { slug: "always-and-forever-snap" },
|
|
223
|
+
a2c088e32541429ba8e5e15d09991264: { slug: "art-of-travel-snap" },
|
|
224
|
+
"0ddec2b965094c8ea03d669e771ff1a6": { slug: "autumn-snapshots-snap" },
|
|
225
|
+
"339699fedd3743f69c5b05587fbfd41a": { slug: "baby-boy-first-year-snap" },
|
|
226
|
+
"091f9a6a83c349b2a9732177d89f8664": { slug: "baby-girl-first-year-snap" },
|
|
227
|
+
e768ec11406545809ca9598be3bda88c: { slug: "best-dad-ever-snap" },
|
|
228
|
+
"0c55a3eb5cc6414c9f2570886132d331": { slug: "best-year-ever-snap" },
|
|
229
|
+
"9c49df50d76b4789834ca7abaabe2bc6": { slug: "bold-shapes-snap" },
|
|
230
|
+
fd7cf7c4dc244705ad391334d76f7229: { slug: "bold-type-snap" },
|
|
231
|
+
"363ceab4906b47a09dd287f53dc1d30f": { slug: "botanicals-snap" },
|
|
232
|
+
e47017576d0e451180ff4591d2aee2fa: { slug: "celebrating-grandma-snap" },
|
|
233
|
+
d9743da5f46843aab84b1f90ff776ee0: { slug: "celebrating-mum-snap" },
|
|
234
|
+
"13039c15c81b4e50af5e39cd99f4e274": { slug: "chalkboard-snap" },
|
|
235
|
+
"0c98757783874104a488a1a88747344d": { slug: "childs-yearbook-snap" },
|
|
236
|
+
"5b0d80d6ca164919b7ee558c0bc2537b": { slug: "classic-fathers-snap" },
|
|
237
|
+
eb734aa7c87a4db1ac9695e935f13489: { slug: "colour-block-rainbow-snap" },
|
|
238
|
+
"7ed9132a96484ed2b200cf30e73cf049": { slug: "contemporary-travel-snap" },
|
|
239
|
+
"3e15106389764a3cb2b6a6c29c065993": { slug: "contemporary-wedding-snap" },
|
|
240
|
+
"47f9e28d811842a5870c74bb4c6b3608": { slug: "design-your-own-snap" },
|
|
241
|
+
bef3d3bc49f3476aa6f39ad073294a04: { slug: "destination-stamps-snap" },
|
|
242
|
+
"496138703d5346bd9678a2fa487b54fd": { slug: "dip-dye-snap" },
|
|
243
|
+
"303773eee9934e8ba9f676b339c84d39": { slug: "earth-tones-snap" },
|
|
244
|
+
"02c52e4cdccd40b0b99cf2215a6b8fe1": { slug: "elegant-florals-snap" },
|
|
245
|
+
c59f05e866344332b2953199fd2972fa: { slug: "everyday-happiness-snap" },
|
|
246
|
+
"5a2d025aaa3746b2b047daa6206ba8ad": { slug: "family-chalkboard-snap" },
|
|
247
|
+
"1c8784e76020435d88ddab7bc8d72cae": { slug: "family-farmhouse-snap" },
|
|
248
|
+
"1735277701d6483e9934074f25053f3a": { slug: "family-memories-snap" },
|
|
249
|
+
"9c35a7f890204c38adb4255571377114": { slug: "family-yearbook-snap" },
|
|
250
|
+
"9c946c20f0dc45adb3f85735690f3395": { slug: "favourite-things-snap" },
|
|
251
|
+
c216373996d945c186cc6db5a53e10b1: { slug: "framed-full-photo-snap" },
|
|
252
|
+
"6f7cd5c4e4e247f2bdf7c44ace0fdad5": { slug: "fresh-cookbook-snap" },
|
|
253
|
+
"7eae47a7cbd743d4a47ca94f7a6b87a7": { slug: "full-and-multi-square-photo-snap" },
|
|
254
|
+
ac7a649cbd27433c9d0b405f34ff29f5: { slug: "full-photo-snap" },
|
|
255
|
+
"3aa989376bc5414eb2a35f2cb930f57c": { slug: "full-photo-snap" },
|
|
256
|
+
d86767aacb4f464892702ed3ffac1a98: { slug: "fun-dots-snap" },
|
|
257
|
+
c5d1654a989d4f2f87594e486239e77b: { slug: "geometric-lines-snap" },
|
|
258
|
+
"73e54769af5f4943a8403c6a5e38f5fb": { slug: "golden-graduation-snap" },
|
|
259
|
+
"7d15aef8b54d41ee82a99d327d571020": { slug: "graduation-memories-snap" },
|
|
260
|
+
"46594aace0ca42b1bdd086d1b8ac0ad4": { slug: "guest-book-snap" },
|
|
261
|
+
"77c78fbe2b4b4c7fb37e34a9515912d2": { slug: "hearts-for-mum-snap" },
|
|
262
|
+
"659893fcc6c24fef9ea1a3a8ccf2539e": { slug: "hello-baby-snap" },
|
|
263
|
+
"0f1182fcc18c428fb7c3d80c5a637c3b": { slug: "hello-baby-boy-snap" },
|
|
264
|
+
"54b7a8ca59774060835fdd48653dba9a": { slug: "hello-baby-girl-snap" },
|
|
265
|
+
"2d56caccc29a40b5bd16334937de0083": { slug: "i-love-my-cat-snap" },
|
|
266
|
+
"3c12993b18ff473fa6fc7f695bd64180": { slug: "i-love-my-dog-snap" },
|
|
267
|
+
c4393a1da2e54ca4ab9a3ec0aeb682e4: { slug: "lets-celebrate-snap" },
|
|
268
|
+
ee9fd665523c41078a65c5389896d0ab: { slug: "love-lives-here-snap" },
|
|
269
|
+
b84d0171dbb748e1ab2fb535fd318830: { slug: "love-story-snap" },
|
|
270
|
+
"4d61b18d992c4d8eb33a331e4201ae05": { slug: "magical-memories-snap" },
|
|
271
|
+
bdbe9158b33343c6ae11217fde9c8a57: { slug: "milestone-memories-snap" },
|
|
272
|
+
"790a78454af94287b2a84c2324d6956e": { slug: "modern-graduation-snap" },
|
|
273
|
+
"4211083b4bad4fee87e04dd65e5fed5d": { slug: "modern-highlights-snap" },
|
|
274
|
+
"47bb41bb9e174657aa0c48ec140ed2c8": { slug: "modern-rustic-snap" },
|
|
275
|
+
bac69bcc341c445d9c5c81f04231c685: { slug: "my-family-snap" },
|
|
276
|
+
"2d561db2b849457f8f830c2e977ced6c": { slug: "my-graduation-snap" },
|
|
277
|
+
e2727f32f9e248a3a7fd02f50cf493ab: { slug: "natural-blues-snap" },
|
|
278
|
+
"85005f9b9c1c4a4485508c52465b7110": { slug: "nautical-summer-snap" },
|
|
279
|
+
df1eded2d6e24c81a9e9bd66567b39f0: { slug: "organic-patterns-snap" },
|
|
280
|
+
bfdc9b325b1a4471a948eccb7c76fd2e: { slug: "organic-shapes-snap" },
|
|
281
|
+
"7cb42c74e4704c08a51f0930703fff34": { slug: "our-wedding-guests-snap" },
|
|
282
|
+
c88a62c1e3584591b278fe0ccfe3b02b: { slug: "over-the-moon-snap" },
|
|
283
|
+
"2a682e5b38d64f77b7c1b6c0a8a06670": { slug: "painterly-patterns-snap" },
|
|
284
|
+
"5eddabc29f704c66ba03deff870f2c18": { slug: "precious-experiences-snap" },
|
|
285
|
+
"18f048f0a07f40c09495fdc3830f7228": { slug: "reflections-on-our-year-snap" },
|
|
286
|
+
f2fd5fd83bbb4e9ebf3af33ba4589561: { slug: "roadtrip-snap" },
|
|
287
|
+
"31ed7e06afb347f2a302ba35267c8a0a": { slug: "rustic-chic-snap" },
|
|
288
|
+
"17e8062b9ed749ba8428cbb3924e719d": { slug: "rustic-family-snapshots-snap" },
|
|
289
|
+
"7573b1a594e8405295adfcf145c5322a": { slug: "serene-memories-snap" },
|
|
290
|
+
acc3ac3b7e724c288a849b471616e373: { slug: "simple-snap" },
|
|
291
|
+
ddb203e3ae0443209ada75135e13a63e: { slug: "simple-family-moments-snap" },
|
|
292
|
+
bdee0a45e5144156b88621238cd31bbe: { slug: "simply-love-snap" },
|
|
293
|
+
dc0d15f9aa474bd89c49e6da49bb3cc5: { slug: "sketched-botanicals-snap" },
|
|
294
|
+
"55cebda93e1c4f52b07d824a57f8677b": { slug: "smitten-snap" },
|
|
295
|
+
"2172f706eedf4c36a3fba10a0fe5448d": { slug: "snow-days-snap" },
|
|
296
|
+
"0964a6d8e0234df7ad7df8e56c33ff2b": { slug: "solid-brights-snap" },
|
|
297
|
+
e47b1860677e45909de56915a350a84e: { slug: "studio-snap" },
|
|
298
|
+
"0b8fcc5f30cb4649bb4d8ea9cf35578c": { slug: "studio-multi-snap" },
|
|
299
|
+
"2972e73653da4dc5805853e22717f1ee": { slug: "summer-snapshots-snap" },
|
|
300
|
+
f292a52aff774e698fe26dc61a7a3f71: { slug: "team-spirit-snap" },
|
|
301
|
+
b9192bf9df6b4984b29f4731b5f0bb63: { slug: "ten-things-i-love-snap" },
|
|
302
|
+
d2dd8fe6e2e44c78935206323ee89af1: { slug: "travel-maps-snap" },
|
|
303
|
+
"61f74eec39ff425b85e4f1c7e9e15ef6": { slug: "travel-memories-snap" },
|
|
304
|
+
"148b777f385c4df2bc1b4900a4208e82": { slug: "travel-stamps-snap" },
|
|
305
|
+
"77550e4c36b34454bac2ae9c4d9d2bd1": { slug: "tropical-beach-escape-snap" },
|
|
306
|
+
"6aac0d2309744e9ea8fd4621f8213dbd": { slug: "unfurgettable-kitty-snap" },
|
|
307
|
+
f5ef0aaddd294a0ba37ebc76012858ff: { slug: "vibrant-memories-snap" },
|
|
308
|
+
"73966e2885a544ed9ba8e0a314a6528c": { slug: "vintage-birthday-memories-snap" },
|
|
309
|
+
"33242c4285024ccfafc57d72a7292ea9": { slug: "warm-neutrals-snap" },
|
|
310
|
+
"605f06522caa449ba93b7c5fa4d8e54b": { slug: "warmest-memories-snap" },
|
|
311
|
+
c154e4664672441fa640f1ddff883db1: { slug: "watercolour-memories-snap" },
|
|
312
|
+
"86024d3f1def489495cc7525d8232bea": { slug: "watercolour-sketchbook-snap" },
|
|
313
|
+
f52d1dd24f9c49ae82d8f70449fe40b7: { slug: "watercolour-wonders-snap" },
|
|
314
|
+
"1cbbd20a3a4542f38d2f9932016c4584": { slug: "watercolours-snap" },
|
|
315
|
+
fdf4b31ea3434b03a5c3ddaab1579084: { slug: "wedding-studio-snap" },
|
|
316
|
+
"1b104c3a036e4825bd60a5c7ceac4e66": { slug: "winter-magic-snap" },
|
|
317
|
+
"03f332e3b2b947ebae73b67a9a22b6f4": { slug: "winter-sparkle-snap" },
|
|
318
|
+
"97f70f6cdb5244a08d45772cccfa2788": { slug: "year-of-memories-snap" }
|
|
211
319
|
};
|
|
212
|
-
var bookSizes = [
|
|
320
|
+
var bookSizes = [
|
|
321
|
+
"5x7",
|
|
322
|
+
"6x6",
|
|
323
|
+
"8x8",
|
|
324
|
+
"10x10",
|
|
325
|
+
"12x12",
|
|
326
|
+
"8x11",
|
|
327
|
+
"11x8",
|
|
328
|
+
"11x14"
|
|
329
|
+
];
|
|
213
330
|
var coverTypes = ["sc", "hc", "pl"];
|
|
214
331
|
var pageTypes = ["sp", "sl", "dl"];
|
|
215
332
|
var imageDensities = ["low", "medium", "high"];
|
|
@@ -228,6 +345,7 @@ var cancelledEventDetail = {
|
|
|
228
345
|
progress: 100,
|
|
229
346
|
message: "Design canceled"
|
|
230
347
|
};
|
|
348
|
+
var formats = ["galleon", "snapfish"];
|
|
231
349
|
|
|
232
350
|
// ../../core/utils/toolbox.ts
|
|
233
351
|
function mergeNestedObject(obj, objToMerge) {
|
|
@@ -295,13 +413,13 @@ function getStyleIdBySlug(slug) {
|
|
|
295
413
|
for (const id in styles) {
|
|
296
414
|
const style = styles[id];
|
|
297
415
|
if (style.slug === slug) {
|
|
298
|
-
return
|
|
416
|
+
return id;
|
|
299
417
|
}
|
|
300
418
|
}
|
|
301
419
|
return void 0;
|
|
302
420
|
}
|
|
303
421
|
|
|
304
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
422
|
+
// ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
|
305
423
|
var util;
|
|
306
424
|
(function(util2) {
|
|
307
425
|
util2.assertEqual = (val) => val;
|
|
@@ -455,7 +573,7 @@ var quotelessJson = (obj) => {
|
|
|
455
573
|
const json = JSON.stringify(obj, null, 2);
|
|
456
574
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
457
575
|
};
|
|
458
|
-
var ZodError = class extends Error {
|
|
576
|
+
var ZodError = class _ZodError extends Error {
|
|
459
577
|
constructor(issues) {
|
|
460
578
|
super();
|
|
461
579
|
this.issues = [];
|
|
@@ -513,6 +631,11 @@ var ZodError = class extends Error {
|
|
|
513
631
|
processError(this);
|
|
514
632
|
return fieldErrors;
|
|
515
633
|
}
|
|
634
|
+
static assert(value) {
|
|
635
|
+
if (!(value instanceof _ZodError)) {
|
|
636
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
516
639
|
toString() {
|
|
517
640
|
return this.message;
|
|
518
641
|
}
|
|
@@ -655,6 +778,13 @@ var makeIssue = (params) => {
|
|
|
655
778
|
...issueData,
|
|
656
779
|
path: fullPath
|
|
657
780
|
};
|
|
781
|
+
if (issueData.message !== void 0) {
|
|
782
|
+
return {
|
|
783
|
+
...issueData,
|
|
784
|
+
path: fullPath,
|
|
785
|
+
message: issueData.message
|
|
786
|
+
};
|
|
787
|
+
}
|
|
658
788
|
let errorMessage = "";
|
|
659
789
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
660
790
|
for (const map of maps) {
|
|
@@ -663,11 +793,12 @@ var makeIssue = (params) => {
|
|
|
663
793
|
return {
|
|
664
794
|
...issueData,
|
|
665
795
|
path: fullPath,
|
|
666
|
-
message:
|
|
796
|
+
message: errorMessage
|
|
667
797
|
};
|
|
668
798
|
};
|
|
669
799
|
var EMPTY_PATH = [];
|
|
670
800
|
function addIssueToContext(ctx, issueData) {
|
|
801
|
+
const overrideMap = getErrorMap();
|
|
671
802
|
const issue = makeIssue({
|
|
672
803
|
issueData,
|
|
673
804
|
data: ctx.data,
|
|
@@ -675,8 +806,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
675
806
|
errorMaps: [
|
|
676
807
|
ctx.common.contextualErrorMap,
|
|
677
808
|
ctx.schemaErrorMap,
|
|
678
|
-
|
|
679
|
-
errorMap
|
|
809
|
+
overrideMap,
|
|
810
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
680
811
|
// then global default map
|
|
681
812
|
].filter((x) => !!x)
|
|
682
813
|
});
|
|
@@ -708,9 +839,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
708
839
|
static async mergeObjectAsync(status, pairs) {
|
|
709
840
|
const syncPairs = [];
|
|
710
841
|
for (const pair of pairs) {
|
|
842
|
+
const key = await pair.key;
|
|
843
|
+
const value = await pair.value;
|
|
711
844
|
syncPairs.push({
|
|
712
|
-
key
|
|
713
|
-
value
|
|
845
|
+
key,
|
|
846
|
+
value
|
|
714
847
|
});
|
|
715
848
|
}
|
|
716
849
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -743,11 +876,29 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
743
876
|
var isDirty = (x) => x.status === "dirty";
|
|
744
877
|
var isValid = (x) => x.status === "valid";
|
|
745
878
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
879
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
880
|
+
if (kind === "a" && !f)
|
|
881
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
882
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
883
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
884
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
885
|
+
}
|
|
886
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
887
|
+
if (kind === "m")
|
|
888
|
+
throw new TypeError("Private method is not writable");
|
|
889
|
+
if (kind === "a" && !f)
|
|
890
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
891
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
892
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
893
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
894
|
+
}
|
|
746
895
|
var errorUtil;
|
|
747
896
|
(function(errorUtil2) {
|
|
748
897
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
749
898
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
750
899
|
})(errorUtil || (errorUtil = {}));
|
|
900
|
+
var _ZodEnum_cache;
|
|
901
|
+
var _ZodNativeEnum_cache;
|
|
751
902
|
var ParseInputLazyPath = class {
|
|
752
903
|
constructor(parent, value, path, key) {
|
|
753
904
|
this._cachedPath = [];
|
|
@@ -796,12 +947,17 @@ function processCreateParams(params) {
|
|
|
796
947
|
if (errorMap2)
|
|
797
948
|
return { errorMap: errorMap2, description };
|
|
798
949
|
const customMap = (iss, ctx) => {
|
|
799
|
-
|
|
800
|
-
|
|
950
|
+
var _a, _b;
|
|
951
|
+
const { message } = params;
|
|
952
|
+
if (iss.code === "invalid_enum_value") {
|
|
953
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
954
|
+
}
|
|
801
955
|
if (typeof ctx.data === "undefined") {
|
|
802
|
-
return { message:
|
|
956
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
803
957
|
}
|
|
804
|
-
|
|
958
|
+
if (iss.code !== "invalid_type")
|
|
959
|
+
return { message: ctx.defaultError };
|
|
960
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
805
961
|
};
|
|
806
962
|
return { errorMap: customMap, description };
|
|
807
963
|
}
|
|
@@ -1049,35 +1205,40 @@ var ZodType = class {
|
|
|
1049
1205
|
}
|
|
1050
1206
|
};
|
|
1051
1207
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1052
|
-
var cuid2Regex = /^[
|
|
1208
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
1053
1209
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1054
1210
|
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
|
|
1211
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1212
|
+
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)?)??$/;
|
|
1213
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1056
1214
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1057
1215
|
var emojiRegex;
|
|
1058
|
-
var ipv4Regex = /^((
|
|
1216
|
+
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
1217
|
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
|
|
1218
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1219
|
+
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])))`;
|
|
1220
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1221
|
+
function timeRegexSource(args) {
|
|
1222
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1061
1223
|
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
|
-
}
|
|
1224
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1225
|
+
} else if (args.precision == null) {
|
|
1226
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1079
1227
|
}
|
|
1080
|
-
|
|
1228
|
+
return regex;
|
|
1229
|
+
}
|
|
1230
|
+
function timeRegex(args) {
|
|
1231
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1232
|
+
}
|
|
1233
|
+
function datetimeRegex(args) {
|
|
1234
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1235
|
+
const opts = [];
|
|
1236
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1237
|
+
if (args.offset)
|
|
1238
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1239
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1240
|
+
return new RegExp(`^${regex}$`);
|
|
1241
|
+
}
|
|
1081
1242
|
function isValidIP(ip, version) {
|
|
1082
1243
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1083
1244
|
return true;
|
|
@@ -1095,15 +1256,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1095
1256
|
const parsedType = this._getType(input);
|
|
1096
1257
|
if (parsedType !== ZodParsedType.string) {
|
|
1097
1258
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1098
|
-
addIssueToContext(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
received: ctx2.parsedType
|
|
1104
|
-
}
|
|
1105
|
-
//
|
|
1106
|
-
);
|
|
1259
|
+
addIssueToContext(ctx2, {
|
|
1260
|
+
code: ZodIssueCode.invalid_type,
|
|
1261
|
+
expected: ZodParsedType.string,
|
|
1262
|
+
received: ctx2.parsedType
|
|
1263
|
+
});
|
|
1107
1264
|
return INVALID;
|
|
1108
1265
|
}
|
|
1109
1266
|
const status = new ParseStatus();
|
|
@@ -1194,6 +1351,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1194
1351
|
});
|
|
1195
1352
|
status.dirty();
|
|
1196
1353
|
}
|
|
1354
|
+
} else if (check.kind === "nanoid") {
|
|
1355
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1356
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1357
|
+
addIssueToContext(ctx, {
|
|
1358
|
+
validation: "nanoid",
|
|
1359
|
+
code: ZodIssueCode.invalid_string,
|
|
1360
|
+
message: check.message
|
|
1361
|
+
});
|
|
1362
|
+
status.dirty();
|
|
1363
|
+
}
|
|
1197
1364
|
} else if (check.kind === "cuid") {
|
|
1198
1365
|
if (!cuidRegex.test(input.data)) {
|
|
1199
1366
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1295,6 +1462,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1295
1462
|
});
|
|
1296
1463
|
status.dirty();
|
|
1297
1464
|
}
|
|
1465
|
+
} else if (check.kind === "date") {
|
|
1466
|
+
const regex = dateRegex;
|
|
1467
|
+
if (!regex.test(input.data)) {
|
|
1468
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1469
|
+
addIssueToContext(ctx, {
|
|
1470
|
+
code: ZodIssueCode.invalid_string,
|
|
1471
|
+
validation: "date",
|
|
1472
|
+
message: check.message
|
|
1473
|
+
});
|
|
1474
|
+
status.dirty();
|
|
1475
|
+
}
|
|
1476
|
+
} else if (check.kind === "time") {
|
|
1477
|
+
const regex = timeRegex(check);
|
|
1478
|
+
if (!regex.test(input.data)) {
|
|
1479
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1480
|
+
addIssueToContext(ctx, {
|
|
1481
|
+
code: ZodIssueCode.invalid_string,
|
|
1482
|
+
validation: "time",
|
|
1483
|
+
message: check.message
|
|
1484
|
+
});
|
|
1485
|
+
status.dirty();
|
|
1486
|
+
}
|
|
1487
|
+
} else if (check.kind === "duration") {
|
|
1488
|
+
if (!durationRegex.test(input.data)) {
|
|
1489
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1490
|
+
addIssueToContext(ctx, {
|
|
1491
|
+
validation: "duration",
|
|
1492
|
+
code: ZodIssueCode.invalid_string,
|
|
1493
|
+
message: check.message
|
|
1494
|
+
});
|
|
1495
|
+
status.dirty();
|
|
1496
|
+
}
|
|
1298
1497
|
} else if (check.kind === "ip") {
|
|
1299
1498
|
if (!isValidIP(input.data, check.version)) {
|
|
1300
1499
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1305,6 +1504,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1305
1504
|
});
|
|
1306
1505
|
status.dirty();
|
|
1307
1506
|
}
|
|
1507
|
+
} else if (check.kind === "base64") {
|
|
1508
|
+
if (!base64Regex.test(input.data)) {
|
|
1509
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1510
|
+
addIssueToContext(ctx, {
|
|
1511
|
+
validation: "base64",
|
|
1512
|
+
code: ZodIssueCode.invalid_string,
|
|
1513
|
+
message: check.message
|
|
1514
|
+
});
|
|
1515
|
+
status.dirty();
|
|
1516
|
+
}
|
|
1308
1517
|
} else {
|
|
1309
1518
|
util.assertNever(check);
|
|
1310
1519
|
}
|
|
@@ -1336,6 +1545,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1336
1545
|
uuid(message) {
|
|
1337
1546
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1338
1547
|
}
|
|
1548
|
+
nanoid(message) {
|
|
1549
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1550
|
+
}
|
|
1339
1551
|
cuid(message) {
|
|
1340
1552
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1341
1553
|
}
|
|
@@ -1345,16 +1557,20 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1345
1557
|
ulid(message) {
|
|
1346
1558
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1347
1559
|
}
|
|
1560
|
+
base64(message) {
|
|
1561
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1562
|
+
}
|
|
1348
1563
|
ip(options) {
|
|
1349
1564
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1350
1565
|
}
|
|
1351
1566
|
datetime(options) {
|
|
1352
|
-
var _a;
|
|
1567
|
+
var _a, _b;
|
|
1353
1568
|
if (typeof options === "string") {
|
|
1354
1569
|
return this._addCheck({
|
|
1355
1570
|
kind: "datetime",
|
|
1356
1571
|
precision: null,
|
|
1357
1572
|
offset: false,
|
|
1573
|
+
local: false,
|
|
1358
1574
|
message: options
|
|
1359
1575
|
});
|
|
1360
1576
|
}
|
|
@@ -1362,9 +1578,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1362
1578
|
kind: "datetime",
|
|
1363
1579
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1364
1580
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1581
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1582
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
date(message) {
|
|
1586
|
+
return this._addCheck({ kind: "date", message });
|
|
1587
|
+
}
|
|
1588
|
+
time(options) {
|
|
1589
|
+
if (typeof options === "string") {
|
|
1590
|
+
return this._addCheck({
|
|
1591
|
+
kind: "time",
|
|
1592
|
+
precision: null,
|
|
1593
|
+
message: options
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
return this._addCheck({
|
|
1597
|
+
kind: "time",
|
|
1598
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1365
1599
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1366
1600
|
});
|
|
1367
1601
|
}
|
|
1602
|
+
duration(message) {
|
|
1603
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1604
|
+
}
|
|
1368
1605
|
regex(regex, message) {
|
|
1369
1606
|
return this._addCheck({
|
|
1370
1607
|
kind: "regex",
|
|
@@ -1443,6 +1680,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1443
1680
|
get isDatetime() {
|
|
1444
1681
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1445
1682
|
}
|
|
1683
|
+
get isDate() {
|
|
1684
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1685
|
+
}
|
|
1686
|
+
get isTime() {
|
|
1687
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1688
|
+
}
|
|
1689
|
+
get isDuration() {
|
|
1690
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1691
|
+
}
|
|
1446
1692
|
get isEmail() {
|
|
1447
1693
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1448
1694
|
}
|
|
@@ -1455,6 +1701,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1455
1701
|
get isUUID() {
|
|
1456
1702
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1457
1703
|
}
|
|
1704
|
+
get isNANOID() {
|
|
1705
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1706
|
+
}
|
|
1458
1707
|
get isCUID() {
|
|
1459
1708
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1460
1709
|
}
|
|
@@ -1467,6 +1716,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1467
1716
|
get isIP() {
|
|
1468
1717
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1469
1718
|
}
|
|
1719
|
+
get isBase64() {
|
|
1720
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1721
|
+
}
|
|
1470
1722
|
get minLength() {
|
|
1471
1723
|
let min = null;
|
|
1472
1724
|
for (const ch of this._def.checks) {
|
|
@@ -2380,9 +2632,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2380
2632
|
const syncPairs = [];
|
|
2381
2633
|
for (const pair of pairs) {
|
|
2382
2634
|
const key = await pair.key;
|
|
2635
|
+
const value = await pair.value;
|
|
2383
2636
|
syncPairs.push({
|
|
2384
2637
|
key,
|
|
2385
|
-
value
|
|
2638
|
+
value,
|
|
2386
2639
|
alwaysSet: pair.alwaysSet
|
|
2387
2640
|
});
|
|
2388
2641
|
}
|
|
@@ -2733,15 +2986,25 @@ var getDiscriminator = (type) => {
|
|
|
2733
2986
|
} else if (type instanceof ZodEnum) {
|
|
2734
2987
|
return type.options;
|
|
2735
2988
|
} else if (type instanceof ZodNativeEnum) {
|
|
2736
|
-
return
|
|
2989
|
+
return util.objectValues(type.enum);
|
|
2737
2990
|
} else if (type instanceof ZodDefault) {
|
|
2738
2991
|
return getDiscriminator(type._def.innerType);
|
|
2739
2992
|
} else if (type instanceof ZodUndefined) {
|
|
2740
2993
|
return [void 0];
|
|
2741
2994
|
} else if (type instanceof ZodNull) {
|
|
2742
2995
|
return [null];
|
|
2996
|
+
} else if (type instanceof ZodOptional) {
|
|
2997
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
2998
|
+
} else if (type instanceof ZodNullable) {
|
|
2999
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
3000
|
+
} else if (type instanceof ZodBranded) {
|
|
3001
|
+
return getDiscriminator(type.unwrap());
|
|
3002
|
+
} else if (type instanceof ZodReadonly) {
|
|
3003
|
+
return getDiscriminator(type.unwrap());
|
|
3004
|
+
} else if (type instanceof ZodCatch) {
|
|
3005
|
+
return getDiscriminator(type._def.innerType);
|
|
2743
3006
|
} else {
|
|
2744
|
-
return
|
|
3007
|
+
return [];
|
|
2745
3008
|
}
|
|
2746
3009
|
};
|
|
2747
3010
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2801,7 +3064,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2801
3064
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2802
3065
|
for (const type of options) {
|
|
2803
3066
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2804
|
-
if (!discriminatorValues) {
|
|
3067
|
+
if (!discriminatorValues.length) {
|
|
2805
3068
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2806
3069
|
}
|
|
2807
3070
|
for (const value of discriminatorValues) {
|
|
@@ -3001,7 +3264,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3001
3264
|
for (const key in ctx.data) {
|
|
3002
3265
|
pairs.push({
|
|
3003
3266
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3004
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3267
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3268
|
+
alwaysSet: key in ctx.data
|
|
3005
3269
|
});
|
|
3006
3270
|
}
|
|
3007
3271
|
if (ctx.common.async) {
|
|
@@ -3345,6 +3609,10 @@ function createZodEnum(values, params) {
|
|
|
3345
3609
|
});
|
|
3346
3610
|
}
|
|
3347
3611
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3612
|
+
constructor() {
|
|
3613
|
+
super(...arguments);
|
|
3614
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3615
|
+
}
|
|
3348
3616
|
_parse(input) {
|
|
3349
3617
|
if (typeof input.data !== "string") {
|
|
3350
3618
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3356,7 +3624,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3356
3624
|
});
|
|
3357
3625
|
return INVALID;
|
|
3358
3626
|
}
|
|
3359
|
-
if (this
|
|
3627
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3628
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3629
|
+
}
|
|
3630
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3360
3631
|
const ctx = this._getOrReturnCtx(input);
|
|
3361
3632
|
const expectedValues = this._def.values;
|
|
3362
3633
|
addIssueToContext(ctx, {
|
|
@@ -3392,15 +3663,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3392
3663
|
}
|
|
3393
3664
|
return enumValues;
|
|
3394
3665
|
}
|
|
3395
|
-
extract(values) {
|
|
3396
|
-
return _ZodEnum.create(values
|
|
3666
|
+
extract(values, newDef = this._def) {
|
|
3667
|
+
return _ZodEnum.create(values, {
|
|
3668
|
+
...this._def,
|
|
3669
|
+
...newDef
|
|
3670
|
+
});
|
|
3397
3671
|
}
|
|
3398
|
-
exclude(values) {
|
|
3399
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
3672
|
+
exclude(values, newDef = this._def) {
|
|
3673
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3674
|
+
...this._def,
|
|
3675
|
+
...newDef
|
|
3676
|
+
});
|
|
3400
3677
|
}
|
|
3401
3678
|
};
|
|
3679
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3402
3680
|
ZodEnum.create = createZodEnum;
|
|
3403
3681
|
var ZodNativeEnum = class extends ZodType {
|
|
3682
|
+
constructor() {
|
|
3683
|
+
super(...arguments);
|
|
3684
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3685
|
+
}
|
|
3404
3686
|
_parse(input) {
|
|
3405
3687
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3406
3688
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3413,7 +3695,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3413
3695
|
});
|
|
3414
3696
|
return INVALID;
|
|
3415
3697
|
}
|
|
3416
|
-
if (
|
|
3698
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3699
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3700
|
+
}
|
|
3701
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3417
3702
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3418
3703
|
addIssueToContext(ctx, {
|
|
3419
3704
|
received: ctx.data,
|
|
@@ -3428,6 +3713,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3428
3713
|
return this._def.values;
|
|
3429
3714
|
}
|
|
3430
3715
|
};
|
|
3716
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3431
3717
|
ZodNativeEnum.create = (values, params) => {
|
|
3432
3718
|
return new ZodNativeEnum({
|
|
3433
3719
|
values,
|
|
@@ -3491,26 +3777,38 @@ var ZodEffects = class extends ZodType {
|
|
|
3491
3777
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3492
3778
|
if (effect.type === "preprocess") {
|
|
3493
3779
|
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
3780
|
if (ctx.common.async) {
|
|
3501
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3502
|
-
|
|
3781
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3782
|
+
if (status.value === "aborted")
|
|
3783
|
+
return INVALID;
|
|
3784
|
+
const result = await this._def.schema._parseAsync({
|
|
3503
3785
|
data: processed2,
|
|
3504
3786
|
path: ctx.path,
|
|
3505
3787
|
parent: ctx
|
|
3506
3788
|
});
|
|
3789
|
+
if (result.status === "aborted")
|
|
3790
|
+
return INVALID;
|
|
3791
|
+
if (result.status === "dirty")
|
|
3792
|
+
return DIRTY(result.value);
|
|
3793
|
+
if (status.value === "dirty")
|
|
3794
|
+
return DIRTY(result.value);
|
|
3795
|
+
return result;
|
|
3507
3796
|
});
|
|
3508
3797
|
} else {
|
|
3509
|
-
|
|
3798
|
+
if (status.value === "aborted")
|
|
3799
|
+
return INVALID;
|
|
3800
|
+
const result = this._def.schema._parseSync({
|
|
3510
3801
|
data: processed,
|
|
3511
3802
|
path: ctx.path,
|
|
3512
3803
|
parent: ctx
|
|
3513
3804
|
});
|
|
3805
|
+
if (result.status === "aborted")
|
|
3806
|
+
return INVALID;
|
|
3807
|
+
if (result.status === "dirty")
|
|
3808
|
+
return DIRTY(result.value);
|
|
3809
|
+
if (status.value === "dirty")
|
|
3810
|
+
return DIRTY(result.value);
|
|
3811
|
+
return result;
|
|
3514
3812
|
}
|
|
3515
3813
|
}
|
|
3516
3814
|
if (effect.type === "refinement") {
|
|
@@ -3799,10 +4097,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3799
4097
|
var ZodReadonly = class extends ZodType {
|
|
3800
4098
|
_parse(input) {
|
|
3801
4099
|
const result = this._def.innerType._parse(input);
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
4100
|
+
const freeze = (data) => {
|
|
4101
|
+
if (isValid(data)) {
|
|
4102
|
+
data.value = Object.freeze(data.value);
|
|
4103
|
+
}
|
|
4104
|
+
return data;
|
|
4105
|
+
};
|
|
4106
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
4107
|
+
}
|
|
4108
|
+
unwrap() {
|
|
4109
|
+
return this._def.innerType;
|
|
3806
4110
|
}
|
|
3807
4111
|
};
|
|
3808
4112
|
ZodReadonly.create = (type, params) => {
|
|
@@ -3812,7 +4116,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
3812
4116
|
...processCreateParams(params)
|
|
3813
4117
|
});
|
|
3814
4118
|
};
|
|
3815
|
-
|
|
4119
|
+
function custom(check, params = {}, fatal) {
|
|
3816
4120
|
if (check)
|
|
3817
4121
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3818
4122
|
var _a, _b;
|
|
@@ -3824,7 +4128,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
3824
4128
|
}
|
|
3825
4129
|
});
|
|
3826
4130
|
return ZodAny.create();
|
|
3827
|
-
}
|
|
4131
|
+
}
|
|
3828
4132
|
var late = {
|
|
3829
4133
|
object: ZodObject.lazycreate
|
|
3830
4134
|
};
|
|
@@ -3943,6 +4247,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3943
4247
|
ZodParsedType,
|
|
3944
4248
|
getParsedType,
|
|
3945
4249
|
ZodType,
|
|
4250
|
+
datetimeRegex,
|
|
3946
4251
|
ZodString,
|
|
3947
4252
|
ZodNumber,
|
|
3948
4253
|
ZodBigInt,
|
|
@@ -4073,6 +4378,7 @@ var bookPropsSchema = z.object({
|
|
|
4073
4378
|
title: z.string(),
|
|
4074
4379
|
subtitle: z.string().optional(),
|
|
4075
4380
|
design_request: bookDesignRequestSchema,
|
|
4381
|
+
sku: z.string().optional(),
|
|
4076
4382
|
state: z.enum(states).optional(),
|
|
4077
4383
|
guid: z.string().optional(),
|
|
4078
4384
|
cancelled_at: z.string().optional(),
|
|
@@ -4086,6 +4392,7 @@ var Book = class {
|
|
|
4086
4392
|
revision;
|
|
4087
4393
|
subtitle;
|
|
4088
4394
|
design_request;
|
|
4395
|
+
sku;
|
|
4089
4396
|
state;
|
|
4090
4397
|
guid;
|
|
4091
4398
|
cancelled_at;
|
|
@@ -4096,6 +4403,7 @@ var Book = class {
|
|
|
4096
4403
|
this.title = props.title;
|
|
4097
4404
|
this.subtitle = props.subtitle;
|
|
4098
4405
|
this.design_request = new BookDesignRequest(props.design_request);
|
|
4406
|
+
this.sku = props.sku;
|
|
4099
4407
|
this.state = props.state;
|
|
4100
4408
|
this.guid = props.guid;
|
|
4101
4409
|
this.cancelled_at = props.cancelled_at;
|
|
@@ -4246,6 +4554,7 @@ var DesignRequest = class {
|
|
|
4246
4554
|
this.subtitle = designRequestProps?.subtitle;
|
|
4247
4555
|
this.occasion = designRequestProps?.occasion || occasions[0];
|
|
4248
4556
|
this.style = designRequestProps?.style || parseInt(Object.keys(styles)[0]);
|
|
4557
|
+
this.sku = designRequestProps?.sku;
|
|
4249
4558
|
this.bookSize = designRequestProps?.bookSize || bookSizes[0];
|
|
4250
4559
|
this.coverType = designRequestProps?.coverType || coverTypes[0];
|
|
4251
4560
|
this.pageType = designRequestProps?.pageType || pageTypes[0];
|
|
@@ -4261,6 +4570,7 @@ var DesignRequest = class {
|
|
|
4261
4570
|
subtitle;
|
|
4262
4571
|
occasion;
|
|
4263
4572
|
style;
|
|
4573
|
+
sku;
|
|
4264
4574
|
bookSize;
|
|
4265
4575
|
coverType;
|
|
4266
4576
|
pageType;
|
|
@@ -4285,7 +4595,8 @@ var DesignRequest = class {
|
|
|
4285
4595
|
await this.client.engineAPI.designOptions.retrieve(
|
|
4286
4596
|
this.bookSize,
|
|
4287
4597
|
imageCount || this.images.length,
|
|
4288
|
-
this.imageFilteringLevel
|
|
4598
|
+
this.imageFilteringLevel,
|
|
4599
|
+
this.sku
|
|
4289
4600
|
)
|
|
4290
4601
|
)
|
|
4291
4602
|
);
|
|
@@ -4337,9 +4648,9 @@ var DesignRequest = class {
|
|
|
4337
4648
|
return this;
|
|
4338
4649
|
}
|
|
4339
4650
|
}
|
|
4340
|
-
async getJSON() {
|
|
4651
|
+
async getJSON(format) {
|
|
4341
4652
|
if (this.state === "ready") {
|
|
4342
|
-
return await this.client.engineAPI.books.
|
|
4653
|
+
return await this.client.engineAPI.books.format(this.parentId, format);
|
|
4343
4654
|
} else {
|
|
4344
4655
|
throw new Error("Design request not ready");
|
|
4345
4656
|
}
|
|
@@ -4401,6 +4712,7 @@ var DesignRequest = class {
|
|
|
4401
4712
|
title: designRequest.title,
|
|
4402
4713
|
subtitle: designRequest.subtitle,
|
|
4403
4714
|
design_request: bookDesignRequest,
|
|
4715
|
+
sku: designRequest.sku,
|
|
4404
4716
|
state: designRequest.state,
|
|
4405
4717
|
user_id: designRequest.userId
|
|
4406
4718
|
});
|
|
@@ -4565,10 +4877,10 @@ var BooksEndpoints = class {
|
|
|
4565
4877
|
});
|
|
4566
4878
|
});
|
|
4567
4879
|
}
|
|
4568
|
-
|
|
4880
|
+
format(bookId, format) {
|
|
4569
4881
|
return handleAsyncFunction(async () => {
|
|
4570
4882
|
const res = await this.engineAPI.fetcher.call({
|
|
4571
|
-
path: `/v1/books/${bookId}/format
|
|
4883
|
+
path: `/v1/books/${bookId}/format/${format}`
|
|
4572
4884
|
});
|
|
4573
4885
|
return bookCreationRequestSchema.parse(res);
|
|
4574
4886
|
});
|
|
@@ -4582,11 +4894,11 @@ var DesignOptionsEndpoints = class {
|
|
|
4582
4894
|
this.engineAPI = engineAPI;
|
|
4583
4895
|
bindThisToFunctions(this);
|
|
4584
4896
|
}
|
|
4585
|
-
retrieve(bookSize, imageCount, imageFilteringLevel) {
|
|
4897
|
+
retrieve(bookSize, imageCount, imageFilteringLevel, sku) {
|
|
4586
4898
|
return handleAsyncFunction(async () => {
|
|
4587
4899
|
const res = await this.engineAPI.fetcher.call({
|
|
4588
4900
|
// eslint-disable-next-line max-len
|
|
4589
|
-
path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
|
|
4901
|
+
path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}${sku ? `?sku=${sku}` : ""}`
|
|
4590
4902
|
});
|
|
4591
4903
|
return designOptionsServerSchema.parse(res);
|
|
4592
4904
|
});
|
|
@@ -5009,6 +5321,7 @@ export {
|
|
|
5009
5321
|
designOptionsSchema,
|
|
5010
5322
|
designOptionsServerSchema,
|
|
5011
5323
|
embellishmentLevels,
|
|
5324
|
+
formats,
|
|
5012
5325
|
imageAssignmentSchema,
|
|
5013
5326
|
imageDensities,
|
|
5014
5327
|
imageDensityOptionSchema,
|