Merge remote-tracking branch 'origin/release/next'
This commit is contained in:
commit
8850ad4202
181 files changed
+10671
-4408
No files matched your search
@@ -6,7 +6,7 @@ title: 2. Adding custom functionality
|
||||
|
||||
## Introduction
|
||||
|
||||
In the previous part of the tutorial we set up your Medusa project using the `medusa new` and started your Medusa server locally. In this part we will start adding some custom functionality that extends the core. In particular this tutorial will take you through adding custom serverices, custom endpoints and subscribers. The custom functionality that we will be adding will create an endpoint called `/welcome/:cart_id` which customers of your store can use to opt-in to receiving a welcome in their email inbox after completing their order.
|
||||
In the previous part of the tutorial we set up your Medusa project using the `medusa new` and started your Medusa server locally. In this part we will start adding some custom functionality that extends the core. In particular this tutorial will take you through adding custom services, custom endpoints and subscribers. The custom functionality that we will be adding will create an endpoint called `/welcome/:cart_id` which customers of your store can use to opt-in to receiving a welcome in their email inbox after completing their order.
|
||||
|
||||
The custom functionality will do a number of things:
|
||||
|
||||
@@ -111,7 +111,7 @@ In the above implementation we are first retrieving the order that we need to ch
|
||||
|
||||
After retrieving the order we list all orders that have the same `customer_id` as the order we just retrieved. We are only interested in the count of these orders so it is sufficient for us to just select the ids of these orders.
|
||||
|
||||
We then check if the number of previous orders is 0, indicating that the customer has not previously purchased anything from our store. If the number of previous orders is greater than 0 we can exit our function prematurely as we only send welcomes to new customers.
|
||||
We then check if the number of previous orders is greater than 1, indicating that the customer has previously purchased anything from our store. If the number of previous orders is greater than 1 we can exit our function prematurely as we only send welcomes to new customers.
|
||||
|
||||
The final part of the implementation checks if the `welcome_optin` metadata has been set to true. If the customer has opted in we use `someEmailService.send` to trigger and email dispatch to the email stored on the order. In this case `someEmailSender` could be any email service for example Sendgrid, SES, Mailgun, etc.
|
||||
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
const path = require("path");
|
||||
const { Region, DiscountRule, Discount } = require("@medusajs/medusa");
|
||||
const path = require("path")
|
||||
const { Region, DiscountRule, Discount } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/discounts", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a discount and updates it", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -62,16 +62,16 @@ describe("/admin/discounts", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 10,
|
||||
})
|
||||
);
|
||||
)
|
||||
|
||||
const updated = await api
|
||||
.post(
|
||||
@@ -86,51 +86,51 @@ describe("/admin/discounts", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(updated.status).toEqual(200);
|
||||
expect(updated.status).toEqual(200)
|
||||
expect(updated.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 20,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on discount codes", () => {
|
||||
let manager;
|
||||
let manager
|
||||
beforeEach(async () => {
|
||||
manager = dbConnection.manager;
|
||||
manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Test discount rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
});
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "test-discount",
|
||||
code: "TESTING",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("successfully creates discount with soft-deleted discount code", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
// First we soft-delete the discount
|
||||
await api
|
||||
@@ -140,8 +140,8 @@ describe("/admin/discounts", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
// Lets try to create a discount with same code as deleted one
|
||||
const response = await api
|
||||
@@ -164,51 +164,81 @@ describe("/admin/discounts", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "TESTING",
|
||||
usage_limit: 10,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("should fails when creating a discount with already existing code", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// Lets try to create a discount with same code as deleted one
|
||||
try {
|
||||
await api.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "TESTING",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toMatch(
|
||||
/duplicate key value violates unique constraint/i
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts/:discount_id/dynamic-codes", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Dynamic rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
});
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "test-discount",
|
||||
code: "DYNAMIC",
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
rule_id: "test-discount-rule",
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a dynamic discount", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -223,10 +253,10 @@ describe("/admin/discounts", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,49 +1,49 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const draftOrderSeeder = require("../../helpers/draft-order-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const draftOrderSeeder = require("../../helpers/draft-order-seeder")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/draft-orders", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /admin/draft-orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a draft order cart", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -62,7 +62,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -71,13 +71,53 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("creates a draft order cart and creates new user", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "non-existing@test.dk",
|
||||
customer_id: "non-existing",
|
||||
shipping_address: "oli-shipping",
|
||||
items: [
|
||||
{
|
||||
variant_id: "test-variant",
|
||||
quantity: 2,
|
||||
metadata: {},
|
||||
},
|
||||
],
|
||||
region_id: "test-region",
|
||||
shipping_methods: [
|
||||
{
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const draftOrder = response.data.draft_order
|
||||
|
||||
expect(draftOrder.cart.customer_id).toBeDefined()
|
||||
expect(draftOrder.cart.email).toEqual("non-existing@test.dk")
|
||||
})
|
||||
|
||||
it("fails to create a draft order with option requirement", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -96,7 +136,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option-req",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -105,13 +145,13 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(400);
|
||||
});
|
||||
return err.response
|
||||
})
|
||||
expect(response.status).toEqual(400)
|
||||
})
|
||||
|
||||
it("creates a draft order with option requirement", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -135,7 +175,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option-req",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -144,13 +184,13 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("creates a draft order with custom item", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -174,7 +214,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -183,13 +223,13 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("creates a draft order with product variant with custom price and custom item price set to 0", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -215,7 +255,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -224,8 +264,8 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const created = await api
|
||||
.get(`/admin/draft-orders/${response.data.draft_order.id}`, {
|
||||
@@ -234,10 +274,10 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(created.data.draft_order.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -248,17 +288,17 @@ describe("/admin/draft-orders", () => {
|
||||
unit_price: 0,
|
||||
}),
|
||||
])
|
||||
);
|
||||
)
|
||||
// Check that discount is applied
|
||||
expect(created.data.draft_order.cart.discounts[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "TEST",
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a draft order with created shipping address", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
@@ -289,7 +329,7 @@ describe("/admin/draft-orders", () => {
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/draft-orders", payload, {
|
||||
@@ -298,13 +338,13 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("creates a draft order and registers manual payment", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
// register system payment for draft order
|
||||
const orderResponse = await api.post(
|
||||
@@ -315,7 +355,7 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
const createdOrder = await api.get(
|
||||
`/admin/orders/${orderResponse.data.order.id}`,
|
||||
@@ -324,7 +364,7 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
const updatedDraftOrder = await api.get(
|
||||
`/admin/draft-orders/test-draft-order`,
|
||||
@@ -333,40 +373,38 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
expect(orderResponse.status).toEqual(200);
|
||||
expect(orderResponse.status).toEqual(200)
|
||||
// expect newly created order to have id of draft order and system payment
|
||||
expect(createdOrder.data.order.draft_order_id).toEqual(
|
||||
"test-draft-order"
|
||||
);
|
||||
expect(createdOrder.data.order.draft_order_id).toEqual("test-draft-order")
|
||||
expect(createdOrder.data.order.payments).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ provider_id: "system" }),
|
||||
])
|
||||
);
|
||||
)
|
||||
// expect draft order to be complete
|
||||
expect(updatedDraftOrder.data.draft_order.status).toEqual("completed");
|
||||
expect(updatedDraftOrder.data.draft_order.completed_at).not.toEqual(null);
|
||||
});
|
||||
});
|
||||
expect(updatedDraftOrder.data.draft_order.status).toEqual("completed")
|
||||
expect(updatedDraftOrder.data.draft_order.completed_at).not.toEqual(null)
|
||||
})
|
||||
})
|
||||
describe("GET /admin/draft-orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists draft orders", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/draft-orders", {
|
||||
@@ -375,20 +413,20 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.draft_orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: "test-draft-order" }),
|
||||
])
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("lists draft orders with query", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/draft-orders?q=oli@test", {
|
||||
@@ -397,10 +435,10 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.draft_orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
@@ -408,11 +446,11 @@ describe("/admin/draft-orders", () => {
|
||||
cart: expect.objectContaining({ email: "oli@test.dk" }),
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("lists no draft orders on query for non-existing email", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/draft-orders?q=heyo@heyo.dk", {
|
||||
@@ -421,34 +459,34 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.draft_orders).toEqual([]);
|
||||
expect(response.data.count).toEqual(0);
|
||||
});
|
||||
});
|
||||
expect(response.data.draft_orders).toEqual([])
|
||||
expect(response.data.count).toEqual(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/draft-orders/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("deletes a draft order", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.delete("/admin/draft-orders/test-draft-order", {
|
||||
@@ -457,36 +495,36 @@ describe("/admin/draft-orders", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data).toEqual({
|
||||
id: "test-draft-order",
|
||||
object: "draft-order",
|
||||
deleted: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/draft-orders/:id/line-items/:line_id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection, { status: "open" });
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection, { status: "open" })
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates a line item on the draft order", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -502,10 +540,10 @@ describe("/admin/draft-orders", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const updatedDraftOrder = await api.get(
|
||||
`/admin/draft-orders/test-draft-order`,
|
||||
@@ -514,16 +552,16 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
const item = updatedDraftOrder.data.draft_order.cart.items[0];
|
||||
const item = updatedDraftOrder.data.draft_order.cart.items[0]
|
||||
|
||||
expect(item.title).toEqual("Update title");
|
||||
expect(item.unit_price).toEqual(1000);
|
||||
});
|
||||
expect(item.title).toEqual("Update title")
|
||||
expect(item.unit_price).toEqual(1000)
|
||||
})
|
||||
|
||||
it("removes the line item, if quantity is 0", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -539,10 +577,10 @@ describe("/admin/draft-orders", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const updatedDraftOrder = await api.get(
|
||||
`/admin/draft-orders/test-draft-order`,
|
||||
@@ -551,31 +589,31 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
const items = updatedDraftOrder.data.draft_order.cart.items;
|
||||
const items = updatedDraftOrder.data.draft_order.cart.items
|
||||
|
||||
expect(items).toEqual([]);
|
||||
});
|
||||
});
|
||||
expect(items).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/draft-orders/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection, { status: "open" });
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection, { status: "open" })
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates a line item on the draft order", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -607,10 +645,10 @@ describe("/admin/draft-orders", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const updatedDraftOrder = await api.get(
|
||||
`/admin/draft-orders/test-draft-order`,
|
||||
@@ -619,14 +657,14 @@ describe("/admin/draft-orders", () => {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
const dorder = updatedDraftOrder.data.draft_order;
|
||||
const dorder = updatedDraftOrder.data.draft_order
|
||||
|
||||
expect(dorder.cart.email).toEqual("lebron@james.com");
|
||||
expect(dorder.cart.billing_address.first_name).toEqual("lebron");
|
||||
expect(dorder.cart.shipping_address.last_name).toEqual("james");
|
||||
expect(dorder.cart.discounts[0].code).toEqual("TEST");
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(dorder.cart.email).toEqual("lebron@james.com")
|
||||
expect(dorder.cart.billing_address.first_name).toEqual("lebron")
|
||||
expect(dorder.cart.shipping_address.last_name).toEqual("james")
|
||||
expect(dorder.cart.discounts[0].code).toEqual("TEST")
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -13,6 +13,14 @@ const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const orderSeeder = require("../../helpers/order-seeder");
|
||||
const swapSeeder = require("../../helpers/swap-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const claimSeeder = require("../../helpers/claim-seeder");
|
||||
|
||||
const {
|
||||
expectPostCallToReturn,
|
||||
expectAllPostCallsToReturn,
|
||||
callGet,
|
||||
partial,
|
||||
} = require("../../helpers/call-helpers");
|
||||
|
||||
jest.setTimeout(30000);
|
||||
|
||||
@@ -70,6 +78,8 @@ describe("/admin/orders", () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await orderSeeder(dbConnection);
|
||||
await swapSeeder(dbConnection);
|
||||
await claimSeeder(dbConnection);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
@@ -217,6 +227,7 @@ describe("/admin/orders", () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await orderSeeder(dbConnection);
|
||||
await claimSeeder(dbConnection);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
@@ -411,6 +422,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
|
||||
expect(response.data.order.claims[0].claim_items).toEqual(
|
||||
@@ -738,6 +750,58 @@ describe("/admin/orders", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("Only allow canceling claim after canceling fulfillments", async () => {
|
||||
const order_id = "order-with-claim";
|
||||
|
||||
const order = await callGet({
|
||||
path: `/admin/orders/${order_id}`,
|
||||
get: "order",
|
||||
});
|
||||
|
||||
const claim = order.claims.filter((s) => s.id === "claim-w-f")[0];
|
||||
const claim_id = claim.id;
|
||||
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/claims/${claim_id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 400 });
|
||||
|
||||
await expectAllPostCallsToReturn({
|
||||
code: 200,
|
||||
col: claim.fulfillments,
|
||||
pathf: (f) =>
|
||||
`/admin/orders/${order_id}/claims/${claim_id}/fulfillments/${f.id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 200 });
|
||||
});
|
||||
|
||||
it("Only allow canceling claim after canceling returns", async () => {
|
||||
const order_id = "order-with-claim";
|
||||
|
||||
const order = await callGet({
|
||||
path: `/admin/orders/${order_id}`,
|
||||
get: "order",
|
||||
});
|
||||
|
||||
const claim = order.claims.filter((c) => c.id === "claim-w-r")[0];
|
||||
const claim_id = claim.id;
|
||||
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/claims/${claim_id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 400 });
|
||||
|
||||
await expectPostCallToReturn({
|
||||
code: 200,
|
||||
path: `/admin/returns/${claim.return_order.id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 200 });
|
||||
});
|
||||
|
||||
it("fails to creates a claim due to no stock on additional items", async () => {
|
||||
const api = useApi();
|
||||
try {
|
||||
@@ -935,6 +999,20 @@ describe("/admin/orders", () => {
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -955,6 +1033,19 @@ describe("/admin/orders", () => {
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -991,6 +1082,19 @@ describe("/admin/orders", () => {
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1027,8 +1131,72 @@ describe("/admin/orders", () => {
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"returns",
|
||||
"test-order-w-r",
|
||||
(o) => o.returns,
|
||||
(r) => `/admin/returns/${r.id}/cancel`,
|
||||
],
|
||||
[
|
||||
"swaps",
|
||||
"test-order-w-s",
|
||||
(o) => o.swaps,
|
||||
(s) => `/admin/orders/test-order-w-s/swaps/${s.id}/cancel`,
|
||||
],
|
||||
[
|
||||
"claims",
|
||||
"test-order-w-c",
|
||||
(o) => o.claims,
|
||||
(c) => `/admin/orders/test-order-w-c/claims/${c.id}/cancel`,
|
||||
],
|
||||
[
|
||||
"fulfillments",
|
||||
"test-order-w-f",
|
||||
(o) => o.fulfillments,
|
||||
(f) => `/admin/orders/test-order-w-f/fulfillments/${f.id}/cancel`,
|
||||
],
|
||||
])(
|
||||
"Only allows canceling order after canceling %s",
|
||||
async (id, o, of, pf) => {
|
||||
const order_id = o;
|
||||
|
||||
const order = await callGet({
|
||||
path: `/admin/orders/${order_id}`,
|
||||
get: "order",
|
||||
});
|
||||
|
||||
const expectCanceltoReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCanceltoReturn({ code: 400 });
|
||||
|
||||
await expectAllPostCallsToReturn({
|
||||
code: 200,
|
||||
col: of(order),
|
||||
pathf: pf,
|
||||
});
|
||||
|
||||
await expectCanceltoReturn({ code: 200 });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe("POST /admin/orders/:id/swaps", () => {
|
||||
@@ -1290,5 +1458,59 @@ describe("/admin/orders", () => {
|
||||
|
||||
expect(received.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("Only allows canceling swap after canceling fulfillments", async () => {
|
||||
try {
|
||||
const swap_id = "swap-w-f";
|
||||
|
||||
const swap = await callGet({
|
||||
path: `/admin/swaps/${swap_id}`,
|
||||
get: "swap",
|
||||
});
|
||||
|
||||
const { order_id } = swap;
|
||||
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 400 });
|
||||
|
||||
await expectAllPostCallsToReturn({
|
||||
code: 200,
|
||||
col: swap.fulfillments,
|
||||
pathf: (f) =>
|
||||
`/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 200 });
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
it("Only allows canceling swap after canceling return", async () => {
|
||||
const swap_id = "swap-w-r";
|
||||
|
||||
const swap = await callGet({
|
||||
path: `/admin/swaps/${swap_id}`,
|
||||
get: "swap",
|
||||
});
|
||||
|
||||
const { order_id } = swap;
|
||||
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 400 });
|
||||
|
||||
await expectPostCallToReturn({
|
||||
code: 200,
|
||||
path: `/admin/returns/${swap.return_order.id}/cancel`,
|
||||
});
|
||||
|
||||
await expectCancelToReturn({ code: 200 });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,52 +1,269 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const productSeeder = require("../../helpers/product-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(50000)
|
||||
|
||||
describe("/admin/products", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/products", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("returns a list of products with child entities", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.products).toMatchSnapshot([
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
images: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant", //expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
prices: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-price*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-variant-option*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
option_id: expect.stringMatching(/^test-opt*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_2", //expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
prices: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-price*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-variant-option*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
option_id: expect.stringMatching(/^test-opt*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_1", // expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
prices: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-price*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-variant-option*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
option_id: expect.stringMatching(/^test-opt*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{
|
||||
id: expect.stringMatching(/^tag*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
type: {
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
collection: {
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
options: [],
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant_4", //expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
prices: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-price*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-variant-option*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
option_id: expect.stringMatching(/^test-opt*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_3", //expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
prices: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-price*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^test-variant-option*/),
|
||||
variant_id: expect.stringMatching(/^test-variant*/),
|
||||
option_id: expect.stringMatching(/^test-opt*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{
|
||||
id: expect.stringMatching(/^tag*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
type: {
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
collection: {
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/products", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection);
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a product", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
title: "Test product",
|
||||
title: "Test",
|
||||
description: "test-product-description",
|
||||
type: { value: "test-type" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
@@ -61,7 +278,7 @@ describe("/admin/products", () => {
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products", payload, {
|
||||
@@ -70,17 +287,16 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test product",
|
||||
title: "Test",
|
||||
discountable: true,
|
||||
is_giftcard: false,
|
||||
handle: "test-product",
|
||||
handle: "test",
|
||||
images: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
url: "test-image.png",
|
||||
@@ -133,11 +349,77 @@ describe("/admin/products", () => {
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("Sets variant ranks when creating a product", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
title: "Test product - 1",
|
||||
description: "test-product-description 1",
|
||||
type: { value: "test-type 1" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant 1",
|
||||
inventory_quantity: 10,
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
{
|
||||
title: "Test variant 2",
|
||||
inventory_quantity: 10,
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const creationResponse = await api
|
||||
.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(creationResponse.status).toEqual(200)
|
||||
|
||||
const productId = creationResponse.data.product.id
|
||||
|
||||
const response = await api
|
||||
.get(`/admin/products/${productId}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test product - 1",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
title: "Test variant 1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
title: "Test variant 2",
|
||||
}),
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a giftcard", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
title: "Test Giftcard",
|
||||
@@ -151,7 +433,7 @@ describe("/admin/products", () => {
|
||||
options: [{ value: "100" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products", payload, {
|
||||
@@ -160,21 +442,21 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test Giftcard",
|
||||
discountable: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("updates a product (update prices, tags, delete collection, delete type, replaces images)", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
collection_id: null,
|
||||
@@ -182,13 +464,19 @@ describe("/admin/products", () => {
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant",
|
||||
prices: [{ currency_code: "usd", amount: 100, sale_amount: 75 }],
|
||||
prices: [
|
||||
{
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
sale_amount: 75,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
tags: [{ value: "123" }],
|
||||
images: ["test-image-2.png"],
|
||||
type: { value: "test-type-2" },
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products/test-product", payload, {
|
||||
@@ -197,10 +485,10 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -231,15 +519,69 @@ describe("/admin/products", () => {
|
||||
value: "test-type-2",
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("updates a product (variant ordering)", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
collection_id: null,
|
||||
type: null,
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant",
|
||||
},
|
||||
{
|
||||
id: "test-variant_1",
|
||||
},
|
||||
{
|
||||
id: "test-variant_2",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products/test-product", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test product",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
id: "test-variant",
|
||||
title: "Test variant",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant_1",
|
||||
title: "Test variant rank (1)",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant_2",
|
||||
title: "Test variant rank (2)",
|
||||
}),
|
||||
],
|
||||
type: null,
|
||||
collection: null,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("add option", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
title: "should_add",
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products/test-product/options", payload, {
|
||||
@@ -248,41 +590,41 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
options: [
|
||||
options: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
title: "should_add",
|
||||
product_id: "test-product",
|
||||
}),
|
||||
],
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("testing for soft-deletion + uniqueness on handles, collection and variant properties", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection);
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("successfully deletes a product", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.delete("/admin/products/test-product", {
|
||||
@@ -291,21 +633,21 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
deleted: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("successfully creates product with soft-deleted product handle", async () => {
|
||||
const api = useApi();
|
||||
it("successfully creates product with soft-deleted product handle and deletes it again", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// First we soft-delete the product
|
||||
const response = await api
|
||||
@@ -315,11 +657,11 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.id).toEqual("test-product");
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.id).toEqual("test-product")
|
||||
|
||||
// Lets try to create a product with same handle as deleted one
|
||||
const payload = {
|
||||
@@ -339,20 +681,70 @@ describe("/admin/products", () => {
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.data.product.handle).toEqual("test-product");
|
||||
});
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product.handle).toEqual("test-product")
|
||||
|
||||
// Delete product again to ensure uniqueness is enforced in all cases
|
||||
const response2 = await api
|
||||
.delete("/admin/products/test-product", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response2.status).toEqual(200)
|
||||
expect(response2.data.id).toEqual("test-product")
|
||||
})
|
||||
|
||||
it("should fail when creating a product with a handle that already exists", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// Lets try to create a product with same handle as deleted one
|
||||
const payload = {
|
||||
title: "Test product",
|
||||
handle: "test-product",
|
||||
description: "test-product-description",
|
||||
type: { value: "test-type" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
inventory_quantity: 10,
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
try {
|
||||
await api.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toMatch(
|
||||
/duplicate key value violates unique constraint/i
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("successfully deletes product collection", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
// First we soft-delete the product collection
|
||||
const response = await api
|
||||
@@ -362,15 +754,15 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.id).toEqual("test-collection");
|
||||
});
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.id).toEqual("test-collection")
|
||||
})
|
||||
|
||||
it("successfully creates soft-deleted product collection", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.delete("/admin/collections/test-collection", {
|
||||
@@ -379,30 +771,62 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.id).toEqual("test-collection");
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.id).toEqual("test-collection")
|
||||
|
||||
// Lets try to create a product collection with same handle as deleted one
|
||||
const payload = {
|
||||
title: "Another test collection",
|
||||
handle: "test-collection",
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api.post("/admin/collections", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.data.collection.handle).toEqual("test-collection");
|
||||
});
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.collection.handle).toEqual("test-collection")
|
||||
})
|
||||
|
||||
it("should fail when creating a collection with a handle that already exists", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// Lets try to create a collection with same handle as deleted one
|
||||
const payload = {
|
||||
title: "Another test collection",
|
||||
handle: "test-collection",
|
||||
}
|
||||
|
||||
try {
|
||||
await api.post("/admin/collections", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toMatch(
|
||||
/duplicate key value violates unique constraint/i
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("successfully creates soft-deleted product variant", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const product = await api
|
||||
.get("/admin/products/test-product", {
|
||||
headers: {
|
||||
Authorization: "bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.delete("/admin/products/test-product/variants/test-variant", {
|
||||
@@ -411,13 +835,12 @@ describe("/admin/products", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.variant_id).toEqual("test-variant");
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.variant_id).toEqual("test-variant")
|
||||
|
||||
// Lets try to create a product collection with same handle as deleted one
|
||||
const payload = {
|
||||
title: "Second variant",
|
||||
sku: "test-sku",
|
||||
@@ -430,19 +853,18 @@ describe("/admin/products", () => {
|
||||
amount: 100,
|
||||
},
|
||||
],
|
||||
};
|
||||
options: [{ option_id: "test-option", value: "inserted value" }],
|
||||
}
|
||||
|
||||
const res = await api.post(
|
||||
"/admin/products/test-product/variants",
|
||||
payload,
|
||||
{
|
||||
const res = await api
|
||||
.post("/admin/products/test-product/variants", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -453,7 +875,7 @@ describe("/admin/products", () => {
|
||||
barcode: "test-barcode",
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,301 @@
|
||||
const path = require("path");
|
||||
const {
|
||||
Region,
|
||||
ShippingProfile,
|
||||
ShippingOption,
|
||||
ShippingOptionRequirement,
|
||||
} = require("@medusajs/medusa");
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
|
||||
jest.setTimeout(30000);
|
||||
|
||||
describe("/admin/shipping-options", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
|
||||
describe("POST /admin/shipping-options", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-out",
|
||||
name: "Test out",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option-req",
|
||||
name: "With req",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 5,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req-2",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "max_subtotal",
|
||||
amount: 10,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
|
||||
it("updates a shipping option with no existing requirements", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
name: "Test option",
|
||||
amount: 100,
|
||||
requirements: [
|
||||
{
|
||||
type: "min_subtotal",
|
||||
amount: 1,
|
||||
},
|
||||
{
|
||||
type: "max_subtotal",
|
||||
amount: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const res = await api.post(`/admin/shipping-options/test-out`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
});
|
||||
|
||||
const requirements = res.data.shipping_option.requirements;
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(requirements.length).toEqual(2);
|
||||
expect(requirements[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: "min_subtotal",
|
||||
shipping_option_id: "test-out",
|
||||
amount: 1,
|
||||
})
|
||||
);
|
||||
expect(requirements[1]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: "max_subtotal",
|
||||
shipping_option_id: "test-out",
|
||||
amount: 2,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("fails as it is not allowed to set id from client side", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
name: "Test option",
|
||||
amount: 100,
|
||||
requirements: [
|
||||
{
|
||||
id: "not_allowed",
|
||||
type: "min_subtotal",
|
||||
amount: 1,
|
||||
},
|
||||
{
|
||||
id: "really_not_allowed",
|
||||
type: "max_subtotal",
|
||||
amount: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-out`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
expect(res.data.message).toEqual("ID does not exist");
|
||||
});
|
||||
|
||||
it("it succesfully updates a set of existing requirements", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
{
|
||||
id: "option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 15,
|
||||
},
|
||||
{
|
||||
id: "option-req-2",
|
||||
type: "max_subtotal",
|
||||
amount: 20,
|
||||
},
|
||||
],
|
||||
amount: 200,
|
||||
};
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("it succesfully updates a set of existing requirements by updating one and deleting the other", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
{
|
||||
id: "option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 15,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("succesfully updates a set of requirements because max. subtotal >= min. subtotal", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
{
|
||||
id: "option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 150,
|
||||
},
|
||||
{
|
||||
id: "option-req-2",
|
||||
type: "max_subtotal",
|
||||
amount: 200,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.data.shipping_option.requirements[0].amount).toEqual(150);
|
||||
expect(res.data.shipping_option.requirements[1].amount).toEqual(200);
|
||||
});
|
||||
|
||||
it("fails to updates a set of requirements because max. subtotal <= min. subtotal", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
{
|
||||
id: "option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 1500,
|
||||
},
|
||||
{
|
||||
id: "option-req-2",
|
||||
type: "max_subtotal",
|
||||
amount: 200,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
expect(res.data.message).toEqual(
|
||||
"Max. subtotal must be greater than Min. subtotal"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/store/variants /test-variant 1`] = `
|
||||
Object {
|
||||
"variant": Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": "test-price",
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"product": Any<Object>,
|
||||
"product_id": "test-product",
|
||||
"sku": "test-sku",
|
||||
"title": "Test variant",
|
||||
"upc": "test-upc",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/store/variants includes default relations 1`] = `
|
||||
Object {
|
||||
"variants": Array [
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": "test-price",
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"product": Any<Object>,
|
||||
"product_id": "test-product",
|
||||
"sku": "test-sku",
|
||||
"title": "Test variant",
|
||||
"upc": "test-upc",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,244 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/store/products /store/products/:id includes default relations 1`] = `
|
||||
Object {
|
||||
"product": Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-collection",
|
||||
"id": "test-collection",
|
||||
"metadata": null,
|
||||
"title": "Test collection",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"collection_id": "test-collection",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product",
|
||||
"images": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-image",
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"url": "test-image.png",
|
||||
},
|
||||
],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-option",
|
||||
"metadata": null,
|
||||
"product_id": "test-product",
|
||||
"title": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"values": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option-1",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 1",
|
||||
"variant_id": "test-variant_1",
|
||||
},
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option-2",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 2",
|
||||
"variant_id": "test-variant_2",
|
||||
},
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option-3",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 3",
|
||||
"variant_id": "test-variant_3",
|
||||
},
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option-4",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 4",
|
||||
"variant_id": "test-variant_4",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"subtitle": null,
|
||||
"tags": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "tag1",
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "123",
|
||||
},
|
||||
],
|
||||
"thumbnail": null,
|
||||
"title": "Test product",
|
||||
"type": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-type",
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "test-type",
|
||||
},
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Array [
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": "test-price",
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"product_id": "test-product",
|
||||
"sku": "test-sku",
|
||||
"title": "Test variant",
|
||||
"upc": "test-upc",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean2",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_2",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": "test-price2",
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": "test-variant_2",
|
||||
},
|
||||
],
|
||||
"product_id": "test-product",
|
||||
"sku": "test-sku2",
|
||||
"title": "Test variant rank (2)",
|
||||
"upc": "test-upc2",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode 1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean1",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_1",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": "test-price1",
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": "test-variant_1",
|
||||
},
|
||||
],
|
||||
"product_id": "test-product",
|
||||
"sku": "test-sku1",
|
||||
"title": "Test variant rank (1)",
|
||||
"upc": "test-upc1",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
}
|
||||
`;
|
||||
@@ -283,7 +283,7 @@ Object {
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"customer_id": "test-customer",
|
||||
"display_id": 2,
|
||||
"display_id": 6,
|
||||
"draft_order_id": null,
|
||||
"email": "test@email.com",
|
||||
"fulfillment_status": "fulfilled",
|
||||
|
||||
@@ -5,7 +5,6 @@ const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
|
||||
const draftOrderSeeder = require("../../helpers/draft-order-seeder");
|
||||
const { create } = require("domain");
|
||||
|
||||
jest.setTimeout(30000);
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
const path = require("path")
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
jest.setTimeout(30000)
|
||||
describe("/store/variants", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("includes default relations", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/variants?ids=test-variant")
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
variants: [
|
||||
{
|
||||
allow_backorder: false,
|
||||
barcode: "test-barcode",
|
||||
created_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
ean: "test-ean",
|
||||
height: null,
|
||||
hs_code: null,
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
length: null,
|
||||
manage_inventory: true,
|
||||
material: null,
|
||||
metadata: null,
|
||||
mid_code: null,
|
||||
origin_country: null,
|
||||
product_id: "test-product",
|
||||
sku: "test-sku",
|
||||
title: "Test variant",
|
||||
upc: "test-upc",
|
||||
updated_at: expect.any(String),
|
||||
weight: null,
|
||||
width: null,
|
||||
prices: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
amount: 100,
|
||||
currency_code: "usd",
|
||||
deleted_at: null,
|
||||
id: "test-price",
|
||||
region_id: null,
|
||||
sale_amount: null,
|
||||
variant_id: "test-variant",
|
||||
},
|
||||
],
|
||||
product: expect.any(Object),
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it("/test-variant", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/variants/test-variant")
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
variant: {
|
||||
allow_backorder: false,
|
||||
barcode: "test-barcode",
|
||||
created_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
ean: "test-ean",
|
||||
height: null,
|
||||
hs_code: null,
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
length: null,
|
||||
manage_inventory: true,
|
||||
material: null,
|
||||
metadata: null,
|
||||
mid_code: null,
|
||||
origin_country: null,
|
||||
product_id: "test-product",
|
||||
sku: "test-sku",
|
||||
title: "Test variant",
|
||||
upc: "test-upc",
|
||||
updated_at: expect.any(String),
|
||||
weight: null,
|
||||
width: null,
|
||||
prices: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
amount: 100,
|
||||
currency_code: "usd",
|
||||
deleted_at: null,
|
||||
id: "test-price",
|
||||
region_id: null,
|
||||
sale_amount: null,
|
||||
variant_id: "test-variant",
|
||||
},
|
||||
],
|
||||
product: expect.any(Object),
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,265 @@
|
||||
const { Product } = require("@medusajs/medusa")
|
||||
const path = require("path")
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
jest.setTimeout(30000)
|
||||
describe("/store/products", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("/store/products/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("includes default relations", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/products/test-product")
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
product: {
|
||||
id: "test-product",
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
title: "Test variant",
|
||||
sku: "test-sku",
|
||||
ean: "test-ean",
|
||||
upc: "test-upc",
|
||||
length: null,
|
||||
manage_inventory: true,
|
||||
material: null,
|
||||
metadata: null,
|
||||
mid_code: null,
|
||||
height: null,
|
||||
hs_code: null,
|
||||
origin_country: null,
|
||||
barcode: "test-barcode",
|
||||
product_id: "test-product",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
prices: [
|
||||
{
|
||||
id: "test-money-amount",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
amount: 100,
|
||||
created_at: expect.any(String),
|
||||
currency_code: "usd",
|
||||
deleted_at: null,
|
||||
id: "test-price",
|
||||
region_id: null,
|
||||
sale_amount: null,
|
||||
updated_at: expect.any(String),
|
||||
variant_id: "test-variant",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_2",
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
title: "Test variant rank (2)",
|
||||
sku: "test-sku2",
|
||||
ean: "test-ean2",
|
||||
upc: "test-upc2",
|
||||
length: null,
|
||||
manage_inventory: true,
|
||||
material: null,
|
||||
metadata: null,
|
||||
mid_code: null,
|
||||
height: null,
|
||||
hs_code: null,
|
||||
origin_country: null,
|
||||
barcode: null,
|
||||
product_id: "test-product",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
prices: [
|
||||
{
|
||||
id: "test-money-amount",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
amount: 100,
|
||||
created_at: expect.any(String),
|
||||
currency_code: "usd",
|
||||
deleted_at: null,
|
||||
id: "test-price2",
|
||||
region_id: null,
|
||||
sale_amount: null,
|
||||
updated_at: expect.any(String),
|
||||
variant_id: "test-variant_2",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_1",
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
title: "Test variant rank (1)",
|
||||
sku: "test-sku1",
|
||||
ean: "test-ean1",
|
||||
upc: "test-upc1",
|
||||
length: null,
|
||||
manage_inventory: true,
|
||||
material: null,
|
||||
metadata: null,
|
||||
mid_code: null,
|
||||
height: null,
|
||||
hs_code: null,
|
||||
origin_country: null,
|
||||
barcode: "test-barcode 1",
|
||||
product_id: "test-product",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
prices: [
|
||||
{
|
||||
id: "test-money-amount",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
amount: 100,
|
||||
created_at: expect.any(String),
|
||||
currency_code: "usd",
|
||||
deleted_at: null,
|
||||
id: "test-price1",
|
||||
region_id: null,
|
||||
sale_amount: null,
|
||||
updated_at: expect.any(String),
|
||||
variant_id: "test-variant_1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
images: [
|
||||
{
|
||||
id: "test-image",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
handle: "test-product",
|
||||
title: "Test product",
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
description: "test-product-description",
|
||||
collection_id: "test-collection",
|
||||
collection: {
|
||||
id: "test-collection",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
type: {
|
||||
id: "test-type",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
tags: [
|
||||
{
|
||||
id: "tag1",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-option",
|
||||
values: [
|
||||
{
|
||||
id: "test-variant-option",
|
||||
value: "Default variant",
|
||||
option_id: "test-option",
|
||||
variant_id: "test-variant",
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: "test-variant-option-1",
|
||||
value: "Default variant 1",
|
||||
option_id: "test-option",
|
||||
variant_id: "test-variant_1",
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: "test-variant-option-2",
|
||||
value: "Default variant 2",
|
||||
option_id: "test-option",
|
||||
variant_id: "test-variant_2",
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: "test-variant-option-3",
|
||||
value: "Default variant 3",
|
||||
option_id: "test-option",
|
||||
variant_id: "test-variant_3",
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: "test-variant-option-4",
|
||||
value: "Default variant 4",
|
||||
option_id: "test-option",
|
||||
variant_id: "test-variant_4",
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it("Fetching variant options without additional relation fails", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/products/test-product")
|
||||
|
||||
const product = response.data.product
|
||||
|
||||
expect(product.variants.some((variant) => variant.options)).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,100 @@
|
||||
const { useApi } = require("../../helpers/use-api");
|
||||
|
||||
const header = {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
};
|
||||
|
||||
const resolveCall = async (path, payload, header) => {
|
||||
const api = useApi();
|
||||
let res;
|
||||
try {
|
||||
const resp = await api.post(path, payload, header);
|
||||
res = resp.status;
|
||||
} catch (expectedException) {
|
||||
try {
|
||||
res = expectedException.response.status;
|
||||
} catch (_) {
|
||||
console.error(expectedException);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
const determineFail = (actual, expected, path) => {
|
||||
if (expected !== actual) {
|
||||
console.log(`failed at path : ${path}`);
|
||||
}
|
||||
expect(actual).toEqual(expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows you to wrap a Call function so that you may reuse some input values.
|
||||
* @param {Function} fun - the function to call with partial information
|
||||
* @param {Object} input - the constant input which we want to supply now
|
||||
* @returns
|
||||
*/
|
||||
module.exports.partial = function (fun, input = {}) {
|
||||
return async (remaining) => await fun({ ...remaining, ...input });
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows you to assert a specific code result from a POST call.
|
||||
* @param {Object} input - the information needed to make the call
|
||||
* (path & payload) and the expected code (code)
|
||||
*/
|
||||
module.exports.expectPostCallToReturn = async function (
|
||||
input = {
|
||||
code,
|
||||
path,
|
||||
payload: {},
|
||||
}
|
||||
) {
|
||||
const res = await resolveCall(input.path, input.payload, header);
|
||||
determineFail(res, input.code, input.path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows you to assert a specific code result from multiple POST
|
||||
* calls.
|
||||
* @param {Object} input - the collection of objects to execute
|
||||
* calls from (col), a function which yields the path (pathf),
|
||||
* and another one which provides the payload (payloadf), as
|
||||
* well as the code (code) which we want to assert.
|
||||
*/
|
||||
module.exports.expectAllPostCallsToReturn = async function (
|
||||
input = {
|
||||
code,
|
||||
col,
|
||||
pathf,
|
||||
payloadf,
|
||||
}
|
||||
) {
|
||||
for (const i of input.col) {
|
||||
const res = await resolveCall(
|
||||
input.pathf(i),
|
||||
input.payloadf ? input.payloadf(i) : {},
|
||||
header
|
||||
);
|
||||
determineFail(res, input.code, input.pathf(i));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows you to retrieve a specific object the response
|
||||
* from get call,
|
||||
* and simultaneously assert that the call was successful.
|
||||
* @param {Object} param0 - contains the path which to
|
||||
* call (path), and the object within the response.data (get)
|
||||
* we want to retrieve.
|
||||
* @returns {Object} found within response.data corresponding
|
||||
* to the get parameter provided.
|
||||
*/
|
||||
module.exports.callGet = async function ({ path, get }) {
|
||||
const api = useApi();
|
||||
const res = await api.get(path, header);
|
||||
|
||||
determineFail(res.status, 200, path);
|
||||
return res?.data[get];
|
||||
};
|
||||
@@ -0,0 +1,118 @@
|
||||
const {
|
||||
ClaimOrder,
|
||||
Order,
|
||||
LineItem,
|
||||
Fulfillment,
|
||||
Return,
|
||||
} = require("@medusajs/medusa");
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
|
||||
let orderWithClaim = manager.create(Order, {
|
||||
id: "order-with-claim",
|
||||
customer_id: "test-customer",
|
||||
email: "test@email.com",
|
||||
payment_status: "captured",
|
||||
fulfillment_status: "fulfilled",
|
||||
billing_address: {
|
||||
id: "test-billing-address",
|
||||
first_name: "lebron",
|
||||
},
|
||||
shipping_address: {
|
||||
id: "test-shipping-address",
|
||||
first_name: "lebron",
|
||||
country_code: "us",
|
||||
},
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
discounts: [],
|
||||
payments: [
|
||||
{
|
||||
id: "test-payment-for-claim-order",
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
items: [],
|
||||
...data,
|
||||
});
|
||||
|
||||
await manager.save(orderWithClaim);
|
||||
|
||||
const li = manager.create(LineItem, {
|
||||
id: "test-item-co-2",
|
||||
fulfilled_quantity: 1,
|
||||
title: "Line Item",
|
||||
description: "Line Item Desc",
|
||||
thumbnail: "https://test.js/1234",
|
||||
unit_price: 8000,
|
||||
quantity: 1,
|
||||
variant_id: "test-variant",
|
||||
order_id: orderWithClaim.id,
|
||||
});
|
||||
|
||||
await manager.save(li);
|
||||
|
||||
const li2 = manager.create(LineItem, {
|
||||
id: "test-item-co-3",
|
||||
fulfilled_quantity: 4,
|
||||
title: "Line Item",
|
||||
description: "Line Item Desc",
|
||||
thumbnail: "https://test.js/1234",
|
||||
unit_price: 8000,
|
||||
quantity: 4,
|
||||
variant_id: "test-variant",
|
||||
order_id: orderWithClaim.id,
|
||||
});
|
||||
|
||||
await manager.save(li2);
|
||||
|
||||
const claimWithFulfillment = manager.create(ClaimOrder, {
|
||||
id: "claim-w-f",
|
||||
type: "replace",
|
||||
payment_status: "na",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
order_id: "order-with-claim",
|
||||
...data,
|
||||
});
|
||||
|
||||
const ful1 = manager.create(Fulfillment, {
|
||||
id: "fulfillment-co-1",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
});
|
||||
|
||||
const ful2 = manager.create(Fulfillment, {
|
||||
id: "fulfillment-co-2",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
});
|
||||
|
||||
claimWithFulfillment.fulfillments = [ful1, ful2];
|
||||
|
||||
await manager.save(claimWithFulfillment);
|
||||
|
||||
const claimWithReturn = manager.create(ClaimOrder, {
|
||||
id: "claim-w-r",
|
||||
type: "replace",
|
||||
payment_status: "na",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
order_id: "order-with-claim",
|
||||
...data,
|
||||
});
|
||||
|
||||
await manager.save(claimWithReturn);
|
||||
|
||||
await manager.insert(Return, {
|
||||
id: "return-id-2",
|
||||
claim_order_id: "claim-w-r",
|
||||
status: "requested",
|
||||
refund_amount: 0,
|
||||
data: {},
|
||||
});
|
||||
};
|
||||
@@ -9,6 +9,7 @@ const {
|
||||
Product,
|
||||
ProductVariant,
|
||||
Region,
|
||||
Payment,
|
||||
Order,
|
||||
Swap,
|
||||
} = require("@medusajs/medusa");
|
||||
@@ -183,4 +184,140 @@ module.exports = async (connection, data = {}) => {
|
||||
price: 1000,
|
||||
data: {},
|
||||
});
|
||||
|
||||
const orderTemplate = () => {
|
||||
return {
|
||||
customer_id: "test-customer",
|
||||
email: "test@gmail.com",
|
||||
payment_status: "not_paid",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
...data,
|
||||
};
|
||||
};
|
||||
|
||||
const paymentTemplate = () => {
|
||||
return {
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
};
|
||||
};
|
||||
|
||||
const orderWithClaim = manager.create(Order, {
|
||||
id: "test-order-w-c",
|
||||
claims: [
|
||||
{
|
||||
type: "replace",
|
||||
id: "claim-1",
|
||||
payment_status: "na",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
payment_provider: "test-pay",
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
|
||||
await manager.save(orderWithClaim);
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-c",
|
||||
id: "o-pay1",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
|
||||
const orderWithSwap = manager.create(Order, {
|
||||
id: "test-order-w-s",
|
||||
...orderTemplate(),
|
||||
});
|
||||
|
||||
await manager.save(orderWithSwap);
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-s",
|
||||
id: "o-pay2",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
|
||||
const swap1 = manager.create(Swap, {
|
||||
id: "swap-1",
|
||||
order_id: "test-order-w-s",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
payment_status: "not_paid",
|
||||
});
|
||||
|
||||
const pay1 = manager.create(Payment, {
|
||||
id: "pay1",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
|
||||
swap1.payment = pay1;
|
||||
|
||||
const swap2 = manager.create(Swap, {
|
||||
id: "swap-2",
|
||||
order_id: "test-order-w-s",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
payment_status: "not_paid",
|
||||
});
|
||||
|
||||
const pay2 = manager.create(Payment, {
|
||||
id: "pay2",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
|
||||
swap2.payment = pay2;
|
||||
|
||||
await manager.save(swap1);
|
||||
await manager.save(swap2);
|
||||
|
||||
const orderWithFulfillment = manager.create(Order, {
|
||||
id: "test-order-w-f",
|
||||
fulfillments: [
|
||||
{
|
||||
id: "fulfillment-on-order-1",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
},
|
||||
{
|
||||
id: "fulfillment-on-order-2",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
|
||||
await manager.save(orderWithFulfillment);
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-f",
|
||||
id: "o-pay3",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
|
||||
const orderWithReturn = manager.create(Order, {
|
||||
id: "test-order-w-r",
|
||||
returns: [
|
||||
{
|
||||
id: "return-on-order-1",
|
||||
refund_amount: 0,
|
||||
},
|
||||
{
|
||||
id: "return-on-order-2",
|
||||
refund_amount: 0,
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
|
||||
await manager.save(orderWithReturn);
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-r",
|
||||
id: "o-pay4",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
};
|
||||
@@ -2,55 +2,56 @@ const {
|
||||
ProductCollection,
|
||||
ProductTag,
|
||||
ProductType,
|
||||
ProductOption,
|
||||
Region,
|
||||
Product,
|
||||
ShippingProfile,
|
||||
ProductVariant,
|
||||
Image,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
})
|
||||
|
||||
const coll = manager.create(ProductCollection, {
|
||||
id: "test-collection",
|
||||
handle: "test-collection",
|
||||
title: "Test collection",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(coll);
|
||||
await manager.save(coll)
|
||||
|
||||
const tag = manager.create(ProductTag, {
|
||||
id: "tag1",
|
||||
value: "123",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(tag);
|
||||
await manager.save(tag)
|
||||
|
||||
const type = manager.create(ProductType, {
|
||||
id: "test-type",
|
||||
value: "test-type",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(type);
|
||||
await manager.save(type)
|
||||
|
||||
const image = manager.create(Image, {
|
||||
id: "test-image",
|
||||
url: "test-image.png",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(image);
|
||||
await manager.save(image)
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
})
|
||||
|
||||
const p = manager.create(Product, {
|
||||
id: "test-product",
|
||||
@@ -64,23 +65,138 @@ module.exports = async (connection, data = {}) => {
|
||||
{ id: "tag1", value: "123" },
|
||||
{ tag: "tag2", value: "456" },
|
||||
],
|
||||
options: [{ id: "test-option", title: "Default value" }],
|
||||
});
|
||||
})
|
||||
|
||||
p.images = [image];
|
||||
p.images = [image]
|
||||
|
||||
await manager.save(p);
|
||||
await manager.save(p)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.save(ProductOption, {
|
||||
id: "test-option",
|
||||
title: "test-option",
|
||||
product_id: "test-product",
|
||||
})
|
||||
|
||||
const variant1 = await manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
variant_rank: 0,
|
||||
sku: "test-sku",
|
||||
ean: "test-ean",
|
||||
upc: "test-upc",
|
||||
barcode: "test-barcode",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price", currency_code: "usd", amount: 100 }],
|
||||
options: [{ id: "test-variant-option", value: "Default variant" }],
|
||||
});
|
||||
};
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option",
|
||||
value: "Default variant",
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(variant1)
|
||||
|
||||
const variant2 = await manager.create(ProductVariant, {
|
||||
id: "test-variant_1",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (1)",
|
||||
variant_rank: 2,
|
||||
sku: "test-sku1",
|
||||
ean: "test-ean1",
|
||||
upc: "test-upc1",
|
||||
barcode: "test-barcode 1",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price1", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-1",
|
||||
value: "Default variant 1",
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(variant2)
|
||||
|
||||
const variant3 = await manager.create(ProductVariant, {
|
||||
id: "test-variant_2",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
variant_rank: 1,
|
||||
sku: "test-sku2",
|
||||
ean: "test-ean2",
|
||||
upc: "test-upc2",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price2", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-2",
|
||||
value: "Default variant 2",
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(variant3)
|
||||
|
||||
const p1 = manager.create(Product, {
|
||||
id: "test-product1",
|
||||
handle: "test-product1",
|
||||
title: "Test product1",
|
||||
profile_id: defaultProfile.id,
|
||||
description: "test-product-description1",
|
||||
collection_id: "test-collection",
|
||||
type: { id: "test-type", value: "test-type" },
|
||||
tags: [
|
||||
{ id: "tag1", value: "123" },
|
||||
{ tag: "tag2", value: "456" },
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(p1)
|
||||
|
||||
const variant4 = await manager.create(ProductVariant, {
|
||||
id: "test-variant_3",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
variant_rank: 1,
|
||||
sku: "test-sku3",
|
||||
ean: "test-ean3",
|
||||
upc: "test-upc3",
|
||||
product_id: "test-product1",
|
||||
prices: [{ id: "test-price3", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-3",
|
||||
value: "Default variant 3",
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(variant4)
|
||||
|
||||
const variant5 = await manager.create(ProductVariant, {
|
||||
id: "test-variant_4",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
variant_rank: 0,
|
||||
sku: "test-sku4",
|
||||
ean: "test-ean4",
|
||||
upc: "test-upc4",
|
||||
product_id: "test-product1",
|
||||
prices: [{ id: "test-price4", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-4",
|
||||
value: "Default variant 4",
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(variant5)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ const {
|
||||
Product,
|
||||
ProductVariant,
|
||||
Region,
|
||||
Payment,
|
||||
Order,
|
||||
Swap,
|
||||
Cart,
|
||||
@@ -43,7 +44,7 @@ module.exports = async (connection, data = {}) => {
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test",
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
@@ -80,7 +81,7 @@ module.exports = async (connection, data = {}) => {
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test",
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
},
|
||||
additional_items: [
|
||||
@@ -100,6 +101,70 @@ module.exports = async (connection, data = {}) => {
|
||||
|
||||
await manager.save(swap);
|
||||
|
||||
const cartTemplate = async (cartId) => {
|
||||
const cart = manager.create(Cart, {
|
||||
id: cartId,
|
||||
customer_id: "test-customer",
|
||||
email: "test-customer@email.com",
|
||||
shipping_address_id: "test-shipping-address",
|
||||
billing_address_id: "test-billing-address",
|
||||
region_id: "test-region",
|
||||
type: "swap",
|
||||
metadata: {},
|
||||
...data,
|
||||
});
|
||||
|
||||
await manager.save(cart);
|
||||
};
|
||||
|
||||
const swapTemplate = async (cartId) => {
|
||||
await cartTemplate(cartId);
|
||||
return {
|
||||
order_id: orderWithSwap.id,
|
||||
fulfillment_status: "fulfilled",
|
||||
payment_status: "not_paid",
|
||||
cart_id: cartId,
|
||||
payment: {
|
||||
amount: 5000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
},
|
||||
...data,
|
||||
};
|
||||
};
|
||||
|
||||
const swapWithFulfillments = manager.create(Swap, {
|
||||
id: "swap-w-f",
|
||||
fulfillments: [
|
||||
{
|
||||
id: "fulfillment-1",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
},
|
||||
{
|
||||
id: "fulfillment-2",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
},
|
||||
],
|
||||
...(await swapTemplate("sc-w-f")),
|
||||
});
|
||||
|
||||
await manager.save(swapWithFulfillments);
|
||||
|
||||
const swapWithReturn = manager.create(Swap, {
|
||||
id: "swap-w-r",
|
||||
return_order: {
|
||||
id: "return-id",
|
||||
status: "requested",
|
||||
refund_amount: 0,
|
||||
},
|
||||
...(await swapTemplate("sc-w-r")),
|
||||
});
|
||||
|
||||
await manager.save(swapWithReturn);
|
||||
const li = manager.create(LineItem, {
|
||||
id: "return-item-1",
|
||||
fulfilled_quantity: 1,
|
||||
@@ -175,7 +240,7 @@ module.exports = async (connection, data = {}) => {
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test",
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
},
|
||||
additional_items: [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const DB_USERNAME = process.env.DB_USERNAME || "postgres";
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD || "";
|
||||
const DB_USERNAME = process.env.DB_USERNAME || "postgres"
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD || ""
|
||||
|
||||
module.exports = {
|
||||
plugins: [],
|
||||
@@ -8,4 +8,4 @@ module.exports = {
|
||||
database_url: `postgres://${DB_USERNAME}:${DB_PASSWORD}@localhost/medusa-integration`,
|
||||
database_type: "postgres",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -8,15 +8,15 @@
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa": "1.1.38-dev-1630001256218",
|
||||
"medusa-interfaces": "1.1.21-dev-1630001256218",
|
||||
"@medusajs/medusa": "1.1.40-dev-1631178030541",
|
||||
"medusa-interfaces": "1.1.21",
|
||||
"typeorm": "^0.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.10",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/node": "^7.12.10",
|
||||
"babel-preset-medusa-package": "1.1.13-dev-1630001256218",
|
||||
"babel-preset-medusa-package": "1.1.13",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
+564
-540
File diff suppressed because it is too large.
Load diff
@@ -21,6 +21,7 @@
|
||||
"import-from": "^3.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"lerna": "^3.22.1",
|
||||
"microbundle": "^0.13.3",
|
||||
"mongoose": "^5.10.15",
|
||||
"pg-god": "^1.0.11",
|
||||
"prettier": "^2.1.1",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.13...babel-preset-medusa-package@1.1.14) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package babel-preset-medusa-package
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.12...babel-preset-medusa-package@1.1.13) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package babel-preset-medusa-package
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-preset-medusa-package",
|
||||
"version": "1.1.13",
|
||||
"version": "1.1.14",
|
||||
"author": "Sebastian Rindom <sebastian@mrbltech.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -26,5 +26,5 @@
|
||||
"engines": {
|
||||
"node": ">=10.14.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
/dist
|
||||
yarn.lock
|
||||
@@ -0,0 +1,37 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
*.un~
|
||||
yarn.lock
|
||||
src
|
||||
flow-typed
|
||||
coverage
|
||||
decls
|
||||
examples
|
||||
|
||||
# tests
|
||||
__tests__
|
||||
@@ -0,0 +1,11 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## 0.0.1 (2021-09-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* adds create-medusa-app ([#377](https://github.com/medusajs/medusa/issues/377)) ([ec6d16e](https://github.com/medusajs/medusa/commit/ec6d16e945f4b8a99e9dcc8ae2e92a2318fbc709))
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
const { run } = require("./dist")
|
||||
|
||||
run().catch((e) => {
|
||||
console.warn(e)
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "create-medusa-app",
|
||||
"version": "0.0.1",
|
||||
"main": "dist/index.js",
|
||||
"bin": "cli.js",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist/index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "microbundle -i src/index.ts --no-pkg-main --target=node -f=cjs --sourcemap=false --compress --alias worker_threads=@ascorbic/worker-threads-shim",
|
||||
"watch": "microbundle -i src/index.ts --no-pkg-main --target=node -f=cjs --sourcemap=false --alias worker_threads=@ascorbic/worker-threads-shim --watch",
|
||||
"prepare": "yarn build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ascorbic/worker-threads-shim": "^1.0.0",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@types/chalk": "^2.2.0",
|
||||
"@types/commander": "^2.12.2",
|
||||
"@types/configstore": "^4.0.0",
|
||||
"@types/fs-extra": "^9.0.12",
|
||||
"@types/node": "^14.17.14",
|
||||
"ansi-wordwrap": "^1.0.2",
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^8.1.0",
|
||||
"common-tags": "^1.8.0",
|
||||
"configstore": "^6.0.0",
|
||||
"enquirer": "^2.3.6",
|
||||
"eslint": "^7.32.0",
|
||||
"execa": "^5.1.1",
|
||||
"fs-exists-cached": "^1.0.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"hosted-git-info": "^4.0.2",
|
||||
"is-valid-path": "^0.1.1",
|
||||
"joi": "^17.4.2",
|
||||
"microbundle": "^0.13.3",
|
||||
"node-fetch": "^2.6.1",
|
||||
"prettier": "^2.3.2",
|
||||
"prompts": "^2.4.1",
|
||||
"string-length": "^4.0.2",
|
||||
"terminal-link": "^2.1.1",
|
||||
"tiny-spin": "^1.0.2",
|
||||
"url": "^0.11.0",
|
||||
"uuid": "3.4.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa.git",
|
||||
"directory": "packages/create-medusa-app"
|
||||
},
|
||||
"author": "Sebastian Rindom <seb@medusa-commerce.com>",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Configstore from "configstore"
|
||||
|
||||
let config: Configstore
|
||||
|
||||
export const getConfigStore = (): Configstore => {
|
||||
if (!config) {
|
||||
config = new Configstore(
|
||||
`medusa`,
|
||||
{},
|
||||
{
|
||||
globalConfigPath: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import path from "path"
|
||||
import Commander from "commander"
|
||||
import chalk from "chalk"
|
||||
|
||||
import { prompt } from "enquirer"
|
||||
import { newStarter } from "./new-starter"
|
||||
import { track } from "./track"
|
||||
|
||||
import pkg from "../package.json"
|
||||
|
||||
let projectPath: string = ""
|
||||
|
||||
const questions = {
|
||||
projectRoot: {
|
||||
type: "input",
|
||||
name: "projectRoot",
|
||||
message: "Where should your project be installed?",
|
||||
initial: "my-medusa-store",
|
||||
},
|
||||
starter: {
|
||||
type: "select",
|
||||
name: "starter",
|
||||
message: "Which Medusa starter would you like to install?",
|
||||
choices: ["medusa-starter-default", "medusa-starter-contentful", "Other"],
|
||||
},
|
||||
starterUrl: {
|
||||
type: "input",
|
||||
name: "starterUrl",
|
||||
message: "Where is the starter located? (URL or path)",
|
||||
},
|
||||
seed: {
|
||||
type: "confirm",
|
||||
name: "seed",
|
||||
message: "Should we attempt to seed your database?",
|
||||
},
|
||||
storefront: {
|
||||
type: "select",
|
||||
name: "storefront",
|
||||
message: "Which storefront starter would you like to install?",
|
||||
choices: ["Gatsby Starter", "Next.js Starter", "None"],
|
||||
},
|
||||
}
|
||||
|
||||
const program = new Commander.Command(pkg.name)
|
||||
.version(pkg.version)
|
||||
.action((name) => (projectPath = name))
|
||||
.option(`-r --root`, `The directory to install your Medusa app`)
|
||||
.option(
|
||||
`-s --starter-url`,
|
||||
`A GitHub URL to a repository that contains a Medusa starter project to bootstrap from`
|
||||
)
|
||||
.option(
|
||||
`--seed`,
|
||||
`If run with the seed flag the script will automatically attempt to seed the database upon setup`
|
||||
)
|
||||
.option(`-v --verbose`, `Show all installation output`)
|
||||
.parse(process.argv)
|
||||
|
||||
export const run = async (): Promise<void> => {
|
||||
track("CREATE_CLI")
|
||||
|
||||
if (typeof projectPath === "string") {
|
||||
projectPath = projectPath.trim()
|
||||
}
|
||||
|
||||
const { projectRoot } = (await prompt(questions.projectRoot)) as {
|
||||
projectRoot: string
|
||||
}
|
||||
let { starter } = (await prompt(questions.starter)) as {
|
||||
starter: string
|
||||
}
|
||||
|
||||
if (starter === "Other") {
|
||||
const { starterUrl } = (await prompt(questions.starterUrl)) as {
|
||||
starterUrl: string
|
||||
}
|
||||
starter = starterUrl
|
||||
} else {
|
||||
starter = `medusajs/${starter}`
|
||||
}
|
||||
track("STARTER_SELECTED", { starter })
|
||||
|
||||
const progOptions = program.opts()
|
||||
|
||||
const seed = progOptions.seed
|
||||
track("SEED_SELECTED", { seed })
|
||||
|
||||
const { storefront } = (await prompt(questions.storefront)) as {
|
||||
storefront: string
|
||||
}
|
||||
track("STOREFRONT_SELECTED", { storefront })
|
||||
|
||||
await newStarter({
|
||||
starter,
|
||||
root: path.join(projectRoot, `backend`),
|
||||
seed,
|
||||
verbose: progOptions.verbose,
|
||||
})
|
||||
|
||||
const hasStorefront = storefront.toLowerCase() !== "none"
|
||||
if (hasStorefront) {
|
||||
const storefrontStarter =
|
||||
storefront.toLowerCase() === "gatsby starter"
|
||||
? "https://github.com/medusajs/gatsby-starter-medusa"
|
||||
: "https://github.com/medusajs/nextjs-starter-medusa"
|
||||
await newStarter({
|
||||
starter: storefrontStarter,
|
||||
root: path.join(projectRoot, `storefront`),
|
||||
verbose: progOptions.verbose,
|
||||
})
|
||||
}
|
||||
await newStarter({
|
||||
starter: "https://github.com/medusajs/admin",
|
||||
root: path.join(projectRoot, `admin`),
|
||||
keepGit: true,
|
||||
verbose: progOptions.verbose,
|
||||
})
|
||||
|
||||
console.log(`
|
||||
Your project is ready 🚀. The available commands are:
|
||||
|
||||
Medusa API
|
||||
cd ${projectRoot}/backend
|
||||
yarn start
|
||||
|
||||
Admin
|
||||
cd ${projectRoot}/admin
|
||||
yarn start
|
||||
`)
|
||||
|
||||
if (hasStorefront) {
|
||||
console.log(`
|
||||
Storefront
|
||||
cd ${projectRoot}/storefront
|
||||
yarn start
|
||||
`)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
import { execSync } from "child_process"
|
||||
import execa from "execa"
|
||||
import { spin } from "tiny-spin"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import fs from "fs-extra"
|
||||
import hostedGitInfo from "hosted-git-info"
|
||||
import isValid from "is-valid-path"
|
||||
import sysPath from "path"
|
||||
import url from "url"
|
||||
|
||||
import { reporter } from "./reporter"
|
||||
import { getConfigStore } from "./get-config-store"
|
||||
|
||||
const packageManagerConfigKey = `cli.packageManager`
|
||||
|
||||
export const getPackageManager = (npmConfigUserAgent) => {
|
||||
const configStore = getConfigStore()
|
||||
const actualPackageManager = configStore.get(packageManagerConfigKey)
|
||||
|
||||
if (actualPackageManager) {
|
||||
return actualPackageManager
|
||||
}
|
||||
|
||||
if (npmConfigUserAgent?.includes(`yarn`)) {
|
||||
configStore.set(packageManagerConfigKey, `yarn`)
|
||||
return `yarn`
|
||||
}
|
||||
|
||||
configStore.set(packageManagerConfigKey, `npm`)
|
||||
return `npm`
|
||||
}
|
||||
|
||||
const removeUndefined = (obj) => {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj)
|
||||
.filter(([_, v]) => v != null)
|
||||
.map(([k, v]) => [k, v === Object(v) ? removeEmpty(v) : v])
|
||||
)
|
||||
}
|
||||
|
||||
const spawnWithArgs = (file, args, options) =>
|
||||
execa(file, args, { stdio: "ignore", preferLocal: false, ...options })
|
||||
|
||||
const spawn = (cmd, options) => {
|
||||
const [file, ...args] = cmd.split(/\s+/)
|
||||
return spawnWithArgs(file, args, options)
|
||||
}
|
||||
// Checks the existence of yarn package
|
||||
// We use yarnpkg instead of yarn to avoid conflict with Hadoop yarn
|
||||
// Refer to https://github.com/yarnpkg/yarn/issues/673
|
||||
const checkForYarn = () => {
|
||||
try {
|
||||
execSync(`yarnpkg --version`, { stdio: `ignore` })
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const isAlreadyGitRepository = async () => {
|
||||
try {
|
||||
return await spawn(`git rev-parse --is-inside-work-tree`, {
|
||||
stdio: `pipe`,
|
||||
}).then((output) => output.stdout === `true`)
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize newly cloned directory as a git repo
|
||||
const gitInit = async (rootPath) => {
|
||||
reporter.info(`Initialising git in ${rootPath}`)
|
||||
|
||||
return await spawn(`git init`, { cwd: rootPath })
|
||||
}
|
||||
|
||||
// Create a .gitignore file if it is missing in the new directory
|
||||
const maybeCreateGitIgnore = async (rootPath) => {
|
||||
if (existsSync(sysPath.join(rootPath, `.gitignore`))) {
|
||||
return
|
||||
}
|
||||
|
||||
reporter.info(`Creating minimal .gitignore in ${rootPath}`)
|
||||
await fs.writeFile(
|
||||
sysPath.join(rootPath, `.gitignore`),
|
||||
`.cache\nnode_modules\npublic\n`
|
||||
)
|
||||
reporter.success(`Created .gitignore in ${rootPath}`)
|
||||
}
|
||||
|
||||
// Create an initial git commit in the new directory
|
||||
const createInitialGitCommit = async (rootPath, starterUrl) => {
|
||||
reporter.info(`Create initial git commit in ${rootPath}`)
|
||||
|
||||
await spawn(`git add -A`, { cwd: rootPath })
|
||||
// use execSync instead of spawn to handle git clients using
|
||||
// pgp signatures (with password)
|
||||
try {
|
||||
execSync(`git commit -m "Initial commit from medusa: (${starterUrl})"`, {
|
||||
cwd: rootPath,
|
||||
})
|
||||
} catch {
|
||||
// Remove git support if initial commit fails
|
||||
reporter.warn(`Initial git commit failed - removing git support\n`)
|
||||
fs.removeSync(sysPath.join(rootPath, `.git`))
|
||||
}
|
||||
}
|
||||
|
||||
// Executes `npm install` or `yarn install` in rootPath.
|
||||
const install = async (rootPath, verbose) => {
|
||||
const prevDir = process.cwd()
|
||||
|
||||
const stop = spin(`Installing packages...`)
|
||||
console.log() // Add some space
|
||||
|
||||
process.chdir(rootPath)
|
||||
|
||||
const npmConfigUserAgent = process.env.npm_config_user_agent
|
||||
|
||||
try {
|
||||
if (getPackageManager() === `yarn` && checkForYarn()) {
|
||||
await fs.remove(`package-lock.json`)
|
||||
await spawn(`yarnpkg`, { stdio: verbose ? `inherit` : `ignore` })
|
||||
} else {
|
||||
await fs.remove(`yarn.lock`)
|
||||
await spawn(`npm install`, { stdio: verbose ? `inherit` : `ignore` })
|
||||
}
|
||||
} finally {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.success(`Packages installed`)
|
||||
process.chdir(prevDir)
|
||||
}
|
||||
}
|
||||
|
||||
const ignored = (path) => !/^\.(git|hg)$/.test(sysPath.basename(path))
|
||||
|
||||
// Copy starter from file system.
|
||||
const copy = async (starterPath, rootPath) => {
|
||||
// Chmod with 755.
|
||||
// 493 = parseInt('755', 8)
|
||||
await fs.ensureDir(rootPath, { mode: 493 })
|
||||
|
||||
if (!existsSync(starterPath)) {
|
||||
throw new Error(`starter ${starterPath} doesn't exist`)
|
||||
}
|
||||
|
||||
if (starterPath === `.`) {
|
||||
throw new Error(
|
||||
`You can't create a starter from the existing directory. If you want to
|
||||
create a new project in the current directory, the trailing dot isn't
|
||||
necessary. If you want to create a project from a local starter, run
|
||||
something like "medusa new my-medusa-store ../local-medusa-starter"`
|
||||
)
|
||||
}
|
||||
|
||||
const stop = spin(`Creating new site from local starter: ${starterPath}`)
|
||||
|
||||
reporter.info(`Copying local starter to ${rootPath} ...`)
|
||||
|
||||
await fs.copy(starterPath, rootPath, { filter: ignored })
|
||||
|
||||
stop()
|
||||
console.log()
|
||||
reporter.success(`Created starter directory layout`)
|
||||
console.log() // Add some space
|
||||
|
||||
await install(rootPath)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Clones starter from URI.
|
||||
const clone = async (hostInfo, rootPath, keepGit, verbose = false) => {
|
||||
let url
|
||||
// Let people use private repos accessed over SSH.
|
||||
if (hostInfo.getDefaultRepresentation() === `sshurl`) {
|
||||
url = hostInfo.ssh({ noCommittish: true })
|
||||
// Otherwise default to normal git syntax.
|
||||
} else {
|
||||
url = hostInfo.https({ noCommittish: true, noGitPlus: true })
|
||||
}
|
||||
|
||||
const branch = hostInfo.committish ? [`-b`, hostInfo.committish] : []
|
||||
|
||||
const stop = spin(`Creating new project from git: ${url}`)
|
||||
|
||||
const args = [
|
||||
`clone`,
|
||||
...branch,
|
||||
url,
|
||||
rootPath,
|
||||
`--recursive`,
|
||||
`--depth=1`,
|
||||
].filter((arg) => Boolean(arg))
|
||||
|
||||
await execa(`git`, args, {})
|
||||
.then(() => {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.success(`Created starter directory layout`)
|
||||
})
|
||||
.catch((err) => {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.error(`Failed to clone repository`)
|
||||
throw err
|
||||
})
|
||||
|
||||
if (!keepGit) {
|
||||
await fs.remove(sysPath.join(rootPath, `.git`))
|
||||
}
|
||||
|
||||
await install(rootPath, verbose)
|
||||
const isGit = await isAlreadyGitRepository()
|
||||
if (!isGit) await gitInit(rootPath)
|
||||
await maybeCreateGitIgnore(rootPath)
|
||||
if (!isGit) await createInitialGitCommit(rootPath, url)
|
||||
}
|
||||
|
||||
const getMedusaConfig = (rootPath) => {
|
||||
try {
|
||||
const configPath = sysPath.join(rootPath, "medusa-config.js")
|
||||
if (existsSync(configPath)) {
|
||||
const resolved = sysPath.resolve(configPath)
|
||||
const configModule = require(resolved)
|
||||
return configModule
|
||||
}
|
||||
throw Error()
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
const getPaths = async (starterPath, rootPath) => {
|
||||
let selectedOtherStarter = false
|
||||
|
||||
// set defaults if no root or starter has been set yet
|
||||
rootPath = rootPath || process.cwd()
|
||||
starterPath = starterPath || `medusajs/medusa-starter-default`
|
||||
|
||||
return { starterPath, rootPath, selectedOtherStarter }
|
||||
}
|
||||
|
||||
const successMessage = (path) => {
|
||||
reporter.info(`Your new Medusa project is ready for you! To start developing run:
|
||||
|
||||
cd ${path}
|
||||
medusa develop
|
||||
`)
|
||||
}
|
||||
|
||||
const setupEnvVars = async (rootPath) => {
|
||||
const templatePath = sysPath.join(rootPath, ".env.template")
|
||||
const destination = sysPath.join(rootPath, ".env")
|
||||
if (existsSync(templatePath)) {
|
||||
fs.renameSync(templatePath, destination)
|
||||
}
|
||||
}
|
||||
|
||||
const attemptSeed = async (rootPath) => {
|
||||
const stop = spin("Seeding database")
|
||||
|
||||
const pkgPath = sysPath.resolve(rootPath, "package.json")
|
||||
if (existsSync(pkgPath)) {
|
||||
const pkg = require(pkgPath)
|
||||
if (pkg.scripts && pkg.scripts.seed) {
|
||||
await setupEnvVars(rootPath)
|
||||
|
||||
const proc = execa(getPackageManager(), [`run`, `seed`], {
|
||||
cwd: rootPath,
|
||||
})
|
||||
|
||||
// Useful for development
|
||||
proc.stdout.pipe(process.stdout)
|
||||
|
||||
await proc
|
||||
.then(() => {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.success("Seed completed")
|
||||
})
|
||||
.catch((err) => {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.error("Failed to complete seed; skipping")
|
||||
console.error(err)
|
||||
})
|
||||
} else {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.error("Starter doesn't provide a seed command; skipping.")
|
||||
}
|
||||
} else {
|
||||
stop()
|
||||
console.log()
|
||||
reporter.error("Could not find package.json")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function that clones or copies the starter.
|
||||
*/
|
||||
export const newStarter = async (args) => {
|
||||
const { starter, root, verbose, seed, keepGit } = args
|
||||
|
||||
const { starterPath, rootPath, selectedOtherStarter } = await getPaths(
|
||||
starter,
|
||||
root
|
||||
)
|
||||
|
||||
const urlObject = url.parse(rootPath)
|
||||
|
||||
if (urlObject.protocol && urlObject.host) {
|
||||
const isStarterAUrl =
|
||||
starter && !url.parse(starter).hostname && !url.parse(starter).protocol
|
||||
|
||||
if (/medusa-starter/gi.test(rootPath) && isStarterAUrl) {
|
||||
reporter.panic({
|
||||
id: `10000`,
|
||||
context: {
|
||||
starter,
|
||||
rootPath,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
reporter.panic({
|
||||
id: `10001`,
|
||||
context: {
|
||||
rootPath,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!isValid(rootPath)) {
|
||||
reporter.panic({
|
||||
id: `10002`,
|
||||
context: {
|
||||
path: sysPath.resolve(rootPath),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (existsSync(sysPath.join(rootPath, `package.json`))) {
|
||||
reporter.panic({
|
||||
id: `10003`,
|
||||
context: {
|
||||
rootPath,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const hostedInfo = hostedGitInfo.fromUrl(starterPath)
|
||||
if (hostedInfo) {
|
||||
await clone(hostedInfo, rootPath, keepGit, verbose)
|
||||
} else {
|
||||
await copy(starterPath, rootPath, verbose)
|
||||
}
|
||||
|
||||
const medusaConfig = getMedusaConfig(rootPath)
|
||||
if (medusaConfig) {
|
||||
let isPostgres = false
|
||||
if (medusaConfig.projectConfig) {
|
||||
const databaseType = medusaConfig.projectConfig.database_type
|
||||
isPostgres = databaseType === "postgres"
|
||||
}
|
||||
|
||||
if (!isPostgres && seed) {
|
||||
await attemptSeed(rootPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
export const panicHandler = (panicData = {}) => {
|
||||
const { id, context } = panicData
|
||||
switch (id) {
|
||||
case "10000":
|
||||
return {
|
||||
message: `Looks like you provided a URL as your project name. Try "medusa new my-medusa-store ${context.rootPath}" instead.`,
|
||||
}
|
||||
case "10001":
|
||||
return {
|
||||
message: `Looks like you provided a URL as your project name. Try "medusa new my-medusa-store ${context.rootPath}" instead.`,
|
||||
}
|
||||
case "10002":
|
||||
return {
|
||||
message: `Could not create project because ${context.path} is not a valid path.`,
|
||||
}
|
||||
case "10003":
|
||||
return {
|
||||
message: `Directory ${context.rootPath} is already a Node project.`,
|
||||
}
|
||||
default:
|
||||
return {
|
||||
message: "Unknown error",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import c from "ansi-colors"
|
||||
import { panicHandler } from "./panic-handler"
|
||||
|
||||
export const reporter = {
|
||||
info: (message: string): void => console.log(message),
|
||||
verbose: (message: string): void => console.log(message),
|
||||
log: (message: string): void => console.log(message),
|
||||
success: (message: string): void =>
|
||||
console.log(c.green(c.symbols.check + ` `) + message),
|
||||
error: (message: string): void =>
|
||||
console.error(c.red(c.symbols.cross + ` `) + message),
|
||||
panic: (panicData: { id: string; context: any }): never => {
|
||||
const { message } = panicHandler(panicData)
|
||||
console.error(message)
|
||||
process.exit(1)
|
||||
},
|
||||
warn: (message: string): void => console.warn(message),
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import fetch from "node-fetch"
|
||||
import uuidv4 from "uuid/v4"
|
||||
import { getConfigStore } from "./get-config-store"
|
||||
|
||||
const store = getConfigStore()
|
||||
const medusaCliVersion = require(`../package.json`).version
|
||||
|
||||
const analyticsApi =
|
||||
process.env.MEDUSA_TELEMETRY_API ||
|
||||
`https://telemetry.medusa-commerce.com/batch`
|
||||
|
||||
const getMachineId = (): string => {
|
||||
let machineId = store.get(`telemetry.machine_id`)
|
||||
|
||||
if (typeof machineId !== `string`) {
|
||||
machineId = uuidv4()
|
||||
store.set(`telemetry.machine_id`, machineId)
|
||||
}
|
||||
|
||||
return machineId
|
||||
}
|
||||
|
||||
const sessionId = uuidv4()
|
||||
|
||||
export const track = (eventType: string, args?: any): void => {
|
||||
fetch(analyticsApi, {
|
||||
method: `POST`,
|
||||
headers: {
|
||||
"content-type": `application/json`,
|
||||
"user-agent": `create-medusa-app:${medusaCliVersion}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
timestamp: new Date(),
|
||||
batch: [
|
||||
{
|
||||
type: eventType,
|
||||
timestamp: new Date(),
|
||||
sessionId,
|
||||
machine_id: getMachineId(),
|
||||
component_id: `create-medusa-app`,
|
||||
cli_version: medusaCliVersion,
|
||||
properties: args,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}).catch(() => {}) /* do nothing, it's telemetry */
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
declare module "stream-filter"
|
||||
declare module "ansi-wordwrap"
|
||||
declare module "uuid/v4"
|
||||
declare module "node-fetch"
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2015",
|
||||
"module": "commonjs",
|
||||
"allowJs": true,
|
||||
"declaration": false,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.json", "src/**/*.js"],
|
||||
"exclude": ["**/__tests__/**/*"]
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.16...@medusajs/medusa-cli@1.1.17) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.15...@medusajs/medusa-cli@1.1.16) (2021-08-17)
|
||||
|
||||
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@medusajs/medusa-cli",
|
||||
"version": "1.1.16",
|
||||
"version": "1.1.17",
|
||||
"description": "Command Line interface for Medusa Commerce",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
@@ -52,7 +52,7 @@
|
||||
"joi-objectid": "^3.0.1",
|
||||
"meant": "^1.0.1",
|
||||
"medusa-core-utils": "^0.1.27",
|
||||
"medusa-telemetry": "^0.0.3",
|
||||
"medusa-telemetry": "^0.0.4",
|
||||
"netrc-parser": "^3.1.6",
|
||||
"open": "^8.0.6",
|
||||
"ora": "^5.4.1",
|
||||
@@ -66,5 +66,5 @@
|
||||
"winston": "^3.3.3",
|
||||
"yargs": "^15.3.1"
|
||||
},
|
||||
"gitHead": "cfe19f7f9d3bb17425348362b148a0b4b7a649ef"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -1300,6 +1300,13 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5:
|
||||
json-schema-traverse "^0.4.1"
|
||||
uri-js "^4.2.2"
|
||||
|
||||
ansi-align@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb"
|
||||
integrity sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==
|
||||
dependencies:
|
||||
string-width "^3.0.0"
|
||||
|
||||
ansi-escapes@^3.1.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
|
||||
@@ -1466,12 +1473,19 @@ aws4@^1.8.0:
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e"
|
||||
integrity sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==
|
||||
|
||||
axios@^0.21.1:
|
||||
version "0.21.1"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
|
||||
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
|
||||
axios-retry@^3.1.9:
|
||||
version "3.1.9"
|
||||
resolved "https://registry.yarnpkg.com/axios-retry/-/axios-retry-3.1.9.tgz#6c30fc9aeb4519aebaec758b90ef56fa03fe72e8"
|
||||
integrity sha512-NFCoNIHq8lYkJa6ku4m+V1837TP6lCa7n79Iuf8/AqATAHYB0ISaAS1eyIenDOfHOLtym34W65Sjke2xjg2fsA==
|
||||
dependencies:
|
||||
follow-redirects "^1.10.0"
|
||||
is-retry-allowed "^1.1.0"
|
||||
|
||||
axios@^0.21.1:
|
||||
version "0.21.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
|
||||
integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.0"
|
||||
|
||||
babel-jest@^25.5.1:
|
||||
version "25.5.1"
|
||||
@@ -1589,6 +1603,20 @@ bl@^4.1.0:
|
||||
inherits "^2.0.4"
|
||||
readable-stream "^3.4.0"
|
||||
|
||||
boxen@^5.0.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/boxen/-/boxen-5.1.1.tgz#4faca6a437885add0bf8d99082e272d480814cd4"
|
||||
integrity sha512-JtIQYts08AFAYGF4eSh3pUt3NQkYV/e75pRtQmAVTLNWR/1L7Bsswxlgzgk8nmLEM+gFszsIlA9BgD3XnSqp3g==
|
||||
dependencies:
|
||||
ansi-align "^3.0.0"
|
||||
camelcase "^6.2.0"
|
||||
chalk "^4.1.0"
|
||||
cli-boxes "^2.2.1"
|
||||
string-width "^4.2.2"
|
||||
type-fest "^0.20.2"
|
||||
widest-line "^3.1.0"
|
||||
wrap-ansi "^7.0.0"
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
@@ -1693,6 +1721,11 @@ camelcase@^5.0.0, camelcase@^5.3.1:
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
|
||||
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||
|
||||
camelcase@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
|
||||
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
|
||||
|
||||
caniuse-lite@^1.0.30001219:
|
||||
version "1.0.30001236"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001236.tgz#0a80de4cdf62e1770bb46a30d884fc8d633e3958"
|
||||
@@ -1780,6 +1813,11 @@ ci-info@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
|
||||
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
|
||||
|
||||
ci-info@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.2.0.tgz#2876cb948a498797b5236f0095bc057d0dca38b6"
|
||||
integrity sha512-dVqRX7fLUm8J6FgHJ418XuIgDLZDkYcDFTeL6TA2gt5WlIZUQrrH6EZrNClwT/H0FateUsZkGIOPRrLbP+PR9A==
|
||||
|
||||
class-utils@^0.3.5:
|
||||
version "0.3.6"
|
||||
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
|
||||
@@ -1797,6 +1835,11 @@ clean-stack@^3.0.0:
|
||||
dependencies:
|
||||
escape-string-regexp "4.0.0"
|
||||
|
||||
cli-boxes@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.1.tgz#ddd5035d25094fce220e9cab40a45840a440318f"
|
||||
integrity sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==
|
||||
|
||||
cli-cursor@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307"
|
||||
@@ -2660,10 +2703,10 @@ fn.name@1.x.x:
|
||||
resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc"
|
||||
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
|
||||
|
||||
follow-redirects@^1.10.0:
|
||||
version "1.13.3"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.3.tgz#e5598ad50174c1bc4e872301e82ac2cd97f90267"
|
||||
integrity sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==
|
||||
follow-redirects@^1.14.0:
|
||||
version "1.14.3"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.3.tgz#6ada78118d8d24caee595595accdc0ac6abd022e"
|
||||
integrity sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==
|
||||
|
||||
for-in@^1.0.2:
|
||||
version "1.0.2"
|
||||
@@ -3164,7 +3207,7 @@ is-docker@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.0.0.tgz#2cb0df0e75e2d064fe1864c37cdeacb7b2dcf25b"
|
||||
integrity sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==
|
||||
|
||||
is-docker@^2.1.1:
|
||||
is-docker@^2.1.1, is-docker@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
|
||||
integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
|
||||
@@ -3263,6 +3306,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
|
||||
dependencies:
|
||||
isobject "^3.0.1"
|
||||
|
||||
is-retry-allowed@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4"
|
||||
integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==
|
||||
|
||||
is-stream@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
@@ -4043,6 +4091,20 @@ medusa-core-utils@^0.1.27:
|
||||
"@hapi/joi" "^16.1.8"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-telemetry@^0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/medusa-telemetry/-/medusa-telemetry-0.0.3.tgz#c11e5e0f3cc969f3eaee41d1c24f78a5c0715362"
|
||||
integrity sha512-Qb/sgOwO8t2Sjjo4nKyBa6hKZ/SjniT4eEWenygEaJDqXZhfogVYGhWc5gn4tLlFFNEHXzDTlrqX2LvzfEJWIw==
|
||||
dependencies:
|
||||
axios "^0.21.1"
|
||||
axios-retry "^3.1.9"
|
||||
boxen "^5.0.1"
|
||||
ci-info "^3.2.0"
|
||||
configstore "5.0.1"
|
||||
is-docker "^2.2.1"
|
||||
remove-trailing-slash "^0.1.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
merge-stream@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
|
||||
@@ -4837,6 +4899,11 @@ remove-trailing-separator@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
|
||||
integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8=
|
||||
|
||||
remove-trailing-slash@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/remove-trailing-slash/-/remove-trailing-slash-0.1.1.tgz#be2285a59f39c74d1bce4f825950061915e3780d"
|
||||
integrity sha512-o4S4Qh6L2jpnCy83ysZDau+VORNvnFw07CKSAymkd6ICNVEPisMyzlc00KlvvicsxKck94SEwhDnMNdICzO+tA==
|
||||
|
||||
repeat-element@^1.1.2:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce"
|
||||
@@ -5324,7 +5391,7 @@ string-width@^3.0.0:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^5.1.0"
|
||||
|
||||
string-width@^4.0.0:
|
||||
string-width@^4.0.0, string-width@^4.2.2:
|
||||
version "4.2.2"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
|
||||
integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
|
||||
@@ -5608,6 +5675,11 @@ type-fest@^0.11.0:
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"
|
||||
integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==
|
||||
|
||||
type-fest@^0.20.2:
|
||||
version "0.20.2"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
|
||||
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
|
||||
|
||||
type-fest@^0.21.3:
|
||||
version "0.21.3"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37"
|
||||
@@ -5733,6 +5805,11 @@ uuid@^3.3.2:
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||
|
||||
uuid@^8.3.2:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
v8-compile-cache@^2.0.3:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.20...medusa-core-utils@1.1.21) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-core-utils
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.19...medusa-core-utils@1.1.20) (2021-08-05)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-core-utils",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.21",
|
||||
"description": "Core utils for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -33,5 +33,5 @@
|
||||
"joi": "^17.3.0",
|
||||
"joi-objectid": "^3.0.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.19](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.18...medusa-dev-cli@0.0.19) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-dev-cli
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.0.18](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.17...medusa-dev-cli@0.0.18) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-dev-cli
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "medusa-dev-cli",
|
||||
"description": "CLI helpers for contributors working on Medusa",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"author": "Sebastian Rindom <skrindom@gmail.com>",
|
||||
"bin": {
|
||||
"medusa-dev": "./dist/index.js"
|
||||
@@ -24,7 +24,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.1",
|
||||
"@babel/core": "^7.12.3",
|
||||
"babel-preset-medusa-package": "^1.1.13",
|
||||
"babel-preset-medusa-package": "^1.1.14",
|
||||
"cross-env": "^7.0.3"
|
||||
},
|
||||
"homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme",
|
||||
@@ -47,5 +47,5 @@
|
||||
"engines": {
|
||||
"node": ">=12.13.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.23...medusa-file-spaces@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-file-spaces
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.22...medusa-file-spaces@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-file-spaces
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-file-spaces",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Digital Ocean Spaces file connector for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,9 +40,9 @@
|
||||
"aws-sdk": "^2.710.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"stripe": "^8.50.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.20...medusa-fulfillment-manual@1.1.21) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-fulfillment-manual
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.19...medusa-fulfillment-manual@1.1.20) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-fulfillment-manual
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-fulfillment-manual",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.21",
|
||||
"description": "A manual fulfillment provider for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -36,7 +36,7 @@
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.24...medusa-fulfillment-webshipper@1.1.25) (2021-09-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.23...medusa-fulfillment-webshipper@1.1.24) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-fulfillment-webshipper
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-fulfillment-webshipper",
|
||||
"version": "1.1.24",
|
||||
"version": "1.1.25",
|
||||
"description": "Webshipper Fulfillment provider for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -37,7 +37,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -582,7 +582,10 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
}
|
||||
|
||||
if (order) {
|
||||
if (order.data.attributes.status !== "pending") {
|
||||
if (
|
||||
order.data.attributes.status !== "pending" &&
|
||||
order.data.attributes.status !== "missing_rate"
|
||||
) {
|
||||
if (order.data.attributes.status === "cancelled") {
|
||||
return Promise.resolve(order)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.21...medusa-interfaces@1.1.22) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-interfaces
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.20...medusa-interfaces@1.1.21) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-interfaces
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-interfaces",
|
||||
"version": "1.1.21",
|
||||
"version": "1.1.22",
|
||||
"description": "Core interfaces for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -35,7 +35,7 @@
|
||||
"typeorm": "0.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.25...medusa-payment-adyen@1.1.26) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.24...medusa-payment-adyen@1.1.25) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-adyen",
|
||||
"version": "1.1.25",
|
||||
"version": "1.1.26",
|
||||
"description": "Adyen Payment provider for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -24,7 +24,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
@@ -42,7 +42,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.25...medusa-payment-klarna@1.1.26) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-klarna
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.24...medusa-payment-klarna@1.1.25) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-klarna
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-klarna",
|
||||
"version": "1.1.25",
|
||||
"version": "1.1.26",
|
||||
"description": "Klarna Payment provider for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,8 +40,8 @@
|
||||
"axios": "^0.21.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.0.3](https://github.com/medusajs/medusa/compare/medusa-payment-manual@1.0.4...medusa-payment-manual@1.0.3) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-manual
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.4](https://github.com/medusajs/medusa/compare/medusa-payment-manual@1.0.2...medusa-payment-manual@1.0.4) (2021-09-02)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-manual",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.3",
|
||||
"description": "A dummy payment provider to be used for testing or manual payments",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -25,7 +25,7 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
@@ -36,5 +36,5 @@
|
||||
"peerDependencies": {
|
||||
"medusa-interfaces": "1.x"
|
||||
},
|
||||
"gitHead": "cb44b73a4ec0319c77058816022367183f28857c"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.0.25](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.24...medusa-payment-paypal@1.0.25) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-paypal
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.24](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.23...medusa-payment-paypal@1.0.24) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-paypal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-paypal",
|
||||
"version": "1.0.24",
|
||||
"version": "1.0.25",
|
||||
"description": "Paypal Payment provider for Meduas Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -26,8 +26,8 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-interfaces": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-interfaces": "^1.1.22",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__,**/__mocks__",
|
||||
@@ -42,7 +42,7 @@
|
||||
"@paypal/checkout-server-sdk": "^1.0.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.23...medusa-payment-stripe@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-stripe
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.22...medusa-payment-stripe@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-stripe
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-stripe",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Stripe Payment provider for Meduas Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -26,7 +26,7 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
@@ -40,8 +40,8 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"stripe": "^8.50.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
import _ from "lodash"
|
||||
import Stripe from "stripe"
|
||||
import { PaymentService } from "medusa-interfaces"
|
||||
|
||||
class IdealProviderService extends PaymentService {
|
||||
static identifier = "stripe-ideal"
|
||||
|
||||
constructor(
|
||||
{ stripeProviderService, customerService, totalsService, regionService },
|
||||
options
|
||||
) {
|
||||
super()
|
||||
|
||||
/**
|
||||
* Required Stripe options:
|
||||
* {
|
||||
* api_key: "stripe_secret_key", REQUIRED
|
||||
* webhook_secret: "stripe_webhook_secret", REQUIRED
|
||||
* // Use this flag to capture payment immediately (default is false)
|
||||
* capture: true
|
||||
* }
|
||||
*/
|
||||
this.options_ = options
|
||||
|
||||
/** @private @const {Stripe} */
|
||||
this.stripe_ = Stripe(options.api_key)
|
||||
|
||||
/** @private @const {CustomerService} */
|
||||
this.stripeProviderService_ = stripeProviderService
|
||||
|
||||
/** @private @const {CustomerService} */
|
||||
this.customerService_ = customerService
|
||||
|
||||
/** @private @const {RegionService} */
|
||||
this.regionService_ = regionService
|
||||
|
||||
/** @private @const {TotalsService} */
|
||||
this.totalsService_ = totalsService
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches Stripe payment intent. Check its status and returns the
|
||||
* corresponding Medusa status.
|
||||
* @param {object} paymentData - payment method data from cart
|
||||
* @returns {string} the status of the payment intent
|
||||
*/
|
||||
async getStatus(paymentData) {
|
||||
return await this.stripeProviderService_.getStatus(paymentData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a customers saved payment methods if registered in Stripe.
|
||||
* @param {object} customer - customer to fetch saved cards for
|
||||
* @returns {Promise<Array<object>>} saved payments methods
|
||||
*/
|
||||
async retrieveSavedMethods(customer) {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a Stripe customer
|
||||
* @param {string} customerId - Stripe customer id
|
||||
* @returns {Promise<object>} Stripe customer
|
||||
*/
|
||||
async retrieveCustomer(customerId) {
|
||||
return await this.stripeProviderService_.retrieveCustomer(customerId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Stripe customer using a Medusa customer.
|
||||
* @param {object} customer - Customer data from Medusa
|
||||
* @returns {Promise<object>} Stripe customer
|
||||
*/
|
||||
async createCustomer(customer) {
|
||||
return await this.stripeProviderService_.createCustomer(customer)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Stripe payment intent.
|
||||
* If customer is not registered in Stripe, we do so.
|
||||
* @param {object} cart - cart to create a payment for
|
||||
* @returns {object} Stripe payment intent
|
||||
*/
|
||||
async createPayment(cart) {
|
||||
const { customer_id, region_id, email } = cart
|
||||
const region = await this.regionService_.retrieve(region_id)
|
||||
const { currency_code } = region
|
||||
|
||||
const amount = await this.totalsService_.getTotal(cart)
|
||||
|
||||
const intentRequest = {
|
||||
amount: Math.round(amount),
|
||||
currency: currency_code,
|
||||
payment_method_types: ["ideal"],
|
||||
capture_method: "automatic",
|
||||
metadata: { cart_id: `${cart.id}` },
|
||||
}
|
||||
|
||||
if (customer_id) {
|
||||
const customer = await this.customerService_.retrieve(customer_id)
|
||||
|
||||
if (customer.metadata?.stripe_id) {
|
||||
intentRequest.customer = customer.metadata.stripe_id
|
||||
} else {
|
||||
const stripeCustomer = await this.createCustomer({
|
||||
email,
|
||||
id: customer_id,
|
||||
})
|
||||
|
||||
intentRequest.customer = stripeCustomer.id
|
||||
}
|
||||
} else {
|
||||
const stripeCustomer = await this.createCustomer({
|
||||
email,
|
||||
})
|
||||
|
||||
intentRequest.customer = stripeCustomer.id
|
||||
}
|
||||
|
||||
const paymentIntent = await this.stripe_.paymentIntents.create(
|
||||
intentRequest
|
||||
)
|
||||
|
||||
return paymentIntent
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Stripe payment intent.
|
||||
* @param {object} data - the data of the payment to retrieve
|
||||
* @returns {Promise<object>} Stripe payment intent
|
||||
*/
|
||||
async retrievePayment(data) {
|
||||
return await this.stripeProviderService_.retrievePayment(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Stripe payment intent and returns it.
|
||||
* @param {object} sessionData - the data of the payment to retrieve
|
||||
* @returns {Promise<object>} Stripe payment intent
|
||||
*/
|
||||
async getPaymentData(sessionData) {
|
||||
return await this.stripeProviderService_.getPaymentData(sessionData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorizes Stripe payment intent by simply returning
|
||||
* the status for the payment intent in use.
|
||||
* @param {object} sessionData - payment session data
|
||||
* @param {object} context - properties relevant to current context
|
||||
* @returns {Promise<{ status: string, data: object }>} result with data and status
|
||||
*/
|
||||
async authorizePayment(sessionData, context = {}) {
|
||||
return await this.stripeProviderService_.authorizePayment(
|
||||
sessionData,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
async updatePaymentData(sessionData, update) {
|
||||
return await this.stripeProviderService_.updatePaymentData(
|
||||
sessionData,
|
||||
update
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates Stripe payment intent.
|
||||
* @param {object} sessionData - payment session data.
|
||||
* @param {object} update - objec to update intent with
|
||||
* @returns {object} Stripe payment intent
|
||||
*/
|
||||
async updatePayment(sessionData, cart) {
|
||||
try {
|
||||
const stripeId = cart.customer?.metadata?.stripe_id || undefined
|
||||
|
||||
if (stripeId !== sessionData.customer) {
|
||||
return this.createPayment(cart)
|
||||
} else {
|
||||
if (cart.total && sessionData.amount === Math.round(cart.total)) {
|
||||
return sessionData
|
||||
}
|
||||
|
||||
return this.stripe_.paymentIntents.update(sessionData.id, {
|
||||
amount: Math.round(cart.total),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async deletePayment(payment) {
|
||||
return await this.stripeProviderService_.deletePayment(payment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates customer of Stripe payment intent.
|
||||
* @param {string} paymentIntentId - id of payment intent to update
|
||||
* @param {string} customerId - id of new Stripe customer
|
||||
* @returns {object} Stripe payment intent
|
||||
*/
|
||||
async updatePaymentIntentCustomer(paymentIntentId, customerId) {
|
||||
return await this.stripeProviderService_.updatePaymentIntentCustomer(
|
||||
paymentIntentId,
|
||||
customerId
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures payment for Stripe payment intent.
|
||||
* @param {object} paymentData - payment method data from cart
|
||||
* @returns {object} Stripe payment intent
|
||||
*/
|
||||
async capturePayment(payment) {
|
||||
return await this.stripeProviderService_.capturePayment(payment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Refunds payment for Stripe payment intent.
|
||||
* @param {object} paymentData - payment method data from cart
|
||||
* @param {number} amountToRefund - amount to refund
|
||||
* @returns {string} refunded payment intent
|
||||
*/
|
||||
async refundPayment(payment, amountToRefund) {
|
||||
return await this.stripeProviderService_.refundPayment(
|
||||
payment,
|
||||
amountToRefund
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels payment for Stripe payment intent.
|
||||
* @param {object} paymentData - payment method data from cart
|
||||
* @returns {object} canceled payment intent
|
||||
*/
|
||||
async cancelPayment(payment) {
|
||||
return await this.stripeProviderService_.cancelPayment(payment)
|
||||
}
|
||||
}
|
||||
|
||||
export default IdealProviderService
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.23...medusa-plugin-add-ons@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.22...medusa-plugin-add-ons@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-add-ons",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Add-on plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -25,7 +25,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
@@ -37,8 +37,8 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"redis": "^3.0.2"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.30...medusa-plugin-brightpearl@1.1.29) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.28...medusa-plugin-brightpearl@1.1.30) (2021-09-02)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-brightpearl",
|
||||
"version": "1.1.30",
|
||||
"version": "1.1.29",
|
||||
"description": "Brightpearl plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -27,8 +27,8 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-interfaces": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-interfaces": "^1.1.22",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"prettier": "^2.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -44,8 +44,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"axios-rate-limit": "^1.2.1",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "cb44b73a4ec0319c77058816022367183f28857c"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.25...medusa-plugin-contentful@1.1.26) (2021-09-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* adds transform medusa ids ([#385](https://github.com/medusajs/medusa/issues/385)) ([0812aca](https://github.com/medusajs/medusa/commit/0812acaf0db19664028cabf08ffd11d67de42f3a))
|
||||
* typo ([5d5c659](https://github.com/medusajs/medusa/commit/5d5c659f8ae9bd96cc0cc565167f3d926e8253ff))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.24...medusa-plugin-contentful@1.1.25) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-contentful
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-contentful",
|
||||
"version": "1.1.25",
|
||||
"version": "1.1.26",
|
||||
"description": "Contentful plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,9 +39,9 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"contentful-management": "^5.27.1",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"redis": "^3.0.2"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class ContentfulService extends BaseService {
|
||||
"en-US": variantLinks,
|
||||
},
|
||||
[this.getCustomField("options", "product")]: {
|
||||
"en-US": p.options,
|
||||
"en-US": this.transformMedusaIds(p.options),
|
||||
},
|
||||
[this.getCustomField("medusaId", "product")]: {
|
||||
"en-US": p.id,
|
||||
@@ -285,10 +285,10 @@ class ContentfulService extends BaseService {
|
||||
"en-US": v.sku,
|
||||
},
|
||||
[this.getCustomField("prices", "variant")]: {
|
||||
"en-US": v.prices,
|
||||
"en-US": this.transformMedusaIds(v.prices),
|
||||
},
|
||||
[this.getCustomField("options", "variant")]: {
|
||||
"en-US": v.options,
|
||||
"en-US": this.transformMedusaIds(v.options),
|
||||
},
|
||||
[this.getCustomField("medusaId", "variant")]: {
|
||||
"en-US": v.id,
|
||||
@@ -476,7 +476,7 @@ class ContentfulService extends BaseService {
|
||||
"en-US": p.description,
|
||||
},
|
||||
[this.getCustomField("options", "product")]: {
|
||||
"en-US": p.options,
|
||||
"en-US": this.transformMedusaIds(p.options),
|
||||
},
|
||||
[this.getCustomField("variants", "product")]: {
|
||||
"en-US": variantLinks,
|
||||
@@ -538,9 +538,8 @@ class ContentfulService extends BaseService {
|
||||
"en-US": p.collection.title,
|
||||
}
|
||||
|
||||
productEntryFields[
|
||||
this.getCustomField("collection", "product")
|
||||
] = collection
|
||||
productEntryFields[this.getCustomField("collection", "product")] =
|
||||
collection
|
||||
}
|
||||
|
||||
if (p.tags) {
|
||||
@@ -624,10 +623,10 @@ class ContentfulService extends BaseService {
|
||||
"en-US": v.sku,
|
||||
},
|
||||
[this.getCustomField("options", "variant")]: {
|
||||
"en-US": v.options,
|
||||
"en-US": this.transformMedusaIds(v.options),
|
||||
},
|
||||
[this.getCustomField("prices", "variant")]: {
|
||||
"en-US": v.prices,
|
||||
"en-US": this.transformMedusaIds(v.prices),
|
||||
},
|
||||
[this.getCustomField("medusaId", "variant")]: {
|
||||
"en-US": v.id,
|
||||
@@ -734,6 +733,29 @@ class ContentfulService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
transformMedusaIds(objOrArray) {
|
||||
let input = objOrArray
|
||||
let isArray = true
|
||||
if (!Array.isArray(objOrArray)) {
|
||||
input = [objOrArray]
|
||||
isArray = false
|
||||
}
|
||||
|
||||
let output = []
|
||||
for (const obj of input) {
|
||||
let transformed = Object.assign({}, obj)
|
||||
transformed.medusaId = obj.id
|
||||
output.push(transformed)
|
||||
}
|
||||
|
||||
console.log(output)
|
||||
if (!isArray) {
|
||||
return output[0]
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
async getType(type) {
|
||||
const environment = await this.getContentfulEnvironment_()
|
||||
return environment.getContentType(type)
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.13...medusa-plugin-discount-generator@1.1.14) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.12...medusa-plugin-discount-generator@1.1.13) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-discount-generator",
|
||||
"version": "1.1.13",
|
||||
"version": "1.1.14",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"author": "Sebastian Rindom",
|
||||
@@ -40,5 +40,5 @@
|
||||
"medusa-core-utils": "^0.1.27",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.23...medusa-plugin-economic@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.22...medusa-plugin-economic@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "E-conomic financial reporting",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,9 +39,9 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"moment": "^2.27.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.13...medusa-plugin-ip-lookup@1.1.14) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.12...medusa-plugin-ip-lookup@1.1.13) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-ip-lookup",
|
||||
"version": "1.1.13",
|
||||
"version": "1.1.14",
|
||||
"description": "IP lookup middleware for Medusa core",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -35,5 +35,5 @@
|
||||
"axios": "^0.20.0",
|
||||
"mongoose": "^5.8.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.23...medusa-plugin-mailchimp@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.22...medusa-plugin-mailchimp@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-mailchimp",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Mailchimp newsletter subscriptions",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,8 +40,8 @@
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"mailchimp-api-v3": "^1.14.0",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.23...medusa-plugin-permissions@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-permissions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.22...medusa-plugin-permissions@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-permissions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-permissions",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Role permission for Medusa core",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -32,9 +32,9 @@
|
||||
"medusa-interfaces": "1.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"mongoose": "^5.8.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.17](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.18...medusa-plugin-restock-notification@0.0.17) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.0.18](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.16...medusa-plugin-restock-notification@0.0.18) (2021-09-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-restock-notification",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.17",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -14,11 +14,11 @@
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/plugin-transform-typescript": "^7.13.0",
|
||||
"@babel/preset-typescript": "^7.12.7",
|
||||
"babel-preset-medusa-package": "^1.1.13",
|
||||
"babel-preset-medusa-package": "^1.1.14",
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"pg": "^8.5.1",
|
||||
"ulid": "^2.3.0"
|
||||
},
|
||||
@@ -36,7 +36,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20"
|
||||
"medusa-core-utils": "^1.1.21"
|
||||
},
|
||||
"gitHead": "cb44b73a4ec0319c77058816022367183f28857c"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.26...medusa-plugin-segment@1.1.27) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-segment
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.25...medusa-plugin-segment@1.1.26) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-segment
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-segment",
|
||||
"version": "1.1.26",
|
||||
"version": "1.1.27",
|
||||
"description": "Segment Analytics",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.24...medusa-plugin-sendgrid@1.1.25) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-sendgrid
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.23...medusa-plugin-sendgrid@1.1.24) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-sendgrid
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-sendgrid",
|
||||
"version": "1.1.24",
|
||||
"version": "1.1.25",
|
||||
"description": "SendGrid transactional emails",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"@sendgrid/mail": "^7.1.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.23...medusa-plugin-slack-notification@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-slack-notification
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.22...medusa-plugin-slack-notification@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-slack-notification
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-slack-notification",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Slack notifications",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,9 +39,9 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"moment": "^2.27.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.23...medusa-plugin-twilio-sms@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.22...medusa-plugin-twilio-sms@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-twilio-sms",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,9 +35,9 @@
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"body-parser": "^1.19.0",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24",
|
||||
"twilio": "^3.49.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.25...medusa-plugin-wishlist@1.1.24) (2021-09-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.23...medusa-plugin-wishlist@1.1.25) (2021-09-02)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-wishlist",
|
||||
"version": "1.1.25",
|
||||
"version": "1.1.24",
|
||||
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -38,8 +38,8 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-test-utils": "^1.1.23"
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"medusa-test-utils": "^1.1.24"
|
||||
},
|
||||
"gitHead": "cb44b73a4ec0319c77058816022367183f28857c"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
@@ -953,18 +953,6 @@
|
||||
exec-sh "^0.3.2"
|
||||
minimist "^1.2.0"
|
||||
|
||||
"@hapi/hoek@^9.0.0":
|
||||
version "9.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
|
||||
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==
|
||||
|
||||
"@hapi/topo@^5.0.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012"
|
||||
integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@istanbuljs/load-nyc-config@^1.0.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
|
||||
@@ -1166,23 +1154,6 @@
|
||||
readdirp "^2.2.1"
|
||||
upath "^1.1.1"
|
||||
|
||||
"@sideway/address@^4.1.0":
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1"
|
||||
integrity sha512-idTz8ibqWFrPU8kMirL0CoPH/A29XOzzAzpyN3zQ4kAWnzmNfFmRaoMNN6VI8ske5M73HZyhIaW4OuSFIdM4oA==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@sideway/formula@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
|
||||
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
|
||||
|
||||
"@sideway/pinpoint@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
|
||||
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
|
||||
@@ -3144,11 +3115,6 @@ is-number@^3.0.0:
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
is-number@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff"
|
||||
integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==
|
||||
|
||||
is-number@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
|
||||
@@ -3642,22 +3608,6 @@ jest@^25.5.2:
|
||||
import-local "^3.0.2"
|
||||
jest-cli "^25.5.4"
|
||||
|
||||
joi-objectid@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668"
|
||||
integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ==
|
||||
|
||||
joi@^17.3.0:
|
||||
version "17.4.2"
|
||||
resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.2.tgz#02f4eb5cf88e515e614830239379dcbbe28ce7f7"
|
||||
integrity sha512-Lm56PP+n0+Z2A2rfRvsfWVDXGEWjXxatPopkQ8qQ5mxCEhwHG+Ettgg5o98FFaxilOxozoa14cFhrE/hOzh/Nw==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
"@hapi/topo" "^5.0.0"
|
||||
"@sideway/address" "^4.1.0"
|
||||
"@sideway/formula" "^3.0.0"
|
||||
"@sideway/pinpoint" "^2.0.0"
|
||||
|
||||
js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
@@ -3878,33 +3828,11 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
math-random@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c"
|
||||
integrity sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==
|
||||
|
||||
media-typer@0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
||||
|
||||
medusa-core-utils@^1.1.20:
|
||||
version "1.1.20"
|
||||
resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.20.tgz#676c0dc863a206b80cc53299a984c532d07df65f"
|
||||
integrity sha512-gf+/L5eeqHea3xgjwD7YZEzfUGlxbjfvaeiiGWi3Wfu0dLa+G1B4S0TsX+upR+oVeWPmk66VMqWC80h3e4csqw==
|
||||
dependencies:
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-test-utils@^1.1.23:
|
||||
version "1.1.23"
|
||||
resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.23.tgz#e8380df499979cd0b97a5bb87779662f4da9d722"
|
||||
integrity sha512-okyUgB4t7bqDieE0XO+HkbVVemn6hE1tTAtF9PXRi2igmKmcnyW/Ljk3lqrKYVhjei4z3Z/b+K2b0oNwhopbGQ==
|
||||
dependencies:
|
||||
"@babel/plugin-transform-classes" "^7.9.5"
|
||||
medusa-core-utils "^1.1.20"
|
||||
randomatic "^3.1.1"
|
||||
|
||||
merge-descriptors@1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
||||
@@ -4451,15 +4379,6 @@ qs@~6.5.2:
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
|
||||
|
||||
randomatic@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.1.tgz#b776efc59375984e36c537b2f51a1f0aff0da1ed"
|
||||
integrity sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==
|
||||
dependencies:
|
||||
is-number "^4.0.0"
|
||||
kind-of "^6.0.0"
|
||||
math-random "^1.0.1"
|
||||
|
||||
range-parser@~1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.4](https://github.com/medusajs/medusa/compare/medusa-telemetry@0.0.3...medusa-telemetry@0.0.4) (2021-09-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* make shipping_option_id on requirements optional ([#340](https://github.com/medusajs/medusa/issues/340)) ([16b0fa3](https://github.com/medusajs/medusa/commit/16b0fa377a577abd7976c2beaff83e2030969df8))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.0.3](https://github.com/medusajs/medusa/compare/medusa-telemetry@0.0.2...medusa-telemetry@0.0.3) (2021-08-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-telemetry
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-telemetry",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"description": "Telemetry for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -16,8 +16,8 @@
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.14.3",
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"babel-preset-medusa-package": "^1.1.13",
|
||||
"@babel/preset-typescript": "^7.15.0",
|
||||
"babel-preset-medusa-package": "^1.1.14",
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
@@ -40,9 +40,10 @@
|
||||
"boxen": "^5.0.1",
|
||||
"ci-info": "^3.2.0",
|
||||
"configstore": "5.0.1",
|
||||
"global": "^4.4.0",
|
||||
"is-docker": "^2.2.1",
|
||||
"remove-trailing-slash": "^0.1.1",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"gitHead": "cfe19f7f9d3bb17425348362b148a0b4b7a649ef"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.23...medusa-test-utils@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.22...medusa-test-utils@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-test-utils",
|
||||
"version": "1.1.23",
|
||||
"version": "1.1.24",
|
||||
"description": "Test utils for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -29,8 +29,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"medusa-core-utils": "^1.1.20",
|
||||
"medusa-core-utils": "^1.1.21",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
||||
}
|
||||
Loaded 100 of 181 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user