chore(): order module index and some impl details (#13462)

* order module fixes

* order module fixes

* fixes

* revert big number

* Create wet-wombats-rule.md
This commit is contained in:
Adrien de Peretti
2025-09-11 09:02:38 +02:00
committed by GitHub
parent 368c1d1e17
commit 823a5c75ff
23 changed files with 680 additions and 463 deletions

View File

@@ -444,6 +444,16 @@ export default class OrderModuleService
filters?: any,
config?: FindConfig<any> | undefined,
sharedContext?: Context
): Promise<OrderTypes.OrderDTO[]> {
const orders = await this.listOrders_(filters, config, sharedContext)
return this.baseRepository_.serialize<OrderTypes.OrderDTO[]>(orders)
}
protected async listOrders_(
filters?: any,
config?: FindConfig<any> | undefined,
@MedusaContext() sharedContext?: Context | undefined
): Promise<OrderTypes.OrderDTO[]> {
config ??= {}
const includeTotals = this.shouldIncludeTotals(config)
@@ -1035,7 +1045,7 @@ export default class OrderModuleService
: [orderIdOrData]
const allOrderIds = data.map((dt) => dt.order_id)
const order = await this.listOrders(
const order = await this.listOrders_(
{ id: allOrderIds },
{ select: ["id", "version"] },
sharedContext
@@ -1212,7 +1222,7 @@ export default class OrderModuleService
let toUpdate: UpdateOrderLineItemDTO[] = []
const detailsToUpdate: UpdateOrderItemWithSelectorDTO[] = []
for (const { selector, data } of updates) {
const items = await this.listOrderLineItems(
const items = await this.orderLineItemService_.list(
{ ...selector },
{},
sharedContext
@@ -1311,7 +1321,7 @@ export default class OrderModuleService
): Promise<InferEntityType<typeof OrderItem>[]> {
let toUpdate: UpdateOrderItemDTO[] = []
for (const { selector, data } of updates) {
const details = await this.listOrderItems(
const details = await this.orderItemService_.list(
{ ...selector },
{},
sharedContext
@@ -1369,7 +1379,7 @@ export default class OrderModuleService
: [orderIdOrData]
const allOrderIds = data.map((dt) => dt.order_id)
const order = await this.listOrders(
const order = await this.listOrders_(
{ id: allOrderIds },
{ select: ["id", "version"] },
sharedContext
@@ -2432,7 +2442,7 @@ export default class OrderModuleService
const orderIds: string[] = []
const dataMap: Record<string, object> = {}
const orderChanges = await this.listOrderChanges(
const orderChanges = await this.orderChangeService_.list(
{
order_id: dataArr.map((data) => data.order_id),
status: [OrderChangeStatus.PENDING, OrderChangeStatus.REQUESTED],
@@ -2441,9 +2451,10 @@ export default class OrderModuleService
sharedContext
)
const orderChangesMap = new Map<string, OrderTypes.OrderChangeDTO>(
orderChanges.map((item) => [item.order_id, item])
)
const orderChangesMap = new Map<
string,
InferEntityType<typeof OrderChange>
>(orderChanges.map((item) => [item.order_id, item]))
for (const change of dataArr) {
orderIds.push(change.order_id)
@@ -3462,7 +3473,7 @@ export default class OrderModuleService
}
}
let orders = await this.listOrders(
let orders = await this.listOrders_(
{ id: deduplicate(ordersIds) },
{
select: ["id", "version", "items.detail", "summary", "total"],
@@ -3744,7 +3755,7 @@ export default class OrderModuleService
isRemoved: boolean,
@MedusaContext() sharedContext: Context = {}
) {
const summaries: any = await super.listOrderSummaries(
const summaries: any = await this.listOrderSummaries(
{
order_id: transactionData.map((trx) => trx.order_id),
version: transactionData[0].version,
@@ -3826,7 +3837,7 @@ export default class OrderModuleService
@MedusaContext() sharedContext: Context = {}
): Promise<OrderTypes.OrderDTO[]> {
const orderIds = Array.isArray(orderId) ? orderId : [orderId]
const orders = await this.listOrders(
const orders = await this.listOrders_(
{
id: orderIds,
},
@@ -3899,7 +3910,7 @@ export default class OrderModuleService
@MedusaContext() sharedContext: Context = {}
): Promise<OrderTypes.OrderDTO[]> {
const orderIds = Array.isArray(orderId) ? orderId : [orderId]
const orders = await this.listOrders(
const orders = await this.listOrders_(
{
id: orderIds,
},
@@ -3964,7 +3975,7 @@ export default class OrderModuleService
@MedusaContext() sharedContext: Context = {}
): Promise<OrderTypes.OrderDTO[]> {
const orderIds = Array.isArray(orderId) ? orderId : [orderId]
const orders = await this.listOrders(
const orders = await this.listOrders_(
{
id: orderIds,
},