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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs 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)),
@@ -4371,13 +4349,13 @@ var DesignRequest = class {
4371
4349
  }
4372
4350
  }
4373
4351
  async getOptions(imageCount) {
4374
- 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
- })
4380
- );
4352
+ const options = designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(
4353
+ await this.client.engineAPI.designOptions.retrieve(
4354
+ this.bookSize,
4355
+ imageCount || this.images.length,
4356
+ this.imageFilteringLevel
4357
+ )
4358
+ ));
4381
4359
  return options;
4382
4360
  }
4383
4361
  async submit(submitDesignRequestProps) {
@@ -4386,12 +4364,9 @@ var DesignRequest = class {
4386
4364
  } else {
4387
4365
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
4388
4366
  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
- });
4367
+ await this.client.engineAPI.books.update(this.parentId, this.toBook());
4393
4368
  this.updateDesignRequest(
4394
- (await this.client.engineAPI.books.design({ bookId: this.parentId })).toDesignRequestProps()
4369
+ (await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
4395
4370
  );
4396
4371
  this.getProgress();
4397
4372
  return this;
@@ -4403,10 +4378,7 @@ var DesignRequest = class {
4403
4378
  } else {
4404
4379
  this.guid = guid;
4405
4380
  this.updateDesignRequest(
4406
- (await this.client.engineAPI.books.update({
4407
- bookId: this.parentId,
4408
- payload: this.toBook()
4409
- })).toDesignRequestProps()
4381
+ (await this.client.engineAPI.books.update(this.parentId, this.toBook())).toDesignRequestProps()
4410
4382
  );
4411
4383
  return this.guid;
4412
4384
  }
@@ -4420,9 +4392,7 @@ var DesignRequest = class {
4420
4392
  throw new Error("Design request not submitted");
4421
4393
  } else {
4422
4394
  this.updateDesignRequest({
4423
- ...(await this.client.engineAPI.books.cancel({
4424
- bookId: this.parentId
4425
- })).toDesignRequestProps(),
4395
+ ...(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps(),
4426
4396
  state: "cancelled"
4427
4397
  });
4428
4398
  await this.eventHandler(cancelledEventDetail);
@@ -4431,31 +4401,22 @@ var DesignRequest = class {
4431
4401
  }
4432
4402
  async getJSON() {
4433
4403
  if (this.state === "ready") {
4434
- return await this.client.engineAPI.books.retrieveGalleon({
4435
- bookId: this.parentId
4436
- });
4404
+ return await this.client.engineAPI.books.retrieveGalleon(this.parentId);
4437
4405
  } else {
4438
4406
  throw new Error("Design request not ready");
4439
4407
  }
4440
4408
  }
4441
4409
  async logEvent(name, data) {
4442
- return await this.client.engineAPI.events.createBookEvent({
4443
- bookId: this.parentId,
4444
- name,
4445
- data
4446
- });
4410
+ return await this.client.engineAPI.events.createBookEvent(this.parentId, name, data);
4447
4411
  }
4448
4412
  async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
4449
4413
  const customEvent = new CustomEvent(type, { detail });
4450
4414
  if (statesToCloseWS.includes(detail.slug)) {
4451
4415
  this.webSocket?.close();
4452
4416
  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
- }
4417
+ await this.client.engineAPI.books.report(this.parentId, {
4418
+ error: detail.slug === "error" ? "design" : "timeout",
4419
+ step: this.state
4459
4420
  });
4460
4421
  }
4461
4422
  }
@@ -4508,7 +4469,7 @@ var DesignRequest = class {
4508
4469
  }
4509
4470
  };
4510
4471
 
4511
- // ../../core/types/galleon.ts
4472
+ // ../../core/models/galleon.ts
4512
4473
  var imageAssignmentSchema = z.object({
4513
4474
  photoRefId: z.string(),
4514
4475
  finalCrop: z.array(z.number())
@@ -4587,357 +4548,128 @@ var bookCreationRequestSchema = z.object({
4587
4548
  reportingData: reportingDataSchema
4588
4549
  });
4589
4550
 
4590
- // ../../core/types/engine-api/endpoints/books.ts
4551
+ // ../../core/models/engine-api/endpoints/books.ts
4591
4552
  var BooksEndpoints = class {
4592
4553
  // eslint-disable-next-line no-unused-vars
4593
4554
  constructor(engineAPI) {
4594
4555
  this.engineAPI = engineAPI;
4556
+ bindThisToFunctions(this);
4595
4557
  }
4596
- create({ book, qs }) {
4558
+ create(book) {
4597
4559
  return handleAsyncFunction(async () => {
4598
4560
  const res = await this.engineAPI.fetcher.call({
4599
4561
  path: "/v1/books",
4600
4562
  options: {
4601
4563
  method: "POST",
4602
4564
  body: cleanJSON(book)
4603
- },
4604
- qs
4565
+ }
4605
4566
  });
4567
+ bookPropsSchema.safeParse(res);
4606
4568
  return new Book(res);
4607
4569
  });
4608
4570
  }
4609
- retrieve({ bookId, qs }) {
4571
+ retrieve(bookId) {
4610
4572
  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);
4573
+ const res = await this.engineAPI.fetcher.call({ path: `/v1/books/${bookId}` });
4574
+ bookPropsSchema.safeParse(res);
4575
+ return new Book(res);
4617
4576
  });
4618
4577
  }
4619
- update({ bookId, payload, qs }) {
4578
+ update(bookId, book) {
4620
4579
  return handleAsyncFunction(async () => {
4621
4580
  const res = await this.engineAPI.fetcher.call({
4622
4581
  path: `/v1/books/${bookId}`,
4623
4582
  options: {
4624
4583
  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
4584
+ body: cleanJSON(book)
4585
+ }
4639
4586
  });
4587
+ bookPropsSchema.safeParse(res);
4588
+ return new Book(res);
4640
4589
  });
4641
4590
  }
4642
- design({ bookId, qs }) {
4591
+ design(bookId) {
4643
4592
  return handleAsyncFunction(async () => {
4644
4593
  const res = await this.engineAPI.fetcher.call({
4645
4594
  path: `/v1/books/${bookId}/design`,
4646
- options: { method: "POST" },
4647
- qs
4595
+ options: { method: "POST" }
4648
4596
  });
4649
- const bookProps = bookPropsSchema.parse(res);
4650
- return new Book(bookProps);
4597
+ bookPropsSchema.safeParse(res);
4598
+ return new Book(res);
4651
4599
  });
4652
4600
  }
4653
- cancel({ bookId, qs }) {
4601
+ cancel(bookId) {
4654
4602
  return handleAsyncFunction(async () => {
4655
4603
  const res = await this.engineAPI.fetcher.call({
4656
4604
  path: `/v1/books/${bookId}/cancel`,
4657
- options: { method: "POST" },
4658
- qs
4605
+ options: { method: "POST" }
4659
4606
  });
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);
4607
+ bookPropsSchema.safeParse(res);
4608
+ return new Book(res);
4671
4609
  });
4672
4610
  }
4673
- report({ bookId, report, qs }) {
4611
+ report(bookId, report) {
4674
4612
  return handleAsyncFunction(async () => {
4675
4613
  await this.engineAPI.fetcher.call({
4676
4614
  path: `/v1/books/${bookId}/report`,
4677
4615
  options: {
4678
4616
  method: "POST",
4679
4617
  body: cleanJSON(report)
4680
- },
4681
- qs
4618
+ }
4682
4619
  });
4683
4620
  });
4684
4621
  }
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;
4622
+ delete(bookId) {
4623
+ return handleAsyncFunction(async () => {
4624
+ await this.engineAPI.fetcher.call({
4625
+ path: `/v1/books/${bookId}`,
4626
+ options: { method: "DELETE" }
4627
+ });
4628
+ });
4692
4629
  }
4693
- retrieve(props) {
4630
+ retrieveGalleon(bookId) {
4694
4631
  return handleAsyncFunction(async () => {
4695
4632
  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
4633
+ path: `/v1/books/${bookId}/format/galleon`
4699
4634
  });
4700
- return designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4635
+ return bookCreationRequestSchema.parse(res);
4701
4636
  });
4702
4637
  }
4703
4638
  };
4704
4639
 
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 {
4640
+ // ../../core/models/engine-api/endpoints/design-options.ts
4641
+ var DesignOptionsEndpoints = class {
4879
4642
  // eslint-disable-next-line no-unused-vars
4880
4643
  constructor(engineAPI) {
4881
4644
  this.engineAPI = engineAPI;
4645
+ bindThisToFunctions(this);
4882
4646
  }
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 }) {
4893
- return handleAsyncFunction(async () => {
4894
- 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 }) {
4647
+ retrieve(bookSize, imageCount, imageFilteringLevel) {
4902
4648
  return handleAsyncFunction(async () => {
4903
4649
  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
- }
4650
+ // eslint-disable-next-line max-len
4651
+ path: `/v1/designoptions/booksize/${bookSize}/imagecount/${imageCount}/imagefilteringlevel/${imageFilteringLevel}`
4909
4652
  });
4910
- return embellishmentSchemas.parse(snakeCaseObjectKeysToCamelCase(res));
4653
+ return designOptionsServerSchema.parse(res);
4911
4654
  });
4912
4655
  }
4913
4656
  };
4914
4657
 
4915
- // ../../core/types/event.ts
4658
+ // ../../core/models/event.ts
4916
4659
  var eventContextSchema = z.record(z.string(), z.unknown()).optional();
4917
4660
  var eventSchema = z.object({
4918
4661
  name: z.string(),
4919
- context: eventContextSchema,
4920
- bookId: z.string(),
4921
- createdAt: z.string()
4662
+ context: eventContextSchema
4922
4663
  });
4923
4664
 
4924
- // ../../core/types/engine-api/endpoints/events.ts
4925
- var eventPaginatedSchema = paginatedResponseSchema(eventSchema);
4665
+ // ../../core/models/engine-api/endpoints/events.ts
4926
4666
  var EventsEndpoints = class {
4927
4667
  // eslint-disable-next-line no-unused-vars
4928
4668
  constructor(engineAPI) {
4929
4669
  this.engineAPI = engineAPI;
4670
+ bindThisToFunctions(this);
4930
4671
  }
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 }) {
4672
+ createBookEvent(bookId, name, data) {
4941
4673
  return handleAsyncFunction(async () => {
4942
4674
  const body = {
4943
4675
  name
@@ -4948,26 +4680,14 @@ var EventsEndpoints = class {
4948
4680
  options: {
4949
4681
  method: "POST",
4950
4682
  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
4683
+ }
4965
4684
  });
4685
+ return eventSchema.parse(res);
4966
4686
  });
4967
4687
  }
4968
4688
  };
4969
4689
 
4970
- // ../../core/types/fetcher.ts
4690
+ // ../../core/models/fetcher.ts
4971
4691
  var baseOptions = {
4972
4692
  headers: {
4973
4693
  "Content-Type": "application/json"
@@ -4988,14 +4708,12 @@ var Fetcher = class {
4988
4708
  }
4989
4709
  const baseOptions2 = { ...this.options };
4990
4710
  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();
4711
+ const res = await fetch(this.cleanUrl(new URL(props.path, this.baseUrl).href), options);
4712
+ if (res.status >= 200 && res.status < 300) {
4995
4713
  try {
4996
- return JSON.parse(result);
4714
+ return await res.json();
4997
4715
  } catch (error) {
4998
- return result;
4716
+ return {};
4999
4717
  }
5000
4718
  } else {
5001
4719
  let detail = res.statusText;
@@ -5010,102 +4728,70 @@ var Fetcher = class {
5010
4728
  }
5011
4729
  }
5012
4730
  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
- });
4731
+ return url.replaceAll(" ", "").trim();
5042
4732
  }
5043
4733
  };
5044
4734
 
5045
- // ../../core/types/engine-api/endpoints/images.ts
4735
+ // ../../core/models/engine-api/endpoints/images.ts
5046
4736
  var ImagesEndpoints = class {
5047
4737
  // eslint-disable-next-line no-unused-vars
5048
4738
  constructor(engineAPI) {
5049
4739
  this.engineAPI = engineAPI;
4740
+ bindThisToFunctions(this);
5050
4741
  }
5051
- list({ bookId, qs }) {
4742
+ list(bookId) {
5052
4743
  return handleAsyncFunction(async () => {
5053
4744
  const res = await this.engineAPI.fetcher.call({
5054
- path: `/v1/images/book/${bookId}`,
5055
- qs
4745
+ path: `/v1/images/book/${bookId}`
5056
4746
  });
5057
4747
  return z.array(imageServerSchema).parse(res);
5058
4748
  });
5059
4749
  }
5060
- addToBook({ bookId, image, qs }) {
4750
+ retrieve(imageId, bookId) {
5061
4751
  return handleAsyncFunction(async () => {
5062
4752
  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
4753
+ path: `/v1/images/${imageId}/book/${bookId}/`
5069
4754
  });
5070
4755
  return imageServerSchema.parse(res);
5071
4756
  });
5072
4757
  }
5073
- retrieve({ bookId, imageId, qs }) {
4758
+ update(imageId, bookId, image) {
5074
4759
  return handleAsyncFunction(async () => {
5075
4760
  const res = await this.engineAPI.fetcher.call({
5076
4761
  path: `/v1/images/${imageId}/book/${bookId}/`,
5077
- qs
4762
+ options: {
4763
+ method: "PUT",
4764
+ body: cleanJSON(image)
4765
+ }
5078
4766
  });
5079
4767
  return imageServerSchema.parse(res);
5080
4768
  });
5081
4769
  }
5082
- update({ bookId, imageId, payload, qs }) {
4770
+ delete(imageId, bookId) {
5083
4771
  return handleAsyncFunction(async () => {
5084
- const res = await this.engineAPI.fetcher.call({
4772
+ await this.engineAPI.fetcher.call({
5085
4773
  path: `/v1/images/${imageId}/book/${bookId}/`,
5086
4774
  options: {
5087
- method: "PUT",
5088
- body: cleanJSON(payload)
5089
- },
5090
- qs
4775
+ method: "DELETE"
4776
+ }
5091
4777
  });
5092
- return imageServerSchema.parse(res);
5093
4778
  });
5094
4779
  }
5095
- delete({ bookId, imageId, qs }) {
4780
+ addToBook(bookId, image) {
5096
4781
  return handleAsyncFunction(async () => {
5097
- await this.engineAPI.fetcher.call({
5098
- path: `/v1/images/${imageId}/book/${bookId}/`,
4782
+ const res = await this.engineAPI.fetcher.call({
4783
+ path: `/v1/images/book/${bookId}`,
5099
4784
  options: {
5100
- method: "DELETE"
5101
- },
5102
- qs
4785
+ method: "POST",
4786
+ body: cleanJSON(image)
4787
+ }
5103
4788
  });
4789
+ return imageServerSchema.parse(res);
5104
4790
  });
5105
4791
  }
5106
4792
  };
5107
4793
 
5108
- // ../../core/types/spread.ts
4794
+ // ../../core/models/spread.ts
5109
4795
  var spreadServerSchema = z.object({
5110
4796
  id: z.string().optional(),
5111
4797
  book_id: z.string(),
@@ -5139,70 +4825,79 @@ var spreadSchema = z.object({
5139
4825
  url: z.string().nullable().optional()
5140
4826
  });
5141
4827
 
5142
- // ../../core/types/engine-api/endpoints/spreads.ts
4828
+ // ../../core/models/engine-api/endpoints/spreads.ts
5143
4829
  var SpreadsEndpoints = class {
5144
4830
  // eslint-disable-next-line no-unused-vars
5145
4831
  constructor(engineAPI) {
5146
4832
  this.engineAPI = engineAPI;
4833
+ bindThisToFunctions(this);
5147
4834
  }
5148
- list({ bookId, qs }) {
4835
+ list(bookId) {
5149
4836
  return handleAsyncFunction(async () => {
5150
4837
  const res = await this.engineAPI.fetcher.call({
5151
- path: `/v1/spreads/book/${bookId}`,
5152
- qs
4838
+ path: `/v1/spreads/book/${bookId}`
5153
4839
  });
5154
- return z.array(spreadSchema).parse(snakeCaseObjectKeysToCamelCase(res));
4840
+ return z.array(spreadServerSchema).parse(res);
5155
4841
  });
5156
4842
  }
5157
- create({ bookId, spread, qs }) {
4843
+ create(bookId, spread) {
5158
4844
  return handleAsyncFunction(async () => {
5159
4845
  const res = await this.engineAPI.fetcher.call({
5160
4846
  path: `/v1/spreads/book/${bookId}`,
5161
4847
  options: {
5162
4848
  method: "POST",
5163
4849
  body: cleanJSON(spread)
5164
- },
5165
- qs
4850
+ }
5166
4851
  });
5167
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4852
+ return spreadServerSchema.parse(res);
5168
4853
  });
5169
4854
  }
5170
- retrieve({ bookId, spreadId, qs }) {
4855
+ retrieve(spreadId, bookId) {
5171
4856
  return handleAsyncFunction(async () => {
5172
4857
  const res = await this.engineAPI.fetcher.call({
5173
- path: `/v1/spreads/${spreadId}/book/${bookId}`,
5174
- qs
4858
+ path: `/v1/spreads/${spreadId}/book/${bookId}`
5175
4859
  });
5176
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4860
+ return spreadServerSchema.parse(res);
5177
4861
  });
5178
4862
  }
5179
- update({ bookId, spreadId, payload, qs }) {
4863
+ update(spreadId, bookId, spread) {
5180
4864
  return handleAsyncFunction(async () => {
5181
4865
  const res = await this.engineAPI.fetcher.call({
5182
4866
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5183
4867
  options: {
5184
4868
  method: "PUT",
5185
- body: cleanJSON(payload)
5186
- },
5187
- qs
4869
+ body: cleanJSON(spread)
4870
+ }
5188
4871
  });
5189
- return spreadSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4872
+ return spreadServerSchema.parse(res);
5190
4873
  });
5191
4874
  }
5192
- delete({ bookId, spreadId, qs }) {
4875
+ delete(spreadId, bookId) {
5193
4876
  return handleAsyncFunction(async () => {
5194
4877
  await this.engineAPI.fetcher.call({
5195
4878
  path: `/v1/spreads/${spreadId}/book/${bookId}`,
5196
4879
  options: {
5197
4880
  method: "DELETE"
5198
- },
5199
- qs
4881
+ }
5200
4882
  });
5201
4883
  });
5202
4884
  }
5203
4885
  };
5204
4886
 
5205
- // ../../core/types/storyboard-item.ts
4887
+ // ../../core/models/storyboard-item.ts
4888
+ var StoryboardItemImageFaceServerSchema = z.object({
4889
+ score: z.number(),
4890
+ bounding_box: z.object({
4891
+ x: z.number(),
4892
+ y: z.number(),
4893
+ width: z.number(),
4894
+ height: z.number()
4895
+ }),
4896
+ size: z.number(),
4897
+ eyes_open_score: z.number(),
4898
+ smile_score: z.number(),
4899
+ facing_camera_score: z.number()
4900
+ });
5206
4901
  var StoryboardItemImageFaceSchema = z.object({
5207
4902
  score: z.number(),
5208
4903
  boundingBox: z.object({
@@ -5216,14 +4911,27 @@ var StoryboardItemImageFaceSchema = z.object({
5216
4911
  smileScore: z.number(),
5217
4912
  facingCameraScore: z.number()
5218
4913
  });
5219
- var StoryboardItemImageSchema = z.object({
4914
+ var StoryboardItemImageServerSchema = z.object({
5220
4915
  id: z.string(),
5221
4916
  url: z.string(),
5222
4917
  category: z.string(),
5223
- aesthetics: z.object({
5224
- score: z.number(),
5225
- scoreWithoutDistance: z.number()
4918
+ aesthetic_score: z.number(),
4919
+ faces: z.array(StoryboardItemImageFaceServerSchema),
4920
+ roi: z.object({
4921
+ x: z.number(),
4922
+ y: z.number(),
4923
+ width: z.number(),
4924
+ height: z.number()
5226
4925
  }),
4926
+ taken_at: z.number(),
4927
+ width: z.number(),
4928
+ height: z.number()
4929
+ });
4930
+ var StoryboardItemImageSchema = z.object({
4931
+ id: z.string(),
4932
+ url: z.string(),
4933
+ category: z.string(),
4934
+ aestheticScore: z.number(),
5227
4935
  faces: z.array(StoryboardItemImageFaceSchema),
5228
4936
  roi: z.object({
5229
4937
  x: z.number(),
@@ -5235,6 +4943,21 @@ var StoryboardItemImageSchema = z.object({
5235
4943
  width: z.number(),
5236
4944
  height: z.number()
5237
4945
  });
4946
+ var StoryboardItemServerSchema = z.object({
4947
+ id: z.string(),
4948
+ sequence: z.number(),
4949
+ book_id: z.string(),
4950
+ similarity: z.number(),
4951
+ duplicate: z.boolean(),
4952
+ selected: z.boolean(),
4953
+ surface_weight: z.number(),
4954
+ front_cover: z.boolean().optional(),
4955
+ back_cover: z.boolean().optional(),
4956
+ scene: z.number(),
4957
+ subscene: z.number(),
4958
+ spine_break: z.boolean().optional(),
4959
+ image: StoryboardItemImageServerSchema
4960
+ });
5238
4961
  var StoryboardItemSchema = z.object({
5239
4962
  id: z.string(),
5240
4963
  sequence: z.number(),
@@ -5251,138 +4974,34 @@ var StoryboardItemSchema = z.object({
5251
4974
  image: StoryboardItemImageSchema
5252
4975
  });
5253
4976
 
5254
- // ../../core/types/engine-api/endpoints/storyboard-items.ts
4977
+ // ../../core/models/engine-api/endpoints/storyboard-items.ts
5255
4978
  var StoryboardItemsEndpoints = class {
5256
4979
  // eslint-disable-next-line no-unused-vars
5257
4980
  constructor(engineAPI) {
5258
4981
  this.engineAPI = engineAPI;
4982
+ bindThisToFunctions(this);
5259
4983
  }
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 }) {
4984
+ list(bookId) {
5356
4985
  return handleAsyncFunction(async () => {
5357
4986
  const res = await this.engineAPI.fetcher.call({
5358
- path: `/v1/styles/${styleSlug}`,
5359
- qs
5360
- });
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
- }
4987
+ path: `/v1/storyboarditems/book/${bookId}`
5373
4988
  });
5374
- return styleSchema.parse(snakeCaseObjectKeysToCamelCase(res));
4989
+ return z.array(StoryboardItemServerSchema).parse(res);
5375
4990
  });
5376
4991
  }
5377
4992
  };
5378
4993
 
5379
- // ../../core/types/engine-api/index.ts
4994
+ // ../../core/models/engine-api/index.ts
5380
4995
  var EngineAPI = class {
4996
+ baseUrl;
4997
+ apiKey;
5381
4998
  fetcher;
5382
4999
  constructor(baseUrl, apiKey) {
5000
+ this.baseUrl = new URL(baseUrl);
5001
+ this.apiKey = apiKey;
5383
5002
  const options = {
5384
5003
  headers: {
5385
- "Authorization": `API-Key ${apiKey}`
5004
+ "Authorization": `API-Key ${this.apiKey}`
5386
5005
  }
5387
5006
  };
5388
5007
  this.fetcher = new Fetcher(baseUrl, options);
@@ -5390,19 +5009,16 @@ var EngineAPI = class {
5390
5009
  books = new BooksEndpoints(this);
5391
5010
  designOptions = new DesignOptionsEndpoints(this);
5392
5011
  events = new EventsEndpoints(this);
5393
- embellishments = new EmbellishmentsEndpoints(this);
5394
- fonts = new FontsEndpoints(this);
5395
5012
  images = new ImagesEndpoints(this);
5396
- spreads = new SpreadsEndpoints(this);
5397
5013
  storyboardItems = new StoryboardItemsEndpoints(this);
5398
- styles = new StylesEndpoints(this);
5014
+ spreads = new SpreadsEndpoints(this);
5399
5015
  };
5400
5016
 
5401
5017
  // ../../core/config.ts
5402
- var defaultApiHost = "https://api.dev-sls.magicbook.io";
5403
- var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
5018
+ var defaultApiHost = "https://api.sfly-sls.magicbook.io";
5019
+ var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
5404
5020
 
5405
- // ../../core/types/client.ts
5021
+ // ../../core/models/client.ts
5406
5022
  var MagicBookClient = class {
5407
5023
  constructor(apiKey, apiHost = defaultApiHost, webSocketHost = defaultWebSocketHost) {
5408
5024
  this.apiKey = apiKey;
@@ -5413,7 +5029,7 @@ var MagicBookClient = class {
5413
5029
  engineAPI;
5414
5030
  async createDesignRequest(designRequestProps) {
5415
5031
  if (designRequestProps.userId) {
5416
- const book = await this.engineAPI.books.create({ book: { user_id: designRequestProps.userId } });
5032
+ const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
5417
5033
  return new DesignRequest(book.id, this, designRequestProps);
5418
5034
  } else {
5419
5035
  throw new Error("userId is required");
@@ -5426,17 +5042,10 @@ var MagicBookClient = class {
5426
5042
  BookDesignRequest,
5427
5043
  DesignRequest,
5428
5044
  DesignRequestOptions,
5429
- EmbellishmentsEndpoints,
5430
- EngineAPI,
5431
5045
  ImageServer,
5432
5046
  Images,
5433
5047
  MagicBookClient,
5434
- StoryboardItemImageFaceSchema,
5435
- StoryboardItemImageSchema,
5436
- StoryboardItemSchema,
5437
- StylesEndpoints,
5438
5048
  assetSchema,
5439
- backgroundSchema,
5440
5049
  bookCreationRequestSchema,
5441
5050
  bookDesignRequestSchema,
5442
5051
  bookPropsSchema,
@@ -5444,68 +5053,34 @@ var MagicBookClient = class {
5444
5053
  canSubmitDesignRequest,
5445
5054
  cancelledEventDetail,
5446
5055
  canvasSchema,
5447
- colorSchema,
5448
- compatibleBackgroundSchema,
5449
5056
  coverTypes,
5450
5057
  designOptionsSchema,
5451
- embellishmentAnchorsSchema,
5452
- embellishmentBackgroundListSchema,
5453
- embellishmentBackgroundSchema,
5454
- embellishmentBandSchema,
5455
- embellishmentBaseSchema,
5456
- embellishmentFrameSchema,
5457
- embellishmentGraphicStickerSchema,
5058
+ designOptionsServerSchema,
5458
5059
  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
5060
  imageAssignmentSchema,
5478
5061
  imageDensities,
5479
5062
  imageDensityOptionSchema,
5063
+ imageDensityOptionServerSchema,
5480
5064
  imageDensityOptionsSchema,
5065
+ imageDensityOptionsServerSchema,
5481
5066
  imageFilteringLevels,
5482
5067
  imageServerSchema,
5483
5068
  imageServerToImage,
5484
5069
  isDesignRequestSubmitted,
5485
- layoutConstraintSchema,
5486
- layoutConstraintsClasses,
5487
- layoutConstraintsSchema,
5488
5070
  magicShopBookSchema,
5489
5071
  occasions,
5490
5072
  pageSchema,
5491
5073
  pageTypes,
5492
- paginatedResponseSchema,
5493
5074
  photoMetadataSchema,
5494
5075
  photoStripSchema,
5495
5076
  positionSchema,
5496
5077
  propertySchema,
5497
5078
  reportingDataSchema,
5498
- spreadSchema,
5499
- spreadServerSchema,
5500
5079
  states,
5501
5080
  statesToCloseWS,
5502
5081
  statesToReport,
5503
- styleBaseSchema,
5504
- styleFontSchema,
5505
- styleSchema,
5506
5082
  styles,
5507
5083
  textStickerLevels,
5508
- timeoutEventDetail,
5509
- whitespaceSchema
5084
+ timeoutEventDetail
5510
5085
  });
5511
5086
  //# sourceMappingURL=index.cjs.map