@medusajs/types 1.12.0-snapshot-20240328221015 → 1.12.0-snapshot-20240329154849

Sign up to get free protection for your applications and to get access to all the features.
@@ -255,6 +255,233 @@ export interface IProductModuleService extends IModuleService {
255
255
  * ```
256
256
  */
257
257
  listAndCount(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<[ProductDTO[], number]>;
258
+ /**
259
+ * This method is used to create a list of products.
260
+ *
261
+ * @param {CreateProductDTO[]} data - The products to be created.
262
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
263
+ * @returns {Promise<ProductDTO[]>} The list of created products.
264
+ *
265
+ * @example
266
+ * import {
267
+ * initialize as initializeProductModule,
268
+ * } from "@medusajs/product"
269
+ *
270
+ * async function createProduct (title: string) {
271
+ * const productModule = await initializeProductModule()
272
+ *
273
+ * const products = await productModule.create([
274
+ * {
275
+ * title
276
+ * }
277
+ * ])
278
+ *
279
+ * // do something with the products or return them
280
+ * }
281
+ */
282
+ create(data: CreateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
283
+ /**
284
+ * This method is used to create a product.
285
+ *
286
+ * @param {CreateProductDTO} data - The product to be created.
287
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
288
+ * @returns {Promise<ProductDTO>} The created product.
289
+ *
290
+ * @example
291
+ * import {
292
+ * initialize as initializeProductModule,
293
+ * } from "@medusajs/product"
294
+ *
295
+ * async function createProduct (title: string) {
296
+ * const productModule = await initializeProductModule()
297
+ *
298
+ * const product = await productModule.create(
299
+ * {
300
+ * title
301
+ * }
302
+ * )
303
+ *
304
+ * // do something with the product or return it
305
+ * }
306
+ */
307
+ create(data: CreateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
308
+ /**
309
+ * This method updates existing products, or creates new ones if they don't exist.
310
+ *
311
+ * @param {CreateProductDTO[]} data - The attributes to update or create for each product.
312
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
313
+ * @returns {Promise<ProductDTO[]>} The updated and created products.
314
+ *
315
+ * @example
316
+ * import {
317
+ * initialize as initializeProductModule,
318
+ * } from "@medusajs/product"
319
+ *
320
+ * async function upserProduct (title: string) {
321
+ * const productModule = await initializeProductModule()
322
+ *
323
+ * const createdProducts = await productModule.upsert([
324
+ * {
325
+ * title
326
+ * }
327
+ * ])
328
+ *
329
+ * // do something with the products or return them
330
+ * }
331
+ */
332
+ upsert(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
333
+ /**
334
+ * This method updates the product if it exists, or creates a new ones if it doesn't.
335
+ *
336
+ * @param {CreateProductDTO} data - The attributes to update or create for the new product.
337
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
338
+ * @returns {Promise<ProductDTO>} The updated or created product.
339
+ *
340
+ * @example
341
+ * import {
342
+ * initialize as initializeProductModule,
343
+ * } from "@medusajs/product"
344
+ *
345
+ * async function upserProduct (title: string) {
346
+ * const productModule = await initializeProductModule()
347
+ *
348
+ * const createdProduct = await productModule.upsert(
349
+ * {
350
+ * title
351
+ * }
352
+ * )
353
+ *
354
+ * // do something with the product or return it
355
+ * }
356
+ */
357
+ upsert(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
358
+ /**
359
+ * This method is used to update a product.
360
+ *
361
+ * @param {string} id - The ID of the product to be updated.
362
+ * @param {UpdateProductDTO} data - The attributes of the product to be updated
363
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
364
+ * @returns {Promise<ProductDTO>} The updated product.
365
+ *
366
+ * @example
367
+ * import {
368
+ * initialize as initializeProductModule,
369
+ * } from "@medusajs/product"
370
+ *
371
+ * async function updateProduct (id: string, title: string) {
372
+ * const productModule = await initializeProductModule()
373
+ *
374
+ * const product = await productModule.update(id, {
375
+ * title
376
+ * }
377
+ * )
378
+ *
379
+ * // do something with the product or return it
380
+ * }
381
+ */
382
+ update(id: string, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
383
+ /**
384
+ * This method is used to update a list of products determined by the selector filters.
385
+ *
386
+ * @param {FilterableProductProps} selector - The filters that will determine which products will be updated.
387
+ * @param {UpdateProductDTO} data - The attributes to be updated on the selected products
388
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
389
+ * @returns {Promise<ProductDTO[]>} The updated products.
390
+ *
391
+ * @example
392
+ * import {
393
+ * initialize as initializeProductModule,
394
+ * } from "@medusajs/product"
395
+ *
396
+ * async function updateProduct (id: string, title: string) {
397
+ * const productModule = await initializeProductModule()
398
+ *
399
+ * const products = await productModule.update({id}, {
400
+ * title
401
+ * }
402
+ * )
403
+ *
404
+ * // do something with the products or return them
405
+ * }
406
+ */
407
+ update(selector: FilterableProductProps, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO[]>;
408
+ /**
409
+ * This method is used to delete products. Unlike the {@link softDelete} method, this method will completely remove the products and they can no longer be accessed or retrieved.
410
+ *
411
+ * @param {string[]} productIds - The IDs of the products to be deleted.
412
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
413
+ * @returns {Promise<void>} Resolves when the products are successfully deleted.
414
+ *
415
+ * @example
416
+ * import {
417
+ * initialize as initializeProductModule,
418
+ * } from "@medusajs/product"
419
+ *
420
+ * async function deleteProducts (ids: string[]) {
421
+ * const productModule = await initializeProductModule()
422
+ *
423
+ * await productModule.delete(ids)
424
+ * }
425
+ */
426
+ delete(productIds: string[], sharedContext?: Context): Promise<void>;
427
+ /**
428
+ * This method is used to delete products. Unlike the {@link delete} method, this method won't completely remove the product. It can still be accessed or retrieved using methods like {@link retrieve} if you pass the `withDeleted` property to the `config` object parameter.
429
+ *
430
+ * The soft-deleted products can be restored using the {@link restore} method.
431
+ *
432
+ * @param {string[]} productIds - The IDs of the products to soft-delete.
433
+ * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
434
+ * Configurations determining which relations to soft delete along with the each of the products. You can pass to its `returnLinkableKeys`
435
+ * property any of the product's relation attribute names, such as `variant_id`.
436
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
437
+ * @returns {Promise<Record<string, string[]> | void>}
438
+ * An object that includes the IDs of related records that were also soft deleted, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of a record associated with the product through this relation, such as the IDs of associated product variants.
439
+ *
440
+ * If there are no related records, the promise resolved to `void`.
441
+ *
442
+ * @example
443
+ * import {
444
+ * initialize as initializeProductModule,
445
+ * } from "@medusajs/product"
446
+ *
447
+ * async function deleteProducts (ids: string[]) {
448
+ * const productModule = await initializeProductModule()
449
+ *
450
+ * const cascadedEntities = await productModule.softDelete(ids)
451
+ *
452
+ * // do something with the returned cascaded entity IDs or return them
453
+ * }
454
+ */
455
+ softDelete<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
456
+ /**
457
+ * This method is used to restore products which were deleted using the {@link softDelete} method.
458
+ *
459
+ * @param {string[]} productIds - The IDs of the products to restore.
460
+ * @param {RestoreReturn<TReturnableLinkableKeys>} config -
461
+ * Configurations determining which relations to restore along with each of the products. You can pass to its `returnLinkableKeys`
462
+ * property any of the product's relation attribute names, such as `variant_id`.
463
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
464
+ * @returns {Promise<Record<string, string[]> | void>}
465
+ * An object that includes the IDs of related records that were restored, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of the record associated with the product through this relation, such as the IDs of associated product variants.
466
+ *
467
+ * If there are no related records that were restored, the promise resolved to `void`.
468
+ *
469
+ * @example
470
+ * import {
471
+ * initialize as initializeProductModule,
472
+ * } from "@medusajs/product"
473
+ *
474
+ * async function restoreProducts (ids: string[]) {
475
+ * const productModule = await initializeProductModule()
476
+ *
477
+ * const cascadedEntities = await productModule.restore(ids, {
478
+ * returnLinkableKeys: ["variant_id"]
479
+ * })
480
+ *
481
+ * // do something with the returned cascaded entity IDs or return them
482
+ * }
483
+ */
484
+ restore<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
258
485
  /**
259
486
  * This method is used to retrieve a tag by its ID.
260
487
  *
@@ -1517,35 +1744,136 @@ export interface IProductModuleService extends IModuleService {
1517
1744
  */
1518
1745
  listVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<ProductVariantDTO[]>;
1519
1746
  /**
1520
- * This method is used to create product variants.
1747
+ * This method is used to retrieve a paginated list of product variants along with the total count of available product variants satisfying the provided filters.
1521
1748
  *
1522
- * @param {CreateProductVariantDTO[]} data - The product variants to be created.
1749
+ * @param {FilterableProductVariantProps} filters - The filters applied on the retrieved product variants.
1750
+ * @param {FindConfig<ProductVariantDTO>} config -
1751
+ * The configurations determining how the product variants are retrieved. Its properties, such as `select` or `relations`, accept the
1752
+ * attributes or relations associated with a product variant.
1523
1753
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1524
- * @returns {Promise<ProductVariantDTO[]>} The list of created product variants.
1754
+ * @returns {Promise<[ProductVariantDTO[], number]>} The list of product variants along with their total count.
1525
1755
  *
1526
1756
  * @example
1757
+ * To retrieve a list of product variants using their IDs:
1758
+ *
1759
+ * ```ts
1527
1760
  * import {
1528
1761
  * initialize as initializeProductModule,
1529
1762
  * } from "@medusajs/product"
1530
1763
  *
1531
- * async function createVariants (title: string) {
1764
+ * async function retrieveProductVariants (ids: string[]) {
1532
1765
  * const productModule = await initializeProductModule()
1533
1766
  *
1534
- * const variants = await productModule.createVariants([
1535
- * {
1536
- * title
1537
- * }
1538
- * ])
1767
+ * const [variants, count] = await productModule.listAndCountVariants({
1768
+ * id: ids
1769
+ * })
1539
1770
  *
1540
1771
  * // do something with the product variants or return them
1541
1772
  * }
1773
+ * ```
1542
1774
  *
1543
- */
1544
- createVariants(data: CreateProductVariantDTO[], sharedContext?: Context): Promise<ProductVariantDTO[]>;
1545
- /**
1546
- * This method is used to create a product variant.
1775
+ * To specify relations that should be retrieved within the product variants:
1547
1776
  *
1548
- * @param {CreateProductVariantDTO} data - The product variant to be created.
1777
+ * ```ts
1778
+ * import {
1779
+ * initialize as initializeProductModule,
1780
+ * } from "@medusajs/product"
1781
+ *
1782
+ * async function retrieveProductVariants (ids: string[]) {
1783
+ * const productModule = await initializeProductModule()
1784
+ *
1785
+ * const [variants, count] = await productModule.listAndCountVariants({
1786
+ * id: ids
1787
+ * }, {
1788
+ * relations: ["options"]
1789
+ * })
1790
+ *
1791
+ * // do something with the product variants or return them
1792
+ * }
1793
+ * ```
1794
+ *
1795
+ * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1796
+ *
1797
+ * ```ts
1798
+ * import {
1799
+ * initialize as initializeProductModule,
1800
+ * } from "@medusajs/product"
1801
+ *
1802
+ * async function retrieveProductVariants (ids: string[], skip: number, take: number) {
1803
+ * const productModule = await initializeProductModule()
1804
+ *
1805
+ * const [variants, count] = await productModule.listAndCountVariants({
1806
+ * id: ids
1807
+ * }, {
1808
+ * relations: ["options"],
1809
+ * skip,
1810
+ * take
1811
+ * })
1812
+ *
1813
+ * // do something with the product variants or return them
1814
+ * }
1815
+ * ```
1816
+ *
1817
+ * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1818
+ *
1819
+ * ```ts
1820
+ * import {
1821
+ * initialize as initializeProductModule,
1822
+ * } from "@medusajs/product"
1823
+ *
1824
+ * async function retrieveProductVariants (ids: string[], sku: string, skip: number, take: number) {
1825
+ * const productModule = await initializeProductModule()
1826
+ *
1827
+ * const [variants, count] = await productModule.listAndCountVariants({
1828
+ * $and: [
1829
+ * {
1830
+ * id: ids
1831
+ * },
1832
+ * {
1833
+ * sku
1834
+ * }
1835
+ * ]
1836
+ * }, {
1837
+ * relations: ["options"],
1838
+ * skip,
1839
+ * take
1840
+ * })
1841
+ *
1842
+ * // do something with the product variants or return them
1843
+ * }
1844
+ * ```
1845
+ */
1846
+ listAndCountVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<[ProductVariantDTO[], number]>;
1847
+ /**
1848
+ * This method is used to create product variants.
1849
+ *
1850
+ * @param {CreateProductVariantDTO[]} data - The product variants to be created.
1851
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1852
+ * @returns {Promise<ProductVariantDTO[]>} The list of created product variants.
1853
+ *
1854
+ * @example
1855
+ * import {
1856
+ * initialize as initializeProductModule,
1857
+ * } from "@medusajs/product"
1858
+ *
1859
+ * async function createVariants (title: string) {
1860
+ * const productModule = await initializeProductModule()
1861
+ *
1862
+ * const variants = await productModule.createVariants([
1863
+ * {
1864
+ * title
1865
+ * }
1866
+ * ])
1867
+ *
1868
+ * // do something with the product variants or return them
1869
+ * }
1870
+ *
1871
+ */
1872
+ createVariants(data: CreateProductVariantDTO[], sharedContext?: Context): Promise<ProductVariantDTO[]>;
1873
+ /**
1874
+ * This method is used to create a product variant.
1875
+ *
1876
+ * @param {CreateProductVariantDTO} data - The product variant to be created.
1549
1877
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1550
1878
  * @returns {Promise<ProductVariantDTO>} The created product variant.
1551
1879
  *
@@ -1687,107 +2015,6 @@ export interface IProductModuleService extends IModuleService {
1687
2015
  * }
1688
2016
  */
1689
2017
  deleteVariants(productVariantIds: string[], sharedContext?: Context): Promise<void>;
1690
- /**
1691
- * This method is used to retrieve a paginated list of product variants along with the total count of available product variants satisfying the provided filters.
1692
- *
1693
- * @param {FilterableProductVariantProps} filters - The filters applied on the retrieved product variants.
1694
- * @param {FindConfig<ProductVariantDTO>} config -
1695
- * The configurations determining how the product variants are retrieved. Its properties, such as `select` or `relations`, accept the
1696
- * attributes or relations associated with a product variant.
1697
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
1698
- * @returns {Promise<[ProductVariantDTO[], number]>} The list of product variants along with their total count.
1699
- *
1700
- * @example
1701
- * To retrieve a list of product variants using their IDs:
1702
- *
1703
- * ```ts
1704
- * import {
1705
- * initialize as initializeProductModule,
1706
- * } from "@medusajs/product"
1707
- *
1708
- * async function retrieveProductVariants (ids: string[]) {
1709
- * const productModule = await initializeProductModule()
1710
- *
1711
- * const [variants, count] = await productModule.listAndCountVariants({
1712
- * id: ids
1713
- * })
1714
- *
1715
- * // do something with the product variants or return them
1716
- * }
1717
- * ```
1718
- *
1719
- * To specify relations that should be retrieved within the product variants:
1720
- *
1721
- * ```ts
1722
- * import {
1723
- * initialize as initializeProductModule,
1724
- * } from "@medusajs/product"
1725
- *
1726
- * async function retrieveProductVariants (ids: string[]) {
1727
- * const productModule = await initializeProductModule()
1728
- *
1729
- * const [variants, count] = await productModule.listAndCountVariants({
1730
- * id: ids
1731
- * }, {
1732
- * relations: ["options"]
1733
- * })
1734
- *
1735
- * // do something with the product variants or return them
1736
- * }
1737
- * ```
1738
- *
1739
- * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
1740
- *
1741
- * ```ts
1742
- * import {
1743
- * initialize as initializeProductModule,
1744
- * } from "@medusajs/product"
1745
- *
1746
- * async function retrieveProductVariants (ids: string[], skip: number, take: number) {
1747
- * const productModule = await initializeProductModule()
1748
- *
1749
- * const [variants, count] = await productModule.listAndCountVariants({
1750
- * id: ids
1751
- * }, {
1752
- * relations: ["options"],
1753
- * skip,
1754
- * take
1755
- * })
1756
- *
1757
- * // do something with the product variants or return them
1758
- * }
1759
- * ```
1760
- *
1761
- * You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example:
1762
- *
1763
- * ```ts
1764
- * import {
1765
- * initialize as initializeProductModule,
1766
- * } from "@medusajs/product"
1767
- *
1768
- * async function retrieveProductVariants (ids: string[], sku: string, skip: number, take: number) {
1769
- * const productModule = await initializeProductModule()
1770
- *
1771
- * const [variants, count] = await productModule.listAndCountVariants({
1772
- * $and: [
1773
- * {
1774
- * id: ids
1775
- * },
1776
- * {
1777
- * sku
1778
- * }
1779
- * ]
1780
- * }, {
1781
- * relations: ["options"],
1782
- * skip,
1783
- * take
1784
- * })
1785
- *
1786
- * // do something with the product variants or return them
1787
- * }
1788
- * ```
1789
- */
1790
- listAndCountVariants(filters?: FilterableProductVariantProps, config?: FindConfig<ProductVariantDTO>, sharedContext?: Context): Promise<[ProductVariantDTO[], number]>;
1791
2018
  /**
1792
2019
  * This method is used to delete variants. Unlike the {@link delete} method, this method won't completely remove the variant. It can still be accessed or retrieved using methods like {@link retrieve} if you pass the `withDeleted` property to the `config` object parameter.
1793
2020
  *
@@ -2267,53 +2494,111 @@ export interface IProductModuleService extends IModuleService {
2267
2494
  */
2268
2495
  deleteCollections(productCollectionIds: string[], sharedContext?: Context): Promise<void>;
2269
2496
  /**
2270
- * This method is used to retrieve a product category by its ID.
2497
+ * This method is used to delete product collections. Unlike the {@link deleteCollections} method, this method won't completely remove the collection. It can still be accessed or retrieved using methods like {@link retrieveCollections} if you pass the `withDeleted` property to the `config` object parameter.
2271
2498
  *
2272
- * @param {string} productCategoryId - The ID of the product category to retrieve.
2273
- * @param {FindConfig<ProductCategoryDTO>} config -
2274
- * The configurations determining how the product category is retrieved. Its properties, such as `select` or `relations`, accept the
2275
- * attributes or relations associated with a product category.
2499
+ * The soft-deleted collections can be restored using the {@link restoreCollections} method.
2500
+ *
2501
+ * @param {string[]} collectionIds - The IDs of the collections to soft-delete.
2502
+ * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
2503
+ * Configurations determining which relations to soft delete along with the each of the collections. You can pass to its `returnLinkableKeys`
2504
+ * property any of the collection's relation attribute names.
2276
2505
  * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2277
- * @returns {Promise<ProductCategoryDTO>} The retrieved product category.
2506
+ * @returns {Promise<Record<string, string[]> | void>}
2507
+ * An object that includes the IDs of related records that were also soft deleted. The object's keys are the ID attribute names of the collection entity's relations.
2278
2508
  *
2279
- * @example
2280
- * A simple example that retrieves a product category by its ID:
2509
+ * If there are no related records, the promise resolved to `void`.
2281
2510
  *
2282
- * ```ts
2511
+ * @example
2283
2512
  * import {
2284
2513
  * initialize as initializeProductModule,
2285
2514
  * } from "@medusajs/product"
2286
2515
  *
2287
- * async function retrieveCategory (id: string) {
2516
+ * async function deleteCollections (ids: string[]) {
2288
2517
  * const productModule = await initializeProductModule()
2289
2518
  *
2290
- * const category = await productModule.retrieveCategory(id)
2519
+ * const cascadedEntities = await productModule.softDeleteCollections(ids)
2291
2520
  *
2292
- * // do something with the product category or return it
2521
+ * // do something with the returned cascaded entity IDs or return them
2293
2522
  * }
2294
- * ```
2523
+ */
2524
+ softDeleteCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2525
+ /**
2526
+ * This method is used to restore collections which were deleted using the {@link softDelete} method.
2295
2527
  *
2296
- * To specify relations that should be retrieved:
2528
+ * @param {string[]} collectionIds - The IDs of the collections to restore.
2529
+ * @param {RestoreReturn<TReturnableLinkableKeys>} config -
2530
+ * Configurations determining which relations to restore along with each of the collections. You can pass to its `returnLinkableKeys`
2531
+ * property any of the collection's relation attribute names.
2532
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2533
+ * @returns {Promise<Record<string, string[]> | void>}
2534
+ * An object that includes the IDs of related records that were restored. The object's keys are the ID attribute names of the product entity's relations.
2297
2535
  *
2298
- * ```ts
2536
+ * If there are no related records that were restored, the promise resolved to `void`.
2537
+ *
2538
+ * @example
2299
2539
  * import {
2300
2540
  * initialize as initializeProductModule,
2301
2541
  * } from "@medusajs/product"
2302
2542
  *
2303
- * async function retrieveCategory (id: string) {
2543
+ * async function restoreCollections (ids: string[]) {
2304
2544
  * const productModule = await initializeProductModule()
2305
2545
  *
2306
- * const category = await productModule.retrieveCategory(id, {
2307
- * relations: ["parent_category"]
2546
+ * const cascadedEntities = await productModule.restoreCollections(ids, {
2547
+ * returnLinkableKeys: []
2308
2548
  * })
2309
2549
  *
2310
- * // do something with the product category or return it
2550
+ * // do something with the returned cascaded entity IDs or return them
2311
2551
  * }
2312
- * ```
2313
2552
  */
2314
- retrieveCategory(productCategoryId: string, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO>;
2553
+ restoreCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2315
2554
  /**
2316
- * This method is used to retrieve a paginated list of product categories based on optional filters and configuration.
2555
+ * This method is used to retrieve a product category by its ID.
2556
+ *
2557
+ * @param {string} productCategoryId - The ID of the product category to retrieve.
2558
+ * @param {FindConfig<ProductCategoryDTO>} config -
2559
+ * The configurations determining how the product category is retrieved. Its properties, such as `select` or `relations`, accept the
2560
+ * attributes or relations associated with a product category.
2561
+ * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2562
+ * @returns {Promise<ProductCategoryDTO>} The retrieved product category.
2563
+ *
2564
+ * @example
2565
+ * A simple example that retrieves a product category by its ID:
2566
+ *
2567
+ * ```ts
2568
+ * import {
2569
+ * initialize as initializeProductModule,
2570
+ * } from "@medusajs/product"
2571
+ *
2572
+ * async function retrieveCategory (id: string) {
2573
+ * const productModule = await initializeProductModule()
2574
+ *
2575
+ * const category = await productModule.retrieveCategory(id)
2576
+ *
2577
+ * // do something with the product category or return it
2578
+ * }
2579
+ * ```
2580
+ *
2581
+ * To specify relations that should be retrieved:
2582
+ *
2583
+ * ```ts
2584
+ * import {
2585
+ * initialize as initializeProductModule,
2586
+ * } from "@medusajs/product"
2587
+ *
2588
+ * async function retrieveCategory (id: string) {
2589
+ * const productModule = await initializeProductModule()
2590
+ *
2591
+ * const category = await productModule.retrieveCategory(id, {
2592
+ * relations: ["parent_category"]
2593
+ * })
2594
+ *
2595
+ * // do something with the product category or return it
2596
+ * }
2597
+ * ```
2598
+ */
2599
+ retrieveCategory(productCategoryId: string, config?: FindConfig<ProductCategoryDTO>, sharedContext?: Context): Promise<ProductCategoryDTO>;
2600
+ /**
2601
+ * This method is used to retrieve a paginated list of product categories based on optional filters and configuration.
2317
2602
  *
2318
2603
  * @param {FilterableProductCategoryProps} filters - The filters to be applied on the retrieved product categories.
2319
2604
  * @param {FindConfig<ProductCategoryDTO>} config -
@@ -2582,317 +2867,5 @@ export interface IProductModuleService extends IModuleService {
2582
2867
  * }
2583
2868
  */
2584
2869
  deleteCategory(categoryId: string, sharedContext?: Context): Promise<void>;
2585
- /**
2586
- * This method is used to create a list of products.
2587
- *
2588
- * @param {CreateProductDTO[]} data - The products to be created.
2589
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2590
- * @returns {Promise<ProductDTO[]>} The list of created products.
2591
- *
2592
- * @example
2593
- * import {
2594
- * initialize as initializeProductModule,
2595
- * } from "@medusajs/product"
2596
- *
2597
- * async function createProduct (title: string) {
2598
- * const productModule = await initializeProductModule()
2599
- *
2600
- * const products = await productModule.create([
2601
- * {
2602
- * title
2603
- * }
2604
- * ])
2605
- *
2606
- * // do something with the products or return them
2607
- * }
2608
- */
2609
- create(data: CreateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
2610
- /**
2611
- * This method is used to create a product.
2612
- *
2613
- * @param {CreateProductDTO} data - The product to be created.
2614
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2615
- * @returns {Promise<ProductDTO>} The created product.
2616
- *
2617
- * @example
2618
- * import {
2619
- * initialize as initializeProductModule,
2620
- * } from "@medusajs/product"
2621
- *
2622
- * async function createProduct (title: string) {
2623
- * const productModule = await initializeProductModule()
2624
- *
2625
- * const product = await productModule.create(
2626
- * {
2627
- * title
2628
- * }
2629
- * )
2630
- *
2631
- * // do something with the product or return it
2632
- * }
2633
- */
2634
- create(data: CreateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
2635
- /**
2636
- * This method updates existing products, or creates new ones if they don't exist.
2637
- *
2638
- * @param {CreateProductDTO[]} data - The attributes to update or create for each product.
2639
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2640
- * @returns {Promise<ProductDTO[]>} The updated and created products.
2641
- *
2642
- * @example
2643
- * import {
2644
- * initialize as initializeProductModule,
2645
- * } from "@medusajs/product"
2646
- *
2647
- * async function upserProduct (title: string) {
2648
- * const productModule = await initializeProductModule()
2649
- *
2650
- * const createdProducts = await productModule.upsert([
2651
- * {
2652
- * title
2653
- * }
2654
- * ])
2655
- *
2656
- * // do something with the products or return them
2657
- * }
2658
- */
2659
- upsert(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
2660
- /**
2661
- * This method updates the product if it exists, or creates a new ones if it doesn't.
2662
- *
2663
- * @param {CreateProductDTO} data - The attributes to update or create for the new product.
2664
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2665
- * @returns {Promise<ProductDTO>} The updated or created product.
2666
- *
2667
- * @example
2668
- * import {
2669
- * initialize as initializeProductModule,
2670
- * } from "@medusajs/product"
2671
- *
2672
- * async function upserProduct (title: string) {
2673
- * const productModule = await initializeProductModule()
2674
- *
2675
- * const createdProduct = await productModule.upsert(
2676
- * {
2677
- * title
2678
- * }
2679
- * )
2680
- *
2681
- * // do something with the product or return it
2682
- * }
2683
- */
2684
- upsert(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
2685
- /**
2686
- * This method is used to update a product.
2687
- *
2688
- * @param {string} id - The ID of the product to be updated.
2689
- * @param {UpdateProductDTO} data - The attributes of the product to be updated
2690
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2691
- * @returns {Promise<ProductDTO>} The updated product.
2692
- *
2693
- * @example
2694
- * import {
2695
- * initialize as initializeProductModule,
2696
- * } from "@medusajs/product"
2697
- *
2698
- * async function updateProduct (id: string, title: string) {
2699
- * const productModule = await initializeProductModule()
2700
- *
2701
- * const product = await productModule.update(id, {
2702
- * title
2703
- * }
2704
- * )
2705
- *
2706
- * // do something with the product or return it
2707
- * }
2708
- */
2709
- update(id: string, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
2710
- /**
2711
- * This method is used to update a list of products determined by the selector filters.
2712
- *
2713
- * @param {FilterableProductProps} selector - The filters that will determine which products will be updated.
2714
- * @param {UpdateProductDTO} data - The attributes to be updated on the selected products
2715
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2716
- * @returns {Promise<ProductDTO[]>} The updated products.
2717
- *
2718
- * @example
2719
- * import {
2720
- * initialize as initializeProductModule,
2721
- * } from "@medusajs/product"
2722
- *
2723
- * async function updateProduct (id: string, title: string) {
2724
- * const productModule = await initializeProductModule()
2725
- *
2726
- * const products = await productModule.update({id}, {
2727
- * title
2728
- * }
2729
- * )
2730
- *
2731
- * // do something with the products or return them
2732
- * }
2733
- */
2734
- update(selector: FilterableProductProps, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO[]>;
2735
- /**
2736
- * This method is used to delete products. Unlike the {@link softDelete} method, this method will completely remove the products and they can no longer be accessed or retrieved.
2737
- *
2738
- * @param {string[]} productIds - The IDs of the products to be deleted.
2739
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2740
- * @returns {Promise<void>} Resolves when the products are successfully deleted.
2741
- *
2742
- * @example
2743
- * import {
2744
- * initialize as initializeProductModule,
2745
- * } from "@medusajs/product"
2746
- *
2747
- * async function deleteProducts (ids: string[]) {
2748
- * const productModule = await initializeProductModule()
2749
- *
2750
- * await productModule.delete(ids)
2751
- * }
2752
- */
2753
- delete(productIds: string[], sharedContext?: Context): Promise<void>;
2754
- /**
2755
- * This method is used to delete products. Unlike the {@link delete} method, this method won't completely remove the product. It can still be accessed or retrieved using methods like {@link retrieve} if you pass the `withDeleted` property to the `config` object parameter.
2756
- *
2757
- * The soft-deleted products can be restored using the {@link restore} method.
2758
- *
2759
- * @param {string[]} productIds - The IDs of the products to soft-delete.
2760
- * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
2761
- * Configurations determining which relations to soft delete along with the each of the products. You can pass to its `returnLinkableKeys`
2762
- * property any of the product's relation attribute names, such as `variant_id`.
2763
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2764
- * @returns {Promise<Record<string, string[]> | void>}
2765
- * An object that includes the IDs of related records that were also soft deleted, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of a record associated with the product through this relation, such as the IDs of associated product variants.
2766
- *
2767
- * If there are no related records, the promise resolved to `void`.
2768
- *
2769
- * @example
2770
- * import {
2771
- * initialize as initializeProductModule,
2772
- * } from "@medusajs/product"
2773
- *
2774
- * async function deleteProducts (ids: string[]) {
2775
- * const productModule = await initializeProductModule()
2776
- *
2777
- * const cascadedEntities = await productModule.softDelete(ids)
2778
- *
2779
- * // do something with the returned cascaded entity IDs or return them
2780
- * }
2781
- */
2782
- softDelete<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2783
- /**
2784
- * This method is used to restore products which were deleted using the {@link softDelete} method.
2785
- *
2786
- * @param {string[]} productIds - The IDs of the products to restore.
2787
- * @param {RestoreReturn<TReturnableLinkableKeys>} config -
2788
- * Configurations determining which relations to restore along with each of the products. You can pass to its `returnLinkableKeys`
2789
- * property any of the product's relation attribute names, such as `variant_id`.
2790
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2791
- * @returns {Promise<Record<string, string[]> | void>}
2792
- * An object that includes the IDs of related records that were restored, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of the record associated with the product through this relation, such as the IDs of associated product variants.
2793
- *
2794
- * If there are no related records that were restored, the promise resolved to `void`.
2795
- *
2796
- * @example
2797
- * import {
2798
- * initialize as initializeProductModule,
2799
- * } from "@medusajs/product"
2800
- *
2801
- * async function restoreProducts (ids: string[]) {
2802
- * const productModule = await initializeProductModule()
2803
- *
2804
- * const cascadedEntities = await productModule.restore(ids, {
2805
- * returnLinkableKeys: ["variant_id"]
2806
- * })
2807
- *
2808
- * // do something with the returned cascaded entity IDs or return them
2809
- * }
2810
- */
2811
- restore<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2812
- /**
2813
- * This method is used to delete product collections. Unlike the {@link deleteCollections} method, this method won't completely remove the collection. It can still be accessed or retrieved using methods like {@link retrieveCollections} if you pass the `withDeleted` property to the `config` object parameter.
2814
- *
2815
- * The soft-deleted collections can be restored using the {@link restoreCollections} method.
2816
- *
2817
- * @param {string[]} collectionIds - The IDs of the collections to soft-delete.
2818
- * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
2819
- * Configurations determining which relations to soft delete along with the each of the collections. You can pass to its `returnLinkableKeys`
2820
- * property any of the collection's relation attribute names.
2821
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2822
- * @returns {Promise<Record<string, string[]> | void>}
2823
- * An object that includes the IDs of related records that were also soft deleted. The object's keys are the ID attribute names of the collection entity's relations.
2824
- *
2825
- * If there are no related records, the promise resolved to `void`.
2826
- *
2827
- * @example
2828
- * import {
2829
- * initialize as initializeProductModule,
2830
- * } from "@medusajs/product"
2831
- *
2832
- * async function deleteCollections (ids: string[]) {
2833
- * const productModule = await initializeProductModule()
2834
- *
2835
- * const cascadedEntities = await productModule.softDeleteCollections(ids)
2836
- *
2837
- * // do something with the returned cascaded entity IDs or return them
2838
- * }
2839
- */
2840
- softDeleteCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2841
- /**
2842
- * This method is used to restore collections which were deleted using the {@link softDelete} method.
2843
- *
2844
- * @param {string[]} collectionIds - The IDs of the collections to restore.
2845
- * @param {RestoreReturn<TReturnableLinkableKeys>} config -
2846
- * Configurations determining which relations to restore along with each of the collections. You can pass to its `returnLinkableKeys`
2847
- * property any of the collection's relation attribute names.
2848
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2849
- * @returns {Promise<Record<string, string[]> | void>}
2850
- * An object that includes the IDs of related records that were restored. The object's keys are the ID attribute names of the product entity's relations.
2851
- *
2852
- * If there are no related records that were restored, the promise resolved to `void`.
2853
- *
2854
- * @example
2855
- * import {
2856
- * initialize as initializeProductModule,
2857
- * } from "@medusajs/product"
2858
- *
2859
- * async function restoreCollections (ids: string[]) {
2860
- * const productModule = await initializeProductModule()
2861
- *
2862
- * const cascadedEntities = await productModule.restoreCollections(ids, {
2863
- * returnLinkableKeys: []
2864
- * })
2865
- *
2866
- * // do something with the returned cascaded entity IDs or return them
2867
- * }
2868
- */
2869
- restoreCollections<TReturnableLinkableKeys extends string = string>(collectionIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2870
- /**
2871
- * This method is used to restore product varaints that were soft deleted. Product variants are soft deleted when they're not
2872
- * provided in a product's details passed to the {@link update} method.
2873
- *
2874
- * @param {string[]} variantIds - The IDs of the variants to restore.
2875
- * @param {RestoreReturn<TReturnableLinkableKeys>} config -
2876
- * Configurations determining which relations to restore along with each of the product variants. You can pass to its `returnLinkableKeys`
2877
- * property any of the product variant's relation attribute names.
2878
- * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
2879
- * @returns {Promise<Record<string, string[]> | void>}
2880
- * An object that includes the IDs of related records that were restored. The object's keys are the ID attribute names of the product variant entity's relations
2881
- * and its value is an array of strings, each being the ID of the record associated with the product variant through this relation.
2882
- *
2883
- * If there are no related records that were restored, the promise resolved to `void`.
2884
- *
2885
- * @example
2886
- * import {
2887
- * initialize as initializeProductModule,
2888
- * } from "@medusajs/product"
2889
- *
2890
- * async function restoreProductVariants (ids: string[]) {
2891
- * const productModule = await initializeProductModule()
2892
- *
2893
- * await productModule.restoreVariants(ids)
2894
- * }
2895
- */
2896
- restoreVariants<TReturnableLinkableKeys extends string = string>(variantIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
2897
2870
  }
2898
2871
  //# sourceMappingURL=service.d.ts.map