chore: added tsdocs to Cart Module (#6881)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-04-05 12:04:15 +02:00
1 parent bd2c5aca16
commit 0a8718f0c5
3 files changed
+2836 -62

No files matched your search

File diff suppressed because it is too large. Load diff
+582
View File
@@ -1,101 +1,345 @@
import { CartDTO, CartLineItemDTO } from "./common" import { CartDTO, CartLineItemDTO } from "./common"
/** ADDRESS START */ /** ADDRESS START */
/**
* The attributes in the address to be created or updated.
*/
export interface UpsertAddressDTO { export interface UpsertAddressDTO {
/**
* The associated customer's ID.
*/
customer_id?: string customer_id?: string
/**
* The company of the address.
*/
company?: string company?: string
/**
* The first name of the address.
*/
first_name?: string first_name?: string
/**
* The last name of the address.
*/
last_name?: string last_name?: string
/**
* The first line of the address.
*/
address_1?: string address_1?: string
/**
* The second line of the address.
*/
address_2?: string address_2?: string
/**
* The city of the address.
*/
city?: string city?: string
/**
* The ISO two country code of the address.
*/
country_code?: string country_code?: string
/**
* The province of the address.
*/
province?: string province?: string
/**
* The postal code of the address.
*/
postal_code?: string postal_code?: string
/**
* The phone of the address.
*/
phone?: string phone?: string
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> metadata?: Record<string, unknown>
} }
/**
* The attributes to update in the address.
*/
export interface UpdateAddressDTO extends UpsertAddressDTO { export interface UpdateAddressDTO extends UpsertAddressDTO {
/**
* The ID of the address.
*/
id: string id: string
} }
/**
* The address to be created.
*/
export interface CreateAddressDTO extends UpsertAddressDTO {} export interface CreateAddressDTO extends UpsertAddressDTO {}
/** ADDRESS END */ /** ADDRESS END */
/** CART START */ /** CART START */
/**
* The cart to be created.
*/
export interface CreateCartDTO { export interface CreateCartDTO {
/**
* The associated region's ID.
*/
region_id?: string region_id?: string
/**
* The associated customer's ID.
*/
customer_id?: string customer_id?: string
/**
* The associated sales channel's ID.
*/
sales_channel_id?: string sales_channel_id?: string
/**
* The email of the customer that owns the cart.
*/
email?: string email?: string
/**
* The currency code of the cart.
*/
currency_code: string currency_code: string
/**
* The associated shipping address's ID.
*/
shipping_address_id?: string shipping_address_id?: string
/**
* The associated billing address's ID.
*/
billing_address_id?: string billing_address_id?: string
/**
* The shipping address of the cart.
*/
shipping_address?: CreateAddressDTO | string shipping_address?: CreateAddressDTO | string
/**
* The billing address of the cart.
*/
billing_address?: CreateAddressDTO | string billing_address?: CreateAddressDTO | string
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> metadata?: Record<string, unknown>
/**
* The items of the cart.
*/
items?: CreateLineItemDTO[] items?: CreateLineItemDTO[]
} }
/**
* The attributes to update in the cart data.
*/
export interface UpdateCartDataDTO { export interface UpdateCartDataDTO {
/**
* The associated region's ID.
*/
region_id?: string region_id?: string
/**
* The associated customer's ID.
*/
customer_id?: string | null customer_id?: string | null
/**
* The associated sales channel's ID.
*/
sales_channel_id?: string | null sales_channel_id?: string | null
/**
* The email of the customer that owns the cart.
*/
email?: string | null email?: string | null
/**
* The currency code of the cart.
*/
currency_code?: string currency_code?: string
/**
* The associated shipping address's ID.
*/
shipping_address_id?: string | null shipping_address_id?: string | null
/**
* The associated billing address's ID.
*/
billing_address_id?: string | null billing_address_id?: string | null
/**
* The billing address of the cart.
*/
billing_address?: CreateAddressDTO | UpdateAddressDTO | null billing_address?: CreateAddressDTO | UpdateAddressDTO | null
/**
* The shipping address of the cart.
*/
shipping_address?: CreateAddressDTO | UpdateAddressDTO | null shipping_address?: CreateAddressDTO | UpdateAddressDTO | null
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null metadata?: Record<string, unknown> | null
} }
/**
* The attributes to update in the cart.
*/
export interface UpdateCartDTO extends UpdateCartDataDTO { export interface UpdateCartDTO extends UpdateCartDataDTO {
/**
* The ID of the cart.
*/
id: string id: string
} }
/** CART END */ /** CART END */
/** ADJUSTMENT START */ /** ADJUSTMENT START */
/**
* The adjustment to be created.
*/
export interface CreateAdjustmentDTO { export interface CreateAdjustmentDTO {
/**
* The code of the promotion that lead to
* this adjustment.
*/
code: string code: string
/**
* The amount to adjust the original amount with.
*/
amount: number amount: number
/**
* The description of the adjustment.
*/
description?: string description?: string
/**
* The associated promotion's ID.
*/
promotion_id?: string promotion_id?: string
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
/**
* The attributes to update in the adjustment.
*/
export interface UpdateAdjustmentDTO { export interface UpdateAdjustmentDTO {
/**
* The ID of the adjustment.
*/
id: string id: string
/**
* The code of the promotion that lead to
* this adjustment.
*/
code?: string code?: string
/**
* The amount to adjust the original amount with.
*/
amount: number amount: number
/**
* The description of the adjustment.
*/
description?: string description?: string
/**
* The associated promotion's ID.
*/
promotion_id?: string promotion_id?: string
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
/**
* The line item adjustment to be created.
*/
export interface CreateLineItemAdjustmentDTO extends CreateAdjustmentDTO { export interface CreateLineItemAdjustmentDTO extends CreateAdjustmentDTO {
/**
* The associated item's ID.
*/
item_id: string item_id: string
} }
/**
* The attributes to update in the line item adjustment.
*/
export interface UpdateLineItemAdjustmentDTO extends UpdateAdjustmentDTO { export interface UpdateLineItemAdjustmentDTO extends UpdateAdjustmentDTO {
/**
* The associated item's ID.
*/
item_id: string item_id: string
} }
/**
* The attributes in the line item adjustment to be created or updated.
*/
export interface UpsertLineItemAdjustmentDTO { export interface UpsertLineItemAdjustmentDTO {
/**
* The ID of the line item adjustment.
*/
id?: string id?: string
/**
* The associated item's ID.
*/
item_id: string item_id: string
/**
* The code of the promotion that lead to the
* adjustment.
*/
code?: string code?: string
/**
* The amount to adjust the original amount with.
*/
amount?: number amount?: number
/**
* The description of the line item adjustment.
*/
description?: string description?: string
/**
* The associated promotion's ID.
*/
promotion_id?: string promotion_id?: string
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
@@ -103,95 +347,305 @@ export interface UpsertLineItemAdjustmentDTO {
/** TAX LINES START */ /** TAX LINES START */
/**
* The tax line to be created.
*/
export interface CreateTaxLineDTO { export interface CreateTaxLineDTO {
/**
* The description of the tax line.
*/
description?: string description?: string
/**
* The associated tax rate's ID.
*/
tax_rate_id?: string tax_rate_id?: string
/**
* The code of the tax line.
*/
code: string code: string
/**
* The rate of the tax line.
*/
rate: number rate: number
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
/**
* The attributes to update in the tax line.
*/
export interface UpdateTaxLineDTO { export interface UpdateTaxLineDTO {
/**
* The ID of the tax line.
*/
id: string id: string
/**
* The description of the tax line.
*/
description?: string description?: string
/**
* The associated tax rate's ID.
*/
tax_rate_id?: string tax_rate_id?: string
/**
* The code of the tax line.
*/
code?: string code?: string
/**
* The rate of the tax line.
*/
rate?: number rate?: number
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
/**
* The shipping method tax line to be created.
*/
export interface CreateShippingMethodTaxLineDTO extends CreateTaxLineDTO {} export interface CreateShippingMethodTaxLineDTO extends CreateTaxLineDTO {}
/**
* The attributes to update in the shipping method tax line.
*/
export interface UpdateShippingMethodTaxLineDTO extends UpdateTaxLineDTO {} export interface UpdateShippingMethodTaxLineDTO extends UpdateTaxLineDTO {}
/**
* The line item tax line to be created.
*/
export interface CreateLineItemTaxLineDTO extends CreateTaxLineDTO {} export interface CreateLineItemTaxLineDTO extends CreateTaxLineDTO {}
/**
* The attributes to update in the line item tax line.
*/
export interface UpdateLineItemTaxLineDTO extends UpdateTaxLineDTO {} export interface UpdateLineItemTaxLineDTO extends UpdateTaxLineDTO {}
/** TAX LINES END */ /** TAX LINES END */
/** LINE ITEMS START */ /** LINE ITEMS START */
/**
* The line item to be created.
*/
export interface CreateLineItemDTO { export interface CreateLineItemDTO {
/**
* The title of the line item.
*/
title: string title: string
/**
* The subtitle of the line item.
*/
subtitle?: string subtitle?: string
/**
* The thumbnail of the line item.
*/
thumbnail?: string thumbnail?: string
/**
* The associated cart's ID.
*/
cart_id?: string cart_id?: string
/**
* The quantity of the line item in the cart.
*/
quantity: number quantity: number
/**
* The associated product's ID.
*/
product_id?: string product_id?: string
/**
* The title of the associated product.
*/
product_title?: string product_title?: string
/**
* The description of the associated product.
*/
product_description?: string product_description?: string
/**
* The subtitle of the associated product.
*/
product_subtitle?: string product_subtitle?: string
/**
* The type of the associated product.
*/
product_type?: string product_type?: string
/**
* The collection of the associated product.
*/
product_collection?: string product_collection?: string
/**
* The handle of the associated product.
*/
product_handle?: string product_handle?: string
/**
* The associated variant's ID.
*/
variant_id?: string variant_id?: string
/**
* The SKU of the associated variant.
*/
variant_sku?: string variant_sku?: string
/**
* The barcode of the associated variant.
*/
variant_barcode?: string variant_barcode?: string
/**
* The title of the associated variant.
*/
variant_title?: string variant_title?: string
/**
* The option values of the associated variant.
*/
variant_option_values?: Record<string, unknown> variant_option_values?: Record<string, unknown>
/**
* Whether the line item requires shipping.
*/
requires_shipping?: boolean requires_shipping?: boolean
/**
* Whether the line item is discountable.
*/
is_discountable?: boolean is_discountable?: boolean
/**
* Whether the line item's amount is tax inclusive.
*/
is_tax_inclusive?: boolean is_tax_inclusive?: boolean
/**
* The calculated price of the line item after applying promotions.
*/
compare_at_unit_price?: number compare_at_unit_price?: number
/**
* The unit price of the line item.
*/
unit_price: number | string unit_price: number | string
/**
* The tax lines of the line item.
*/
tax_lines?: CreateTaxLineDTO[] tax_lines?: CreateTaxLineDTO[]
/**
* The adjustments of the line item.
*/
adjustments?: CreateAdjustmentDTO[] adjustments?: CreateAdjustmentDTO[]
} }
/**
* The line item to be created in a cart.
*/
export interface CreateLineItemForCartDTO extends CreateLineItemDTO { export interface CreateLineItemForCartDTO extends CreateLineItemDTO {
/**
* The associated cart's ID.
*/
cart_id: string 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 { export interface UpdateLineItemWithSelectorDTO {
/**
* Filters to specify which line items to update.
*/
selector: Partial<CartLineItemDTO> selector: Partial<CartLineItemDTO>
/**
* The attributes to update in the line items.
*/
data: Partial<UpdateLineItemDTO> data: Partial<UpdateLineItemDTO>
} }
/**
* 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 { export interface UpdateCartWithSelectorDTO {
/**
* Filters to specify which carts to update.
*/
selector: Partial<CartDTO> selector: Partial<CartDTO>
/**
* The attributes to update in the carts.
*/
data: UpdateCartDataDTO data: UpdateCartDataDTO
} }
/**
* The attributes to update in a line item.
*/
export interface UpdateLineItemDTO export interface UpdateLineItemDTO
extends Omit< extends Omit<
CreateLineItemDTO, CreateLineItemDTO,
"tax_lines" | "adjustments" | "title" | "quantity" | "unit_price" "tax_lines" | "adjustments" | "title" | "quantity" | "unit_price"
> { > {
/**
* The ID of the line item.
*/
id: string id: string
/**
* The title of the line item.
*/
title?: string title?: string
/**
* The quantity of the line item in the cart.
*/
quantity?: number quantity?: number
/**
* The unit price of the line item.
*/
unit_price?: number unit_price?: number
/**
* Holds custom data in key-value pairs.
*/
metadata?: Record<string, unknown> | null metadata?: Record<string, unknown> | null
/**
* The tax lines of the line item.
*/
tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[] tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[]
/**
* The adjustments of the line item.
*/
adjustments?: UpdateAdjustmentDTO[] | CreateAdjustmentDTO[] adjustments?: UpdateAdjustmentDTO[] | CreateAdjustmentDTO[]
} }
@@ -199,47 +653,175 @@ export interface UpdateLineItemDTO
/** SHIPPING METHODS START */ /** SHIPPING METHODS START */
/**
* The shipping method to be created.
*/
export interface CreateShippingMethodDTO { export interface CreateShippingMethodDTO {
/**
* The name of the shipping method.
*/
name: string name: string
/**
* The associated cart's ID.
*/
cart_id: string cart_id: string
/**
* The amount of the shipping method.
*/
amount: number amount: number
/**
* The data of the shipping method.
*/
data?: Record<string, unknown> data?: Record<string, unknown>
/**
* The tax lines of the shipping method.
*/
tax_lines?: CreateTaxLineDTO[] tax_lines?: CreateTaxLineDTO[]
/**
* The adjustments of the shipping method.
*/
adjustments?: CreateAdjustmentDTO[] adjustments?: CreateAdjustmentDTO[]
} }
/**
* The shipping method to be created in a cart.
*/
export interface CreateShippingMethodForSingleCartDTO { export interface CreateShippingMethodForSingleCartDTO {
/**
* The name of the shipping method.
*/
name: string name: string
/**
* The amount of the shipping method.
*/
amount: number amount: number
/**
* The data of the shipping method.
*/
data?: Record<string, unknown> data?: Record<string, unknown>
/**
* The tax lines of the shipping method.
*/
tax_lines?: CreateTaxLineDTO[] tax_lines?: CreateTaxLineDTO[]
/**
* The adjustments of the shipping method.
*/
adjustments?: CreateAdjustmentDTO[] adjustments?: CreateAdjustmentDTO[]
} }
/**
* The attributes to update in the shipping method.
*/
export interface UpdateShippingMethodDTO { export interface UpdateShippingMethodDTO {
/**
* The ID of the shipping method.
*/
id: string id: string
/**
* The name of the shipping method.
*/
name?: string name?: string
/**
* The amount of the shipping method.
*/
amount?: number amount?: number
/**
* The data of the shipping method.
*/
data?: Record<string, unknown> data?: Record<string, unknown>
/**
* The tax lines of the shipping method.
*/
tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[] tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[]
/**
* The adjustments of the shipping method.
*/
adjustments?: CreateAdjustmentDTO[] | UpdateAdjustmentDTO[] adjustments?: CreateAdjustmentDTO[] | UpdateAdjustmentDTO[]
} }
/**
* The shipping method adjustment to be created.
*/
export interface CreateShippingMethodAdjustmentDTO { export interface CreateShippingMethodAdjustmentDTO {
/**
* The associated shipping method's ID.
*/
shipping_method_id: string shipping_method_id: string
/**
* The code of the promotion that lead to
* this adjustment.
*/
code: string code: string
/**
* The amount to adjust the original amount with.
*/
amount: number amount: number
/**
* The description of the shipping method adjustment.
*/
description?: string description?: string
/**
* The associated promotion's ID.
*/
promotion_id?: string promotion_id?: string
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
/**
* The attributes to update in the shipping method adjustment.
*/
export interface UpdateShippingMethodAdjustmentDTO { export interface UpdateShippingMethodAdjustmentDTO {
/**
* The ID of the shipping method adjustment.
*/
id: string id: string
/**
* The code of the promotion that lead to
* this adjustment.
*/
code?: string code?: string
/**
* The amount to adjust the original amount with.
*/
amount?: number amount?: number
/**
* The description of the shipping method adjustment.
*/
description?: string description?: string
/**
* The associated promotion's ID.
*/
promotion_id?: string promotion_id?: string
/**
* The associated provider's ID.
*/
provider_id?: string provider_id?: string
} }
File diff suppressed because it is too large. Load diff