@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.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);
|
|
@@ -106,6 +112,7 @@ var occasions = [
|
|
|
106
112
|
"year-in-review"
|
|
107
113
|
];
|
|
108
114
|
var styles = {
|
|
115
|
+
//shutterfly styles
|
|
109
116
|
1005: { slug: "modern-black-sfly" },
|
|
110
117
|
1101: { slug: "bon-voyage-sfly" },
|
|
111
118
|
1103: { slug: "fun-in-the-sun-sfly" },
|
|
@@ -276,9 +283,120 @@ var styles = {
|
|
|
276
283
|
6098: { slug: "black-and-white-rustic-sfly" },
|
|
277
284
|
6099: { slug: "bright-color-pop-sfly" },
|
|
278
285
|
6159: { slug: "grateful-for-you-sfly" },
|
|
279
|
-
6156: { slug: "europe-mementos-sfly" }
|
|
286
|
+
6156: { slug: "europe-mementos-sfly" },
|
|
287
|
+
//snapfish styles
|
|
288
|
+
be5f79d7525f4717844db77a2f1b5e50: { slug: "abstract-baby-first-year-snap" },
|
|
289
|
+
"519bf5f2b6734103a9a359469be4961b": { slug: "album-snap" },
|
|
290
|
+
"029a2ebd65b448bf93753c813b7b7363": { slug: "all-about-love-snap" },
|
|
291
|
+
"16d0d436594b4171bd9688876a85c9c1": { slug: "alphabet-book-snap" },
|
|
292
|
+
"5b95e1d678584558b2c3397ab996da7b": { slug: "always-and-forever-snap" },
|
|
293
|
+
a2c088e32541429ba8e5e15d09991264: { slug: "art-of-travel-snap" },
|
|
294
|
+
"0ddec2b965094c8ea03d669e771ff1a6": { slug: "autumn-snapshots-snap" },
|
|
295
|
+
"339699fedd3743f69c5b05587fbfd41a": { slug: "baby-boy-first-year-snap" },
|
|
296
|
+
"091f9a6a83c349b2a9732177d89f8664": { slug: "baby-girl-first-year-snap" },
|
|
297
|
+
e768ec11406545809ca9598be3bda88c: { slug: "best-dad-ever-snap" },
|
|
298
|
+
"0c55a3eb5cc6414c9f2570886132d331": { slug: "best-year-ever-snap" },
|
|
299
|
+
"9c49df50d76b4789834ca7abaabe2bc6": { slug: "bold-shapes-snap" },
|
|
300
|
+
fd7cf7c4dc244705ad391334d76f7229: { slug: "bold-type-snap" },
|
|
301
|
+
"363ceab4906b47a09dd287f53dc1d30f": { slug: "botanicals-snap" },
|
|
302
|
+
e47017576d0e451180ff4591d2aee2fa: { slug: "celebrating-grandma-snap" },
|
|
303
|
+
d9743da5f46843aab84b1f90ff776ee0: { slug: "celebrating-mum-snap" },
|
|
304
|
+
"13039c15c81b4e50af5e39cd99f4e274": { slug: "chalkboard-snap" },
|
|
305
|
+
"0c98757783874104a488a1a88747344d": { slug: "childs-yearbook-snap" },
|
|
306
|
+
"5b0d80d6ca164919b7ee558c0bc2537b": { slug: "classic-fathers-snap" },
|
|
307
|
+
eb734aa7c87a4db1ac9695e935f13489: { slug: "colour-block-rainbow-snap" },
|
|
308
|
+
"7ed9132a96484ed2b200cf30e73cf049": { slug: "contemporary-travel-snap" },
|
|
309
|
+
"3e15106389764a3cb2b6a6c29c065993": { slug: "contemporary-wedding-snap" },
|
|
310
|
+
"47f9e28d811842a5870c74bb4c6b3608": { slug: "design-your-own-snap" },
|
|
311
|
+
bef3d3bc49f3476aa6f39ad073294a04: { slug: "destination-stamps-snap" },
|
|
312
|
+
"496138703d5346bd9678a2fa487b54fd": { slug: "dip-dye-snap" },
|
|
313
|
+
"303773eee9934e8ba9f676b339c84d39": { slug: "earth-tones-snap" },
|
|
314
|
+
"02c52e4cdccd40b0b99cf2215a6b8fe1": { slug: "elegant-florals-snap" },
|
|
315
|
+
c59f05e866344332b2953199fd2972fa: { slug: "everyday-happiness-snap" },
|
|
316
|
+
"5a2d025aaa3746b2b047daa6206ba8ad": { slug: "family-chalkboard-snap" },
|
|
317
|
+
"1c8784e76020435d88ddab7bc8d72cae": { slug: "family-farmhouse-snap" },
|
|
318
|
+
"1735277701d6483e9934074f25053f3a": { slug: "family-memories-snap" },
|
|
319
|
+
"9c35a7f890204c38adb4255571377114": { slug: "family-yearbook-snap" },
|
|
320
|
+
"9c946c20f0dc45adb3f85735690f3395": { slug: "favourite-things-snap" },
|
|
321
|
+
c216373996d945c186cc6db5a53e10b1: { slug: "framed-full-photo-snap" },
|
|
322
|
+
"6f7cd5c4e4e247f2bdf7c44ace0fdad5": { slug: "fresh-cookbook-snap" },
|
|
323
|
+
"7eae47a7cbd743d4a47ca94f7a6b87a7": { slug: "full-and-multi-square-photo-snap" },
|
|
324
|
+
ac7a649cbd27433c9d0b405f34ff29f5: { slug: "full-photo-snap" },
|
|
325
|
+
"3aa989376bc5414eb2a35f2cb930f57c": { slug: "full-photo-snap" },
|
|
326
|
+
d86767aacb4f464892702ed3ffac1a98: { slug: "fun-dots-snap" },
|
|
327
|
+
c5d1654a989d4f2f87594e486239e77b: { slug: "geometric-lines-snap" },
|
|
328
|
+
"73e54769af5f4943a8403c6a5e38f5fb": { slug: "golden-graduation-snap" },
|
|
329
|
+
"7d15aef8b54d41ee82a99d327d571020": { slug: "graduation-memories-snap" },
|
|
330
|
+
"46594aace0ca42b1bdd086d1b8ac0ad4": { slug: "guest-book-snap" },
|
|
331
|
+
"77c78fbe2b4b4c7fb37e34a9515912d2": { slug: "hearts-for-mum-snap" },
|
|
332
|
+
"659893fcc6c24fef9ea1a3a8ccf2539e": { slug: "hello-baby-snap" },
|
|
333
|
+
"0f1182fcc18c428fb7c3d80c5a637c3b": { slug: "hello-baby-boy-snap" },
|
|
334
|
+
"54b7a8ca59774060835fdd48653dba9a": { slug: "hello-baby-girl-snap" },
|
|
335
|
+
"2d56caccc29a40b5bd16334937de0083": { slug: "i-love-my-cat-snap" },
|
|
336
|
+
"3c12993b18ff473fa6fc7f695bd64180": { slug: "i-love-my-dog-snap" },
|
|
337
|
+
c4393a1da2e54ca4ab9a3ec0aeb682e4: { slug: "lets-celebrate-snap" },
|
|
338
|
+
ee9fd665523c41078a65c5389896d0ab: { slug: "love-lives-here-snap" },
|
|
339
|
+
b84d0171dbb748e1ab2fb535fd318830: { slug: "love-story-snap" },
|
|
340
|
+
"4d61b18d992c4d8eb33a331e4201ae05": { slug: "magical-memories-snap" },
|
|
341
|
+
bdbe9158b33343c6ae11217fde9c8a57: { slug: "milestone-memories-snap" },
|
|
342
|
+
"790a78454af94287b2a84c2324d6956e": { slug: "modern-graduation-snap" },
|
|
343
|
+
"4211083b4bad4fee87e04dd65e5fed5d": { slug: "modern-highlights-snap" },
|
|
344
|
+
"47bb41bb9e174657aa0c48ec140ed2c8": { slug: "modern-rustic-snap" },
|
|
345
|
+
bac69bcc341c445d9c5c81f04231c685: { slug: "my-family-snap" },
|
|
346
|
+
"2d561db2b849457f8f830c2e977ced6c": { slug: "my-graduation-snap" },
|
|
347
|
+
e2727f32f9e248a3a7fd02f50cf493ab: { slug: "natural-blues-snap" },
|
|
348
|
+
"85005f9b9c1c4a4485508c52465b7110": { slug: "nautical-summer-snap" },
|
|
349
|
+
df1eded2d6e24c81a9e9bd66567b39f0: { slug: "organic-patterns-snap" },
|
|
350
|
+
bfdc9b325b1a4471a948eccb7c76fd2e: { slug: "organic-shapes-snap" },
|
|
351
|
+
"7cb42c74e4704c08a51f0930703fff34": { slug: "our-wedding-guests-snap" },
|
|
352
|
+
c88a62c1e3584591b278fe0ccfe3b02b: { slug: "over-the-moon-snap" },
|
|
353
|
+
"2a682e5b38d64f77b7c1b6c0a8a06670": { slug: "painterly-patterns-snap" },
|
|
354
|
+
"5eddabc29f704c66ba03deff870f2c18": { slug: "precious-experiences-snap" },
|
|
355
|
+
"18f048f0a07f40c09495fdc3830f7228": { slug: "reflections-on-our-year-snap" },
|
|
356
|
+
f2fd5fd83bbb4e9ebf3af33ba4589561: { slug: "roadtrip-snap" },
|
|
357
|
+
"31ed7e06afb347f2a302ba35267c8a0a": { slug: "rustic-chic-snap" },
|
|
358
|
+
"17e8062b9ed749ba8428cbb3924e719d": { slug: "rustic-family-snapshots-snap" },
|
|
359
|
+
"7573b1a594e8405295adfcf145c5322a": { slug: "serene-memories-snap" },
|
|
360
|
+
acc3ac3b7e724c288a849b471616e373: { slug: "simple-snap" },
|
|
361
|
+
ddb203e3ae0443209ada75135e13a63e: { slug: "simple-family-moments-snap" },
|
|
362
|
+
bdee0a45e5144156b88621238cd31bbe: { slug: "simply-love-snap" },
|
|
363
|
+
dc0d15f9aa474bd89c49e6da49bb3cc5: { slug: "sketched-botanicals-snap" },
|
|
364
|
+
"55cebda93e1c4f52b07d824a57f8677b": { slug: "smitten-snap" },
|
|
365
|
+
"2172f706eedf4c36a3fba10a0fe5448d": { slug: "snow-days-snap" },
|
|
366
|
+
"0964a6d8e0234df7ad7df8e56c33ff2b": { slug: "solid-brights-snap" },
|
|
367
|
+
e47b1860677e45909de56915a350a84e: { slug: "studio-snap" },
|
|
368
|
+
"0b8fcc5f30cb4649bb4d8ea9cf35578c": { slug: "studio-multi-snap" },
|
|
369
|
+
"2972e73653da4dc5805853e22717f1ee": { slug: "summer-snapshots-snap" },
|
|
370
|
+
f292a52aff774e698fe26dc61a7a3f71: { slug: "team-spirit-snap" },
|
|
371
|
+
b9192bf9df6b4984b29f4731b5f0bb63: { slug: "ten-things-i-love-snap" },
|
|
372
|
+
d2dd8fe6e2e44c78935206323ee89af1: { slug: "travel-maps-snap" },
|
|
373
|
+
"61f74eec39ff425b85e4f1c7e9e15ef6": { slug: "travel-memories-snap" },
|
|
374
|
+
"148b777f385c4df2bc1b4900a4208e82": { slug: "travel-stamps-snap" },
|
|
375
|
+
"77550e4c36b34454bac2ae9c4d9d2bd1": { slug: "tropical-beach-escape-snap" },
|
|
376
|
+
"6aac0d2309744e9ea8fd4621f8213dbd": { slug: "unfurgettable-kitty-snap" },
|
|
377
|
+
f5ef0aaddd294a0ba37ebc76012858ff: { slug: "vibrant-memories-snap" },
|
|
378
|
+
"73966e2885a544ed9ba8e0a314a6528c": { slug: "vintage-birthday-memories-snap" },
|
|
379
|
+
"33242c4285024ccfafc57d72a7292ea9": { slug: "warm-neutrals-snap" },
|
|
380
|
+
"605f06522caa449ba93b7c5fa4d8e54b": { slug: "warmest-memories-snap" },
|
|
381
|
+
c154e4664672441fa640f1ddff883db1: { slug: "watercolour-memories-snap" },
|
|
382
|
+
"86024d3f1def489495cc7525d8232bea": { slug: "watercolour-sketchbook-snap" },
|
|
383
|
+
f52d1dd24f9c49ae82d8f70449fe40b7: { slug: "watercolour-wonders-snap" },
|
|
384
|
+
"1cbbd20a3a4542f38d2f9932016c4584": { slug: "watercolours-snap" },
|
|
385
|
+
fdf4b31ea3434b03a5c3ddaab1579084: { slug: "wedding-studio-snap" },
|
|
386
|
+
"1b104c3a036e4825bd60a5c7ceac4e66": { slug: "winter-magic-snap" },
|
|
387
|
+
"03f332e3b2b947ebae73b67a9a22b6f4": { slug: "winter-sparkle-snap" },
|
|
388
|
+
"97f70f6cdb5244a08d45772cccfa2788": { slug: "year-of-memories-snap" }
|
|
280
389
|
};
|
|
281
|
-
var bookSizes = [
|
|
390
|
+
var bookSizes = [
|
|
391
|
+
"5x7",
|
|
392
|
+
"6x6",
|
|
393
|
+
"8x8",
|
|
394
|
+
"10x10",
|
|
395
|
+
"12x12",
|
|
396
|
+
"8x11",
|
|
397
|
+
"11x8",
|
|
398
|
+
"11x14"
|
|
399
|
+
];
|
|
282
400
|
var coverTypes = ["sc", "hc", "pl"];
|
|
283
401
|
var pageTypes = ["sp", "sl", "dl"];
|
|
284
402
|
var imageDensities = ["low", "medium", "high"];
|
|
@@ -297,6 +415,7 @@ var cancelledEventDetail = {
|
|
|
297
415
|
progress: 100,
|
|
298
416
|
message: "Design canceled"
|
|
299
417
|
};
|
|
418
|
+
var formats = ["galleon", "snapfish"];
|
|
300
419
|
|
|
301
420
|
// ../../core/utils/toolbox.ts
|
|
302
421
|
function mergeNestedObject(obj, objToMerge) {
|
|
@@ -364,13 +483,13 @@ function getStyleIdBySlug(slug) {
|
|
|
364
483
|
for (const id in styles) {
|
|
365
484
|
const style = styles[id];
|
|
366
485
|
if (style.slug === slug) {
|
|
367
|
-
return
|
|
486
|
+
return id;
|
|
368
487
|
}
|
|
369
488
|
}
|
|
370
489
|
return void 0;
|
|
371
490
|
}
|
|
372
491
|
|
|
373
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
492
|
+
// ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
|
374
493
|
var util;
|
|
375
494
|
(function(util2) {
|
|
376
495
|
util2.assertEqual = (val) => val;
|
|
@@ -524,7 +643,7 @@ var quotelessJson = (obj) => {
|
|
|
524
643
|
const json = JSON.stringify(obj, null, 2);
|
|
525
644
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
526
645
|
};
|
|
527
|
-
var ZodError = class extends Error {
|
|
646
|
+
var ZodError = class _ZodError extends Error {
|
|
528
647
|
constructor(issues) {
|
|
529
648
|
super();
|
|
530
649
|
this.issues = [];
|
|
@@ -582,6 +701,11 @@ var ZodError = class extends Error {
|
|
|
582
701
|
processError(this);
|
|
583
702
|
return fieldErrors;
|
|
584
703
|
}
|
|
704
|
+
static assert(value) {
|
|
705
|
+
if (!(value instanceof _ZodError)) {
|
|
706
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
585
709
|
toString() {
|
|
586
710
|
return this.message;
|
|
587
711
|
}
|
|
@@ -724,6 +848,13 @@ var makeIssue = (params) => {
|
|
|
724
848
|
...issueData,
|
|
725
849
|
path: fullPath
|
|
726
850
|
};
|
|
851
|
+
if (issueData.message !== void 0) {
|
|
852
|
+
return {
|
|
853
|
+
...issueData,
|
|
854
|
+
path: fullPath,
|
|
855
|
+
message: issueData.message
|
|
856
|
+
};
|
|
857
|
+
}
|
|
727
858
|
let errorMessage = "";
|
|
728
859
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
729
860
|
for (const map of maps) {
|
|
@@ -732,11 +863,12 @@ var makeIssue = (params) => {
|
|
|
732
863
|
return {
|
|
733
864
|
...issueData,
|
|
734
865
|
path: fullPath,
|
|
735
|
-
message:
|
|
866
|
+
message: errorMessage
|
|
736
867
|
};
|
|
737
868
|
};
|
|
738
869
|
var EMPTY_PATH = [];
|
|
739
870
|
function addIssueToContext(ctx, issueData) {
|
|
871
|
+
const overrideMap = getErrorMap();
|
|
740
872
|
const issue = makeIssue({
|
|
741
873
|
issueData,
|
|
742
874
|
data: ctx.data,
|
|
@@ -744,8 +876,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
744
876
|
errorMaps: [
|
|
745
877
|
ctx.common.contextualErrorMap,
|
|
746
878
|
ctx.schemaErrorMap,
|
|
747
|
-
|
|
748
|
-
errorMap
|
|
879
|
+
overrideMap,
|
|
880
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
749
881
|
// then global default map
|
|
750
882
|
].filter((x) => !!x)
|
|
751
883
|
});
|
|
@@ -777,9 +909,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
777
909
|
static async mergeObjectAsync(status, pairs) {
|
|
778
910
|
const syncPairs = [];
|
|
779
911
|
for (const pair of pairs) {
|
|
912
|
+
const key = await pair.key;
|
|
913
|
+
const value = await pair.value;
|
|
780
914
|
syncPairs.push({
|
|
781
|
-
key
|
|
782
|
-
value
|
|
915
|
+
key,
|
|
916
|
+
value
|
|
783
917
|
});
|
|
784
918
|
}
|
|
785
919
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -812,11 +946,29 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
812
946
|
var isDirty = (x) => x.status === "dirty";
|
|
813
947
|
var isValid = (x) => x.status === "valid";
|
|
814
948
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
949
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
950
|
+
if (kind === "a" && !f)
|
|
951
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
952
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
953
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
954
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
955
|
+
}
|
|
956
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
957
|
+
if (kind === "m")
|
|
958
|
+
throw new TypeError("Private method is not writable");
|
|
959
|
+
if (kind === "a" && !f)
|
|
960
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
961
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
962
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
963
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
964
|
+
}
|
|
815
965
|
var errorUtil;
|
|
816
966
|
(function(errorUtil2) {
|
|
817
967
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
818
968
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
819
969
|
})(errorUtil || (errorUtil = {}));
|
|
970
|
+
var _ZodEnum_cache;
|
|
971
|
+
var _ZodNativeEnum_cache;
|
|
820
972
|
var ParseInputLazyPath = class {
|
|
821
973
|
constructor(parent, value, path, key) {
|
|
822
974
|
this._cachedPath = [];
|
|
@@ -865,12 +1017,17 @@ function processCreateParams(params) {
|
|
|
865
1017
|
if (errorMap2)
|
|
866
1018
|
return { errorMap: errorMap2, description };
|
|
867
1019
|
const customMap = (iss, ctx) => {
|
|
868
|
-
|
|
869
|
-
|
|
1020
|
+
var _a, _b;
|
|
1021
|
+
const { message } = params;
|
|
1022
|
+
if (iss.code === "invalid_enum_value") {
|
|
1023
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
1024
|
+
}
|
|
870
1025
|
if (typeof ctx.data === "undefined") {
|
|
871
|
-
return { message:
|
|
1026
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
872
1027
|
}
|
|
873
|
-
|
|
1028
|
+
if (iss.code !== "invalid_type")
|
|
1029
|
+
return { message: ctx.defaultError };
|
|
1030
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
874
1031
|
};
|
|
875
1032
|
return { errorMap: customMap, description };
|
|
876
1033
|
}
|
|
@@ -1118,35 +1275,40 @@ var ZodType = class {
|
|
|
1118
1275
|
}
|
|
1119
1276
|
};
|
|
1120
1277
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1121
|
-
var cuid2Regex = /^[
|
|
1278
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
1122
1279
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1123
1280
|
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
|
|
1281
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1282
|
+
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)?)??$/;
|
|
1283
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1125
1284
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1126
1285
|
var emojiRegex;
|
|
1127
|
-
var ipv4Regex = /^((
|
|
1286
|
+
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
1287
|
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
|
|
1288
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1289
|
+
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])))`;
|
|
1290
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1291
|
+
function timeRegexSource(args) {
|
|
1292
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1130
1293
|
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
|
-
}
|
|
1294
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1295
|
+
} else if (args.precision == null) {
|
|
1296
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1148
1297
|
}
|
|
1149
|
-
|
|
1298
|
+
return regex;
|
|
1299
|
+
}
|
|
1300
|
+
function timeRegex(args) {
|
|
1301
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1302
|
+
}
|
|
1303
|
+
function datetimeRegex(args) {
|
|
1304
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1305
|
+
const opts = [];
|
|
1306
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1307
|
+
if (args.offset)
|
|
1308
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1309
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1310
|
+
return new RegExp(`^${regex}$`);
|
|
1311
|
+
}
|
|
1150
1312
|
function isValidIP(ip, version) {
|
|
1151
1313
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1152
1314
|
return true;
|
|
@@ -1164,15 +1326,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1164
1326
|
const parsedType = this._getType(input);
|
|
1165
1327
|
if (parsedType !== ZodParsedType.string) {
|
|
1166
1328
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1167
|
-
addIssueToContext(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
received: ctx2.parsedType
|
|
1173
|
-
}
|
|
1174
|
-
//
|
|
1175
|
-
);
|
|
1329
|
+
addIssueToContext(ctx2, {
|
|
1330
|
+
code: ZodIssueCode.invalid_type,
|
|
1331
|
+
expected: ZodParsedType.string,
|
|
1332
|
+
received: ctx2.parsedType
|
|
1333
|
+
});
|
|
1176
1334
|
return INVALID;
|
|
1177
1335
|
}
|
|
1178
1336
|
const status = new ParseStatus();
|
|
@@ -1263,6 +1421,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1263
1421
|
});
|
|
1264
1422
|
status.dirty();
|
|
1265
1423
|
}
|
|
1424
|
+
} else if (check.kind === "nanoid") {
|
|
1425
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1426
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1427
|
+
addIssueToContext(ctx, {
|
|
1428
|
+
validation: "nanoid",
|
|
1429
|
+
code: ZodIssueCode.invalid_string,
|
|
1430
|
+
message: check.message
|
|
1431
|
+
});
|
|
1432
|
+
status.dirty();
|
|
1433
|
+
}
|
|
1266
1434
|
} else if (check.kind === "cuid") {
|
|
1267
1435
|
if (!cuidRegex.test(input.data)) {
|
|
1268
1436
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1364,6 +1532,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1364
1532
|
});
|
|
1365
1533
|
status.dirty();
|
|
1366
1534
|
}
|
|
1535
|
+
} else if (check.kind === "date") {
|
|
1536
|
+
const regex = dateRegex;
|
|
1537
|
+
if (!regex.test(input.data)) {
|
|
1538
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1539
|
+
addIssueToContext(ctx, {
|
|
1540
|
+
code: ZodIssueCode.invalid_string,
|
|
1541
|
+
validation: "date",
|
|
1542
|
+
message: check.message
|
|
1543
|
+
});
|
|
1544
|
+
status.dirty();
|
|
1545
|
+
}
|
|
1546
|
+
} else if (check.kind === "time") {
|
|
1547
|
+
const regex = timeRegex(check);
|
|
1548
|
+
if (!regex.test(input.data)) {
|
|
1549
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1550
|
+
addIssueToContext(ctx, {
|
|
1551
|
+
code: ZodIssueCode.invalid_string,
|
|
1552
|
+
validation: "time",
|
|
1553
|
+
message: check.message
|
|
1554
|
+
});
|
|
1555
|
+
status.dirty();
|
|
1556
|
+
}
|
|
1557
|
+
} else if (check.kind === "duration") {
|
|
1558
|
+
if (!durationRegex.test(input.data)) {
|
|
1559
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1560
|
+
addIssueToContext(ctx, {
|
|
1561
|
+
validation: "duration",
|
|
1562
|
+
code: ZodIssueCode.invalid_string,
|
|
1563
|
+
message: check.message
|
|
1564
|
+
});
|
|
1565
|
+
status.dirty();
|
|
1566
|
+
}
|
|
1367
1567
|
} else if (check.kind === "ip") {
|
|
1368
1568
|
if (!isValidIP(input.data, check.version)) {
|
|
1369
1569
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1374,6 +1574,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1374
1574
|
});
|
|
1375
1575
|
status.dirty();
|
|
1376
1576
|
}
|
|
1577
|
+
} else if (check.kind === "base64") {
|
|
1578
|
+
if (!base64Regex.test(input.data)) {
|
|
1579
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1580
|
+
addIssueToContext(ctx, {
|
|
1581
|
+
validation: "base64",
|
|
1582
|
+
code: ZodIssueCode.invalid_string,
|
|
1583
|
+
message: check.message
|
|
1584
|
+
});
|
|
1585
|
+
status.dirty();
|
|
1586
|
+
}
|
|
1377
1587
|
} else {
|
|
1378
1588
|
util.assertNever(check);
|
|
1379
1589
|
}
|
|
@@ -1405,6 +1615,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1405
1615
|
uuid(message) {
|
|
1406
1616
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1407
1617
|
}
|
|
1618
|
+
nanoid(message) {
|
|
1619
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1620
|
+
}
|
|
1408
1621
|
cuid(message) {
|
|
1409
1622
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1410
1623
|
}
|
|
@@ -1414,16 +1627,20 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1414
1627
|
ulid(message) {
|
|
1415
1628
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1416
1629
|
}
|
|
1630
|
+
base64(message) {
|
|
1631
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1632
|
+
}
|
|
1417
1633
|
ip(options) {
|
|
1418
1634
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1419
1635
|
}
|
|
1420
1636
|
datetime(options) {
|
|
1421
|
-
var _a;
|
|
1637
|
+
var _a, _b;
|
|
1422
1638
|
if (typeof options === "string") {
|
|
1423
1639
|
return this._addCheck({
|
|
1424
1640
|
kind: "datetime",
|
|
1425
1641
|
precision: null,
|
|
1426
1642
|
offset: false,
|
|
1643
|
+
local: false,
|
|
1427
1644
|
message: options
|
|
1428
1645
|
});
|
|
1429
1646
|
}
|
|
@@ -1431,9 +1648,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1431
1648
|
kind: "datetime",
|
|
1432
1649
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1433
1650
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1651
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1652
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
date(message) {
|
|
1656
|
+
return this._addCheck({ kind: "date", message });
|
|
1657
|
+
}
|
|
1658
|
+
time(options) {
|
|
1659
|
+
if (typeof options === "string") {
|
|
1660
|
+
return this._addCheck({
|
|
1661
|
+
kind: "time",
|
|
1662
|
+
precision: null,
|
|
1663
|
+
message: options
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
return this._addCheck({
|
|
1667
|
+
kind: "time",
|
|
1668
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1434
1669
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1435
1670
|
});
|
|
1436
1671
|
}
|
|
1672
|
+
duration(message) {
|
|
1673
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1674
|
+
}
|
|
1437
1675
|
regex(regex, message) {
|
|
1438
1676
|
return this._addCheck({
|
|
1439
1677
|
kind: "regex",
|
|
@@ -1512,6 +1750,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1512
1750
|
get isDatetime() {
|
|
1513
1751
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1514
1752
|
}
|
|
1753
|
+
get isDate() {
|
|
1754
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1755
|
+
}
|
|
1756
|
+
get isTime() {
|
|
1757
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1758
|
+
}
|
|
1759
|
+
get isDuration() {
|
|
1760
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1761
|
+
}
|
|
1515
1762
|
get isEmail() {
|
|
1516
1763
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1517
1764
|
}
|
|
@@ -1524,6 +1771,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1524
1771
|
get isUUID() {
|
|
1525
1772
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1526
1773
|
}
|
|
1774
|
+
get isNANOID() {
|
|
1775
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1776
|
+
}
|
|
1527
1777
|
get isCUID() {
|
|
1528
1778
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1529
1779
|
}
|
|
@@ -1536,6 +1786,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1536
1786
|
get isIP() {
|
|
1537
1787
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1538
1788
|
}
|
|
1789
|
+
get isBase64() {
|
|
1790
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1791
|
+
}
|
|
1539
1792
|
get minLength() {
|
|
1540
1793
|
let min = null;
|
|
1541
1794
|
for (const ch of this._def.checks) {
|
|
@@ -2449,9 +2702,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2449
2702
|
const syncPairs = [];
|
|
2450
2703
|
for (const pair of pairs) {
|
|
2451
2704
|
const key = await pair.key;
|
|
2705
|
+
const value = await pair.value;
|
|
2452
2706
|
syncPairs.push({
|
|
2453
2707
|
key,
|
|
2454
|
-
value
|
|
2708
|
+
value,
|
|
2455
2709
|
alwaysSet: pair.alwaysSet
|
|
2456
2710
|
});
|
|
2457
2711
|
}
|
|
@@ -2802,15 +3056,25 @@ var getDiscriminator = (type) => {
|
|
|
2802
3056
|
} else if (type instanceof ZodEnum) {
|
|
2803
3057
|
return type.options;
|
|
2804
3058
|
} else if (type instanceof ZodNativeEnum) {
|
|
2805
|
-
return
|
|
3059
|
+
return util.objectValues(type.enum);
|
|
2806
3060
|
} else if (type instanceof ZodDefault) {
|
|
2807
3061
|
return getDiscriminator(type._def.innerType);
|
|
2808
3062
|
} else if (type instanceof ZodUndefined) {
|
|
2809
3063
|
return [void 0];
|
|
2810
3064
|
} else if (type instanceof ZodNull) {
|
|
2811
3065
|
return [null];
|
|
3066
|
+
} else if (type instanceof ZodOptional) {
|
|
3067
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
3068
|
+
} else if (type instanceof ZodNullable) {
|
|
3069
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
3070
|
+
} else if (type instanceof ZodBranded) {
|
|
3071
|
+
return getDiscriminator(type.unwrap());
|
|
3072
|
+
} else if (type instanceof ZodReadonly) {
|
|
3073
|
+
return getDiscriminator(type.unwrap());
|
|
3074
|
+
} else if (type instanceof ZodCatch) {
|
|
3075
|
+
return getDiscriminator(type._def.innerType);
|
|
2812
3076
|
} else {
|
|
2813
|
-
return
|
|
3077
|
+
return [];
|
|
2814
3078
|
}
|
|
2815
3079
|
};
|
|
2816
3080
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2870,7 +3134,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2870
3134
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2871
3135
|
for (const type of options) {
|
|
2872
3136
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2873
|
-
if (!discriminatorValues) {
|
|
3137
|
+
if (!discriminatorValues.length) {
|
|
2874
3138
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2875
3139
|
}
|
|
2876
3140
|
for (const value of discriminatorValues) {
|
|
@@ -3070,7 +3334,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3070
3334
|
for (const key in ctx.data) {
|
|
3071
3335
|
pairs.push({
|
|
3072
3336
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3073
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3337
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3338
|
+
alwaysSet: key in ctx.data
|
|
3074
3339
|
});
|
|
3075
3340
|
}
|
|
3076
3341
|
if (ctx.common.async) {
|
|
@@ -3414,6 +3679,10 @@ function createZodEnum(values, params) {
|
|
|
3414
3679
|
});
|
|
3415
3680
|
}
|
|
3416
3681
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3682
|
+
constructor() {
|
|
3683
|
+
super(...arguments);
|
|
3684
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3685
|
+
}
|
|
3417
3686
|
_parse(input) {
|
|
3418
3687
|
if (typeof input.data !== "string") {
|
|
3419
3688
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3425,7 +3694,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3425
3694
|
});
|
|
3426
3695
|
return INVALID;
|
|
3427
3696
|
}
|
|
3428
|
-
if (this
|
|
3697
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3698
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3699
|
+
}
|
|
3700
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3429
3701
|
const ctx = this._getOrReturnCtx(input);
|
|
3430
3702
|
const expectedValues = this._def.values;
|
|
3431
3703
|
addIssueToContext(ctx, {
|
|
@@ -3461,15 +3733,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3461
3733
|
}
|
|
3462
3734
|
return enumValues;
|
|
3463
3735
|
}
|
|
3464
|
-
extract(values) {
|
|
3465
|
-
return _ZodEnum.create(values
|
|
3736
|
+
extract(values, newDef = this._def) {
|
|
3737
|
+
return _ZodEnum.create(values, {
|
|
3738
|
+
...this._def,
|
|
3739
|
+
...newDef
|
|
3740
|
+
});
|
|
3466
3741
|
}
|
|
3467
|
-
exclude(values) {
|
|
3468
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
3742
|
+
exclude(values, newDef = this._def) {
|
|
3743
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3744
|
+
...this._def,
|
|
3745
|
+
...newDef
|
|
3746
|
+
});
|
|
3469
3747
|
}
|
|
3470
3748
|
};
|
|
3749
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3471
3750
|
ZodEnum.create = createZodEnum;
|
|
3472
3751
|
var ZodNativeEnum = class extends ZodType {
|
|
3752
|
+
constructor() {
|
|
3753
|
+
super(...arguments);
|
|
3754
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3755
|
+
}
|
|
3473
3756
|
_parse(input) {
|
|
3474
3757
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3475
3758
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3482,7 +3765,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3482
3765
|
});
|
|
3483
3766
|
return INVALID;
|
|
3484
3767
|
}
|
|
3485
|
-
if (
|
|
3768
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3769
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3770
|
+
}
|
|
3771
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3486
3772
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3487
3773
|
addIssueToContext(ctx, {
|
|
3488
3774
|
received: ctx.data,
|
|
@@ -3497,6 +3783,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3497
3783
|
return this._def.values;
|
|
3498
3784
|
}
|
|
3499
3785
|
};
|
|
3786
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3500
3787
|
ZodNativeEnum.create = (values, params) => {
|
|
3501
3788
|
return new ZodNativeEnum({
|
|
3502
3789
|
values,
|
|
@@ -3560,26 +3847,38 @@ var ZodEffects = class extends ZodType {
|
|
|
3560
3847
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3561
3848
|
if (effect.type === "preprocess") {
|
|
3562
3849
|
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
3850
|
if (ctx.common.async) {
|
|
3570
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3571
|
-
|
|
3851
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3852
|
+
if (status.value === "aborted")
|
|
3853
|
+
return INVALID;
|
|
3854
|
+
const result = await this._def.schema._parseAsync({
|
|
3572
3855
|
data: processed2,
|
|
3573
3856
|
path: ctx.path,
|
|
3574
3857
|
parent: ctx
|
|
3575
3858
|
});
|
|
3859
|
+
if (result.status === "aborted")
|
|
3860
|
+
return INVALID;
|
|
3861
|
+
if (result.status === "dirty")
|
|
3862
|
+
return DIRTY(result.value);
|
|
3863
|
+
if (status.value === "dirty")
|
|
3864
|
+
return DIRTY(result.value);
|
|
3865
|
+
return result;
|
|
3576
3866
|
});
|
|
3577
3867
|
} else {
|
|
3578
|
-
|
|
3868
|
+
if (status.value === "aborted")
|
|
3869
|
+
return INVALID;
|
|
3870
|
+
const result = this._def.schema._parseSync({
|
|
3579
3871
|
data: processed,
|
|
3580
3872
|
path: ctx.path,
|
|
3581
3873
|
parent: ctx
|
|
3582
3874
|
});
|
|
3875
|
+
if (result.status === "aborted")
|
|
3876
|
+
return INVALID;
|
|
3877
|
+
if (result.status === "dirty")
|
|
3878
|
+
return DIRTY(result.value);
|
|
3879
|
+
if (status.value === "dirty")
|
|
3880
|
+
return DIRTY(result.value);
|
|
3881
|
+
return result;
|
|
3583
3882
|
}
|
|
3584
3883
|
}
|
|
3585
3884
|
if (effect.type === "refinement") {
|
|
@@ -3868,10 +4167,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3868
4167
|
var ZodReadonly = class extends ZodType {
|
|
3869
4168
|
_parse(input) {
|
|
3870
4169
|
const result = this._def.innerType._parse(input);
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
4170
|
+
const freeze = (data) => {
|
|
4171
|
+
if (isValid(data)) {
|
|
4172
|
+
data.value = Object.freeze(data.value);
|
|
4173
|
+
}
|
|
4174
|
+
return data;
|
|
4175
|
+
};
|
|
4176
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
4177
|
+
}
|
|
4178
|
+
unwrap() {
|
|
4179
|
+
return this._def.innerType;
|
|
3875
4180
|
}
|
|
3876
4181
|
};
|
|
3877
4182
|
ZodReadonly.create = (type, params) => {
|
|
@@ -3881,7 +4186,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
3881
4186
|
...processCreateParams(params)
|
|
3882
4187
|
});
|
|
3883
4188
|
};
|
|
3884
|
-
|
|
4189
|
+
function custom(check, params = {}, fatal) {
|
|
3885
4190
|
if (check)
|
|
3886
4191
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3887
4192
|
var _a, _b;
|
|
@@ -3893,7 +4198,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
3893
4198
|
}
|
|
3894
4199
|
});
|
|
3895
4200
|
return ZodAny.create();
|
|
3896
|
-
}
|
|
4201
|
+
}
|
|
3897
4202
|
var late = {
|
|
3898
4203
|
object: ZodObject.lazycreate
|
|
3899
4204
|
};
|
|
@@ -4012,6 +4317,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4012
4317
|
ZodParsedType,
|
|
4013
4318
|
getParsedType,
|
|
4014
4319
|
ZodType,
|
|
4320
|
+
datetimeRegex,
|
|
4015
4321
|
ZodString,
|
|
4016
4322
|
ZodNumber,
|
|
4017
4323
|
ZodBigInt,
|
|
@@ -4142,6 +4448,7 @@ var bookPropsSchema = z.object({
|
|
|
4142
4448
|
title: z.string(),
|
|
4143
4449
|
subtitle: z.string().optional(),
|
|
4144
4450
|
design_request: bookDesignRequestSchema,
|
|
4451
|
+
sku: z.string().optional(),
|
|
4145
4452
|
state: z.enum(states).optional(),
|
|
4146
4453
|
guid: z.string().optional(),
|
|
4147
4454
|
cancelled_at: z.string().optional(),
|
|
@@ -4155,6 +4462,7 @@ var Book = class {
|
|
|
4155
4462
|
revision;
|
|
4156
4463
|
subtitle;
|
|
4157
4464
|
design_request;
|
|
4465
|
+
sku;
|
|
4158
4466
|
state;
|
|
4159
4467
|
guid;
|
|
4160
4468
|
cancelled_at;
|
|
@@ -4165,6 +4473,7 @@ var Book = class {
|
|
|
4165
4473
|
this.title = props.title;
|
|
4166
4474
|
this.subtitle = props.subtitle;
|
|
4167
4475
|
this.design_request = new BookDesignRequest(props.design_request);
|
|
4476
|
+
this.sku = props.sku;
|
|
4168
4477
|
this.state = props.state;
|
|
4169
4478
|
this.guid = props.guid;
|
|
4170
4479
|
this.cancelled_at = props.cancelled_at;
|
|
@@ -4315,6 +4624,7 @@ var DesignRequest = class {
|
|
|
4315
4624
|
this.subtitle = designRequestProps?.subtitle;
|
|
4316
4625
|
this.occasion = designRequestProps?.occasion || occasions[0];
|
|
4317
4626
|
this.style = designRequestProps?.style || parseInt(Object.keys(styles)[0]);
|
|
4627
|
+
this.sku = designRequestProps?.sku;
|
|
4318
4628
|
this.bookSize = designRequestProps?.bookSize || bookSizes[0];
|
|
4319
4629
|
this.coverType = designRequestProps?.coverType || coverTypes[0];
|
|
4320
4630
|
this.pageType = designRequestProps?.pageType || pageTypes[0];
|
|
@@ -4330,6 +4640,7 @@ var DesignRequest = class {
|
|
|
4330
4640
|
subtitle;
|
|
4331
4641
|
occasion;
|
|
4332
4642
|
style;
|
|
4643
|
+
sku;
|
|
4333
4644
|
bookSize;
|
|
4334
4645
|
coverType;
|
|
4335
4646
|
pageType;
|
|
@@ -4354,7 +4665,8 @@ var DesignRequest = class {
|
|
|
4354
4665
|
await this.client.engineAPI.designOptions.retrieve(
|
|
4355
4666
|
this.bookSize,
|
|
4356
4667
|
imageCount || this.images.length,
|
|
4357
|
-
this.imageFilteringLevel
|
|
4668
|
+
this.imageFilteringLevel,
|
|
4669
|
+
this.sku
|
|
4358
4670
|
)
|
|
4359
4671
|
)
|
|
4360
4672
|
);
|
|
@@ -4406,9 +4718,9 @@ var DesignRequest = class {
|
|
|
4406
4718
|
return this;
|
|
4407
4719
|
}
|
|
4408
4720
|
}
|
|
4409
|
-
async getJSON() {
|
|
4721
|
+
async getJSON(format) {
|
|
4410
4722
|
if (this.state === "ready") {
|
|
4411
|
-
return await this.client.engineAPI.books.
|
|
4723
|
+
return await this.client.engineAPI.books.format(this.parentId, format);
|
|
4412
4724
|
} else {
|
|
4413
4725
|
throw new Error("Design request not ready");
|
|
4414
4726
|
}
|
|
@@ -4470,6 +4782,7 @@ var DesignRequest = class {
|
|
|
4470
4782
|
title: designRequest.title,
|
|
4471
4783
|
subtitle: designRequest.subtitle,
|
|
4472
4784
|
design_request: bookDesignRequest,
|
|
4785
|
+
sku: designRequest.sku,
|
|
4473
4786
|
state: designRequest.state,
|
|
4474
4787
|
user_id: designRequest.userId
|
|
4475
4788
|
});
|
|
@@ -4634,10 +4947,10 @@ var BooksEndpoints = class {
|
|
|
4634
4947
|
});
|
|
4635
4948
|
});
|
|
4636
4949
|
}
|
|
4637
|
-
|
|
4950
|
+
format(bookId, format) {
|
|
4638
4951
|
return handleAsyncFunction(async () => {
|
|
4639
4952
|
const res = await this.engineAPI.fetcher.call({
|
|
4640
|
-
path: `/v1/books/${bookId}/format
|
|
4953
|
+
path: `/v1/books/${bookId}/format/${format}`
|
|
4641
4954
|
});
|
|
4642
4955
|
return bookCreationRequestSchema.parse(res);
|
|
4643
4956
|
});
|
|
@@ -4651,11 +4964,11 @@ var DesignOptionsEndpoints = class {
|
|
|
4651
4964
|
this.engineAPI = engineAPI;
|
|
4652
4965
|
bindThisToFunctions(this);
|
|
4653
4966
|
}
|
|
4654
|
-
retrieve(bookSize, imageCount, imageFilteringLevel) {
|
|
4967
|
+
retrieve(bookSize, imageCount, imageFilteringLevel, sku) {
|
|
4655
4968
|
return handleAsyncFunction(async () => {
|
|
4656
4969
|
const res = await this.engineAPI.fetcher.call({
|
|
4657
4970
|
// eslint-disable-next-line max-len
|
|
4658
|
-
path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
|
|
4971
|
+
path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}${sku ? `?sku=${sku}` : ""}`
|
|
4659
4972
|
});
|
|
4660
4973
|
return designOptionsServerSchema.parse(res);
|
|
4661
4974
|
});
|
|
@@ -5079,6 +5392,7 @@ var MagicBookClient = class {
|
|
|
5079
5392
|
designOptionsSchema,
|
|
5080
5393
|
designOptionsServerSchema,
|
|
5081
5394
|
embellishmentLevels,
|
|
5395
|
+
formats,
|
|
5082
5396
|
imageAssignmentSchema,
|
|
5083
5397
|
imageDensities,
|
|
5084
5398
|
imageDensityOptionSchema,
|