chore: remove legacy plugins (#7224)

* chore(): remove more legacy plugins

* chore(): remove more legacy plugins

* rm plugins
This commit is contained in:
Adrien de Peretti
2024-05-03 14:47:16 +02:00
committed by GitHub
parent bbccd6481d
commit 224ebb2154
95 changed files with 12 additions and 12529 deletions

View File

@@ -102,11 +102,6 @@ module.exports = {
"./packages/core/utils/tsconfig.spec.json",
"./packages/core/medusa-test-utils/tsconfig.spec.json",
"./packages/fulfillment-manual/tsconfig.spec.json",
"./packages/medusa-plugin-meilisearch/tsconfig.spec.json",
"./packages/medusa-plugin-algolia/tsconfig.spec.json",
"./packages/modules/product/tsconfig.json",
"./packages/modules/event-bus-local/tsconfig.spec.json",
"./packages/modules/event-bus-redis/tsconfig.spec.json",

View File

@@ -28,9 +28,7 @@
"@medusajs/utils": "workspace:^",
"@medusajs/workflow-engine-inmemory": "workspace:*",
"faker": "^5.5.3",
"medusa-fulfillment-webshipper": "workspace:*",
"medusa-interfaces": "workspace:*",
"medusa-plugin-sendgrid": "workspace:*",
"pg": "^8.11.0",
"typeorm": "^0.3.16"
},

View File

@@ -31,9 +31,7 @@
"@medusajs/utils": "workspace:^",
"@medusajs/workflow-engine-inmemory": "workspace:*",
"faker": "^5.5.3",
"medusa-fulfillment-webshipper": "workspace:*",
"medusa-interfaces": "workspace:*",
"medusa-plugin-sendgrid": "workspace:*",
"medusa-test-utils": "workspace:*",
"pg": "^8.11.0",
"typeorm": "^0.3.16"

View File

@@ -1,933 +0,0 @@
const path = require("path")
const {
startBootstrapApp,
} = require("../../../environment-helpers/bootstrap-app")
const { initDb, useDb } = require("../../../environment-helpers/use-db")
const { useApi } = require("../../../environment-helpers/use-api")
const adminSeeder = require("../../../helpers/admin-seeder")
jest.setTimeout(10000)
const {
simpleOrderFactory,
simpleStoreFactory,
simpleProductFactory,
simpleShippingOptionFactory,
} = require("../../../factories")
const { getContainer } = require("../../../environment-helpers/use-container")
describe("medusa-plugin-sendgrid", () => {
let appContainer
let dbConnection
let shutdownServer
const doAfterEach = async () => {
const db = useDb()
return await db.teardown()
}
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
shutdownServer = await startBootstrapApp({ cwd })
appContainer = getContainer()
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
await shutdownServer()
})
afterEach(async () => {
return await doAfterEach()
})
test("order canceled data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection, {
notShipped: true,
})
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/cancel`,
{},
{ headers: { "x-medusa-access-token": "test_token" } }
)
expect(response.status).toEqual(200)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("order.canceled", {
id: order.id,
})
expect(data).toMatchSnapshot({
date: expect.any(String),
id: expect.any(String),
display_id: expect.any(Number),
sales_channel_id: null,
created_at: expect.any(Date),
canceled_at: expect.any(Date),
updated_at: expect.any(Date),
customer_id: expect.any(String),
customer: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
shipping_methods: [
{
id: expect.any(String),
shipping_option_id: expect.any(String),
order_id: expect.any(String),
shipping_option: {
id: expect.any(String),
profile_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
],
shipping_address_id: expect.any(String),
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
order_edit_id: null,
original_item_id: null,
updated_at: expect.any(Date),
order_id: expect.any(String),
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
},
],
region: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
})
})
test("order shipment created data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection, {
notShipped: true,
})
const api = useApi()
const { data: fulfillmentData } = await api.post(
`/admin/orders/${order.id}/fulfillment`,
{ items: [{ item_id: "test-item", quantity: 2 }] },
{ headers: { "x-medusa-access-token": "test_token" } }
)
const fulfillment = fulfillmentData.order.fulfillments[0]
const response = await api.post(
`/admin/orders/${order.id}/shipment`,
{ fulfillment_id: fulfillment.id },
{ headers: { "x-medusa-access-token": "test_token" } }
)
expect(response.status).toEqual(200)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("order.shipment_created", {
id: order.id,
fulfillment_id: fulfillment.id,
})
expect(data).toMatchSnapshot({
date: expect.any(String),
fulfillment: {
id: expect.any(String),
order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
shipped_at: expect.any(Date),
items: [
{
fulfillment_id: expect.any(String),
},
],
},
order: {
display_id: expect.any(Number),
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
customer_id: expect.any(String),
customer: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
fulfillments: [
{
id: expect.any(String),
order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
shipped_at: expect.any(Date),
items: [
{
fulfillment_id: expect.any(String),
},
],
},
],
shipping_methods: [
{
id: expect.any(String),
shipping_option_id: expect.any(String),
order_id: expect.any(String),
shipping_option: {
id: expect.any(String),
profile_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
],
shipping_address_id: expect.any(String),
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_edit_id: null,
original_item_id: null,
order_id: expect.any(String),
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
},
],
region: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
})
})
test("order placed data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("order.placed", {
id: order.id,
})
expect(data).toMatchSnapshot({
date: expect.any(String),
id: expect.any(String),
display_id: expect.any(Number),
created_at: expect.any(Date),
updated_at: expect.any(Date),
customer_id: expect.any(String),
customer: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
shipping_address_id: expect.any(String),
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_id: expect.any(String),
order_edit_id: null,
original_item_id: null,
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
totals: {
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
},
},
],
region: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
})
})
test("swap received data", async () => {
await simpleStoreFactory(dbConnection)
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/swaps`,
{
additional_items: [{ variant_id: "variant-2", quantity: 1 }],
return_items: [{ item_id: "test-item", quantity: 1 }],
},
{ headers: { "x-medusa-access-token": "test_token" } }
)
expect(response.status).toEqual(200)
const swap = response.data.order.swaps[0]
const returnOrder = swap.return_order
await api.post(
`/admin/returns/${returnOrder.id}/receive`,
{
items: returnOrder.items.map((i) => ({
item_id: i.item_id,
quantity: i.quantity,
})),
},
{ headers: { "x-medusa-access-token": "test_token" } }
)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("swap.received", {
id: swap.id,
order_id: order.id,
})
expect(data.return_total).toMatchSnapshot()
expect(data.refund_amount).toMatchSnapshot()
expect(data.additional_total).toMatchSnapshot()
})
test("items returned data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/return`,
{
items: [{ item_id: "test-item", quantity: 1 }],
},
{
headers: {
"x-medusa-access-token": "test_token",
},
}
)
expect(response.status).toEqual(200)
const returnOrder = response.data.order.returns[0]
const returnId = returnOrder.id
await api.post(
`/admin/returns/${returnId}/receive`,
{
items: returnOrder.items.map((i) => ({
item_id: i.item_id,
quantity: i.quantity,
})),
},
{ headers: { "x-medusa-access-token": "test_token" } }
)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("order.items_returned", {
id: order.id,
return_id: returnId,
})
const returnSnap = getReturnSnap(true)
expect(data).toMatchSnapshot(returnSnap)
})
test("claim shipment created data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const shippingOut = await simpleShippingOptionFactory(dbConnection, {
region_id: "test-region",
price: 500,
})
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/claims`,
{
type: "replace",
additional_items: [{ variant_id: "variant-2", quantity: 1 }],
shipping_methods: [
{
option_id: shippingOut.id,
price: 0,
},
],
claim_items: [
{ reason: "missing_item", item_id: "test-item", quantity: 1 },
],
},
{ headers: { "x-medusa-access-token": "test_token" } }
)
expect(response.status).toEqual(200)
const claimId = response.data.order.claims[0].id
const { data: fulfillmentData } = await api.post(
`/admin/orders/${order.id}/claims/${claimId}/fulfillments`,
{},
{ headers: { "x-medusa-access-token": "test_token" } }
)
const fulfillmentId = fulfillmentData.order.claims[0].fulfillments[0].id
await api.post(
`/admin/orders/${order.id}/claims/${claimId}/shipments`,
{ fulfillment_id: fulfillmentId },
{ headers: { "x-medusa-access-token": "test_token" } }
)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("claim.shipment_created", {
id: claimId,
fulfillment_id: fulfillmentId,
})
const orderSnap = {
id: expect.any(String),
display_id: expect.any(Number),
customer_id: expect.any(String),
shipping_address_id: expect.any(String),
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
created_at: expect.any(Date),
updated_at: expect.any(Date),
items: [
{
id: expect.any(String),
order_id: expect.any(String),
order_edit_id: null,
original_item_id: null,
created_at: expect.any(Date),
updated_at: expect.any(Date),
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
},
],
}
expect(data).toMatchSnapshot({
claim: {
id: expect.any(String),
order_id: expect.any(String),
shipping_address_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
idempotency_key: expect.any(String),
order: orderSnap,
},
fulfillment: {
id: expect.any(String),
claim_order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
shipped_at: expect.any(Date),
items: [
{
fulfillment_id: expect.any(String),
item_id: expect.any(String),
},
],
},
order: orderSnap,
})
})
test("swap shipment created data", async () => {
await simpleStoreFactory(dbConnection)
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const shippingOut = await simpleShippingOptionFactory(dbConnection, {
region_id: "test-region",
price: 500,
})
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/swaps`,
{
additional_items: [{ variant_id: "variant-2", quantity: 1 }],
return_items: [{ item_id: "test-item", quantity: 1 }],
},
{ headers: { "x-medusa-access-token": "test_token" } }
)
expect(response.status).toEqual(200)
const swapId = response.data.order.swaps[0].id
const cartId = response.data.order.swaps[0].cart_id
await api.post(`/store/carts/${cartId}`, {
shipping_address: {
address_1: "121 W Something St",
postal_code: "1234",
province: "something",
city: "ville la something",
phone: "12353245",
},
})
await api.post(`/store/carts/${cartId}/shipping-methods`, {
option_id: shippingOut.id,
})
await api.post(`/store/carts/${cartId}/payment-sessions`)
await api.post(`/store/carts/${cartId}/complete`)
const { data: fulfillmentData } = await api.post(
`/admin/orders/${order.id}/swaps/${swapId}/fulfillments`,
{},
{ headers: { "x-medusa-access-token": "test_token" } }
)
const fulfillmentId = fulfillmentData.order.swaps[0].fulfillments[0].id
await api.post(
`/admin/orders/${order.id}/swaps/${swapId}/shipments`,
{ fulfillment_id: fulfillmentId },
{ headers: { "x-medusa-access-token": "test_token" } }
)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("swap.shipment_created", {
id: swapId,
fulfillment_id: fulfillmentId,
})
const itemSnap = {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_edit_id: null,
original_item_id: null,
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
tax_lines: [
{
id: expect.any(String),
item_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
}
const swapSnap = {
id: expect.any(String),
cart_id: expect.any(String),
order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
confirmed_at: expect.any(Date),
idempotency_key: expect.any(String),
shipping_address_id: expect.any(String),
additional_items: [
{
swap_id: expect.any(String),
cart_id: expect.any(String),
...itemSnap,
},
],
}
expect(data).toMatchSnapshot({
date: expect.any(String),
swap: {
...swapSnap,
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
shipping_methods: [
{
id: expect.any(String),
cart_id: expect.any(String),
swap_id: expect.any(String),
shipping_option: {
id: expect.any(String),
profile_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
shipping_option_id: expect.any(String),
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
shipping_method_id: expect.any(String),
},
],
},
],
return_order: {
id: expect.any(String),
swap_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
items: [
{
return_id: expect.any(String),
},
],
},
},
fulfillment: {
id: expect.any(String),
created_at: expect.any(Date),
shipped_at: expect.any(Date),
updated_at: expect.any(Date),
swap_id: expect.any(String),
items: [
{
fulfillment_id: expect.any(String),
item_id: expect.any(String),
},
],
},
order: {
display_id: expect.any(Number),
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
items: [{ order_id: expect.any(String), ...itemSnap }],
customer_id: expect.any(String),
shipping_address_id: expect.any(String),
sales_channel_id: null,
swaps: [swapSnap],
region: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
items: [
{
swap_id: expect.any(String),
cart_id: expect.any(String),
...itemSnap,
},
],
})
})
test("return requested data", async () => {
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/return`,
{
items: [{ item_id: "test-item", quantity: 1 }],
},
{
headers: {
"x-medusa-access-token": "test_token",
},
}
)
expect(response.status).toEqual(200)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("order.return_requested", {
id: response.data.order.id,
return_id: response.data.order.returns[0].id,
})
const returnSnap = getReturnSnap()
expect(data).toMatchSnapshot(returnSnap)
})
test("swap created data", async () => {
await simpleStoreFactory(dbConnection)
await adminSeeder(dbConnection)
const order = await createReturnableOrder(dbConnection)
const api = useApi()
const response = await api.post(
`/admin/orders/${order.id}/swaps`,
{
additional_items: [{ variant_id: "variant-2", quantity: 1 }],
return_items: [{ item_id: "test-item", quantity: 1 }],
},
{
headers: {
"x-medusa-access-token": "test_token",
},
}
)
expect(response.status).toEqual(200)
const sendgridService = appContainer.resolve("sendgridService")
const data = await sendgridService.fetchData("swap.created", {
id: response.data.order.swaps[0].id,
})
expect(data.return_total).toMatchSnapshot()
expect(data.refund_amount).toMatchSnapshot()
expect(data.additional_total).toMatchSnapshot()
})
})
const getReturnSnap = (received = false) => {
const itemSnap = {
id: expect.any(String),
order_id: expect.any(String),
order_edit_id: null,
original_item_id: null,
created_at: expect.any(Date),
updated_at: expect.any(Date),
variant: {
created_at: expect.any(Date),
updated_at: expect.any(Date),
product: {
profile_id: expect.any(String),
profile: expect.any(Object),
profiles: expect.any(Array),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
}
return {
date: expect.any(String),
order: {
display_id: expect.any(Number),
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
items: [itemSnap],
customer_id: expect.any(String),
shipping_address_id: expect.any(String),
returns: [
{
id: expect.any(String),
received_at: received ? expect.any(Date) : null,
order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
idempotency_key: expect.any(String),
items: [
{
return_id: expect.any(String),
},
],
},
],
shipping_address: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
region: {
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
},
return_request: {
id: expect.any(String),
received_at: received ? expect.any(Date) : null,
order_id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
idempotency_key: expect.any(String),
items: [
{
return_id: expect.any(String),
item: itemSnap,
},
],
},
items: [
{
...itemSnap,
totals: {
tax_lines: [
{
id: expect.any(String),
created_at: expect.any(Date),
updated_at: expect.any(Date),
},
],
},
},
],
}
}
const createReturnableOrder = async (dbConnection, options = {}) => {
await simpleProductFactory(
dbConnection,
{
id: "test-product",
variants: [
{ id: "test-variant" },
{ id: "variant-2", prices: [{ currency: "usd", amount: 1000 }] },
],
},
100
)
let discounts = []
if (options.discount) {
discounts = [
{
code: "TESTCODE",
},
]
}
return await simpleOrderFactory(dbConnection, {
email: "test@testson.com",
tax_rate: null,
fulfillment_status: "fulfilled",
payment_status: "captured",
shipping_methods: options.notShipped
? [
{
price: 0,
shipping_option: { name: "free", region_id: "test-region" },
},
]
: [],
region: {
id: "test-region",
name: "Test region",
tax_rate: 12.5, // Should be ignored due to item tax line
},
discounts,
line_items: [
{
id: "test-item",
variant_id: "test-variant",
quantity: 2,
fulfilled_quantity: options.notShipped ? 0 : 2,
shipped_quantity: options.notShipped ? 0 : 2,
unit_price: 1000,
tax_lines: [
{
name: "default",
code: "default",
rate: 20,
},
],
},
],
})
}

View File

@@ -11,23 +11,7 @@ process.env.LOG_LEVEL = "error"
const enableMedusaV2 = process.env.MEDUSA_FF_MEDUSA_V2 == "true"
module.exports = {
plugins: [
{
resolve: `medusa-fulfillment-webshipper`,
options: {
account: "test-account",
api_token: "something",
order_channel_id: "1",
webhook_secret: "1234",
},
},
{
resolve: `medusa-plugin-sendgrid`,
options: {
api_key: "SG.TEST",
},
},
],
plugins: [],
projectConfig: {
// redis_url: REDIS_URL,
database_url: DB_URL,

View File

@@ -30,9 +30,7 @@
"@medusajs/utils": "workspace:^",
"@medusajs/workflow-engine-inmemory": "workspace:*",
"faker": "^5.5.3",
"medusa-fulfillment-webshipper": "workspace:*",
"medusa-interfaces": "workspace:*",
"medusa-plugin-sendgrid": "workspace:*",
"pg": "^8.11.0",
"typeorm": "^0.3.16"
},

View File

@@ -1,13 +0,0 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes"
],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}

View File

@@ -1,13 +0,0 @@
/lib
node_modules
.DS_store
.env*
/*.js
!index.js
yarn.lock
/api
/services
/models
/subscribers

View File

@@ -1,8 +0,0 @@
.DS_store
src
dist
yarn.lock
.babelrc
.turbo
.yarn

View File

@@ -1,261 +0,0 @@
# Change Log
## 1.1.40
### Patch Changes
- Updated dependencies [[`8f8a4f9b13`](https://github.com/medusajs/medusa/commit/8f8a4f9b1353087d98f6cc75346d43a7f49901a8)]:
- medusa-interfaces@1.3.9
## 1.1.39
### Patch Changes
- Updated dependencies [[`45996d58a2`](https://github.com/medusajs/medusa/commit/45996d58a2665d72335faad11bea958f8da74195), [`f86877586`](https://github.com/medusajs/medusa/commit/f86877586147ecedbf7f56a1c57f37ef0c33286c), [`46d610bc5`](https://github.com/medusajs/medusa/commit/46d610bc555797df2ae81eb89b18faf1411b33b8)]:
- medusa-interfaces@1.3.8
- medusa-core-utils@1.2.1
## 1.1.38
### Patch Changes
- [#4221](https://github.com/medusajs/medusa/pull/4221) [`109096465`](https://github.com/medusajs/medusa/commit/109096465dacdc5879a816a56ef4f2d7a9927e1a) Thanks [@josipmatichr](https://github.com/josipmatichr)! - fix(medusa-fulfillment-manual): Missing retrieveDocuments override
## 1.1.37
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
## 1.1.37-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
## 1.1.36
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.1.35
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.1.34
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.1.33
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
## 1.1.32
### Patch Changes
- [#1962](https://github.com/medusajs/medusa/pull/1962) [`c97ccd3fb`](https://github.com/medusajs/medusa/commit/c97ccd3fb5dbe796b0e4fbf37def5bb6e8201557) Thanks [@pKorsholm](https://github.com/pKorsholm)! - Convert FulfillmentService to TypeScript
- Updated dependencies [[`c97ccd3fb`](https://github.com/medusajs/medusa/commit/c97ccd3fb5dbe796b0e4fbf37def5bb6e8201557)]:
- medusa-interfaces@1.3.3
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.30...medusa-fulfillment-manual@1.1.31) (2021-12-08)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.29...medusa-fulfillment-manual@1.1.30) (2021-11-23)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.28...medusa-fulfillment-manual@1.1.29) (2021-11-22)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.27...medusa-fulfillment-manual@1.1.28) (2021-11-19)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.26...medusa-fulfillment-manual@1.1.27) (2021-11-19)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.25...medusa-fulfillment-manual@1.1.26) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.24...medusa-fulfillment-manual@1.1.25) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.22...medusa-fulfillment-manual@1.1.24) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.22...medusa-fulfillment-manual@1.1.23) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.21...medusa-fulfillment-manual@1.1.22) (2021-09-15)
**Note:** Version bump only for package medusa-fulfillment-manual
## [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.1.19](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.18...medusa-fulfillment-manual@1.1.19) (2021-07-26)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.16...medusa-fulfillment-manual@1.1.18) (2021-07-15)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.16...medusa-fulfillment-manual@1.1.17) (2021-07-15)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.15...medusa-fulfillment-manual@1.1.16) (2021-07-02)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.14...medusa-fulfillment-manual@1.1.15) (2021-06-22)
### Bug Fixes
- Adds manual return option ([#290](https://github.com/medusajs/medusa/issues/290)) ([350603a](https://github.com/medusajs/medusa/commit/350603ac579027bd96d6855b9a78750a46d857a3))
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.13...medusa-fulfillment-manual@1.1.14) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.12...medusa-fulfillment-manual@1.1.13) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.11...medusa-fulfillment-manual@1.1.12) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.10...medusa-fulfillment-manual@1.1.11) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.9...medusa-fulfillment-manual@1.1.10) (2021-06-08)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.6...medusa-fulfillment-manual@1.1.9) (2021-04-28)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.7...medusa-fulfillment-manual@1.1.8) (2021-04-20)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.6...medusa-fulfillment-manual@1.1.7) (2021-04-20)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.5...medusa-fulfillment-manual@1.1.6) (2021-04-13)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.4...medusa-fulfillment-manual@1.1.5) (2021-04-09)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.3...medusa-fulfillment-manual@1.1.4) (2021-03-30)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.2...medusa-fulfillment-manual@1.1.3) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.0...medusa-fulfillment-manual@1.1.2) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.0...medusa-fulfillment-manual@1.1.1) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-manual
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.0.12...medusa-fulfillment-manual@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-fulfillment-manual
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.0.11...medusa-fulfillment-manual@1.0.12) (2020-11-24)
**Note:** Version bump only for package medusa-fulfillment-manual
## 1.0.11 (2020-10-06)
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,50 +0,0 @@
# Manual Fulfillment
A minimal fulfillment provider that allows merchants to handle fulfillments manually.
[Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Provides a restriction-free fulfillment provider that can be used during checkout and while processing orders.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-fulfillment-manual
```
2\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
`medusa-fulfillment-manual`
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Enable the fulfillment provider in the admin. You can refer to [this User Guide](https://docs.medusajs.com/user-guide/regions/providers) to learn how to do that. Alternatively, you can use the [Admin APIs](https://docs.medusajs.com/api/admin#tag/Region/operation/PostRegionsRegion).
3\. Add shipping options for the fulfillment provider. You can do that using either the [Medusa Admin](../../user-guide/regions/shipping-options.mdx) or the [Admin REST APIs](../../modules/regions-and-currencies/admin/manage-regions.mdx#add-a-shipping-option-to-a-region).
3\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should be able to use the manual fulfillment provider during checkout.

View File

@@ -1 +0,0 @@
// noop

View File

@@ -1,49 +0,0 @@
{
"name": "medusa-fulfillment-manual",
"version": "1.1.40",
"description": "A manual fulfillment provider for Medusa",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-fulfillment-manual"
},
"engines": {
"node": ">=16"
},
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.9"
},
"scripts": {
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"prepare": "cross-env NODE_ENV=production yarn run build"
},
"peerDependencies": {
"medusa-interfaces": "1.3.9"
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/runtime": "^7.7.6",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.1"
},
"gitHead": "7770046479c361f375842a8605b15e5d7bc24624",
"keywords": [
"medusa-plugin",
"medusa-plugin-fulfillment"
]
}

View File

@@ -1,62 +0,0 @@
import { FulfillmentService } from "medusa-interfaces"
class ManualFulfillmentService extends FulfillmentService {
static identifier = "manual"
constructor() {
super()
}
getFulfillmentOptions() {
return [
{
id: "manual-fulfillment",
},
{
id: "manual-fulfillment-return",
is_return: true,
},
]
}
validateFulfillmentData(_, data, cart) {
return data
}
validateOption(data) {
return true
}
canCalculate() {
return false
}
calculatePrice() {
throw Error("Manual Fulfillment service cannot calculatePrice")
}
createOrder() {
// No data is being sent anywhere
return Promise.resolve({})
}
createReturn() {
// No data is being sent anywhere
return Promise.resolve({})
}
createFulfillment() {
// No data is being sent anywhere
return Promise.resolve({})
}
cancelFulfillment() {
return Promise.resolve({})
}
retrieveDocuments() {
return Promise.resolve([])
}
}
export default ManualFulfillmentService

View File

@@ -1,13 +0,0 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes"
],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}

View File

@@ -1,14 +0,0 @@
/lib
node_modules
.DS_store
.env*
/*.js
!index.js
yarn.lock
/api
/services
/models
/subscribers
/utils

View File

@@ -1,8 +0,0 @@
.DS_store
src
dist
yarn.lock
.babelrc
.turbo
.yarn

View File

@@ -1,366 +0,0 @@
# Change Log
## 1.4.2
### Patch Changes
- [#5869](https://github.com/medusajs/medusa/pull/5869) [`45996d58a2`](https://github.com/medusajs/medusa/commit/45996d58a2665d72335faad11bea958f8da74195) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa, interfaces, utils, webshiper): Uniformise class checks
- Updated dependencies [[`42cc8ae3f`](https://github.com/medusajs/medusa/commit/42cc8ae3f89ed7d642e51654d1a3cca011f13155), [`45996d58a2`](https://github.com/medusajs/medusa/commit/45996d58a2665d72335faad11bea958f8da74195), [`9cc787cac4`](https://github.com/medusajs/medusa/commit/9cc787cac4bf1c5d8edf1c4b548bb3205100e822), [`355075097`](https://github.com/medusajs/medusa/commit/3550750975a0c9359fd887929377733606ef03af), [`f86877586`](https://github.com/medusajs/medusa/commit/f86877586147ecedbf7f56a1c57f37ef0c33286c), [`fbee006e5`](https://github.com/medusajs/medusa/commit/fbee006e512ef2d56ffb23eeabad8b51b56be285), [`c41f3002f`](https://github.com/medusajs/medusa/commit/c41f3002f3118b1f195c5c822fe0f400091d115b), [`46d610bc5`](https://github.com/medusajs/medusa/commit/46d610bc555797df2ae81eb89b18faf1411b33b8), [`d16d10619`](https://github.com/medusajs/medusa/commit/d16d10619dfbd3966a4709753de3d8cc37c6f2eb), [`890e76a5c`](https://github.com/medusajs/medusa/commit/890e76a5c53039576c42ca4d46af6f6977cdebd1), [`fe007d01b`](https://github.com/medusajs/medusa/commit/fe007d01bd827f0e09ee545e48cef18913540c68), [`76332ca6c`](https://github.com/medusajs/medusa/commit/76332ca6c153a786acc07d3f06ff45c3b9346fd3)]:
- @medusajs/utils@1.11.3
- medusa-core-utils@1.2.1
## 1.4.1
### Patch Changes
- [#5543](https://github.com/medusajs/medusa/pull/5543) [`f90ba0208`](https://github.com/medusajs/medusa/commit/f90ba02087778d8131aed3a59a6dc9c8ca3c95f4) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(utils): Introduce promiseAll util
- Updated dependencies [[`c39bf69a5`](https://github.com/medusajs/medusa/commit/c39bf69a5e5cae75d7fa12aa6022b10903557a32), [`154c9b43b`](https://github.com/medusajs/medusa/commit/154c9b43bde1fdff562aba9da8a79af2660b29b3)]:
- @medusajs/utils@1.10.5
## 1.4.0
### Minor Changes
- [#4922](https://github.com/medusajs/medusa/pull/4922) [`17d91c276`](https://github.com/medusajs/medusa/commit/17d91c276a68de4d2b360335f32fcce48a16c9ec) Thanks [@olivermrbl](https://github.com/olivermrbl)! - [wip] feat(medusa): Add AbstractFulfillmentService
### Patch Changes
- [#4846](https://github.com/medusajs/medusa/pull/4846) [`c7b149a7b`](https://github.com/medusajs/medusa/commit/c7b149a7bc87dc4df1c78edccb36b45f19ee8e36) Thanks [@josipmatichr](https://github.com/josipmatichr)! - feat(medusa-fulfillment-webshipper): Create webshipper return order
## 1.3.10
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
## 1.3.9
### Patch Changes
- [#3879](https://github.com/medusajs/medusa/pull/3879) [`7e213f210`](https://github.com/medusajs/medusa/commit/7e213f2106ed76449fbdfa6eda5594b59522443a) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix(medusa,medusa-fulfillment-webshipper): Add missing variant + product relation on items
## 1.3.8
### Patch Changes
- [#3685](https://github.com/medusajs/medusa/pull/3685) [`8ddb3952c`](https://github.com/medusajs/medusa/commit/8ddb3952c045e6c05c8d0f6922f0d4ba30cf3bd4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Fix RC package versions
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
## 1.3.8-rc.1
### Patch Changes
- chore: Fix RC package versions
## 1.3.8-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
## 1.3.7
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.3.6
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.3.5
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.3.4
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.3](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.3.2...medusa-fulfillment-webshipper@1.3.3) (2022-07-05)
### Bug Fixes
- **webshipper:** allow cancelling WS orders with error status ([#1755](https://github.com/medusajs/medusa/issues/1755)) ([1d3032d](https://github.com/medusajs/medusa/commit/1d3032dc671b477654afd13a218caa772454bde0))
- **webshipper:** only add invoices if invoice generator produces a file ([#1749](https://github.com/medusajs/medusa/issues/1749)) ([c0e18d4](https://github.com/medusajs/medusa/commit/c0e18d473c050d143f67ed2c76fa9ec9414daf1a))
## [1.3.2](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.3.0...medusa-fulfillment-webshipper@1.3.2) (2022-06-19)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.3.1](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.3.0...medusa-fulfillment-webshipper@1.3.1) (2022-05-31)
**Note:** Version bump only for package medusa-fulfillment-webshipper
# [1.3.0](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.2.1...medusa-fulfillment-webshipper@1.3.0) (2022-05-01)
### Features
- Add DiscountConditions ([#1230](https://github.com/medusajs/medusa/issues/1230)) ([a610805](https://github.com/medusajs/medusa/commit/a610805917ee930d4cebde74905e541a468aa83b)), closes [#1146](https://github.com/medusajs/medusa/issues/1146) [#1149](https://github.com/medusajs/medusa/issues/1149) [#1156](https://github.com/medusajs/medusa/issues/1156) [#1170](https://github.com/medusajs/medusa/issues/1170) [#1172](https://github.com/medusajs/medusa/issues/1172) [#1212](https://github.com/medusajs/medusa/issues/1212) [#1224](https://github.com/medusajs/medusa/issues/1224) [#1228](https://github.com/medusajs/medusa/issues/1228)
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.35...medusa-fulfillment-webshipper@1.2.1) (2022-02-28)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([47588e7](https://github.com/medusajs/medusa/commit/47588e7a8d3b2ae2fed0c1e87fdf1ee2db6bcdc2)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.35...medusa-fulfillment-webshipper@1.2.0) (2022-02-25)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([c56660f](https://github.com/medusajs/medusa/commit/c56660fca9921a3f3637bc137d9794781c5b090f)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.34...medusa-fulfillment-webshipper@1.1.35) (2021-12-08)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.33...medusa-fulfillment-webshipper@1.1.34) (2021-11-23)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.32...medusa-fulfillment-webshipper@1.1.33) (2021-11-22)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.31...medusa-fulfillment-webshipper@1.1.32) (2021-11-19)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.30...medusa-fulfillment-webshipper@1.1.31) (2021-11-19)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.29...medusa-fulfillment-webshipper@1.1.30) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.28...medusa-fulfillment-webshipper@1.1.29) (2021-10-18)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.26...medusa-fulfillment-webshipper@1.1.28) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.26...medusa-fulfillment-webshipper@1.1.27) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.25...medusa-fulfillment-webshipper@1.1.26) (2021-09-15)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [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.1.23](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.22...medusa-fulfillment-webshipper@1.1.23) (2021-07-26)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.20...medusa-fulfillment-webshipper@1.1.22) (2021-07-15)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.20...medusa-fulfillment-webshipper@1.1.21) (2021-07-15)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.19...medusa-fulfillment-webshipper@1.1.20) (2021-07-02)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.18...medusa-fulfillment-webshipper@1.1.19) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.17...medusa-fulfillment-webshipper@1.1.18) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.16...medusa-fulfillment-webshipper@1.1.17) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.15...medusa-fulfillment-webshipper@1.1.16) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.14...medusa-fulfillment-webshipper@1.1.15) (2021-06-09)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.13...medusa-fulfillment-webshipper@1.1.14) (2021-06-08)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.12...medusa-fulfillment-webshipper@1.1.13) (2021-05-05)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.9...medusa-fulfillment-webshipper@1.1.12) (2021-04-28)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.10...medusa-fulfillment-webshipper@1.1.11) (2021-04-20)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.9...medusa-fulfillment-webshipper@1.1.10) (2021-04-20)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.8...medusa-fulfillment-webshipper@1.1.9) (2021-04-13)
### Bug Fixes
- gitignore ([fa1fe9d](https://github.com/medusajs/medusa/commit/fa1fe9d619e19a277db6ee3a25ebb177222fa04b))
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
### Features
- adds support for certificate of origin ([f21dae8](https://github.com/medusajs/medusa/commit/f21dae827ad64522fd1f4d6317740c6b0ded0536))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.7...medusa-fulfillment-webshipper@1.1.8) (2021-04-13)
### Bug Fixes
- gitignore ([fa1fe9d](https://github.com/medusajs/medusa/commit/fa1fe9d619e19a277db6ee3a25ebb177222fa04b))
### Features
- adds support for certificate of origin ([f21dae8](https://github.com/medusajs/medusa/commit/f21dae827ad64522fd1f4d6317740c6b0ded0536))
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.6...medusa-fulfillment-webshipper@1.1.7) (2021-03-30)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.5...medusa-fulfillment-webshipper@1.1.6) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.3...medusa-fulfillment-webshipper@1.1.5) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.3...medusa-fulfillment-webshipper@1.1.4) (2021-03-17)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.3-next.0...medusa-fulfillment-webshipper@1.1.3) (2021-02-25)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.1.3-next.0](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.2...medusa-fulfillment-webshipper@1.1.3-next.0) (2021-02-22)
### Features
- **medusa:** tracking links ([#177](https://github.com/medusajs/medusa/issues/177)) ([99ad43b](https://github.com/medusajs/medusa/commit/99ad43bf47c3922f391d433448b1c4affd88f457))
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.1...medusa-fulfillment-webshipper@1.1.2) (2021-02-17)
### Features
- notifications ([#172](https://github.com/medusajs/medusa/issues/172)) ([7308946](https://github.com/medusajs/medusa/commit/7308946e567ed4e63e1ed3d9d31b30c4f1a73f0d))
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.0...medusa-fulfillment-webshipper@1.1.1) (2021-02-03)
### Features
- **medusa,brightpearl,segment,webshipper:** claims ([#163](https://github.com/medusajs/medusa/issues/163)) ([690d339](https://github.com/medusajs/medusa/commit/690d33966754a7dbe159c3ac09712a3c3bfaff0b))
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.11...medusa-fulfillment-webshipper@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.11](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.10...medusa-fulfillment-webshipper@1.0.11) (2020-11-24)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.10](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.9...medusa-fulfillment-webshipper@1.0.10) (2020-11-13)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.9](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.8...medusa-fulfillment-webshipper@1.0.9) (2020-10-21)
### Bug Fixes
- **medusa-fulfillment-webshipper:** adds return customs_lines ([#130](https://github.com/medusajs/medusa/issues/130)) ([3b1f142](https://github.com/medusajs/medusa/commit/3b1f1422757f374efa8f3af99046753473d3f745))
## [1.0.8](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.7...medusa-fulfillment-webshipper@1.0.8) (2020-10-15)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.7](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.6...medusa-fulfillment-webshipper@1.0.7) (2020-10-15)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.6](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.5...medusa-fulfillment-webshipper@1.0.6) (2020-10-14)
### Features
- return shipping and flow ([#125](https://github.com/medusajs/medusa/issues/125)) ([c1e821d](https://github.com/medusajs/medusa/commit/c1e821d9d4d33756c7309e5cf110d7aa9b67297d))
## [1.0.5](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.4...medusa-fulfillment-webshipper@1.0.5) (2020-10-06)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.4](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.3...medusa-fulfillment-webshipper@1.0.4) (2020-10-06)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.3](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.2...medusa-fulfillment-webshipper@1.0.3) (2020-10-06)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## [1.0.2](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.0.1...medusa-fulfillment-webshipper@1.0.2) (2020-10-05)
**Note:** Version bump only for package medusa-fulfillment-webshipper
## 1.0.1 (2020-10-05)
### Features
- webshipper ([#118](https://github.com/medusajs/medusa/issues/118)) ([893a7f6](https://github.com/medusajs/medusa/commit/893a7f69afea67e854a67fc3b92c8a10c9c1b75c))

View File

@@ -1,105 +0,0 @@
# Webshipper
Handle order fulfillments using Webshipper.
[Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Webshipper can be used as a shipping option during checkouts and for handling order fulfillment.
- Sync order details and updates with Webshipper.
- Support for Webshipper webhooks.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Webshipper Account](https://webshipper.com)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-fulfillment-webshipper
```
2\. Set the following environment variables in `.env`:
```bash
WEBSHIPPER_ACCOUNT=<YOUR_WEBSHIPPER_ACCOUNT>
WEBSHIPPER_API_TOKEN=<YOUR_WEBSHIPPER_API_TOKEN>
WEBSHIPPER_ORDER_CHANNEL_ID=<YOUR_WEBSHIPPER_ORDER_CHANNEL_ID>
WEBSHIPPER_WEBHOOK_SECRET=<YOUR_WEBSHIPPER_WEBHOOK_SECRET>
WEBSHIPPER_COO_COUNTRIES=<WEBSHIPPER_COO_COUNTRIES>
WEBSHIPPER_DELETE_ON_CANCEL=<WEBSHIPPER_DELETE_ON_CANCEL>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
{
resolve: `medusa-fulfillment-webshipper`,
options: {
account: process.env.WEBSHIPPER_ACCOUNT, // required
api_token: process.env.WEBSHIPPER_API_TOKEN, // required
order_channel_id: process.env.WEBSHIPPER_ORDER_CHANNEL_ID, // required, the channel id to register orders on
webhook_secret: process.env.WEBSHIPPER_WEBHOOK_SECRET, // required, the webhook secret used to listen for shipments
coo_countries: process.env.WEBSHIPPER_COO_COUNTRIES, // default: "all", an array of countries or a string of one country in which a Certificate of Origin will be attached
delete_on_cancel: process.env.WEBSHIPPER_DELETE_ON_CANCEL, // default: false, determines whether Webshipper orders are deleted when a Medusa fulfillment is canceled
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Enable the fulfillment provider in the admin. You can refer to [this User Guide](https://docs.medusajs.com/user-guide/regions/providers) to learn how to do that. Alternatively, you can use the [Admin APIs](https://docs.medusajs.com/api/admin#tag/Region/operation/PostRegionsRegion).
3\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should be able to use the manual fulfillment provider during checkout.
---
## Additional Details
### Personal Customs Numbers
In countries like South Korea, a personal customs number is required to clear customs. The Webshipper fulfillment plugin is able pass this information to Webshipper given that the number is stored in `order.shipping_address.metadata.personal_customs_no`.
#### Modifications in Checkout Flow
To pass the information along you should dynamically show an input field to the customer when they are shopping from a region that requires a personal customs number, and make sure that the metadata field is set when updating the cart shipping address.
```js
const onUpdateAddress = async () => {
const address = {
first_name: "John",
last_name: "Johnson",
...,
metadata: {
personal_customs_no: "my-customs-number"
}
}
await medusaClient.carts
.update(cartId, {
shipping_address: address
})
.then(() => {
console.log("Good stuff - Webshipper will pass along the customs number")
})
}
```

View File

@@ -1 +0,0 @@
// noop

View File

@@ -1,53 +0,0 @@
{
"name": "medusa-fulfillment-webshipper",
"version": "1.4.2",
"description": "Webshipper Fulfillment provider for Medusa",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-fulfillment-webshipper"
},
"engines": {
"node": ">=16"
},
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-instanceof": "^7.12.13",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/runtime": "^7.9.6",
"@medusajs/medusa": "^1.19.1",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.8"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"@medusajs/medusa": "^1.12.0",
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"@medusajs/utils": "^1.11.3",
"axios": "^0.20.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.1"
},
"gitHead": "7770046479c361f375842a8605b15e5d7bc24624",
"keywords": [
"medusa-plugin",
"medusa-plugin-fulfillment"
]
}

View File

@@ -1,76 +0,0 @@
import { Router } from "express"
import bodyParser from "body-parser"
import crypto from "crypto"
import cors from "cors"
import { getConfigFile, parseCorsOrigins } from "medusa-core-utils"
export default (rootDirectory) => {
const app = Router()
const { configModule } = getConfigFile(rootDirectory, "medusa-config")
const { projectConfig } = configModule
const corsOptions = {
origin: parseCorsOrigins(projectConfig.store_cors),
credentials: true,
}
app.options("/webshipper/drop-points/:rate_id", cors(corsOptions))
app.get(
"/webshipper/drop-points/:rate_id",
cors(corsOptions),
async (req, res) => {
const { rate_id } = req.params
const { address_1, postal_code, country_code } = req.query
try {
const webshipperService = req.scope.resolve(
"webshipperFulfillmentService"
)
const dropPoints = await webshipperService.retrieveDropPoints(
rate_id,
postal_code,
country_code,
address_1
)
res.json({
drop_points: dropPoints,
})
} catch (err) {
res.json({ drop_points: [] })
}
}
)
app.post(
"/webshipper/shipments",
bodyParser.raw({ type: "application/vnd.api+json" }),
async (req, res) => {
const webshipperService = req.scope.resolve(
"webshipperFulfillmentService"
)
const eventBus = req.scope.resolve("eventBusService")
const logger = req.scope.resolve("logger")
const secret = webshipperService.options_.webhook_secret
const hmac = crypto.createHmac("sha256", secret)
const digest = hmac.update(req.body).digest("base64")
const hash = req.header("x-webshipper-hmac-sha256")
if (hash === digest) {
eventBus.emit("webshipper.shipment", {
headers: req.headers,
body: JSON.parse(req.body),
})
} else {
logger.warn("Webshipper webhook could not be authenticated")
}
res.sendStatus(200)
}
)
return app
}

View File

@@ -1,327 +0,0 @@
import WebshipperFulfillmentService from "../webshipper-fulfillment"
describe("WebshipperFulfillmentService", () => {
const orderService = {
createShipment: jest.fn(),
}
const swapService = {
createShipment: jest.fn(),
}
const claimService = {
createShipment: jest.fn(),
}
const totalsService = {
getLineItemTotals: jest.fn().mockImplementation(() => {
return {
unit_price: 1000,
tax_lines: [
{
rate: 20,
},
],
}
}),
}
describe("handleWebhook", () => {
beforeEach(() => {
jest.clearAllMocks()
})
it("creates an order shipment", async () => {
const webshipper = new WebshipperFulfillmentService(
{
orderService,
claimService,
swapService,
},
{}
)
webshipper.retrieveRelationship = () => {
return {
data: {
attributes: {
ext_ref: "order_test.ful_test",
},
},
}
}
const body = {
data: {
attributes: {
tracking_links: [
{
url: "https://test/1134",
number: "12324245345",
},
{
url: "https://test/1234",
number: "12324245345",
},
],
},
relationships: {
order: {
id: "order",
},
},
},
}
await webshipper.handleWebhook("", body)
expect(claimService.createShipment).toHaveBeenCalledTimes(0)
expect(swapService.createShipment).toHaveBeenCalledTimes(0)
expect(orderService.createShipment).toHaveBeenCalledTimes(1)
expect(orderService.createShipment).toHaveBeenCalledWith(
"order_test",
"ful_test",
[
{
url: "https://test/1134",
tracking_number: "12324245345",
},
{
url: "https://test/1234",
tracking_number: "12324245345",
},
]
)
})
it("creates a claim shipment", async () => {
const webshipper = new WebshipperFulfillmentService(
{
orderService,
claimService,
swapService,
},
{}
)
webshipper.retrieveRelationship = () => {
return {
data: {
attributes: {
ext_ref: "claim_test.ful_test",
},
},
}
}
const body = {
data: {
attributes: {
tracking_links: [
{
url: "https://test/1134",
number: "12324245345",
},
{
url: "https://test/1234",
number: "12324245345",
},
],
},
relationships: {
order: {
id: "order",
},
},
},
}
await webshipper.handleWebhook("", body)
expect(orderService.createShipment).toHaveBeenCalledTimes(0)
expect(swapService.createShipment).toHaveBeenCalledTimes(0)
expect(claimService.createShipment).toHaveBeenCalledTimes(1)
expect(claimService.createShipment).toHaveBeenCalledWith(
"claim_test",
"ful_test",
[
{
url: "https://test/1134",
tracking_number: "12324245345",
},
{
url: "https://test/1234",
tracking_number: "12324245345",
},
]
)
})
it("creates a swap shipment", async () => {
const webshipper = new WebshipperFulfillmentService(
{
orderService,
claimService,
swapService,
},
{}
)
webshipper.retrieveRelationship = () => {
return {
data: {
attributes: {
ext_ref: "swap_test.ful_test",
},
},
}
}
const body = {
data: {
attributes: {
tracking_links: [
{
url: "https://test/1134",
number: "12324245345",
},
{
url: "https://test/1234",
number: "12324245345",
},
],
},
relationships: {
order: {
id: "order",
},
},
},
}
await webshipper.handleWebhook("", body)
expect(orderService.createShipment).toHaveBeenCalledTimes(0)
expect(claimService.createShipment).toHaveBeenCalledTimes(0)
expect(swapService.createShipment).toHaveBeenCalledTimes(1)
expect(swapService.createShipment).toHaveBeenCalledWith(
"swap_test",
"ful_test",
[
{
url: "https://test/1134",
tracking_number: "12324245345",
},
{
url: "https://test/1234",
tracking_number: "12324245345",
},
]
)
})
})
describe("buildWebshipperItem", () => {
beforeEach(() => {
jest.clearAllMocks()
})
const medusaItem = {
id: "item_id",
title: "item_title",
quantity: 1,
}
const order = {
currency_code: "dkk",
}
it("builds a webshipper item", async () => {
const webshipper = new WebshipperFulfillmentService(
{
totalsService,
},
{}
)
let item
try {
item = await webshipper.buildWebshipperItem(medusaItem, 1, order)
} catch (error) {
console.log(error)
}
expect(item).toEqual({
ext_ref: "item_id",
description: "item_title",
quantity: 1,
unit_price: 10,
vat_percent: 20,
})
})
it("builds a webshipper item with additional props from variant", async () => {
const webshipper = new WebshipperFulfillmentService(
{
totalsService,
},
{}
)
medusaItem.variant = {}
medusaItem.variant.origin_country = "DK"
medusaItem.variant.sku = "sku"
medusaItem.variant.hs_code = "hs"
let item
try {
item = await webshipper.buildWebshipperItem(medusaItem, 1, order)
} catch (error) {
console.log(error)
}
expect(item).toEqual({
ext_ref: "item_id",
description: "item_title",
quantity: 1,
unit_price: 10,
vat_percent: 20,
country_of_origin: "DK",
sku: "sku",
tarif_number: "hs",
})
})
it("builds a webshipper item with additional props from product", async () => {
const webshipper = new WebshipperFulfillmentService(
{
totalsService,
},
{}
)
medusaItem.variant = {}
medusaItem.variant.product = {}
medusaItem.variant.product.origin_country = "DK"
medusaItem.variant.product.hs_code = "test"
let item
try {
item = await webshipper.buildWebshipperItem(medusaItem, 1, order)
} catch (error) {
console.log(error)
}
expect(item).toEqual({
ext_ref: "item_id",
description: "item_title",
quantity: 1,
unit_price: 10,
vat_percent: 20,
country_of_origin: "DK",
tarif_number: "test",
})
})
})
})

View File

@@ -1,706 +0,0 @@
import { humanizeAmount } from "medusa-core-utils"
import Webshipper from "../utils/webshipper"
import { AbstractFulfillmentService } from "@medusajs/medusa"
import { promiseAll } from "@medusajs/utils"
class WebshipperFulfillmentService extends AbstractFulfillmentService {
static identifier = "webshipper"
constructor(
{ logger, totalsService, claimService, swapService, orderService },
options
) {
super(...arguments)
this.options_ = options
if (!options.coo_countries) {
this.options_.coo_countries = ["all"]
} else if (Array.isArray(options.coo_countries)) {
this.options_.coo_countries = options.coo_countries.map((c) =>
c.toLowerCase()
)
} else if (typeof options.coo_countries === "string") {
this.options_.coo_countries = [options.coo_countries]
}
/** @private @const {logger} */
this.logger_ = logger
/** @private @const {OrderService} */
this.orderService_ = orderService
/** @private @const {TotalsService} */
this.totalsService_ = totalsService
/** @private @const {SwapService} */
this.swapService_ = swapService
/** @private @const {SwapService} */
this.claimService_ = claimService
/** @private @const {AxiosClient} */
this.client_ = new Webshipper({
account: this.options_.account,
token: this.options_.api_token,
})
}
registerInvoiceGenerator(service) {
if (typeof service.createInvoice === "function") {
this.invoiceGenerator_ = service
}
}
async getFulfillmentOptions() {
const rates = await this.client_.shippingRates.list({
order_channel_id: this.options_.order_channel_id,
})
return rates.data.map((r) => ({
id: r.attributes.name,
webshipper_id: r.id,
name: r.attributes.name,
require_drop_point: r.attributes.require_drop_point,
carrier_id: r.attributes.carrier_id,
is_return: r.attributes.is_return,
}))
}
async validateFulfillmentData(optionData, data, _) {
if (optionData.require_drop_point) {
if (!data.drop_point_id) {
throw new Error("Must have drop point id")
} else {
// TODO: validate that the drop point exists
}
}
return {
...optionData,
...data,
}
}
async validateOption(data) {
const rate = await this.client_.shippingRates
.retrieve(data.webshipper_id)
.catch(() => undefined)
return !!rate
}
canCalculate() {
// Return whether or not we are able to calculate dynamically
return false
}
calculatePrice() {
// Calculate prices
}
/**
* Creates a return order in webshipper and links it to an existing shipment.
*/
async createReturnOrder(shipment, fromOrder) {
const fulfillmentData = fromOrder.fulfillments[0]?.data
if (!shipment?.id || !fulfillmentData?.id) {
return
}
const customsLines = shipment.attributes?.packages?.[0]?.customs_lines
if (!customsLines?.length) {
return
}
const returnOrderData = {
type: "returns",
attributes: {
status: "pending",
return_lines: customsLines.map(({ ext_ref, quantity }) => ({
order_line_id: fulfillmentData.attributes?.order_lines?.find(
(order_line) => order_line.ext_ref === ext_ref
)?.id,
cause_id: this.options_.return_portal?.cause_id || "1",
quantity: quantity,
})),
},
relationships: {
order: {
data: {
id: fulfillmentData.id,
type: "orders",
},
},
portal: {
data: {
id: this.options_.return_portal.id || "1",
type: "return_portals",
},
},
refund_method: {
data: {
id: this.options_.return_portal.refund_method_id || "1",
type: "return_refund_methods",
},
},
shipping_method: {
data: {
id: shipment.shipping_method?.data?.webshipper_id || "1",
type: "return_shipping_methods",
},
},
shipment: {
data: {
id: shipment.id,
type: "shipments",
},
},
},
}
this.client_.returns.create(returnOrderData)
}
/**
* Creates a return shipment in webshipper using the given method data, and
* return lines.
*/
async createReturn(returnOrder) {
let orderId
if (returnOrder.order_id) {
orderId = returnOrder.order_id
} else if (returnOrder.swap) {
orderId = returnOrder.swap.order_id
} else if (returnOrder.claim_order) {
orderId = returnOrder.claim_order.order_id
}
const fromOrder = await this.orderService_.retrieve(orderId, {
select: ["total"],
relations: [
"discounts",
"discounts.rule",
"shipping_address",
"returns",
"fulfillments",
],
})
const methodData = returnOrder.shipping_method.data
const relationships = {
shipping_rate: {
data: {
type: "shipping_rates",
id: methodData.webshipper_id,
},
},
}
const existing =
fromOrder.metadata && fromOrder.metadata.webshipper_order_id
if (existing) {
relationships.order = {
data: {
type: "orders",
id: existing,
},
}
}
const docs = []
if (this.invoiceGenerator_) {
const base64Invoice = await this.invoiceGenerator_.createReturnInvoice(
fromOrder,
returnOrder.items
)
docs.push({
document_size: "A4",
document_format: "PDF",
base64: base64Invoice,
document_type: "invoice",
})
}
const { shipping_address } = fromOrder
const returnShipment = {
type: "shipments",
attributes: {
reference: `R${fromOrder.display_id}-${fromOrder.returns.length + 1}`,
ext_ref: `${fromOrder.id}.${returnOrder.id}`,
is_return: true,
included_documents: docs,
packages: [
{
weight: 500,
weight_unit: "g",
dimensions: {
unit: "cm",
height: 15,
width: 15,
length: 15,
},
customs_lines: await promiseAll(
returnOrder.items.map(async ({ item, quantity }) => {
const customLine = await this.buildWebshipperItem(
item,
quantity,
fromOrder
)
return {
...customLine,
currency: fromOrder.currency_code.toUpperCase(),
}
})
),
},
],
sender_address: {
att_contact: `${shipping_address.first_name} ${shipping_address.last_name}`,
// Some carriers require a company_name
company_name: `${shipping_address.first_name} ${shipping_address.last_name}`,
address_1: shipping_address.address_1,
address_2: shipping_address.address_2,
zip: shipping_address.postal_code,
city: shipping_address.city,
country_code: shipping_address.country_code.toUpperCase(),
state: shipping_address.province,
phone: shipping_address.phone,
email: fromOrder.email,
},
delivery_address: this.options_.return_address,
},
relationships,
}
return this.client_.shipments
.create(returnShipment)
.then((result) => {
if (this.options_.return_portal?.id) {
this.createReturnOrder(result.data, fromOrder)
}
return result.data
})
.catch((err) => {
this.logger_.warn(err.response)
throw err
})
}
async getReturnDocuments(data) {
const shipment = await this.client_.shipments.retrieve(data.id)
const labels = await this.retrieveRelationship(
shipment.data.relationships.labels
).then((res) => res.data)
const docs = await this.retrieveRelationship(
shipment.data.relationships.documents
).then((res) => res.data)
const toReturn = []
for (const d of labels) {
toReturn.push({
name: "Return label",
base_64: d.attributes.base64,
type: "pdf",
})
}
for (const d of docs) {
toReturn.push({
name: d.attributes.document_type,
base_64: d.attributes.base64,
type: "pdf",
})
}
return toReturn
}
async createFulfillment(
methodData,
fulfillmentItems,
fromOrder,
fulfillment
) {
const existing =
fromOrder.metadata && fromOrder.metadata.webshipper_order_id
let webshipperOrder
if (existing) {
webshipperOrder = await this.client_.orders.retrieve(existing)
}
const { shipping_address } = fromOrder
if (!webshipperOrder) {
let invoice
let certificateOfOrigin
if (this.invoiceGenerator_) {
const base64Invoice = await this.invoiceGenerator_.createInvoice(
fromOrder,
fulfillmentItems
)
if (base64Invoice) {
invoice = await this.client_.documents
.create({
type: "documents",
attributes: {
document_size: this.options_.document_size || "A4",
document_format: "PDF",
base64: base64Invoice,
document_type: "invoice",
},
})
.catch((err) => {
throw err
})
}
const cooCountries = this.options_.coo_countries
if (
(cooCountries.includes("all") ||
cooCountries.includes(
shipping_address.country_code.toLowerCase()
)) &&
this.invoiceGenerator_.createCertificateOfOrigin
) {
const base64Coo =
await this.invoiceGenerator_.createCertificateOfOrigin(
fromOrder,
fulfillmentItems
)
certificateOfOrigin = await this.client_.documents
.create({
type: "documents",
attributes: {
document_size: this.options_.document_size || "A4",
document_format: "PDF",
base64: base64Coo,
document_type: "certificate",
},
})
.catch((err) => {
throw err
})
}
}
const id = fulfillment.id
let visible_ref = `${fromOrder.display_id}-${id.substr(id.length - 4)}`
let ext_ref = `${fromOrder.id}.${fulfillment.id}`
if (fromOrder.is_swap) {
ext_ref = `${fromOrder.id}.${fulfillment.id}`
visible_ref = `S-${fromOrder.display_id}`
}
const newOrder = {
type: "orders",
attributes: {
status: "pending",
ext_ref,
visible_ref,
order_lines: await promiseAll(
fulfillmentItems.map(async (item) => {
const orderLine = await this.buildWebshipperItem(
item,
item.quantity,
fromOrder
)
return orderLine
})
),
delivery_address: {
att_contact: `${shipping_address.first_name} ${shipping_address.last_name}`,
address_1: shipping_address.address_1,
address_2: shipping_address.address_2,
zip: shipping_address.postal_code,
city: shipping_address.city,
country_code: shipping_address.country_code.toUpperCase(),
state: shipping_address.province,
phone: shipping_address.phone,
email: fromOrder.email,
personal_customs_no:
shipping_address.metadata?.personal_customs_no || null,
},
currency: fromOrder.currency_code.toUpperCase(),
},
relationships: {
order_channel: {
data: {
id: this.options_.order_channel_id,
type: "order_channels",
},
},
shipping_rate: {
data: {
id: methodData.webshipper_id,
type: "shipping_rates",
},
},
},
}
if (methodData.require_drop_point) {
newOrder.attributes.drop_point = {
drop_point_id: methodData.drop_point_id,
name: methodData.drop_point_name,
zip: methodData.drop_point_zip,
address_1: methodData.drop_point_address_1,
city: methodData.drop_point_city,
country_code: methodData.drop_point_country_code.toUpperCase(),
}
}
if (invoice || certificateOfOrigin) {
const docData = []
if (invoice) {
docData.push({
id: invoice.data.id,
type: invoice.data.type,
})
}
if (certificateOfOrigin) {
docData.push({
id: certificateOfOrigin.data.id,
type: certificateOfOrigin.data.type,
})
}
newOrder.relationships.documents = {
data: docData,
}
}
return this.client_.orders
.create(newOrder)
.then((result) => {
return result.data
})
.catch((err) => {
this.logger_.warn(err.response)
throw err
})
}
}
async handleWebhook(_, body) {
const wsOrder = await this.retrieveRelationship(
body.data.relationships.order
)
if (wsOrder.data && wsOrder.data.attributes.ext_ref) {
const trackingLinks = body.data.attributes.tracking_links.map((l) => ({
url: l.url,
tracking_number: l.number,
}))
const [orderId, fulfillmentIndex] =
wsOrder.data.attributes.ext_ref.split(".")
if (orderId.charAt(0).toLowerCase() === "s") {
if (fulfillmentIndex.startsWith("ful")) {
return this.swapService_.createShipment(
orderId,
fulfillmentIndex,
trackingLinks
)
} else {
const swap = await this.swapService_.retrieve(orderId.substring(1), {
relations: ["fulfillments"],
})
const fulfillment = swap.fulfillments[fulfillmentIndex]
return this.swapService_.createShipment(
swap.id,
fulfillment.id,
trackingLinks
)
}
} else if (orderId.charAt(0).toLowerCase() === "c") {
return this.claimService_.createShipment(
orderId,
fulfillmentIndex,
trackingLinks
)
} else {
if (fulfillmentIndex.startsWith("ful")) {
return this.orderService_.createShipment(
orderId,
fulfillmentIndex,
trackingLinks
)
} else {
const order = await this.orderService_.retrieve(orderId, {
relations: ["fulfillments"],
})
const fulfillment = order.fulfillments[fulfillmentIndex]
if (fulfillment) {
return this.orderService_.createShipment(
order.id,
fulfillment.id,
trackingLinks
)
}
}
}
}
}
async retrieveDocuments(fulfillmentData, documentType) {
const labelRelation = fulfillmentData?.relationships?.labels
const docRelation = fulfillmentData?.relationships?.documents
switch (documentType) {
case "label":
if (labelRelation) {
const docs = await this.retrieveRelationship(labelRelation)
.then(({ data }) => data)
.catch((_) => [])
return docs.map((d) => ({
name: d.attributes.document_type,
base_64: d.attributes.base64,
type: "application/pdf",
}))
}
return []
case "invoice":
if (docRelation) {
const docs = await this.retrieveRelationship(docRelation)
.then(({ data }) => data)
.catch((_) => [])
return docs.map((d) => ({
name: d.attributes.document_type,
base_64: d.attributes.base64,
type: "application/pdf",
}))
}
return []
default:
return []
}
}
async getFulfillmentDocuments(data) {
const order = await this.client_.orders.retrieve(data.id)
const docs = await this.retrieveRelationship(
order.data.relationships.documents
).then((res) => res.data)
return docs.map((d) => ({
name: d.attributes.document_type,
base_64: d.attributes.base64,
type: "pdf",
}))
}
async retrieveDropPoints(id, zip, countryCode, address1) {
const points = await this.client_
.request({
method: "POST",
url: `/v2/drop_point_locators`,
data: {
data: {
type: "drop_point_locators",
attributes: {
shipping_rate_id: id,
delivery_address: {
zip,
country_code: countryCode.toUpperCase(),
address_1: address1,
},
},
},
},
})
.then(({ data }) => data)
return points.attributes.drop_points
}
retrieveRelationship(relation) {
const link = relation.links.related
return this.client_.request({
method: "GET",
url: link,
})
}
/**
* Cancels a fulfillment. If the fulfillment has already been canceled this
* is idemptotent. Can only cancel pending orders.
* @param {object} data - the fulfilment data
* @return {Promise<object>} the result of the cancellation
*/
async cancelFulfillment(data) {
if (Array.isArray(data)) {
data = data[0]
}
const order = await this.client_.orders
.retrieve(data.id)
.catch(() => undefined)
// if order does not exist, we resolve gracefully
if (!order) {
return Promise.resolve()
}
if (this.options_.delete_on_cancel) {
return await this.client_.orders.delete(data.id)
}
return await this.client_.orders.update(data.id, {
id: data.id,
type: "orders",
attributes: {
status: "cancelled",
},
})
}
async buildWebshipperItem(item, quantity, order) {
const totals = await this.totalsService_.getLineItemTotals(item, order, {
include_tax: true,
use_tax_lines: true,
})
const webShipperItem = {
ext_ref: item.id,
description: item.title,
quantity: quantity,
unit_price: humanizeAmount(totals.unit_price, order.currency_code),
vat_percent: totals.tax_lines.reduce((acc, next) => acc + next.rate, 0),
}
const coo =
item?.variant?.origin_country || item?.variant?.product?.origin_country
const sku = item?.variant?.sku
const tarifNumber =
item?.variant?.hs_code || item?.variant?.product?.hs_code
if (coo) {
webShipperItem.country_of_origin = coo
}
if (sku) {
webShipperItem.sku = sku
}
if (tarifNumber) {
webShipperItem.tarif_number = tarifNumber
}
return webShipperItem
}
}
export default WebshipperFulfillmentService

View File

@@ -1,13 +0,0 @@
class WebshipperSubscriber {
constructor({ eventBusService, webshipperFulfillmentService }) {
this.webshipperService_ = webshipperFulfillmentService
eventBusService.subscribe("webshipper.shipment", this.handleShipment)
}
handleShipment = async ({ headers, body }) => {
return this.webshipperService_.handleWebhook(headers, body)
}
}
export default WebshipperSubscriber

View File

@@ -1,145 +0,0 @@
import axios from "axios"
class Webshipper {
constructor({ account, token }) {
this.account_ = account
this.token_ = token
this.client_ = axios.create({
baseURL: `https://${account}.api.webshipper.io`,
headers: {
"content-type": "application/vnd.api+json",
Authorization: `Bearer ${token}`,
},
})
this.documents = this.buildDocumentEndpoints_()
this.shippingRates = this.buildShippingRateEndpoints_()
this.orders = this.buildOrderEndpoints_()
this.shipments = this.buildShipmentEndpoints_()
this.returns = this.buildReturnEndpoints_()
}
async request(data) {
return this.client_(data).then(({ data }) => data)
}
buildDocumentEndpoints_ = () => {
return {
create: async (data) => {
const path = `/v2/documents`
return this.client_({
method: "POST",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
}
}
buildShippingRateEndpoints_ = () => {
return {
retrieve: async (id) => {
const path = `/v2/shipping_rates/${id}`
return this.client_({
method: "GET",
url: path,
}).then(({ data }) => data)
},
list: async (params = {}) => {
let path = `/v2/shipping_rates`
if (Object.entries(params).length) {
const search = Object.entries(params).map(([key, value]) => {
return `filter[${key}]=${value}`
})
path += `?${search.join("&")}`
}
return this.client_({
method: "GET",
url: path,
}).then(({ data }) => data)
},
}
}
buildOrderEndpoints_ = () => {
return {
retrieve: async (id) => {
const path = `/v2/orders/${id}`
return this.client_({
method: "GET",
url: path,
}).then(({ data }) => data)
},
create: async (data) => {
const path = `/v2/orders`
return this.client_({
method: "POST",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
update: async (id, data) => {
const path = `/v2/orders/${id}`
return this.client_({
method: "PATCH",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
delete: async (id) => {
const path = `/v2/orders/${id}`
return this.client_({
method: "DELETE",
url: path,
}).then(({ data }) => data)
},
}
}
buildShipmentEndpoints_ = () => {
return {
retrieve: async (id) => {
const path = `/v2/shipments/${id}`
return this.client_({
method: "GET",
url: path,
}).then(({ data }) => data)
},
create: async (data) => {
const path = `/v2/shipments`
return this.client_({
method: "POST",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
}
}
buildReturnEndpoints_ = () => {
return {
create: async (data) => {
const path = `/v2/returns`
return this.client_({
method: "POST",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
}
}
}
export default Webshipper

View File

@@ -1,15 +0,0 @@
/dist
.env
.DS_Store
/uploads
/node_modules
yarn-error.log
/dist
/api
/services
/models
/subscribers
/loaders
/utils

View File

@@ -1,255 +0,0 @@
# Change Log
## 0.2.20
### Patch Changes
- [#4623](https://github.com/medusajs/medusa/pull/4623) [`107ae23a3`](https://github.com/medusajs/medusa/commit/107ae23a3f41ef0d676e9d03f53dafc7c1af6118) Thanks [@riqwan](https://github.com/riqwan)! - fix(utils, types, medusa-plugin-meilisearch, medusa-plugin-algolia): move SoftDeletableFilterKey, variantKeys, indexTypes from types to utils
- Updated dependencies [[`107ae23a3`](https://github.com/medusajs/medusa/commit/107ae23a3f41ef0d676e9d03f53dafc7c1af6118)]:
- @medusajs/utils@1.9.4
## 0.2.19
### Patch Changes
- [#4420](https://github.com/medusajs/medusa/pull/4420) [`6f1fa244f`](https://github.com/medusajs/medusa/commit/6f1fa244fa47d4ecdaa7363483bd7da555dbbf32) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa-cli): Cleanup plugin setup + include Logger type update which is used across multiple packages
- Updated dependencies [[`499c3478c`](https://github.com/medusajs/medusa/commit/499c3478c910c8b922a15cc6f4d9fbad122a347f), [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086), [`9760d4a96`](https://github.com/medusajs/medusa/commit/9760d4a96c27f6f89a8c3f3b6e73b17547f97f2a)]:
- @medusajs/utils@1.9.2
## 0.2.18
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
- Updated dependencies [[`f98ba5bde`](https://github.com/medusajs/medusa/commit/f98ba5bde83ba785eead31b0c9eb9f135d664178), [`14c0f62f8`](https://github.com/medusajs/medusa/commit/14c0f62f84704a4c87beff3daaff60a52f5c88b8)]:
- @medusajs/utils@1.9.1
- @medusajs/modules-sdk@1.8.8
## 0.2.17
### Patch Changes
- Updated dependencies [[`a91987fab`](https://github.com/medusajs/medusa/commit/a91987fab33745f9864eab21bd1c27e8e3e24571), [`e73c3e51c`](https://github.com/medusajs/medusa/commit/e73c3e51c9cd192eeae7a57b24b07bd466214145), [`db4199530`](https://github.com/medusajs/medusa/commit/db419953075e0907b8c4d27ab5188e9bd3e3d72b), [`c0e527d6e`](https://github.com/medusajs/medusa/commit/c0e527d6e0a67d0c53577a0b9c3d16ee8dc5740f)]:
- @medusajs/utils@1.9.0
- @medusajs/modules-sdk@1.8.7
## 0.2.16
### Patch Changes
- Updated dependencies [[`cdbac2c84`](https://github.com/medusajs/medusa/commit/cdbac2c8403a3c15c0e11993f6b7dab268fa5c08), [`6511959e2`](https://github.com/medusajs/medusa/commit/6511959e23177f3b4831915db0e8e788bc9047fa)]:
- @medusajs/utils@1.8.5
- @medusajs/modules-sdk@1.8.6
## 0.2.15
### Patch Changes
- Updated dependencies [[`1ea57c3a6`](https://github.com/medusajs/medusa/commit/1ea57c3a69a5377a8dd0821df819743ded4a222b)]:
- @medusajs/utils@1.8.4
- @medusajs/modules-sdk@1.8.5
## 0.2.14
### Patch Changes
- Updated dependencies [[`0e488e71b`](https://github.com/medusajs/medusa/commit/0e488e71b186f7d08b18c4c6ba409ef3cadb8152), [`d539c6fee`](https://github.com/medusajs/medusa/commit/d539c6feeba8ee431f9a655b6cd4e9102cba2b25)]:
- @medusajs/utils@1.8.3
- @medusajs/modules-sdk@1.8.4
## 0.2.13
### Patch Changes
- Updated dependencies [[`af710f1b4`](https://github.com/medusajs/medusa/commit/af710f1b48a4545a5064029a557013af34c4c100), [`491566df6`](https://github.com/medusajs/medusa/commit/491566df6b7ced35f655f810961422945e10ecd0)]:
- @medusajs/utils@1.8.2
- @medusajs/modules-sdk@1.8.3
## 0.2.12
### Patch Changes
- Updated dependencies []:
- @medusajs/modules-sdk@1.8.2
## 0.2.11
### Patch Changes
- Updated dependencies [[`654a54622`](https://github.com/medusajs/medusa/commit/654a54622303139e7180538bd686630ad9a46cfd), [`abdb74d99`](https://github.com/medusajs/medusa/commit/abdb74d997f49f994bff49787a396179982843b0)]:
- @medusajs/utils@1.8.1
- @medusajs/modules-sdk@1.8.1
## 0.2.10
### Patch Changes
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
- upgrade typeorm from 0.2.51 to 0.3.11
- Plugin repository loader to work with Typeorm update
- [#3685](https://github.com/medusajs/medusa/pull/3685) [`8ddb3952c`](https://github.com/medusajs/medusa/commit/8ddb3952c045e6c05c8d0f6922f0d4ba30cf3bd4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Fix RC package versions
- [#3510](https://github.com/medusajs/medusa/pull/3510) [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-algolia): Revamp Algolia search plugin
- Updated dependencies [[`8ddb3952c`](https://github.com/medusajs/medusa/commit/8ddb3952c045e6c05c8d0f6922f0d4ba30cf3bd4), [`a0c919a8d`](https://github.com/medusajs/medusa/commit/a0c919a8d01ca5edf62336de48e9a112e3822f38), [`55e94d0b4`](https://github.com/medusajs/medusa/commit/55e94d0b45776776639d3970d4264b8f5c5385dd), [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb), [`bd12a9508`](https://github.com/medusajs/medusa/commit/bd12a95083b69a70b83ad38578c5a68738c41b2b), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73), [`bca1f80dd`](https://github.com/medusajs/medusa/commit/bca1f80dd501d878455e1ad4f5091cf20ef900ea), [`271844aed`](https://github.com/medusajs/medusa/commit/271844aedbe45c369e188b5d06458dbd6984cd39), [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def)]:
- @medusajs/modules-sdk@1.8.0
- @medusajs/utils@1.8.0
## 0.2.10-rc.3
### Patch Changes
- Updated dependencies [[`a0c919a8d`](https://github.com/medusajs/medusa/commit/a0c919a8d01ca5edf62336de48e9a112e3822f38), [`bd12a9508`](https://github.com/medusajs/medusa/commit/bd12a95083b69a70b83ad38578c5a68738c41b2b)]:
- @medusajs/utils@0.0.2-rc.2
- @medusajs/modules-sdk@0.1.0-rc.4
## 0.2.10-rc.2
### Patch Changes
- Updated dependencies [[`55e94d0b4`](https://github.com/medusajs/medusa/commit/55e94d0b45776776639d3970d4264b8f5c5385dd)]:
- @medusajs/modules-sdk@0.1.0-rc.3
## 0.2.10-rc.1
### Patch Changes
- chore: Fix RC package versions
- Updated dependencies []:
- @medusajs/modules-sdk@0.1.0-rc.2
- @medusajs/utils@0.0.2-rc.1
## 0.2.10-rc.0
### Patch Changes
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
- upgrade typeorm from 0.2.51 to 0.3.11
- Plugin repository loader to work with Typeorm update
- [#3510](https://github.com/medusajs/medusa/pull/3510) [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-algolia): Revamp Algolia search plugin
- Updated dependencies [[`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73), [`271844aed`](https://github.com/medusajs/medusa/commit/271844aedbe45c369e188b5d06458dbd6984cd39), [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def)]:
- @medusajs/utils@0.0.2-rc.0
- @medusajs/modules-sdk@0.1.0-rc.0
## 0.2.9
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 0.2.8
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 0.2.7
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 0.2.6
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
## 0.2.5
### Patch Changes
- Updated dependencies [[`c97ccd3fb`](https://github.com/medusajs/medusa/commit/c97ccd3fb5dbe796b0e4fbf37def5bb6e8201557)]:
- medusa-interfaces@1.3.3
## 0.2.4
### Patch Changes
- [#1914](https://github.com/medusajs/medusa/pull/1914) [`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68) Thanks [@fPolic](https://github.com/fPolic)! - Version bump due to missing changesets in merged PRs
- Updated dependencies [[`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68), [`b8ddb31f6`](https://github.com/medusajs/medusa/commit/b8ddb31f6fe296a11d2d988276ba8e991c37fa9b)]:
- medusa-interfaces@1.3.2
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.3](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.2.2...medusa-plugin-algolia@0.2.3) (2022-07-05)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.2.2](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.2.0...medusa-plugin-algolia@0.2.2) (2022-06-19)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.2.0...medusa-plugin-algolia@0.2.1) (2022-05-31)
**Note:** Version bump only for package medusa-plugin-algolia
# [0.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.1.1...medusa-plugin-algolia@0.2.0) (2022-05-01)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.8...medusa-plugin-algolia@0.1.1) (2022-02-28)
**Note:** Version bump only for package medusa-plugin-algolia
# [0.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.8...medusa-plugin-algolia@0.1.0) (2022-02-25)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.0.8](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.7...medusa-plugin-algolia@0.0.8) (2022-02-06)
### Bug Fixes
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.6...medusa-plugin-algolia@0.0.7) (2022-02-06)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.0.6](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.5...medusa-plugin-algolia@0.0.6) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.0.5](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.4...medusa-plugin-algolia@0.0.5) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.0.4](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.3...medusa-plugin-algolia@0.0.4) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-algolia
## [0.0.3](https://github.com/medusajs/medusa/compare/medusa-plugin-algolia@0.0.2...medusa-plugin-algolia@0.0.3) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-algolia
## 0.0.2 (2021-11-19)
### Features
- Algolia plugin for medusa ([#718](https://github.com/medusajs/medusa/issues/718)) ([8ce9b20](https://github.com/medusajs/medusa/commit/8ce9b20222e1f4db75f730898549f0ed09eb1574))
- Typescript for API layer ([#817](https://github.com/medusajs/medusa/issues/817)) ([373532e](https://github.com/medusajs/medusa/commit/373532ecbc8196f47e71af95a8cf82a14a4b1f9e))

View File

@@ -1,92 +0,0 @@
# Algolia
Provide powerful indexing and searching features in your commerce application with Algolia.
[Algolia Plugin Documentation](https://docs.medusajs.com/plugins/search/algolia) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Flexible configurations for specifying searchable and retrievable attributes.
- Ready-integration with [Medusa's Next.js starter storefront](https://docs.medusajs.com/starters/nextjs-medusa-starter).
- Utilize Algolia's powerful search functionalities including typo-tolerance, query suggestions, results ranking, and more.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Algolia account](https://www.algolia.com/)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-algolia
```
2\. Set the following environment variables in `.env`:
```bash
ALGOLIA_APP_ID=<YOUR_APP_ID>
ALGOLIA_ADMIN_API_KEY=<YOUR_ADMIN_API_KEY>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
{
resolve: `medusa-plugin-algolia`,
options: {
applicationId: process.env.ALGOLIA_APP_ID,
adminApiKey: process.env.ALGOLIA_ADMIN_API_KEY,
settings: {
products: {
indexSettings: {
searchableAttributes: ["title", "description"],
attributesToRetrieve: [
"id",
"title",
"description",
"handle",
"thumbnail",
"variants",
"variant_sku",
"options",
"collection_title",
"collection_handle",
"images",
],
},
transformer: (product) => ({
id: product.id,
// other attributes...
}),
},
},
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Try searching products either using your storefront or using the [Store APIs](https://docs.medusajs.com/api/store#tag/Product/operation/PostProductsSearch).
---
## Additional Resources
- [Algolia Plugin Documentation](https://docs.medusajs.com/plugins/search/algolia)

View File

@@ -1,3 +0,0 @@
module.exports = {
testEnvironment: "node",
}

View File

@@ -1,42 +0,0 @@
{
"name": "medusa-plugin-algolia",
"version": "0.2.20",
"description": "Algolia search plugin for Medusa",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-algolia"
},
"files": [
"dist"
],
"engines": {
"node": ">=16"
},
"author": "Medusa",
"license": "MIT",
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"test": "jest --passWithNoTests src",
"build": "rimraf dist && tsc",
"watch": "tsc --watch"
},
"dependencies": {
"@medusajs/modules-sdk": "^1.8.8",
"@medusajs/utils": "^1.9.4",
"algoliasearch": "^4.15.0"
},
"devDependencies": {
"@medusajs/types": "^1.10.0",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"rimraf": "^5.0.1",
"typescript": "^4.4.4"
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
"keywords": [
"medusa-plugin",
"medusa-plugin-search"
]
}

View File

@@ -1,25 +0,0 @@
import { MedusaContainer } from "@medusajs/modules-sdk"
import { Logger } from "@medusajs/types"
import AlgoliaService from "../services/algolia"
import { AlgoliaPluginOptions } from "../types"
export default async (
container: MedusaContainer,
options: AlgoliaPluginOptions
) => {
const logger: Logger = container.resolve("logger")
try {
const algoliaService: AlgoliaService = container.resolve("algoliaService")
const { settings } = options
await Promise.all(
Object.entries(settings || {}).map(async ([indexName, value]) => {
return await algoliaService.updateSettings(indexName, value)
})
)
} catch (err) {
// ignore
logger.warn(err)
}
}

View File

@@ -1,177 +0,0 @@
import { SearchTypes } from "@medusajs/types"
import { SearchUtils } from "@medusajs/utils"
import Algolia, { SearchClient } from "algoliasearch"
import { AlgoliaPluginOptions, SearchOptions } from "../types"
import { transformProduct } from "../utils/transformer"
class AlgoliaService extends SearchUtils.AbstractSearchService {
isDefault = false
protected readonly config_: AlgoliaPluginOptions
protected readonly client_: SearchClient
constructor(_, options: AlgoliaPluginOptions) {
super(_, options)
this.config_ = options
const { applicationId, adminApiKey } = options
if (!applicationId) {
throw new Error("Please provide a valid Application ID")
}
if (!adminApiKey) {
throw new Error("Please provide a valid Admin Api Key")
}
this.client_ = Algolia(applicationId, adminApiKey)
}
/**
* Add two numbers.
* @param {string} indexName - The name of the index
* @param {*} options - not required just to match the schema we are used it
* @return {*}
*/
createIndex(indexName: string, options: Record<string, unknown> = {}) {
return this.client_.initIndex(indexName)
}
/**
* Used to get an index
* @param {string} indexName - the index name.
* @return {Promise<{object}>} - returns response from search engine provider
*/
async getIndex(indexName: string) {
let hits: Record<string, unknown>[] = []
return await this.client_
.initIndex(indexName)
.browseObjects({
query: indexName,
batch: (batch) => {
hits = hits.concat(batch)
},
})
.then(() => hits)
}
/**
*
* @param {string} indexName
* @param {Array} documents - products list array
* @param {*} type
* @return {*}
*/
async addDocuments(indexName: string, documents: any, type: string) {
const transformedDocuments = await this.getTransformedDocuments(
type,
documents
)
return await this.client_
.initIndex(indexName)
.saveObjects(transformedDocuments)
}
/**
* Used to replace documents
* @param {string} indexName - the index name.
* @param {Object} documents - array of document objects that will replace existing documents
* @param {Array.<Object>} type - type of documents to be replaced (e.g: products, regions, orders, etc)
* @return {Promise<{object}>} - returns response from search engine provider
*/
async replaceDocuments(indexName: string, documents: any, type: string) {
const transformedDocuments = await this.getTransformedDocuments(
type,
documents
)
return await this.client_
.initIndex(indexName)
.replaceAllObjects(transformedDocuments)
}
/**
* Used to delete document
* @param {string} indexName - the index name
* @param {string} documentId - the id of the document
* @return {Promise<{object}>} - returns response from search engine provider
*/
async deleteDocument(indexName: string, documentId: string) {
return await this.client_.initIndex(indexName).deleteObject(documentId)
}
/**
* Used to delete all documents
* @param {string} indexName - the index name
* @return {Promise<{object}>} - returns response from search engine provider
*/
async deleteAllDocuments(indexName: string) {
return await this.client_.initIndex(indexName).delete()
}
/**
* Used to search for a document in an index
* @param {string} indexName - the index name
* @param {string} query - the search query
* @param {*} options
* - any options passed to the request object other than the query and indexName
* - additionalOptions contain any provider specific options
* @return {*} - returns response from search engine provider
*/
async search(
indexName: string,
query: string,
options: SearchOptions & Record<string, unknown>
) {
const { paginationOptions, filter, additionalOptions } = options
// fit our pagination options to what Algolia expects
if ("limit" in paginationOptions && paginationOptions.limit != null) {
paginationOptions["length"] = paginationOptions.limit
delete paginationOptions.limit
}
return await this.client_.initIndex(indexName).search(query, {
filters: filter,
...paginationOptions,
...additionalOptions,
})
}
/**
* Used to update the settings of an index
* @param {string} indexName - the index name
* @param {object} settings - settings object
* @return {Promise<{object}>} - returns response from search engine provider
*/
async updateSettings(
indexName: string,
settings: SearchTypes.IndexSettings & Record<string, unknown>
) {
// backward compatibility
const indexSettings = settings.indexSettings ?? settings ?? {}
return await this.client_.initIndex(indexName).setSettings(indexSettings)
}
async getTransformedDocuments(type: string, documents: any[]) {
if (!documents?.length) {
return []
}
switch (type) {
case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer =
this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct
return documents.map(productsTransformer)
default:
return documents
}
}
}
export default AlgoliaService

View File

@@ -1,18 +0,0 @@
import { SearchTypes } from "@medusajs/types"
export type SearchOptions = {
paginationOptions: Record<string, unknown>
filter: string
additionalOptions: Record<string, unknown>
}
export type AlgoliaPluginOptions = {
applicationId: string
adminApiKey: string
/**
* Index settings
*/
settings?: {
[key: string]: SearchTypes.IndexSettings
}
}

View File

@@ -1,44 +0,0 @@
import { variantKeys } from "@medusajs/utils"
const prefix = `variant`
export const transformProduct = (product: any) => {
let transformedProduct = { ...product } as Record<string, unknown>
const initialObj = variantKeys.reduce((obj, key) => {
obj[`${prefix}_${key}`] = []
return obj
}, {})
initialObj[`${prefix}_options_value`] = []
const flattenedVariantFields = product.variants.reduce((obj, variant) => {
variantKeys.forEach((k) => {
if (k === "options" && variant[k]) {
const values = variant[k].map((option) => option.value)
obj[`${prefix}_options_value`] =
obj[`${prefix}_options_value`].concat(values)
return
}
return variant[k] && obj[`${prefix}_${k}`].push(variant[k])
})
return obj
}, initialObj)
transformedProduct.objectID = product.id
transformedProduct.type_value = product.type && product.type.value
transformedProduct.collection_title =
product.collection && product.collection.title
transformedProduct.collection_handle =
product.collection && product.collection.handle
transformedProduct.tags_value = product.tags
? product.tags.map((t) => t.value)
: []
transformedProduct.categories = (product?.categories || []).map((c) => c.name)
const prod = {
...transformedProduct,
...flattenedVariantFields,
}
return prod
}

View File

@@ -1,29 +0,0 @@
{
"compilerOptions": {
"lib": ["es2020"],
"target": "es2020",
"outDir": "./dist",
"esModuleInterop": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"allowJs": true,
"skipLibCheck": true,
"downlevelIteration": true // to use ES5 specific tooling
},
"include": ["src"],
"exclude": [
"dist",
"src/**/__tests__",
"src/**/__mocks__",
"src/**/__fixtures__",
"node_modules"
]
}

View File

@@ -1,5 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@@ -1,22 +0,0 @@
const ignore = []
// Jest needs to compile this code, but generally we don't want this copied
// to output folders
if (process.env.NODE_ENV !== `test`) {
ignore.push(`**/__tests__`)
}
module.exports = {
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes",
],
presets: ["@babel/preset-env"],
env: {
test: {
plugins: ["@babel/plugin-transform-runtime"],
},
},
ignore,
}

View File

@@ -1,17 +0,0 @@
/lib
node_modules
.DS_store
.env*
/*.js
!.babelrc.js
!index.js
yarn.lock
/dist
/api
/services
/models
/subscribers
/loaders

View File

@@ -1,8 +0,0 @@
.DS_store
src
dist
yarn.lock
.babelrc
.turbo
.yarn

View File

@@ -1,382 +0,0 @@
# Change Log
## 1.2.11
### Patch Changes
- [#5543](https://github.com/medusajs/medusa/pull/5543) [`f90ba0208`](https://github.com/medusajs/medusa/commit/f90ba02087778d8131aed3a59a6dc9c8ca3c95f4) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(utils): Introduce promiseAll util
- Updated dependencies [[`c39bf69a5`](https://github.com/medusajs/medusa/commit/c39bf69a5e5cae75d7fa12aa6022b10903557a32), [`154c9b43b`](https://github.com/medusajs/medusa/commit/154c9b43bde1fdff562aba9da8a79af2660b29b3)]:
- @medusajs/utils@1.10.5
## 1.2.10
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
## 1.2.9
### Patch Changes
- [#3991](https://github.com/medusajs/medusa/pull/3991) [`eba21d9c5`](https://github.com/medusajs/medusa/commit/eba21d9c5f5fac292013cf1c39ead1d5523414d6) Thanks [@pKorsholm](https://github.com/pKorsholm)! - feat(medusa-plugin-contentful): include sku from inventory module when syncing variants and products
- [#4026](https://github.com/medusajs/medusa/pull/4026) [`a91987fab`](https://github.com/medusajs/medusa/commit/a91987fab33745f9864eab21bd1c27e8e3e24571) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa): Remove sqlite support
## 1.2.8
### Patch Changes
- [#3187](https://github.com/medusajs/medusa/pull/3187) [`f97b3d7cc`](https://github.com/medusajs/medusa/commit/f97b3d7ccee381d3491337ab5144bb44520382a7) Thanks [@fPolic](https://github.com/fPolic)! - feat(medusa, cache-redis, cache-inmemory): Added cache modules
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
- medusa-test-utils@1.1.40
## 1.2.8-rc.0
### Patch Changes
- [#3187](https://github.com/medusajs/medusa/pull/3187) [`f97b3d7cc`](https://github.com/medusajs/medusa/commit/f97b3d7ccee381d3491337ab5144bb44520382a7) Thanks [@fPolic](https://github.com/fPolic)! - feat(medusa, cache-redis, cache-inmemory): Added cache modules
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
- medusa-test-utils@1.1.40-rc.0
## 1.2.7
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.2.6
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.2.5
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.2.4
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.3](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.2.2...medusa-plugin-contentful@1.2.3) (2022-07-05)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.2.2](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.2.0...medusa-plugin-contentful@1.2.2) (2022-06-19)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.2.0...medusa-plugin-contentful@1.2.1) (2022-05-31)
**Note:** Version bump only for package medusa-plugin-contentful
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.40...medusa-plugin-contentful@1.2.0) (2022-05-01)
### Bug Fixes
- **medusa-plugin-contentful:** add type and collection entity synchronisation ([#1191](https://github.com/medusajs/medusa/issues/1191)) ([36bfdfe](https://github.com/medusajs/medusa/commit/36bfdfe6e1eb3cefea7aacf711cfd22d44893a8c))
## [1.1.40](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.39...medusa-plugin-contentful@1.1.40) (2022-01-11)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.39](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.38...medusa-plugin-contentful@1.1.39) (2021-12-29)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.37...medusa-plugin-contentful@1.1.38) (2021-12-17)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.36...medusa-plugin-contentful@1.1.37) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.35...medusa-plugin-contentful@1.1.36) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.34...medusa-plugin-contentful@1.1.35) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.33...medusa-plugin-contentful@1.1.34) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.32...medusa-plugin-contentful@1.1.33) (2021-11-19)
### Bug Fixes
- ignore tests in build output ([#579](https://github.com/medusajs/medusa/issues/579)) ([53178cb](https://github.com/medusajs/medusa/commit/53178cbda3b4f5e9ac30829c99b4d4df6616a0cf))
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.31...medusa-plugin-contentful@1.1.32) (2021-10-25)
### Bug Fixes
- make contentful data sync ([548f6c7](https://github.com/medusajs/medusa/commit/548f6c7138d9a08b6c2113ebdda27f13dee848ac))
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.30...medusa-plugin-contentful@1.1.31) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.29...medusa-plugin-contentful@1.1.30) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.27...medusa-plugin-contentful@1.1.29) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.27...medusa-plugin-contentful@1.1.28) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.26...medusa-plugin-contentful@1.1.27) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-contentful
## [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.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.23...medusa-plugin-contentful@1.1.24) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.21...medusa-plugin-contentful@1.1.23) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.21...medusa-plugin-contentful@1.1.22) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.20...medusa-plugin-contentful@1.1.21) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.19...medusa-plugin-contentful@1.1.20) (2021-06-24)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.18...medusa-plugin-contentful@1.1.19) (2021-06-22)
### Bug Fixes
- region sync ([8e29e6e](https://github.com/medusajs/medusa/commit/8e29e6e63c305b684a37d817b504b3e471d697bd))
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
- typo ([4b6445a](https://github.com/medusajs/medusa/commit/4b6445a1b0509dd0c00f240a4ae287caf1a46ebf))
- wrong custom field ([05bda95](https://github.com/medusajs/medusa/commit/05bda956d97bd0a5f2c43f4c727be569170168c6))
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.17...medusa-plugin-contentful@1.1.18) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.16...medusa-plugin-contentful@1.1.17) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.15...medusa-plugin-contentful@1.1.16) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.14...medusa-plugin-contentful@1.1.15) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.13...medusa-plugin-contentful@1.1.14) (2021-06-08)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.10...medusa-plugin-contentful@1.1.13) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.11...medusa-plugin-contentful@1.1.12) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.10...medusa-plugin-contentful@1.1.11) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.9...medusa-plugin-contentful@1.1.10) (2021-04-13)
### Bug Fixes
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.8...medusa-plugin-contentful@1.1.9) (2021-04-13)
### Bug Fixes
- publish assist ([7719957](https://github.com/medusajs/medusa/commit/7719957b44a0c0d950eff948faf31188fe0e3ef1))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.8...medusa-plugin-contentful@1.1.8) (2021-03-30)
### Bug Fixes
- publish assist ([7719957](https://github.com/medusajs/medusa/commit/7719957b44a0c0d950eff948faf31188fe0e3ef1))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.7...medusa-plugin-contentful@1.1.8) (2021-03-26)
### Bug Fixes
- update all contentful ([806918a](https://github.com/medusajs/medusa/commit/806918a10e42fde60240dcc785d8e175dc8507b5))
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.6...medusa-plugin-contentful@1.1.7) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.4...medusa-plugin-contentful@1.1.6) (2021-03-17)
### Bug Fixes
- contentful sync ([#206](https://github.com/medusajs/medusa/issues/206)) ([227cdb6](https://github.com/medusajs/medusa/commit/227cdb622234126df6087992203ce82ff9446974))
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.4...medusa-plugin-contentful@1.1.5) (2021-03-17)
### Bug Fixes
- contentful sync ([#206](https://github.com/medusajs/medusa/issues/206)) ([227cdb6](https://github.com/medusajs/medusa/commit/227cdb622234126df6087992203ce82ff9446974))
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.3...medusa-plugin-contentful@1.1.4) (2021-02-25)
### Bug Fixes
- **medusa-plugin-contentful:** Allow custom fields in plugin options ([#180](https://github.com/medusajs/medusa/issues/180)) ([587a464](https://github.com/medusajs/medusa/commit/587a464e83576833ff616bde7bb26b1bb48472fe))
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.2...medusa-plugin-contentful@1.1.3) (2021-02-17)
### Features
- **medusa:** Product category, type and tags ([c4d1203](https://github.com/medusajs/medusa/commit/c4d1203155b7cc03e8892f0409efec83e030063e))
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.1...medusa-plugin-contentful@1.1.2) (2021-02-03)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.0...medusa-plugin-contentful@1.1.1) (2021-01-27)
**Note:** Version bump only for package medusa-plugin-contentful
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.0.15...medusa-plugin-contentful@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.0.15](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.0.14...medusa-plugin-contentful@1.0.15) (2020-12-17)
### Features
- **medusa:** Adds product variant sale price ([#148](https://github.com/medusajs/medusa/issues/148)) ([451451a](https://github.com/medusajs/medusa/commit/451451a38eeffa88e04f1992c4026882cd2be66f))
## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.0.13...medusa-plugin-contentful@1.0.14) (2020-12-13)
### Bug Fixes
- **medusa-plugin-contentful:** Adds correct thumbnail and images sync. ([#145](https://github.com/medusajs/medusa/issues/145)) ([725241d](https://github.com/medusajs/medusa/commit/725241df6624daddf1aea28817eaeb652e325f0d))
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.0.12...medusa-plugin-contentful@1.0.13) (2020-11-24)
**Note:** Version bump only for package medusa-plugin-contentful
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.0.11...medusa-plugin-contentful@1.0.12) (2020-11-17)
### Bug Fixes
- **medusa-plugin-contentful:** Fixes Medusa Contentful plugin ([34d3014](https://github.com/medusajs/medusa/commit/34d3014db0f1d6be3df0e2ff4b5ca11c505b245d))
## 1.0.11 (2020-10-19)
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
# 1.0.0 (2020-09-03)
# 1.0.0-y.18 (2020-09-01)
### Bug Fixes
- use redis url from options ([4747a11](https://github.com/medusajs/medusa/commit/4747a1103cc13848a5ac23444b64c8d087aaa78f))
# 1.0.0-y.10 (2020-09-01)
### Bug Fixes
- typo ([857c440](https://github.com/medusajs/medusa/commit/857c440c03d9b9ff94f067f7209632a34660d5af))
# 1.0.0-y.7 (2020-09-01)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
### Bug Fixes
- **contentful-plugin:** Keep existing entry fields ([eb47896](https://github.com/medusajs/medusa/commit/eb478966684776bb2aa48e98789519644b05cd33))
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.5 (2020-08-20)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,76 +0,0 @@
# Contentful
Manage the content of your storefront with rich Content Management System (CMS) capabilities using Contentful.
[Contentful Plugin Documentation](https://docs.medusajs.com/plugins/cms/contentful/) | [Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Handle the presentational content of your commerce application using Contentful.
- Two-way sync between Medusa and Contentful, allowing you to manage products details consistently.
- Benefit from Contentful's advanced CMS features such as localization and versioning.
---
## Prerequisites
- [Contentful account](https://www.contentful.com)
- [Medusa CLI Tool](https://docs.medusajs.com/cli/reference#how-to-install-cli-tool)
- [PostgreSQL](https://docs.medusajs.com/development/backend/prepare-environment#postgresql)
- [Redis](https://docs.medusajs.com/development/backend/prepare-environment#redis)
---
## How to Install
1\. Run the following command to install a new Medusa server configured with Contentful:
```bash
medusa new medusa-contentful https://github.com/medusajs/medusa-starter-contentful
```
2\. Change to the newly created directory `medusa-contentful`:
```bash
cd medusa-contentful
```
3\. Set the following environment variables in `.env`:
```bash
CONTENTFUL_SPACE_ID=<YOUR_CONTENTFUL_SPACE_ID>
CONTENTFUL_ACCESS_TOKEN=<YOUR_CONTENTFUL_ACCESS_TOKEN>
CONTENTFUL_ENV=<YOUR_CONTENTFUL_ENV>
REDIS_URL=<YOUR_REDIS_URL>
DATABASE_URL=<YOUR_DB_URL>
```
4\. Migrate the content types into Contentful with the following command:
```bash
npm run migrate:contentful
```
5\. Seed Contentful with demo content data using the following command:
```bash
npm run seed:contentful
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. You can then setup the [Gatsby Contentful Storefront](https://docs.medusajs.com/plugins/cms/contentful/#setup-gatsby-storefront), or connect to Contentful from your own storefront to retrieve content data.
---
## Additional Resources
- [Contentful Plugin Documentation](https://docs.medusajs.com/plugins/cms/contentful/)

View File

@@ -1 +0,0 @@
// noop

View File

@@ -1,56 +0,0 @@
{
"name": "medusa-plugin-contentful",
"version": "1.2.11",
"description": "Contentful plugin for Medusa Commerce",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-contentful"
},
"engines": {
"node": ">=16"
},
"author": "Oliver Juhl",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"@medusajs/utils": "^1.10.5",
"body-parser": "^1.19.0",
"contentful-management": "^5.27.1",
"express": "^4.17.1",
"lodash": "^4.17.21",
"medusa-core-utils": "^1.2.0",
"redis": "^3.0.2"
},
"gitHead": "3bbd1e8507e00bc471de6ae3c30207999a4a4011",
"keywords": [
"medusa-plugin",
"medusa-plugin-cms"
]
}

View File

@@ -1,10 +0,0 @@
import { Router } from "express"
import hooks from "./routes/hooks"
export default (container) => {
const app = Router()
hooks(app)
return app
}

View File

@@ -1 +0,0 @@
export default (fn) => (...args) => fn(...args).catch(args[2])

View File

@@ -1,5 +0,0 @@
import { default as wrap } from "./await-middleware"
export default {
wrap,
}

View File

@@ -1,26 +0,0 @@
export default async (req, res) => {
try {
const contentfulService = req.scope.resolve("contentfulService")
const contentfulType = req.body.sys.contentType.sys.id
const entryId = req.body.sys.id
let updated = {}
switch (contentfulType) {
case "product":
updated = await contentfulService.sendContentfulProductToAdmin(entryId)
break
case "productVariant":
updated = await contentfulService.sendContentfulProductVariantToAdmin(
entryId
)
break
default:
break
}
res.status(200).send(updated)
} catch (error) {
res.status(400).send(`Webhook error: ${error.message}`)
}
}

View File

@@ -1,17 +0,0 @@
import { Router } from "express"
import bodyParser from "body-parser"
import middlewares from "../../middlewares"
const route = Router()
export default (app) => {
app.use("/hooks", route)
route.post(
"/contentful",
bodyParser.json(),
middlewares.wrap(require("./contentful").default)
)
return app
}

View File

@@ -1,76 +0,0 @@
const checkContentTypes = async (container) => {
const contentfulService = container.resolve("contentfulService")
let product
let variant
try {
product = await contentfulService.getType("product")
variant = await contentfulService.getType("productVariant")
} catch (error) {
if (!product) {
throw Error("Content type: `product` is missing in Contentful")
}
if (!variant) {
throw Error("Content type: `productVariant` is missing in Contentful")
}
}
if (product && product.fields) {
const productFields = product.fields
const customProductFields = Object.keys(
contentfulService.options_.custom_product_fields || {}
)
const keys = Object.values(productFields).map((f) => f.id)
const missingKeys = requiredProductFields.filter(
(rpf) => !keys.includes(rpf) && !customProductFields.includes(rpf)
)
if (missingKeys.length) {
throw Error(
`Contentful: Content type ${`product`} is missing some required key(s). Required: ${requiredProductFields.join(
", "
)}`
)
}
}
if (variant && variant.fields) {
const variantFields = variant.fields
const customVariantFields = Object.keys(
contentfulService.options_.custom_variant_fields || {}
)
const keys = Object.values(variantFields).map((f) => f.id)
const missingKeys = requiredVariantFields.filter(
(rpf) => !keys.includes(rpf) && !customVariantFields.includes(rpf)
)
if (missingKeys.length) {
throw Error(
`Contentful: Content type ${`productVariant`} is missing some required key(s). Required: ${requiredVariantFields.join(
", "
)}`
)
}
}
}
const requiredProductFields = [
"title",
"variants",
"options",
"medusaId",
"type",
"collection",
"tags",
"handle",
]
const requiredVariantFields = ["title", "sku", "prices", "options", "medusaId"]
export default checkContentTypes

View File

@@ -1,7 +0,0 @@
export const createClient = jest.fn()
const mock = jest.fn().mockImplementation(() => {
return { createClient }
})
export default mock

View File

@@ -1,179 +0,0 @@
import ContentfulService from "../contentful"
describe("ContentfulService", () => {
describe("delete in medusa", () => {
const regionService = {
retrieve: jest.fn((id) => {
if (id === "exists") {
return Promise.resolve({ id: "exists" })
}
return Promise.resolve(undefined)
}),
}
const productService = {
retrieve: jest.fn((id) => {
if (id === "exists") {
return Promise.resolve({ id: "exists" })
}
return Promise.resolve(undefined)
}),
}
const cacheService = {
get: async (id) => {
// const key = `${id}_ignore_${side}`
if (id === `ignored_ignore_contentful`) {
return { id }
}
return undefined
},
set: async (id) => {
return undefined
},
}
const productVariantService = {
retrieve: jest.fn((id) => {
if (id === "exists") {
return Promise.resolve({ id: "exists" })
}
return Promise.resolve(undefined)
}),
}
const eventBusService = {}
const service = new ContentfulService(
{
regionService,
productService,
cacheService,
productVariantService,
eventBusService,
},
{
space_id: "test_id",
environment: "master",
access_token: "test_token",
}
)
const entry = {
unpublish: jest.fn(async () => {
return {
id: "id",
}
}),
archive: jest.fn(async () => {
return {
id: "id",
}
}),
}
service.contentful_ = {
getSpace: async (space_id) => {
return {
getEnvironment: async (env) => {
return {
getEntry: async (id) => {
if (id === "onlyMedusa") {
throw new Error("doesn't exist")
}
return entry
},
}
},
}
},
}
beforeEach(() => {
jest.clearAllMocks()
})
describe("archiveProductInContentful", () => {
it("Calls entry.unpublish and entry.archive", async () => {
await service.archiveProductInContentful({ id: "test" })
expect(entry.unpublish).toHaveBeenCalledTimes(1)
expect(entry.archive).toHaveBeenCalledTimes(1)
})
it("Doesn't call entry.unpublish and entry.archive if the product still exists in medusa", async () => {
await service.archiveProductInContentful({ id: "exists" })
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
it("Doesn't call productService if request should be ignored", async () => {
await service.archiveProductInContentful({ id: "ignored" })
expect(productService.retrieve).toHaveBeenCalledTimes(0)
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
})
describe("archiveProductVariantInContentful", () => {
it("Calls entry.unpublish and entry.archive", async () => {
await service.archiveProductVariantInContentful({ id: "test" })
expect(entry.unpublish).toHaveBeenCalledTimes(1)
expect(entry.archive).toHaveBeenCalledTimes(1)
})
it("Doesn't call entry.unpublish and entry.archive if the variant still exists in medusa", async () => {
await service.archiveProductVariantInContentful({ id: "exists" })
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
it("Doesn't call productVariantService if request should be ignored", async () => {
await service.archiveProductVariantInContentful({ id: "ignored" })
expect(productVariantService.retrieve).toHaveBeenCalledTimes(0)
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
})
describe("archiveRegionInContentful", () => {
it("Calls entry.unpublish and entry.archive", async () => {
await service.archiveRegionInContentful({ id: "test" })
expect(entry.unpublish).toHaveBeenCalledTimes(1)
expect(entry.archive).toHaveBeenCalledTimes(1)
})
it("Doesn't call entry.unpublish and entry.archive if the region still exists in medusa", async () => {
await service.archiveRegionInContentful({ id: "exists" })
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
it("Doesn't call RegionService if request should be ignored", async () => {
await service.archiveRegionInContentful({ id: "ignored" })
expect(regionService.retrieve).toHaveBeenCalledTimes(0)
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
})
describe("archiveEntryWidthId", () => {
it("Calls archive if entry exists", async () => {
await service.archiveEntryWidthId("exists")
expect(entry.unpublish).toHaveBeenCalledTimes(1)
expect(entry.archive).toHaveBeenCalledTimes(1)
})
it("Doesnt call archive if entry doesn't exists", async () => {
await service.archiveEntryWidthId("onlyMedusa")
expect(entry.unpublish).toHaveBeenCalledTimes(0)
expect(entry.archive).toHaveBeenCalledTimes(0)
})
})
})
})

View File

@@ -1,988 +0,0 @@
import { BaseService } from "medusa-interfaces"
import _ from "lodash"
import { createClient } from "contentful-management"
import { promiseAll } from "@medusajs/utils"
const IGNORE_THRESHOLD = 2 // seconds
class ContentfulService extends BaseService {
constructor(
{
regionService,
productService,
cacheService,
productVariantService,
eventBusService,
productVariantInventoryService,
featureFlagRouter,
},
options
) {
super()
this.productService_ = productService
this.productVariantService_ = productVariantService
this.regionService_ = regionService
this.eventBus_ = eventBusService
this.options_ = options
this.contentful_ = createClient({
accessToken: options.access_token,
})
this.cacheService_ = cacheService
this.productVariantInventoryService_ = productVariantInventoryService
this.featureFlagRouter_ = featureFlagRouter
this.capab_ = {}
}
async addIgnore_(id, side) {
const key = `${id}_ignore_${side}`
return await this.cacheService_.set(
key,
1,
this.options_.ignore_threshold || IGNORE_THRESHOLD
)
}
async shouldIgnore_(id, side) {
const key = `${id}_ignore_${side}`
return await this.cacheService_.get(key)
}
async getContentfulEnvironment_() {
const space = await this.contentful_.getSpace(this.options_.space_id)
const environment = await space.getEnvironment(this.options_.environment)
return environment
}
async getVariantEntries_(variants, config = { publish: false }) {
const contentfulVariants = await promiseAll(
variants.map(async (variant) => {
let updated = await this.updateProductVariantInContentful(variant)
if (config.publish) {
updated = updated.publish()
}
return updated
})
)
return contentfulVariants
}
getLink_(fromEntry) {
return {
sys: {
type: "Link",
linkType: "Entry",
id: fromEntry.sys.id,
},
}
}
getVariantLinks_(variantEntries) {
return variantEntries.map((v) => this.getLink_(v))
}
async createImageAssets(product) {
const environment = await this.getContentfulEnvironment_()
const assets = []
await Promise.all(
product.images
.filter((image) => image.url !== product.thumbnail)
.map(async (image, i) => {
const asset = await environment.createAsset({
fields: {
title: {
"en-US": `${product.title} - ${i}`,
},
description: {
"en-US": "",
},
file: {
"en-US": {
contentType: "image/xyz",
fileName: image.url,
upload: image.url,
},
},
},
})
const finalAsset = await asset
.processForAllLocales()
.then((ast) => ast.publish())
assets.push({
sys: {
type: "Link",
linkType: "Asset",
id: finalAsset.sys.id,
},
})
})
)
return assets
}
getCustomField(field, type) {
const customOptions = this.options_[`custom_${type}_fields`]
if (customOptions) {
return customOptions[field] || field
} else {
return field
}
}
async createProductInContentful(product) {
const p = await this.productService_.retrieve(product.id, {
relations: [
"variants",
"options",
"tags",
"type",
"collection",
"images",
],
})
const environment = await this.getContentfulEnvironment_()
const variantEntries = await this.getVariantEntries_(p.variants, {
publish: true,
})
const variantLinks = this.getVariantLinks_(variantEntries)
const fields = {
[this.getCustomField("title", "product")]: {
"en-US": p.title,
},
[this.getCustomField("subtitle", "product")]: {
"en-US": p.subtitle,
},
[this.getCustomField("description", "product")]: {
"en-US": p.description,
},
[this.getCustomField("variants", "product")]: {
"en-US": variantLinks,
},
[this.getCustomField("options", "product")]: {
"en-US": this.transformMedusaIds(p.options),
},
[this.getCustomField("medusaId", "product")]: {
"en-US": p.id,
},
}
if (p.images.length > 0) {
const imageLinks = await this.createImageAssets(product)
if (imageLinks) {
fields.images = {
"en-US": imageLinks,
}
}
}
if (p.thumbnail) {
const thumbnailAsset = await environment.createAsset({
fields: {
title: {
"en-US": `${p.title}`,
},
description: {
"en-US": "",
},
file: {
"en-US": {
contentType: "image/xyz",
fileName: p.thumbnail,
upload: p.thumbnail,
},
},
},
})
await thumbnailAsset.processForAllLocales().then((a) => a.publish())
const thumbnailLink = {
sys: {
type: "Link",
linkType: "Asset",
id: thumbnailAsset.sys.id,
},
}
fields.thumbnail = {
"en-US": thumbnailLink,
}
}
await this.createSpecialProductFields(fields, p)
const result = await environment.createEntryWithId("product", p.id, {
fields,
})
return result
}
async createProductVariantInContentful(variant) {
const v = await this.productVariantService_.retrieve(variant.id, {
relations: ["prices", "options"],
})
let sku = v.sku
if (this.featureFlagRouter_.isFeatureEnabled("inventoryService")) {
const [inventoryItem] =
await this.productVariantInventoryService_.listInventoryItemsByVariant(
v.id
)
if (inventoryItem) {
sku = inventoryItem.sku
}
}
const environment = await this.getContentfulEnvironment_()
const result = await environment.createEntryWithId("productVariant", v.id, {
fields: {
[this.getCustomField("title", "variant")]: {
"en-US": v.title,
},
[this.getCustomField("sku", "variant")]: {
"en-US": sku,
},
[this.getCustomField("prices", "variant")]: {
"en-US": this.transformMedusaIds(v.prices),
},
[this.getCustomField("options", "variant")]: {
"en-US": this.transformMedusaIds(v.options),
},
[this.getCustomField("medusaId", "variant")]: {
"en-US": v.id,
},
},
})
return result
}
async createRegionInContentful(region) {
const hasType = await this.getType("region")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const r = await this.regionService_.retrieve(region.id, {
relations: ["countries", "payment_providers", "fulfillment_providers"],
})
const environment = await this.getContentfulEnvironment_()
const fields = {
[this.getCustomField("medusaId", "region")]: {
"en-US": r.id,
},
[this.getCustomField("name", "region")]: {
"en-US": r.name,
},
[this.getCustomField("countries", "region")]: {
"en-US": r.countries,
},
[this.getCustomField("paymentProviders", "region")]: {
"en-US": r.payment_providers,
},
[this.getCustomField("fulfillmentProviders", "region")]: {
"en-US": r.fulfillment_providers,
},
}
const result = await environment.createEntryWithId("region", r.id, {
fields,
})
return result
}
async updateRegionInContentful(data) {
const hasType = await this.getType("region")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const updateFields = [
"name",
"currency_code",
"countries",
"payment_providers",
"fulfillment_providers",
]
const found = data.fields.find((f) => updateFields.includes(f))
if (!found) {
return
}
const ignore = await this.shouldIgnore_(data.id, "contentful")
if (ignore) {
return
}
const r = await this.regionService_.retrieve(data.id, {
relations: ["countries", "payment_providers", "fulfillment_providers"],
})
const environment = await this.getContentfulEnvironment_()
// check if region exists
let regionEntry = undefined
try {
regionEntry = await environment.getEntry(data.id)
} catch (error) {
return this.createRegionInContentful(r)
}
const regionEntryFields = {
...regionEntry.fields,
[this.getCustomField("name", "region")]: {
"en-US": r.name,
},
[this.getCustomField("countries", "region")]: {
"en-US": r.countries,
},
[this.getCustomField("paymentProviders", "region")]: {
"en-US": r.payment_providers,
},
[this.getCustomField("fulfillmentProviders", "region")]: {
"en-US": r.fulfillment_providers,
},
}
regionEntry.fields = regionEntryFields
const updatedEntry = await regionEntry.update()
const publishedEntry = await updatedEntry.publish()
await this.addIgnore_(data.id, "medusa")
return publishedEntry
}
async createCollectionInContentful(collection) {
const hasType = await this.getType("collection")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const environment = await this.getContentfulEnvironment_()
const fields = {
[this.getCustomField("medusaId", "collection")]: {
"en-US": collection.id,
},
[this.getCustomField("title", "collection")]: {
"en-US": collection.title,
},
}
const result = await environment.createEntryWithId(
"collection",
collection.id,
{
fields,
}
)
return result
}
async createTypeInContentful(type) {
const hasType = await this.getType("productType")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const environment = await this.getContentfulEnvironment_()
const fields = {
[this.getCustomField("medusaId", "type")]: {
"en-US": type.id,
},
[this.getCustomField("name", "type")]: {
"en-US": type.value,
},
}
const result = await environment.createEntryWithId("productType", type.id, {
fields,
})
return result
}
async upsertTypeEntry(type) {
const hasType = await this.getType("productType")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const environment = await this.getContentfulEnvironment_()
// check if type exists
let typeEntry = undefined
try {
typeEntry = await environment.getEntry(type.id)
} catch (error) {
return this.createTypeInContentful(type)
}
const typeEntryFields = {
...typeEntry.fields,
[this.getCustomField("name", "type")]: {
"en-US": type.value,
},
}
typeEntry.fields = typeEntryFields
return await typeEntry.update()
}
async upsertCollectionEntry(collection) {
const hasType = await this.getType("collection")
.then(() => true)
.catch(() => false)
if (!hasType) {
return Promise.resolve()
}
const environment = await this.getContentfulEnvironment_()
// check if collection exists
let collectionEntry = undefined
try {
collectionEntry = await environment.getEntry(collection.id)
} catch (error) {
return this.createCollectionInContentful(collection)
}
const collectionEntryFields = {
...collectionEntry.fields,
[this.getCustomField("title", "collection")]: {
"en-US": collection.title,
},
}
collectionEntry.fields = collectionEntryFields
return await collectionEntry.update()
}
async updateProductInContentful(data) {
const updateFields = [
"variants",
"options",
"tags",
"title",
"subtitle",
"tags",
"type",
"type_id",
"collection",
"collection_id",
"thumbnail",
]
const found = data.fields.find((f) => updateFields.includes(f))
if (!found) {
return Promise.resolve()
}
const ignore = await this.shouldIgnore_(data.id, "contentful")
if (ignore) {
return Promise.resolve()
}
const p = await this.productService_.retrieve(data.id, {
relations: [
"options",
"variants",
"type",
"collection",
"tags",
"images",
],
})
const environment = await this.getContentfulEnvironment_()
// check if product exists
let productEntry = undefined
try {
productEntry = await environment.getEntry(data.id)
} catch (error) {
return this.createProductInContentful(p)
}
const variantEntries = await this.getVariantEntries_(p.variants)
const variantLinks = this.getVariantLinks_(variantEntries)
const productEntryFields = {
...productEntry.fields,
[this.getCustomField("title", "product")]: {
"en-US": p.title,
},
[this.getCustomField("subtitle", "product")]: {
"en-US": p.subtitle,
},
[this.getCustomField("description", "product")]: {
"en-US": p.description,
},
[this.getCustomField("options", "product")]: {
"en-US": this.transformMedusaIds(p.options),
},
[this.getCustomField("variants", "product")]: {
"en-US": variantLinks,
},
[this.getCustomField("medusaId", "product")]: {
"en-US": p.id,
},
}
if (data.fields.includes("thumbnail") && p.thumbnail) {
let url = p.thumbnail
if (p.thumbnail.startsWith("//")) {
url = `https:${url}`
}
const thumbnailAsset = await environment.createAsset({
fields: {
title: {
"en-US": `${p.title}`,
},
description: {
"en-US": "",
},
file: {
"en-US": {
contentType: "image/xyz",
fileName: url,
upload: url,
},
},
},
})
await thumbnailAsset.processForAllLocales().then((a) => a.publish())
const thumbnailLink = {
sys: {
type: "Link",
linkType: "Asset",
id: thumbnailAsset.sys.id,
},
}
productEntryFields.thumbnail = {
"en-US": thumbnailLink,
}
}
await this.createSpecialProductFields(productEntryFields, p)
productEntry.fields = productEntryFields
const updatedEntry = await productEntry.update()
const publishedEntry = await updatedEntry.publish()
await this.addIgnore_(data.id, "medusa")
return publishedEntry
}
async createSpecialProductFields(fields, p) {
const capabilities = await this.checkCapabilities("product")
if (p.type) {
if (capabilities.type) {
const val = {
"en-US": this.getLink_(await this.upsertTypeEntry(p.type)),
}
fields[this.getCustomField("type", "product")] = val
} else {
const type = {
"en-US": p.type.value,
}
fields[this.getCustomField("type", "product")] = type
}
}
if (p.collection) {
if (capabilities.collection) {
const val = {
"en-US": this.getLink_(
await this.upsertCollectionEntry(p.collection)
),
}
fields[this.getCustomField("collection", "product")] = val
} else {
const collection = {
"en-US": p.collection.title,
}
fields[this.getCustomField("collection", "product")] = collection
}
}
if (p.tags) {
const tags = {
"en-US": p.tags,
}
fields[this.getCustomField("tags", "product")] = tags
}
if (p.handle) {
const handle = {
"en-US": p.handle,
}
fields[this.getCustomField("handle", "product")] = handle
}
}
async updateProductVariantInContentful(variant) {
const updateFields = [
"title",
"prices",
"sku",
"material",
"weight",
"length",
"height",
"origin_country",
"options",
]
// Update came directly from product variant service so only act on a couple
// of fields. When the update comes from the product we want to ensure
// references are set up correctly so we run through everything.
if (variant.fields) {
const found = variant.fields.find((f) => updateFields.includes(f))
if (!found) {
return Promise.resolve()
}
}
const ignore = await this.shouldIgnore_(variant.id, "contentful")
if (ignore) {
return Promise.resolve()
}
const environment = await this.getContentfulEnvironment_()
// check if product exists
let variantEntry = undefined
// if not, we create a new one
try {
variantEntry = await environment.getEntry(variant.id)
} catch (error) {
return this.createProductVariantInContentful(variant)
}
const v = await this.productVariantService_.retrieve(variant.id, {
relations: ["prices", "options"],
})
let sku = v.sku
if (this.featureFlagRouter_.isFeatureEnabled("inventoryService")) {
const [inventoryItem] =
await this.productVariantInventoryService_.listInventoryItemsByVariant(
v.id
)
if (inventoryItem) {
sku = inventoryItem.sku
}
}
const variantEntryFields = {
...variantEntry.fields,
[this.getCustomField("title", "variant")]: {
"en-US": v.title,
},
[this.getCustomField("sku", "variant")]: {
"en-US": sku,
},
[this.getCustomField("options", "variant")]: {
"en-US": this.transformMedusaIds(v.options),
},
[this.getCustomField("prices", "variant")]: {
"en-US": this.transformMedusaIds(v.prices),
},
[this.getCustomField("medusaId", "variant")]: {
"en-US": v.id,
},
}
variantEntry.fields = variantEntryFields
const updatedEntry = await variantEntry.update()
const publishedEntry = await updatedEntry.publish()
await this.addIgnore_(variant.id, "medusa")
return publishedEntry
}
async archiveProductVariantInContentful(variant) {
let variantEntity
const ignore = await this.shouldIgnore_(variant.id, "contentful")
if (ignore) {
return Promise.resolve()
}
try {
variantEntity = await this.productVariantService_.retrieve(variant.id)
} catch (err) {
// ignore
}
if (variantEntity) {
return Promise.resolve()
}
return await this.archiveEntryWidthId(variant.id)
}
async archiveProductInContentful(product) {
let productEntity
const ignore = await this.shouldIgnore_(product.id, "contentful")
if (ignore) {
return Promise.resolve()
}
try {
productEntity = await this.productService_.retrieve(product.id)
} catch (err) {
// noop
}
if (productEntity) {
return Promise.resolve()
}
return await this.archiveEntryWidthId(product.id)
}
async archiveRegionInContentful(region) {
let regionEntity
const ignore = await this.shouldIgnore_(region.id, "contentful")
if (ignore) {
return Promise.resolve()
}
try {
regionEntity = await this.regionService_.retrieve(region.id)
} catch (err) {
// noop
}
if (regionEntity) {
return Promise.resolve()
}
return await this.archiveEntryWidthId(region.id)
}
async archiveEntryWidthId(id) {
const environment = await this.getContentfulEnvironment_()
// check if product exists
let entry = undefined
try {
entry = await environment.getEntry(id)
} catch (error) {
return Promise.resolve()
}
const unpublishEntry = await entry.unpublish()
const archivedEntry = await entry.archive()
await this.addIgnore_(id, "medusa")
return archivedEntry
}
async sendContentfulProductToAdmin(productId) {
const ignore = await this.shouldIgnore_(productId, "medusa")
if (ignore) {
return
}
const environment = await this.getContentfulEnvironment_()
const productEntry = await environment.getEntry(productId)
const product = await this.productService_.retrieve(productId, {
select: ["id", "handle", "title", "subtitle", "description", "thumbnail"],
})
const update = {}
const title =
productEntry.fields[this.getCustomField("title", "product")]?.["en-US"]
const subtitle =
productEntry.fields[this.getCustomField("subtitle", "product")]?.["en-US"]
const description =
productEntry.fields[this.getCustomField("description", "product")]?.[
"en-US"
]
const handle =
productEntry.fields[this.getCustomField("handle", "product")]?.["en-US"]
if (product.title !== title) {
update.title = title
}
if (product.subtitle !== subtitle) {
update.subtitle = subtitle
}
if (product.description !== description) {
update.description = description
}
if (product.handle !== handle) {
update.handle = handle
}
// Get the thumbnail, if present
if (productEntry.fields.thumbnail) {
const thumb = await environment.getAsset(
productEntry.fields.thumbnail["en-US"].sys.id
)
if (thumb.fields.file["en-US"].url) {
if (!product.thumbnail?.includes(thumb.fields.file["en-US"].url)) {
update.thumbnail = thumb.fields.file["en-US"].url
}
}
}
if (!_.isEmpty(update)) {
await this.productService_.update(productId, update).then(async () => {
return await this.addIgnore_(productId, "contentful")
})
}
}
async sendContentfulProductVariantToAdmin(variantId) {
const ignore = this.shouldIgnore_(variantId, "medusa")
if (ignore) {
return
}
const environment = await this.getContentfulEnvironment_()
const variantEntry = await environment.getEntry(variantId)
const updatedVariant = await this.productVariantService_
.update(variantId, {
title:
variantEntry.fields[this.getCustomField("title", "variant")]["en-US"],
})
.then(async () => {
return await this.addIgnore_(variantId, "contentful")
})
return updatedVariant
}
transformMedusaIds(objOrArray) {
let input = objOrArray
let isArray = true
if (!Array.isArray(objOrArray)) {
input = [objOrArray]
isArray = false
}
const output = []
for (const obj of input) {
const transformed = Object.assign({}, obj)
transformed.medusaId = obj.id
output.push(transformed)
}
if (!isArray) {
return output[0]
}
return output
}
async getType(type) {
const environment = await this.getContentfulEnvironment_()
return environment.getContentType(type)
}
async checkCapabilities(type) {
switch (type) {
case "product":
return this.checkProductCapabilities()
default:
return {}
}
}
async checkProductCapabilities() {
if (this.capab_["product"]) {
return this.capab_["product"]
}
const product = await this.getType("product")
const capabilities = {
collection: false,
type: false,
}
if (product.fields) {
const typeField = product.fields.find((f) => f.id === "type")
if (typeField) {
capabilities.type = typeField.linkType === "Entry"
}
const collectionField = product.fields.find((f) => f.id === "collection")
if (collectionField) {
capabilities.collection = collectionField.linkType === "Entry"
}
}
this.capab_["product"] = capabilities
return capabilities
}
}
export default ContentfulService

View File

@@ -1,47 +0,0 @@
class ContentfulSubscriber {
constructor({
contentfulService,
productVariantService,
productService,
eventBusService,
}) {
this.productVariantService_ = productVariantService
this.productService_ = productService
this.contentfulService_ = contentfulService
this.eventBus_ = eventBusService
this.eventBus_.subscribe("region.created", async (data) => {
await this.contentfulService_.createRegionInContentful(data)
})
this.eventBus_.subscribe("region.updated", async (data) => {
await this.contentfulService_.updateRegionInContentful(data)
})
this.eventBus_.subscribe("region.deleted", async (data) => {
await this.contentfulService_.updateRegionInContentful(data)
})
this.eventBus_.subscribe("product-variant.updated", async (data) => {
await this.contentfulService_.updateProductVariantInContentful(data)
})
this.eventBus_.subscribe("product-variant.deleted", async (data) => {
await this.contentfulService_.archiveProductVariantInContentful(data)
})
this.eventBus_.subscribe("product.updated", async (data) => {
await this.contentfulService_.updateProductInContentful(data)
})
this.eventBus_.subscribe("product.created", async (data) => {
await this.contentfulService_.createProductInContentful(data)
})
this.eventBus_.subscribe("product.deleted", async (data) => {
await this.contentfulService_.archiveProductInContentful(data)
})
}
}
export default ContentfulSubscriber

View File

@@ -1,4 +0,0 @@
dist
node_modules
.DS_store
yarn.lock

View File

@@ -1,413 +0,0 @@
# Change Log
## 2.0.10
### Patch Changes
- [#4623](https://github.com/medusajs/medusa/pull/4623) [`107ae23a3`](https://github.com/medusajs/medusa/commit/107ae23a3f41ef0d676e9d03f53dafc7c1af6118) Thanks [@riqwan](https://github.com/riqwan)! - fix(utils, types, medusa-plugin-meilisearch, medusa-plugin-algolia): move SoftDeletableFilterKey, variantKeys, indexTypes from types to utils
- Updated dependencies [[`107ae23a3`](https://github.com/medusajs/medusa/commit/107ae23a3f41ef0d676e9d03f53dafc7c1af6118)]:
- @medusajs/utils@1.9.4
## 2.0.9
### Patch Changes
- [#4420](https://github.com/medusajs/medusa/pull/4420) [`6f1fa244f`](https://github.com/medusajs/medusa/commit/6f1fa244fa47d4ecdaa7363483bd7da555dbbf32) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa-cli): Cleanup plugin setup + include Logger type update which is used across multiple packages
- Updated dependencies [[`499c3478c`](https://github.com/medusajs/medusa/commit/499c3478c910c8b922a15cc6f4d9fbad122a347f), [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086), [`9760d4a96`](https://github.com/medusajs/medusa/commit/9760d4a96c27f6f89a8c3f3b6e73b17547f97f2a)]:
- @medusajs/utils@1.9.2
## 2.0.8
### Patch Changes
- chore: Update deps
## 2.0.7
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
- Updated dependencies [[`f98ba5bde`](https://github.com/medusajs/medusa/commit/f98ba5bde83ba785eead31b0c9eb9f135d664178), [`14c0f62f8`](https://github.com/medusajs/medusa/commit/14c0f62f84704a4c87beff3daaff60a52f5c88b8)]:
- @medusajs/utils@1.9.1
- @medusajs/modules-sdk@1.8.8
## 2.0.6
### Patch Changes
- Updated dependencies [[`a91987fab`](https://github.com/medusajs/medusa/commit/a91987fab33745f9864eab21bd1c27e8e3e24571), [`db4199530`](https://github.com/medusajs/medusa/commit/db419953075e0907b8c4d27ab5188e9bd3e3d72b), [`c0e527d6e`](https://github.com/medusajs/medusa/commit/c0e527d6e0a67d0c53577a0b9c3d16ee8dc5740f)]:
- @medusajs/utils@1.9.0
## 2.0.5
### Patch Changes
- Updated dependencies [[`cdbac2c84`](https://github.com/medusajs/medusa/commit/cdbac2c8403a3c15c0e11993f6b7dab268fa5c08), [`6511959e2`](https://github.com/medusajs/medusa/commit/6511959e23177f3b4831915db0e8e788bc9047fa)]:
- @medusajs/utils@1.8.5
## 2.0.4
### Patch Changes
- Updated dependencies [[`1ea57c3a6`](https://github.com/medusajs/medusa/commit/1ea57c3a69a5377a8dd0821df819743ded4a222b)]:
- @medusajs/utils@1.8.4
## 2.0.3
### Patch Changes
- Updated dependencies [[`0e488e71b`](https://github.com/medusajs/medusa/commit/0e488e71b186f7d08b18c4c6ba409ef3cadb8152), [`d539c6fee`](https://github.com/medusajs/medusa/commit/d539c6feeba8ee431f9a655b6cd4e9102cba2b25)]:
- @medusajs/utils@1.8.3
## 2.0.2
### Patch Changes
- [#3898](https://github.com/medusajs/medusa/pull/3898) [`aec7ae219`](https://github.com/medusajs/medusa/commit/aec7ae219de9e84a43e4945cb62b04d96672d6d2) Thanks [@pevey](https://github.com/pevey)! - Update meilisearch library dependency
- Updated dependencies [[`af710f1b4`](https://github.com/medusajs/medusa/commit/af710f1b48a4545a5064029a557013af34c4c100), [`491566df6`](https://github.com/medusajs/medusa/commit/491566df6b7ced35f655f810961422945e10ecd0)]:
- @medusajs/utils@1.8.2
## 2.0.1
### Patch Changes
- Updated dependencies [[`654a54622`](https://github.com/medusajs/medusa/commit/654a54622303139e7180538bd686630ad9a46cfd), [`abdb74d99`](https://github.com/medusajs/medusa/commit/abdb74d997f49f994bff49787a396179982843b0)]:
- @medusajs/utils@1.8.1
## 2.0.0
### Major Changes
- [#3377](https://github.com/medusajs/medusa/pull/3377) [`7e17e0ddc`](https://github.com/medusajs/medusa/commit/7e17e0ddc2e6b2891e9ee1420b04a541899d2a9d) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-meilisearch): Update + improve Meilisearch plugin
**What**
- Bumps `meilisearch` dep to latest major
- Migrates plugin to TypeScript
- Changes the way indexes are configured in `medusa-config.js`:
**Before**
```
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: { host: "...", apiKey: "..." },
settings: {
products: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],
},
},
},
},
```
**After**
```
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: { host: "...", apiKey: "..." },
settings: {
products: {
**indexSettings**: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],
},
},
},
},
},
```
This is done to allow for additional configuration of indexes, that are not necessarily passed on query-time.
We introduce two new settings:
```
settings: {
products: {
indexSettings: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],,
},
primaryKey: "id"
transformer: (document) => ({ id: "yo" })
},
},
```
Meilisearch changed their primary key inference in the major release. Now we must be explicit when multiple properties end with `id`. Read more in their [docs](https://docs.meilisearch.com/learn/core_concepts/primary_key.html#primary-field).
The transformer allows developers to specify how their documents are stored in Meilisearch. It is configurable for each index.
### Patch Changes
- [#3685](https://github.com/medusajs/medusa/pull/3685) [`8ddb3952c`](https://github.com/medusajs/medusa/commit/8ddb3952c045e6c05c8d0f6922f0d4ba30cf3bd4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Fix RC package versions
- [#3510](https://github.com/medusajs/medusa/pull/3510) [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-algolia): Revamp Algolia search plugin
- [#3531](https://github.com/medusajs/medusa/pull/3531) [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Remove dependency on @medusajs/medusa from Inventory and Stock-Location Modules
- Updated dependencies [[`8ddb3952c`](https://github.com/medusajs/medusa/commit/8ddb3952c045e6c05c8d0f6922f0d4ba30cf3bd4), [`a0c919a8d`](https://github.com/medusajs/medusa/commit/a0c919a8d01ca5edf62336de48e9a112e3822f38), [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb), [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def)]:
- @medusajs/utils@1.8.0
## 2.0.0-rc.2
### Patch Changes
- Updated dependencies [[`a0c919a8d`](https://github.com/medusajs/medusa/commit/a0c919a8d01ca5edf62336de48e9a112e3822f38)]:
- @medusajs/utils@0.0.2-rc.2
## 2.0.0-rc.1
### Patch Changes
- chore: Fix RC package versions
- Updated dependencies []:
- @medusajs/utils@0.0.2-rc.1
## 2.0.0-rc.0
### Major Changes
- [#3377](https://github.com/medusajs/medusa/pull/3377) [`7e17e0ddc`](https://github.com/medusajs/medusa/commit/7e17e0ddc2e6b2891e9ee1420b04a541899d2a9d) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-meilisearch): Update + improve Meilisearch plugin
**What**
- Bumps `meilisearch` dep to latest major
- Migrates plugin to TypeScript
- Changes the way indexes are configured in `medusa-config.js`:
**Before**
```
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: { host: "...", apiKey: "..." },
settings: {
products: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],
},
},
},
},
```
**After**
```
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: { host: "...", apiKey: "..." },
settings: {
products: {
**indexSettings**: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],
},
},
},
},
},
```
This is done to allow for additional configuration of indexes, that are not necessarily passed on query-time.
We introduce two new settings:
```
settings: {
products: {
indexSettings: {
searchableAttributes: ["title"],
displayedAttributes: ["title"],,
},
primaryKey: "id"
transformer: (document) => ({ id: "yo" })
},
},
```
Meilisearch changed their primary key inference in the major release. Now we must be explicit when multiple properties end with `id`. Read more in their [docs](https://docs.meilisearch.com/learn/core_concepts/primary_key.html#primary-field).
The transformer allows developers to specify how their documents are stored in Meilisearch. It is configurable for each index.
### Patch Changes
- [#3510](https://github.com/medusajs/medusa/pull/3510) [`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa-plugin-algolia): Revamp Algolia search plugin
- [#3531](https://github.com/medusajs/medusa/pull/3531) [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Remove dependency on @medusajs/medusa from Inventory and Stock-Location Modules
- Updated dependencies [[`74bc4b16a`](https://github.com/medusajs/medusa/commit/74bc4b16a07f78668003ca930bf2a0d928897ceb), [`4e9d257d3`](https://github.com/medusajs/medusa/commit/4e9d257d3bf76703ef5be8ca054cc9f0f7339def)]:
- @medusajs/utils@0.0.2-rc.0
## 1.0.4
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.0.3
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.0.2
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.0.1
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
## 1.0.0
### Major Changes
- [#2140](https://github.com/medusajs/medusa/pull/2140) [`e707b4649`](https://github.com/medusajs/medusa/commit/e707b46499e05e7244fe7a9788995a826680d4ed) Thanks [@olivermrbl](https://github.com/olivermrbl)! - Update meilisearch deps to respect latest breaking changes
BREAKING CHANGE
## 0.2.5
### Patch Changes
- Updated dependencies [[`c97ccd3fb`](https://github.com/medusajs/medusa/commit/c97ccd3fb5dbe796b0e4fbf37def5bb6e8201557)]:
- medusa-interfaces@1.3.3
## 0.2.4
### Patch Changes
- [#1914](https://github.com/medusajs/medusa/pull/1914) [`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68) Thanks [@fPolic](https://github.com/fPolic)! - Version bump due to missing changesets in merged PRs
- Updated dependencies [[`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68), [`b8ddb31f6`](https://github.com/medusajs/medusa/commit/b8ddb31f6fe296a11d2d988276ba8e991c37fa9b)]:
- medusa-interfaces@1.3.2
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.3](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.2.2...medusa-plugin-meilisearch@0.2.3) (2022-07-05)
### Bug Fixes
- **meilisearch:** remove medusa-interfaces dependency ([#1751](https://github.com/medusajs/medusa/issues/1751)) ([f7e300e](https://github.com/medusajs/medusa/commit/f7e300e8cec082cab23626907333682e9a643238))
## [0.2.2](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.2.0...medusa-plugin-meilisearch@0.2.2) (2022-06-19)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.2.0...medusa-plugin-meilisearch@0.2.1) (2022-05-31)
**Note:** Version bump only for package medusa-plugin-meilisearch
# [0.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.1.1...medusa-plugin-meilisearch@0.2.0) (2022-05-01)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.14...medusa-plugin-meilisearch@0.1.1) (2022-02-28)
**Note:** Version bump only for package medusa-plugin-meilisearch
# [0.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.14...medusa-plugin-meilisearch@0.1.0) (2022-02-25)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.13...medusa-plugin-meilisearch@0.0.14) (2022-02-06)
### Bug Fixes
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
## [0.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.12...medusa-plugin-meilisearch@0.0.13) (2022-02-06)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.11...medusa-plugin-meilisearch@0.0.12) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.11](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.10...medusa-plugin-meilisearch@0.0.11) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.10](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.9...medusa-plugin-meilisearch@0.0.10) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.9](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.8...medusa-plugin-meilisearch@0.0.9) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.8](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.7...medusa-plugin-meilisearch@0.0.8) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.6...medusa-plugin-meilisearch@0.0.7) (2021-11-03)
### Bug Fixes
- include discount rule in swap retrieval ([#682](https://github.com/medusajs/medusa/issues/682)) ([a5fe1c2](https://github.com/medusajs/medusa/commit/a5fe1c2e284ff5cb757b792c1a3c8414c211e4e8))
## [0.0.6](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.5...medusa-plugin-meilisearch@0.0.6) (2021-10-19)
### Bug Fixes
- allow changing regions safely ([06f5fe2](https://github.com/medusajs/medusa/commit/06f5fe267013d95231d96318fe8a055ad8040174))
- cleanup ([5441d47](https://github.com/medusajs/medusa/commit/5441d47f88d759742e3d3d29b29bc38feceac583))
## [0.0.5](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.4...medusa-plugin-meilisearch@0.0.5) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-meilisearch
## [0.0.4](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.3...medusa-plugin-meilisearch@0.0.4) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-meilisearch
## 0.0.3 (2021-10-18)
### Bug Fixes
- meiliesearch README.md + remove: searchService from silentResolver ([1444353](https://github.com/medusajs/medusa/commit/1444353b0af4e18a23cebbf46b6d1246aa495bb4))
- move subscriber to core ([700f8c3](https://github.com/medusajs/medusa/commit/700f8c39190469337c74d9bf3f046f293024e521))
- remove package-lock ([08b2d8f](https://github.com/medusajs/medusa/commit/08b2d8fc39e7e04fadbfb012fcbc083febf9c290))
- use type to choose transformer before adding or replacing documents ([24eecd2](https://github.com/medusajs/medusa/commit/24eecd2922e0c3425f2d43549b3227c756820387))
## 0.0.2 (2021-10-18)
### Bug Fixes
- meiliesearch README.md + remove: searchService from silentResolver ([1444353](https://github.com/medusajs/medusa/commit/1444353b0af4e18a23cebbf46b6d1246aa495bb4))
- move subscriber to core ([700f8c3](https://github.com/medusajs/medusa/commit/700f8c39190469337c74d9bf3f046f293024e521))
- remove package-lock ([08b2d8f](https://github.com/medusajs/medusa/commit/08b2d8fc39e7e04fadbfb012fcbc083febf9c290))
- use type to choose transformer before adding or replacing documents ([24eecd2](https://github.com/medusajs/medusa/commit/24eecd2922e0c3425f2d43549b3227c756820387))

View File

@@ -1,93 +0,0 @@
# MeiliSearch
Provide powerful indexing and searching features in your commerce application with MeiliSearch.
[MeiliSearch Plugin Documentation](https://docs.medusajs.com/plugins/search/meilisearch) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Flexible configurations for specifying searchable and retrievable attributes.
- Ready-integration with [Medusa's Next.js starter storefront](https://docs.medusajs.com/starters/nextjs-medusa-starter).
- Utilize MeiliSearch's powerful search functionalities including typo-tolerance, synonyms, filtering, and more.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [MeiliSearch instance](https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-meilisearch
```
2\. Set the following environment variables in `.env`:
```bash
MEILISEARCH_HOST=<YOUR_MEILISEARCH_HOST>
MEILISEARCH_API_KEY=<YOUR_MASTER_KEY>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: {
host: process.env.MEILISEARCH_HOST,
apiKey: process.env.MEILISEARCH_API_KEY,
},
settings: {
products: {
indexSettings: {
searchableAttributes: [
"title",
"description",
"variant_sku",
],
displayedAttributes: [
"title",
"description",
"variant_sku",
"thumbnail",
"handle",
],
},
primaryKey: "id",
transformer: (product) => ({
id: product.id,
// other attributes...
}),
},
},
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Try searching products either using your storefront or using the [Store APIs](https://docs.medusajs.com/api/store#tag/Product/operation/PostProductsSearch).
---
## Additional Resources
- [MeiliSearch Plugin Documentation](https://docs.medusajs.com/plugins/search/meilisearch)

View File

@@ -1,13 +0,0 @@
module.exports = {
globals: {
"ts-jest": {
tsconfig: "tsconfig.spec.json",
isolatedModules: false,
},
},
transform: {
"^.+\\.[jt]s?$": "ts-jest",
},
testEnvironment: `node`,
moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`],
}

View File

@@ -1,47 +0,0 @@
{
"name": "medusa-plugin-meilisearch",
"version": "2.0.10",
"description": "Meilisearch search plugin for Medusa",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-meilisearch"
},
"engines": {
"node": ">=16"
},
"files": [
"dist"
],
"author": "Medusa",
"license": "MIT",
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"test": "jest --passWithNoTests src",
"build": "rimraf dist && tsc",
"watch": "tsc --watch"
},
"dependencies": {
"@medusajs/modules-sdk": "^1.8.8",
"@medusajs/utils": "^1.9.4",
"body-parser": "^1.19.0",
"lodash": "^4.17.21",
"meilisearch": "^0.32.3"
},
"peerDependencies": {
"@medusajs/medusa": "^1.12.0"
},
"devDependencies": {
"@medusajs/medusa": "^1.12.2",
"@medusajs/types": "^1.10.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"rimraf": "^5.0.1",
"typescript": "^4.9.5"
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
"keywords": [
"medusa-plugin",
"medusa-plugin-search"
]
}

View File

@@ -1,27 +0,0 @@
import { MedusaContainer } from "@medusajs/modules-sdk"
import { Logger } from "@medusajs/types"
import MeiliSearchService from "../services/meilisearch"
import { MeilisearchPluginOptions } from "../types"
export default async (
container: MedusaContainer,
options: MeilisearchPluginOptions
) => {
const logger: Logger = container.resolve("logger")
try {
const meilisearchService: MeiliSearchService =
container.resolve("meilisearchService")
const { settings } = options
await Promise.all(
Object.entries(settings || {}).map(async ([indexName, value]) => {
return await meilisearchService.updateSettings(indexName, value)
})
)
} catch (err) {
// ignore
logger.warn(err)
}
}

View File

@@ -1,120 +0,0 @@
import { SearchTypes } from "@medusajs/types"
import { SearchUtils } from "@medusajs/utils"
import { MeiliSearch, Settings } from "meilisearch"
import { meilisearchErrorCodes, MeilisearchPluginOptions } from "../types"
import { transformProduct } from "../utils/transformer"
class MeiliSearchService extends SearchUtils.AbstractSearchService {
isDefault = false
protected readonly config_: MeilisearchPluginOptions
protected readonly client_: MeiliSearch
constructor(_, options: MeilisearchPluginOptions) {
super(_, options)
this.config_ = options
if (process.env.NODE_ENV !== "development") {
if (!options.config?.apiKey) {
throw Error(
"Meilisearch API key is missing in plugin config. See https://docs.medusajs.com/add-plugins/meilisearch"
)
}
}
if (!options.config?.host) {
throw Error(
"Meilisearch host is missing in plugin config. See https://docs.medusajs.com/add-plugins/meilisearch"
)
}
this.client_ = new MeiliSearch(options.config)
}
async createIndex(
indexName: string,
options: Record<string, unknown> = { primaryKey: "id" }
) {
return await this.client_.createIndex(indexName, options)
}
getIndex(indexName: string) {
return this.client_.index(indexName)
}
async addDocuments(indexName: string, documents: any, type: string) {
const transformedDocuments = this.getTransformedDocuments(type, documents)
return await this.client_
.index(indexName)
.addDocuments(transformedDocuments)
}
async replaceDocuments(indexName: string, documents: any, type: string) {
const transformedDocuments = this.getTransformedDocuments(type, documents)
return await this.client_
.index(indexName)
.addDocuments(transformedDocuments)
}
async deleteDocument(indexName: string, documentId: string) {
return await this.client_.index(indexName).deleteDocument(documentId)
}
async deleteAllDocuments(indexName: string) {
return await this.client_.index(indexName).deleteAllDocuments()
}
async search(indexName: string, query: string, options: Record<string, any>) {
const { paginationOptions, filter, additionalOptions } = options
return await this.client_
.index(indexName)
.search(query, { filter, ...paginationOptions, ...additionalOptions })
}
async updateSettings(
indexName: string,
settings: SearchTypes.IndexSettings & Settings
) {
// backward compatibility
const indexSettings = settings.indexSettings ?? settings ?? {}
await this.upsertIndex(indexName, settings)
return await this.client_.index(indexName).updateSettings(indexSettings)
}
async upsertIndex(indexName: string, settings: SearchTypes.IndexSettings) {
try {
await this.client_.getIndex(indexName)
} catch (error) {
if (error.code === meilisearchErrorCodes.INDEX_NOT_FOUND) {
await this.createIndex(indexName, {
primaryKey: settings?.primaryKey ?? "id",
})
}
}
}
getTransformedDocuments(type: string, documents: any[]) {
if (!documents?.length) {
return []
}
switch (type) {
case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer =
this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct
return documents.map(productsTransformer)
default:
return documents
}
}
}
export default MeiliSearchService

View File

@@ -1,19 +0,0 @@
import { SearchTypes } from "@medusajs/types"
import { Config } from "meilisearch"
export const meilisearchErrorCodes = {
INDEX_NOT_FOUND: "index_not_found",
}
export interface MeilisearchPluginOptions {
/**
* Meilisearch client configuration
*/
config: Config
/**
* Index settings
*/
settings?: {
[key: string]: SearchTypes.IndexSettings
}
}

View File

@@ -1,43 +0,0 @@
import { variantKeys } from "@medusajs/utils"
const prefix = `variant`
export const transformProduct = (product: any) => {
let transformedProduct = { ...product } as Record<string, unknown>
const initialObj = variantKeys.reduce((obj, key) => {
obj[`${prefix}_${key}`] = []
return obj
}, {})
initialObj[`${prefix}_options_value`] = []
const flattenedVariantFields = product.variants.reduce((obj, variant) => {
variantKeys.forEach((k) => {
if (k === "options" && variant[k]) {
const values = variant[k].map((option) => option.value)
obj[`${prefix}_options_value`] =
obj[`${prefix}_options_value`].concat(values)
return
}
return variant[k] && obj[`${prefix}_${k}`].push(variant[k])
})
return obj
}, initialObj)
transformedProduct.type_value = product.type && product.type.value
transformedProduct.collection_title =
product.collection && product.collection.title
transformedProduct.collection_handle =
product.collection && product.collection.handle
transformedProduct.tags_value = product.tags
? product.tags.map((t) => t.value)
: []
transformedProduct.categories = (product?.categories || []).map((c) => c.name)
const prod = {
...transformedProduct,
...flattenedVariantFields,
}
return prod
}

View File

@@ -1,29 +0,0 @@
{
"compilerOptions": {
"lib": ["es2020"],
"target": "es2020",
"outDir": "./dist",
"esModuleInterop": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"allowJs": true,
"skipLibCheck": true,
"downlevelIteration": true // to use ES5 specific tooling
},
"include": ["src"],
"exclude": [
"dist",
"src/**/__tests__",
"src/**/__mocks__",
"src/**/__fixtures__",
"node_modules"
]
}

View File

@@ -1,5 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@@ -1,13 +0,0 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes"
],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}

View File

@@ -1,17 +0,0 @@
/lib
node_modules
.DS_store
.env*
/*.js
!index.js
!jest.config.js
/dist
/api
/services
/models
/subscribers
*.tgz

View File

@@ -1,9 +0,0 @@
.DS_store
src
dist
yarn.lock
.babelrc
jest.config.js
.turbo
.yarn

View File

@@ -1,391 +0,0 @@
# Change Log
## 1.3.12
### Patch Changes
- [`43205914c`](https://github.com/medusajs/medusa/commit/43205914cb5ff3587f00ac5cd7202db0e1c3dc97) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix: Support custom template
## 1.3.11
### Patch Changes
- [#4524](https://github.com/medusajs/medusa/pull/4524) [`fe6586e56`](https://github.com/medusajs/medusa/commit/fe6586e560ad20ec59df4727bb8a7f1f42072f4a) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix(medusa-plugin-sendgrid): Use correct SendGrid client
## 1.3.10
### Patch Changes
- [#4389](https://github.com/medusajs/medusa/pull/4389) [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa, utils): fix the way selects are consumed alongside the relations
- [#4384](https://github.com/medusajs/medusa/pull/4384) [`f65a501da`](https://github.com/medusajs/medusa/commit/f65a501da5101da75217a2b69a61ccd4fd3a3b4d) Thanks [@pevey](https://github.com/pevey)! - feat(medusa-plugin-sendgrid): Add error messages to SendgridService.sendNotification
## 1.3.9
### Patch Changes
- [#3763](https://github.com/medusajs/medusa/pull/3763) [`4104d9ccb`](https://github.com/medusajs/medusa/commit/4104d9ccb25276c85b5363f85e14b3093e64df85) Thanks [@StephixOne](https://github.com/StephixOne)! - fix(plugin-discount-generator,plugin-economic,plugin-mailchimp,plugin-restock-notification,plugin-sendgrid,plugin-wishlist): Temporarily remove payload validation in some plugins
## 1.3.8
### Patch Changes
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
- upgrade typeorm from 0.2.51 to 0.3.11
- Plugin repository loader to work with Typeorm update
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
- medusa-test-utils@1.1.40
## 1.3.8-rc.0
### Patch Changes
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
- upgrade typeorm from 0.2.51 to 0.3.11
- Plugin repository loader to work with Typeorm update
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
- medusa-test-utils@1.1.40-rc.0
## 1.3.7
### Patch Changes
- [#3238](https://github.com/medusajs/medusa/pull/3238) [`8194d19b0`](https://github.com/medusajs/medusa/commit/8194d19b0e933310fdc65af25300da5dd185e669) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix(medusa-plugin-sendgrid): Undefined order
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.3.6
### Patch Changes
- [#2941](https://github.com/medusajs/medusa/pull/2941) [`2551fe0b9`](https://github.com/medusajs/medusa/commit/2551fe0b935c19476828a05c47f4cf3e0d9e6d79) Thanks [@RegisHubelia](https://github.com/RegisHubelia)! - fix(medusa-plugin-sendgrid): Inject GiftCardService to eliminate undefined error
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.3.5
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.3.4
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.3](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.3.2...medusa-plugin-sendgrid@1.3.3) (2022-07-05)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.3.2](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.3.0...medusa-plugin-sendgrid@1.3.2) (2022-06-19)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.3.1](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.3.0...medusa-plugin-sendgrid@1.3.1) (2022-05-31)
**Note:** Version bump only for package medusa-plugin-sendgrid
# [1.3.0](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.2.1...medusa-plugin-sendgrid@1.3.0) (2022-05-01)
### Features
- Add DiscountConditions ([#1230](https://github.com/medusajs/medusa/issues/1230)) ([a610805](https://github.com/medusajs/medusa/commit/a610805917ee930d4cebde74905e541a468aa83b)), closes [#1146](https://github.com/medusajs/medusa/issues/1146) [#1149](https://github.com/medusajs/medusa/issues/1149) [#1156](https://github.com/medusajs/medusa/issues/1156) [#1170](https://github.com/medusajs/medusa/issues/1170) [#1172](https://github.com/medusajs/medusa/issues/1172) [#1212](https://github.com/medusajs/medusa/issues/1212) [#1224](https://github.com/medusajs/medusa/issues/1224) [#1228](https://github.com/medusajs/medusa/issues/1228)
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.38...medusa-plugin-sendgrid@1.2.1) (2022-02-28)
### Bug Fixes
- reset user password subscription in sendgrid plugin ([#1072](https://github.com/medusajs/medusa/issues/1072)) ([91263fb](https://github.com/medusajs/medusa/commit/91263fbc8e70a8566a496cce97ed6256e559a786))
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([47588e7](https://github.com/medusajs/medusa/commit/47588e7a8d3b2ae2fed0c1e87fdf1ee2db6bcdc2)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.38...medusa-plugin-sendgrid@1.2.0) (2022-02-25)
### Bug Fixes
- reset user password subscription in sendgrid plugin ([#1072](https://github.com/medusajs/medusa/issues/1072)) ([90121dd](https://github.com/medusajs/medusa/commit/90121dd19d5419e239ea5d1b6feda9e7bc754d63))
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([c56660f](https://github.com/medusajs/medusa/commit/c56660fca9921a3f3637bc137d9794781c5b090f)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.37...medusa-plugin-sendgrid@1.1.38) (2022-01-11)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.36...medusa-plugin-sendgrid@1.1.37) (2021-12-29)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.35...medusa-plugin-sendgrid@1.1.36) (2021-12-17)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.34...medusa-plugin-sendgrid@1.1.35) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.33...medusa-plugin-sendgrid@1.1.34) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.32...medusa-plugin-sendgrid@1.1.33) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.31...medusa-plugin-sendgrid@1.1.32) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.30...medusa-plugin-sendgrid@1.1.31) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.29...medusa-plugin-sendgrid@1.1.30) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.28...medusa-plugin-sendgrid@1.1.29) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.26...medusa-plugin-sendgrid@1.1.28) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.26...medusa-plugin-sendgrid@1.1.27) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.25...medusa-plugin-sendgrid@1.1.26) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [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.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.22...medusa-plugin-sendgrid@1.1.23) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.20...medusa-plugin-sendgrid@1.1.22) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.20...medusa-plugin-sendgrid@1.1.21) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.19...medusa-plugin-sendgrid@1.1.20) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.18...medusa-plugin-sendgrid@1.1.19) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.17...medusa-plugin-sendgrid@1.1.18) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.16...medusa-plugin-sendgrid@1.1.17) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.15...medusa-plugin-sendgrid@1.1.16) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.14...medusa-plugin-sendgrid@1.1.15) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.13...medusa-plugin-sendgrid@1.1.14) (2021-06-08)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.10...medusa-plugin-sendgrid@1.1.13) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.11...medusa-plugin-sendgrid@1.1.12) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.10...medusa-plugin-sendgrid@1.1.11) (2021-04-20)
### Features
- **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345))
- **medusa-plugin-sendgrid:** adds localization option ([#238](https://github.com/medusajs/medusa/issues/238)) ([a81ea1c](https://github.com/medusajs/medusa/commit/a81ea1c20a8779ba72e1ee5cc58c9b5335b79eca))
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.9...medusa-plugin-sendgrid@1.1.10) (2021-04-13)
### Bug Fixes
- creates restock functionality ([2b25550](https://github.com/medusajs/medusa/commit/2b2555004e52e97c15bfca59e030fdfc3d86ae49))
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
- normalize thumbanils ([26e7f20](https://github.com/medusajs/medusa/commit/26e7f203069547b954796c1f04f5844b406c1e33))
- restock ([237ed51](https://github.com/medusajs/medusa/commit/237ed5130760645c6b892fa1d5fc09a713b95f58))
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.8...medusa-plugin-sendgrid@1.1.9) (2021-04-13)
### Bug Fixes
- creates restock functionality ([2b25550](https://github.com/medusajs/medusa/commit/2b2555004e52e97c15bfca59e030fdfc3d86ae49))
- normalize thumbanils ([26e7f20](https://github.com/medusajs/medusa/commit/26e7f203069547b954796c1f04f5844b406c1e33))
- restock ([237ed51](https://github.com/medusajs/medusa/commit/237ed5130760645c6b892fa1d5fc09a713b95f58))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.7...medusa-plugin-sendgrid@1.1.8) (2021-03-30)
### Bug Fixes
- format numbers correctly in sendgrid ([7682980](https://github.com/medusajs/medusa/commit/7682980c58f1a01f0c510b1d4feae3a62892040c))
- publish assist ([7719957](https://github.com/medusajs/medusa/commit/7719957b44a0c0d950eff948faf31188fe0e3ef1))
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.6...medusa-plugin-sendgrid@1.1.7) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.4...medusa-plugin-sendgrid@1.1.6) (2021-03-17)
### Bug Fixes
- enable gift-card creation without order_id ([9ce935a](https://github.com/medusajs/medusa/commit/9ce935a779aec90ff1ad301c73114ab69ce51b36))
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.4...medusa-plugin-sendgrid@1.1.5) (2021-03-17)
### Bug Fixes
- enable gift-card creation without order_id ([9ce935a](https://github.com/medusajs/medusa/commit/9ce935a779aec90ff1ad301c73114ab69ce51b36))
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.3...medusa-plugin-sendgrid@1.1.4) (2021-02-25)
### Bug Fixes
- add tracking links to shipments ([7be4bb5](https://github.com/medusajs/medusa/commit/7be4bb5f2daa0aad805abe0f97278f53cf3af402))
- sendgrid tracking links ([5cfc8d8](https://github.com/medusajs/medusa/commit/5cfc8d80bd3eaee93595027d0cc3ce67ae98d275))
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.2...medusa-plugin-sendgrid@1.1.3) (2021-02-17)
### Bug Fixes
- attachment generator for invoices ([0cc2ccd](https://github.com/medusajs/medusa/commit/0cc2ccd3b2100960ce7d3422e20ce89ca96704a0))
- handles normalizeThumb without thumbnail ([93f6812](https://github.com/medusajs/medusa/commit/93f68126bfb27f694211b6f890ce0370c42fa08a))
### Features
- notifications ([#172](https://github.com/medusajs/medusa/issues/172)) ([7308946](https://github.com/medusajs/medusa/commit/7308946e567ed4e63e1ed3d9d31b30c4f1a73f0d))
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.1...medusa-plugin-sendgrid@1.1.2) (2021-02-03)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.0...medusa-plugin-sendgrid@1.1.1) (2021-01-27)
**Note:** Version bump only for package medusa-plugin-sendgrid
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.0.14...medusa-plugin-sendgrid@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.0.13...medusa-plugin-sendgrid@1.0.14) (2020-12-17)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.0.12...medusa-plugin-sendgrid@1.0.13) (2020-11-24)
**Note:** Version bump only for package medusa-plugin-sendgrid
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.0.11...medusa-plugin-sendgrid@1.0.12) (2020-10-19)
**Note:** Version bump only for package medusa-plugin-sendgrid
## 1.0.11 (2020-09-11)
### Bug Fixes
- **medusa-plugin-sendgrid:** do display_value calculations ([5e47aec](https://github.com/medusajs/medusa/commit/5e47aecbf7495486c18236336c09490338bd419a))
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
### Bug Fixes
- **medusa:** product variant metadata ([#98](https://github.com/medusajs/medusa/issues/98)) ([520115a](https://github.com/medusajs/medusa/commit/520115a2cef7ee3f0259a682bd82e693c6327790))
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.35 (2020-08-28)
### Bug Fixes
- **medusa-plugin-sendgrid:** Adds order shipped support ([ddfd26d](https://github.com/medusajs/medusa/commit/ddfd26dbe38298c8a9c736cbf8ef5a5dd55e0cc8))
# 1.0.0-alpha.34 (2020-08-28)
### Bug Fixes
- **medusa-plugin-sendgrid:** decorate order placed data for email ([2edf152](https://github.com/medusajs/medusa/commit/2edf152c8eafbd54c5c99602e340ad41fcc783f2))
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
# 1.0.0-alpha.25 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,78 +0,0 @@
# SendGrid
Handle sending emails to customers related to orders, restock notifications, users, or custom events.
[SendGrid Plugin Documentation](https://docs.medusajs.com/plugins/notifications/sendgrid) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Send emails when an event related to orders, restock notifications, or users is triggered.
- Use dynamic templates in SendGrid to build the emails to be sent.
- Send emails with SendGrid for custom events.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [SendGrid account](https://signup.sendgrid.com/)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-sendgrid
```
2\. Set the following environment variable in `.env`:
```bash
SENDGRID_API_KEY=<API_KEY>
SENDGRID_FROM=<SEND_FROM_EMAIL>
# IDs for different email templates
SENDGRID_ORDER_PLACED_ID=<ORDER_PLACED_TEMPLATE_ID> # example
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...,
{
resolve: `medusa-plugin-sendgrid`,
options: {
api_key: process.env.SENDGRID_API_KEY,
from: process.env.SENDGRID_FROM,
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID,
localization: {
"de-DE": { // locale key
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID_LOCALIZED,
},
},
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should receive a confirmation email.
---
## Additional Resources
- [SendGrid Plugin Documentation](https://docs.medusajs.com/plugins/notifications/sendgrid)

View File

@@ -1 +0,0 @@
// noop

View File

@@ -1,3 +0,0 @@
module.exports = {
testEnvironment: "node",
}

View File

@@ -1,55 +0,0 @@
{
"name": "medusa-plugin-sendgrid",
"version": "1.3.12",
"description": "SendGrid transactional emails",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-sendgrid"
},
"engines": {
"node": ">=16"
},
"author": "Oliver Juhl",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40",
"typeorm": "^0.3.16"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7",
"typeorm": "^0.3.16"
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"@sendgrid/mail": "^7.1.1",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.0"
},
"gitHead": "3bbd1e8507e00bc471de6ae3c30207999a4a4011",
"keywords": [
"medusa-plugin",
"medusa-plugin-notification"
]
}

View File

@@ -1,10 +0,0 @@
import { Router } from "express"
import routes from "./routes"
export default (container) => {
const app = Router()
routes(app)
return app
}

View File

@@ -1 +0,0 @@
export default (fn) => (...args) => fn(...args).catch(args[2])

View File

@@ -1,5 +0,0 @@
import { default as wrap } from "./await-middleware"
export default {
wrap,
}

View File

@@ -1,16 +0,0 @@
import { Router } from "express"
import bodyParser from "body-parser"
import middlewares from "../middleware"
const route = Router()
export default (app) => {
app.use("/sendgrid", route)
route.post(
"/send",
bodyParser.raw({ type: "application/json" }),
middlewares.wrap(require("./send-email").default)
)
return app
}

View File

@@ -1,10 +0,0 @@
export default async (req, res) => {
const sendgridService = req.scope.resolve("sendgridService")
await sendgridService.sendEmail(
req.body.template_id,
req.body.from,
req.body.to,
req.body.data || {}
)
res.sendStatus(200)
}

View File

@@ -1,215 +0,0 @@
import SendGridService from "../sendgrid"
import SendGrid from "@sendgrid/mail"
jest.genMockFromModule("@sendgrid/mail")
jest.mock("@sendgrid/mail")
const mockedSendGrid = SendGrid
mockedSendGrid.setApiKey.mockResolvedValue(mockedSendGrid)
mockedSendGrid.send.mockResolvedValue(Promise.resolve())
describe("SendGridService", () => {
let sendGridService
const totalsService = {
withTransaction: function () {
return this
},
getCalculationContext: jest.fn().mockImplementation((order, lineItems) => {
return Promise.resolve({})
}),
getLineItemTotals: jest.fn().mockImplementation(() => {
return Promise.resolve({})
}),
getLineItemRefund: () => {},
getTotal: (o) => {
return o.total || 0
},
getGiftCardableAmount: (o) => {
return o.subtotal || 0
},
getRefundedTotal: (o) => {
return o.refunded_total || 0
},
getShippingTotal: (o) => {
return o.shipping_total || 0
},
getGiftCardTotal: (o) => {
return o.gift_card_total || 0
},
getDiscountTotal: (o) => {
return o.discount_total || 0
},
getTaxTotal: (o) => {
return o.tax_total || 0
},
getSubtotal: (o) => {
return o.subtotal || 0
},
getPaidTotal: (o) => {
return o.paid_total || 0
},
}
beforeEach(() => {
jest.clearAllMocks()
})
it("should call SendGrid.send when template is configured and correct data is passed", async () => {
const orderServiceMock = {
retrieve: jest.fn().mockImplementation((data) => {
return Promise.resolve({
email: "test@test.com",
currency_code: "usd",
items: [],
discounts: [],
gift_cards: [],
created_at: new Date(),
})
}),
}
sendGridService = new SendGridService(
{ orderService: orderServiceMock, totalsService },
{
api_key: "SG.test",
order_placed_template: "lol",
}
)
await sendGridService.sendNotification("order.placed", { id: "test" })
expect(mockedSendGrid.send).toBeCalled()
})
it("should failed to send an email when event does not exist", async () => {
expect.assertions(1)
const orderServiceMock = {
retrieve: jest.fn().mockImplementation((data) => {
return Promise.resolve({
email: "test@test.com",
currency_code: "usd",
items: [],
discounts: [],
gift_cards: [],
created_at: new Date(),
})
}),
}
sendGridService = new SendGridService(
{ orderService: orderServiceMock, totalsService },
{
api_key: "SG.test",
order_placed_template: "lol",
}
)
try {
await sendGridService.sendNotification("some.non-existing_event", {
id: "test",
})
} catch (error) {
expect(error.message).toEqual(
"Sendgrid service: No template was set for event: some.non-existing_event"
)
}
})
it("should failed to send an email when template id is not configured", async () => {
expect.assertions(1)
const orderServiceMock = {
retrieve: jest.fn().mockImplementation((data) => {
return Promise.resolve({
email: "test@test.com",
currency_code: "usd",
items: [],
discounts: [],
gift_cards: [],
created_at: new Date(),
})
}),
}
sendGridService = new SendGridService(
{ orderService: orderServiceMock, totalsService },
{
api_key: "SG.test",
}
)
try {
await sendGridService.sendNotification("order.placed", {
id: "test",
})
} catch (error) {
expect(error.message).toEqual(
"Sendgrid service: No template was set for event: order.placed"
)
}
})
it("should use localized template to send an email", async () => {
const cartServiceMock = {
retrieve: jest.fn().mockImplementation((data) => {
return Promise.resolve({
context: {
locale: "de-DE",
},
})
}),
}
const orderServiceMock = {
retrieve: jest.fn().mockImplementation((data) => {
return Promise.resolve({
email: "test@test.com",
currency_code: "usd",
items: [],
discounts: [],
gift_cards: [],
created_at: new Date(),
cart_id: "test-id",
})
}),
}
sendGridService = new SendGridService(
{
orderService: orderServiceMock,
totalsService,
cartService: cartServiceMock,
},
{
api_key: "SG.test",
localization: {
"de-DE": {
order_placed_template: "lol",
},
},
}
)
await sendGridService.sendNotification("order.placed", {
id: "test",
})
expect(mockedSendGrid.send).toBeCalled()
})
it("should send message to non predefined template", async () => {
sendGridService = new SendGridService({}, { "send-otp": "test-template" })
await sendGridService.sendNotification("send-otp", {
otp: "test",
validity: "12-01-2020",
})
expect(mockedSendGrid.send).toBeCalled()
expect(mockedSendGrid.send).toHaveBeenCalledWith(
expect.objectContaining({
template_id: "test-template",
dynamic_template_data: {
otp: "test",
validity: "12-01-2020",
},
})
)
})
})

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +0,0 @@
class OrderSubscriber {
constructor({ notificationService }) {
this.notificationService_ = notificationService
this.notificationService_.subscribe("order.shipment_created", "sendgrid")
this.notificationService_.subscribe("order.gift_card_created", "sendgrid")
this.notificationService_.subscribe("gift_card.created", "sendgrid")
this.notificationService_.subscribe("order.placed", "sendgrid")
this.notificationService_.subscribe("order.canceled", "sendgrid")
this.notificationService_.subscribe("customer.password_reset", "sendgrid")
this.notificationService_.subscribe("claim.shipment_created", "sendgrid")
this.notificationService_.subscribe("swap.shipment_created", "sendgrid")
this.notificationService_.subscribe("swap.created", "sendgrid")
this.notificationService_.subscribe("order.items_returned", "sendgrid")
this.notificationService_.subscribe("order.return_requested", "sendgrid")
this.notificationService_.subscribe("order.refund_created", "sendgrid")
}
}
export default OrderSubscriber

View File

@@ -1,41 +0,0 @@
class RestockNotification {
constructor({ eventBusService, sendgridService }) {
eventBusService.subscribe(
"restock-notification.restocked",
async (eventData) => {
const templateId = await sendgridService.getTemplateId(
"restock-notification.restocked"
)
if (!templateId) {
return
}
const data = await sendgridService.fetchData(
"restock-notification.restocked",
eventData,
null
)
if (!data.emails) {
return
}
return await Promise.all(
data.emails.map(async (e) => {
const sendOptions = {
template_id: templateId,
from: sendgridService.options_.from,
to: e,
dynamic_template_data: data,
}
return await sendgridService.sendEmail(sendOptions)
})
)
}
)
}
}
export default RestockNotification

View File

@@ -1,17 +0,0 @@
class UserSubscriber {
constructor({ sendgridService, eventBusService }) {
this.sendgridService_ = sendgridService
this.eventBus_ = eventBusService
this.eventBus_.subscribe("user.password_reset", async (data) => {
await this.sendgridService_.sendNotification(
"user.password_reset",
data,
null
)
})
}
}
export default UserSubscriber

View File

@@ -1,13 +0,0 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes"
],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}

View File

@@ -1,15 +0,0 @@
/lib
node_modules
.DS_store
.env*
/*.js
!index.js
!jest.config.js
/dist
/api
/services
/models
/subscribers

View File

@@ -1,9 +0,0 @@
.DS_store
src
dist
yarn.lock
.babelrc
jest.config.js
.turbo
.yarn

View File

@@ -1,325 +0,0 @@
# Change Log
## 1.3.10
### Patch Changes
- [#4389](https://github.com/medusajs/medusa/pull/4389) [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa, utils): fix the way selects are consumed alongside the relations
## 1.3.9
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
- medusa-test-utils@1.1.40
## 1.3.9-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
- medusa-test-utils@1.1.40-rc.0
## 1.3.8
### Patch Changes
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.3.7
### Patch Changes
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.3.6
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.3.5
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
## 1.3.4
### Patch Changes
- [#2069](https://github.com/medusajs/medusa/pull/2069) [`ad717b953`](https://github.com/medusajs/medusa/commit/ad717b9533a0500e20c4e312d1ee48b35ea9d5e1) Thanks [@olivermrbl](https://github.com/olivermrbl)! - Remove deprecated dependency `@hapi/joi`
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.3](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.3.2...medusa-plugin-slack-notification@1.3.3) (2022-07-05)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.3.2](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.3.0...medusa-plugin-slack-notification@1.3.2) (2022-06-19)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.3.1](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.3.0...medusa-plugin-slack-notification@1.3.1) (2022-05-31)
**Note:** Version bump only for package medusa-plugin-slack-notification
# [1.3.0](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.2.1...medusa-plugin-slack-notification@1.3.0) (2022-05-01)
### Features
- Add DiscountConditions ([#1230](https://github.com/medusajs/medusa/issues/1230)) ([a610805](https://github.com/medusajs/medusa/commit/a610805917ee930d4cebde74905e541a468aa83b)), closes [#1146](https://github.com/medusajs/medusa/issues/1146) [#1149](https://github.com/medusajs/medusa/issues/1149) [#1156](https://github.com/medusajs/medusa/issues/1156) [#1170](https://github.com/medusajs/medusa/issues/1170) [#1172](https://github.com/medusajs/medusa/issues/1172) [#1212](https://github.com/medusajs/medusa/issues/1212) [#1224](https://github.com/medusajs/medusa/issues/1224) [#1228](https://github.com/medusajs/medusa/issues/1228)
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.37...medusa-plugin-slack-notification@1.2.1) (2022-02-28)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([47588e7](https://github.com/medusajs/medusa/commit/47588e7a8d3b2ae2fed0c1e87fdf1ee2db6bcdc2)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.37...medusa-plugin-slack-notification@1.2.0) (2022-02-25)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([c56660f](https://github.com/medusajs/medusa/commit/c56660fca9921a3f3637bc137d9794781c5b090f)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.36...medusa-plugin-slack-notification@1.1.37) (2022-01-11)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.35...medusa-plugin-slack-notification@1.1.36) (2021-12-29)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.34...medusa-plugin-slack-notification@1.1.35) (2021-12-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.33...medusa-plugin-slack-notification@1.1.34) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.32...medusa-plugin-slack-notification@1.1.33) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.31...medusa-plugin-slack-notification@1.1.32) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.30...medusa-plugin-slack-notification@1.1.31) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.29...medusa-plugin-slack-notification@1.1.30) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.28...medusa-plugin-slack-notification@1.1.29) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.27...medusa-plugin-slack-notification@1.1.28) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.25...medusa-plugin-slack-notification@1.1.27) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.25...medusa-plugin-slack-notification@1.1.26) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.24...medusa-plugin-slack-notification@1.1.25) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [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.22](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.21...medusa-plugin-slack-notification@1.1.22) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.19...medusa-plugin-slack-notification@1.1.21) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.19...medusa-plugin-slack-notification@1.1.20) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.18...medusa-plugin-slack-notification@1.1.19) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.17...medusa-plugin-slack-notification@1.1.18) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.16...medusa-plugin-slack-notification@1.1.17) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.15...medusa-plugin-slack-notification@1.1.16) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.14...medusa-plugin-slack-notification@1.1.15) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.13...medusa-plugin-slack-notification@1.1.14) (2021-06-09)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.12...medusa-plugin-slack-notification@1.1.13) (2021-06-08)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.9...medusa-plugin-slack-notification@1.1.12) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.10...medusa-plugin-slack-notification@1.1.11) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.9...medusa-plugin-slack-notification@1.1.10) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.8...medusa-plugin-slack-notification@1.1.9) (2021-04-13)
### Bug Fixes
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.7...medusa-plugin-slack-notification@1.1.8) (2021-04-13)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.6...medusa-plugin-slack-notification@1.1.7) (2021-03-30)
### Bug Fixes
- **slack:** show discount code flag ([b5bf650](https://github.com/medusajs/medusa/commit/b5bf650ec26182be6324bc56e7f6efd744a7131e))
- zero decimal amounts in slack + gc total ([c6a5dff](https://github.com/medusajs/medusa/commit/c6a5dffa7bd8f627310d1f90364492084051dd47))
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.5...medusa-plugin-slack-notification@1.1.6) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.3...medusa-plugin-slack-notification@1.1.5) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.3...medusa-plugin-slack-notification@1.1.4) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.2...medusa-plugin-slack-notification@1.1.3) (2021-02-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.1...medusa-plugin-slack-notification@1.1.2) (2021-02-03)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.0...medusa-plugin-slack-notification@1.1.1) (2021-01-27)
**Note:** Version bump only for package medusa-plugin-slack-notification
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.0.13...medusa-plugin-slack-notification@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.0.12...medusa-plugin-slack-notification@1.0.13) (2020-12-17)
**Note:** Version bump only for package medusa-plugin-slack-notification
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.0.11...medusa-plugin-slack-notification@1.0.12) (2020-11-24)
**Note:** Version bump only for package medusa-plugin-slack-notification
## 1.0.11 (2020-10-19)
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.5 (2020-09-06)
### Bug Fixes
- **medusa-plugin-slack-notification:** adds currency code to line items ([83c49e0](https://github.com/medusajs/medusa/commit/83c49e0b9cf0c6bc30aefc47fcde10ed221b89e3))
## 1.0.4 (2020-09-06)
## 1.0.3 (2020-09-06)
### Bug Fixes
- **medusa-plugin-slack-order-notification:** adds additional information ([#102](https://github.com/medusajs/medusa/issues/102)) ([f732a2d](https://github.com/medusajs/medusa/commit/f732a2d26a3ead4ef330a555961b49222e1f7244))
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
### Bug Fixes
- **medusa-plugin-slack-notification:** Fixes slackbot ([#100](https://github.com/medusajs/medusa/issues/100)) ([1c8384c](https://github.com/medusajs/medusa/commit/1c8384c7c342ac3cb703f07a6d4d705b327e9716))
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,68 +0,0 @@
# Slack
Receive new order notifications on Slack.
[Slack Plugin Documentation](https://docs.medusajs.com/plugins/notifications/slack) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Receive details about new orders including purchased items, totals, customer information, and more.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Slack account](https://slack.com)
- [Redis](https://docs.medusajs.com/development/backend/prepare-environment#redis)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-slack-notification
```
2\. Set the following environment variable in `.env`:
```bash
SLACK_WEBHOOK_URL=<YOUR_SLACK_WEBHOOK_URL>
SLACK_ADMIN_ORDERS_URL=<YOUR_ADMIN_ORDERS_URL>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...,
{
resolve: `medusa-plugin-slack-notification`,
options: {
show_discount_code: false, // optional, whether the discount code should be shown in notifications
slack_url: process.env.SLACK_WEBHOOK_URL,
admin_orders_url: process.env.SLACK_ADMIN_ORDERS_URL, // for example, http://localhost:7001/a/orders
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should receive a notification on your Slack workspace.
---
## Additional Resources
- [Slack Plugin Documentation](https://docs.medusajs.com/plugins/notifications/slack)

View File

@@ -1 +0,0 @@
// noop

View File

@@ -1,3 +0,0 @@
module.exports = {
testEnvironment: "node",
}

View File

@@ -1,54 +0,0 @@
{
"name": "medusa-plugin-slack-notification",
"version": "1.3.10",
"description": "Slack notifications",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-slack-notification"
},
"engines": {
"node": ">=16"
},
"author": "Oliver Juhl",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.0",
"moment": "^2.27.0"
},
"gitHead": "c46300d58fbfd0b2dc2c02745ae143e6247e885b",
"keywords": [
"medusa-plugin",
"medusa-plugin-notification"
]
}

View File

@@ -1,188 +0,0 @@
import axios from "axios"
import { humanizeAmount, zeroDecimalCurrencies } from "medusa-core-utils"
import { BaseService } from "medusa-interfaces"
class SlackService extends BaseService {
/**
* @param {Object} options - options defined in `medusa-config.js`
* {
* show_discount_code: If set to true the discount code used will be
* displayed in the order channel.
* slack_url: "https://hooks.slack.com/services/...",
* admin_orders_url: "https:..../orders"
* }
*/
constructor({ orderService, totalsService, regionService }, options) {
super()
this.orderService_ = orderService
this.totalsService_ = totalsService
this.regionService_ = regionService
this.options_ = options
}
async orderNotification(orderId) {
const order = await this.orderService_.retrieve(orderId, {
select: [
"shipping_total",
"discount_total",
"tax_total",
"refunded_total",
"gift_card_total",
"subtotal",
"total",
],
relations: [
"customer",
"billing_address",
"shipping_address",
"discounts",
"discounts.rule",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
"fulfillments",
"returns",
"gift_cards",
"gift_card_transactions",
"swaps",
"swaps.return_order",
"swaps.payment",
"swaps.shipping_methods",
"swaps.shipping_methods.shipping_option",
"swaps.shipping_address",
"swaps.additional_items",
"swaps.fulfillments",
],
})
const { subtotal, tax_total, discount_total, shipping_total, total } = order
const currencyCode = order.currency_code.toUpperCase()
const getDisplayAmount = (amount) => {
const humanAmount = humanizeAmount(amount, currencyCode)
if (zeroDecimalCurrencies.includes(currencyCode.toLowerCase())) {
return humanAmount
}
return humanAmount.toFixed(2)
}
const blocks = [
{
type: "section",
text: {
type: "mrkdwn",
text: `Order *<${this.options_.admin_orders_url}/${order.id}|#${order.display_id}>* has been processed.`,
},
},
{
type: "section",
text: {
type: "mrkdwn",
text: `*Customer*\n${order.shipping_address.first_name} ${
order.shipping_address.last_name
}\n${order.email}\n*Destination*\n${
order.shipping_address.address_1
}\n${
order.shipping_address.city
}, ${order.shipping_address.country_code.toUpperCase()}`,
},
},
{
type: "section",
text: {
type: "mrkdwn",
text: `*Subtotal*\t${getDisplayAmount(
subtotal
)} ${currencyCode}\n*Shipping*\t${getDisplayAmount(
shipping_total
)} ${currencyCode}\n*Discount Total*\t${getDisplayAmount(
discount_total
)} ${currencyCode}\n*Tax*\t${getDisplayAmount(
tax_total
)} ${currencyCode}\n*Total*\t${getDisplayAmount(
total
)} ${currencyCode}`,
},
},
]
if (order.gift_card_total) {
blocks.push({
type: "section",
text: {
type: "mrkdwn",
text: `*Gift Card Total*\t${getDisplayAmount(
order.gift_card_total
)} ${currencyCode}`,
},
})
}
if (this.options_.show_discount_code) {
order.discounts.forEach((d) => {
blocks.push({
type: "section",
text: {
type: "mrkdwn",
text: `*Promo Code*\t${d.code} ${d.rule.value}${
d.rule.type === "percentage" ? "%" : ` ${currencyCode}`
}`,
},
})
})
}
blocks.push({
type: "divider",
})
for (const lineItem of order.items) {
const totals = await this.totalsService_.getLineItemTotals(
lineItem,
order,
{
include_tax: true,
}
)
const line = {
type: "section",
text: {
type: "mrkdwn",
text: `*${lineItem.title}*\n${lineItem.quantity} x ${getDisplayAmount(
totals.original_total
)} ${currencyCode}`,
},
}
if (lineItem.thumbnail) {
let url = lineItem.thumbnail
if (lineItem.thumbnail.startsWith("//")) {
url = `https:${lineItem.thumbnail}`
}
line.accessory = {
type: "image",
alt_text: "Item",
image_url: url,
}
}
blocks.push(line)
blocks.push({
type: "divider",
})
}
return axios.post(this.options_.slack_url, {
text: `Order ${order.display_id} was processed`,
blocks,
})
}
}
export default SlackService

View File

@@ -1,13 +0,0 @@
class OrderSubscriber {
constructor({ slackService, eventBusService }) {
this.slackService_ = slackService
this.eventBus_ = eventBusService
this.eventBus_.subscribe("order.placed", async ({ id }) => {
await this.slackService_.orderNotification(id)
})
}
}
export default OrderSubscriber

478
yarn.lock
View File

@@ -19,138 +19,6 @@ __metadata:
languageName: node
linkType: hard
"@algolia/cache-browser-local-storage@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/cache-browser-local-storage@npm:4.18.0"
dependencies:
"@algolia/cache-common": 4.18.0
checksum: 4d2efe7a523427e13ea3549d89378564bb60de7e4178e33e86ae0fd709b2582486817a20f94c011e6135f14182bb3e37f72047280208903802a3a17daff42b6f
languageName: node
linkType: hard
"@algolia/cache-common@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/cache-common@npm:4.18.0"
checksum: bd68a75ae6c49ee78bb79add9d887ead952b5b6c2829241d35f04fdaa9a7666bc329795c2f0e1f16d035294356b957abacce862eca938691d0a0db734eb884a1
languageName: node
linkType: hard
"@algolia/cache-in-memory@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/cache-in-memory@npm:4.18.0"
dependencies:
"@algolia/cache-common": 4.18.0
checksum: 3faa3673857272146f32fd906f6b1c97ef0afcb84c7d32902bcfe6dc15cce45e7def0e00bbd8c27d90ad353f40d5b956a0692e1f7c9e1cd7e2296620458e2232
languageName: node
linkType: hard
"@algolia/client-account@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/client-account@npm:4.18.0"
dependencies:
"@algolia/client-common": 4.18.0
"@algolia/client-search": 4.18.0
"@algolia/transporter": 4.18.0
checksum: 9bd922abaa55f11a7e4fbc4bea347d345c5d91b5b6f09b5be02ff1a7c41a50f35ec17b4d117edec6a3b5e99c7ffb94409ec640d68728e4c5181e638a691f467a
languageName: node
linkType: hard
"@algolia/client-analytics@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/client-analytics@npm:4.18.0"
dependencies:
"@algolia/client-common": 4.18.0
"@algolia/client-search": 4.18.0
"@algolia/requester-common": 4.18.0
"@algolia/transporter": 4.18.0
checksum: fceaf153f2eb952bcf5d090aa9ce9c6dd36092b50d7fc67d43d025c76d168b6baf2b73bd0295c891156e11aaae2da65e878359396fc44ad5c5be5e0e83fb9ba4
languageName: node
linkType: hard
"@algolia/client-common@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/client-common@npm:4.18.0"
dependencies:
"@algolia/requester-common": 4.18.0
"@algolia/transporter": 4.18.0
checksum: d898bb3ea10a9deff19efa1cd252bbdfb76800a3eeb7763f87c94c1064af3fafb1b60b687434c53e89832cb5a13024bc9d75f0ae5bf4b7d3fa609a26bb113d01
languageName: node
linkType: hard
"@algolia/client-personalization@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/client-personalization@npm:4.18.0"
dependencies:
"@algolia/client-common": 4.18.0
"@algolia/requester-common": 4.18.0
"@algolia/transporter": 4.18.0
checksum: 4a93e672206c2127e760560db436301f89fc26445032c7df41b1a9321798506d4738dbe05668dd3191e97affba5085227cdea4845d3bcb26f49f78fccd87943f
languageName: node
linkType: hard
"@algolia/client-search@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/client-search@npm:4.18.0"
dependencies:
"@algolia/client-common": 4.18.0
"@algolia/requester-common": 4.18.0
"@algolia/transporter": 4.18.0
checksum: 23457f9d40384e275d359ab4eea7550a57b9c53c75fa63ec26e6bcd947b1ce96d2f28b6a9caefd8bc47f4d0659b7fd9981fbf09c3e43cf006f6bc934e70f09e5
languageName: node
linkType: hard
"@algolia/logger-common@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/logger-common@npm:4.18.0"
checksum: 31015b2f2261618c44a2876272dc24661d5e02a41fdac1d95a17360637cc76073a73b00f90baa8780979901051d6c4524ccd416390d7a48dff0773bb710fbaa2
languageName: node
linkType: hard
"@algolia/logger-console@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/logger-console@npm:4.18.0"
dependencies:
"@algolia/logger-common": 4.18.0
checksum: eee7c1c61c72e082bc9842bd92136ec09c87e3b2bc3639df40db191096a4e15f6c4f1475b05729741dad7111cb9a853e3024b33b67a517a3a13af46e421728f6
languageName: node
linkType: hard
"@algolia/requester-browser-xhr@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/requester-browser-xhr@npm:4.18.0"
dependencies:
"@algolia/requester-common": 4.18.0
checksum: a725d19cb256aa689c07f4e0b7b3db2a2e7d68c99fe103baa52126adf78a62fc25b6eb0969aeccf7d27bab6d3009ff306fe71c65554017a3fa6e57cdf88a07b1
languageName: node
linkType: hard
"@algolia/requester-common@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/requester-common@npm:4.18.0"
checksum: 3e641f6084b34c5849a763048c7d14ac4e91833e944e18364edf4d7da241ce5d66cf8ed9ba55f105e28109dd5fd10fa0d3ed5d709b943fd91d5732c6dee5633c
languageName: node
linkType: hard
"@algolia/requester-node-http@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/requester-node-http@npm:4.18.0"
dependencies:
"@algolia/requester-common": 4.18.0
checksum: e32eb8d832da528314e61095041ce3c6ea5aa0d1d085f1370ec04da6fec476edcde303f3f1f9be1942562fc7ba2f7dcad64f8d128f1bc3d8477e251f40a64b34
languageName: node
linkType: hard
"@algolia/transporter@npm:4.18.0":
version: 4.18.0
resolution: "@algolia/transporter@npm:4.18.0"
dependencies:
"@algolia/cache-common": 4.18.0
"@algolia/logger-common": 4.18.0
"@algolia/requester-common": 4.18.0
checksum: 5a0ca91479677119ddaceb04bc3d407502c451188ac4f745d4d4e15bf06b4f6db4fc271466c060d66c241cd1d237f6965b034ffe5ac2bf32a8b8c2d1d101d74a
languageName: node
linkType: hard
"@alloc/quick-lru@npm:^5.2.0":
version: 5.2.0
resolution: "@alloc/quick-lru@npm:5.2.0"
@@ -2652,7 +2520,7 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-transform-instanceof@npm:^7.10.4, @babel/plugin-transform-instanceof@npm:^7.12.1, @babel/plugin-transform-instanceof@npm:^7.12.13, @babel/plugin-transform-instanceof@npm:^7.8.3":
"@babel/plugin-transform-instanceof@npm:^7.10.4, @babel/plugin-transform-instanceof@npm:^7.12.1, @babel/plugin-transform-instanceof@npm:^7.8.3":
version: 7.22.5
resolution: "@babel/plugin-transform-instanceof@npm:7.22.5"
dependencies:
@@ -7009,7 +6877,7 @@ __metadata:
languageName: node
linkType: hard
"@medusajs/medusa@^1.12.2, @medusajs/medusa@^1.17.1, @medusajs/medusa@^1.19.1, @medusajs/medusa@^1.20.3, @medusajs/medusa@^1.20.4, @medusajs/medusa@^1.20.5, @medusajs/medusa@workspace:*, @medusajs/medusa@workspace:^, @medusajs/medusa@workspace:packages/medusa":
"@medusajs/medusa@^1.17.1, @medusajs/medusa@^1.20.3, @medusajs/medusa@^1.20.4, @medusajs/medusa@^1.20.5, @medusajs/medusa@workspace:*, @medusajs/medusa@workspace:^, @medusajs/medusa@workspace:packages/medusa":
version: 0.0.0-use.local
resolution: "@medusajs/medusa@workspace:packages/medusa"
dependencies:
@@ -7090,7 +6958,7 @@ __metadata:
languageName: unknown
linkType: soft
"@medusajs/modules-sdk@^1.12.10, @medusajs/modules-sdk@^1.12.11, @medusajs/modules-sdk@^1.12.3, @medusajs/modules-sdk@^1.12.8, @medusajs/modules-sdk@^1.12.9, @medusajs/modules-sdk@^1.8.8, @medusajs/modules-sdk@workspace:^, @medusajs/modules-sdk@workspace:packages/core/modules-sdk":
"@medusajs/modules-sdk@^1.12.10, @medusajs/modules-sdk@^1.12.11, @medusajs/modules-sdk@^1.12.3, @medusajs/modules-sdk@^1.12.8, @medusajs/modules-sdk@^1.12.9, @medusajs/modules-sdk@workspace:^, @medusajs/modules-sdk@workspace:packages/core/modules-sdk":
version: 0.0.0-use.local
resolution: "@medusajs/modules-sdk@workspace:packages/core/modules-sdk"
dependencies:
@@ -7472,7 +7340,7 @@ __metadata:
languageName: unknown
linkType: soft
"@medusajs/types@^1.10.0, @medusajs/types@^1.11.12, @medusajs/types@^1.11.14, @medusajs/types@^1.11.15, @medusajs/types@^1.11.16, @medusajs/types@^1.11.6, @medusajs/types@workspace:^, @medusajs/types@workspace:packages/core/types":
"@medusajs/types@^1.11.12, @medusajs/types@^1.11.14, @medusajs/types@^1.11.15, @medusajs/types@^1.11.16, @medusajs/types@^1.11.6, @medusajs/types@workspace:^, @medusajs/types@workspace:packages/core/types":
version: 0.0.0-use.local
resolution: "@medusajs/types@workspace:packages/core/types"
dependencies:
@@ -7605,7 +7473,7 @@ __metadata:
languageName: unknown
linkType: soft
"@medusajs/utils@1.11.9, @medusajs/utils@^1.10.5, @medusajs/utils@^1.11.2, @medusajs/utils@^1.11.3, @medusajs/utils@^1.11.5, @medusajs/utils@^1.11.7, @medusajs/utils@^1.11.8, @medusajs/utils@^1.11.9, @medusajs/utils@^1.9.4, @medusajs/utils@workspace:^, @medusajs/utils@workspace:packages/core/utils":
"@medusajs/utils@1.11.9, @medusajs/utils@^1.11.2, @medusajs/utils@^1.11.5, @medusajs/utils@^1.11.7, @medusajs/utils@^1.11.8, @medusajs/utils@^1.11.9, @medusajs/utils@workspace:^, @medusajs/utils@workspace:packages/core/utils":
version: 0.0.0-use.local
resolution: "@medusajs/utils@workspace:packages/core/utils"
dependencies:
@@ -10273,35 +10141,6 @@ __metadata:
languageName: node
linkType: hard
"@sendgrid/client@npm:^7.7.0":
version: 7.7.0
resolution: "@sendgrid/client@npm:7.7.0"
dependencies:
"@sendgrid/helpers": ^7.7.0
axios: ^0.26.0
checksum: acf1db2dcc5181f6f9befba811ba6acb31e50051ab6bded952cb073f117c9237d86013602cdf523b91582c40545e1085a413f1e9e490a46b1d664a5c956c1f3f
languageName: node
linkType: hard
"@sendgrid/helpers@npm:^7.7.0":
version: 7.7.0
resolution: "@sendgrid/helpers@npm:7.7.0"
dependencies:
deepmerge: ^4.2.2
checksum: 14dfe9af191dd9ad18f0b2744d6d12dbc80f830507b6112d8c4c1c4741ff282393a06e4b4559c0f404d33971639ecadb1017e0cc3b7187e56ec64ab9ee5ff21c
languageName: node
linkType: hard
"@sendgrid/mail@npm:^7.1.1":
version: 7.7.0
resolution: "@sendgrid/mail@npm:7.7.0"
dependencies:
"@sendgrid/client": ^7.7.0
"@sendgrid/helpers": ^7.7.0
checksum: 5a1d617f1e3f8d47d4fe188ff08f18fca63e3006545ad1f954bf30887806c810f6c0dea7d8850c24de03b3aca75f70f4324369ed2497d957870b8a65f1451127
languageName: node
linkType: hard
"@sideway/address@npm:^4.1.3, @sideway/address@npm:^4.1.4":
version: 4.1.4
resolution: "@sideway/address@npm:4.1.4"
@@ -15895,28 +15734,6 @@ __metadata:
languageName: node
linkType: hard
"algoliasearch@npm:^4.15.0":
version: 4.18.0
resolution: "algoliasearch@npm:4.18.0"
dependencies:
"@algolia/cache-browser-local-storage": 4.18.0
"@algolia/cache-common": 4.18.0
"@algolia/cache-in-memory": 4.18.0
"@algolia/client-account": 4.18.0
"@algolia/client-analytics": 4.18.0
"@algolia/client-common": 4.18.0
"@algolia/client-personalization": 4.18.0
"@algolia/client-search": 4.18.0
"@algolia/logger-common": 4.18.0
"@algolia/logger-console": 4.18.0
"@algolia/requester-browser-xhr": 4.18.0
"@algolia/requester-common": 4.18.0
"@algolia/requester-node-http": 4.18.0
"@algolia/transporter": 4.18.0
checksum: 3966bf487d45d06a6904a1ebfc1c8cca92a670e7ed8ee003cf7af9c48ba90eb24c9eb16e8dbc516d3c88ab092672d2c3cdda694c0bc6dc17f65ea8f73650b478
languageName: node
linkType: hard
"analytics-node@npm:^3.4.0-beta.1":
version: 3.5.0
resolution: "analytics-node@npm:3.5.0"
@@ -16704,7 +16521,7 @@ __metadata:
languageName: node
linkType: hard
"axios@npm:^0.19.0, axios@npm:^0.19.2":
"axios@npm:^0.19.2":
version: 0.19.2
resolution: "axios@npm:0.19.2"
dependencies:
@@ -16740,15 +16557,6 @@ __metadata:
languageName: node
linkType: hard
"axios@npm:^0.26.0":
version: 0.26.1
resolution: "axios@npm:0.26.1"
dependencies:
follow-redirects: ^1.14.8
checksum: 77ad7f1e6ca04fcd3fa8af1795b09d8b7c005b71a31f28d99ba40cda0bdcc12a4627801d7fac5efa62b9f667a8402bd54c669039694373bc8d44f6be611f785c
languageName: node
linkType: hard
"axios@npm:^0.27.2":
version: 0.27.2
resolution: "axios@npm:0.27.2"
@@ -19236,31 +19044,6 @@ __metadata:
languageName: node
linkType: hard
"contentful-management@npm:^5.27.1":
version: 5.28.0
resolution: "contentful-management@npm:5.28.0"
dependencies:
axios: ^0.19.0
contentful-sdk-core: ^6.4.0
lodash: ^4.17.11
type-fest: 0.15.1
checksum: 66b79a333330ad9e51d62b77179ae24166d241b2189bdc8203eeb7d6a66291a574b8c503a2c9728df12138294f8f39b79aab5ceda2f40689cecea08925652a8b
languageName: node
linkType: hard
"contentful-sdk-core@npm:^6.4.0":
version: 6.11.0
resolution: "contentful-sdk-core@npm:6.11.0"
dependencies:
fast-copy: ^2.1.0
lodash.isplainobject: ^4.0.6
lodash.isstring: ^4.0.1
p-throttle: ^4.1.1
qs: ^6.9.4
checksum: c28c609b576320321c83e73d79b70892ec10bd628e50f3041d4e2ee1030b2753f59deb26edc9560977ad7cef33e7c80ef111e538e55c02fd961f02e2e4f69f63
languageName: node
linkType: hard
"convert-source-map@npm:^1.1.0, convert-source-map@npm:^1.4.0, convert-source-map@npm:^1.6.0, convert-source-map@npm:^1.7.0":
version: 1.9.0
resolution: "convert-source-map@npm:1.9.0"
@@ -19638,7 +19421,7 @@ __metadata:
languageName: node
linkType: hard
"cross-fetch@npm:^3.1.5, cross-fetch@npm:^3.1.6":
"cross-fetch@npm:^3.1.5":
version: 3.1.8
resolution: "cross-fetch@npm:3.1.8"
dependencies:
@@ -20473,13 +20256,6 @@ __metadata:
languageName: node
linkType: hard
"denque@npm:^1.5.0":
version: 1.5.1
resolution: "denque@npm:1.5.1"
checksum: 9e6fc1a63e1c9ded38325290302fef40e5ad28471ad8c66d68eaea623ef847bd25fc75a7c3f47396206dc967922615999066470a364e1786f2758d61337872b7
languageName: node
linkType: hard
"denque@npm:^2.1.0":
version: 2.1.0
resolution: "denque@npm:2.1.0"
@@ -22606,13 +22382,6 @@ __metadata:
languageName: node
linkType: hard
"fast-copy@npm:^2.1.0":
version: 2.1.7
resolution: "fast-copy@npm:2.1.7"
checksum: 1fa3c6f21305fa49581d543812f0c96429c0748b97c074b1aca5d2d6d43520ff1452a8021b4051f5a894c0fdbcac463797b5660e0813399054914dd91e7f27f5
languageName: node
linkType: hard
"fast-deep-equal@npm:^3.1.1, fast-deep-equal@npm:^3.1.3":
version: 3.1.3
resolution: "fast-deep-equal@npm:3.1.3"
@@ -23149,7 +22918,7 @@ __metadata:
languageName: node
linkType: hard
"follow-redirects@npm:^1.10.0, follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4, follow-redirects@npm:^1.14.8, follow-redirects@npm:^1.14.9":
"follow-redirects@npm:^1.10.0, follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4, follow-redirects@npm:^1.14.9":
version: 1.15.2
resolution: "follow-redirects@npm:1.15.2"
peerDependenciesMeta:
@@ -25193,9 +24962,7 @@ __metadata:
form-data: ^4.0.0
jest: ^26.6.3
jest-environment-node: 26.6.2
medusa-fulfillment-webshipper: "workspace:*"
medusa-interfaces: "workspace:*"
medusa-plugin-sendgrid: "workspace:*"
pg: ^8.11.0
typeorm: ^0.3.16
languageName: unknown
@@ -25235,9 +25002,7 @@ __metadata:
faker: ^5.5.3
jest: ^26.6.3
jest-environment-node: 26.6.2
medusa-fulfillment-webshipper: "workspace:*"
medusa-interfaces: "workspace:*"
medusa-plugin-sendgrid: "workspace:*"
medusa-test-utils: "workspace:*"
pg: ^8.11.0
typeorm: ^0.3.16
@@ -25278,9 +25043,7 @@ __metadata:
faker: ^5.5.3
jest: ^26.6.3
jest-environment-node: 26.6.2
medusa-fulfillment-webshipper: "workspace:*"
medusa-interfaces: "workspace:*"
medusa-plugin-sendgrid: "workspace:*"
pg: ^8.11.0
typeorm: ^0.3.16
languageName: unknown
@@ -30529,58 +30292,7 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-fulfillment-manual@workspace:packages/medusa-fulfillment-manual":
version: 0.0.0-use.local
resolution: "medusa-fulfillment-manual@workspace:packages/medusa-fulfillment-manual"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/runtime": ^7.9.6
client-sessions: ^0.8.0
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.1
medusa-interfaces: ^1.3.9
peerDependencies:
medusa-interfaces: 1.3.9
languageName: unknown
linkType: soft
"medusa-fulfillment-webshipper@workspace:*, medusa-fulfillment-webshipper@workspace:packages/medusa-fulfillment-webshipper":
version: 0.0.0-use.local
resolution: "medusa-fulfillment-webshipper@workspace:packages/medusa-fulfillment-webshipper"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-instanceof": ^7.12.13
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/runtime": ^7.9.6
"@medusajs/medusa": ^1.19.1
"@medusajs/utils": ^1.11.3
axios: ^0.20.0
body-parser: ^1.19.0
client-sessions: ^0.8.0
cors: ^2.8.5
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.1
medusa-interfaces: ^1.3.8
peerDependencies:
"@medusajs/medusa": ^1.12.0
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-interfaces@^1.3.7, medusa-interfaces@^1.3.8, medusa-interfaces@^1.3.9, medusa-interfaces@workspace:*, medusa-interfaces@workspace:packages/medusa-interfaces":
"medusa-interfaces@^1.3.7, medusa-interfaces@^1.3.9, medusa-interfaces@workspace:*, medusa-interfaces@workspace:packages/medusa-interfaces":
version: 0.0.0-use.local
resolution: "medusa-interfaces@workspace:packages/medusa-interfaces"
dependencies:
@@ -30602,53 +30314,6 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-plugin-algolia@workspace:packages/medusa-plugin-algolia":
version: 0.0.0-use.local
resolution: "medusa-plugin-algolia@workspace:packages/medusa-plugin-algolia"
dependencies:
"@medusajs/modules-sdk": ^1.8.8
"@medusajs/types": ^1.10.0
"@medusajs/utils": ^1.9.4
algoliasearch: ^4.15.0
client-sessions: ^0.8.0
cross-env: ^5.2.1
jest: ^25.5.4
rimraf: ^5.0.1
typescript: ^4.4.4
languageName: unknown
linkType: soft
"medusa-plugin-contentful@workspace:packages/medusa-plugin-contentful":
version: 0.0.0-use.local
resolution: "medusa-plugin-contentful@workspace:packages/medusa-plugin-contentful"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/node": ^7.7.4
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/register": ^7.7.4
"@babel/runtime": ^7.9.6
"@medusajs/utils": ^1.10.5
body-parser: ^1.19.0
client-sessions: ^0.8.0
contentful-management: ^5.27.1
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
lodash: ^4.17.21
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
redis: ^3.0.2
peerDependencies:
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-plugin-discount-generator@workspace:packages/medusa-plugin-discount-generator":
version: 0.0.0-use.local
resolution: "medusa-plugin-discount-generator@workspace:packages/medusa-plugin-discount-generator"
@@ -30697,26 +30362,6 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-plugin-meilisearch@workspace:packages/medusa-plugin-meilisearch":
version: 0.0.0-use.local
resolution: "medusa-plugin-meilisearch@workspace:packages/medusa-plugin-meilisearch"
dependencies:
"@medusajs/medusa": ^1.12.2
"@medusajs/modules-sdk": ^1.8.8
"@medusajs/types": ^1.10.0
"@medusajs/utils": ^1.9.4
body-parser: ^1.19.0
cross-env: ^5.2.1
jest: ^25.5.4
lodash: ^4.17.21
meilisearch: ^0.32.3
rimraf: ^5.0.1
typescript: ^4.9.5
peerDependencies:
"@medusajs/medusa": ^1.12.0
languageName: unknown
linkType: soft
"medusa-plugin-restock-notification@workspace:packages/medusa-plugin-restock-notification":
version: 0.0.0-use.local
resolution: "medusa-plugin-restock-notification@workspace:packages/medusa-plugin-restock-notification"
@@ -30765,65 +30410,6 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-plugin-sendgrid@workspace:*, medusa-plugin-sendgrid@workspace:packages/medusa-plugin-sendgrid":
version: 0.0.0-use.local
resolution: "medusa-plugin-sendgrid@workspace:packages/medusa-plugin-sendgrid"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/node": ^7.7.4
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/register": ^7.7.4
"@babel/runtime": ^7.9.6
"@sendgrid/mail": ^7.1.1
body-parser: ^1.19.0
client-sessions: ^0.8.0
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
typeorm: ^0.3.16
peerDependencies:
medusa-interfaces: ^1.3.7
typeorm: ^0.3.16
languageName: unknown
linkType: soft
"medusa-plugin-slack-notification@workspace:packages/medusa-plugin-slack-notification":
version: 0.0.0-use.local
resolution: "medusa-plugin-slack-notification@workspace:packages/medusa-plugin-slack-notification"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/node": ^7.7.4
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/register": ^7.7.4
"@babel/runtime": ^7.9.6
axios: ^0.19.2
body-parser: ^1.19.0
client-sessions: ^0.8.0
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
moment: ^2.27.0
peerDependencies:
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-plugin-wishlist@workspace:packages/medusa-plugin-wishlist":
version: 0.0.0-use.local
resolution: "medusa-plugin-wishlist@workspace:packages/medusa-plugin-wishlist"
@@ -30953,15 +30539,6 @@ __metadata:
languageName: unknown
linkType: soft
"meilisearch@npm:^0.32.3":
version: 0.32.5
resolution: "meilisearch@npm:0.32.5"
dependencies:
cross-fetch: ^3.1.6
checksum: bf4ced846a9124802217598b374087b2993125b5c37fa7dd67422e578f63d175e20779f726d8c13759b4b63fdd12550b502c88e4736442e316e1b3ac612e09f8
languageName: node
linkType: hard
"memfs@npm:^3.1.2":
version: 3.5.3
resolution: "memfs@npm:3.5.3"
@@ -31578,7 +31155,7 @@ __metadata:
languageName: node
linkType: hard
"moment@npm:^2.19.3, moment@npm:^2.27.0, moment@npm:~2.29.3":
"moment@npm:^2.19.3, moment@npm:~2.29.3":
version: 2.29.4
resolution: "moment@npm:2.29.4"
checksum: 844c6f3ce42862ac9467c8ca4f5e48a00750078682cc5bda1bc0e50cc7ca88e2115a0f932d65a06e4a90e26cb78892be9b3ca3dd6546ca2c4d994cebb787fc2b
@@ -32950,13 +32527,6 @@ __metadata:
languageName: node
linkType: hard
"p-throttle@npm:^4.1.1":
version: 4.1.1
resolution: "p-throttle@npm:4.1.1"
checksum: c4bfdcd0318d704b446a7af59dd8e0e32e37ba3d9841dd8dfced1c09742bc2f7a95bc0fcf4072030c62abf4533a9a2ef2954e559462052c5f406ae03d195925a
languageName: node
linkType: hard
"p-timeout@npm:^3.1.0, p-timeout@npm:^3.2.0":
version: 3.2.0
resolution: "p-timeout@npm:3.2.0"
@@ -34902,7 +34472,7 @@ __metadata:
languageName: node
linkType: hard
"qs@npm:^6.10.0, qs@npm:^6.10.3, qs@npm:^6.11.0, qs@npm:^6.11.2, qs@npm:^6.5.1, qs@npm:^6.9.4":
"qs@npm:^6.10.0, qs@npm:^6.10.3, qs@npm:^6.11.0, qs@npm:^6.11.2, qs@npm:^6.5.1":
version: 6.11.2
resolution: "qs@npm:6.11.2"
dependencies:
@@ -35707,13 +35277,6 @@ __metadata:
languageName: node
linkType: hard
"redis-commands@npm:^1.7.0":
version: 1.7.0
resolution: "redis-commands@npm:1.7.0"
checksum: c78b46d8d6e811f422961878538c57048a451ab56760d3f1657a7c8f29aaae42cc23890f75655556a59ec67611022e18cb443d2976e6c55036934bfe783aa60e
languageName: node
linkType: hard
"redis-errors@npm:^1.0.0, redis-errors@npm:^1.2.0":
version: 1.2.0
resolution: "redis-errors@npm:1.2.0"
@@ -35730,18 +35293,6 @@ __metadata:
languageName: node
linkType: hard
"redis@npm:^3.0.2":
version: 3.1.2
resolution: "redis@npm:3.1.2"
dependencies:
denque: ^1.5.0
redis-commands: ^1.7.0
redis-errors: ^1.2.0
redis-parser: ^3.0.0
checksum: 452d4ed65948b101e379c1abcce7682619382c90929a6611baae5f7f1d38134ce20ad65adfbaa569b735274b49db14a2ebb622800e0b45a4d1559e2133c7aabe
languageName: node
linkType: hard
"redoc@npm:~2.1.3":
version: 2.1.3
resolution: "redoc@npm:2.1.3"
@@ -40184,13 +39735,6 @@ __metadata:
languageName: node
linkType: hard
"type-fest@npm:0.15.1":
version: 0.15.1
resolution: "type-fest@npm:0.15.1"
checksum: 2eff115f870aa2802b1624f6a74069b2237124356ad3302896775c875c92d2365ddefcba72e8bd1c1cade26010a5c41b20797686df621cab32c8739dcf26eb8d
languageName: node
linkType: hard
"type-fest@npm:^0.13.1":
version: 0.13.1
resolution: "type-fest@npm:0.13.1"