@medusajs/js-sdk 2.0.5-preview-20241119150151 → 2.0.5-preview-20241119180151

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/dist/admin/product-tag.d.ts +130 -0
  2. package/dist/admin/product-tag.d.ts.map +1 -1
  3. package/dist/admin/product-tag.js +130 -0
  4. package/dist/admin/product-tag.js.map +1 -1
  5. package/dist/admin/product-type.d.ts +131 -0
  6. package/dist/admin/product-type.d.ts.map +1 -1
  7. package/dist/admin/product-type.js +131 -0
  8. package/dist/admin/product-type.js.map +1 -1
  9. package/dist/admin/product-variant.d.ts +48 -1
  10. package/dist/admin/product-variant.d.ts.map +1 -1
  11. package/dist/admin/product-variant.js +49 -2
  12. package/dist/admin/product-variant.js.map +1 -1
  13. package/dist/admin/product.d.ts +634 -2
  14. package/dist/admin/product.d.ts.map +1 -1
  15. package/dist/admin/product.js +636 -4
  16. package/dist/admin/product.js.map +1 -1
  17. package/dist/esm/admin/product-tag.d.ts +130 -0
  18. package/dist/esm/admin/product-tag.d.ts.map +1 -1
  19. package/dist/esm/admin/product-tag.js +130 -0
  20. package/dist/esm/admin/product-tag.js.map +1 -1
  21. package/dist/esm/admin/product-type.d.ts +131 -0
  22. package/dist/esm/admin/product-type.d.ts.map +1 -1
  23. package/dist/esm/admin/product-type.js +131 -0
  24. package/dist/esm/admin/product-type.js.map +1 -1
  25. package/dist/esm/admin/product-variant.d.ts +48 -1
  26. package/dist/esm/admin/product-variant.d.ts.map +1 -1
  27. package/dist/esm/admin/product-variant.js +49 -2
  28. package/dist/esm/admin/product-variant.js.map +1 -1
  29. package/dist/esm/admin/product.d.ts +634 -2
  30. package/dist/esm/admin/product.d.ts.map +1 -1
  31. package/dist/esm/admin/product.js +636 -4
  32. package/dist/esm/admin/product.js.map +1 -1
  33. package/package.json +2 -2
@@ -8,6 +8,27 @@ class Product {
8
8
  constructor(client) {
9
9
  this.client = client;
10
10
  }
11
+ /**
12
+ * This method creates a product import. The products are only imported after
13
+ * the import is confirmed using the {@link confirmImport} method.
14
+ *
15
+ * This method sends a request to the
16
+ * [Create Product Import](https://docs.medusajs.com/api/admin#products_postproductsimport)
17
+ * API route.
18
+ *
19
+ * @param body - The import's details.
20
+ * @param query - Query parameters to pass to the request.
21
+ * @param headers - Headers to pass in the request.
22
+ * @returns The import's details.
23
+ *
24
+ * @example
25
+ * sdk.admin.product.import({
26
+ * file // uploaded File instance
27
+ * })
28
+ * .then(({ transaction_id }) => {
29
+ * console.log(transaction_id)
30
+ * })
31
+ */
11
32
  async import(body, query, headers) {
12
33
  const form = new FormData();
13
34
  form.append("file", body.file);
@@ -22,6 +43,23 @@ class Product {
22
43
  query,
23
44
  });
24
45
  }
46
+ /**
47
+ * This method confirms a product import created using the method {@link import}.
48
+ * It sends a request to the
49
+ * [Confirm Product Import](https://docs.medusajs.com/api/admin#products_postproductsimporttransaction_idconfirm)
50
+ * API route.
51
+ *
52
+ * @param transactionId - The ID of the transaction of the created product import. This is returned
53
+ * by the API route used to create the product import.
54
+ * @param query - Query parameters to pass in the request.
55
+ * @param headers - Headers to pass in the request.
56
+ *
57
+ * @example
58
+ * sdk.admin.product.confirmImport("transaction_123")
59
+ * .then(() => {
60
+ * console.log("Import confirmed")
61
+ * })
62
+ */
25
63
  async confirmImport(transactionId, query, headers) {
26
64
  return await this.client.fetch(`/admin/products/import/${transactionId}/confirm`, {
27
65
  method: "POST",
@@ -30,6 +68,31 @@ class Product {
30
68
  query,
31
69
  });
32
70
  }
71
+ /**
72
+ * This method starts a product export process to retrieve a CSV of exported products.
73
+ *
74
+ * You'll receive in the response the transaction ID of the workflow generating the CSV file.
75
+ * To check the status of the execution, send a `GET` request to
76
+ * `/admin/workflows-executions/export-products/:transaction-id`.
77
+ *
78
+ * Once the execution finishes successfully, a notification is created for the export.
79
+ * You can retrieve the notifications using the `/admin/notification` API route to
80
+ * retrieve the file's download URL.
81
+ *
82
+ * This method sends a request to the [Export Product](https://docs.medusajs.com/api/admin#products_postproductsexport)
83
+ * API route.
84
+ *
85
+ * @param body - The export's details.
86
+ * @param query - Filters to specify which products to export.
87
+ * @param headers - Headers to pass in the request.
88
+ * @returns The export's details.
89
+ *
90
+ * @example
91
+ * sdk.admin.product.export({})
92
+ * .then(({ transaction_id }) => {
93
+ * console.log(transaction_id)
94
+ * })
95
+ */
33
96
  async export(body, query, headers) {
34
97
  return await this.client.fetch(`/admin/products/export`, {
35
98
  method: "POST",
@@ -38,6 +101,46 @@ class Product {
38
101
  query,
39
102
  });
40
103
  }
104
+ /**
105
+ * This method manages products to create, update, or delete them. It sends a request to the
106
+ * [Manage Products](https://docs.medusajs.com/api/admin#products_postproductsbatch)
107
+ * API route.
108
+ *
109
+ * @param body - The products to create, update, or delete.
110
+ * @param query - Configure the fields to retrieve in the products.
111
+ * @param headers - Headers to pass in the request
112
+ * @returns The batch operations details.
113
+ *
114
+ * @example
115
+ * sdk.admin.product.batch({
116
+ * create: [
117
+ * {
118
+ * title: "Shirt",
119
+ * options: [{
120
+ * title: "Default",
121
+ * values: ["Default Option"]
122
+ * }],
123
+ * variants: [
124
+ * {
125
+ * title: "Default",
126
+ * options: {
127
+ * Default: "Default Option"
128
+ * },
129
+ * prices: []
130
+ * }
131
+ * ]
132
+ * }
133
+ * ],
134
+ * update: [{
135
+ * id: "prod_123",
136
+ * title: "Pants"
137
+ * }],
138
+ * delete: ["prod_321"]
139
+ * })
140
+ * .then(({ created, updated, deleted }) => {
141
+ * console.log(created, updated, deleted)
142
+ * })
143
+ */
41
144
  async batch(body, query, headers) {
42
145
  return await this.client.fetch(`/admin/products/batch`, {
43
146
  method: "POST",
@@ -46,6 +149,37 @@ class Product {
46
149
  query,
47
150
  });
48
151
  }
152
+ /**
153
+ * This method creates a product. It sends a request to the
154
+ * [Create Product](https://docs.medusajs.com/api/admin#products_postproducts)
155
+ * API route.
156
+ *
157
+ * @param body - The product's details.
158
+ * @param query - Configure the fields to retrieve in the product.
159
+ * @param headers - Headers to pass in the request
160
+ * @returns The product's details.
161
+ *
162
+ * @example
163
+ * sdk.admin.product.create({
164
+ * title: "Shirt",
165
+ * options: [{
166
+ * title: "Default",
167
+ * values: ["Default Option"]
168
+ * }],
169
+ * variants: [
170
+ * {
171
+ * title: "Default",
172
+ * options: {
173
+ * Default: "Default Option"
174
+ * },
175
+ * prices: []
176
+ * }
177
+ * ]
178
+ * })
179
+ * .then(({ product }) => {
180
+ * console.log(product)
181
+ * })
182
+ */
49
183
  async create(body, query, headers) {
50
184
  return await this.client.fetch(`/admin/products`, {
51
185
  method: "POST",
@@ -54,6 +188,25 @@ class Product {
54
188
  query,
55
189
  });
56
190
  }
191
+ /**
192
+ * This method updates a product. It sends a request to the
193
+ * [Update Product](https://docs.medusajs.com/api/admin#products_postproductsid)
194
+ * API route.
195
+ *
196
+ * @param id - The product's ID.
197
+ * @param body - The data to update in the product.
198
+ * @param query - Configure the fields to retrieve in the product.
199
+ * @param headers - Headers to pass in the request
200
+ * @returns The product's details.
201
+ *
202
+ * @example
203
+ * sdk.admin.product.update("prod_123", {
204
+ * title: "Shirt",
205
+ * })
206
+ * .then(({ product }) => {
207
+ * console.log(product)
208
+ * })
209
+ */
57
210
  async update(id, body, query, headers) {
58
211
  return await this.client.fetch(`/admin/products/${id}`, {
59
212
  method: "POST",
@@ -62,24 +215,152 @@ class Product {
62
215
  query,
63
216
  });
64
217
  }
218
+ /**
219
+ * This method retrieves a paginated list of products. It sends a request to the
220
+ * [List Products](https://docs.medusajs.com/api/admin#products_getproducts) API route.
221
+ *
222
+ * @param query - Filters and pagination configurations.
223
+ * @param headers - Headers to pass in the request.
224
+ * @returns The paginated list of products.
225
+ *
226
+ * @example
227
+ * To retrieve the list of products:
228
+ *
229
+ * ```ts
230
+ * sdk.admin.product.list()
231
+ * .then(({ products, count, limit, offset }) => {
232
+ * console.log(products)
233
+ * })
234
+ * ```
235
+ *
236
+ * To configure the pagination, pass the `limit` and `offset` query parameters.
237
+ *
238
+ * For example, to retrieve only 10 items and skip 10 items:
239
+ *
240
+ * ```ts
241
+ * sdk.admin.product.list({
242
+ * limit: 10,
243
+ * offset: 10
244
+ * })
245
+ * .then(({ products, count, limit, offset }) => {
246
+ * console.log(products)
247
+ * })
248
+ * ```
249
+ *
250
+ * Using the `fields` query parameter, you can specify the fields and relations to retrieve
251
+ * in each products:
252
+ *
253
+ * ```ts
254
+ * sdk.admin.product.list({
255
+ * fields: "id,*variants"
256
+ * })
257
+ * .then(({ products, count, limit, offset }) => {
258
+ * console.log(products)
259
+ * })
260
+ * ```
261
+ *
262
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
263
+ */
65
264
  async list(queryParams, headers) {
66
265
  return await this.client.fetch(`/admin/products`, {
67
266
  headers,
68
267
  query: queryParams,
69
268
  });
70
269
  }
270
+ /**
271
+ * This method retrieves a product by its ID. It sends a request to the
272
+ * [Get Product](https://docs.medusajs.com/api/admin#products_getproductsid)
273
+ * API route.
274
+ *
275
+ * @param id - The product's ID.
276
+ * @param query - Configure the fields to retrieve in the product.
277
+ * @param headers - Headers to pass in the request
278
+ * @returns The product's details.
279
+ *
280
+ * @example
281
+ * To retrieve a product by its ID:
282
+ *
283
+ * ```ts
284
+ * sdk.admin.product.retrieve("prod_123")
285
+ * .then(({ product }) => {
286
+ * console.log(product)
287
+ * })
288
+ * ```
289
+ *
290
+ * To specify the fields and relations to retrieve:
291
+ *
292
+ * ```ts
293
+ * sdk.admin.product.retrieve("prod_123", {
294
+ * fields: "id,*variants"
295
+ * })
296
+ * .then(({ product }) => {
297
+ * console.log(product)
298
+ * })
299
+ * ```
300
+ *
301
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
302
+ */
71
303
  async retrieve(id, query, headers) {
72
304
  return await this.client.fetch(`/admin/products/${id}`, {
73
305
  query,
74
306
  headers,
75
307
  });
76
308
  }
309
+ /**
310
+ * This method deletes a product. It sends a request to the
311
+ * [Delete Product](https://docs.medusajs.com/api/admin#products_deleteproductsid)
312
+ * API route.
313
+ *
314
+ * @param id - The product's ID.
315
+ * @param headers - Headers to pass in the request
316
+ * @returns The deletion's details.
317
+ *
318
+ * @example
319
+ * sdk.admin.product.delete("prod_123")
320
+ * .then(({ deleted }) => {
321
+ * console.log(deleted)
322
+ * })
323
+ */
77
324
  async delete(id, headers) {
78
325
  return await this.client.fetch(`/admin/products/${id}`, {
79
326
  method: "DELETE",
80
327
  headers,
81
328
  });
82
329
  }
330
+ /**
331
+ * This method manages the variants of a product. It sends a request to the
332
+ * [Manage Variants](https://docs.medusajs.com/api/admin#products_postproductsidvariantsbatch)
333
+ * API route.
334
+ *
335
+ * @param productId - The product's ID.
336
+ * @param body - The variants to create, update, or delete.
337
+ * @param query - Configure the fields to retrieve in the product variants.
338
+ * @param headers - Headers to pass in the request
339
+ * @returns The product variants' details.
340
+ *
341
+ * @example
342
+ * sdk.admin.product.batchVariants("prod_123", {
343
+ * create: [
344
+ * {
345
+ * title: "Blue Shirt",
346
+ * options: {
347
+ * Color: "Blue"
348
+ * },
349
+ * prices: []
350
+ * }
351
+ * ],
352
+ * update: [
353
+ * {
354
+ * id: "variant_123",
355
+ * title: "Pants"
356
+ * }
357
+ * ],
358
+ * delete: ["variant_123"]
359
+ * })
360
+ * .then(({ created, updated, deleted }) => {
361
+ * console.log(created, updated, deleted)
362
+ * })
363
+ */
83
364
  async batchVariants(productId, body, query, headers) {
84
365
  return await this.client.fetch(`/admin/products/${productId}/variants/batch`, {
85
366
  method: "POST",
@@ -88,6 +369,34 @@ class Product {
88
369
  query,
89
370
  });
90
371
  }
372
+ /**
373
+ * This method creates a variant for a product. It sends a request to the
374
+ * [Create Variant](https://docs.medusajs.com/api/admin#products_postproductsidvariants)
375
+ * API route.
376
+ *
377
+ * @param productId - The product's ID.
378
+ * @param body - The variant's details.
379
+ * @param query - Configure the fields to retrieve in the product.
380
+ * @param headers - Headers to pass in the request
381
+ * @returns The product's details.
382
+ *
383
+ * @example
384
+ * sdk.admin.product.createVariant("prod_123", {
385
+ * title: "Blue Shirt",
386
+ * options: {
387
+ * Color: "Blue"
388
+ * },
389
+ * prices: [
390
+ * {
391
+ * amount: 10,
392
+ * currency_code: "usd"
393
+ * }
394
+ * ]
395
+ * })
396
+ * .then(({ product }) => {
397
+ * console.log(product)
398
+ * })
399
+ */
91
400
  async createVariant(productId, body, query, headers) {
92
401
  return await this.client.fetch(`/admin/products/${productId}/variants`, {
93
402
  method: "POST",
@@ -96,6 +405,30 @@ class Product {
96
405
  query,
97
406
  });
98
407
  }
408
+ /**
409
+ * This method updates a variant of a product. It sends a request to the
410
+ * [Update Variant](https://docs.medusajs.com/api/admin#products_postproductsidvariantsvariant_id)
411
+ * API route.
412
+ *
413
+ * @param productId - The product's ID.
414
+ * @param id - The variant's ID.
415
+ * @param body - The data to update in the variant.
416
+ * @param query - Configure the fields to retrieve in the product.
417
+ * @param headers - Headers to pass in the request
418
+ * @returns The product's details.
419
+ *
420
+ * @example
421
+ * sdk.admin.product.updateVariant(
422
+ * "prod_123",
423
+ * "variant_123",
424
+ * {
425
+ * title: "Blue Shirt",
426
+ * }
427
+ * )
428
+ * .then(({ product }) => {
429
+ * console.log(product)
430
+ * })
431
+ */
99
432
  async updateVariant(productId, id, body, query, headers) {
100
433
  return await this.client.fetch(`/admin/products/${productId}/variants/${id}`, {
101
434
  method: "POST",
@@ -104,24 +437,172 @@ class Product {
104
437
  query,
105
438
  });
106
439
  }
107
- async listVariants(productId, queryParams, headers) {
440
+ /**
441
+ * This method retrieves a paginated list of products. It sends a request to the
442
+ * [List Products](https://docs.medusajs.com/api/admin#products_getproductsidvariants) API route.
443
+ *
444
+ * @param productId - The ID of the product to retrieve its variants.
445
+ * @param query - Filters and pagination configurations.
446
+ * @param headers - Headers to pass in the request.
447
+ * @returns The paginated list of product variants.
448
+ *
449
+ * @example
450
+ * To retrieve the list of product variants:
451
+ *
452
+ * ```ts
453
+ * sdk.admin.product.listVariants("prod_123")
454
+ * .then(({ variants, count, limit, offset }) => {
455
+ * console.log(variants)
456
+ * })
457
+ * ```
458
+ *
459
+ * To configure the pagination, pass the `limit` and `offset` query parameters.
460
+ *
461
+ * For example, to retrieve only 10 items and skip 10 items:
462
+ *
463
+ * ```ts
464
+ * sdk.admin.product.listVariants("prod_123", {
465
+ * limit: 10,
466
+ * offset: 10
467
+ * })
468
+ * .then(({ variants, count, limit, offset }) => {
469
+ * console.log(variants)
470
+ * })
471
+ * ```
472
+ *
473
+ * Using the `fields` query parameter, you can specify the fields and relations to retrieve
474
+ * in each product variant:
475
+ *
476
+ * ```ts
477
+ * sdk.admin.product.listVariants("prod_123", {
478
+ * fields: "id,*product"
479
+ * })
480
+ * .then(({ variants, count, limit, offset }) => {
481
+ * console.log(variants)
482
+ * })
483
+ * ```
484
+ *
485
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
486
+ */
487
+ async listVariants(productId, query, headers) {
108
488
  return await this.client.fetch(`/admin/products/${productId}/variants`, {
109
489
  headers,
110
- query: queryParams,
490
+ query,
111
491
  });
112
492
  }
493
+ /**
494
+ * This method retrieves a product's variant. It sends a request to the
495
+ * [Retrieve Variant](https://docs.medusajs.com/api/admin#products_getproductsidvariantsvariant_id)
496
+ * API route.
497
+ *
498
+ * @param productId - The product's ID.
499
+ * @param id - The variant's ID.
500
+ * @param query - Configure the fields to retrieve in the product variant.
501
+ * @param headers - Headers to pass in the request
502
+ * @returns The product variant's details.
503
+ *
504
+ * @example
505
+ * To retrieve a product variant by its ID:
506
+ *
507
+ * ```ts
508
+ * sdk.admin.product.retrieveVariant(
509
+ * "prod_123",
510
+ * "variant_123"
511
+ * )
512
+ * .then(({ variant }) => {
513
+ * console.log(variant)
514
+ * })
515
+ * ```
516
+ *
517
+ * To specify the fields and relations to retrieve:
518
+ *
519
+ * ```ts
520
+ * sdk.admin.product.retrieveVariant(
521
+ * "prod_123",
522
+ * "variant_123",
523
+ * {
524
+ * fields: "id, *product"
525
+ * }
526
+ * )
527
+ * .then(({ variant }) => {
528
+ * console.log(variant)
529
+ * })
530
+ * ```
531
+ *
532
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
533
+ */
113
534
  async retrieveVariant(productId, id, query, headers) {
114
535
  return await this.client.fetch(`/admin/products/${productId}/variants/${id}`, {
115
536
  query,
116
537
  headers,
117
538
  });
118
539
  }
540
+ /**
541
+ * This method deletes a product's variant. It sends a request to the
542
+ * [Delete Variant](https://docs.medusajs.com/api/admin#products_deleteproductsidvariantsvariant_id)
543
+ * API route.
544
+ *
545
+ * @param productId - The product's ID.
546
+ * @param id - The ID of the variant.
547
+ * @param headers - Headers to pass in the request
548
+ * @returns The deletion's details.
549
+ *
550
+ * @example
551
+ * sdk.admin.product.deleteVariant("prod_123", "variant_123")
552
+ * .then(({ deleted }) => {
553
+ * console.log(deleted)
554
+ * })
555
+ */
119
556
  async deleteVariant(productId, id, headers) {
120
557
  return await this.client.fetch(`/admin/products/${productId}/variants/${id}`, {
121
558
  method: "DELETE",
122
559
  headers,
123
560
  });
124
561
  }
562
+ /**
563
+ * This method manages a product's variant's inventories to associate them with inventory items,
564
+ * update their inventory items, or delete their association with inventory items.
565
+ *
566
+ * It sends a request to the
567
+ * [Manage Variant Inventory](https://docs.medusajs.com/api/admin#products_postproductsidvariantsinventoryitemsbatch)
568
+ * API route.
569
+ *
570
+ * @param productId - The ID of the product that the variant belongs to.
571
+ * @param body - The inventory items to create, update, or delete.
572
+ * @param query - Pass query parameters in the request.
573
+ * @param headers - Headers to pass in the request
574
+ * @returns The details of the created, updated, or deleted inventory items.
575
+ *
576
+ * @example
577
+ * sdk.admin.product.batchVariantInventoryItems(
578
+ * "prod_123",
579
+ * {
580
+ * create: [
581
+ * {
582
+ * inventory_item_id: "iitem_123",
583
+ * variant_id: "variant_123",
584
+ * required_quantity: 10
585
+ * }
586
+ * ],
587
+ * update: [
588
+ * {
589
+ * inventory_item_id: "iitem_1234",
590
+ * variant_id: "variant_1234",
591
+ * required_quantity: 20
592
+ * }
593
+ * ],
594
+ * delete: [
595
+ * {
596
+ * inventory_item_id: "iitem_321",
597
+ * variant_id: "variant_321"
598
+ * }
599
+ * ]
600
+ * }
601
+ * )
602
+ * .then(({ created, updated, deleted }) => {
603
+ * console.log(created, updated, deleted)
604
+ * })
605
+ */
125
606
  async batchVariantInventoryItems(productId, body, query, headers) {
126
607
  return await this.client.fetch(`/admin/products/${productId}/variants/inventory-items/batch`, {
127
608
  method: "POST",
@@ -130,6 +611,29 @@ class Product {
130
611
  query,
131
612
  });
132
613
  }
614
+ /**
615
+ * This method creates an option in a product. It sends a request to the
616
+ * [Create Option](https://docs.medusajs.com/api/admin#products_postproductsidoptions)
617
+ * API route.
618
+ *
619
+ * @param productId - The product's ID.
620
+ * @param body - The option's details.
621
+ * @param query - Configure the fields to retrieve in the product.
622
+ * @param headers - Headers to pass in the request
623
+ * @returns The product's details.
624
+ *
625
+ * @example
626
+ * sdk.admin.product.createOption(
627
+ * "prod_123",
628
+ * {
629
+ * title: "Color",
630
+ * values: ["Green", "Blue"]
631
+ * }
632
+ * )
633
+ * .then(({ product }) => {
634
+ * console.log(product)
635
+ * })
636
+ */
133
637
  async createOption(productId, body, query, headers) {
134
638
  return await this.client.fetch(`/admin/products/${productId}/options`, {
135
639
  method: "POST",
@@ -138,6 +642,30 @@ class Product {
138
642
  query,
139
643
  });
140
644
  }
645
+ /**
646
+ * This method updates a product's option. It sends a request to the
647
+ * [Update Option](https://docs.medusajs.com/api/admin#products_postproductsidoptionsoption_id)
648
+ * API route.
649
+ *
650
+ * @param productId - The product's ID.
651
+ * @param id - The ID of the option to update.
652
+ * @param body - The data to update in the option.
653
+ * @param query - Configure the fields to retrieve in the product.
654
+ * @param headers - Headers to pass in the request
655
+ * @returns The product's details.
656
+ *
657
+ * @example
658
+ * sdk.admin.product.updateOption(
659
+ * "prod_123",
660
+ * "prodopt_123",
661
+ * {
662
+ * title: "Color"
663
+ * }
664
+ * )
665
+ * .then(({ product }) => {
666
+ * console.log(product)
667
+ * })
668
+ */
141
669
  async updateOption(productId, id, body, query, headers) {
142
670
  return await this.client.fetch(`/admin/products/${productId}/options/${id}`, {
143
671
  method: "POST",
@@ -146,18 +674,122 @@ class Product {
146
674
  query,
147
675
  });
148
676
  }
149
- async listOptions(productId, queryParams, headers) {
677
+ /**
678
+ * This method retrieves a paginated list of product options. It sends a request to the
679
+ * [List Options](https://docs.medusajs.com/api/admin#products_getproductsidoptions) API route.
680
+ *
681
+ * @param productId - The ID of the product to retrieve its options
682
+ * @param query - Filters and pagination configurations.
683
+ * @param headers - Headers to pass in the request.
684
+ * @returns The paginated list of product options.
685
+ *
686
+ * @example
687
+ * To retrieve the list of product options:
688
+ *
689
+ * ```ts
690
+ * sdk.admin.product.listOptions("prod_123")
691
+ * .then(({ product_options, count, limit, offset }) => {
692
+ * console.log(product_options)
693
+ * })
694
+ * ```
695
+ *
696
+ * To configure the pagination, pass the `limit` and `offset` query parameters.
697
+ *
698
+ * For example, to retrieve only 10 items and skip 10 items:
699
+ *
700
+ * ```ts
701
+ * sdk.admin.product.listOptions("prod_123", {
702
+ * limit: 10,
703
+ * offset: 10
704
+ * })
705
+ * .then(({ product_options, count, limit, offset }) => {
706
+ * console.log(product_options)
707
+ * })
708
+ * ```
709
+ *
710
+ * Using the `fields` query parameter, you can specify the fields and relations to retrieve
711
+ * in each product options:
712
+ *
713
+ * ```ts
714
+ * sdk.admin.product.listOptions("prod_123", {
715
+ * fields: "id,title"
716
+ * })
717
+ * .then(({ product_options, count, limit, offset }) => {
718
+ * console.log(product_options)
719
+ * })
720
+ * ```
721
+ *
722
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
723
+ */
724
+ async listOptions(productId, query, headers) {
150
725
  return await this.client.fetch(`/admin/products/${productId}/options`, {
151
726
  headers,
152
- query: queryParams,
727
+ query,
153
728
  });
154
729
  }
730
+ /**
731
+ * This method retrieves a product's option. It sends a request to the
732
+ * [Get Option](https://docs.medusajs.com/api/admin#products_getproductsidoptionsoption_id)
733
+ * API route.
734
+ *
735
+ * @param productId - The product's ID.
736
+ * @param id - The product option's ID.
737
+ * @param query - Configure the fields to retrieve in the product option.
738
+ * @param headers - Headers to pass in the request
739
+ * @returns The product option's details.
740
+ *
741
+ * @example
742
+ * To retrieve a product option by its ID:
743
+ *
744
+ * ```ts
745
+ * sdk.admin.product.retrieveOption(
746
+ * "prod_123",
747
+ * "prodopt_123"
748
+ * )
749
+ * .then(({ product_option }) => {
750
+ * console.log(product_option)
751
+ * })
752
+ * ```
753
+ *
754
+ * To specify the fields and relations to retrieve:
755
+ *
756
+ * ```ts
757
+ * sdk.admin.product.retrieveOption(
758
+ * "prod_123",
759
+ * "prodopt_123",
760
+ * {
761
+ * fields: "id,title"
762
+ * }
763
+ * )
764
+ * .then(({ product_option }) => {
765
+ * console.log(product_option)
766
+ * })
767
+ * ```
768
+ *
769
+ * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
770
+ */
155
771
  async retrieveOption(productId, id, query, headers) {
156
772
  return await this.client.fetch(`/admin/products/${productId}/options/${id}`, {
157
773
  query,
158
774
  headers,
159
775
  });
160
776
  }
777
+ /**
778
+ * This method deletes a product's option. It sends a request to the
779
+ * [Delete Option](https://docs.medusajs.com/api/admin#products_deleteproductsidoptionsoption_id)
780
+ * API route.
781
+ *
782
+ * @param productId - The product's ID.
783
+ * @param id - The option's ID.
784
+ * @param headers - Headers to pass in the request
785
+ * @returns The deletion's details.
786
+ *
787
+ * @example
788
+ * sdk.admin.product.deleteOption("prod_123", "prodopt_123")
789
+ * .then(({ deleted }) => {
790
+ * console.log(deleted)
791
+ * })
792
+ */
161
793
  async deleteOption(productId, id, headers) {
162
794
  return await this.client.fetch(`/admin/products/${productId}/options/${id}`, {
163
795
  method: "DELETE",