@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.cjs CHANGED
@@ -24,17 +24,10 @@ __export(src_exports, {
24
24
  BookDesignRequest: () => BookDesignRequest,
25
25
  DesignRequest: () => DesignRequest,
26
26
  DesignRequestOptions: () => DesignRequestOptions,
27
- EmbellishmentsEndpoints: () => EmbellishmentsEndpoints,
28
- EngineAPI: () => EngineAPI,
29
27
  ImageServer: () => ImageServer,
30
28
  Images: () => Images,
31
29
  MagicBookClient: () => MagicBookClient,
32
- StoryboardItemImageFaceSchema: () => StoryboardItemImageFaceSchema,
33
- StoryboardItemImageSchema: () => StoryboardItemImageSchema,
34
- StoryboardItemSchema: () => StoryboardItemSchema,
35
- StylesEndpoints: () => StylesEndpoints,
36
30
  assetSchema: () => assetSchema,
37
- backgroundSchema: () => backgroundSchema,
38
31
  bookCreationRequestSchema: () => bookCreationRequestSchema,
39
32
  bookDesignRequestSchema: () => bookDesignRequestSchema,
40
33
  bookPropsSchema: () => bookPropsSchema,
@@ -42,69 +35,35 @@ __export(src_exports, {
42
35
  canSubmitDesignRequest: () => canSubmitDesignRequest,
43
36
  cancelledEventDetail: () => cancelledEventDetail,
44
37
  canvasSchema: () => canvasSchema,
45
- colorSchema: () => colorSchema,
46
- compatibleBackgroundSchema: () => compatibleBackgroundSchema,
47
38
  coverTypes: () => coverTypes,
48
39
  designOptionsSchema: () => designOptionsSchema,
49
- embellishmentAnchorsSchema: () => embellishmentAnchorsSchema,
50
- embellishmentBackgroundListSchema: () => embellishmentBackgroundListSchema,
51
- embellishmentBackgroundSchema: () => embellishmentBackgroundSchema,
52
- embellishmentBandSchema: () => embellishmentBandSchema,
53
- embellishmentBaseSchema: () => embellishmentBaseSchema,
54
- embellishmentFrameSchema: () => embellishmentFrameSchema,
55
- embellishmentGraphicStickerSchema: () => embellishmentGraphicStickerSchema,
40
+ designOptionsServerSchema: () => designOptionsServerSchema,
56
41
  embellishmentLevels: () => embellishmentLevels,
57
- embellishmentListSchemas: () => embellishmentListSchemas,
58
- embellishmentOrientations: () => embellishmentOrientations,
59
- embellishmentPageCornerSchema: () => embellishmentPageCornerSchema,
60
- embellishmentPhotoCornerAnchorsSchema: () => embellishmentPhotoCornerAnchorsSchema,
61
- embellishmentPhotoCornerSchema: () => embellishmentPhotoCornerSchema,
62
- embellishmentPostcardSchema: () => embellishmentPostcardSchema,
63
- embellishmentSchemas: () => embellishmentSchemas,
64
- embellishmentStackings: () => embellishmentStackings,
65
- embellishmentStampSchema: () => embellishmentStampSchema,
66
- embellishmentStripSchema: () => embellishmentStripSchema,
67
- embellishmentTPointSchema: () => embellishmentTPointSchema,
68
- embellishmentTapeSchema: () => embellishmentTapeSchema,
69
- embellishmentTextStickerSchema: () => embellishmentTextStickerSchema,
70
- embellishmentThicknesses: () => embellishmentThicknesses,
71
- embellishmentTypes: () => embellishmentTypes,
72
- embellishmentUpdateSchemas: () => embellishmentUpdateSchemas,
73
- fontRoles: () => fontRoles,
74
- fontSchema: () => fontSchema,
75
42
  imageAssignmentSchema: () => imageAssignmentSchema,
76
43
  imageDensities: () => imageDensities,
77
44
  imageDensityOptionSchema: () => imageDensityOptionSchema,
45
+ imageDensityOptionServerSchema: () => imageDensityOptionServerSchema,
78
46
  imageDensityOptionsSchema: () => imageDensityOptionsSchema,
47
+ imageDensityOptionsServerSchema: () => imageDensityOptionsServerSchema,
79
48
  imageFilteringLevels: () => imageFilteringLevels,
80
49
  imageServerSchema: () => imageServerSchema,
81
50
  imageServerToImage: () => imageServerToImage,
82
51
  isDesignRequestSubmitted: () => isDesignRequestSubmitted,
83
- layoutConstraintSchema: () => layoutConstraintSchema,
84
- layoutConstraintsClasses: () => layoutConstraintsClasses,
85
- layoutConstraintsSchema: () => layoutConstraintsSchema,
86
52
  magicShopBookSchema: () => magicShopBookSchema,
87
53
  occasions: () => occasions,
88
54
  pageSchema: () => pageSchema,
89
55
  pageTypes: () => pageTypes,
90
- paginatedResponseSchema: () => paginatedResponseSchema,
91
56
  photoMetadataSchema: () => photoMetadataSchema,
92
57
  photoStripSchema: () => photoStripSchema,
93
58
  positionSchema: () => positionSchema,
94
59
  propertySchema: () => propertySchema,
95
60
  reportingDataSchema: () => reportingDataSchema,
96
- spreadSchema: () => spreadSchema,
97
- spreadServerSchema: () => spreadServerSchema,
98
61
  states: () => states,
99
62
  statesToCloseWS: () => statesToCloseWS,
100
63
  statesToReport: () => statesToReport,
101
- styleBaseSchema: () => styleBaseSchema,
102
- styleFontSchema: () => styleFontSchema,
103
- styleSchema: () => styleSchema,
104
64
  styles: () => styles,
105
65
  textStickerLevels: () => textStickerLevels,
106
- timeoutEventDetail: () => timeoutEventDetail,
107
- whitespaceSchema: () => whitespaceSchema
66
+ timeoutEventDetail: () => timeoutEventDetail
108
67
  });
109
68
  module.exports = __toCommonJS(src_exports);
110
69
 
@@ -315,7 +274,9 @@ var styles = {
315
274
  6096: { slug: "simply-scrapbook-sfly" },
316
275
  6097: { slug: "boho-wedding-sfly" },
317
276
  6098: { slug: "black-and-white-rustic-sfly" },
318
- 6099: { slug: "bright-color-pop-sfly" }
277
+ 6099: { slug: "bright-color-pop-sfly" },
278
+ 6159: { slug: "grateful-for-you-sfly" },
279
+ 6156: { slug: "europe-mementos-sfly" }
319
280
  };
320
281
  var bookSizes = ["8x8", "10x10", "12x12", "8x11", "11x8", "11x14"];
321
282
  var coverTypes = ["sc", "hc", "pl"];
@@ -375,11 +336,7 @@ function snakeCaseObjectKeysToCamelCase(snakeCaseObject) {
375
336
  delete snakeCaseObject[key];
376
337
  }
377
338
  if (typeof snakeCaseObject[camelCaseKey] === "object") {
378
- if (snakeCaseObject[camelCaseKey] === null) {
379
- snakeCaseObject[camelCaseKey] = null;
380
- } else {
381
- snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
382
- }
339
+ snakeCaseObject[camelCaseKey] = snakeCaseObjectKeysToCamelCase(snakeCaseObject[camelCaseKey]);
383
340
  }
384
341
  });
385
342
  return snakeCaseObject;
@@ -391,6 +348,15 @@ async function handleAsyncFunction(fn) {
391
348
  return Promise.reject(error);
392
349
  }
393
350
  }
351
+ function bindThisToFunctions(instance) {
352
+ for (const name of Object.getOwnPropertyNames(
353
+ Object.getPrototypeOf(instance)
354
+ )) {
355
+ if (typeof instance[name] === "function" && name !== "constructor") {
356
+ instance[name] = instance[name].bind(instance);
357
+ }
358
+ }
359
+ }
394
360
  function cleanJSON(obj) {
395
361
  return JSON.parse(JSON.stringify(obj));
396
362
  }
@@ -4137,7 +4103,7 @@ var z = /* @__PURE__ */ Object.freeze({
4137
4103
  ZodError
4138
4104
  });
4139
4105
 
4140
- // ../../core/types/book.ts
4106
+ // ../../core/models/book.ts
4141
4107
  var BookDesignRequest = class {
4142
4108
  occasion;
4143
4109
  style;
@@ -4179,7 +4145,7 @@ var bookPropsSchema = z.object({
4179
4145
  state: z.enum(states).optional(),
4180
4146
  guid: z.string().optional(),
4181
4147
  cancelled_at: z.string().optional(),
4182
- mb_client_timeout: z.string().optional(),
4148
+ mb_client_timeout: z.number().optional(),
4183
4149
  user_id: z.string().optional(),
4184
4150
  revision: z.number().optional()
4185
4151
  });
@@ -4202,7 +4168,7 @@ var Book = class {
4202
4168
  this.state = props.state;
4203
4169
  this.guid = props.guid;
4204
4170
  this.cancelled_at = props.cancelled_at;
4205
- this.timeout = props.mb_client_timeout ? parseInt(props.mb_client_timeout) * 1e3 : void 0;
4171
+ this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
4206
4172
  this.user_id = props.user_id;
4207
4173
  this.revision = props.revision;
4208
4174
  }
@@ -4216,12 +4182,12 @@ var Book = class {
4216
4182
  toBookProps() {
4217
4183
  return {
4218
4184
  ...this,
4219
- mb_client_timeout: this.timeout ? (this.timeout / 1e3).toString() : void 0
4185
+ mb_client_timeout: this.timeout ? this.timeout / 1e3 : void 0
4220
4186
  };
4221
4187
  }
4222
4188
  };
4223
4189
 
4224
- // ../../core/types/design-request/image.ts
4190
+ // ../../core/models/design-request/image.ts
4225
4191
  var Images = class {
4226
4192
  // eslint-disable-next-line no-unused-vars
4227
4193
  constructor(client, parentId, designRequestState) {
@@ -4241,10 +4207,7 @@ var Images = class {
4241
4207
  } else {
4242
4208
  this.images.push(image);
4243
4209
  this.length = this.images.length;
4244
- await this.client.engineAPI.images.addToBook({
4245
- bookId: this.parentId,
4246
- image: new ImageServer(image)
4247
- });
4210
+ await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
4248
4211
  return new Promise((resolve) => {
4249
4212
  resolve(this.length);
4250
4213
  });
@@ -4299,7 +4262,7 @@ function imageServerToImage(imageServer) {
4299
4262
  };
4300
4263
  }
4301
4264
 
4302
- // ../../core/types/design-request/design-options.ts
4265
+ // ../../core/models/design-request/design-options.ts
4303
4266
  var imageDensityOptionSchema = z.object({
4304
4267
  maxPageCount: z.number(),
4305
4268
  minPageCount: z.number(),
@@ -4315,8 +4278,23 @@ var imageDensityOptionsSchema = z.object({
4315
4278
  var designOptionsSchema = z.object({
4316
4279
  densities: imageDensityOptionsSchema
4317
4280
  });
4281
+ var imageDensityOptionServerSchema = z.object({
4282
+ max_page_count: z.number(),
4283
+ min_page_count: z.number(),
4284
+ max_image_count: z.number(),
4285
+ avg_image_count: z.number(),
4286
+ min_image_count: z.number()
4287
+ });
4288
+ var imageDensityOptionsServerSchema = z.object({
4289
+ high: imageDensityOptionServerSchema,
4290
+ medium: imageDensityOptionServerSchema,
4291
+ low: imageDensityOptionServerSchema
4292
+ });
4293
+ var designOptionsServerSchema = z.object({
4294
+ densities: imageDensityOptionsServerSchema
4295
+ });
4318
4296
 
4319
- // ../../core/types/design-request/index.ts
4297
+ // ../../core/models/design-request/index.ts
4320
4298
  var DesignRequestOptions = {
4321
4299
  occasion: occasions,
4322
4300
  style: Object.keys(styles).map((key) => parseInt(key)),
@@ -4372,27 +4350,31 @@ var DesignRequest = class {
4372
4350
  }
4373
4351
  async getOptions(imageCount) {
4374
4352
  const options = designOptionsSchema.parse(
4375
- await this.client.engineAPI.designOptions.retrieve({
4376
- bookSize: this.bookSize,
4377
- imageCount: imageCount || this.images.length,
4378
- imageFilteringLevel: this.imageFilteringLevel
4379
- })
4353
+ snakeCaseObjectKeysToCamelCase(
4354
+ await this.client.engineAPI.designOptions.retrieve(
4355
+ this.bookSize,
4356
+ imageCount || this.images.length,
4357
+ this.imageFilteringLevel
4358
+ )
4359
+ )
4380
4360
  );
4381
4361
  return options;
4382
4362
  }
4363
+ async getAlternateLayouts(pageNumber) {
4364
+ if (this.state === "ready") {
4365
+ return await this.client.engineAPI.spreads.layouts(this.parentId, pageNumber);
4366
+ } else {
4367
+ throw new Error("Design request not ready");
4368
+ }
4369
+ }
4383
4370
  async submit(submitDesignRequestProps) {
4384
4371
  if (!canSubmitDesignRequest(this.state)) {
4385
4372
  throw new Error("You need to wait for the current design request to be ready before submitting a new one");
4386
4373
  } else {
4387
4374
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
4388
4375
  this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
4389
- await this.client.engineAPI.books.update({
4390
- bookId: this.parentId,
4391
- payload: this.toBook()
4392
- });
4393
- this.updateDesignRequest(
4394
- (await this.client.engineAPI.books.design({ bookId: this.parentId })).toDesignRequestProps()
4395
- );
4376
+ await this.client.engineAPI.books.update(this.parentId, this.toBook());
4377
+ this.updateDesignRequest((await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps());
4396
4378
  this.getProgress();
4397
4379
  return this;
4398
4380
  }
@@ -4403,10 +4385,7 @@ var DesignRequest = class {
4403
4385
  } else {
4404
4386
  this.guid = guid;
4405
4387
  this.updateDesignRequest(
4406
- (await this.client.engineAPI.books.update({
4407
- bookId: this.parentId,
4408
- payload: this.toBook()
4409
- })).toDesignRequestProps()
4388
+ (await this.client.engineAPI.books.update(this.parentId, this.toBook())).toDesignRequestProps()
4410
4389
  );
4411
4390
  return this.guid;
4412
4391
  }
@@ -4420,9 +4399,7 @@ var DesignRequest = class {
4420
4399
  throw new Error("Design request not submitted");
4421
4400
  } else {
4422
4401
  this.updateDesignRequest({
4423
- ...(await this.client.engineAPI.books.cancel({
4424
- bookId: this.parentId
4425
- })).toDesignRequestProps(),
4402
+ ...(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps(),
4426
4403
  state: "cancelled"
4427
4404
  });
4428
4405
  await this.eventHandler(cancelledEventDetail);
@@ -4431,31 +4408,22 @@ var DesignRequest = class {
4431
4408
  }
4432
4409
  async getJSON() {
4433
4410
  if (this.state === "ready") {
4434
- return await this.client.engineAPI.books.retrieveGalleon({
4435
- bookId: this.parentId
4436
- });
4411
+ return await this.client.engineAPI.books.retrieveGalleon(this.parentId);
4437
4412
  } else {
4438
4413
  throw new Error("Design request not ready");
4439
4414
  }
4440
4415
  }
4441
4416
  async logEvent(name, data) {
4442
- return await this.client.engineAPI.events.createBookEvent({
4443
- bookId: this.parentId,
4444
- name,
4445
- data
4446
- });
4417
+ return await this.client.engineAPI.events.createBookEvent(this.parentId, name, data);
4447
4418
  }
4448
4419
  async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
4449
4420
  const customEvent = new CustomEvent(type, { detail });
4450
4421
  if (statesToCloseWS.includes(detail.slug)) {
4451
4422
  this.webSocket?.close();
4452
4423
  if (statesToReport.includes(detail.slug)) {
4453
- await this.client.engineAPI.books.report({
4454
- bookId: this.parentId,
4455
- report: {
4456
- error: detail.slug === "error" ? "design" : "timeout",
4457
- step: this.state
4458
- }
4424
+ await this.client.engineAPI.books.report(this.parentId, {
4425
+ error: detail.slug === "error" ? "design" : "timeout",
4426
+ step: this.state
4459
4427
  });
4460
4428
  }
4461
4429
  }
@@ -4508,7 +4476,7 @@ var DesignRequest = class {
4508
4476
  }
4509
4477
  };
4510
4478
 
4511
- // ../../core/types/galleon.ts
4479
+ // ../../core/models/galleon.ts
4512
4480
  var imageAssignmentSchema = z.object({
4513
4481
  photoRefId: z.string(),
4514
4482
  finalCrop: z.array(z.number())
@@ -4587,357 +4555,128 @@ var bookCreationRequestSchema = z.object({
4587
4555
  reportingData: reportingDataSchema
4588
4556
  });
4589
4557
 
4590
- // ../../core/types/engine-api/endpoints/books.ts
4558
+ // ../../core/models/engine-api/endpoints/books.ts
4591
4559
  var BooksEndpoints = class {
4592
4560
  // eslint-disable-next-line no-unused-vars
4593
4561
  constructor(engineAPI) {
4594
4562
  this.engineAPI = engineAPI;
4563
+ bindThisToFunctions(this);
4595
4564
  }
4596
- create({ book, qs }) {
4565
+ create(book) {
4597
4566
  return handleAsyncFunction(async () => {
4598
4567
  const res = await this.engineAPI.fetcher.call({
4599
4568
  path: "/v1/books",
4600
4569
  options: {
4601
4570
  method: "POST",
4602
4571
  body: cleanJSON(book)
4603
- },
4604
- qs
4572
+ }
4605
4573
  });
4574
+ bookPropsSchema.safeParse(res);
4606
4575
  return new Book(res);
4607
4576
  });
4608
4577
  }
4609
- retrieve({ bookId, qs }) {
4578
+ retrieve(bookId) {
4610
4579
  return handleAsyncFunction(async () => {
4611
- const res = await this.engineAPI.fetcher.call({
4612
- path: `/v1/books/${bookId}`,
4613
- qs
4614
- });
4615
- const bookProps = bookPropsSchema.parse(res);
4616
- return new Book(bookProps);
4580
+ const res = await this.engineAPI.fetcher.call({ path: `/v1/books/${bookId}` });
4581
+ bookPropsSchema.safeParse(res);
4582
+ return new Book(res);
4617
4583
  });
4618
4584
  }
4619
- update({ bookId, payload, qs }) {
4585
+ update(bookId, book) {
4620
4586
  return handleAsyncFunction(async () => {
4621
4587
  const res = await this.engineAPI.fetcher.call({
4622
4588
  path: `/v1/books/${bookId}`,
4623
4589
  options: {
4624
4590
  method: "PUT",
4625
- body: cleanJSON(payload)
4626
- },
4627
- qs
4628
- });
4629
- const bookProps = bookPropsSchema.parse(res);
4630
- return new Book(bookProps);
4631
- });
4632
- }
4633
- delete({ bookId, qs }) {
4634
- return handleAsyncFunction(async () => {
4635
- await this.engineAPI.fetcher.call({
4636
- path: `/v1/books/${bookId}`,
4637
- options: { method: "DELETE" },
4638
- qs
4591
+ body: cleanJSON(book)
4592
+ }
4639
4593
  });
4594
+ bookPropsSchema.safeParse(res);
4595
+ return new Book(res);
4640
4596
  });
4641
4597
  }
4642
- design({ bookId, qs }) {
4598
+ design(bookId) {
4643
4599
  return handleAsyncFunction(async () => {
4644
4600
  const res = await this.engineAPI.fetcher.call({
4645
4601
  path: `/v1/books/${bookId}/design`,
4646
- options: { method: "POST" },
4647
- qs
4602
+ options: { method: "POST" }
4648
4603
  });
4649
- const bookProps = bookPropsSchema.parse(res);
4650
- return new Book(bookProps);
4604
+ bookPropsSchema.safeParse(res);
4605
+ return new Book(res);
4651
4606
  });
4652
4607
  }
4653
- cancel({ bookId, qs }) {
4608
+ cancel(bookId) {
4654
4609
  return handleAsyncFunction(async () => {
4655
4610
  const res = await this.engineAPI.fetcher.call({
4656
4611
  path: `/v1/books/${bookId}/cancel`,
4657
- options: { method: "POST" },
4658
- qs
4612
+ options: { method: "POST" }
4659
4613
  });
4660
- const bookProps = bookPropsSchema.parse(res);
4661
- return new Book(bookProps);
4662
- });
4663
- }
4664
- retrieveGalleon({ bookId, qs }) {
4665
- return handleAsyncFunction(async () => {
4666
- const res = await this.engineAPI.fetcher.call({
4667
- path: `/v1/books/${bookId}/format/galleon`,
4668
- qs
4669
- });
4670
- return bookCreationRequestSchema.parse(res);
4614
+ bookPropsSchema.safeParse(res);
4615
+ return new Book(res);
4671
4616
  });
4672
4617
  }
4673
- report({ bookId, report, qs }) {
4618
+ report(bookId, report) {
4674
4619
  return handleAsyncFunction(async () => {
4675
4620
  await this.engineAPI.fetcher.call({
4676
4621
  path: `/v1/books/${bookId}/report`,
4677
4622
  options: {
4678
4623
  method: "POST",
4679
4624
  body: cleanJSON(report)
4680
- },
4681
- qs
4625
+ }
4682
4626
  });
4683
4627
  });
4684
4628
  }
4685
- };
4686
-
4687
- // ../../core/types/engine-api/endpoints/design-options.ts
4688
- var DesignOptionsEndpoints = class {
4689
- // eslint-disable-next-line no-unused-vars
4690
- constructor(engineAPI) {
4691
- this.engineAPI = engineAPI;
4629
+ delete(bookId) {
4630
+ return handleAsyncFunction(async () => {
4631
+ await this.engineAPI.fetcher.call({
4632
+ path: `/v1/books/${bookId}`,
4633
+ options: { method: "DELETE" }
4634
+ });
4635
+ });
4692
4636
  }
4693
- retrieve(props) {
4637
+ retrieveGalleon(bookId) {
4694
4638
  return handleAsyncFunction(async () => {
4695
4639
  const res = await this.engineAPI.fetcher.call({
4696
- // eslint-disable-next-line max-len
4697
- path: `/v1/designoptions/booksize/${props.bookSize}/imagecount/${props.imageCount}/imagefilteringlevel/${props.imageFilteringLevel}`,
4698
- qs: props.qs
4640
+ path: `/v1/books/${bookId}/format/galleon`
4699
4641
  });
4700
- return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4642
+ return bookCreationRequestSchema.parse(res);
4701
4643
  });
4702
4644
  }
4703
4645
  };
4704
4646
 
4705
- // ../../core/types/embellishment.ts
4706
- var embellishmentTypes = [
4707
- "background",
4708
- "band",
4709
- "strip",
4710
- "page-corner",
4711
- "photo-corner",
4712
- "frame",
4713
- "t-point",
4714
- "luggage-tag",
4715
- "stamp",
4716
- "tape",
4717
- "postcard",
4718
- "top-sticker",
4719
- "bottom-sticker",
4720
- "graphic-sticker",
4721
- "text-sticker"
4722
- ];
4723
- var embellishmentOrientations = [
4724
- "top",
4725
- "bottom",
4726
- "left",
4727
- "right",
4728
- "top-left",
4729
- "top-right",
4730
- "bottom-right",
4731
- "bottom-left"
4732
- ];
4733
- var embellishmentThicknesses = ["thin", "thick", "normal"];
4734
- var embellishmentStackings = ["front", "back"];
4735
- var embellishmentAnchorsSchema = z.object({
4736
- x0: z.number(),
4737
- x1: z.number(),
4738
- y0: z.number(),
4739
- y1: z.number()
4740
- });
4741
- var embellishmentPhotoCornerAnchorsSchema = z.object({
4742
- x0: z.number(),
4743
- y0: z.number()
4744
- });
4745
- var embellishmentBaseSchema = z.object({
4746
- id: z.string(),
4747
- active: z.boolean(),
4748
- url: z.string(),
4749
- name: z.string(),
4750
- pattern: z.string(),
4751
- primaryColor: z.string(),
4752
- margin: z.number(),
4753
- width: z.number(),
4754
- height: z.number(),
4755
- style: z.string()
4756
- });
4757
- var embellishmentTextStickerSchema = embellishmentBaseSchema.extend({
4758
- type: z.literal("text-sticker"),
4759
- text: z.string(),
4760
- isSpecific: z.boolean(),
4761
- minSurface: z.number(),
4762
- maxSurface: z.number()
4763
- });
4764
- var embellishmentTPointSchema = embellishmentBaseSchema.extend({
4765
- type: z.literal("t-point"),
4766
- minSurface: z.number(),
4767
- maxSurface: z.number()
4768
- });
4769
- var embellishmentGraphicStickerSchema = embellishmentBaseSchema.extend({
4770
- type: z.literal("graphic-sticker"),
4771
- minSurface: z.number(),
4772
- maxSurface: z.number(),
4773
- hFlippable: z.boolean(),
4774
- vFlippable: z.boolean()
4775
- });
4776
- var embellishmentStampSchema = embellishmentBaseSchema.extend({
4777
- type: z.literal("stamp"),
4778
- minSurface: z.number(),
4779
- maxSurface: z.number(),
4780
- hFlippable: z.boolean(),
4781
- vFlippable: z.boolean()
4782
- });
4783
- var embellishmentTapeSchema = embellishmentBaseSchema.extend({
4784
- type: z.literal("tape"),
4785
- minSurface: z.number(),
4786
- maxSurface: z.number(),
4787
- hFlippable: z.boolean(),
4788
- vFlippable: z.boolean()
4789
- });
4790
- var embellishmentPostcardSchema = embellishmentBaseSchema.extend({
4791
- type: z.literal("postcard"),
4792
- minSurface: z.number(),
4793
- maxSurface: z.number(),
4794
- hFlippable: z.boolean(),
4795
- vFlippable: z.boolean()
4796
- });
4797
- var embellishmentBandSchema = embellishmentBaseSchema.extend({
4798
- type: z.literal("band"),
4799
- orientation: z.enum(embellishmentOrientations),
4800
- orientations: z.array(z.enum(embellishmentOrientations)),
4801
- thickness: z.enum(embellishmentThicknesses)
4802
- });
4803
- var embellishmentStripSchema = embellishmentBaseSchema.extend({
4804
- type: z.literal("strip"),
4805
- orientation: z.enum(embellishmentOrientations),
4806
- orientations: z.array(z.enum(embellishmentOrientations)),
4807
- thickness: z.enum(embellishmentThicknesses)
4808
- });
4809
- var embellishmentPhotoCornerSchema = embellishmentBaseSchema.extend({
4810
- type: z.literal("photo-corner"),
4811
- orientation: z.enum(embellishmentOrientations),
4812
- orientations: z.array(z.enum(embellishmentOrientations)),
4813
- anchors: embellishmentPhotoCornerAnchorsSchema,
4814
- stacking: z.enum(embellishmentStackings),
4815
- scale: z.number()
4816
- });
4817
- var embellishmentPageCornerSchema = embellishmentBaseSchema.extend({
4818
- type: z.literal("page-corner"),
4819
- orientation: z.enum(embellishmentOrientations),
4820
- orientations: z.array(z.enum(embellishmentOrientations)),
4821
- scale: z.number()
4822
- });
4823
- var embellishmentFrameSchema = embellishmentBaseSchema.extend({
4824
- type: z.literal("frame"),
4825
- rotatable: z.boolean(),
4826
- anchors: embellishmentAnchorsSchema,
4827
- stacking: z.enum(embellishmentStackings)
4828
- });
4829
- var embellishmentBackgroundListSchema = embellishmentBaseSchema.extend({
4830
- type: z.literal("background"),
4831
- rotatable: z.boolean()
4832
- });
4833
- var embellishmentBackgroundSchema = embellishmentBackgroundListSchema.extend({
4834
- colors: z.record(z.unknown()),
4835
- backgrounds: z.record(z.unknown())
4836
- });
4837
- var embellishmentSchemasArray = [
4838
- embellishmentBackgroundSchema,
4839
- embellishmentFrameSchema,
4840
- embellishmentTextStickerSchema,
4841
- embellishmentBandSchema,
4842
- embellishmentStripSchema,
4843
- embellishmentPageCornerSchema,
4844
- embellishmentPhotoCornerSchema,
4845
- embellishmentTPointSchema,
4846
- embellishmentStampSchema,
4847
- embellishmentTapeSchema,
4848
- embellishmentPostcardSchema,
4849
- embellishmentGraphicStickerSchema
4850
- ];
4851
- var embellishmentSchemas = z.union(
4852
- [...embellishmentSchemasArray]
4853
- );
4854
- var embellishmentUpdateSchemas = z.union(
4855
- [
4856
- ...embellishmentSchemasArray.map((schema) => schema.partial().optional())
4857
- ]
4858
- );
4859
- var embellishmentListSchemasArray = [...embellishmentSchemasArray];
4860
- embellishmentListSchemasArray.shift();
4861
- embellishmentListSchemasArray.push(embellishmentBackgroundListSchema);
4862
- var embellishmentListSchemas = z.union(
4863
- [...embellishmentListSchemasArray]
4864
- );
4865
-
4866
- // ../../core/types/engine-api/pagination.ts
4867
- function paginatedResponseSchema(arrayOf) {
4868
- return z.object({
4869
- count: z.number(),
4870
- nextCursor: z.string().nullable(),
4871
- previousCursor: z.string().optional(),
4872
- results: z.array(arrayOf)
4873
- });
4874
- }
4875
-
4876
- // ../../core/types/engine-api/endpoints/embellishments.ts
4877
- var embellishmentPaginatedSchema = paginatedResponseSchema(embellishmentListSchemas);
4878
- var EmbellishmentsEndpoints = class {
4647
+ // ../../core/models/engine-api/endpoints/design-options.ts
4648
+ var DesignOptionsEndpoints = class {
4879
4649
  // eslint-disable-next-line no-unused-vars
4880
4650
  constructor(engineAPI) {
4881
4651
  this.engineAPI = engineAPI;
4652
+ bindThisToFunctions(this);
4882
4653
  }
4883
- list({ styleSlug, qs }) {
4884
- return handleAsyncFunction(async () => {
4885
- const res = await this.engineAPI.fetcher.call({
4886
- path: `/v1/embellishments/style/${styleSlug}`,
4887
- qs
4888
- });
4889
- return embellishmentPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4890
- });
4891
- }
4892
- retrieve({ styleSlug, embellishmentId, qs }) {
4654
+ retrieve(bookSize, imageCount, imageFilteringLevel) {
4893
4655
  return handleAsyncFunction(async () => {
4894
4656
  const res = await this.engineAPI.fetcher.call({
4895
- path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
4896
- qs
4897
- });
4898
- return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
4899
- });
4900
- }
4901
- update({ styleSlug, embellishmentId, payload }) {
4902
- return handleAsyncFunction(async () => {
4903
- const res = await this.engineAPI.fetcher.call({
4904
- path: `/v1/embellishments/${embellishmentId}/style/${styleSlug}`,
4905
- options: {
4906
- method: "PUT",
4907
- body: cleanJSON(camelCaseObjectKeysToSnakeCase({ ...payload }))
4908
- }
4657
+ // eslint-disable-next-line max-len
4658
+ path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
4909
4659
  });
4910
- return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
4660
+ return designOptionsServerSchema.parse(res);
4911
4661
  });
4912
4662
  }
4913
4663
  };
4914
4664
 
4915
- // ../../core/types/event.ts
4665
+ // ../../core/models/event.ts
4916
4666
  var eventContextSchema = z.record(z.string(), z.unknown()).optional();
4917
4667
  var eventSchema = z.object({
4918
4668
  name: z.string(),
4919
- context: eventContextSchema,
4920
- bookId: z.string(),
4921
- createdAt: z.string()
4669
+ context: eventContextSchema
4922
4670
  });
4923
4671
 
4924
- // ../../core/types/engine-api/endpoints/events.ts
4925
- var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
4672
+ // ../../core/models/engine-api/endpoints/events.ts
4926
4673
  var EventsEndpoints = class {
4927
4674
  // eslint-disable-next-line no-unused-vars
4928
4675
  constructor(engineAPI) {
4929
4676
  this.engineAPI = engineAPI;
4677
+ bindThisToFunctions(this);
4930
4678
  }
4931
- listBookEvents({ bookId, qs }) {
4932
- return handleAsyncFunction(async () => {
4933
- const res = await this.engineAPI.fetcher.call({
4934
- path: `/v1/events/book/${bookId}`,
4935
- qs
4936
- });
4937
- return eventPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4938
- });
4939
- }
4940
- createBookEvent({ name, data, bookId, qs }) {
4679
+ createBookEvent(bookId, name, data) {
4941
4680
  return handleAsyncFunction(async () => {
4942
4681
  const body = {
4943
4682
  name
@@ -4948,26 +4687,14 @@ var EventsEndpoints = class {
4948
4687
  options: {
4949
4688
  method: "POST",
4950
4689
  body: cleanJSON(body)
4951
- },
4952
- qs
4953
- });
4954
- return eventSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4955
- });
4956
- }
4957
- deleteBookEvent({ name, bookId, qs }) {
4958
- return handleAsyncFunction(async () => {
4959
- await this.engineAPI.fetcher.call({
4960
- path: `/v1/events/book/${bookId}/name/${name}`,
4961
- options: {
4962
- method: "DELETE"
4963
- },
4964
- qs
4690
+ }
4965
4691
  });
4692
+ return eventSchema.parse(res);
4966
4693
  });
4967
4694
  }
4968
4695
  };
4969
4696
 
4970
- // ../../core/types/fetcher.ts
4697
+ // ../../core/models/fetcher.ts
4971
4698
  var baseOptions = {
4972
4699
  headers: {
4973
4700
  "Content-Type": "application/json"
@@ -4988,14 +4715,12 @@ var Fetcher = class {
4988
4715
  }
4989
4716
  const baseOptions2 = { ...this.options };
4990
4717
  const options = props.options ? mergeNestedObject(baseOptions2, props.options) : baseOptions2;
4991
- const qs = props.qs ? `?${props.qs}` : "";
4992
- const res = await fetch(this.cleanUrl(`${this.baseUrl}${props.path}${qs}`), options);
4993
- if (res.status >= 200 && res.status < 300 && res.ok) {
4994
- const result = await res.text();
4718
+ const res = await fetch(this.cleanUrl(new URL(props.path, this.baseUrl).href), options);
4719
+ if (res.status >= 200 && res.status < 300) {
4995
4720
  try {
4996
- return JSON.parse(result);
4721
+ return await res.json();
4997
4722
  } catch (error) {
4998
- return result;
4723
+ return {};
4999
4724
  }
5000
4725
  } else {
5001
4726
  let detail = res.statusText;
@@ -5010,102 +4735,70 @@ var Fetcher = class {
5010
4735
  }
5011
4736
  }
5012
4737
  cleanUrl(url) {
5013
- return url.replace(/\/\//g, "/").replaceAll(" ", "").trim();
5014
- }
5015
- };
5016
-
5017
- // ../../core/types/font.ts
5018
- var fontRoles = ["title", "subtitle", "caption"];
5019
- var fontSchema = z.object({
5020
- slug: z.string(),
5021
- family: z.string()
5022
- });
5023
- var styleFontSchema = fontSchema.extend({
5024
- role: z.enum(fontRoles)
5025
- });
5026
-
5027
- // ../../core/types/engine-api/endpoints/fonts.ts
5028
- var fontPaginatedSchema = paginatedResponseSchema(fontSchema);
5029
- var FontsEndpoints = class {
5030
- // eslint-disable-next-line no-unused-vars
5031
- constructor(engineAPI) {
5032
- this.engineAPI = engineAPI;
5033
- }
5034
- list(props) {
5035
- return handleAsyncFunction(async () => {
5036
- const res = await this.engineAPI.fetcher.call({
5037
- path: "/v1/fonts",
5038
- qs: props?.qs
5039
- });
5040
- return fontPaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
5041
- });
4738
+ return url.replaceAll(" ", "").trim();
5042
4739
  }
5043
4740
  };
5044
4741
 
5045
- // ../../core/types/engine-api/endpoints/images.ts
4742
+ // ../../core/models/engine-api/endpoints/images.ts
5046
4743
  var ImagesEndpoints = class {
5047
4744
  // eslint-disable-next-line no-unused-vars
5048
4745
  constructor(engineAPI) {
5049
4746
  this.engineAPI = engineAPI;
4747
+ bindThisToFunctions(this);
5050
4748
  }
5051
- list({ bookId, qs }) {
4749
+ list(bookId) {
5052
4750
  return handleAsyncFunction(async () => {
5053
4751
  const res = await this.engineAPI.fetcher.call({
5054
- path: `/v1/images/book/${bookId}`,
5055
- qs
4752
+ path: `/v1/images/book/${bookId}`
5056
4753
  });
5057
4754
  return z.array(imageServerSchema).parse(res);
5058
4755
  });
5059
4756
  }
5060
- addToBook({ bookId, image, qs }) {
4757
+ retrieve(imageId, bookId) {
5061
4758
  return handleAsyncFunction(async () => {
5062
4759
  const res = await this.engineAPI.fetcher.call({
5063
- path: `/v1/images/book/${bookId}`,
5064
- options: {
5065
- method: "POST",
5066
- body: cleanJSON(image)
5067
- },
5068
- qs
4760
+ path: `/v1/images/${imageId}/book/${bookId}/`
5069
4761
  });
5070
4762
  return imageServerSchema.parse(res);
5071
4763
  });
5072
4764
  }
5073
- retrieve({ bookId, imageId, qs }) {
4765
+ update(imageId, bookId, image) {
5074
4766
  return handleAsyncFunction(async () => {
5075
4767
  const res = await this.engineAPI.fetcher.call({
5076
4768
  path: `/v1/images/${imageId}/book/${bookId}/`,
5077
- qs
4769
+ options: {
4770
+ method: "PUT",
4771
+ body: cleanJSON(image)
4772
+ }
5078
4773
  });
5079
4774
  return imageServerSchema.parse(res);
5080
4775
  });
5081
4776
  }
5082
- update({ bookId, imageId, payload, qs }) {
4777
+ delete(imageId, bookId) {
5083
4778
  return handleAsyncFunction(async () => {
5084
- const res = await this.engineAPI.fetcher.call({
4779
+ await this.engineAPI.fetcher.call({
5085
4780
  path: `/v1/images/${imageId}/book/${bookId}/`,
5086
4781
  options: {
5087
- method: "PUT",
5088
- body: cleanJSON(payload)
5089
- },
5090
- qs
4782
+ method: "DELETE"
4783
+ }
5091
4784
  });
5092
- return imageServerSchema.parse(res);
5093
4785
  });
5094
4786
  }
5095
- delete({ bookId, imageId, qs }) {
4787
+ addToBook(bookId, image) {
5096
4788
  return handleAsyncFunction(async () => {
5097
- await this.engineAPI.fetcher.call({
5098
- path: `/v1/images/${imageId}/book/${bookId}/`,
4789
+ const res = await this.engineAPI.fetcher.call({
4790
+ path: `/v1/images/book/${bookId}`,
5099
4791
  options: {
5100
- method: "DELETE"
5101
- },
5102
- qs
4792
+ method: "POST",
4793
+ body: cleanJSON(image)
4794
+ }
5103
4795
  });
4796
+ return imageServerSchema.parse(res);
5104
4797
  });
5105
4798
  }
5106
4799
  };
5107
4800
 
5108
- // ../../core/types/spread.ts
4801
+ // ../../core/models/spread.ts
5109
4802
  var spreadServerSchema = z.object({
5110
4803
  id: z.string().optional(),
5111
4804
  book_id: z.string(),
@@ -5139,70 +4832,94 @@ var spreadSchema = z.object({
5139
4832
  url: z.string().nullable().optional()
5140
4833
  });
5141
4834
 
5142
- // ../../core/types/engine-api/endpoints/spreads.ts
4835
+ // ../../core/models/engine-api/endpoints/spreads.ts
5143
4836
  var SpreadsEndpoints = class {
5144
4837
  // eslint-disable-next-line no-unused-vars
5145
4838
  constructor(engineAPI) {
5146
4839
  this.engineAPI = engineAPI;
4840
+ bindThisToFunctions(this);
5147
4841
  }
5148
- list({ bookId, qs }) {
4842
+ list(bookId) {
5149
4843
  return handleAsyncFunction(async () => {
5150
4844
  const res = await this.engineAPI.fetcher.call({
5151
- path: `/v1/spreads/book/${bookId}`,
5152
- qs
4845
+ path: `/v1/spreads/book/${bookId}`
5153
4846
  });
5154
- return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
4847
+ return z.array(spreadServerSchema).parse(res);
5155
4848
  });
5156
4849
  }
5157
- create({ bookId, spread, qs }) {
4850
+ create(bookId, spread) {
5158
4851
  return handleAsyncFunction(async () => {
5159
4852
  const res = await this.engineAPI.fetcher.call({
5160
4853
  path: `/v1/spreads/book/${bookId}`,
5161
4854
  options: {
5162
4855
  method: "POST",
5163
4856
  body: cleanJSON(spread)
5164
- },
5165
- qs
4857
+ }
5166
4858
  });
5167
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4859
+ return spreadServerSchema.parse(res);
5168
4860
  });
5169
4861
  }
5170
- retrieve({ bookId, spreadId, qs }) {
4862
+ retrieve(spreadId, bookId) {
5171
4863
  return handleAsyncFunction(async () => {
5172
4864
  const res = await this.engineAPI.fetcher.call({
5173
- path: `/v1/spreads/${spreadId}/book/${bookId}`,
5174
- qs
4865
+ path: `/v1/spreads/${spreadId}/book/${bookId}`
5175
4866
  });
5176
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4867
+ return spreadServerSchema.parse(res);
5177
4868
  });
5178
4869
  }
5179
- update({ bookId, spreadId, payload, qs }) {
4870
+ update(spreadId, bookId, spread) {
5180
4871
  return handleAsyncFunction(async () => {
5181
4872
  const res = await this.engineAPI.fetcher.call({
5182
4873
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5183
4874
  options: {
5184
4875
  method: "PUT",
5185
- body: cleanJSON(payload)
5186
- },
5187
- qs
4876
+ body: cleanJSON(spread)
4877
+ }
5188
4878
  });
5189
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4879
+ return spreadServerSchema.parse(res);
5190
4880
  });
5191
4881
  }
5192
- delete({ bookId, spreadId, qs }) {
4882
+ delete(spreadId, bookId) {
5193
4883
  return handleAsyncFunction(async () => {
5194
4884
  await this.engineAPI.fetcher.call({
5195
4885
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5196
4886
  options: {
5197
4887
  method: "DELETE"
5198
- },
5199
- qs
4888
+ }
4889
+ });
4890
+ });
4891
+ }
4892
+ layouts(bookId, page) {
4893
+ return handleAsyncFunction(async () => {
4894
+ const res = await this.engineAPI.fetcher.call({
4895
+ path: "/v1/spreads/layouts",
4896
+ options: {
4897
+ method: "POST",
4898
+ body: cleanJSON({
4899
+ user_id: bookId,
4900
+ page_num: page
4901
+ })
4902
+ }
5200
4903
  });
4904
+ return z.array(canvasSchema).parse(res);
5201
4905
  });
5202
4906
  }
5203
4907
  };
5204
4908
 
5205
- // ../../core/types/storyboard-item.ts
4909
+ // ../../core/models/storyboard-item.ts
4910
+ var StoryboardItemImageFaceServerSchema = z.object({
4911
+ score: z.number(),
4912
+ bounding_box: z.object({
4913
+ x: z.number(),
4914
+ y: z.number(),
4915
+ width: z.number(),
4916
+ height: z.number()
4917
+ }),
4918
+ size: z.number(),
4919
+ eyes_open_score: z.number(),
4920
+ smile_score: z.number(),
4921
+ facing_camera_score: z.number()
4922
+ });
5206
4923
  var StoryboardItemImageFaceSchema = z.object({
5207
4924
  score: z.number(),
5208
4925
  boundingBox: z.object({
@@ -5216,14 +4933,27 @@ var StoryboardItemImageFaceSchema = z.object({
5216
4933
  smileScore: z.number(),
5217
4934
  facingCameraScore: z.number()
5218
4935
  });
5219
- var StoryboardItemImageSchema = z.object({
4936
+ var StoryboardItemImageServerSchema = z.object({
5220
4937
  id: z.string(),
5221
4938
  url: z.string(),
5222
4939
  category: z.string(),
5223
- aesthetics: z.object({
5224
- score: z.number(),
5225
- scoreWithoutDistance: z.number()
4940
+ aesthetic_score: z.number(),
4941
+ faces: z.array(StoryboardItemImageFaceServerSchema),
4942
+ roi: z.object({
4943
+ x: z.number(),
4944
+ y: z.number(),
4945
+ width: z.number(),
4946
+ height: z.number()
5226
4947
  }),
4948
+ taken_at: z.number(),
4949
+ width: z.number(),
4950
+ height: z.number()
4951
+ });
4952
+ var StoryboardItemImageSchema = z.object({
4953
+ id: z.string(),
4954
+ url: z.string(),
4955
+ category: z.string(),
4956
+ aestheticScore: z.number(),
5227
4957
  faces: z.array(StoryboardItemImageFaceSchema),
5228
4958
  roi: z.object({
5229
4959
  x: z.number(),
@@ -5235,6 +4965,21 @@ var StoryboardItemImageSchema = z.object({
5235
4965
  width: z.number(),
5236
4966
  height: z.number()
5237
4967
  });
4968
+ var StoryboardItemServerSchema = z.object({
4969
+ id: z.string(),
4970
+ sequence: z.number(),
4971
+ book_id: z.string(),
4972
+ similarity: z.number(),
4973
+ duplicate: z.boolean(),
4974
+ selected: z.boolean(),
4975
+ surface_weight: z.number(),
4976
+ front_cover: z.boolean().optional(),
4977
+ back_cover: z.boolean().optional(),
4978
+ scene: z.number(),
4979
+ subscene: z.number(),
4980
+ spine_break: z.boolean().optional(),
4981
+ image: StoryboardItemImageServerSchema
4982
+ });
5238
4983
  var StoryboardItemSchema = z.object({
5239
4984
  id: z.string(),
5240
4985
  sequence: z.number(),
@@ -5251,138 +4996,34 @@ var StoryboardItemSchema = z.object({
5251
4996
  image: StoryboardItemImageSchema
5252
4997
  });
5253
4998
 
5254
- // ../../core/types/engine-api/endpoints/storyboard-items.ts
4999
+ // ../../core/models/engine-api/endpoints/storyboard-items.ts
5255
5000
  var StoryboardItemsEndpoints = class {
5256
5001
  // eslint-disable-next-line no-unused-vars
5257
5002
  constructor(engineAPI) {
5258
5003
  this.engineAPI = engineAPI;
5004
+ bindThisToFunctions(this);
5259
5005
  }
5260
- list(props) {
5261
- return handleAsyncFunction(async () => {
5262
- const res = await this.engineAPI.fetcher.call({
5263
- path: `/v1/storyboarditems/book/${props.bookId}`
5264
- });
5265
- return z.array(StoryboardItemSchema).parse(snakeCaseObjectKeysToCamelCase(res));
5266
- });
5267
- }
5268
- };
5269
-
5270
- // ../../core/types/style.ts
5271
- var styleBaseSchema = z.object({
5272
- active: z.boolean(),
5273
- name: z.string(),
5274
- slug: z.string()
5275
- });
5276
- var backgroundSchema = z.object({
5277
- url: z.string(),
5278
- compatible: z.boolean()
5279
- });
5280
- var colorSchema = z.object({
5281
- compatible: z.boolean()
5282
- });
5283
- var compatibleBackgroundSchema = z.object({
5284
- id: z.string(),
5285
- url: z.string(),
5286
- backgrounds: z.record(z.string(), backgroundSchema),
5287
- colors: z.record(z.string(), colorSchema)
5288
- });
5289
- var whitespaceSchema = z.object({
5290
- min: z.number(),
5291
- max: z.number()
5292
- });
5293
- var layoutConstraintsClasses = [
5294
- "A",
5295
- "B",
5296
- "C",
5297
- "D",
5298
- "E",
5299
- "F",
5300
- "G",
5301
- "H",
5302
- "I",
5303
- "J",
5304
- "K",
5305
- "L",
5306
- "M",
5307
- "N",
5308
- "O",
5309
- "P",
5310
- "Q",
5311
- "R",
5312
- "S",
5313
- "T",
5314
- "U",
5315
- "V",
5316
- "W",
5317
- "X",
5318
- "Y",
5319
- "Z"
5320
- ];
5321
- var layoutConstraintSchema = z.object({
5322
- whitespace: whitespaceSchema,
5323
- iWhitespace: whitespaceSchema,
5324
- classes: z.array(z.enum(layoutConstraintsClasses))
5325
- });
5326
- var layoutConstraintsSchema = z.object({
5327
- lots: layoutConstraintSchema,
5328
- few: layoutConstraintSchema,
5329
- none: layoutConstraintSchema
5330
- });
5331
- var styleSchema = styleBaseSchema.extend({
5332
- position: z.number(),
5333
- compatibleBackgrounds: z.array(compatibleBackgroundSchema),
5334
- fonts: z.array(styleFontSchema),
5335
- layoutConstraints: layoutConstraintsSchema,
5336
- colors: z.record(z.string(), z.array(z.string()))
5337
- });
5338
-
5339
- // ../../core/types/engine-api/endpoints/styles.ts
5340
- var stylePaginatedSchema = paginatedResponseSchema(styleBaseSchema);
5341
- var StylesEndpoints = class {
5342
- // eslint-disable-next-line no-unused-vars
5343
- constructor(engineAPI) {
5344
- this.engineAPI = engineAPI;
5345
- }
5346
- list(props) {
5347
- return handleAsyncFunction(async () => {
5348
- const res = await this.engineAPI.fetcher.call({
5349
- path: "/v1/styles",
5350
- qs: props?.qs
5351
- });
5352
- return stylePaginatedSchema.parse(snakeCaseObjectKeysToCamelCase(res));
5353
- });
5354
- }
5355
- retrieve({ styleSlug, qs }) {
5006
+ list(bookId) {
5356
5007
  return handleAsyncFunction(async () => {
5357
5008
  const res = await this.engineAPI.fetcher.call({
5358
- path: `/v1/styles/${styleSlug}`,
5359
- qs
5009
+ path: `/v1/storyboarditems/book/${bookId}`
5360
5010
  });
5361
- return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
5362
- });
5363
- }
5364
- update({ styleSlug, payload, qs }) {
5365
- return handleAsyncFunction(async () => {
5366
- const res = await this.engineAPI.fetcher.call({
5367
- path: `/v1/styles/${styleSlug}`,
5368
- qs,
5369
- options: {
5370
- method: "PUT",
5371
- body: cleanJSON(payload)
5372
- }
5373
- });
5374
- return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
5011
+ return z.array(StoryboardItemServerSchema).parse(res);
5375
5012
  });
5376
5013
  }
5377
5014
  };
5378
5015
 
5379
- // ../../core/types/engine-api/index.ts
5016
+ // ../../core/models/engine-api/index.ts
5380
5017
  var EngineAPI = class {
5018
+ baseUrl;
5019
+ apiKey;
5381
5020
  fetcher;
5382
5021
  constructor(baseUrl, apiKey) {
5022
+ this.baseUrl = new URL(baseUrl);
5023
+ this.apiKey = apiKey;
5383
5024
  const options = {
5384
5025
  headers: {
5385
- "Authorization": `API-Key ${apiKey}`
5026
+ "Authorization": `API-Key ${this.apiKey}`
5386
5027
  }
5387
5028
  };
5388
5029
  this.fetcher = new Fetcher(baseUrl, options);
@@ -5390,19 +5031,16 @@ var EngineAPI = class {
5390
5031
  books = new BooksEndpoints(this);
5391
5032
  designOptions = new DesignOptionsEndpoints(this);
5392
5033
  events = new EventsEndpoints(this);
5393
- embellishments = new EmbellishmentsEndpoints(this);
5394
- fonts = new FontsEndpoints(this);
5395
5034
  images = new ImagesEndpoints(this);
5396
- spreads = new SpreadsEndpoints(this);
5397
5035
  storyboardItems = new StoryboardItemsEndpoints(this);
5398
- styles = new StylesEndpoints(this);
5036
+ spreads = new SpreadsEndpoints(this);
5399
5037
  };
5400
5038
 
5401
5039
  // ../../core/config.ts
5402
- var defaultApiHost = "https://api.dev-sls.magicbook.io";
5403
- var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
5040
+ var defaultApiHost = "https://api.sfly-sls.magicbook.io";
5041
+ var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
5404
5042
 
5405
- // ../../core/types/client.ts
5043
+ // ../../core/models/client.ts
5406
5044
  var MagicBookClient = class {
5407
5045
  constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
5408
5046
  this.apiKey = apiKey;
@@ -5413,7 +5051,7 @@ var MagicBookClient = class {
5413
5051
  engineAPI;
5414
5052
  async createDesignRequest(designRequestProps) {
5415
5053
  if (designRequestProps.userId) {
5416
- const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
5054
+ const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
5417
5055
  return new DesignRequest(book.id, this, designRequestProps);
5418
5056
  } else {
5419
5057
  throw new Error("userId is required");
@@ -5426,17 +5064,10 @@ var MagicBookClient = class {
5426
5064
  BookDesignRequest,
5427
5065
  DesignRequest,
5428
5066
  DesignRequestOptions,
5429
- EmbellishmentsEndpoints,
5430
- EngineAPI,
5431
5067
  ImageServer,
5432
5068
  Images,
5433
5069
  MagicBookClient,
5434
- StoryboardItemImageFaceSchema,
5435
- StoryboardItemImageSchema,
5436
- StoryboardItemSchema,
5437
- StylesEndpoints,
5438
5070
  assetSchema,
5439
- backgroundSchema,
5440
5071
  bookCreationRequestSchema,
5441
5072
  bookDesignRequestSchema,
5442
5073
  bookPropsSchema,
@@ -5444,68 +5075,34 @@ var MagicBookClient = class {
5444
5075
  canSubmitDesignRequest,
5445
5076
  cancelledEventDetail,
5446
5077
  canvasSchema,
5447
- colorSchema,
5448
- compatibleBackgroundSchema,
5449
5078
  coverTypes,
5450
5079
  designOptionsSchema,
5451
- embellishmentAnchorsSchema,
5452
- embellishmentBackgroundListSchema,
5453
- embellishmentBackgroundSchema,
5454
- embellishmentBandSchema,
5455
- embellishmentBaseSchema,
5456
- embellishmentFrameSchema,
5457
- embellishmentGraphicStickerSchema,
5080
+ designOptionsServerSchema,
5458
5081
  embellishmentLevels,
5459
- embellishmentListSchemas,
5460
- embellishmentOrientations,
5461
- embellishmentPageCornerSchema,
5462
- embellishmentPhotoCornerAnchorsSchema,
5463
- embellishmentPhotoCornerSchema,
5464
- embellishmentPostcardSchema,
5465
- embellishmentSchemas,
5466
- embellishmentStackings,
5467
- embellishmentStampSchema,
5468
- embellishmentStripSchema,
5469
- embellishmentTPointSchema,
5470
- embellishmentTapeSchema,
5471
- embellishmentTextStickerSchema,
5472
- embellishmentThicknesses,
5473
- embellishmentTypes,
5474
- embellishmentUpdateSchemas,
5475
- fontRoles,
5476
- fontSchema,
5477
5082
  imageAssignmentSchema,
5478
5083
  imageDensities,
5479
5084
  imageDensityOptionSchema,
5085
+ imageDensityOptionServerSchema,
5480
5086
  imageDensityOptionsSchema,
5087
+ imageDensityOptionsServerSchema,
5481
5088
  imageFilteringLevels,
5482
5089
  imageServerSchema,
5483
5090
  imageServerToImage,
5484
5091
  isDesignRequestSubmitted,
5485
- layoutConstraintSchema,
5486
- layoutConstraintsClasses,
5487
- layoutConstraintsSchema,
5488
5092
  magicShopBookSchema,
5489
5093
  occasions,
5490
5094
  pageSchema,
5491
5095
  pageTypes,
5492
- paginatedResponseSchema,
5493
5096
  photoMetadataSchema,
5494
5097
  photoStripSchema,
5495
5098
  positionSchema,
5496
5099
  propertySchema,
5497
5100
  reportingDataSchema,
5498
- spreadSchema,
5499
- spreadServerSchema,
5500
5101
  states,
5501
5102
  statesToCloseWS,
5502
5103
  statesToReport,
5503
- styleBaseSchema,
5504
- styleFontSchema,
5505
- styleSchema,
5506
5104
  styles,
5507
5105
  textStickerLevels,
5508
- timeoutEventDetail,
5509
- whitespaceSchema
5106
+ timeoutEventDetail
5510
5107
  });
5511
5108
  //# sourceMappingURL=index.cjs.map