@medusajs/types
Version:
Medusa Types definition
1,089 lines • 110 kB
TypeScript
import { RestoreReturn, SoftDeleteReturn } from "../dal";
import { CreateProductCategoryDTO, CreateProductCollectionDTO, CreateProductDTO, CreateProductOptionDTO, CreateProductOptionValueDTO, CreateProductTagDTO, CreateProductTypeDTO, CreateProductVariantDTO, FilterableProductCategoryProps, FilterableProductCollectionProps, FilterableProductOptionProps, FilterableProductOptionValueProps, FilterableProductProps, FilterableProductTagProps, FilterableProductTypeProps, FilterableProductVariantProps, ProductCategoryDTO, ProductCollectionDTO, ProductDTO, ProductOptionDTO, ProductOptionValueDTO, ProductTagDTO, ProductTypeDTO, ProductVariantDTO, UpdateProductCategoryDTO, UpdateProductCollectionDTO, UpdateProductDTO, UpdateProductOptionDTO, UpdateProductOptionValueDTO, UpdateProductTagDTO, UpdateProductTypeDTO, UpdateProductVariantDTO, UpsertProductCategoryDTO, UpsertProductCollectionDTO, UpsertProductDTO, UpsertProductOptionDTO, UpsertProductTagDTO, UpsertProductTypeDTO, UpsertProductVariantDTO } from "./common";
import { FindConfig } from "../common";
import { IModuleService } from "../modules-sdk";
import { Context } from "../shared-context";
/**
* The main service interface for the Product Module.
*/
export interface IProductModuleService extends IModuleService {
/**
* This method is used to retrieve a product by its ID
*
* @param {string} productId - The ID of the product to retrieve.
* @param {FindConfig<ProductDTO>} config -
* The configurations determining how the product is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO>} The retrieved product.
*
* @example
* A simple example that retrieves a product by its ID:
*
* ```ts
* const product =
* await productModuleService.retrieveProduct("prod_123")
* ```
*
* To specify relations that should be retrieved:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const product = await productModuleService.retrieveProduct(
* "prod_123",
* {
* relations: ["categories"],
* }
* )
* ```
*/
retrieveProduct(productId: string, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO>;
/**
* This method is used to retrieve a paginated list of products based on optional filters and configuration.
*
* @param {FilterableProductProps} filters - The filters to apply on the retrieved products.
* @param {FindConfig<ProductDTO>} config -
* The configurations determining how the products are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO[]>} The list of products.
*
* @example
* To retrieve a list of products using their IDs:
*
* ```ts
* const products = await productModuleService.listProducts({
* id: ["prod_123", "prod_321"],
* })
* ```
*
* To specify relations that should be retrieved within the products:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const products = await productModuleService.listProducts(
* {
* id: ["prod_123", "prod_321"],
* },
* {
* relations: ["categories"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const products = await productModuleService.listProducts(
* {
* id: ["prod_123", "prod_321"],
* },
* {
* relations: ["categories"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listProducts(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<ProductDTO[]>;
/**
* This method is used to retrieve a paginated list of products along with the total count of available products satisfying the provided filters.
*
* @param {FilterableProductProps} filters - The filters to apply on the retrieved products.
* @param {FindConfig<ProductDTO>} config -
* The configurations determining how the products are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO[]>} The list of products along with the total count.
*
* @example
* To retrieve a list of products using their IDs:
*
* ```ts
* const [products, count] =
* await productModuleService.listAndCountProducts({
* id: ["prod_123", "prod_321"],
* })
* ```
*
* To specify relations that should be retrieved within the products:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const [products, count] =
* await productModuleService.listAndCountProducts(
* {
* id: ["prod_123", "prod_321"],
* },
* {
* relations: ["categories"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const [products, count] =
* await productModuleService.listAndCountProducts(
* {
* id: ["prod_123", "prod_321"],
* },
* {
* relations: ["categories"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listAndCountProducts(filters?: FilterableProductProps, config?: FindConfig<ProductDTO>, sharedContext?: Context): Promise<[ProductDTO[], number]>;
/**
* This method is used to create a list of products.
*
* @param {CreateProductDTO[]} data - The products to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO[]>} The list of created products.
*
* @example
* const products = await productModuleService.createProducts([
* {
* title: "Shirt",
* },
* {
* title: "Pants",
* handle: "pants",
* },
* ])
*/
createProducts(data: CreateProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
/**
* This method is used to create a product.
*
* @param {CreateProductDTO} data - The product to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO>} The created product.
*
* @example
* const product = await productModuleService.createProducts({
* title: "Shirt",
* })
*/
createProducts(data: CreateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
/**
* This method updates existing products, or creates new ones if they don't exist.
*
* @param {UpsertProductDTO[]} data - The attributes to update or create for each product.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO[]>} The updated and created products.
*
* @example
* const products = await productModuleService.upsertProducts([
* {
* id: "prod_123",
* handle: "pant",
* },
* {
* title: "Shirt",
* },
* ])
*/
upsertProducts(data: UpsertProductDTO[], sharedContext?: Context): Promise<ProductDTO[]>;
/**
* This method updates the product if it exists, or creates a new ones if it doesn't.
*
* @param {UpsertProductDTO} data - The attributes to update or create for the new product.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO>} The updated or created product.
*
* @example
* const product = await productModuleService.upsertProducts({
* title: "Shirt",
* })
*/
upsertProducts(data: UpsertProductDTO, sharedContext?: Context): Promise<ProductDTO>;
/**
* This method is used to update a product.
*
* @param {string} id - The ID of the product to be updated.
* @param {UpdateProductDTO} data - The attributes of the product to be updated
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO>} The updated product.
*
* @example
* const product = await productModuleService.updateProducts(
* "prod_123",
* {
* handle: "pant",
* }
* )
*/
updateProducts(id: string, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO>;
/**
* This method is used to update a list of products matching the specified filters.
*
* @param {FilterableProductProps} selector - The filters specifying which products to update.
* @param {UpdateProductDTO} data - The attributes to be updated on the selected products
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductDTO[]>} The updated products.
*
* @example
* const products = await productModuleService.updateProducts(
* {
* title: "Pant",
* },
* {
* handle: "pant",
* }
* )
*/
updateProducts(selector: FilterableProductProps, data: UpdateProductDTO, sharedContext?: Context): Promise<ProductDTO[]>;
/**
* 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.
*
* @param {string[]} productIds - The IDs of the products to be deleted.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<void>} Resolves when the products are successfully deleted.
*
* @example
* await productModuleService.deleteProducts(["prod_123", "prod_321"])
*/
deleteProducts(productIds: string[], sharedContext?: Context): Promise<void>;
/**
* 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.
*
* The soft-deleted products can be restored using the {@link restore} method.
*
* @param {string[]} productIds - The IDs of the products to soft-delete.
* @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to soft delete along with the each of the products. You can pass to its `returnLinkableKeys`
* property any of the product's relation attribute names, such as `variant_id`.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* 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.
*
* If there are no related records, the promise resolved to `void`.
*
* @example
* await productModuleService.softDeleteProducts([
* "prod_123",
* "prod_321",
* ])
*/
softDeleteProducts<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to restore products which were deleted using the {@link softDelete} method.
*
* @param {string[]} productIds - The IDs of the products to restore.
* @param {RestoreReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to restore along with each of the products. You can pass to its `returnLinkableKeys`
* property any of the product's relation attribute names, such as `variant_id`.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* 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.
*
* If there are no related records that were restored, the promise resolved to `void`.
*
* @example
* await productModuleService.restoreProducts(["prod_123", "prod_321"])
*/
restoreProducts<TReturnableLinkableKeys extends string = string>(productIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to retrieve a tag by its ID.
*
* @param {string} tagId - The ID of the tag to retrieve.
* @param {FindConfig<ProductTagDTO>} config -
* The configurations determining how the product tag is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product tag.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO>} The retrieved product tag.
*
* @example
* A simple example that retrieves a product tag by its ID:
*
* ```ts
* const tag = await productModuleService.retrieveProductTag("ptag_123")
* ```
*
* To specify relations that should be retrieved:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const tag = await productModuleService.retrieveProductTag(
* "ptag_123",
* {
* relations: ["products"],
* }
* )
* ```
*/
retrieveProductTag(tagId: string, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO>;
/**
* This method is used to retrieve a paginated list of tags based on optional filters and configuration.
*
* @param {FilterableProductTagProps} filters - The filters applied on the retrieved product tags.
* @param {FindConfig<ProductTagDTO>} config -
* The configurations determining how the product tags are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product tag.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO[]>} The list of product tags.
*
* @example
* To retrieve a list of product tags using their IDs:
*
* ```ts
* const tags = await productModuleService.listProductTags({
* id: ["ptag_123", "ptag_321"],
* })
* ```
*
* To specify relations that should be retrieved within the product tags:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const tags = await productModuleService.listProductTags(
* {
* id: ["ptag_123", "ptag_321"],
* },
* {
* relations: ["products"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const tags = await productModuleService.listProductTags(
* {
* id: ["ptag_123", "ptag_321"],
* },
* {
* relations: ["products"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listProductTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<ProductTagDTO[]>;
/**
* This method is used to retrieve a paginated list of product tags along with the total count of available product tags satisfying the provided filters.
*
* @param {FilterableProductTagProps} filters - The filters applied on the retrieved product tags.
* @param {FindConfig<ProductTagDTO>} config -
* The configurations determining how the product tags are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product tag.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<[ProductTagDTO[], number]>} The list of product tags along with the total count.
*
* @example
* To retrieve a list of product tags using their IDs:
*
* ```ts
* const [tags, count] =
* await productModuleService.listAndCountProductTags({
* id: ["ptag_123", "ptag_321"],
* })
* ```
*
* To specify relations that should be retrieved within the product tags:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const [tags, count] =
* await productModuleService.listAndCountProductTags(
* {
* id: ["ptag_123", "ptag_321"],
* },
* {
* relations: ["products"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const [tags, count] =
* await productModuleService.listAndCountProductTags(
* {
* id: ["ptag_123", "ptag_321"],
* },
* {
* relations: ["products"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listAndCountProductTags(filters?: FilterableProductTagProps, config?: FindConfig<ProductTagDTO>, sharedContext?: Context): Promise<[ProductTagDTO[], number]>;
/**
* This method is used to create a product tag.
*
* @param {CreateProductTagDTO[]} data - The product tags to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @return {Promise<ProductTagDTO[]>} The list of created product tags.
*
* @example
* const productTags = await productModuleService.createProductTags([
* {
* value: "digital",
* },
* ])
*/
createProductTags(data: CreateProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
/**
* This method is used to create a product tag.
*
* @param {CreateProductTagDTO} data - The product tag to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO>} The created product tag.
*
* @example
* const productTag = await productModuleService.createProductTags({
* value: "digital",
* })
*
*/
createProductTags(data: CreateProductTagDTO, sharedContext?: Context): Promise<ProductTagDTO>;
/**
* This method updates existing tags, or creates new ones if they don't exist.
*
* @param {UpsertProductTagDTO[]} data - The attributes to update or create for each tag.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO[]>} The updated and created tags.
*
* @example
* const productTags = await productModuleService.upsertProductTags([
* {
* id: "ptag_123",
* metadata: {
* test: true,
* },
* },
* {
* value: "Digital",
* },
* ])
*/
upsertProductTags(data: UpsertProductTagDTO[], sharedContext?: Context): Promise<ProductTagDTO[]>;
/**
* This method updates an existing tag, or creates a new one if it doesn't exist.
*
* @param {UpsertProductTagDTO} data - The attributes to update or create for the tag.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO>} The updated or created tag.
*
* @example
* const productTag = await productModuleService.upsertProductTags({
* id: "ptag_123",
* metadata: {
* test: true,
* },
* })
*/
upsertProductTags(data: UpsertProductTagDTO, sharedContext?: Context): Promise<ProductTagDTO>;
/**
* This method is used to update a tag.
*
* @param {string} id - The ID of the tag to be updated.
* @param {UpdateProductTagDTO} data - The attributes of the tag to be updated
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO>} The updated tag.
*
* @example
* const productTag = await productModuleService.updateProductTags(
* "ptag_123",
* {
* value: "Digital",
* }
* )
*/
updateProductTags(id: string, data: UpdateProductTagDTO, sharedContext?: Context): Promise<ProductTagDTO>;
/**
* This method is used to update a list of tags matching the specified filters.
*
* @param {FilterableProductTagProps} selector - The filters specifying which tags to update.
* @param {UpdateProductTagDTO} data - The attributes to be updated on the selected tags
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTagDTO[]>} The updated tags.
*
* @example
* const productTags = await productModuleService.updateProductTags(
* {
* id: ["ptag_123", "ptag_321"],
* },
* {
* value: "Digital",
* }
* )
*/
updateProductTags(selector: FilterableProductTagProps, data: UpdateProductTagDTO, sharedContext?: Context): Promise<ProductTagDTO[]>;
/**
* This method is used to delete product tags by their ID.
*
* @param {string[]} productTagIds - The IDs of the product tags to be deleted.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<void>} Resolves when the product tags are successfully deleted.
*
* @example
* await productModuleService.deleteProductTags([
* "ptag_123",
* "ptag_321",
* ])
*/
deleteProductTags(productTagIds: string[], sharedContext?: Context): Promise<void>;
/**
* This method is used to delete tags. Unlike the {@link delete} method, this method won't completely remove the tag. It can still be accessed or retrieved using methods like {@link retrieve} if you pass the `withDeleted` property to the `config` object parameter.
*
* The soft-deleted tags can be restored using the {@link restore} method.
*
* @param {string[]} tagIds - The IDs of the tags to soft-delete.
* @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to soft delete along with the each of the tags. You can pass to its `returnLinkableKeys`
* property any of the tag's relation attribute names.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* 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 tag entity's relations, and its value is an array of strings, each being the ID of a record associated with the tag through this relation.
*
* If there are no related records, the promise resolved to `void`.
*
* @example
* await productModuleService.softDeleteProductTags([
* "ptag_123",
* "ptag_321",
* ])
*/
softDeleteProductTags<TReturnableLinkableKeys extends string = string>(tagIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to restore tags which were deleted using the {@link softDelete} method.
*
* @param {string[]} tagIds - The IDs of the tags to restore.
* @param {RestoreReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to restore along with each of the tags. You can pass to its `returnLinkableKeys`
* property any of the tag's relation attribute names.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* An object that includes the IDs of related records that were restored. The object's keys are the ID attribute names of the tag entity's relations, and its value is an array of strings, each being the ID of the record associated with the tag through this relation.
*
* If there are no related records that were restored, the promise resolved to `void`.
*
* @example
* await productModuleService.restoreProductTags([
* "ptag_123",
* "ptag_321",
* ])
*/
restoreProductTags<TReturnableLinkableKeys extends string = string>(tagIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to retrieve a product type by its ID.
*
* @param {string} typeId - The ID of the product type to retrieve.
* @param {FindConfig<ProductTypeDTO>} config -
* The configurations determining how the product type is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product type.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO>} The retrieved product type.
*
* @example
* const productType =
* await productModuleService.retrieveProductType("ptyp_123")
*/
retrieveProductType(typeId: string, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO>;
/**
* This method is used to retrieve a paginated list of product types based on optional filters and configuration.
*
* @param {FilterableProductTypeProps} filters - The filters to apply on the retrieved product types.
* @param {FindConfig<ProductTypeDTO>} config -
* The configurations determining how the product types are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product type.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO[]>} The list of product types.
*
* @example
* To retrieve a list of product types using their IDs:
*
* ```ts
* const productTypes = await productModuleService.listProductTypes({
* id: ["ptyp_123", "ptyp_321"],
* })
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const productTypes = await productModuleService.listProductTypes(
* {
* id: ["ptyp_123", "ptyp_321"],
* },
* {
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listProductTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<ProductTypeDTO[]>;
/**
* This method is used to retrieve a paginated list of product types along with the total count of available product types satisfying the provided filters.
*
* @param {FilterableProductTypeProps} filters - The filters to be applied on the retrieved product type.
* @param {FindConfig<ProductTypeDTO>} config -
* The configurations determining how the product types are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product type.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<[ProductTypeDTO[], number]>} The list of product types along with their total count.
*
* @example
* To retrieve a list of product types using their IDs:
*
* ```ts
* const [productTypes, count] =
* await productModuleService.listAndCountProductTypes({
* id: ["ptyp_123", "ptyp_321"],
* })
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const [productTypes, count] =
* await productModuleService.listAndCountProductTypes(
* {
* id: ["ptyp_123", "ptyp_321"],
* },
* {
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listAndCountProductTypes(filters?: FilterableProductTypeProps, config?: FindConfig<ProductTypeDTO>, sharedContext?: Context): Promise<[ProductTypeDTO[], number]>;
/**
* This method is used to create a product type.
*
* @param {CreateProductTypeDTO[]} data - The product types to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @return {Promise<ProductTypeDTO[]>} The list of created product types.
*
* @example
* const productTypes = await productModuleService.createProductTypes([
* {
* value: "digital",
* },
* ])
*/
createProductTypes(data: CreateProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
/**
* This method is used to create a product type.
*
* @param {CreateProductTypeDTO} data - The product type to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO>} The created product type.
*
* @example
* const productType = await productModuleService.createProductTypes({
* value: "digital",
* })
*
*/
createProductTypes(data: CreateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
/**
* This method updates existing types, or creates new ones if they don't exist.
*
* @param {UpsertProductTypeDTO[]} data - The attributes to update or create for each type.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO[]>} The updated and created types.
*
* @example
* const productTypes = await productModuleService.upsertProductTypes([
* {
* id: "ptyp_123",
* metadata: {
* test: true,
* },
* },
* {
* value: "Digital",
* },
* ])
*/
upsertProductTypes(data: UpsertProductTypeDTO[], sharedContext?: Context): Promise<ProductTypeDTO[]>;
/**
* This method updates an existing type, or creates a new one if it doesn't exist.
*
* @param {UpsertProductTypeDTO} data - The attributes to update or create for the type.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO>} The updated or created type.
*
* @example
* const productType = await productModuleService.upsertProductTypes({
* id: "ptyp_123",
* metadata: {
* test: true,
* },
* })
*/
upsertProductTypes(data: UpsertProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
/**
* This method is used to update a type.
*
* @param {string} id - The ID of the type to be updated.
* @param {UpdateProductTypeDTO} data - The attributes of the type to be updated
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO>} The updated type.
*
* @example
* const productType = await productModuleService.updateProductTypes(
* "ptyp_123",
* {
* value: "Digital",
* }
* )
*/
updateProductTypes(id: string, data: UpdateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO>;
/**
* This method is used to update a list of types matching the specified filters.
*
* @param {FilterableProductTypeProps} selector - The filters specifying which types to update.
* @param {UpdateProductTypeDTO} data - The attributes to be updated on the selected types
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductTypeDTO[]>} The updated types.
*
* @example
* const productTypes = await productModuleService.updateProductTypes(
* {
* id: ["ptyp_123", "ptyp_321"],
* },
* {
* value: "Digital",
* }
* )
*/
updateProductTypes(selector: FilterableProductTypeProps, data: UpdateProductTypeDTO, sharedContext?: Context): Promise<ProductTypeDTO[]>;
/**
* This method is used to delete a product type.
*
* @param {string[]} productTypeIds - The IDs of the product types to be deleted.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<void>} Resolves when the product types are successfully deleted.
*
* @example
* await productModuleService.deleteProductTypes([
* "ptyp_123",
* "ptyp_321",
* ])
*/
deleteProductTypes(productTypeIds: string[], sharedContext?: Context): Promise<void>;
/**
* This method is used to delete types. Unlike the {@link delete} method, this method won't completely remove the type. It can still be accessed or retrieved using methods like {@link retrieve} if you pass the `withDeleted` property to the `config` object parameter.
*
* The soft-deleted types can be restored using the {@link restore} method.
*
* @param {string[]} typeIds - The IDs of the types to soft-delete.
* @param {SoftDeleteReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to soft delete along with the each of the types. You can pass to its `returnLinkableKeys`
* property any of the type's relation attribute names.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* 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 type entity's relations, and its value is an array of strings, each being the ID of a record associated with the type through this relation.
*
* If there are no related records, the promise resolved to `void`.
*
* @example
* await productModuleService.softDeleteProductTypes([
* "ptyp_123",
* "ptyp_321",
* ])
*/
softDeleteProductTypes<TReturnableLinkableKeys extends string = string>(typeIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to restore types which were deleted using the {@link softDelete} method.
*
* @param {string[]} typeIds - The IDs of the types to restore.
* @param {RestoreReturn<TReturnableLinkableKeys>} config -
* Configurations determining which relations to restore along with each of the types. You can pass to its `returnLinkableKeys`
* property any of the type's relation attribute names.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, string[]> | void>}
* An object that includes the IDs of related records that were restored. The object's keys are the ID attribute names of the type entity's relations, and its value is an array of strings, each being the ID of the record associated with the type through this relation.
*
* If there are no related records that were restored, the promise resolved to `void`.
*
* @example
* await productModuleService.restoreProductTypes([
* "ptyp_123",
* "ptyp_321",
* ])
*/
restoreProductTypes<TReturnableLinkableKeys extends string = string>(typeIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
/**
* This method is used to retrieve a product option by its ID.
*
* @param {string} optionId - The ID of the product option to retrieve.
* @param {FindConfig<ProductOptionDTO>} config -
* The configurations determining how the product option is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product option.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO>} The retrieved product option.
*
* @example
* A simple example that retrieves a product option by its ID:
*
* ```ts
* const option =
* await productModuleService.retrieveProductOption("opt_123")
* ```
*
* To specify relations that should be retrieved:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const option = await productModuleService.retrieveProductOption(
* "opt_123",
* {
* relations: ["product"],
* }
* )
* ```
*/
retrieveProductOption(optionId: string, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO>;
/**
* This method is used to retrieve a paginated list of product options based on optional filters and configuration.
*
* @param {FilterableProductOptionProps} filters - The filters applied on the retrieved product options.
* @param {FindConfig<ProductOptionDTO>} config -
* The configurations determining how the product options are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product option.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO[]>} The list of product options.
*
* @example
* To retrieve a list of product options using their IDs:
*
* ```ts
* const options = await productModuleService.listProductOptions({
id: ["opt_123", "opt_321"],
* })
* ```
*
* To specify relations that should be retrieved within the product options:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const options = await productModuleService.listProductOptions(
* {
* id: ["opt_123", "opt_321"],
* },
* {
* relations: ["product"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const options = await productModuleService.listProductOptions(
* {
* id: ["opt_123", "opt_321"],
* },
* {
* relations: ["product"],
* take: 20,
* skip: 2,
* }
* )
* ```
*
*/
listProductOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<ProductOptionDTO[]>;
/**
* This method is used to retrieve a paginated list of product options along with the total count of available product options satisfying the provided filters.
*
* @param {FilterableProductOptionProps} filters - The filters applied on the retrieved product options.
* @param {FindConfig<ProductOptionDTO>} config -
* The configurations determining how the product options are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a product option.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<[ProductOptionDTO[], number]>} The list of product options along with the total count.
*
* @example
* To retrieve a list of product options using their IDs:
*
* ```ts
* const [options, count] =
* await productModuleService.listAndCountProductOptions({
* id: ["opt_123", "opt_321"],
* })
* ```
*
* To specify relations that should be retrieved within the product options:
*
* :::note
*
* You can only retrieve data models defined in the same module. To retrieve linked data models
* from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead.
*
* :::
*
* ```ts
* const [options, count] =
* await productModuleService.listAndCountProductOptions(
* {
* id: ["opt_123", "opt_321"],
* },
* {
* relations: ["product"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const [options, count] =
* await productModuleService.listAndCountProductOptions(
* {
* id: ["opt_123", "opt_321"],
* },
* {
* relations: ["product"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listAndCountProductOptions(filters?: FilterableProductOptionProps, config?: FindConfig<ProductOptionDTO>, sharedContext?: Context): Promise<[ProductOptionDTO[], number]>;
/**
* This method is used to create product options.
*
* @param {CreateProductOptionDTO[]} data - The product options to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO[]>} The list of created product options.
*
* @example
* const options = await productModuleService.createProductOptions([
* {
* title: "Color",
* values: ["Blue", "Green"],
* product_id: "prod_123",
* },
* {
* title: "Size",
* values: ["Small", "Medium"],
* product_id: "prod_321",
* },
* ])
*
*/
createProductOptions(data: CreateProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
/**
* This method is used to create a product option.
*
* @param {CreateProductOptionDTO} data - The product option to be created.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO>} The created product option.
*
* @example
* const option = await productModuleService.createProductOptions({
* title: "Color",
* values: ["Blue", "Green"],
* product_id: "prod_123",
* })
*
*/
createProductOptions(data: CreateProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO>;
/**
* This method updates existing options, or creates new ones if they don't exist.
*
* @param {UpsertProductOptionDTO[]} data - The attributes to update or create for each option.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO[]>} The updated and created options.
*
* @example
* const options = await productModuleService.upsertProductOptions([
* {
* id: "opt_123",
* title: "Color",
* },
* {
* title: "Color",
* values: ["Blue", "Green"],
* product_id: "prod_123",
* },
* ])
*/
upsertProductOptions(data: UpsertProductOptionDTO[], sharedContext?: Context): Promise<ProductOptionDTO[]>;
/**
* This method updates an existing option, or creates a new one if it doesn't exist.
*
* @param {UpsertProductOptionDTO} data - The attributes to update or create for the option.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<ProductOptionDTO>} The updated or created option.
*
* @example
* const option = await productModuleService.upsertProductOptions({
* id: "opt_123",
* title: "Color",
* })
*/
upsertProductOptions(data: UpsertProductOptionDTO, sharedContext?: Context): Promise<ProductOptionDTO>;
/**
* This method is used to update a option.
*
* @param {string} id - The ID of the option to be updated.
* @param {UpdatePr