chore(feature-flags): Remove OrderEditing feature flag (#3006)
This commit is contained in:
committed by
GitHub
parent
d2c692aa96
commit
9e3beaf531
5
.changeset/long-pans-deliver.md
Normal file
5
.changeset/long-pans-deliver.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
chore(feature-flags): Remove OrderEditing feature flag
|
||||
15
1673550502785-unique_pay_sess_cart_id.ts
Normal file
15
1673550502785-unique_pay_sess_cart_id.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class uniquePaySessCartId1673550502785 implements MigrationInterface {
|
||||
name = 'uniquePaySessCartId1673550502785'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."UniqPaymentSessionCartIdProviderId"`);
|
||||
await queryRunner.query(`CREATE UNIQUE INDEX "UniqPaymentSessionCartIdProviderId" ON "payment_session" ("cart_id", "provider_id") WHERE cart_id IS NOT NULL`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."UniqPaymentSessionCartIdProviderId"`);
|
||||
await queryRunner.query(`CREATE UNIQUE INDEX "UniqPaymentSessionCartIdProviderId" ON "payment_session" ("cart_id", "provider_id") `);
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,6 @@ import TabItem from '@theme/TabItem';
|
||||
|
||||
In this document, you’ll learn how to create an order edit using the Admin API endpoints.
|
||||
|
||||
:::note
|
||||
|
||||
The Order Editing feature is currently in beta mode and guarded by a feature flag. To use Order Editing either:
|
||||
|
||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
||||
|
||||
You can learn more about enabling it in the [feature flags](../backend/feature-flags/toggle.md) documentation.
|
||||
|
||||
:::
|
||||
|
||||
## Overview
|
||||
|
||||
The Admin API can be used to edit a customer’s order using the Order Editing feature.
|
||||
|
||||
@@ -1492,17 +1492,6 @@ Object of the following format:
|
||||
|
||||
This section holds all events related to order edits.
|
||||
|
||||
:::note
|
||||
|
||||
As of Medusa v1.3.9, Order Edits are available but guarded by a feature flag. To use Order Edits either:
|
||||
|
||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
||||
|
||||
You can learn more about enabling it in the [feature flags](../feature-flags/toggle.md) documentation.
|
||||
|
||||
:::
|
||||
|
||||
<table class="reference-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -1671,17 +1660,6 @@ Object of the following format:
|
||||
|
||||
This section holds all events related to order edit item changes.
|
||||
|
||||
:::note
|
||||
|
||||
As of Medusa v1.3.9, Order Edits are available but guarded by a feature flag. To use Order Edits either:
|
||||
|
||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
||||
|
||||
You can learn more about enabling it in the [feature flags](../feature-flags/toggle.md) documentation.
|
||||
|
||||
:::
|
||||
|
||||
<table class="reference-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -5,17 +5,6 @@ import TabItem from '@theme/TabItem';
|
||||
|
||||
In this document, you’ll learn how to allow a customer to confirm or decline an Order Edit.
|
||||
|
||||
:::note
|
||||
|
||||
The Order Editing feature is currently in beta mode and guarded by a feature flag. To use Order Editing either:
|
||||
|
||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
||||
|
||||
You can learn more about enabling it in the [feature flags](../backend/feature-flags/toggle.md) documentation.
|
||||
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require("path")
|
||||
const startServerWithEnvironment =
|
||||
require("../../../helpers/start-server-with-environment").default
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { useDb } = require("../../../helpers/use-db")
|
||||
const { useDb, initDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const {
|
||||
simpleOrderEditFactory,
|
||||
@@ -21,6 +21,7 @@ const {
|
||||
simpleRegionFactory,
|
||||
} = require("../../factories")
|
||||
const { OrderEditItemChangeType, OrderEdit } = require("@medusajs/medusa")
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -30,19 +31,17 @@ const adminHeaders = {
|
||||
},
|
||||
}
|
||||
|
||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
||||
describe("/admin/order-edits", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
const adminUserId = "admin_user"
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
||||
})
|
||||
dbConnection = connection
|
||||
medusaProcess = process
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ const adminHeaders = {
|
||||
},
|
||||
}
|
||||
|
||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment-collections", () => {
|
||||
describe("/admin/payment-collections", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
@@ -27,7 +27,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment-collections", () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
||||
})
|
||||
dbConnection = connection
|
||||
medusaProcess = process
|
||||
|
||||
@@ -21,7 +21,7 @@ const adminHeaders = {
|
||||
},
|
||||
}
|
||||
|
||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment", () => {
|
||||
describe("/admin/payment", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
@@ -30,7 +30,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment", () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
||||
})
|
||||
dbConnection = connection
|
||||
medusaProcess = process
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Claims creates a refund claim 1`] = `
|
||||
Object {
|
||||
"additional_items": Array [],
|
||||
"canceled_at": null,
|
||||
"claim_items": ArrayContaining [
|
||||
ObjectContaining {
|
||||
"item": Any<Object>,
|
||||
"item_id": "test-item",
|
||||
"quantity": 1,
|
||||
},
|
||||
],
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"fulfillment_status": "not_fulfilled",
|
||||
"fulfillments": Array [],
|
||||
"id": StringMatching /\\^claim_\\*/,
|
||||
"idempotency_key": Any<String>,
|
||||
"metadata": null,
|
||||
"no_notification": null,
|
||||
"order_id": Any<String>,
|
||||
"payment_status": "refunded",
|
||||
"refund_amount": 1200,
|
||||
"return_order": null,
|
||||
"shipping_address": Any<Object>,
|
||||
"shipping_address_id": Any<String>,
|
||||
"shipping_methods": Array [],
|
||||
"type": "refund",
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Claims creates a replace claim 1`] = `
|
||||
Object {
|
||||
"additional_items": Array [
|
||||
Object {
|
||||
"adjustments": Array [],
|
||||
"allow_discounts": true,
|
||||
"cart_id": null,
|
||||
"claim_order_id": StringMatching /\\^claim_\\*/,
|
||||
"created_at": Any<String>,
|
||||
"description": "Refined Wooden Chair",
|
||||
"fulfilled_quantity": null,
|
||||
"has_shipping": null,
|
||||
"id": StringMatching /\\^item_\\*/,
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_id": null,
|
||||
"quantity": 1,
|
||||
"refundable": 113,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": null,
|
||||
"should_merge": true,
|
||||
"swap_id": null,
|
||||
"tax_lines": Array [
|
||||
Object {
|
||||
"code": "default",
|
||||
"created_at": Any<String>,
|
||||
"id": StringMatching /\\^litl_\\*/,
|
||||
"item_id": StringMatching /\\^item_\\*/,
|
||||
"metadata": null,
|
||||
"name": "default",
|
||||
"rate": 12.5,
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
],
|
||||
"thumbnail": null,
|
||||
"title": "Gorgeous Cotton Table",
|
||||
"unit_price": 100,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant",
|
||||
"inventory_quantity": 9,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"product": Object {
|
||||
"collection_id": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": null,
|
||||
"discountable": true,
|
||||
"external_id": null,
|
||||
"handle": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Gorgeous Cotton Table",
|
||||
"type_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"product_id": "test-product",
|
||||
"sku": null,
|
||||
"title": "Refined Wooden Chair",
|
||||
"upc": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"canceled_at": null,
|
||||
"claim_items": ArrayContaining [
|
||||
ObjectContaining {
|
||||
"item": Any<Object>,
|
||||
"item_id": "test-item",
|
||||
"quantity": 1,
|
||||
},
|
||||
],
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"fulfillment_status": "not_fulfilled",
|
||||
"fulfillments": Array [],
|
||||
"id": StringMatching /\\^claim_\\*/,
|
||||
"idempotency_key": Any<String>,
|
||||
"metadata": null,
|
||||
"no_notification": null,
|
||||
"order_id": Any<String>,
|
||||
"payment_status": "na",
|
||||
"refund_amount": null,
|
||||
"return_order": null,
|
||||
"shipping_address": Any<Object>,
|
||||
"shipping_address_id": Any<String>,
|
||||
"shipping_methods": Array [],
|
||||
"type": "replace",
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
@@ -64,23 +64,20 @@ describe("Claims", () => {
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.order.claims[0]).toMatchSnapshot({
|
||||
id: expect.stringMatching(/^claim_*/),
|
||||
order_id: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
idempotency_key: expect.any(String),
|
||||
shipping_address_id: expect.any(String),
|
||||
refund_amount: 1200,
|
||||
shipping_address: expect.any(Object),
|
||||
claim_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item: expect.any(Object),
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
expect(response.data.order.claims[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^claim_*/),
|
||||
order_id: expect.any(String),
|
||||
refund_amount: 1200,
|
||||
claim_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item: expect.any(Object),
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
test("creates a replace claim", async () => {
|
||||
@@ -110,49 +107,33 @@ describe("Claims", () => {
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.order.claims[0]).toMatchSnapshot({
|
||||
id: expect.stringMatching(/^claim_*/),
|
||||
order_id: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
idempotency_key: expect.any(String),
|
||||
shipping_address_id: expect.any(String),
|
||||
refund_amount: null,
|
||||
shipping_address: expect.any(Object),
|
||||
additional_items: [
|
||||
{
|
||||
id: expect.stringMatching(/^item_*/),
|
||||
claim_order_id: expect.stringMatching(/^claim_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: {
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product: {
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
},
|
||||
tax_lines: [
|
||||
{
|
||||
id: expect.stringMatching(/^litl_*/),
|
||||
item_id: expect.stringMatching(/^item_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
rate: 12.5,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
claim_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item: expect.any(Object),
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
expect(response.data.order.claims[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^claim_*/),
|
||||
order_id: expect.any(String),
|
||||
additional_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^item_*/),
|
||||
claim_order_id: expect.stringMatching(/^claim_*/),
|
||||
variant: expect.objectContaining({ id: "test-variant" }),
|
||||
tax_lines: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^litl_*/),
|
||||
item_id: expect.stringMatching(/^item_*/),
|
||||
rate: 12.5,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
claim_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item: expect.any(Object),
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
test("creates a replace claim fulfillment", async () => {
|
||||
|
||||
@@ -1,385 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/store/carts /store/swaps simple swap 1`] = `
|
||||
Object {
|
||||
"swap": Object {
|
||||
"additional_items": Array [
|
||||
Object {
|
||||
"allow_discounts": true,
|
||||
"cart_id": StringMatching /\\^cart_\\*/,
|
||||
"claim_order_id": null,
|
||||
"created_at": Any<String>,
|
||||
"description": "Swap product",
|
||||
"fulfilled_quantity": null,
|
||||
"has_shipping": null,
|
||||
"id": StringMatching /\\^item_\\*/,
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_id": null,
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": null,
|
||||
"should_merge": true,
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
"unit_price": 8000,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant-2",
|
||||
"inventory_quantity": 1,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"product": Object {
|
||||
"collection_id": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": null,
|
||||
"discountable": true,
|
||||
"external_id": null,
|
||||
"handle": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
"type_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"product_id": "test-product",
|
||||
"sku": null,
|
||||
"title": "Swap product",
|
||||
"upc": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"variant_id": "test-variant-2",
|
||||
},
|
||||
],
|
||||
"cart": Object {
|
||||
"billing_address_id": "test-billing-address",
|
||||
"completed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"customer_id": "test-customer",
|
||||
"deleted_at": null,
|
||||
"email": "test@email.com",
|
||||
"id": StringMatching /\\^cart_\\*/,
|
||||
"idempotency_key": null,
|
||||
"metadata": Object {
|
||||
"parent_order_id": "test-order",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
},
|
||||
"object": "cart",
|
||||
"payment_authorized_at": null,
|
||||
"payment_id": null,
|
||||
"region_id": "test-region",
|
||||
"sales_channel_id": Any<String>,
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
"type": "swap",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"cart_id": StringMatching /\\^cart_\\*/,
|
||||
"confirmed_at": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"difference_due": null,
|
||||
"fulfillment_status": "not_fulfilled",
|
||||
"fulfillments": Array [],
|
||||
"id": StringMatching /\\^swap_\\*/,
|
||||
"idempotency_key": Any<String>,
|
||||
"metadata": null,
|
||||
"order": Object {
|
||||
"billing_address_id": "test-billing-address",
|
||||
"canceled_at": null,
|
||||
"cart_id": null,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"customer_id": "test-customer",
|
||||
"display_id": 1,
|
||||
"draft_order_id": null,
|
||||
"email": "test@email.com",
|
||||
"external_id": null,
|
||||
"fulfillment_status": "fulfilled",
|
||||
"id": "test-order",
|
||||
"idempotency_key": null,
|
||||
"metadata": null,
|
||||
"no_notification": null,
|
||||
"object": "order",
|
||||
"payment_status": "captured",
|
||||
"region_id": "test-region",
|
||||
"sales_channel_id": null,
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
"status": "pending",
|
||||
"tax_rate": 0,
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"order_id": "test-order",
|
||||
"payment": null,
|
||||
"payment_status": "not_paid",
|
||||
"return_order": Object {
|
||||
"claim_order_id": null,
|
||||
"created_at": Any<String>,
|
||||
"id": StringMatching /\\^ret_\\*/,
|
||||
"idempotency_key": null,
|
||||
"items": Array [
|
||||
Object {
|
||||
"is_requested": true,
|
||||
"item_id": "test-item",
|
||||
"metadata": null,
|
||||
"note": null,
|
||||
"quantity": 1,
|
||||
"reason_id": null,
|
||||
"received_quantity": null,
|
||||
"requested_quantity": 1,
|
||||
"return_id": StringMatching /\\^ret_\\*/,
|
||||
},
|
||||
],
|
||||
"location_id": null,
|
||||
"metadata": null,
|
||||
"no_notification": true,
|
||||
"order_id": null,
|
||||
"received_at": null,
|
||||
"refund_amount": 7200,
|
||||
"shipping_data": null,
|
||||
"shipping_method": null,
|
||||
"status": "requested",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"shipping_address": null,
|
||||
"shipping_address_id": null,
|
||||
"shipping_methods": Array [],
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/store/carts /store/swaps swap with return shipping 1`] = `
|
||||
Object {
|
||||
"swap": Object {
|
||||
"additional_items": Array [
|
||||
Object {
|
||||
"allow_discounts": true,
|
||||
"cart_id": StringMatching /\\^cart_\\*/,
|
||||
"claim_order_id": null,
|
||||
"created_at": Any<String>,
|
||||
"description": "Swap product",
|
||||
"fulfilled_quantity": null,
|
||||
"has_shipping": null,
|
||||
"id": StringMatching /\\^item_\\*/,
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_id": null,
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": null,
|
||||
"should_merge": true,
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
"unit_price": 8000,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant-2",
|
||||
"inventory_quantity": 1,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"product": Object {
|
||||
"collection_id": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": null,
|
||||
"discountable": true,
|
||||
"external_id": null,
|
||||
"handle": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
"type_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"product_id": "test-product",
|
||||
"sku": null,
|
||||
"title": "Swap product",
|
||||
"upc": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
"variant_id": "test-variant-2",
|
||||
},
|
||||
],
|
||||
"cart": Object {
|
||||
"billing_address_id": "test-billing-address",
|
||||
"completed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"customer_id": "test-customer",
|
||||
"deleted_at": null,
|
||||
"email": "test@email.com",
|
||||
"id": StringMatching /\\^cart_\\*/,
|
||||
"idempotency_key": null,
|
||||
"metadata": Object {
|
||||
"parent_order_id": "test-order",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
},
|
||||
"object": "cart",
|
||||
"payment_authorized_at": null,
|
||||
"payment_id": null,
|
||||
"region_id": "test-region",
|
||||
"sales_channel_id": Any<String>,
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
"type": "swap",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"cart_id": StringMatching /\\^cart_\\*/,
|
||||
"confirmed_at": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"difference_due": null,
|
||||
"fulfillment_status": "not_fulfilled",
|
||||
"fulfillments": Array [],
|
||||
"id": StringMatching /\\^swap_\\*/,
|
||||
"idempotency_key": Any<String>,
|
||||
"metadata": null,
|
||||
"order": Object {
|
||||
"billing_address_id": "test-billing-address",
|
||||
"canceled_at": null,
|
||||
"cart_id": null,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"customer_id": "test-customer",
|
||||
"display_id": Any<Number>,
|
||||
"draft_order_id": null,
|
||||
"email": "test@email.com",
|
||||
"external_id": null,
|
||||
"fulfillment_status": "fulfilled",
|
||||
"id": "test-order",
|
||||
"idempotency_key": null,
|
||||
"metadata": null,
|
||||
"no_notification": null,
|
||||
"object": "order",
|
||||
"payment_status": "captured",
|
||||
"region_id": "test-region",
|
||||
"sales_channel_id": null,
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
"status": "pending",
|
||||
"tax_rate": 0,
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"order_id": "test-order",
|
||||
"payment": null,
|
||||
"payment_status": "not_paid",
|
||||
"return_order": Object {
|
||||
"claim_order_id": null,
|
||||
"created_at": Any<String>,
|
||||
"id": StringMatching /\\^ret_\\*/,
|
||||
"idempotency_key": null,
|
||||
"items": Array [
|
||||
Object {
|
||||
"is_requested": true,
|
||||
"item_id": "test-item",
|
||||
"metadata": null,
|
||||
"note": null,
|
||||
"quantity": 1,
|
||||
"reason_id": null,
|
||||
"received_quantity": null,
|
||||
"requested_quantity": 1,
|
||||
"return_id": StringMatching /\\^ret_\\*/,
|
||||
},
|
||||
],
|
||||
"location_id": null,
|
||||
"metadata": null,
|
||||
"no_notification": true,
|
||||
"order_id": null,
|
||||
"received_at": null,
|
||||
"refund_amount": 6200,
|
||||
"shipping_data": Object {},
|
||||
"shipping_method": Object {
|
||||
"cart_id": null,
|
||||
"claim_order_id": null,
|
||||
"data": Object {},
|
||||
"id": StringMatching /\\^sm_\\*/,
|
||||
"order_id": null,
|
||||
"price": 1000,
|
||||
"return_id": StringMatching /\\^ret_\\*/,
|
||||
"shipping_option": Object {
|
||||
"admin_only": false,
|
||||
"amount": 1000,
|
||||
"created_at": Any<String>,
|
||||
"data": Object {},
|
||||
"deleted_at": null,
|
||||
"id": "return-option",
|
||||
"is_return": true,
|
||||
"metadata": null,
|
||||
"name": "Test ret",
|
||||
"price_type": "flat_rate",
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"provider_id": "test-ful",
|
||||
"region_id": "test-region",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"shipping_option_id": "return-option",
|
||||
"swap_id": null,
|
||||
},
|
||||
"status": "requested",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"shipping_address": null,
|
||||
"shipping_address_id": null,
|
||||
"shipping_methods": Array [],
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
}
|
||||
`;
|
||||
@@ -3,7 +3,7 @@ const path = require("path")
|
||||
const startServerWithEnvironment =
|
||||
require("../../../helpers/start-server-with-environment").default
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { useDb } = require("../../../helpers/use-db")
|
||||
const { useDb, initDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const {
|
||||
getClientAuthenticationCookie,
|
||||
@@ -22,21 +22,20 @@ const {
|
||||
simpleCustomerFactory,
|
||||
} = require("../../factories")
|
||||
const { OrderEditItemChangeType } = require("@medusajs/medusa")
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("[MEDUSA_FF_ORDER_EDITING] /store/order-edits", () => {
|
||||
describe("/store/order-edits", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
||||
})
|
||||
dbConnection = connection
|
||||
medusaProcess = process
|
||||
|
||||
await simpleCustomerFactory(dbConnection, {
|
||||
id: "customer",
|
||||
|
||||
@@ -18,7 +18,7 @@ const {
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("[MEDUSA_FF_ORDER_EDITING] /store/payment-collections", () => {
|
||||
describe("/store/payment-collections", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
@@ -27,7 +27,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /store/payment-collections", () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
||||
})
|
||||
dbConnection = connection
|
||||
medusaProcess = process
|
||||
|
||||
@@ -81,67 +81,50 @@ describe("/store/carts", () => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
swap: {
|
||||
id: expect.stringMatching(/^swap_*/),
|
||||
idempotency_key: expect.any(String),
|
||||
additional_items: [
|
||||
{
|
||||
id: expect.stringMatching(/^item_*/),
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
variant: {
|
||||
id: "test-variant-2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product: {
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
},
|
||||
quantity: 1,
|
||||
variant_id: "test-variant-2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
order: {
|
||||
id: "test-order",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
cart: {
|
||||
id: expect.stringMatching(/^cart_*/),
|
||||
sales_channel_id: expect.any(String),
|
||||
billing_address_id: "test-billing-address",
|
||||
type: "swap",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
shipping_address_id: "test-shipping-address",
|
||||
metadata: {
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
},
|
||||
},
|
||||
return_order: {
|
||||
id: expect.stringMatching(/^ret_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
refund_amount: 7200,
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
expect(response.data).toEqual(
|
||||
expect.objectContaining({
|
||||
swap: expect.objectContaining({
|
||||
id: expect.stringMatching(/^swap_*/),
|
||||
additional_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^item_*/),
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
variant: expect.objectContaining({
|
||||
id: "test-variant-2",
|
||||
}),
|
||||
quantity: 1,
|
||||
return_id: expect.stringMatching(/^ret_*/),
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
})
|
||||
variant_id: "test-variant-2",
|
||||
}),
|
||||
]),
|
||||
order: expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
cart: expect.objectContaining({
|
||||
id: expect.stringMatching(/^cart_*/),
|
||||
billing_address_id: "test-billing-address",
|
||||
type: "swap",
|
||||
shipping_address_id: "test-shipping-address",
|
||||
metadata: expect.objectContaining({
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
}),
|
||||
}),
|
||||
return_order: expect.objectContaining({
|
||||
id: expect.stringMatching(/^ret_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
refund_amount: 7200,
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
return_id: expect.stringMatching(/^ret_*/),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("swap with return shipping", async () => {
|
||||
@@ -168,76 +151,54 @@ describe("/store/carts", () => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
swap: {
|
||||
expect(response.data).toEqual({
|
||||
swap: expect.objectContaining({
|
||||
id: expect.stringMatching(/^swap_*/),
|
||||
idempotency_key: expect.any(String),
|
||||
additional_items: [
|
||||
{
|
||||
additional_items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^item_*/),
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
variant: {
|
||||
variant: expect.objectContaining({
|
||||
id: "test-variant-2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product: {
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
},
|
||||
}),
|
||||
quantity: 1,
|
||||
variant_id: "test-variant-2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
order: {
|
||||
}),
|
||||
]),
|
||||
order: expect.objectContaining({
|
||||
id: "test-order",
|
||||
display_id: expect.any(Number),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
}),
|
||||
cart_id: expect.stringMatching(/^cart_*/),
|
||||
cart: {
|
||||
cart: expect.objectContaining({
|
||||
id: expect.stringMatching(/^cart_*/),
|
||||
sales_channel_id: expect.any(String),
|
||||
billing_address_id: "test-billing-address",
|
||||
shipping_address_id: "test-shipping-address",
|
||||
type: "swap",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
metadata: {
|
||||
metadata: expect.objectContaining({
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
},
|
||||
},
|
||||
return_order: {
|
||||
}),
|
||||
}),
|
||||
return_order: expect.objectContaining({
|
||||
id: expect.stringMatching(/^ret_*/),
|
||||
swap_id: expect.stringMatching(/^swap_*/),
|
||||
refund_amount: 6200,
|
||||
shipping_method: {
|
||||
shipping_method: expect.objectContaining({
|
||||
id: expect.stringMatching(/^sm_*/),
|
||||
return_id: expect.stringMatching(/^ret_*/),
|
||||
shipping_option: {
|
||||
shipping_option: expect.objectContaining({
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
},
|
||||
items: [
|
||||
{
|
||||
}),
|
||||
}),
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
return_id: expect.stringMatching(/^ret_*/),
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,9 +18,11 @@ const startServerWithEnvironment = async ({
|
||||
cwd,
|
||||
})
|
||||
|
||||
Object.entries(env).forEach(([key]) => {
|
||||
delete process.env[key]
|
||||
})
|
||||
if (env) {
|
||||
Object.entries(env).forEach(([key]) => {
|
||||
delete process.env[key]
|
||||
})
|
||||
}
|
||||
|
||||
const medusaProcess = await setupServer({
|
||||
cwd,
|
||||
|
||||
@@ -38,7 +38,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"quantity": 2,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 2,
|
||||
@@ -192,7 +194,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"quantity": 2,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 2,
|
||||
@@ -308,7 +312,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"price": "12.00 USD",
|
||||
"quantity": 1,
|
||||
"returned_quantity": 1,
|
||||
@@ -442,7 +448,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"original_tax_total": 400,
|
||||
"original_total": 2400,
|
||||
"quantity": 2,
|
||||
@@ -629,7 +637,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"quantity": 2,
|
||||
"returned_quantity": 1,
|
||||
"shipped_quantity": 2,
|
||||
@@ -787,7 +797,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"original_tax_total": 400,
|
||||
"original_total": 2400,
|
||||
"price": "10.00 USD",
|
||||
@@ -1018,7 +1030,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"original_tax_total": 400,
|
||||
"original_total": 2400,
|
||||
"price": "12.00 USD",
|
||||
@@ -1293,7 +1307,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"original_tax_total": 400,
|
||||
"original_total": 2400,
|
||||
"quantity": 2,
|
||||
@@ -1487,7 +1503,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"price": "12.00 USD",
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
@@ -1621,7 +1639,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"original_tax_total": 400,
|
||||
"original_total": 2400,
|
||||
"quantity": 2,
|
||||
@@ -1808,7 +1828,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"quantity": 2,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 2,
|
||||
@@ -1966,7 +1988,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_edit_id": null,
|
||||
"order_id": null,
|
||||
"original_item_id": null,
|
||||
"price": "11.25 USD",
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
@@ -2073,7 +2097,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": null,
|
||||
"order_edit_id": null,
|
||||
"order_id": Any<String>,
|
||||
"original_item_id": null,
|
||||
"quantity": 2,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 2,
|
||||
@@ -2193,7 +2219,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_edit_id": null,
|
||||
"order_id": null,
|
||||
"original_item_id": null,
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 1,
|
||||
@@ -2307,7 +2335,9 @@ Object {
|
||||
"is_giftcard": false,
|
||||
"is_return": false,
|
||||
"metadata": Object {},
|
||||
"order_edit_id": null,
|
||||
"order_id": null,
|
||||
"original_item_id": null,
|
||||
"quantity": 1,
|
||||
"returned_quantity": null,
|
||||
"shipped_quantity": 1,
|
||||
|
||||
@@ -104,6 +104,8 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
{
|
||||
adjustments: [],
|
||||
created_at: expect.any(Date),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
updated_at: expect.any(Date),
|
||||
order_id: expect.any(String),
|
||||
tax_lines: [
|
||||
@@ -225,6 +227,8 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
adjustments: [],
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
order_id: expect.any(String),
|
||||
tax_lines: [
|
||||
{
|
||||
@@ -285,6 +289,8 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
order_id: expect.any(String),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
tax_lines: [
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -473,6 +479,8 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
{
|
||||
id: expect.any(String),
|
||||
order_id: expect.any(String),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
variant: {
|
||||
@@ -577,6 +585,8 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
variant: {
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
@@ -762,6 +772,8 @@ const getReturnSnap = (received = false) => {
|
||||
const itemSnap = {
|
||||
id: expect.any(String),
|
||||
order_id: expect.any(String),
|
||||
order_edit_id: null,
|
||||
original_item_id: null,
|
||||
created_at: expect.any(Date),
|
||||
updated_at: expect.any(Date),
|
||||
variant: {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("POST /admin/order-edits/:id/cancel", () => {
|
||||
@@ -17,8 +16,7 @@ describe("POST /admin/order-edits/:id/cancel", () => {
|
||||
jwt: {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("POST /admin/order-edits/:id/confirm", () => {
|
||||
@@ -18,7 +17,6 @@ describe("POST /admin/order-edits/:id/confirm", () => {
|
||||
userId: "admin_user",
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("POST /admin/order-edits", () => {
|
||||
@@ -20,7 +19,6 @@ describe("POST /admin/order-edits", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("DELETE /admin/order-edits/:id/items/:item_id", () => {
|
||||
@@ -16,7 +15,6 @@ describe("DELETE /admin/order-edits/:id/items/:item_id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("DELETE /admin/order-edits/:id/changes/:change_id", () => {
|
||||
@@ -19,7 +18,6 @@ describe("DELETE /admin/order-edits/:id/changes/:change_id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("DELETE /admin/order-edits/:id", () => {
|
||||
@@ -15,7 +14,6 @@ describe("DELETE /admin/order-edits/:id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import {
|
||||
defaultOrderEditFields,
|
||||
defaultOrderEditRelations,
|
||||
defaultOrderEditRelations
|
||||
} from "../../../../../types/order-edit"
|
||||
|
||||
describe("GET /admin/order-edits/:id", () => {
|
||||
@@ -19,7 +18,6 @@ describe("GET /admin/order-edits/:id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import {
|
||||
defaultOrderEditFields,
|
||||
defaultOrderEditRelations,
|
||||
defaultOrderEditRelations
|
||||
} from "../../../../../types/order-edit"
|
||||
|
||||
describe("GET /admin/order-edits", () => {
|
||||
@@ -18,7 +17,6 @@ describe("GET /admin/order-edits", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
|
||||
describe("GET /admin/order-edits/:id", () => {
|
||||
describe("successfully requests an order edit confirmation", () => {
|
||||
@@ -19,7 +18,6 @@ describe("GET /admin/order-edits/:id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
payload: {
|
||||
payment_collection_description: "PayCol description",
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
|
||||
describe("POST /admin/order-edits/:id/items/:item_id", () => {
|
||||
@@ -22,7 +21,6 @@ describe("POST /admin/order-edits/:id/items/:item_id", () => {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
import { Router } from "express"
|
||||
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { OrderEdit } from "../../../../models"
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
||||
import {
|
||||
defaultOrderEditFields,
|
||||
defaultOrderEditRelations,
|
||||
} from "../../../../types/order-edit"
|
||||
import { OrderEdit } from "../../../../models"
|
||||
import { AdminPostOrderEditsOrderEditReq } from "./update-order-edit"
|
||||
import { AdminPostOrderEditsReq } from "./create-order-edit"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { AdminPostOrderEditsEditLineItemsReq } from "./add-line-item"
|
||||
import { AdminPostOrderEditsEditLineItemsLineItemReq } from "./update-order-edit-line-item"
|
||||
import { GetOrderEditsParams } from "./list-order-edit"
|
||||
import { AdminPostOrderEditsReq } from "./create-order-edit"
|
||||
import { GetOrderEditsOrderEditParams } from "./get-order-edit"
|
||||
import { GetOrderEditsParams } from "./list-order-edit"
|
||||
import { AdminPostOrderEditsRequestConfirmationReq } from "./request-confirmation"
|
||||
import { AdminPostOrderEditsOrderEditReq } from "./update-order-edit"
|
||||
import { AdminPostOrderEditsEditLineItemsLineItemReq } from "./update-order-edit-line-item"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app) => {
|
||||
app.use(
|
||||
"/order-edits",
|
||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
||||
route
|
||||
)
|
||||
app.use("/order-edits", route)
|
||||
|
||||
route.post(
|
||||
"/",
|
||||
@@ -117,10 +111,10 @@ export type AdminOrderEditItemChangeDeleteRes = {
|
||||
deleted: boolean
|
||||
}
|
||||
|
||||
export * from "./update-order-edit"
|
||||
export * from "./update-order-edit-line-item"
|
||||
export * from "./add-line-item"
|
||||
export * from "./create-order-edit"
|
||||
export * from "./get-order-edit"
|
||||
export * from "./list-order-edit"
|
||||
export * from "./add-line-item"
|
||||
export * from "./request-confirmation"
|
||||
export * from "./update-order-edit"
|
||||
export * from "./update-order-edit-line-item"
|
||||
|
||||
@@ -4,21 +4,15 @@ import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
||||
|
||||
import { PaymentCollection } from "../../../../models"
|
||||
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
||||
import { AdminUpdatePaymentCollectionsReq } from "./update-payment-collection"
|
||||
import { PaymentCollection } from "../../../../models"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app, container) => {
|
||||
app.use(
|
||||
"/payment-collections",
|
||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
||||
route
|
||||
)
|
||||
app.use("/payment-collections", route)
|
||||
|
||||
route.get(
|
||||
"/:id",
|
||||
|
||||
@@ -4,17 +4,15 @@ import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
||||
|
||||
import { Payment, Refund } from "../../../../models"
|
||||
import { GetPaymentsParams } from "./get-payment"
|
||||
import { AdminPostPaymentRefundsReq } from "./refund-payment"
|
||||
import { Payment, Refund } from "../../../../models"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app, container) => {
|
||||
app.use("/payments", isFeatureFlagEnabled(OrderEditingFeatureFlag.key), route)
|
||||
app.use("/payments", route)
|
||||
|
||||
route.get(
|
||||
"/:id",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
|
||||
describe("GET /store/order-edits/:id/complete", () => {
|
||||
describe("successfully complete an order edit", () => {
|
||||
@@ -12,9 +11,6 @@ describe("GET /store/order-edits/:id/complete", () => {
|
||||
subject = await request(
|
||||
"POST",
|
||||
`/store/order-edits/${orderEditId}/complete`,
|
||||
{
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -44,7 +40,6 @@ describe("GET /store/order-edits/:id/complete", () => {
|
||||
"POST",
|
||||
`/store/order-edits/${orderEditId}/complete`,
|
||||
{
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
clientSession: {
|
||||
jwt: {
|
||||
user: IdMap.getId("lebron"),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
|
||||
describe("GET /store/order-edits/:id/decline", () => {
|
||||
describe("successfully decline an order edit", () => {
|
||||
@@ -18,7 +17,6 @@ describe("GET /store/order-edits/:id/decline", () => {
|
||||
`/store/order-edits/${orderEditId}/decline`,
|
||||
{
|
||||
payload,
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
||||
import {
|
||||
defaultStoreOrderEditFields,
|
||||
defaultStoreOrderEditRelations,
|
||||
defaultStoreOrderEditRelations
|
||||
} from "../../../../../types/order-edit"
|
||||
|
||||
describe("GET /store/order-edits/:id", () => {
|
||||
@@ -13,9 +12,7 @@ describe("GET /store/order-edits/:id", () => {
|
||||
let subject
|
||||
|
||||
beforeAll(async () => {
|
||||
subject = await request("GET", `/store/order-edits/${orderEditId}`, {
|
||||
flags: [OrderEditingFeatureFlag],
|
||||
})
|
||||
subject = await request("GET", `/store/order-edits/${orderEditId}`)
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
import { Router } from "express"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { OrderEdit } from "../../../../models"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
||||
import {
|
||||
defaultStoreOrderEditFields,
|
||||
defaultStoreOrderEditRelations,
|
||||
} from "../../../../types/order-edit"
|
||||
import { OrderEdit } from "../../../../models"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { StorePostOrderEditsOrderEditDecline } from "./decline-order-edit"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app) => {
|
||||
app.use(
|
||||
"/order-edits",
|
||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
||||
route
|
||||
)
|
||||
app.use("/order-edits", route)
|
||||
|
||||
route.get(
|
||||
"/:id",
|
||||
|
||||
@@ -5,23 +5,16 @@ import middlewares, {
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
|
||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
||||
|
||||
import { StorePostPaymentCollectionsBatchSessionsReq } from "./manage-batch-payment-sessions"
|
||||
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
||||
import { PaymentCollection, PaymentSession } from "../../../../models"
|
||||
import { StorePaymentCollectionSessionsReq } from "./manage-payment-session"
|
||||
import { StorePostPaymentCollectionsBatchSessionsAuthorizeReq } from "./authorize-batch-payment-sessions"
|
||||
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
||||
import { StorePostPaymentCollectionsBatchSessionsReq } from "./manage-batch-payment-sessions"
|
||||
import { StorePaymentCollectionSessionsReq } from "./manage-payment-session"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app, container) => {
|
||||
app.use(
|
||||
"/payment-collections",
|
||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
||||
route
|
||||
)
|
||||
app.use("/payment-collections", route)
|
||||
|
||||
route.get(
|
||||
"/:id",
|
||||
@@ -86,8 +79,8 @@ export type StorePaymentCollectionsSessionRes = {
|
||||
payment_session: PaymentSession
|
||||
}
|
||||
|
||||
export * from "./get-payment-collection"
|
||||
export * from "./manage-payment-session"
|
||||
export * from "./manage-batch-payment-sessions"
|
||||
export * from "./refresh-payment-session"
|
||||
export * from "./authorize-batch-payment-sessions"
|
||||
export * from "./get-payment-collection"
|
||||
export * from "./manage-batch-payment-sessions"
|
||||
export * from "./manage-payment-session"
|
||||
export * from "./refresh-payment-session"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import glob from "glob"
|
||||
import path from "path"
|
||||
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import { trackFeatureFlag } from "medusa-telemetry"
|
||||
import { FlagSettings } from "../../types/feature-flags"
|
||||
import { Logger } from "../../types/global"
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import { FlagRouter } from "../../utils/flag-router"
|
||||
|
||||
const isTruthy = (val: string | boolean | undefined): boolean => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FlagSettings } from "../../types/feature-flags"
|
||||
|
||||
const OrderEditingFeatureFlag: FlagSettings = {
|
||||
key: "order_editing",
|
||||
default_val: false,
|
||||
default_val: true,
|
||||
env_key: "MEDUSA_FF_ORDER_EDITING",
|
||||
description: "[WIP] Enable the order editing feature",
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export const featureFlag = OrderEditingFeatureFlag.key
|
||||
|
||||
export class orderEditing1663059812399 implements MigrationInterface {
|
||||
name = "orderEditing1663059812399"
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export const featureFlag = OrderEditingFeatureFlag.key
|
||||
|
||||
export class lineItemOriginalItemRelation1663059812400
|
||||
implements MigrationInterface
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export const featureFlag = OrderEditingFeatureFlag.key
|
||||
|
||||
export class paymentCollection1664880666982 implements MigrationInterface {
|
||||
name = "paymentCollection1664880666982"
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ export * from "./address"
|
||||
export * from "./analytics-config"
|
||||
export * from "./batch-job"
|
||||
export * from "./cart"
|
||||
export * from "./product-category"
|
||||
export * from "./claim-image"
|
||||
export * from "./claim-item"
|
||||
export * from "./claim-order"
|
||||
@@ -45,6 +44,7 @@ export * from "./payment-provider"
|
||||
export * from "./payment-session"
|
||||
export * from "./price-list"
|
||||
export * from "./product"
|
||||
export * from "./product-category"
|
||||
export * from "./product-collection"
|
||||
export * from "./product-option"
|
||||
export * from "./product-option-value"
|
||||
@@ -61,7 +61,6 @@ export * from "./region"
|
||||
export * from "./return"
|
||||
export * from "./return-item"
|
||||
export * from "./return-reason"
|
||||
export * from "./sales-channel-location"
|
||||
export * from "./sales-channel"
|
||||
export * from "./sales-channel-location"
|
||||
export * from "./shipping-method"
|
||||
|
||||
@@ -6,42 +6,35 @@ import {
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToMany
|
||||
} from "typeorm"
|
||||
|
||||
import { BaseEntity } from "../interfaces"
|
||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { FeatureFlagColumn } from "../utils/feature-flag-decorators"
|
||||
import { Cart } from "./cart"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { LineItemAdjustment } from "./line-item-adjustment"
|
||||
import { LineItemTaxLine } from "./line-item-tax-line"
|
||||
import { Order } from "./order"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { Swap } from "./swap"
|
||||
import { generateEntityId } from "../utils"
|
||||
import {
|
||||
FeatureFlagClassDecorators,
|
||||
FeatureFlagColumn,
|
||||
FeatureFlagDecorators,
|
||||
} from "../utils/feature-flag-decorators"
|
||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
|
||||
@Check(`"fulfilled_quantity" <= "quantity"`)
|
||||
@Check(`"shipped_quantity" <= "fulfilled_quantity"`)
|
||||
@Check(`"returned_quantity" <= "quantity"`)
|
||||
@Check(`"quantity" > 0`)
|
||||
@FeatureFlagClassDecorators(OrderEditingFeatureFlag.key, [
|
||||
Index(
|
||||
"unique_li_original_item_id_order_edit_id",
|
||||
["order_edit_id", "original_item_id"],
|
||||
{
|
||||
unique: true,
|
||||
where: "WHERE original_item_id IS NOT NULL AND order_edit_id IS NOT NULL",
|
||||
}
|
||||
),
|
||||
])
|
||||
@Index(
|
||||
"unique_li_original_item_id_order_edit_id",
|
||||
["order_edit_id", "original_item_id"],
|
||||
{
|
||||
unique: true,
|
||||
where: "original_item_id IS NOT NULL AND order_edit_id IS NOT NULL",
|
||||
}
|
||||
)
|
||||
@Entity()
|
||||
export class LineItem extends BaseEntity {
|
||||
@Index()
|
||||
@@ -84,25 +77,14 @@ export class LineItem extends BaseEntity {
|
||||
})
|
||||
adjustments: LineItemAdjustment[]
|
||||
|
||||
@FeatureFlagColumn(OrderEditingFeatureFlag.key, {
|
||||
nullable: true,
|
||||
type: "varchar",
|
||||
})
|
||||
@Column({ nullable: true, type: "varchar" })
|
||||
original_item_id?: string | null
|
||||
|
||||
@FeatureFlagColumn(OrderEditingFeatureFlag.key, {
|
||||
nullable: true,
|
||||
type: "varchar",
|
||||
})
|
||||
@Column({ nullable: true, type: "varchar" })
|
||||
order_edit_id?: string | null
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
ManyToOne(
|
||||
() => OrderEdit,
|
||||
(orderEdit) => orderEdit.items
|
||||
),
|
||||
JoinColumn({ name: "order_edit_id" }),
|
||||
])
|
||||
@ManyToOne(() => OrderEdit, (orderEdit) => orderEdit.items)
|
||||
@JoinColumn({ name: "order_edit_id" })
|
||||
order_edit?: OrderEdit | null
|
||||
|
||||
@Column()
|
||||
|
||||
@@ -2,18 +2,17 @@ import {
|
||||
AfterLoad,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
|
||||
import { BaseEntity } from "../interfaces"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { resolveDbType } from "../utils/db-aware-column"
|
||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
||||
|
||||
import { LineItem, Order, OrderItemChange, PaymentCollection } from "."
|
||||
|
||||
@@ -25,7 +24,7 @@ export enum OrderEditStatus {
|
||||
CANCELED = "canceled",
|
||||
}
|
||||
|
||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
||||
@Entity()
|
||||
export class OrderEdit extends BaseEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
@@ -8,12 +9,10 @@ import {
|
||||
} from "typeorm"
|
||||
|
||||
import { SoftDeletableEntity } from "../interfaces"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
import { LineItem } from "./line-item"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
|
||||
export enum OrderEditItemChangeType {
|
||||
ITEM_ADD = "item_add",
|
||||
@@ -21,9 +20,9 @@ export enum OrderEditItemChangeType {
|
||||
ITEM_UPDATE = "item_update",
|
||||
}
|
||||
|
||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
||||
@Unique(["order_edit_id", "original_line_item_id"])
|
||||
@Unique(["order_edit_id", "line_item_id"])
|
||||
@Entity()
|
||||
export class OrderItemChange extends SoftDeletableEntity {
|
||||
@DbAwareColumn({
|
||||
type: "enum",
|
||||
|
||||
@@ -21,8 +21,10 @@ import {
|
||||
FeatureFlagDecorators,
|
||||
} from "../utils/feature-flag-decorators"
|
||||
|
||||
import { Address } from "./address"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||
import { Address } from "./address"
|
||||
import { Cart } from "./cart"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { Currency } from "./currency"
|
||||
@@ -33,6 +35,7 @@ import { Fulfillment } from "./fulfillment"
|
||||
import { GiftCard } from "./gift-card"
|
||||
import { GiftCardTransaction } from "./gift-card-transaction"
|
||||
import { LineItem } from "./line-item"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
import { Payment } from "./payment"
|
||||
import { Refund } from "./refund"
|
||||
import { Region } from "./region"
|
||||
@@ -40,10 +43,6 @@ import { Return } from "./return"
|
||||
import { SalesChannel } from "./sales-channel"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { Swap } from "./swap"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||
import { OrderEdit } from "./order-edit"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export enum OrderStatus {
|
||||
PENDING = "pending",
|
||||
@@ -211,12 +210,7 @@ export class Order extends BaseEntity {
|
||||
@JoinColumn({ name: "draft_order_id" })
|
||||
draft_order: DraftOrder
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
OneToMany(
|
||||
() => OrderEdit,
|
||||
(oe) => oe.order
|
||||
),
|
||||
])
|
||||
@OneToMany(() => OrderEdit, (oe) => oe.order)
|
||||
edits: OrderEdit[]
|
||||
|
||||
@OneToMany(() => LineItem, (lineItem) => lineItem.order, {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
@@ -8,13 +9,10 @@ import {
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { Currency, Payment, PaymentSession, Region } from "."
|
||||
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
export enum PaymentCollectionStatus {
|
||||
NOT_PAID = "not_paid",
|
||||
@@ -28,7 +26,7 @@ export enum PaymentCollectionType {
|
||||
ORDER_EDIT = "order_edit",
|
||||
}
|
||||
|
||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
||||
@Entity()
|
||||
export class PaymentCollection extends SoftDeletableEntity {
|
||||
@DbAwareColumn({ type: "enum", enum: PaymentCollectionType })
|
||||
type: PaymentCollectionType
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { BeforeInsert, Column, Entity, Index, JoinColumn, ManyToOne, Unique, } from "typeorm"
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
|
||||
import { BaseEntity } from "../interfaces"
|
||||
import { Cart } from "./cart"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils"
|
||||
import { FeatureFlagDecorators } from "../utils/feature-flag-decorators"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { Cart } from "./cart"
|
||||
|
||||
export enum PaymentSessionStatus {
|
||||
AUTHORIZED = "authorized",
|
||||
@@ -16,8 +22,10 @@ export enum PaymentSessionStatus {
|
||||
}
|
||||
|
||||
@Unique("OneSelected", ["cart_id", "is_selected"])
|
||||
// TODO: This uniq constraint should be updated once the order edit flag is dropped and should add a where clause on cart_id is not null
|
||||
@Unique("UniqPaymentSessionCartIdProviderId", ["cart_id", "provider_id"])
|
||||
@Index("UniqPaymentSessionCartIdProviderId", ["cart_id", "provider_id"], {
|
||||
unique: true,
|
||||
where: "cart_id IS NOT NULL",
|
||||
})
|
||||
@Entity()
|
||||
export class PaymentSession extends BaseEntity {
|
||||
@Index()
|
||||
@@ -47,14 +55,10 @@ export class PaymentSession extends BaseEntity {
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Column({ type: "integer", nullable: true }),
|
||||
])
|
||||
@Column({ type: "integer", nullable: true })
|
||||
amount: number
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Column({ type: resolveDbType("timestamptz"), nullable: true }),
|
||||
])
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
payment_authorized_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
|
||||
@@ -10,11 +10,9 @@ import {
|
||||
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { Order } from "./order"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
import { Order } from "./order"
|
||||
import { Payment } from "./payment"
|
||||
import { FeatureFlagDecorators } from "../utils/feature-flag-decorators"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export enum RefundReason {
|
||||
DISCOUNT = "discount",
|
||||
@@ -30,20 +28,16 @@ export class Refund extends BaseEntity {
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Index(),
|
||||
Column({ nullable: true }),
|
||||
])
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
payment_id: string
|
||||
|
||||
@ManyToOne(() => Order, (order) => order.payments)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
OneToOne(() => Payment, { nullable: true }),
|
||||
JoinColumn({ name: "payment_id" }),
|
||||
])
|
||||
@OneToOne(() => Payment, { nullable: true })
|
||||
@JoinColumn({ name: "payment_id" })
|
||||
payment: Payment
|
||||
|
||||
@Column({ type: "int" })
|
||||
|
||||
@@ -4,7 +4,6 @@ import LineItemService from "../line-item"
|
||||
import { PricingServiceMock } from "../__mocks__/pricing"
|
||||
import { ProductVariantServiceMock } from "../__mocks__/product-variant"
|
||||
import { RegionServiceMock } from "../__mocks__/region"
|
||||
|
||||
;[true, false].forEach((isTaxInclusiveEnabled) => {
|
||||
describe(`tax inclusive flag set to: ${isTaxInclusiveEnabled}`, () => {
|
||||
describe("LineItemService", () => {
|
||||
@@ -428,6 +427,7 @@ describe("LineItemService", () => {
|
||||
thumbnail: "",
|
||||
variant_id: IdMap.getId("test-variant"),
|
||||
quantity: 1,
|
||||
order_edit_id: null,
|
||||
allow_discounts: undefined,
|
||||
is_giftcard: undefined,
|
||||
metadata: {},
|
||||
@@ -464,6 +464,7 @@ describe("LineItemService", () => {
|
||||
variant_id: IdMap.getId("test-variant"),
|
||||
quantity: 1,
|
||||
allow_discounts: undefined,
|
||||
order_edit_id: null,
|
||||
is_giftcard: undefined,
|
||||
metadata: {},
|
||||
should_merge: true,
|
||||
@@ -585,6 +586,7 @@ describe("LineItemService", () => {
|
||||
variant_id: IdMap.getId("test-variant"),
|
||||
quantity: 1,
|
||||
allow_discounts: undefined,
|
||||
order_edit_id: null,
|
||||
is_giftcard: undefined,
|
||||
metadata: {},
|
||||
should_merge: true,
|
||||
@@ -621,6 +623,7 @@ describe("LineItemService", () => {
|
||||
quantity: 1,
|
||||
allow_discounts: undefined,
|
||||
is_giftcard: undefined,
|
||||
order_edit_id: null,
|
||||
metadata: {},
|
||||
should_merge: true,
|
||||
includes_tax: false,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { EntityManager, In } from "typeorm"
|
||||
import { DeepPartial } from "typeorm/common/DeepPartial"
|
||||
|
||||
import { TransactionBaseService } from "../interfaces"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||
import {
|
||||
LineItem,
|
||||
@@ -70,6 +69,7 @@ class LineItemService extends TransactionBaseService {
|
||||
taxProviderService,
|
||||
featureFlagRouter,
|
||||
}: InjectedDependencies) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
super(arguments[0])
|
||||
|
||||
this.manager_ = manager
|
||||
@@ -348,9 +348,7 @@ class LineItemService extends TransactionBaseService {
|
||||
rawLineItem.includes_tax = unitPriceIncludesTax
|
||||
}
|
||||
|
||||
if (this.featureFlagRouter_.isFeatureEnabled(OrderEditingFeatureFlag.key)) {
|
||||
rawLineItem.order_edit_id = context.order_edit_id || null
|
||||
}
|
||||
rawLineItem.order_edit_id = context.order_edit_id || null
|
||||
|
||||
const lineItemRepo = transactionManager.getCustomRepository(
|
||||
this.lineItemRepository_
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import { BasePaymentService } from "medusa-interfaces"
|
||||
import { EntityManager } from "typeorm"
|
||||
import {
|
||||
AbstractPaymentService,
|
||||
PaymentContext,
|
||||
PaymentSessionResponse,
|
||||
TransactionBaseService,
|
||||
} from "../interfaces"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { PaymentSessionRepository } from "../repositories/payment-session"
|
||||
import { PaymentRepository } from "../repositories/payment"
|
||||
import { RefundRepository } from "../repositories/refund"
|
||||
import { PaymentProviderRepository } from "../repositories/payment-provider"
|
||||
import { buildQuery, isString } from "../utils"
|
||||
import { FindConfig, Selector } from "../types/common"
|
||||
import {
|
||||
Cart,
|
||||
Payment,
|
||||
@@ -21,12 +15,17 @@ import {
|
||||
PaymentSessionStatus,
|
||||
Refund,
|
||||
} from "../models"
|
||||
import { FlagRouter } from "../utils/flag-router"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
import PaymentService from "./payment"
|
||||
import { PaymentRepository } from "../repositories/payment"
|
||||
import { PaymentProviderRepository } from "../repositories/payment-provider"
|
||||
import { PaymentSessionRepository } from "../repositories/payment-session"
|
||||
import { RefundRepository } from "../repositories/refund"
|
||||
import { FindConfig, Selector } from "../types/common"
|
||||
import { Logger } from "../types/global"
|
||||
import { CreatePaymentInput, PaymentSessionInput } from "../types/payment"
|
||||
import { buildQuery, isString } from "../utils"
|
||||
import { FlagRouter } from "../utils/flag-router"
|
||||
import { CustomerService } from "./index"
|
||||
import PaymentService from "./payment"
|
||||
|
||||
type PaymentProviderKey = `pp_${string}` | "systemPaymentProviderService"
|
||||
type InjectedDependencies = {
|
||||
@@ -414,10 +413,7 @@ export default class PaymentProviderService extends TransactionBaseService {
|
||||
session.data = data
|
||||
session.status = status
|
||||
|
||||
if (
|
||||
this.featureFlagRouter_.isFeatureEnabled(OrderEditingFeatureFlag.key) &&
|
||||
status === PaymentSessionStatus.AUTHORIZED
|
||||
) {
|
||||
if (status === PaymentSessionStatus.AUTHORIZED) {
|
||||
session.payment_authorized_at = new Date()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user