@magiclabs.ai/magicbook-client 0.7.16-canary → 0.7.18-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.iife.js CHANGED
@@ -93,7 +93,7 @@ var MagicLabs = (() => {
93
93
  ];
94
94
  var statesToReport = ["error", "timeout"];
95
95
  var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
96
- var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
96
+ var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready", "error"].includes(state);
97
97
  var occasions = [
98
98
  "baby",
99
99
  "birthday",
@@ -5657,7 +5657,7 @@ var MagicLabs = (() => {
5657
5657
  designRequestState;
5658
5658
  async add(image) {
5659
5659
  if (!canSubmitDesignRequest(this.designRequestState)) {
5660
- throw new Error("You need to wait for the current design request to be ready before adding new images.");
5660
+ throw new Error("You need to wait for the current design request to be completed before adding new images.");
5661
5661
  } else {
5662
5662
  const serverImage = await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
5663
5663
  const img = imageServerToImage(serverImage);
@@ -5670,7 +5670,7 @@ var MagicLabs = (() => {
5670
5670
  }
5671
5671
  async delete(imageId) {
5672
5672
  if (!canSubmitDesignRequest(this.designRequestState)) {
5673
- throw new Error("You need to wait for the current design request to be ready before deleting images.");
5673
+ throw new Error("You need to wait for the current design request to be completed before deleting images.");
5674
5674
  } else {
5675
5675
  await this.client.engineAPI.images.delete(imageId, this.parentId);
5676
5676
  this.list.splice(this.list.findIndex((image) => image.handle === imageId), 1);
@@ -5842,7 +5842,7 @@ var MagicLabs = (() => {
5842
5842
  }
5843
5843
  async submit(submitDesignRequestProps) {
5844
5844
  if (!canSubmitDesignRequest(this.state)) {
5845
- throw new Error("You need to wait for the current design request to be ready before submitting a new one");
5845
+ throw new Error("You need to wait for the current design request to be completed before submitting a new one.");
5846
5846
  } else {
5847
5847
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
5848
5848
  this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
@@ -5934,7 +5934,7 @@ var MagicLabs = (() => {
5934
5934
  };
5935
5935
  delete designRequest.client;
5936
5936
  delete designRequest.webSocket;
5937
- const styleSlug = styles[this.style].slug;
5937
+ const styleSlug = styles[this.style]?.slug || this.style;
5938
5938
  const bookDesignRequest = camelCaseObjectKeysToSnakeCase(cleanJSON(designRequest));
5939
5939
  bookDesignRequest.style = styleSlug;
5940
5940
  return new Book({
package/index.js CHANGED
@@ -23,7 +23,7 @@ var statesToCloseWS = [
23
23
  ];
24
24
  var statesToReport = ["error", "timeout"];
25
25
  var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
26
- var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
26
+ var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready", "error"].includes(state);
27
27
  var occasions = [
28
28
  "baby",
29
29
  "birthday",
@@ -5595,7 +5595,7 @@ var Images = class {
5595
5595
  designRequestState;
5596
5596
  async add(image) {
5597
5597
  if (!canSubmitDesignRequest(this.designRequestState)) {
5598
- throw new Error("You need to wait for the current design request to be ready before adding new images.");
5598
+ throw new Error("You need to wait for the current design request to be completed before adding new images.");
5599
5599
  } else {
5600
5600
  const serverImage = await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
5601
5601
  const img = imageServerToImage(serverImage);
@@ -5608,7 +5608,7 @@ var Images = class {
5608
5608
  }
5609
5609
  async delete(imageId) {
5610
5610
  if (!canSubmitDesignRequest(this.designRequestState)) {
5611
- throw new Error("You need to wait for the current design request to be ready before deleting images.");
5611
+ throw new Error("You need to wait for the current design request to be completed before deleting images.");
5612
5612
  } else {
5613
5613
  await this.client.engineAPI.images.delete(imageId, this.parentId);
5614
5614
  this.list.splice(this.list.findIndex((image) => image.handle === imageId), 1);
@@ -5784,7 +5784,7 @@ var DesignRequest = class {
5784
5784
  }
5785
5785
  async submit(submitDesignRequestProps) {
5786
5786
  if (!canSubmitDesignRequest(this.state)) {
5787
- throw new Error("You need to wait for the current design request to be ready before submitting a new one");
5787
+ throw new Error("You need to wait for the current design request to be completed before submitting a new one.");
5788
5788
  } else {
5789
5789
  submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
5790
5790
  this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
@@ -5876,7 +5876,7 @@ var DesignRequest = class {
5876
5876
  };
5877
5877
  delete designRequest.client;
5878
5878
  delete designRequest.webSocket;
5879
- const styleSlug = styles[this.style].slug;
5879
+ const styleSlug = styles[this.style]?.slug || this.style;
5880
5880
  const bookDesignRequest = camelCaseObjectKeysToSnakeCase(cleanJSON(designRequest));
5881
5881
  bookDesignRequest.style = styleSlug;
5882
5882
  return new Book({