diff --git a/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx b/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx index 429ad2e161..61622ec318 100644 --- a/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx +++ b/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx @@ -32,7 +32,7 @@ import { } from "../../../../../hooks/api/invites" import { useUserInviteTableQuery } from "../../../../../hooks/table/query/use-user-invite-table-query" import { useDataTable } from "../../../../../hooks/use-data-table" -import { isFetchError } from "../../../../../lib/is-fetch-error.ts" +import { isFetchError } from "../../../../../lib/is-fetch-error" const InviteUserSchema = zod.object({ email: zod.string().email(), @@ -168,6 +168,7 @@ export const InviteUserForm = () => { search="autofocus" isLoading={isLoading} queryObject={raw} + prefix={PREFIX} orderBy={[ { key: "email", label: t("fields.email") }, { key: "created_at", label: t("fields.createdAt") }, diff --git a/packages/core/js-sdk/src/store/index.ts b/packages/core/js-sdk/src/store/index.ts index 87f3cc2344..64d315252e 100644 --- a/packages/core/js-sdk/src/store/index.ts +++ b/packages/core/js-sdk/src/store/index.ts @@ -1,8 +1,4 @@ -import { - FindParams, - HttpTypes, - SelectParams, -} from "@medusajs/types" +import { FindParams, HttpTypes, SelectParams } from "@medusajs/types" import { Client } from "../client" import { ClientHeaders } from "../types" @@ -21,29 +17,29 @@ export class Store { public region = { /** - * This method retrieves the paginated list of regions in the store. It sends a request to the + * This method retrieves the paginated list of regions in the store. It sends a request to the * [List Regions API route](https://docs.medusajs.com/api/store#regions_getregions). - * + * * Related guide: [How to list regions in a storefront](https://docs.medusajs.com/resources/storefront-development/regions/list). - * + * * @param query - Filters and pagination configurations. * @param headers - Headers to pass in the request * @returns The paginated list of regions. - * + * * @example * To retrieve the list of regions: - * + * * ```ts * sdk.store.region.list() * .then(({ regions, count, limit, offset }) => { * console.log(regions) * }) * ``` - * + * * To configure the pagination, pass the `limit` and `offset` query parameters. - * + * * For example, to retrieve only 10 items and skip 10 items: - * + * * ```ts * sdk.store.region.list({ * limit: 10, @@ -53,10 +49,10 @@ export class Store { * console.log(regions) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each region: - * + * * ```ts * sdk.store.region.list({ * fields: "id,*countries" @@ -65,43 +61,44 @@ export class Store { * console.log(regions) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ list: async ( query?: FindParams & HttpTypes.StoreRegionFilters, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreRegionListResponse - >(`/store/regions`, { - query, - headers, - }) + return this.client.fetch( + `/store/regions`, + { + query, + headers, + } + ) }, /** * This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/api/store#regions_getregionsid) * API route. - * + * * Related guide: [Store and retrieve regions in a storefront](https://docs.medusajs.com/resources/storefront-development/regions/store-retrieve-region). - * + * * @param id - The region's ID. * @param query - Configure the fields to retrieve in the region. * @param headers - Headers to pass in the request * @returns The region. - * + * * @example * To retrieve a region by its ID: - * + * * ```ts * sdk.store.region.retrieve("reg_123") * .then(({ region }) => { * console.log(region) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.region.retrieve( * "reg_123", @@ -113,7 +110,7 @@ export class Store { * console.log(region) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -135,27 +132,27 @@ export class Store { /** * This method retrieves a paginated list of product collections. It sends a request to the * [List Collections](https://docs.medusajs.com/api/store#collections_getcollections) API route. - * + * * Related guide: [How to retrieve collections in a storefront](https://docs.medusajs.com/resources/storefront-development/products/collections/list). - * + * * @param query - Filters and pagination configurations. * @param headers - Headers to pass in the request * @returns The paginated list of collections. - * + * * @example * To retrieve the list of collections: - * + * * ```ts * sdk.store.collection.list() * .then(({ collections, count, limit, offset }) => { * console.log(collections) * }) * ``` - * + * * To configure the pagination, pass the `limit` and `offset` query parameters. - * + * * For example, to retrieve only 10 items and skip 10 items: - * + * * ```ts * sdk.store.collection.list({ * limit: 10, @@ -165,10 +162,10 @@ export class Store { * console.log(collections) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each collection: - * + * * ```ts * sdk.store.collection.list({ * fields: "id,handle" @@ -177,43 +174,44 @@ export class Store { * console.log(collections) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ list: async ( query?: FindParams & HttpTypes.StoreCollectionFilters, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCollectionListResponse - >(`/store/collections`, { - query, - headers, - }) + return this.client.fetch( + `/store/collections`, + { + query, + headers, + } + ) }, /** * This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/api/store#collections_getcollectionsid) * API route. - * + * * Related guide: [How to retrieve a collection in a storefront](https://docs.medusajs.com/resources/storefront-development/products/collections/retrieve). - * + * * @param id - The ID of the collection to retrieve. * @param query - Configure the fields to retrieve in the collection. * @param headers - Headers to pass in the request * @returns The collection. - * + * * @example * To retrieve a collection by its ID: - * + * * ```ts * sdk.store.collection.retrieve("pcol_123") * .then(({ collection }) => { * console.log(collection) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.collection.retrieve("pcol_123", { * fields: "id,handle" @@ -222,7 +220,7 @@ export class Store { * console.log(collection) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -242,29 +240,29 @@ export class Store { public category = { /** - * This method retrieves a paginated list of product categories. It sends a request to the + * This method retrieves a paginated list of product categories. It sends a request to the * [List Categories](https://docs.medusajs.com/api/store#product-categories_getproductcategories) API route. - * + * * Related guide: [How to retrieve list of categories in the storefront](https://docs.medusajs.com/resources/storefront-development/products/categories/list). - * + * * @param query - Filters and pagination configurations. * @param headers - Headers to pass in the request. - * @returns The paginated list of categoreis. - * + * @returns The paginated list of categories. + * * @example - * To retrieve the list of categoreis: - * + * To retrieve the list of categories: + * * ```ts * sdk.store.category.list() * .then(({ product_categories, count, offset, limit }) => { * console.log(product_categories) * }) * ``` - * + * * To configure the pagination, pass the `limit` and `offset` query parameters. - * + * * For example, to retrieve only 10 items and skip 10 items: - * + * * ```ts * sdk.store.category.list({ * limit: 10, @@ -274,10 +272,10 @@ export class Store { * console.log(product_categories) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each category: - * + * * ```ts * sdk.store.category.list({ * fields: "id,*parent_category" @@ -286,43 +284,44 @@ export class Store { * console.log(product_categories) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ list: async ( query?: FindParams & HttpTypes.StoreProductCategoryListParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreProductCategoryListResponse - >(`/store/product-categories`, { - query, - headers, - }) + return this.client.fetch( + `/store/product-categories`, + { + query, + headers, + } + ) }, /** - * This method retrieves a category by its ID. It sends a request to the + * This method retrieves a category by its ID. It sends a request to the * [Retrieve Product Category](https://docs.medusajs.com/api/store#product-categories_getproductcategoriesid). - * + * * Related guide: [How to retrieve a category in the storefront](https://docs.medusajs.com/resources/storefront-development/products/categories/retrieve). - * + * * @param id - The ID of the category to retrieve. * @param query - Configure the fields to retrieve in the category. * @param headers - Headers to pass in the request * @returns The category. - * + * * @example * To retrieve a category by its ID: - * + * * ```ts * sdk.store.category.retrieve("pcat_123") * .then(({ product_category }) => { * console.log(product_category) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.category.retrieve("pcat_123", { * fields: "id,*parent_category" @@ -331,7 +330,7 @@ export class Store { * console.log(product_category) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -339,12 +338,13 @@ export class Store { query?: HttpTypes.StoreProductCategoryParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreProductCategoryResponse - >(`/store/product-categories/${id}`, { - query, - headers, - }) + return this.client.fetch( + `/store/product-categories/${id}`, + { + query, + headers, + } + ) }, } @@ -352,30 +352,30 @@ export class Store { /** * This method retrieves a list of products. It sends a request to the * [List Products API route](https://docs.medusajs.com/api/store#products_getproducts). - * + * * Related guides: - * + * * - [How to list products in a storefront](https://docs.medusajs.com/resources/storefront-development/products/list). * - [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/resources/storefront-development/products/price) - * + * * @param query - 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.store.product.list() * .then(({ products, count, offset, limit }) => { * 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.store.product.list({ * limit: 10, @@ -385,10 +385,10 @@ export class Store { * console.log(products) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each product: - * + * * ```ts * sdk.store.product.list({ * fields: "id,*collection" @@ -397,7 +397,7 @@ export class Store { * console.log(products) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ list: async ( @@ -413,31 +413,31 @@ export class Store { ) }, /** - * This method is used to retrieve a product by its ID. It sends a request to the + * This method is used to retrieve a product by its ID. It sends a request to the * [Get Product](https://docs.medusajs.com/api/store#products_getproductsid) API route. - * + * * Related guides: - * + * * - [How to retrieve a product in the storefront](https://docs.medusajs.com/resources/storefront-development/products/retrieve). * - [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/resources/storefront-development/products/price) - * + * * @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. - * + * * @example * To retrieve a product by its ID: - * + * * ```ts * sdk.store.product.retrieve("prod_123") * .then(({ product }) => { * console.log(product) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.product.retrieve("prod_123", { * fields: "id,*collection" @@ -446,7 +446,7 @@ export class Store { * console.log(product) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -471,14 +471,14 @@ export class Store { /** * This method creates a cart. It sends a request to the [Create Cart](https://docs.medusajs.com/api/store#carts_postcarts) * API route. - * + * * Related guide: [How to create a cart in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/create). - * + * * @param body - The details of the cart to create. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The created cart. - * + * * @example * sdk.store.cart.create({ * region_id: "reg_123" @@ -502,15 +502,15 @@ export class Store { /** * This method updates a cart. It sends a request to the * [Update Cart](https://docs.medusajs.com/api/store#carts_postcartsid) API route. - * + * * Related guide: [How to update a cart in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/update). - * + * * @param id - The cart's ID. * @param body - The data to update in the cart. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The updated cart. - * + * * @example * sdk.store.cart.update("cart_123", { * region_id: "reg_123" @@ -536,28 +536,28 @@ export class Store { ) }, /** - * This method retrieves a cart by its ID. It sends a request to the + * This method retrieves a cart by its ID. It sends a request to the * [Get Cart](https://docs.medusajs.com/api/store#carts_getcartsid) API route. - * + * * Related guide: [How to retrieve a cart in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/retrieve). - * + * * @param id - The cart's ID. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The cart's details. - * + * * @example * To retrieve a cart by its ID: - * + * * ```ts * sdk.store.cart.retrieve("cart_123") * .then(({ cart }) => { * console.log(cart) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.cart.retrieve("cart_123", { * fields: "id,*items" @@ -566,7 +566,7 @@ export class Store { * console.log(cart) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -585,15 +585,15 @@ export class Store { /** * This methods adds a product variant to the cart as a line item. It sends a request to the * [Add Line Item](https://docs.medusajs.com/api/store#carts_postcartsidlineitems) API route. - * + * * Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/manage-items). - * + * * @param cartId - The cart's ID. * @param body - The details of the item to add. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The cart's details. - * + * * @example * sdk.store.cart.createLineItem("cart_123", { * variant_id: "variant_123", @@ -620,21 +620,21 @@ export class Store { ) }, /** - * This method updates a line item in a cart. It sends a request to the + * This method updates a line item in a cart. It sends a request to the * [Update Line Item](https://docs.medusajs.com/api/store#carts_postcartsidlineitemsline_id) API route. - * + * * Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/manage-items). - * + * * @param cartId - The cart's ID. * @param lineItemId - The line item's ID. * @param body - The data to update. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The cart's details. - * + * * @example * sdk.store.cart.updateLineItem( - * "cart_123", + * "cart_123", * "li_123", * { * quantity: 1 @@ -664,14 +664,14 @@ export class Store { /** * This method deletes a line item from a cart. It sends a request to the * [Remove Line Item](https://docs.medusajs.com/api/store#carts_deletecartsidlineitemsline_id) API route. - * + * * Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/resources/storefront-development/cart/manage-items). - * + * * @param cartId - The cart's ID. * @param lineItemId - The item's ID. * @param headers - Headers to pass in the request. * @returns The deletion's details. - * + * * @example * sdk.store.cart.deleteLineItem( * "cart_123", @@ -695,17 +695,17 @@ export class Store { ) }, /** - * This method adds a shipping method to a cart. It sends a request to + * This method adds a shipping method to a cart. It sends a request to * the [Add Shipping Method](https://docs.medusajs.com/api/store#carts_postcartsidshippingmethods) API routes. - * + * * Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/shipping). - * + * * @param cartId - The cart's ID. * @param body - The shipping method's details. * @param query - Configure the fields to retrieve in the cart. * @param headers - Headers to pass in the request. * @returns The cart's details. - * + * * @example * sdk.store.cart.addShippingMethod("cart_123", { * option_id: "so_123", @@ -737,14 +737,14 @@ export class Store { * This method completes a cart and places the order. It's the last step of the checkout flow. * The method sends a request to the [Complete Cart](https://docs.medusajs.com/api/store#carts_postcartsidcomplete) * API route. - * + * * Related guide: [Learn how to complete cart in checkout flow](https://docs.medusajs.com/resources/storefront-development/checkout/complete-cart). - * + * * @param cartId - The cart's ID. * @param query - Configure the fields to retrieve in the created order. * @param headers - Headers to pass in the request. * @returns The order's details, if it was placed successfully. Otherwise, the cart is returned with an error. - * + * * @example * sdk.store.cart.complete("cart_123") * .then((data) => { @@ -762,13 +762,14 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCompleteCartResponse - >(`/store/carts/${cartId}/complete`, { - method: "POST", - headers, - query, - }) + return this.client.fetch( + `/store/carts/${cartId}/complete`, + { + method: "POST", + headers, + query, + } + ) }, } @@ -777,13 +778,13 @@ export class Store { * This method retrieves the list of shipping options for a cart. It sends a request to * the [List Shipping Options](https://docs.medusajs.com/api/store#shipping-options_getshippingoptions) * API route. - * + * * Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/shipping). - * + * * @param query - The cart's details along with configurations of the fields to retrieve in the options. * @param headers - Headers to pass in the request. * @returns The shipping options that can be used for the cart. - * + * * @example * sdk.store.fulfillment.listCartOptions({ * cart_id: "cart_123" @@ -796,12 +797,13 @@ export class Store { query?: HttpTypes.StoreGetShippingOptionList, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreShippingOptionListResponse - >(`/store/shipping-options`, { - headers, - query, - }) + return this.client.fetch( + `/store/shipping-options`, + { + headers, + query, + } + ) }, } @@ -810,17 +812,17 @@ export class Store { * This method retrieves the payment providers available in a region, which is useful during checkout. * It sends a request to the [List Payment Providers](https://docs.medusajs.com/api/store#payment-providers_getpaymentproviders) * API route. - * + * * Related guide: [Implement payment step during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment). - * - * @param query - The filters to apply on the retrieved providers, along with configurations of the + * + * @param query - The filters to apply on the retrieved providers, along with configurations of the * fields to retrieve in the options. * @param headers - Headers to pass in the request. * @returns The list of payment providers. - * + * * @example * To retrieve the list of payment providers for a region: - * + * * ```ts * sdk.store.payment.listPaymentProviders({ * region_id: "reg_123" @@ -829,11 +831,11 @@ export class Store { * console.log(payment_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.store.payment.listPaymentProviders({ * region_id: "reg_123", @@ -844,10 +846,10 @@ export class Store { * console.log(payment_providers) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each provider: - * + * * ```ts * sdk.store.payment.listPaymentProviders({ * region_id: "reg_123", @@ -859,38 +861,39 @@ export class Store { * console.log(payment_providers) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ listPaymentProviders: async ( query?: FindParams & HttpTypes.StorePaymentProviderFilters, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StorePaymentProviderListResponse - >(`/store/payment-providers`, { - headers, - query, - }) + return this.client.fetch( + `/store/payment-providers`, + { + headers, + query, + } + ) }, /** * This method creates a payment session of a cart's payment collection, selecting a payment provider. * It sends a request to the [Initialize Payment Session](https://docs.medusajs.com/api/store#payment-collections_postpaymentcollectionsidpaymentsessions) * API route. - * + * * If the cart doesn't have a payment collection, a payment collection is created for the cart by * sending a request to the [Create Payment Collection](https://docs.medusajs.com/api/store#payment-collections_postpaymentcollections) * API route. - * + * * Related guide: [Implement payment step during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment). - * + * * @param cart - The cart's details. * @param body - The payment session's details. * @param query - Configure the fields to retrieve in the payment collection. * @param headers - Headers to pass in the request. * @returns The payment collection's details. - * + * * @example * sdk.store.payment.initiatePaymentSession( * cart, // assuming you already have the cart object. @@ -917,24 +920,26 @@ export class Store { cart_id: cart.id, } paymentCollectionId = ( - await this.client.fetch< - HttpTypes.StorePaymentCollectionResponse - >(`/store/payment-collections`, { - method: "POST", - headers, - body: collectionBody, - }) + await this.client.fetch( + `/store/payment-collections`, + { + method: "POST", + headers, + body: collectionBody, + } + ) ).payment_collection.id } - return this.client.fetch< - HttpTypes.StorePaymentCollectionResponse - >(`/store/payment-collections/${paymentCollectionId}/payment-sessions`, { - method: "POST", - headers, - body, - query, - }) + return this.client.fetch( + `/store/payment-collections/${paymentCollectionId}/payment-sessions`, + { + method: "POST", + headers, + body, + query, + } + ) }, } @@ -943,25 +948,25 @@ export class Store { * This method retrieves a paginated list of orders matching the specified filters. It * sends a request to the [List Orders](https://docs.medusajs.com/api/store#orders_getorders) * API route. - * + * * @param query - Configure the fields to retrieve in the orders. * @param headers - Headers to pass in the request. * @returns The paginated list of orders. - * + * * @example * To retrieve the list of orders: - * + * * ```ts * sdk.store.order.list() * .then(({ orders, count, offset, limit }) => { * console.log(orders) * }) * ``` - * + * * To configure the pagination, pass the `limit` and `offset` query parameters. - * + * * For example, to retrieve only 10 items and skip 10 items: - * + * * ```ts * sdk.store.order.list({ * limit: 10, @@ -971,10 +976,10 @@ export class Store { * console.log(orders) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each order: - * + * * ```ts * sdk.store.order.list({ * fields: "id,*items" @@ -983,41 +988,42 @@ export class Store { * console.log(orders) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ list: async ( query?: HttpTypes.StoreOrderFilters, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreOrderListResponse - >(`/store/orders`, { - query, - headers, - }) + return this.client.fetch( + `/store/orders`, + { + query, + headers, + } + ) }, /** - * This method retrieves an order by its ID. It sends a request to the + * This method retrieves an order by its ID. It sends a request to the * [Get Order](https://docs.medusajs.com/api/store#orders_getordersid) API route. - * + * * @param id - The order's ID. * @param query - Configure the fields to retrieve in the order. * @param headers - Headers to pass in the request. * @returns The order's details. - * + * * @example * To retrieve an order by its ID: - * + * * ```ts * sdk.store.order.retrieve("order_123") * .then(({ order }) => { * console.log(order) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.order.retrieve("order_123", { * fields: "id,*items" @@ -1026,7 +1032,7 @@ export class Store { * console.log(order) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieve: async ( @@ -1048,23 +1054,23 @@ export class Store { /** * This method registers a customer. It sends a request to the [Register Customer](https://docs.medusajs.com/api/store#customers_postcustomers) * API route. - * + * * You must use the {@link Auth.register} method first to retrieve a registration token. Then, pass that - * registration token in the `headers` parameter of this method as an authorization bearer header. - * + * registration token in the `headers` parameter of this method as an authorization bearer header. + * * Related guide: [How to register customer in storefront](https://docs.medusajs.com/resources/storefront-development/customers/register) - * + * * @param body - The customer's details. * @param query - Configure the fields to retrieve in the customer. * @param headers - Headers to pass in the request. This is where you include the authorization JWT registration token. * @returns The customer's details. - * + * * @example * const token = await sdk.auth.register("customer", "emailpass", { * "email": "customer@gmail.com", * "password": "supersecret" * }) - * + * * sdk.store.customer.create( * { * "email": "customer@gmail.com" @@ -1083,29 +1089,30 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerResponse - >(`/store/customers`, { - method: "POST", - headers, - body, - query, - }) + return this.client.fetch( + `/store/customers`, + { + method: "POST", + headers, + body, + query, + } + ) }, /** * This method updates the logged-in customer's details. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the * [Update Customer](https://docs.medusajs.com/api/store#customers_postcustomersme) API route. - * + * * Related guide: [How to edit customer's profile in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/profile). - * + * * @param body - The customer's details to update. * @param query - Configure the fields to retrieve in the customer. * @param headers - Headers to pass in the request. * @returns The customer's details. - * + * * @example * sdk.store.customer.update({ * first_name: "John" @@ -1119,9 +1126,7 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerResponse - >( + return this.client.fetch( `/store/customers/me`, { method: "POST", @@ -1134,14 +1139,14 @@ export class Store { /** * This method retrieves the logged-in customer's details. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [Get Logged-In Customer](https://docs.medusajs.com/api/store#customers_getcustomersme) * API route. - * + * * @param query - Configure the fields to retrieve in the customer. * @param headers - Headers to pass in the request. * @returns The customer's details. - * + * * @example * sdk.store.customer.retrieve() * .then(({ customer }) => { @@ -1160,17 +1165,17 @@ export class Store { /** * This method creates an address for the logged-in customer. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [Create Address](https://docs.medusajs.com/api/store#customers_postcustomersmeaddresses) * API route. - * + * * Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/addresses) - * + * * @param body - The address's details. * @param query - Configure the fields to retrieve in the customer. * @param headers - Headers to pass in the request. * @returns The customer's details. - * + * * @example * sdk.store.customer.createAddress({ * country_code: "us" @@ -1184,30 +1189,31 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerResponse - >(`/store/customers/me/addresses`, { - method: "POST", - headers, - body, - query, - }) + return this.client.fetch( + `/store/customers/me/addresses`, + { + method: "POST", + headers, + body, + query, + } + ) }, /** * This method updates the address of the logged-in customer. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [Update Address](https://docs.medusajs.com/api/store#customers_postcustomersmeaddressesaddress_id) * API route. - * + * * Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/addresses) - * + * * @param addressId - The ID of the address to update. * @param body - The details to update in the address. * @param query - Configure the fields to retrieve in the customer. * @param headers - Headers to pass in the request. * @returns The customer's details. - * + * * @example * sdk.store.customer.updateAddress( * "caddr_123", @@ -1225,9 +1231,7 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerResponse - >( + return this.client.fetch( `/store/customers/me/addresses/${addressId}`, { method: "POST", @@ -1240,30 +1244,30 @@ export class Store { /** * This method retrieves the logged-in customer's address. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [List Customer's Address](https://docs.medusajs.com/api/store#customers_getcustomersmeaddresses) * API route. - * + * * Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/addresses) - * + * * @param query - Configure the fields to retrieve in the addresses. * @param headers - Headers to pass in the request. * @returns The paginated list of addresses. - * + * * @example * To retrieve the list of addresses: - * + * * ```ts * sdk.store.customer.listAddress() * .then(({ addresses, count, offset, limit }) => { * console.log(addresses) * }) * ``` - * + * * To configure the pagination, pass the `limit` and `offset` query parameters. - * + * * For example, to retrieve only 10 items and skip 10 items: - * + * * ```ts * sdk.store.customer.listAddress({ * limit: 10, @@ -1273,10 +1277,10 @@ export class Store { * console.log(addresses) * }) * ``` - * + * * Using the `fields` query parameter, you can specify the fields and relations to retrieve * in each address: - * + * * ```ts * sdk.store.customer.listAddress({ * fields: "id,country_code" @@ -1285,37 +1289,38 @@ export class Store { * console.log(addresses) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ listAddress: async ( query?: FindParams & HttpTypes.StoreCustomerAddressFilters, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerAddressListResponse - >(`/store/customers/me/addresses`, { - query, - headers, - }) + return this.client.fetch( + `/store/customers/me/addresses`, + { + query, + headers, + } + ) }, /** * This method retrieves an address of the logged-in customer. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [Get Address](https://docs.medusajs.com/api/store#customers_getcustomersmeaddressesaddress_id) * API route. - * + * * Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/addresses) - * + * * @param addressId - The address's ID. * @param query - Configure the fields to retrieve in the address. * @param headers - Headers to pass in the request. * @returns The address's details. - * + * * @example * To retrieve an address by its ID: - * + * * ```ts * sdk.store.customer.retrieveAddress( * "caddr_123" @@ -1324,9 +1329,9 @@ export class Store { * console.log(address) * }) * ``` - * + * * To specify the fields and relations to retrieve: - * + * * ```ts * sdk.store.customer.retrieveAddress( * "caddr_123", @@ -1338,7 +1343,7 @@ export class Store { * console.log(address) * }) * ``` - * + * * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). */ retrieveAddress: async ( @@ -1346,9 +1351,7 @@ export class Store { query?: SelectParams, headers?: ClientHeaders ) => { - return this.client.fetch< - HttpTypes.StoreCustomerAddressResponse - >( + return this.client.fetch( `/store/customers/me/addresses/${addressId}`, { query, @@ -1359,16 +1362,16 @@ export class Store { /** * This method deletes an address of the logged-in customer. The customer must be logged in * first with the {@link Auth.login} method. - * + * * It sends a request to the [Remove Address](https://docs.medusajs.com/api/store#customers_deletecustomersmeaddressesaddress_id) * API route. - * + * * Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/resources/storefront-development/customers/addresses) - * + * * @param addressId - The address's ID. * @param headers - Headers to pass in the request. * @returns The deletion's details. - * + * * @example * sdk.store.customer.deleteAddress("caddr_123") * .then(({ deleted, parent: customer }) => {