From f04adaf0c1f3b6096809f23f33f9f8e8a9010e5b Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 6 Aug 2024 10:18:31 +0300 Subject: [PATCH] chore: added and updated TSDocs of order module service (#8246) - Added/updated TSDocs of the order module's service type + other related types. - Renamed parameter names that were inconsistent / had typos Note: found some minor inconsistencies in some of the method signatures. Will open a separate PR to resolve them. Closes DOCS-783 --- packages/core/types/src/order/common.ts | 1072 +++++- packages/core/types/src/order/mutations.ts | 1573 ++++++++- packages/core/types/src/order/service.ts | 3620 +++++++++++++++++--- 3 files changed, 5666 insertions(+), 599 deletions(-) diff --git a/packages/core/types/src/order/common.ts b/packages/core/types/src/order/common.ts index e2c04be7b2..0951ade7c2 100644 --- a/packages/core/types/src/order/common.ts +++ b/packages/core/types/src/order/common.ts @@ -5,6 +5,9 @@ import { PaymentCollectionDTO } from "../payment" import { BigNumberInput, BigNumberRawValue, BigNumberValue } from "../totals" import { ClaimReason } from "./mutations" +/** + * The change action's type. + */ export type ChangeActionType = | "CANCEL" | "CANCEL_RETURN_ITEM" @@ -21,133 +24,231 @@ export type ChangeActionType = | "WRITE_OFF_ITEM" | "REINSTATE_ITEM" +/** + * @interface + * + * The order summary details. + */ export type OrderSummaryDTO = { + /** + * The total of the order summary. + */ total: BigNumberValue + + /** + * The subtotal of the order summary. + */ subtotal: BigNumberValue + + /** + * The total tax of the order summary. + */ total_tax: BigNumberValue + /** + * The ordered total of the order summary. + */ ordered_total: BigNumberValue + + /** + * The fulfilled total of the order summary. + */ fulfilled_total: BigNumberValue + + /** + * The returned total of the order summary. + */ returned_total: BigNumberValue + + /** + * The return request total of the order summary. + */ return_request_total: BigNumberValue + + /** + * The write off total of the order summary. + */ write_off_total: BigNumberValue + + /** + * The projected total of the order summary. + */ projected_total: BigNumberValue + /** + * The net total of the order summary. + */ net_total: BigNumberValue + + /** + * The net subtotal of the order summary. + */ net_subtotal: BigNumberValue + + /** + * The net total tax of the order summary. + */ net_total_tax: BigNumberValue + /** + * The balance of the order summary. + */ balance: BigNumberValue + /** + * The paid total of the order summary. + */ paid_total: BigNumberValue + + /** + * The refunded total of the order summary. + */ refunded_total: BigNumberValue } +/** + * The adjustment line details. + */ export interface OrderAdjustmentLineDTO { /** * The ID of the adjustment line */ id: string + /** * The code of the adjustment line */ code?: string + /** * The amount of the adjustment line */ amount: BigNumberValue + /** * The ID of the associated order */ order_id: string + /** * The description of the adjustment line */ description?: string + /** * The ID of the associated promotion */ promotion_id?: string + /** * The ID of the associated provider */ provider_id?: string + /** * When the adjustment line was created */ created_at: Date | string + /** * When the adjustment line was updated */ updated_at: Date | string } +/** + * The shipping method adjustment details. + */ export interface OrderShippingMethodAdjustmentDTO extends OrderAdjustmentLineDTO { /** - * The associated shipping method + * The associated shipping method. + * + * @expandable */ shipping_method: OrderShippingMethodDTO + /** - * 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 OrderLineItemAdjustmentDTO extends OrderAdjustmentLineDTO { /** - * The associated line item + * The associated line item. + * * @expandable */ item: OrderLineItemDTO + /** - * The associated line item + * The ID of the associated line item. */ item_id: string } +/** + * The tax line details. + */ export interface OrderTaxLineDTO { /** - * The ID of the tax line + * The ID of the tax line. */ id: string + /** - * The description of the tax line + * 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 OrderShippingMethodTaxLineDTO extends OrderTaxLineDTO { /** - * The associated shipping method + * The associated shipping method. + * + * @expandable */ shipping_method: OrderShippingMethodDTO + /** - * The ID of the associated shipping method + * The ID of the associated shipping method. */ shipping_method_id: string @@ -172,13 +273,19 @@ export interface OrderShippingMethodTaxLineDTO extends OrderTaxLineDTO { raw_subtotal: BigNumberRawValue } +/** + * The line item tax line details. + */ export interface OrderLineItemTaxLineDTO extends OrderTaxLineDTO { /** - * The associated line item + * The associated line item. + * + * @expandable */ item: OrderLineItemDTO + /** - * The ID of the associated line item + * The ID of the associated line item. */ item_id: string @@ -203,105 +310,127 @@ export interface OrderLineItemTaxLineDTO extends OrderTaxLineDTO { raw_subtotal: BigNumberRawValue } +/** + * The address details. + */ export interface OrderAddressDTO { /** - * 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 order shipping method details. + */ export interface OrderShippingMethodDTO { /** - * The ID of the shipping method + * The ID of the shipping method. */ id: string /** - * The ID of the associated order + * The ID of the associated order. */ order_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: BigNumberValue /** - * The raw price of the shipping method + * The raw price of the shipping method. */ raw_amount: BigNumberRawValue + /** - * Whether the shipping method price is tax inclusive or not + * Whether the shipping method price is tax inclusive or not. */ 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 @@ -321,6 +450,7 @@ export interface OrderShippingMethodDTO { * @expandable */ tax_lines?: OrderShippingMethodTaxLineDTO[] + /** * The associated adjustments. * @@ -332,6 +462,7 @@ export interface OrderShippingMethodDTO { * When the shipping method was created. */ created_at: Date | string + /** * When the shipping method was updated. */ @@ -418,6 +549,9 @@ export interface OrderShippingMethodDTO { raw_discount_tax_total: BigNumberRawValue } +/** + * The order line item totals details. + */ export interface OrderLineItemTotalsDTO { /** * The original total of the order line item. @@ -482,7 +616,6 @@ export interface OrderLineItemTotalsDTO { /** * The refundable total per unit of the order line item. */ - refundable_total_per_unit: BigNumberValue /** @@ -551,129 +684,132 @@ export interface OrderLineItemTotalsDTO { raw_refundable_total_per_unit: BigNumberRawValue } +/** + * The line item details. + */ export interface OrderLineItemDTO extends OrderLineItemTotalsDTO { /** - * The ID of the order line item. + * The ID of the line item. */ id: string /** - * The title of the order line item. + * The title of the line item. */ title: string /** - * The subtitle of the order line item. + * The subtitle of the line item. */ subtitle?: string | null /** - * The thumbnail of the order line item. + * The thumbnail of the line item. */ thumbnail?: string | null /** - * The ID of the variant associated with the order line item. + * The ID of the variant associated with the line item. */ variant_id?: string | null /** - * The ID of the product associated with the order line item. + * The ID of the product associated with the line item. */ product_id?: string | null /** - * The title of the product associated with the order line item. + * The title of the product associated with the line item. */ product_title?: string | null /** - * The description of the product associated with the order line item. + * The description of the product associated with the line item. */ product_description?: string | null /** - * The subtitle of the product associated with the order line item. + * The subtitle of the product associated with the line item. */ product_subtitle?: string | null /** - * The type of the product associated with the order line item. + * The type of the product associated with the line item. */ product_type?: string | null /** - * The collection of the product associated with the order line item. + * The collection of the product associated with the line item. */ product_collection?: string | null /** - * The handle of the product associated with the order line item. + * The handle of the product associated with the line item. */ product_handle?: string | null /** - * The SKU (stock keeping unit) of the variant associated with the order line item. + * The SKU (stock keeping unit) of the variant associated with the line item. */ variant_sku?: string | null /** - * The barcode of the variant associated with the order line item. + * The barcode of the variant associated with the line item. */ variant_barcode?: string | null /** - * The title of the variant associated with the order line item. + * The title of the variant associated with the line item. */ variant_title?: string | null /** - * The option values of the variant associated with the order line item. + * The option values of the variant associated with the line item. */ variant_option_values?: Record | null /** - * Indicates whether the order line item requires shipping. + * Indicates whether the line item requires shipping. */ requires_shipping: boolean /** - * Indicates whether the order line item is discountable. + * Indicates whether the line item is discountable. */ is_discountable: boolean /** - * Indicates whether the order line item price is tax inclusive. + * Indicates whether the line item price is tax inclusive. */ is_tax_inclusive: boolean /** - * The compare at unit price of the order line item. + * The compare at unit price of the line item. */ compare_at_unit_price?: number /** - * The raw compare at unit price of the order line item. + * The raw compare at unit price of the line item. */ raw_compare_at_unit_price?: BigNumberRawValue /** - * The unit price of the order line item. + * The unit price of the line item. */ unit_price: number /** - * The raw unit price of the order line item. + * The raw unit price of the line item. */ raw_unit_price: BigNumberRawValue /** - * The quantity of the order line item. + * The quantity of the line item. */ quantity: number /** - * The raw quantity of the order line item. + * The raw quantity of the line item. */ raw_quantity: BigNumberRawValue @@ -683,6 +819,7 @@ export interface OrderLineItemDTO extends OrderLineItemTotalsDTO { * @expandable */ tax_lines?: OrderLineItemTaxLineDTO[] + /** * The associated adjustments. * @@ -696,12 +833,12 @@ export interface OrderLineItemDTO extends OrderLineItemTotalsDTO { detail: OrderItemDTO /** - * The date when the order line item was created. + * The date when the line item was created. */ created_at: Date /** - * The date when the order line item was last updated. + * The date when the line item was last updated. */ updated_at: Date @@ -711,9 +848,12 @@ export interface OrderLineItemDTO extends OrderLineItemTotalsDTO { metadata?: Record | null } +/** + * The order item details. + */ export interface OrderItemDTO { /** - * The ID of the order detail. + * The ID of the order item. */ id: string @@ -723,7 +863,9 @@ export interface OrderItemDTO { item_id: string /** - * The Line Item of the order detail. + * The associated line item. + * + * @expandable */ item: OrderLineItemDTO @@ -813,6 +955,9 @@ export interface OrderItemDTO { updated_at: Date } +/** + * The order's status. + */ type OrderStatus = | "pending" | "completed" @@ -821,61 +966,78 @@ type OrderStatus = | "canceled" | "requires_action" +/** + * The order details. + */ export interface OrderDTO { /** * The ID of the order. */ id: string + /** * The version of the order. */ version: number + /** * The active order change, if any. + * + * @expandable */ order_change?: OrderChangeDTO + /** * The status of the order. */ status: OrderStatus + /** * The ID of the region the order belongs to. */ region_id?: string + /** * The ID of the customer on the order. */ customer_id?: string + /** * The ID of the sales channel the order belongs to. */ sales_channel_id?: string + /** * The email of the order. */ email?: string + /** * The currency of the order */ currency_code: string + /** * The associated shipping address. * * @expandable */ shipping_address?: OrderAddressDTO + /** * The associated billing address. * * @expandable */ billing_address?: OrderAddressDTO + /** * The associated order details / line items. * * @expandable */ items?: OrderLineItemDTO[] + /** * The associated shipping methods * @@ -889,22 +1051,29 @@ export interface OrderDTO { * @expandable */ transactions?: OrderTransactionDTO[] + /** * The summary of the order totals. + * + * @expandable */ summary?: OrderSummaryDTO + /** * Holds custom data in key-value pairs. */ metadata?: Record | null + /** * When the order was canceled. */ canceled_at?: string | Date + /** * When the order was created. */ created_at?: string | Date + /** * When the order was updated. */ @@ -1131,88 +1300,340 @@ export interface OrderDTO { raw_original_shipping_tax_total: BigNumberRawValue } +/** + * The return's status. + */ type ReturnStatus = "requested" | "received" | "partially_received" | "canceled" +/** + * The return details. + */ export interface ReturnDTO extends Omit { + /** + * The ID of the return. + */ id: string + + /** + * The status of the return. + */ status: ReturnStatus + + /** + * The refund amount of the return. + */ refund_amount?: BigNumberValue + + /** + * The associated order's ID. + */ order_id: string + + /** + * The items of the return + */ items: OrderReturnItemDTO[] } +/** + * The order return item details. + */ export interface OrderReturnItemDTO { + /** + * The ID of the order return item. + */ id: string + + /** + * The associated return's ID. + */ return_id: string + + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated line item's ID. + */ item_id: string + + /** + * The associated reason's ID. + */ reason_id?: string | null + + /** + * The quantity of the item to return. + */ quantity: number + + /** + * The raw quantity of the item to return. + */ raw_quantity: BigNumberRawValue + + /** + * The received quantity of the return item. + */ received_quantity?: number + + /** + * The raw received quantity of the return item. + */ raw_received_quantity?: BigNumberRawValue + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The creation date of the return item. + */ created_at?: Date | string + + /** + * The update date of the return item. + */ updated_at?: Date | string } +/** + * The order claim item details. + */ export interface OrderClaimItemDTO { + /** + * The ID of the order claim item. + */ id: string + + /** + * The associated claim's ID. + */ claim_id: string + + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The quantity of the order claim item + */ quantity: number + + /** + * The reason of the order claim item + */ reason: ClaimReason + + /** + * The raw quantity of the order claim item + */ raw_quantity: BigNumberRawValue + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The creation date of the order claim item + */ created_at?: Date | string + + /** + * The update date of the order claim item + */ updated_at?: Date | string } +/** + * The order claim item image details. + */ export interface OrderClaimItemImageDTO { + /** + * The ID of the order claim item image. + */ id: string + + /** + * The associated claim item's ID. + */ claim_item_id: string + + /** + * The url of the order claim item image + */ url: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The creation date of the order claim item image + */ created_at?: Date | string + + /** + * The update date of the order claim item image + */ updated_at?: Date | string } +/** + * The order exchange item details. + */ export interface OrderExchangeItemDTO { + /** + * The ID of the order exchange item. + */ id: string + + /** + * The associated exchange's ID. + */ exchange_id: string + + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The quantity of the order exchange item + */ quantity: number + + /** + * The raw quantity of the order exchange item + */ raw_quantity: BigNumberRawValue + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The creation date of the order exchange item + */ created_at?: Date | string + + /** + * The update date of the order exchange item + */ updated_at?: Date | string } +/** + * The claim details. + */ export interface OrderClaimDTO extends Omit { + /** + * The ID of the associated order. + */ order_id: string + + /** + * The items to be received from the customer + * if the claim's type is `replace`. + */ claim_items: any[] + + /** + * The items to be sent to the customer + * if the claim's type is `replace`. + */ additional_items: any[] + + /** + * The associated return, if the claim's type is `replace`. + */ return?: ReturnDTO + + /** + * The ID of the associated return, if the claim's type is `replace`. + */ return_id?: string + + /** + * Whether the customer should receive notifications related + * to updates on the claim. + */ no_notification?: boolean + + /** + * The refund amount of the claim. + */ refund_amount?: BigNumberValue } +/** + * The exchange details. + */ export interface OrderExchangeDTO extends Omit { + /** + * The associated order's ID. + */ order_id: string + + /** + * The items to be returned from the customer. + */ return_items: any[] + + /** + * The items to be sent to the customer. + */ additional_items: any[] + + /** + * Whether the customer should receive notifications related + * to updates on the exchange. + */ no_notification?: boolean + + /** + * The difference due of the order exchange. + * + * - If less than `0`, the merchant owes the customer this amount. + * - If greater than `0`, the customer owes the merchange this amount. + * - If equal to `0`, no payment is required by either sides. + */ difference_due?: BigNumberValue + + /** + * The associated return. + */ return?: ReturnDTO + + /** + * The associated return's ID. + */ return_id?: string } +/** + * The payment's status. + */ export type PaymentStatus = | "not_paid" | "awaiting" @@ -1225,6 +1646,9 @@ export type PaymentStatus = | "canceled" | "requires_action" +/** + * The fulfillment's status. + */ export type FulfillmentStatus = | "not_fulfilled" | "partially_fulfilled" @@ -1235,60 +1659,95 @@ export type FulfillmentStatus = | "delivered" | "canceled" +/** + * The data of the order details. + */ export interface OrderDetailDTO extends OrderDTO { + /** + * The associated payment collections. + * + * @expandable + */ payment_collections: PaymentCollectionDTO[] + + /** + * The payment status of the order detail. + */ payment_status: PaymentStatus + + /** + * The associated fulfillments. + * + * @expandable + */ fulfillments: FulfillmentDTO[] + + /** + * The fulfillment status of the order detail. + */ fulfillment_status: FulfillmentStatus } +/** + * The order change details. + */ export interface OrderChangeDTO { /** * The ID of the order change */ id: string + /** * The version of the order change */ version: number + /** * The type of the order change */ change_type?: "return" | "exchange" | "claim" | "edit" + /** * The ID of the associated order */ order_id: string + /** * The ID of the associated return order */ return_id: string + /** * The ID of the associated exchange order */ exchange_id: string + /** * The ID of the associated claim order */ claim_id: string + /** * The associated order * * @expandable */ order: OrderDTO + /** * The associated return order * * @expandable */ return_order: ReturnDTO + /** * The associated exchange order * * @expandable */ exchange: OrderExchangeDTO + /** * The associated claim order * @@ -1302,69 +1761,87 @@ export interface OrderChangeDTO { * @expandable */ actions: OrderChangeActionDTO[] + /** * The status of the order change */ status: string + /** * The requested by of the order change */ requested_by: string | null + /** * When the order change was requested */ requested_at: Date | string | null + /** * The confirmed by of the order change */ confirmed_by: string | null + /** * When the order change was confirmed */ confirmed_at: Date | string | null + /** * The declined by of the order change */ declined_by: string | null + /** * The declined reason of the order change */ declined_reason: string | null + /** * The metadata of the order change */ metadata: Record | null + /** * When the order change was declined */ declined_at: Date | string | null + /** * The canceled by of the order change */ canceled_by: string | null + /** * When the order change was canceled */ canceled_at: Date | string | null + /** * When the order change was created */ created_at: Date | string + /** * When the order change was updated */ updated_at: Date | string } +/** + * The order change action details. + */ export interface OrderChangeActionDTO { /** * The ID of the order change action */ id: string + /** * The ID of the associated order change */ order_change_id: string | null + /** * The associated order change * @@ -1376,338 +1853,801 @@ export interface OrderChangeActionDTO { * The ID of the associated order */ order_id: string | null + + /** + * The ID of the associated return. + */ return_id: string | null + + /** + * The ID of the associated claim. + */ claim_id: string | null + + /** + * The ID of the associated exchange. + */ exchange_id: string | null + /** * The associated order * * @expandable */ order: OrderDTO | null + /** * The reference of the order change action */ reference: string + /** * The ID of the reference */ reference_id: string + /** * The action of the order change action */ action: ChangeActionType + /** * The details of the order change action */ details: Record | null + /** * The internal note of the order change action */ internal_note: string | null + /** * When the order change action was created */ created_at: Date | string + /** * When the order change action was updated */ updated_at: Date | string } +/** + * The order transaction details. + */ export interface OrderTransactionDTO { /** * The ID of the transaction */ id: string + /** * The ID of the associated order */ order_id: string + /** * The associated order * * @expandable */ order: OrderDTO + /** * The amount of the transaction */ amount: BigNumberValue + /** * The raw amount of the transaction */ raw_amount: BigNumberRawValue + /** * The currency code of the transaction */ currency_code: string + /** * The reference of the transaction */ reference: string + /** * The ID of the reference */ reference_id: string + /** * When the transaction was created */ created_at: Date | string + /** * When the transaction was updated */ updated_at: Date | string } +/** + * The order transaction details. + */ export interface OrderTransactionDTO { /** * The ID of the transaction */ id: string + /** * The ID of the associated order */ order_id: string + /** * The associated order * * @expandable */ order: OrderDTO + /** * The amount of the transaction */ amount: BigNumberValue + /** * The raw amount of the transaction */ raw_amount: BigNumberRawValue + /** * The currency code of the transaction */ currency_code: string + /** * The reference of the transaction */ reference: string + /** * The ID of the reference */ reference_id: string + /** * The metadata of the transaction */ metadata: Record | null + /** * When the transaction was created */ created_at: Date | string + /** * When the transaction was updated */ updated_at: Date | string } +/** + * The order return reason details. + */ export interface OrderReturnReasonDTO { /** * The ID of the return reason */ id: string + /** * The unique value of the return reason */ value: string + /** * The label of the return reason */ label: string + /** * The description of the return reason */ description?: string + /** * The parent return reason ID */ parent_return_reason_id?: string + /** + * The associated order return reason. + */ parent_return_reason?: OrderReturnReasonDTO + /** + * The return reason children of the order return reason. + */ return_reason_children?: OrderReturnReasonDTO[] /** * The metadata of the return reason */ metadata: Record | null + /** * When the return reason was created */ created_at: Date | string + /** * When the return reason was updated */ updated_at: Date | string } +/** + * The filters to apply on the retrieved orders. + */ export interface FilterableOrderProps extends BaseFilterable { + /** + * The IDs to filter the orders by. + */ id?: string | string[] + /** + * Filter orders by their associated sales channel's ID. + */ sales_channel_id?: string | string[] | OperatorMap + + /** + * Filter orders by their associated customer's ID. + */ customer_id?: string | string[] | OperatorMap + + /** + * Filter orders by their associated region's ID. + */ region_id?: string | string[] | OperatorMap + /** + * Filter the orders by their creation date. + */ created_at?: OperatorMap + + /** + * Filter orders by their update date. + */ updated_at?: OperatorMap } +/** + * The filters to apply on the retrieved order addresss. + */ export interface FilterableOrderAddressProps extends BaseFilterable { + /** + * The IDs to filter the order addresss by. + */ id?: string | string[] } +/** + * The filters to apply on the retrieved order line items. + */ export interface FilterableOrderLineItemProps extends BaseFilterable { + /** + * The IDs to filter the order line items by. + */ id?: string | string[] + + /** + * Filter line items by their associated order's ID. + */ order_id?: string | string[] + + /** + * Filter by line items' title. + */ title?: string + + /** + * Filter line items by their associated variant's ID. + */ variant_id?: string | string[] + + /** + * Filter line items by their associated product's ID. + */ product_id?: string | string[] } +/** + * The filters to apply on the retrieved line item adjustments. + */ export interface FilterableOrderLineItemAdjustmentProps extends BaseFilterable { + /** + * The IDs to filter the line item adjustments by. + */ id?: string | string[] + + /** + * Filter adjustments by their associated item's ID. + */ item_id?: string | string[] + + /** + * Filter adjustments by their associated promotion's ID. + */ promotion_id?: string | string[] + + /** + * Filter adjustments by their associated provider's ID. + */ provider_id?: string | string[] + + /** + * The filters to apply on the associated line items. + */ item?: FilterableOrderLineItemProps } + +/** + * The filters to apply on the retrieved shipping methods. + */ export interface FilterableOrderShippingMethodProps extends BaseFilterable { + /** + * The IDs to filter the shipping methods by. + */ id?: string | string[] + + /** + * Filter the shipping methods by their associated order's ID. + */ order_id?: string | string[] + + /** + * Filter shipping methods by their name. + */ name?: string + + /** + * Filter the shipping methods by their associated shipping option's ID. + */ shipping_option_id?: string | string[] } +/** + * The filters to apply on the retrieved shipping method adjustments. + */ export interface FilterableOrderShippingMethodAdjustmentProps extends BaseFilterable { + /** + * The IDs to filter the shipping method adjustments by. + */ id?: string | string[] + + /** + * Filter the adjustments by their associated shipping method's ID. + */ shipping_method_id?: string | string[] + + /** + * Filter the adjustments by their associated promotion's ID. + */ promotion_id?: string | string[] + + /** + * Filter the adjustments by their associated provider's ID. + */ provider_id?: string | string[] + + /** + * The filters to apply on the associated shipping methods. + */ shipping_method?: FilterableOrderShippingMethodProps } +/** + * The filters to apply on the retrieved line item tax lines. + */ export interface FilterableOrderLineItemTaxLineProps extends BaseFilterable { + /** + * The IDs to filter the line item tax lines by. + */ id?: string | string[] + + /** + * Filter line item tax lines by their description. + */ description?: string + + /** + * Filter line item tax lines by their code. + */ code?: string | string[] + + /** + * Filter the tax lines by their associated tax rate's ID. + */ tax_rate_id?: string | string[] + + /** + * Filter the tax lines by their associated provider's ID. + */ provider_id?: string | string[] + + /** + * Filter the tax lines by their associated item's ID. + */ item_id?: string | string[] + + /** + * The filters to apply on the associated line items. + */ item?: FilterableOrderLineItemProps } +/** + * The filters to apply on the retrieved shipping method tax lines. + */ export interface FilterableOrderShippingMethodTaxLineProps extends BaseFilterable { + /** + * The IDs to filter the order shipping method tax lines by. + */ id?: string | string[] + + /** + * Filter the tax lines by their description + */ description?: string + + /** + * Filter the tax lines by their code. + */ code?: string | string[] + + /** + * Filter the tax lines by their associated tax rate's ID. + */ tax_rate_id?: string | string[] + + /** + * Filter the tax lines by their associated provider's ID. + */ provider_id?: string | string[] + + /** + * Filter the tax lines by their associated shipping method's ID. + */ shipping_method_id?: string | string[] + + /** + * The filters to apply on the retrieved associated shipping methods. + */ shipping_method?: FilterableOrderShippingMethodProps } +/** + * The filters to apply on the retrieved order changes. + */ export interface FilterableOrderChangeProps extends BaseFilterable { + /** + * The IDs to filter the order changes by. + */ id?: string | string[] | OperatorMap + + /** + * Filter the changes by their associated order's ID. + */ order_id?: string | string[] | OperatorMap + + /** + * Filter the order changes by their status. + */ status?: string | string[] | OperatorMap + + /** + * Filter the order changes by who requested them. + */ requested_by?: string | string[] | OperatorMap + + /** + * Filter the order changes by who confirmed them. + */ confirmed_by?: string | string[] | OperatorMap + + /** + * Filter the order changes by who declined them. + */ declined_by?: string | string[] | OperatorMap + + /** + * Filter the order changes by who canceled them. + */ canceled_by?: string | string[] | OperatorMap + + /** + * Filter the order changes by their creation date. + */ created_at?: OperatorMap + + /** + * Filter the order changes by their update date. + */ updated_at?: OperatorMap + + /** + * Filter the order changes by their deletion date. + */ deleted_at?: OperatorMap + + /** + * Filter the order changes by their cancelation date. + */ canceled_at?: OperatorMap } +/** + * The filters to apply on the retrieved order change actions. + */ export interface FilterableOrderChangeActionProps extends BaseFilterable { + /** + * The IDs to filter the order change actions by. + */ id?: string | string[] | OperatorMap + + /** + * Filter the actions by their associated order change's ID. + */ order_change_id?: string | string[] | OperatorMap + + /** + * Filter the actions by their reference. + */ reference?: string | string[] | OperatorMap + + /** + * Filter the actions by their reference ID. + */ reference_id?: string | string[] | OperatorMap } +/** + * The filters to apply on the retrieved transactions. + */ export interface FilterableOrderTransactionProps extends BaseFilterable { + /** + * The IDs to filter the transactions by. + */ id?: string | string[] | OperatorMap + + /** + * Filter the transactions by their associated order's ID. + */ order_id?: string | string[] | OperatorMap + + /** + * Filter the transactions by their currency code. + */ currency_code?: string | string[] | OperatorMap + + /** + * Filter the transactions by their reference. + */ reference?: string | string[] | OperatorMap + + /** + * Filter the transactions by their associated reference's ID. + */ reference_id?: string | string[] | OperatorMap + /** + * Filter the transactions by their creation date. + */ created_at?: OperatorMap } +/** + * The filters to apply on the retrieved order items. + */ export interface FilterableOrderItemProps extends BaseFilterable { + /** + * The IDs to filter the order items by. + */ id?: string | string[] | OperatorMap + + /** + * Filter the order items by their associated order's ID. + */ order_id?: string | string[] | OperatorMap + + /** + * Filter the order items by their version. + */ version?: string | string[] | OperatorMap + + /** + * Filter the order items by their associated line item's ID. + */ item_id?: string | string[] | OperatorMap } +/** + * The filters to apply on the retrieved return reasons. + */ export interface FilterableOrderReturnReasonProps extends BaseFilterable { + /** + * The IDs to filter the return reasons by. + */ id?: string | string[] + + /** + * Filter the return reason by their value. + */ value?: string | string[] + + /** + * Filter the return reason by their label. + */ label?: string + + /** + * Filter the return reason by their description. + */ description?: string } +/** + * The filters to apply on the retrieved returns. + */ export interface FilterableReturnProps extends BaseFilterable { + /** + * The IDs to filter the returns by. + */ id?: string | string[] + + /** + * Filter the returns by their associated order's ID. + */ order_id?: string | string[] + + /** + * Filter the returns by their associated claim's ID. + */ claim_id?: string | string[] + + /** + * Filter the returns by their associated exchange's ID. + */ exchange_id?: string | string[] + + /** + * Filter the returns by their status. + */ status?: string | string[] + + /** + * Filter the returns by their refund amount. + */ refund_amount?: string | string[] } +/** + * The filters to apply on the retrieved claims. + */ export interface FilterableOrderClaimProps extends BaseFilterable { + /** + * The IDs to filter the claims by. + */ id?: string | string[] + + /** + * Filter the claims by their associated order's ID. + */ order_id?: string | string[] + + /** + * Filter the claims by their associated return's ID. + */ return_id?: string | string[] } +/** + * The filters to apply on the retrieved exchanges. + */ export interface FilterableOrderExchangeProps extends BaseFilterable { + /** + * The IDs to filter the exchanges by. + */ id?: string | string[] + + /** + * Filter the exchanges by their associated order's ID. + */ order_id?: string | string[] + + /** + * Filter the exchanges by their associated return's ID. + */ return_id?: string | string[] + + /** + * Filter the exchanges by whether backorders are allowed. + */ allow_backorder?: boolean } +/** + * The details of changes made on orders. + */ export interface OrderChangeReturn { + /** + * The list of items created or updated. + */ items: { + /** + * The associated item's ID. + */ item_id: string + + /** + * The associated order's ID. + */ order_id: string + + /** + * The item's fulfilled quantity. + */ fulfilled_quantity: BigNumberInput + + /** + * The item's shipped quantity. + */ shipped_quantity: BigNumberInput + + /** + * The item's request quantity to be returned. + */ return_requested_quantity: BigNumberInput + + /** + * The item's quantity that was received through a return. + */ return_received_quantity: BigNumberInput + + /** + * The item's quantity that was dismissed in a return. + */ return_dismissed_quantity: BigNumberInput + + /** + * The item's quantity that was written off. + */ written_off_quantity: BigNumberInput + + /** + * Other details updated in an item. + */ [key: string]: any }[] + + /** + * The list of shipping methods created or updated. + */ shippingMethods: any[] } diff --git a/packages/core/types/src/order/mutations.ts b/packages/core/types/src/order/mutations.ts index 67606905dc..63df655fdf 100644 --- a/packages/core/types/src/order/mutations.ts +++ b/packages/core/types/src/order/mutations.ts @@ -11,437 +11,1538 @@ import { } from "./common" /** ADDRESS START */ +/** + * The data to create or update in the address. + */ export interface UpsertOrderAddressDTO { + /** + * The associated customer's ID. + */ customer_id?: string + + /** + * The company name. + */ company?: string + + /** + * The first name of the customer. + */ first_name?: string + + /** + * The last name of the customer. + */ last_name?: string + + /** + * The address 1 of the address. + */ address_1?: string + + /** + * The address 2 of the address. + */ address_2?: string + + /** + * The city of the address. + */ city?: string + + /** + * The 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 | null } +/** + * The attributes to update in the address. + */ export interface UpdateOrderAddressDTO extends UpsertOrderAddressDTO { + /** + * The ID of the address. + */ id: string } +/** + * The address to be created. + */ export interface CreateOrderAddressDTO extends UpsertOrderAddressDTO {} /** ADDRESS END */ - /** ORDER START */ +/** + * The data of the order to be created. + */ export interface CreateOrderDTO { + /** + * 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 status of the order. + */ status?: string + + /** + * The email of the customer that placed the order. + */ email?: string + + /** + * The currency code of the order. + */ 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 order. + */ shipping_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO + + /** + * The billing address of the order. + */ billing_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO + + /** + * Whether the customer should receive notifications about + * order updates. + */ no_notification?: boolean + + /** + * The items of the order. + */ items?: CreateOrderLineItemDTO[] + + /** + * The shipping methods of the order. + */ shipping_methods?: Omit[] + + /** + * The transactions of the order. + */ transactions?: Omit[] + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + /** + * The promo codes of the order. + */ promo_codes?: string[] } +/** + * The attributes to update in the order. + */ export interface UpdateOrderDTO { + /** + * The ID of the order. + */ id?: string + + /** + * The version of the order. + */ version?: number + + /** + * 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 items of the order. + */ items?: CreateOrderLineItemDTO[] + + /** + * The shipping address of the order. + */ shipping_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO + + /** + * The billing address of the order. + */ billing_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO + + /** + * The email of the customer that placed the order. + */ email?: string + + /** + * Whether the customer should receive notifications + * about order updates. + */ no_notification?: boolean + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } /** ORDER END */ - /** ADJUSTMENT START */ +/** + * The data of the order adjustment to be created. + */ export interface CreateOrderAdjustmentDTO { + /** + * The code of the adjustment. + */ code?: string + + /** + * The amount of the adjustment. + */ amount: BigNumberInput + + /** + * 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 UpdateOrderAdjustmentDTO { + /** + * The ID of the adjustment. + */ id: string + + /** + * The code of the adjustment. + */ code?: string + + /** + * The amount of the adjustment. + */ amount: BigNumberInput + + /** + * 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 CreateOrderLineItemAdjustmentDTO extends CreateOrderAdjustmentDTO { + /** + * The associated item's ID. + */ item_id: string } +/** + * The attributes to update in the line item adjustment. + */ export interface UpdateOrderLineItemAdjustmentDTO extends UpdateOrderAdjustmentDTO { + /** + * The associated item's ID. + */ item_id: string } +/** + * The attributes in the line item adjustment to be created or updated. + */ export interface UpsertOrderLineItemAdjustmentDTO { + /** + * The ID of the line item adjustment. + */ id?: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The code of the line item adjustment. + */ code?: string + + /** + * The amount of the line item adjustment. + */ amount?: BigNumberInput + + /** + * 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 } /** ADJUSTMENTS END */ - /** TAX LINES START */ - +/** + * The dat of the tax line to be created. + */ export interface CreateOrderTaxLineDTO { + /** + * 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: BigNumberInput + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The attributes to update in the tax line. + */ export interface UpdateOrderTaxLineDTO { + /** + * 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?: BigNumberInput + + /** + * The associated provider's ID. + */ provider_id?: string } +/** + * The shipping method tax line to be created. + */ export interface CreateOrderShippingMethodTaxLineDTO extends CreateOrderTaxLineDTO {} +/** + * The attributes to update in the shipping method tax line. + */ export interface UpdateOrderShippingMethodTaxLineDTO extends UpdateOrderTaxLineDTO {} +/** + * The line item tax line to be created. + */ export interface CreateOrderLineItemTaxLineDTO extends CreateOrderTaxLineDTO {} +/** + * The attributes to update in the line item tax line. + */ export interface UpdateOrderLineItemTaxLineDTO extends UpdateOrderTaxLineDTO {} /** TAX LINES END */ - /** LINE ITEMS START */ +/** + * The data of the line item to create. + */ export interface CreateOrderLineItemDTO { + /** + * 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 order's ID. + */ order_id?: string + /** + * The quantity of the line item. + */ quantity: BigNumberInput + /** + * The associated product's ID. + */ product_id?: string + + /** + * The product title of the line item. + */ product_title?: string + + /** + * The product description of the line item. + */ product_description?: string + + /** + * The product subtitle of the line item. + */ product_subtitle?: string + + /** + * The product type of the line item. + */ product_type?: string + + /** + * The product collection of the line item. + */ product_collection?: string + + /** + * The product handle of the line item. + */ product_handle?: string + /** + * The associated variant's ID. + */ variant_id?: string + + /** + * The variant sku of the line item. + */ variant_sku?: string + + /** + * The variant barcode of the line item. + */ variant_barcode?: string + + /** + * The variant title of the line item. + */ variant_title?: string + + /** + * The variant option values of the line item. + */ 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 is tax inclusive. + */ is_tax_inclusive?: boolean + /** + * The compare-at unit price of the line item. + */ compare_at_unit_price?: BigNumberInput + + /** + * The unit price of the line item. + */ unit_price: BigNumberInput + /** + * The tax lines of the line item. + */ tax_lines?: CreateOrderTaxLineDTO[] + + /** + * The adjustments of the line item. + */ adjustments?: CreateOrderAdjustmentDTO[] + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The line item to be created. + */ export interface CreateOrderLineItemForOrderDTO extends CreateOrderLineItemDTO { + /** + * The associated order's ID. + */ order_id: string } +/** + * The attributes to update in the line item with selector. + */ export interface UpdateOrderLineItemWithSelectorDTO { + /** + * The selector of the line item with selector. + */ selector: Partial + + /** + * The data of the line item with selector. + */ data: Partial } +/** + * The attributes to update in the line item. + */ export interface UpdateOrderLineItemDTO extends Omit< CreateOrderLineItemDTO, "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. + */ quantity?: BigNumberInput + + /** + * The unit price of the line item. + */ unit_price?: BigNumberInput + /** + * The tax lines of the line item. + */ tax_lines?: UpdateOrderTaxLineDTO[] | CreateOrderTaxLineDTO[] + + /** + * The adjustments of the line item. + */ adjustments?: UpdateOrderAdjustmentDTO[] | CreateOrderAdjustmentDTO[] } /** LINE ITEMS END */ - /** SHIPPING METHODS START */ - +/** + * The data of the shipping method to be created. + */ export interface CreateOrderShippingMethodDTO { + /** + * The name of the shipping method. + */ name: string + + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated return's ID. + */ return_id?: string + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string + + /** + * The version of the shipping method. + */ version?: number + + /** + * The amount of the shipping method. + */ amount: BigNumberInput + + /** + * Whether the shipping method is tax inclusive. + */ is_tax_inclusive?: boolean + + /** + * The associated shipping option's ID. + */ shipping_option_id?: string + + /** + * The data of the shipping method. + */ data?: Record + + /** + * The tax lines of the shipping method. + */ tax_lines?: CreateOrderTaxLineDTO[] + + /** + * The adjustments of the shipping method. + */ adjustments?: CreateOrderAdjustmentDTO[] } +/** + * The attributes to update in the shipping method. + */ export interface UpdateOrderShippingMethodDTO { + /** + * The ID of the shipping method. + */ id: string + + /** + * The name of the shipping method. + */ name?: string + + /** + * The associated shipping option's ID. + */ shipping_option_id?: string + + /** + * The amount of the shipping method. + */ amount?: BigNumberInput + + /** + * The data of the shipping method. + */ data?: Record + + /** + * The tax lines of the shipping method. + */ tax_lines?: UpdateOrderTaxLineDTO[] | CreateOrderTaxLineDTO[] + + /** + * The adjustments of the shipping method. + */ adjustments?: CreateOrderAdjustmentDTO[] | UpdateOrderAdjustmentDTO[] } +/** + * The shipping method adjustment to be created. + */ export interface CreateOrderShippingMethodAdjustmentDTO { + /** + * The associated shipping method's ID. + */ shipping_method_id: string + + /** + * The code of the adjustment. + */ code: string + + /** + * The amount of the adjustment. + */ amount: BigNumberInput + + /** + * 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 shipping method adjustment. + */ export interface UpdateOrderShippingMethodAdjustmentDTO { + /** + * The ID of the shipping method adjustment. + */ id: string + + /** + * The code of the adjustment. + */ code?: string + + /** + * The amount of the adjustment. + */ amount?: BigNumberInput + + /** + * The description of the adjustment. + */ description?: string + + /** + * The associated promotion's ID. + */ promotion_id?: string + + /** + * The associated provider's ID. + */ provider_id?: string } /** SHIPPING METHODS END */ - /** ORDER CHANGE START */ - +/** + * The data of the order change to be created. + */ export interface CreateOrderChangeDTO { + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated return's ID. + */ return_id?: string + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string + + /** + * The type of the order change. + */ change_type?: | "return_request" | "return_receive" | "exchange" | "claim" | "edit" + + /** + * The description of the order change. + */ description?: string + + /** + * The internal note of the order change. + */ internal_note?: string | null + + /** + * The user or customer that requested the order change. + */ requested_by?: string + + /** + * The date that the order change was requested. + */ requested_at?: Date + + /** + * The user that created the order change. + */ created_by?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The actions of the order change. + */ actions?: CreateOrderChangeActionDTO[] } +/** + * The attributes to update in the order change. + */ export interface UpdateOrderChangeDTO { + /** + * The ID of the order change. + */ id: string + + /** + * The status of the order change. + */ status?: string + + /** + * The description of the order change. + */ description?: string + + /** + * The internal note of the order change. + */ internal_note?: string | null + + /** + * The user or customer that requested the + * order change. + */ requested_by?: string | null + + /** + * The date the order change was requested. + */ requested_at?: Date | null + + /** + * The user or customer that confirmed the + * order change. + */ confirmed_by?: string | null + + /** + * The date the order change was confirmed. + */ confirmed_at?: Date | null + + /** + * The user or customer that declined + * the order change. + */ declined_by?: string | null + + /** + * The reason that the order change was declined. + */ declined_reason?: string | null + + /** + * The date that the order change was declined. + */ declined_at?: Date | null + + /** + * The user or customer that canceled the + * order change. + */ canceled_by?: string | null + + /** + * The date that the order change was canceled. + */ canceled_at?: Date | null + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The details of the order change cancelation. + */ export interface CancelOrderChangeDTO { + /** + * The ID of the order change. + */ id: string + + /** + * The user or customer that canceled the order change. + */ canceled_by?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The details of declining the order change. + */ export interface DeclineOrderChangeDTO { + /** + * The ID of the order change. + */ id: string + + /** + * The user or customer who declined the order change. + */ declined_by?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The details of the order change confirmation. + */ export interface ConfirmOrderChangeDTO { + /** + * The ID of the order change. + */ id: string + + /** + * The user or customer that confirmed the + * order change. + */ confirmed_by?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } /** ORDER CHANGE END */ - /** ORDER CHANGE ACTION START */ - +/** + * The data of the order change action to be created. + */ export interface CreateOrderChangeActionDTO { + /** + * The associated order change's ID. + */ order_change_id?: string + + /** + * The associated order's ID. + */ order_id?: string + + /** + * The associated return's ID. + */ return_id?: string + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string + + /** + * The version of the order change action. + * Once the order change action is confirmed, this + * becomes the order's version. + */ version?: number + + /** + * The name of the data model that this action + * references. For example, `return`. + */ reference?: string + + /** + * The ID of the record references of the data model + * specified in {@link reference}. + * + * For example, if `reference` is `return`, the `reference_id` + * is the ID of the return. + */ reference_id?: string + + /** + * The type of action. + */ action: ChangeActionType + + /** + * The internal note of the order change action. + */ internal_note?: string | null + + /** + * The amount of the order change action. + */ amount?: BigNumberInput + + /** + * The details of the order change action. + * + * This could include the returned items or their changed + * quantity, based on the type of this action. + */ details?: Record } +/** + * The attributes to update in the order change action. + */ export interface UpdateOrderChangeActionDTO { + /** + * The ID of the order change action. + */ id: string + + /** + * The internal note of the order change action. + */ internal_note?: string | null } /** ORDER TRANSACTION START */ - +/** + * The data of the transaction to be created. + */ export interface CreateOrderTransactionDTO { + /** + * The associated order's ID. + */ order_id: string + + /** + * The description of the transaction. + */ description?: string + + /** + * The data model this transaction references. + * For example, `payment`. + */ reference?: string + + /** + * The ID of the data model's record referenced. + * For example, `pay_132`. + */ reference_id?: string + + /** + * The internal note of the transaction. + */ internal_note?: string | null + + /** + * The user or customer that created this + * transaction. + */ created_by?: string + + /** + * The amount of the transaction. + */ amount: BigNumberInput + + /** + * The currency code of the transaction. + */ currency_code: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the transaction. + */ export interface UpdateOrderTransactionDTO { + /** + * The ID of the transaction. + */ id: string + + /** + * The amount of the transaction. + */ amount?: BigNumberInput + + /** + * The currency code of the transaction. + */ currency_code?: string + + /** + * The description of the transaction. + */ description?: string + + /** + * The internal note of the transaction. + */ internal_note?: string | null + + /** + * The data model this transaction references. + * For example, `payment`. + */ reference?: string + + /** + * The ID of the data model's record referenced. + * For example, `pay_132`. + */ reference_id?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the transaction with filters + * specifying which transactions to update. + */ export interface UpdateOrderTransactionWithSelectorDTO { + /** + * The filters specifying which transactions to update. + */ selector: Partial + + /** + * The data of the transaction to update. + */ data: Partial } /** ORDER TRANSACTION END */ - /** ORDER DETAIL START */ +/** + * The data to update in the order items. + */ export interface UpdateOrderItemDTO { + /** + * The ID of the item. + */ id: string + + /** + * The associated order's ID. + */ order_id?: string + + /** + * The version of the item. + */ version?: number + + /** + * The associated item's ID. + */ item_id?: string + + /** + * The quantity of the item. + */ quantity?: BigNumberInput + + /** + * The fulfilled quantity of the item. + */ fulfilled_quantity?: BigNumberInput + + /** + * The requested quantity of the item to be returned. + */ return_requested_quantity?: BigNumberInput + + /** + * The quantity of the item received through a return. + */ return_received_quantity?: BigNumberInput + + /** + * The dismissed quantity of the item through a return. + */ return_dismissed_quantity?: BigNumberInput + + /** + * The quantity written off of the item due to + * an order change. + */ written_off_quantity?: BigNumberInput + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the item with filters specifying + * which items to update. + */ export interface UpdateOrderItemWithSelectorDTO { + /** + * The filters specifying which items to update. + */ selector: Partial + + /** + * The data of the item to update. + */ data: Partial } /** ORDER DETAIL END */ - /** ORDER bundled action flows */ - +/** + * The details of an item used in a change action + * performed on an order. + */ interface BaseOrderBundledItemActionsDTO { + /** + * The ID of the item. + */ id: string + + /** + * The quantity of the item. + */ quantity: BigNumberInput + + /** + * The internal note of the item. + */ internal_note?: string + + /** + * The note of the item. + */ note?: string | null + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * Other details related to the item. + */ [key: string]: any } + +/** + * The details of the action performed on an order, + * return, claim, or exchange. + */ interface BaseOrderBundledActionsDTO { + /** + * The associated order's ID. + */ order_id: string + + /** + * The associated return's ID. + */ return_id?: string + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string + /** + * The description of the action. + */ description?: string + + /** + * The internal note of the action. + */ internal_note?: string + + /** + * The name of the data model the action + * references. For example, `return`. + */ reference?: string + + /** + * The ID of the record of the data model + * specified in {@link reference}. + * + * For example, if `reference` is `return`, the + * value is `return_123`. + */ reference_id?: string + + /** + * The user or customer that created this action. + */ created_by?: string | null + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The details to register a fulfillment of an order, return, + * exchange, or claim. + */ export interface RegisterOrderFulfillmentDTO extends BaseOrderBundledActionsDTO { + /** + * The items of the fulfillment. + */ items: BaseOrderBundledItemActionsDTO[] } +/** + * The details to cancel a fulfillment of an order, return, + * exchange, or claim. + */ export interface CancelOrderFulfillmentDTO extends BaseOrderBundledActionsDTO { + /** + * The items whose fulfillment is canceled. + */ items: BaseOrderBundledItemActionsDTO[] } +/** + * The details to register a shipment of an order, return, exchange, + * or claim. + */ export interface RegisterOrderShipmentDTO extends BaseOrderBundledActionsDTO { + /** + * The items of the shipment. + */ items?: BaseOrderBundledItemActionsDTO[] + + /** + * Whether the customer should receive notifications about the shipment. + */ no_notification?: boolean } +/** + * The return to be created. + */ export interface CreateOrderReturnDTO extends BaseOrderBundledActionsDTO { + /** + * The ID of the location to return the items to. + */ location_id?: string + + /** + * The items of the return. + */ items?: { + /** + * The ID of the item. + */ id: string + + /** + * The quantity of the item. + */ quantity: BigNumberInput + + /** + * The internal note of the item. + */ internal_note?: string | null + + /** + * The note of the item. + */ note?: string | null + + /** + * The associated reason's ID. + */ reason_id?: string | null + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null }[] + + /** + * The shipping method of the return. + */ shipping_method?: Omit | string + + /** + * The refund amount of the return. + */ refund_amount?: BigNumberInput + + /** + * Whether the customer should receive notifications related to + * updates on the return. + */ no_notification?: boolean + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string } +/** + * A return's status. + */ export type ReturnStatus = | "open" | "requested" @@ -449,171 +1550,611 @@ export type ReturnStatus = | "partially_received" | "canceled" +/** + * The attributes to update in the return. + */ export interface UpdateReturnDTO { + /** + * The ID of the return. + */ id: string + + /** + * The ID of the location to return the items to. + */ location_id?: string + + /** + * The refund amount of the return. + */ refund_amount?: BigNumberInput + + /** + * Whether the customer should receive notifications related + * to updates on the return. + */ no_notification?: boolean + + /** + * The associated claim's ID. + */ claim_id?: string + + /** + * The associated exchange's ID. + */ exchange_id?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null + + /** + * The items of the return. + */ items?: { + /** + * The quantity of the item. + */ quantity: BigNumberInput + + /** + * The internal note of the item. + */ internal_note?: string | null + + /** + * The note of the item. + */ note?: string | null + + /** + * The associated reason's ID. + */ reason_id?: string | null + + /** + * The associated return's ID. + */ return_id?: string | null + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null }[] status?: ReturnStatus requested_at?: Date } +/** + * The attributes to update in the claim. + */ export interface UpdateOrderClaimDTO { + /** + * The ID of the claim. + */ id: string + + /** + * The refund amount of the claim. + */ refund_amount?: BigNumberInput + + /** + * Whether the customer should receive notifications + * about updates related to the claim. + */ no_notification?: boolean + + /** + * The associated return's ID, if the + * claim's {@link type} is `replace`. + */ return_id?: string + + /** + * The type of the claim. + */ type?: OrderClaimType + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the exchange. + */ export interface UpdateOrderExchangeDTO { + /** + * The ID of the exchange. + */ id: string + + /** + * The difference due of the exchange. + * + * - If less than `0`, the merchant owes the customer this amount. + * - If greater than `0`, the customer owes the merchange this amount. + * - If equal to `0`, no payment is required by either sides. + */ difference_due?: BigNumberInput + + /** + * Whether the customer should receive notifications related + * to updates on the exchange. + */ no_notification?: boolean + + /** + * The associated return's ID. + */ return_id?: string + + /** + * Whether backorders are allowed on the exchange's items. + */ allow_backorder?: boolean + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The order return item to be created. + */ export interface CreateOrderReturnItemDTO { + /** + * The ID of the associated return. + */ return_id: string + + /** + * The ID of the associated line item. + */ item_id: string + + /** + * The quantity to return. + */ quantity?: BigNumberInput + + /** + * The ID of the associated return reason. + */ reason_id?: string + + /** + * The note of the return. + */ note?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The order claim item to be created. + */ export interface CreateOrderClaimItemDTO { + /** + * The associated claim's ID. + */ claim_id: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The reason of the order claim item + */ reason?: ClaimReason + + /** + * Whether the order claim item is an additional item sent + * as a replacement to the customer. + */ is_additional_item?: boolean + + /** + * The quantity of the order claim item + */ quantity?: BigNumberInput + + /** + * The note of the order claim item + */ note?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The order exchange item to be created. + */ export interface CreateOrderExchangeItemDTO { + /** + * The associated exchange's ID. + */ exchange_id: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The quantity of the order exchange item + */ quantity?: BigNumberInput + + /** + * The note of the order exchange item + */ note?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The order exchange item to be created. + */ export interface CreateOrderExchangeItemDTO { + /** + * The associated exchange's ID. + */ exchange_id: string + + /** + * The associated item's ID. + */ item_id: string + + /** + * The quantity of the order exchange item + */ quantity?: BigNumberInput + + /** + * The note of the order exchange item + */ note?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the return with filters specifying + * which returns to update. + */ export interface UpdateOrderReturnWithSelectorDTO { + /** + * The filters specifying which returns to update. + */ selector: Partial + + /** + * The data of the return to update. + */ data: Partial } +/** + * The attributes to update in the claim with filters specifying + * which claims to update. + */ export interface UpdateOrderClaimWithSelectorDTO { + /** + * The filters specifying which claims to update. + */ selector: Partial + + /** + * The data of the claim to update. + */ data: Partial } +/** + * The attributes to update in the exchange with filters specifying + * which exchanges to update. + */ export interface UpdateOrderExchangeWithSelectorDTO { + /** + * The filters specifying which exchanges to update. + */ selector: Partial + + /** + * The data of the exchange to update. + */ data: Partial } + +/** + * The details of canceling a return. + */ export interface CancelOrderReturnDTO extends Omit { + /** + * The return's ID. + */ return_id: string } +/** + * A claim's type. + */ export type OrderClaimType = "refund" | "replace" + +/** + * A claim's reason. + */ export type ClaimReason = | "missing_item" | "wrong_item" | "production_failure" | "other" + +/** + * The claim to be created. + */ export interface CreateOrderClaimDTO extends BaseOrderBundledActionsDTO { + /** + * The type of the claim. + */ type: OrderClaimType + + /** + * The items of the claim. + */ claim_items?: (BaseOrderBundledItemActionsDTO & { + /** + * The reason the item is claimed. + */ reason?: ClaimReason + + /** + * Images of the item explaining why it's claimed. + */ images?: { + /** + * The image's URL. + */ url: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null }[] })[] + + /** + * The items to be sent to the customer in replacement, if the + * claim's type is `replace`. + */ additional_items?: BaseOrderBundledItemActionsDTO[] + + /** + * The shipping methods used to send the additional items to the customer, + * if the claim's type is `replace`. + */ shipping_methods?: Omit[] | string[] + + /** + * The shipping methods used to send the items to be returned from the customer, + * if the claim's type is `replace`. + */ return_shipping?: Omit | string + + /** + * The amount to be refunded. + */ refund_amount?: BigNumberInput + + /** + * Whether the customer should receive notifications related to updates + * on the claim. + */ no_notification?: boolean } +/** + * The details of canceling a claim. + */ export interface CancelOrderClaimDTO extends Omit { + /** + * The claim's ID. + */ claim_id: string } +/** + * The exchange to be created. + */ export interface CreateOrderExchangeDTO extends BaseOrderBundledActionsDTO { + /** + * The items to be sent to the customer. + */ additional_items?: BaseOrderBundledItemActionsDTO[] + + /** + * The shipping methods used to send the additional items + * to the customer. + */ shipping_methods?: Omit[] | string[] + + /** + * The shipping methods used to return items from the customer. + */ return_shipping?: Omit | string + + /** + * The difference due of the exchange. + * + * - If less than `0`, the merchant owes the customer this amount. + * - If greater than `0`, the customer owes the merchange this amount. + * - If equal to `0`, no payment is required by either sides. + */ difference_due?: BigNumberInput + + /** + * Whether backorder is allowed for the exchange's items. + */ allow_backorder?: boolean + + /** + * Whether the customer should receive notifications related to + * updates on the exchange. + */ no_notification?: boolean } +/** + * The details of the exchange cancelation. + */ export interface CancelOrderExchangeDTO extends Omit { + /** + * The exchange's ID. + */ exchange_id: string } +/** + * The details of return receival. + */ export interface ReceiveOrderReturnDTO extends Omit { + /** + * The items received. + */ items: BaseOrderBundledItemActionsDTO[] + + /** + * The return's ID. + */ return_id: string } /** ORDER bundled action flows */ - +/** + * The return reason to be created. + */ export interface CreateOrderReturnReasonDTO { + /** + * The unique value of the return reason. + */ value: string + + /** + * The label of the return reason. + */ label: string + + /** + * The description of the return reason. + */ description?: string + + /** + * The associated parent return reason's ID. + */ parent_return_reason_id?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the return reason. + */ export interface UpdateOrderReturnReasonDTO { + /** + * The ID of the return reason. + */ id?: string + + /** + * The label of the return reason. + */ label?: string + + /** + * The unique value of the return reason. + */ value?: string + + /** + * The description of the return reason. + */ description?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the return reason + */ export interface ReturnReasonUpdatableFields { + /** + * he unique value of the return reason. + */ value?: string + + /** + * The label of the return reason. + */ label?: string + + /** + * The description of the return reason. + */ description?: string + + /** + * Holds custom data in key-value pairs. + */ metadata?: Record | null } +/** + * The attributes to update in the return reason with filters + * specifying which return reasons to update. + */ export interface UpdateOrderReturnReasonWithSelectorDTO { + /** + * The filters specifying which return reasons to update. + */ selector: Partial + + /** + * The data of the return reasons to update. + */ data: Partial } diff --git a/packages/core/types/src/order/service.ts b/packages/core/types/src/order/service.ts index 656545aa2a..5b9b40d5e3 100644 --- a/packages/core/types/src/order/service.ts +++ b/packages/core/types/src/order/service.ts @@ -89,24 +89,39 @@ import { UpdateReturnDTO, UpsertOrderLineItemAdjustmentDTO, } from "./mutations" - // TODO: missing listOrderShippingMethods and listOrderChanges, fix module integration to remove any cast + /** - * {summary} + * The main service interface for the Order Module. */ export interface IOrderModuleService extends IModuleService { /** - * This method retrieves a {return type} by its ID. + * This method retrieves an order by its ID. * * @param {string} orderId - The order's ID. * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a order. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The retrieved {return type}(s). + * @returns {Promise} The retrieved order. * * @example - * ```typescript - * const result = await orderModuleService.retrieveOrder("orderId123"); + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const order = await orderModuleService.retrieveOrder( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const order = await orderModuleService.retrieveOrder( + * "123", + * { + * relations: ["items"] + * } + * ) * ``` * */ @@ -117,17 +132,43 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of orders based on optional filters and configuration. * * @param {FilterableOrderProps} filters - The filters to apply on the retrieved order. * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a order. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The list of {return type}(s). + * @returns {Promise} The list of orders. * * @example - * ```typescript - * const orderDTOs = await orderModuleService.listOrders(); + * To retrieve a list of orders using their IDs: + * + * ```ts + * const orders = await orderModuleService.listOrders({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the order: + * + * ```ts + * const orders = await orderModuleService.listOrders({ + * id: ["123", "321"] + * }, { + * relations: ["items"] + * }) + * ``` + * + * 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 orders = await orderModuleService.listOrders({ + * id: ["123", "321"] + * }, { + * relations: ["items"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -138,17 +179,43 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a paginated list of {return type} along with the total count of available {return type}(s) satisfying the provided filters. + * This method retrieves a paginated list of orders along with the total count of available orders satisfying the provided filters. * * @param {FilterableOrderProps} filters - The filters to apply on the retrieved order. * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a order. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[OrderDTO[], number]>} The list of {return type}(s) along with their total count. + * @returns {Promise<[OrderDTO[], number]>} The list of orders along with their total count. * * @example - * ```typescript - * await orderModuleService.listAndCountOrders(); + * To retrieve a list of orders using their IDs: + * + * ```ts + * const [orders, count] = await orderModuleService.listAndCountOrders({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the order: + * + * ```ts + * const [orders, count] = await orderModuleService.listAndCountOrders({ + * id: ["123", "321"] + * }, { + * relations: ["items"], + * }) + * ``` + * + * 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 [orders, count] = await orderModuleService.listAndCountOrders({ + * id: ["123", "321"] + * }, { + * relations: ["items"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -158,54 +225,381 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise<[OrderDTO[], number]> + /** + * This method retrieves a return by its ID. + * + * @param {string} returnId - The return's ID. + * @param {FindConfig} config - The configurations determining how the return is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a return. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved return. + * + * @example + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const orderReturn = await orderModuleService.retrieveReturn( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const orderReturn = await orderModuleService.retrieveReturn( + * "123", + * { + * relations: ["order"] + * } + * ) + * ``` + */ retrieveReturn( returnId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of returns based on optional filters and configuration. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved returns. + * @param {FindConfig} config - The configurations determining how the return is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a return. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of returns. + * + * @example + * To retrieve a list of returns using their IDs: + * + * ```ts + * const returns = await orderModuleService.listReturns({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the return: + * + * ```ts + * const returns = await orderModuleService.listReturns({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 returns = await orderModuleService.listReturns({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listReturns( filters?: FilterableOrderProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of returns along with the total count of available returns satisfying the provided filters. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved returns. + * @param {FindConfig} config - The configurations determining how the return is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a return. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[ReturnDTO[], number]>} The list of returns along with their total count. + * + * @example + * To retrieve a list of returns using their IDs: + * + * ```ts + * const [returns, count] = await orderModuleService.listAndCountReturns({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the return: + * + * ```ts + * const [returns, count] = await orderModuleService.listAndCountReturns({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * }) + * ``` + * + * 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 [returns, count] = await orderModuleService.listAndCountReturns({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listAndCountReturns( filters?: FilterableOrderProps, config?: FindConfig, sharedContext?: Context ): Promise<[ReturnDTO[], number]> + /** + * This method retrieves an order claim by its ID. + * + * @param {string} claimId - The claim's ID. + * @param {FindConfig} config - The configurations determining how the order claim is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order claim. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved order claim. + * + * @example + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const claim = await orderModuleService.retrieveOrderClaim( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const claim = await orderModuleService.retrieveOrderClaim( + * "123", + * { + * relations: ["order"] + * } + * ) + * ``` + */ retrieveOrderClaim( - claimnId: string, + claimId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of order claims based on optional filters and configuration. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved order claims. + * @param {FindConfig} config - The configurations determining how the order claim is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order claim. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of order claims. + * + * @example + * To retrieve a list of order claims using their IDs: + * + * ```ts + * const claims = await orderModuleService.listOrderClaims({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the claim: + * + * ```ts + * const claims = await orderModuleService.listOrderClaims({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 claims = await orderModuleService.listOrderClaims({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listOrderClaims( filters?: FilterableOrderProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of order claims along with the total count of available claims satisfying the provided filters. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved order claims. + * @param {FindConfig} config - The configurations determining how the order claim is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order claim. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[OrderClaimDTO[], number]>} The list of order claims along with their total count. + * + * @example + * To retrieve a list of order claims using their IDs: + * + * ```ts + * const [claims, count] = await orderModuleService.listAndCountOrderClaims({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the claim: + * + * ```ts + * const [claims, count] = await orderModuleService.listAndCountOrderClaims({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * }) + * ``` + * + * 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 [claims, count] = await orderModuleService.listAndCountOrderClaims({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listAndCountOrderClaims( filters?: FilterableOrderProps, config?: FindConfig, sharedContext?: Context ): Promise<[OrderClaimDTO[], number]> + /** + * This method retrieves an order exchange by its ID. + * + * @param {string} exchangeId - The exchange's ID. + * @param {FindConfig} config - The configurations determining how the order exchange is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order exchange. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved order exchange. + * + * @example + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const exchange = await orderModuleService.retrieveOrderExchange( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const exchange = await orderModuleService.retrieveOrderExchange( + * "123", + * { + * relations: ["order"] + * } + * ) + * ``` + */ retrieveOrderExchange( - claimnId: string, + exchangeId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of order exchanges based on optional filters and configuration. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved exchanges. + * @param {FindConfig} config - The configurations determining how the order exchange is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order exchange. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of exchanges. + * + * @example + * To retrieve a list of exchanges using their IDs: + * + * ```ts + * const exchanges = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the exchange: + * + * ```ts + * const exchanges = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 exchanges = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listOrderExchanges( filters?: FilterableOrderProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of exchanges along with the total count of available exchanges satisfying the provided filters. + * + * @param {FilterableOrderProps} filters - The filters to apply on the retrieved exchanges. + * @param {FindConfig} config - The configurations determining how the order exchange is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order exchange. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[OrderExchangeDTO[], number]>} The list of exchanges along with their total count. + * + * @example + * To retrieve a list of exchanges using their IDs: + * + * ```ts + * const [exchanges, count] = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the exchange: + * + * ```ts + * const [exchanges, count] = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * }) + * ``` + * + * 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 [exchanges, count] = await orderModuleService.listOrderExchanges({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listAndCountOrderExchanges( filters?: FilterableOrderProps, config?: FindConfig, @@ -213,28 +607,24 @@ export interface IOrderModuleService extends IModuleService { ): Promise<[OrderExchangeDTO[], number]> /** - * This method creates {return type}(s) + * This method creates orders * * @param {CreateOrderDTO[]} data - The order 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 {return type}(s). + * @returns {Promise} The created orders. * * @example - * ```typescript - * const orderData: CreateOrderDTO[] = [ + * ```ts + * const orders = await orderModuleService.createOrders([{ + * currency_code: "usd", + * items: [ * { - * currency_code: "USD", - * items: [ - * { - * title: "Product Name", - * quantity: 1, - * unit_price: 1999, // Assuming type is an integer for price in cents - * } - * ] + * title: "Product Name", + * quantity: 1, + * unit_price: 20 * } - * ]; - * - * const result = await orderModuleService.createOrders(orderData); + * ] + * }]) * ``` * */ @@ -244,43 +634,41 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method creates {return type}(s) + * This method creates orders * * @param {CreateOrderDTO} data - The order 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 {return type}(s). + * @returns {Promise} The created orders. * * @example - * ```typescript - * // Example execution of the create method of IOrderModuleService - * const orderData: CreateOrderDTO = { - * currency_code: "USD" - * }; - * - * const createdOrder = await orderModuleService.createOrders(orderData); + * ```ts + * const order = await orderModuleService.createOrders({ + * currency_code: "usd", + * items: [ + * { + * title: "Product Name", + * quantity: 1, + * unit_price: 20 + * } + * ] + * }) * ``` * */ createOrders(data: CreateOrderDTO, sharedContext?: Context): Promise /** - * This method updates existing {return type}(s). + * This method updates existing orders. The order IDs are specified in each order object. * * @param {UpdateOrderDTO[]} data - The attributes to update in the order. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated orders. * * @example * ```typescript - * const updatedOrders = await orderModuleService.updateOrders([ - * { - * id: "order_id_1", - * status: "shipped" - * }, - * { - * id: "order_id_2", - * status: "delivered" - * } - * ]); + * const orders = await orderModuleService.updateOrders([{ + * id: "123", + * email: "example@gmail.com" + * }]) * ``` * */ @@ -290,18 +678,21 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing orders. * - * @param {string} orderId - The order's ID. + * @param {string} orderId - The ID of the order to update. * @param {UpdateOrderDTO} data - The attributes to update in the order. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated orders. * * @example * ```typescript - * await orderModuleService.updateOrders("orderId123", { - * status: "shipped" - * }); + * const order = await orderModuleService.updateOrders( + * "123", + * { + * email: "example@gmail.com" + * } + * ) * ``` * */ @@ -312,19 +703,20 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing orders matching the specified filters. * - * @param {Partial} selector - Make all properties in T optional - * @param {UpdateOrderDTO} data - The attributes to update in the order. + * @param {Partial} selector - The filters specifying which orders to update. + * @param {UpdateOrderDTO} data - The attributes to update in the orders. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated orders. * * @example * ```typescript - * await orderModuleService.updateOrders( - * { id: "order-123" }, - * { status: "completed" } - * ); + * const orders = await orderModuleService.updateOrders({ + * id: ["123", "321"] + * }, { + * email: "example@gmail.com" + * }) * ``` * */ @@ -335,47 +727,108 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes {return type} by its ID. + * This method deletes orders by its ID. * - * @param {string[]} orderIds - The list of {summary} + * @param {string[]} orderIds - The IDs of orders to delete. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the orders are deleted successfully. * * @example * ```typescript - * await orderModuleService.deleteOrders(["12345abc", "67890def"]); + * await orderModuleService.deleteOrders(["123", "321"]) * ``` * */ deleteOrders(orderIds: string[], sharedContext?: Context): Promise /** - * This method deletes {return type} by its ID. + * This method deletes an order by its ID. * * @param {string} orderId - The order'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 {summary} + * @returns {Promise} Resolves when the order is deleted successfully. * * @example * ```typescript - * await orderModuleService.deleteOrders("orderId"); + * await orderModuleService.deleteOrders("123"); * ``` * */ deleteOrders(orderId: string, sharedContext?: Context): Promise + /** + * This method soft deletes orders by their IDs. + * + * @param {string[]} orderIds - The list of order IDs. + * @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 items. + * The object's keys are the ID attribute names of the order 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 order through this relation, such as the IDs of associated item. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteOrders(["123", "321"]) + */ softDeleteOrders( - storeIds: string[], + orderIds: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft deleted orders by their IDs. + * + * @param {string[]} orderIds - The list of order IDs. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the orders. You can pass to its `returnLinkableKeys` + * property any of the order'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 IDs of associated items. + * The object's keys are the ID attribute names of the order 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 order through this relation, + * such as the IDs of associated items. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreOrders(["123", "321"]) + */ restoreOrders( - storeIds: string[], + orderIds: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method retrieves a paginated list of addresses based on optional filters and configuration. + * + * @param {FilterableOrderAddressProps} filters - The filters to apply on the retrieved order addresss. + * @param {FindConfig} config - The configurations determining how the order address is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order 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 orderModuleService.listAddresses({ + * id: ["123", "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 orderModuleService.listAddresses({ + * id: ["123", "321"] + * }, { + * take: 20, + * skip: 2 + * }) + * ``` + */ listAddresses( filters?: FilterableOrderAddressProps, config?: FindConfig, @@ -383,15 +836,15 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method creates {return type}(s) + * This method creates addresses. * - * @param {CreateOrderAddressDTO[]} data - The order address to be created. + * @param {CreateOrderAddressDTO[]} data - The addresses 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 {return type}(s). + * @returns {Promise} The created addresses. * * @example * ```typescript - * await orderModuleService.createAddresses([ + * const addresses = await orderModuleService.createAddresses([ * { * first_name: "John", * last_name: "Doe", @@ -401,7 +854,7 @@ export interface IOrderModuleService extends IModuleService { * province: "AnyState", * postal_code: "12345" * } - * ]); + * ]) * ``` * */ @@ -411,24 +864,23 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method creates {return type}(s) + * This method creates a return. * - * @param {CreateOrderAddressDTO} data - The order address to be created. + * @param {CreateOrderAddressDTO} 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 {return type}(s). + * @returns {Promise} The created return. * * @example * ```typescript - * const orderAddressData: CreateOrderAddressDTO = { - * orderId: '123', - * line1: '123 Main St', - * city: 'Metropolis', - * state: 'NY', - * postalCode: '12345', - * country: 'USA' - * }; - * - * const result = await orderModuleService.createAddresses(orderAddressData); + * const address = await orderModuleService.createAddresses({ + * first_name: "John", + * last_name: "Doe", + * address_1: "123 Main St", + * city: "Anytown", + * country_code: "US", + * province: "AnyState", + * postal_code: "12345" + * }) * ``` * */ @@ -438,28 +890,18 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing addresses. The address ID is specified in each address object. * - * @param {UpdateOrderAddressDTO[]} data - The attributes to update in the order address. + * @param {UpdateOrderAddressDTO[]} 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 {return type}(s). + * @returns {Promise} The updated addresses. * * @example * ```typescript - * const updatedAddress: UpdateOrderAddressDTO[] = [ - * { - * id: "address1", - * first_name: "John", - * last_name: "Doe", - * address_1: "123 Main St", - * city: "Anytown", - * country_code: "US", - * province: "AnyState", - * postal_code: "12345" - * } - * ]; - * - * const result = await orderModuleService.updateAddresses(updatedAddress); + * const addresses = await orderModuleService.updateAddresses([{ + * id: "123", + * first_name: "John", + * }]) * ``` * */ @@ -469,23 +911,18 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates an existing address. * - * @param {UpdateOrderAddressDTO} data - The attributes to update in the order address. + * @param {UpdateOrderAddressDTO} 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 {return type}(s). + * @returns {Promise} The updated address. * * @example * ```typescript - * const updateOrderAddressData: UpdateOrderAddressDTO = { - * id: '123', - * address_1: '123 Main St', - * city: 'Metropolis', - * province: 'NY', - * postal_code: '12345', - * }; - * - * const updatedAddress = await orderModuleService.updateAddresses(updateOrderAddressData); + * const address = await orderModuleService.updateAddresses({ + * id: "123", + * first_name: "John", + * }) * ``` * */ @@ -495,47 +932,60 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes {return type} by its ID. + * This method deletes addresses by their IDs. * - * @param {string[]} ids - The list of {summary} + * @param {string[]} ids - The list of address IDs. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the addresses are deleted. * * @example * ```typescript - * await orderModuleService.deleteAddresses(["your_address_id_1", "your_address_id_2"]); + * await orderModuleService.deleteAddresses(["123", "321"]) * ``` * */ deleteAddresses(ids: string[], sharedContext?: Context): Promise /** - * This method deletes {return type} by its ID. + * This method deletes an address by its ID. * - * @param {string} ids - {summary} + * @param {string} ids - The ID of the address. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the address is deleted. * * @example * ```typescript - * await orderModuleService.deleteAddresses("123456"); + * await orderModuleService.deleteAddresses("123") * ``` * */ deleteAddresses(ids: string, sharedContext?: Context): Promise /** - * This method retrieves a {return type} by its ID. + * This method retrieves a line item by its ID. * * @param {string} itemId - The item's ID. - * @param {FindConfig} config - The configurations determining how the order line item is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order line item. + * @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 {return type}(s). + * @returns {Promise} The retrieved line item. * * @example - * ```typescript - * await orderModuleService.retrieveLineItem("12345"); + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const lineItem = await orderModuleService.retrieveLineItem("123") + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const lineItem = await orderModuleService.retrieveLineItem( + * "123", + * { + * relations: ["order"] + * } + * ) * ``` * */ @@ -546,19 +996,43 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of line items based on optional filters and configuration. * - * @param {FilterableOrderLineItemProps} filters - The filters to apply on the retrieved order line item. - * @param {FindConfig} config - The configurations determining how the order line item is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order line item. + * @param {FilterableOrderLineItemProps} filters - The filters to apply on the retrieved line item. + * @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 {return type}(s). + * @returns {Promise} The list of line items. * * @example - * ```typescript - * const result = await orderModuleService.listLineItems({ - * title: "Sample Product Title", - * }); + * To retrieve a list of line items using their IDs: + * + * ```ts + * const lineItems = await orderModuleService.listLineItems({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the line item: + * + * ```ts + * const lineItems = await orderModuleService.listLineItems({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 orderModuleService.listLineItems({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -568,14 +1042,62 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates a line item. + * + * @param {CreateOrderLineItemDTO} data - The line item 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 line items. + * + * @example + * const lineItems = await orderModuleService.createLineItems({ + * title: "Shirt", + * quantity: 1, + * unit_price: 20 + * }) + */ createLineItems( data: CreateOrderLineItemDTO, sharedContext?: Context ): Promise + + /** + * This method creates line items. + * + * @param {CreateOrderLineItemDTO[]} data - The line items 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 line items. + * + * @example + * const lineItems = await orderModuleService.createLineItems([{ + * title: "Shirt", + * quantity: 1, + * unit_price: 20 + * }]) + */ createLineItems( data: CreateOrderLineItemDTO[], sharedContext?: Context ): Promise + + /** + * This method creates orders. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderLineItemDTO[]} items - The order line items 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 orders. + * + * @example + * const lineItems = await orderModuleService.createLineItems( + * "123", + * [{ + * title: "Shirt", + * quantity: 1, + * unit_price: 20 + * }] + * ) + */ createLineItems( orderId: string, items: CreateOrderLineItemDTO[], @@ -583,27 +1105,23 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing line items. The line item to update is specified by the `selector` property of the first parameter. * * @param {UpdateOrderLineItemWithSelectorDTO[]} data - The attributes to update in the order line item with selector. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated line items. * * @example * ```typescript - * const updateOrderLineItems: UpdateOrderLineItemWithSelectorDTO[] = [ + * const lineItems = await orderModuleService.updateLineItems([ * { * selector: { - * id: "line-item-id-1" + * id: "123" * }, * data: { - * id: "line-item-id-1", - * quantity: 2, - * unit_price: 1999 + * quantity: 2 * } * } - * ]; - * - * const updatedLineItems = await orderModuleService.updateLineItems(updateOrderLineItems); + * ]) * ``` * */ @@ -613,20 +1131,19 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing line items matching the specified filters. * - * @param {Partial} selector - Make all properties in T optional - * @param {Partial} data - Make all properties in T optional + * @param {Partial} selector - The filters specifying which line items to update. + * @param {Partial} data - The data 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 {return type}(s). + * @returns {Promise} The updated line items. * * @example - * ```typescript - * const result = await orderModuleService.updateLineItems( - * { id: "line-item-id-1" }, - * { quantity: 10 } - * ); - * ``` + * const lineItems = await orderModuleService.updateLineItems({ + * id: "123" + * }, { + * quantity: 2 + * }) * */ updateLineItems( @@ -636,22 +1153,20 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates an existing line item. * - * @param {string} lineId - The line's ID. - * @param {Partial} data - Make all properties in T optional + * @param {string} lineId - The line items's ID. + * @param {Partial} data - The data 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 {return type}(s). + * @returns {Promise} The updated line item. * * @example - * ```typescript - * const result = await orderModuleService.updateLineItems( - * "lineIdExample", + * const lineItem = await orderModuleService.updateLineItems( + * "123", * { - * quantity: 10, + * quantity: 2 * } - * ); - * ``` + * ) * */ updateLineItems( @@ -660,28 +1175,63 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes line items by their IDs. + * + * @param {string[]} itemIds - The IDs of the line items to delete. + * @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 orderModuleService.deleteLineItems([ + * "123", "321" + * ]) + */ deleteLineItems(itemIds: string[], sharedContext?: Context): Promise - deleteLineItems(itemIds: string, sharedContext?: Context): Promise + + /** + * This method deletes a line item by its ID. + * + * @param {string} itemId - The line item'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 line item is deleted successfully. + * + * @example + * await orderModuleService.deleteLineItems("123") + */ + deleteLineItems(itemId: string, sharedContext?: Context): Promise + + /** + * This method deletes line items that match the specified filters. + * + * @param {Partial} selector - The filters specifying which line items to delete. + * @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 orderModuleService.deleteLineItems({ + * id: ["123", "321"] + * }) + */ deleteLineItems( selector: Partial, sharedContext?: Context ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing order items matching the specified filters. * - * @param {Partial} selector - Make all properties in T optional + * @param {Partial} selector - The filters specifying which order items to update. * @param {UpdateOrderItemDTO} data - The attributes to update in the order item. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order items. * * @example - * ```typescript - * await orderModuleService.updateOrderItem( - * { id: "item123" }, - * { quantity: "2" } - * ); - * ``` + * const orderItems = await orderModuleService.updateOrderItem({ + * id: "123" + * }, { + * quantity: 2 + * }) * */ updateOrderItem( @@ -691,53 +1241,48 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates existing {return type}(s). + * This method updates an existing order item. * - * @param {string} orderDetailId - The order detail's ID. - * @param {Partial} data - Make all properties in T optional + * @param {string} orderItemId - The order item's ID. + * @param {Partial} data - The data to update in the order item. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order item. * * @example - * ```typescript - * await orderModuleService.updateOrderItem( - * 'orderDetailId123', + * const orderItem = await orderModuleService.updateOrderItem( + * "123", * { - * item_id: 'item123', * quantity: 2 * } - * ); - * ``` + * ) * */ updateOrderItem( - orderDetailId: string, + orderItemId: string, data: Partial, sharedContext?: Context ): Promise /** - * This method updates existing {return type}(s). + * This method updates existing order items. The items are identified either by their ID or the specified filters. * - * @param {string | Partial | UpdateOrderItemWithSelectorDTO[]} orderDetailIdOrDataOrSelector - The string | partial< order item d t o> | update order item with selector details. - * @param {UpdateOrderItemDTO | Partial} data - {summary} + * @param {string | Partial | UpdateOrderItemWithSelectorDTO[]} orderItemIdOrDataOrSelector - Either the ID of an order item, or the + * filters specifying which order items to update. + * @param {UpdateOrderItemDTO | Partial} data - The data to update. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order items. * * @example - * ```typescript - * await orderModuleService.updateOrderItem( - * "order-detail-id", + * const orderItem = await orderModuleService.updateOrderItem( + * "123", * { - * quantity: 2, - * item_id: 'item123', + * quantity: 2 * } - * ); - * ``` + * ) * */ updateOrderItem( - orderDetailIdOrDataOrSelector: + orderItemIdOrDataOrSelector: | string | UpdateOrderItemWithSelectorDTO[] | Partial, @@ -746,20 +1291,43 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of shipping methods based on optional filters and configuration. * - * @param {FilterableOrderShippingMethodProps} filters - The filters to apply on the retrieved order shipping method. - * @param {FindConfig} config - The configurations determining how the order shipping method is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order shipping method. + * @param {FilterableOrderShippingMethodProps} filters - The filters to apply on the retrieved shipping method. + * @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 {return type}(s). + * @returns {Promise} The list of shipping methods. * * @example - * ```typescript - * await orderModuleService.listShippingMethods( - * { order_id: "order_123" }, - * { limit: 10, offset: 0 } - * ); + * To retrieve a list of shipping methods using their IDs: + * + * ```ts + * const shippingMethods = await orderModuleService.listShippingMethods({ + * id: ["123", "321"] + * }, {}) + * ``` + * + * To specify relations that should be retrieved within the shipping method: + * + * ```ts + * const shippingMethods = await orderModuleService.listShippingMethods({ + * id: ["123", "321"] + * }, { + * relations: ["adjustments"] + * }) + * ``` + * + * 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 orderModuleService.listShippingMethods({ + * id: ["123", "321"] + * }, { + * relations: ["adjustments"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -769,55 +1337,191 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates a shipping method. + * + * @param {CreateOrderShippingMethodDTO} data - The shipping method to be created. + * @returns {Promise} The created shipping method. + * + * @example + * const shippingMethod = await orderModuleService.createShippingMethods({ + * name: "Express Shipping", + * order_id: "123", + * amount: 10 + * }) + */ createShippingMethods( data: CreateOrderShippingMethodDTO, sharedContext?: Context ): Promise + + /** + * This method creates shipping methods. + * + * @param {CreateOrderShippingMethodDTO[]} data - The order shipping methods to be created. + * @returns {Promise} The created orders. + * + * @example + * const shippingMethods = await orderModuleService.createShippingMethods([{ + * name: "Express Shipping", + * order_id: "123", + * amount: 10 + * }]) + */ createShippingMethods( data: CreateOrderShippingMethodDTO[], sharedContext?: Context ): Promise + + /** + * This method creates shipping methods for an order. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderShippingMethodDTO[]} methods - The shipping methods 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 shipping methods. + * + * @example + * const shippingMethods = await orderModuleService.createShippingMethods( + * "123", + * [ + * { + * name: "Express Shipping", + * order_id: "123", + * amount: 10 + * } + * ] + * ) + */ createShippingMethods( orderId: string, methods: CreateOrderShippingMethodDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing shipping methods. The shipping method IDs are specified in each shipping method object. + * + * @param {UpdateOrderShippingMethodDTO[]} data - The attributes to update in the shipping methods. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated shipping methods. + * + * @example + * const shippingMethods = await orderModuleService.updateShippingMethods([{ + * id: "123", + * name: "Express Shipping" + * }]) + */ updateShippingMethods( data: UpdateOrderShippingMethodDTO[], sharedContext?: Context ): Promise + /** + * This method updates an existing shipping method. + * + * @param {UpdateOrderShippingMethodDTO} data - The attributes to update in the shipping method. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated shipping method. + * + * @example + * const shippingMethod = await orderModuleService.updateShippingMethods({ + * id: "123", + * name: "Express Shipping" + * }) + */ updateShippingMethods( data: UpdateOrderShippingMethodDTO, sharedContext?: Context ): Promise + /** + * This method deletes shipping methods by their IDs. + * + * @param {string[]} methodIds - The list of 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 orderModuleService.deleteShippingMethods([ + * "123", "321" + * ]) + */ deleteShippingMethods( methodIds: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a shipping method by its ID. + * + * @param {string} methodId - The shipping method'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 shipping method is deleted successfully. + * + * @example + * await orderModuleService.deleteShippingMethods("123") + */ deleteShippingMethods( - methodIds: string, + methodId: string, sharedContext?: Context ): Promise + + /** + * This method deletes shipping methods matching the specified filters. + * + * @param {Partial} selector - The filters specifying the shipping methods to delete. + * @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 orderModuleService.deleteShippingMethods({ + * id: "123" + * }) + */ deleteShippingMethods( selector: Partial, sharedContext?: Context ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of line item adjustments based on optional filters and configuration. * - * @param {FilterableOrderLineItemAdjustmentProps} filters - The filters to apply on the retrieved order line item adjustment. - * @param {FindConfig} config - The configurations determining how the order line item adjustment is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order line item adjustment. + * @param {FilterableOrderLineItemAdjustmentProps} filters - The filters to apply on the retrieved line item adjustment. + * @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 {return type}(s). + * @returns {Promise} The list of line item adjustments. * * @example - * ```typescript - * const orderLineItemAdjustments = await orderModuleService.listLineItemAdjustments({ item_id: "order-line-item-123" }); + * To retrieve a list of line item adjustments using their IDs: + * + * ```ts + * const lineItemAdjustment = await orderModuleService.listLineItemAdjustments({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the line item adjustment: + * + * ```ts + * const lineItemAdjustment = await orderModuleService.listLineItemAdjustments({ + * id: ["123", "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 lineItemAdjustment = await orderModuleService.listLineItemAdjustments({ + * id: ["123", "321"] + * }, { + * relations: ["item"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -827,14 +1531,53 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates line item adjustments. + * + * @param {CreateOrderAdjustmentDTO[]} data - The line item adjustments to be created. + * @returns {Promise} The created line item adjustments. + * + * @example + * const lineItemAdjustments = await orderModuleService.createLineItemAdjustments([{ + * amount: 5 + * }]) + */ createLineItemAdjustments( data: CreateOrderAdjustmentDTO[], sharedContext?: Context ): Promise + + /** + * This method creates a line item adjustment. + * + * @param {CreateOrderAdjustmentDTO} data - The line-item adjustment to be created. + * @returns {Promise} The created line-item adjustment. + * + * @example + * const lineItemAdjustment = await orderModuleService.createLineItemAdjustments({ + * amount: 5 + * }) + */ createLineItemAdjustments( data: CreateOrderAdjustmentDTO, sharedContext?: Context ): Promise + + /** + * This method creates line item adjustments for an order. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderAdjustmentDTO[]} data - The line-item adjustments to be created. + * @returns {Promise} The created line item adjustments. + * + * @example + * const lineItemAdjustments = await orderModuleService.createLineItemAdjustments( + * "123", + * [{ + * amount: 5 + * }] + * ) + */ createLineItemAdjustments( orderId: string, data: CreateOrderAdjustmentDTO[], @@ -842,22 +1585,29 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method sets the line item adjustments of an order. * * @param {string} orderId - The order's ID. - * @param {UpsertOrderLineItemAdjustmentDTO[]} data - The upsert order line item adjustment details. + * @param {UpsertOrderLineItemAdjustmentDTO[]} data - The line item adjustments to create or update. If the `id` property is provided + * in an object, it means an existing line item adjustment will be updated. Otherwise, a new one is created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Represents the completion of an asynchronous operation + * @returns {Promise} The order's line item adjustments. * * @example - * ```typescript - * const adjustmentsData: UpsertOrderLineItemAdjustmentDTO[] = [{ - * item_id: "item123", - * amount: 1000 - * }]; - * - * const result = await orderModuleService.setLineItemAdjustments("order456", adjustmentsData); - * ``` + * const lineItemAdjustments = await orderModuleService.setLineItemAdjustments( + * "123", + * [ + * { + * item_id: "1234", + * amount: 10 + * }, + * { + * id: "123", + * item_id: "4321", + * amount: 20 + * } + * ] + * ) * */ setLineItemAdjustments( @@ -866,33 +1616,96 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes a line item adjustment by its ID. + * + * @param {string[]} adjustmentIds - The IDs of 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 orderModuleService.deleteLineItemAdjustments([ + * "123", "321" + * ]) + */ deleteLineItemAdjustments( adjustmentIds: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a line item adjustment by its ID. + * + * @param {string} adjustmentId - 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. + * + * @example + * await orderModuleService.deleteLineItemAdjustments("123") + */ deleteLineItemAdjustments( - adjustmentIds: string, + adjustmentId: string, sharedContext?: Context ): Promise + + /** + * This method deletes line item adjustments matching the specified filters. + * + * @param {Partial} selector - The filters specifying which line item adjustments to delete. + * @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 orderModuleService.deleteLineItemAdjustments({ + * id: "123" + * }) + */ deleteLineItemAdjustments( selector: Partial, sharedContext?: Context ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of shipping method adjustments based on optional filters and configuration. * - * @param {FilterableOrderShippingMethodAdjustmentProps} filters - The filters to apply on the retrieved order shipping method adjustment. - * @param {FindConfig} config - The configurations determining how the order shipping method adjustment is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order shipping method adjustment. + * @param {FilterableOrderShippingMethodAdjustmentProps} filters - The filters to apply on the retrieved shipping method adjustment. + * @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 {return type}(s). + * @returns {Promise} The list of shipping method adjustments. * * @example - * ```typescript - * const result = await orderModuleService.listShippingMethodAdjustments({ - * id: "12345", - * }); + * To retrieve a list of shipping method adjustments using their IDs: + * + * ```ts + * const shippingMethodAdjustments = await orderModuleService + * .listShippingMethodAdjustments({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the shipping method adjustment: + * + * ```ts + * const shippingMethodAdjustments = await orderModuleService + * .listShippingMethodAdjustments({ + * id: ["123", "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 orderModuleService + * .listShippingMethodAdjustments({ + * id: ["123", "321"] + * }, { + * relations: ["shipping_method"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -902,14 +1715,65 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates shipping method adjustments. + * + * @param {CreateOrderShippingMethodAdjustmentDTO[]} data - The order shipping method adjustments to be created. + * @returns {Promise} The created shipping method adjustments. + * + * @example + * const shippingMethodAdjustments = await orderModuleService + * .createShippingMethodAdjustments([ + * { + * shipping_method_id: "123", + * code: "50OFF", + * amount: 5 + * } + * ]) + */ createShippingMethodAdjustments( data: CreateOrderShippingMethodAdjustmentDTO[], sharedContext?: Context ): Promise + + /** + * This method creates a shipping method adjustment. + * + * @param {CreateOrderShippingMethodAdjustmentDTO} data - The shipping method adjustment to be created. + * @returns {Promise} The created shipping method adjustment. + * + * @example + * const shippingMethodAdjustment = await orderModuleService + * .createShippingMethodAdjustments({ + * shipping_method_id: "123", + * code: "50OFF", + * amount: 5 + * }) + */ createShippingMethodAdjustments( data: CreateOrderShippingMethodAdjustmentDTO, sharedContext?: Context ): Promise + + /** + * This method creates shipping method adjustments for an order. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderShippingMethodAdjustmentDTO[]} data - The order shipping method adjustments 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 shipping method adjustments. + * + * @example + * const shippingMethodAdjustments = await orderModuleService + * .createShippingMethodAdjustments( + * "123", + * [{ + * shipping_method_id: "123", + * code: "50OFF", + * amount: 5 + * }] + * ) + */ createShippingMethodAdjustments( orderId: string, data: CreateOrderShippingMethodAdjustmentDTO[], @@ -917,23 +1781,30 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method sets the shipping method adjustments of an order. * * @param {string} orderId - The order's ID. - * @param {(CreateOrderShippingMethodAdjustmentDTO | UpdateOrderShippingMethodAdjustmentDTO)[]} data - The list of The order shipping method adjustment d t o | update order shipping method adjustment to be created. + * @param {(CreateOrderShippingMethodAdjustmentDTO | UpdateOrderShippingMethodAdjustmentDTO)[]} data - The shipping method adjustments to be created + * or updated. If an adjustment object has an `id` property, it's updated. Otherwise, a new adjustment is created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Represents the completion of an asynchronous operation + * @returns {Promise} The order's shipping method adjustments. * * @example - * ```typescript - * await orderModuleService.setShippingMethodAdjustments("orderId123", [ - * { - * shipping_method_id: "shipMethodId123", - * code: "CODE123", - * amount: 1000, - * } - * ]); - * ``` + * const shippingMethodAdjustments = await orderModuleService + * .setShippingMethodAdjustments( + * "123", + * [ + * { + * shipping_method_id: "123", + * code: "50OFF", + * amount: 5 + * }, + * { + * id: "321", + * amount: 5 + * } + * ] + * ) * */ setShippingMethodAdjustments( @@ -945,31 +1816,96 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes shipping method adjustments by their IDs. + * + * @param {string[]} adjustmentIds - The IDs of 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 orderModuleService.deleteShippingMethodAdjustments([ + * "123", "321" + * ]) + */ deleteShippingMethodAdjustments( adjustmentIds: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a shipping method adjustment by its ID. + * + * @param {string} adjustmentId - The adjustment'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 shipping method adjustment is deleted successfully + * + * @example + * await orderModuleService.deleteShippingMethodAdjustments("123") + */ deleteShippingMethodAdjustments( adjustmentId: string, sharedContext?: Context ): Promise + + /** + * This method deletes shipping method adjustments matching the specified filters. + * + * @param {Partial} selector - The filters specifying which shipping method adjustments to delete. + * @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. + * + * @example + * await orderModuleService.deleteShippingMethodAdjustments({ + * id: "123" + * }) + */ deleteShippingMethodAdjustments( selector: Partial, sharedContext?: Context ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of line item taxes based on optional filters and configuration. * - * @param {FilterableOrderLineItemTaxLineProps} filters - The filters to apply on the retrieved order line item tax line. - * @param {FindConfig} config - The configurations determining how the order line item tax line is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order line item tax line. + * @param {FilterableOrderLineItemTaxLineProps} filters - The filters to apply on the retrieved line item tax line. + * @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 {return type}(s). + * @returns {Promise} The list of line item taxes. * * @example - * ```typescript - * await orderModuleService.listLineItemTaxLines({ id: "123" }); + * To retrieve a list of line item tax lines using their IDs: + * + * ```ts + * const lineItemTaxLines = await orderModuleService + * .listLineItemTaxLines({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the line item tax line: + * + * ```ts + * const lineItemTaxLines = await orderModuleService + * .listLineItemTaxLines({ + * id: ["123", "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 orderModuleService + * .listLineItemTaxLines({ + * id: ["123", "321"] + * }, { + * relations: ["item"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -979,14 +1915,64 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates line item tax lines. + * + * @param {CreateOrderLineItemTaxLineDTO[]} taxLines - The line item tax lines to be created. + * @returns {Promise} The created line item tax lines. + * + * @example + * const lineItemTaxLines = await orderModuleService + * .createLineItemTaxLines([ + * { + * code: "123", + * rate: 2 + * } + * ]) + */ createLineItemTaxLines( taxLines: CreateOrderLineItemTaxLineDTO[], sharedContext?: Context ): Promise + + /** + * This method creates a line item tax line. + * + * @param {CreateOrderLineItemTaxLineDTO} taxLine - The line item tax line to be created. + * @returns {Promise} The created line item tax line. + * + * @example + * const lineItemTaxLines = await orderModuleService + * .createLineItemTaxLines({ + * code: "123", + * rate: 2 + * }) + */ createLineItemTaxLines( taxLine: CreateOrderLineItemTaxLineDTO, sharedContext?: Context ): Promise + + /** + * This method creates line item tax lines for an order. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderLineItemTaxLineDTO | CreateOrderLineItemTaxLineDTO[]} taxLines - The line item tax lines 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 line item tax line. + * + * @example + * const lineItemTaxLines = await orderModuleService + * .createLineItemTaxLines( + * "123", + * [ + * { + * code: "123", + * rate: 2 + * } + * ] + * ) + */ createLineItemTaxLines( orderId: string, taxLines: CreateOrderLineItemTaxLineDTO[] | CreateOrderLineItemTaxLineDTO, @@ -994,27 +1980,25 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method sets the line item tax lines of an order. * * @param {string} orderId - The order's ID. - * @param {(CreateOrderLineItemTaxLineDTO | UpdateOrderLineItemTaxLineDTO)[]} taxLines - The list of The order line item tax line d t o | update order line item tax line to be created. + * @param {(CreateOrderLineItemTaxLineDTO | UpdateOrderLineItemTaxLineDTO)[]} taxLines - The line item tax lines to create or update. If the + * tax line object has an `id` property, it'll be updated. Otherwise, a tax line is created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Represents the completion of an asynchronous operation + * @returns {Promise} The order's line item tax lines. * * @example - * ```typescript - * const orderId = '12345'; - * const taxLines: (CreateOrderLineItemTaxLineDTO | UpdateOrderLineItemTaxLineDTO)[] = [ - * { - * code: "TAX1001", - * rate: 70, - * } - * ]; - * - * const result = await orderModuleService.setLineItemTaxLines(orderId, taxLines); - * - * console.log(result); - * ``` + * const lineItemTaxLines = await orderModuleService + * .setLineItemTaxLines( + * "123", + * [ + * { + * code: "123", + * rate: 2 + * } + * ] + * ) * */ setLineItemTaxLines( @@ -1023,35 +2007,96 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes line item tax lines by their IDs. + * + * @param {string[]} taxLineIds - 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 orderModuleService.deleteLineItemTaxLines([ + * "123", "321" + * ]) + */ deleteLineItemTaxLines( taxLineIds: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a line item tax line by its ID. + * + * @param {string} taxLineId - 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 orderModuleService.deleteLineItemTaxLines("123") + */ deleteLineItemTaxLines( - taxLineIds: string, + taxLineId: string, sharedContext?: Context ): Promise + + /** + * This method deletes line item tax lines matching the specified filters. + * + * @param {FilterableOrderLineItemTaxLineProps} selector - The filters specifying which line item tax lines to update. + * @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 orderModuleService.deleteLineItemTaxLines({ + * id: ["123", "321"] + * }) + */ deleteLineItemTaxLines( selector: FilterableOrderLineItemTaxLineProps, sharedContext?: Context ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of shipping method tax lines based on optional filters and configuration. * - * @param {FilterableOrderShippingMethodTaxLineProps} filters - The filters to apply on the retrieved order shipping method tax line. - * @param {FindConfig} config - The configurations determining how the order shipping method tax line is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order shipping method tax line. + * @param {FilterableOrderShippingMethodTaxLineProps} filters - The filters to apply on the retrieved shipping method tax line. + * @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 {return type}(s). + * @returns {Promise} The list of shipping method tax lines. * * @example - * ```typescript - * async function executeMethod() { - * const result = await orderModuleService.listShippingMethodTaxLines({ - * id: "123", - * }); - * } + * To retrieve a list of shipping method tax lines using their IDs: + * + * ```ts + * const shippingMethodTaxLines = await orderModuleService + * .listShippingMethodTaxLines({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the shipping method tax line: + * + * ```ts + * const shippingMethodTaxLines = await orderModuleService + * .listShippingMethodTaxLines({ + * id: ["123", "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 orderModuleService + * .listShippingMethodTaxLines({ + * id: ["123", "321"] + * }, { + * relations: ["shipping_method"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -1061,14 +2106,62 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates shipping method tax lines. + * + * @param {CreateOrderShippingMethodTaxLineDTO[]} taxLines - The shipping method tax lines to be created. + * @returns {Promise} The created shipping method tax lines. + * + * @example + * const shippingMethodTaxLines = await orderModuleService + * .createShippingMethodTaxLines([ + * { + * code: "123", + * rate: 2 + * } + * ]) + */ createShippingMethodTaxLines( taxLines: CreateOrderShippingMethodTaxLineDTO[], sharedContext?: Context ): Promise + + /** + * This method creates a shipping method tax line. + * + * @param {CreateOrderShippingMethodTaxLineDTO} taxLine - The shipping method tax line to be created. + * @returns {Promise} The created shipping method tax line. + * + * @example + * const shippingMethodTaxLine = await orderModuleService + * .createShippingMethodTaxLines({ + * code: "123", + * rate: 2 + * }) + */ createShippingMethodTaxLines( taxLine: CreateOrderShippingMethodTaxLineDTO, sharedContext?: Context ): Promise + + /** + * This method creates shipping method tax lines for an order. + * + * @param {string} orderId - The order's ID. + * @param {CreateOrderShippingMethodTaxLineDTO | CreateOrderShippingMethodTaxLineDTO[]} taxLines - The shipping method tax lines 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 shipping method tax lines. + * + * @example + * const shippingMethodTaxLines = await orderModuleService + * .createShippingMethodTaxLines( + * "123", + * [{ + * code: "123", + * rate: 2 + * }] + * ) + */ createShippingMethodTaxLines( orderId: string, taxLines: @@ -1078,25 +2171,29 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method set the shipping method tax lines of an order. * * @param {string} orderId - The order's ID. - * @param {(CreateOrderShippingMethodTaxLineDTO | UpdateOrderShippingMethodTaxLineDTO)[]} taxLines - The list of The order shipping method tax line d t o | update order shipping method tax line to be created. + * @param {(CreateOrderShippingMethodTaxLineDTO | UpdateOrderShippingMethodTaxLineDTO)[]} taxLines - The shipping method tax lines to create or update. + * If a tax line object has an `id` property, it's updated. Otherwise, a tax line is created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Represents the completion of an asynchronous operation + * @returns {Promise} The order's shipping method tax lines. * * @example - * ```typescript - * const orderId = "someOrderId"; - * const taxLines = [ - * { - * code: "VAT20", - * rate: 20, - * } - * ]; - * - * const result = await orderModuleService.setShippingMethodTaxLines(orderId, taxLines); - * ``` + * const shippingMethodTaxLines = await orderModuleService + * .setShippingMethodTaxLines( + * "123", + * [ + * { + * code: "123", + * rate: 2 + * }, + * { + * id: "321", + * rate: 2 + * } + * ] + * ) * */ setShippingMethodTaxLines( @@ -1108,33 +2205,83 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method deletes shipping method tax lines by their IDs. + * + * @param {string[]} taxLineIds - The list of 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 orderModuleService.deleteShippingMethodTaxLines([ + * "123", "321" + * ]) + */ deleteShippingMethodTaxLines( taxLineIds: string[], sharedContext?: Context ): Promise + + /** + * This method deletes a shipping method tax line by its ID. + * + * @param {string} taxLineId - 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 orderModuleService.deleteShippingMethodTaxLines("123") + */ deleteShippingMethodTaxLines( - taxLineIds: string, + taxLineId: string, sharedContext?: Context ): Promise + + /** + * This method deletes shipping method tax line matching the specified filters. + * + * @param {FilterableOrderShippingMethodTaxLineProps} selector - The filters specifying which shipping method tax lines to delete. + * @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 orderModuleService.deleteShippingMethodTaxLines({ + * id: ["123", "321"] + * }) + */ deleteShippingMethodTaxLines( selector: FilterableOrderShippingMethodTaxLineProps, sharedContext?: Context ): Promise - // Order Change /** - * This method retrieves a {return type} by its ID. + * This method retrieves an order change by its ID. * * @param {string} orderChangeId - The order change ID. - * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order. + * @param {FindConfig} config - The configurations determining how the order change is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a order change. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The retrieved {return type}(s). + * @returns {Promise} The retrieved order change. * * @example - * ```typescript - * const result = await orderModuleService.retrieveOrder("orderId123"); + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const orderChange = await orderModuleService.retrieveOrderChange( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const orderChange = await orderModuleService.retrieveOrderChange( + * "123", + * { + * relations: ["order"] + * } + * ) * ``` * */ @@ -1144,29 +2291,36 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates an order change. + * + * @param {CreateOrderChangeDTO} data - The order change 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 order change. + * + * @example + * const orderChange = await orderModuleService.createOrderChange({ + * order_id: "123", + * }) + */ createOrderChange( data: CreateOrderChangeDTO, sharedContext?: Context ): Promise /** - * This method creates {return type}(s) + * This method creates order changes. * - * @param {CreateOrderChangeDTO[]} data - The order change to be created. + * @param {CreateOrderChangeDTO[]} data - The order changes 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 {return type}(s). + * @returns {Promise} The created order changes. * * @example - * ```typescript - * // Example call to createOrderChange - * - * const createOrderChangeData: CreateOrderChangeDTO[] = [{ - * order_id: "order123", - * description: "Change due to customer request" - * }]; - * - * const result = await orderModuleService.createOrderChange(createOrderChangeData); - * ``` + * const orderChanges = await orderModuleService.createOrderChange([ + * { + * order_id: "123", + * } + * ]) * */ createOrderChange( @@ -1175,19 +2329,18 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method creates {return type}(s) + * This method creates order changes. * - * @param {CreateOrderChangeDTO | CreateOrderChangeDTO[]} data - The order change d t o | create order change to be created. + * @param {CreateOrderChangeDTO | CreateOrderChangeDTO[]} data - The order changes 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 {return type}(s). + * @returns {Promise} The created order changes. * * @example - * ```typescript - * const result = await orderModuleService.createOrderChange({ - * order_id: "order123", - * description: "Adding new item to the order" - * }); - * ``` + * const orderChanges = await orderModuleService.createOrderChange([ + * { + * order_id: "123", + * } + * ]) * */ createOrderChange( @@ -1195,29 +2348,34 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method updates an existing order change. + * + * @param {UpdateOrderChangeDTO} data - The attributes to update in the order change. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order change. + * + * @example + * const orderChange = await orderModuleService.updateOrderChanges({ + * id: "123" + * }) + */ updateOrderChanges( data: UpdateOrderChangeDTO, sharedContext?: Context ): Promise /** - * This method updates {return type}(s) + * This method updates order changes. The order changes are identified by the `id` property of each order change object. * - * @param {UpdateOrderChangeDTO[]} data - The order change to be updated. + * @param {UpdateOrderChangeDTO[]} data - The order changes to be updated. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order changes. * * @example - * ```typescript - * // Example call to updateOrderChanges - * - * const updateOrderChangesData: UpdateOrderChangeDTO[] = [{ - * id: "orderchange123", - * description: "Change due to customer request" - * }]; - * - * const result = await orderModuleService.updateOrderChanges(updateOrderChangesData); - * ``` + * const orderChanges = await orderModuleService.updateOrderChanges([{ + * id: "123" + * }]) * */ updateOrderChanges( @@ -1226,19 +2384,16 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates {return type}(s) + * This method updates order changes. The order changes are identified by the `id` property of each order change object. * - * @param {UpdateOrderChangeDTO | UpdateOrderChangeDTO[]} data - The order change d t o | order change to be updated. + * @param {UpdateOrderChangeDTO | UpdateOrderChangeDTO[]} data - The data to update in each order change. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order changes. * * @example - * ```typescript - * const result = await orderModuleService.createOrderChange({ - * order_id: "order123", - * description: "Adding new item to the order" - * }); - * ``` + * const orderChanges = await orderModuleService.updateOrderChanges([{ + * id: "123" + * }]) * */ updateOrderChanges( @@ -1247,16 +2402,14 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes order change by its ID. + * This method deletes order changes by their IDs. * - * @param {string[]} orderChangeId - The list of {summary} + * @param {string[]} orderChangeId - The IDs of order changes. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order changes are deleted successfully. * * @example - * ```typescript - * await orderModuleService.deleteOrderChanges(["orderChangeId1", "orderChangeId2"]); - * ``` + * await orderModuleService.deleteOrderChanges(["123", "321"]) * */ deleteOrderChanges( @@ -1265,16 +2418,14 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes order change by its ID. + * This method deletes an order change by its ID. * - * @param {string} orderChangeId - The order's ID. + * @param {string} orderChangeId - The order change'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 {summary} + * @returns {Promise} Resolves when the order change is deleted successfully. * * @example - * ```typescript - * await orderModuleService.deleteOrderChanges("orderChangeId"); - * ``` + * await orderModuleService.deleteOrderChanges("123") * */ deleteOrderChanges( @@ -1283,55 +2434,60 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method cancels an order's change. * * @param {string} orderId - The order'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 {summary} + * @returns {Promise} Resolves when the order's change is canceled successfully. * * @example - * ```typescript - * await orderModuleService.cancelOrderChange("orderId123"); - * ``` + * await orderModuleService.cancelOrderChange("123") * */ cancelOrderChange(orderId: string, sharedContext?: Context): Promise /** - * This method Represents the completion of an asynchronous operation + * This method cancels orders' changes. * - * @param {string[]} orderId - The order's ID. + * @param {string[]} orderId - The orders IDs. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the orders' changes are canceled successfully. * * @example - * ```typescript - * await orderModuleService.cancelOrderChange(["1234ABCD"]); - * ``` + * await orderModuleService.cancelOrderChange(["123", "321"]) * */ cancelOrderChange(orderId: string[], sharedContext?: Context): Promise + /** + * This method retrieves a preview of an order if its change was confirmed and applied on it. + * + * @param {string} orderId - The order's ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The preview of the order. + * + * @example + * const orderPreview = await orderModuleService.previewOrderChange( + * "123" + * ) + */ previewOrderChange( orderId: string, sharedContext?: Context ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method cancels an order's change, providing cancelation details. * - * @param {CancelOrderChangeDTO} data - The cancel order change details. + * @param {CancelOrderChangeDTO} data - The cancelation details of the order's change. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order's change is canceled successfully. * * @example - * ```typescript - * const cancelOrderChangeData: CancelOrderChangeDTO = { - * id: "orderChangeId", - * }; - * - * await orderModuleService.cancelOrderChange(cancelOrderChangeData); - * ``` + * await orderModuleService.cancelOrderChange({ + * id: "123", + * canceled_by: "user_123" + * }) * */ cancelOrderChange( @@ -1340,16 +2496,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method cancels orders' changes, providing cancelation details. * - * @param {CancelOrderChangeDTO[]} data - The cancel order change details. + * @param {CancelOrderChangeDTO[]} data - The cancelation details of the orders' changes. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the orders' changes are canceled successfully. * * @example - * ```typescript - * await orderModuleService.cancelOrderChange([{ id: "orderChangeId" }]); - * ``` + * await orderModuleService.cancelOrderChange([{ + * id: "123", + * canceled_by: "user_123" + * }]) * */ cancelOrderChange( @@ -1358,16 +2515,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method confirms an order change, applying these changes on the associated order. * - * @param {string} orderId - The order's ID. + * @param {string} orderChangeId - The order change'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 {summary} + * @returns {Promise} The item and shipping method changes made on the order. * * @example - * ```typescript - * await orderModuleService.confirmOrderChange("123456789"); - * ``` + * const { + * items, + * shippingMethods + * } = await orderModuleService.confirmOrderChange("123") * */ confirmOrderChange( @@ -1376,16 +2534,14 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method confirms order changes, applying these changes on the associated orders. * - * @param {string[]} orderChangeId - The order change's ID. + * @param {string[]} orderChangeId - The order changes' IDs. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} The item and shipping method changes made on the order. * * @example - * ```typescript - * await orderModuleService.confirmOrderChange(["12345"]); - * ``` + * await orderModuleService.confirmOrderChange(["123"]) * */ confirmOrderChange( @@ -1394,18 +2550,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method confirms an order change, specifying confirmation details. * - * @param {ConfirmOrderChangeDTO} data - The confirm order change details. + * @param {ConfirmOrderChangeDTO} data - The confirmation's details of the order change. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} The item and shipping method changes made on the order. * * @example - * ```typescript * await orderModuleService.confirmOrderChange({ - * id: "123456" - * }); - * ``` + * id: "123", + * confirmed_by: "user_123" + * }) * */ confirmOrderChange( @@ -1414,20 +2569,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method confirms order changes, specifying confirmation details. * - * @param {ConfirmOrderChangeDTO[]} data - The confirm order change details. + * @param {ConfirmOrderChangeDTO[]} data - The confirm order changes details. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} The item and shipping method changes made on all the orders. * * @example - * ```typescript - * const confirmOrderChangesData: ConfirmOrderChangeDTO[] = [{ - * id: "orderChangeId", - * }]; - * - * await orderModuleService.confirmOrderChange(confirmOrderChangesData); - * ``` + * await orderModuleService.confirmOrderChange([{ + * id: "123", + * confirmed_by: "user_123" + * }]) * */ confirmOrderChange( @@ -1436,16 +2588,14 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method declines an order change. * * @param {string} orderChangeId - The order change'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 {summary} + * @returns {Promise} Resolves when the order change is declined successfully. * * @example - * ```typescript - * await orderModuleService.declineOrderChange("orderChangeId"); - * ``` + * await orderModuleService.declineOrderChange("123") * */ declineOrderChange( @@ -1454,16 +2604,14 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method declines order changes. * - * @param {string[]} orderChangeId - The order change's ID. + * @param {string[]} orderChangeId - The order changes' IDs. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order changes are declined successfully. * * @example - * ```typescript - * await orderModuleService.declineOrderChange(["orderChangeId"]); - * ``` + * await orderModuleService.declineOrderChange(["123", "321"]) * */ declineOrderChange( @@ -1472,18 +2620,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method declines an order change, providing additional details. * - * @param {DeclineOrderChangeDTO} data - The decline order change details. + * @param {DeclineOrderChangeDTO} data - The details of the order change decline. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order change is declined successfully. * * @example - * ```typescript * await orderModuleService.declineOrderChange({ - * id: "123456", - * }); - * ``` + * id: "123", + * declined_by: "user_123" + * }) * */ declineOrderChange( @@ -1492,20 +2639,19 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method Represents the completion of an asynchronous operation + * This method declines order changes, providing additional details for each. * - * @param {DeclineOrderChangeDTO[]} data - The decline order change details. + * @param {DeclineOrderChangeDTO[]} data - The details of the order change declines. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order changes are declined successfully. * * @example - * ```typescript * await orderModuleService.declineOrderChange([ * { - * id: "12345", + * id: "123", + * declined_by: "user_123" * } - * ]); - * ``` + * ]) * */ declineOrderChange( @@ -1513,12 +2659,47 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method soft deletes order changes by their IDs. + * + * @param {string | string[]} orderChangeId - The IDs of order changes. + * @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. + * The object's keys are the ID attribute names of the order change entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the order through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteOrderChanges([ + * "123", "321" + * ]) + */ softDeleteOrderChanges( orderChangeId: string | string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft deleted order changes by their IDs. + * + * @param {string | string[]} orderChangeId - The IDs of order changes. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the order. You can pass to its `returnLinkableKeys` + * property any of the order change'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. + * The object's keys are the ID attribute names of the order change entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the order change through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreOrderChanges([ + * "123", "321" + * ]) + */ restoreOrderChanges( orderChangeId: string | string[], config?: RestoreReturn, @@ -1526,16 +2707,19 @@ export interface IOrderModuleService extends IModuleService { ): Promise | void> /** - * This method {summary} + * This method applies orders' actions who are still pending on the order. * * @param {string | string[]} orderId - The order's ID. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {(orderId: string | string[], sharedContext?: Context) => Promise} {summary} + * @returns {Promise} The changes made by applying the actions on the orders. * * @example - * ```typescript - * await orderModuleService.applyPendingOrderActions("12345"); - * ``` + * const { + * items, + * shippingMethods + * } = await orderModuleService.applyPendingOrderActions([ + * "123", "321" + * ]) * */ applyPendingOrderActions( @@ -1544,17 +2728,43 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a paginated list of {return type}(s) based on optional filters and configuration. + * This method retrieves a paginated list of order change actions based on optional filters and configuration. * * @param {FilterableOrderChangeActionProps} filters - The filters to apply on the retrieved order change action. - * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order. + * @param {FindConfig} config - The configurations determining how the order change action is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with an order change action. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The list of {return type}(s). + * @returns {Promise} The list of order change actions. * * @example - * ```typescript - * const orderChangeActions = await orderModuleService.listOrderChangeActions(); + * To retrieve a list of shipping method tax lines using their IDs: + * + * ```ts + * const orderChangeActions = await orderModuleService.listOrderChangeActions({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the shipping method tax line: + * + * ```ts + * const orderChangeActions = await orderModuleService.listOrderChangeActions({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 orderChangeActions = await orderModuleService.listOrderChangeActions({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) * ``` * */ @@ -1565,17 +2775,32 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method retrieves a {return type} by its ID. + * This method retrieves an orde rchange action by its ID. * * @param {string} actionId - The order change action's ID. - * @param {FindConfig} config - The configurations determining how the order is retrieved. Its properties, such as `select` or `relations`, accept the - * attributes or relations associated with a order. + * @param {FindConfig} config - The configurations determining how the order change action is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with an order change action. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The retrieved {return type}(s). + * @returns {Promise} The retrieved order change action. * * @example - * ```typescript - * const result = await orderModuleService.retrieveOrderChangeAction("actionId123"); + * A simple example that retrieves an order change by its ID: + * + * ```ts + * const orderChangeAction = await orderModuleService.retrieveOrderChangeAction( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const orderChangeAction = await orderModuleService.retrieveOrderChangeAction( + * "123", + * { + * relations: ["order"] + * } + * ) * ``` * */ @@ -1585,29 +2810,36 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method updates an existing order change action. + * + * @param {UpdateOrderChangeActionDTO} data - The attributes to update in the order change action. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order change action. + * + * @example + * const orderChangeAction = await orderModuleService.updateOrderChangeActions({ + * id: "123", + * internal_note: "Changing an item" + * }) + */ updateOrderChangeActions( data: UpdateOrderChangeActionDTO, sharedContext?: Context ): Promise /** - * This method updates {return type}(s) + * This method updates order change actions. * - * @param {UpdateOrderChangeActionDTO[]} data - The order change action to be updated. + * @param {UpdateOrderChangeActionDTO[]} data - The order change actions to be updated. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order change actions. * * @example - * ```typescript - * // Example call to updateOrderChangeActions - * - * const updateOrderChangeActionsData: UpdateOrderChangeActionDTO[] = [{ - * id: "orderchangeaction123", - * ... - * }]; - * - * const result = await orderModuleService.updateOrderChangeActions(updateOrderChangeActionsData); - * ``` + * const orderChangeActions = await orderModuleService.updateOrderChangeActions([{ + * id: "123", + * internal_note: "Changing an item" + * }]) * */ updateOrderChangeActions( @@ -1616,19 +2848,17 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method updates {return type}(s) + * This method updates order change actions. * - * @param {UpdateOrderChangeActionDTO | UpdateOrderChangeActionDTO[]} data - The order change action d t o | order change to be updated. + * @param {UpdateOrderChangeActionDTO | UpdateOrderChangeActionDTO[]} data - The order change actions to be updated. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} The updated {return type}(s). + * @returns {Promise} The updated order change actions. * * @example - * ```typescript - * const result = await orderModuleService.updateOrderChangeActions({ - * id: "orderChangeAction123", - * ... - * }); - * ``` + * const orderChangeActions = await orderModuleService.updateOrderChangeActions([{ + * id: "123", + * internal_note: "Changing an item" + * }]) * */ updateOrderChangeActions( @@ -1636,26 +2866,55 @@ export interface IOrderModuleService extends IModuleService { sharedContext?: Context ): Promise + /** + * This method creates and adds an action to an order and its change. + * + * @param {CreateOrderChangeActionDTO} data - The action to be added to an order. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The order change action added. + * + * @example + * const orderChangeAction = await orderModuleService.addOrderAction({ + * order_id: "123", + * order_change_id: "321", + * action: "ITEM_ADD" + * }) + */ addOrderAction( data: CreateOrderChangeActionDTO, sharedContext?: Context ): Promise + + /** + * This method creates and adds actions to orders and their changes. + * + * @param {CreateOrderChangeActionDTO[]} data - The order change actions 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 order change actions. + * + * @example + * const orderChangeActions = await orderModuleService.addOrderAction([{ + * order_id: "123", + * order_change_id: "321", + * action: "ITEM_ADD" + * }]) + */ addOrderAction( data: CreateOrderChangeActionDTO[], sharedContext?: Context ): Promise /** - * This method deletes {return type} by its ID. + * This method deletes order change actions by their IDs. * - * @param {string[]} actionId - The list of {summary} + * @param {string[]} actionId - The IDs of order change actions. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} Resolves when {summary} + * @returns {Promise} Resolves when the order change actions are deleted successfully. * * @example - * ```typescript - * await orderModuleService.deleteOrderActions(["12345abc", "67890def"]); - * ``` + * await orderModuleService.deleteOrderChangeActions([ + * "123", "321" + * ]) * */ deleteOrderChangeActions( @@ -1664,15 +2923,15 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes {return type} by its ID. + * This method deletes an order change action by its ID. * - * @param {string} orderId - The order action's ID. + * @param {string} actionId - The order change action'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 {summary} + * @returns {Promise} Resolves when the order change action is deleted successfully. * * @example * ```typescript - * await orderModuleService.deleteOrderActions("orderActionId"); + * await orderModuleService.deleteOrderActions("123") * ``` * */ @@ -1682,426 +2941,1753 @@ export interface IOrderModuleService extends IModuleService { ): Promise /** - * This method deletes {return type} by its ID. + * This method soft-deletes order change actions by their IDs. * - * @param {string} orderId - The order action's ID. + * @param {string} actionIds - The order change action'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 {summary} + * @returns {Promise} Resolves when the order change action is soft-deleted successfully. * * @example - * ```typescript - * await orderModuleService.softDeleteOrderChangeActions("orderActionId"); - * ``` + * await orderModuleService.softDeleteOrderChangeActions([ + * "123", "321" + * ]) * */ - softDeleteOrderChangeActions( actionIds: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted order change actions by their IDs. + * + * @param {string | string[]} actionId - The IDs of order change actions. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the order change action. You can pass to its `returnLinkableKeys` + * property any of the order'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. + * The object's keys are the ID attribute names of the order change action entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the order through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreOrderChangeActions([ + * "123", "321" + * ]) + */ restoreOrderChangeActions( actionId: string | 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. + * The object's keys are the ID attribute names of the address entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the order through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteAddresses([ + * "123", "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. + * The object's keys are the ID attribute names of the address entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the address through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreAddresses([ + * "123", "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. + * The object's keys are the ID attribute names of the line item entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the line item through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteLineItems([ + * "123", "321" + * ]) + */ softDeleteLineItems( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft-deleted line item 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 order. You can pass to its `returnLinkableKeys` + * property any of the line item'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. + * The object's keys are the ID attribute names of the line item entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the line item through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreLineItems([ + * "123", "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. + * The object's keys are the ID attribute names of the shipping method entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the shipping method through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteShippingMethods([ + * "123", "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. + * @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. + * The object's keys are the ID attribute names of the shipping method entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the shipping method through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreShippingMethods([ + * "123", "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. + * The object's keys are the ID attribute names of the line item adjustment entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the line item adjustment through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteLineItemAdjustments([ + * "123", "321" + * ]) + */ softDeleteLineItemAdjustments< - TReturnableLinkableKeys extends string = string + TReturnableLinkableKeys extends string = string, >( ids: string[], 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 adjustment. 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. + * The object's keys are the ID attribute names of the line item adjustment entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the line item adjustment through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreLineItemAdjustments([ + * "123", "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. + * The object's keys are the ID attribute names of the shipping method adjustment entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the shipping method adjustment through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteShippingMethodAdjustments([ + * "123", "321" + * ]) + */ softDeleteShippingMethodAdjustments< - TReturnableLinkableKeys extends string = string + TReturnableLinkableKeys extends string = string, >( ids: string[], 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 adjustments. 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. + * The object's keys are the ID attribute names of the shipping method adjustment entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the shipping method adjustment through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreShippingMethodAdjustments([ + * "123", "321" + * ]) + */ restoreShippingMethodAdjustments< - TReturnableLinkableKeys extends string = string + TReturnableLinkableKeys extends string = string, >( ids: string[], config?: RestoreReturn, 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. + * The object's keys are the ID attribute names of the line item tax line entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the line item tax line through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteLineItemTaxLines([ + * "123", "321" + * ]) + */ softDeleteLineItemTaxLines( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + + /** + * This method restores soft-deleted line item tax lines by their 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. + * The object's keys are the ID attribute names of the line item tax line entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the line item tax line through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreLineItemTaxLines([ + * "123", "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. + * The object's keys are the ID attribute names of the shipping method tax line entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the shipping method tax line through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteShippingMethodTaxLines([ + * "123", "321" + * ]) + */ softDeleteShippingMethodTaxLines< - TReturnableLinkableKeys extends string = string + TReturnableLinkableKeys extends string = string, >( ids: string[], 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. + * The object's keys are the ID attribute names of the shipping method tax line entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the shipping method tax line through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreShippingMethodTaxLines([ + * "123", "321" + * ]) + */ restoreShippingMethodTaxLines< - TReturnableLinkableKeys extends string = string + TReturnableLinkableKeys extends string = string, >( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method reverts an order to its last version. + * + * @param {string} orderId - The order'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 order is reverted. + * + * @example + * await orderModuleService.revertLastVersion("123") + */ revertLastVersion(orderId: string, sharedContext?: Context): Promise + /** + * This method retrieves a paginated list of transactions based on optional filters and configuration. + * + * @param {FilterableOrderTransactionProps} filters - The filters to apply on the retrieved transactions. + * @param {FindConfig} config - The configurations determining how the transaction is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a transaction. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of transactions. + * + * @example + * To retrieve a list of transactions using their IDs: + * + * ```ts + * const transactions = await orderModuleService.listTransactions({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the transaction: + * + * ```ts + * const transactions = await orderModuleService.listTransactions({ + * id: ["123", "321"] + * }, { + * relations: ["order"] + * }) + * ``` + * + * 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 transactions = await orderModuleService.listTransactions({ + * id: ["123", "321"] + * }, { + * relations: ["order"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listTransactions( filters?: FilterableOrderTransactionProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method adds a transaction to an order. + * + * @param {CreateOrderTransactionDTO} data - The transaction 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 transaction. + * + * @example + * const transaction = await orderModuleService.addTransactions({ + * order_id: "123", + * amount: 10, + * currency_code: "usd" + * }) + */ addTransactions( data: CreateOrderTransactionDTO, sharedContext?: Context ): Promise + /** + * This method adds transactions to an order. + * + * @param {CreateOrderTransactionDTO[]} data - The order transactions 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 order transactions. + * + * @example + * const transactions = await orderModuleService.addTransactions([{ + * order_id: "123", + * amount: 10, + * currency_code: "usd" + * }]) + */ addTransactions( data: CreateOrderTransactionDTO[], sharedContext?: Context ): Promise + /** + * This method deletes transactions by their IDs. + * + * @param {string | object | string[] | object[]} transactionIds - The ID(s) of the transaction to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the transaction(s) are deleted successfully. + * + * @example + * To delete one transaction: + * + * ```ts + * await orderModuleService.deleteTransactions("123") + * ``` + * + * To delete multiple transactions: + * + * ```ts + * await orderModuleService.deleteTransactions(["123", "321"]) + * ``` + */ deleteTransactions( transactionIds: string | object | string[] | object[], sharedContext?: Context ): Promise + /** + * This method soft deletes transactions by their IDs. + * + * @param {string[]} transactionIds - The IDs of transactions. + * @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. + * The object's keys are the ID attribute names of the transaction entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the transaction through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteTransactions(["123", "321"]) + */ softDeleteTransactions( transactionIds: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted transactions by their IDs. + * + * @param {string[]} transactionIds - The IDs of transactions. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the transactions. You can pass to its `returnLinkableKeys` + * property any of the transaction'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. + * The object's keys are the ID attribute names of the transaction entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the transaction through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreTransactions(["123", "321"]) + */ restoreTransactions( transactionIds: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method retrieves a return reason by its ID. + * + * @param {string} reasonId - The return reason's ID. + * @param {FindConfig} config - The configurations determining how the return reason is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a return reason. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved return reason. + * + * @example + * A simple example that retrieves a return reason by its ID: + * + * ```ts + * const returnReason = await orderModuleService.retrieveReturnReason( + * "123" + * ) + * ``` + * + * To specify relations that should be retrieved: + * + * ```ts + * const returnReason = await orderModuleService.retrieveReturnReason( + * "123", + * { + * relations: ["parent_return_reason"] + * } + * ) + * ``` + */ retrieveReturnReason( reasonId: string, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method retrieves a paginated list of return reasons based on optional filters and configuration. + * + * @param {FilterableOrderReturnReasonProps} filters - The filters to apply on the retrieved return reasons. + * @param {FindConfig} config - The configurations determining how the return reason is retrieved. Its properties, such as `select` or `relations`, accept the + * attributes or relations associated with a return reason. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of return reasons. + * + * @example + * To retrieve a list of return reasons using their IDs: + * + * ```ts + * const returnReasons = await orderModuleService.listReturnReasons({ + * id: ["123", "321"] + * }) + * ``` + * + * To specify relations that should be retrieved within the return reason: + * + * ```ts + * const returnReasons = await orderModuleService.listReturnReasons({ + * id: ["123", "321"] + * }, { + * relations: ["parent_return_reason"] + * }) + * ``` + * + * 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 returnReasons = await orderModuleService.listReturnReasons({ + * id: ["123", "321"] + * }, { + * relations: ["parent_return_reason"], + * take: 20, + * skip: 2 + * }) + * ``` + */ listReturnReasons( filters: FilterableOrderReturnReasonProps, config?: FindConfig, sharedContext?: Context ): Promise + /** + * This method creates a return reason. + * + * @param {CreateOrderReturnReasonDTO} returnReasonData - The return reason 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 return reason. + * + * @example + * const returnReason = await orderModuleService.createReturnReasons({ + * label: "Damaged", + * value: "damaged" + * }) + */ createReturnReasons( returnReasonData: CreateOrderReturnReasonDTO, sharedContext?: Context ): Promise + /** + * This method creates return reasons. + * + * @param {CreateOrderReturnReasonDTO[]} returnReasonData - The return reasons 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 return reason. + * + * @example + * const returnReasons = await orderModuleService.createReturnReasons([{ + * label: "Damaged", + * value: "damaged" + * }]) + */ createReturnReasons( returnReasonData: CreateOrderReturnReasonDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing return reasons. + * + * @param {UpdateOrderReturnReasonWithSelectorDTO[]} data - The filters that specifies which + * return reasons to update, and the data to update in them. + * @returns {Promise} The updated return reasons. + * + * @example + * const returnReasons = await orderModuleService.updateReturnReasons([{ + * selector: { + * id: "13" + * }, + * data: { + * label: "Damaged" + * } + * }]) + */ updateReturnReasons( data: UpdateOrderReturnReasonWithSelectorDTO[], sharedContext?: Context ): Promise + + /** + * This method updates existing return reasons matching the specified filters. + * + * @param {Partial} selector - The filters specifying which return reason to delete. + * @param {Partial} data - The data to update in the return reasons. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated return reasons. + * + * @example + * const returnReasons = await orderModuleService.updateReturnReasons({ + * id: "123" + * }, { + * label: "Damaged" + * }) + */ updateReturnReasons( selector: Partial, data: Partial, sharedContext?: Context ): Promise + + /** + * This method updates an existing return reason. + * + * @param {string} id - The ID of the return reason. + * @param {Partial} data - The data to update in the return reason. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated return reason. + * + * @example + * const returnReason = await orderModuleService.updateReturnReasons( + * "123", + * { + * label: "Damaged" + * } + * ) + */ updateReturnReasons( id: string, data: Partial, sharedContext?: Context ): Promise + /** + * This method deletes return reasons by their IDs. + * + * @param {string[]} returnReasonIds - The IDs of return reasons. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the return reasons are deleted successfully. + * + * @example + * await orderModuleService.deleteReturnReasons([ + * "123", "321" + * ]) + */ deleteReturnReasons( returnReasonIds: string[], sharedContext?: Context ): Promise + /** + * This method soft deletes return reasons by their IDs. + * + * @param {string[]} ids - The IDs of the return reasons. + * @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. + * The object's keys are the ID attribute names of the return reason entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the return reason through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteReturnReasons([ + * "123", "321" + * ]) + */ softDeleteReturnReasons( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted return reasons by their IDs. + * + * @param {string[]} ids - The IDs of the return reasons. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the return reasons. You can pass to its `returnLinkableKeys` + * property any of the return reason'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. + * The object's keys are the ID attribute names of the return reason entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the return reason through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreReturnReasons([ + * "123", "321" + * ]) + */ restoreReturnReasons( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method creates a return item. + * + * @param {CreateOrderReturnItemDTO} data - The return item 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 return item. + * + * @example + * const returnItem = await orderModuleService.createReturnItems({ + * return_id: "123", + * item_id: "321", + * quantity: 1 + * }) + */ createReturnItems( data: CreateOrderReturnItemDTO, sharedContext?: Context ): Promise + /** + * This method creates return items. + * + * @param {CreateOrderReturnItemDTO[]} data - The return items 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 return items. + * + * @example + * const returnItems = await orderModuleService.createReturnItems([{ + * return_id: "123", + * item_id: "321", + * quantity: 1 + * }]) + */ createReturnItems( data: CreateOrderReturnItemDTO[], sharedContext?: Context ): Promise + /** + * This method creates a order claim item. + * + * @param {CreateOrderClaimItemDTO} data - The order claim item 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 order claim item. + * + * @example + * const orderClaimItem = await orderModuleService.createOrderClaimItems({ + * claim_id: "123", + * item_id: "321", + * quantity: 1 + * }) + */ createOrderClaimItems( data: CreateOrderClaimItemDTO, sharedContext?: Context ): Promise + /** + * This method creates order claim items. + * + * @param {CreateOrderClaimItemDTO[]} data - The order claim items 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 order claim items. + * + * @example + * const orderClaimItems = await orderModuleService.createOrderClaimItems([ + * { + * claim_id: "123", + * item_id: "321", + * quantity: 1 + * }, + * { + * claim_id: "321", + * item_id: "321", + * is_additional_item: 1, + * quantity: 1 + * } + * ]) + */ createOrderClaimItems( data: CreateOrderClaimItemDTO[], sharedContext?: Context ): Promise + /** + * This method creates an order exchange item. + * + * @param {CreateOrderExchangeItemDTO} data - The order exchange item 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 order exchange item. + * + * @example + * const orderExchangeItem = await orderModuleService.createOrderExchangeItems({ + * exchange_id: "123", + * item_id: "321", + * quantity: 1 + * }) + */ createOrderExchangeItems( data: CreateOrderExchangeItemDTO, sharedContext?: Context ): Promise + /** + * This method creates order exchange items. + * + * @param {CreateOrderExchangeItemDTO[]} data - The order exchange items 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 order exchange items. + * + * @example + * const orderExchangeItems = await orderModuleService.createOrderExchangeItems([ + * { + * exchange_id: "123", + * item_id: "321", + * quantity: 1 + * }, + * { + * exchange_id: "321", + * item_id: "123", + * quantity: 1 + * } + * ]) + */ createOrderExchangeItems( data: CreateOrderExchangeItemDTO[], sharedContext?: Context ): Promise + /** + * This method creates a return. + * + * @param {CreateOrderReturnDTO} data - The return 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 return. + * + * @example + * const orderReturn = await orderModuleService.createReturns({ + * order_id: "123", + * items: [ + * { + * id: "321", + * quantity: 1 + * } + * ] + * }) + */ createReturns( data: CreateOrderReturnDTO, sharedContext?: Context ): Promise + /** + * This method creates returns. + * + * @param {CreateOrderReturnDTO[]} data - The returns 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 returns. + * + * @example + * const returns = await orderModuleService.createReturns([{ + * order_id: "123", + * items: [ + * { + * id: "321", + * quantity: 1 + * } + * ] + * }]) + */ createReturns( data: CreateOrderReturnDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing returns. + * + * @param {UpdateOrderReturnWithSelectorDTO[]} data - The filters specifying which returns to update, + * and the data to update in them. + * @returns {Promise} The updated returns. + * + * @example + * const returns = await orderModuleService.updateReturns([{ + * selector: { + * id: "123" + * }, + * data: { + * refund_amount: 10 + * } + * }]) + */ updateReturns( data: UpdateOrderReturnWithSelectorDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing returns matching the specified filters. + * + * @param {Partial} selector - The filters specifying which returns to update. + * @param {Partial} data - The data to update in the returns. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated returns. + * + * @example + * const returns = await orderModuleService.updateReturns({ + * id: "123" + * }, { + * refund_amount: 10 + * }) + */ updateReturns( selector: Partial, data: Partial, sharedContext?: Context ): Promise + + /** + * This method updates an existing return. + * + * @param {string} id - The ID of the return. + * @param {Partial} data - The data to update. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated return. + * + * @example + * const orderReturn = await orderModuleService.updateReturns( + * "123", + * { + * refund_amount: 10 + * } + * ) + */ updateReturns( id: string, data: Partial, sharedContext?: Context ): Promise + /** + * This method deletes returns by their IDs. + * + * @param {string[]} ids - The IDs of the returns. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the returns are deleted successfully. + * + * @example + * await orderModuleService.deleteReturns(["123", "321"]) + */ deleteReturns(ids: string[], sharedContext?: Context): Promise + /** + * This method deletes return items by their IDs. + * + * @param {string[]} ids - The IDs of the return 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 return items are deleted successfully. + * + * @example + * await orderModuleService.deleteReturnItems(["123", "321"]) + */ deleteReturnItems(ids: string[], sharedContext?: Context): Promise + /** + * This method soft deletes returns by their IDs. + * + * @param {string[]} ids - The IDs of the returns. + * @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. + * The object's keys are the ID attribute names of the return entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the return through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteReturns(["123", "321"]) + */ softDeleteReturns( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted returns by their IDs. + * + * @param {string[]} ids - The IDs of the returns. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the returns. You can pass to its `returnLinkableKeys` + * property any of the return'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. + * The object's keys are the ID attribute names of the return entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the return through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreReturns(["123", "321"]) + */ restoreReturns( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method creates an order claim. + * + * @param {CreateOrderClaimDTO} data - The order claim 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 order claim. + * + * @example + * const claim = await orderModuleService.createOrderClaims({ + * order_id: "123", + * type: "refund" + * }) + */ createOrderClaims( data: CreateOrderClaimDTO, sharedContext?: Context ): Promise + /** + * This method creates order claims. + * + * @param {CreateOrderClaimDTO[]} data - The order claims 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 order claims. + * + * @example + * const claims = await orderModuleService.createOrderClaims([{ + * order_id: "123", + * type: "refund" + * }]) + */ createOrderClaims( data: CreateOrderClaimDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing order claims. + * + * @param {UpdateOrderClaimWithSelectorDTO[]} data - The filters specifying which order claims to update, + * and the data to update in them. + * @returns {Promise} The updated order claims. + * + * @example + * const claims = await orderModuleService.updateOrderClaims([ + * { + * selector: { + * id: "123" + * }, + * data: { + * type: "refund" + * } + * } + * ]) + */ updateOrderClaims( data: UpdateOrderClaimWithSelectorDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing order claims matching the specified filters. + * + * @param {Partial} selector - The filters specifying which order claims to update. + * @param {Partial} data - The data to update in the order claims. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order claims. + * + * @example + * const claims = await orderModuleService.updateOrderClaims({ + * id: "123" + * }, { + * type: "refund" + * }) + */ updateOrderClaims( selector: Partial, data: Partial, sharedContext?: Context ): Promise + + /** + * This method updates an existing order claim. + * + * @param {string} id - The ID of the order claim. + * @param {Partial} data - The data to update in the order claim. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order claim. + * + * @example + * const claim = await orderModuleService.updateOrderClaims("123", { + * type: "refund" + * }) + */ updateOrderClaims( id: string, data: Partial, sharedContext?: Context ): Promise + /** + * This method deletes an order claim by its ID. + * + * @param {string[]} ids - The IDs of the order claims. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the order claims are deleted successfully. + * + * @example + * await orderModuleService.deleteOrderClaims(["123", "321"]) + */ deleteOrderClaims(ids: string[], sharedContext?: Context): Promise + /** + * This method deletes order claim items by their IDs. + * + * @param {string[]} ids - The IDs of the order claim 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 claim items are deleted. + * + * @example + * await orderModuleService.deleteOrderClaimItems([ + * "123", "321" + * ]) + */ deleteOrderClaimItems(ids: string[], sharedContext?: Context): Promise + /** + * This method deletes order claim item images by their IDs. + * + * @param {string[]} ids - The IDs of the order claim item images. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the claim items are deleted. + * + * @example + * await orderModuleService.deleteOrderClaimItemImages([ + * "123", "321" + * ]) + */ deleteOrderClaimItemImages( ids: string[], sharedContext?: Context ): Promise + /** + * This method soft deletes order claims by their IDs. + * + * @param {string[]} ids - The IDs of the order claims. + * @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. + * The object's keys are the ID attribute names of the order claim entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the order claim through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteOrderClaims(["123", "321"]) + */ softDeleteOrderClaims( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted order claims by their IDs. + * + * @param {string[]} ids - The IDs of the order claims. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the order. You can pass to its `returnLinkableKeys` + * property any of the order claim'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. + * The object's keys are the ID attribute names of the order claim entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the order claims through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreOrderClaims(["123", "321"]) + */ restoreOrderClaims( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> + /** + * This method creates an order exchange. + * + * @param {CreateOrderExchangeDTO} data - The order exchange 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 order exchange. + * + * @example + * const exchange = await orderModuleService.createOrderExchanges({ + * order_id: "123", + * additional_items: [ + * { + * id: "123", + * quantity: 1 + * } + * ] + * }) + */ createOrderExchanges( data: CreateOrderExchangeDTO, sharedContext?: Context ): Promise + /** + * This method creates order exchanges. + * + * @param {CreateOrderExchangeDTO[]} data - The order exchanges 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 order exchanges. + * + * @example + * const exchanges = await orderModuleService.createOrderExchanges([{ + * order_id: "123", + * additional_items: [ + * { + * id: "123", + * quantity: 1 + * } + * ] + * }]) + */ createOrderExchanges( data: CreateOrderExchangeDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing order exchanges. + * + * @param {UpdateOrderExchangeWithSelectorDTO[]} data - The filters specifying which exchanges to update, + * and the data to update in them. + * @returns {Promise} The updated order exchanges. + * + * @example + * const exchanges = await orderModuleService.updateOrderExchanges([ + * { + * selector: { + * id: "123" + * }, + * data: { + * return_id: "123" + * } + * } + * ]) + */ updateOrderExchanges( data: UpdateOrderExchangeWithSelectorDTO[], sharedContext?: Context ): Promise + /** + * This method updates existing order exchanges matching the specified filters. + * + * @param {Partial} selector - The filters specifying which order exchanges to update. + * @param {Partial} data - The data to update in the order exchanges. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order exchanges. + * + * @example + * const exchanges = await orderModuleService.updateOrderExchanges({ + * id: "123" + * }, { + * return_id: "123" + * }) + */ updateOrderExchanges( selector: Partial, data: Partial, sharedContext?: Context ): Promise + + /** + * This method updates an existing order exchange. + * + * @param {string} id - The ID of the order exchange. + * @param {Partial} data - The data to update in the order exchange. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The updated order exchange. + * + * @example + * const exchange = await orderModuleService.updateOrderExchanges( + * "123", + * { + * return_id: "123" + * } + * ) + */ updateOrderExchanges( id: string, data: Partial, sharedContext?: Context ): Promise + /** + * This method deletes order exchanges by their IDs. + * + * @param {string[]} ids - The IDs of the order exchanges. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the order exchanges are deleted successfully. + * + * @example + * await orderModuleService.deleteOrderExchanges(["123", "321"]) + */ deleteOrderExchanges(ids: string[], sharedContext?: Context): Promise + /** + * This method deletes order exchange items by their IDs. + * + * @param {string[]} ids - The IDs of the order exchange 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 order exchange items are deleted successfully. + * + * @example + * await orderModuleService.deleteOrderExchangeItems([ + * "123", "321" + * ]) + */ deleteOrderExchangeItems( ids: string[], sharedContext?: Context ): Promise + /** + * This method soft deletes order exchanges by their IDs. + * + * @param {string[]} ids - The IDs of the order exchanges. + * @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. + * The object's keys are the ID attribute names of the order exchange entity's relations, and its value is an array of strings, each being the ID of a record associated + * with the order exchange through this relation. + * + * If there are no related records, the promise resolves to `void`. + * + * @example + * await orderModuleService.softDeleteOrderExchanges(["123", "321"]) + */ softDeleteOrderExchanges( ids: string[], config?: SoftDeleteReturn, sharedContext?: Context ): Promise | void> + /** + * This method restores soft-deleted order exchanges by their IDs. + * + * @param {string[]} ids - The IDs of the order exchanges. + * @param {RestoreReturn} config - Configurations determining which relations to restore along with each of the order exchanges. You can pass to its `returnLinkableKeys` + * property any of the order exchange'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. + * The object's keys are the ID attribute names of the order exchange entity's relations, + * and its value is an array of strings, each being the ID of the record associated with the order exchange through this relation. + * + * If there are no related records restored, the promise resolves to `void`. + * + * @example + * await orderModuleService.restoreOrderExchanges(["123", "321"]) + */ restoreOrderExchanges( ids: string[], config?: RestoreReturn, sharedContext?: Context ): Promise | void> - archive(orderId: string[], sharedContext?: Context): Promise + /** + * This method sets the status of orders to `archived`. + * + * @param {string[]} orderIds - The orders' ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The archived orders. + * + * @example + * const orders = await orderModuleService.archive(["123", "321"]) + */ + archive(orderIds: string[], sharedContext?: Context): Promise + + /** + * This method sets the status of an order to `archived`. + * + * @param {string} orderId - The order's ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The archived order. + * + * @example + * const order = await orderModuleService.archive("123") + */ archive(orderId: string, sharedContext?: Context): Promise - completeOrder(orderId: string[], sharedContext?: Context): Promise + /** + * This method sets the status of orders to `completed`. + * + * @param {string[]} orderIds - The orders' IDs. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The completed orders. + * + * @example + * const orders = await orderModuleService.completeOrder([ + * "123", "321" + * ]) + */ + completeOrder( + orderIds: string[], + sharedContext?: Context + ): Promise + + /** + * This method sets the status of an order to `completed`. + * + * @param {string} orderId - The order's ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The completed order. + * + * @example + * const order = await orderModuleService.completeOrder("123") + */ completeOrder(orderId: string, sharedContext?: Context): Promise + /** + * This method sets the status of orders to `canceled`. + * + * @param {string[]} orderId - The orders' IDs. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The canceled orders. + * + * @example + * const orders = await orderModuleService.cancel(["123", "321"]) + */ cancel(orderId: string[], sharedContext?: Context): Promise - cancel(orderId: string, sharedContext?: Context): Promise + /** + * This method sets the status of an order to `canceled`. + * + * @param {string} orderId - The order's ID. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Represents the completion of an asynchronous operation + * + * @example + * const orders = await orderModuleService.cancel("123") + */ + cancel(orderId: string, sharedContext?: Context): Promise // Bundled flows + + /** + * Register a fulfillment for an order, return, exchange, or claim. + * + * @param {RegisterOrderFulfillmentDTO} data - The fulfillment's details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the fulfillment is registered successfully. + * + * @example + * await orderModuleService.registerFulfillment({ + * order_id: "123", + * items: [ + * { + * id: "321", + * quantity: 1 + * } + * ] + * }) + */ registerFulfillment( data: RegisterOrderFulfillmentDTO, sharedContext?: Context ): Promise + /** + * This method cancels the fulfillment of an order, return, claim, or exchange. + * + * @param {CancelOrderFulfillmentDTO} data - The cancelation details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the fulfillment is canceled. + * + * @example + * await orderModuleService.cancelFulfillment({ + * order_id: "123", + * items: [ + * { + * id: "321", + * quantity: 1 + * } + * ] + * }) + */ cancelFulfillment( data: CancelOrderFulfillmentDTO, sharedContext?: Context ): Promise + /** + * This method registers a shipment for an order, return, claim, or exchange. + * + * @param {RegisterOrderShipmentDTO} data - The shipment's data. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the shipment's data are registered successfully. + * + * @example + * await orderModuleService.registerShipment({ + * order_id: "123", + * items: [ + * { + * id: "321", + * quantity: 1 + * } + * ] + * }) + */ registerShipment( data: RegisterOrderShipmentDTO, sharedContext?: Context ): Promise + /** + * This method creates a return. + * + * @param {CreateOrderReturnDTO} returnData - The order return 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 order return. + * + * @example + * const orderReturn = await orderModuleService.createReturn({ + * order_id: "123", + * items: [{ + * id: "321", + * quantity: 1 + * }] + * }) + */ createReturn( returnData: CreateOrderReturnDTO, sharedContext?: Context ): Promise + /** + * This method cancels an order return. + * + * @param {CancelOrderReturnDTO} data - The cancelation details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The canceled return. + * + * @example + * const orderReturn = await orderModuleService.cancelReturn({ + * return_id: "123" + * }) + */ cancelReturn( data: CancelOrderReturnDTO, sharedContext?: Context ): Promise + /** + * This method marks a return as received, changing its status to `received`. + * + * @param {ReceiveOrderReturnDTO} returnData - The receival details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The received return. + * + * @example + * const orderReturn = await orderModuleService.receiveReturn({ + * return_id: "123", + * items: [ + * { + * id: "123", + * quantity:1 + * } + * ] + * }) + */ receiveReturn( returnData: ReceiveOrderReturnDTO, sharedContext?: Context ): Promise + /** + * This method creates a claim. + * + * @param {CreateOrderClaimDTO} claimData - The order claim 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 claim. + * + * @example + * const claim = await orderModuleService.createClaim({ + * order_id: "123", + * type: "refund" + * }) + */ createClaim( claimData: CreateOrderClaimDTO, sharedContext?: Context ): Promise + /** + * This method cancels a claim. + * + * @param {CancelOrderClaimDTO} data - The cancelation details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The canceled claim. + * + * @example + * const claim = await orderModuleService.cancelClaim({ + * claim_id: "123", + * }) + */ cancelClaim( data: CancelOrderClaimDTO, sharedContext?: Context ): Promise + /** + * This method creates an order exchange. + * + * @param {CreateOrderExchangeDTO} exchangeData - The order exchange 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 order exchange. + * + * @example + * const exchange = await orderModuleService.createExchange({ + * order_id: "123", + * additional_items: [ + * { + * id: "123", + * quantity: 1 + * } + * ] + * }) + */ createExchange( exchangeData: CreateOrderExchangeDTO, sharedContext?: Context ): Promise + /** + * This method cancels an exchange. + * + * @param {CancelOrderExchangeDTO} data - The cancelation details. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The canceled order exchange. + * + * @example + * const exchange = await orderModuleService.cancelExchange({ + * exchange_id: "123" + * }) + */ cancelExchange( data: CancelOrderExchangeDTO, sharedContext?: Context