feat(medusa, core-flows, types): Allow to update the rules from a shipping options (#7175)

**What**
Add support for the following operations
- update rules from the update shipping options end point
- update rules from the batch update end point

Also added some improvements, that can be revisited later
- Add a rule value normalizer, jsonb will transform the input value to a [primitive](https://www.postgresql.org/docs/current/datatype-json.html#JSON-TYPE-MAPPING-TABLE) when possible meaning that passing `"true"` will result in storing `true` and not the string. The normalizer takes care of that
This commit is contained in:
Adrien de Peretti
2024-04-30 16:45:17 +00:00
committed by GitHub
parent 3affcc2525
commit e26cda4b6a
11 changed files with 470 additions and 41 deletions
@@ -254,6 +254,14 @@ medusaIntegrationTestRunner({
amount: 10000,
},
],
rules: [
shippingOptionRule,
{
operator: RuleOperator.EQ,
attribute: "new_attr",
value: "true",
},
],
}
const updateResponse = await api.post(
@@ -264,6 +272,7 @@ medusaIntegrationTestRunner({
expect(updateResponse.status).toEqual(200)
expect(updateResponse.data.shipping_option.prices).toHaveLength(2)
expect(updateResponse.data.shipping_option.rules).toHaveLength(2)
expect(updateResponse.data.shipping_option).toEqual(
expect.objectContaining({
id: expect.any(String),
@@ -301,6 +310,12 @@ medusaIntegrationTestRunner({
attribute: "old_attr",
value: "old value",
}),
expect.objectContaining({
id: expect.any(String),
operator: "eq",
attribute: "new_attr",
value: "true",
}),
]),
})
)