@magiclabs.ai/magicbook-client 0.6.14-canary → 0.7.1-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/README.md CHANGED
@@ -23,6 +23,7 @@ Initiate the creation of a photo book by creating a design request. The design r
23
23
 
24
24
  ```ts
25
25
  const designRequest = await client.createDesignRequest({
26
+ userId: 'd72f1bbc-80c1-4338-987d-ca3eff058305' // Required value
26
27
  title: 'Australia 2023',
27
28
  occasion: 'travel',
28
29
  style: '1234',
@@ -32,7 +33,7 @@ const designRequest = await client.createDesignRequest({
32
33
  })
33
34
  ```
34
35
 
35
- Individual parameters can also be set directly on the design request instance:
36
+ Individual parameters can also be set directly on the design request instance (except for `userId`):
36
37
 
37
38
  ```ts
38
39
  const designRequest = await client.createDesignRequest()
package/index.cjs CHANGED
@@ -4085,7 +4085,8 @@ var bookPropsSchema = z.object({
4085
4085
  state: z.enum(states).optional(),
4086
4086
  guid: z.string().optional(),
4087
4087
  cancelled_at: z.string().optional(),
4088
- mb_client_timeout: z.number().optional()
4088
+ mb_client_timeout: z.number().optional(),
4089
+ user_id: z.string().optional()
4089
4090
  });
4090
4091
  var Book = class {
4091
4092
  id;
@@ -4096,6 +4097,7 @@ var Book = class {
4096
4097
  guid;
4097
4098
  cancelled_at;
4098
4099
  timeout;
4100
+ user_id;
4099
4101
  constructor(props) {
4100
4102
  this.id = props.id || "";
4101
4103
  this.title = props.title;
@@ -4105,6 +4107,7 @@ var Book = class {
4105
4107
  this.guid = props.guid;
4106
4108
  this.cancelled_at = props.cancelled_at;
4107
4109
  this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
4110
+ this.user_id = props.user_id;
4108
4111
  }
4109
4112
  toDesignRequestProps() {
4110
4113
  const props = { ...this, ...this.design_request };
@@ -4239,6 +4242,7 @@ var DesignRequest = class {
4239
4242
  this.embellishmentLevel = designRequestProps?.embellishmentLevel || embellishmentLevels[0];
4240
4243
  this.textStickerLevel = designRequestProps?.textStickerLevel || textStickerLevels[0];
4241
4244
  this.images = new Images(this.client, this.parentId);
4245
+ this.userId = designRequestProps?.userId;
4242
4246
  }
4243
4247
  webSocket;
4244
4248
  state;
@@ -4255,6 +4259,7 @@ var DesignRequest = class {
4255
4259
  embellishmentLevel;
4256
4260
  textStickerLevel;
4257
4261
  images;
4262
+ userId;
4258
4263
  guid;
4259
4264
  timeout;
4260
4265
  updateDesignRequest(designRequestProps) {
@@ -4369,7 +4374,8 @@ var DesignRequest = class {
4369
4374
  title: designRequest.title,
4370
4375
  subtitle: designRequest.subtitle,
4371
4376
  design_request: bookDesignRequest,
4372
- state: designRequest.state
4377
+ state: designRequest.state,
4378
+ user_id: designRequest.userId
4373
4379
  });
4374
4380
  }
4375
4381
  };
@@ -4460,12 +4466,13 @@ var BooksEndpoints = class {
4460
4466
  this.engineAPI = engineAPI;
4461
4467
  bindThisToFunctions(this);
4462
4468
  }
4463
- create() {
4469
+ create(book) {
4464
4470
  return handleAsyncFunction(async () => {
4465
4471
  const res = await this.engineAPI.fetcher.call({
4466
4472
  path: "/v1/books",
4467
4473
  options: {
4468
- method: "POST"
4474
+ method: "POST",
4475
+ body: cleanJSON(book)
4469
4476
  }
4470
4477
  });
4471
4478
  bookPropsSchema.safeParse(res);
@@ -4922,8 +4929,12 @@ var MagicBookClient = class {
4922
4929
  }
4923
4930
  engineAPI;
4924
4931
  async createDesignRequest(designRequestProps) {
4925
- const book = await this.engineAPI.books.create();
4926
- return new DesignRequest(book.id, this, designRequestProps);
4932
+ if (designRequestProps.userId) {
4933
+ const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
4934
+ return new DesignRequest(book.id, this, designRequestProps);
4935
+ } else {
4936
+ throw new Error("userId is required");
4937
+ }
4927
4938
  }
4928
4939
  };
4929
4940
  // Annotate the CommonJS export names for ESM import in node: