@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.js
CHANGED
|
@@ -265,7 +265,11 @@ function snakeCaseObjectKeysToCamelCase(snakeCaseObject) {
|
|
|
265
265
|
delete snakeCaseObject[key];
|
|
266
266
|
}
|
|
267
267
|
if (typeof snakeCaseObject[camelCaseKey] === "object") {
|
|
268
|
-
snakeCaseObject[camelCaseKey]
|
|
268
|
+
if (snakeCaseObject[camelCaseKey] === null) {
|
|
269
|
+
snakeCaseObject[camelCaseKey] = null;
|
|
270
|
+
} else {
|
|
271
|
+
snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
|
|
272
|
+
}
|
|
269
273
|
}
|
|
270
274
|
});
|
|
271
275
|
return snakeCaseObject;
|
|
@@ -277,15 +281,6 @@ async function handleAsyncFunction(fn) {
|
|
|
277
281
|
return Promise.reject(error);
|
|
278
282
|
}
|
|
279
283
|
}
|
|
280
|
-
function bindThisToFunctions(instance) {
|
|
281
|
-
for (const name of Object.getOwnPropertyNames(
|
|
282
|
-
Object.getPrototypeOf(instance)
|
|
283
|
-
)) {
|
|
284
|
-
if (typeof instance[name] === "function" && name !== "constructor") {
|
|
285
|
-
instance[name] = instance[name].bind(instance);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
284
|
function cleanJSON(obj) {
|
|
290
285
|
return JSON.parse(JSON.stringify(obj));
|
|
291
286
|
}
|
|
@@ -299,7 +294,7 @@ function getStyleIdBySlug(slug) {
|
|
|
299
294
|
return void 0;
|
|
300
295
|
}
|
|
301
296
|
|
|
302
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
297
|
+
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
303
298
|
var util;
|
|
304
299
|
(function(util2) {
|
|
305
300
|
util2.assertEqual = (val) => val;
|
|
@@ -725,7 +720,7 @@ var ParseStatus = class _ParseStatus {
|
|
|
725
720
|
status.dirty();
|
|
726
721
|
if (value.status === "dirty")
|
|
727
722
|
status.dirty();
|
|
728
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
723
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
729
724
|
finalObject[key.value] = value.value;
|
|
730
725
|
}
|
|
731
726
|
}
|
|
@@ -828,6 +823,7 @@ var ZodType = class {
|
|
|
828
823
|
this.catch = this.catch.bind(this);
|
|
829
824
|
this.describe = this.describe.bind(this);
|
|
830
825
|
this.pipe = this.pipe.bind(this);
|
|
826
|
+
this.readonly = this.readonly.bind(this);
|
|
831
827
|
this.isNullable = this.isNullable.bind(this);
|
|
832
828
|
this.isOptional = this.isOptional.bind(this);
|
|
833
829
|
}
|
|
@@ -1035,6 +1031,9 @@ var ZodType = class {
|
|
|
1035
1031
|
pipe(target) {
|
|
1036
1032
|
return ZodPipeline.create(this, target);
|
|
1037
1033
|
}
|
|
1034
|
+
readonly() {
|
|
1035
|
+
return ZodReadonly.create(this);
|
|
1036
|
+
}
|
|
1038
1037
|
isOptional() {
|
|
1039
1038
|
return this.safeParse(void 0).success;
|
|
1040
1039
|
}
|
|
@@ -1044,10 +1043,11 @@ var ZodType = class {
|
|
|
1044
1043
|
};
|
|
1045
1044
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1046
1045
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
1047
|
-
var ulidRegex =
|
|
1048
|
-
var uuidRegex = /^
|
|
1049
|
-
var emailRegex = /^(
|
|
1050
|
-
var
|
|
1046
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1047
|
+
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;
|
|
1048
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1049
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1050
|
+
var emojiRegex;
|
|
1051
1051
|
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}))$/;
|
|
1052
1052
|
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})))$/;
|
|
1053
1053
|
var datetimeRegex = (args) => {
|
|
@@ -1081,27 +1081,6 @@ function isValidIP(ip, version) {
|
|
|
1081
1081
|
return false;
|
|
1082
1082
|
}
|
|
1083
1083
|
var ZodString = class _ZodString extends ZodType {
|
|
1084
|
-
constructor() {
|
|
1085
|
-
super(...arguments);
|
|
1086
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
1087
|
-
validation,
|
|
1088
|
-
code: ZodIssueCode.invalid_string,
|
|
1089
|
-
...errorUtil.errToObj(message)
|
|
1090
|
-
});
|
|
1091
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
1092
|
-
this.trim = () => new _ZodString({
|
|
1093
|
-
...this._def,
|
|
1094
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
1095
|
-
});
|
|
1096
|
-
this.toLowerCase = () => new _ZodString({
|
|
1097
|
-
...this._def,
|
|
1098
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1099
|
-
});
|
|
1100
|
-
this.toUpperCase = () => new _ZodString({
|
|
1101
|
-
...this._def,
|
|
1102
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
1084
|
_parse(input) {
|
|
1106
1085
|
if (this._def.coerce) {
|
|
1107
1086
|
input.data = String(input.data);
|
|
@@ -1186,6 +1165,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1186
1165
|
status.dirty();
|
|
1187
1166
|
}
|
|
1188
1167
|
} else if (check.kind === "emoji") {
|
|
1168
|
+
if (!emojiRegex) {
|
|
1169
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1170
|
+
}
|
|
1189
1171
|
if (!emojiRegex.test(input.data)) {
|
|
1190
1172
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1191
1173
|
addIssueToContext(ctx, {
|
|
@@ -1322,6 +1304,13 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1322
1304
|
}
|
|
1323
1305
|
return { status: status.value, value: input.data };
|
|
1324
1306
|
}
|
|
1307
|
+
_regex(regex, validation, message) {
|
|
1308
|
+
return this.refinement((data) => regex.test(data), {
|
|
1309
|
+
validation,
|
|
1310
|
+
code: ZodIssueCode.invalid_string,
|
|
1311
|
+
...errorUtil.errToObj(message)
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1325
1314
|
_addCheck(check) {
|
|
1326
1315
|
return new _ZodString({
|
|
1327
1316
|
...this._def,
|
|
@@ -1419,6 +1408,31 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1419
1408
|
...errorUtil.errToObj(message)
|
|
1420
1409
|
});
|
|
1421
1410
|
}
|
|
1411
|
+
/**
|
|
1412
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1413
|
+
* @see {@link ZodString.min}
|
|
1414
|
+
*/
|
|
1415
|
+
nonempty(message) {
|
|
1416
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1417
|
+
}
|
|
1418
|
+
trim() {
|
|
1419
|
+
return new _ZodString({
|
|
1420
|
+
...this._def,
|
|
1421
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
toLowerCase() {
|
|
1425
|
+
return new _ZodString({
|
|
1426
|
+
...this._def,
|
|
1427
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
toUpperCase() {
|
|
1431
|
+
return new _ZodString({
|
|
1432
|
+
...this._def,
|
|
1433
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1422
1436
|
get isDatetime() {
|
|
1423
1437
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1424
1438
|
}
|
|
@@ -3010,6 +3024,12 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3010
3024
|
}
|
|
3011
3025
|
};
|
|
3012
3026
|
var ZodMap = class extends ZodType {
|
|
3027
|
+
get keySchema() {
|
|
3028
|
+
return this._def.keyType;
|
|
3029
|
+
}
|
|
3030
|
+
get valueSchema() {
|
|
3031
|
+
return this._def.valueType;
|
|
3032
|
+
}
|
|
3013
3033
|
_parse(input) {
|
|
3014
3034
|
const { status, ctx } = this._processInputParams(input);
|
|
3015
3035
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -3204,27 +3224,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3204
3224
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
3205
3225
|
const fn = ctx.data;
|
|
3206
3226
|
if (this._def.returns instanceof ZodPromise) {
|
|
3207
|
-
|
|
3227
|
+
const me = this;
|
|
3228
|
+
return OK(async function(...args) {
|
|
3208
3229
|
const error = new ZodError([]);
|
|
3209
|
-
const parsedArgs = await
|
|
3230
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
3210
3231
|
error.addIssue(makeArgsIssue(args, e));
|
|
3211
3232
|
throw error;
|
|
3212
3233
|
});
|
|
3213
|
-
const result = await fn
|
|
3214
|
-
const parsedReturns = await
|
|
3234
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3235
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
3215
3236
|
error.addIssue(makeReturnsIssue(result, e));
|
|
3216
3237
|
throw error;
|
|
3217
3238
|
});
|
|
3218
3239
|
return parsedReturns;
|
|
3219
3240
|
});
|
|
3220
3241
|
} else {
|
|
3221
|
-
|
|
3222
|
-
|
|
3242
|
+
const me = this;
|
|
3243
|
+
return OK(function(...args) {
|
|
3244
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
3223
3245
|
if (!parsedArgs.success) {
|
|
3224
3246
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3225
3247
|
}
|
|
3226
|
-
const result = fn
|
|
3227
|
-
const parsedReturns =
|
|
3248
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3249
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
3228
3250
|
if (!parsedReturns.success) {
|
|
3229
3251
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3230
3252
|
}
|
|
@@ -3446,8 +3468,28 @@ var ZodEffects = class extends ZodType {
|
|
|
3446
3468
|
_parse(input) {
|
|
3447
3469
|
const { status, ctx } = this._processInputParams(input);
|
|
3448
3470
|
const effect = this._def.effect || null;
|
|
3471
|
+
const checkCtx = {
|
|
3472
|
+
addIssue: (arg) => {
|
|
3473
|
+
addIssueToContext(ctx, arg);
|
|
3474
|
+
if (arg.fatal) {
|
|
3475
|
+
status.abort();
|
|
3476
|
+
} else {
|
|
3477
|
+
status.dirty();
|
|
3478
|
+
}
|
|
3479
|
+
},
|
|
3480
|
+
get path() {
|
|
3481
|
+
return ctx.path;
|
|
3482
|
+
}
|
|
3483
|
+
};
|
|
3484
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3449
3485
|
if (effect.type === "preprocess") {
|
|
3450
|
-
const processed = effect.transform(ctx.data);
|
|
3486
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3487
|
+
if (ctx.common.issues.length) {
|
|
3488
|
+
return {
|
|
3489
|
+
status: "dirty",
|
|
3490
|
+
value: ctx.data
|
|
3491
|
+
};
|
|
3492
|
+
}
|
|
3451
3493
|
if (ctx.common.async) {
|
|
3452
3494
|
return Promise.resolve(processed).then((processed2) => {
|
|
3453
3495
|
return this._def.schema._parseAsync({
|
|
@@ -3464,20 +3506,6 @@ var ZodEffects = class extends ZodType {
|
|
|
3464
3506
|
});
|
|
3465
3507
|
}
|
|
3466
3508
|
}
|
|
3467
|
-
const checkCtx = {
|
|
3468
|
-
addIssue: (arg) => {
|
|
3469
|
-
addIssueToContext(ctx, arg);
|
|
3470
|
-
if (arg.fatal) {
|
|
3471
|
-
status.abort();
|
|
3472
|
-
} else {
|
|
3473
|
-
status.dirty();
|
|
3474
|
-
}
|
|
3475
|
-
},
|
|
3476
|
-
get path() {
|
|
3477
|
-
return ctx.path;
|
|
3478
|
-
}
|
|
3479
|
-
};
|
|
3480
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3481
3509
|
if (effect.type === "refinement") {
|
|
3482
3510
|
const executeRefinement = (acc) => {
|
|
3483
3511
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -3761,6 +3789,22 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3761
3789
|
});
|
|
3762
3790
|
}
|
|
3763
3791
|
};
|
|
3792
|
+
var ZodReadonly = class extends ZodType {
|
|
3793
|
+
_parse(input) {
|
|
3794
|
+
const result = this._def.innerType._parse(input);
|
|
3795
|
+
if (isValid(result)) {
|
|
3796
|
+
result.value = Object.freeze(result.value);
|
|
3797
|
+
}
|
|
3798
|
+
return result;
|
|
3799
|
+
}
|
|
3800
|
+
};
|
|
3801
|
+
ZodReadonly.create = (type, params) => {
|
|
3802
|
+
return new ZodReadonly({
|
|
3803
|
+
innerType: type,
|
|
3804
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
3805
|
+
...processCreateParams(params)
|
|
3806
|
+
});
|
|
3807
|
+
};
|
|
3764
3808
|
var custom = (check, params = {}, fatal) => {
|
|
3765
3809
|
if (check)
|
|
3766
3810
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -3814,6 +3858,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3814
3858
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
3815
3859
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
3816
3860
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3861
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3817
3862
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3818
3863
|
var instanceOfType = (cls, params = {
|
|
3819
3864
|
message: `Input not instance of ${cls.name}`
|
|
@@ -3928,6 +3973,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3928
3973
|
BRAND,
|
|
3929
3974
|
ZodBranded,
|
|
3930
3975
|
ZodPipeline,
|
|
3976
|
+
ZodReadonly,
|
|
3931
3977
|
custom,
|
|
3932
3978
|
Schema: ZodType,
|
|
3933
3979
|
ZodSchema: ZodType,
|
|
@@ -3981,7 +4027,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3981
4027
|
ZodError
|
|
3982
4028
|
});
|
|
3983
4029
|
|
|
3984
|
-
// ../../core/
|
|
4030
|
+
// ../../core/types/book.ts
|
|
3985
4031
|
var BookDesignRequest = class {
|
|
3986
4032
|
occasion;
|
|
3987
4033
|
style;
|
|
@@ -4023,7 +4069,7 @@ var bookPropsSchema = z.object({
|
|
|
4023
4069
|
state: z.enum(states).optional(),
|
|
4024
4070
|
guid: z.string().optional(),
|
|
4025
4071
|
cancelled_at: z.string().optional(),
|
|
4026
|
-
mb_client_timeout: z.
|
|
4072
|
+
mb_client_timeout: z.string().optional(),
|
|
4027
4073
|
user_id: z.string().optional(),
|
|
4028
4074
|
revision: z.number().optional()
|
|
4029
4075
|
});
|
|
@@ -4046,7 +4092,7 @@ var Book = class {
|
|
|
4046
4092
|
this.state = props.state;
|
|
4047
4093
|
this.guid = props.guid;
|
|
4048
4094
|
this.cancelled_at = props.cancelled_at;
|
|
4049
|
-
this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
|
|
4095
|
+
this.timeout = props.mb_client_timeout ? parseInt(props.mb_client_timeout) * 1e3 : void 0;
|
|
4050
4096
|
this.user_id = props.user_id;
|
|
4051
4097
|
this.revision = props.revision;
|
|
4052
4098
|
}
|
|
@@ -4060,12 +4106,12 @@ var Book = class {
|
|
|
4060
4106
|
toBookProps() {
|
|
4061
4107
|
return {
|
|
4062
4108
|
...this,
|
|
4063
|
-
mb_client_timeout: this.timeout ? this.timeout / 1e3 : void 0
|
|
4109
|
+
mb_client_timeout: this.timeout ? (this.timeout / 1e3).toString() : void 0
|
|
4064
4110
|
};
|
|
4065
4111
|
}
|
|
4066
4112
|
};
|
|
4067
4113
|
|
|
4068
|
-
// ../../core/
|
|
4114
|
+
// ../../core/types/design-request/image.ts
|
|
4069
4115
|
var Images = class {
|
|
4070
4116
|
// eslint-disable-next-line no-unused-vars
|
|
4071
4117
|
constructor(client, parentId, designRequestState) {
|
|
@@ -4085,7 +4131,10 @@ var Images = class {
|
|
|
4085
4131
|
} else {
|
|
4086
4132
|
this.images.push(image);
|
|
4087
4133
|
this.length = this.images.length;
|
|
4088
|
-
await this.client.engineAPI.images.addToBook(
|
|
4134
|
+
await this.client.engineAPI.images.addToBook({
|
|
4135
|
+
bookId: this.parentId,
|
|
4136
|
+
image: new ImageServer(image)
|
|
4137
|
+
});
|
|
4089
4138
|
return new Promise((resolve) => {
|
|
4090
4139
|
resolve(this.length);
|
|
4091
4140
|
});
|
|
@@ -4126,8 +4175,21 @@ var ImageServer = class {
|
|
|
4126
4175
|
this.filename = image.filename;
|
|
4127
4176
|
}
|
|
4128
4177
|
};
|
|
4178
|
+
function imageServerToImage(imageServer) {
|
|
4179
|
+
return {
|
|
4180
|
+
handle: imageServer.handle,
|
|
4181
|
+
url: imageServer.url,
|
|
4182
|
+
width: imageServer.width,
|
|
4183
|
+
height: imageServer.height,
|
|
4184
|
+
rotation: imageServer.orientation,
|
|
4185
|
+
captureTime: imageServer.taken_at,
|
|
4186
|
+
cameraMake: imageServer.camera_make,
|
|
4187
|
+
cameraModel: imageServer.camera,
|
|
4188
|
+
filename: imageServer.filename
|
|
4189
|
+
};
|
|
4190
|
+
}
|
|
4129
4191
|
|
|
4130
|
-
// ../../core/
|
|
4192
|
+
// ../../core/types/design-request/design-options.ts
|
|
4131
4193
|
var imageDensityOptionSchema = z.object({
|
|
4132
4194
|
maxPageCount: z.number(),
|
|
4133
4195
|
minPageCount: z.number(),
|
|
@@ -4143,23 +4205,8 @@ var imageDensityOptionsSchema = z.object({
|
|
|
4143
4205
|
var designOptionsSchema = z.object({
|
|
4144
4206
|
densities: imageDensityOptionsSchema
|
|
4145
4207
|
});
|
|
4146
|
-
var imageDensityOptionServerSchema = z.object({
|
|
4147
|
-
max_page_count: z.number(),
|
|
4148
|
-
min_page_count: z.number(),
|
|
4149
|
-
max_image_count: z.number(),
|
|
4150
|
-
avg_image_count: z.number(),
|
|
4151
|
-
min_image_count: z.number()
|
|
4152
|
-
});
|
|
4153
|
-
var imageDensityOptionsServerSchema = z.object({
|
|
4154
|
-
high: imageDensityOptionServerSchema,
|
|
4155
|
-
medium: imageDensityOptionServerSchema,
|
|
4156
|
-
low: imageDensityOptionServerSchema
|
|
4157
|
-
});
|
|
4158
|
-
var designOptionsServerSchema = z.object({
|
|
4159
|
-
densities: imageDensityOptionsServerSchema
|
|
4160
|
-
});
|
|
4161
4208
|
|
|
4162
|
-
// ../../core/
|
|
4209
|
+
// ../../core/types/design-request/index.ts
|
|
4163
4210
|
var DesignRequestOptions = {
|
|
4164
4211
|
occasion: occasions,
|
|
4165
4212
|
style: Object.keys(styles).map((key) => parseInt(key)),
|
|
@@ -4214,13 +4261,13 @@ var DesignRequest = class {
|
|
|
4214
4261
|
}
|
|
4215
4262
|
}
|
|
4216
4263
|
async getOptions(imageCount) {
|
|
4217
|
-
const options = designOptionsSchema.parse(
|
|
4218
|
-
await this.client.engineAPI.designOptions.retrieve(
|
|
4219
|
-
this.bookSize,
|
|
4220
|
-
imageCount || this.images.length,
|
|
4221
|
-
this.imageFilteringLevel
|
|
4222
|
-
)
|
|
4223
|
-
)
|
|
4264
|
+
const options = designOptionsSchema.parse(
|
|
4265
|
+
await this.client.engineAPI.designOptions.retrieve({
|
|
4266
|
+
bookSize: this.bookSize,
|
|
4267
|
+
imageCount: imageCount || this.images.length,
|
|
4268
|
+
imageFilteringLevel: this.imageFilteringLevel
|
|
4269
|
+
})
|
|
4270
|
+
);
|
|
4224
4271
|
return options;
|
|
4225
4272
|
}
|
|
4226
4273
|
async submit(submitDesignRequestProps) {
|
|
@@ -4229,9 +4276,12 @@ var DesignRequest = class {
|
|
|
4229
4276
|
} else {
|
|
4230
4277
|
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
4231
4278
|
this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
|
|
4232
|
-
await this.client.engineAPI.books.update(
|
|
4279
|
+
await this.client.engineAPI.books.update({
|
|
4280
|
+
bookId: this.parentId,
|
|
4281
|
+
payload: this.toBook()
|
|
4282
|
+
});
|
|
4233
4283
|
this.updateDesignRequest(
|
|
4234
|
-
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4284
|
+
(await this.client.engineAPI.books.design({ bookId: this.parentId })).toDesignRequestProps()
|
|
4235
4285
|
);
|
|
4236
4286
|
this.getProgress();
|
|
4237
4287
|
return this;
|
|
@@ -4243,7 +4293,10 @@ var DesignRequest = class {
|
|
|
4243
4293
|
} else {
|
|
4244
4294
|
this.guid = guid;
|
|
4245
4295
|
this.updateDesignRequest(
|
|
4246
|
-
(await this.client.engineAPI.books.update(
|
|
4296
|
+
(await this.client.engineAPI.books.update({
|
|
4297
|
+
bookId: this.parentId,
|
|
4298
|
+
payload: this.toBook()
|
|
4299
|
+
})).toDesignRequestProps()
|
|
4247
4300
|
);
|
|
4248
4301
|
return this.guid;
|
|
4249
4302
|
}
|
|
@@ -4257,7 +4310,9 @@ var DesignRequest = class {
|
|
|
4257
4310
|
throw new Error("Design request not submitted");
|
|
4258
4311
|
} else {
|
|
4259
4312
|
this.updateDesignRequest({
|
|
4260
|
-
...(await this.client.engineAPI.books.cancel(
|
|
4313
|
+
...(await this.client.engineAPI.books.cancel({
|
|
4314
|
+
bookId: this.parentId
|
|
4315
|
+
})).toDesignRequestProps(),
|
|
4261
4316
|
state: "cancelled"
|
|
4262
4317
|
});
|
|
4263
4318
|
await this.eventHandler(cancelledEventDetail);
|
|
@@ -4266,22 +4321,31 @@ var DesignRequest = class {
|
|
|
4266
4321
|
}
|
|
4267
4322
|
async getJSON() {
|
|
4268
4323
|
if (this.state === "ready") {
|
|
4269
|
-
return await this.client.engineAPI.books.retrieveGalleon(
|
|
4324
|
+
return await this.client.engineAPI.books.retrieveGalleon({
|
|
4325
|
+
bookId: this.parentId
|
|
4326
|
+
});
|
|
4270
4327
|
} else {
|
|
4271
4328
|
throw new Error("Design request not ready");
|
|
4272
4329
|
}
|
|
4273
4330
|
}
|
|
4274
4331
|
async logEvent(name, data) {
|
|
4275
|
-
return await this.client.engineAPI.events.createBookEvent(
|
|
4332
|
+
return await this.client.engineAPI.events.createBookEvent({
|
|
4333
|
+
bookId: this.parentId,
|
|
4334
|
+
name,
|
|
4335
|
+
data
|
|
4336
|
+
});
|
|
4276
4337
|
}
|
|
4277
4338
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4278
4339
|
const customEvent = new CustomEvent(type, { detail });
|
|
4279
4340
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4280
4341
|
this.webSocket?.close();
|
|
4281
4342
|
if (statesToReport.includes(detail.slug)) {
|
|
4282
|
-
await this.client.engineAPI.books.report(
|
|
4283
|
-
|
|
4284
|
-
|
|
4343
|
+
await this.client.engineAPI.books.report({
|
|
4344
|
+
bookId: this.parentId,
|
|
4345
|
+
report: {
|
|
4346
|
+
error: detail.slug === "error" ? "design" : "timeout",
|
|
4347
|
+
step: this.state
|
|
4348
|
+
}
|
|
4285
4349
|
});
|
|
4286
4350
|
}
|
|
4287
4351
|
}
|
|
@@ -4334,7 +4398,7 @@ var DesignRequest = class {
|
|
|
4334
4398
|
}
|
|
4335
4399
|
};
|
|
4336
4400
|
|
|
4337
|
-
// ../../core/
|
|
4401
|
+
// ../../core/types/galleon.ts
|
|
4338
4402
|
var imageAssignmentSchema = z.object({
|
|
4339
4403
|
photoRefId: z.string(),
|
|
4340
4404
|
finalCrop: z.array(z.number())
|
|
@@ -4413,128 +4477,357 @@ var bookCreationRequestSchema = z.object({
|
|
|
4413
4477
|
reportingData: reportingDataSchema
|
|
4414
4478
|
});
|
|
4415
4479
|
|
|
4416
|
-
// ../../core/
|
|
4480
|
+
// ../../core/types/engine-api/endpoints/books.ts
|
|
4417
4481
|
var BooksEndpoints = class {
|
|
4418
4482
|
// eslint-disable-next-line no-unused-vars
|
|
4419
4483
|
constructor(engineAPI) {
|
|
4420
4484
|
this.engineAPI = engineAPI;
|
|
4421
|
-
bindThisToFunctions(this);
|
|
4422
4485
|
}
|
|
4423
|
-
create(book) {
|
|
4486
|
+
create({ book, qs }) {
|
|
4424
4487
|
return handleAsyncFunction(async () => {
|
|
4425
4488
|
const res = await this.engineAPI.fetcher.call({
|
|
4426
4489
|
path: "/v1/books",
|
|
4427
4490
|
options: {
|
|
4428
4491
|
method: "POST",
|
|
4429
4492
|
body: cleanJSON(book)
|
|
4430
|
-
}
|
|
4493
|
+
},
|
|
4494
|
+
qs
|
|
4431
4495
|
});
|
|
4432
|
-
bookPropsSchema.safeParse(res);
|
|
4433
4496
|
return new Book(res);
|
|
4434
4497
|
});
|
|
4435
4498
|
}
|
|
4436
|
-
retrieve(bookId) {
|
|
4499
|
+
retrieve({ bookId, qs }) {
|
|
4437
4500
|
return handleAsyncFunction(async () => {
|
|
4438
|
-
const res = await this.engineAPI.fetcher.call({
|
|
4439
|
-
|
|
4440
|
-
|
|
4501
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4502
|
+
path: `/v1/books/${bookId}`,
|
|
4503
|
+
qs
|
|
4504
|
+
});
|
|
4505
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4506
|
+
return new Book(bookProps);
|
|
4441
4507
|
});
|
|
4442
4508
|
}
|
|
4443
|
-
update(bookId,
|
|
4509
|
+
update({ bookId, payload, qs }) {
|
|
4444
4510
|
return handleAsyncFunction(async () => {
|
|
4445
4511
|
const res = await this.engineAPI.fetcher.call({
|
|
4446
4512
|
path: `/v1/books/${bookId}`,
|
|
4447
4513
|
options: {
|
|
4448
4514
|
method: "PUT",
|
|
4449
|
-
body: cleanJSON(
|
|
4450
|
-
}
|
|
4515
|
+
body: cleanJSON(payload)
|
|
4516
|
+
},
|
|
4517
|
+
qs
|
|
4518
|
+
});
|
|
4519
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4520
|
+
return new Book(bookProps);
|
|
4521
|
+
});
|
|
4522
|
+
}
|
|
4523
|
+
delete({ bookId, qs }) {
|
|
4524
|
+
return handleAsyncFunction(async () => {
|
|
4525
|
+
await this.engineAPI.fetcher.call({
|
|
4526
|
+
path: `/v1/books/${bookId}`,
|
|
4527
|
+
options: { method: "DELETE" },
|
|
4528
|
+
qs
|
|
4451
4529
|
});
|
|
4452
|
-
bookPropsSchema.safeParse(res);
|
|
4453
|
-
return new Book(res);
|
|
4454
4530
|
});
|
|
4455
4531
|
}
|
|
4456
|
-
design(bookId) {
|
|
4532
|
+
design({ bookId, qs }) {
|
|
4457
4533
|
return handleAsyncFunction(async () => {
|
|
4458
4534
|
const res = await this.engineAPI.fetcher.call({
|
|
4459
4535
|
path: `/v1/books/${bookId}/design`,
|
|
4460
|
-
options: { method: "POST" }
|
|
4536
|
+
options: { method: "POST" },
|
|
4537
|
+
qs
|
|
4461
4538
|
});
|
|
4462
|
-
bookPropsSchema.
|
|
4463
|
-
return new Book(
|
|
4539
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4540
|
+
return new Book(bookProps);
|
|
4464
4541
|
});
|
|
4465
4542
|
}
|
|
4466
|
-
cancel(bookId) {
|
|
4543
|
+
cancel({ bookId, qs }) {
|
|
4467
4544
|
return handleAsyncFunction(async () => {
|
|
4468
4545
|
const res = await this.engineAPI.fetcher.call({
|
|
4469
4546
|
path: `/v1/books/${bookId}/cancel`,
|
|
4470
|
-
options: { method: "POST" }
|
|
4547
|
+
options: { method: "POST" },
|
|
4548
|
+
qs
|
|
4471
4549
|
});
|
|
4472
|
-
bookPropsSchema.
|
|
4473
|
-
return new Book(
|
|
4550
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4551
|
+
return new Book(bookProps);
|
|
4552
|
+
});
|
|
4553
|
+
}
|
|
4554
|
+
retrieveGalleon({ bookId, qs }) {
|
|
4555
|
+
return handleAsyncFunction(async () => {
|
|
4556
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4557
|
+
path: `/v1/books/${bookId}/format/galleon`,
|
|
4558
|
+
qs
|
|
4559
|
+
});
|
|
4560
|
+
return bookCreationRequestSchema.parse(res);
|
|
4474
4561
|
});
|
|
4475
4562
|
}
|
|
4476
|
-
report(bookId, report) {
|
|
4563
|
+
report({ bookId, report, qs }) {
|
|
4477
4564
|
return handleAsyncFunction(async () => {
|
|
4478
4565
|
await this.engineAPI.fetcher.call({
|
|
4479
4566
|
path: `/v1/books/${bookId}/report`,
|
|
4480
4567
|
options: {
|
|
4481
4568
|
method: "POST",
|
|
4482
4569
|
body: cleanJSON(report)
|
|
4483
|
-
}
|
|
4570
|
+
},
|
|
4571
|
+
qs
|
|
4484
4572
|
});
|
|
4485
4573
|
});
|
|
4486
4574
|
}
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4575
|
+
};
|
|
4576
|
+
|
|
4577
|
+
// ../../core/types/engine-api/endpoints/design-options.ts
|
|
4578
|
+
var DesignOptionsEndpoints = class {
|
|
4579
|
+
// eslint-disable-next-line no-unused-vars
|
|
4580
|
+
constructor(engineAPI) {
|
|
4581
|
+
this.engineAPI = engineAPI;
|
|
4494
4582
|
}
|
|
4495
|
-
|
|
4583
|
+
retrieve(props) {
|
|
4496
4584
|
return handleAsyncFunction(async () => {
|
|
4497
4585
|
const res = await this.engineAPI.fetcher.call({
|
|
4498
|
-
|
|
4586
|
+
// eslint-disable-next-line max-len
|
|
4587
|
+
path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
|
|
4588
|
+
qs: props.qs
|
|
4499
4589
|
});
|
|
4500
|
-
return
|
|
4590
|
+
return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4501
4591
|
});
|
|
4502
4592
|
}
|
|
4503
4593
|
};
|
|
4504
4594
|
|
|
4505
|
-
// ../../core/
|
|
4506
|
-
var
|
|
4595
|
+
// ../../core/types/embellishment.ts
|
|
4596
|
+
var embellishmentTypes = [
|
|
4597
|
+
"background",
|
|
4598
|
+
"band",
|
|
4599
|
+
"strip",
|
|
4600
|
+
"page-corner",
|
|
4601
|
+
"photo-corner",
|
|
4602
|
+
"frame",
|
|
4603
|
+
"t-point",
|
|
4604
|
+
"luggage-tag",
|
|
4605
|
+
"stamp",
|
|
4606
|
+
"tape",
|
|
4607
|
+
"postcard",
|
|
4608
|
+
"top-sticker",
|
|
4609
|
+
"bottom-sticker",
|
|
4610
|
+
"graphic-sticker",
|
|
4611
|
+
"text-sticker"
|
|
4612
|
+
];
|
|
4613
|
+
var embellishmentOrientations = [
|
|
4614
|
+
"top",
|
|
4615
|
+
"bottom",
|
|
4616
|
+
"left",
|
|
4617
|
+
"right",
|
|
4618
|
+
"top-left",
|
|
4619
|
+
"top-right",
|
|
4620
|
+
"bottom-right",
|
|
4621
|
+
"bottom-left"
|
|
4622
|
+
];
|
|
4623
|
+
var embellishmentThicknesses = ["thin", "thick", "normal"];
|
|
4624
|
+
var embellishmentStackings = ["front", "back"];
|
|
4625
|
+
var embellishmentAnchorsSchema = z.object({
|
|
4626
|
+
x0: z.number(),
|
|
4627
|
+
x1: z.number(),
|
|
4628
|
+
y0: z.number(),
|
|
4629
|
+
y1: z.number()
|
|
4630
|
+
});
|
|
4631
|
+
var embellishmentPhotoCornerAnchorsSchema = z.object({
|
|
4632
|
+
x0: z.number(),
|
|
4633
|
+
y0: z.number()
|
|
4634
|
+
});
|
|
4635
|
+
var embellishmentBaseSchema = z.object({
|
|
4636
|
+
id: z.string(),
|
|
4637
|
+
active: z.boolean(),
|
|
4638
|
+
url: z.string(),
|
|
4639
|
+
name: z.string(),
|
|
4640
|
+
pattern: z.string(),
|
|
4641
|
+
primaryColor: z.string(),
|
|
4642
|
+
margin: z.number(),
|
|
4643
|
+
width: z.number(),
|
|
4644
|
+
height: z.number(),
|
|
4645
|
+
style: z.string()
|
|
4646
|
+
});
|
|
4647
|
+
var embellishmentTextStickerSchema = embellishmentBaseSchema.extend({
|
|
4648
|
+
type: z.literal("text-sticker"),
|
|
4649
|
+
text: z.string(),
|
|
4650
|
+
isSpecific: z.boolean(),
|
|
4651
|
+
minSurface: z.number(),
|
|
4652
|
+
maxSurface: z.number()
|
|
4653
|
+
});
|
|
4654
|
+
var embellishmentTPointSchema = embellishmentBaseSchema.extend({
|
|
4655
|
+
type: z.literal("t-point"),
|
|
4656
|
+
minSurface: z.number(),
|
|
4657
|
+
maxSurface: z.number()
|
|
4658
|
+
});
|
|
4659
|
+
var embellishmentGraphicStickerSchema = embellishmentBaseSchema.extend({
|
|
4660
|
+
type: z.literal("graphic-sticker"),
|
|
4661
|
+
minSurface: z.number(),
|
|
4662
|
+
maxSurface: z.number(),
|
|
4663
|
+
hFlippable: z.boolean(),
|
|
4664
|
+
vFlippable: z.boolean()
|
|
4665
|
+
});
|
|
4666
|
+
var embellishmentStampSchema = embellishmentBaseSchema.extend({
|
|
4667
|
+
type: z.literal("stamp"),
|
|
4668
|
+
minSurface: z.number(),
|
|
4669
|
+
maxSurface: z.number(),
|
|
4670
|
+
hFlippable: z.boolean(),
|
|
4671
|
+
vFlippable: z.boolean()
|
|
4672
|
+
});
|
|
4673
|
+
var embellishmentTapeSchema = embellishmentBaseSchema.extend({
|
|
4674
|
+
type: z.literal("tape"),
|
|
4675
|
+
minSurface: z.number(),
|
|
4676
|
+
maxSurface: z.number(),
|
|
4677
|
+
hFlippable: z.boolean(),
|
|
4678
|
+
vFlippable: z.boolean()
|
|
4679
|
+
});
|
|
4680
|
+
var embellishmentPostcardSchema = embellishmentBaseSchema.extend({
|
|
4681
|
+
type: z.literal("postcard"),
|
|
4682
|
+
minSurface: z.number(),
|
|
4683
|
+
maxSurface: z.number(),
|
|
4684
|
+
hFlippable: z.boolean(),
|
|
4685
|
+
vFlippable: z.boolean()
|
|
4686
|
+
});
|
|
4687
|
+
var embellishmentBandSchema = embellishmentBaseSchema.extend({
|
|
4688
|
+
type: z.literal("band"),
|
|
4689
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4690
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4691
|
+
thickness: z.enum(embellishmentThicknesses)
|
|
4692
|
+
});
|
|
4693
|
+
var embellishmentStripSchema = embellishmentBaseSchema.extend({
|
|
4694
|
+
type: z.literal("strip"),
|
|
4695
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4696
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4697
|
+
thickness: z.enum(embellishmentThicknesses)
|
|
4698
|
+
});
|
|
4699
|
+
var embellishmentPhotoCornerSchema = embellishmentBaseSchema.extend({
|
|
4700
|
+
type: z.literal("photo-corner"),
|
|
4701
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4702
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4703
|
+
anchors: embellishmentPhotoCornerAnchorsSchema,
|
|
4704
|
+
stacking: z.enum(embellishmentStackings),
|
|
4705
|
+
scale: z.number()
|
|
4706
|
+
});
|
|
4707
|
+
var embellishmentPageCornerSchema = embellishmentBaseSchema.extend({
|
|
4708
|
+
type: z.literal("page-corner"),
|
|
4709
|
+
orientation: z.enum(embellishmentOrientations),
|
|
4710
|
+
orientations: z.array(z.enum(embellishmentOrientations)),
|
|
4711
|
+
scale: z.number()
|
|
4712
|
+
});
|
|
4713
|
+
var embellishmentFrameSchema = embellishmentBaseSchema.extend({
|
|
4714
|
+
type: z.literal("frame"),
|
|
4715
|
+
rotatable: z.boolean(),
|
|
4716
|
+
anchors: embellishmentAnchorsSchema,
|
|
4717
|
+
stacking: z.enum(embellishmentStackings)
|
|
4718
|
+
});
|
|
4719
|
+
var embellishmentBackgroundListSchema = embellishmentBaseSchema.extend({
|
|
4720
|
+
type: z.literal("background"),
|
|
4721
|
+
rotatable: z.boolean()
|
|
4722
|
+
});
|
|
4723
|
+
var embellishmentBackgroundSchema = embellishmentBackgroundListSchema.extend({
|
|
4724
|
+
colors: z.record(z.unknown()),
|
|
4725
|
+
backgrounds: z.record(z.unknown())
|
|
4726
|
+
});
|
|
4727
|
+
var embellishmentSchemasArray = [
|
|
4728
|
+
embellishmentBackgroundSchema,
|
|
4729
|
+
embellishmentFrameSchema,
|
|
4730
|
+
embellishmentTextStickerSchema,
|
|
4731
|
+
embellishmentBandSchema,
|
|
4732
|
+
embellishmentStripSchema,
|
|
4733
|
+
embellishmentPageCornerSchema,
|
|
4734
|
+
embellishmentPhotoCornerSchema,
|
|
4735
|
+
embellishmentTPointSchema,
|
|
4736
|
+
embellishmentStampSchema,
|
|
4737
|
+
embellishmentTapeSchema,
|
|
4738
|
+
embellishmentPostcardSchema,
|
|
4739
|
+
embellishmentGraphicStickerSchema
|
|
4740
|
+
];
|
|
4741
|
+
var embellishmentSchemas = z.union(
|
|
4742
|
+
[...embellishmentSchemasArray]
|
|
4743
|
+
);
|
|
4744
|
+
var embellishmentUpdateSchemas = z.union(
|
|
4745
|
+
[
|
|
4746
|
+
...embellishmentSchemasArray.map((schema) => schema.partial().optional())
|
|
4747
|
+
]
|
|
4748
|
+
);
|
|
4749
|
+
var embellishmentListSchemasArray = [...embellishmentSchemasArray];
|
|
4750
|
+
embellishmentListSchemasArray.shift();
|
|
4751
|
+
embellishmentListSchemasArray.push(embellishmentBackgroundListSchema);
|
|
4752
|
+
var embellishmentListSchemas = z.union(
|
|
4753
|
+
[...embellishmentListSchemasArray]
|
|
4754
|
+
);
|
|
4755
|
+
|
|
4756
|
+
// ../../core/types/engine-api/pagination.ts
|
|
4757
|
+
function paginatedResponseSchema(arrayOf) {
|
|
4758
|
+
return z.object({
|
|
4759
|
+
count: z.number(),
|
|
4760
|
+
nextCursor: z.string().nullable(),
|
|
4761
|
+
previousCursor: z.string().optional(),
|
|
4762
|
+
results: z.array(arrayOf)
|
|
4763
|
+
});
|
|
4764
|
+
}
|
|
4765
|
+
|
|
4766
|
+
// ../../core/types/engine-api/endpoints/embellishments.ts
|
|
4767
|
+
var embellishmentPaginatedSchema = paginatedResponseSchema(embellishmentListSchemas);
|
|
4768
|
+
var EmbellishmentsEndpoints = class {
|
|
4507
4769
|
// eslint-disable-next-line no-unused-vars
|
|
4508
4770
|
constructor(engineAPI) {
|
|
4509
4771
|
this.engineAPI = engineAPI;
|
|
4510
|
-
bindThisToFunctions(this);
|
|
4511
4772
|
}
|
|
4512
|
-
|
|
4773
|
+
list({ styleSlug, qs }) {
|
|
4513
4774
|
return handleAsyncFunction(async () => {
|
|
4514
4775
|
const res = await this.engineAPI.fetcher.call({
|
|
4515
|
-
|
|
4516
|
-
|
|
4776
|
+
path: `/v1/embellishments/style/${styleSlug}`,
|
|
4777
|
+
qs
|
|
4778
|
+
});
|
|
4779
|
+
return embellishmentPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4782
|
+
retrieve({ styleSlug, embellishmentId, qs }) {
|
|
4783
|
+
return handleAsyncFunction(async () => {
|
|
4784
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4785
|
+
path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
|
|
4786
|
+
qs
|
|
4787
|
+
});
|
|
4788
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4789
|
+
});
|
|
4790
|
+
}
|
|
4791
|
+
update({ styleSlug, embellishmentId, payload }) {
|
|
4792
|
+
return handleAsyncFunction(async () => {
|
|
4793
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4794
|
+
path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
|
|
4795
|
+
options: {
|
|
4796
|
+
method: "PUT",
|
|
4797
|
+
body: cleanJSON(camelCaseObjectKeysToSnakeCase({ ...payload }))
|
|
4798
|
+
}
|
|
4517
4799
|
});
|
|
4518
|
-
return
|
|
4800
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4519
4801
|
});
|
|
4520
4802
|
}
|
|
4521
4803
|
};
|
|
4522
4804
|
|
|
4523
|
-
// ../../core/
|
|
4805
|
+
// ../../core/types/event.ts
|
|
4524
4806
|
var eventContextSchema = z.record(z.string(), z.unknown()).optional();
|
|
4525
4807
|
var eventSchema = z.object({
|
|
4526
4808
|
name: z.string(),
|
|
4527
|
-
context: eventContextSchema
|
|
4809
|
+
context: eventContextSchema,
|
|
4810
|
+
bookId: z.string(),
|
|
4811
|
+
createdAt: z.string()
|
|
4528
4812
|
});
|
|
4529
4813
|
|
|
4530
|
-
// ../../core/
|
|
4814
|
+
// ../../core/types/engine-api/endpoints/events.ts
|
|
4815
|
+
var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
|
|
4531
4816
|
var EventsEndpoints = class {
|
|
4532
4817
|
// eslint-disable-next-line no-unused-vars
|
|
4533
4818
|
constructor(engineAPI) {
|
|
4534
4819
|
this.engineAPI = engineAPI;
|
|
4535
|
-
bindThisToFunctions(this);
|
|
4536
4820
|
}
|
|
4537
|
-
|
|
4821
|
+
listBookEvents({ bookId, qs }) {
|
|
4822
|
+
return handleAsyncFunction(async () => {
|
|
4823
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4824
|
+
path: `/v1/events/book/${bookId}`,
|
|
4825
|
+
qs
|
|
4826
|
+
});
|
|
4827
|
+
return eventPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4828
|
+
});
|
|
4829
|
+
}
|
|
4830
|
+
createBookEvent({ name, data, bookId, qs }) {
|
|
4538
4831
|
return handleAsyncFunction(async () => {
|
|
4539
4832
|
const body = {
|
|
4540
4833
|
name
|
|
@@ -4545,14 +4838,26 @@ var EventsEndpoints = class {
|
|
|
4545
4838
|
options: {
|
|
4546
4839
|
method: "POST",
|
|
4547
4840
|
body: cleanJSON(body)
|
|
4548
|
-
}
|
|
4841
|
+
},
|
|
4842
|
+
qs
|
|
4843
|
+
});
|
|
4844
|
+
return eventSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4847
|
+
deleteBookEvent({ name, bookId, qs }) {
|
|
4848
|
+
return handleAsyncFunction(async () => {
|
|
4849
|
+
await this.engineAPI.fetcher.call({
|
|
4850
|
+
path: `/v1/events/book/${bookId}/name/${name}`,
|
|
4851
|
+
options: {
|
|
4852
|
+
method: "DELETE"
|
|
4853
|
+
},
|
|
4854
|
+
qs
|
|
4549
4855
|
});
|
|
4550
|
-
return eventSchema.parse(res);
|
|
4551
4856
|
});
|
|
4552
4857
|
}
|
|
4553
4858
|
};
|
|
4554
4859
|
|
|
4555
|
-
// ../../core/
|
|
4860
|
+
// ../../core/types/fetcher.ts
|
|
4556
4861
|
var baseOptions = {
|
|
4557
4862
|
headers: {
|
|
4558
4863
|
"Content-Type": "application/json"
|
|
@@ -4573,12 +4878,14 @@ var Fetcher = class {
|
|
|
4573
4878
|
}
|
|
4574
4879
|
const baseOptions2 = { ...this.options };
|
|
4575
4880
|
const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
|
|
4576
|
-
const
|
|
4577
|
-
|
|
4881
|
+
const qs = props.qs ? `?${props.qs}` : "";
|
|
4882
|
+
const res = await fetch(this.cleanUrl(`${this.baseUrl}${props.path}${qs}`), options);
|
|
4883
|
+
if (res.status >= 200 && res.status < 300 && res.ok) {
|
|
4884
|
+
const result = await res.text();
|
|
4578
4885
|
try {
|
|
4579
|
-
return
|
|
4886
|
+
return JSON.parse(result);
|
|
4580
4887
|
} catch (error) {
|
|
4581
|
-
return
|
|
4888
|
+
return result;
|
|
4582
4889
|
}
|
|
4583
4890
|
} else {
|
|
4584
4891
|
let detail = res.statusText;
|
|
@@ -4593,70 +4900,102 @@ var Fetcher = class {
|
|
|
4593
4900
|
}
|
|
4594
4901
|
}
|
|
4595
4902
|
cleanUrl(url) {
|
|
4596
|
-
return url.replaceAll(" ", "").trim();
|
|
4903
|
+
return url.replace(/\/\//g, "/").replaceAll(" ", "").trim();
|
|
4904
|
+
}
|
|
4905
|
+
};
|
|
4906
|
+
|
|
4907
|
+
// ../../core/types/font.ts
|
|
4908
|
+
var fontRoles = ["title", "subtitle", "caption"];
|
|
4909
|
+
var fontSchema = z.object({
|
|
4910
|
+
slug: z.string(),
|
|
4911
|
+
family: z.string()
|
|
4912
|
+
});
|
|
4913
|
+
var styleFontSchema = fontSchema.extend({
|
|
4914
|
+
role: z.enum(fontRoles)
|
|
4915
|
+
});
|
|
4916
|
+
|
|
4917
|
+
// ../../core/types/engine-api/endpoints/fonts.ts
|
|
4918
|
+
var fontPaginatedSchema = paginatedResponseSchema(fontSchema);
|
|
4919
|
+
var FontsEndpoints = class {
|
|
4920
|
+
// eslint-disable-next-line no-unused-vars
|
|
4921
|
+
constructor(engineAPI) {
|
|
4922
|
+
this.engineAPI = engineAPI;
|
|
4923
|
+
}
|
|
4924
|
+
list(props) {
|
|
4925
|
+
return handleAsyncFunction(async () => {
|
|
4926
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4927
|
+
path: "/v1/fonts",
|
|
4928
|
+
qs: props?.qs
|
|
4929
|
+
});
|
|
4930
|
+
return fontPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4931
|
+
});
|
|
4597
4932
|
}
|
|
4598
4933
|
};
|
|
4599
4934
|
|
|
4600
|
-
// ../../core/
|
|
4935
|
+
// ../../core/types/engine-api/endpoints/images.ts
|
|
4601
4936
|
var ImagesEndpoints = class {
|
|
4602
4937
|
// eslint-disable-next-line no-unused-vars
|
|
4603
4938
|
constructor(engineAPI) {
|
|
4604
4939
|
this.engineAPI = engineAPI;
|
|
4605
|
-
bindThisToFunctions(this);
|
|
4606
4940
|
}
|
|
4607
|
-
list(bookId) {
|
|
4941
|
+
list({ bookId, qs }) {
|
|
4608
4942
|
return handleAsyncFunction(async () => {
|
|
4609
4943
|
const res = await this.engineAPI.fetcher.call({
|
|
4610
|
-
path: `/v1/images/book/${bookId}
|
|
4944
|
+
path: `/v1/images/book/${bookId}`,
|
|
4945
|
+
qs
|
|
4611
4946
|
});
|
|
4612
4947
|
return z.array(imageServerSchema).parse(res);
|
|
4613
4948
|
});
|
|
4614
4949
|
}
|
|
4615
|
-
|
|
4950
|
+
addToBook({ bookId, image, qs }) {
|
|
4616
4951
|
return handleAsyncFunction(async () => {
|
|
4617
4952
|
const res = await this.engineAPI.fetcher.call({
|
|
4618
|
-
path: `/v1/images
|
|
4953
|
+
path: `/v1/images/book/${bookId}`,
|
|
4954
|
+
options: {
|
|
4955
|
+
method: "POST",
|
|
4956
|
+
body: cleanJSON(image)
|
|
4957
|
+
},
|
|
4958
|
+
qs
|
|
4619
4959
|
});
|
|
4620
4960
|
return imageServerSchema.parse(res);
|
|
4621
4961
|
});
|
|
4622
4962
|
}
|
|
4623
|
-
|
|
4963
|
+
retrieve({ bookId, imageId, qs }) {
|
|
4624
4964
|
return handleAsyncFunction(async () => {
|
|
4625
4965
|
const res = await this.engineAPI.fetcher.call({
|
|
4626
4966
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4627
|
-
|
|
4628
|
-
method: "PUT",
|
|
4629
|
-
body: cleanJSON(image)
|
|
4630
|
-
}
|
|
4967
|
+
qs
|
|
4631
4968
|
});
|
|
4632
4969
|
return imageServerSchema.parse(res);
|
|
4633
4970
|
});
|
|
4634
4971
|
}
|
|
4635
|
-
|
|
4972
|
+
update({ bookId, imageId, payload, qs }) {
|
|
4636
4973
|
return handleAsyncFunction(async () => {
|
|
4637
|
-
await this.engineAPI.fetcher.call({
|
|
4974
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4638
4975
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4639
4976
|
options: {
|
|
4640
|
-
method: "
|
|
4641
|
-
|
|
4977
|
+
method: "PUT",
|
|
4978
|
+
body: cleanJSON(payload)
|
|
4979
|
+
},
|
|
4980
|
+
qs
|
|
4642
4981
|
});
|
|
4982
|
+
return imageServerSchema.parse(res);
|
|
4643
4983
|
});
|
|
4644
4984
|
}
|
|
4645
|
-
|
|
4985
|
+
delete({ bookId, imageId, qs }) {
|
|
4646
4986
|
return handleAsyncFunction(async () => {
|
|
4647
|
-
|
|
4648
|
-
path: `/v1/images/book/${bookId}
|
|
4987
|
+
await this.engineAPI.fetcher.call({
|
|
4988
|
+
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4649
4989
|
options: {
|
|
4650
|
-
method: "
|
|
4651
|
-
|
|
4652
|
-
|
|
4990
|
+
method: "DELETE"
|
|
4991
|
+
},
|
|
4992
|
+
qs
|
|
4653
4993
|
});
|
|
4654
|
-
return imageServerSchema.parse(res);
|
|
4655
4994
|
});
|
|
4656
4995
|
}
|
|
4657
4996
|
};
|
|
4658
4997
|
|
|
4659
|
-
// ../../core/
|
|
4998
|
+
// ../../core/types/spread.ts
|
|
4660
4999
|
var spreadServerSchema = z.object({
|
|
4661
5000
|
id: z.string().optional(),
|
|
4662
5001
|
book_id: z.string(),
|
|
@@ -4690,79 +5029,70 @@ var spreadSchema = z.object({
|
|
|
4690
5029
|
url: z.string().nullable().optional()
|
|
4691
5030
|
});
|
|
4692
5031
|
|
|
4693
|
-
// ../../core/
|
|
5032
|
+
// ../../core/types/engine-api/endpoints/spreads.ts
|
|
4694
5033
|
var SpreadsEndpoints = class {
|
|
4695
5034
|
// eslint-disable-next-line no-unused-vars
|
|
4696
5035
|
constructor(engineAPI) {
|
|
4697
5036
|
this.engineAPI = engineAPI;
|
|
4698
|
-
bindThisToFunctions(this);
|
|
4699
5037
|
}
|
|
4700
|
-
list(bookId) {
|
|
5038
|
+
list({ bookId, qs }) {
|
|
4701
5039
|
return handleAsyncFunction(async () => {
|
|
4702
5040
|
const res = await this.engineAPI.fetcher.call({
|
|
4703
|
-
path: `/v1/spreads/book/${bookId}
|
|
5041
|
+
path: `/v1/spreads/book/${bookId}`,
|
|
5042
|
+
qs
|
|
4704
5043
|
});
|
|
4705
|
-
return z.array(
|
|
5044
|
+
return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4706
5045
|
});
|
|
4707
5046
|
}
|
|
4708
|
-
create(bookId, spread) {
|
|
5047
|
+
create({ bookId, spread, qs }) {
|
|
4709
5048
|
return handleAsyncFunction(async () => {
|
|
4710
5049
|
const res = await this.engineAPI.fetcher.call({
|
|
4711
5050
|
path: `/v1/spreads/book/${bookId}`,
|
|
4712
5051
|
options: {
|
|
4713
5052
|
method: "POST",
|
|
4714
5053
|
body: cleanJSON(spread)
|
|
4715
|
-
}
|
|
5054
|
+
},
|
|
5055
|
+
qs
|
|
4716
5056
|
});
|
|
4717
|
-
return
|
|
5057
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4718
5058
|
});
|
|
4719
5059
|
}
|
|
4720
|
-
retrieve(spreadId,
|
|
5060
|
+
retrieve({ bookId, spreadId, qs }) {
|
|
4721
5061
|
return handleAsyncFunction(async () => {
|
|
4722
5062
|
const res = await this.engineAPI.fetcher.call({
|
|
4723
|
-
path: `/v1/spreads/${spreadId}/book/${bookId}
|
|
5063
|
+
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5064
|
+
qs
|
|
4724
5065
|
});
|
|
4725
|
-
return
|
|
5066
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4726
5067
|
});
|
|
4727
5068
|
}
|
|
4728
|
-
update(spreadId,
|
|
5069
|
+
update({ bookId, spreadId, payload, qs }) {
|
|
4729
5070
|
return handleAsyncFunction(async () => {
|
|
4730
5071
|
const res = await this.engineAPI.fetcher.call({
|
|
4731
5072
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4732
5073
|
options: {
|
|
4733
5074
|
method: "PUT",
|
|
4734
|
-
body: cleanJSON(
|
|
4735
|
-
}
|
|
5075
|
+
body: cleanJSON(payload)
|
|
5076
|
+
},
|
|
5077
|
+
qs
|
|
4736
5078
|
});
|
|
4737
|
-
return
|
|
5079
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4738
5080
|
});
|
|
4739
5081
|
}
|
|
4740
|
-
delete(spreadId,
|
|
5082
|
+
delete({ bookId, spreadId, qs }) {
|
|
4741
5083
|
return handleAsyncFunction(async () => {
|
|
4742
5084
|
await this.engineAPI.fetcher.call({
|
|
4743
5085
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4744
5086
|
options: {
|
|
4745
5087
|
method: "DELETE"
|
|
4746
|
-
}
|
|
5088
|
+
},
|
|
5089
|
+
qs
|
|
4747
5090
|
});
|
|
4748
5091
|
});
|
|
4749
5092
|
}
|
|
4750
5093
|
};
|
|
4751
5094
|
|
|
4752
|
-
// ../../core/
|
|
4753
|
-
var StoryboardItemImageFaceServerSchema = z.object({
|
|
4754
|
-
score: z.number(),
|
|
4755
|
-
bounding_box: z.object({
|
|
4756
|
-
x: z.number(),
|
|
4757
|
-
y: z.number(),
|
|
4758
|
-
width: z.number(),
|
|
4759
|
-
height: z.number()
|
|
4760
|
-
}),
|
|
4761
|
-
size: z.number(),
|
|
4762
|
-
eyes_open_score: z.number(),
|
|
4763
|
-
smile_score: z.number(),
|
|
4764
|
-
facing_camera_score: z.number()
|
|
4765
|
-
});
|
|
5095
|
+
// ../../core/types/storyboard-item.ts
|
|
4766
5096
|
var StoryboardItemImageFaceSchema = z.object({
|
|
4767
5097
|
score: z.number(),
|
|
4768
5098
|
boundingBox: z.object({
|
|
@@ -4776,27 +5106,14 @@ var StoryboardItemImageFaceSchema = z.object({
|
|
|
4776
5106
|
smileScore: z.number(),
|
|
4777
5107
|
facingCameraScore: z.number()
|
|
4778
5108
|
});
|
|
4779
|
-
var StoryboardItemImageServerSchema = z.object({
|
|
4780
|
-
id: z.string(),
|
|
4781
|
-
url: z.string(),
|
|
4782
|
-
category: z.string(),
|
|
4783
|
-
aesthetic_score: z.number(),
|
|
4784
|
-
faces: z.array(StoryboardItemImageFaceServerSchema),
|
|
4785
|
-
roi: z.object({
|
|
4786
|
-
x: z.number(),
|
|
4787
|
-
y: z.number(),
|
|
4788
|
-
width: z.number(),
|
|
4789
|
-
height: z.number()
|
|
4790
|
-
}),
|
|
4791
|
-
taken_at: z.number(),
|
|
4792
|
-
width: z.number(),
|
|
4793
|
-
height: z.number()
|
|
4794
|
-
});
|
|
4795
5109
|
var StoryboardItemImageSchema = z.object({
|
|
4796
5110
|
id: z.string(),
|
|
4797
5111
|
url: z.string(),
|
|
4798
5112
|
category: z.string(),
|
|
4799
|
-
|
|
5113
|
+
aesthetics: z.object({
|
|
5114
|
+
score: z.number(),
|
|
5115
|
+
scoreWithoutDistance: z.number()
|
|
5116
|
+
}),
|
|
4800
5117
|
faces: z.array(StoryboardItemImageFaceSchema),
|
|
4801
5118
|
roi: z.object({
|
|
4802
5119
|
x: z.number(),
|
|
@@ -4808,21 +5125,6 @@ var StoryboardItemImageSchema = z.object({
|
|
|
4808
5125
|
width: z.number(),
|
|
4809
5126
|
height: z.number()
|
|
4810
5127
|
});
|
|
4811
|
-
var StoryboardItemServerSchema = z.object({
|
|
4812
|
-
id: z.string(),
|
|
4813
|
-
sequence: z.number(),
|
|
4814
|
-
book_id: z.string(),
|
|
4815
|
-
similarity: z.number(),
|
|
4816
|
-
duplicate: z.boolean(),
|
|
4817
|
-
selected: z.boolean(),
|
|
4818
|
-
surface_weight: z.number(),
|
|
4819
|
-
front_cover: z.boolean().optional(),
|
|
4820
|
-
back_cover: z.boolean().optional(),
|
|
4821
|
-
scene: z.number(),
|
|
4822
|
-
subscene: z.number(),
|
|
4823
|
-
spine_break: z.boolean().optional(),
|
|
4824
|
-
image: StoryboardItemImageServerSchema
|
|
4825
|
-
});
|
|
4826
5128
|
var StoryboardItemSchema = z.object({
|
|
4827
5129
|
id: z.string(),
|
|
4828
5130
|
sequence: z.number(),
|
|
@@ -4839,34 +5141,138 @@ var StoryboardItemSchema = z.object({
|
|
|
4839
5141
|
image: StoryboardItemImageSchema
|
|
4840
5142
|
});
|
|
4841
5143
|
|
|
4842
|
-
// ../../core/
|
|
5144
|
+
// ../../core/types/engine-api/endpoints/storyboard-items.ts
|
|
4843
5145
|
var StoryboardItemsEndpoints = class {
|
|
4844
5146
|
// eslint-disable-next-line no-unused-vars
|
|
4845
5147
|
constructor(engineAPI) {
|
|
4846
5148
|
this.engineAPI = engineAPI;
|
|
4847
|
-
bindThisToFunctions(this);
|
|
4848
5149
|
}
|
|
4849
|
-
list(
|
|
5150
|
+
list(props) {
|
|
4850
5151
|
return handleAsyncFunction(async () => {
|
|
4851
5152
|
const res = await this.engineAPI.fetcher.call({
|
|
4852
|
-
path: `/v1/storyboarditems/book/${bookId}`
|
|
5153
|
+
path: `/v1/storyboarditems/book/${props.bookId}`
|
|
4853
5154
|
});
|
|
4854
|
-
return z.array(
|
|
5155
|
+
return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4855
5156
|
});
|
|
4856
5157
|
}
|
|
4857
5158
|
};
|
|
4858
5159
|
|
|
4859
|
-
// ../../core/
|
|
5160
|
+
// ../../core/types/style.ts
|
|
5161
|
+
var styleBaseSchema = z.object({
|
|
5162
|
+
active: z.boolean(),
|
|
5163
|
+
name: z.string(),
|
|
5164
|
+
slug: z.string()
|
|
5165
|
+
});
|
|
5166
|
+
var backgroundSchema = z.object({
|
|
5167
|
+
url: z.string(),
|
|
5168
|
+
compatible: z.boolean()
|
|
5169
|
+
});
|
|
5170
|
+
var colorSchema = z.object({
|
|
5171
|
+
compatible: z.boolean()
|
|
5172
|
+
});
|
|
5173
|
+
var compatibleBackgroundSchema = z.object({
|
|
5174
|
+
id: z.string(),
|
|
5175
|
+
url: z.string(),
|
|
5176
|
+
backgrounds: z.record(z.string(), backgroundSchema),
|
|
5177
|
+
colors: z.record(z.string(), colorSchema)
|
|
5178
|
+
});
|
|
5179
|
+
var whitespaceSchema = z.object({
|
|
5180
|
+
min: z.number(),
|
|
5181
|
+
max: z.number()
|
|
5182
|
+
});
|
|
5183
|
+
var layoutConstraintsClasses = [
|
|
5184
|
+
"A",
|
|
5185
|
+
"B",
|
|
5186
|
+
"C",
|
|
5187
|
+
"D",
|
|
5188
|
+
"E",
|
|
5189
|
+
"F",
|
|
5190
|
+
"G",
|
|
5191
|
+
"H",
|
|
5192
|
+
"I",
|
|
5193
|
+
"J",
|
|
5194
|
+
"K",
|
|
5195
|
+
"L",
|
|
5196
|
+
"M",
|
|
5197
|
+
"N",
|
|
5198
|
+
"O",
|
|
5199
|
+
"P",
|
|
5200
|
+
"Q",
|
|
5201
|
+
"R",
|
|
5202
|
+
"S",
|
|
5203
|
+
"T",
|
|
5204
|
+
"U",
|
|
5205
|
+
"V",
|
|
5206
|
+
"W",
|
|
5207
|
+
"X",
|
|
5208
|
+
"Y",
|
|
5209
|
+
"Z"
|
|
5210
|
+
];
|
|
5211
|
+
var layoutConstraintSchema = z.object({
|
|
5212
|
+
whitespace: whitespaceSchema,
|
|
5213
|
+
iWhitespace: whitespaceSchema,
|
|
5214
|
+
classes: z.array(z.enum(layoutConstraintsClasses))
|
|
5215
|
+
});
|
|
5216
|
+
var layoutConstraintsSchema = z.object({
|
|
5217
|
+
lots: layoutConstraintSchema,
|
|
5218
|
+
few: layoutConstraintSchema,
|
|
5219
|
+
none: layoutConstraintSchema
|
|
5220
|
+
});
|
|
5221
|
+
var styleSchema = styleBaseSchema.extend({
|
|
5222
|
+
position: z.number(),
|
|
5223
|
+
compatibleBackgrounds: z.array(compatibleBackgroundSchema),
|
|
5224
|
+
fonts: z.array(styleFontSchema),
|
|
5225
|
+
layoutConstraints: layoutConstraintsSchema,
|
|
5226
|
+
colors: z.record(z.string(), z.array(z.string()))
|
|
5227
|
+
});
|
|
5228
|
+
|
|
5229
|
+
// ../../core/types/engine-api/endpoints/styles.ts
|
|
5230
|
+
var stylePaginatedSchema = paginatedResponseSchema(styleBaseSchema);
|
|
5231
|
+
var StylesEndpoints = class {
|
|
5232
|
+
// eslint-disable-next-line no-unused-vars
|
|
5233
|
+
constructor(engineAPI) {
|
|
5234
|
+
this.engineAPI = engineAPI;
|
|
5235
|
+
}
|
|
5236
|
+
list(props) {
|
|
5237
|
+
return handleAsyncFunction(async () => {
|
|
5238
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5239
|
+
path: "/v1/styles",
|
|
5240
|
+
qs: props?.qs
|
|
5241
|
+
});
|
|
5242
|
+
return stylePaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5243
|
+
});
|
|
5244
|
+
}
|
|
5245
|
+
retrieve({ styleSlug, qs }) {
|
|
5246
|
+
return handleAsyncFunction(async () => {
|
|
5247
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5248
|
+
path: `/v1/styles/${styleSlug}`,
|
|
5249
|
+
qs
|
|
5250
|
+
});
|
|
5251
|
+
return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5252
|
+
});
|
|
5253
|
+
}
|
|
5254
|
+
update({ styleSlug, payload, qs }) {
|
|
5255
|
+
return handleAsyncFunction(async () => {
|
|
5256
|
+
const res = await this.engineAPI.fetcher.call({
|
|
5257
|
+
path: `/v1/styles/${styleSlug}`,
|
|
5258
|
+
qs,
|
|
5259
|
+
options: {
|
|
5260
|
+
method: "PUT",
|
|
5261
|
+
body: cleanJSON(payload)
|
|
5262
|
+
}
|
|
5263
|
+
});
|
|
5264
|
+
return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5265
|
+
});
|
|
5266
|
+
}
|
|
5267
|
+
};
|
|
5268
|
+
|
|
5269
|
+
// ../../core/types/engine-api/index.ts
|
|
4860
5270
|
var EngineAPI = class {
|
|
4861
|
-
baseUrl;
|
|
4862
|
-
apiKey;
|
|
4863
5271
|
fetcher;
|
|
4864
5272
|
constructor(baseUrl, apiKey) {
|
|
4865
|
-
this.baseUrl = new URL(baseUrl);
|
|
4866
|
-
this.apiKey = apiKey;
|
|
4867
5273
|
const options = {
|
|
4868
5274
|
headers: {
|
|
4869
|
-
"Authorization": `API-Key ${
|
|
5275
|
+
"Authorization": `API-Key ${apiKey}`
|
|
4870
5276
|
}
|
|
4871
5277
|
};
|
|
4872
5278
|
this.fetcher = new Fetcher(baseUrl, options);
|
|
@@ -4874,16 +5280,19 @@ var EngineAPI = class {
|
|
|
4874
5280
|
books = new BooksEndpoints(this);
|
|
4875
5281
|
designOptions = new DesignOptionsEndpoints(this);
|
|
4876
5282
|
events = new EventsEndpoints(this);
|
|
5283
|
+
embellishments = new EmbellishmentsEndpoints(this);
|
|
5284
|
+
fonts = new FontsEndpoints(this);
|
|
4877
5285
|
images = new ImagesEndpoints(this);
|
|
4878
|
-
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
4879
5286
|
spreads = new SpreadsEndpoints(this);
|
|
5287
|
+
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
5288
|
+
styles = new StylesEndpoints(this);
|
|
4880
5289
|
};
|
|
4881
5290
|
|
|
4882
5291
|
// ../../core/config.ts
|
|
4883
|
-
var defaultApiHost = "https://api.
|
|
4884
|
-
var defaultWebSocketHost = "wss://socket.
|
|
5292
|
+
var defaultApiHost = "https://api.dev-sls.magicbook.io";
|
|
5293
|
+
var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
|
|
4885
5294
|
|
|
4886
|
-
// ../../core/
|
|
5295
|
+
// ../../core/types/client.ts
|
|
4887
5296
|
var MagicBookClient = class {
|
|
4888
5297
|
constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
|
|
4889
5298
|
this.apiKey = apiKey;
|
|
@@ -4894,7 +5303,7 @@ var MagicBookClient = class {
|
|
|
4894
5303
|
engineAPI;
|
|
4895
5304
|
async createDesignRequest(designRequestProps) {
|
|
4896
5305
|
if (designRequestProps.userId) {
|
|
4897
|
-
const book = await this.engineAPI.books.create(
|
|
5306
|
+
const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
|
|
4898
5307
|
return new DesignRequest(book.id, this, designRequestProps);
|
|
4899
5308
|
} else {
|
|
4900
5309
|
throw new Error("userId is required");
|
|
@@ -4906,10 +5315,17 @@ export {
|
|
|
4906
5315
|
BookDesignRequest,
|
|
4907
5316
|
DesignRequest,
|
|
4908
5317
|
DesignRequestOptions,
|
|
5318
|
+
EmbellishmentsEndpoints,
|
|
5319
|
+
EngineAPI,
|
|
4909
5320
|
ImageServer,
|
|
4910
5321
|
Images,
|
|
4911
5322
|
MagicBookClient,
|
|
5323
|
+
StoryboardItemImageFaceSchema,
|
|
5324
|
+
StoryboardItemImageSchema,
|
|
5325
|
+
StoryboardItemSchema,
|
|
5326
|
+
StylesEndpoints,
|
|
4912
5327
|
assetSchema,
|
|
5328
|
+
backgroundSchema,
|
|
4913
5329
|
bookCreationRequestSchema,
|
|
4914
5330
|
bookDesignRequestSchema,
|
|
4915
5331
|
bookPropsSchema,
|
|
@@ -4917,33 +5333,68 @@ export {
|
|
|
4917
5333
|
canSubmitDesignRequest,
|
|
4918
5334
|
cancelledEventDetail,
|
|
4919
5335
|
canvasSchema,
|
|
5336
|
+
colorSchema,
|
|
5337
|
+
compatibleBackgroundSchema,
|
|
4920
5338
|
coverTypes,
|
|
4921
5339
|
designOptionsSchema,
|
|
4922
|
-
|
|
5340
|
+
embellishmentAnchorsSchema,
|
|
5341
|
+
embellishmentBackgroundListSchema,
|
|
5342
|
+
embellishmentBackgroundSchema,
|
|
5343
|
+
embellishmentBandSchema,
|
|
5344
|
+
embellishmentBaseSchema,
|
|
5345
|
+
embellishmentFrameSchema,
|
|
5346
|
+
embellishmentGraphicStickerSchema,
|
|
4923
5347
|
embellishmentLevels,
|
|
5348
|
+
embellishmentListSchemas,
|
|
5349
|
+
embellishmentOrientations,
|
|
5350
|
+
embellishmentPageCornerSchema,
|
|
5351
|
+
embellishmentPhotoCornerAnchorsSchema,
|
|
5352
|
+
embellishmentPhotoCornerSchema,
|
|
5353
|
+
embellishmentPostcardSchema,
|
|
5354
|
+
embellishmentSchemas,
|
|
5355
|
+
embellishmentStackings,
|
|
5356
|
+
embellishmentStampSchema,
|
|
5357
|
+
embellishmentStripSchema,
|
|
5358
|
+
embellishmentTPointSchema,
|
|
5359
|
+
embellishmentTapeSchema,
|
|
5360
|
+
embellishmentTextStickerSchema,
|
|
5361
|
+
embellishmentThicknesses,
|
|
5362
|
+
embellishmentTypes,
|
|
5363
|
+
embellishmentUpdateSchemas,
|
|
5364
|
+
fontRoles,
|
|
5365
|
+
fontSchema,
|
|
4924
5366
|
imageAssignmentSchema,
|
|
4925
5367
|
imageDensities,
|
|
4926
5368
|
imageDensityOptionSchema,
|
|
4927
|
-
imageDensityOptionServerSchema,
|
|
4928
5369
|
imageDensityOptionsSchema,
|
|
4929
|
-
imageDensityOptionsServerSchema,
|
|
4930
5370
|
imageFilteringLevels,
|
|
4931
5371
|
imageServerSchema,
|
|
5372
|
+
imageServerToImage,
|
|
4932
5373
|
isDesignRequestSubmitted,
|
|
5374
|
+
layoutConstraintSchema,
|
|
5375
|
+
layoutConstraintsClasses,
|
|
5376
|
+
layoutConstraintsSchema,
|
|
4933
5377
|
magicShopBookSchema,
|
|
4934
5378
|
occasions,
|
|
4935
5379
|
pageSchema,
|
|
4936
5380
|
pageTypes,
|
|
5381
|
+
paginatedResponseSchema,
|
|
4937
5382
|
photoMetadataSchema,
|
|
4938
5383
|
photoStripSchema,
|
|
4939
5384
|
positionSchema,
|
|
4940
5385
|
propertySchema,
|
|
4941
5386
|
reportingDataSchema,
|
|
5387
|
+
spreadSchema,
|
|
5388
|
+
spreadServerSchema,
|
|
4942
5389
|
states,
|
|
4943
5390
|
statesToCloseWS,
|
|
4944
5391
|
statesToReport,
|
|
5392
|
+
styleBaseSchema,
|
|
5393
|
+
styleFontSchema,
|
|
5394
|
+
styleSchema,
|
|
4945
5395
|
styles,
|
|
4946
5396
|
textStickerLevels,
|
|
4947
|
-
timeoutEventDetail
|
|
5397
|
+
timeoutEventDetail,
|
|
5398
|
+
whitespaceSchema
|
|
4948
5399
|
};
|
|
4949
5400
|
//# sourceMappingURL=index.js.map
|