@magiclabs.ai/magicbook-client 0.7.4-canary → 0.7.5-canary.0
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 +763 -271
- package/index.cjs.map +1 -1
- package/index.d.cts +2427 -549
- package/index.d.ts +2427 -549
- package/index.js +716 -266
- package/index.js.map +1 -1
- package/package.json +11 -11
package/index.cjs
CHANGED
|
@@ -24,45 +24,87 @@ __export(src_exports, {
|
|
|
24
24
|
BookDesignRequest: () => BookDesignRequest,
|
|
25
25
|
DesignRequest: () => DesignRequest,
|
|
26
26
|
DesignRequestOptions: () => DesignRequestOptions,
|
|
27
|
+
EmbellishmentsEndpoints: () => EmbellishmentsEndpoints,
|
|
28
|
+
EngineAPI: () => EngineAPI,
|
|
27
29
|
ImageServer: () => ImageServer,
|
|
28
30
|
Images: () => Images,
|
|
29
31
|
MagicBookClient: () => MagicBookClient,
|
|
32
|
+
StoryboardItemImageFaceSchema: () => StoryboardItemImageFaceSchema,
|
|
33
|
+
StoryboardItemImageSchema: () => StoryboardItemImageSchema,
|
|
34
|
+
StoryboardItemSchema: () => StoryboardItemSchema,
|
|
35
|
+
StylesEndpoints: () => StylesEndpoints,
|
|
30
36
|
assetSchema: () => assetSchema,
|
|
37
|
+
backgroundSchema: () => backgroundSchema,
|
|
31
38
|
bookCreationRequestSchema: () => bookCreationRequestSchema,
|
|
32
39
|
bookDesignRequestSchema: () => bookDesignRequestSchema,
|
|
33
40
|
bookPropsSchema: () => bookPropsSchema,
|
|
34
41
|
bookSizes: () => bookSizes,
|
|
35
|
-
|
|
42
|
+
canSubmitDesignRequest: () => canSubmitDesignRequest,
|
|
36
43
|
cancelledEventDetail: () => cancelledEventDetail,
|
|
37
44
|
canvasSchema: () => canvasSchema,
|
|
45
|
+
colorSchema: () => colorSchema,
|
|
46
|
+
compatibleBackgroundSchema: () => compatibleBackgroundSchema,
|
|
38
47
|
coverTypes: () => coverTypes,
|
|
39
48
|
designOptionsSchema: () => designOptionsSchema,
|
|
40
|
-
|
|
49
|
+
embellishmentAnchorsSchema: () => embellishmentAnchorsSchema,
|
|
50
|
+
embellishmentBackgroundListSchema: () => embellishmentBackgroundListSchema,
|
|
51
|
+
embellishmentBackgroundSchema: () => embellishmentBackgroundSchema,
|
|
52
|
+
embellishmentBandSchema: () => embellishmentBandSchema,
|
|
53
|
+
embellishmentBaseSchema: () => embellishmentBaseSchema,
|
|
54
|
+
embellishmentFrameSchema: () => embellishmentFrameSchema,
|
|
55
|
+
embellishmentGraphicStickerSchema: () => embellishmentGraphicStickerSchema,
|
|
41
56
|
embellishmentLevels: () => embellishmentLevels,
|
|
57
|
+
embellishmentListSchemas: () => embellishmentListSchemas,
|
|
58
|
+
embellishmentOrientations: () => embellishmentOrientations,
|
|
59
|
+
embellishmentPageCornerSchema: () => embellishmentPageCornerSchema,
|
|
60
|
+
embellishmentPhotoCornerAnchorsSchema: () => embellishmentPhotoCornerAnchorsSchema,
|
|
61
|
+
embellishmentPhotoCornerSchema: () => embellishmentPhotoCornerSchema,
|
|
62
|
+
embellishmentPostcardSchema: () => embellishmentPostcardSchema,
|
|
63
|
+
embellishmentSchemas: () => embellishmentSchemas,
|
|
64
|
+
embellishmentStackings: () => embellishmentStackings,
|
|
65
|
+
embellishmentStampSchema: () => embellishmentStampSchema,
|
|
66
|
+
embellishmentStripSchema: () => embellishmentStripSchema,
|
|
67
|
+
embellishmentTPointSchema: () => embellishmentTPointSchema,
|
|
68
|
+
embellishmentTapeSchema: () => embellishmentTapeSchema,
|
|
69
|
+
embellishmentTextStickerSchema: () => embellishmentTextStickerSchema,
|
|
70
|
+
embellishmentThicknesses: () => embellishmentThicknesses,
|
|
71
|
+
embellishmentTypes: () => embellishmentTypes,
|
|
72
|
+
embellishmentUpdateSchemas: () => embellishmentUpdateSchemas,
|
|
73
|
+
fontRoles: () => fontRoles,
|
|
74
|
+
fontSchema: () => fontSchema,
|
|
42
75
|
imageAssignmentSchema: () => imageAssignmentSchema,
|
|
43
76
|
imageDensities: () => imageDensities,
|
|
44
77
|
imageDensityOptionSchema: () => imageDensityOptionSchema,
|
|
45
|
-
imageDensityOptionServerSchema: () => imageDensityOptionServerSchema,
|
|
46
78
|
imageDensityOptionsSchema: () => imageDensityOptionsSchema,
|
|
47
|
-
imageDensityOptionsServerSchema: () => imageDensityOptionsServerSchema,
|
|
48
79
|
imageFilteringLevels: () => imageFilteringLevels,
|
|
49
80
|
imageServerSchema: () => imageServerSchema,
|
|
81
|
+
imageServerToImage: () => imageServerToImage,
|
|
50
82
|
isDesignRequestSubmitted: () => isDesignRequestSubmitted,
|
|
83
|
+
layoutConstraintSchema: () => layoutConstraintSchema,
|
|
84
|
+
layoutConstraintsClasses: () => layoutConstraintsClasses,
|
|
85
|
+
layoutConstraintsSchema: () => layoutConstraintsSchema,
|
|
51
86
|
magicShopBookSchema: () => magicShopBookSchema,
|
|
52
87
|
occasions: () => occasions,
|
|
53
88
|
pageSchema: () => pageSchema,
|
|
54
89
|
pageTypes: () => pageTypes,
|
|
90
|
+
paginatedResponseSchema: () => paginatedResponseSchema,
|
|
55
91
|
photoMetadataSchema: () => photoMetadataSchema,
|
|
56
92
|
photoStripSchema: () => photoStripSchema,
|
|
57
93
|
positionSchema: () => positionSchema,
|
|
58
94
|
propertySchema: () => propertySchema,
|
|
59
95
|
reportingDataSchema: () => reportingDataSchema,
|
|
96
|
+
spreadSchema: () => spreadSchema,
|
|
97
|
+
spreadServerSchema: () => spreadServerSchema,
|
|
60
98
|
states: () => states,
|
|
61
99
|
statesToCloseWS: () => statesToCloseWS,
|
|
62
100
|
statesToReport: () => statesToReport,
|
|
101
|
+
styleBaseSchema: () => styleBaseSchema,
|
|
102
|
+
styleFontSchema: () => styleFontSchema,
|
|
103
|
+
styleSchema: () => styleSchema,
|
|
63
104
|
styles: () => styles,
|
|
64
105
|
textStickerLevels: () => textStickerLevels,
|
|
65
|
-
timeoutEventDetail: () => timeoutEventDetail
|
|
106
|
+
timeoutEventDetail: () => timeoutEventDetail,
|
|
107
|
+
whitespaceSchema: () => whitespaceSchema
|
|
66
108
|
});
|
|
67
109
|
module.exports = __toCommonJS(src_exports);
|
|
68
110
|
|
|
@@ -86,7 +128,7 @@ var states = [
|
|
|
86
128
|
var statesToCloseWS = ["error", "timeout", "ready", "cancelled"];
|
|
87
129
|
var statesToReport = ["error", "timeout"];
|
|
88
130
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
89
|
-
var
|
|
131
|
+
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
90
132
|
var occasions = [
|
|
91
133
|
"baby",
|
|
92
134
|
"birthday",
|
|
@@ -333,7 +375,11 @@ function snakeCaseObjectKeysToCamelCase(snakeCaseObject) {
|
|
|
333
375
|
delete snakeCaseObject[key];
|
|
334
376
|
}
|
|
335
377
|
if (typeof snakeCaseObject[camelCaseKey] === "object") {
|
|
336
|
-
snakeCaseObject[camelCaseKey]
|
|
378
|
+
if (snakeCaseObject[camelCaseKey] === null) {
|
|
379
|
+
snakeCaseObject[camelCaseKey] = null;
|
|
380
|
+
} else {
|
|
381
|
+
snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
|
|
382
|
+
}
|
|
337
383
|
}
|
|
338
384
|
});
|
|
339
385
|
return snakeCaseObject;
|
|
@@ -345,15 +391,6 @@ async function handleAsyncFunction(fn) {
|
|
|
345
391
|
return Promise.reject(error);
|
|
346
392
|
}
|
|
347
393
|
}
|
|
348
|
-
function bindThisToFunctions(instance) {
|
|
349
|
-
for (const name of Object.getOwnPropertyNames(
|
|
350
|
-
Object.getPrototypeOf(instance)
|
|
351
|
-
)) {
|
|
352
|
-
if (typeof instance[name] === "function" && name !== "constructor") {
|
|
353
|
-
instance[name] = instance[name].bind(instance);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
394
|
function cleanJSON(obj) {
|
|
358
395
|
return JSON.parse(JSON.stringify(obj));
|
|
359
396
|
}
|
|
@@ -367,7 +404,7 @@ function getStyleIdBySlug(slug) {
|
|
|
367
404
|
return void 0;
|
|
368
405
|
}
|
|
369
406
|
|
|
370
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
407
|
+
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
371
408
|
var util;
|
|
372
409
|
(function(util2) {
|
|
373
410
|
util2.assertEqual = (val) => val;
|
|
@@ -793,7 +830,7 @@ var ParseStatus = class _ParseStatus {
|
|
|
793
830
|
status.dirty();
|
|
794
831
|
if (value.status === "dirty")
|
|
795
832
|
status.dirty();
|
|
796
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
833
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
797
834
|
finalObject[key.value] = value.value;
|
|
798
835
|
}
|
|
799
836
|
}
|
|
@@ -896,6 +933,7 @@ var ZodType = class {
|
|
|
896
933
|
this.catch = this.catch.bind(this);
|
|
897
934
|
this.describe = this.describe.bind(this);
|
|
898
935
|
this.pipe = this.pipe.bind(this);
|
|
936
|
+
this.readonly = this.readonly.bind(this);
|
|
899
937
|
this.isNullable = this.isNullable.bind(this);
|
|
900
938
|
this.isOptional = this.isOptional.bind(this);
|
|
901
939
|
}
|
|
@@ -1103,6 +1141,9 @@ var ZodType = class {
|
|
|
1103
1141
|
pipe(target) {
|
|
1104
1142
|
return ZodPipeline.create(this, target);
|
|
1105
1143
|
}
|
|
1144
|
+
readonly() {
|
|
1145
|
+
return ZodReadonly.create(this);
|
|
1146
|
+
}
|
|
1106
1147
|
isOptional() {
|
|
1107
1148
|
return this.safeParse(void 0).success;
|
|
1108
1149
|
}
|
|
@@ -1112,10 +1153,11 @@ var ZodType = class {
|
|
|
1112
1153
|
};
|
|
1113
1154
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1114
1155
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
1115
|
-
var ulidRegex =
|
|
1116
|
-
var uuidRegex = /^
|
|
1117
|
-
var emailRegex = /^(
|
|
1118
|
-
var
|
|
1156
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1157
|
+
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;
|
|
1158
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1159
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1160
|
+
var emojiRegex;
|
|
1119
1161
|
var ipv4Regex = /^(((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}))$/;
|
|
1120
1162
|
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})))$/;
|
|
1121
1163
|
var datetimeRegex = (args) => {
|
|
@@ -1149,27 +1191,6 @@ function isValidIP(ip, version) {
|
|
|
1149
1191
|
return false;
|
|
1150
1192
|
}
|
|
1151
1193
|
var ZodString = class _ZodString extends ZodType {
|
|
1152
|
-
constructor() {
|
|
1153
|
-
super(...arguments);
|
|
1154
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
1155
|
-
validation,
|
|
1156
|
-
code: ZodIssueCode.invalid_string,
|
|
1157
|
-
...errorUtil.errToObj(message)
|
|
1158
|
-
});
|
|
1159
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
1160
|
-
this.trim = () => new _ZodString({
|
|
1161
|
-
...this._def,
|
|
1162
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
1163
|
-
});
|
|
1164
|
-
this.toLowerCase = () => new _ZodString({
|
|
1165
|
-
...this._def,
|
|
1166
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1167
|
-
});
|
|
1168
|
-
this.toUpperCase = () => new _ZodString({
|
|
1169
|
-
...this._def,
|
|
1170
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
1194
|
_parse(input) {
|
|
1174
1195
|
if (this._def.coerce) {
|
|
1175
1196
|
input.data = String(input.data);
|
|
@@ -1254,6 +1275,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1254
1275
|
status.dirty();
|
|
1255
1276
|
}
|
|
1256
1277
|
} else if (check.kind === "emoji") {
|
|
1278
|
+
if (!emojiRegex) {
|
|
1279
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1280
|
+
}
|
|
1257
1281
|
if (!emojiRegex.test(input.data)) {
|
|
1258
1282
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1259
1283
|
addIssueToContext(ctx, {
|
|
@@ -1390,6 +1414,13 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1390
1414
|
}
|
|
1391
1415
|
return { status: status.value, value: input.data };
|
|
1392
1416
|
}
|
|
1417
|
+
_regex(regex, validation, message) {
|
|
1418
|
+
return this.refinement((data) => regex.test(data), {
|
|
1419
|
+
validation,
|
|
1420
|
+
code: ZodIssueCode.invalid_string,
|
|
1421
|
+
...errorUtil.errToObj(message)
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1393
1424
|
_addCheck(check) {
|
|
1394
1425
|
return new _ZodString({
|
|
1395
1426
|
...this._def,
|
|
@@ -1487,6 +1518,31 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1487
1518
|
...errorUtil.errToObj(message)
|
|
1488
1519
|
});
|
|
1489
1520
|
}
|
|
1521
|
+
/**
|
|
1522
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1523
|
+
* @see {@link ZodString.min}
|
|
1524
|
+
*/
|
|
1525
|
+
nonempty(message) {
|
|
1526
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1527
|
+
}
|
|
1528
|
+
trim() {
|
|
1529
|
+
return new _ZodString({
|
|
1530
|
+
...this._def,
|
|
1531
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
toLowerCase() {
|
|
1535
|
+
return new _ZodString({
|
|
1536
|
+
...this._def,
|
|
1537
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
toUpperCase() {
|
|
1541
|
+
return new _ZodString({
|
|
1542
|
+
...this._def,
|
|
1543
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1490
1546
|
get isDatetime() {
|
|
1491
1547
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1492
1548
|
}
|
|
@@ -3078,6 +3134,12 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3078
3134
|
}
|
|
3079
3135
|
};
|
|
3080
3136
|
var ZodMap = class extends ZodType {
|
|
3137
|
+
get keySchema() {
|
|
3138
|
+
return this._def.keyType;
|
|
3139
|
+
}
|
|
3140
|
+
get valueSchema() {
|
|
3141
|
+
return this._def.valueType;
|
|
3142
|
+
}
|
|
3081
3143
|
_parse(input) {
|
|
3082
3144
|
const { status, ctx } = this._processInputParams(input);
|
|
3083
3145
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -3272,27 +3334,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3272
3334
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
3273
3335
|
const fn = ctx.data;
|
|
3274
3336
|
if (this._def.returns instanceof ZodPromise) {
|
|
3275
|
-
|
|
3337
|
+
const me = this;
|
|
3338
|
+
return OK(async function(...args) {
|
|
3276
3339
|
const error = new ZodError([]);
|
|
3277
|
-
const parsedArgs = await
|
|
3340
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
3278
3341
|
error.addIssue(makeArgsIssue(args, e));
|
|
3279
3342
|
throw error;
|
|
3280
3343
|
});
|
|
3281
|
-
const result = await fn
|
|
3282
|
-
const parsedReturns = await
|
|
3344
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3345
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
3283
3346
|
error.addIssue(makeReturnsIssue(result, e));
|
|
3284
3347
|
throw error;
|
|
3285
3348
|
});
|
|
3286
3349
|
return parsedReturns;
|
|
3287
3350
|
});
|
|
3288
3351
|
} else {
|
|
3289
|
-
|
|
3290
|
-
|
|
3352
|
+
const me = this;
|
|
3353
|
+
return OK(function(...args) {
|
|
3354
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
3291
3355
|
if (!parsedArgs.success) {
|
|
3292
3356
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3293
3357
|
}
|
|
3294
|
-
const result = fn
|
|
3295
|
-
const parsedReturns =
|
|
3358
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3359
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
3296
3360
|
if (!parsedReturns.success) {
|
|
3297
3361
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3298
3362
|
}
|
|
@@ -3514,8 +3578,28 @@ var ZodEffects = class extends ZodType {
|
|
|
3514
3578
|
_parse(input) {
|
|
3515
3579
|
const { status, ctx } = this._processInputParams(input);
|
|
3516
3580
|
const effect = this._def.effect || null;
|
|
3581
|
+
const checkCtx = {
|
|
3582
|
+
addIssue: (arg) => {
|
|
3583
|
+
addIssueToContext(ctx, arg);
|
|
3584
|
+
if (arg.fatal) {
|
|
3585
|
+
status.abort();
|
|
3586
|
+
} else {
|
|
3587
|
+
status.dirty();
|
|
3588
|
+
}
|
|
3589
|
+
},
|
|
3590
|
+
get path() {
|
|
3591
|
+
return ctx.path;
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3517
3595
|
if (effect.type === "preprocess") {
|
|
3518
|
-
const processed = effect.transform(ctx.data);
|
|
3596
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3597
|
+
if (ctx.common.issues.length) {
|
|
3598
|
+
return {
|
|
3599
|
+
status: "dirty",
|
|
3600
|
+
value: ctx.data
|
|
3601
|
+
};
|
|
3602
|
+
}
|
|
3519
3603
|
if (ctx.common.async) {
|
|
3520
3604
|
return Promise.resolve(processed).then((processed2) => {
|
|
3521
3605
|
return this._def.schema._parseAsync({
|
|
@@ -3532,20 +3616,6 @@ var ZodEffects = class extends ZodType {
|
|
|
3532
3616
|
});
|
|
3533
3617
|
}
|
|
3534
3618
|
}
|
|
3535
|
-
const checkCtx = {
|
|
3536
|
-
addIssue: (arg) => {
|
|
3537
|
-
addIssueToContext(ctx, arg);
|
|
3538
|
-
if (arg.fatal) {
|
|
3539
|
-
status.abort();
|
|
3540
|
-
} else {
|
|
3541
|
-
status.dirty();
|
|
3542
|
-
}
|
|
3543
|
-
},
|
|
3544
|
-
get path() {
|
|
3545
|
-
return ctx.path;
|
|
3546
|
-
}
|
|
3547
|
-
};
|
|
3548
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3549
3619
|
if (effect.type === "refinement") {
|
|
3550
3620
|
const executeRefinement = (acc) => {
|
|
3551
3621
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -3829,6 +3899,22 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3829
3899
|
});
|
|
3830
3900
|
}
|
|
3831
3901
|
};
|
|
3902
|
+
var ZodReadonly = class extends ZodType {
|
|
3903
|
+
_parse(input) {
|
|
3904
|
+
const result = this._def.innerType._parse(input);
|
|
3905
|
+
if (isValid(result)) {
|
|
3906
|
+
result.value = Object.freeze(result.value);
|
|
3907
|
+
}
|
|
3908
|
+
return result;
|
|
3909
|
+
}
|
|
3910
|
+
};
|
|
3911
|
+
ZodReadonly.create = (type, params) => {
|
|
3912
|
+
return new ZodReadonly({
|
|
3913
|
+
innerType: type,
|
|
3914
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
3915
|
+
...processCreateParams(params)
|
|
3916
|
+
});
|
|
3917
|
+
};
|
|
3832
3918
|
var custom = (check, params = {}, fatal) => {
|
|
3833
3919
|
if (check)
|
|
3834
3920
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -3882,6 +3968,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3882
3968
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
3883
3969
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
3884
3970
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3971
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3885
3972
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3886
3973
|
var instanceOfType = (cls, params = {
|
|
3887
3974
|
message: `Input not instance of ${cls.name}`
|
|
@@ -3996,6 +4083,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3996
4083
|
BRAND,
|
|
3997
4084
|
ZodBranded,
|
|
3998
4085
|
ZodPipeline,
|
|
4086
|
+
ZodReadonly,
|
|
3999
4087
|
custom,
|
|
4000
4088
|
Schema: ZodType,
|
|
4001
4089
|
ZodSchema: ZodType,
|
|
@@ -4049,7 +4137,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4049
4137
|
ZodError
|
|
4050
4138
|
});
|
|
4051
4139
|
|
|
4052
|
-
// ../../core/
|
|
4140
|
+
// ../../core/types/book.ts
|
|
4053
4141
|
var BookDesignRequest = class {
|
|
4054
4142
|
occasion;
|
|
4055
4143
|
style;
|
|
@@ -4091,7 +4179,7 @@ var bookPropsSchema = z.object({
|
|
|
4091
4179
|
state: z.enum(states).optional(),
|
|
4092
4180
|
guid: z.string().optional(),
|
|
4093
4181
|
cancelled_at: z.string().optional(),
|
|
4094
|
-
mb_client_timeout: z.
|
|
4182
|
+
mb_client_timeout: z.string().optional(),
|
|
4095
4183
|
user_id: z.string().optional(),
|
|
4096
4184
|
revision: z.number().optional()
|
|
4097
4185
|
});
|
|
@@ -4114,7 +4202,7 @@ var Book = class {
|
|
|
4114
4202
|
this.state = props.state;
|
|
4115
4203
|
this.guid = props.guid;
|
|
4116
4204
|
this.cancelled_at = props.cancelled_at;
|
|
4117
|
-
this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
|
|
4205
|
+
this.timeout = props.mb_client_timeout ? parseInt(props.mb_client_timeout) * 1e3 : void 0;
|
|
4118
4206
|
this.user_id = props.user_id;
|
|
4119
4207
|
this.revision = props.revision;
|
|
4120
4208
|
}
|
|
@@ -4128,12 +4216,12 @@ var Book = class {
|
|
|
4128
4216
|
toBookProps() {
|
|
4129
4217
|
return {
|
|
4130
4218
|
...this,
|
|
4131
|
-
mb_client_timeout: this.timeout ? this.timeout / 1e3 : void 0
|
|
4219
|
+
mb_client_timeout: this.timeout ? (this.timeout / 1e3).toString() : void 0
|
|
4132
4220
|
};
|
|
4133
4221
|
}
|
|
4134
4222
|
};
|
|
4135
4223
|
|
|
4136
|
-
// ../../core/
|
|
4224
|
+
// ../../core/types/design-request/image.ts
|
|
4137
4225
|
var Images = class {
|
|
4138
4226
|
// eslint-disable-next-line no-unused-vars
|
|
4139
4227
|
constructor(client, parentId, designRequestState) {
|
|
@@ -4148,12 +4236,15 @@ var Images = class {
|
|
|
4148
4236
|
length;
|
|
4149
4237
|
designRequestState;
|
|
4150
4238
|
async add(image) {
|
|
4151
|
-
if (!
|
|
4239
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4152
4240
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4153
4241
|
} else {
|
|
4154
4242
|
this.images.push(image);
|
|
4155
4243
|
this.length = this.images.length;
|
|
4156
|
-
await this.client.engineAPI.images.addToBook(
|
|
4244
|
+
await this.client.engineAPI.images.addToBook({
|
|
4245
|
+
bookId: this.parentId,
|
|
4246
|
+
image: new ImageServer(image)
|
|
4247
|
+
});
|
|
4157
4248
|
return new Promise((resolve) => {
|
|
4158
4249
|
resolve(this.length);
|
|
4159
4250
|
});
|
|
@@ -4194,8 +4285,21 @@ var ImageServer = class {
|
|
|
4194
4285
|
this.filename = image.filename;
|
|
4195
4286
|
}
|
|
4196
4287
|
};
|
|
4288
|
+
function imageServerToImage(imageServer) {
|
|
4289
|
+
return {
|
|
4290
|
+
handle: imageServer.handle,
|
|
4291
|
+
url: imageServer.url,
|
|
4292
|
+
width: imageServer.width,
|
|
4293
|
+
height: imageServer.height,
|
|
4294
|
+
rotation: imageServer.orientation,
|
|
4295
|
+
captureTime: imageServer.taken_at,
|
|
4296
|
+
cameraMake: imageServer.camera_make,
|
|
4297
|
+
cameraModel: imageServer.camera,
|
|
4298
|
+
filename: imageServer.filename
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4197
4301
|
|
|
4198
|
-
// ../../core/
|
|
4302
|
+
// ../../core/types/design-request/design-options.ts
|
|
4199
4303
|
var imageDensityOptionSchema = z.object({
|
|
4200
4304
|
maxPageCount: z.number(),
|
|
4201
4305
|
minPageCount: z.number(),
|
|
@@ -4211,23 +4315,8 @@ var imageDensityOptionsSchema = z.object({
|
|
|
4211
4315
|
var designOptionsSchema = z.object({
|
|
4212
4316
|
densities: imageDensityOptionsSchema
|
|
4213
4317
|
});
|
|
4214
|
-
var imageDensityOptionServerSchema = z.object({
|
|
4215
|
-
max_page_count: z.number(),
|
|
4216
|
-
min_page_count: z.number(),
|
|
4217
|
-
max_image_count: z.number(),
|
|
4218
|
-
avg_image_count: z.number(),
|
|
4219
|
-
min_image_count: z.number()
|
|
4220
|
-
});
|
|
4221
|
-
var imageDensityOptionsServerSchema = z.object({
|
|
4222
|
-
high: imageDensityOptionServerSchema,
|
|
4223
|
-
medium: imageDensityOptionServerSchema,
|
|
4224
|
-
low: imageDensityOptionServerSchema
|
|
4225
|
-
});
|
|
4226
|
-
var designOptionsServerSchema = z.object({
|
|
4227
|
-
densities: imageDensityOptionsServerSchema
|
|
4228
|
-
});
|
|
4229
4318
|
|
|
4230
|
-
// ../../core/
|
|
4319
|
+
// ../../core/types/design-request/index.ts
|
|
4231
4320
|
var DesignRequestOptions = {
|
|
4232
4321
|
occasion: occasions,
|
|
4233
4322
|
style: Object.keys(styles).map((key) => parseInt(key)),
|
|
@@ -4282,27 +4371,29 @@ var DesignRequest = class {
|
|
|
4282
4371
|
}
|
|
4283
4372
|
}
|
|
4284
4373
|
async getOptions(imageCount) {
|
|
4285
|
-
const options = designOptionsSchema.parse(
|
|
4286
|
-
await this.client.engineAPI.designOptions.retrieve(
|
|
4287
|
-
this.bookSize,
|
|
4288
|
-
imageCount || this.images.length,
|
|
4289
|
-
this.imageFilteringLevel
|
|
4290
|
-
)
|
|
4291
|
-
)
|
|
4374
|
+
const options = designOptionsSchema.parse(
|
|
4375
|
+
await this.client.engineAPI.designOptions.retrieve({
|
|
4376
|
+
bookSize: this.bookSize,
|
|
4377
|
+
imageCount: imageCount || this.images.length,
|
|
4378
|
+
imageFilteringLevel: this.imageFilteringLevel
|
|
4379
|
+
})
|
|
4380
|
+
);
|
|
4292
4381
|
return options;
|
|
4293
4382
|
}
|
|
4294
4383
|
async submit(submitDesignRequestProps) {
|
|
4295
|
-
if (!
|
|
4384
|
+
if (!canSubmitDesignRequest(this.state)) {
|
|
4296
4385
|
throw new Error("You need to wait for the current design request to be ready before submitting a new one");
|
|
4297
4386
|
} else {
|
|
4298
4387
|
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
4299
4388
|
this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
|
|
4300
|
-
await this.client.engineAPI.books.update(
|
|
4389
|
+
await this.client.engineAPI.books.update({
|
|
4390
|
+
bookId: this.parentId,
|
|
4391
|
+
payload: this.toBook()
|
|
4392
|
+
});
|
|
4301
4393
|
this.updateDesignRequest(
|
|
4302
|
-
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4394
|
+
(await this.client.engineAPI.books.design({ bookId: this.parentId })).toDesignRequestProps()
|
|
4303
4395
|
);
|
|
4304
4396
|
this.getProgress();
|
|
4305
|
-
this.updateDesignRequest({ state: states[1] });
|
|
4306
4397
|
return this;
|
|
4307
4398
|
}
|
|
4308
4399
|
}
|
|
@@ -4312,7 +4403,10 @@ var DesignRequest = class {
|
|
|
4312
4403
|
} else {
|
|
4313
4404
|
this.guid = guid;
|
|
4314
4405
|
this.updateDesignRequest(
|
|
4315
|
-
(await this.client.engineAPI.books.update(
|
|
4406
|
+
(await this.client.engineAPI.books.update({
|
|
4407
|
+
bookId: this.parentId,
|
|
4408
|
+
payload: this.toBook()
|
|
4409
|
+
})).toDesignRequestProps()
|
|
4316
4410
|
);
|
|
4317
4411
|
return this.guid;
|
|
4318
4412
|
}
|
|
@@ -4326,7 +4420,9 @@ var DesignRequest = class {
|
|
|
4326
4420
|
throw new Error("Design request not submitted");
|
|
4327
4421
|
} else {
|
|
4328
4422
|
this.updateDesignRequest({
|
|
4329
|
-
...(await this.client.engineAPI.books.cancel(
|
|
4423
|
+
...(await this.client.engineAPI.books.cancel({
|
|
4424
|
+
bookId: this.parentId
|
|
4425
|
+
})).toDesignRequestProps(),
|
|
4330
4426
|
state: "cancelled"
|
|
4331
4427
|
});
|
|
4332
4428
|
await this.eventHandler(cancelledEventDetail);
|
|
@@ -4335,22 +4431,31 @@ var DesignRequest = class {
|
|
|
4335
4431
|
}
|
|
4336
4432
|
async getJSON() {
|
|
4337
4433
|
if (this.state === "ready") {
|
|
4338
|
-
return await this.client.engineAPI.books.retrieveGalleon(
|
|
4434
|
+
return await this.client.engineAPI.books.retrieveGalleon({
|
|
4435
|
+
bookId: this.parentId
|
|
4436
|
+
});
|
|
4339
4437
|
} else {
|
|
4340
4438
|
throw new Error("Design request not ready");
|
|
4341
4439
|
}
|
|
4342
4440
|
}
|
|
4343
4441
|
async logEvent(name, data) {
|
|
4344
|
-
return await this.client.engineAPI.events.createBookEvent(
|
|
4442
|
+
return await this.client.engineAPI.events.createBookEvent({
|
|
4443
|
+
bookId: this.parentId,
|
|
4444
|
+
name,
|
|
4445
|
+
data
|
|
4446
|
+
});
|
|
4345
4447
|
}
|
|
4346
4448
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4347
4449
|
const customEvent = new CustomEvent(type, { detail });
|
|
4348
4450
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4349
4451
|
this.webSocket?.close();
|
|
4350
4452
|
if (statesToReport.includes(detail.slug)) {
|
|
4351
|
-
await this.client.engineAPI.books.report(
|
|
4352
|
-
|
|
4353
|
-
|
|
4453
|
+
await this.client.engineAPI.books.report({
|
|
4454
|
+
bookId: this.parentId,
|
|
4455
|
+
report: {
|
|
4456
|
+
error: detail.slug === "error" ? "design" : "timeout",
|
|
4457
|
+
step: this.state
|
|
4458
|
+
}
|
|
4354
4459
|
});
|
|
4355
4460
|
}
|
|
4356
4461
|
}
|
|
@@ -4371,7 +4476,7 @@ var DesignRequest = class {
|
|
|
4371
4476
|
let timeout;
|
|
4372
4477
|
this.webSocket.onmessage = async (event) => {
|
|
4373
4478
|
const detail = JSON.parse(event.data);
|
|
4374
|
-
if (this.state !== detail.slug) {
|
|
4479
|
+
if (this.state !== detail.slug || detail.slug === "submitted") {
|
|
4375
4480
|
timeout && clearTimeout(timeout);
|
|
4376
4481
|
timeout = this.timeoutHandler();
|
|
4377
4482
|
await this.eventHandler(detail);
|
|
@@ -4403,7 +4508,7 @@ var DesignRequest = class {
|
|
|
4403
4508
|
}
|
|
4404
4509
|
};
|
|
4405
4510
|
|
|
4406
|
-
// ../../core/
|
|
4511
|
+
// ../../core/types/galleon.ts
|
|
4407
4512
|
var imageAssignmentSchema = z.object({
|
|
4408
4513
|
photoRefId: z.string(),
|
|
4409
4514
|
finalCrop: z.array(z.number())
|
|
@@ -4482,128 +4587,357 @@ var bookCreationRequestSchema = z.object({
|
|
|
4482
4587
|
reportingData: reportingDataSchema
|
|
4483
4588
|
});
|
|
4484
4589
|
|
|
4485
|
-
// ../../core/
|
|
4590
|
+
// ../../core/types/engine-api/endpoints/books.ts
|
|
4486
4591
|
var BooksEndpoints = class {
|
|
4487
4592
|
// eslint-disable-next-line no-unused-vars
|
|
4488
4593
|
constructor(engineAPI) {
|
|
4489
4594
|
this.engineAPI = engineAPI;
|
|
4490
|
-
bindThisToFunctions(this);
|
|
4491
4595
|
}
|
|
4492
|
-
create(book) {
|
|
4596
|
+
create({ book, qs }) {
|
|
4493
4597
|
return handleAsyncFunction(async () => {
|
|
4494
4598
|
const res = await this.engineAPI.fetcher.call({
|
|
4495
4599
|
path: "/v1/books",
|
|
4496
4600
|
options: {
|
|
4497
4601
|
method: "POST",
|
|
4498
4602
|
body: cleanJSON(book)
|
|
4499
|
-
}
|
|
4603
|
+
},
|
|
4604
|
+
qs
|
|
4500
4605
|
});
|
|
4501
|
-
bookPropsSchema.safeParse(res);
|
|
4502
4606
|
return new Book(res);
|
|
4503
4607
|
});
|
|
4504
4608
|
}
|
|
4505
|
-
retrieve(bookId) {
|
|
4609
|
+
retrieve({ bookId, qs }) {
|
|
4506
4610
|
return handleAsyncFunction(async () => {
|
|
4507
|
-
const res = await this.engineAPI.fetcher.call({
|
|
4508
|
-
|
|
4509
|
-
|
|
4611
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4612
|
+
path: `/v1/books/${bookId}`,
|
|
4613
|
+
qs
|
|
4614
|
+
});
|
|
4615
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4616
|
+
return new Book(bookProps);
|
|
4510
4617
|
});
|
|
4511
4618
|
}
|
|
4512
|
-
update(bookId,
|
|
4619
|
+
update({ bookId, payload, qs }) {
|
|
4513
4620
|
return handleAsyncFunction(async () => {
|
|
4514
4621
|
const res = await this.engineAPI.fetcher.call({
|
|
4515
4622
|
path: `/v1/books/${bookId}`,
|
|
4516
4623
|
options: {
|
|
4517
4624
|
method: "PUT",
|
|
4518
|
-
body: cleanJSON(
|
|
4519
|
-
}
|
|
4625
|
+
body: cleanJSON(payload)
|
|
4626
|
+
},
|
|
4627
|
+
qs
|
|
4628
|
+
});
|
|
4629
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4630
|
+
return new Book(bookProps);
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4633
|
+
delete({ bookId, qs }) {
|
|
4634
|
+
return handleAsyncFunction(async () => {
|
|
4635
|
+
await this.engineAPI.fetcher.call({
|
|
4636
|
+
path: `/v1/books/${bookId}`,
|
|
4637
|
+
options: { method: "DELETE" },
|
|
4638
|
+
qs
|
|
4520
4639
|
});
|
|
4521
|
-
bookPropsSchema.safeParse(res);
|
|
4522
|
-
return new Book(res);
|
|
4523
4640
|
});
|
|
4524
4641
|
}
|
|
4525
|
-
design(bookId) {
|
|
4642
|
+
design({ bookId, qs }) {
|
|
4526
4643
|
return handleAsyncFunction(async () => {
|
|
4527
4644
|
const res = await this.engineAPI.fetcher.call({
|
|
4528
4645
|
path: `/v1/books/${bookId}/design`,
|
|
4529
|
-
options: { method: "POST" }
|
|
4646
|
+
options: { method: "POST" },
|
|
4647
|
+
qs
|
|
4530
4648
|
});
|
|
4531
|
-
bookPropsSchema.
|
|
4532
|
-
return new Book(
|
|
4649
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4650
|
+
return new Book(bookProps);
|
|
4533
4651
|
});
|
|
4534
4652
|
}
|
|
4535
|
-
cancel(bookId) {
|
|
4653
|
+
cancel({ bookId, qs }) {
|
|
4536
4654
|
return handleAsyncFunction(async () => {
|
|
4537
4655
|
const res = await this.engineAPI.fetcher.call({
|
|
4538
4656
|
path: `/v1/books/${bookId}/cancel`,
|
|
4539
|
-
options: { method: "POST" }
|
|
4657
|
+
options: { method: "POST" },
|
|
4658
|
+
qs
|
|
4540
4659
|
});
|
|
4541
|
-
bookPropsSchema.
|
|
4542
|
-
return new Book(
|
|
4660
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4661
|
+
return new Book(bookProps);
|
|
4662
|
+
});
|
|
4663
|
+
}
|
|
4664
|
+
retrieveGalleon({ bookId, qs }) {
|
|
4665
|
+
return handleAsyncFunction(async () => {
|
|
4666
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4667
|
+
path: `/v1/books/${bookId}/format/galleon`,
|
|
4668
|
+
qs
|
|
4669
|
+
});
|
|
4670
|
+
return bookCreationRequestSchema.parse(res);
|
|
4543
4671
|
});
|
|
4544
4672
|
}
|
|
4545
|
-
report(bookId, report) {
|
|
4673
|
+
report({ bookId, report, qs }) {
|
|
4546
4674
|
return handleAsyncFunction(async () => {
|
|
4547
4675
|
await this.engineAPI.fetcher.call({
|
|
4548
4676
|
path: `/v1/books/${bookId}/report`,
|
|
4549
4677
|
options: {
|
|
4550
4678
|
method: "POST",
|
|
4551
4679
|
body: cleanJSON(report)
|
|
4552
|
-
}
|
|
4680
|
+
},
|
|
4681
|
+
qs
|
|
4553
4682
|
});
|
|
4554
4683
|
});
|
|
4555
4684
|
}
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4685
|
+
};
|
|
4686
|
+
|
|
4687
|
+
// ../../core/types/engine-api/endpoints/design-options.ts
|
|
4688
|
+
var DesignOptionsEndpoints = class {
|
|
4689
|
+
// eslint-disable-next-line no-unused-vars
|
|
4690
|
+
constructor(engineAPI) {
|
|
4691
|
+
this.engineAPI = engineAPI;
|
|
4563
4692
|
}
|
|
4564
|
-
|
|
4693
|
+
retrieve(props) {
|
|
4565
4694
|
return handleAsyncFunction(async () => {
|
|
4566
4695
|
const res = await this.engineAPI.fetcher.call({
|
|
4567
|
-
|
|
4696
|
+
// eslint-disable-next-line max-len
|
|
4697
|
+
path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
|
|
4698
|
+
qs: props.qs
|
|
4568
4699
|
});
|
|
4569
|
-
return
|
|
4700
|
+
return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4570
4701
|
});
|
|
4571
4702
|
}
|
|
4572
4703
|
};
|
|
4573
4704
|
|
|
4574
|
-
// ../../core/
|
|
4575
|
-
var
|
|
4705
|
+
// ../../core/types/embellishment.ts
|
|
4706
|
+
var embellishmentTypes = [
|
|
4707
|
+
"background",
|
|
4708
|
+
"band",
|
|
4709
|
+
"strip",
|
|
4710
|
+
"page-corner",
|
|
4711
|
+
"photo-corner",
|
|
4712
|
+
"frame",
|
|
4713
|
+
"t-point",
|
|
4714
|
+
"luggage-tag",
|
|
4715
|
+
"stamp",
|
|
4716
|
+
"tape",
|
|
4717
|
+
"postcard",
|
|
4718
|
+
"top-sticker",
|
|
4719
|
+
"bottom-sticker",
|
|
4720
|
+
"graphic-sticker",
|
|
4721
|
+
"text-sticker"
|
|
4722
|
+
];
|
|
4723
|
+
var embellishmentOrientations = [
|
|
4724
|
+
"top",
|
|
4725
|
+
"bottom",
|
|
4726
|
+
"left",
|
|
4727
|
+
"right",
|
|
4728
|
+
"top-left",
|
|
4729
|
+
"top-right",
|
|
4730
|
+
"bottom-right",
|
|
4731
|
+
"bottom-left"
|
|
4732
|
+
];
|
|
4733
|
+
var embellishmentThicknesses = ["thin", "thick", "normal"];
|
|
4734
|
+
var embellishmentStackings = ["front", "back"];
|
|
4735
|
+
var embellishmentAnchorsSchema = z.object({
|
|
4736
|
+
x0: z.number(),
|
|
4737
|
+
x1: z.number(),
|
|
4738
|
+
y0: z.number(),
|
|
4739
|
+
y1: z.number()
|
|
4740
|
+
});
|
|
4741
|
+
var embellishmentPhotoCornerAnchorsSchema = z.object({
|
|
4742
|
+
x0: z.number(),
|
|
4743
|
+
y0: z.number()
|
|
4744
|
+
});
|
|
4745
|
+
var embellishmentBaseSchema = z.object({
|
|
4746
|
+
id: z.string(),
|
|
4747
|
+
active: z.boolean(),
|
|
4748
|
+
url: z.string(),
|
|
4749
|
+
name: z.string(),
|
|
4750
|
+
pattern: z.string(),
|
|
4751
|
+
primaryColor: z.string(),
|
|
4752
|
+
margin: z.number(),
|
|
4753
|
+
width: z.number(),
|
|
4754
|
+
height: z.number(),
|
|
4755
|
+
style: z.string()
|
|
4756
|
+
});
|
|
4757
|
+
var embellishmentTextStickerSchema = embellishmentBaseSchema.extend({
|
|
4758
|
+
type: z.literal("text-sticker"),
|
|
4759
|
+
text: z.string(),
|
|
4760
|
+
isSpecific: z.boolean(),
|
|
4761
|
+
minSurface: z.number(),
|
|
4762
|
+
maxSurface: z.number()
|
|
4763
|
+
});
|
|
4764
|
+
var embellishmentTPointSchema = embellishmentBaseSchema.extend({
|
|
4765
|
+
type: z.literal("t-point"),
|
|
4766
|
+
minSurface: z.number(),
|
|
4767
|
+
maxSurface: z.number()
|
|
4768
|
+
});
|
|
4769
|
+
var embellishmentGraphicStickerSchema = embellishmentBaseSchema.extend({
|
|
4770
|
+
type: z.literal("graphic-sticker"),
|
|
4771
|
+
minSurface: z.number(),
|
|
4772
|
+
maxSurface: z.number(),
|
|
4773
|
+
hFlippable: z.boolean(),
|
|
4774
|
+
vFlippable: z.boolean()
|
|
4775
|
+
});
|
|
4776
|
+
var embellishmentStampSchema = embellishmentBaseSchema.extend({
|
|
4777
|
+
type: z.literal("stamp"),
|
|
4778
|
+
minSurface: z.number(),
|
|
4779
|
+
maxSurface: z.number(),
|
|
4780
|
+
hFlippable: z.boolean(),
|
|
4781
|
+
vFlippable: z.boolean()
|
|
4782
|
+
});
|
|
4783
|
+
var embellishmentTapeSchema = embellishmentBaseSchema.extend({
|
|
4784
|
+
type: z.literal("tape"),
|
|
4785
|
+
minSurface: z.number(),
|
|
4786
|
+
maxSurface: z.number(),
|
|
4787
|
+
hFlippable: z.boolean(),
|
|
4788
|
+
vFlippable: z.boolean()
|
|
4789
|
+
});
|
|
4790
|
+
var embellishmentPostcardSchema = embellishmentBaseSchema.extend({
|
|
4791
|
+
type: z.literal("postcard"),
|
|
4792
|
+
minSurface: z.number(),
|
|
4793
|
+
maxSurface: z.number(),
|
|
4794
|
+
hFlippable: z.boolean(),
|
|
4795
|
+
vFlippable: z.boolean()
|
|
4796
|
+
});
|
|
4797
|
+
var embellishmentBandSchema = embellishmentBaseSchema.extend({
|
|
4798
|
+
type: z.literal("band"),
|
|
4799
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4800
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4801
|
+
thickness: z.enum(embellishmentThicknesses)
|
|
4802
|
+
});
|
|
4803
|
+
var embellishmentStripSchema = embellishmentBaseSchema.extend({
|
|
4804
|
+
type: z.literal("strip"),
|
|
4805
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4806
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4807
|
+
thickness: z.enum(embellishmentThicknesses)
|
|
4808
|
+
});
|
|
4809
|
+
var embellishmentPhotoCornerSchema = embellishmentBaseSchema.extend({
|
|
4810
|
+
type: z.literal("photo-corner"),
|
|
4811
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4812
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4813
|
+
anchors: embellishmentPhotoCornerAnchorsSchema,
|
|
4814
|
+
stacking: z.enum(embellishmentStackings),
|
|
4815
|
+
scale: z.number()
|
|
4816
|
+
});
|
|
4817
|
+
var embellishmentPageCornerSchema = embellishmentBaseSchema.extend({
|
|
4818
|
+
type: z.literal("page-corner"),
|
|
4819
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4820
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4821
|
+
scale: z.number()
|
|
4822
|
+
});
|
|
4823
|
+
var embellishmentFrameSchema = embellishmentBaseSchema.extend({
|
|
4824
|
+
type: z.literal("frame"),
|
|
4825
|
+
rotatable: z.boolean(),
|
|
4826
|
+
anchors: embellishmentAnchorsSchema,
|
|
4827
|
+
stacking: z.enum(embellishmentStackings)
|
|
4828
|
+
});
|
|
4829
|
+
var embellishmentBackgroundListSchema = embellishmentBaseSchema.extend({
|
|
4830
|
+
type: z.literal("background"),
|
|
4831
|
+
rotatable: z.boolean()
|
|
4832
|
+
});
|
|
4833
|
+
var embellishmentBackgroundSchema = embellishmentBackgroundListSchema.extend({
|
|
4834
|
+
colors: z.record(z.unknown()),
|
|
4835
|
+
backgrounds: z.record(z.unknown())
|
|
4836
|
+
});
|
|
4837
|
+
var embellishmentSchemasArray = [
|
|
4838
|
+
embellishmentBackgroundSchema,
|
|
4839
|
+
embellishmentFrameSchema,
|
|
4840
|
+
embellishmentTextStickerSchema,
|
|
4841
|
+
embellishmentBandSchema,
|
|
4842
|
+
embellishmentStripSchema,
|
|
4843
|
+
embellishmentPageCornerSchema,
|
|
4844
|
+
embellishmentPhotoCornerSchema,
|
|
4845
|
+
embellishmentTPointSchema,
|
|
4846
|
+
embellishmentStampSchema,
|
|
4847
|
+
embellishmentTapeSchema,
|
|
4848
|
+
embellishmentPostcardSchema,
|
|
4849
|
+
embellishmentGraphicStickerSchema
|
|
4850
|
+
];
|
|
4851
|
+
var embellishmentSchemas = z.union(
|
|
4852
|
+
[...embellishmentSchemasArray]
|
|
4853
|
+
);
|
|
4854
|
+
var embellishmentUpdateSchemas = z.union(
|
|
4855
|
+
[
|
|
4856
|
+
...embellishmentSchemasArray.map((schema) => schema.partial().optional())
|
|
4857
|
+
]
|
|
4858
|
+
);
|
|
4859
|
+
var embellishmentListSchemasArray = [...embellishmentSchemasArray];
|
|
4860
|
+
embellishmentListSchemasArray.shift();
|
|
4861
|
+
embellishmentListSchemasArray.push(embellishmentBackgroundListSchema);
|
|
4862
|
+
var embellishmentListSchemas = z.union(
|
|
4863
|
+
[...embellishmentListSchemasArray]
|
|
4864
|
+
);
|
|
4865
|
+
|
|
4866
|
+
// ../../core/types/engine-api/pagination.ts
|
|
4867
|
+
function paginatedResponseSchema(arrayOf) {
|
|
4868
|
+
return z.object({
|
|
4869
|
+
count: z.number(),
|
|
4870
|
+
nextCursor: z.string().nullable(),
|
|
4871
|
+
previousCursor: z.string().optional(),
|
|
4872
|
+
results: z.array(arrayOf)
|
|
4873
|
+
});
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4876
|
+
// ../../core/types/engine-api/endpoints/embellishments.ts
|
|
4877
|
+
var embellishmentPaginatedSchema = paginatedResponseSchema(embellishmentListSchemas);
|
|
4878
|
+
var EmbellishmentsEndpoints = class {
|
|
4576
4879
|
// eslint-disable-next-line no-unused-vars
|
|
4577
4880
|
constructor(engineAPI) {
|
|
4578
4881
|
this.engineAPI = engineAPI;
|
|
4579
|
-
bindThisToFunctions(this);
|
|
4580
4882
|
}
|
|
4581
|
-
|
|
4883
|
+
list({ styleSlug, qs }) {
|
|
4582
4884
|
return handleAsyncFunction(async () => {
|
|
4583
4885
|
const res = await this.engineAPI.fetcher.call({
|
|
4584
|
-
|
|
4585
|
-
|
|
4886
|
+
path: `/v1/embellishments/style/${styleSlug}`,
|
|
4887
|
+
qs
|
|
4888
|
+
});
|
|
4889
|
+
return embellishmentPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4892
|
+
retrieve({ styleSlug, embellishmentId, qs }) {
|
|
4893
|
+
return handleAsyncFunction(async () => {
|
|
4894
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4895
|
+
path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
|
|
4896
|
+
qs
|
|
4897
|
+
});
|
|
4898
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4899
|
+
});
|
|
4900
|
+
}
|
|
4901
|
+
update({ styleSlug, embellishmentId, payload }) {
|
|
4902
|
+
return handleAsyncFunction(async () => {
|
|
4903
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4904
|
+
path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
|
|
4905
|
+
options: {
|
|
4906
|
+
method: "PUT",
|
|
4907
|
+
body: cleanJSON(camelCaseObjectKeysToSnakeCase({ ...payload }))
|
|
4908
|
+
}
|
|
4586
4909
|
});
|
|
4587
|
-
return
|
|
4910
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4588
4911
|
});
|
|
4589
4912
|
}
|
|
4590
4913
|
};
|
|
4591
4914
|
|
|
4592
|
-
// ../../core/
|
|
4915
|
+
// ../../core/types/event.ts
|
|
4593
4916
|
var eventContextSchema = z.record(z.string(), z.unknown()).optional();
|
|
4594
4917
|
var eventSchema = z.object({
|
|
4595
4918
|
name: z.string(),
|
|
4596
|
-
context: eventContextSchema
|
|
4919
|
+
context: eventContextSchema,
|
|
4920
|
+
bookId: z.string(),
|
|
4921
|
+
createdAt: z.string()
|
|
4597
4922
|
});
|
|
4598
4923
|
|
|
4599
|
-
// ../../core/
|
|
4924
|
+
// ../../core/types/engine-api/endpoints/events.ts
|
|
4925
|
+
var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
|
|
4600
4926
|
var EventsEndpoints = class {
|
|
4601
4927
|
// eslint-disable-next-line no-unused-vars
|
|
4602
4928
|
constructor(engineAPI) {
|
|
4603
4929
|
this.engineAPI = engineAPI;
|
|
4604
|
-
bindThisToFunctions(this);
|
|
4605
4930
|
}
|
|
4606
|
-
|
|
4931
|
+
listBookEvents({ bookId, qs }) {
|
|
4932
|
+
return handleAsyncFunction(async () => {
|
|
4933
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4934
|
+
path: `/v1/events/book/${bookId}`,
|
|
4935
|
+
qs
|
|
4936
|
+
});
|
|
4937
|
+
return eventPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
createBookEvent({ name, data, bookId, qs }) {
|
|
4607
4941
|
return handleAsyncFunction(async () => {
|
|
4608
4942
|
const body = {
|
|
4609
4943
|
name
|
|
@@ -4614,14 +4948,26 @@ var EventsEndpoints = class {
|
|
|
4614
4948
|
options: {
|
|
4615
4949
|
method: "POST",
|
|
4616
4950
|
body: cleanJSON(body)
|
|
4617
|
-
}
|
|
4951
|
+
},
|
|
4952
|
+
qs
|
|
4953
|
+
});
|
|
4954
|
+
return eventSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4955
|
+
});
|
|
4956
|
+
}
|
|
4957
|
+
deleteBookEvent({ name, bookId, qs }) {
|
|
4958
|
+
return handleAsyncFunction(async () => {
|
|
4959
|
+
await this.engineAPI.fetcher.call({
|
|
4960
|
+
path: `/v1/events/book/${bookId}/name/${name}`,
|
|
4961
|
+
options: {
|
|
4962
|
+
method: "DELETE"
|
|
4963
|
+
},
|
|
4964
|
+
qs
|
|
4618
4965
|
});
|
|
4619
|
-
return eventSchema.parse(res);
|
|
4620
4966
|
});
|
|
4621
4967
|
}
|
|
4622
4968
|
};
|
|
4623
4969
|
|
|
4624
|
-
// ../../core/
|
|
4970
|
+
// ../../core/types/fetcher.ts
|
|
4625
4971
|
var baseOptions = {
|
|
4626
4972
|
headers: {
|
|
4627
4973
|
"Content-Type": "application/json"
|
|
@@ -4642,12 +4988,14 @@ var Fetcher = class {
|
|
|
4642
4988
|
}
|
|
4643
4989
|
const baseOptions2 = { ...this.options };
|
|
4644
4990
|
const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
|
|
4645
|
-
const
|
|
4646
|
-
|
|
4991
|
+
const qs = props.qs ? `?${props.qs}` : "";
|
|
4992
|
+
const res = await fetch(this.cleanUrl(`${this.baseUrl}${props.path}${qs}`), options);
|
|
4993
|
+
if (res.status >= 200 && res.status < 300 && res.ok) {
|
|
4994
|
+
const result = await res.text();
|
|
4647
4995
|
try {
|
|
4648
|
-
return
|
|
4996
|
+
return JSON.parse(result);
|
|
4649
4997
|
} catch (error) {
|
|
4650
|
-
return
|
|
4998
|
+
return result;
|
|
4651
4999
|
}
|
|
4652
5000
|
} else {
|
|
4653
5001
|
let detail = res.statusText;
|
|
@@ -4662,70 +5010,102 @@ var Fetcher = class {
|
|
|
4662
5010
|
}
|
|
4663
5011
|
}
|
|
4664
5012
|
cleanUrl(url) {
|
|
4665
|
-
return url.replaceAll(" ", "").trim();
|
|
5013
|
+
return url.replace(/\/\//g, "/").replaceAll(" ", "").trim();
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
5016
|
+
|
|
5017
|
+
// ../../core/types/font.ts
|
|
5018
|
+
var fontRoles = ["title", "subtitle", "caption"];
|
|
5019
|
+
var fontSchema = z.object({
|
|
5020
|
+
slug: z.string(),
|
|
5021
|
+
family: z.string()
|
|
5022
|
+
});
|
|
5023
|
+
var styleFontSchema = fontSchema.extend({
|
|
5024
|
+
role: z.enum(fontRoles)
|
|
5025
|
+
});
|
|
5026
|
+
|
|
5027
|
+
// ../../core/types/engine-api/endpoints/fonts.ts
|
|
5028
|
+
var fontPaginatedSchema = paginatedResponseSchema(fontSchema);
|
|
5029
|
+
var FontsEndpoints = class {
|
|
5030
|
+
// eslint-disable-next-line no-unused-vars
|
|
5031
|
+
constructor(engineAPI) {
|
|
5032
|
+
this.engineAPI = engineAPI;
|
|
5033
|
+
}
|
|
5034
|
+
list(props) {
|
|
5035
|
+
return handleAsyncFunction(async () => {
|
|
5036
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5037
|
+
path: "/v1/fonts",
|
|
5038
|
+
qs: props?.qs
|
|
5039
|
+
});
|
|
5040
|
+
return fontPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5041
|
+
});
|
|
4666
5042
|
}
|
|
4667
5043
|
};
|
|
4668
5044
|
|
|
4669
|
-
// ../../core/
|
|
5045
|
+
// ../../core/types/engine-api/endpoints/images.ts
|
|
4670
5046
|
var ImagesEndpoints = class {
|
|
4671
5047
|
// eslint-disable-next-line no-unused-vars
|
|
4672
5048
|
constructor(engineAPI) {
|
|
4673
5049
|
this.engineAPI = engineAPI;
|
|
4674
|
-
bindThisToFunctions(this);
|
|
4675
5050
|
}
|
|
4676
|
-
list(bookId) {
|
|
5051
|
+
list({ bookId, qs }) {
|
|
4677
5052
|
return handleAsyncFunction(async () => {
|
|
4678
5053
|
const res = await this.engineAPI.fetcher.call({
|
|
4679
|
-
path: `/v1/images/book/${bookId}
|
|
5054
|
+
path: `/v1/images/book/${bookId}`,
|
|
5055
|
+
qs
|
|
4680
5056
|
});
|
|
4681
5057
|
return z.array(imageServerSchema).parse(res);
|
|
4682
5058
|
});
|
|
4683
5059
|
}
|
|
4684
|
-
|
|
5060
|
+
addToBook({ bookId, image, qs }) {
|
|
4685
5061
|
return handleAsyncFunction(async () => {
|
|
4686
5062
|
const res = await this.engineAPI.fetcher.call({
|
|
4687
|
-
path: `/v1/images
|
|
5063
|
+
path: `/v1/images/book/${bookId}`,
|
|
5064
|
+
options: {
|
|
5065
|
+
method: "POST",
|
|
5066
|
+
body: cleanJSON(image)
|
|
5067
|
+
},
|
|
5068
|
+
qs
|
|
4688
5069
|
});
|
|
4689
5070
|
return imageServerSchema.parse(res);
|
|
4690
5071
|
});
|
|
4691
5072
|
}
|
|
4692
|
-
|
|
5073
|
+
retrieve({ bookId, imageId, qs }) {
|
|
4693
5074
|
return handleAsyncFunction(async () => {
|
|
4694
5075
|
const res = await this.engineAPI.fetcher.call({
|
|
4695
5076
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4696
|
-
|
|
4697
|
-
method: "PUT",
|
|
4698
|
-
body: cleanJSON(image)
|
|
4699
|
-
}
|
|
5077
|
+
qs
|
|
4700
5078
|
});
|
|
4701
5079
|
return imageServerSchema.parse(res);
|
|
4702
5080
|
});
|
|
4703
5081
|
}
|
|
4704
|
-
|
|
5082
|
+
update({ bookId, imageId, payload, qs }) {
|
|
4705
5083
|
return handleAsyncFunction(async () => {
|
|
4706
|
-
await this.engineAPI.fetcher.call({
|
|
5084
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4707
5085
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4708
5086
|
options: {
|
|
4709
|
-
method: "
|
|
4710
|
-
|
|
5087
|
+
method: "PUT",
|
|
5088
|
+
body: cleanJSON(payload)
|
|
5089
|
+
},
|
|
5090
|
+
qs
|
|
4711
5091
|
});
|
|
5092
|
+
return imageServerSchema.parse(res);
|
|
4712
5093
|
});
|
|
4713
5094
|
}
|
|
4714
|
-
|
|
5095
|
+
delete({ bookId, imageId, qs }) {
|
|
4715
5096
|
return handleAsyncFunction(async () => {
|
|
4716
|
-
|
|
4717
|
-
path: `/v1/images/book/${bookId}
|
|
5097
|
+
await this.engineAPI.fetcher.call({
|
|
5098
|
+
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4718
5099
|
options: {
|
|
4719
|
-
method: "
|
|
4720
|
-
|
|
4721
|
-
|
|
5100
|
+
method: "DELETE"
|
|
5101
|
+
},
|
|
5102
|
+
qs
|
|
4722
5103
|
});
|
|
4723
|
-
return imageServerSchema.parse(res);
|
|
4724
5104
|
});
|
|
4725
5105
|
}
|
|
4726
5106
|
};
|
|
4727
5107
|
|
|
4728
|
-
// ../../core/
|
|
5108
|
+
// ../../core/types/spread.ts
|
|
4729
5109
|
var spreadServerSchema = z.object({
|
|
4730
5110
|
id: z.string().optional(),
|
|
4731
5111
|
book_id: z.string(),
|
|
@@ -4759,79 +5139,70 @@ var spreadSchema = z.object({
|
|
|
4759
5139
|
url: z.string().nullable().optional()
|
|
4760
5140
|
});
|
|
4761
5141
|
|
|
4762
|
-
// ../../core/
|
|
5142
|
+
// ../../core/types/engine-api/endpoints/spreads.ts
|
|
4763
5143
|
var SpreadsEndpoints = class {
|
|
4764
5144
|
// eslint-disable-next-line no-unused-vars
|
|
4765
5145
|
constructor(engineAPI) {
|
|
4766
5146
|
this.engineAPI = engineAPI;
|
|
4767
|
-
bindThisToFunctions(this);
|
|
4768
5147
|
}
|
|
4769
|
-
list(bookId) {
|
|
5148
|
+
list({ bookId, qs }) {
|
|
4770
5149
|
return handleAsyncFunction(async () => {
|
|
4771
5150
|
const res = await this.engineAPI.fetcher.call({
|
|
4772
|
-
path: `/v1/spreads/book/${bookId}
|
|
5151
|
+
path: `/v1/spreads/book/${bookId}`,
|
|
5152
|
+
qs
|
|
4773
5153
|
});
|
|
4774
|
-
return z.array(
|
|
5154
|
+
return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4775
5155
|
});
|
|
4776
5156
|
}
|
|
4777
|
-
create(bookId, spread) {
|
|
5157
|
+
create({ bookId, spread, qs }) {
|
|
4778
5158
|
return handleAsyncFunction(async () => {
|
|
4779
5159
|
const res = await this.engineAPI.fetcher.call({
|
|
4780
5160
|
path: `/v1/spreads/book/${bookId}`,
|
|
4781
5161
|
options: {
|
|
4782
5162
|
method: "POST",
|
|
4783
5163
|
body: cleanJSON(spread)
|
|
4784
|
-
}
|
|
5164
|
+
},
|
|
5165
|
+
qs
|
|
4785
5166
|
});
|
|
4786
|
-
return
|
|
5167
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4787
5168
|
});
|
|
4788
5169
|
}
|
|
4789
|
-
retrieve(spreadId,
|
|
5170
|
+
retrieve({ bookId, spreadId, qs }) {
|
|
4790
5171
|
return handleAsyncFunction(async () => {
|
|
4791
5172
|
const res = await this.engineAPI.fetcher.call({
|
|
4792
|
-
path: `/v1/spreads/${spreadId}/book/${bookId}
|
|
5173
|
+
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5174
|
+
qs
|
|
4793
5175
|
});
|
|
4794
|
-
return
|
|
5176
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4795
5177
|
});
|
|
4796
5178
|
}
|
|
4797
|
-
update(spreadId,
|
|
5179
|
+
update({ bookId, spreadId, payload, qs }) {
|
|
4798
5180
|
return handleAsyncFunction(async () => {
|
|
4799
5181
|
const res = await this.engineAPI.fetcher.call({
|
|
4800
5182
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4801
5183
|
options: {
|
|
4802
5184
|
method: "PUT",
|
|
4803
|
-
body: cleanJSON(
|
|
4804
|
-
}
|
|
5185
|
+
body: cleanJSON(payload)
|
|
5186
|
+
},
|
|
5187
|
+
qs
|
|
4805
5188
|
});
|
|
4806
|
-
return
|
|
5189
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4807
5190
|
});
|
|
4808
5191
|
}
|
|
4809
|
-
delete(spreadId,
|
|
5192
|
+
delete({ bookId, spreadId, qs }) {
|
|
4810
5193
|
return handleAsyncFunction(async () => {
|
|
4811
5194
|
await this.engineAPI.fetcher.call({
|
|
4812
5195
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4813
5196
|
options: {
|
|
4814
5197
|
method: "DELETE"
|
|
4815
|
-
}
|
|
5198
|
+
},
|
|
5199
|
+
qs
|
|
4816
5200
|
});
|
|
4817
5201
|
});
|
|
4818
5202
|
}
|
|
4819
5203
|
};
|
|
4820
5204
|
|
|
4821
|
-
// ../../core/
|
|
4822
|
-
var StoryboardItemImageFaceServerSchema = z.object({
|
|
4823
|
-
score: z.number(),
|
|
4824
|
-
bounding_box: z.object({
|
|
4825
|
-
x: z.number(),
|
|
4826
|
-
y: z.number(),
|
|
4827
|
-
width: z.number(),
|
|
4828
|
-
height: z.number()
|
|
4829
|
-
}),
|
|
4830
|
-
size: z.number(),
|
|
4831
|
-
eyes_open_score: z.number(),
|
|
4832
|
-
smile_score: z.number(),
|
|
4833
|
-
facing_camera_score: z.number()
|
|
4834
|
-
});
|
|
5205
|
+
// ../../core/types/storyboard-item.ts
|
|
4835
5206
|
var StoryboardItemImageFaceSchema = z.object({
|
|
4836
5207
|
score: z.number(),
|
|
4837
5208
|
boundingBox: z.object({
|
|
@@ -4845,27 +5216,14 @@ var StoryboardItemImageFaceSchema = z.object({
|
|
|
4845
5216
|
smileScore: z.number(),
|
|
4846
5217
|
facingCameraScore: z.number()
|
|
4847
5218
|
});
|
|
4848
|
-
var StoryboardItemImageServerSchema = z.object({
|
|
4849
|
-
id: z.string(),
|
|
4850
|
-
url: z.string(),
|
|
4851
|
-
category: z.string(),
|
|
4852
|
-
aesthetic_score: z.number(),
|
|
4853
|
-
faces: z.array(StoryboardItemImageFaceServerSchema),
|
|
4854
|
-
roi: z.object({
|
|
4855
|
-
x: z.number(),
|
|
4856
|
-
y: z.number(),
|
|
4857
|
-
width: z.number(),
|
|
4858
|
-
height: z.number()
|
|
4859
|
-
}),
|
|
4860
|
-
taken_at: z.number(),
|
|
4861
|
-
width: z.number(),
|
|
4862
|
-
height: z.number()
|
|
4863
|
-
});
|
|
4864
5219
|
var StoryboardItemImageSchema = z.object({
|
|
4865
5220
|
id: z.string(),
|
|
4866
5221
|
url: z.string(),
|
|
4867
5222
|
category: z.string(),
|
|
4868
|
-
|
|
5223
|
+
aesthetics: z.object({
|
|
5224
|
+
score: z.number(),
|
|
5225
|
+
scoreWithoutDistance: z.number()
|
|
5226
|
+
}),
|
|
4869
5227
|
faces: z.array(StoryboardItemImageFaceSchema),
|
|
4870
5228
|
roi: z.object({
|
|
4871
5229
|
x: z.number(),
|
|
@@ -4877,21 +5235,6 @@ var StoryboardItemImageSchema = z.object({
|
|
|
4877
5235
|
width: z.number(),
|
|
4878
5236
|
height: z.number()
|
|
4879
5237
|
});
|
|
4880
|
-
var StoryboardItemServerSchema = z.object({
|
|
4881
|
-
id: z.string(),
|
|
4882
|
-
sequence: z.number(),
|
|
4883
|
-
book_id: z.string(),
|
|
4884
|
-
similarity: z.number(),
|
|
4885
|
-
duplicate: z.boolean(),
|
|
4886
|
-
selected: z.boolean(),
|
|
4887
|
-
surface_weight: z.number(),
|
|
4888
|
-
front_cover: z.boolean().optional(),
|
|
4889
|
-
back_cover: z.boolean().optional(),
|
|
4890
|
-
scene: z.number(),
|
|
4891
|
-
subscene: z.number(),
|
|
4892
|
-
spine_break: z.boolean().optional(),
|
|
4893
|
-
image: StoryboardItemImageServerSchema
|
|
4894
|
-
});
|
|
4895
5238
|
var StoryboardItemSchema = z.object({
|
|
4896
5239
|
id: z.string(),
|
|
4897
5240
|
sequence: z.number(),
|
|
@@ -4908,34 +5251,138 @@ var StoryboardItemSchema = z.object({
|
|
|
4908
5251
|
image: StoryboardItemImageSchema
|
|
4909
5252
|
});
|
|
4910
5253
|
|
|
4911
|
-
// ../../core/
|
|
5254
|
+
// ../../core/types/engine-api/endpoints/storyboard-items.ts
|
|
4912
5255
|
var StoryboardItemsEndpoints = class {
|
|
4913
5256
|
// eslint-disable-next-line no-unused-vars
|
|
4914
5257
|
constructor(engineAPI) {
|
|
4915
5258
|
this.engineAPI = engineAPI;
|
|
4916
|
-
bindThisToFunctions(this);
|
|
4917
5259
|
}
|
|
4918
|
-
list(
|
|
5260
|
+
list(props) {
|
|
4919
5261
|
return handleAsyncFunction(async () => {
|
|
4920
5262
|
const res = await this.engineAPI.fetcher.call({
|
|
4921
|
-
path: `/v1/storyboarditems/book/${bookId}`
|
|
5263
|
+
path: `/v1/storyboarditems/book/${props.bookId}`
|
|
4922
5264
|
});
|
|
4923
|
-
return z.array(
|
|
5265
|
+
return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4924
5266
|
});
|
|
4925
5267
|
}
|
|
4926
5268
|
};
|
|
4927
5269
|
|
|
4928
|
-
// ../../core/
|
|
5270
|
+
// ../../core/types/style.ts
|
|
5271
|
+
var styleBaseSchema = z.object({
|
|
5272
|
+
active: z.boolean(),
|
|
5273
|
+
name: z.string(),
|
|
5274
|
+
slug: z.string()
|
|
5275
|
+
});
|
|
5276
|
+
var backgroundSchema = z.object({
|
|
5277
|
+
url: z.string(),
|
|
5278
|
+
compatible: z.boolean()
|
|
5279
|
+
});
|
|
5280
|
+
var colorSchema = z.object({
|
|
5281
|
+
compatible: z.boolean()
|
|
5282
|
+
});
|
|
5283
|
+
var compatibleBackgroundSchema = z.object({
|
|
5284
|
+
id: z.string(),
|
|
5285
|
+
url: z.string(),
|
|
5286
|
+
backgrounds: z.record(z.string(), backgroundSchema),
|
|
5287
|
+
colors: z.record(z.string(), colorSchema)
|
|
5288
|
+
});
|
|
5289
|
+
var whitespaceSchema = z.object({
|
|
5290
|
+
min: z.number(),
|
|
5291
|
+
max: z.number()
|
|
5292
|
+
});
|
|
5293
|
+
var layoutConstraintsClasses = [
|
|
5294
|
+
"A",
|
|
5295
|
+
"B",
|
|
5296
|
+
"C",
|
|
5297
|
+
"D",
|
|
5298
|
+
"E",
|
|
5299
|
+
"F",
|
|
5300
|
+
"G",
|
|
5301
|
+
"H",
|
|
5302
|
+
"I",
|
|
5303
|
+
"J",
|
|
5304
|
+
"K",
|
|
5305
|
+
"L",
|
|
5306
|
+
"M",
|
|
5307
|
+
"N",
|
|
5308
|
+
"O",
|
|
5309
|
+
"P",
|
|
5310
|
+
"Q",
|
|
5311
|
+
"R",
|
|
5312
|
+
"S",
|
|
5313
|
+
"T",
|
|
5314
|
+
"U",
|
|
5315
|
+
"V",
|
|
5316
|
+
"W",
|
|
5317
|
+
"X",
|
|
5318
|
+
"Y",
|
|
5319
|
+
"Z"
|
|
5320
|
+
];
|
|
5321
|
+
var layoutConstraintSchema = z.object({
|
|
5322
|
+
whitespace: whitespaceSchema,
|
|
5323
|
+
iWhitespace: whitespaceSchema,
|
|
5324
|
+
classes: z.array(z.enum(layoutConstraintsClasses))
|
|
5325
|
+
});
|
|
5326
|
+
var layoutConstraintsSchema = z.object({
|
|
5327
|
+
lots: layoutConstraintSchema,
|
|
5328
|
+
few: layoutConstraintSchema,
|
|
5329
|
+
none: layoutConstraintSchema
|
|
5330
|
+
});
|
|
5331
|
+
var styleSchema = styleBaseSchema.extend({
|
|
5332
|
+
position: z.number(),
|
|
5333
|
+
compatibleBackgrounds: z.array(compatibleBackgroundSchema),
|
|
5334
|
+
fonts: z.array(styleFontSchema),
|
|
5335
|
+
layoutConstraints: layoutConstraintsSchema,
|
|
5336
|
+
colors: z.record(z.string(), z.array(z.string()))
|
|
5337
|
+
});
|
|
5338
|
+
|
|
5339
|
+
// ../../core/types/engine-api/endpoints/styles.ts
|
|
5340
|
+
var stylePaginatedSchema = paginatedResponseSchema(styleBaseSchema);
|
|
5341
|
+
var StylesEndpoints = class {
|
|
5342
|
+
// eslint-disable-next-line no-unused-vars
|
|
5343
|
+
constructor(engineAPI) {
|
|
5344
|
+
this.engineAPI = engineAPI;
|
|
5345
|
+
}
|
|
5346
|
+
list(props) {
|
|
5347
|
+
return handleAsyncFunction(async () => {
|
|
5348
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5349
|
+
path: "/v1/styles",
|
|
5350
|
+
qs: props?.qs
|
|
5351
|
+
});
|
|
5352
|
+
return stylePaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
5355
|
+
retrieve({ styleSlug, qs }) {
|
|
5356
|
+
return handleAsyncFunction(async () => {
|
|
5357
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5358
|
+
path: `/v1/styles/${styleSlug}`,
|
|
5359
|
+
qs
|
|
5360
|
+
});
|
|
5361
|
+
return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5362
|
+
});
|
|
5363
|
+
}
|
|
5364
|
+
update({ styleSlug, payload, qs }) {
|
|
5365
|
+
return handleAsyncFunction(async () => {
|
|
5366
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5367
|
+
path: `/v1/styles/${styleSlug}`,
|
|
5368
|
+
qs,
|
|
5369
|
+
options: {
|
|
5370
|
+
method: "PUT",
|
|
5371
|
+
body: cleanJSON(payload)
|
|
5372
|
+
}
|
|
5373
|
+
});
|
|
5374
|
+
return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5375
|
+
});
|
|
5376
|
+
}
|
|
5377
|
+
};
|
|
5378
|
+
|
|
5379
|
+
// ../../core/types/engine-api/index.ts
|
|
4929
5380
|
var EngineAPI = class {
|
|
4930
|
-
baseUrl;
|
|
4931
|
-
apiKey;
|
|
4932
5381
|
fetcher;
|
|
4933
5382
|
constructor(baseUrl, apiKey) {
|
|
4934
|
-
this.baseUrl = new URL(baseUrl);
|
|
4935
|
-
this.apiKey = apiKey;
|
|
4936
5383
|
const options = {
|
|
4937
5384
|
headers: {
|
|
4938
|
-
"Authorization": `API-Key ${
|
|
5385
|
+
"Authorization": `API-Key ${apiKey}`
|
|
4939
5386
|
}
|
|
4940
5387
|
};
|
|
4941
5388
|
this.fetcher = new Fetcher(baseUrl, options);
|
|
@@ -4943,16 +5390,19 @@ var EngineAPI = class {
|
|
|
4943
5390
|
books = new BooksEndpoints(this);
|
|
4944
5391
|
designOptions = new DesignOptionsEndpoints(this);
|
|
4945
5392
|
events = new EventsEndpoints(this);
|
|
5393
|
+
embellishments = new EmbellishmentsEndpoints(this);
|
|
5394
|
+
fonts = new FontsEndpoints(this);
|
|
4946
5395
|
images = new ImagesEndpoints(this);
|
|
4947
|
-
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
4948
5396
|
spreads = new SpreadsEndpoints(this);
|
|
5397
|
+
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
5398
|
+
styles = new StylesEndpoints(this);
|
|
4949
5399
|
};
|
|
4950
5400
|
|
|
4951
5401
|
// ../../core/config.ts
|
|
4952
|
-
var defaultApiHost = "https://api.
|
|
4953
|
-
var defaultWebSocketHost = "wss://socket.
|
|
5402
|
+
var defaultApiHost = "https://api.dev-sls.magicbook.io";
|
|
5403
|
+
var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
|
|
4954
5404
|
|
|
4955
|
-
// ../../core/
|
|
5405
|
+
// ../../core/types/client.ts
|
|
4956
5406
|
var MagicBookClient = class {
|
|
4957
5407
|
constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
|
|
4958
5408
|
this.apiKey = apiKey;
|
|
@@ -4963,7 +5413,7 @@ var MagicBookClient = class {
|
|
|
4963
5413
|
engineAPI;
|
|
4964
5414
|
async createDesignRequest(designRequestProps) {
|
|
4965
5415
|
if (designRequestProps.userId) {
|
|
4966
|
-
const book = await this.engineAPI.books.create(
|
|
5416
|
+
const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
|
|
4967
5417
|
return new DesignRequest(book.id, this, designRequestProps);
|
|
4968
5418
|
} else {
|
|
4969
5419
|
throw new Error("userId is required");
|
|
@@ -4976,44 +5426,86 @@ var MagicBookClient = class {
|
|
|
4976
5426
|
BookDesignRequest,
|
|
4977
5427
|
DesignRequest,
|
|
4978
5428
|
DesignRequestOptions,
|
|
5429
|
+
EmbellishmentsEndpoints,
|
|
5430
|
+
EngineAPI,
|
|
4979
5431
|
ImageServer,
|
|
4980
5432
|
Images,
|
|
4981
5433
|
MagicBookClient,
|
|
5434
|
+
StoryboardItemImageFaceSchema,
|
|
5435
|
+
StoryboardItemImageSchema,
|
|
5436
|
+
StoryboardItemSchema,
|
|
5437
|
+
StylesEndpoints,
|
|
4982
5438
|
assetSchema,
|
|
5439
|
+
backgroundSchema,
|
|
4983
5440
|
bookCreationRequestSchema,
|
|
4984
5441
|
bookDesignRequestSchema,
|
|
4985
5442
|
bookPropsSchema,
|
|
4986
5443
|
bookSizes,
|
|
4987
|
-
|
|
5444
|
+
canSubmitDesignRequest,
|
|
4988
5445
|
cancelledEventDetail,
|
|
4989
5446
|
canvasSchema,
|
|
5447
|
+
colorSchema,
|
|
5448
|
+
compatibleBackgroundSchema,
|
|
4990
5449
|
coverTypes,
|
|
4991
5450
|
designOptionsSchema,
|
|
4992
|
-
|
|
5451
|
+
embellishmentAnchorsSchema,
|
|
5452
|
+
embellishmentBackgroundListSchema,
|
|
5453
|
+
embellishmentBackgroundSchema,
|
|
5454
|
+
embellishmentBandSchema,
|
|
5455
|
+
embellishmentBaseSchema,
|
|
5456
|
+
embellishmentFrameSchema,
|
|
5457
|
+
embellishmentGraphicStickerSchema,
|
|
4993
5458
|
embellishmentLevels,
|
|
5459
|
+
embellishmentListSchemas,
|
|
5460
|
+
embellishmentOrientations,
|
|
5461
|
+
embellishmentPageCornerSchema,
|
|
5462
|
+
embellishmentPhotoCornerAnchorsSchema,
|
|
5463
|
+
embellishmentPhotoCornerSchema,
|
|
5464
|
+
embellishmentPostcardSchema,
|
|
5465
|
+
embellishmentSchemas,
|
|
5466
|
+
embellishmentStackings,
|
|
5467
|
+
embellishmentStampSchema,
|
|
5468
|
+
embellishmentStripSchema,
|
|
5469
|
+
embellishmentTPointSchema,
|
|
5470
|
+
embellishmentTapeSchema,
|
|
5471
|
+
embellishmentTextStickerSchema,
|
|
5472
|
+
embellishmentThicknesses,
|
|
5473
|
+
embellishmentTypes,
|
|
5474
|
+
embellishmentUpdateSchemas,
|
|
5475
|
+
fontRoles,
|
|
5476
|
+
fontSchema,
|
|
4994
5477
|
imageAssignmentSchema,
|
|
4995
5478
|
imageDensities,
|
|
4996
5479
|
imageDensityOptionSchema,
|
|
4997
|
-
imageDensityOptionServerSchema,
|
|
4998
5480
|
imageDensityOptionsSchema,
|
|
4999
|
-
imageDensityOptionsServerSchema,
|
|
5000
5481
|
imageFilteringLevels,
|
|
5001
5482
|
imageServerSchema,
|
|
5483
|
+
imageServerToImage,
|
|
5002
5484
|
isDesignRequestSubmitted,
|
|
5485
|
+
layoutConstraintSchema,
|
|
5486
|
+
layoutConstraintsClasses,
|
|
5487
|
+
layoutConstraintsSchema,
|
|
5003
5488
|
magicShopBookSchema,
|
|
5004
5489
|
occasions,
|
|
5005
5490
|
pageSchema,
|
|
5006
5491
|
pageTypes,
|
|
5492
|
+
paginatedResponseSchema,
|
|
5007
5493
|
photoMetadataSchema,
|
|
5008
5494
|
photoStripSchema,
|
|
5009
5495
|
positionSchema,
|
|
5010
5496
|
propertySchema,
|
|
5011
5497
|
reportingDataSchema,
|
|
5498
|
+
spreadSchema,
|
|
5499
|
+
spreadServerSchema,
|
|
5012
5500
|
states,
|
|
5013
5501
|
statesToCloseWS,
|
|
5014
5502
|
statesToReport,
|
|
5503
|
+
styleBaseSchema,
|
|
5504
|
+
styleFontSchema,
|
|
5505
|
+
styleSchema,
|
|
5015
5506
|
styles,
|
|
5016
5507
|
textStickerLevels,
|
|
5017
|
-
timeoutEventDetail
|
|
5508
|
+
timeoutEventDetail,
|
|
5509
|
+
whitespaceSchema
|
|
5018
5510
|
});
|
|
5019
5511
|
//# sourceMappingURL=index.cjs.map
|