chore(js-sdk, types): update TSDocs related to tax provider changes (#12428)

This commit is contained in:
Shahed Nasser
2025-05-09 14:34:45 +03:00
committed by GitHub
parent 6032f3ec40
commit 0f802a977a
4 changed files with 81 additions and 3 deletions

View File

@@ -20,6 +20,8 @@ export class TaxProvider {
* This method retrieves a list of tax providers. It sends a request to the
* [List Tax Providers](https://docs.medusajs.com/api/admin#tax-providers_gettaxproviders)
* API route.
*
* @version 2.8.0
*
* @param query - Filters and pagination configurations.
* @param headers - Headers to pass in the request.
@@ -34,6 +36,34 @@ export class TaxProvider {
* console.log(tax_providers)
* })
* ```
*
* 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.taxProvider.list({
* limit: 10,
* offset: 10,
* })
* .then(({ tax_providers, count, limit, offset }) => {
* console.log(tax_providers)
* })
* ```
*
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
* in each products:
*
* ```ts
* sdk.admin.taxProvider.list({
* fields: "id,*regions"
* })
* .then(({ tax_providers, count, limit, offset }) => {
* console.log(tax_providers)
* })
* ```
*
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
*/
async list(
query?: HttpTypes.AdminGetTaxProvidersParams,

View File

@@ -66,6 +66,8 @@ export class TaxRegion {
* This method updates a tax region. It sends a request to the
* [Update Tax Region](https://docs.medusajs.com/api/admin#tax-regions_posttaxregionsid)
* API route.
*
* @version 2.8.0
*
* @param id - The ID of the tax region to update.
* @param body - The details of the tax region to update.

View File

@@ -42,7 +42,9 @@ export type ItemTaxCalculationLine = {
*
* ### Identifier Property
*
* The `identifier` property in a tax provider is used when the tax provider is loaded by the Tax Module and added to the database. A tax provider is represented in the database by the `TaxProvider` data model.
* Each tax provider has a unique identifier defined in its class. The provider's ID
* will be stored as `tp_{identifier}_{id}`, where `{id}` is the provider's `id`
* property in the `medusa-config.ts`.
*
* For example:
*

View File

@@ -584,14 +584,58 @@ export interface ITaxModuleService extends IModuleService {
/**
* This method retrieves a paginated list of tax providers based on optional filters and configuration.
*
* @version 2.8.0
*
* @param {FilterableTaxProviderProps} filters - The filters to apply on the retrieved tax providers.
* @param {FindConfig<TaxProviderDTO>} config - The configurations determining how the tax provider is retrieved.
* @param {FindConfig<TaxProviderDTO>} config - The configurations determining how the tax provider is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a tax provider.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<TaxProviderDTO[]>} The list of tax providers.
*
* @example
* const taxProviders = await taxModuleService.listTaxProviders()
* To retrieve a list of tax providers using their associated tax rate's ID:
*
* ```ts
* const taxProviders = await taxModuleService.listTaxProviders({
* id: ["tp_custom_custom"],
* })
* ```
*
* To specify relations that should be retrieved within the tax provider:
*
* :::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 taxProviders = await taxModuleService.listTaxProviders(
* {
* id: ["tp_custom_custom"],
* },
* {
* relations: ["regions"],
* }
* )
* ```
*
* 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 taxProviders = await taxModuleService.listTaxProviders(
* {
* id: ["tp_custom_custom"],
* },
* {
* relations: ["regions"],
* take: 20,
* skip: 2,
* }
* )
* ```
*/
listTaxProviders(