@magiclabs.ai/magicbook-client 0.6.14 → 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/index.d.cts CHANGED
@@ -6,7 +6,7 @@ type EventContext = z.infer<typeof eventContextSchema>;
6
6
  declare class BooksEndpoints {
7
7
  private readonly engineAPI;
8
8
  constructor(engineAPI: EngineAPI);
9
- create(): Promise<Book>;
9
+ create(book: Partial<Book>): Promise<Book>;
10
10
  retrieve(bookId: string): Promise<Book>;
11
11
  update(bookId: string, book: Partial<Book>): Promise<Book>;
12
12
  cancel(bookId: string): Promise<Book>;
@@ -371,7 +371,7 @@ declare class MagicBookClient {
371
371
  readonly webSocketHost: string;
372
372
  engineAPI: EngineAPI;
373
373
  constructor(apiKey: string, apiHost?: string, webSocketHost?: string);
374
- createDesignRequest(designRequestProps?: DesignRequestProps): Promise<DesignRequest>;
374
+ createDesignRequest(designRequestProps: DesignRequestProps): Promise<DesignRequest>;
375
375
  }
376
376
 
377
377
  type Image = {
@@ -985,6 +985,7 @@ type DesignRequestProps = {
985
985
  imageFilteringLevel?: ImageFilteringLevel;
986
986
  embellishmentLevel?: EmbellishmentLevel;
987
987
  textStickerLevel?: TextStickerLevel;
988
+ userId: string;
988
989
  };
989
990
  type State = typeof states[number];
990
991
  type DesignRequestEventDetail = {
@@ -1011,6 +1012,7 @@ declare class DesignRequest {
1011
1012
  embellishmentLevel: EmbellishmentLevel;
1012
1013
  textStickerLevel: TextStickerLevel;
1013
1014
  images: Images;
1015
+ userId?: string;
1014
1016
  guid?: string;
1015
1017
  timeout?: number;
1016
1018
  constructor(parentId: string, client: MagicBookClient, designRequestProps?: DesignRequestProps);
@@ -1040,7 +1042,7 @@ declare class DesignRequest {
1040
1042
  };
1041
1043
  };
1042
1044
  }>;
1043
- submit(submitDesignRequestProps?: DesignRequestProps): Promise<this>;
1045
+ submit(submitDesignRequestProps?: Partial<DesignRequestProps>): Promise<this>;
1044
1046
  setGuid(guid: string): Promise<string>;
1045
1047
  cancel(): Promise<this>;
1046
1048
  getJSON(): Promise<{
@@ -1217,6 +1219,7 @@ declare const bookPropsSchema: z.ZodObject<{
1217
1219
  guid: z.ZodOptional<z.ZodString>;
1218
1220
  cancelled_at: z.ZodOptional<z.ZodString>;
1219
1221
  mb_client_timeout: z.ZodOptional<z.ZodNumber>;
1222
+ user_id: z.ZodOptional<z.ZodString>;
1220
1223
  }, "strip", z.ZodTypeAny, {
1221
1224
  title: string;
1222
1225
  design_request: {
@@ -1236,6 +1239,7 @@ declare const bookPropsSchema: z.ZodObject<{
1236
1239
  guid?: string | undefined;
1237
1240
  cancelled_at?: string | undefined;
1238
1241
  mb_client_timeout?: number | undefined;
1242
+ user_id?: string | undefined;
1239
1243
  }, {
1240
1244
  title: string;
1241
1245
  design_request: {
@@ -1255,6 +1259,7 @@ declare const bookPropsSchema: z.ZodObject<{
1255
1259
  guid?: string | undefined;
1256
1260
  cancelled_at?: string | undefined;
1257
1261
  mb_client_timeout?: number | undefined;
1262
+ user_id?: string | undefined;
1258
1263
  }>;
1259
1264
  type BookProps = z.infer<typeof bookPropsSchema>;
1260
1265
  declare class Book {
@@ -1266,8 +1271,9 @@ declare class Book {
1266
1271
  guid?: string;
1267
1272
  cancelled_at?: string;
1268
1273
  timeout?: number;
1274
+ user_id?: string;
1269
1275
  constructor(props: BookProps);
1270
- toDesignRequestProps(): Record<string, unknown>;
1276
+ toDesignRequestProps(): DesignRequestProps;
1271
1277
  toBookProps(): BookProps;
1272
1278
  }
1273
1279
 
package/index.d.ts CHANGED
@@ -6,7 +6,7 @@ type EventContext = z.infer<typeof eventContextSchema>;
6
6
  declare class BooksEndpoints {
7
7
  private readonly engineAPI;
8
8
  constructor(engineAPI: EngineAPI);
9
- create(): Promise<Book>;
9
+ create(book: Partial<Book>): Promise<Book>;
10
10
  retrieve(bookId: string): Promise<Book>;
11
11
  update(bookId: string, book: Partial<Book>): Promise<Book>;
12
12
  cancel(bookId: string): Promise<Book>;
@@ -371,7 +371,7 @@ declare class MagicBookClient {
371
371
  readonly webSocketHost: string;
372
372
  engineAPI: EngineAPI;
373
373
  constructor(apiKey: string, apiHost?: string, webSocketHost?: string);
374
- createDesignRequest(designRequestProps?: DesignRequestProps): Promise<DesignRequest>;
374
+ createDesignRequest(designRequestProps: DesignRequestProps): Promise<DesignRequest>;
375
375
  }
376
376
 
377
377
  type Image = {
@@ -985,6 +985,7 @@ type DesignRequestProps = {
985
985
  imageFilteringLevel?: ImageFilteringLevel;
986
986
  embellishmentLevel?: EmbellishmentLevel;
987
987
  textStickerLevel?: TextStickerLevel;
988
+ userId: string;
988
989
  };
989
990
  type State = typeof states[number];
990
991
  type DesignRequestEventDetail = {
@@ -1011,6 +1012,7 @@ declare class DesignRequest {
1011
1012
  embellishmentLevel: EmbellishmentLevel;
1012
1013
  textStickerLevel: TextStickerLevel;
1013
1014
  images: Images;
1015
+ userId?: string;
1014
1016
  guid?: string;
1015
1017
  timeout?: number;
1016
1018
  constructor(parentId: string, client: MagicBookClient, designRequestProps?: DesignRequestProps);
@@ -1040,7 +1042,7 @@ declare class DesignRequest {
1040
1042
  };
1041
1043
  };
1042
1044
  }>;
1043
- submit(submitDesignRequestProps?: DesignRequestProps): Promise<this>;
1045
+ submit(submitDesignRequestProps?: Partial<DesignRequestProps>): Promise<this>;
1044
1046
  setGuid(guid: string): Promise<string>;
1045
1047
  cancel(): Promise<this>;
1046
1048
  getJSON(): Promise<{
@@ -1217,6 +1219,7 @@ declare const bookPropsSchema: z.ZodObject<{
1217
1219
  guid: z.ZodOptional<z.ZodString>;
1218
1220
  cancelled_at: z.ZodOptional<z.ZodString>;
1219
1221
  mb_client_timeout: z.ZodOptional<z.ZodNumber>;
1222
+ user_id: z.ZodOptional<z.ZodString>;
1220
1223
  }, "strip", z.ZodTypeAny, {
1221
1224
  title: string;
1222
1225
  design_request: {
@@ -1236,6 +1239,7 @@ declare const bookPropsSchema: z.ZodObject<{
1236
1239
  guid?: string | undefined;
1237
1240
  cancelled_at?: string | undefined;
1238
1241
  mb_client_timeout?: number | undefined;
1242
+ user_id?: string | undefined;
1239
1243
  }, {
1240
1244
  title: string;
1241
1245
  design_request: {
@@ -1255,6 +1259,7 @@ declare const bookPropsSchema: z.ZodObject<{
1255
1259
  guid?: string | undefined;
1256
1260
  cancelled_at?: string | undefined;
1257
1261
  mb_client_timeout?: number | undefined;
1262
+ user_id?: string | undefined;
1258
1263
  }>;
1259
1264
  type BookProps = z.infer<typeof bookPropsSchema>;
1260
1265
  declare class Book {
@@ -1266,8 +1271,9 @@ declare class Book {
1266
1271
  guid?: string;
1267
1272
  cancelled_at?: string;
1268
1273
  timeout?: number;
1274
+ user_id?: string;
1269
1275
  constructor(props: BookProps);
1270
- toDesignRequestProps(): Record<string, unknown>;
1276
+ toDesignRequestProps(): DesignRequestProps;
1271
1277
  toBookProps(): BookProps;
1272
1278
  }
1273
1279
 
package/index.js CHANGED
@@ -4018,7 +4018,8 @@ var bookPropsSchema = z.object({
4018
4018
  state: z.enum(states).optional(),
4019
4019
  guid: z.string().optional(),
4020
4020
  cancelled_at: z.string().optional(),
4021
- mb_client_timeout: z.number().optional()
4021
+ mb_client_timeout: z.number().optional(),
4022
+ user_id: z.string().optional()
4022
4023
  });
4023
4024
  var Book = class {
4024
4025
  id;
@@ -4029,6 +4030,7 @@ var Book = class {
4029
4030
  guid;
4030
4031
  cancelled_at;
4031
4032
  timeout;
4033
+ user_id;
4032
4034
  constructor(props) {
4033
4035
  this.id = props.id || "";
4034
4036
  this.title = props.title;
@@ -4038,6 +4040,7 @@ var Book = class {
4038
4040
  this.guid = props.guid;
4039
4041
  this.cancelled_at = props.cancelled_at;
4040
4042
  this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
4043
+ this.user_id = props.user_id;
4041
4044
  }
4042
4045
  toDesignRequestProps() {
4043
4046
  const props = { ...this, ...this.design_request };
@@ -4172,6 +4175,7 @@ var DesignRequest = class {
4172
4175
  this.embellishmentLevel = designRequestProps?.embellishmentLevel || embellishmentLevels[0];
4173
4176
  this.textStickerLevel = designRequestProps?.textStickerLevel || textStickerLevels[0];
4174
4177
  this.images = new Images(this.client, this.parentId);
4178
+ this.userId = designRequestProps?.userId;
4175
4179
  }
4176
4180
  webSocket;
4177
4181
  state;
@@ -4188,6 +4192,7 @@ var DesignRequest = class {
4188
4192
  embellishmentLevel;
4189
4193
  textStickerLevel;
4190
4194
  images;
4195
+ userId;
4191
4196
  guid;
4192
4197
  timeout;
4193
4198
  updateDesignRequest(designRequestProps) {
@@ -4302,7 +4307,8 @@ var DesignRequest = class {
4302
4307
  title: designRequest.title,
4303
4308
  subtitle: designRequest.subtitle,
4304
4309
  design_request: bookDesignRequest,
4305
- state: designRequest.state
4310
+ state: designRequest.state,
4311
+ user_id: designRequest.userId
4306
4312
  });
4307
4313
  }
4308
4314
  };
@@ -4393,12 +4399,13 @@ var BooksEndpoints = class {
4393
4399
  this.engineAPI = engineAPI;
4394
4400
  bindThisToFunctions(this);
4395
4401
  }
4396
- create() {
4402
+ create(book) {
4397
4403
  return handleAsyncFunction(async () => {
4398
4404
  const res = await this.engineAPI.fetcher.call({
4399
4405
  path: "/v1/books",
4400
4406
  options: {
4401
- method: "POST"
4407
+ method: "POST",
4408
+ body: cleanJSON(book)
4402
4409
  }
4403
4410
  });
4404
4411
  bookPropsSchema.safeParse(res);
@@ -4842,8 +4849,8 @@ var EngineAPI = class {
4842
4849
  };
4843
4850
 
4844
4851
  // ../../core/config.ts
4845
- var defaultApiHost = "https://api.sfly-sls.magicbook.io";
4846
- var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
4852
+ var defaultApiHost = "https://api.dev-sls.magicbook.io";
4853
+ var defaultWebSocketHost = "wss://socket.dev-sls.magicbook.io";
4847
4854
 
4848
4855
  // ../../core/models/client.ts
4849
4856
  var MagicBookClient = class {
@@ -4855,8 +4862,12 @@ var MagicBookClient = class {
4855
4862
  }
4856
4863
  engineAPI;
4857
4864
  async createDesignRequest(designRequestProps) {
4858
- const book = await this.engineAPI.books.create();
4859
- return new DesignRequest(book.id, this, designRequestProps);
4865
+ if (designRequestProps.userId) {
4866
+ const book = await this.engineAPI.books.create(camelCaseObjectKeysToSnakeCase({ ...designRequestProps }));
4867
+ return new DesignRequest(book.id, this, designRequestProps);
4868
+ } else {
4869
+ throw new Error("userId is required");
4870
+ }
4860
4871
  }
4861
4872
  };
4862
4873
  export {