@magiclabs.ai/magicbook-client 0.7.4 → 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 +757 -264
- package/index.cjs.map +1 -1
- package/index.d.cts +2426 -548
- package/index.d.ts +2426 -548
- package/index.js +711 -260
- package/index.js.map +1 -1
- package/package.json +11 -11
package/index.cjs
CHANGED
|
@@ -24,10 +24,17 @@ __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,
|
|
@@ -35,34 +42,69 @@ __export(src_exports, {
|
|
|
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
|
|
|
@@ -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) {
|
|
@@ -4153,7 +4241,10 @@ var Images = class {
|
|
|
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,13 +4371,13 @@ 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) {
|
|
@@ -4297,9 +4386,12 @@ var DesignRequest = class {
|
|
|
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
4397
|
return this;
|
|
@@ -4311,7 +4403,10 @@ var DesignRequest = class {
|
|
|
4311
4403
|
} else {
|
|
4312
4404
|
this.guid = guid;
|
|
4313
4405
|
this.updateDesignRequest(
|
|
4314
|
-
(await this.client.engineAPI.books.update(
|
|
4406
|
+
(await this.client.engineAPI.books.update({
|
|
4407
|
+
bookId: this.parentId,
|
|
4408
|
+
payload: this.toBook()
|
|
4409
|
+
})).toDesignRequestProps()
|
|
4315
4410
|
);
|
|
4316
4411
|
return this.guid;
|
|
4317
4412
|
}
|
|
@@ -4325,7 +4420,9 @@ var DesignRequest = class {
|
|
|
4325
4420
|
throw new Error("Design request not submitted");
|
|
4326
4421
|
} else {
|
|
4327
4422
|
this.updateDesignRequest({
|
|
4328
|
-
...(await this.client.engineAPI.books.cancel(
|
|
4423
|
+
...(await this.client.engineAPI.books.cancel({
|
|
4424
|
+
bookId: this.parentId
|
|
4425
|
+
})).toDesignRequestProps(),
|
|
4329
4426
|
state: "cancelled"
|
|
4330
4427
|
});
|
|
4331
4428
|
await this.eventHandler(cancelledEventDetail);
|
|
@@ -4334,22 +4431,31 @@ var DesignRequest = class {
|
|
|
4334
4431
|
}
|
|
4335
4432
|
async getJSON() {
|
|
4336
4433
|
if (this.state === "ready") {
|
|
4337
|
-
return await this.client.engineAPI.books.retrieveGalleon(
|
|
4434
|
+
return await this.client.engineAPI.books.retrieveGalleon({
|
|
4435
|
+
bookId: this.parentId
|
|
4436
|
+
});
|
|
4338
4437
|
} else {
|
|
4339
4438
|
throw new Error("Design request not ready");
|
|
4340
4439
|
}
|
|
4341
4440
|
}
|
|
4342
4441
|
async logEvent(name, data) {
|
|
4343
|
-
return await this.client.engineAPI.events.createBookEvent(
|
|
4442
|
+
return await this.client.engineAPI.events.createBookEvent({
|
|
4443
|
+
bookId: this.parentId,
|
|
4444
|
+
name,
|
|
4445
|
+
data
|
|
4446
|
+
});
|
|
4344
4447
|
}
|
|
4345
4448
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4346
4449
|
const customEvent = new CustomEvent(type, { detail });
|
|
4347
4450
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4348
4451
|
this.webSocket?.close();
|
|
4349
4452
|
if (statesToReport.includes(detail.slug)) {
|
|
4350
|
-
await this.client.engineAPI.books.report(
|
|
4351
|
-
|
|
4352
|
-
|
|
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
|
+
}
|
|
4353
4459
|
});
|
|
4354
4460
|
}
|
|
4355
4461
|
}
|
|
@@ -4402,7 +4508,7 @@ var DesignRequest = class {
|
|
|
4402
4508
|
}
|
|
4403
4509
|
};
|
|
4404
4510
|
|
|
4405
|
-
// ../../core/
|
|
4511
|
+
// ../../core/types/galleon.ts
|
|
4406
4512
|
var imageAssignmentSchema = z.object({
|
|
4407
4513
|
photoRefId: z.string(),
|
|
4408
4514
|
finalCrop: z.array(z.number())
|
|
@@ -4481,128 +4587,357 @@ var bookCreationRequestSchema = z.object({
|
|
|
4481
4587
|
reportingData: reportingDataSchema
|
|
4482
4588
|
});
|
|
4483
4589
|
|
|
4484
|
-
// ../../core/
|
|
4590
|
+
// ../../core/types/engine-api/endpoints/books.ts
|
|
4485
4591
|
var BooksEndpoints = class {
|
|
4486
4592
|
// eslint-disable-next-line no-unused-vars
|
|
4487
4593
|
constructor(engineAPI) {
|
|
4488
4594
|
this.engineAPI = engineAPI;
|
|
4489
|
-
bindThisToFunctions(this);
|
|
4490
4595
|
}
|
|
4491
|
-
create(book) {
|
|
4596
|
+
create({ book, qs }) {
|
|
4492
4597
|
return handleAsyncFunction(async () => {
|
|
4493
4598
|
const res = await this.engineAPI.fetcher.call({
|
|
4494
4599
|
path: "/v1/books",
|
|
4495
4600
|
options: {
|
|
4496
4601
|
method: "POST",
|
|
4497
4602
|
body: cleanJSON(book)
|
|
4498
|
-
}
|
|
4603
|
+
},
|
|
4604
|
+
qs
|
|
4499
4605
|
});
|
|
4500
|
-
bookPropsSchema.safeParse(res);
|
|
4501
4606
|
return new Book(res);
|
|
4502
4607
|
});
|
|
4503
4608
|
}
|
|
4504
|
-
retrieve(bookId) {
|
|
4609
|
+
retrieve({ bookId, qs }) {
|
|
4505
4610
|
return handleAsyncFunction(async () => {
|
|
4506
|
-
const res = await this.engineAPI.fetcher.call({
|
|
4507
|
-
|
|
4508
|
-
|
|
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);
|
|
4509
4617
|
});
|
|
4510
4618
|
}
|
|
4511
|
-
update(bookId,
|
|
4619
|
+
update({ bookId, payload, qs }) {
|
|
4512
4620
|
return handleAsyncFunction(async () => {
|
|
4513
4621
|
const res = await this.engineAPI.fetcher.call({
|
|
4514
4622
|
path: `/v1/books/${bookId}`,
|
|
4515
4623
|
options: {
|
|
4516
4624
|
method: "PUT",
|
|
4517
|
-
body: cleanJSON(
|
|
4518
|
-
}
|
|
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
|
|
4519
4639
|
});
|
|
4520
|
-
bookPropsSchema.safeParse(res);
|
|
4521
|
-
return new Book(res);
|
|
4522
4640
|
});
|
|
4523
4641
|
}
|
|
4524
|
-
design(bookId) {
|
|
4642
|
+
design({ bookId, qs }) {
|
|
4525
4643
|
return handleAsyncFunction(async () => {
|
|
4526
4644
|
const res = await this.engineAPI.fetcher.call({
|
|
4527
4645
|
path: `/v1/books/${bookId}/design`,
|
|
4528
|
-
options: { method: "POST" }
|
|
4646
|
+
options: { method: "POST" },
|
|
4647
|
+
qs
|
|
4529
4648
|
});
|
|
4530
|
-
bookPropsSchema.
|
|
4531
|
-
return new Book(
|
|
4649
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4650
|
+
return new Book(bookProps);
|
|
4532
4651
|
});
|
|
4533
4652
|
}
|
|
4534
|
-
cancel(bookId) {
|
|
4653
|
+
cancel({ bookId, qs }) {
|
|
4535
4654
|
return handleAsyncFunction(async () => {
|
|
4536
4655
|
const res = await this.engineAPI.fetcher.call({
|
|
4537
4656
|
path: `/v1/books/${bookId}/cancel`,
|
|
4538
|
-
options: { method: "POST" }
|
|
4657
|
+
options: { method: "POST" },
|
|
4658
|
+
qs
|
|
4539
4659
|
});
|
|
4540
|
-
bookPropsSchema.
|
|
4541
|
-
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);
|
|
4542
4671
|
});
|
|
4543
4672
|
}
|
|
4544
|
-
report(bookId, report) {
|
|
4673
|
+
report({ bookId, report, qs }) {
|
|
4545
4674
|
return handleAsyncFunction(async () => {
|
|
4546
4675
|
await this.engineAPI.fetcher.call({
|
|
4547
4676
|
path: `/v1/books/${bookId}/report`,
|
|
4548
4677
|
options: {
|
|
4549
4678
|
method: "POST",
|
|
4550
4679
|
body: cleanJSON(report)
|
|
4551
|
-
}
|
|
4680
|
+
},
|
|
4681
|
+
qs
|
|
4552
4682
|
});
|
|
4553
4683
|
});
|
|
4554
4684
|
}
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
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;
|
|
4562
4692
|
}
|
|
4563
|
-
|
|
4693
|
+
retrieve(props) {
|
|
4564
4694
|
return handleAsyncFunction(async () => {
|
|
4565
4695
|
const res = await this.engineAPI.fetcher.call({
|
|
4566
|
-
|
|
4696
|
+
// eslint-disable-next-line max-len
|
|
4697
|
+
path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
|
|
4698
|
+
qs: props.qs
|
|
4567
4699
|
});
|
|
4568
|
-
return
|
|
4700
|
+
return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4569
4701
|
});
|
|
4570
4702
|
}
|
|
4571
4703
|
};
|
|
4572
4704
|
|
|
4573
|
-
// ../../core/
|
|
4574
|
-
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 {
|
|
4575
4879
|
// eslint-disable-next-line no-unused-vars
|
|
4576
4880
|
constructor(engineAPI) {
|
|
4577
4881
|
this.engineAPI = engineAPI;
|
|
4578
|
-
bindThisToFunctions(this);
|
|
4579
4882
|
}
|
|
4580
|
-
|
|
4883
|
+
list({ styleSlug, qs }) {
|
|
4581
4884
|
return handleAsyncFunction(async () => {
|
|
4582
4885
|
const res = await this.engineAPI.fetcher.call({
|
|
4583
|
-
|
|
4584
|
-
|
|
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
|
+
}
|
|
4585
4909
|
});
|
|
4586
|
-
return
|
|
4910
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4587
4911
|
});
|
|
4588
4912
|
}
|
|
4589
4913
|
};
|
|
4590
4914
|
|
|
4591
|
-
// ../../core/
|
|
4915
|
+
// ../../core/types/event.ts
|
|
4592
4916
|
var eventContextSchema = z.record(z.string(), z.unknown()).optional();
|
|
4593
4917
|
var eventSchema = z.object({
|
|
4594
4918
|
name: z.string(),
|
|
4595
|
-
context: eventContextSchema
|
|
4919
|
+
context: eventContextSchema,
|
|
4920
|
+
bookId: z.string(),
|
|
4921
|
+
createdAt: z.string()
|
|
4596
4922
|
});
|
|
4597
4923
|
|
|
4598
|
-
// ../../core/
|
|
4924
|
+
// ../../core/types/engine-api/endpoints/events.ts
|
|
4925
|
+
var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
|
|
4599
4926
|
var EventsEndpoints = class {
|
|
4600
4927
|
// eslint-disable-next-line no-unused-vars
|
|
4601
4928
|
constructor(engineAPI) {
|
|
4602
4929
|
this.engineAPI = engineAPI;
|
|
4603
|
-
bindThisToFunctions(this);
|
|
4604
4930
|
}
|
|
4605
|
-
|
|
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 }) {
|
|
4606
4941
|
return handleAsyncFunction(async () => {
|
|
4607
4942
|
const body = {
|
|
4608
4943
|
name
|
|
@@ -4613,14 +4948,26 @@ var EventsEndpoints = class {
|
|
|
4613
4948
|
options: {
|
|
4614
4949
|
method: "POST",
|
|
4615
4950
|
body: cleanJSON(body)
|
|
4616
|
-
}
|
|
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
|
|
4617
4965
|
});
|
|
4618
|
-
return eventSchema.parse(res);
|
|
4619
4966
|
});
|
|
4620
4967
|
}
|
|
4621
4968
|
};
|
|
4622
4969
|
|
|
4623
|
-
// ../../core/
|
|
4970
|
+
// ../../core/types/fetcher.ts
|
|
4624
4971
|
var baseOptions = {
|
|
4625
4972
|
headers: {
|
|
4626
4973
|
"Content-Type": "application/json"
|
|
@@ -4641,12 +4988,14 @@ var Fetcher = class {
|
|
|
4641
4988
|
}
|
|
4642
4989
|
const baseOptions2 = { ...this.options };
|
|
4643
4990
|
const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
|
|
4644
|
-
const
|
|
4645
|
-
|
|
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();
|
|
4646
4995
|
try {
|
|
4647
|
-
return
|
|
4996
|
+
return JSON.parse(result);
|
|
4648
4997
|
} catch (error) {
|
|
4649
|
-
return
|
|
4998
|
+
return result;
|
|
4650
4999
|
}
|
|
4651
5000
|
} else {
|
|
4652
5001
|
let detail = res.statusText;
|
|
@@ -4661,70 +5010,102 @@ var Fetcher = class {
|
|
|
4661
5010
|
}
|
|
4662
5011
|
}
|
|
4663
5012
|
cleanUrl(url) {
|
|
4664
|
-
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
|
+
});
|
|
4665
5042
|
}
|
|
4666
5043
|
};
|
|
4667
5044
|
|
|
4668
|
-
// ../../core/
|
|
5045
|
+
// ../../core/types/engine-api/endpoints/images.ts
|
|
4669
5046
|
var ImagesEndpoints = class {
|
|
4670
5047
|
// eslint-disable-next-line no-unused-vars
|
|
4671
5048
|
constructor(engineAPI) {
|
|
4672
5049
|
this.engineAPI = engineAPI;
|
|
4673
|
-
bindThisToFunctions(this);
|
|
4674
5050
|
}
|
|
4675
|
-
list(bookId) {
|
|
5051
|
+
list({ bookId, qs }) {
|
|
4676
5052
|
return handleAsyncFunction(async () => {
|
|
4677
5053
|
const res = await this.engineAPI.fetcher.call({
|
|
4678
|
-
path: `/v1/images/book/${bookId}
|
|
5054
|
+
path: `/v1/images/book/${bookId}`,
|
|
5055
|
+
qs
|
|
4679
5056
|
});
|
|
4680
5057
|
return z.array(imageServerSchema).parse(res);
|
|
4681
5058
|
});
|
|
4682
5059
|
}
|
|
4683
|
-
|
|
5060
|
+
addToBook({ bookId, image, qs }) {
|
|
4684
5061
|
return handleAsyncFunction(async () => {
|
|
4685
5062
|
const res = await this.engineAPI.fetcher.call({
|
|
4686
|
-
path: `/v1/images
|
|
5063
|
+
path: `/v1/images/book/${bookId}`,
|
|
5064
|
+
options: {
|
|
5065
|
+
method: "POST",
|
|
5066
|
+
body: cleanJSON(image)
|
|
5067
|
+
},
|
|
5068
|
+
qs
|
|
4687
5069
|
});
|
|
4688
5070
|
return imageServerSchema.parse(res);
|
|
4689
5071
|
});
|
|
4690
5072
|
}
|
|
4691
|
-
|
|
5073
|
+
retrieve({ bookId, imageId, qs }) {
|
|
4692
5074
|
return handleAsyncFunction(async () => {
|
|
4693
5075
|
const res = await this.engineAPI.fetcher.call({
|
|
4694
5076
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4695
|
-
|
|
4696
|
-
method: "PUT",
|
|
4697
|
-
body: cleanJSON(image)
|
|
4698
|
-
}
|
|
5077
|
+
qs
|
|
4699
5078
|
});
|
|
4700
5079
|
return imageServerSchema.parse(res);
|
|
4701
5080
|
});
|
|
4702
5081
|
}
|
|
4703
|
-
|
|
5082
|
+
update({ bookId, imageId, payload, qs }) {
|
|
4704
5083
|
return handleAsyncFunction(async () => {
|
|
4705
|
-
await this.engineAPI.fetcher.call({
|
|
5084
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4706
5085
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4707
5086
|
options: {
|
|
4708
|
-
method: "
|
|
4709
|
-
|
|
5087
|
+
method: "PUT",
|
|
5088
|
+
body: cleanJSON(payload)
|
|
5089
|
+
},
|
|
5090
|
+
qs
|
|
4710
5091
|
});
|
|
5092
|
+
return imageServerSchema.parse(res);
|
|
4711
5093
|
});
|
|
4712
5094
|
}
|
|
4713
|
-
|
|
5095
|
+
delete({ bookId, imageId, qs }) {
|
|
4714
5096
|
return handleAsyncFunction(async () => {
|
|
4715
|
-
|
|
4716
|
-
path: `/v1/images/book/${bookId}
|
|
5097
|
+
await this.engineAPI.fetcher.call({
|
|
5098
|
+
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4717
5099
|
options: {
|
|
4718
|
-
method: "
|
|
4719
|
-
|
|
4720
|
-
|
|
5100
|
+
method: "DELETE"
|
|
5101
|
+
},
|
|
5102
|
+
qs
|
|
4721
5103
|
});
|
|
4722
|
-
return imageServerSchema.parse(res);
|
|
4723
5104
|
});
|
|
4724
5105
|
}
|
|
4725
5106
|
};
|
|
4726
5107
|
|
|
4727
|
-
// ../../core/
|
|
5108
|
+
// ../../core/types/spread.ts
|
|
4728
5109
|
var spreadServerSchema = z.object({
|
|
4729
5110
|
id: z.string().optional(),
|
|
4730
5111
|
book_id: z.string(),
|
|
@@ -4758,79 +5139,70 @@ var spreadSchema = z.object({
|
|
|
4758
5139
|
url: z.string().nullable().optional()
|
|
4759
5140
|
});
|
|
4760
5141
|
|
|
4761
|
-
// ../../core/
|
|
5142
|
+
// ../../core/types/engine-api/endpoints/spreads.ts
|
|
4762
5143
|
var SpreadsEndpoints = class {
|
|
4763
5144
|
// eslint-disable-next-line no-unused-vars
|
|
4764
5145
|
constructor(engineAPI) {
|
|
4765
5146
|
this.engineAPI = engineAPI;
|
|
4766
|
-
bindThisToFunctions(this);
|
|
4767
5147
|
}
|
|
4768
|
-
list(bookId) {
|
|
5148
|
+
list({ bookId, qs }) {
|
|
4769
5149
|
return handleAsyncFunction(async () => {
|
|
4770
5150
|
const res = await this.engineAPI.fetcher.call({
|
|
4771
|
-
path: `/v1/spreads/book/${bookId}
|
|
5151
|
+
path: `/v1/spreads/book/${bookId}`,
|
|
5152
|
+
qs
|
|
4772
5153
|
});
|
|
4773
|
-
return z.array(
|
|
5154
|
+
return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4774
5155
|
});
|
|
4775
5156
|
}
|
|
4776
|
-
create(bookId, spread) {
|
|
5157
|
+
create({ bookId, spread, qs }) {
|
|
4777
5158
|
return handleAsyncFunction(async () => {
|
|
4778
5159
|
const res = await this.engineAPI.fetcher.call({
|
|
4779
5160
|
path: `/v1/spreads/book/${bookId}`,
|
|
4780
5161
|
options: {
|
|
4781
5162
|
method: "POST",
|
|
4782
5163
|
body: cleanJSON(spread)
|
|
4783
|
-
}
|
|
5164
|
+
},
|
|
5165
|
+
qs
|
|
4784
5166
|
});
|
|
4785
|
-
return
|
|
5167
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4786
5168
|
});
|
|
4787
5169
|
}
|
|
4788
|
-
retrieve(spreadId,
|
|
5170
|
+
retrieve({ bookId, spreadId, qs }) {
|
|
4789
5171
|
return handleAsyncFunction(async () => {
|
|
4790
5172
|
const res = await this.engineAPI.fetcher.call({
|
|
4791
|
-
path: `/v1/spreads/${spreadId}/book/${bookId}
|
|
5173
|
+
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5174
|
+
qs
|
|
4792
5175
|
});
|
|
4793
|
-
return
|
|
5176
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4794
5177
|
});
|
|
4795
5178
|
}
|
|
4796
|
-
update(spreadId,
|
|
5179
|
+
update({ bookId, spreadId, payload, qs }) {
|
|
4797
5180
|
return handleAsyncFunction(async () => {
|
|
4798
5181
|
const res = await this.engineAPI.fetcher.call({
|
|
4799
5182
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4800
5183
|
options: {
|
|
4801
5184
|
method: "PUT",
|
|
4802
|
-
body: cleanJSON(
|
|
4803
|
-
}
|
|
5185
|
+
body: cleanJSON(payload)
|
|
5186
|
+
},
|
|
5187
|
+
qs
|
|
4804
5188
|
});
|
|
4805
|
-
return
|
|
5189
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4806
5190
|
});
|
|
4807
5191
|
}
|
|
4808
|
-
delete(spreadId,
|
|
5192
|
+
delete({ bookId, spreadId, qs }) {
|
|
4809
5193
|
return handleAsyncFunction(async () => {
|
|
4810
5194
|
await this.engineAPI.fetcher.call({
|
|
4811
5195
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4812
5196
|
options: {
|
|
4813
5197
|
method: "DELETE"
|
|
4814
|
-
}
|
|
5198
|
+
},
|
|
5199
|
+
qs
|
|
4815
5200
|
});
|
|
4816
5201
|
});
|
|
4817
5202
|
}
|
|
4818
5203
|
};
|
|
4819
5204
|
|
|
4820
|
-
// ../../core/
|
|
4821
|
-
var StoryboardItemImageFaceServerSchema = z.object({
|
|
4822
|
-
score: z.number(),
|
|
4823
|
-
bounding_box: z.object({
|
|
4824
|
-
x: z.number(),
|
|
4825
|
-
y: z.number(),
|
|
4826
|
-
width: z.number(),
|
|
4827
|
-
height: z.number()
|
|
4828
|
-
}),
|
|
4829
|
-
size: z.number(),
|
|
4830
|
-
eyes_open_score: z.number(),
|
|
4831
|
-
smile_score: z.number(),
|
|
4832
|
-
facing_camera_score: z.number()
|
|
4833
|
-
});
|
|
5205
|
+
// ../../core/types/storyboard-item.ts
|
|
4834
5206
|
var StoryboardItemImageFaceSchema = z.object({
|
|
4835
5207
|
score: z.number(),
|
|
4836
5208
|
boundingBox: z.object({
|
|
@@ -4844,27 +5216,14 @@ var StoryboardItemImageFaceSchema = z.object({
|
|
|
4844
5216
|
smileScore: z.number(),
|
|
4845
5217
|
facingCameraScore: z.number()
|
|
4846
5218
|
});
|
|
4847
|
-
var StoryboardItemImageServerSchema = z.object({
|
|
4848
|
-
id: z.string(),
|
|
4849
|
-
url: z.string(),
|
|
4850
|
-
category: z.string(),
|
|
4851
|
-
aesthetic_score: z.number(),
|
|
4852
|
-
faces: z.array(StoryboardItemImageFaceServerSchema),
|
|
4853
|
-
roi: z.object({
|
|
4854
|
-
x: z.number(),
|
|
4855
|
-
y: z.number(),
|
|
4856
|
-
width: z.number(),
|
|
4857
|
-
height: z.number()
|
|
4858
|
-
}),
|
|
4859
|
-
taken_at: z.number(),
|
|
4860
|
-
width: z.number(),
|
|
4861
|
-
height: z.number()
|
|
4862
|
-
});
|
|
4863
5219
|
var StoryboardItemImageSchema = z.object({
|
|
4864
5220
|
id: z.string(),
|
|
4865
5221
|
url: z.string(),
|
|
4866
5222
|
category: z.string(),
|
|
4867
|
-
|
|
5223
|
+
aesthetics: z.object({
|
|
5224
|
+
score: z.number(),
|
|
5225
|
+
scoreWithoutDistance: z.number()
|
|
5226
|
+
}),
|
|
4868
5227
|
faces: z.array(StoryboardItemImageFaceSchema),
|
|
4869
5228
|
roi: z.object({
|
|
4870
5229
|
x: z.number(),
|
|
@@ -4876,21 +5235,6 @@ var StoryboardItemImageSchema = z.object({
|
|
|
4876
5235
|
width: z.number(),
|
|
4877
5236
|
height: z.number()
|
|
4878
5237
|
});
|
|
4879
|
-
var StoryboardItemServerSchema = z.object({
|
|
4880
|
-
id: z.string(),
|
|
4881
|
-
sequence: z.number(),
|
|
4882
|
-
book_id: z.string(),
|
|
4883
|
-
similarity: z.number(),
|
|
4884
|
-
duplicate: z.boolean(),
|
|
4885
|
-
selected: z.boolean(),
|
|
4886
|
-
surface_weight: z.number(),
|
|
4887
|
-
front_cover: z.boolean().optional(),
|
|
4888
|
-
back_cover: z.boolean().optional(),
|
|
4889
|
-
scene: z.number(),
|
|
4890
|
-
subscene: z.number(),
|
|
4891
|
-
spine_break: z.boolean().optional(),
|
|
4892
|
-
image: StoryboardItemImageServerSchema
|
|
4893
|
-
});
|
|
4894
5238
|
var StoryboardItemSchema = z.object({
|
|
4895
5239
|
id: z.string(),
|
|
4896
5240
|
sequence: z.number(),
|
|
@@ -4907,34 +5251,138 @@ var StoryboardItemSchema = z.object({
|
|
|
4907
5251
|
image: StoryboardItemImageSchema
|
|
4908
5252
|
});
|
|
4909
5253
|
|
|
4910
|
-
// ../../core/
|
|
5254
|
+
// ../../core/types/engine-api/endpoints/storyboard-items.ts
|
|
4911
5255
|
var StoryboardItemsEndpoints = class {
|
|
4912
5256
|
// eslint-disable-next-line no-unused-vars
|
|
4913
5257
|
constructor(engineAPI) {
|
|
4914
5258
|
this.engineAPI = engineAPI;
|
|
4915
|
-
bindThisToFunctions(this);
|
|
4916
5259
|
}
|
|
4917
|
-
list(
|
|
5260
|
+
list(props) {
|
|
4918
5261
|
return handleAsyncFunction(async () => {
|
|
4919
5262
|
const res = await this.engineAPI.fetcher.call({
|
|
4920
|
-
path: `/v1/storyboarditems/book/${bookId}`
|
|
5263
|
+
path: `/v1/storyboarditems/book/${props.bookId}`
|
|
4921
5264
|
});
|
|
4922
|
-
return z.array(
|
|
5265
|
+
return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4923
5266
|
});
|
|
4924
5267
|
}
|
|
4925
5268
|
};
|
|
4926
5269
|
|
|
4927
|
-
// ../../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
|
|
4928
5380
|
var EngineAPI = class {
|
|
4929
|
-
baseUrl;
|
|
4930
|
-
apiKey;
|
|
4931
5381
|
fetcher;
|
|
4932
5382
|
constructor(baseUrl, apiKey) {
|
|
4933
|
-
this.baseUrl = new URL(baseUrl);
|
|
4934
|
-
this.apiKey = apiKey;
|
|
4935
5383
|
const options = {
|
|
4936
5384
|
headers: {
|
|
4937
|
-
"Authorization": `API-Key ${
|
|
5385
|
+
"Authorization": `API-Key ${apiKey}`
|
|
4938
5386
|
}
|
|
4939
5387
|
};
|
|
4940
5388
|
this.fetcher = new Fetcher(baseUrl, options);
|
|
@@ -4942,16 +5390,19 @@ var EngineAPI = class {
|
|
|
4942
5390
|
books = new BooksEndpoints(this);
|
|
4943
5391
|
designOptions = new DesignOptionsEndpoints(this);
|
|
4944
5392
|
events = new EventsEndpoints(this);
|
|
5393
|
+
embellishments = new EmbellishmentsEndpoints(this);
|
|
5394
|
+
fonts = new FontsEndpoints(this);
|
|
4945
5395
|
images = new ImagesEndpoints(this);
|
|
4946
|
-
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
4947
5396
|
spreads = new SpreadsEndpoints(this);
|
|
5397
|
+
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
5398
|
+
styles = new StylesEndpoints(this);
|
|
4948
5399
|
};
|
|
4949
5400
|
|
|
4950
5401
|
// ../../core/config.ts
|
|
4951
|
-
var defaultApiHost = "https://api.
|
|
4952
|
-
var defaultWebSocketHost = "wss://socket.
|
|
5402
|
+
var defaultApiHost = "https://api.dev-sls.magicbook.io";
|
|
5403
|
+
var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
|
|
4953
5404
|
|
|
4954
|
-
// ../../core/
|
|
5405
|
+
// ../../core/types/client.ts
|
|
4955
5406
|
var MagicBookClient = class {
|
|
4956
5407
|
constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
|
|
4957
5408
|
this.apiKey = apiKey;
|
|
@@ -4962,7 +5413,7 @@ var MagicBookClient = class {
|
|
|
4962
5413
|
engineAPI;
|
|
4963
5414
|
async createDesignRequest(designRequestProps) {
|
|
4964
5415
|
if (designRequestProps.userId) {
|
|
4965
|
-
const book = await this.engineAPI.books.create(
|
|
5416
|
+
const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
|
|
4966
5417
|
return new DesignRequest(book.id, this, designRequestProps);
|
|
4967
5418
|
} else {
|
|
4968
5419
|
throw new Error("userId is required");
|
|
@@ -4975,10 +5426,17 @@ var MagicBookClient = class {
|
|
|
4975
5426
|
BookDesignRequest,
|
|
4976
5427
|
DesignRequest,
|
|
4977
5428
|
DesignRequestOptions,
|
|
5429
|
+
EmbellishmentsEndpoints,
|
|
5430
|
+
EngineAPI,
|
|
4978
5431
|
ImageServer,
|
|
4979
5432
|
Images,
|
|
4980
5433
|
MagicBookClient,
|
|
5434
|
+
StoryboardItemImageFaceSchema,
|
|
5435
|
+
StoryboardItemImageSchema,
|
|
5436
|
+
StoryboardItemSchema,
|
|
5437
|
+
StylesEndpoints,
|
|
4981
5438
|
assetSchema,
|
|
5439
|
+
backgroundSchema,
|
|
4982
5440
|
bookCreationRequestSchema,
|
|
4983
5441
|
bookDesignRequestSchema,
|
|
4984
5442
|
bookPropsSchema,
|
|
@@ -4986,33 +5444,68 @@ var MagicBookClient = class {
|
|
|
4986
5444
|
canSubmitDesignRequest,
|
|
4987
5445
|
cancelledEventDetail,
|
|
4988
5446
|
canvasSchema,
|
|
5447
|
+
colorSchema,
|
|
5448
|
+
compatibleBackgroundSchema,
|
|
4989
5449
|
coverTypes,
|
|
4990
5450
|
designOptionsSchema,
|
|
4991
|
-
|
|
5451
|
+
embellishmentAnchorsSchema,
|
|
5452
|
+
embellishmentBackgroundListSchema,
|
|
5453
|
+
embellishmentBackgroundSchema,
|
|
5454
|
+
embellishmentBandSchema,
|
|
5455
|
+
embellishmentBaseSchema,
|
|
5456
|
+
embellishmentFrameSchema,
|
|
5457
|
+
embellishmentGraphicStickerSchema,
|
|
4992
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,
|
|
4993
5477
|
imageAssignmentSchema,
|
|
4994
5478
|
imageDensities,
|
|
4995
5479
|
imageDensityOptionSchema,
|
|
4996
|
-
imageDensityOptionServerSchema,
|
|
4997
5480
|
imageDensityOptionsSchema,
|
|
4998
|
-
imageDensityOptionsServerSchema,
|
|
4999
5481
|
imageFilteringLevels,
|
|
5000
5482
|
imageServerSchema,
|
|
5483
|
+
imageServerToImage,
|
|
5001
5484
|
isDesignRequestSubmitted,
|
|
5485
|
+
layoutConstraintSchema,
|
|
5486
|
+
layoutConstraintsClasses,
|
|
5487
|
+
layoutConstraintsSchema,
|
|
5002
5488
|
magicShopBookSchema,
|
|
5003
5489
|
occasions,
|
|
5004
5490
|
pageSchema,
|
|
5005
5491
|
pageTypes,
|
|
5492
|
+
paginatedResponseSchema,
|
|
5006
5493
|
photoMetadataSchema,
|
|
5007
5494
|
photoStripSchema,
|
|
5008
5495
|
positionSchema,
|
|
5009
5496
|
propertySchema,
|
|
5010
5497
|
reportingDataSchema,
|
|
5498
|
+
spreadSchema,
|
|
5499
|
+
spreadServerSchema,
|
|
5011
5500
|
states,
|
|
5012
5501
|
statesToCloseWS,
|
|
5013
5502
|
statesToReport,
|
|
5503
|
+
styleBaseSchema,
|
|
5504
|
+
styleFontSchema,
|
|
5505
|
+
styleSchema,
|
|
5014
5506
|
styles,
|
|
5015
5507
|
textStickerLevels,
|
|
5016
|
-
timeoutEventDetail
|
|
5508
|
+
timeoutEventDetail,
|
|
5509
|
+
whitespaceSchema
|
|
5017
5510
|
});
|
|
5018
5511
|
//# sourceMappingURL=index.cjs.map
|