diff --git a/src/admin/automations/automations-form/automations-rules-form/index.tsx b/src/admin/automations/automations-form/automations-rules-form/index.tsx index 48a8fa1..9e592d7 100644 --- a/src/admin/automations/automations-form/automations-rules-form/index.tsx +++ b/src/admin/automations/automations-form/automations-rules-form/index.tsx @@ -1,10 +1,9 @@ -import { Label, Select, Button } from "@medusajs/ui" +import { Button } from "@medusajs/ui" import { useAvailableEvents } from "../../../../hooks/api/available-events" -import { OPERATOR_TYPES } from "../../../../modules/mpn-automation/types/types" -import { Controller, useFieldArray } from "react-hook-form" +import { useFieldArray } from "react-hook-form" import { useMemo } from "react" -import { Trash, Plus } from "@medusajs/icons" -import { RuleValueInput } from "./rule-value-input" +import { Plus } from "@medusajs/icons" +import { RuleItem } from "./rule-item" export function AutomationsRulesForm({ form, @@ -76,116 +75,13 @@ export function AutomationsRulesForm({ )} {fields.map((field, index) => ( -
-
-
- ( - <> - - - {fieldState.error && ( - - {fieldState.error.message} - - )} - - )} - /> - ( - <> - - - {fieldState.error && ( - - {fieldState.error.message} - - )} - - )} - /> - -
- -
-
+ control={form.control} + index={index} + eventAttributes={eventAttributes} + onRemove={() => handleRemoveRule(index)} + /> ))} + + + ) +} + diff --git a/src/modules/mpn-automation/types/modules/index.ts b/src/modules/mpn-automation/types/modules/index.ts index 99ad811..a2db6fa 100644 --- a/src/modules/mpn-automation/types/modules/index.ts +++ b/src/modules/mpn-automation/types/modules/index.ts @@ -15,6 +15,16 @@ import { Attribute } from "../types" */ export type EventMetadata = { eventName: string + /** + * Description of when this event is triggered + * Example: "Triggered when a customer completes checkout and an order is created" + */ + description?: string + /** + * Example scenarios when this event would fire + * Example: ["Customer completes payment", "Order is confirmed"] + */ + examples?: string[] attributes: Array templates: Array<{ value: string; name: string }> } @@ -39,6 +49,12 @@ export function getEventMetadata( const EVENT_METADATA_REGISTRY: Record = { // Inventory Events "inventory.inventory-level.created": { + description: "Triggered when a new inventory level is created for a location", + examples: [ + "New stock location is added", + "Inventory item is assigned to a location", + "Initial stock is recorded" + ], attributes: INVENTORY_LEVEL_ATTRIBUTES, templates: [ { @@ -48,6 +64,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "inventory.inventory-level.updated": { + description: "Triggered when inventory level changes (stock quantity, reserved quantity, etc.)", + examples: [ + "Stock quantity is updated", + "Items are reserved or released", + "Inventory adjustments are made" + ], attributes: INVENTORY_LEVEL_ATTRIBUTES, templates: [ { @@ -57,6 +79,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "inventory.inventory-level.deleted": { + description: "Triggered when an inventory level is deleted from a location", + examples: [ + "Stock location is removed", + "Inventory item is unassigned from a location", + "Inventory level record is deleted" + ], attributes: INVENTORY_LEVEL_ATTRIBUTES, templates: [ { @@ -66,6 +94,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "inventory.inventory-item.created": { + description: "Triggered when a new inventory item is created", + examples: [ + "New product variant is added to inventory", + "Inventory item is registered in the system", + "Stock tracking begins for a new item" + ], attributes: INVENTORY_ITEM_ATTRIBUTES, templates: [ { @@ -75,6 +109,13 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "inventory.inventory-item.updated": { + description: "Triggered when inventory item data is modified (quantities, location, etc.)", + examples: [ + "Stock quantity changes", + "Reserved quantity is updated", + "Available quantity changes", + "Incoming quantity is adjusted" + ], attributes: INVENTORY_ITEM_ATTRIBUTES, templates: [ { @@ -84,6 +125,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "inventory.inventory-item.deleted": { + description: "Triggered when an inventory item is deleted", + examples: [ + "Product variant is removed from inventory", + "Inventory item is discontinued", + "Stock tracking is stopped for an item" + ], attributes: INVENTORY_ITEM_ATTRIBUTES, templates: [ { @@ -93,6 +140,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "product.updated": { + description: "Triggered when product data is modified (title, description, status, etc.)", + examples: [ + "Product title or description changes", + "Product status is updated", + "Product metadata is modified" + ], attributes: PRODUCT_ATTRIBUTES, templates: [ { @@ -102,6 +155,13 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "product-variant.updated": { + description: "Triggered when product variant data is modified (SKU, price, inventory settings, etc.)", + examples: [ + "Variant SKU is updated", + "Variant price changes", + "Inventory management settings change", + "Variant attributes are modified" + ], attributes: PRODUCT_VARIANT_ATTRIBUTES, templates: [ { @@ -111,6 +171,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "product-tag.updated": { + description: "Triggered when a product tag is modified", + examples: [ + "Tag name/value is changed", + "Tag is renamed", + "Tag metadata is updated" + ], attributes: PRODUCT_TAG_ATTRIBUTES, templates: [ { @@ -120,6 +186,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "product-type.updated": { + description: "Triggered when a product type is modified", + examples: [ + "Product type name/value is changed", + "Product type is renamed", + "Product type metadata is updated" + ], attributes: PRODUCT_TYPE_ATTRIBUTES, templates: [ { @@ -129,6 +201,13 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "product-category.updated": { + description: "Triggered when a product category is modified (name, description, parent, etc.)", + examples: [ + "Category name or description changes", + "Category parent is changed", + "Category status (active/inactive) is updated", + "Category rank/order is modified" + ], attributes: PRODUCT_CATEGORY_ATTRIBUTES, templates: [ { @@ -138,6 +217,13 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "order.updated": { + description: "Triggered when any order data is modified (status, totals, items, etc.)", + examples: [ + "Order status changes", + "Order totals are recalculated", + "Items are added or removed", + "Payment collection status changes" + ], attributes: ORDER_ATTRIBUTES, templates: [ { @@ -147,6 +233,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "order.placed": { + description: "Triggered when a customer completes checkout and an order is created", + examples: [ + "Customer completes payment", + "Order is confirmed", + "Order enters the system" + ], attributes: ORDER_ATTRIBUTES, templates: [ { @@ -156,6 +248,13 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "order.canceled": { + description: "Triggered when an order is canceled", + examples: [ + "Customer cancels their order", + "Merchant cancels an order", + "Order is canceled due to payment failure", + "Order cancellation is processed" + ], attributes: ORDER_ATTRIBUTES, templates: [ { @@ -165,6 +264,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "order.completed": { + description: "Triggered when an order is marked as completed", + examples: [ + "All items are fulfilled", + "Order is finalized", + "Order processing is finished" + ], attributes: ORDER_ATTRIBUTES, templates: [ { @@ -174,6 +279,12 @@ const EVENT_METADATA_REGISTRY: Record = { ], }, "order.archived": { + description: "Triggered when an order is archived", + examples: [ + "Order is moved to archive", + "Completed order is archived", + "Old order is archived for record keeping" + ], attributes: ORDER_ATTRIBUTES, templates: [ { diff --git a/src/modules/mpn-automation/types/modules/inventory/inventory.ts b/src/modules/mpn-automation/types/modules/inventory/inventory.ts index 7606f33..b9101a8 100644 --- a/src/modules/mpn-automation/types/modules/inventory/inventory.ts +++ b/src/modules/mpn-automation/types/modules/inventory/inventory.ts @@ -2,22 +2,32 @@ export const INVENTORY_ITEM_ATTRIBUTES = [ { value: "inventory_item.stocked_quantity", label: "Stocked Quantity", + description: "Total quantity of items in stock", + examples: ["0", "10", "100", "500"], }, { value: "inventory_item.reserved_quantity", label: "Reserved Quantity", + description: "Quantity of items currently reserved (e.g., in carts or pending orders)", + examples: ["0", "5", "20", "50"], }, { value: "inventory_item.available_quantity", label: "Available Quantity", + description: "Quantity available for sale (stocked - reserved)", + examples: ["0", "5", "50", "200"], }, { value: "inventory_item.incoming_quantity", label: "Incoming Quantity", + description: "Quantity of items expected to arrive (e.g., from suppliers)", + examples: ["0", "10", "100", "500"], }, { value: "inventory_item.location_id", label: "Location ID", + description: "Unique identifier of the inventory location", + examples: ["loc_01ABC123"], }, ] @@ -25,34 +35,50 @@ export const INVENTORY_LEVEL_ATTRIBUTES = [ { value: "inventory_level.id", label: "ID", + description: "Unique identifier of the inventory level", + examples: ["ilev_01ABC123", "ilev_01XYZ789"], }, { value: "inventory_level.inventory_item_id", label: "Inventory Item ID", + description: "Unique identifier of the inventory item", + examples: ["iitem_01ABC123"], }, { value: "inventory_level.stocked_quantity", label: "Stocked Quantity", + description: "Total quantity of items in stock at this location", + examples: ["0", "10", "100", "500"], }, { value: "inventory_level.reserved_quantity", label: "Reserved Quantity", + description: "Quantity of items currently reserved at this location", + examples: ["0", "5", "20", "50"], }, { value: "inventory_level.available_quantity", label: "Available Quantity", + description: "Quantity available for sale at this location (stocked - reserved)", + examples: ["0", "5", "50", "200"], }, { value: "inventory_level.incoming_quantity", label: "Incoming Quantity", + description: "Quantity of items expected to arrive at this location", + examples: ["0", "10", "100", "500"], }, { value: "inventory_level.location_id", label: "Location ID", + description: "Unique identifier of the stock location", + examples: ["loc_01ABC123"], }, { value: "inventory_level.stock_locations.id", label: "Stock Location ID", + description: "Unique identifier of the stock location. This is an array - operator 'eq' checks if ANY value matches", + examples: ["loc_01ABC123"], type: "array", isRelation: true, relationType: "stock_locations", @@ -60,6 +86,8 @@ export const INVENTORY_LEVEL_ATTRIBUTES = [ { value: "inventory_level.stock_locations.name", label: "Stock Location Name", + description: "Name of the stock location. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Main Warehouse", "Store A", "Distribution Center"], type: "array", isRelation: true, relationType: "stock_locations", diff --git a/src/modules/mpn-automation/types/modules/order/helpers.ts b/src/modules/mpn-automation/types/modules/order/helpers.ts new file mode 100644 index 0000000..5e45cf2 --- /dev/null +++ b/src/modules/mpn-automation/types/modules/order/helpers.ts @@ -0,0 +1,30 @@ +import { OrderStatus, PaymentCollectionStatus } from "@medusajs/framework/utils" + +/** + * Helper to get all possible OrderStatus values + */ +export const ORDER_STATUS_VALUES = Object.values(OrderStatus) as string[] + +/** + * Helper to get all possible PaymentCollectionStatus values + */ +export const PAYMENT_COLLECTION_STATUS_VALUES = Object.values( + PaymentCollectionStatus +) as string[] + +/** + * FulfillmentStatus is a union type, not an enum, so we define values manually + * Based on: @medusajs/framework/types - FulfillmentStatus + * import { FulfillmentStatus } from "@medusajs/framework/types" + */ +export const FULFILLMENT_STATUS_VALUES: string[] = [ + "not_fulfilled", + "partially_fulfilled", + "fulfilled", + "partially_shipped", + "shipped", + "partially_delivered", + "delivered", + "canceled", +] + diff --git a/src/modules/mpn-automation/types/modules/order/order.ts b/src/modules/mpn-automation/types/modules/order/order.ts index 1eed3c3..d1caf38 100644 --- a/src/modules/mpn-automation/types/modules/order/order.ts +++ b/src/modules/mpn-automation/types/modules/order/order.ts @@ -1,3 +1,9 @@ +import { + ORDER_STATUS_VALUES, + PAYMENT_COLLECTION_STATUS_VALUES, + FULFILLMENT_STATUS_VALUES, +} from "./helpers" + // Attributes available in rules (without technical relations with *) // These attributes are displayed in the UI for creating conditions in automations export const ORDER_ATTRIBUTES = [ @@ -5,184 +11,297 @@ export const ORDER_ATTRIBUTES = [ { value: "order.id", label: "ID", + description: "Unique identifier of the order", + examples: ["order_01ABC123", "order_01XYZ789"], }, { value: "order.display_id", label: "Display ID", + description: "Human-readable order number displayed to customers", + examples: ["#1001", "#2050", "#9999"], }, { value: "order.custom_display_id", label: "Custom Display ID", + description: "Custom order identifier set by the merchant", + examples: ["CUSTOM-001", "PO-2024-001"], }, { value: "order.status", label: "Status", + description: "Current status of the order", + examples: ORDER_STATUS_VALUES, }, { value: "order.locale", label: "Locale", + description: "Locale code for the order (language and region)", + examples: ["pl", "en", "en-US", "pl-PL"], }, { value: "order.email", label: "Email", + description: "Customer email address associated with the order", + examples: ["customer@example.com", "user@domain.com"], }, { value: "order.currency_code", label: "Currency Code", + description: "ISO 4217 currency code for the order", + examples: ["USD", "EUR", "PLN", "GBP"], }, { value: "order.region_id", label: "Region ID", + description: "Unique identifier of the region", + examples: ["reg_01ABC123"], }, { value: "order.created_at", label: "Created At", + description: "Date and time when the order was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "order.updated_at", label: "Updated At", + description: "Date and time when the order was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, // Totals { value: "order.total", label: "Total", + description: "Total amount of the order including taxes, shipping, and discounts", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.subtotal", label: "Subtotal", + description: "Subtotal amount before taxes and shipping", + examples: ["80.00", "200.00", "850.00"], }, { value: "order.tax_total", label: "Tax Total", + description: "Total amount of taxes applied to the order", + examples: ["20.00", "50.00", "149.99"], }, { value: "order.original_total", label: "Original Total", + description: "Original total amount before any changes or adjustments", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.original_subtotal", label: "Original Subtotal", + description: "Original subtotal before any changes or adjustments", + examples: ["80.00", "200.00", "850.00"], }, { value: "order.original_tax_total", label: "Original Tax Total", + description: "Original tax total before any changes or adjustments", + examples: ["20.00", "50.00", "149.99"], }, { value: "order.discount_total", label: "Discount Total", + description: "Total amount of discounts applied to the order", + examples: ["0.00", "10.00", "50.00"], }, { value: "order.discount_tax_total", label: "Discount Tax Total", + description: "Tax amount on discounts applied to the order", + examples: ["0.00", "2.50", "12.50"], }, // Shipping (specific fields, not *) { value: "order.shipping_methods.amount", label: "Shipping Methods Amount", + description: "Total shipping cost for all shipping methods. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "10.00", "25.50"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.subtotal", label: "Shipping Methods Subtotal", + description: "Shipping subtotal before taxes. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "8.00", "20.00"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.tax_total", label: "Shipping Methods Tax Total", + description: "Tax amount on shipping. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "2.00", "5.50"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.original_total", label: "Shipping Methods Original Total", + description: "Original shipping total before adjustments. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "10.00", "25.50"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.original_subtotal", label: "Shipping Methods Original Subtotal", + description: "Original shipping subtotal before adjustments. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "8.00", "20.00"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.original_tax_total", label: "Shipping Methods Original Tax Total", + description: "Original shipping tax total before adjustments. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "2.00", "5.50"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.discount_total", label: "Shipping Methods Discount Total", + description: "Total shipping discounts applied. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "5.00", "10.00"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.discount_subtotal", label: "Shipping Methods Discount Subtotal", + description: "Shipping discount subtotal. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "4.00", "8.00"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, { value: "order.shipping_methods.discount_tax_total", label: "Shipping Methods Discount Tax Total", + description: "Tax amount on shipping discounts. This is an array - operator 'eq' checks if ANY value matches", + examples: ["0.00", "1.00", "2.00"], + type: "array", + isRelation: true, + relationType: "shipping_methods", }, // Summary (specific fields) { value: "order.summary.total", label: "Summary Total", + description: "Summary total amount including all adjustments", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.summary.subtotal", label: "Summary Subtotal", + description: "Summary subtotal amount", + examples: ["80.00", "200.00", "850.00"], }, { value: "order.summary.tax_total", label: "Summary Tax Total", + description: "Summary tax total amount", + examples: ["20.00", "50.00", "149.99"], }, { value: "order.summary.discount_total", label: "Summary Discount Total", + description: "Summary discount total amount", + examples: ["0.00", "10.00", "50.00"], }, { value: "order.summary.original_order_total", label: "Summary Original Order Total", + description: "Summary original order total before adjustments", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.summary.current_order_total", label: "Summary Current Order Total", + description: "Summary current order total after all adjustments", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.summary.paid_total", label: "Summary Paid Total", + description: "Total amount that has been paid for this order", + examples: ["0.00", "100.00", "250.50"], }, { value: "order.summary.refunded_total", label: "Summary Refunded Total", + description: "Total amount that has been refunded for this order", + examples: ["0.00", "50.00", "100.00"], }, { value: "order.summary.accounting_total", label: "Summary Accounting Total", + description: "Total amount for accounting purposes", + examples: ["100.00", "250.50", "999.99"], }, { value: "order.summary.credit_line_total", label: "Summary Credit Line Total", + description: "Total amount from credit lines applied to this order", + examples: ["0.00", "25.00", "100.00"], }, { value: "order.summary.transaction_total", label: "Summary Transaction Total", + description: "Total amount of all transactions for this order", + examples: ["0.00", "100.00", "250.50"], }, { value: "order.summary.pending_difference", label: "Summary Pending Difference", + description: "Difference between expected and actual payment amounts", + examples: ["0.00", "10.00", "-5.00"], }, // Customer relation { value: "order.customer.id", label: "Customer ID", + description: "Unique identifier of the customer who placed the order", + examples: ["cus_01ABC123"], isRelation: true, relationType: "customer", }, { value: "order.customer.email", label: "Customer Email", + description: "Email address of the customer who placed the order", + examples: ["customer@example.com"], isRelation: true, relationType: "customer", }, { value: "order.customer.first_name", label: "Customer First Name", + description: "First name of the customer", + examples: ["John", "Jane", "Jan"], isRelation: true, relationType: "customer", }, { value: "order.customer.last_name", label: "Customer Last Name", + description: "Last name of the customer", + examples: ["Doe", "Smith", "Kowalski"], isRelation: true, relationType: "customer", }, @@ -190,12 +309,16 @@ export const ORDER_ATTRIBUTES = [ { value: "order.sales_channel.id", label: "Sales Channel ID", + description: "Unique identifier of the sales channel", + examples: ["sc_01ABC123"], isRelation: true, relationType: "sales_channel", }, { value: "order.sales_channel.name", label: "Sales Channel Name", + description: "Name of the sales channel", + examples: ["Default Channel", "Online Store", "Mobile App"], isRelation: true, relationType: "sales_channel", }, @@ -203,36 +326,48 @@ export const ORDER_ATTRIBUTES = [ { value: "order.shipping_address.first_name", label: "Shipping First Name", + description: "First name for shipping address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["John", "Jane"], isRelation: true, relationType: "shipping_address", }, { value: "order.shipping_address.last_name", label: "Shipping Last Name", + description: "Last name for shipping address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Doe", "Smith"], isRelation: true, relationType: "shipping_address", }, { value: "order.shipping_address.address_1", label: "Shipping Address 1", + description: "Primary street address for shipping. This is an array - operator 'eq' checks if ANY value matches", + examples: ["123 Main St", "456 Oak Ave"], isRelation: true, relationType: "shipping_address", }, { value: "order.shipping_address.city", label: "Shipping City", + description: "City for shipping address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Warsaw", "Krakow", "London"], isRelation: true, relationType: "shipping_address", }, { value: "order.shipping_address.country_code", label: "Shipping Country Code", + description: "ISO 3166-1 alpha-2 country code for shipping. This is an array - operator 'eq' checks if ANY value matches", + examples: ["PL", "US", "GB", "DE"], isRelation: true, relationType: "shipping_address", }, { value: "order.shipping_address.postal_code", label: "Shipping Postal Code", + description: "Postal/ZIP code for shipping address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["00-001", "10001", "SW1A 1AA"], isRelation: true, relationType: "shipping_address", }, @@ -240,36 +375,48 @@ export const ORDER_ATTRIBUTES = [ { value: "order.billing_address.first_name", label: "Billing First Name", + description: "First name for billing address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["John", "Jane"], isRelation: true, relationType: "billing_address", }, { value: "order.billing_address.last_name", label: "Billing Last Name", + description: "Last name for billing address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Doe", "Smith"], isRelation: true, relationType: "billing_address", }, { value: "order.billing_address.address_1", label: "Billing Address 1", + description: "Primary street address for billing. This is an array - operator 'eq' checks if ANY value matches", + examples: ["123 Main St", "456 Oak Ave"], isRelation: true, relationType: "billing_address", }, { value: "order.billing_address.city", label: "Billing City", + description: "City for billing address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Warsaw", "Krakow", "London"], isRelation: true, relationType: "billing_address", }, { value: "order.billing_address.country_code", label: "Billing Country Code", + description: "ISO 3166-1 alpha-2 country code for billing. This is an array - operator 'eq' checks if ANY value matches", + examples: ["PL", "US", "GB", "DE"], isRelation: true, relationType: "billing_address", }, { value: "order.billing_address.postal_code", label: "Billing Postal Code", + description: "Postal/ZIP code for billing address. This is an array - operator 'eq' checks if ANY value matches", + examples: ["00-001", "10001", "SW1A 1AA"], isRelation: true, relationType: "billing_address", }, @@ -277,6 +424,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.id", label: "Item ID", + description: "Unique identifier of the order item. This is an array - operator 'eq' checks if ANY value matches", + examples: ["item_01ABC123"], type: "array", isRelation: true, relationType: "items", @@ -284,6 +433,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.quantity", label: "Item Quantity", + description: "Quantity of this item in the order. This is an array - operator 'eq' checks if ANY value matches", + examples: ["1", "2", "5", "10"], type: "array", isRelation: true, relationType: "items", @@ -291,6 +442,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.title", label: "Item Title", + description: "Title/name of the order item. This is an array - operator 'eq' checks if ANY value matches", + examples: ["T-Shirt", "Jeans", "Sneakers"], type: "array", isRelation: true, relationType: "items", @@ -298,6 +451,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.unit_price", label: "Item Unit Price", + description: "Price per unit of this item. This is an array - operator 'eq' checks if ANY value matches", + examples: ["29.99", "99.99", "199.99"], type: "array", isRelation: true, relationType: "items", @@ -305,6 +460,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.variant.id", label: "Item Variant ID", + description: "Unique identifier of the product variant. This is an array - operator 'eq' checks if ANY value matches", + examples: ["variant_01ABC123"], type: "array", isRelation: true, relationType: "items", @@ -312,6 +469,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.variant.sku", label: "Item Variant SKU", + description: "SKU (Stock Keeping Unit) of the product variant. This is an array - operator 'eq' checks if ANY value matches", + examples: ["TSHIRT-SM-BLUE", "JEANS-32-BLACK"], type: "array", isRelation: true, relationType: "items", @@ -319,6 +478,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.product.id", label: "Item Product ID", + description: "Unique identifier of the product. This is an array - operator 'eq' checks if ANY value matches", + examples: ["prod_01ABC123"], type: "array", isRelation: true, relationType: "items", @@ -326,6 +487,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.items.product.title", label: "Item Product Title", + description: "Title/name of the product. This is an array - operator 'eq' checks if ANY value matches", + examples: ["T-Shirt", "Jeans", "Sneakers"], type: "array", isRelation: true, relationType: "items", @@ -334,6 +497,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.payment_collections.id", label: "Payment Collection ID", + description: "Unique identifier of the payment collection. This is an array - operator 'eq' checks if ANY value matches", + examples: ["paycol_01ABC123"], type: "array", isRelation: true, relationType: "payment_collections", @@ -341,6 +506,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.payment_collections.status", label: "Payment Collection Status", + description: "Status of payment collections for this order. This is an array - operator 'eq' checks if ANY value matches", + examples: PAYMENT_COLLECTION_STATUS_VALUES, type: "array", isRelation: true, relationType: "payment_collections", @@ -348,6 +515,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.payment_collections.amount", label: "Payment Collection Amount", + description: "Amount of the payment collection. This is an array - operator 'eq' checks if ANY value matches", + examples: ["100.00", "250.50", "999.99"], type: "array", isRelation: true, relationType: "payment_collections", @@ -356,6 +525,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.fulfillments.id", label: "Fulfillment ID", + description: "Unique identifier of the fulfillment. This is an array - operator 'eq' checks if ANY value matches", + examples: ["ful_01ABC123"], type: "array", isRelation: true, relationType: "fulfillments", @@ -363,6 +534,8 @@ export const ORDER_ATTRIBUTES = [ { value: "order.fulfillments.status", label: "Fulfillment Status", + description: "Status of fulfillments for this order. This is an array - operator 'eq' checks if ANY value matches", + examples: FULFILLMENT_STATUS_VALUES, type: "array", isRelation: true, relationType: "fulfillments", @@ -384,6 +557,7 @@ export const ORDER_QUERY_FIELDS = [ "order.shipping_methods.*", "order.shipping_methods.tax_lines.*", "order.shipping_methods.adjustments.*", + "order.fulfillments.*", "order.credit_lines.*", "order.summary.*", ] diff --git a/src/modules/mpn-automation/types/modules/product-category/product-category.ts b/src/modules/mpn-automation/types/modules/product-category/product-category.ts index cc6255c..c68c78d 100644 --- a/src/modules/mpn-automation/types/modules/product-category/product-category.ts +++ b/src/modules/mpn-automation/types/modules/product-category/product-category.ts @@ -2,42 +2,62 @@ export const PRODUCT_CATEGORY_ATTRIBUTES = [ { value: "product_category.id", label: "ID", + description: "Unique identifier of the product category", + examples: ["cat_01ABC123", "cat_01XYZ789"], }, { value: "product_category.name", label: "Name", + description: "Name of the product category", + examples: ["Clothing", "Electronics", "Home & Garden", "Sports & Outdoors"], }, { value: "product_category.description", label: "Description", + description: "Description of the product category", + examples: ["All clothing items", "Electronic devices and accessories"], }, { value: "product_category.handle", label: "Handle", + description: "URL-friendly identifier for the category (used in category URLs)", + examples: ["clothing", "electronics", "home-garden"], }, { value: "product_category.is_active", label: "Is Active", + description: "Whether the category is currently active", + examples: ["true", "false"], }, { value: "product_category.is_internal", label: "Is Internal", + description: "Whether the category is for internal use only (not visible to customers)", + examples: ["true", "false"], }, { value: "product_category.rank", label: "Rank", + description: "Display order/rank of the category", + examples: ["0", "1", "2", "10"], }, { value: "product_category.parent_category_id", label: "Parent Category ID", + description: "Unique identifier of the parent category (null for top-level categories)", + examples: ["cat_01ABC123", null], }, { value: "product_category.created_at", label: "Created At", + description: "Date and time when the category was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product_category.updated_at", label: "Updated At", + description: "Date and time when the category was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, ] diff --git a/src/modules/mpn-automation/types/modules/product-tag/product-tag.ts b/src/modules/mpn-automation/types/modules/product-tag/product-tag.ts index f0b47a9..47f1e6e 100644 --- a/src/modules/mpn-automation/types/modules/product-tag/product-tag.ts +++ b/src/modules/mpn-automation/types/modules/product-tag/product-tag.ts @@ -2,18 +2,26 @@ export const PRODUCT_TAG_ATTRIBUTES = [ { value: "product_tag.id", label: "ID", + description: "Unique identifier of the product tag", + examples: ["tag_01ABC123", "tag_01XYZ789"], }, { value: "product_tag.value", label: "Value", + description: "Value/name of the product tag", + examples: ["summer", "sale", "new", "bestseller", "limited-edition"], }, { value: "product_tag.created_at", label: "Created At", + description: "Date and time when the tag was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product_tag.updated_at", label: "Updated At", + description: "Date and time when the tag was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, ] diff --git a/src/modules/mpn-automation/types/modules/product-type/product-type.ts b/src/modules/mpn-automation/types/modules/product-type/product-type.ts index 1bcfb20..40092ef 100644 --- a/src/modules/mpn-automation/types/modules/product-type/product-type.ts +++ b/src/modules/mpn-automation/types/modules/product-type/product-type.ts @@ -2,18 +2,26 @@ export const PRODUCT_TYPE_ATTRIBUTES = [ { value: "product_type.id", label: "ID", + description: "Unique identifier of the product type", + examples: ["ptyp_01ABC123", "ptyp_01XYZ789"], }, { value: "product_type.value", label: "Value", + description: "Value/name of the product type", + examples: ["Clothing", "Electronics", "Accessories", "Home & Garden", "Books"], }, { value: "product_type.created_at", label: "Created At", + description: "Date and time when the product type was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product_type.updated_at", label: "Updated At", + description: "Date and time when the product type was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, ] diff --git a/src/modules/mpn-automation/types/modules/product-variant/product-variant.ts b/src/modules/mpn-automation/types/modules/product-variant/product-variant.ts index c563d30..755f9c4 100644 --- a/src/modules/mpn-automation/types/modules/product-variant/product-variant.ts +++ b/src/modules/mpn-automation/types/modules/product-variant/product-variant.ts @@ -2,66 +2,98 @@ export const PRODUCT_VARIANT_ATTRIBUTES = [ { value: "product_variant.id", label: "ID", + description: "Unique identifier of the product variant", + examples: ["variant_01ABC123", "variant_01XYZ789"], }, { value: "product_variant.title", label: "Title", + description: "Title/name of the product variant (e.g., size and color combination)", + examples: ["Small / Blue", "Medium / Red", "Large / Black"], }, { value: "product_variant.sku", label: "SKU", + description: "SKU (Stock Keeping Unit) of the product variant", + examples: ["TSHIRT-SM-BLUE", "JEANS-32-BLACK", "SNEAKERS-42-WHITE"], }, { value: "product_variant.barcode", label: "Barcode", + description: "Barcode identifier for the product variant", + examples: ["1234567890123", "9876543210987"], }, { value: "product_variant.ean", label: "EAN", + description: "European Article Number (EAN) barcode", + examples: ["1234567890123", "9876543210987"], }, { value: "product_variant.upc", label: "UPC", + description: "Universal Product Code (UPC) barcode", + examples: ["123456789012", "987654321098"], }, { value: "product_variant.allow_backorder", label: "Allow Backorder", + description: "Whether backorders are allowed for this variant", + examples: ["true", "false"], }, { value: "product_variant.manage_inventory", label: "Manage Inventory", + description: "Whether inventory is managed for this variant", + examples: ["true", "false"], }, { value: "product_variant.hs_code", label: "HS Code", + description: "Harmonized System (HS) code for customs classification", + examples: ["6109.10.00", "6403.99.00"], }, { value: "product_variant.origin_country", label: "Origin Country", + description: "ISO 3166-1 alpha-2 country code where the variant originates", + examples: ["PL", "US", "CN", "DE"], }, { value: "product_variant.mid_code", label: "MID Code", + description: "Manufacturer Identification (MID) code", + examples: ["MID123456"], }, { value: "product_variant.material", label: "Material", + description: "Material composition of the product variant", + examples: ["Cotton", "Polyester", "Leather", "Metal"], }, { value: "product_variant.weight", label: "Weight", + description: "Weight of the product variant in grams", + examples: ["100", "500", "1000", "2500"], }, { value: "product_variant.length", label: "Length", + description: "Length of the product variant in centimeters", + examples: ["10", "20", "30", "50"], }, { value: "product_variant.height", label: "Height", + description: "Height of the product variant in centimeters", + examples: ["5", "10", "15", "25"], }, { value: "product_variant.width", label: "Width", + description: "Width of the product variant in centimeters", + examples: ["10", "20", "30", "40"], }, // { // value: "product_variant.metadata", @@ -70,18 +102,26 @@ export const PRODUCT_VARIANT_ATTRIBUTES = [ { value: "product_variant.variant_rank", label: "Variant Rank", + description: "Display order/rank of the variant", + examples: ["0", "1", "2", "10"], }, { value: "product_variant.product_id", label: "Product ID", + description: "Unique identifier of the parent product", + examples: ["prod_01ABC123"], }, { value: "product_variant.created_at", label: "Created At", + description: "Date and time when the variant was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product_variant.updated_at", label: "Updated At", + description: "Date and time when the variant was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, ] diff --git a/src/modules/mpn-automation/types/modules/product/helpers.ts b/src/modules/mpn-automation/types/modules/product/helpers.ts new file mode 100644 index 0000000..b6bf320 --- /dev/null +++ b/src/modules/mpn-automation/types/modules/product/helpers.ts @@ -0,0 +1,7 @@ +import { ProductStatus } from "@medusajs/framework/utils" + +/** + * Helper to get all possible ProductStatus values + */ +export const PRODUCT_STATUS_VALUES = Object.values(ProductStatus) as string[] + diff --git a/src/modules/mpn-automation/types/modules/product/product.ts b/src/modules/mpn-automation/types/modules/product/product.ts index dfa26b9..3a9d300 100644 --- a/src/modules/mpn-automation/types/modules/product/product.ts +++ b/src/modules/mpn-automation/types/modules/product/product.ts @@ -1,99 +1,149 @@ +import { PRODUCT_STATUS_VALUES } from "./helpers" + export const PRODUCT_ATTRIBUTES = [ { value: "product.id", label: "ID", + description: "Unique identifier of the product", + examples: ["prod_01ABC123", "prod_01XYZ789"], }, { value: "product.title", label: "Title", + description: "Title/name of the product", + examples: ["T-Shirt", "Jeans", "Sneakers", "Laptop"], }, { value: "product.handle", label: "Handle", + description: "URL-friendly identifier for the product (used in product URLs)", + examples: ["t-shirt", "blue-jeans", "running-sneakers"], }, { value: "product.subtitle", label: "Subtitle", + description: "Subtitle or short description of the product", + examples: ["Comfortable cotton t-shirt", "Premium denim jeans"], }, { value: "product.description", label: "Description", + description: "Full description of the product", + examples: ["This is a high-quality product...", "Made from premium materials..."], }, { value: "product.is_giftcard", label: "Is Giftcard", + description: "Whether this product is a gift card", + examples: ["true", "false"], }, { value: "product.status", label: "Status", + description: "Current status of the product", + examples: PRODUCT_STATUS_VALUES, }, { value: "product.sku", label: "SKU", + description: "SKU (Stock Keeping Unit) of the product", + examples: ["TSHIRT-001", "JEANS-BLUE-32"], }, { value: "product.barcode", label: "Barcode", + description: "Barcode identifier for the product", + examples: ["1234567890123", "9876543210987"], }, { value: "product.ean", label: "EAN", + description: "European Article Number (EAN) barcode", + examples: ["1234567890123", "9876543210987"], }, { value: "product.upc", label: "UPC", + description: "Universal Product Code (UPC) barcode", + examples: ["123456789012", "987654321098"], }, { value: "product.thumbnail", label: "Thumbnail", + description: "URL of the product thumbnail image", + examples: ["https://example.com/image.jpg"], }, { value: "product.hs_code", label: "HS Code", + description: "Harmonized System (HS) code for customs classification", + examples: ["6109.10.00", "6403.99.00"], }, { value: "product.origin_country", label: "Origin Country", + description: "ISO 3166-1 alpha-2 country code where the product originates", + examples: ["PL", "US", "CN", "DE"], }, { value: "product.mid_code", label: "MID Code", + description: "Manufacturer Identification (MID) code", + examples: ["MID123456"], }, { value: "product.material", label: "Material", + description: "Material composition of the product", + examples: ["Cotton", "Polyester", "Leather", "Metal"], }, { value: "product.weight", label: "Weight", + description: "Weight of the product in grams", + examples: ["100", "500", "1000", "2500"], }, { value: "product.length", label: "Length", + description: "Length of the product in centimeters", + examples: ["10", "20", "30", "50"], }, { value: "product.height", label: "Height", + description: "Height of the product in centimeters", + examples: ["5", "10", "15", "25"], }, { value: "product.width", label: "Width", + description: "Width of the product in centimeters", + examples: ["10", "20", "30", "40"], }, { value: "product.created_at", label: "Created At", + description: "Date and time when the product was created (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product.updated_at", label: "Updated At", + description: "Date and time when the product was last updated (ISO 8601 format)", + examples: ["2024-01-15T10:30:00Z", "2024-12-25T00:00:00Z"], }, { value: "product.deleted_at", label: "Deleted At", + description: "Date and time when the product was deleted (ISO 8601 format), null if not deleted", + examples: ["2024-01-15T10:30:00Z", null], }, { value: "product.tags.id", label: "Tag ID", + description: "Unique identifier of the product tag. This is an array - operator 'eq' checks if ANY value matches", + examples: ["tag_01ABC123"], type: "array", isRelation: true, relationType: "tags", @@ -101,6 +151,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.tags.value", label: "Tag Value", + description: "Value/name of the product tag. This is an array - operator 'eq' checks if ANY value matches", + examples: ["summer", "sale", "new", "bestseller"], type: "array", isRelation: true, relationType: "tags", @@ -108,6 +160,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.categories.id", label: "Category ID", + description: "Unique identifier of the product category. This is an array - operator 'eq' checks if ANY value matches", + examples: ["cat_01ABC123"], type: "array", isRelation: true, relationType: "categories", @@ -115,6 +169,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.categories.name", label: "Category Name", + description: "Name of the product category. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Clothing", "Electronics", "Home & Garden"], type: "array", isRelation: true, relationType: "categories", @@ -122,6 +178,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.categories.handle", label: "Category Handle", + description: "URL-friendly identifier of the category. This is an array - operator 'eq' checks if ANY value matches", + examples: ["clothing", "electronics", "home-garden"], type: "array", isRelation: true, relationType: "categories", @@ -129,6 +187,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.variants.id", label: "Variant ID", + description: "Unique identifier of the product variant. This is an array - operator 'eq' checks if ANY value matches", + examples: ["variant_01ABC123"], type: "array", isRelation: true, relationType: "variants", @@ -136,6 +196,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.variants.sku", label: "Variant SKU", + description: "SKU of the product variant. This is an array - operator 'eq' checks if ANY value matches", + examples: ["TSHIRT-SM-BLUE", "JEANS-32-BLACK"], type: "array", isRelation: true, relationType: "variants", @@ -143,6 +205,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.variants.title", label: "Variant Title", + description: "Title/name of the product variant. This is an array - operator 'eq' checks if ANY value matches", + examples: ["Small / Blue", "32 / Black", "Large / Red"], type: "array", isRelation: true, relationType: "variants", @@ -150,6 +214,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.type.id", label: "Type ID", + description: "Unique identifier of the product type", + examples: ["ptyp_01ABC123"], type: "object", isRelation: true, relationType: "type", @@ -157,6 +223,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.type.value", label: "Type Value", + description: "Value/name of the product type", + examples: ["Clothing", "Electronics", "Accessories"], type: "object", isRelation: true, relationType: "type", @@ -164,6 +232,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.collection.id", label: "Collection ID", + description: "Unique identifier of the product collection", + examples: ["pcol_01ABC123"], type: "object", isRelation: true, relationType: "collection", @@ -171,6 +241,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.collection.title", label: "Collection Title", + description: "Title/name of the product collection", + examples: ["Summer Collection", "Winter Sale", "New Arrivals"], type: "object", isRelation: true, relationType: "collection", @@ -178,6 +250,8 @@ export const PRODUCT_ATTRIBUTES = [ { value: "product.collection.handle", label: "Collection Handle", + description: "URL-friendly identifier of the collection", + examples: ["summer-collection", "winter-sale", "new-arrivals"], type: "object", isRelation: true, relationType: "collection", diff --git a/src/modules/mpn-automation/types/types.ts b/src/modules/mpn-automation/types/types.ts index 8640d1f..53912f1 100644 --- a/src/modules/mpn-automation/types/types.ts +++ b/src/modules/mpn-automation/types/types.ts @@ -43,6 +43,16 @@ export type CustomAction = { export type Attribute = { value?: string label?: string + /** + * Description of what this attribute represents + * Example: "Total amount of the order including taxes and shipping" + */ + description?: string + /** + * Example values for this attribute + * Example: ["completed", "pending", "canceled"] for status fields + */ + examples?: string[] /** * Type of the attribute value * - "primitive": single value (string, number, boolean)