import { HttpTypes, SelectParams } from "@medusajs/types"; import { Client } from "../client.js"; import { ClientHeaders } from "../types.js"; export declare class Product { /** * @ignore */ private client; /** * @ignore */ constructor(client: Client); /** * This method creates a product import. The products are only imported after * the import is confirmed using the {@link confirmImport} method. * * This method sends a request to the * [Create Product Import](https://docs.medusajs.com/api/admin/products/create-product-import) * API route. * * @privateRemarks * NOTE: Declared as a class-field arrow function rather than a method * (`async import(...) {}`). Bundlers like Vite scan compiled output for the * literal token sequence `import(` to detect dynamic imports. A method * named `import` compiles to that same sequence and gets corrupted by * Vite's import-analysis rewrite. An arrow function field instead compiles * to `this.import = async (...) => {...}` in the constructor, which avoids * the false positive. See: https://github.com/medusajs/medusa/issues/15892 * * @param body - The import's details. * @param query - Query parameters to pass to the request. * @param headers - Headers to pass in the request. * @returns The import's details. * * @example * sdk.admin.product.import({ * file // uploaded File instance * }) * .then(({ transaction_id }) => { * console.log(transaction_id) * }) */ import: (body: HttpTypes.AdminImportProductRequest, query?: {}, headers?: ClientHeaders) => Promise; /** * This method creates a product import. The products are only imported after * the import is confirmed using the {@link confirmImport} method. * * This method sends a request to the * [Create Product Import](https://docs.medusajs.com/api/admin/products/create-product-import-2) * API route. * * @since 2.8.5 * * @param body - The import's details. * @param query - Query parameters to pass to the request. * @param headers - Headers to pass in the request. * @returns The import's details. * * @example * sdk.admin.product.createImport({ * file // uploaded File instance * }) * .then(({ transaction_id }) => { * console.log(transaction_id) * }) */ createImport(body: HttpTypes.AdminImportProductRequest, query?: {}, headers?: ClientHeaders): Promise; /** * This method confirms a product import created using the method {@link import}. * It sends a request to the * [Confirm Product Import](https://docs.medusajs.com/api/admin/products/confirm-product-import) * API route. * * @since 2.8.5 * * @param transactionId - The ID of the transaction of the created product import. This is returned * by the API route used to create the product import. * @param query - Query parameters to pass in the request. * @param headers - Headers to pass in the request. * * @example * sdk.admin.product.confirmImport("transaction_123") * .then(() => { * console.log("Import confirmed") * }) */ confirmImport(transactionId: string, query?: {}, headers?: ClientHeaders): Promise<{}>; /** * This method starts a product export process to retrieve a CSV of exported products. * * You'll receive in the response the transaction ID of the workflow generating the CSV file. * To check the status of the execution, send a `GET` request to * `/admin/workflows-executions/export-products/:transaction-id`. * * Once the execution finishes successfully, a notification is created for the export. * You can retrieve the notifications using the `/admin/notification` API route to * retrieve the file's download URL. * * This method sends a request to the [Export Product](https://docs.medusajs.com/api/admin/products/export-products) * API route. * * @param body - The export's details. * @param query - Filters to specify which products to export. * @param headers - Headers to pass in the request. * @returns The export's details. * * @example * sdk.admin.product.export({}) * .then(({ transaction_id }) => { * console.log(transaction_id) * }) */ export(body: HttpTypes.AdminExportProductRequest, query?: HttpTypes.AdminProductListParams, headers?: ClientHeaders): Promise; /** * This method manages products to create, update, or delete them. It sends a request to the * [Manage Products](https://docs.medusajs.com/api/admin/products/manage-products) * API route. * * @param body - The products to create, update, or delete. * @param query - Configure the fields to retrieve in the products. * @param headers - Headers to pass in the request * @returns The batch operations details. * * @example * sdk.admin.product.batch({ * create: [ * { * title: "Shirt", * options: [{ * title: "Default", * values: ["Default Option"] * }], * variants: [ * { * title: "Default", * options: { * Default: "Default Option" * }, * prices: [] * } * ] * } * ], * update: [{ * id: "prod_123", * title: "Pants" * }], * delete: ["prod_321"] * }) * .then(({ created, updated, deleted }) => { * console.log(created, updated, deleted) * }) */ batch(body: HttpTypes.AdminBatchProductRequest, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method creates a product. It sends a request to the * [Create Product](https://docs.medusajs.com/api/admin/products/create-product) * API route. * * @param body - The product's details. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * sdk.admin.product.create({ * title: "Shirt", * options: [{ * title: "Default", * values: ["Default Option"] * }], * variants: [ * { * title: "Default", * options: { * Default: "Default Option" * }, * prices: [] * } * ], * shipping_profile_id: "sp_123" * }) * .then(({ product }) => { * console.log(product) * }) */ create(body: HttpTypes.AdminCreateProduct, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method updates a product. It sends a request to the * [Update Product](https://docs.medusajs.com/api/admin/products/update-a-product) * API route. * * @param id - The product's ID. * @param body - The data to update in the product. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * sdk.admin.product.update("prod_123", { * title: "Shirt", * }) * .then(({ product }) => { * console.log(product) * }) */ update(id: string, body: HttpTypes.AdminUpdateProduct, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method retrieves a paginated list of products. It sends a request to the * [List Products](https://docs.medusajs.com/api/admin/products/list-products) API route. * * @param queryParams - Filters and pagination configurations. * @param headers - Headers to pass in the request. * @returns The paginated list of products. * * @example * To retrieve the list of products: * * ```ts * sdk.admin.product.list() * .then(({ products, count, limit, offset }) => { * console.log(products) * }) * ``` * * To configure the pagination, pass the `limit` and `offset` query parameters. * * For example, to retrieve only 10 items and skip 10 items: * * ```ts * sdk.admin.product.list({ * limit: 10, * offset: 10 * }) * .then(({ products, count, limit, offset }) => { * console.log(products) * }) * ``` * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each products: * * ```ts * sdk.admin.product.list({ * fields: "id,*variants" * }) * .then(({ products, count, limit, offset }) => { * console.log(products) * }) * ``` * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). */ list(queryParams?: HttpTypes.AdminProductListParams, headers?: ClientHeaders): Promise; /** * This method retrieves a product by its ID. It sends a request to the * [Get Product](https://docs.medusajs.com/api/admin/products/get-a-product) * API route. * * @param id - The product's ID. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * To retrieve a product by its ID: * * ```ts * sdk.admin.product.retrieve("prod_123") * .then(({ product }) => { * console.log(product) * }) * ``` * * To specify the fields and relations to retrieve: * * ```ts * sdk.admin.product.retrieve("prod_123", { * fields: "id,*variants" * }) * .then(({ product }) => { * console.log(product) * }) * ``` * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). */ retrieve(id: string, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method deletes a product. It sends a request to the * [Delete Product](https://docs.medusajs.com/api/admin/products/delete-a-product) * API route. * * @param id - The product's ID. * @param headers - Headers to pass in the request * @returns The deletion's details. * * @example * sdk.admin.product.delete("prod_123") * .then(({ deleted }) => { * console.log(deleted) * }) */ delete(id: string, headers?: ClientHeaders): Promise; /** * This method manages the variants of a product. It sends a request to the * [Manage Variants](https://docs.medusajs.com/api/admin/products/manage-variants-in-a-product) * API route. * * @param productId - The product's ID. * @param body - The variants to create, update, or delete. * @param query - Configure the fields to retrieve in the product variants. * @param headers - Headers to pass in the request * @returns The product variants' details. * * @example * sdk.admin.product.batchVariants("prod_123", { * create: [ * { * title: "Blue Shirt", * options: { * Color: "Blue" * }, * prices: [] * } * ], * update: [ * { * id: "variant_123", * title: "Pants" * } * ], * delete: ["variant_123"] * }) * .then(({ created, updated, deleted }) => { * console.log(created, updated, deleted) * }) */ batchVariants(productId: string, body: HttpTypes.AdminBatchProductVariantRequest, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method creates a variant for a product. It sends a request to the * [Create Variant](https://docs.medusajs.com/api/admin/products/create-variant) * API route. * * @param productId - The product's ID. * @param body - The variant's details. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * sdk.admin.product.createVariant("prod_123", { * title: "Blue Shirt", * options: { * Color: "Blue" * }, * prices: [ * { * amount: 10, * currency_code: "usd" * } * ] * }) * .then(({ product }) => { * console.log(product) * }) */ createVariant(productId: string, body: HttpTypes.AdminCreateProductVariant, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method updates a variant of a product. It sends a request to the * [Update Variant](https://docs.medusajs.com/api/admin/products/update-variant) * API route. * * @param productId - The product's ID. * @param id - The variant's ID. * @param body - The data to update in the variant. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * sdk.admin.product.updateVariant( * "prod_123", * "variant_123", * { * title: "Blue Shirt", * } * ) * .then(({ product }) => { * console.log(product) * }) */ updateVariant(productId: string, id: string, body: HttpTypes.AdminUpdateProductVariant, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method retrieves a paginated list of products. It sends a request to the * [List Products](https://docs.medusajs.com/api/admin/products/list-variants) API route. * * @param productId - The ID of the product to retrieve its variants. * @param query - Filters and pagination configurations. * @param headers - Headers to pass in the request. * @returns The paginated list of product variants. * * @example * To retrieve the list of product variants: * * ```ts * sdk.admin.product.listVariants("prod_123") * .then(({ variants, count, limit, offset }) => { * console.log(variants) * }) * ``` * * To configure the pagination, pass the `limit` and `offset` query parameters. * * For example, to retrieve only 10 items and skip 10 items: * * ```ts * sdk.admin.product.listVariants("prod_123", { * limit: 10, * offset: 10 * }) * .then(({ variants, count, limit, offset }) => { * console.log(variants) * }) * ``` * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each product variant: * * ```ts * sdk.admin.product.listVariants("prod_123", { * fields: "id,*product" * }) * .then(({ variants, count, limit, offset }) => { * console.log(variants) * }) * ``` * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). */ listVariants(productId: string, query?: HttpTypes.AdminProductVariantParams, headers?: ClientHeaders): Promise; /** * This method retrieves a product's variant. It sends a request to the * [Retrieve Variant](https://docs.medusajs.com/api/admin/products/get-variant) * API route. * * @param productId - The product's ID. * @param id - The variant's ID. * @param query - Configure the fields to retrieve in the product variant. * @param headers - Headers to pass in the request * @returns The product variant's details. * * @example * To retrieve a product variant by its ID: * * ```ts * sdk.admin.product.retrieveVariant( * "prod_123", * "variant_123" * ) * .then(({ variant }) => { * console.log(variant) * }) * ``` * * To specify the fields and relations to retrieve: * * ```ts * sdk.admin.product.retrieveVariant( * "prod_123", * "variant_123", * { * fields: "id, *product" * } * ) * .then(({ variant }) => { * console.log(variant) * }) * ``` * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). */ retrieveVariant(productId: string, id: string, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method deletes a product's variant. It sends a request to the * [Delete Variant](https://docs.medusajs.com/api/admin/products/delete-variant) * API route. * * @param productId - The product's ID. * @param id - The ID of the variant. * @param headers - Headers to pass in the request * @param query - Configure the fields to retrieve in the product variant. * @returns The deletion's details. * * @example * sdk.admin.product.deleteVariant("prod_123", "variant_123") * .then(({ deleted }) => { * console.log(deleted) * }) */ deleteVariant(productId: string, id: string, headers?: ClientHeaders, query?: SelectParams): Promise; /** * This method manages a product's variant's inventories to associate them with inventory items, * update their inventory items, or delete their association with inventory items. * * It sends a request to the * [Manage Variant Inventory](https://docs.medusajs.com/api/admin/products/manage-variants-inventory) * API route. * * @param productId - The ID of the product that the variant belongs to. * @param body - The inventory items to create, update, or delete. * @param query - Pass query parameters in the request. * @param headers - Headers to pass in the request * @returns The details of the created, updated, or deleted inventory items. * * @example * sdk.admin.product.batchVariantInventoryItems( * "prod_123", * { * create: [ * { * inventory_item_id: "iitem_123", * variant_id: "variant_123", * required_quantity: 10 * } * ], * update: [ * { * inventory_item_id: "iitem_1234", * variant_id: "variant_1234", * required_quantity: 20 * } * ], * delete: [ * { * inventory_item_id: "iitem_321", * variant_id: "variant_321" * } * ] * } * ) * .then(({ created, updated, deleted }) => { * console.log(created, updated, deleted) * }) */ batchVariantInventoryItems(productId: string, body: HttpTypes.AdminBatchProductVariantInventoryItemRequest, query?: SelectParams, headers?: ClientHeaders): Promise; /** * This method retrieves a paginated list of product options. It sends a request to the * [List Options](https://docs.medusajs.com/api/admin/products/list-options) API route. * * @param productId - The ID of the product to retrieve its options * @param query - Filters and pagination configurations. * @param headers - Headers to pass in the request. * @returns The paginated list of product options. * * @example * To retrieve the list of product options: * * ```ts * sdk.admin.product.listOptions("prod_123") * .then(({ product_options, count, limit, offset }) => { * console.log(product_options) * }) * ``` * * To configure the pagination, pass the `limit` and `offset` query parameters. * * For example, to retrieve only 10 items and skip 10 items: * * ```ts * sdk.admin.product.listOptions("prod_123", { * limit: 10, * offset: 10 * }) * .then(({ product_options, count, limit, offset }) => { * console.log(product_options) * }) * ``` * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each product options: * * ```ts * sdk.admin.product.listOptions("prod_123", { * fields: "id,title" * }) * .then(({ product_options, count, limit, offset }) => { * console.log(product_options) * }) * ``` * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store/select-fields-and-relations). */ listOptions(productId: string, query?: HttpTypes.AdminProductOptionParams, headers?: ClientHeaders): Promise; /** * This method manages image-variant associations for a specific image. It sends a request to the * [Batch Image Variants](https://docs.medusajs.com/api/admin/products/manage-variants-of-product-image) * API route. * * @since 2.11.2 * * @param productId - The product's ID. * @param imageId - The image's ID. * @param body - The variants to add or remove from the image. * @param headers - Headers to pass in the request * @returns The batch operation details. * * @example * sdk.admin.product.batchImageVariants("prod_123", "img_123", { * add: ["variant_123", "variant_456"], * remove: ["variant_789"] * }) * .then(({ added, removed }) => { * console.log(added, removed) * }) */ batchImageVariants(productId: string, imageId: string, body: HttpTypes.AdminBatchImageVariantRequest, headers?: ClientHeaders): Promise; /** * This method manages variant-image associations for a specific variant. It sends a request to the * [Batch Variant Images](https://docs.medusajs.com/api/admin/products/manage-images-of-product-variant) * API route. * * @since 2.11.2 * * @param productId - The product's ID. * @param variantId - The variant's ID. * @param body - The images to add or remove from the variant. * @param headers - Headers to pass in the request * @returns The batch operation details. * * @example * sdk.admin.product.batchVariantImages("prod_123", "variant_123", { * add: ["img_123", "img_456"], * remove: ["img_789"] * }) * .then(({ added, removed }) => { * console.log(added, removed) * }) */ batchVariantImages(productId: string, variantId: string, body: HttpTypes.AdminBatchVariantImagesRequest, headers?: ClientHeaders): Promise; /** * This method links product options to a product. It allows adding new options, * removing existing ones, or updating option values. It sends a request to the * [Batch Product Product Options](https://docs.medusajs.com/api/admin/products/add-options-to-product) * API route. * * @since 2.16.0 * * @param productId - The product's ID. * @param body - The options to add or remove. * @param query - Configure the fields to retrieve in the product. * @param headers - Headers to pass in the request * @returns The product's details. * * @example * sdk.admin.product.linkOptions("prod_123", { * add: [ * "opt_123", * { * id: "opt_123", * value_ids: ["optval_1", "optval_2"] * } * ], * remove: ["opt_456"] * }) * .then(({ product }) => { * console.log(product) * }) */ linkOptions(productId: string, body: HttpTypes.AdminLinkProductOptions, query?: SelectParams, headers?: ClientHeaders): Promise; } //# sourceMappingURL=product.d.ts.map