@magiclabs.ai/magicbook-client 0.7.4-canary → 0.7.5-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +763 -271
- package/index.cjs.map +1 -1
- package/index.d.cts +2427 -549
- package/index.d.ts +2427 -549
- package/index.js +716 -266
- package/index.js.map +1 -1
- package/package.json +11 -11
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var states = [
|
|
|
18
18
|
var statesToCloseWS = ["error", "timeout", "ready", "cancelled"];
|
|
19
19
|
var statesToReport = ["error", "timeout"];
|
|
20
20
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
21
|
-
var
|
|
21
|
+
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
22
22
|
var occasions = [
|
|
23
23
|
"baby",
|
|
24
24
|
"birthday",
|
|
@@ -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) {
|
|
@@ -4080,12 +4126,15 @@ var Images = class {
|
|
|
4080
4126
|
length;
|
|
4081
4127
|
designRequestState;
|
|
4082
4128
|
async add(image) {
|
|
4083
|
-
if (!
|
|
4129
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4084
4130
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
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,27 +4261,29 @@ 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) {
|
|
4227
|
-
if (!
|
|
4274
|
+
if (!canSubmitDesignRequest(this.state)) {
|
|
4228
4275
|
throw new Error("You need to wait for the current design request to be ready before submitting a new one");
|
|
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
|
-
this.updateDesignRequest({ state: states[1] });
|
|
4238
4287
|
return this;
|
|
4239
4288
|
}
|
|
4240
4289
|
}
|
|
@@ -4244,7 +4293,10 @@ var DesignRequest = class {
|
|
|
4244
4293
|
} else {
|
|
4245
4294
|
this.guid = guid;
|
|
4246
4295
|
this.updateDesignRequest(
|
|
4247
|
-
(await this.client.engineAPI.books.update(
|
|
4296
|
+
(await this.client.engineAPI.books.update({
|
|
4297
|
+
bookId: this.parentId,
|
|
4298
|
+
payload: this.toBook()
|
|
4299
|
+
})).toDesignRequestProps()
|
|
4248
4300
|
);
|
|
4249
4301
|
return this.guid;
|
|
4250
4302
|
}
|
|
@@ -4258,7 +4310,9 @@ var DesignRequest = class {
|
|
|
4258
4310
|
throw new Error("Design request not submitted");
|
|
4259
4311
|
} else {
|
|
4260
4312
|
this.updateDesignRequest({
|
|
4261
|
-
...(await this.client.engineAPI.books.cancel(
|
|
4313
|
+
...(await this.client.engineAPI.books.cancel({
|
|
4314
|
+
bookId: this.parentId
|
|
4315
|
+
})).toDesignRequestProps(),
|
|
4262
4316
|
state: "cancelled"
|
|
4263
4317
|
});
|
|
4264
4318
|
await this.eventHandler(cancelledEventDetail);
|
|
@@ -4267,22 +4321,31 @@ var DesignRequest = class {
|
|
|
4267
4321
|
}
|
|
4268
4322
|
async getJSON() {
|
|
4269
4323
|
if (this.state === "ready") {
|
|
4270
|
-
return await this.client.engineAPI.books.retrieveGalleon(
|
|
4324
|
+
return await this.client.engineAPI.books.retrieveGalleon({
|
|
4325
|
+
bookId: this.parentId
|
|
4326
|
+
});
|
|
4271
4327
|
} else {
|
|
4272
4328
|
throw new Error("Design request not ready");
|
|
4273
4329
|
}
|
|
4274
4330
|
}
|
|
4275
4331
|
async logEvent(name, data) {
|
|
4276
|
-
return await this.client.engineAPI.events.createBookEvent(
|
|
4332
|
+
return await this.client.engineAPI.events.createBookEvent({
|
|
4333
|
+
bookId: this.parentId,
|
|
4334
|
+
name,
|
|
4335
|
+
data
|
|
4336
|
+
});
|
|
4277
4337
|
}
|
|
4278
4338
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4279
4339
|
const customEvent = new CustomEvent(type, { detail });
|
|
4280
4340
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4281
4341
|
this.webSocket?.close();
|
|
4282
4342
|
if (statesToReport.includes(detail.slug)) {
|
|
4283
|
-
await this.client.engineAPI.books.report(
|
|
4284
|
-
|
|
4285
|
-
|
|
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
|
+
}
|
|
4286
4349
|
});
|
|
4287
4350
|
}
|
|
4288
4351
|
}
|
|
@@ -4303,7 +4366,7 @@ var DesignRequest = class {
|
|
|
4303
4366
|
let timeout;
|
|
4304
4367
|
this.webSocket.onmessage = async (event) => {
|
|
4305
4368
|
const detail = JSON.parse(event.data);
|
|
4306
|
-
if (this.state !== detail.slug) {
|
|
4369
|
+
if (this.state !== detail.slug || detail.slug === "submitted") {
|
|
4307
4370
|
timeout && clearTimeout(timeout);
|
|
4308
4371
|
timeout = this.timeoutHandler();
|
|
4309
4372
|
await this.eventHandler(detail);
|
|
@@ -4335,7 +4398,7 @@ var DesignRequest = class {
|
|
|
4335
4398
|
}
|
|
4336
4399
|
};
|
|
4337
4400
|
|
|
4338
|
-
// ../../core/
|
|
4401
|
+
// ../../core/types/galleon.ts
|
|
4339
4402
|
var imageAssignmentSchema = z.object({
|
|
4340
4403
|
photoRefId: z.string(),
|
|
4341
4404
|
finalCrop: z.array(z.number())
|
|
@@ -4414,128 +4477,357 @@ var bookCreationRequestSchema = z.object({
|
|
|
4414
4477
|
reportingData: reportingDataSchema
|
|
4415
4478
|
});
|
|
4416
4479
|
|
|
4417
|
-
// ../../core/
|
|
4480
|
+
// ../../core/types/engine-api/endpoints/books.ts
|
|
4418
4481
|
var BooksEndpoints = class {
|
|
4419
4482
|
// eslint-disable-next-line no-unused-vars
|
|
4420
4483
|
constructor(engineAPI) {
|
|
4421
4484
|
this.engineAPI = engineAPI;
|
|
4422
|
-
bindThisToFunctions(this);
|
|
4423
4485
|
}
|
|
4424
|
-
create(book) {
|
|
4486
|
+
create({ book, qs }) {
|
|
4425
4487
|
return handleAsyncFunction(async () => {
|
|
4426
4488
|
const res = await this.engineAPI.fetcher.call({
|
|
4427
4489
|
path: "/v1/books",
|
|
4428
4490
|
options: {
|
|
4429
4491
|
method: "POST",
|
|
4430
4492
|
body: cleanJSON(book)
|
|
4431
|
-
}
|
|
4493
|
+
},
|
|
4494
|
+
qs
|
|
4432
4495
|
});
|
|
4433
|
-
bookPropsSchema.safeParse(res);
|
|
4434
4496
|
return new Book(res);
|
|
4435
4497
|
});
|
|
4436
4498
|
}
|
|
4437
|
-
retrieve(bookId) {
|
|
4499
|
+
retrieve({ bookId, qs }) {
|
|
4438
4500
|
return handleAsyncFunction(async () => {
|
|
4439
|
-
const res = await this.engineAPI.fetcher.call({
|
|
4440
|
-
|
|
4441
|
-
|
|
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);
|
|
4442
4507
|
});
|
|
4443
4508
|
}
|
|
4444
|
-
update(bookId,
|
|
4509
|
+
update({ bookId, payload, qs }) {
|
|
4445
4510
|
return handleAsyncFunction(async () => {
|
|
4446
4511
|
const res = await this.engineAPI.fetcher.call({
|
|
4447
4512
|
path: `/v1/books/${bookId}`,
|
|
4448
4513
|
options: {
|
|
4449
4514
|
method: "PUT",
|
|
4450
|
-
body: cleanJSON(
|
|
4451
|
-
}
|
|
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
|
|
4452
4529
|
});
|
|
4453
|
-
bookPropsSchema.safeParse(res);
|
|
4454
|
-
return new Book(res);
|
|
4455
4530
|
});
|
|
4456
4531
|
}
|
|
4457
|
-
design(bookId) {
|
|
4532
|
+
design({ bookId, qs }) {
|
|
4458
4533
|
return handleAsyncFunction(async () => {
|
|
4459
4534
|
const res = await this.engineAPI.fetcher.call({
|
|
4460
4535
|
path: `/v1/books/${bookId}/design`,
|
|
4461
|
-
options: { method: "POST" }
|
|
4536
|
+
options: { method: "POST" },
|
|
4537
|
+
qs
|
|
4462
4538
|
});
|
|
4463
|
-
bookPropsSchema.
|
|
4464
|
-
return new Book(
|
|
4539
|
+
const bookProps = bookPropsSchema.parse(res);
|
|
4540
|
+
return new Book(bookProps);
|
|
4465
4541
|
});
|
|
4466
4542
|
}
|
|
4467
|
-
cancel(bookId) {
|
|
4543
|
+
cancel({ bookId, qs }) {
|
|
4468
4544
|
return handleAsyncFunction(async () => {
|
|
4469
4545
|
const res = await this.engineAPI.fetcher.call({
|
|
4470
4546
|
path: `/v1/books/${bookId}/cancel`,
|
|
4471
|
-
options: { method: "POST" }
|
|
4547
|
+
options: { method: "POST" },
|
|
4548
|
+
qs
|
|
4472
4549
|
});
|
|
4473
|
-
bookPropsSchema.
|
|
4474
|
-
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);
|
|
4475
4561
|
});
|
|
4476
4562
|
}
|
|
4477
|
-
report(bookId, report) {
|
|
4563
|
+
report({ bookId, report, qs }) {
|
|
4478
4564
|
return handleAsyncFunction(async () => {
|
|
4479
4565
|
await this.engineAPI.fetcher.call({
|
|
4480
4566
|
path: `/v1/books/${bookId}/report`,
|
|
4481
4567
|
options: {
|
|
4482
4568
|
method: "POST",
|
|
4483
4569
|
body: cleanJSON(report)
|
|
4484
|
-
}
|
|
4570
|
+
},
|
|
4571
|
+
qs
|
|
4485
4572
|
});
|
|
4486
4573
|
});
|
|
4487
4574
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
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;
|
|
4495
4582
|
}
|
|
4496
|
-
|
|
4583
|
+
retrieve(props) {
|
|
4497
4584
|
return handleAsyncFunction(async () => {
|
|
4498
4585
|
const res = await this.engineAPI.fetcher.call({
|
|
4499
|
-
|
|
4586
|
+
// eslint-disable-next-line max-len
|
|
4587
|
+
path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
|
|
4588
|
+
qs: props.qs
|
|
4500
4589
|
});
|
|
4501
|
-
return
|
|
4590
|
+
return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4502
4591
|
});
|
|
4503
4592
|
}
|
|
4504
4593
|
};
|
|
4505
4594
|
|
|
4506
|
-
// ../../core/
|
|
4507
|
-
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 {
|
|
4508
4769
|
// eslint-disable-next-line no-unused-vars
|
|
4509
4770
|
constructor(engineAPI) {
|
|
4510
4771
|
this.engineAPI = engineAPI;
|
|
4511
|
-
bindThisToFunctions(this);
|
|
4512
4772
|
}
|
|
4513
|
-
|
|
4773
|
+
list({ styleSlug, qs }) {
|
|
4514
4774
|
return handleAsyncFunction(async () => {
|
|
4515
4775
|
const res = await this.engineAPI.fetcher.call({
|
|
4516
|
-
|
|
4517
|
-
|
|
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
|
+
}
|
|
4518
4799
|
});
|
|
4519
|
-
return
|
|
4800
|
+
return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4520
4801
|
});
|
|
4521
4802
|
}
|
|
4522
4803
|
};
|
|
4523
4804
|
|
|
4524
|
-
// ../../core/
|
|
4805
|
+
// ../../core/types/event.ts
|
|
4525
4806
|
var eventContextSchema = z.record(z.string(), z.unknown()).optional();
|
|
4526
4807
|
var eventSchema = z.object({
|
|
4527
4808
|
name: z.string(),
|
|
4528
|
-
context: eventContextSchema
|
|
4809
|
+
context: eventContextSchema,
|
|
4810
|
+
bookId: z.string(),
|
|
4811
|
+
createdAt: z.string()
|
|
4529
4812
|
});
|
|
4530
4813
|
|
|
4531
|
-
// ../../core/
|
|
4814
|
+
// ../../core/types/engine-api/endpoints/events.ts
|
|
4815
|
+
var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
|
|
4532
4816
|
var EventsEndpoints = class {
|
|
4533
4817
|
// eslint-disable-next-line no-unused-vars
|
|
4534
4818
|
constructor(engineAPI) {
|
|
4535
4819
|
this.engineAPI = engineAPI;
|
|
4536
|
-
bindThisToFunctions(this);
|
|
4537
4820
|
}
|
|
4538
|
-
|
|
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 }) {
|
|
4539
4831
|
return handleAsyncFunction(async () => {
|
|
4540
4832
|
const body = {
|
|
4541
4833
|
name
|
|
@@ -4546,14 +4838,26 @@ var EventsEndpoints = class {
|
|
|
4546
4838
|
options: {
|
|
4547
4839
|
method: "POST",
|
|
4548
4840
|
body: cleanJSON(body)
|
|
4549
|
-
}
|
|
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
|
|
4550
4855
|
});
|
|
4551
|
-
return eventSchema.parse(res);
|
|
4552
4856
|
});
|
|
4553
4857
|
}
|
|
4554
4858
|
};
|
|
4555
4859
|
|
|
4556
|
-
// ../../core/
|
|
4860
|
+
// ../../core/types/fetcher.ts
|
|
4557
4861
|
var baseOptions = {
|
|
4558
4862
|
headers: {
|
|
4559
4863
|
"Content-Type": "application/json"
|
|
@@ -4574,12 +4878,14 @@ var Fetcher = class {
|
|
|
4574
4878
|
}
|
|
4575
4879
|
const baseOptions2 = { ...this.options };
|
|
4576
4880
|
const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
|
|
4577
|
-
const
|
|
4578
|
-
|
|
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();
|
|
4579
4885
|
try {
|
|
4580
|
-
return
|
|
4886
|
+
return JSON.parse(result);
|
|
4581
4887
|
} catch (error) {
|
|
4582
|
-
return
|
|
4888
|
+
return result;
|
|
4583
4889
|
}
|
|
4584
4890
|
} else {
|
|
4585
4891
|
let detail = res.statusText;
|
|
@@ -4594,70 +4900,102 @@ var Fetcher = class {
|
|
|
4594
4900
|
}
|
|
4595
4901
|
}
|
|
4596
4902
|
cleanUrl(url) {
|
|
4597
|
-
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
|
+
});
|
|
4598
4932
|
}
|
|
4599
4933
|
};
|
|
4600
4934
|
|
|
4601
|
-
// ../../core/
|
|
4935
|
+
// ../../core/types/engine-api/endpoints/images.ts
|
|
4602
4936
|
var ImagesEndpoints = class {
|
|
4603
4937
|
// eslint-disable-next-line no-unused-vars
|
|
4604
4938
|
constructor(engineAPI) {
|
|
4605
4939
|
this.engineAPI = engineAPI;
|
|
4606
|
-
bindThisToFunctions(this);
|
|
4607
4940
|
}
|
|
4608
|
-
list(bookId) {
|
|
4941
|
+
list({ bookId, qs }) {
|
|
4609
4942
|
return handleAsyncFunction(async () => {
|
|
4610
4943
|
const res = await this.engineAPI.fetcher.call({
|
|
4611
|
-
path: `/v1/images/book/${bookId}
|
|
4944
|
+
path: `/v1/images/book/${bookId}`,
|
|
4945
|
+
qs
|
|
4612
4946
|
});
|
|
4613
4947
|
return z.array(imageServerSchema).parse(res);
|
|
4614
4948
|
});
|
|
4615
4949
|
}
|
|
4616
|
-
|
|
4950
|
+
addToBook({ bookId, image, qs }) {
|
|
4617
4951
|
return handleAsyncFunction(async () => {
|
|
4618
4952
|
const res = await this.engineAPI.fetcher.call({
|
|
4619
|
-
path: `/v1/images
|
|
4953
|
+
path: `/v1/images/book/${bookId}`,
|
|
4954
|
+
options: {
|
|
4955
|
+
method: "POST",
|
|
4956
|
+
body: cleanJSON(image)
|
|
4957
|
+
},
|
|
4958
|
+
qs
|
|
4620
4959
|
});
|
|
4621
4960
|
return imageServerSchema.parse(res);
|
|
4622
4961
|
});
|
|
4623
4962
|
}
|
|
4624
|
-
|
|
4963
|
+
retrieve({ bookId, imageId, qs }) {
|
|
4625
4964
|
return handleAsyncFunction(async () => {
|
|
4626
4965
|
const res = await this.engineAPI.fetcher.call({
|
|
4627
4966
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4628
|
-
|
|
4629
|
-
method: "PUT",
|
|
4630
|
-
body: cleanJSON(image)
|
|
4631
|
-
}
|
|
4967
|
+
qs
|
|
4632
4968
|
});
|
|
4633
4969
|
return imageServerSchema.parse(res);
|
|
4634
4970
|
});
|
|
4635
4971
|
}
|
|
4636
|
-
|
|
4972
|
+
update({ bookId, imageId, payload, qs }) {
|
|
4637
4973
|
return handleAsyncFunction(async () => {
|
|
4638
|
-
await this.engineAPI.fetcher.call({
|
|
4974
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4639
4975
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4640
4976
|
options: {
|
|
4641
|
-
method: "
|
|
4642
|
-
|
|
4977
|
+
method: "PUT",
|
|
4978
|
+
body: cleanJSON(payload)
|
|
4979
|
+
},
|
|
4980
|
+
qs
|
|
4643
4981
|
});
|
|
4982
|
+
return imageServerSchema.parse(res);
|
|
4644
4983
|
});
|
|
4645
4984
|
}
|
|
4646
|
-
|
|
4985
|
+
delete({ bookId, imageId, qs }) {
|
|
4647
4986
|
return handleAsyncFunction(async () => {
|
|
4648
|
-
|
|
4649
|
-
path: `/v1/images/book/${bookId}
|
|
4987
|
+
await this.engineAPI.fetcher.call({
|
|
4988
|
+
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4650
4989
|
options: {
|
|
4651
|
-
method: "
|
|
4652
|
-
|
|
4653
|
-
|
|
4990
|
+
method: "DELETE"
|
|
4991
|
+
},
|
|
4992
|
+
qs
|
|
4654
4993
|
});
|
|
4655
|
-
return imageServerSchema.parse(res);
|
|
4656
4994
|
});
|
|
4657
4995
|
}
|
|
4658
4996
|
};
|
|
4659
4997
|
|
|
4660
|
-
// ../../core/
|
|
4998
|
+
// ../../core/types/spread.ts
|
|
4661
4999
|
var spreadServerSchema = z.object({
|
|
4662
5000
|
id: z.string().optional(),
|
|
4663
5001
|
book_id: z.string(),
|
|
@@ -4691,79 +5029,70 @@ var spreadSchema = z.object({
|
|
|
4691
5029
|
url: z.string().nullable().optional()
|
|
4692
5030
|
});
|
|
4693
5031
|
|
|
4694
|
-
// ../../core/
|
|
5032
|
+
// ../../core/types/engine-api/endpoints/spreads.ts
|
|
4695
5033
|
var SpreadsEndpoints = class {
|
|
4696
5034
|
// eslint-disable-next-line no-unused-vars
|
|
4697
5035
|
constructor(engineAPI) {
|
|
4698
5036
|
this.engineAPI = engineAPI;
|
|
4699
|
-
bindThisToFunctions(this);
|
|
4700
5037
|
}
|
|
4701
|
-
list(bookId) {
|
|
5038
|
+
list({ bookId, qs }) {
|
|
4702
5039
|
return handleAsyncFunction(async () => {
|
|
4703
5040
|
const res = await this.engineAPI.fetcher.call({
|
|
4704
|
-
path: `/v1/spreads/book/${bookId}
|
|
5041
|
+
path: `/v1/spreads/book/${bookId}`,
|
|
5042
|
+
qs
|
|
4705
5043
|
});
|
|
4706
|
-
return z.array(
|
|
5044
|
+
return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4707
5045
|
});
|
|
4708
5046
|
}
|
|
4709
|
-
create(bookId, spread) {
|
|
5047
|
+
create({ bookId, spread, qs }) {
|
|
4710
5048
|
return handleAsyncFunction(async () => {
|
|
4711
5049
|
const res = await this.engineAPI.fetcher.call({
|
|
4712
5050
|
path: `/v1/spreads/book/${bookId}`,
|
|
4713
5051
|
options: {
|
|
4714
5052
|
method: "POST",
|
|
4715
5053
|
body: cleanJSON(spread)
|
|
4716
|
-
}
|
|
5054
|
+
},
|
|
5055
|
+
qs
|
|
4717
5056
|
});
|
|
4718
|
-
return
|
|
5057
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4719
5058
|
});
|
|
4720
5059
|
}
|
|
4721
|
-
retrieve(spreadId,
|
|
5060
|
+
retrieve({ bookId, spreadId, qs }) {
|
|
4722
5061
|
return handleAsyncFunction(async () => {
|
|
4723
5062
|
const res = await this.engineAPI.fetcher.call({
|
|
4724
|
-
path: `/v1/spreads/${spreadId}/book/${bookId}
|
|
5063
|
+
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5064
|
+
qs
|
|
4725
5065
|
});
|
|
4726
|
-
return
|
|
5066
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4727
5067
|
});
|
|
4728
5068
|
}
|
|
4729
|
-
update(spreadId,
|
|
5069
|
+
update({ bookId, spreadId, payload, qs }) {
|
|
4730
5070
|
return handleAsyncFunction(async () => {
|
|
4731
5071
|
const res = await this.engineAPI.fetcher.call({
|
|
4732
5072
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4733
5073
|
options: {
|
|
4734
5074
|
method: "PUT",
|
|
4735
|
-
body: cleanJSON(
|
|
4736
|
-
}
|
|
5075
|
+
body: cleanJSON(payload)
|
|
5076
|
+
},
|
|
5077
|
+
qs
|
|
4737
5078
|
});
|
|
4738
|
-
return
|
|
5079
|
+
return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4739
5080
|
});
|
|
4740
5081
|
}
|
|
4741
|
-
delete(spreadId,
|
|
5082
|
+
delete({ bookId, spreadId, qs }) {
|
|
4742
5083
|
return handleAsyncFunction(async () => {
|
|
4743
5084
|
await this.engineAPI.fetcher.call({
|
|
4744
5085
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
4745
5086
|
options: {
|
|
4746
5087
|
method: "DELETE"
|
|
4747
|
-
}
|
|
5088
|
+
},
|
|
5089
|
+
qs
|
|
4748
5090
|
});
|
|
4749
5091
|
});
|
|
4750
5092
|
}
|
|
4751
5093
|
};
|
|
4752
5094
|
|
|
4753
|
-
// ../../core/
|
|
4754
|
-
var StoryboardItemImageFaceServerSchema = z.object({
|
|
4755
|
-
score: z.number(),
|
|
4756
|
-
bounding_box: z.object({
|
|
4757
|
-
x: z.number(),
|
|
4758
|
-
y: z.number(),
|
|
4759
|
-
width: z.number(),
|
|
4760
|
-
height: z.number()
|
|
4761
|
-
}),
|
|
4762
|
-
size: z.number(),
|
|
4763
|
-
eyes_open_score: z.number(),
|
|
4764
|
-
smile_score: z.number(),
|
|
4765
|
-
facing_camera_score: z.number()
|
|
4766
|
-
});
|
|
5095
|
+
// ../../core/types/storyboard-item.ts
|
|
4767
5096
|
var StoryboardItemImageFaceSchema = z.object({
|
|
4768
5097
|
score: z.number(),
|
|
4769
5098
|
boundingBox: z.object({
|
|
@@ -4777,27 +5106,14 @@ var StoryboardItemImageFaceSchema = z.object({
|
|
|
4777
5106
|
smileScore: z.number(),
|
|
4778
5107
|
facingCameraScore: z.number()
|
|
4779
5108
|
});
|
|
4780
|
-
var StoryboardItemImageServerSchema = z.object({
|
|
4781
|
-
id: z.string(),
|
|
4782
|
-
url: z.string(),
|
|
4783
|
-
category: z.string(),
|
|
4784
|
-
aesthetic_score: z.number(),
|
|
4785
|
-
faces: z.array(StoryboardItemImageFaceServerSchema),
|
|
4786
|
-
roi: z.object({
|
|
4787
|
-
x: z.number(),
|
|
4788
|
-
y: z.number(),
|
|
4789
|
-
width: z.number(),
|
|
4790
|
-
height: z.number()
|
|
4791
|
-
}),
|
|
4792
|
-
taken_at: z.number(),
|
|
4793
|
-
width: z.number(),
|
|
4794
|
-
height: z.number()
|
|
4795
|
-
});
|
|
4796
5109
|
var StoryboardItemImageSchema = z.object({
|
|
4797
5110
|
id: z.string(),
|
|
4798
5111
|
url: z.string(),
|
|
4799
5112
|
category: z.string(),
|
|
4800
|
-
|
|
5113
|
+
aesthetics: z.object({
|
|
5114
|
+
score: z.number(),
|
|
5115
|
+
scoreWithoutDistance: z.number()
|
|
5116
|
+
}),
|
|
4801
5117
|
faces: z.array(StoryboardItemImageFaceSchema),
|
|
4802
5118
|
roi: z.object({
|
|
4803
5119
|
x: z.number(),
|
|
@@ -4809,21 +5125,6 @@ var StoryboardItemImageSchema = z.object({
|
|
|
4809
5125
|
width: z.number(),
|
|
4810
5126
|
height: z.number()
|
|
4811
5127
|
});
|
|
4812
|
-
var StoryboardItemServerSchema = z.object({
|
|
4813
|
-
id: z.string(),
|
|
4814
|
-
sequence: z.number(),
|
|
4815
|
-
book_id: z.string(),
|
|
4816
|
-
similarity: z.number(),
|
|
4817
|
-
duplicate: z.boolean(),
|
|
4818
|
-
selected: z.boolean(),
|
|
4819
|
-
surface_weight: z.number(),
|
|
4820
|
-
front_cover: z.boolean().optional(),
|
|
4821
|
-
back_cover: z.boolean().optional(),
|
|
4822
|
-
scene: z.number(),
|
|
4823
|
-
subscene: z.number(),
|
|
4824
|
-
spine_break: z.boolean().optional(),
|
|
4825
|
-
image: StoryboardItemImageServerSchema
|
|
4826
|
-
});
|
|
4827
5128
|
var StoryboardItemSchema = z.object({
|
|
4828
5129
|
id: z.string(),
|
|
4829
5130
|
sequence: z.number(),
|
|
@@ -4840,34 +5141,138 @@ var StoryboardItemSchema = z.object({
|
|
|
4840
5141
|
image: StoryboardItemImageSchema
|
|
4841
5142
|
});
|
|
4842
5143
|
|
|
4843
|
-
// ../../core/
|
|
5144
|
+
// ../../core/types/engine-api/endpoints/storyboard-items.ts
|
|
4844
5145
|
var StoryboardItemsEndpoints = class {
|
|
4845
5146
|
// eslint-disable-next-line no-unused-vars
|
|
4846
5147
|
constructor(engineAPI) {
|
|
4847
5148
|
this.engineAPI = engineAPI;
|
|
4848
|
-
bindThisToFunctions(this);
|
|
4849
5149
|
}
|
|
4850
|
-
list(
|
|
5150
|
+
list(props) {
|
|
4851
5151
|
return handleAsyncFunction(async () => {
|
|
4852
5152
|
const res = await this.engineAPI.fetcher.call({
|
|
4853
|
-
path: `/v1/storyboarditems/book/${bookId}`
|
|
5153
|
+
path: `/v1/storyboarditems/book/${props.bookId}`
|
|
4854
5154
|
});
|
|
4855
|
-
return z.array(
|
|
5155
|
+
return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
4856
5156
|
});
|
|
4857
5157
|
}
|
|
4858
5158
|
};
|
|
4859
5159
|
|
|
4860
|
-
// ../../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
|
|
4861
5270
|
var EngineAPI = class {
|
|
4862
|
-
baseUrl;
|
|
4863
|
-
apiKey;
|
|
4864
5271
|
fetcher;
|
|
4865
5272
|
constructor(baseUrl, apiKey) {
|
|
4866
|
-
this.baseUrl = new URL(baseUrl);
|
|
4867
|
-
this.apiKey = apiKey;
|
|
4868
5273
|
const options = {
|
|
4869
5274
|
headers: {
|
|
4870
|
-
"Authorization": `API-Key ${
|
|
5275
|
+
"Authorization": `API-Key ${apiKey}`
|
|
4871
5276
|
}
|
|
4872
5277
|
};
|
|
4873
5278
|
this.fetcher = new Fetcher(baseUrl, options);
|
|
@@ -4875,16 +5280,19 @@ var EngineAPI = class {
|
|
|
4875
5280
|
books = new BooksEndpoints(this);
|
|
4876
5281
|
designOptions = new DesignOptionsEndpoints(this);
|
|
4877
5282
|
events = new EventsEndpoints(this);
|
|
5283
|
+
embellishments = new EmbellishmentsEndpoints(this);
|
|
5284
|
+
fonts = new FontsEndpoints(this);
|
|
4878
5285
|
images = new ImagesEndpoints(this);
|
|
4879
|
-
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
4880
5286
|
spreads = new SpreadsEndpoints(this);
|
|
5287
|
+
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
5288
|
+
styles = new StylesEndpoints(this);
|
|
4881
5289
|
};
|
|
4882
5290
|
|
|
4883
5291
|
// ../../core/config.ts
|
|
4884
|
-
var defaultApiHost = "https://api.
|
|
4885
|
-
var defaultWebSocketHost = "wss://socket.
|
|
5292
|
+
var defaultApiHost = "https://api.dev-sls.magicbook.io";
|
|
5293
|
+
var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
|
|
4886
5294
|
|
|
4887
|
-
// ../../core/
|
|
5295
|
+
// ../../core/types/client.ts
|
|
4888
5296
|
var MagicBookClient = class {
|
|
4889
5297
|
constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
|
|
4890
5298
|
this.apiKey = apiKey;
|
|
@@ -4895,7 +5303,7 @@ var MagicBookClient = class {
|
|
|
4895
5303
|
engineAPI;
|
|
4896
5304
|
async createDesignRequest(designRequestProps) {
|
|
4897
5305
|
if (designRequestProps.userId) {
|
|
4898
|
-
const book = await this.engineAPI.books.create(
|
|
5306
|
+
const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
|
|
4899
5307
|
return new DesignRequest(book.id, this, designRequestProps);
|
|
4900
5308
|
} else {
|
|
4901
5309
|
throw new Error("userId is required");
|
|
@@ -4907,44 +5315,86 @@ export {
|
|
|
4907
5315
|
BookDesignRequest,
|
|
4908
5316
|
DesignRequest,
|
|
4909
5317
|
DesignRequestOptions,
|
|
5318
|
+
EmbellishmentsEndpoints,
|
|
5319
|
+
EngineAPI,
|
|
4910
5320
|
ImageServer,
|
|
4911
5321
|
Images,
|
|
4912
5322
|
MagicBookClient,
|
|
5323
|
+
StoryboardItemImageFaceSchema,
|
|
5324
|
+
StoryboardItemImageSchema,
|
|
5325
|
+
StoryboardItemSchema,
|
|
5326
|
+
StylesEndpoints,
|
|
4913
5327
|
assetSchema,
|
|
5328
|
+
backgroundSchema,
|
|
4914
5329
|
bookCreationRequestSchema,
|
|
4915
5330
|
bookDesignRequestSchema,
|
|
4916
5331
|
bookPropsSchema,
|
|
4917
5332
|
bookSizes,
|
|
4918
|
-
|
|
5333
|
+
canSubmitDesignRequest,
|
|
4919
5334
|
cancelledEventDetail,
|
|
4920
5335
|
canvasSchema,
|
|
5336
|
+
colorSchema,
|
|
5337
|
+
compatibleBackgroundSchema,
|
|
4921
5338
|
coverTypes,
|
|
4922
5339
|
designOptionsSchema,
|
|
4923
|
-
|
|
5340
|
+
embellishmentAnchorsSchema,
|
|
5341
|
+
embellishmentBackgroundListSchema,
|
|
5342
|
+
embellishmentBackgroundSchema,
|
|
5343
|
+
embellishmentBandSchema,
|
|
5344
|
+
embellishmentBaseSchema,
|
|
5345
|
+
embellishmentFrameSchema,
|
|
5346
|
+
embellishmentGraphicStickerSchema,
|
|
4924
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,
|
|
4925
5366
|
imageAssignmentSchema,
|
|
4926
5367
|
imageDensities,
|
|
4927
5368
|
imageDensityOptionSchema,
|
|
4928
|
-
imageDensityOptionServerSchema,
|
|
4929
5369
|
imageDensityOptionsSchema,
|
|
4930
|
-
imageDensityOptionsServerSchema,
|
|
4931
5370
|
imageFilteringLevels,
|
|
4932
5371
|
imageServerSchema,
|
|
5372
|
+
imageServerToImage,
|
|
4933
5373
|
isDesignRequestSubmitted,
|
|
5374
|
+
layoutConstraintSchema,
|
|
5375
|
+
layoutConstraintsClasses,
|
|
5376
|
+
layoutConstraintsSchema,
|
|
4934
5377
|
magicShopBookSchema,
|
|
4935
5378
|
occasions,
|
|
4936
5379
|
pageSchema,
|
|
4937
5380
|
pageTypes,
|
|
5381
|
+
paginatedResponseSchema,
|
|
4938
5382
|
photoMetadataSchema,
|
|
4939
5383
|
photoStripSchema,
|
|
4940
5384
|
positionSchema,
|
|
4941
5385
|
propertySchema,
|
|
4942
5386
|
reportingDataSchema,
|
|
5387
|
+
spreadSchema,
|
|
5388
|
+
spreadServerSchema,
|
|
4943
5389
|
states,
|
|
4944
5390
|
statesToCloseWS,
|
|
4945
5391
|
statesToReport,
|
|
5392
|
+
styleBaseSchema,
|
|
5393
|
+
styleFontSchema,
|
|
5394
|
+
styleSchema,
|
|
4946
5395
|
styles,
|
|
4947
5396
|
textStickerLevels,
|
|
4948
|
-
timeoutEventDetail
|
|
5397
|
+
timeoutEventDetail,
|
|
5398
|
+
whitespaceSchema
|
|
4949
5399
|
};
|
|
4950
5400
|
//# sourceMappingURL=index.js.map
|