@magiclabs.ai/magicbook-client 0.7.5-canary.1 → 0.7.6-canary

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.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
- if (snakeCaseObject[camelCaseKey] === null) {
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/types/book.ts
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.string().optional(),
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 ? parseInt(props.mb_client_timeout) * 1e3 : void 0;
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 ? (this.timeout / 1e3).toString() : void 0
4116
+ mb_client_timeout: this.timeout ? this.timeout / 1e3 : void 0
4110
4117
  };
4111
4118
  }
4112
4119
  };
4113
4120
 
4114
- // ../../core/types/design-request/image.ts
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/types/design-request/design-options.ts
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/types/design-request/index.ts
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)),
@@ -4262,27 +4281,31 @@ var DesignRequest = class {
4262
4281
  }
4263
4282
  async getOptions(imageCount) {
4264
4283
  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
- })
4284
+ snakeCaseObjectKeysToCamelCase(
4285
+ await this.client.engineAPI.designOptions.retrieve(
4286
+ this.bookSize,
4287
+ imageCount || this.images.length,
4288
+ this.imageFilteringLevel
4289
+ )
4290
+ )
4270
4291
  );
4271
4292
  return options;
4272
4293
  }
4294
+ async getAlternateLayouts(pageNumber) {
4295
+ if (this.state === "ready") {
4296
+ return await this.client.engineAPI.spreads.layouts(this.parentId, pageNumber);
4297
+ } else {
4298
+ throw new Error("Design request not ready");
4299
+ }
4300
+ }
4273
4301
  async submit(submitDesignRequestProps) {
4274
4302
  if (!canSubmitDesignRequest(this.state)) {
4275
4303
  throw new Error("You need to wait for the current design request to be ready before submitting a new one");
4276
4304
  } else {
4277
4305
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
4278
4306
  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
- });
4283
- this.updateDesignRequest(
4284
- (await this.client.engineAPI.books.design({ bookId: this.parentId })).toDesignRequestProps()
4285
- );
4307
+ await this.client.engineAPI.books.update(this.parentId, this.toBook());
4308
+ this.updateDesignRequest((await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps());
4286
4309
  this.getProgress();
4287
4310
  return this;
4288
4311
  }
@@ -4293,10 +4316,7 @@ var DesignRequest = class {
4293
4316
  } else {
4294
4317
  this.guid = guid;
4295
4318
  this.updateDesignRequest(
4296
- (await this.client.engineAPI.books.update({
4297
- bookId: this.parentId,
4298
- payload: this.toBook()
4299
- })).toDesignRequestProps()
4319
+ (await this.client.engineAPI.books.update(this.parentId, this.toBook())).toDesignRequestProps()
4300
4320
  );
4301
4321
  return this.guid;
4302
4322
  }
@@ -4310,9 +4330,7 @@ var DesignRequest = class {
4310
4330
  throw new Error("Design request not submitted");
4311
4331
  } else {
4312
4332
  this.updateDesignRequest({
4313
- ...(await this.client.engineAPI.books.cancel({
4314
- bookId: this.parentId
4315
- })).toDesignRequestProps(),
4333
+ ...(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps(),
4316
4334
  state: "cancelled"
4317
4335
  });
4318
4336
  await this.eventHandler(cancelledEventDetail);
@@ -4321,31 +4339,22 @@ var DesignRequest = class {
4321
4339
  }
4322
4340
  async getJSON() {
4323
4341
  if (this.state === "ready") {
4324
- return await this.client.engineAPI.books.retrieveGalleon({
4325
- bookId: this.parentId
4326
- });
4342
+ return await this.client.engineAPI.books.retrieveGalleon(this.parentId);
4327
4343
  } else {
4328
4344
  throw new Error("Design request not ready");
4329
4345
  }
4330
4346
  }
4331
4347
  async logEvent(name, data) {
4332
- return await this.client.engineAPI.events.createBookEvent({
4333
- bookId: this.parentId,
4334
- name,
4335
- data
4336
- });
4348
+ return await this.client.engineAPI.events.createBookEvent(this.parentId, name, data);
4337
4349
  }
4338
4350
  async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
4339
4351
  const customEvent = new CustomEvent(type, { detail });
4340
4352
  if (statesToCloseWS.includes(detail.slug)) {
4341
4353
  this.webSocket?.close();
4342
4354
  if (statesToReport.includes(detail.slug)) {
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
- }
4355
+ await this.client.engineAPI.books.report(this.parentId, {
4356
+ error: detail.slug === "error" ? "design" : "timeout",
4357
+ step: this.state
4349
4358
  });
4350
4359
  }
4351
4360
  }
@@ -4398,7 +4407,7 @@ var DesignRequest = class {
4398
4407
  }
4399
4408
  };
4400
4409
 
4401
- // ../../core/types/galleon.ts
4410
+ // ../../core/models/galleon.ts
4402
4411
  var imageAssignmentSchema = z.object({
4403
4412
  photoRefId: z.string(),
4404
4413
  finalCrop: z.array(z.number())
@@ -4477,357 +4486,128 @@ var bookCreationRequestSchema = z.object({
4477
4486
  reportingData: reportingDataSchema
4478
4487
  });
4479
4488
 
4480
- // ../../core/types/engine-api/endpoints/books.ts
4489
+ // ../../core/models/engine-api/endpoints/books.ts
4481
4490
  var BooksEndpoints = class {
4482
4491
  // eslint-disable-next-line no-unused-vars
4483
4492
  constructor(engineAPI) {
4484
4493
  this.engineAPI = engineAPI;
4494
+ bindThisToFunctions(this);
4485
4495
  }
4486
- create({ book, qs }) {
4496
+ create(book) {
4487
4497
  return handleAsyncFunction(async () => {
4488
4498
  const res = await this.engineAPI.fetcher.call({
4489
4499
  path: "/v1/books",
4490
4500
  options: {
4491
4501
  method: "POST",
4492
4502
  body: cleanJSON(book)
4493
- },
4494
- qs
4503
+ }
4495
4504
  });
4505
+ bookPropsSchema.safeParse(res);
4496
4506
  return new Book(res);
4497
4507
  });
4498
4508
  }
4499
- retrieve({ bookId, qs }) {
4509
+ retrieve(bookId) {
4500
4510
  return handleAsyncFunction(async () => {
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);
4511
+ const res = await this.engineAPI.fetcher.call({ path: `/v1/books/${bookId}` });
4512
+ bookPropsSchema.safeParse(res);
4513
+ return new Book(res);
4507
4514
  });
4508
4515
  }
4509
- update({ bookId, payload, qs }) {
4516
+ update(bookId, book) {
4510
4517
  return handleAsyncFunction(async () => {
4511
4518
  const res = await this.engineAPI.fetcher.call({
4512
4519
  path: `/v1/books/${bookId}`,
4513
4520
  options: {
4514
4521
  method: "PUT",
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
4522
+ body: cleanJSON(book)
4523
+ }
4529
4524
  });
4525
+ bookPropsSchema.safeParse(res);
4526
+ return new Book(res);
4530
4527
  });
4531
4528
  }
4532
- design({ bookId, qs }) {
4529
+ design(bookId) {
4533
4530
  return handleAsyncFunction(async () => {
4534
4531
  const res = await this.engineAPI.fetcher.call({
4535
4532
  path: `/v1/books/${bookId}/design`,
4536
- options: { method: "POST" },
4537
- qs
4533
+ options: { method: "POST" }
4538
4534
  });
4539
- const bookProps = bookPropsSchema.parse(res);
4540
- return new Book(bookProps);
4535
+ bookPropsSchema.safeParse(res);
4536
+ return new Book(res);
4541
4537
  });
4542
4538
  }
4543
- cancel({ bookId, qs }) {
4539
+ cancel(bookId) {
4544
4540
  return handleAsyncFunction(async () => {
4545
4541
  const res = await this.engineAPI.fetcher.call({
4546
4542
  path: `/v1/books/${bookId}/cancel`,
4547
- options: { method: "POST" },
4548
- qs
4543
+ options: { method: "POST" }
4549
4544
  });
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);
4545
+ bookPropsSchema.safeParse(res);
4546
+ return new Book(res);
4561
4547
  });
4562
4548
  }
4563
- report({ bookId, report, qs }) {
4549
+ report(bookId, report) {
4564
4550
  return handleAsyncFunction(async () => {
4565
4551
  await this.engineAPI.fetcher.call({
4566
4552
  path: `/v1/books/${bookId}/report`,
4567
4553
  options: {
4568
4554
  method: "POST",
4569
4555
  body: cleanJSON(report)
4570
- },
4571
- qs
4556
+ }
4572
4557
  });
4573
4558
  });
4574
4559
  }
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;
4560
+ delete(bookId) {
4561
+ return handleAsyncFunction(async () => {
4562
+ await this.engineAPI.fetcher.call({
4563
+ path: `/v1/books/${bookId}`,
4564
+ options: { method: "DELETE" }
4565
+ });
4566
+ });
4582
4567
  }
4583
- retrieve(props) {
4568
+ retrieveGalleon(bookId) {
4584
4569
  return handleAsyncFunction(async () => {
4585
4570
  const res = await this.engineAPI.fetcher.call({
4586
- // eslint-disable-next-line max-len
4587
- path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
4588
- qs: props.qs
4571
+ path: `/v1/books/${bookId}/format/galleon`
4589
4572
  });
4590
- return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4573
+ return bookCreationRequestSchema.parse(res);
4591
4574
  });
4592
4575
  }
4593
4576
  };
4594
4577
 
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 {
4578
+ // ../../core/models/engine-api/endpoints/design-options.ts
4579
+ var DesignOptionsEndpoints = class {
4769
4580
  // eslint-disable-next-line no-unused-vars
4770
4581
  constructor(engineAPI) {
4771
4582
  this.engineAPI = engineAPI;
4583
+ bindThisToFunctions(this);
4772
4584
  }
4773
- list({ styleSlug, qs }) {
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 }) {
4585
+ retrieve(bookSize, imageCount, imageFilteringLevel) {
4783
4586
  return handleAsyncFunction(async () => {
4784
4587
  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
- }
4588
+ // eslint-disable-next-line max-len
4589
+ path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
4799
4590
  });
4800
- return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
4591
+ return designOptionsServerSchema.parse(res);
4801
4592
  });
4802
4593
  }
4803
4594
  };
4804
4595
 
4805
- // ../../core/types/event.ts
4596
+ // ../../core/models/event.ts
4806
4597
  var eventContextSchema = z.record(z.string(), z.unknown()).optional();
4807
4598
  var eventSchema = z.object({
4808
4599
  name: z.string(),
4809
- context: eventContextSchema,
4810
- bookId: z.string(),
4811
- createdAt: z.string()
4600
+ context: eventContextSchema
4812
4601
  });
4813
4602
 
4814
- // ../../core/types/engine-api/endpoints/events.ts
4815
- var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
4603
+ // ../../core/models/engine-api/endpoints/events.ts
4816
4604
  var EventsEndpoints = class {
4817
4605
  // eslint-disable-next-line no-unused-vars
4818
4606
  constructor(engineAPI) {
4819
4607
  this.engineAPI = engineAPI;
4608
+ bindThisToFunctions(this);
4820
4609
  }
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 }) {
4610
+ createBookEvent(bookId, name, data) {
4831
4611
  return handleAsyncFunction(async () => {
4832
4612
  const body = {
4833
4613
  name
@@ -4838,26 +4618,14 @@ var EventsEndpoints = class {
4838
4618
  options: {
4839
4619
  method: "POST",
4840
4620
  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
4621
+ }
4855
4622
  });
4623
+ return eventSchema.parse(res);
4856
4624
  });
4857
4625
  }
4858
4626
  };
4859
4627
 
4860
- // ../../core/types/fetcher.ts
4628
+ // ../../core/models/fetcher.ts
4861
4629
  var baseOptions = {
4862
4630
  headers: {
4863
4631
  "Content-Type": "application/json"
@@ -4878,14 +4646,12 @@ var Fetcher = class {
4878
4646
  }
4879
4647
  const baseOptions2 = { ...this.options };
4880
4648
  const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
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();
4649
+ const res = await fetch(this.cleanUrl(new URL(props.path, this.baseUrl).href), options);
4650
+ if (res.status >= 200 && res.status < 300) {
4885
4651
  try {
4886
- return JSON.parse(result);
4652
+ return await res.json();
4887
4653
  } catch (error) {
4888
- return result;
4654
+ return {};
4889
4655
  }
4890
4656
  } else {
4891
4657
  let detail = res.statusText;
@@ -4900,102 +4666,70 @@ var Fetcher = class {
4900
4666
  }
4901
4667
  }
4902
4668
  cleanUrl(url) {
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
- });
4669
+ return url.replaceAll(" ", "").trim();
4932
4670
  }
4933
4671
  };
4934
4672
 
4935
- // ../../core/types/engine-api/endpoints/images.ts
4673
+ // ../../core/models/engine-api/endpoints/images.ts
4936
4674
  var ImagesEndpoints = class {
4937
4675
  // eslint-disable-next-line no-unused-vars
4938
4676
  constructor(engineAPI) {
4939
4677
  this.engineAPI = engineAPI;
4678
+ bindThisToFunctions(this);
4940
4679
  }
4941
- list({ bookId, qs }) {
4680
+ list(bookId) {
4942
4681
  return handleAsyncFunction(async () => {
4943
4682
  const res = await this.engineAPI.fetcher.call({
4944
- path: `/v1/images/book/${bookId}`,
4945
- qs
4683
+ path: `/v1/images/book/${bookId}`
4946
4684
  });
4947
4685
  return z.array(imageServerSchema).parse(res);
4948
4686
  });
4949
4687
  }
4950
- addToBook({ bookId, image, qs }) {
4688
+ retrieve(imageId, bookId) {
4951
4689
  return handleAsyncFunction(async () => {
4952
4690
  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
4691
+ path: `/v1/images/${imageId}/book/${bookId}/`
4959
4692
  });
4960
4693
  return imageServerSchema.parse(res);
4961
4694
  });
4962
4695
  }
4963
- retrieve({ bookId, imageId, qs }) {
4696
+ update(imageId, bookId, image) {
4964
4697
  return handleAsyncFunction(async () => {
4965
4698
  const res = await this.engineAPI.fetcher.call({
4966
4699
  path: `/v1/images/${imageId}/book/${bookId}/`,
4967
- qs
4700
+ options: {
4701
+ method: "PUT",
4702
+ body: cleanJSON(image)
4703
+ }
4968
4704
  });
4969
4705
  return imageServerSchema.parse(res);
4970
4706
  });
4971
4707
  }
4972
- update({ bookId, imageId, payload, qs }) {
4708
+ delete(imageId, bookId) {
4973
4709
  return handleAsyncFunction(async () => {
4974
- const res = await this.engineAPI.fetcher.call({
4710
+ await this.engineAPI.fetcher.call({
4975
4711
  path: `/v1/images/${imageId}/book/${bookId}/`,
4976
4712
  options: {
4977
- method: "PUT",
4978
- body: cleanJSON(payload)
4979
- },
4980
- qs
4713
+ method: "DELETE"
4714
+ }
4981
4715
  });
4982
- return imageServerSchema.parse(res);
4983
4716
  });
4984
4717
  }
4985
- delete({ bookId, imageId, qs }) {
4718
+ addToBook(bookId, image) {
4986
4719
  return handleAsyncFunction(async () => {
4987
- await this.engineAPI.fetcher.call({
4988
- path: `/v1/images/${imageId}/book/${bookId}/`,
4720
+ const res = await this.engineAPI.fetcher.call({
4721
+ path: `/v1/images/book/${bookId}`,
4989
4722
  options: {
4990
- method: "DELETE"
4991
- },
4992
- qs
4723
+ method: "POST",
4724
+ body: cleanJSON(image)
4725
+ }
4993
4726
  });
4727
+ return imageServerSchema.parse(res);
4994
4728
  });
4995
4729
  }
4996
4730
  };
4997
4731
 
4998
- // ../../core/types/spread.ts
4732
+ // ../../core/models/spread.ts
4999
4733
  var spreadServerSchema = z.object({
5000
4734
  id: z.string().optional(),
5001
4735
  book_id: z.string(),
@@ -5029,70 +4763,94 @@ var spreadSchema = z.object({
5029
4763
  url: z.string().nullable().optional()
5030
4764
  });
5031
4765
 
5032
- // ../../core/types/engine-api/endpoints/spreads.ts
4766
+ // ../../core/models/engine-api/endpoints/spreads.ts
5033
4767
  var SpreadsEndpoints = class {
5034
4768
  // eslint-disable-next-line no-unused-vars
5035
4769
  constructor(engineAPI) {
5036
4770
  this.engineAPI = engineAPI;
4771
+ bindThisToFunctions(this);
5037
4772
  }
5038
- list({ bookId, qs }) {
4773
+ list(bookId) {
5039
4774
  return handleAsyncFunction(async () => {
5040
4775
  const res = await this.engineAPI.fetcher.call({
5041
- path: `/v1/spreads/book/${bookId}`,
5042
- qs
4776
+ path: `/v1/spreads/book/${bookId}`
5043
4777
  });
5044
- return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
4778
+ return z.array(spreadServerSchema).parse(res);
5045
4779
  });
5046
4780
  }
5047
- create({ bookId, spread, qs }) {
4781
+ create(bookId, spread) {
5048
4782
  return handleAsyncFunction(async () => {
5049
4783
  const res = await this.engineAPI.fetcher.call({
5050
4784
  path: `/v1/spreads/book/${bookId}`,
5051
4785
  options: {
5052
4786
  method: "POST",
5053
4787
  body: cleanJSON(spread)
5054
- },
5055
- qs
4788
+ }
5056
4789
  });
5057
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4790
+ return spreadServerSchema.parse(res);
5058
4791
  });
5059
4792
  }
5060
- retrieve({ bookId, spreadId, qs }) {
4793
+ retrieve(spreadId, bookId) {
5061
4794
  return handleAsyncFunction(async () => {
5062
4795
  const res = await this.engineAPI.fetcher.call({
5063
- path: `/v1/spreads/${spreadId}/book/${bookId}`,
5064
- qs
4796
+ path: `/v1/spreads/${spreadId}/book/${bookId}`
5065
4797
  });
5066
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4798
+ return spreadServerSchema.parse(res);
5067
4799
  });
5068
4800
  }
5069
- update({ bookId, spreadId, payload, qs }) {
4801
+ update(spreadId, bookId, spread) {
5070
4802
  return handleAsyncFunction(async () => {
5071
4803
  const res = await this.engineAPI.fetcher.call({
5072
4804
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5073
4805
  options: {
5074
4806
  method: "PUT",
5075
- body: cleanJSON(payload)
5076
- },
5077
- qs
4807
+ body: cleanJSON(spread)
4808
+ }
5078
4809
  });
5079
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4810
+ return spreadServerSchema.parse(res);
5080
4811
  });
5081
4812
  }
5082
- delete({ bookId, spreadId, qs }) {
4813
+ delete(spreadId, bookId) {
5083
4814
  return handleAsyncFunction(async () => {
5084
4815
  await this.engineAPI.fetcher.call({
5085
4816
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5086
4817
  options: {
5087
4818
  method: "DELETE"
5088
- },
5089
- qs
4819
+ }
4820
+ });
4821
+ });
4822
+ }
4823
+ layouts(bookId, page) {
4824
+ return handleAsyncFunction(async () => {
4825
+ const res = await this.engineAPI.fetcher.call({
4826
+ path: "/v1/spreads/layouts",
4827
+ options: {
4828
+ method: "POST",
4829
+ body: cleanJSON({
4830
+ user_id: bookId,
4831
+ page_num: page
4832
+ })
4833
+ }
5090
4834
  });
4835
+ return z.array(canvasSchema).parse(res);
5091
4836
  });
5092
4837
  }
5093
4838
  };
5094
4839
 
5095
- // ../../core/types/storyboard-item.ts
4840
+ // ../../core/models/storyboard-item.ts
4841
+ var StoryboardItemImageFaceServerSchema = z.object({
4842
+ score: z.number(),
4843
+ bounding_box: z.object({
4844
+ x: z.number(),
4845
+ y: z.number(),
4846
+ width: z.number(),
4847
+ height: z.number()
4848
+ }),
4849
+ size: z.number(),
4850
+ eyes_open_score: z.number(),
4851
+ smile_score: z.number(),
4852
+ facing_camera_score: z.number()
4853
+ });
5096
4854
  var StoryboardItemImageFaceSchema = z.object({
5097
4855
  score: z.number(),
5098
4856
  boundingBox: z.object({
@@ -5106,14 +4864,27 @@ var StoryboardItemImageFaceSchema = z.object({
5106
4864
  smileScore: z.number(),
5107
4865
  facingCameraScore: z.number()
5108
4866
  });
5109
- var StoryboardItemImageSchema = z.object({
4867
+ var StoryboardItemImageServerSchema = z.object({
5110
4868
  id: z.string(),
5111
4869
  url: z.string(),
5112
4870
  category: z.string(),
5113
- aesthetics: z.object({
5114
- score: z.number(),
5115
- scoreWithoutDistance: z.number()
4871
+ aesthetic_score: z.number(),
4872
+ faces: z.array(StoryboardItemImageFaceServerSchema),
4873
+ roi: z.object({
4874
+ x: z.number(),
4875
+ y: z.number(),
4876
+ width: z.number(),
4877
+ height: z.number()
5116
4878
  }),
4879
+ taken_at: z.number(),
4880
+ width: z.number(),
4881
+ height: z.number()
4882
+ });
4883
+ var StoryboardItemImageSchema = z.object({
4884
+ id: z.string(),
4885
+ url: z.string(),
4886
+ category: z.string(),
4887
+ aestheticScore: z.number(),
5117
4888
  faces: z.array(StoryboardItemImageFaceSchema),
5118
4889
  roi: z.object({
5119
4890
  x: z.number(),
@@ -5125,6 +4896,21 @@ var StoryboardItemImageSchema = z.object({
5125
4896
  width: z.number(),
5126
4897
  height: z.number()
5127
4898
  });
4899
+ var StoryboardItemServerSchema = z.object({
4900
+ id: z.string(),
4901
+ sequence: z.number(),
4902
+ book_id: z.string(),
4903
+ similarity: z.number(),
4904
+ duplicate: z.boolean(),
4905
+ selected: z.boolean(),
4906
+ surface_weight: z.number(),
4907
+ front_cover: z.boolean().optional(),
4908
+ back_cover: z.boolean().optional(),
4909
+ scene: z.number(),
4910
+ subscene: z.number(),
4911
+ spine_break: z.boolean().optional(),
4912
+ image: StoryboardItemImageServerSchema
4913
+ });
5128
4914
  var StoryboardItemSchema = z.object({
5129
4915
  id: z.string(),
5130
4916
  sequence: z.number(),
@@ -5141,138 +4927,34 @@ var StoryboardItemSchema = z.object({
5141
4927
  image: StoryboardItemImageSchema
5142
4928
  });
5143
4929
 
5144
- // ../../core/types/engine-api/endpoints/storyboard-items.ts
4930
+ // ../../core/models/engine-api/endpoints/storyboard-items.ts
5145
4931
  var StoryboardItemsEndpoints = class {
5146
4932
  // eslint-disable-next-line no-unused-vars
5147
4933
  constructor(engineAPI) {
5148
4934
  this.engineAPI = engineAPI;
4935
+ bindThisToFunctions(this);
5149
4936
  }
5150
- list(props) {
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 }) {
4937
+ list(bookId) {
5246
4938
  return handleAsyncFunction(async () => {
5247
4939
  const res = await this.engineAPI.fetcher.call({
5248
- path: `/v1/styles/${styleSlug}`,
5249
- qs
4940
+ path: `/v1/storyboarditems/book/${bookId}`
5250
4941
  });
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));
4942
+ return z.array(StoryboardItemServerSchema).parse(res);
5265
4943
  });
5266
4944
  }
5267
4945
  };
5268
4946
 
5269
- // ../../core/types/engine-api/index.ts
4947
+ // ../../core/models/engine-api/index.ts
5270
4948
  var EngineAPI = class {
4949
+ baseUrl;
4950
+ apiKey;
5271
4951
  fetcher;
5272
4952
  constructor(baseUrl, apiKey) {
4953
+ this.baseUrl = new URL(baseUrl);
4954
+ this.apiKey = apiKey;
5273
4955
  const options = {
5274
4956
  headers: {
5275
- "Authorization": `API-Key ${apiKey}`
4957
+ "Authorization": `API-Key ${this.apiKey}`
5276
4958
  }
5277
4959
  };
5278
4960
  this.fetcher = new Fetcher(baseUrl, options);
@@ -5280,19 +4962,16 @@ var EngineAPI = class {
5280
4962
  books = new BooksEndpoints(this);
5281
4963
  designOptions = new DesignOptionsEndpoints(this);
5282
4964
  events = new EventsEndpoints(this);
5283
- embellishments = new EmbellishmentsEndpoints(this);
5284
- fonts = new FontsEndpoints(this);
5285
4965
  images = new ImagesEndpoints(this);
5286
- spreads = new SpreadsEndpoints(this);
5287
4966
  storyboardItems = new StoryboardItemsEndpoints(this);
5288
- styles = new StylesEndpoints(this);
4967
+ spreads = new SpreadsEndpoints(this);
5289
4968
  };
5290
4969
 
5291
4970
  // ../../core/config.ts
5292
- var defaultApiHost = "https://api.dev-sls.magicbook.io";
5293
- var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
4971
+ var defaultApiHost = "https://api.sfly-sls.magicbook.io";
4972
+ var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
5294
4973
 
5295
- // ../../core/types/client.ts
4974
+ // ../../core/models/client.ts
5296
4975
  var MagicBookClient = class {
5297
4976
  constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
5298
4977
  this.apiKey = apiKey;
@@ -5303,7 +4982,7 @@ var MagicBookClient = class {
5303
4982
  engineAPI;
5304
4983
  async createDesignRequest(designRequestProps) {
5305
4984
  if (designRequestProps.userId) {
5306
- const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
4985
+ const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
5307
4986
  return new DesignRequest(book.id, this, designRequestProps);
5308
4987
  } else {
5309
4988
  throw new Error("userId is required");
@@ -5315,17 +4994,10 @@ export {
5315
4994
  BookDesignRequest,
5316
4995
  DesignRequest,
5317
4996
  DesignRequestOptions,
5318
- EmbellishmentsEndpoints,
5319
- EngineAPI,
5320
4997
  ImageServer,
5321
4998
  Images,
5322
4999
  MagicBookClient,
5323
- StoryboardItemImageFaceSchema,
5324
- StoryboardItemImageSchema,
5325
- StoryboardItemSchema,
5326
- StylesEndpoints,
5327
5000
  assetSchema,
5328
- backgroundSchema,
5329
5001
  bookCreationRequestSchema,
5330
5002
  bookDesignRequestSchema,
5331
5003
  bookPropsSchema,
@@ -5333,68 +5005,34 @@ export {
5333
5005
  canSubmitDesignRequest,
5334
5006
  cancelledEventDetail,
5335
5007
  canvasSchema,
5336
- colorSchema,
5337
- compatibleBackgroundSchema,
5338
5008
  coverTypes,
5339
5009
  designOptionsSchema,
5340
- embellishmentAnchorsSchema,
5341
- embellishmentBackgroundListSchema,
5342
- embellishmentBackgroundSchema,
5343
- embellishmentBandSchema,
5344
- embellishmentBaseSchema,
5345
- embellishmentFrameSchema,
5346
- embellishmentGraphicStickerSchema,
5010
+ designOptionsServerSchema,
5347
5011
  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
5012
  imageAssignmentSchema,
5367
5013
  imageDensities,
5368
5014
  imageDensityOptionSchema,
5015
+ imageDensityOptionServerSchema,
5369
5016
  imageDensityOptionsSchema,
5017
+ imageDensityOptionsServerSchema,
5370
5018
  imageFilteringLevels,
5371
5019
  imageServerSchema,
5372
5020
  imageServerToImage,
5373
5021
  isDesignRequestSubmitted,
5374
- layoutConstraintSchema,
5375
- layoutConstraintsClasses,
5376
- layoutConstraintsSchema,
5377
5022
  magicShopBookSchema,
5378
5023
  occasions,
5379
5024
  pageSchema,
5380
5025
  pageTypes,
5381
- paginatedResponseSchema,
5382
5026
  photoMetadataSchema,
5383
5027
  photoStripSchema,
5384
5028
  positionSchema,
5385
5029
  propertySchema,
5386
5030
  reportingDataSchema,
5387
- spreadSchema,
5388
- spreadServerSchema,
5389
5031
  states,
5390
5032
  statesToCloseWS,
5391
5033
  statesToReport,
5392
- styleBaseSchema,
5393
- styleFontSchema,
5394
- styleSchema,
5395
5034
  styles,
5396
5035
  textStickerLevels,
5397
- timeoutEventDetail,
5398
- whitespaceSchema
5036
+ timeoutEventDetail
5399
5037
  };
5400
5038
  //# sourceMappingURL=index.js.map