release: next (#315)
Co-authored-by: Sebastian Mateos Nicolajsen <sebastian.m.nicolajsen@gmail.com> Co-authored-by: Abraham Ugbeshe <abrahamugbeshe@gmail.com> Co-authored-by: olivermrbl <oliver@mrbltech.com>
This commit is contained in:
1 parent
44d31b4d83
commit
2585e958de
144 files changed
+2554
-240
No files matched your search
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.10...babel-preset-medusa-package@1.1.11) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package babel-preset-medusa-package
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.9...babel-preset-medusa-package@1.1.10) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package babel-preset-medusa-package
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "babel-preset-medusa-package",
|
||||
"version": "1.1.10",
|
||||
"version": "1.1.11",
|
||||
"author": "Sebastian Rindom <sebastian@mrbltech.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.12](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.11...@medusajs/medusa-cli@1.1.12) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.10...@medusajs/medusa-cli@1.1.11) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@medusajs/medusa-cli",
|
||||
"version": "1.1.11",
|
||||
"version": "1.1.12",
|
||||
"description": "Command Line interface for Medusa Commerce",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.16...medusa-core-utils@1.1.17) (2021-07-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* better store/customer support ([6342e68](https://github.com/medusajs/medusa/commit/6342e68d069636e5eb4877c7ebf7aac952b5e363))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.15...medusa-core-utils@1.1.16) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-core-utils
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-core-utils",
|
||||
"version": "1.1.16",
|
||||
"version": "1.1.17",
|
||||
"description": "Core utils for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
export const MedusaErrorTypes = {
|
||||
/** Errors stemming from the database */
|
||||
DB_ERROR: "database_error",
|
||||
DUPLICATE_ERROR: "duplicate_error",
|
||||
INVALID_ARGUMENT: "invalid_argument",
|
||||
INVALID_DATA: "invalid_data",
|
||||
NOT_FOUND: "not_found",
|
||||
NOT_ALLOWED: "not_allowed"
|
||||
NOT_ALLOWED: "not_allowed",
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3740,12 +3740,7 @@ lodash.sortby@^4.7.0:
|
||||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
||||
|
||||
lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15:
|
||||
version "4.17.20"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||
|
||||
lodash@^4.17.19:
|
||||
lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.16](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.15...medusa-dev-cli@0.0.16) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-dev-cli
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.0.15](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.14...medusa-dev-cli@0.0.15) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-dev-cli
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "medusa-dev-cli",
|
||||
"description": "CLI helpers for contributors working on Medusa",
|
||||
"version": "0.0.15",
|
||||
"version": "0.0.16",
|
||||
"author": "Sebastian Rindom <skrindom@gmail.com>",
|
||||
"bin": {
|
||||
"medusa-dev": "./dist/index.js"
|
||||
@@ -24,7 +24,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.1",
|
||||
"@babel/core": "^7.12.3",
|
||||
"babel-preset-medusa-package": "^1.1.10",
|
||||
"babel-preset-medusa-package": "^1.1.11",
|
||||
"cross-env": "^7.0.3"
|
||||
},
|
||||
"homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.19...medusa-file-spaces@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-file-spaces
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.18...medusa-file-spaces@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-file-spaces
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-file-spaces",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Digital Ocean Spaces file connector for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,8 +40,8 @@
|
||||
"aws-sdk": "^2.710.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"stripe": "^8.50.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/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,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-fulfillment-manual",
|
||||
"version": "1.1.16",
|
||||
"version": "1.1.17",
|
||||
"description": "A manual fulfillment provider for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -36,7 +36,7 @@
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-fulfillment-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,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-fulfillment-webshipper",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.21",
|
||||
"description": "Webshipper Fulfillment provider for Medusa",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -37,7 +37,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.17...medusa-interfaces@1.1.18) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-interfaces
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.16...medusa-interfaces@1.1.17) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-interfaces
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-interfaces",
|
||||
"version": "1.1.17",
|
||||
"version": "1.1.18",
|
||||
"description": "Core interfaces for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -35,7 +35,7 @@
|
||||
"typeorm": "0.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.21...medusa-payment-adyen@1.1.22) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.20...medusa-payment-adyen@1.1.21) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-adyen",
|
||||
"version": "1.1.21",
|
||||
"version": "1.1.22",
|
||||
"description": "Adyen Payment provider for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -24,7 +24,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
@@ -42,7 +42,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.21...medusa-payment-klarna@1.1.22) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-klarna
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.20...medusa-payment-klarna@1.1.21) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-klarna
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-klarna",
|
||||
"version": "1.1.21",
|
||||
"version": "1.1.22",
|
||||
"description": "Klarna Payment provider for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,8 +40,8 @@
|
||||
"axios": "^0.21.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.0.21](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.20...medusa-payment-paypal@1.0.21) (2021-07-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* paypal order ([1f6ee0f](https://github.com/medusajs/medusa/commit/1f6ee0fc00024c25d6628e6531097f93f54f8a1b))
|
||||
* support for hook completion of swap carts ([fca29cc](https://github.com/medusajs/medusa/commit/fca29cc5cc0d6f20d01fada7445d32da85291cd8))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.20](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.19...medusa-payment-paypal@1.0.20) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-paypal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-paypal",
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.21",
|
||||
"description": "Paypal Payment provider for Meduas Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -26,8 +26,8 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-interfaces": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-interfaces": "^1.1.18",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__,**/__mocks__",
|
||||
@@ -42,7 +42,7 @@
|
||||
"@paypal/checkout-server-sdk": "^1.0.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -22,7 +22,8 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const authId = req.body.resource.id
|
||||
const body = req.body
|
||||
const authId = body.resource.id
|
||||
const auth = await paypalService.retrieveAuthorization(authId)
|
||||
|
||||
const order = await paypalService.retrieveOrderFromAuth(auth)
|
||||
@@ -37,18 +38,44 @@ export default async (req, res) => {
|
||||
|
||||
const manager = req.scope.resolve("manager")
|
||||
const cartService = req.scope.resolve("cartService")
|
||||
const swapService = req.scope.resolve("swapService")
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
await manager.transaction(async (m) => {
|
||||
const order = await orderService
|
||||
.withTransaction(m)
|
||||
.retrieveByCartId(cartId)
|
||||
.catch((_) => undefined)
|
||||
const cart = await cartService.withTransaction(m).retrieve(cartId)
|
||||
|
||||
if (!order) {
|
||||
await cartService.withTransaction(m).setPaymentSession(cartId, "paypal")
|
||||
await cartService.withTransaction(m).authorizePayment(cartId)
|
||||
await orderService.withTransaction(m).createFromCart(cartId)
|
||||
switch (cart.type) {
|
||||
case "swap": {
|
||||
const swap = await swapService
|
||||
.withTransaction(m)
|
||||
.retrieveByCartId(cartId)
|
||||
.catch((_) => undefined)
|
||||
|
||||
if (swap && swap.confirmed_at === null) {
|
||||
await cartService
|
||||
.withTransaction(m)
|
||||
.setPaymentSession(cartId, "paypal")
|
||||
await cartService.withTransaction(m).authorizePayment(cartId)
|
||||
await swapService.withTransaction(m).registerCartCompletion(swap.id)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
const order = await orderService
|
||||
.withTransaction(m)
|
||||
.retrieveByCartId(cartId)
|
||||
.catch((_) => undefined)
|
||||
|
||||
if (!order) {
|
||||
await cartService
|
||||
.withTransaction(m)
|
||||
.setPaymentSession(cartId, "paypal")
|
||||
await cartService.withTransaction(m).authorizePayment(cartId)
|
||||
await orderService.withTransaction(m).createFromCart(cartId)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.19...medusa-payment-stripe@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-stripe
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.18...medusa-payment-stripe@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-stripe
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-payment-stripe",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Stripe Payment provider for Meduas Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -26,7 +26,7 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
@@ -40,7 +40,7 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"stripe": "^8.50.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.19...medusa-plugin-add-ons@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.18...medusa-plugin-add-ons@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-add-ons",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Add-on plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -25,7 +25,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
@@ -37,7 +37,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"redis": "^3.0.2"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.24...medusa-plugin-brightpearl@1.1.25) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.23...medusa-plugin-brightpearl@1.1.24) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-brightpearl",
|
||||
"version": "1.1.24",
|
||||
"version": "1.1.25",
|
||||
"description": "Brightpearl plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -27,7 +27,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"prettier": "^2.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -43,7 +43,7 @@
|
||||
"axios": "^0.19.2",
|
||||
"axios-rate-limit": "^1.2.1",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-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,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-contentful",
|
||||
"version": "1.1.21",
|
||||
"version": "1.1.22",
|
||||
"description": "Contentful plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"contentful-management": "^5.27.1",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"redis": "^3.0.2"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.10...medusa-plugin-discount-generator@1.1.11) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.9...medusa-plugin-discount-generator@1.1.10) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-discount-generator",
|
||||
"version": "1.1.10",
|
||||
"version": "1.1.11",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"author": "Sebastian Rindom",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.19...medusa-plugin-economic@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.18...medusa-plugin-economic@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "E-conomic financial reporting",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"moment": "^2.27.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.10...medusa-plugin-ip-lookup@1.1.11) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.9...medusa-plugin-ip-lookup@1.1.10) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-ip-lookup",
|
||||
"version": "1.1.10",
|
||||
"version": "1.1.11",
|
||||
"description": "IP lookup middleware for Medusa core",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.19...medusa-plugin-mailchimp@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.18...medusa-plugin-mailchimp@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-mailchimp",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Mailchimp newsletter subscriptions",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -40,8 +40,8 @@
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"mailchimp-api-v3": "^1.14.0",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.19...medusa-plugin-permissions@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-permissions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.18...medusa-plugin-permissions@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-permissions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-permissions",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Role permission for Medusa core",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -32,8 +32,8 @@
|
||||
"medusa-interfaces": "1.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"mongoose": "^5.8.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.12...medusa-plugin-restock-notification@0.0.13) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.11...medusa-plugin-restock-notification@0.0.12) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||
|
||||
@@ -35,7 +35,7 @@ Body
|
||||
}
|
||||
```
|
||||
|
||||
The endpoint responds with `200 OK` on succesful signups. If a signup for an already in stock item is attempted the endpoint will have a 400 response code.
|
||||
The endpoint responds with `200 OK` on successful signups. If a signup for an already in stock item is attempted the endpoint will have a 400 response code.
|
||||
|
||||
|
||||
## Restock events
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-restock-notification",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.13",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -14,11 +14,11 @@
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/plugin-transform-typescript": "^7.13.0",
|
||||
"@babel/preset-typescript": "^7.12.7",
|
||||
"babel-preset-medusa-package": "^1.1.10",
|
||||
"babel-preset-medusa-package": "^1.1.11",
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"pg": "^8.5.1",
|
||||
"ulid": "^2.3.0"
|
||||
},
|
||||
@@ -36,7 +36,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16"
|
||||
"medusa-core-utils": "^1.1.17"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.22...medusa-plugin-segment@1.1.23) (2021-07-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sends return reasons to segment on Order Refunded event ([55ba9ba](https://github.com/medusajs/medusa/commit/55ba9bae05527d602d654f99d678b610c5ba7229))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.21...medusa-plugin-segment@1.1.22) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-segment
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-segment",
|
||||
"version": "1.1.22",
|
||||
"version": "1.1.23",
|
||||
"description": "Segment Analytics",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -134,6 +134,68 @@ describe("SegmentService", () => {
|
||||
})
|
||||
})
|
||||
|
||||
it("successfully adds return reason and note on buildOrder", async () => {
|
||||
jest.clearAllMocks()
|
||||
|
||||
const order = orderFactory()
|
||||
order.items = order.items.map((i) => {
|
||||
i.note = "testing 1234"
|
||||
i.reason = {
|
||||
value: "test_reason",
|
||||
id: "rr_test",
|
||||
}
|
||||
return i
|
||||
})
|
||||
const segmentOrder = await segmentService.buildOrder(order)
|
||||
|
||||
expect(segmentOrder).toEqual({
|
||||
checkout_id: "cart_13",
|
||||
coupon: undefined,
|
||||
currency: "DKK",
|
||||
discount: 0,
|
||||
email: "test@example.com",
|
||||
order_id: "12355",
|
||||
payment_provider: "",
|
||||
products: [
|
||||
{
|
||||
category: "Collection",
|
||||
name: "Test",
|
||||
price: 4.47,
|
||||
product_id: "prod_123",
|
||||
quantity: 2,
|
||||
reporting_revenue: 8.94,
|
||||
sku: "",
|
||||
subtitle: "Subtitle",
|
||||
type: "Type",
|
||||
variant: "TEST",
|
||||
reason_id: "rr_test",
|
||||
reason_value: "test_reason",
|
||||
note: "testing 1234",
|
||||
},
|
||||
],
|
||||
region_id: "reg_123",
|
||||
reporting_discount: 0,
|
||||
reporting_revenue: 123.99,
|
||||
reporting_shipping: 123.99,
|
||||
reporting_subtotal: 22,
|
||||
reporting_tax: 0,
|
||||
reporting_total: 123.99,
|
||||
revenue: 123.99,
|
||||
shipping: 123.99,
|
||||
shipping_city: undefined,
|
||||
shipping_country: "DK",
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "standard",
|
||||
price: 12399,
|
||||
},
|
||||
],
|
||||
subtotal: 22,
|
||||
tax: 0,
|
||||
total: 123.99,
|
||||
})
|
||||
})
|
||||
|
||||
it("successfully builds order with zero decimal currency", async () => {
|
||||
jest.clearAllMocks()
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class SegmentService extends BaseService {
|
||||
{ relations: ["collection", "type"] }
|
||||
)
|
||||
|
||||
return {
|
||||
const toReturn = {
|
||||
name,
|
||||
variant,
|
||||
price: this.rounded_(
|
||||
@@ -155,6 +155,19 @@ class SegmentService extends BaseService {
|
||||
sku,
|
||||
quantity: item.quantity,
|
||||
}
|
||||
|
||||
// If we are building a refund order include details about
|
||||
// the reason for return
|
||||
if (item.reason) {
|
||||
toReturn.reason_id = item.reason.id
|
||||
toReturn.reason_value = item.reason.value
|
||||
}
|
||||
|
||||
if (item.note) {
|
||||
toReturn.note = item.note
|
||||
}
|
||||
|
||||
return toReturn
|
||||
})
|
||||
),
|
||||
}
|
||||
|
||||
@@ -163,7 +163,9 @@ class OrderSubscriber {
|
||||
],
|
||||
})
|
||||
|
||||
const ret = await this.returnService_.retrieve(return_id)
|
||||
const ret = await this.returnService_.retrieve(return_id, {
|
||||
relations: ["items", "items.reason"],
|
||||
})
|
||||
|
||||
const shipping = []
|
||||
if (ret.shipping_method && ret.shipping_method.price) {
|
||||
@@ -185,7 +187,17 @@ class OrderSubscriber {
|
||||
const toBuildFrom = {
|
||||
...order,
|
||||
shipping_methods: shipping,
|
||||
items: ret.items.map((i) => merged.find((l) => l.id === i.item_id)),
|
||||
items: ret.items.map((i) => {
|
||||
const li = merged.find((l) => l.id === i.item_id)
|
||||
if (i.reason) {
|
||||
li.reason = i.reason
|
||||
}
|
||||
|
||||
if (i.note) {
|
||||
li.note = i.note
|
||||
}
|
||||
return li
|
||||
}),
|
||||
}
|
||||
|
||||
const orderData = await segmentService.buildOrder(toBuildFrom)
|
||||
|
||||
@@ -879,6 +879,18 @@
|
||||
exec-sh "^0.3.2"
|
||||
minimist "^1.2.0"
|
||||
|
||||
"@hapi/hoek@^9.0.0":
|
||||
version "9.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
|
||||
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==
|
||||
|
||||
"@hapi/topo@^5.0.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012"
|
||||
integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@istanbuljs/load-nyc-config@^1.0.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
|
||||
@@ -1071,6 +1083,23 @@
|
||||
component-type "^1.2.1"
|
||||
join-component "^1.1.0"
|
||||
|
||||
"@sideway/address@^4.1.0":
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1"
|
||||
integrity sha512-idTz8ibqWFrPU8kMirL0CoPH/A29XOzzAzpyN3zQ4kAWnzmNfFmRaoMNN6VI8ske5M73HZyhIaW4OuSFIdM4oA==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@sideway/formula@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
|
||||
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
|
||||
|
||||
"@sideway/pinpoint@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
|
||||
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.0.tgz#c8d68821a854c555bba172f3b06959a0039b236d"
|
||||
@@ -2997,6 +3026,11 @@ is-number@^3.0.0:
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
is-number@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff"
|
||||
integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==
|
||||
|
||||
is-number@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
|
||||
@@ -3487,6 +3521,22 @@ jest@^25.5.2:
|
||||
import-local "^3.0.2"
|
||||
jest-cli "^25.5.4"
|
||||
|
||||
joi-objectid@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668"
|
||||
integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ==
|
||||
|
||||
joi@^17.3.0:
|
||||
version "17.4.0"
|
||||
resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.0.tgz#b5c2277c8519e016316e49ababd41a1908d9ef20"
|
||||
integrity sha512-F4WiW2xaV6wc1jxete70Rw4V/VuMd6IN+a5ilZsxG4uYtUXWu2kq9W5P2dz30e7Gmw8RCbY/u/uk+dMPma9tAg==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
"@hapi/topo" "^5.0.0"
|
||||
"@sideway/address" "^4.1.0"
|
||||
"@sideway/formula" "^3.0.0"
|
||||
"@sideway/pinpoint" "^2.0.0"
|
||||
|
||||
join-component@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5"
|
||||
@@ -3726,6 +3776,11 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
math-random@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c"
|
||||
integrity sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==
|
||||
|
||||
md5@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9"
|
||||
@@ -3740,6 +3795,23 @@ media-typer@0.3.0:
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
||||
|
||||
medusa-core-utils@^1.1.16:
|
||||
version "1.1.16"
|
||||
resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.16.tgz#e7002d861aebf81dec7bd0654615eefbd55cb530"
|
||||
integrity sha512-O176mtAILLbwahxJu2dAOZRnz9AzrX6Oa1NDhrtbBvaPuaFZlhxiajwZkP3KM58bGZ9feKfJ4mVuY2Mtsgj3YA==
|
||||
dependencies:
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-test-utils@^1.1.19:
|
||||
version "1.1.19"
|
||||
resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.19.tgz#f765b6ba39e0bfe6301423a9b39d4e7e3b1ed32b"
|
||||
integrity sha512-GkGWOUQsrNTm7tv2P7fG9f651+C05cLpy+nuPPSouIAkxpS0mDqeD1VSrHjFnpz1BPUsjwJGWFFAH5Jd8X5yvQ==
|
||||
dependencies:
|
||||
"@babel/plugin-transform-classes" "^7.9.5"
|
||||
medusa-core-utils "^1.1.16"
|
||||
randomatic "^3.1.1"
|
||||
|
||||
merge-descriptors@1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
||||
@@ -4290,6 +4362,15 @@ qs@~6.5.2:
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
|
||||
|
||||
randomatic@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.1.tgz#b776efc59375984e36c537b2f51a1f0aff0da1ed"
|
||||
integrity sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==
|
||||
dependencies:
|
||||
is-number "^4.0.0"
|
||||
kind-of "^6.0.0"
|
||||
math-random "^1.0.1"
|
||||
|
||||
range-parser@~1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-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,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-sendgrid",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.21",
|
||||
"description": "SendGrid transactional emails",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"@sendgrid/mail": "^7.1.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-slack-notification",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Slack notifications",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -39,8 +39,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"moment": "^2.27.0"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.19...medusa-plugin-twilio-sms@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.18...medusa-plugin-twilio-sms@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-twilio-sms",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,8 +35,8 @@
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"body-parser": "^1.19.0",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"twilio": "^3.49.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.19...medusa-plugin-wishlist@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-wishlist
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.18...medusa-plugin-wishlist@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-wishlist
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-plugin-wishlist",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -37,8 +37,8 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19"
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
}
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.19...medusa-test-utils@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.18...medusa-test-utils@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "medusa-test-utils",
|
||||
"version": "1.1.19",
|
||||
"version": "1.1.20",
|
||||
"description": "Test utils for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
|
||||
|
||||
@@ -3,6 +3,21 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.29...@medusajs/medusa@1.1.30) (2021-07-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* adds tracking links to customer orders ([c013270](https://github.com/medusajs/medusa/commit/c0132700b78d171d6c7e29e2604b99129c5a1921))
|
||||
* allow updating billing address on customer ([5a1cbc6](https://github.com/medusajs/medusa/commit/5a1cbc68b721fe80d223e4ff611ebc81346333d7))
|
||||
* better store/customer support ([6342e68](https://github.com/medusajs/medusa/commit/6342e68d069636e5eb4877c7ebf7aac952b5e363))
|
||||
* create fulfillment ([0603a86](https://github.com/medusajs/medusa/commit/0603a86d65a528af86bdbdc46227faa2f48a93bb))
|
||||
* **medusa:** Resolve issue with soft-delete and unique indexes in DB ([#296](https://github.com/medusajs/medusa/issues/296)) ([6358f8f](https://github.com/medusajs/medusa/commit/6358f8fc756291710a82ce39a47d0cbec1395b87))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.28...@medusajs/medusa@1.1.29) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @medusajs/medusa
|
||||
|
||||
@@ -36,7 +36,7 @@ The steps can be done in any order. The standard path would probably be:
|
||||
|
||||
Assuming that shipping methods are static within each region we can display all shipping methods at checkout time. If shipping is dynamically calculated the price of the shipping method may change, we will ask the fulfillment provider for new rates.
|
||||
|
||||
Payment details can be entered at any point as long as the final amount is known. If the final amount changes afer the payment details are entered the payment method may therefore be invalidated.
|
||||
Payment details can be entered at any point as long as the final amount is known. If the final amount changes after the payment details are entered the payment method may therefore be invalidated.
|
||||
|
||||
Within the store UI you could imagine each step being taken care of by a single button click, which calls all endpoints.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@medusajs/medusa",
|
||||
"version": "1.1.29",
|
||||
"version": "1.1.30",
|
||||
"description": "E-commerce for JAMstack",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
@@ -17,11 +17,11 @@
|
||||
"@babel/cli": "^7.14.3",
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"babel-preset-medusa-package": "^1.1.10",
|
||||
"babel-preset-medusa-package": "^1.1.11",
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-interfaces": "^1.1.17",
|
||||
"medusa-interfaces": "^1.1.18",
|
||||
"nodemon": "^2.0.1",
|
||||
"prettier": "^1.19.1",
|
||||
"supertest": "^4.0.2"
|
||||
@@ -59,8 +59,8 @@
|
||||
"joi": "^17.3.0",
|
||||
"joi-objectid": "^3.0.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"medusa-core-utils": "^1.1.16",
|
||||
"medusa-test-utils": "^1.1.19",
|
||||
"medusa-core-utils": "^1.1.17",
|
||||
"medusa-test-utils": "^1.1.20",
|
||||
"morgan": "^1.9.1",
|
||||
"multer": "^1.4.2",
|
||||
"passport": "^0.4.0",
|
||||
|
||||
@@ -9,6 +9,9 @@ export default () => {
|
||||
|
||||
let statusCode = 500
|
||||
switch (err.name) {
|
||||
case MedusaError.Types.DUPLICATE_ERROR:
|
||||
statusCode = 409
|
||||
break
|
||||
case MedusaError.Types.NOT_ALLOWED:
|
||||
case MedusaError.Types.INVALID_DATA:
|
||||
statusCode = 400
|
||||
|
||||
@@ -63,6 +63,9 @@ import { defaultFields, defaultRelations } from "."
|
||||
* customer_id:
|
||||
* description: The id of the customer to add on the draft order
|
||||
* type: string
|
||||
* no_notification_order:
|
||||
* description: An optional flag passed to the resulting order to determine use of notifications.
|
||||
* type: boolean
|
||||
* shipping_methods:
|
||||
* description: The shipping methods for the draft order
|
||||
* type: array
|
||||
@@ -123,6 +126,7 @@ export default async (req, res) => {
|
||||
})
|
||||
.optional(),
|
||||
customer_id: Validator.string().optional(),
|
||||
no_notification_order: Validator.boolean().optional(),
|
||||
shipping_methods: Validator.array()
|
||||
.items({
|
||||
option_id: Validator.string().required(),
|
||||
|
||||
@@ -78,6 +78,7 @@ export const defaultFields = [
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"metadata",
|
||||
"no_notification_order",
|
||||
]
|
||||
|
||||
export const allowedFields = [
|
||||
@@ -89,6 +90,7 @@ export const allowedFields = [
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"metadata",
|
||||
"no_notification_order",
|
||||
]
|
||||
|
||||
export const allowedRelations = ["cart"]
|
||||
@@ -35,6 +35,9 @@ import { defaultCartFields, defaultCartRelations, defaultFields } from "."
|
||||
* code:
|
||||
* description: "The code that a Discount is identifed by."
|
||||
* type: string
|
||||
* no_notification_order:
|
||||
* description: "An optional flag passed to the resulting order to determine use of notifications."
|
||||
* type: boolean
|
||||
* customer_id:
|
||||
* description: "The id of the Customer to associate the Draft Order with."
|
||||
* type: string
|
||||
@@ -68,6 +71,7 @@ export default async (req, res) => {
|
||||
})
|
||||
.optional(),
|
||||
customer_id: Validator.string().optional(),
|
||||
no_notification_order: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -88,6 +92,13 @@ export default async (req, res) => {
|
||||
)
|
||||
}
|
||||
|
||||
if ("no_notification_order" in value) {
|
||||
await draftOrderService.update(draftOrder.id, {
|
||||
no_notification_order: value.no_notification_order,
|
||||
})
|
||||
delete value.no_notification_order
|
||||
}
|
||||
|
||||
await cartService.update(draftOrder.cart_id, value)
|
||||
|
||||
draftOrder.cart = await cartService.retrieve(draftOrder.cart_id, {
|
||||
|
||||
@@ -33,7 +33,10 @@ export const defaultFields = [
|
||||
"metadata",
|
||||
]
|
||||
|
||||
export const defaultRelations = ["region"]
|
||||
export const defaultRelations = [
|
||||
"region",
|
||||
"order",
|
||||
]
|
||||
|
||||
export const allowedFields = [
|
||||
"id",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { MedusaError, Validator } from "medusa-core-utils"
|
||||
import { defaultFields, defaultRelations } from "./"
|
||||
|
||||
/**
|
||||
@@ -21,14 +22,23 @@ import { defaultFields, defaultRelations } from "./"
|
||||
*/
|
||||
export default async (req, res) => {
|
||||
try {
|
||||
const limit = parseInt(req.query.limit) || 50
|
||||
const offset = parseInt(req.query.offset) || 0
|
||||
|
||||
const selector = {}
|
||||
|
||||
if ("q" in req.query) {
|
||||
selector.q = req.query.q
|
||||
}
|
||||
|
||||
const giftCardService = req.scope.resolve("giftCardService")
|
||||
|
||||
const giftCards = await giftCardService.list(selector, {
|
||||
select: defaultFields,
|
||||
relations: defaultRelations,
|
||||
order: { created_at: "DESC" },
|
||||
limit: limit,
|
||||
skip: offset,
|
||||
})
|
||||
|
||||
res.status(200).json({ gift_cards: giftCards })
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { MedusaError, Validator } from "medusa-core-utils"
|
||||
import { defaultFields, defaultRelations } from "./"
|
||||
|
||||
/**
|
||||
* @oas [post] /gift-cards/{id}
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("POST /admin/orders/:id/fulfillment", () => {
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
undefined
|
||||
{ metadata: undefined, no_notification: undefined }
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ const defaultFields = [
|
||||
"total",
|
||||
"paid_total",
|
||||
"refundable_amount",
|
||||
"no_notification",
|
||||
]
|
||||
|
||||
describe("GET /admin/orders", () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orders } from "../../../../../services/__mocks__/order"
|
||||
import { ReturnService } from "../../../../../services/__mocks__/return"
|
||||
import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus"
|
||||
|
||||
describe("POST /admin/orders/:id/return", () => {
|
||||
describe("successfully returns full order", () => {
|
||||
@@ -21,6 +21,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund: 10,
|
||||
no_notification: true,
|
||||
},
|
||||
adminSession: {
|
||||
jwt: {
|
||||
@@ -47,6 +48,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund_amount: 10,
|
||||
no_notification: true,
|
||||
shipping_method: undefined,
|
||||
})
|
||||
})
|
||||
@@ -69,6 +71,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund: -1,
|
||||
no_notification: true,
|
||||
},
|
||||
adminSession: {
|
||||
jwt: {
|
||||
@@ -95,6 +98,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund_amount: 0,
|
||||
no_notification: true,
|
||||
shipping_method: undefined,
|
||||
})
|
||||
})
|
||||
@@ -118,6 +122,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
],
|
||||
refund: -1,
|
||||
},
|
||||
no_notification: true,
|
||||
adminSession: {
|
||||
jwt: {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
@@ -143,6 +148,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund_amount: 0,
|
||||
no_notification: true,
|
||||
shipping_method: undefined,
|
||||
})
|
||||
})
|
||||
@@ -165,6 +171,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund: 100,
|
||||
no_notification: true,
|
||||
return_shipping: {
|
||||
option_id: "opt_1234",
|
||||
price: 12,
|
||||
@@ -195,6 +202,7 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
],
|
||||
refund_amount: 100,
|
||||
no_notification: true,
|
||||
shipping_method: {
|
||||
option_id: "opt_1234",
|
||||
price: 12,
|
||||
@@ -205,4 +213,82 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
expect(ReturnService.fulfill).toHaveBeenCalledWith("return")
|
||||
})
|
||||
})
|
||||
|
||||
describe("the api call overrides notification settings of order", () => {
|
||||
it("eventBus is called with the proper no notification feature", async () => {
|
||||
jest.clearAllMocks()
|
||||
const subject = await request(
|
||||
"POST",
|
||||
`/admin/orders/${IdMap.getId("test-order")}/return`,
|
||||
{
|
||||
payload: {
|
||||
items: [
|
||||
{
|
||||
item_id: IdMap.getId("existingLine"),
|
||||
quantity: 10,
|
||||
},
|
||||
],
|
||||
refund: 100,
|
||||
return_shipping: {
|
||||
option_id: "opt_1234",
|
||||
price: 12,
|
||||
},
|
||||
no_notification: false,
|
||||
},
|
||||
adminSession: {
|
||||
jwt: {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
{
|
||||
id: expect.any(String),
|
||||
no_notification: false,
|
||||
return_id: expect.any(String),
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("the api call inherits notification settings of order", () => {
|
||||
it("eventBus is called with the proper no notification feature", async () => {
|
||||
jest.clearAllMocks()
|
||||
await request(
|
||||
"POST",
|
||||
`/admin/orders/${IdMap.getId("test-order")}/return`,
|
||||
{
|
||||
payload: {
|
||||
items: [
|
||||
{
|
||||
item_id: IdMap.getId("existingLine"),
|
||||
quantity: 10,
|
||||
},
|
||||
],
|
||||
refund: 100,
|
||||
return_shipping: {
|
||||
option_id: "opt_1234",
|
||||
price: 12,
|
||||
},
|
||||
},
|
||||
adminSession: {
|
||||
jwt: {
|
||||
userId: IdMap.getId("admin_user"),
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
{
|
||||
id: expect.any(String),
|
||||
no_notification: true,
|
||||
return_id: expect.any(String),
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -91,6 +91,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* refund_amount:
|
||||
* description: The amount to refund the Customer when the Claim type is `refund`.
|
||||
* type: integer
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Claim.
|
||||
* type: boolean
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
@@ -108,7 +111,6 @@ import { defaultRelations, defaultFields } from "./"
|
||||
*/
|
||||
export default async (req, res) => {
|
||||
const { id } = req.params
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
type: Validator.string()
|
||||
.valid("replace", "refund")
|
||||
@@ -155,6 +157,7 @@ export default async (req, res) => {
|
||||
.integer()
|
||||
.optional(),
|
||||
shipping_address: Validator.object().optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
@@ -162,7 +165,6 @@ export default async (req, res) => {
|
||||
if (error) {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
const idempotencyKeyService = req.scope.resolve("idempotencyKeyService")
|
||||
|
||||
const headerKey = req.get("Idempotency-Key") || ""
|
||||
@@ -212,6 +214,7 @@ export default async (req, res) => {
|
||||
return_shipping: value.return_shipping,
|
||||
additional_items: value.additional_items,
|
||||
shipping_methods: value.shipping_methods,
|
||||
no_notification: value.no_notification,
|
||||
metadata: value.metadata,
|
||||
})
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* quantity:
|
||||
* description: The quantity of the Line Item to fulfill.
|
||||
* type: integer
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Swap.
|
||||
* type: boolean
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
@@ -49,6 +52,7 @@ export default async (req, res) => {
|
||||
quantity: Validator.number().required(),
|
||||
})
|
||||
.required(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
@@ -60,7 +64,10 @@ export default async (req, res) => {
|
||||
try {
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
await orderService.createFulfillment(id, value.items, value.metadata)
|
||||
await orderService.createFulfillment(id, value.items, {
|
||||
metadata: value.metadata,
|
||||
no_notification: value.no_notification,
|
||||
})
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
select: defaultFields,
|
||||
|
||||
@@ -27,6 +27,7 @@ export default async (req, res) => {
|
||||
items: Validator.array().optional(),
|
||||
})
|
||||
.required(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Shipment.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -41,6 +44,7 @@ export default async (req, res) => {
|
||||
tracking_numbers: Validator.array()
|
||||
.items(Validator.string())
|
||||
.optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -54,7 +58,8 @@ export default async (req, res) => {
|
||||
await orderService.createShipment(
|
||||
id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n })),
|
||||
{ no_notification: value.no_notification }
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -22,6 +22,9 @@ import { defaultFields, defaultRelations } from "./"
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Claim.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -42,6 +45,7 @@ export default async (req, res) => {
|
||||
tracking_numbers: Validator.array()
|
||||
.items(Validator.string())
|
||||
.optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -56,7 +60,8 @@ export default async (req, res) => {
|
||||
await swapService.createShipment(
|
||||
swap_id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n })),
|
||||
{ no_notification: value.no_notification }
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -45,6 +45,9 @@ import { defaultFields, defaultRelations } from "./"
|
||||
* quantity:
|
||||
* description: The quantity of the Product Variant to ship.
|
||||
* type: integer
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Swap.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -79,6 +82,7 @@ export default async (req, res) => {
|
||||
variant_id: Validator.string().required(),
|
||||
quantity: Validator.number().required(),
|
||||
}),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -134,7 +138,10 @@ export default async (req, res) => {
|
||||
value.return_items,
|
||||
value.additional_items,
|
||||
value.return_shipping,
|
||||
{ idempotency_key: idempotencyKey.idempotency_key }
|
||||
{
|
||||
idempotency_key: idempotencyKey.idempotency_key,
|
||||
no_notification: value.no_notification,
|
||||
}
|
||||
)
|
||||
|
||||
await swapService.withTransaction(manager).createCart(swap.id)
|
||||
|
||||
@@ -17,6 +17,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Claim.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -34,6 +37,7 @@ export default async (req, res) => {
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
metadata: Validator.object().optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -47,9 +51,10 @@ export default async (req, res) => {
|
||||
const entityManager = req.scope.resolve("manager")
|
||||
|
||||
await entityManager.transaction(async manager => {
|
||||
await claimService
|
||||
.withTransaction(manager)
|
||||
.createFulfillment(claim_id, value.metadata)
|
||||
await claimService.withTransaction(manager).createFulfillment(claim_id, {
|
||||
metadata: value.metadata,
|
||||
no_notification: value.no_notification,
|
||||
})
|
||||
})
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -17,6 +17,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Claim.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -34,6 +37,7 @@ export default async (req, res) => {
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
metadata: Validator.object().optional(),
|
||||
no_notification: Validator.boolean().optional,
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -47,9 +51,10 @@ export default async (req, res) => {
|
||||
const entityManager = req.scope.resolve("manager")
|
||||
|
||||
await entityManager.transaction(async manager => {
|
||||
await swapService
|
||||
.withTransaction(manager)
|
||||
.createFulfillment(swap_id, value.metadata)
|
||||
await swapService.withTransaction(manager).createFulfillment(swap_id, {
|
||||
metadata: value.metadata,
|
||||
no_notification: value.no_notification,
|
||||
})
|
||||
|
||||
const order = await orderService.withTransaction(manager).retrieve(id, {
|
||||
select: defaultFields,
|
||||
|
||||
@@ -237,6 +237,7 @@ export const defaultFields = [
|
||||
"total",
|
||||
"paid_total",
|
||||
"refundable_amount",
|
||||
"no_notification",
|
||||
]
|
||||
|
||||
export const allowedFields = [
|
||||
@@ -265,6 +266,7 @@ export const allowedFields = [
|
||||
"total",
|
||||
"paid_total",
|
||||
"refundable_amount",
|
||||
"no_notification",
|
||||
]
|
||||
|
||||
export const allowedRelations = [
|
||||
|
||||
@@ -25,6 +25,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* note:
|
||||
* description: A not with additional details about the Refund.
|
||||
* type: string
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Refund.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -47,9 +50,11 @@ export default async (req, res) => {
|
||||
note: Validator.string()
|
||||
.allow("")
|
||||
.optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
|
||||
if (error) {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
@@ -57,7 +62,13 @@ export default async (req, res) => {
|
||||
try {
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
await orderService.createRefund(id, value.amount, value.reason, value.note)
|
||||
await orderService.createRefund(
|
||||
id,
|
||||
value.amount,
|
||||
value.reason,
|
||||
value.note,
|
||||
{ no_notification: value.no_notification }
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
select: defaultFields,
|
||||
|
||||
@@ -43,6 +43,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* receive_now:
|
||||
* description: A flag to indicate if the Return should be registerd as received immediately.
|
||||
* type: boolean
|
||||
* no_notification:
|
||||
* description: A flag to indicate if no notifications should be emitted related to the requested Return.
|
||||
* type: boolean
|
||||
* refund:
|
||||
* description: The amount to refund.
|
||||
* type: integer
|
||||
@@ -79,6 +82,7 @@ export default async (req, res) => {
|
||||
})
|
||||
.optional(),
|
||||
receive_now: Validator.boolean().default(false),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
refund: Validator.number()
|
||||
.integer()
|
||||
.optional(),
|
||||
@@ -141,6 +145,13 @@ export default async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
let order = await orderService
|
||||
.withTransaction(manager)
|
||||
.retrieve(id)
|
||||
|
||||
const evaluatedNoNotification = value.no_notification !== undefined ? value.no_notification : order.no_notification
|
||||
returnObj.no_notification = evaluatedNoNotification
|
||||
|
||||
const createdReturn = await returnService
|
||||
.withTransaction(manager)
|
||||
.create(returnObj)
|
||||
@@ -150,12 +161,13 @@ export default async (req, res) => {
|
||||
.withTransaction(manager)
|
||||
.fulfill(createdReturn.id)
|
||||
}
|
||||
|
||||
|
||||
await eventBus
|
||||
.withTransaction(manager)
|
||||
.emit("order.return_requested", {
|
||||
id,
|
||||
return_id: createdReturn.id,
|
||||
no_notification: evaluatedNoNotification
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -62,6 +62,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* price:
|
||||
* description: The price to charge for the Shipping Method
|
||||
* type: integer
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Swap.
|
||||
* type: boolean
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
@@ -106,6 +109,7 @@ export default async (req, res) => {
|
||||
.optional(),
|
||||
})
|
||||
.optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async (req, res) => {
|
||||
data: Validator.object(),
|
||||
items: Validator.array(),
|
||||
}),
|
||||
no_notification: Validator.boolean(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
|
||||
@@ -54,6 +54,7 @@ export default async (req, res) => {
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
|
||||
if (error) {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { CustomerServiceMock } from "../../../../../services/__mocks__/customer"
|
||||
import { defaultFields, defaultRelations } from "../"
|
||||
|
||||
describe("POST /store/customers", () => {
|
||||
describe("successfully creates a customer", () => {
|
||||
@@ -34,7 +35,7 @@ describe("POST /store/customers", () => {
|
||||
expect(CustomerServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
||||
expect(CustomerServiceMock.retrieve).toHaveBeenCalledWith(
|
||||
IdMap.getId("lebron"),
|
||||
{ relations: ["shipping_addresses"] }
|
||||
{ relations: defaultRelations, select: defaultFields }
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { defaultFields, defaultRelations } from "../"
|
||||
import { CustomerServiceMock } from "../../../../../services/__mocks__/customer"
|
||||
|
||||
describe("POST /store/customers/:id", () => {
|
||||
@@ -42,7 +43,7 @@ describe("POST /store/customers/:id", () => {
|
||||
expect(CustomerServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
||||
expect(CustomerServiceMock.retrieve).toHaveBeenCalledWith(
|
||||
IdMap.getId("lebron"),
|
||||
{ relations: ["shipping_addresses"] }
|
||||
{ relations: defaultRelations, select: defaultFields }
|
||||
)
|
||||
})
|
||||
|
||||
@@ -55,6 +56,98 @@ describe("POST /store/customers/:id", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("successfully updates a customer with billing address id", () => {
|
||||
let subject
|
||||
beforeAll(async () => {
|
||||
subject = await request(
|
||||
"POST",
|
||||
`/store/customers/${IdMap.getId("lebron")}`,
|
||||
{
|
||||
payload: {
|
||||
billing_address: "test",
|
||||
},
|
||||
clientSession: {
|
||||
jwt: {
|
||||
customer_id: IdMap.getId("lebron"),
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it("calls CustomerService update", () => {
|
||||
expect(CustomerServiceMock.update).toHaveBeenCalledTimes(1)
|
||||
expect(CustomerServiceMock.update).toHaveBeenCalledWith(
|
||||
IdMap.getId("lebron"),
|
||||
{
|
||||
billing_address: "test",
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it("status code 200", () => {
|
||||
expect(subject.status).toEqual(200)
|
||||
})
|
||||
})
|
||||
|
||||
describe("successfully updates a customer with billing address object", () => {
|
||||
let subject
|
||||
beforeAll(async () => {
|
||||
subject = await request(
|
||||
"POST",
|
||||
`/store/customers/${IdMap.getId("lebron")}`,
|
||||
{
|
||||
payload: {
|
||||
billing_address: {
|
||||
first_name: "Olli",
|
||||
last_name: "Juhl",
|
||||
address_1: "Laksegade",
|
||||
city: "Copenhagen",
|
||||
country_code: "dk",
|
||||
postal_code: "2100",
|
||||
phone: "+1 (222) 333 4444",
|
||||
},
|
||||
},
|
||||
clientSession: {
|
||||
jwt: {
|
||||
customer_id: IdMap.getId("lebron"),
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it("calls CustomerService update", () => {
|
||||
expect(CustomerServiceMock.update).toHaveBeenCalledTimes(1)
|
||||
expect(CustomerServiceMock.update).toHaveBeenCalledWith(
|
||||
IdMap.getId("lebron"),
|
||||
{
|
||||
billing_address: {
|
||||
first_name: "Olli",
|
||||
last_name: "Juhl",
|
||||
address_1: "Laksegade",
|
||||
city: "Copenhagen",
|
||||
country_code: "dk",
|
||||
postal_code: "2100",
|
||||
phone: "+1 (222) 333 4444",
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it("status code 200", () => {
|
||||
expect(subject.status).toEqual(200)
|
||||
})
|
||||
})
|
||||
|
||||
describe("fails if not authenticated", () => {
|
||||
let subject
|
||||
beforeAll(async () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Validator, MedusaError } from "medusa-core-utils"
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [post] /customers/{id}/addresses
|
||||
@@ -45,7 +46,8 @@ export default async (req, res) => {
|
||||
|
||||
let customer = await customerService.addAddress(id, value.address)
|
||||
customer = await customerService.retrieve(id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
res.status(200).json({ customer })
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import jwt from "jsonwebtoken"
|
||||
import { Validator, MedusaError } from "medusa-core-utils"
|
||||
import config from "../../../../config"
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [post] /customers
|
||||
@@ -40,6 +41,7 @@ export default async (req, res) => {
|
||||
if (error) {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
try {
|
||||
const customerService = req.scope.resolve("customerService")
|
||||
let customer = await customerService.create(value)
|
||||
@@ -50,7 +52,8 @@ export default async (req, res) => {
|
||||
})
|
||||
|
||||
customer = await customerService.retrieve(customer.id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
res.status(200).json({ customer })
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [delete] /customers/{id}/addresses/{address_id}
|
||||
* operationId: DeleteCustomersCustomerAddressesAddress
|
||||
@@ -25,7 +27,8 @@ export default async (req, res) => {
|
||||
try {
|
||||
await customerService.removeAddress(id, address_id)
|
||||
customer = await customerService.retrieve(id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
res.json({ customer })
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [get] /customers/{id}
|
||||
* operationId: GetCustomersCustomer
|
||||
@@ -22,7 +24,8 @@ export default async (req, res) => {
|
||||
try {
|
||||
const customerService = req.scope.resolve("customerService")
|
||||
const customer = await customerService.retrieve(id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
res.json({ customer })
|
||||
} catch (err) {
|
||||
|
||||
@@ -57,3 +57,39 @@ export default (app, container) => {
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
export const defaultRelations = ["shipping_addresses", "billing_address"]
|
||||
|
||||
export const defaultFields = [
|
||||
"id",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"billing_address_id",
|
||||
"phone",
|
||||
"has_account",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
"metadata",
|
||||
]
|
||||
|
||||
export const allowedRelations = [
|
||||
"shipping_addresses",
|
||||
"billing_address",
|
||||
"orders",
|
||||
]
|
||||
|
||||
export const allowedFields = [
|
||||
"id",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"billing_address_id",
|
||||
"phone",
|
||||
"has_account",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
"metadata",
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Validator, MedusaError } from "medusa-core-utils"
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [post] /customers/{id}/addresses/{address_id}
|
||||
@@ -50,7 +51,8 @@ export default async (req, res) => {
|
||||
)
|
||||
|
||||
customer = await customerService.retrieve(id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
res.json({ customer })
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Validator, MedusaError } from "medusa-core-utils"
|
||||
import { defaultRelations, defaultFields } from "./"
|
||||
|
||||
/**
|
||||
* @oas [post] /customers/{id}
|
||||
@@ -18,12 +19,19 @@ import { Validator, MedusaError } from "medusa-core-utils"
|
||||
* last_name:
|
||||
* description: "The Customer's last name."
|
||||
* type: string
|
||||
* billing_address:
|
||||
* description: "The Address to be used for billing purposes."
|
||||
* anyOf:
|
||||
* - $ref: "#/components/schemas/address"
|
||||
* password:
|
||||
* description: "The Customer's password."
|
||||
* type: string
|
||||
* phone:
|
||||
* description: "The Customer's phone number."
|
||||
* type: string
|
||||
* metadata:
|
||||
* description: "Metadata about the customer."
|
||||
* type: object
|
||||
* tags:
|
||||
* - Customer
|
||||
* responses:
|
||||
@@ -40,10 +48,12 @@ export default async (req, res) => {
|
||||
const { id } = req.params
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
billing_address: Validator.address().optional(),
|
||||
first_name: Validator.string().optional(),
|
||||
last_name: Validator.string().optional(),
|
||||
password: Validator.string().optional(),
|
||||
phone: Validator.string().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -56,7 +66,8 @@ export default async (req, res) => {
|
||||
let customer = await customerService.update(id, value)
|
||||
|
||||
customer = await customerService.retrieve(customer.id, {
|
||||
relations: ["shipping_addresses"],
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
res.status(200).json({ customer })
|
||||
|
||||
Loaded 100 of 144 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user