@medusajs/js-sdk 2.0.5-snapshot-20241113173305 → 2.0.5-snapshot-20241120130614

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