@magiclabs.ai/magicbook-client 0.7.5-canary.0 → 0.7.5
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 +217 -642
- package/index.cjs.map +1 -1
- package/index.d.cts +507 -2378
- package/index.d.ts +507 -2378
- package/index.js +213 -597
- package/index.js.map +1 -1
- package/package.json +11 -11
package/index.js
CHANGED
|
@@ -205,7 +205,9 @@ var styles = {
|
|
|
205
205
|
6096: { slug: "simply-scrapbook-sfly" },
|
|
206
206
|
6097: { slug: "boho-wedding-sfly" },
|
|
207
207
|
6098: { slug: "black-and-white-rustic-sfly" },
|
|
208
|
-
6099: { slug: "bright-color-pop-sfly" }
|
|
208
|
+
6099: { slug: "bright-color-pop-sfly" },
|
|
209
|
+
6159: { slug: "grateful-for-you-sfly" },
|
|
210
|
+
6156: { slug: "europe-mementos-sfly" }
|
|
209
211
|
};
|
|
210
212
|
var bookSizes = ["8x8", "10x10", "12x12", "8x11", "11x8", "11x14"];
|
|
211
213
|
var coverTypes = ["sc", "hc", "pl"];
|
|
@@ -265,11 +267,7 @@ function snakeCaseObjectKeysToCamelCase(snakeCaseObject) {
|
|
|
265
267
|
delete snakeCaseObject[key];
|
|
266
268
|
}
|
|
267
269
|
if (typeof snakeCaseObject[camelCaseKey] === "object") {
|
|
268
|
-
|
|
269
|
-
snakeCaseObject[camelCaseKey] = null;
|
|
270
|
-
} else {
|
|
271
|
-
snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
|
|
272
|
-
}
|
|
270
|
+
snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
|
|
273
271
|
}
|
|
274
272
|
});
|
|
275
273
|
return snakeCaseObject;
|
|
@@ -281,6 +279,15 @@ async function handleAsyncFunction(fn) {
|
|
|
281
279
|
return Promise.reject(error);
|
|
282
280
|
}
|
|
283
281
|
}
|
|
282
|
+
function bindThisToFunctions(instance) {
|
|
283
|
+
for (const name of Object.getOwnPropertyNames(
|
|
284
|
+
Object.getPrototypeOf(instance)
|
|
285
|
+
)) {
|
|
286
|
+
if (typeof instance[name] === "function" && name !== "constructor") {
|
|
287
|
+
instance[name] = instance[name].bind(instance);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
284
291
|
function cleanJSON(obj) {
|
|
285
292
|
return JSON.parse(JSON.stringify(obj));
|
|
286
293
|
}
|
|
@@ -4027,7 +4034,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4027
4034
|
ZodError
|
|
4028
4035
|
});
|
|
4029
4036
|
|
|
4030
|
-
// ../../core/
|
|
4037
|
+
// ../../core/models/book.ts
|
|
4031
4038
|
var BookDesignRequest = class {
|
|
4032
4039
|
occasion;
|
|
4033
4040
|
style;
|
|
@@ -4069,7 +4076,7 @@ var bookPropsSchema = z.object({
|
|
|
4069
4076
|
state: z.enum(states).optional(),
|
|
4070
4077
|
guid: z.string().optional(),
|
|
4071
4078
|
cancelled_at: z.string().optional(),
|
|
4072
|
-
mb_client_timeout: z.
|
|
4079
|
+
mb_client_timeout: z.number().optional(),
|
|
4073
4080
|
user_id: z.string().optional(),
|
|
4074
4081
|
revision: z.number().optional()
|
|
4075
4082
|
});
|
|
@@ -4092,7 +4099,7 @@ var Book = class {
|
|
|
4092
4099
|
this.state = props.state;
|
|
4093
4100
|
this.guid = props.guid;
|
|
4094
4101
|
this.cancelled_at = props.cancelled_at;
|
|
4095
|
-
this.timeout = props.mb_client_timeout ?
|
|
4102
|
+
this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
|
|
4096
4103
|
this.user_id = props.user_id;
|
|
4097
4104
|
this.revision = props.revision;
|
|
4098
4105
|
}
|
|
@@ -4106,12 +4113,12 @@ var Book = class {
|
|
|
4106
4113
|
toBookProps() {
|
|
4107
4114
|
return {
|
|
4108
4115
|
...this,
|
|
4109
|
-
mb_client_timeout: this.timeout ?
|
|
4116
|
+
mb_client_timeout: this.timeout ? this.timeout / 1e3 : void 0
|
|
4110
4117
|
};
|
|
4111
4118
|
}
|
|
4112
4119
|
};
|
|
4113
4120
|
|
|
4114
|
-
// ../../core/
|
|
4121
|
+
// ../../core/models/design-request/image.ts
|
|
4115
4122
|
var Images = class {
|
|
4116
4123
|
// eslint-disable-next-line no-unused-vars
|
|
4117
4124
|
constructor(client, parentId, designRequestState) {
|
|
@@ -4131,10 +4138,7 @@ var Images = class {
|
|
|
4131
4138
|
} else {
|
|
4132
4139
|
this.images.push(image);
|
|
4133
4140
|
this.length = this.images.length;
|
|
4134
|
-
await this.client.engineAPI.images.addToBook(
|
|
4135
|
-
bookId: this.parentId,
|
|
4136
|
-
image: new ImageServer(image)
|
|
4137
|
-
});
|
|
4141
|
+
await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
|
|
4138
4142
|
return new Promise((resolve) => {
|
|
4139
4143
|
resolve(this.length);
|
|
4140
4144
|
});
|
|
@@ -4189,7 +4193,7 @@ function imageServerToImage(imageServer) {
|
|
|
4189
4193
|
};
|
|
4190
4194
|
}
|
|
4191
4195
|
|
|
4192
|
-
// ../../core/
|
|
4196
|
+
// ../../core/models/design-request/design-options.ts
|
|
4193
4197
|
var imageDensityOptionSchema = z.object({
|
|
4194
4198
|
maxPageCount: z.number(),
|
|
4195
4199
|
minPageCount: z.number(),
|
|
@@ -4205,8 +4209,23 @@ var imageDensityOptionsSchema = z.object({
|
|
|
4205
4209
|
var designOptionsSchema = z.object({
|
|
4206
4210
|
densities: imageDensityOptionsSchema
|
|
4207
4211
|
});
|
|
4212
|
+
var imageDensityOptionServerSchema = z.object({
|
|
4213
|
+
max_page_count: z.number(),
|
|
4214
|
+
min_page_count: z.number(),
|
|
4215
|
+
max_image_count: z.number(),
|
|
4216
|
+
avg_image_count: z.number(),
|
|
4217
|
+
min_image_count: z.number()
|
|
4218
|
+
});
|
|
4219
|
+
var imageDensityOptionsServerSchema = z.object({
|
|
4220
|
+
high: imageDensityOptionServerSchema,
|
|
4221
|
+
medium: imageDensityOptionServerSchema,
|
|
4222
|
+
low: imageDensityOptionServerSchema
|
|
4223
|
+
});
|
|
4224
|
+
var designOptionsServerSchema = z.object({
|
|
4225
|
+
densities: imageDensityOptionsServerSchema
|
|
4226
|
+
});
|
|
4208
4227
|
|
|
4209
|
-
// ../../core/
|
|
4228
|
+
// ../../core/models/design-request/index.ts
|
|
4210
4229
|
var DesignRequestOptions = {
|
|
4211
4230
|
occasion: occasions,
|
|
4212
4231
|
style: Object.keys(styles).map((key) => parseInt(key)),
|
|
@@ -4261,13 +4280,13 @@ var DesignRequest = class {
|
|
|
4261
4280
|
}
|
|
4262
4281
|
}
|
|
4263
4282
|
async getOptions(imageCount) {
|
|
4264
|
-
const options = designOptionsSchema.parse(
|
|
4265
|
-
await this.client.engineAPI.designOptions.retrieve(
|
|
4266
|
-
|
|
4267
|
-
imageCount
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
);
|
|
4283
|
+
const options = designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(
|
|
4284
|
+
await this.client.engineAPI.designOptions.retrieve(
|
|
4285
|
+
this.bookSize,
|
|
4286
|
+
imageCount || this.images.length,
|
|
4287
|
+
this.imageFilteringLevel
|
|
4288
|
+
)
|
|
4289
|
+
));
|
|
4271
4290
|
return options;
|
|
4272
4291
|
}
|
|
4273
4292
|
async submit(submitDesignRequestProps) {
|
|
@@ -4276,12 +4295,9 @@ var DesignRequest = class {
|
|
|
4276
4295
|
} else {
|
|
4277
4296
|
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
4278
4297
|
this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
|
|
4279
|
-
await this.client.engineAPI.books.update(
|
|
4280
|
-
bookId: this.parentId,
|
|
4281
|
-
payload: this.toBook()
|
|
4282
|
-
});
|
|
4298
|
+
await this.client.engineAPI.books.update(this.parentId, this.toBook());
|
|
4283
4299
|
this.updateDesignRequest(
|
|
4284
|
-
(await this.client.engineAPI.books.design(
|
|
4300
|
+
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4285
4301
|
);
|
|
4286
4302
|
this.getProgress();
|
|
4287
4303
|
return this;
|
|
@@ -4293,10 +4309,7 @@ var DesignRequest = class {
|
|
|
4293
4309
|
} else {
|
|
4294
4310
|
this.guid = guid;
|
|
4295
4311
|
this.updateDesignRequest(
|
|
4296
|
-
(await this.client.engineAPI.books.update(
|
|
4297
|
-
bookId: this.parentId,
|
|
4298
|
-
payload: this.toBook()
|
|
4299
|
-
})).toDesignRequestProps()
|
|
4312
|
+
(await this.client.engineAPI.books.update(this.parentId, this.toBook())).toDesignRequestProps()
|
|
4300
4313
|
);
|
|
4301
4314
|
return this.guid;
|
|
4302
4315
|
}
|
|
@@ -4310,9 +4323,7 @@ var DesignRequest = class {
|
|
|
4310
4323
|
throw new Error("Design request not submitted");
|
|
4311
4324
|
} else {
|
|
4312
4325
|
this.updateDesignRequest({
|
|
4313
|
-
...(await this.client.engineAPI.books.cancel(
|
|
4314
|
-
bookId: this.parentId
|
|
4315
|
-
})).toDesignRequestProps(),
|
|
4326
|
+
...(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps(),
|
|
4316
4327
|
state: "cancelled"
|
|
4317
4328
|
});
|
|
4318
4329
|
await this.eventHandler(cancelledEventDetail);
|
|
@@ -4321,31 +4332,22 @@ var DesignRequest = class {
|
|
|
4321
4332
|
}
|
|
4322
4333
|
async getJSON() {
|
|
4323
4334
|
if (this.state === "ready") {
|
|
4324
|
-
return await this.client.engineAPI.books.retrieveGalleon(
|
|
4325
|
-
bookId: this.parentId
|
|
4326
|
-
});
|
|
4335
|
+
return await this.client.engineAPI.books.retrieveGalleon(this.parentId);
|
|
4327
4336
|
} else {
|
|
4328
4337
|
throw new Error("Design request not ready");
|
|
4329
4338
|
}
|
|
4330
4339
|
}
|
|
4331
4340
|
async logEvent(name, data) {
|
|
4332
|
-
return await this.client.engineAPI.events.createBookEvent(
|
|
4333
|
-
bookId: this.parentId,
|
|
4334
|
-
name,
|
|
4335
|
-
data
|
|
4336
|
-
});
|
|
4341
|
+
return await this.client.engineAPI.events.createBookEvent(this.parentId, name, data);
|
|
4337
4342
|
}
|
|
4338
4343
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4339
4344
|
const customEvent = new CustomEvent(type, { detail });
|
|
4340
4345
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4341
4346
|
this.webSocket?.close();
|
|
4342
4347
|
if (statesToReport.includes(detail.slug)) {
|
|
4343
|
-
await this.client.engineAPI.books.report({
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
error: detail.slug === "error" ? "design" : "timeout",
|
|
4347
|
-
step: this.state
|
|
4348
|
-
}
|
|
4348
|
+
await this.client.engineAPI.books.report(this.parentId, {
|
|
4349
|
+
error: detail.slug === "error" ? "design" : "timeout",
|
|
4350
|
+
step: this.state
|
|
4349
4351
|
});
|
|
4350
4352
|
}
|
|
4351
4353
|
}
|
|
@@ -4398,7 +4400,7 @@ var DesignRequest = class {
|
|
|
4398
4400
|
}
|
|
4399
4401
|
};
|
|
4400
4402
|
|
|
4401
|
-
// ../../core/
|
|
4403
|
+
// ../../core/models/galleon.ts
|
|
4402
4404
|
var imageAssignmentSchema = z.object({
|
|
4403
4405
|
photoRefId: z.string(),
|
|
4404
4406
|
finalCrop: z.array(z.number())
|
|
@@ -4477,357 +4479,128 @@ var bookCreationRequestSchema = z.object({
|
|
|
4477
4479
|
reportingData: reportingDataSchema
|
|
4478
4480
|
});
|
|
4479
4481
|
|
|
4480
|
-
// ../../core/
|
|
4482
|
+
// ../../core/models/engine-api/endpoints/books.ts
|
|
4481
4483
|
var BooksEndpoints = class {
|
|
4482
4484
|
// eslint-disable-next-line no-unused-vars
|
|
4483
4485
|
constructor(engineAPI) {
|
|
4484
4486
|
this.engineAPI = engineAPI;
|
|
4487
|
+
bindThisToFunctions(this);
|
|
4485
4488
|
}
|
|
4486
|
-
create(
|
|
4489
|
+
create(book) {
|
|
4487
4490
|
return handleAsyncFunction(async () => {
|
|
4488
4491
|
const res = await this.engineAPI.fetcher.call({
|
|
4489
4492
|
path: "/v1/books",
|
|
4490
4493
|
options: {
|
|
4491
4494
|
method: "POST",
|
|
4492
4495
|
body: cleanJSON(book)
|
|
4493
|
-
}
|
|
4494
|
-
qs
|
|
4496
|
+
}
|
|
4495
4497
|
});
|
|
4498
|
+
bookPropsSchema.safeParse(res);
|
|
4496
4499
|
return new Book(res);
|
|
4497
4500
|
});
|
|
4498
4501
|
}
|
|
4499
|
-
retrieve(
|
|
4502
|
+
retrieve(bookId) {
|
|
4500
4503
|
return handleAsyncFunction(async () => {
|
|
4501
|
-
const res = await this.engineAPI.fetcher.call({
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
});
|
|
4505
|
-
const bookProps = bookPropsSchema.parse(res);
|
|
4506
|
-
return new Book(bookProps);
|
|
4504
|
+
const res = await this.engineAPI.fetcher.call({ path: `/v1/books/${bookId}` });
|
|
4505
|
+
bookPropsSchema.safeParse(res);
|
|
4506
|
+
return new Book(res);
|
|
4507
4507
|
});
|
|
4508
4508
|
}
|
|
4509
|
-
update(
|
|
4509
|
+
update(bookId, book) {
|
|
4510
4510
|
return handleAsyncFunction(async () => {
|
|
4511
4511
|
const res = await this.engineAPI.fetcher.call({
|
|
4512
4512
|
path: `/v1/books/${bookId}`,
|
|
4513
4513
|
options: {
|
|
4514
4514
|
method: "PUT",
|
|
4515
|
-
body: cleanJSON(
|
|
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
|
|
4515
|
+
body: cleanJSON(book)
|
|
4516
|
+
}
|
|
4529
4517
|
});
|
|
4518
|
+
bookPropsSchema.safeParse(res);
|
|
4519
|
+
return new Book(res);
|
|
4530
4520
|
});
|
|
4531
4521
|
}
|
|
4532
|
-
design(
|
|
4522
|
+
design(bookId) {
|
|
4533
4523
|
return handleAsyncFunction(async () => {
|
|
4534
4524
|
const res = await this.engineAPI.fetcher.call({
|
|
4535
4525
|
path: `/v1/books/${bookId}/design`,
|
|
4536
|
-
options: { method: "POST" }
|
|
4537
|
-
qs
|
|
4526
|
+
options: { method: "POST" }
|
|
4538
4527
|
});
|
|
4539
|
-
|
|
4540
|
-
return new Book(
|
|
4528
|
+
bookPropsSchema.safeParse(res);
|
|
4529
|
+
return new Book(res);
|
|
4541
4530
|
});
|
|
4542
4531
|
}
|
|
4543
|
-
cancel(
|
|
4532
|
+
cancel(bookId) {
|
|
4544
4533
|
return handleAsyncFunction(async () => {
|
|
4545
4534
|
const res = await this.engineAPI.fetcher.call({
|
|
4546
4535
|
path: `/v1/books/${bookId}/cancel`,
|
|
4547
|
-
options: { method: "POST" }
|
|
4548
|
-
qs
|
|
4536
|
+
options: { method: "POST" }
|
|
4549
4537
|
});
|
|
4550
|
-
|
|
4551
|
-
return new Book(
|
|
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);
|
|
4538
|
+
bookPropsSchema.safeParse(res);
|
|
4539
|
+
return new Book(res);
|
|
4561
4540
|
});
|
|
4562
4541
|
}
|
|
4563
|
-
report(
|
|
4542
|
+
report(bookId, report) {
|
|
4564
4543
|
return handleAsyncFunction(async () => {
|
|
4565
4544
|
await this.engineAPI.fetcher.call({
|
|
4566
4545
|
path: `/v1/books/${bookId}/report`,
|
|
4567
4546
|
options: {
|
|
4568
4547
|
method: "POST",
|
|
4569
4548
|
body: cleanJSON(report)
|
|
4570
|
-
}
|
|
4571
|
-
qs
|
|
4549
|
+
}
|
|
4572
4550
|
});
|
|
4573
4551
|
});
|
|
4574
4552
|
}
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4553
|
+
delete(bookId) {
|
|
4554
|
+
return handleAsyncFunction(async () => {
|
|
4555
|
+
await this.engineAPI.fetcher.call({
|
|
4556
|
+
path: `/v1/books/${bookId}`,
|
|
4557
|
+
options: { method: "DELETE" }
|
|
4558
|
+
});
|
|
4559
|
+
});
|
|
4582
4560
|
}
|
|
4583
|
-
|
|
4561
|
+
retrieveGalleon(bookId) {
|
|
4584
4562
|
return handleAsyncFunction(async () => {
|
|
4585
4563
|
const res = await this.engineAPI.fetcher.call({
|
|
4586
|
-
|
|
4587
|
-
path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
|
|
4588
|
-
qs: props.qs
|
|
4564
|
+
path: `/v1/books/${bookId}/format/galleon`
|
|
4589
4565
|
});
|
|
4590
|
-
return
|
|
4566
|
+
return bookCreationRequestSchema.parse(res);
|
|
4591
4567
|
});
|
|
4592
4568
|
}
|
|
4593
4569
|
};
|
|
4594
4570
|
|
|
4595
|
-
// ../../core/
|
|
4596
|
-
var
|
|
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 {
|
|
4571
|
+
// ../../core/models/engine-api/endpoints/design-options.ts
|
|
4572
|
+
var DesignOptionsEndpoints = class {
|
|
4769
4573
|
// eslint-disable-next-line no-unused-vars
|
|
4770
4574
|
constructor(engineAPI) {
|
|
4771
4575
|
this.engineAPI = engineAPI;
|
|
4576
|
+
bindThisToFunctions(this);
|
|
4772
4577
|
}
|
|
4773
|
-
|
|
4774
|
-
return handleAsyncFunction(async () => {
|
|
4775
|
-
const res = await this.engineAPI.fetcher.call({
|
|
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 }) {
|
|
4578
|
+
retrieve(bookSize, imageCount, imageFilteringLevel) {
|
|
4792
4579
|
return handleAsyncFunction(async () => {
|
|
4793
4580
|
const res = await this.engineAPI.fetcher.call({
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
method: "PUT",
|
|
4797
|
-
body: cleanJSON(camelCaseObjectKeysToSnakeCase({ ...payload }))
|
|
4798
|
-
}
|
|
4581
|
+
// eslint-disable-next-line max-len
|
|
4582
|
+
path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
|
|
4799
4583
|
});
|
|
4800
|
-
return
|
|
4584
|
+
return designOptionsServerSchema.parse(res);
|
|
4801
4585
|
});
|
|
4802
4586
|
}
|
|
4803
4587
|
};
|
|
4804
4588
|
|
|
4805
|
-
// ../../core/
|
|
4589
|
+
// ../../core/models/event.ts
|
|
4806
4590
|
var eventContextSchema = z.record(z.string(), z.unknown()).optional();
|
|
4807
4591
|
var eventSchema = z.object({
|
|
4808
4592
|
name: z.string(),
|
|
4809
|
-
context: eventContextSchema
|
|
4810
|
-
bookId: z.string(),
|
|
4811
|
-
createdAt: z.string()
|
|
4593
|
+
context: eventContextSchema
|
|
4812
4594
|
});
|
|
4813
4595
|
|
|
4814
|
-
// ../../core/
|
|
4815
|
-
var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
|
|
4596
|
+
// ../../core/models/engine-api/endpoints/events.ts
|
|
4816
4597
|
var EventsEndpoints = class {
|
|
4817
4598
|
// eslint-disable-next-line no-unused-vars
|
|
4818
4599
|
constructor(engineAPI) {
|
|
4819
4600
|
this.engineAPI = engineAPI;
|
|
4601
|
+
bindThisToFunctions(this);
|
|
4820
4602
|
}
|
|
4821
|
-
|
|
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 }) {
|
|
4603
|
+
createBookEvent(bookId, name, data) {
|
|
4831
4604
|
return handleAsyncFunction(async () => {
|
|
4832
4605
|
const body = {
|
|
4833
4606
|
name
|
|
@@ -4838,26 +4611,14 @@ var EventsEndpoints = class {
|
|
|
4838
4611
|
options: {
|
|
4839
4612
|
method: "POST",
|
|
4840
4613
|
body: cleanJSON(body)
|
|
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
|
|
4614
|
+
}
|
|
4855
4615
|
});
|
|
4616
|
+
return eventSchema.parse(res);
|
|
4856
4617
|
});
|
|
4857
4618
|
}
|
|
4858
4619
|
};
|
|
4859
4620
|
|
|
4860
|
-
// ../../core/
|
|
4621
|
+
// ../../core/models/fetcher.ts
|
|
4861
4622
|
var baseOptions = {
|
|
4862
4623
|
headers: {
|
|
4863
4624
|
"Content-Type": "application/json"
|
|
@@ -4878,14 +4639,12 @@ var Fetcher = class {
|
|
|
4878
4639
|
}
|
|
4879
4640
|
const baseOptions2 = { ...this.options };
|
|
4880
4641
|
const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
|
|
4881
|
-
const
|
|
4882
|
-
|
|
4883
|
-
if (res.status >= 200 && res.status < 300 && res.ok) {
|
|
4884
|
-
const result = await res.text();
|
|
4642
|
+
const res = await fetch(this.cleanUrl(new URL(props.path, this.baseUrl).href), options);
|
|
4643
|
+
if (res.status >= 200 && res.status < 300) {
|
|
4885
4644
|
try {
|
|
4886
|
-
return
|
|
4645
|
+
return await res.json();
|
|
4887
4646
|
} catch (error) {
|
|
4888
|
-
return
|
|
4647
|
+
return {};
|
|
4889
4648
|
}
|
|
4890
4649
|
} else {
|
|
4891
4650
|
let detail = res.statusText;
|
|
@@ -4900,102 +4659,70 @@ var Fetcher = class {
|
|
|
4900
4659
|
}
|
|
4901
4660
|
}
|
|
4902
4661
|
cleanUrl(url) {
|
|
4903
|
-
return url.
|
|
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
|
-
});
|
|
4662
|
+
return url.replaceAll(" ", "").trim();
|
|
4932
4663
|
}
|
|
4933
4664
|
};
|
|
4934
4665
|
|
|
4935
|
-
// ../../core/
|
|
4666
|
+
// ../../core/models/engine-api/endpoints/images.ts
|
|
4936
4667
|
var ImagesEndpoints = class {
|
|
4937
4668
|
// eslint-disable-next-line no-unused-vars
|
|
4938
4669
|
constructor(engineAPI) {
|
|
4939
4670
|
this.engineAPI = engineAPI;
|
|
4671
|
+
bindThisToFunctions(this);
|
|
4940
4672
|
}
|
|
4941
|
-
list(
|
|
4673
|
+
list(bookId) {
|
|
4942
4674
|
return handleAsyncFunction(async () => {
|
|
4943
4675
|
const res = await this.engineAPI.fetcher.call({
|
|
4944
|
-
path: `/v1/images/book/${bookId}
|
|
4945
|
-
qs
|
|
4676
|
+
path: `/v1/images/book/${bookId}`
|
|
4946
4677
|
});
|
|
4947
4678
|
return z.array(imageServerSchema).parse(res);
|
|
4948
4679
|
});
|
|
4949
4680
|
}
|
|
4950
|
-
|
|
4681
|
+
retrieve(imageId, bookId) {
|
|
4951
4682
|
return handleAsyncFunction(async () => {
|
|
4952
4683
|
const res = await this.engineAPI.fetcher.call({
|
|
4953
|
-
path: `/v1/images/book/${bookId}
|
|
4954
|
-
options: {
|
|
4955
|
-
method: "POST",
|
|
4956
|
-
body: cleanJSON(image)
|
|
4957
|
-
},
|
|
4958
|
-
qs
|
|
4684
|
+
path: `/v1/images/${imageId}/book/${bookId}/`
|
|
4959
4685
|
});
|
|
4960
4686
|
return imageServerSchema.parse(res);
|
|
4961
4687
|
});
|
|
4962
4688
|
}
|
|
4963
|
-
|
|
4689
|
+
update(imageId, bookId, image) {
|
|
4964
4690
|
return handleAsyncFunction(async () => {
|
|
4965
4691
|
const res = await this.engineAPI.fetcher.call({
|
|
4966
4692
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4967
|
-
|
|
4693
|
+
options: {
|
|
4694
|
+
method: "PUT",
|
|
4695
|
+
body: cleanJSON(image)
|
|
4696
|
+
}
|
|
4968
4697
|
});
|
|
4969
4698
|
return imageServerSchema.parse(res);
|
|
4970
4699
|
});
|
|
4971
4700
|
}
|
|
4972
|
-
|
|
4701
|
+
delete(imageId, bookId) {
|
|
4973
4702
|
return handleAsyncFunction(async () => {
|
|
4974
|
-
|
|
4703
|
+
await this.engineAPI.fetcher.call({
|
|
4975
4704
|
path: `/v1/images/${imageId}/book/${bookId}/`,
|
|
4976
4705
|
options: {
|
|
4977
|
-
method: "
|
|
4978
|
-
|
|
4979
|
-
},
|
|
4980
|
-
qs
|
|
4706
|
+
method: "DELETE"
|
|
4707
|
+
}
|
|
4981
4708
|
});
|
|
4982
|
-
return imageServerSchema.parse(res);
|
|
4983
4709
|
});
|
|
4984
4710
|
}
|
|
4985
|
-
|
|
4711
|
+
addToBook(bookId, image) {
|
|
4986
4712
|
return handleAsyncFunction(async () => {
|
|
4987
|
-
await this.engineAPI.fetcher.call({
|
|
4988
|
-
path: `/v1/images
|
|
4713
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4714
|
+
path: `/v1/images/book/${bookId}`,
|
|
4989
4715
|
options: {
|
|
4990
|
-
method: "
|
|
4991
|
-
|
|
4992
|
-
|
|
4716
|
+
method: "POST",
|
|
4717
|
+
body: cleanJSON(image)
|
|
4718
|
+
}
|
|
4993
4719
|
});
|
|
4720
|
+
return imageServerSchema.parse(res);
|
|
4994
4721
|
});
|
|
4995
4722
|
}
|
|
4996
4723
|
};
|
|
4997
4724
|
|
|
4998
|
-
// ../../core/
|
|
4725
|
+
// ../../core/models/spread.ts
|
|
4999
4726
|
var spreadServerSchema = z.object({
|
|
5000
4727
|
id: z.string().optional(),
|
|
5001
4728
|
book_id: z.string(),
|
|
@@ -5029,70 +4756,79 @@ var spreadSchema = z.object({
|
|
|
5029
4756
|
url: z.string().nullable().optional()
|
|
5030
4757
|
});
|
|
5031
4758
|
|
|
5032
|
-
// ../../core/
|
|
4759
|
+
// ../../core/models/engine-api/endpoints/spreads.ts
|
|
5033
4760
|
var SpreadsEndpoints = class {
|
|
5034
4761
|
// eslint-disable-next-line no-unused-vars
|
|
5035
4762
|
constructor(engineAPI) {
|
|
5036
4763
|
this.engineAPI = engineAPI;
|
|
4764
|
+
bindThisToFunctions(this);
|
|
5037
4765
|
}
|
|
5038
|
-
list(
|
|
4766
|
+
list(bookId) {
|
|
5039
4767
|
return handleAsyncFunction(async () => {
|
|
5040
4768
|
const res = await this.engineAPI.fetcher.call({
|
|
5041
|
-
path: `/v1/spreads/book/${bookId}
|
|
5042
|
-
qs
|
|
4769
|
+
path: `/v1/spreads/book/${bookId}`
|
|
5043
4770
|
});
|
|
5044
|
-
return z.array(
|
|
4771
|
+
return z.array(spreadServerSchema).parse(res);
|
|
5045
4772
|
});
|
|
5046
4773
|
}
|
|
5047
|
-
create(
|
|
4774
|
+
create(bookId, spread) {
|
|
5048
4775
|
return handleAsyncFunction(async () => {
|
|
5049
4776
|
const res = await this.engineAPI.fetcher.call({
|
|
5050
4777
|
path: `/v1/spreads/book/${bookId}`,
|
|
5051
4778
|
options: {
|
|
5052
4779
|
method: "POST",
|
|
5053
4780
|
body: cleanJSON(spread)
|
|
5054
|
-
}
|
|
5055
|
-
qs
|
|
4781
|
+
}
|
|
5056
4782
|
});
|
|
5057
|
-
return
|
|
4783
|
+
return spreadServerSchema.parse(res);
|
|
5058
4784
|
});
|
|
5059
4785
|
}
|
|
5060
|
-
retrieve(
|
|
4786
|
+
retrieve(spreadId, bookId) {
|
|
5061
4787
|
return handleAsyncFunction(async () => {
|
|
5062
4788
|
const res = await this.engineAPI.fetcher.call({
|
|
5063
|
-
path: `/v1/spreads/${spreadId}/book/${bookId}
|
|
5064
|
-
qs
|
|
4789
|
+
path: `/v1/spreads/${spreadId}/book/${bookId}`
|
|
5065
4790
|
});
|
|
5066
|
-
return
|
|
4791
|
+
return spreadServerSchema.parse(res);
|
|
5067
4792
|
});
|
|
5068
4793
|
}
|
|
5069
|
-
update(
|
|
4794
|
+
update(spreadId, bookId, spread) {
|
|
5070
4795
|
return handleAsyncFunction(async () => {
|
|
5071
4796
|
const res = await this.engineAPI.fetcher.call({
|
|
5072
4797
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5073
4798
|
options: {
|
|
5074
4799
|
method: "PUT",
|
|
5075
|
-
body: cleanJSON(
|
|
5076
|
-
}
|
|
5077
|
-
qs
|
|
4800
|
+
body: cleanJSON(spread)
|
|
4801
|
+
}
|
|
5078
4802
|
});
|
|
5079
|
-
return
|
|
4803
|
+
return spreadServerSchema.parse(res);
|
|
5080
4804
|
});
|
|
5081
4805
|
}
|
|
5082
|
-
delete(
|
|
4806
|
+
delete(spreadId, bookId) {
|
|
5083
4807
|
return handleAsyncFunction(async () => {
|
|
5084
4808
|
await this.engineAPI.fetcher.call({
|
|
5085
4809
|
path: `/v1/spreads/${spreadId}/book/${bookId}`,
|
|
5086
4810
|
options: {
|
|
5087
4811
|
method: "DELETE"
|
|
5088
|
-
}
|
|
5089
|
-
qs
|
|
4812
|
+
}
|
|
5090
4813
|
});
|
|
5091
4814
|
});
|
|
5092
4815
|
}
|
|
5093
4816
|
};
|
|
5094
4817
|
|
|
5095
|
-
// ../../core/
|
|
4818
|
+
// ../../core/models/storyboard-item.ts
|
|
4819
|
+
var StoryboardItemImageFaceServerSchema = z.object({
|
|
4820
|
+
score: z.number(),
|
|
4821
|
+
bounding_box: z.object({
|
|
4822
|
+
x: z.number(),
|
|
4823
|
+
y: z.number(),
|
|
4824
|
+
width: z.number(),
|
|
4825
|
+
height: z.number()
|
|
4826
|
+
}),
|
|
4827
|
+
size: z.number(),
|
|
4828
|
+
eyes_open_score: z.number(),
|
|
4829
|
+
smile_score: z.number(),
|
|
4830
|
+
facing_camera_score: z.number()
|
|
4831
|
+
});
|
|
5096
4832
|
var StoryboardItemImageFaceSchema = z.object({
|
|
5097
4833
|
score: z.number(),
|
|
5098
4834
|
boundingBox: z.object({
|
|
@@ -5106,14 +4842,27 @@ var StoryboardItemImageFaceSchema = z.object({
|
|
|
5106
4842
|
smileScore: z.number(),
|
|
5107
4843
|
facingCameraScore: z.number()
|
|
5108
4844
|
});
|
|
5109
|
-
var
|
|
4845
|
+
var StoryboardItemImageServerSchema = z.object({
|
|
5110
4846
|
id: z.string(),
|
|
5111
4847
|
url: z.string(),
|
|
5112
4848
|
category: z.string(),
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
4849
|
+
aesthetic_score: z.number(),
|
|
4850
|
+
faces: z.array(StoryboardItemImageFaceServerSchema),
|
|
4851
|
+
roi: z.object({
|
|
4852
|
+
x: z.number(),
|
|
4853
|
+
y: z.number(),
|
|
4854
|
+
width: z.number(),
|
|
4855
|
+
height: z.number()
|
|
5116
4856
|
}),
|
|
4857
|
+
taken_at: z.number(),
|
|
4858
|
+
width: z.number(),
|
|
4859
|
+
height: z.number()
|
|
4860
|
+
});
|
|
4861
|
+
var StoryboardItemImageSchema = z.object({
|
|
4862
|
+
id: z.string(),
|
|
4863
|
+
url: z.string(),
|
|
4864
|
+
category: z.string(),
|
|
4865
|
+
aestheticScore: z.number(),
|
|
5117
4866
|
faces: z.array(StoryboardItemImageFaceSchema),
|
|
5118
4867
|
roi: z.object({
|
|
5119
4868
|
x: z.number(),
|
|
@@ -5125,6 +4874,21 @@ var StoryboardItemImageSchema = z.object({
|
|
|
5125
4874
|
width: z.number(),
|
|
5126
4875
|
height: z.number()
|
|
5127
4876
|
});
|
|
4877
|
+
var StoryboardItemServerSchema = z.object({
|
|
4878
|
+
id: z.string(),
|
|
4879
|
+
sequence: z.number(),
|
|
4880
|
+
book_id: z.string(),
|
|
4881
|
+
similarity: z.number(),
|
|
4882
|
+
duplicate: z.boolean(),
|
|
4883
|
+
selected: z.boolean(),
|
|
4884
|
+
surface_weight: z.number(),
|
|
4885
|
+
front_cover: z.boolean().optional(),
|
|
4886
|
+
back_cover: z.boolean().optional(),
|
|
4887
|
+
scene: z.number(),
|
|
4888
|
+
subscene: z.number(),
|
|
4889
|
+
spine_break: z.boolean().optional(),
|
|
4890
|
+
image: StoryboardItemImageServerSchema
|
|
4891
|
+
});
|
|
5128
4892
|
var StoryboardItemSchema = z.object({
|
|
5129
4893
|
id: z.string(),
|
|
5130
4894
|
sequence: z.number(),
|
|
@@ -5141,138 +4905,34 @@ var StoryboardItemSchema = z.object({
|
|
|
5141
4905
|
image: StoryboardItemImageSchema
|
|
5142
4906
|
});
|
|
5143
4907
|
|
|
5144
|
-
// ../../core/
|
|
4908
|
+
// ../../core/models/engine-api/endpoints/storyboard-items.ts
|
|
5145
4909
|
var StoryboardItemsEndpoints = class {
|
|
5146
4910
|
// eslint-disable-next-line no-unused-vars
|
|
5147
4911
|
constructor(engineAPI) {
|
|
5148
4912
|
this.engineAPI = engineAPI;
|
|
4913
|
+
bindThisToFunctions(this);
|
|
5149
4914
|
}
|
|
5150
|
-
list(
|
|
5151
|
-
return handleAsyncFunction(async () => {
|
|
5152
|
-
const res = await this.engineAPI.fetcher.call({
|
|
5153
|
-
path: `/v1/storyboarditems/book/${props.bookId}`
|
|
5154
|
-
});
|
|
5155
|
-
return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
|
|
5156
|
-
});
|
|
5157
|
-
}
|
|
5158
|
-
};
|
|
5159
|
-
|
|
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 }) {
|
|
4915
|
+
list(bookId) {
|
|
5246
4916
|
return handleAsyncFunction(async () => {
|
|
5247
4917
|
const res = await this.engineAPI.fetcher.call({
|
|
5248
|
-
path: `/v1/
|
|
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
|
-
}
|
|
4918
|
+
path: `/v1/storyboarditems/book/${bookId}`
|
|
5263
4919
|
});
|
|
5264
|
-
return
|
|
4920
|
+
return z.array(StoryboardItemServerSchema).parse(res);
|
|
5265
4921
|
});
|
|
5266
4922
|
}
|
|
5267
4923
|
};
|
|
5268
4924
|
|
|
5269
|
-
// ../../core/
|
|
4925
|
+
// ../../core/models/engine-api/index.ts
|
|
5270
4926
|
var EngineAPI = class {
|
|
4927
|
+
baseUrl;
|
|
4928
|
+
apiKey;
|
|
5271
4929
|
fetcher;
|
|
5272
4930
|
constructor(baseUrl, apiKey) {
|
|
4931
|
+
this.baseUrl = new URL(baseUrl);
|
|
4932
|
+
this.apiKey = apiKey;
|
|
5273
4933
|
const options = {
|
|
5274
4934
|
headers: {
|
|
5275
|
-
"Authorization": `API-Key ${apiKey}`
|
|
4935
|
+
"Authorization": `API-Key ${this.apiKey}`
|
|
5276
4936
|
}
|
|
5277
4937
|
};
|
|
5278
4938
|
this.fetcher = new Fetcher(baseUrl, options);
|
|
@@ -5280,19 +4940,16 @@ var EngineAPI = class {
|
|
|
5280
4940
|
books = new BooksEndpoints(this);
|
|
5281
4941
|
designOptions = new DesignOptionsEndpoints(this);
|
|
5282
4942
|
events = new EventsEndpoints(this);
|
|
5283
|
-
embellishments = new EmbellishmentsEndpoints(this);
|
|
5284
|
-
fonts = new FontsEndpoints(this);
|
|
5285
4943
|
images = new ImagesEndpoints(this);
|
|
5286
|
-
spreads = new SpreadsEndpoints(this);
|
|
5287
4944
|
storyboardItems = new StoryboardItemsEndpoints(this);
|
|
5288
|
-
|
|
4945
|
+
spreads = new SpreadsEndpoints(this);
|
|
5289
4946
|
};
|
|
5290
4947
|
|
|
5291
4948
|
// ../../core/config.ts
|
|
5292
|
-
var defaultApiHost = "https://api.
|
|
5293
|
-
var defaultWebSocketHost = "wss://socket.
|
|
4949
|
+
var defaultApiHost = "https://api.sfly-sls.magicbook.io";
|
|
4950
|
+
var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
|
|
5294
4951
|
|
|
5295
|
-
// ../../core/
|
|
4952
|
+
// ../../core/models/client.ts
|
|
5296
4953
|
var MagicBookClient = class {
|
|
5297
4954
|
constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
|
|
5298
4955
|
this.apiKey = apiKey;
|
|
@@ -5303,7 +4960,7 @@ var MagicBookClient = class {
|
|
|
5303
4960
|
engineAPI;
|
|
5304
4961
|
async createDesignRequest(designRequestProps) {
|
|
5305
4962
|
if (designRequestProps.userId) {
|
|
5306
|
-
const book = await this.engineAPI.books.create({
|
|
4963
|
+
const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
|
|
5307
4964
|
return new DesignRequest(book.id, this, designRequestProps);
|
|
5308
4965
|
} else {
|
|
5309
4966
|
throw new Error("userId is required");
|
|
@@ -5315,17 +4972,10 @@ export {
|
|
|
5315
4972
|
BookDesignRequest,
|
|
5316
4973
|
DesignRequest,
|
|
5317
4974
|
DesignRequestOptions,
|
|
5318
|
-
EmbellishmentsEndpoints,
|
|
5319
|
-
EngineAPI,
|
|
5320
4975
|
ImageServer,
|
|
5321
4976
|
Images,
|
|
5322
4977
|
MagicBookClient,
|
|
5323
|
-
StoryboardItemImageFaceSchema,
|
|
5324
|
-
StoryboardItemImageSchema,
|
|
5325
|
-
StoryboardItemSchema,
|
|
5326
|
-
StylesEndpoints,
|
|
5327
4978
|
assetSchema,
|
|
5328
|
-
backgroundSchema,
|
|
5329
4979
|
bookCreationRequestSchema,
|
|
5330
4980
|
bookDesignRequestSchema,
|
|
5331
4981
|
bookPropsSchema,
|
|
@@ -5333,68 +4983,34 @@ export {
|
|
|
5333
4983
|
canSubmitDesignRequest,
|
|
5334
4984
|
cancelledEventDetail,
|
|
5335
4985
|
canvasSchema,
|
|
5336
|
-
colorSchema,
|
|
5337
|
-
compatibleBackgroundSchema,
|
|
5338
4986
|
coverTypes,
|
|
5339
4987
|
designOptionsSchema,
|
|
5340
|
-
|
|
5341
|
-
embellishmentBackgroundListSchema,
|
|
5342
|
-
embellishmentBackgroundSchema,
|
|
5343
|
-
embellishmentBandSchema,
|
|
5344
|
-
embellishmentBaseSchema,
|
|
5345
|
-
embellishmentFrameSchema,
|
|
5346
|
-
embellishmentGraphicStickerSchema,
|
|
4988
|
+
designOptionsServerSchema,
|
|
5347
4989
|
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,
|
|
5366
4990
|
imageAssignmentSchema,
|
|
5367
4991
|
imageDensities,
|
|
5368
4992
|
imageDensityOptionSchema,
|
|
4993
|
+
imageDensityOptionServerSchema,
|
|
5369
4994
|
imageDensityOptionsSchema,
|
|
4995
|
+
imageDensityOptionsServerSchema,
|
|
5370
4996
|
imageFilteringLevels,
|
|
5371
4997
|
imageServerSchema,
|
|
5372
4998
|
imageServerToImage,
|
|
5373
4999
|
isDesignRequestSubmitted,
|
|
5374
|
-
layoutConstraintSchema,
|
|
5375
|
-
layoutConstraintsClasses,
|
|
5376
|
-
layoutConstraintsSchema,
|
|
5377
5000
|
magicShopBookSchema,
|
|
5378
5001
|
occasions,
|
|
5379
5002
|
pageSchema,
|
|
5380
5003
|
pageTypes,
|
|
5381
|
-
paginatedResponseSchema,
|
|
5382
5004
|
photoMetadataSchema,
|
|
5383
5005
|
photoStripSchema,
|
|
5384
5006
|
positionSchema,
|
|
5385
5007
|
propertySchema,
|
|
5386
5008
|
reportingDataSchema,
|
|
5387
|
-
spreadSchema,
|
|
5388
|
-
spreadServerSchema,
|
|
5389
5009
|
states,
|
|
5390
5010
|
statesToCloseWS,
|
|
5391
5011
|
statesToReport,
|
|
5392
|
-
styleBaseSchema,
|
|
5393
|
-
styleFontSchema,
|
|
5394
|
-
styleSchema,
|
|
5395
5012
|
styles,
|
|
5396
5013
|
textStickerLevels,
|
|
5397
|
-
timeoutEventDetail
|
|
5398
|
-
whitespaceSchema
|
|
5014
|
+
timeoutEventDetail
|
|
5399
5015
|
};
|
|
5400
5016
|
//# sourceMappingURL=index.js.map
|