@magiclabs.ai/magicbook-client 0.7.5 → 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.d.cts CHANGED
@@ -304,6 +304,33 @@ declare class SpreadsEndpoints {
304
304
  url?: string | null | undefined;
305
305
  }>;
306
306
  delete(spreadId: string, bookId: string): Promise<void>;
307
+ layouts(bookId: string, page: number): Promise<{
308
+ backgroundId: string | null;
309
+ assets?: {
310
+ type: string;
311
+ position: {
312
+ x: number;
313
+ y: number;
314
+ rotation: number;
315
+ width?: number | undefined;
316
+ height?: number | undefined;
317
+ };
318
+ seqNum: number;
319
+ z: number;
320
+ imageAssignment?: {
321
+ photoRefId: string;
322
+ finalCrop: number[];
323
+ } | undefined;
324
+ id?: string | undefined;
325
+ horizJustification?: string | undefined;
326
+ vertJustification?: string | null | undefined;
327
+ text?: string | undefined;
328
+ fontId?: string | undefined;
329
+ fontSize?: number | undefined;
330
+ fontColor?: string | undefined;
331
+ frame?: string | undefined;
332
+ }[] | undefined;
333
+ }[]>;
307
334
  }
308
335
 
309
336
  declare class StoryboardItemsEndpoints {
@@ -974,15 +1001,15 @@ declare const textStickerLevels: readonly ["none", "few", "lots"];
974
1001
  declare const timeoutEventDetail: DesignRequestEventDetail;
975
1002
  declare const cancelledEventDetail: DesignRequestEventDetail;
976
1003
 
977
- type Occasion = typeof occasions[number];
1004
+ type Occasion = (typeof occasions)[number];
978
1005
  type Style = keyof typeof styles;
979
- type BookSize = typeof bookSizes[number];
980
- type CoverType = typeof coverTypes[number];
981
- type PageType = typeof pageTypes[number];
982
- type ImageDensity = typeof imageDensities[number];
983
- type ImageFilteringLevel = typeof imageFilteringLevels[number];
984
- type EmbellishmentLevel = typeof embellishmentLevels[number];
985
- type TextStickerLevel = typeof textStickerLevels[number];
1006
+ type BookSize = (typeof bookSizes)[number];
1007
+ type CoverType = (typeof coverTypes)[number];
1008
+ type PageType = (typeof pageTypes)[number];
1009
+ type ImageDensity = (typeof imageDensities)[number];
1010
+ type ImageFilteringLevel = (typeof imageFilteringLevels)[number];
1011
+ type EmbellishmentLevel = (typeof embellishmentLevels)[number];
1012
+ type TextStickerLevel = (typeof textStickerLevels)[number];
986
1013
  declare const DesignRequestOptions: {
987
1014
  occasion: readonly ["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"];
988
1015
  style: number[];
@@ -1009,7 +1036,7 @@ type DesignRequestProps = {
1009
1036
  textStickerLevel?: TextStickerLevel;
1010
1037
  userId: string;
1011
1038
  };
1012
- type State = typeof states[number];
1039
+ type State = (typeof states)[number];
1013
1040
  type DesignRequestEventDetail = {
1014
1041
  state: string;
1015
1042
  slug: State;
@@ -1064,6 +1091,33 @@ declare class DesignRequest {
1064
1091
  };
1065
1092
  };
1066
1093
  }>;
1094
+ getAlternateLayouts(pageNumber: number): Promise<{
1095
+ backgroundId: string | null;
1096
+ assets?: {
1097
+ type: string;
1098
+ position: {
1099
+ x: number;
1100
+ y: number;
1101
+ rotation: number;
1102
+ width?: number | undefined;
1103
+ height?: number | undefined;
1104
+ };
1105
+ seqNum: number;
1106
+ z: number;
1107
+ imageAssignment?: {
1108
+ photoRefId: string;
1109
+ finalCrop: number[];
1110
+ } | undefined;
1111
+ id?: string | undefined;
1112
+ horizJustification?: string | undefined;
1113
+ vertJustification?: string | null | undefined;
1114
+ text?: string | undefined;
1115
+ fontId?: string | undefined;
1116
+ fontSize?: number | undefined;
1117
+ fontColor?: string | undefined;
1118
+ frame?: string | undefined;
1119
+ }[] | undefined;
1120
+ }[]>;
1067
1121
  submit(submitDesignRequestProps?: Partial<DesignRequestProps>): Promise<this>;
1068
1122
  setGuid(guid: string): Promise<string>;
1069
1123
  cancel(): Promise<this>;
package/index.d.ts CHANGED
@@ -304,6 +304,33 @@ declare class SpreadsEndpoints {
304
304
  url?: string | null | undefined;
305
305
  }>;
306
306
  delete(spreadId: string, bookId: string): Promise<void>;
307
+ layouts(bookId: string, page: number): Promise<{
308
+ backgroundId: string | null;
309
+ assets?: {
310
+ type: string;
311
+ position: {
312
+ x: number;
313
+ y: number;
314
+ rotation: number;
315
+ width?: number | undefined;
316
+ height?: number | undefined;
317
+ };
318
+ seqNum: number;
319
+ z: number;
320
+ imageAssignment?: {
321
+ photoRefId: string;
322
+ finalCrop: number[];
323
+ } | undefined;
324
+ id?: string | undefined;
325
+ horizJustification?: string | undefined;
326
+ vertJustification?: string | null | undefined;
327
+ text?: string | undefined;
328
+ fontId?: string | undefined;
329
+ fontSize?: number | undefined;
330
+ fontColor?: string | undefined;
331
+ frame?: string | undefined;
332
+ }[] | undefined;
333
+ }[]>;
307
334
  }
308
335
 
309
336
  declare class StoryboardItemsEndpoints {
@@ -974,15 +1001,15 @@ declare const textStickerLevels: readonly ["none", "few", "lots"];
974
1001
  declare const timeoutEventDetail: DesignRequestEventDetail;
975
1002
  declare const cancelledEventDetail: DesignRequestEventDetail;
976
1003
 
977
- type Occasion = typeof occasions[number];
1004
+ type Occasion = (typeof occasions)[number];
978
1005
  type Style = keyof typeof styles;
979
- type BookSize = typeof bookSizes[number];
980
- type CoverType = typeof coverTypes[number];
981
- type PageType = typeof pageTypes[number];
982
- type ImageDensity = typeof imageDensities[number];
983
- type ImageFilteringLevel = typeof imageFilteringLevels[number];
984
- type EmbellishmentLevel = typeof embellishmentLevels[number];
985
- type TextStickerLevel = typeof textStickerLevels[number];
1006
+ type BookSize = (typeof bookSizes)[number];
1007
+ type CoverType = (typeof coverTypes)[number];
1008
+ type PageType = (typeof pageTypes)[number];
1009
+ type ImageDensity = (typeof imageDensities)[number];
1010
+ type ImageFilteringLevel = (typeof imageFilteringLevels)[number];
1011
+ type EmbellishmentLevel = (typeof embellishmentLevels)[number];
1012
+ type TextStickerLevel = (typeof textStickerLevels)[number];
986
1013
  declare const DesignRequestOptions: {
987
1014
  occasion: readonly ["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"];
988
1015
  style: number[];
@@ -1009,7 +1036,7 @@ type DesignRequestProps = {
1009
1036
  textStickerLevel?: TextStickerLevel;
1010
1037
  userId: string;
1011
1038
  };
1012
- type State = typeof states[number];
1039
+ type State = (typeof states)[number];
1013
1040
  type DesignRequestEventDetail = {
1014
1041
  state: string;
1015
1042
  slug: State;
@@ -1064,6 +1091,33 @@ declare class DesignRequest {
1064
1091
  };
1065
1092
  };
1066
1093
  }>;
1094
+ getAlternateLayouts(pageNumber: number): Promise<{
1095
+ backgroundId: string | null;
1096
+ assets?: {
1097
+ type: string;
1098
+ position: {
1099
+ x: number;
1100
+ y: number;
1101
+ rotation: number;
1102
+ width?: number | undefined;
1103
+ height?: number | undefined;
1104
+ };
1105
+ seqNum: number;
1106
+ z: number;
1107
+ imageAssignment?: {
1108
+ photoRefId: string;
1109
+ finalCrop: number[];
1110
+ } | undefined;
1111
+ id?: string | undefined;
1112
+ horizJustification?: string | undefined;
1113
+ vertJustification?: string | null | undefined;
1114
+ text?: string | undefined;
1115
+ fontId?: string | undefined;
1116
+ fontSize?: number | undefined;
1117
+ fontColor?: string | undefined;
1118
+ frame?: string | undefined;
1119
+ }[] | undefined;
1120
+ }[]>;
1067
1121
  submit(submitDesignRequestProps?: Partial<DesignRequestProps>): Promise<this>;
1068
1122
  setGuid(guid: string): Promise<string>;
1069
1123
  cancel(): Promise<this>;
package/index.js CHANGED
@@ -4280,15 +4280,24 @@ var DesignRequest = class {
4280
4280
  }
4281
4281
  }
4282
4282
  async getOptions(imageCount) {
4283
- const options = designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(
4284
- await this.client.engineAPI.designOptions.retrieve(
4285
- this.bookSize,
4286
- imageCount || this.images.length,
4287
- this.imageFilteringLevel
4283
+ const options = designOptionsSchema.parse(
4284
+ snakeCaseObjectKeysToCamelCase(
4285
+ await this.client.engineAPI.designOptions.retrieve(
4286
+ this.bookSize,
4287
+ imageCount || this.images.length,
4288
+ this.imageFilteringLevel
4289
+ )
4288
4290
  )
4289
- ));
4291
+ );
4290
4292
  return options;
4291
4293
  }
4294
+ async getAlternateLayouts(pageNumber) {
4295
+ if (this.state === "ready") {
4296
+ return await this.client.engineAPI.spreads.layouts(this.parentId, pageNumber);
4297
+ } else {
4298
+ throw new Error("Design request not ready");
4299
+ }
4300
+ }
4292
4301
  async submit(submitDesignRequestProps) {
4293
4302
  if (!canSubmitDesignRequest(this.state)) {
4294
4303
  throw new Error("You need to wait for the current design request to be ready before submitting a new one");
@@ -4296,9 +4305,7 @@ var DesignRequest = class {
4296
4305
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
4297
4306
  this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
4298
4307
  await this.client.engineAPI.books.update(this.parentId, this.toBook());
4299
- this.updateDesignRequest(
4300
- (await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
4301
- );
4308
+ this.updateDesignRequest((await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps());
4302
4309
  this.getProgress();
4303
4310
  return this;
4304
4311
  }
@@ -4813,6 +4820,21 @@ var SpreadsEndpoints = class {
4813
4820
  });
4814
4821
  });
4815
4822
  }
4823
+ layouts(bookId, page) {
4824
+ return handleAsyncFunction(async () => {
4825
+ const res = await this.engineAPI.fetcher.call({
4826
+ path: "/v1/spreads/layouts",
4827
+ options: {
4828
+ method: "POST",
4829
+ body: cleanJSON({
4830
+ user_id: bookId,
4831
+ page_num: page
4832
+ })
4833
+ }
4834
+ });
4835
+ return z.array(canvasSchema).parse(res);
4836
+ });
4837
+ }
4816
4838
  };
4817
4839
 
4818
4840
  // ../../core/models/storyboard-item.ts