Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-heads-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codee-sh/medusa-plugin-automations": patch
---

update ORDER_ATTRIBUTES to ORDER_QUERY_FIELDS for improved totals calculation and UI consistency
11 changes: 11 additions & 0 deletions src/modules/mpn-automation/services/slack-action-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import {
import { renderInventoryLevel } from "../../../templates/slack/inventory-level"
import { renderProductVariant } from "../../../templates/slack/product-variant/product-variant"
import { renderProduct } from "../../../templates/slack/product/product"
import { renderOrderPlaced } from "../../../templates/slack/order/order-placed"
import { renderOrderCompleted } from "../../../templates/slack/order/order-completed"
import { renderOrderUpdated } from "../../../templates/slack/order/order-updated"
import { renderOrderCanceled } from "../../../templates/slack/order/order-canceled"
import { renderOrderArchived } from "../../../templates/slack/order/order-archived"

export class SlackActionService extends BaseActionService {
id = "slack"
Expand Down Expand Up @@ -35,6 +40,12 @@ export class SlackActionService extends BaseActionService {
renderProductVariant as any
)
this.registerTemplate("product", renderProduct as any)

this.registerTemplate("order-placed", renderOrderPlaced as any)
this.registerTemplate("order-completed", renderOrderCompleted as any)
this.registerTemplate("order-updated", renderOrderUpdated as any)
this.registerTemplate("order-canceled", renderOrderCanceled as any)
this.registerTemplate("order-archived", renderOrderArchived as any)
}

/**
Expand Down
46 changes: 46 additions & 0 deletions src/modules/mpn-automation/types/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PRODUCT_VARIANT_ATTRIBUTES } from "./product-variant"
import { PRODUCT_TAG_ATTRIBUTES } from "./product-tag"
import { PRODUCT_TYPE_ATTRIBUTES } from "./product-type"
import { PRODUCT_CATEGORY_ATTRIBUTES } from "./product-category"
import { ORDER_ATTRIBUTES } from "./order"
import { Attribute } from "../types"

/**
Expand Down Expand Up @@ -136,4 +137,49 @@ const EVENT_METADATA_REGISTRY: Record<string, any> = {
},
],
},
"order.updated": {
attributes: ORDER_ATTRIBUTES,
templates: [
{
value: "order-updated",
name: "Order updated",
},
],
},
"order.placed": {
attributes: ORDER_ATTRIBUTES,
templates: [
{
value: "order-placed",
name: "Order placed",
},
],
},
"order.canceled": {
attributes: ORDER_ATTRIBUTES,
templates: [
{
value: "order-canceled",
name: "Order canceled",
},
],
},
"order.completed": {
attributes: ORDER_ATTRIBUTES,
templates: [
{
value: "order-completed",
name: "Order completed",
},
],
},
"order.archived": {
attributes: ORDER_ATTRIBUTES,
templates: [
{
value: "order-archived",
name: "Order archived",
},
],
},
}
12 changes: 12 additions & 0 deletions src/modules/mpn-automation/types/modules/inventory/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ export const INVENTORY_LEVEL_ATTRIBUTES = [
relationType: "stock_locations",
},
]

// Fields for use in query.graph() - includes technical relations with *
// These fields are needed for correct data retrieval including all relation data
// INVENTORY_LEVEL_QUERY_FIELDS contains all fields from INVENTORY_LEVEL_ATTRIBUTES plus technical relations
export const INVENTORY_LEVEL_QUERY_FIELDS = [
// Basic fields from INVENTORY_LEVEL_ATTRIBUTES
...INVENTORY_LEVEL_ATTRIBUTES.map((attr) => attr.value),

// Technical relations required for complete data retrieval
// These fields are not available in UI rules, but are needed for correct data retrieval
"inventory_level.stock_locations.*",
]
1 change: 1 addition & 0 deletions src/modules/mpn-automation/types/modules/order/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./order"
Loading