@medusajs/promotion 2.22.4 → 2.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/AGENTS.md +3 -2
  2. package/CHANGELOG.md +644 -0
  3. package/README.md +1 -0
  4. package/dist/migrations/Migration20261023080209.d.ts +6 -0
  5. package/dist/migrations/Migration20261023080209.d.ts.map +1 -0
  6. package/dist/migrations/Migration20261023080209.js +22 -0
  7. package/dist/migrations/Migration20261023080209.js.map +1 -0
  8. package/dist/models/application-method.d.ts +1 -0
  9. package/dist/models/application-method.d.ts.map +1 -1
  10. package/dist/models/application-method.js +4 -0
  11. package/dist/models/application-method.js.map +1 -1
  12. package/dist/models/campaign-budget-usage.d.ts +2 -0
  13. package/dist/models/campaign-budget-usage.d.ts.map +1 -1
  14. package/dist/models/campaign-budget.d.ts +2 -0
  15. package/dist/models/campaign-budget.d.ts.map +1 -1
  16. package/dist/models/campaign.d.ts +2 -0
  17. package/dist/models/campaign.d.ts.map +1 -1
  18. package/dist/models/promotion-rule-value.d.ts +4 -0
  19. package/dist/models/promotion-rule-value.d.ts.map +1 -1
  20. package/dist/models/promotion-rule.d.ts +2 -0
  21. package/dist/models/promotion-rule.d.ts.map +1 -1
  22. package/dist/services/promotion-module.d.ts +7 -0
  23. package/dist/services/promotion-module.d.ts.map +1 -1
  24. package/dist/types/application-method.d.ts +3 -1
  25. package/dist/types/application-method.d.ts.map +1 -1
  26. package/dist/utils/compute-actions/build-promotion-rule-query-filter-from-context.js +8 -2
  27. package/dist/utils/compute-actions/build-promotion-rule-query-filter-from-context.js.map +1 -1
  28. package/dist/utils/compute-actions/buy-get.d.ts.map +1 -1
  29. package/dist/utils/compute-actions/buy-get.js +47 -16
  30. package/dist/utils/compute-actions/buy-get.js.map +1 -1
  31. package/dist/utils/validations/application-method.d.ts.map +1 -1
  32. package/dist/utils/validations/application-method.js +13 -0
  33. package/dist/utils/validations/application-method.js.map +1 -1
  34. package/package.json +5 -5
package/AGENTS.md CHANGED
@@ -16,12 +16,12 @@ const promotionModuleService: IPromotionModuleService =
16
16
  ```
17
17
 
18
18
  - Prefer the existing workflows in `@medusajs/core-flows` (cart promotion workflows, `registerUsageStep` in `core-flows/src/promotion/steps/register-usage.ts`, whose compensation calls `revertUsage`) over calling the service directly.
19
- - Enums (`PromotionType`, `PromotionStatus`, `ApplicationMethodType`, `ApplicationMethodTargetType`, `ApplicationMethodAllocation`, `CampaignBudgetType`, `ComputedActions`) come from `@medusajs/framework/utils`.
19
+ - Enums (`PromotionType`, `PromotionStatus`, `ApplicationMethodType`, `ApplicationMethodTargetType`, `ApplicationMethodAllocation`, `ApplicationMethodTargetSelectionStrategy`, `CampaignBudgetType`, `ComputedActions`) come from `@medusajs/framework/utils`.
20
20
 
21
21
  ### Data models (`src/models`)
22
22
 
23
23
  - `Promotion` (`promo_`): `code` (unique among non-deleted), `type` (`standard` | `buyget`), `status` (`draft` | `active` | `inactive`), `is_automatic`, `is_tax_inclusive`, `limit` / `used`, `campaign`, `application_method`, `rules`.
24
- - `ApplicationMethod` (`proappmet_`): `value`, `currency_code`, `type`, `target_type` (`order` | `items` | `shipping_methods`), `allocation` (`each` | `across` | `once`), `max_quantity`, `apply_to_quantity`, `buy_rules_min_quantity`, `target_rules`, `buy_rules`.
24
+ - `ApplicationMethod` (`proappmet_`): `value`, `currency_code`, `type`, `target_type` (`order` | `items` | `shipping_methods`), `allocation` (`each` | `across` | `once`), `max_quantity`, `apply_to_quantity`, `buy_rules_min_quantity`, `target_selection_strategy` (`most_expensive_first` | `cheapest_first`, default `most_expensive_first`), `target_rules`, `buy_rules`.
25
25
  - `PromotionRule` (`prorul_`) + `PromotionRuleValue` (`prorulval_`): `attribute`, `operator`, `values`. Shared by promotion rules, target rules, and buy rules.
26
26
  - `Campaign` (`procamp_`), `CampaignBudget` (`probudg_`, type `spend` | `usage` | `use_by_attribute` | `spend_by_attribute`), `CampaignBudgetUsage` (`probudgus_`, per-attribute-value usage).
27
27
 
@@ -69,3 +69,4 @@ yarn migration:create # after any change in src/models
69
69
  - `use_by_attribute` and `spend_by_attribute` budgets require the budget `attribute` value (e.g. `customer_id`) in the compute context. Without it, `computeActions` skips automatic promotions and throws `INVALID_DATA` for code-applied ones. Per-attribute usage (count or spent amount) is stored in `CampaignBudgetUsage`; the budget's own `used` is only an aggregate.
70
70
  - Rule attributes for target rules are prefixed by scope (`items.` / `shipping_methods.`); the prefix is stripped before evaluating against the item or shipping method.
71
71
  - `buyget` promotions require `apply_to_quantity`, `buy_rules_min_quantity`, and `max_quantity >= apply_to_quantity`; `max_quantity` is not allowed with `across` allocation; percentage values must be 0-100.
72
+ - `target_selection_strategy` only matters for `buyget` promotions: the buy side always reserves the most expensive eligible units, and `cheapest_first` discounts the cheapest units left over instead of the most expensive ones. Any value other than `most_expensive_first` on a `standard` promotion throws `INVALID_DATA`.