From 0a8718f0c5741ca2b0100fb4732a2726cf5830c5 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Fri, 5 Apr 2024 13:04:15 +0300 Subject: [PATCH] chore: added tsdocs to Cart Module (#6881) --- packages/types/src/cart/common.ts | 667 ++++++++++- packages/types/src/cart/mutations.ts | 582 +++++++++ packages/types/src/cart/service.ts | 1649 ++++++++++++++++++++++++++ 3 files changed, 2836 insertions(+), 62 deletions(-) diff --git a/packages/types/src/cart/common.ts b/packages/types/src/cart/common.ts index d79ff23845..100a266ac3 100644 --- a/packages/types/src/cart/common.ts +++ b/packages/types/src/cart/common.ts @@ -1,220 +1,280 @@ import { BaseFilterable } from "../dal" import { OperatorMap } from "../dal/utils" +/** + * The adjustment line details. + */ export interface AdjustmentLineDTO { /** * The ID of the adjustment line */ id: string + /** - * The code of the adjustment line + * The code of the promotion that lead to + * this adjustment. */ code?: string + /** - * The amount of the adjustment line + * The amount to adjust the original amount with. */ amount: number + /** - * The ID of the associated cart + * The ID of the associated cart. */ cart_id: string + /** - * The description of the adjustment line + * The description of the adjustment line. */ description?: string + /** - * The ID of the associated promotion + * The ID of the associated promotion. */ promotion_id?: string + /** - * The ID of the associated provider + * The ID of the associated provider. */ provider_id?: string + /** - * When the adjustment line was created + * When the adjustment line was created. */ created_at: Date | string + /** - * When the adjustment line was updated + * When the adjustment line was updated. */ updated_at: Date | string } +/** + * The shipping method adjustment details. + */ export interface ShippingMethodAdjustmentDTO extends AdjustmentLineDTO { /** - * The associated shipping method + * The associated shipping method. */ shipping_method: CartShippingMethodDTO + /** - * The ID of the associated shipping method + * The ID of the associated shipping method. */ shipping_method_id: string } +/** + * The line item adjustment details. + */ export interface LineItemAdjustmentDTO extends AdjustmentLineDTO { /** - * The associated line item + * The associated line item. + * * @expandable */ item: CartLineItemDTO + /** - * The associated line item + * The ID of the associated line item. */ item_id: string } +/** + * The tax line details. + */ export interface TaxLineDTO { /** * The ID of the tax line */ id: string + /** * The description of the tax line */ description?: string + /** - * The ID of the associated tax rate + * The ID of the associated tax rate. */ tax_rate_id?: string + /** - * The code of the tax line + * The code of the tax line. */ code: string + /** - * The rate of the tax line + * The rate of the tax line. */ rate: number + /** - * The ID of the associated provider + * The ID of the associated provider. */ provider_id?: string + /** - * When the tax line was created + * When the tax line was created. */ created_at: Date | string + /** - * When the tax line was updated + * When the tax line was updated. */ updated_at: Date | string } +/** + * The shipping method tax line details. + */ export interface ShippingMethodTaxLineDTO extends TaxLineDTO { /** - * The associated shipping method + * The associated shipping method. */ shipping_method: CartShippingMethodDTO + /** - * The ID of the associated shipping method + * The ID of the associated shipping method. */ shipping_method_id: string } +/** + * The line item tax line details. + */ export interface LineItemTaxLineDTO extends TaxLineDTO { /** - * The associated line item + * The associated line item. */ item: CartLineItemDTO + /** - * The ID of the associated line item + * The ID of the associated line item. */ item_id: string } +/** + * The cart address details. + */ export interface CartAddressDTO { /** - * The ID of the address + * The ID of the address. */ id: string + /** - * The customer ID of the address + * The customer ID of the address. */ customer_id?: string + /** - * The first name of the address + * The first name of the address. */ first_name?: string + /** - * The last name of the address + * The last name of the address. */ last_name?: string + /** - * The phone number of the address + * The phone number of the address. */ phone?: string + /** - * The company of the address + * The company of the address. */ company?: string + /** - * The first address line of the address + * The first address line of the address. */ address_1?: string + /** - * The second address line of the address + * The second address line of the address. */ address_2?: string + /** - * The city of the address + * The city of the address. */ city?: string + /** - * The country code of the address + * The country code of the address. */ country_code?: string + /** - * The province/state of the address + * The province/state of the address. */ province?: string + /** - * The postal code of the address + * The postal code of the address. */ postal_code?: string + /** * Holds custom data in key-value pairs. */ metadata?: Record | null + /** * When the address was created. */ created_at: Date | string + /** * When the address was updated. */ updated_at: Date | string } +/** + * The cart shipping method details. + */ export interface CartShippingMethodDTO { /** - * The ID of the shipping method + * The ID of the shipping method. */ id: string /** - * The ID of the associated cart + * The ID of the associated cart. */ cart_id: string /** - * The name of the shipping method + * The name of the shipping method. */ name: string + /** - * The description of the shipping method + * The description of the shipping method. */ description?: string /** - * The price of the shipping method + * The price of the shipping method. */ amount: number /** - * Whether the shipping method price is tax inclusive or not + * Whether the shipping method price is tax inclusive. */ is_tax_inclusive: boolean /** - * The ID of the shipping option the method was created from + * The ID of the shipping option the method was created from. */ shipping_option_id?: string @@ -234,6 +294,7 @@ export interface CartShippingMethodDTO { * @expandable */ tax_lines?: ShippingMethodTaxLineDTO[] + /** * The associated adjustments. * @@ -245,361 +306,843 @@ export interface CartShippingMethodDTO { * When the shipping method was created. */ created_at: Date | string + /** * When the shipping method was updated. */ updated_at: Date | string + /** + * The original total of the cart shipping method. + */ original_total: number + + /** + * The original subtotal of the cart shipping method. + */ original_subtotal: number + + /** + * The original tax total of the cart shipping method. + */ original_tax_total: number + /** + * The total of the cart shipping method. + */ total: number + + /** + * The subtotal of the cart shipping method. + */ subtotal: number + + /** + * The tax total of the cart shipping method. + */ tax_total: number + + /** + * The discount total of the cart shipping method. + */ discount_total: number + + /** + * The discount tax total of the cart shipping method. + */ discount_tax_total: number } +/** + * The cart line item totals details. + */ export interface CartLineItemTotalsDTO { + /** + * The original total of the cart line item. + */ original_total: number + + /** + * The original subtotal of the cart line item. + */ original_subtotal: number + + /** + * The original tax total of the cart line item. + */ original_tax_total: number + /** + * The item total of the cart line item. + */ item_total: number + + /** + * The item subtotal of the cart line item. + */ item_subtotal: number + + /** + * The item tax total of the cart line item. + */ item_tax_total: number + /** + * The total of the cart line item. + */ total: number + + /** + * The subtotal of the cart line item. + */ subtotal: number + + /** + * The tax total of the cart line item. + */ tax_total: number + + /** + * The discount total of the cart line item. + */ discount_total: number + + /** + * The discount tax total of the cart line item. + */ discount_tax_total: number } +/** + * The cart line item details. + */ export interface CartLineItemDTO extends CartLineItemTotalsDTO { /** * The ID of the line item. */ id: string + /** * The title of the line item. */ title: string + /** * The subtitle of the line item. */ subtitle?: string + /** - * The url of the line item thumbnail. + * The line item's thumbnail. */ thumbnail?: string + /** - * The line item quantity + * The line item's quantity in the cart. */ quantity: number + /** - * The product ID of the line item. + * The ID of the associated product. */ product_id?: string + /** - * The product title of the line item. + * The title of the associated product. */ product_title?: string + /** - * The product description of the line item. + * The description of the associated product. */ product_description?: string + /** - * The product subtitle of the line item. + * The subtitle of the associated product. */ product_subtitle?: string + /** - * The product type of the line item. + * The type of the associated product. */ product_type?: string + /** - * The product collection of the line item. + * The collection of the associated product. */ product_collection?: string + /** - * The product handle of the line item. + * The handle of the associated product. */ product_handle?: string + /** - * The variant ID of the line item. + * The associated variant's ID of the line item. */ variant_id?: string + /** - * The variant sku of the line item. + * The sku of the associated variant. */ variant_sku?: string + /** - * The variant barcode of the line item. + * The barcode of the associated variant. */ variant_barcode?: string + /** - * The variant title of the line item. + * The title of the associated variant. */ variant_title?: string + /** - * The variant option values of the line item. + * The option values of the associated variant. */ variant_option_values?: Record + /** - * Whether the line item requires shipping or not + * Whether the line item requires shipping. */ requires_shipping: boolean + /** - * Whether the line item is discountable or not + * Whether the line item is discountable. */ is_discountable: boolean + /** - * Whether the line item price is tax inclusive or not + * Whether the line item price is tax inclusive. */ is_tax_inclusive: boolean + /** - * The original price of the item before an adjustment or a sale. + * The calculated price of the line item. */ compare_at_unit_price?: number + /** - * The price of the item + * The unit price of the item. */ unit_price: number + /** * The associated tax lines. * * @expandable */ tax_lines?: LineItemTaxLineDTO[] + /** * The associated adjustments. * * @expandable */ adjustments?: LineItemAdjustmentDTO[] + /** * The associated cart. * * @expandable */ cart: CartDTO + /** * The ID of the associated cart. */ cart_id: string + /** * Holds custom data in key-value pairs. */ metadata?: Record | null + /** * When the line item was created. */ created_at?: Date + /** * When the line item was updated. */ updated_at?: Date + /** * When the line item was deleted. */ deleted_at?: Date } +/** + * The cart details. + */ export interface CartDTO { /** * The ID of the cart. */ id: string + /** * The ID of the region the cart belongs to. */ region_id?: string + /** - * The ID of the customer on the cart. + * The ID of the associated customer */ customer_id?: string + /** * The ID of the sales channel the cart belongs to. */ sales_channel_id?: string + /** - * The email of the cart. + * The email of the customer that owns the cart. */ email?: string + /** * The currency of the cart */ currency_code: string + /** * The associated shipping address. * * @expandable */ shipping_address?: CartAddressDTO + /** * The associated billing address. * * @expandable */ billing_address?: CartAddressDTO + /** * The associated line items. * * @expandable */ items?: CartLineItemDTO[] + /** * The associated shipping methods * * @expandable */ shipping_methods?: CartShippingMethodDTO[] + /** * Holds custom data in key-value pairs. */ metadata?: Record | null + /** * When the cart was created. */ created_at?: string | Date + /** * When the cart was updated. */ updated_at?: string | Date + /** + * The original item total of the cart. + */ original_item_total: number + + /** + * The original item subtotal of the cart. + */ original_item_subtotal: number + + /** + * The original item tax total of the cart. + */ original_item_tax_total: number + /** + * The item total of the cart. + */ item_total: number + + /** + * The item subtotal of the cart. + */ item_subtotal: number + + /** + * The item tax total of the cart. + */ item_tax_total: number + /** + * The original total of the cart. + */ original_total: number + + /** + * The original subtotal of the cart. + */ original_subtotal: number + + /** + * The original tax total of the cart. + */ original_tax_total: number + /** + * The total of the cart. + */ total: number + + /** + * The subtotal of the cart. + */ subtotal: number + + /** + * The tax total of the cart. + */ tax_total: number + + /** + * The discount total of the cart. + */ discount_total: number + + /** + * The raw discount total of the cart. + */ raw_discount_total: any + + /** + * The discount tax total of the cart. + */ discount_tax_total: number + /** + * The gift card total of the cart. + */ gift_card_total: number + + /** + * The gift card tax total of the cart. + */ gift_card_tax_total: number + /** + * The shipping total of the cart. + */ shipping_total: number + + /** + * The shipping subtotal of the cart. + */ shipping_subtotal: number + + /** + * The shipping tax total of the cart. + */ shipping_tax_total: number + /** + * The original shipping total of the cart. + */ original_shipping_total: number + + /** + * The original shipping subtotal of the cart. + */ original_shipping_subtotal: number + + /** + * The original shipping tax total of the cart. + */ original_shipping_tax_total: number } +/** + * The filters to apply on the retrieved carts. + */ export interface FilterableCartProps extends BaseFilterable { + /** + * The IDs to filter the carts by. + */ id?: string | string[] + /** + * Filter the carts by the ID of their associated sales channel. + */ sales_channel_id?: string | string[] | OperatorMap + + /** + * Filter the carts by the ID of their associated customer. + */ customer_id?: string | string[] | OperatorMap + + /** + * Filter the carts by the ID of their associated region. + */ region_id?: string | string[] | OperatorMap + /** + * Filter the carts by their creation date. + */ created_at?: OperatorMap + + /** + * Filter the carts by their update date. + */ updated_at?: OperatorMap } +/** + * The filters to apply on the retrieved addresss. + */ export interface FilterableAddressProps extends BaseFilterable { + /** + * The IDs to filter the addresss by. + */ id?: string | string[] } +/** + * The filters to apply on the retrieved line items. + */ export interface FilterableLineItemProps extends BaseFilterable { + /** + * The IDs to filter the line items by. + */ id?: string | string[] + + /** + * Filter the line items by the ID of their associated cart. + */ cart_id?: string | string[] + + /** + * Filter the line items by their title. + */ title?: string + + /** + * Filter the line items by the ID of their associated variant. + */ variant_id?: string | string[] + + /** + * Filter the line items by the ID of their associated product. + */ product_id?: string | string[] } +/** + * The filters to apply on the retrieved line item adjustments. + */ export interface FilterableLineItemAdjustmentProps extends BaseFilterable { + /** + * The IDs to filter the line item adjustments by. + */ id?: string | string[] + + /** + * Filter the adjustments by the ID of their associated line item. + */ item_id?: string | string[] + + /** + * Filter the line item adjustments by the ID of their associated promotion. + */ promotion_id?: string | string[] + + /** + * Filter the line item adjustments by the ID of their associated provider. + */ provider_id?: string | string[] + + /** + * Filter the adjustments by their associated line item. + */ item?: FilterableLineItemProps } + +/** + * The filters to apply on the retrieved shipping methods. + */ export interface FilterableShippingMethodProps extends BaseFilterable { + /** + * The IDs to filter the shipping methods by. + */ id?: string | string[] + + /** + * Filter the shipping methods by the ID of their associated cart. + */ cart_id?: string | string[] + + /** + * Filter the shipping methods by their name. + */ name?: string + + /** + * Filter the shipping methods by the ID of their associated shipping option. + */ shipping_option_id?: string | string[] } +/** + * The filters to apply on the retrieved shipping method adjustments. + */ export interface FilterableShippingMethodAdjustmentProps extends BaseFilterable { + /** + * The IDs to filter the shipping method adjustments by. + */ id?: string | string[] + + /** + * Filter the adjustments by the ID of their associated shipping method. + */ shipping_method_id?: string | string[] + + /** + * Filter the shipping method adjustments by the ID of their associated promotion. + */ promotion_id?: string | string[] + + /** + * Filter the shipping method adjustments by the ID of their associated provider. + */ provider_id?: string | string[] + + /** + * Filter the adjustments by their associated shipping method. + */ shipping_method?: FilterableShippingMethodProps } +/** + * The filters to apply on the retrieved line item tax lines. + */ export interface FilterableLineItemTaxLineProps extends BaseFilterable { + /** + * The IDs to filter the line item tax lines by. + */ id?: string | string[] + + /** + * Filter the line item tax lines by their description. + */ description?: string + + /** + * Filter the line item tax lines by their code. + */ code?: string | string[] + + /** + * Filter the line item tax lines by the ID of their associated tax rate. + */ tax_rate_id?: string | string[] + + /** + * Filter the line item tax lines by the ID of their associated provider. + */ provider_id?: string | string[] + + /** + * Filter the tax lines by the ID of their associated line item. + */ item_id?: string | string[] + + /** + * Filter the tax lines by their associated line item. + */ item?: FilterableLineItemProps } +/** + * The filters to apply on the retrieved shipping method tax lines. + */ export interface FilterableShippingMethodTaxLineProps extends BaseFilterable { + /** + * The IDs to filter the shipping method tax lines by. + */ id?: string | string[] + + /** + * Filter the shipping method tax lines by their description. + */ description?: string + + /** + * Filter the shipping method tax lines by their code. + */ code?: string | string[] + + /** + * Filter the shipping method tax lines by the ID of their associated tax rate. + */ tax_rate_id?: string | string[] + + /** + * Filter the shipping method tax lines by the ID of their associated provider. + */ provider_id?: string | string[] + + /** + * Filter the tax lines by the ID of their associated shipping method. + */ shipping_method_id?: string | string[] + + /** + * Filter the tax lines by their associated shipping method. + */ shipping_method?: FilterableShippingMethodProps } /** * TODO: Remove this in favor of CartDTO, when module is released + * * @deprecated Use CartDTO instead */ export type legacy_CartDTO = { + /** + * The ID of the cart. + */ id?: string + + /** + * The email of the cart. + */ email?: string + + /** + * The associated billing address's ID. + */ billing_address_id?: string + + /** + * The associated shipping address's ID. + */ shipping_address_id?: string + + /** + * The associated region's ID. + */ region_id?: string + + /** + * The associated customer's ID. + */ customer_id?: string + + /** + * The associated payment's ID. + */ payment_id?: string + + /** + * The associated date. + */ completed_at?: Date + + /** + * The associated date. + */ payment_authorized_at?: Date + + /** + * The idempotency key of the cart. + */ idempotency_key?: string + + /** + * The context of the cart. + */ context?: Record + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record + + /** + * The associated sales channel's ID. + */ sales_channel_id?: string | null + + /** + * The shipping total of the cart. + */ shipping_total?: number + + /** + * The discount total of the cart. + */ discount_total?: number + + /** + * The raw discount total of the cart. + */ raw_discount_total?: number + + /** + * The item tax total of the cart. + */ item_tax_total?: number | null + + /** + * The shipping tax total of the cart. + */ shipping_tax_total?: number | null + + /** + * The tax total of the cart. + */ tax_total?: number | null + + /** + * The refunded total of the cart. + */ refunded_total?: number + + /** + * The total of the cart. + */ total?: number + + /** + * The subtotal of the cart. + */ subtotal?: number + + /** + * The refundable amount of the cart. + */ refundable_amount?: number + + /** + * The gift card total of the cart. + */ gift_card_total?: number + + /** + * The gift card tax total of the cart. + */ gift_card_tax_total?: number } diff --git a/packages/types/src/cart/mutations.ts b/packages/types/src/cart/mutations.ts index b113edb6dc..7e1fd40c0d 100644 --- a/packages/types/src/cart/mutations.ts +++ b/packages/types/src/cart/mutations.ts @@ -1,101 +1,345 @@ import { CartDTO, CartLineItemDTO } from "./common" /** ADDRESS START */ + +/** + * The attributes in the address to be created or updated. + */ export interface UpsertAddressDTO { + /** + * The associated customer's ID. + */ customer_id?: string + + /** + * The company of the address. + */ company?: string + + /** + * The first name of the address. + */ first_name?: string + + /** + * The last name of the address. + */ last_name?: string + + /** + * The first line of the address. + */ address_1?: string + + /** + * The second line of the address. + */ address_2?: string + + /** + * The city of the address. + */ city?: string + + /** + * The ISO two country code of the address. + */ country_code?: string + + /** + * The province of the address. + */ province?: string + + /** + * The postal code of the address. + */ postal_code?: string + + /** + * The phone of the address. + */ phone?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record } +/** + * The attributes to update in the address. + */ export interface UpdateAddressDTO extends UpsertAddressDTO { + /** + * The ID of the address. + */ id: string } +/** + * The address to be created. + */ export interface CreateAddressDTO extends UpsertAddressDTO {} /** ADDRESS END */ /** CART START */ + +/** + * The cart to be created. + */ export interface CreateCartDTO { + /** + * The associated region's ID. + */ region_id?: string + + /** + * The associated customer's ID. + */ customer_id?: string + + /** + * The associated sales channel's ID. + */ sales_channel_id?: string + + /** + * The email of the customer that owns the cart. + */ email?: string + + /** + * The currency code of the cart. + */ currency_code: string + + /** + * The associated shipping address's ID. + */ shipping_address_id?: string + + /** + * The associated billing address's ID. + */ billing_address_id?: string + + /** + * The shipping address of the cart. + */ shipping_address?: CreateAddressDTO | string + + /** + * The billing address of the cart. + */ billing_address?: CreateAddressDTO | string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record + /** + * The items of the cart. + */ items?: CreateLineItemDTO[] } +/** + * The attributes to update in the cart data. + */ export interface UpdateCartDataDTO { + /** + * The associated region's ID. + */ region_id?: string + + /** + * The associated customer's ID. + */ customer_id?: string | null + + /** + * The associated sales channel's ID. + */ sales_channel_id?: string | null + /** + * The email of the customer that owns the cart. + */ email?: string | null + + /** + * The currency code of the cart. + */ currency_code?: string + /** + * The associated shipping address's ID. + */ shipping_address_id?: string | null + + /** + * The associated billing address's ID. + */ billing_address_id?: string | null + /** + * The billing address of the cart. + */ billing_address?: CreateAddressDTO | UpdateAddressDTO | null + + /** + * The shipping address of the cart. + */ shipping_address?: CreateAddressDTO | UpdateAddressDTO | null + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the cart. + */ export interface UpdateCartDTO extends UpdateCartDataDTO { + /** + * The ID of the cart. + */ id: string } /** CART END */ /** ADJUSTMENT START */ + +/** + * The adjustment to be created. + */ export interface CreateAdjustmentDTO { + /** + * The code of the promotion that lead to + * this adjustment. + */ code: string + + /** + * The amount to adjust the original amount with. + */ amount: number + + /** + * The description of the adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The attributes to update in the adjustment. + */ export interface UpdateAdjustmentDTO { + /** + * The ID of the adjustment. + */ id: string + + /** + * The code of the promotion that lead to + * this adjustment. + */ code?: string + + /** + * The amount to adjust the original amount with. + */ amount: number + + /** + * The description of the adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The line item adjustment to be created. + */ export interface CreateLineItemAdjustmentDTO extends CreateAdjustmentDTO { + /** + * The associated item's ID. + */ item_id: string } +/** + * The attributes to update in the line item adjustment. + */ export interface UpdateLineItemAdjustmentDTO extends UpdateAdjustmentDTO { + /** + * The associated item's ID. + */ item_id: string } +/** + * The attributes in the line item adjustment to be created or updated. + */ export interface UpsertLineItemAdjustmentDTO { + /** + * The ID of the line item adjustment. + */ id?: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The code of the promotion that lead to the + * adjustment. + */ code?: string + + /** + * The amount to adjust the original amount with. + */ amount?: number + + /** + * The description of the line item adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } @@ -103,95 +347,305 @@ export interface UpsertLineItemAdjustmentDTO { /** TAX LINES START */ +/** + * The tax line to be created. + */ export interface CreateTaxLineDTO { + /** + * The description of the tax line. + */ description?: string + + /** + * The associated tax rate's ID. + */ tax_rate_id?: string + + /** + * The code of the tax line. + */ code: string + + /** + * The rate of the tax line. + */ rate: number + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The attributes to update in the tax line. + */ export interface UpdateTaxLineDTO { + /** + * The ID of the tax line. + */ id: string + + /** + * The description of the tax line. + */ description?: string + + /** + * The associated tax rate's ID. + */ tax_rate_id?: string + + /** + * The code of the tax line. + */ code?: string + + /** + * The rate of the tax line. + */ rate?: number + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The shipping method tax line to be created. + */ export interface CreateShippingMethodTaxLineDTO extends CreateTaxLineDTO {} +/** + * The attributes to update in the shipping method tax line. + */ export interface UpdateShippingMethodTaxLineDTO extends UpdateTaxLineDTO {} +/** + * The line item tax line to be created. + */ export interface CreateLineItemTaxLineDTO extends CreateTaxLineDTO {} +/** + * The attributes to update in the line item tax line. + */ export interface UpdateLineItemTaxLineDTO extends UpdateTaxLineDTO {} /** TAX LINES END */ /** LINE ITEMS START */ + +/** + * The line item to be created. + */ export interface CreateLineItemDTO { + /** + * The title of the line item. + */ title: string + + /** + * The subtitle of the line item. + */ subtitle?: string + + /** + * The thumbnail of the line item. + */ thumbnail?: string + /** + * The associated cart's ID. + */ cart_id?: string + /** + * The quantity of the line item in the cart. + */ quantity: number + /** + * The associated product's ID. + */ product_id?: string + + /** + * The title of the associated product. + */ product_title?: string + + /** + * The description of the associated product. + */ product_description?: string + + /** + * The subtitle of the associated product. + */ product_subtitle?: string + + /** + * The type of the associated product. + */ product_type?: string + + /** + * The collection of the associated product. + */ product_collection?: string + + /** + * The handle of the associated product. + */ product_handle?: string + /** + * The associated variant's ID. + */ variant_id?: string + + /** + * The SKU of the associated variant. + */ variant_sku?: string + + /** + * The barcode of the associated variant. + */ variant_barcode?: string + + /** + * The title of the associated variant. + */ variant_title?: string + + /** + * The option values of the associated variant. + */ variant_option_values?: Record + /** + * Whether the line item requires shipping. + */ requires_shipping?: boolean + + /** + * Whether the line item is discountable. + */ is_discountable?: boolean + + /** + * Whether the line item's amount is tax inclusive. + */ is_tax_inclusive?: boolean + /** + * The calculated price of the line item after applying promotions. + */ compare_at_unit_price?: number + + /** + * The unit price of the line item. + */ unit_price: number | string + /** + * The tax lines of the line item. + */ tax_lines?: CreateTaxLineDTO[] + + /** + * The adjustments of the line item. + */ adjustments?: CreateAdjustmentDTO[] } +/** + * The line item to be created in a cart. + */ export interface CreateLineItemForCartDTO extends CreateLineItemDTO { + /** + * The associated cart's ID. + */ cart_id: string } +/** + * A pair of selectors and data, where the selectors determine which + * line items to update, and the data determines what to update + * in the line items. + */ export interface UpdateLineItemWithSelectorDTO { + /** + * Filters to specify which line items to update. + */ selector: Partial + + /** + * The attributes to update in the line items. + */ data: Partial } +/** + * A pair of selectors and data, where the selectors determine which + * carts to update, and the data determines what to update + * in the carts. + */ export interface UpdateCartWithSelectorDTO { + /** + * Filters to specify which carts to update. + */ selector: Partial + + /** + * The attributes to update in the carts. + */ data: UpdateCartDataDTO } +/** + * The attributes to update in a line item. + */ export interface UpdateLineItemDTO extends Omit< CreateLineItemDTO, "tax_lines" | "adjustments" | "title" | "quantity" | "unit_price" > { + /** + * The ID of the line item. + */ id: string + /** + * The title of the line item. + */ title?: string + + /** + * The quantity of the line item in the cart. + */ quantity?: number + + /** + * The unit price of the line item. + */ unit_price?: number + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + /** + * The tax lines of the line item. + */ tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[] + + /** + * The adjustments of the line item. + */ adjustments?: UpdateAdjustmentDTO[] | CreateAdjustmentDTO[] } @@ -199,47 +653,175 @@ export interface UpdateLineItemDTO /** SHIPPING METHODS START */ +/** + * The shipping method to be created. + */ export interface CreateShippingMethodDTO { + /** + * The name of the shipping method. + */ name: string + + /** + * The associated cart's ID. + */ cart_id: string + + /** + * The amount of the shipping method. + */ amount: number + + /** + * The data of the shipping method. + */ data?: Record + + /** + * The tax lines of the shipping method. + */ tax_lines?: CreateTaxLineDTO[] + + /** + * The adjustments of the shipping method. + */ adjustments?: CreateAdjustmentDTO[] } +/** + * The shipping method to be created in a cart. + */ export interface CreateShippingMethodForSingleCartDTO { + /** + * The name of the shipping method. + */ name: string + + /** + * The amount of the shipping method. + */ amount: number + + /** + * The data of the shipping method. + */ data?: Record + + /** + * The tax lines of the shipping method. + */ tax_lines?: CreateTaxLineDTO[] + + /** + * The adjustments of the shipping method. + */ adjustments?: CreateAdjustmentDTO[] } +/** + * The attributes to update in the shipping method. + */ export interface UpdateShippingMethodDTO { + /** + * The ID of the shipping method. + */ id: string + + /** + * The name of the shipping method. + */ name?: string + + /** + * The amount of the shipping method. + */ amount?: number + + /** + * The data of the shipping method. + */ data?: Record + + /** + * The tax lines of the shipping method. + */ tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[] + + /** + * The adjustments of the shipping method. + */ adjustments?: CreateAdjustmentDTO[] | UpdateAdjustmentDTO[] } +/** + * The shipping method adjustment to be created. + */ export interface CreateShippingMethodAdjustmentDTO { + /** + * The associated shipping method's ID. + */ shipping_method_id: string + + /** + * The code of the promotion that lead to + * this adjustment. + */ code: string + + /** + * The amount to adjust the original amount with. + */ amount: number + + /** + * The description of the shipping method adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The attributes to update in the shipping method adjustment. + */ export interface UpdateShippingMethodAdjustmentDTO { + /** + * The ID of the shipping method adjustment. + */ id: string + + /** + * The code of the promotion that lead to + * this adjustment. + */ code?: string + + /** + * The amount to adjust the original amount with. + */ amount?: number + + /** + * The description of the shipping method adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } diff --git a/packages/types/src/cart/service.ts b/packages/types/src/cart/service.ts index e1394969a7..5989412ddb 100644 --- a/packages/types/src/cart/service.ts +++ b/packages/types/src/cart/service.ts @@ -42,163 +42,1108 @@ import { UpsertLineItemAdjustmentDTO, } from "./mutations" +/** + * The main service interface for the Cart Module. + */ export interface ICartModuleService extends IModuleService { + /** + * This method retrieves a cart by its ID. + * + * @param {string} cartId - The cart's ID. + * @param {FindConfig} config - The configurations determining how the cart is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved cart. + * + * @example + * A simple example that retrieves a cart by its ID: + * + * ```ts + * const cart = await cartModuleService.retrieve("cart_123") + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const cart = await cartModuleService.retrieve("cart_123", { + * relations: ["shipping_address"], + * }) + * ``` + */ retrieve( cartId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of carts based on optional filters and configuration. + * + * @param {FilterableCartProps} filters - The filters to apply on the retrieved carts. + * @param {FindConfig} config - The configurations determining how the cart is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of carts. + * + * @example + * To retrieve a list of carts using their IDs: + * + * ```ts + * const carts = await cartModuleService.list({ + * id: ["cart_123", "cart_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the carts: + * + * ```ts + * const carts = await cartModuleService.list( + * { + * id: ["cart_123", "cart_321"], + * }, + * { + * relations: ["shipping_address"], + * } + * ) + * ``` + * + * 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 carts = await cartModuleService.list( + * { + * id: ["cart_123", "cart_321"], + * }, + * { + * relations: ["shipping_address"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ list( filters?: FilterableCartProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of carts along with the total count of available carts satisfying the provided filters. + * + * @param {FilterableCartProps} filters - The filters to apply on the retrieved carts. + * @param {FindConfig} config - The configurations determining how the cart is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[CartDTO[], number]>} The list of carts along with their total count. + * + * @example + * To retrieve a list of carts using their IDs: + * + * ```ts + * const [carts, count] = await cartModuleService.listAndCount({ + * id: ["cart_123", "cart_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the carts: + * + * ```ts + * const [carts, count] = await cartModuleService.listAndCount( + * { + * id: ["cart_123", "cart_321"], + * }, + * { + * relations: ["shipping_address"], + * } + * ) + * ``` + * + * 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 [carts, count] = await cartModuleService.listAndCount( + * { + * id: ["cart_123", "cart_321"], + * }, + * { + * relations: ["shipping_address"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listAndCount( filters?: FilterableCartProps, config?: FindConfig, sharedContext?: Context ): Promise<[CartDTO[], number]> + /** + * This method creates carts. + * + * @param {CreateCartDTO[]} data - The carts to be created. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The created carts. + * + * @example + * const carts = await cartModuleService.create([ + * { + * currency_code: "usd", + * }, + * { + * currency_code: "eur", + * }, + * ]) + */ create(data: CreateCartDTO[], sharedContext?: Context): Promise + + /** + * This method creates a cart. + * + * @param {CreateCartDTO} data - The cart to be created. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The created cart. + * + * @example + * const cart = await cartModuleService.create({ + * currency_code: "usd", + * }) + */ create(data: CreateCartDTO, sharedContext?: Context): Promise + /** + * This method updates existing carts. + * + * @param {UpdateCartDTO[]} data - The attributes to update in the carts. + * @returns {Promise} The updated carts. + * + * @example + * const carts = await cartModuleService.update([ + * { + * id: "cart_123", + * region_id: "reg_123", + * }, + * { + * id: "cart_321", + * customer_id: "cus_123", + * }, + * ]) + */ update(data: UpdateCartDTO[]): Promise + + /** + * This method updates an existing cart. + * + * @param {string} cartId - The cart's ID. + * @param {UpdateCartDataDTO} data - The attributes to update in the cart data. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated cart. + * + * @example + * const cart = await cartModuleService.update("cart_123", { + * region_id: "reg_123", + * }) + */ update( cartId: string, data: UpdateCartDataDTO, sharedContext?: Context ): Promise + + /** + * This method updates existing carts matching the specified filters. + * + * @param {Partial} selector - The filters that specify which carts to update. + * @param {UpdateCartDataDTO} data - The attributes to update in the carts. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated carts. + * + * @example + * const carts = await cartModuleService.update( + * { + * currency_code: "usd", + * }, + * { + * region_id: "reg_123", + * } + * ) + */ update( selector: Partial, data: UpdateCartDataDTO, sharedContext?: Context ): Promise + /** + * This method deletes carts by their IDs. + * + * @param {string[]} cartIds - The list of cart IDs. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the carts are deleted successfully. + * + * @example + * await cartModuleService.delete(["cart_123", "cart_321"]) + */ delete(cartIds: string[], sharedContext?: Context): Promise + + /** + * This method deletes a cart by its ID. + * + * @param {string} cartId - The cart's ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the carts are deleted successfully. + * + * @example + * await cartModuleService.delete("cart_123") + */ delete(cartId: string, sharedContext?: Context): Promise + /** + * This method retrieves a paginated list of addresses based on optional filters and configuration. + * + * @param {FilterableAddressProps} filters - The filters to apply on the retrieved addresss. + * @param {FindConfig} config - The configurations determining how the address is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a address. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of addresses. + * + * @example + * To retrieve a list of addresses using their IDs: + * + * ```ts + * const addresses = await cartModuleService.listAddresses({ + * id: ["caaddr_123", "caaddr_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 addresses = await cartModuleService.listAddresses( + * { + * id: ["caaddr_123", "caaddr_321"], + * }, + * { + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listAddresses( filters?: FilterableAddressProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method creates addresses. + * + * @param {CreateAddressDTO[]} data - The addresss to be created. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The created addresses. + * + * @example + * const addresses = await cartModuleService.createAddresses([ + * { + * address_1: "412 E Cheyenne Rd", + * country_code: "us", + * }, + * { + * first_name: "Genevieve", + * last_name: "Fox", + * address_1: "17350 Northwest Fwy", + * country_code: "us", + * }, + * ]) + */ createAddresses( data: CreateAddressDTO[], sharedContext?: Context ): Promise + + /** + * This method creates a address. + * + * @param {CreateAddressDTO} data - The address to be created. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The created address. + * + * @example + * const address = await cartModuleService.createAddresses({ + * first_name: "Genevieve", + * last_name: "Fox", + * address_1: "17350 Northwest Fwy", + * country_code: "us", + * }) + */ createAddresses( data: CreateAddressDTO, sharedContext?: Context ): Promise + /** + * This method updates existing addresses. + * + * @param {UpdateAddressDTO[]} data - The attributes to update in the addresss. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated addresses. + * + * @example + * const addresses = await cartModuleService.updateAddresses([ + * { + * id: "caaddr_123", + * first_name: "Leroy", + * }, + * { + * id: "caaddr_321", + * last_name: "Hunt", + * }, + * ]) + */ updateAddresses( data: UpdateAddressDTO[], sharedContext?: Context ): Promise + + /** + * This method updates an existing address. + * + * @param {UpdateAddressDTO} data - The attributes to update in the address. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated address. + * + * @example + * const address = await cartModuleService.updateAddresses({ + * id: "caaddr_123", + * first_name: "Leroy", + * }) + */ updateAddresses( data: UpdateAddressDTO, sharedContext?: Context ): Promise + /** + * This method deletes addresses by their IDs. + * + * @param {string[]} ids - The IDs of the cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the addresses are deleted successfully. + * + * @example + * await cartModuleService.deleteAddresses([ + * "caaddr_123", + * "caaddr_321", + * ]) + */ deleteAddresses(ids: string[], sharedContext?: Context): Promise + + /** + * This method deletes an address by its ID. + * + * @param {string} ids - The IDs of the cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the address are deleted successfully. + * + * @example + * await cartModuleService.deleteAddresses("caaddr_123") + */ deleteAddresses(ids: string, sharedContext?: Context): Promise + /** + * This method retrieves a line item by its ID. + * + * @param {string} itemId - The item's ID. + * @param {FindConfig} config - The configurations determining how the line item is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a line item. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved line item. + * + * @example + * A simple example that retrieves a line item by its ID: + * + * ```ts + * const lineItem = + * await cartModuleService.retrieveLineItem("cali_123") + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const lineItem = await cartModuleService.retrieveLineItem( + * "cali_123", + * { + * relations: ["cart"], + * } + * ) + * ``` + */ retrieveLineItem( itemId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of line items based on optional filters and configuration. + * + * @param {FilterableLineItemProps} filters - The filters to apply on the retrieved line items. + * @param {FindConfig} config - The configurations determining how the line item is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a line item. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of line items. + * + * @example + * To retrieve a list of line items using their IDs: + * + * ```ts + * const lineItems = await cartModuleService.listLineItems({ + * id: ["cali_123", "cali_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the line items: + * + * ```ts + * const lineItems = await cartModuleService.listLineItems( + * { + * id: ["cali_123", "cali_321"], + * }, + * { + * relations: ["cart"], + * } + * ) + * ``` + * + * 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 lineItems = await cartModuleService.listLineItems( + * { + * id: ["cali_123", "cali_321"], + * }, + * { + * relations: ["cart"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listLineItems( filters: FilterableLineItemProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method adds a line item to a cart + * + * @param {CreateLineItemForCartDTO} data - The line item to create and add to the cart. + * The cart is specified in the `cart_id` field. + * @returns {Promise} The added line item. + * + * @example + * const lineItem = await cartModuleService.addLineItems({ + * cart_id: "cart_123", + * title: "Shirt", + * quantity: 2, + * unit_price: 4000, + * }) + */ addLineItems(data: CreateLineItemForCartDTO): Promise + + /** + * This method adds line items to carts. + * + * @param {CreateLineItemForCartDTO[]} data - The line item to create and add to the carts. + * The cart is specified in the `cart_id` field. + * @returns {Promise} The added line items. + * + * @example + * const lineItems = await cartModuleService.addLineItems([ + * { + * cart_id: "cart_123", + * title: "Shirt", + * quantity: 2, + * unit_price: 4000, + * }, + * { + * cart_id: "cart_123", + * title: "Pants", + * quantity: 1, + * unit_price: 3000, + * }, + * ]) + */ addLineItems(data: CreateLineItemForCartDTO[]): Promise + + /** + * This method adds line items to a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateLineItemDTO[]} items - The line items to be created and added. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added line items. + * + * @example + * const lineItems = await cartModuleService.addLineItems( + * "cart_123", + * [ + * { + * title: "Shirt", + * quantity: 2, + * unit_price: 4000, + * }, + * { + * title: "Pants", + * quantity: 1, + * unit_price: 3000, + * }, + * ] + * ) + */ addLineItems( cartId: string, items: CreateLineItemDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing line items. + * + * @param {UpdateLineItemWithSelectorDTO[]} data - A list of objects, each holding the filters that specify which items + * to update, and the attributes to update in the items. + * @returns {Promise} The updated line items. + * + * @example + * const lineItems = await cartModuleService.updateLineItems([ + * { + * selector: { + * id: "cali_123", + * }, + * data: { + * quantity: 2, + * }, + * }, + * { + * selector: { + * variant_sku: "PANTS", + * }, + * data: { + * unit_price: 3000, + * }, + * }, + * ]) + */ updateLineItems( data: UpdateLineItemWithSelectorDTO[] ): Promise + + /** + * This method updates existing line items matching the specified filters. + * + * @param {Partial} selector - The filters that specify which line items to update. + * @param {Partial} data - The attributes to update in the line items. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated line items. + * + * @example + * const lineItems = await cartModuleService.updateLineItems( + * { + * variant_sku: "PANTS", + * }, + * { + * unit_price: 4000, + * } + * ) + */ updateLineItems( selector: Partial, data: Partial, sharedContext?: Context ): Promise + + /** + * This method updates an existing line item. + * + * @param {string} lineId - The line item's ID. + * @param {Partial} data - The attributes to update in the line item. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated line item. + * + * @example + * const lineItem = await cartModuleService.updateLineItems( + * "cali_123", + * { + * unit_price: 3000, + * } + * ) + */ updateLineItems( lineId: string, data: Partial, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of shipping methods based on optional filters and configuration. + * + * @param {FilterableShippingMethodProps} filters - The filters to apply on the retrieved shipping methods. + * @param {FindConfig} config - The configurations determining how the shipping method is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a shipping method. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of shipping methods. + * + * @example + * To retrieve a list of shipping methods using their IDs: + * + * ```ts + * const shippingMethods = + * await cartModuleService.listShippingMethods( + * { + * id: ["casm_123", "casm_321"], + * }, + * {} + * ) + * ``` + * + * To specify relations that should be retrieved within the shipping methods: + * + * ```ts + * const shippingMethods = + * await cartModuleService.listShippingMethods( + * { + * id: ["casm_123", "casm_321"], + * }, + * { + * relations: ["cart"], + * } + * ) + * ``` + * + * 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 shippingMethods = + * await cartModuleService.listShippingMethods( + * { + * id: ["casm_123", "casm_321"], + * }, + * { + * relations: ["cart"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listShippingMethods( filters: FilterableShippingMethodProps, config: FindConfig, sharedContext?: Context ): Promise + /** + * This method adds a shipping method to carts. + * + * @param {CreateShippingMethodDTO} data - The shipping method to be created and added to the carts. + * The cart is specified in the `cart_id` field. + * @returns {Promise} The added shipping method. + * + * @example + * const shippingMethod = + * await cartModuleService.addShippingMethods({ + * cart_id: "cart_123", + * name: "UPS", + * amount: 3000, + * }) + */ addShippingMethods( data: CreateShippingMethodDTO ): Promise + + /** + * This method adds shipping methods to carts. + * + * @param {CreateShippingMethodDTO[]} data - The shipping methods to be created and added to the carts. + * The cart is specified in the `cart_id` field. + * @returns {Promise} The added shipping methods. + * + * @example + * const shippingMethods = + * await cartModuleService.addShippingMethods([ + * { + * cart_id: "cart_123", + * name: "UPS", + * amount: 3000, + * }, + * { + * cart_id: "cart_123", + * name: "FedEx", + * amount: 2000, + * }, + * ]) + */ addShippingMethods( data: CreateShippingMethodDTO[] ): Promise + + /** + * This method adds shipping methods to a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateShippingMethodForSingleCartDTO[]} methods - The shipping methods to be created and added. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added shipping methods. + * + * @example + * const shippingMethods = + * await cartModuleService.addShippingMethods("cart_123", [ + * { + * name: "UPS", + * amount: 3000, + * }, + * { + * name: "FedEx", + * amount: 2000, + * }, + * ]) + */ addShippingMethods( cartId: string, methods: CreateShippingMethodForSingleCartDTO[], sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of line item adjustments based on optional filters and configuration. + * + * @param {FilterableLineItemAdjustmentProps} filters - The filters to apply on the retrieved line item adjustments. + * @param {FindConfig} config - The configurations determining how the line item adjustment is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a line item adjustment. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of line item adjustments. + * + * @example + * To retrieve a list of line item adjustments using their IDs: + * + * ```ts + * const lineItemAdjustments = + * await cartModuleService.listLineItemAdjustments({ + * id: ["caliadj_123", "caliadj_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the line item adjustments: + * + * ```ts + * const lineItemAdjustments = + * await cartModuleService.listLineItemAdjustments( + * { + * id: ["caliadj_123", "caliadj_321"], + * }, + * { + * relations: ["item"], + * } + * ) + * ``` + * + * 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 lineItemAdjustments = + * await cartModuleService.listLineItemAdjustments( + * { + * id: ["caliadj_123", "caliadj_321"], + * }, + * { + * relations: ["item"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listLineItemAdjustments( filters: FilterableLineItemAdjustmentProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method adds line item adjustments to line items. + * + * @param {CreateLineItemAdjustmentDTO[]} data - The line item adjustments to be created and added to line items. + * The line item is specified by the `item_id` field. + * @returns {Promise} The added line item adjustments. + * + * @example + * const lineItemAdjustments = + * await cartModuleService.addLineItemAdjustments([ + * { + * item_id: "caliadj_123", + * code: "50%OFF", + * amount: 3000, + * }, + * { + * item_id: "caliadj_321", + * code: "10%OFF", + * amount: 3000, + * }, + * ]) + */ addLineItemAdjustments( data: CreateLineItemAdjustmentDTO[] ): Promise + + /** + * This method adds a line item adjustment to a line item. + * + * @param {CreateLineItemAdjustmentDTO} data - The line item adjustment to be created and added to a line item. + * The line item is specified by the `item_id` field. + * @returns {Promise} The added line item adjustment. + * + * @example + * const lineItemAdjustments = + * await cartModuleService.addLineItemAdjustments({ + * item_id: "caliadj_123", + * code: "50%OFF", + * amount: 3000, + * }) + */ addLineItemAdjustments( data: CreateLineItemAdjustmentDTO ): Promise + + /** + * This method adds line item adjustments to line items in a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateLineItemAdjustmentDTO[]} data - The line item adjustments to be created and added to line items. + * The line item is specified by the `item_id` field. + * @returns {Promise} The added line item adjustment. + * + * @example + * const lineItemAdjustments = + * await cartModuleService.addLineItemAdjustments("cart_123", [ + * { + * item_id: "caliadj_123", + * code: "50%OFF", + * amount: 3000, + * }, + * { + * item_id: "caliadj_321", + * code: "10%OFF", + * amount: 2000, + * }, + * ]) + */ addLineItemAdjustments( cartId: string, data: CreateLineItemAdjustmentDTO[] ): Promise + /** + * This method set the line item adjustments of line items in a cart. The existing line item adjustments, except those + * included in the specified list, of an item are removed and replaced with the specified adjustments. + * + * @param {string} cartId - The cart's ID. + * @param {UpsertLineItemAdjustmentDTO[]} data - The line item adjustments to add to the line items. + * The line item is specified by the `item_id` field. If the `id` field is specified, the adjustment + * is kept in the line item's adjustment and its attributes can be updated. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added line item adjustments. + * + * @example + * const lineItemAdjustments = + * await cartModuleService.setLineItemAdjustments("cart_123", [ + * { + * id: "adj_123", + * item_id: "caliadj_123", + * }, + * { + * item_id: "caliadj_123", + * code: "10%OFF", + * amount: 2000, + * }, + * { + * item_id: "caliadj_321", + * code: "50%OFF", + * amount: 3000, + * }, + * ]) + */ setLineItemAdjustments( cartId: string, data: UpsertLineItemAdjustmentDTO[], sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of shipping method adjustments based on optional filters and configuration. + * + * @param {FilterableShippingMethodAdjustmentProps} filters - The filters to apply on the retrieved shipping method adjustments. + * @param {FindConfig} config - The configurations determining how the shipping method adjustment is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a shipping method adjustment. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of shipping method adjustments. + * + * @example + * To retrieve a list of shipping method adjustments using their IDs: + * + * ```ts + * const shippingMethodAdjustments = + * await cartModuleService.listShippingMethodAdjustments({ + * id: ["casmadj_123", "casmadj_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the shipping method adjustments: + * + * ```ts + * const shippingMethodAdjustments = + * await cartModuleService.listShippingMethodAdjustments( + * { + * id: ["casmadj_123", "casmadj_321"], + * }, + * { + * relations: ["shipping_method"], + * } + * ) + * ``` + * + * 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 shippingMethodAdjustments = + * await cartModuleService.listShippingMethodAdjustments( + * { + * id: ["casmadj_123", "casmadj_321"], + * }, + * { + * relations: ["shipping_method"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listShippingMethodAdjustments( filters: FilterableShippingMethodAdjustmentProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method adds shipping method adjustments to shipping methods. + * + * @param {CreateShippingMethodAdjustmentDTO[]} data - The shipping method adjustments to be created and added to + * shipping methods. The shipping method is specified by the `shipping_method_id` field. + * @returns {Promise} The added shipping method adjustments. + * + * @example + * const shippingMethodAdjustments = + * await cartModuleService.addShippingMethodAdjustments([ + * { + * shipping_method_id: "casm_123", + * code: "FREESHIPPING", + * amount: 3000, + * }, + * { + * shipping_method_id: "casm_321", + * code: "10%OFF", + * amount: 1500, + * }, + * ]) + */ addShippingMethodAdjustments( data: CreateShippingMethodAdjustmentDTO[] ): Promise + + /** + * This method adds a shipping method adjustment to a shipping method. + * + * @param {CreateShippingMethodAdjustmentDTO} data - The shipping method adjustment to be created and added to a + * shipping method. The shipping method is specified by the `shipping_method_id` field. + * @returns {Promise} The added shipping method adjustment. + * + * @example + * const shippingMethodAdjustment = + * await cartModuleService.addShippingMethodAdjustments({ + * shipping_method_id: "casm_123", + * code: "FREESHIPPING", + * amount: 3000, + * }) + */ addShippingMethodAdjustments( data: CreateShippingMethodAdjustmentDTO ): Promise + + /** + * This method adds shipping method adjustments to shipping methods in a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateShippingMethodAdjustmentDTO[]} data - The shipping method adjustments to be created and added to + * shipping methods. The shipping method is specified by the `shipping_method_id` field. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added shipping method adjustments. + * + * @example + * const shippingMethodAdjustments = + * await cartModuleService.addShippingMethodAdjustments( + * "cart_123", + * [ + * { + * shipping_method_id: "casm_123", + * code: "FREESHIPPING", + * amount: 3000, + * }, + * { + * shipping_method_id: "casm_321", + * code: "10%OFF", + * amount: 1500, + * }, + * ] + * ) + */ addShippingMethodAdjustments( cartId: string, data: CreateShippingMethodAdjustmentDTO[], sharedContext?: Context ): Promise + /** + * This method sets the shipping method adjustment of shipping methods in a cart. The existing shipping method adjustments, + * except those included in the specified list, of an item are removed and replaced with the specified adjustments. + * + * @param {string} cartId - The cart's ID. + * @param {(CreateShippingMethodAdjustmentDTO | UpdateShippingMethodAdjustmentDTO)[]} data - The shipping method adjustments to add to the shipping + * method. If the `id` field is specified, the adjustment is kept in the shipping method's adjustment and its attributes can be updated. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added shipping method adjustments. + * + * @example + * const shippingMethodAdjustments = + * await cartModuleService.setShippingMethodAdjustments( + * "cart_123", + * [ + * { + * id: "casmadj_123", + * shipping_method_id: "casm_123", + * code: "FREESHIPPING", + * }, + * { + * shipping_method_id: "casm_321", + * code: "10%OFF", + * amount: 1500, + * }, + * ] + * ) + */ setShippingMethodAdjustments( cartId: string, data: ( @@ -208,48 +1153,304 @@ export interface ICartModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of line item tax lines based on optional filters and configuration. + * + * @param {FilterableLineItemTaxLineProps} filters - The filters to apply on the retrieved line item tax lines. + * @param {FindConfig} config - The configurations determining how the line item tax line is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a line item tax line. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of line item tax lines. + * + * @example + * To retrieve a list of line item tax lines using their IDs: + * + * ```ts + * const lineItemTaxLines = + * await cartModuleService.listLineItemTaxLines({ + * id: ["calitxl_123", "calitxl_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the line item tax lines: + * + * ```ts + * const lineItemTaxLines = + * await cartModuleService.listLineItemTaxLines( + * { + * id: ["calitxl_123", "calitxl_321"], + * }, + * { + * relations: ["item"], + * } + * ) + * ``` + * + * 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 lineItemTaxLines = + * await cartModuleService.listLineItemTaxLines( + * { + * id: ["calitxl_123", "calitxl_321"], + * }, + * { + * relations: ["item"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listLineItemTaxLines( filters: FilterableLineItemTaxLineProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method creates and adds line item tax lines. + * + * @param {CreateLineItemTaxLineDTO[]} taxLines - The line item tax lines to be created. + * @returns {Promise} The added line item tax lines. + * + * @example + * const lineItemTaxLines = + * await cartModuleService.addLineItemTaxLines([ + * { + * code: "1000", + * rate: 10, + * }, + * { + * code: "1234", + * rate: 20, + * }, + * ]) + */ addLineItemTaxLines( taxLines: CreateLineItemTaxLineDTO[] ): Promise + + /** + * This method creates and adds a line item tax line. + * + * @param {CreateLineItemTaxLineDTO} taxLine - The line item tax line to be created. + * @returns {Promise} The added line item tax line. + * + * @example + * const lineItemTaxLines = + * await cartModuleService.addLineItemTaxLines({ + * code: "1000", + * rate: 10, + * }) + */ addLineItemTaxLines( taxLine: CreateLineItemTaxLineDTO ): Promise + + /** + * This method creates and adds one or more line item tax lines to a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateLineItemTaxLineDTO | CreateLineItemTaxLineDTO[]} taxLines - The line item tax lines to add. + * You can specify one or more items. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added line item tax lines. + * + * @example + * const lineItemTaxLines = + * await cartModuleService.addLineItemTaxLines("cart_123", { + * code: "1000", + * rate: 10, + * }) + */ addLineItemTaxLines( cartId: string, taxLines: CreateLineItemTaxLineDTO[] | CreateLineItemTaxLineDTO, sharedContext?: Context ): Promise + /** + * This method sets the line item tax lines in a cart. The existing line item tax lines, + * except those included in the specified list, are removed and replaced with the specified tax lines. + * + * @param {string} cartId - The cart's ID. + * @param {(CreateLineItemTaxLineDTO | UpdateLineItemTaxLineDTO)[]} taxLines - The line item tax lines to add. + * If the `id` field is specified, the tax line is kept and its attributes can be updated. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added line item tax lines. + * + * @example + * const lineItemTaxLines = + * await cartModuleService.setLineItemTaxLines("cart_123", [ + * { + * code: "1000", + * rate: 10, + * }, + * { + * code: "1234", + * rate: 20, + * }, + * ]) + */ setLineItemTaxLines( cartId: string, taxLines: (CreateLineItemTaxLineDTO | UpdateLineItemTaxLineDTO)[], sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of shipping method tax lines based on optional filters and configuration. + * + * @param {FilterableShippingMethodTaxLineProps} filters - The filters to apply on the retrieved shipping method tax lines. + * @param {FindConfig} config - The configurations determining how the shipping method tax line is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a shipping method tax line. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of shipping method tax lines. + * + * @example + * To retrieve a list of shipping method tax lines using their IDs: + * + * ```ts + * const shippingMethodTaxLines = + * await cartModuleService.listShippingMethodTaxLines({ + * id: ["casmtxl_123", "casmtxl_321"], + * }) + * ``` + * + * To specify relations that should be retrieved within the shipping method tax lines: + * + * ```ts + * const shippingMethodTaxLines = + * await cartModuleService.listShippingMethodTaxLines( + * { + * id: ["casmtxl_123", "casmtxl_321"], + * }, + * { + * relations: ["shipping_method"], + * } + * ) + * ``` + * + * 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 shippingMethodTaxLines = + * await cartModuleService.listShippingMethodTaxLines( + * { + * id: ["casmtxl_123", "casmtxl_321"], + * }, + * { + * relations: ["shipping_method"], + * take: 20, + * skip: 2, + * } + * ) + * ``` + */ listShippingMethodTaxLines( filters: FilterableShippingMethodTaxLineProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method creates and adds shipping method tax lines. + * + * @param {CreateShippingMethodTaxLineDTO[]} taxLines - The shipping method tax lines to be created. + * @returns {Promise} The added shipping method tax lines. + * + * @example + * const shippingMethodTaxLines = + * await cartModuleService.addShippingMethodTaxLines([ + * { + * code: "1000", + * rate: 10, + * }, + * { + * code: "1234", + * rate: 20, + * }, + * ]) + */ addShippingMethodTaxLines( taxLines: CreateShippingMethodTaxLineDTO[] ): Promise + + /** + * This method creates and adds a shipping method tax line. + * + * @param {CreateShippingMethodTaxLineDTO} taxLine - The shipping method tax line to be created. + * @returns {Promise} The added shipping method tax line. + * + * @example + * const shippingMethodTaxLine = + * await cartModuleService.addShippingMethodTaxLines({ + * code: "1000", + * rate: 10, + * }) + */ addShippingMethodTaxLines( taxLine: CreateShippingMethodTaxLineDTO ): Promise + + /** + * This method creates and adds one or more shipping method tax lines to a cart. + * + * @param {string} cartId - The cart's ID. + * @param {CreateShippingMethodTaxLineDTO | CreateShippingMethodTaxLineDTO[]} taxLines - The shipping item tax lines to add. + * If the `id` field is specified, the tax line is kept and its attributes can be updated. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added shipping method tax lines. + * + * @example + * const shippingMethodTaxLines = + * await cartModuleService.addShippingMethodTaxLines( + * "cart_123", + * [ + * { + * code: "1000", + * rate: 10, + * }, + * { + * code: "1234", + * rate: 20, + * }, + * ] + * ) + */ addShippingMethodTaxLines( cartId: string, taxLines: CreateShippingMethodTaxLineDTO[] | CreateShippingMethodTaxLineDTO, sharedContext?: Context ): Promise + /** + * This method sets the shipping item tax lines in a cart. The shipping line item tax lines, + * except those included in the specified list, are removed and replaced with the specified tax lines. + * + * @param {string} cartId - The cart's ID. + * @param {(CreateShippingMethodTaxLineDTO | UpdateShippingMethodTaxLineDTO)[]} taxLines - The shipping item tax lines to add. + * If the `id` field is specified, the tax line is kept and its attributes can be updated. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The added shipping method tax lines. + * + * @example + * const shippingMethodTaxLines = + * await cartModuleService.setShippingMethodTaxLines( + * "cart_123", + * [ + * { + * code: "1000", + * rate: 10, + * }, + * { + * code: "1234", + * rate: 20, + * }, + * ] + * ) + */ setShippingMethodTaxLines( cartId: string, taxLines: ( @@ -259,80 +1460,415 @@ export interface ICartModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes carts by their IDs. + * + * @param {string[]} ids - The IDs of the cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the carts are deleted successfully. + * + * @example + * await cartModuleService.delete(["cart_123", "cart_321"]) + */ delete(ids: string[], sharedContext?: Context): Promise + + /** + * This method deletes a cart by its ID. + * + * @param {string} id - The ID of the cart. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when a cart is deleted successfully. + * + * @example + * await cartModuleService.delete("cart_123") + */ delete(id: string, sharedContext?: Context): Promise + + /** + * This method deletes line items by their IDs. + * + * @param {string[]} ids - The IDs of the line items. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the line items are deleted successfully. + * + * @example + * await cartModuleService.deleteLineItems([ + * "cali_123", + * "cali_321", + * ]) + */ deleteLineItems(ids: string[], sharedContext?: Context): Promise + + /** + * This method deletes a line item by its ID. + * + * @param {string} id - The ID of the line item. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when a line item is deleted successfully. + * + * @example + * await cartModuleService.deleteLineItems("cali_123") + */ deleteLineItems(id: string, sharedContext?: Context): Promise + + /** + * This method deletes shipping methods by their IDs. + * + * @param {string[]} ids - The IDs of the shipping methods. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipping methods are deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethods([ + * "casm_123", + * "casm_321", + * ]) + */ deleteShippingMethods(ids: string[], sharedContext?: Context): Promise + + /** + * This method deletes a shipping method by its ID. + * + * @param {string} id - The ID of the shipping method. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipping method is deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethods("casm_123") + */ deleteShippingMethods(id: string, sharedContext?: Context): Promise + + /** + * This method deletes line item adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the line item adjustments. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the line item adjustments are deleted successfully. + * + * @example + * await cartModuleService.deleteLineItemAdjustments([ + * "caliadj_123", + * "caliadj_321", + * ]) + */ deleteLineItemAdjustments( ids: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a line item adjustment by its ID. + * + * @param {string} id - The ID of the line item adjustment. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the line item adjustment is deleted successfully. + * + * @example + * await cartModuleService.deleteLineItemAdjustments( + * "caliadj_123" + * ) + */ deleteLineItemAdjustments(id: string, sharedContext?: Context): Promise + + /** + * This method deletes shipping method adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method adjustments. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipping method adjustments are deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethodAdjustments([ + * "casmadj_123", + * "casmadj_321", + * ]) + */ deleteShippingMethodAdjustments( ids: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a shipping method adjustment by its ID. + * + * @param {string} id - The ID of the shipping method adjustment. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when shipping method adjustment is deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethodAdjustments( + * "casmadj_123" + * ) + */ deleteShippingMethodAdjustments( id: string, sharedContext?: Context ): Promise + + /** + * This method deletes line item tax lines by their IDs. + * + * @param {string[]} ids - The IDs of the line item tax lines. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the line item tax lines are deleted successfully. + * + * @example + * await cartModuleService.deleteLineItemTaxLines([ + * "calitxl_123", + * "calitxl_321", + * ]) + */ deleteLineItemTaxLines(ids: string[], sharedContext?: Context): Promise + + /** + * This method deletes a line item tax line by its ID. + * + * @param {string} id - The ID of the line item tax line. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the line item tax line is deleted successfully. + * + * @example + * await cartModuleService.deleteLineItemTaxLines("calitxl_123") + */ deleteLineItemTaxLines(id: string, sharedContext?: Context): Promise + + /** + * This method deletes shipping method tax lines by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method tax lines. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipping method tax lines are deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethodTaxLines([ + * "casmtxl_123", + * "casmtxl_321", + * ]) + */ deleteShippingMethodTaxLines( ids: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a shipping method tax line by its ID. + * + * @param {string} id - The ID of the shipping method tax line. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipping method tax line is deleted successfully. + * + * @example + * await cartModuleService.deleteShippingMethodTaxLines( + * "casmtxl_123" + * ) + */ deleteShippingMethodTaxLines( id: string, sharedContext?: Context ): Promise + /** + * This method soft deletes carts by their IDs. + * + * @param {string[]} ids - The IDs of the carts. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated line item. + * The object's keys are the ID attribute names of the cart entity's relations, such as `item_id`, and its value is an array of strings, each being the ID of a record associated + * with the cart through this relation, such as the IDs of associated line item. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDelete(["cart_123", "cart_321"]) + */ softDelete( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted carts by their IDs. + * + * @param {string[]} ids - The IDs of the carts. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the carts. You can pass to its `returnLinkableKeys` + * property any of the cart's relation attribute names, such as `items`. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were restored, such as the ID of associated line item. + * The object's keys are the ID attribute names of the cart entity's relations, such as `item_id`, + * and its value is an array of strings, each being the ID of the record associated with the cart through this relation, + * such as the IDs of associated line item. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restore(["cart_123", "cart_321"]) + */ restore( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes addresses by their IDs. + * + * @param {string[]} ids - The IDs of the addresses. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted. + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteAddresses([ + * "caaddr_123", + * "caaddr_321", + * ]) + */ softDeleteAddresses( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted addresses by their IDs. + * + * @param {string[]} ids - The IDs of the addresses. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the addresses. You can pass to its `returnLinkableKeys` + * property any of the address'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>} An object that includes the IDs of related records that were restored. + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreAddresses([ + * "caaddr_123", + * "caaddr_321", + * ]) + */ restoreAddresses( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes line items by their IDs. + * + * @param {string[]} ids - The IDs of the line items. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated tax lines. + * The object's keys are the ID attribute names of the line item entity's relations, such as `tax_line_id`, and its value is an array of strings, each being the ID of a record associated + * with the line item through this relation, such as the IDs of associated tax lines. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteLineItems([ + * "cali_123", + * "cali_321", + * ]) + */ softDeleteLineItems( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted line items by their IDs. + * + * @param {string[]} ids - The IDs of the line items. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the line items. You can pass to its `returnLinkableKeys` + * property any of the line item's relation attribute names, such as `tax_lines`. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were restored, such as the ID of associated tax line. + * The object's keys are the ID attribute names of the line item entity's relations, such as `tax_line_id`, + * and its value is an array of strings, each being the ID of the record associated with the line item through this relation, + * such as the IDs of associated tax line. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreLineItems([ + * "cali_123", + * "cali_321", + * ]) + */ restoreLineItems( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes shipping methods by their IDs. + * + * @param {string[]} ids - The IDs of the shipping methods. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated tax lines. + * The object's keys are the ID attribute names of the shipping method entity's relations, such as `tax_line_id`, and its value is an array of strings, each being the ID of a record associated + * with the shipping method through this relation, such as the IDs of associated tax line. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteShippingMethods([ + * "casm_123", + * "casm_321", + * ]) + */ softDeleteShippingMethods( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted shipping methods by their IDs. + * + * @param {string[]} ids - The IDs of the shipping methods. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the shipping methods. You can pass to its `returnLinkableKeys` + * property any of the shipping method's relation attribute names, such as `tax_lines`. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were restored, such as the ID of associated tax lines. + * The object's keys are the ID attribute names of the shipping method entity's relations, such as `tax_line_id`, + * and its value is an array of strings, each being the ID of the record associated with the shipping method through this relation, + * such as the IDs of associated tax lines. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreShippingMethods([ + * "casm_123", + * "casm_321", + * ]) + */ restoreShippingMethods( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes line item adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the line item adjustments. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted. + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteLineItemAdjustments([ + * "caliadj_123", + * "caliadj_321", + * ]) + */ softDeleteLineItemAdjustments< TReturnableLinkableKeys extends string = string >( @@ -340,12 +1876,44 @@ export interface ICartModuleService extends IModuleService { config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted line item adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the line item adjustments. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the line item adjustments. You can pass to its `returnLinkableKeys` + * property any of the line item adjustment'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>} An object that includes the IDs of related records that were restored. + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreLineItemAdjustments([ + * "caliadj_123", + * "caliadj_321", + * ]) + */ restoreLineItemAdjustments( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes shipping method adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method adjustments. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted. + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteShippingMethodAdjustments([ + * "casmadj_123", + * "casmadj_321", + * ]) + */ softDeleteShippingMethodAdjustments< TReturnableLinkableKeys extends string = string >( @@ -353,6 +1921,23 @@ export interface ICartModuleService extends IModuleService { config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted shipping method adjustments by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method adjustments. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the shipping method adjustment. You can pass to its `returnLinkableKeys` + * property any of the shipping method adjustment'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>} An object that includes the IDs of related records that were restored. + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreShippingMethodAdjustments([ + * "casmadj_123", + * "casmadj_321", + * ]) + */ restoreShippingMethodAdjustments< TReturnableLinkableKeys extends string = string >( @@ -361,17 +1946,64 @@ export interface ICartModuleService extends IModuleService { sharedContext?: Context ): Promise | void> + /** + * This method soft deletes line item tax lines by their IDs. + * + * @param {string[]} ids - The IDs of the line item tax lines. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted. + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteLineItemTaxLines([ + * "calitxl_123", + * "calitxl_321", + * ]) + */ softDeleteLineItemTaxLines( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted line item tax lines by its IDs. + * + * @param {string[]} ids - The IDs of the line item tax lines. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the line item tax lines. You can pass to its `returnLinkableKeys` + * property any of the line item tax line'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>} An object that includes the IDs of related records that were restored. + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreLineItemTaxLines([ + * "calitxl_123", + * "calitxl_321", + * ]) + */ restoreLineItemTaxLines( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method soft deletes shipping method tax lines by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method tax lines. + * @param {SoftDeleteReturn} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise>} An object that includes the IDs of related records that were also soft deleted. + * If there are no related records, the promise resolves to `void`. + * + * @example + * await cartModuleService.softDeleteShippingMethodTaxLines([ + * "casmtxl_123", + * "casmtxl_321", + * ]) + */ softDeleteShippingMethodTaxLines< TReturnableLinkableKeys extends string = string >( @@ -379,6 +2011,23 @@ export interface ICartModuleService extends IModuleService { config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft deleted shipping method tax lines by their IDs. + * + * @param {string[]} ids - The IDs of the shipping method tax lines. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the shipping method tax lines. You can pass to its `returnLinkableKeys` + * property any of the shipping method tax line'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>} An object that includes the IDs of related records that were restored. + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await cartModuleService.restoreShippingMethodTaxLines([ + * "casmtxl_123", + * "casmtxl_321", + * ]) + */ restoreShippingMethodTaxLines< TReturnableLinkableKeys extends string = string >(