diff --git a/.babelrc.js b/.babelrc.js index bde709c495..39c0fa3e45 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -1,13 +1,13 @@ -let ignore = [`**/dist`] +let ignore = [`**/dist`]; // 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__`) + ignore.push(`**/__tests__`); } module.exports = { sourceMaps: true, presets: ["babel-preset-medusa-package"], ignore, -} +}; diff --git a/packages/babel-preset-medusa-package/CHANGELOG.md b/packages/babel-preset-medusa-package/CHANGELOG.md index e107c5bd56..dbe30dd940 100644 --- a/packages/babel-preset-medusa-package/CHANGELOG.md +++ b/packages/babel-preset-medusa-package/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.8](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.7...babel-preset-medusa-package@1.1.8) (2021-06-09) + +**Note:** Version bump only for package babel-preset-medusa-package + + + + + +## [1.1.7](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.6...babel-preset-medusa-package@1.1.7) (2021-06-09) + +**Note:** Version bump only for package babel-preset-medusa-package + + + + + +## [1.1.6](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.5...babel-preset-medusa-package@1.1.6) (2021-06-09) + +**Note:** Version bump only for package babel-preset-medusa-package + + + + + +## [1.1.5](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.4...babel-preset-medusa-package@1.1.5) (2021-06-09) + +**Note:** Version bump only for package babel-preset-medusa-package + + + + + ## [1.1.4](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.3...babel-preset-medusa-package@1.1.4) (2021-06-08) diff --git a/packages/babel-preset-medusa-package/package.json b/packages/babel-preset-medusa-package/package.json index f36301b102..2b5c0ae92f 100644 --- a/packages/babel-preset-medusa-package/package.json +++ b/packages/babel-preset-medusa-package/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-medusa-package", - "version": "1.1.4", + "version": "1.1.8", "author": "Sebastian Rindom ", "repository": { "type": "git", diff --git a/packages/medusa-cli/CHANGELOG.md b/packages/medusa-cli/CHANGELOG.md index 72f7e3394f..3256e9b141 100644 --- a/packages/medusa-cli/CHANGELOG.md +++ b/packages/medusa-cli/CHANGELOG.md @@ -3,6 +3,74 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.9](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.8...@medusajs/medusa-cli@1.1.9) (2021-06-09) + + +### Bug Fixes + +* better cli ([953747f](https://github.com/medusajs/medusa/commit/953747f3d2409cef82faf926ad316a384e6667b4)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) + + + + + +## [1.1.8](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.8...@medusajs/medusa-cli@1.1.8) (2021-06-09) + + +### Bug Fixes + +* better cli ([953747f](https://github.com/medusajs/medusa/commit/953747f3d2409cef82faf926ad316a384e6667b4)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) + + + + + +## [1.1.7](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.8...@medusajs/medusa-cli@1.1.7) (2021-06-09) + + +### Bug Fixes + +* better cli ([953747f](https://github.com/medusajs/medusa/commit/953747f3d2409cef82faf926ad316a384e6667b4)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) + + + + + +## [1.1.6](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.8...@medusajs/medusa-cli@1.1.6) (2021-06-09) + + +### Bug Fixes + +* better cli ([953747f](https://github.com/medusajs/medusa/commit/953747f3d2409cef82faf926ad316a384e6667b4)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) + + + + + ## [1.1.5](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.8...@medusajs/medusa-cli@1.1.5) (2021-06-08) diff --git a/packages/medusa-cli/package.json b/packages/medusa-cli/package.json index 676e45061e..bc9afb2a08 100644 --- a/packages/medusa-cli/package.json +++ b/packages/medusa-cli/package.json @@ -1,6 +1,6 @@ { "name": "@medusajs/medusa-cli", - "version": "1.1.5", + "version": "1.1.9", "description": "Command Line interface for Medusa Commerce", "main": "dist/index.js", "bin": { diff --git a/packages/medusa-core-utils/CHANGELOG.md b/packages/medusa-core-utils/CHANGELOG.md index 7ad44968df..f26f0bfbec 100644 --- a/packages/medusa-core-utils/CHANGELOG.md +++ b/packages/medusa-core-utils/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.13...medusa-core-utils@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-core-utils + + + + + +## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.12...medusa-core-utils@1.1.13) (2021-06-09) + +**Note:** Version bump only for package medusa-core-utils + + + + + +## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.11...medusa-core-utils@1.1.12) (2021-06-09) + +**Note:** Version bump only for package medusa-core-utils + + + + + +## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.10...medusa-core-utils@1.1.11) (2021-06-09) + +**Note:** Version bump only for package medusa-core-utils + + + + + ## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.9...medusa-core-utils@1.1.10) (2021-06-08) **Note:** Version bump only for package medusa-core-utils diff --git a/packages/medusa-core-utils/package.json b/packages/medusa-core-utils/package.json index 9a66966120..6c1b410c9f 100644 --- a/packages/medusa-core-utils/package.json +++ b/packages/medusa-core-utils/package.json @@ -1,6 +1,6 @@ { "name": "medusa-core-utils", - "version": "1.1.10", + "version": "1.1.14", "description": "Core utils for Medusa", "main": "dist/index.js", "repository": { diff --git a/packages/medusa-core-utils/src/__tests__/transform-idable-fields.js b/packages/medusa-core-utils/src/__tests__/transform-idable-fields.js new file mode 100644 index 0000000000..c8f8113cf5 --- /dev/null +++ b/packages/medusa-core-utils/src/__tests__/transform-idable-fields.js @@ -0,0 +1,105 @@ +import { transformIdableFields } from "../transform-idable-fields" + +describe("transformIdableFields", () => { + test("one field", () => { + const test = { + shipping_address: "test_id", + } + + const result = transformIdableFields(test, ["shipping_address"]) + + expect(test).toEqual(test) + + expect(result).toEqual({ + shipping_address_id: "test_id", + }) + }) + + test("duplicate field", () => { + const test = { + shipping_address: "test_id", + shipping_address_id: "something else", + } + + const result = transformIdableFields(test, ["shipping_address"]) + + expect(test).toEqual(test) + + expect(result).toEqual({ + shipping_address_id: "test_id", + }) + }) + + test("many fields", () => { + const test = { + shipping_address: "test_id", + customer: "cus_test", + region: "reg_test", + something: "else", + } + + const result = transformIdableFields(test, [ + "shipping_address", + "customer", + "region", + ]) + + expect(test).toEqual(test) + + expect(result).toEqual({ + shipping_address_id: "test_id", + customer_id: "cus_test", + region_id: "reg_test", + something: "else", + }) + }) + + test("mix fields", () => { + const test = { + shipping_address: { + address_1: "my home", + }, + customer: "cus_test", + region: "reg_test", + something: "else", + } + + const result = transformIdableFields(test, [ + "shipping_address", + "customer", + "region", + ]) + + expect(test).toEqual(test) + + expect(result).toEqual({ + shipping_address: { + address_1: "my home", + }, + customer_id: "cus_test", + region_id: "reg_test", + something: "else", + }) + }) + + test("no fields", () => { + const test = { + something: "else", + and: "more", + maybe: "one more", + } + + const result = transformIdableFields(test, [ + "shipping_address", + "customer", + "region", + ]) + + expect(test).toEqual(test) + expect(result).toEqual({ + something: "else", + and: "more", + maybe: "one more", + }) + }) +}) diff --git a/packages/medusa-core-utils/src/index.js b/packages/medusa-core-utils/src/index.js index d30a469a72..c12fd278ef 100644 --- a/packages/medusa-core-utils/src/index.js +++ b/packages/medusa-core-utils/src/index.js @@ -1,5 +1,6 @@ export { countries } from "./countries" export { isoCountryLookup } from "./countries" +export { transformIdableFields } from "./transform-idable-fields" export { default as Validator } from "./validator" export { default as MedusaError } from "./errors" export { default as getConfigFile } from "./get-config-file" diff --git a/packages/medusa-core-utils/src/transform-idable-fields.js b/packages/medusa-core-utils/src/transform-idable-fields.js new file mode 100644 index 0000000000..eabfaeace5 --- /dev/null +++ b/packages/medusa-core-utils/src/transform-idable-fields.js @@ -0,0 +1,22 @@ +/** + * Takes an object and a list of fields to tranform in that object. If the field + * exists on the object and its value is a string it will append `_id` to the + * field name. This is used when allowing API calls to hold either ID or object + * values in the payload. The method returns a new object with the + * transformation. + * @param {Object} obj - the object to transform + * @param {Array} fields - the fields to apply transformation to + * @returns {Object} the transformed object + */ +export const transformIdableFields = (obj, fields) => { + const ret = { ...obj } + + for (const key of fields) { + if (key in obj && typeof ret[key] === "string") { + ret[`${key}_id`] = ret[key] + delete ret[key] + } + } + + return ret +} diff --git a/packages/medusa-dev-cli/CHANGELOG.md b/packages/medusa-dev-cli/CHANGELOG.md index c7e0f4df09..64e8464f5f 100644 --- a/packages/medusa-dev-cli/CHANGELOG.md +++ b/packages/medusa-dev-cli/CHANGELOG.md @@ -3,6 +3,38 @@ 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-dev-cli@0.0.12...medusa-dev-cli@0.0.13) (2021-06-09) + +**Note:** Version bump only for package medusa-dev-cli + + + + + +## [0.0.12](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.11...medusa-dev-cli@0.0.12) (2021-06-09) + +**Note:** Version bump only for package medusa-dev-cli + + + + + +## [0.0.11](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.10...medusa-dev-cli@0.0.11) (2021-06-09) + +**Note:** Version bump only for package medusa-dev-cli + + + + + +## [0.0.10](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.9...medusa-dev-cli@0.0.10) (2021-06-09) + +**Note:** Version bump only for package medusa-dev-cli + + + + + ## [0.0.9](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.8...medusa-dev-cli@0.0.9) (2021-06-08) diff --git a/packages/medusa-dev-cli/package.json b/packages/medusa-dev-cli/package.json index 007d5f1fd9..aa0bc061b1 100644 --- a/packages/medusa-dev-cli/package.json +++ b/packages/medusa-dev-cli/package.json @@ -1,7 +1,7 @@ { "name": "medusa-dev-cli", "description": "CLI helpers for contributors working on Medusa", - "version": "0.0.9", + "version": "0.0.13", "author": "Sebastian Rindom ", "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.4", + "babel-preset-medusa-package": "^1.1.8", "cross-env": "^7.0.3" }, "homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme", diff --git a/packages/medusa-file-spaces/CHANGELOG.md b/packages/medusa-file-spaces/CHANGELOG.md index ab8eb589ff..1260d136b4 100644 --- a/packages/medusa-file-spaces/CHANGELOG.md +++ b/packages/medusa-file-spaces/CHANGELOG.md @@ -3,6 +3,38 @@ 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-file-spaces@1.1.16...medusa-file-spaces@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-file-spaces + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.15...medusa-file-spaces@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-file-spaces + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.14...medusa-file-spaces@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-file-spaces + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.13...medusa-file-spaces@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-file-spaces + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.12...medusa-file-spaces@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-file-spaces diff --git a/packages/medusa-file-spaces/package.json b/packages/medusa-file-spaces/package.json index dacca54d59..848758b47d 100644 --- a/packages/medusa-file-spaces/package.json +++ b/packages/medusa-file-spaces/package.json @@ -1,6 +1,6 @@ { "name": "medusa-file-spaces", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "stripe": "^8.50.0" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-fulfillment-manual/CHANGELOG.md b/packages/medusa-fulfillment-manual/CHANGELOG.md index 810ec158c7..b2fded00ee 100644 --- a/packages/medusa-fulfillment-manual/CHANGELOG.md +++ b/packages/medusa-fulfillment-manual/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-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 diff --git a/packages/medusa-fulfillment-manual/package.json b/packages/medusa-fulfillment-manual/package.json index 570b7a71b3..b3e64b0294 100644 --- a/packages/medusa-fulfillment-manual/package.json +++ b/packages/medusa-fulfillment-manual/package.json @@ -1,6 +1,6 @@ { "name": "medusa-fulfillment-manual", - "version": "1.1.10", + "version": "1.1.14", "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.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js index 389dca5127..a03d5499e7 100644 --- a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js +++ b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js @@ -12,6 +12,10 @@ class ManualFulfillmentService extends FulfillmentService { { id: "manual-fulfillment", }, + { + id: "manual-fulfillment-return", + is_return: true, + }, ] } @@ -36,6 +40,11 @@ class ManualFulfillmentService extends FulfillmentService { return Promise.resolve({}) } + createReturn() { + // No data is being sent anywhere + return Promise.resolve({}) + } + createFulfillment() { // No data is being sent anywhere return Promise.resolve({}) diff --git a/packages/medusa-fulfillment-webshipper/CHANGELOG.md b/packages/medusa-fulfillment-webshipper/CHANGELOG.md index cc3094aa67..9d36930538 100644 --- a/packages/medusa-fulfillment-webshipper/CHANGELOG.md +++ b/packages/medusa-fulfillment-webshipper/CHANGELOG.md @@ -3,6 +3,38 @@ 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-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 diff --git a/packages/medusa-fulfillment-webshipper/package.json b/packages/medusa-fulfillment-webshipper/package.json index dd7b3ed2dd..0f3c6f0c3b 100644 --- a/packages/medusa-fulfillment-webshipper/package.json +++ b/packages/medusa-fulfillment-webshipper/package.json @@ -1,6 +1,6 @@ { "name": "medusa-fulfillment-webshipper", - "version": "1.1.14", + "version": "1.1.18", "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.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-interfaces/CHANGELOG.md b/packages/medusa-interfaces/CHANGELOG.md index ac1eaeffe3..ba8c268074 100644 --- a/packages/medusa-interfaces/CHANGELOG.md +++ b/packages/medusa-interfaces/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.14...medusa-interfaces@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-interfaces + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.13...medusa-interfaces@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-interfaces + + + + + +## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.12...medusa-interfaces@1.1.13) (2021-06-09) + +**Note:** Version bump only for package medusa-interfaces + + + + + +## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.11...medusa-interfaces@1.1.12) (2021-06-09) + +**Note:** Version bump only for package medusa-interfaces + + + + + ## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.10...medusa-interfaces@1.1.11) (2021-06-08) **Note:** Version bump only for package medusa-interfaces diff --git a/packages/medusa-interfaces/package.json b/packages/medusa-interfaces/package.json index 52f5ed27c4..273529fb9f 100644 --- a/packages/medusa-interfaces/package.json +++ b/packages/medusa-interfaces/package.json @@ -1,6 +1,6 @@ { "name": "medusa-interfaces", - "version": "1.1.11", + "version": "1.1.15", "description": "Core interfaces for Medusa", "main": "dist/index.js", "repository": { @@ -35,7 +35,7 @@ "typeorm": "0.x" }, "dependencies": { - "medusa-core-utils": "^1.1.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-payment-adyen/CHANGELOG.md b/packages/medusa-payment-adyen/CHANGELOG.md index b3d2397301..d468e7b1bf 100644 --- a/packages/medusa-payment-adyen/CHANGELOG.md +++ b/packages/medusa-payment-adyen/CHANGELOG.md @@ -3,6 +3,38 @@ 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-payment-adyen@1.1.16...medusa-payment-adyen@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-adyen + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.15...medusa-payment-adyen@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-adyen + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.14...medusa-payment-adyen@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-adyen + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.13...medusa-payment-adyen@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-adyen + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.12...medusa-payment-adyen@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-payment-adyen diff --git a/packages/medusa-payment-adyen/package.json b/packages/medusa-payment-adyen/package.json index 2f12fe175b..5fb8637b79 100644 --- a/packages/medusa-payment-adyen/package.json +++ b/packages/medusa-payment-adyen/package.json @@ -1,6 +1,6 @@ { "name": "medusa-payment-adyen", - "version": "1.1.13", + "version": "1.1.17", "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.13" + "medusa-test-utils": "^1.1.17" }, "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.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-payment-adyen/src/api/routes/store/index.js b/packages/medusa-payment-adyen/src/api/routes/store/index.js deleted file mode 100644 index 4dbb57ba25..0000000000 --- a/packages/medusa-payment-adyen/src/api/routes/store/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import { Router } from "express" -import cors from "cors" -import bodyParser from "body-parser" -import middlewares from "../../middlewares" -import { getConfigFile } from "medusa-core-utils" - -const route = Router() - -export default (app, rootDirectory) => { - const { configModule } = getConfigFile(rootDirectory, `medusa-config`) - const config = (configModule && configModule.projectConfig) || {} - - const storeCors = config.store_cors || "" - route.use( - cors({ - origin: storeCors.split(","), - credentials: true, - }) - ) - - app.use("/adyen", route) - - route.post( - "/payment-methods", - bodyParser.json(), - middlewares.wrap(require("./retrieve-payment-methods").default) - ) - - return app -} diff --git a/packages/medusa-payment-adyen/src/api/routes/store/retrieve-payment-methods.js b/packages/medusa-payment-adyen/src/api/routes/store/retrieve-payment-methods.js deleted file mode 100644 index 8887f2b8e0..0000000000 --- a/packages/medusa-payment-adyen/src/api/routes/store/retrieve-payment-methods.js +++ /dev/null @@ -1,57 +0,0 @@ -import { Validator, MedusaError } from "medusa-core-utils" - -export default async (req, res) => { - const schema = Validator.object().keys({ - cart_id: Validator.string().required(), - }) - - const { value, error } = schema.validate(req.body) - if (error) { - throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) - } - - try { - const adyenService = req.scope.resolve("adyenService") - const cartService = req.scope.resolve("cartService") - - const cart = await cartService.retrieve(value.cart_id, { - select: ["total"], - relations: ["region", "region.payment_providers", "payment_sessions"], - }) - - const allowedMethods = cart.payment_sessions.map((ps) => { - if (ps.provider_id.includes("adyen")) { - return ps.provider_id.split("-adyen")[0] - } - }) - - if (allowedMethods.length === 0) { - res.status(200).json({ paymentMethods: {} }) - return - } - - const pmMethods = await adyenService.retrievePaymentMethods( - allowedMethods, - cart.total, - cart.currency_code, - cart.customer_id || "" - ) - - // Adyen does not behave 100% correctly in regards to allowed methods - // Therefore, we sanity filter before sending them to the storefront - const { paymentMethods, groups, storedPaymentMethods } = pmMethods - const methods = paymentMethods.filter((pm) => - allowedMethods.includes(pm.type) - ) - - const response = { - paymentMethods: methods, - groups, - storedPaymentMethods, - } - - res.status(200).json({ payment_methods: response }) - } catch (err) { - throw err - } -} diff --git a/packages/medusa-payment-adyen/src/services/adyen.js b/packages/medusa-payment-adyen/src/services/adyen.js index 4310536964..1eed6bb0c9 100644 --- a/packages/medusa-payment-adyen/src/services/adyen.js +++ b/packages/medusa-payment-adyen/src/services/adyen.js @@ -28,7 +28,7 @@ class AdyenService extends BaseService { /** @private @constant {AxiosClient} */ this.adyenClient_ = this.initAdyenClient() - /** @private @constant {AdyenClient} */ + /** @private @constant {AxiosClient} */ this.adyenPaymentApi = this.initPaymentClient() } @@ -51,16 +51,6 @@ class AdyenService extends BaseService { return this.options_ } - initPaymentClient() { - return axios.create({ - baseURL: this.options_.payment_endpoint, - headers: { - "Content-Type": "application/json", - "x-API-key": this.options_.api_key, - }, - }) - } - initAdyenClient() { const config = new Config() config.apiKey = this.options_.api_key @@ -70,14 +60,22 @@ class AdyenService extends BaseService { config, }) - client.setEnvironment( - this.options_.environment, - this.options_.live_endpoint_prefix - ) + client.setEnvironment(this.options_.environment) return client } + initPaymentClient() { + return axios.create({ + baseURL: + this.options_.payment_endpoint || "https://checkout-test.adyen.com/v67", + headers: { + "Content-Type": "application/json", + "x-API-key": this.options_.api_key, + }, + }) + } + /** * Validates an Adyen webhook notification * @param {object} notification - notification to validate @@ -90,6 +88,7 @@ class AdyenService extends BaseService { notification, this.options_.notification_hmac ) + return validated } @@ -228,6 +227,10 @@ class AdyenService extends BaseService { const status = this.getStatus(sessionData) + if (sessionData.resultCode === "RedirectShopper") { + return { data: sessionData, status: "requires_more" } + } + // If session data is present, we already called authorize once. // Therefore, this is most likely a call for getting additional details if (status === "requires_more") { @@ -253,38 +256,28 @@ class AdyenService extends BaseService { value: cart.total, } + let paymentData = sessionData.paymentData + if (!paymentData) { + paymentData = { + paymentMethod: { + type: sessionData.type, + }, + } + } + let request = { amount, + merchantAccount: this.options_.merchant_account, shopperIP: context.ip_address || "", shopperReference: cart.customer_id, - paymentMethod: sessionData.paymentData.paymentMethod, - reference: cart.id, - merchantAccount: this.options_.merchant_account, returnUrl: this.options_.return_url, - origin: this.options_.origin, - channel: "Web", - redirectFromIssuerMethod: "GET", - browserInfo: sessionData.browserInfo || {}, - billingAddress: { - city: cart.shipping_address.city, - country: cart.shipping_address.country_code, - houseNumberOrName: cart.shipping_address.address_2 || "", - postalCode: cart.shipping_address.postal_code, - stateOrProvice: cart.shipping_address.province || "", - street: cart.shipping_address.address_1, - }, + paymentMethod: paymentData.paymentMethod, + reference: cart.id, metadata: { cart_id: cart.id, }, } - // If customer chose to save the payment method - if (sessionData.storePaymentMethod) { - request.storePaymentMethod = "true" - request.shopperInteraction = "Ecommerce" - request.recurringProcessingModel = "CardOnFile" - } - const checkout = new CheckoutAPI(this.adyenClient_) try { @@ -344,31 +337,34 @@ class AdyenService extends BaseService { * @returns {string} status = processing_captures */ async capturePayment(payment) { + if (payment.captured_at !== null) { + return + } + const { pspReference, merchantReference } = payment.data const { amount, currency_code } = payment try { - const captured = await this.adyenPaymentApi.post("/capture", { - originalReference: pspReference, - modificationAmount: { - value: amount, - currency: currency_code.toUpperCase(), - }, - merchantAccount: this.options_.merchant_account, - reference: merchantReference, - }) + const captured = await this.adyenPaymentApi.post( + `/payments/${pspReference}/captures`, + { + merchantAccount: this.options_.merchant_account, + amount: { + value: amount, + currency: currency_code.toUpperCase(), + }, + reference: merchantReference, + } + ) - if ( - captured.data.pspReference && - captured.data.response !== "[capture-received]" - ) { + if (captured.data.pspReference && captured.data.status !== "received") { throw new MedusaError( MedusaError.Types.INVALID_ARGUMENT, "Could not process capture" ) } - return { originalReference: pspReference, ...captured.data } + return { pspReference } } catch (error) { throw error } @@ -381,7 +377,7 @@ class AdyenService extends BaseService { * @returns {object} payment data result of refund */ async refundPayment(payment, amountToRefund) { - const { originalReference, merchantReference } = payment.data + const { pspReference } = payment.data const { currency_code } = payment const refundAmount = { @@ -390,14 +386,12 @@ class AdyenService extends BaseService { } try { - const refunded = await this.adyenPaymentApi.post("/refund", { - originalReference, + await this.adyenPaymentApi.post(`/payments/${pspReference}/refunds`, { merchantAccount: this.options_.merchant_account, - modificationAmount: refundAmount, - reference: merchantReference, + amount: refundAmount, }) - return { originalReference, ...refunded.data } + return { pspReference } } catch (error) { throw error } diff --git a/packages/medusa-payment-adyen/src/services/applepay-adyen.js b/packages/medusa-payment-adyen/src/services/applepay-adyen.js deleted file mode 100644 index d93ea5992e..0000000000 --- a/packages/medusa-payment-adyen/src/services/applepay-adyen.js +++ /dev/null @@ -1,104 +0,0 @@ -import _ from "lodash" -import https from "https" -import fs from "fs" -import axios from "axios" -import { PaymentService } from "medusa-interfaces" - -class ApplePayAdyenService extends PaymentService { - static identifier = "applepay-adyen" - - constructor({ adyenService }, options) { - super() - - this.adyenService_ = adyenService - - this.options_ = options - } - - /** - * Status for Adyen payment. - * @param {Object} paymentData - payment method data from cart - * @returns {string} the status of the payment - */ - async getStatus(paymentData) { - const { resultCode } = paymentData - let status = "initial" - - if (resultCode === "Authorised") { - status = "authorized" - } - - return status - } - - async createPayment(_) { - return {} - } - - async getApplePaySession(validationUrl) { - let certificate - try { - // Place certificate in root folder - certificate = fs.readFileSync("./apple-pay-cert.pem") - } catch (error) { - throw new Error( - "Could not find ApplePay certificate. Make sure to place it in root folder of your server" - ) - } - - const httpsAgent = new https.Agent({ - cert: certificate, - key: certificate, - rejectUnauthorized: false, - }) - - const request = { - merchantIdentifier: this.options_.applepay_merchant_id, - displayName: this.options_.applepay_display_name, - initiative: "web", - initiativeContext: this.options_.applepay_initiative_context, - } - - return axios.post(validationUrl, request, { - httpsAgent, - }) - } - - async authorizePayment(sessionData, context) { - return this.adyenService_.authorizePayment(sessionData, context) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async retrievePayment(data) { - return this.adyenService_.retrievePayment(data) - } - - async updatePaymentData(sessionData, update) { - return this.adyenService_.updatePaymentData(sessionData, update) - } - - async updatePayment(data, _) { - return this.adyenService_.updatePayment(data) - } - - async deletePayment(data) { - return this.adyenService_.deletePayment(data) - } - - async capturePayment(data) { - return this.adyenService_.capturePayment(data) - } - - async refundPayment(data, amountToRefund) { - return this.adyenService_.refundPayment(data, amountToRefund) - } - - async cancelPayment(data) { - return this.adyenService_.cancelPayment(data) - } -} - -export default ApplePayAdyenService diff --git a/packages/medusa-payment-adyen/src/services/card-adyen.js b/packages/medusa-payment-adyen/src/services/card-adyen.js deleted file mode 100644 index bc6028dda9..0000000000 --- a/packages/medusa-payment-adyen/src/services/card-adyen.js +++ /dev/null @@ -1,62 +0,0 @@ -import _ from "lodash" -import { PaymentService } from "medusa-interfaces" - -class CardAdyenService extends PaymentService { - static identifier = "scheme-adyen" - - constructor({ adyenService }) { - super() - - this.adyenService_ = adyenService - } - - async retrieveSavedMethods(customer) { - return this.adyenService_.retrieveSavedMethods(customer) - } - - async getStatus(paymentData) { - return this.adyenService_.getStatus(paymentData) - } - - async createPayment(data) { - return this.adyenService_.createPayment(data) - } - - async authorizePayment(sessionData, context) { - return this.adyenService_.authorizePayment(sessionData, context) - } - - async retrievePayment(data) { - return this.adyenService_.retrievePayment(data) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async updatePayment(data, _) { - return this.adyenService_.updatePayment(data) - } - - async updatePaymentData(sessionData, update) { - return this.adyenService_.updatePaymentData(sessionData, update) - } - - async deletePayment(data) { - return this.adyenService_.deletePayment(data) - } - - async capturePayment(data) { - return this.adyenService_.capturePayment(data) - } - - async refundPayment(data, amountToRefund) { - return this.adyenService_.refundPayment(data, amountToRefund) - } - - async cancelPayment(data) { - return this.adyenService_.cancelPayment(data) - } -} - -export default CardAdyenService diff --git a/packages/medusa-payment-adyen/src/services/googlepay-adyen.js b/packages/medusa-payment-adyen/src/services/googlepay-adyen.js deleted file mode 100644 index 2a24847d88..0000000000 --- a/packages/medusa-payment-adyen/src/services/googlepay-adyen.js +++ /dev/null @@ -1,58 +0,0 @@ -import _ from "lodash" -import { PaymentService } from "medusa-interfaces" - -class GooglePayAdyenService extends PaymentService { - static identifier = "paywithgoogle-adyen" - - constructor({ adyenService }) { - super() - - this.adyenService_ = adyenService - } - - async getStatus(paymentData) { - return this.adyenService_.getStatus(paymentData) - } - - async createPayment(data) { - return this.adyenService_.createPayment(data) - } - - async authorizePayment(sessionData, context) { - return this.adyenService_.authorizePayment(sessionData, context) - } - - async retrievePayment(data) { - return this.adyenService_.retrievePayment(data) - } - - async updatePayment(data, _) { - return this.adyenService_.updatePayment(data) - } - - async updatePaymentData(sessionData, update) { - return this.adyenService_.updatePaymentData(sessionData, update) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async deletePayment(data) { - return this.adyenService_.deletePayment(data) - } - - async capturePayment(data) { - return this.adyenService_.capturePayment(data) - } - - async refundPayment(data, amountToRefund) { - return this.adyenService_.refundPayment(data, amountToRefund) - } - - async cancelPayment(data) { - return this.adyenService_.cancelPayment(data) - } -} - -export default GooglePayAdyenService diff --git a/packages/medusa-payment-adyen/src/services/ideal-adyen.js b/packages/medusa-payment-adyen/src/services/ideal-adyen.js deleted file mode 100644 index c51c714d0b..0000000000 --- a/packages/medusa-payment-adyen/src/services/ideal-adyen.js +++ /dev/null @@ -1,62 +0,0 @@ -import _ from "lodash" -import { PaymentService } from "medusa-interfaces" - -class IdealAdyenService extends PaymentService { - static identifier = "ideal-adyen" - - constructor({ adyenService }) { - super() - - this.adyenService_ = adyenService - } - - async getStatus(paymentData) { - return this.adyenService_.getStatus(paymentData) - } - - async createPayment(data) { - return this.adyenService_.createPayment(data) - } - - async authorizePayment(sessionData, context) { - return this.adyenService_.authorizePayment(sessionData, context) - } - - async retrievePayment(data) { - return this.adyenService_.retrievePayment(data) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async updatePayment(data, _) { - return this.adyenService_.updatePayment(data) - } - - async updatePaymentData(sessionData, update) { - return this.adyenService_.updatePaymentData(sessionData, update) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async deletePayment(data) { - return this.adyenService_.deletePayment(data) - } - - async capturePayment(data) { - return this.adyenService_.capturePayment(data) - } - - async refundPayment(data, amountToRefund) { - return this.adyenService_.refundPayment(data, amountToRefund) - } - - async cancelPayment(data) { - return this.adyenService_.cancelPayment(data) - } -} - -export default IdealAdyenService diff --git a/packages/medusa-payment-adyen/src/services/mobilepay-adyen.js b/packages/medusa-payment-adyen/src/services/mobilepay-adyen.js index 9df408e14d..3cf851cd51 100644 --- a/packages/medusa-payment-adyen/src/services/mobilepay-adyen.js +++ b/packages/medusa-payment-adyen/src/services/mobilepay-adyen.js @@ -15,7 +15,9 @@ class MobilePayAdyenService extends PaymentService { } async createPayment(data) { - return this.adyenService_.createPayment(data) + const raw = await this.adyenService_.createPayment(data) + raw.type = "mobilepay" + return raw } async authorizePayment(sessionData, context) { diff --git a/packages/medusa-payment-adyen/src/services/paypal-adyen.js b/packages/medusa-payment-adyen/src/services/paypal-adyen.js deleted file mode 100644 index e7aefa023f..0000000000 --- a/packages/medusa-payment-adyen/src/services/paypal-adyen.js +++ /dev/null @@ -1,58 +0,0 @@ -import _ from "lodash" -import { PaymentService } from "medusa-interfaces" - -class PayPalAdyenService extends PaymentService { - static identifier = "paypal-adyen" - - constructor({ adyenService }) { - super() - - this.adyenService_ = adyenService - } - - async getStatus(paymentData) { - return this.adyenService_.getStatus(paymentData) - } - - async createPayment(data) { - return this.adyenService_.createPayment(data) - } - - async authorizePayment(sessionData, context) { - return this.adyenService_.authorizePayment(sessionData, context) - } - - async retrievePayment(data) { - return this.adyenService_.retrievePayment(data) - } - - async getPaymentData(data) { - return this.adyenService_.getPaymentData(data) - } - - async updatePayment(data, _) { - return this.adyenService_.updatePayment(data) - } - - async updatePaymentData(sessionData, update) { - return this.adyenService_.updatePaymentData(sessionData, update) - } - - async deletePayment(data) { - return this.adyenService_.deletePayment(data) - } - - async capturePayment(data) { - return this.adyenService_.capturePayment(data) - } - - async refundPayment(data, amountToRefund) { - return this.adyenService_.refundPayment(data, amountToRefund) - } - - async cancelPayment(data) { - return this.adyenService_.cancelPayment(data) - } -} - -export default PayPalAdyenService diff --git a/packages/medusa-payment-adyen/src/subscribers/adyen.js b/packages/medusa-payment-adyen/src/subscribers/adyen.js index 2c140d518e..66ef276ca9 100644 --- a/packages/medusa-payment-adyen/src/subscribers/adyen.js +++ b/packages/medusa-payment-adyen/src/subscribers/adyen.js @@ -105,7 +105,6 @@ class AdyenSubscriber { await this.paymentRepository_.save(updatedPayment) } catch (error) { - console.log(error) await this.manager_.transaction(async (manager) => { const session = { pspReference: notification.pspReference, diff --git a/packages/medusa-payment-klarna/CHANGELOG.md b/packages/medusa-payment-klarna/CHANGELOG.md index 1a9fb10967..ab1a439df6 100644 --- a/packages/medusa-payment-klarna/CHANGELOG.md +++ b/packages/medusa-payment-klarna/CHANGELOG.md @@ -3,6 +3,38 @@ 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-payment-klarna@1.1.17...medusa-payment-klarna@1.1.18) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-klarna + + + + + +## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.16...medusa-payment-klarna@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-klarna + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.15...medusa-payment-klarna@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-klarna + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.14...medusa-payment-klarna@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-klarna + + + + + ## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.13...medusa-payment-klarna@1.1.14) (2021-06-08) **Note:** Version bump only for package medusa-payment-klarna diff --git a/packages/medusa-payment-klarna/package.json b/packages/medusa-payment-klarna/package.json index bec7873d5f..cc342b5101 100644 --- a/packages/medusa-payment-klarna/package.json +++ b/packages/medusa-payment-klarna/package.json @@ -1,6 +1,6 @@ { "name": "medusa-payment-klarna", - "version": "1.1.14", + "version": "1.1.18", "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.10", - "medusa-test-utils": "^1.1.13" + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-payment-klarna/src/api/routes/hooks/address.js b/packages/medusa-payment-klarna/src/api/routes/hooks/address.js index f00cd85c75..dc61a4f3c0 100644 --- a/packages/medusa-payment-klarna/src/api/routes/hooks/address.js +++ b/packages/medusa-payment-klarna/src/api/routes/hooks/address.js @@ -25,7 +25,6 @@ export default async (req, res) => { if (shipping_address) { const shippingAddress = { - ...cart.shipping_address, first_name: shipping_address.given_name, last_name: shipping_address.family_name, address_1: shipping_address.street_address, @@ -47,13 +46,6 @@ export default async (req, res) => { phone: shipping_address.phone, } - if (cart.billing_address) { - billingAddress = { - ...billingAddress, - ...cart.billing_address, - } - } - await cartService.update(cart.id, { shipping_address: shippingAddress, billing_address: billingAddress, diff --git a/packages/medusa-payment-paypal/CHANGELOG.md b/packages/medusa-payment-paypal/CHANGELOG.md index a6da119ab5..c66ffe8368 100644 --- a/packages/medusa-payment-paypal/CHANGELOG.md +++ b/packages/medusa-payment-paypal/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.18](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.17...medusa-payment-paypal@1.0.18) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-paypal + + + + + +## [1.0.17](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.16...medusa-payment-paypal@1.0.17) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-paypal + + + + + +## [1.0.16](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.15...medusa-payment-paypal@1.0.16) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-paypal + + + + + +## [1.0.15](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.14...medusa-payment-paypal@1.0.15) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-paypal + + + + + ## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.13...medusa-payment-paypal@1.0.14) (2021-06-08) **Note:** Version bump only for package medusa-payment-paypal diff --git a/packages/medusa-payment-paypal/package.json b/packages/medusa-payment-paypal/package.json index bef631975b..d61aa19646 100644 --- a/packages/medusa-payment-paypal/package.json +++ b/packages/medusa-payment-paypal/package.json @@ -1,6 +1,6 @@ { "name": "medusa-payment-paypal", - "version": "1.0.14", + "version": "1.0.18", "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.11", - "medusa-test-utils": "^1.1.13" + "medusa-interfaces": "^1.1.15", + "medusa-test-utils": "^1.1.17" }, "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.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-payment-stripe/CHANGELOG.md b/packages/medusa-payment-stripe/CHANGELOG.md index 953f127e9a..8f6cdc1947 100644 --- a/packages/medusa-payment-stripe/CHANGELOG.md +++ b/packages/medusa-payment-stripe/CHANGELOG.md @@ -3,6 +3,38 @@ 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-payment-stripe@1.1.16...medusa-payment-stripe@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-stripe + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.15...medusa-payment-stripe@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-stripe + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.14...medusa-payment-stripe@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-stripe + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.13...medusa-payment-stripe@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-payment-stripe + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.12...medusa-payment-stripe@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-payment-stripe diff --git a/packages/medusa-payment-stripe/package.json b/packages/medusa-payment-stripe/package.json index 11b4acd264..8e39688cca 100644 --- a/packages/medusa-payment-stripe/package.json +++ b/packages/medusa-payment-stripe/package.json @@ -1,6 +1,6 @@ { "name": "medusa-payment-stripe", - "version": "1.1.13", + "version": "1.1.17", "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.13" + "medusa-test-utils": "^1.1.17" }, "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.10", + "medusa-core-utils": "^1.1.14", "stripe": "^8.50.0" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js b/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js index 2c1c1771b6..65538328ae 100644 --- a/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js +++ b/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js @@ -23,10 +23,8 @@ export default async (req, res) => { // handle payment intent events switch (event.type) { case "payment_intent.succeeded": - if (order) { - await orderService.update(order.id, { - payment_status: "captured", - }) + if (order && order.payment_status !== "captured") { + await orderService.capturePayment(order.id) } break //case "payment_intent.canceled": @@ -41,8 +39,9 @@ export default async (req, res) => { break case "payment_intent.amount_capturable_updated": if (!order) { - const cart = await cartService.retrieve(cartId) - await orderService.createFromCart(cart) + await cartService.setPaymentSession(cartId, "stripe") + await cartService.authorizePayment(cartId) + await orderService.createFromCart(cartId) } break default: diff --git a/packages/medusa-payment-stripe/src/services/stripe-giropay.js b/packages/medusa-payment-stripe/src/services/stripe-giropay.js new file mode 100644 index 0000000000..9df35469df --- /dev/null +++ b/packages/medusa-payment-stripe/src/services/stripe-giropay.js @@ -0,0 +1,241 @@ +import _ from "lodash" +import Stripe from "stripe" +import { PaymentService } from "medusa-interfaces" + +class GiropayProviderService extends PaymentService { + static identifier = "stripe-giropay" + + constructor( + { stripeProviderService, customerService, totalsService, regionService }, + options + ) { + super() + + /** + * Required Stripe options: + * { + * api_key: "stripe_secret_key", REQUIRED + * webhook_secret: "stripe_webhook_secret", REQUIRED + * // Use this flag to capture payment immediately (default is false) + * capture: true + * } + */ + this.options_ = options + + /** @private @const {Stripe} */ + this.stripe_ = Stripe(options.api_key) + + /** @private @const {CustomerService} */ + this.stripeProviderService_ = stripeProviderService + + /** @private @const {CustomerService} */ + this.customerService_ = customerService + + /** @private @const {RegionService} */ + this.regionService_ = regionService + + /** @private @const {TotalsService} */ + this.totalsService_ = totalsService + } + + /** + * Fetches Stripe payment intent. Check its status and returns the + * corresponding Medusa status. + * @param {object} paymentData - payment method data from cart + * @returns {string} the status of the payment intent + */ + async getStatus(paymentData) { + return await this.stripeProviderService_.getStatus(paymentData) + } + + /** + * Fetches a customers saved payment methods if registered in Stripe. + * @param {object} customer - customer to fetch saved cards for + * @returns {Promise>} saved payments methods + */ + async retrieveSavedMethods(customer) { + return Promise.resolve([]) + } + + /** + * Fetches a Stripe customer + * @param {string} customerId - Stripe customer id + * @returns {Promise} Stripe customer + */ + async retrieveCustomer(customerId) { + return await this.stripeProviderService_.retrieveCustomer(customerId) + } + + /** + * Creates a Stripe customer using a Medusa customer. + * @param {object} customer - Customer data from Medusa + * @returns {Promise} Stripe customer + */ + async createCustomer(customer) { + return await this.stripeProviderService_.createCustomer(customer) + } + + /** + * Creates a Stripe payment intent. + * If customer is not registered in Stripe, we do so. + * @param {object} cart - cart to create a payment for + * @returns {object} Stripe payment intent + */ + async createPayment(cart) { + const { customer_id, region_id, email } = cart + const region = await this.regionService_.retrieve(region_id) + const { currency_code } = region + + const amount = await this.totalsService_.getTotal(cart) + + const intentRequest = { + amount: Math.round(amount), + currency: currency_code, + payment_method_types: ["giropay"], + capture_method: "automatic", + metadata: { cart_id: `${cart.id}` }, + } + + if (customer_id) { + const customer = await this.customerService_.retrieve(customer_id) + + if (customer.metadata?.stripe_id) { + intentRequest.customer = customer.metadata.stripe_id + } else { + const stripeCustomer = await this.createCustomer({ + email, + id: customer_id, + }) + + intentRequest.customer = stripeCustomer.id + } + } else { + const stripeCustomer = await this.createCustomer({ + email, + }) + + intentRequest.customer = stripeCustomer.id + } + + const paymentIntent = await this.stripe_.paymentIntents.create( + intentRequest + ) + + return paymentIntent + } + + /** + * Retrieves Stripe payment intent. + * @param {object} data - the data of the payment to retrieve + * @returns {Promise} Stripe payment intent + */ + async retrievePayment(data) { + return await this.stripeProviderService_.retrievePayment(data) + } + + /** + * Gets a Stripe payment intent and returns it. + * @param {object} sessionData - the data of the payment to retrieve + * @returns {Promise} Stripe payment intent + */ + async getPaymentData(sessionData) { + return await this.stripeProviderService_.getPaymentData(sessionData) + } + + /** + * Authorizes Stripe payment intent by simply returning + * the status for the payment intent in use. + * @param {object} sessionData - payment session data + * @param {object} context - properties relevant to current context + * @returns {Promise<{ status: string, data: object }>} result with data and status + */ + async authorizePayment(sessionData, context = {}) { + return await this.stripeProviderService_.authorizePayment( + sessionData, + context + ) + } + + async updatePaymentData(sessionData, update) { + return await this.stripeProviderService_.updatePaymentData( + sessionData, + update + ) + } + + /** + * Updates Stripe payment intent. + * @param {object} sessionData - payment session data. + * @param {object} update - objec to update intent with + * @returns {object} Stripe payment intent + */ + async updatePayment(sessionData, cart) { + try { + const stripeId = cart.customer?.metadata?.stripe_id || undefined + + if (stripeId !== sessionData.customer) { + return this.createPayment(cart) + } else { + if (cart.total && sessionData.amount === Math.round(cart.total)) { + return sessionData + } + + return this.stripe_.paymentIntents.update(sessionData.id, { + amount: Math.round(cart.total), + }) + } + } catch (error) { + throw error + } + } + + async deletePayment(payment) { + return await this.stripeProviderService_.deletePayment(payment) + } + + /** + * Updates customer of Stripe payment intent. + * @param {string} paymentIntentId - id of payment intent to update + * @param {string} customerId - id of new Stripe customer + * @returns {object} Stripe payment intent + */ + async updatePaymentIntentCustomer(paymentIntentId, customerId) { + return await this.stripeProviderService_.updatePaymentIntentCustomer( + paymentIntentId, + customerId + ) + } + + /** + * Captures payment for Stripe payment intent. + * @param {object} paymentData - payment method data from cart + * @returns {object} Stripe payment intent + */ + async capturePayment(payment) { + return await this.stripeProviderService_.capturePayment(payment) + } + + /** + * Refunds payment for Stripe payment intent. + * @param {object} paymentData - payment method data from cart + * @param {number} amountToRefund - amount to refund + * @returns {string} refunded payment intent + */ + async refundPayment(payment, amountToRefund) { + return await this.stripeProviderService_.refundPayment( + payment, + amountToRefund + ) + } + + /** + * Cancels payment for Stripe payment intent. + * @param {object} paymentData - payment method data from cart + * @returns {object} canceled payment intent + */ + async cancelPayment(payment) { + return await this.stripeProviderService_.cancelPayment(payment) + } +} + +export default GiropayProviderService diff --git a/packages/medusa-payment-stripe/src/services/stripe-provider.js b/packages/medusa-payment-stripe/src/services/stripe-provider.js index 34406cd467..da97bc9c01 100644 --- a/packages/medusa-payment-stripe/src/services/stripe-provider.js +++ b/packages/medusa-payment-stripe/src/services/stripe-provider.js @@ -293,8 +293,14 @@ class StripeProviderService extends PaymentService { async capturePayment(payment) { const { id } = payment.data try { - return this.stripe_.paymentIntents.capture(id) + const intent = await this.stripe_.paymentIntents.capture(id) + return intent } catch (error) { + if (error.code === "payment_intent_unexpected_state") { + if (error.payment_intent.status === "succeeded") { + return error.payment_intent + } + } throw error } } diff --git a/packages/medusa-plugin-add-ons/CHANGELOG.md b/packages/medusa-plugin-add-ons/CHANGELOG.md index dfa57da011..f9c90b921f 100644 --- a/packages/medusa-plugin-add-ons/CHANGELOG.md +++ b/packages/medusa-plugin-add-ons/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-add-ons@1.1.16...medusa-plugin-add-ons@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-add-ons + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.15...medusa-plugin-add-ons@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-add-ons + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.14...medusa-plugin-add-ons@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-add-ons + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.13...medusa-plugin-add-ons@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-add-ons + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.12...medusa-plugin-add-ons@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-add-ons diff --git a/packages/medusa-plugin-add-ons/package.json b/packages/medusa-plugin-add-ons/package.json index 0704b135e7..4b4994f1bf 100644 --- a/packages/medusa-plugin-add-ons/package.json +++ b/packages/medusa-plugin-add-ons/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-add-ons", - "version": "1.1.13", + "version": "1.1.17", "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.13" + "medusa-test-utils": "^1.1.17" }, "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.10", + "medusa-core-utils": "^1.1.14", "redis": "^3.0.2" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-brightpearl/CHANGELOG.md b/packages/medusa-plugin-brightpearl/CHANGELOG.md index efc521dfb2..725f267363 100644 --- a/packages/medusa-plugin-brightpearl/CHANGELOG.md +++ b/packages/medusa-plugin-brightpearl/CHANGELOG.md @@ -3,6 +3,38 @@ 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-brightpearl@1.1.19...medusa-plugin-brightpearl@1.1.20) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-brightpearl + + + + + +## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.18...medusa-plugin-brightpearl@1.1.19) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-brightpearl + + + + + +## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.17...medusa-plugin-brightpearl@1.1.18) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-brightpearl + + + + + +## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.16...medusa-plugin-brightpearl@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-brightpearl + + + + + ## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.15...medusa-plugin-brightpearl@1.1.16) (2021-06-08) **Note:** Version bump only for package medusa-plugin-brightpearl diff --git a/packages/medusa-plugin-brightpearl/package.json b/packages/medusa-plugin-brightpearl/package.json index f696e84123..7f87a2548f 100644 --- a/packages/medusa-plugin-brightpearl/package.json +++ b/packages/medusa-plugin-brightpearl/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-brightpearl", - "version": "1.1.16", + "version": "1.1.20", "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.13", + "medusa-test-utils": "^1.1.17", "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.10", + "medusa-core-utils": "^1.1.14", "randomatic": "^3.1.1" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-contentful/CHANGELOG.md b/packages/medusa-plugin-contentful/CHANGELOG.md index dba6c5effe..0be5b3b6b8 100644 --- a/packages/medusa-plugin-contentful/CHANGELOG.md +++ b/packages/medusa-plugin-contentful/CHANGELOG.md @@ -3,6 +3,38 @@ 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-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 diff --git a/packages/medusa-plugin-contentful/package.json b/packages/medusa-plugin-contentful/package.json index bb5dd370b6..ad2c2cfc98 100644 --- a/packages/medusa-plugin-contentful/package.json +++ b/packages/medusa-plugin-contentful/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-contentful", - "version": "1.1.14", + "version": "1.1.18", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "redis": "^3.0.2" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-contentful/src/services/contentful.js b/packages/medusa-plugin-contentful/src/services/contentful.js index f78d714073..ab28b058db 100644 --- a/packages/medusa-plugin-contentful/src/services/contentful.js +++ b/packages/medusa-plugin-contentful/src/services/contentful.js @@ -2,9 +2,17 @@ import _ from "lodash" import { BaseService } from "medusa-interfaces" import { createClient } from "contentful-management" +const IGNORE_THRESHOLD = 2 // seconds + class ContentfulService extends BaseService { constructor( - { productService, redisClient, productVariantService, eventBusService }, + { + regionService, + productService, + redisClient, + productVariantService, + eventBusService, + }, options ) { super() @@ -13,6 +21,8 @@ class ContentfulService extends BaseService { this.productVariantService_ = productVariantService + this.regionService_ = regionService + this.eventBus_ = eventBusService this.options_ = options @@ -24,16 +34,19 @@ class ContentfulService extends BaseService { this.redis_ = redisClient } - async getIgnoreIds_(type) { - return new Promise((resolve, reject) => { - this.redis_.get(`${type}_ignore_ids`, (err, reply) => { - if (err) { - return reject(err) - } + async addIgnore_(id, side) { + const key = `${id}_ignore_${side}` + return await this.redis_.set( + key, + 1, + "EX", + this.options_.ignore_threshold || IGNORE_THRESHOLD + ) + } - return resolve(JSON.parse(reply)) - }) - }) + async shouldIgnore_(id, side) { + const key = `${id}_ignore_${side}` + return await this.redis_.get(key) } async getContentfulEnvironment_() { @@ -46,12 +59,17 @@ class ContentfulService extends BaseService { } } - async getVariantEntries_(variants) { + async getVariantEntries_(variants, config = { publish: false }) { try { const contentfulVariants = await Promise.all( - variants.map((variant) => - this.updateProductVariantInContentful(variant) - ) + variants.map(async (variant) => { + let updated = await this.updateProductVariantInContentful(variant) + if (config.publish) { + updated = updated.publish() + } + + return updated + }) ) return contentfulVariants @@ -137,13 +155,21 @@ class ContentfulService extends BaseService { }) const environment = await this.getContentfulEnvironment_() - const variantEntries = await this.getVariantEntries_(p.variants) + 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, }, @@ -157,7 +183,14 @@ class ContentfulService extends BaseService { 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: { @@ -176,7 +209,7 @@ class ContentfulService extends BaseService { }, }) - await thumbnailAsset.processForAllLocales() + await thumbnailAsset.processForAllLocales().then((a) => a.publish()) const thumbnailLink = { sys: { @@ -189,12 +222,6 @@ class ContentfulService extends BaseService { fields.thumbnail = { "en-US": thumbnailLink, } - - if (imageLinks) { - fields.images = { - "en-US": imageLinks, - } - } } if (p.type) { @@ -233,9 +260,6 @@ class ContentfulService extends BaseService { fields, }) - // const ignoreIds = (await this.getIgnoreIds_("product")) || [] - // ignoreIds.push(product.id) - // this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds)) return result } catch (error) { throw error @@ -282,12 +306,125 @@ class ContentfulService extends BaseService { } } + async createRegionInContentful(region) { + const hasType = await this.getType("region") + .then(() => true) + .catch(() => false) + if (!hasType) { + return + } + try { + 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 + } catch (error) { + throw error + } + } + + async updateRegionInContentful(data) { + const hasType = await this.getType("region") + .then(() => true) + .catch(() => false) + if (!hasType) { + return + } + + const updateFields = [ + "name", + "currency_code", + "countries", + "payment_providers", + "fulfillment_providers", + ] + + const found = data.fields.find((f) => updateFields.includes(f)) + if (!found) { + return + } + + try { + 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 + } catch (error) { + throw error + } + } + async updateProductInContentful(data) { const updateFields = [ "variants", "options", "tags", "title", + "subtitle", "tags", "type", "type_id", @@ -302,16 +439,10 @@ class ContentfulService extends BaseService { } try { - // const ignoreIds = (await this.getIgnoreIds_("product")) || [] - - // if (ignoreIds.includes(product.id)) { - // const newIgnoreIds = ignoreIds.filter((id) => id !== product.id) - // this.redis_.set("product_ignore_ids", JSON.stringify(newIgnoreIds)) - // return - // } else { - // ignoreIds.push(product.id) - // this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds)) - // } + const ignore = await this.shouldIgnore_(data.id, "contentful") + if (ignore) { + return + } const p = await this.productService_.retrieve(data.id, { relations: [ @@ -341,6 +472,12 @@ class ContentfulService extends BaseService { [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": p.options, }, @@ -376,7 +513,7 @@ class ContentfulService extends BaseService { }, }) - await thumbnailAsset.processForAllLocales() + await thumbnailAsset.processForAllLocales().then((a) => a.publish()) const thumbnailLink = { sys: { @@ -430,6 +567,8 @@ class ContentfulService extends BaseService { const updatedEntry = await productEntry.update() const publishedEntry = await updatedEntry.publish() + await this.addIgnore_(data.id, "medusa") + return publishedEntry } catch (error) { throw error @@ -460,19 +599,10 @@ class ContentfulService extends BaseService { } try { - // const ignoreIds = (await this.getIgnoreIds_("product_variant")) || [] - - //if (ignoreIds.includes(variant.id)) { - // const newIgnoreIds = ignoreIds.filter((id) => id !== variant.id) - // this.redis_.set( - // "product_variant_ignore_ids", - // JSON.stringify(newIgnoreIds) - // ) - // return - //} else { - // ignoreIds.push(variant.id) - // this.redis_.set("product_variant_ignore_ids", JSON.stringify(ignoreIds)) - //} + const ignore = await this.shouldIgnore_(variant.id, "contentful") + if (ignore) { + return + } const environment = await this.getContentfulEnvironment_() // check if product exists @@ -512,6 +642,8 @@ class ContentfulService extends BaseService { const updatedEntry = await variantEntry.update() const publishedEntry = await updatedEntry.publish() + await this.addIgnore_(variant.id, "medusa") + return publishedEntry } catch (error) { throw error @@ -519,29 +651,42 @@ class ContentfulService extends BaseService { } async sendContentfulProductToAdmin(productId) { + const ignore = await this.shouldIgnore_(productId, "medusa") + if (ignore) { + return + } + try { const environment = await this.getContentfulEnvironment_() const productEntry = await environment.getEntry(productId) const product = await this.productService_.retrieve(productId) - //const ignoreIds = (await this.getIgnoreIds_("product")) || [] - //if (ignoreIds.includes(productId)) { - // const newIgnoreIds = ignoreIds.filter((id) => id !== productId) - // this.redis_.set("product_ignore_ids", JSON.stringify(newIgnoreIds)) - // return - //} else { - // ignoreIds.push(productId) - // this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds)) - //} - let 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" + ] + if (product.title !== title) { update.title = title } + if (product.subtitle !== subtitle) { + update.subtitle = subtitle + } + + if (product.description !== description) { + update.description = description + } + // Get the thumbnail, if present if (productEntry.fields.thumbnail) { const thumb = await environment.getAsset( @@ -556,7 +701,9 @@ class ContentfulService extends BaseService { } if (!_.isEmpty(update)) { - await this.productService_.update(productId, update) + await this.productService_.update(productId, update).then(async () => { + return await this.addIgnore_(productId, "contentful") + }) } } catch (error) { throw error @@ -564,32 +711,25 @@ class ContentfulService extends BaseService { } async sendContentfulProductVariantToAdmin(variantId) { + const ignore = this.shouldIgnore_(variantId, "medusa") + if (ignore) { + return + } + try { const environment = await this.getContentfulEnvironment_() const variantEntry = await environment.getEntry(variantId) - // const ignoreIds = (await this.getIgnoreIds_("product_variant")) || [] - // if (ignoreIds.includes(variantId)) { - // const newIgnoreIds = ignoreIds.filter((id) => id !== variantId) - // this.redis_.set( - // "product_variant_ignore_ids", - // JSON.stringify(newIgnoreIds) - // ) - // return - // } else { - // ignoreIds.push(variantId) - // this.redis_.set("product_variant_ignore_ids", JSON.stringify(ignoreIds)) - // } - - const updatedVariant = await this.productVariantService_.update( - 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 } catch (error) { diff --git a/packages/medusa-plugin-contentful/src/subscribers/contentful.js b/packages/medusa-plugin-contentful/src/subscribers/contentful.js index 301ac00160..6431ea60c4 100644 --- a/packages/medusa-plugin-contentful/src/subscribers/contentful.js +++ b/packages/medusa-plugin-contentful/src/subscribers/contentful.js @@ -10,6 +10,14 @@ class ContentfulSubscriber { 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("product-variant.updated", async (data) => { await this.contentfulService_.updateProductVariantInContentful(data) }) diff --git a/packages/medusa-plugin-discount-generator/CHANGELOG.md b/packages/medusa-plugin-discount-generator/CHANGELOG.md index 17b8fec484..a19a7f8fec 100644 --- a/packages/medusa-plugin-discount-generator/CHANGELOG.md +++ b/packages/medusa-plugin-discount-generator/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.7...medusa-plugin-discount-generator@1.1.8) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-discount-generator + + + + + +## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.6...medusa-plugin-discount-generator@1.1.7) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-discount-generator + + + + + +## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.5...medusa-plugin-discount-generator@1.1.6) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-discount-generator + + + + + +## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.4...medusa-plugin-discount-generator@1.1.5) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-discount-generator + + + + + ## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.3...medusa-plugin-discount-generator@1.1.4) (2021-06-08) **Note:** Version bump only for package medusa-plugin-discount-generator diff --git a/packages/medusa-plugin-discount-generator/package.json b/packages/medusa-plugin-discount-generator/package.json index a0e3929c28..4b12758e75 100644 --- a/packages/medusa-plugin-discount-generator/package.json +++ b/packages/medusa-plugin-discount-generator/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-discount-generator", - "version": "1.1.4", + "version": "1.1.8", "main": "index.js", "license": "MIT", "author": "Sebastian Rindom", diff --git a/packages/medusa-plugin-economic/CHANGELOG.md b/packages/medusa-plugin-economic/CHANGELOG.md index aabd6d340d..1758a421ea 100644 --- a/packages/medusa-plugin-economic/CHANGELOG.md +++ b/packages/medusa-plugin-economic/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-economic@1.1.16...medusa-plugin-economic@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-economic + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.15...medusa-plugin-economic@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-economic + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.14...medusa-plugin-economic@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-economic + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.13...medusa-plugin-economic@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-economic + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.12...medusa-plugin-economic@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-economic diff --git a/packages/medusa-plugin-economic/package-lock.json b/packages/medusa-plugin-economic/package-lock.json index 9ce1b8ab42..e217073df5 100644 --- a/packages/medusa-plugin-economic/package-lock.json +++ b/packages/medusa-plugin-economic/package-lock.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-economic", - "version": "1.1.13", + "version": "1.1.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/medusa-plugin-economic/package.json b/packages/medusa-plugin-economic/package.json index 41e5959502..ddfdead8c1 100644 --- a/packages/medusa-plugin-economic/package.json +++ b/packages/medusa-plugin-economic/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-economic", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "moment": "^2.27.0" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-ip-lookup/CHANGELOG.md b/packages/medusa-plugin-ip-lookup/CHANGELOG.md index bbe21dc3f7..00f24d8ed3 100644 --- a/packages/medusa-plugin-ip-lookup/CHANGELOG.md +++ b/packages/medusa-plugin-ip-lookup/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.7...medusa-plugin-ip-lookup@1.1.8) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-ip-lookup + + + + + +## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.6...medusa-plugin-ip-lookup@1.1.7) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-ip-lookup + + + + + +## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.5...medusa-plugin-ip-lookup@1.1.6) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-ip-lookup + + + + + +## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.4...medusa-plugin-ip-lookup@1.1.5) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-ip-lookup + + + + + ## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.3...medusa-plugin-ip-lookup@1.1.4) (2021-06-08) **Note:** Version bump only for package medusa-plugin-ip-lookup diff --git a/packages/medusa-plugin-ip-lookup/package.json b/packages/medusa-plugin-ip-lookup/package.json index 7bbd864939..f3b538c9e6 100644 --- a/packages/medusa-plugin-ip-lookup/package.json +++ b/packages/medusa-plugin-ip-lookup/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-ip-lookup", - "version": "1.1.4", + "version": "1.1.8", "description": "IP lookup middleware for Medusa core", "main": "dist/index.js", "repository": { diff --git a/packages/medusa-plugin-mailchimp/CHANGELOG.md b/packages/medusa-plugin-mailchimp/CHANGELOG.md index ee9c616191..0fbc598341 100644 --- a/packages/medusa-plugin-mailchimp/CHANGELOG.md +++ b/packages/medusa-plugin-mailchimp/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-mailchimp@1.1.16...medusa-plugin-mailchimp@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-mailchimp + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.15...medusa-plugin-mailchimp@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-mailchimp + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.14...medusa-plugin-mailchimp@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-mailchimp + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.13...medusa-plugin-mailchimp@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-mailchimp + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.12...medusa-plugin-mailchimp@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-mailchimp diff --git a/packages/medusa-plugin-mailchimp/package.json b/packages/medusa-plugin-mailchimp/package.json index 5113a6d7cb..b730d382ae 100644 --- a/packages/medusa-plugin-mailchimp/package.json +++ b/packages/medusa-plugin-mailchimp/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-mailchimp", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13" + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-plugin-permissions/CHANGELOG.md b/packages/medusa-plugin-permissions/CHANGELOG.md index ea3e2f5c20..1742bc5d97 100644 --- a/packages/medusa-plugin-permissions/CHANGELOG.md +++ b/packages/medusa-plugin-permissions/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-permissions@1.1.16...medusa-plugin-permissions@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-permissions + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.15...medusa-plugin-permissions@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-permissions + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.14...medusa-plugin-permissions@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-permissions + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.13...medusa-plugin-permissions@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-permissions + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.12...medusa-plugin-permissions@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-permissions diff --git a/packages/medusa-plugin-permissions/package.json b/packages/medusa-plugin-permissions/package.json index 5d07300664..adebd10435 100644 --- a/packages/medusa-plugin-permissions/package.json +++ b/packages/medusa-plugin-permissions/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-permissions", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "mongoose": "^5.8.0" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-restock-notification/CHANGELOG.md b/packages/medusa-plugin-restock-notification/CHANGELOG.md index e57e27c139..15e17e341c 100644 --- a/packages/medusa-plugin-restock-notification/CHANGELOG.md +++ b/packages/medusa-plugin-restock-notification/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.0.9](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.8...medusa-plugin-restock-notification@0.0.9) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-restock-notification + + + + + +## [0.0.8](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.7...medusa-plugin-restock-notification@0.0.8) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-restock-notification + + + + + +## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.7...medusa-plugin-restock-notification@0.0.7) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-restock-notification + + + + + +## [0.0.6](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.7...medusa-plugin-restock-notification@0.0.6) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-restock-notification + + + + + ## [0.0.4](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.7...medusa-plugin-restock-notification@0.0.4) (2021-06-08) **Note:** Version bump only for package medusa-plugin-restock-notification diff --git a/packages/medusa-plugin-restock-notification/package.json b/packages/medusa-plugin-restock-notification/package.json index df1a06513e..1f97aa89cf 100644 --- a/packages/medusa-plugin-restock-notification/package.json +++ b/packages/medusa-plugin-restock-notification/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-restock-notification", - "version": "0.0.6-next.13+df18c05", + "version": "0.0.9", "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.4", + "babel-preset-medusa-package": "^1.1.8", "cross-env": "^5.2.1", "eslint": "^6.8.0", "jest": "^25.5.2", - "medusa-test-utils": "^1.1.13", + "medusa-test-utils": "^1.1.17", "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.10" + "medusa-core-utils": "^1.1.14" }, "gitHead": "df18c053cb9ec801dd3cb54b0a60a4b9ce8e23c4" } diff --git a/packages/medusa-plugin-segment/CHANGELOG.md b/packages/medusa-plugin-segment/CHANGELOG.md index 47d8031759..dc785f5f2f 100644 --- a/packages/medusa-plugin-segment/CHANGELOG.md +++ b/packages/medusa-plugin-segment/CHANGELOG.md @@ -3,6 +3,38 @@ 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-segment@1.1.19...medusa-plugin-segment@1.1.20) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-segment + + + + + +## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.18...medusa-plugin-segment@1.1.19) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-segment + + + + + +## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.17...medusa-plugin-segment@1.1.18) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-segment + + + + + +## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.16...medusa-plugin-segment@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-segment + + + + + ## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.15...medusa-plugin-segment@1.1.16) (2021-06-08) **Note:** Version bump only for package medusa-plugin-segment diff --git a/packages/medusa-plugin-segment/package.json b/packages/medusa-plugin-segment/package.json index 2daa8dd62f..6db34925bc 100644 --- a/packages/medusa-plugin-segment/package.json +++ b/packages/medusa-plugin-segment/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-segment", - "version": "1.1.16", + "version": "1.1.20", "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.10", - "medusa-test-utils": "^1.1.13" + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-plugin-sendgrid/CHANGELOG.md b/packages/medusa-plugin-sendgrid/CHANGELOG.md index 1f9676bf27..88ebb5c580 100644 --- a/packages/medusa-plugin-sendgrid/CHANGELOG.md +++ b/packages/medusa-plugin-sendgrid/CHANGELOG.md @@ -3,6 +3,38 @@ 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-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 diff --git a/packages/medusa-plugin-sendgrid/package.json b/packages/medusa-plugin-sendgrid/package.json index aa08449ff6..4bc8e618ae 100644 --- a/packages/medusa-plugin-sendgrid/package.json +++ b/packages/medusa-plugin-sendgrid/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-sendgrid", - "version": "1.1.14", + "version": "1.1.18", "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.10", - "medusa-test-utils": "^1.1.13" + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-plugin-slack-notification/CHANGELOG.md b/packages/medusa-plugin-slack-notification/CHANGELOG.md index 994369394d..64421426e0 100644 --- a/packages/medusa-plugin-slack-notification/CHANGELOG.md +++ b/packages/medusa-plugin-slack-notification/CHANGELOG.md @@ -3,6 +3,38 @@ 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-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 diff --git a/packages/medusa-plugin-slack-notification/package-lock.json b/packages/medusa-plugin-slack-notification/package-lock.json index 9ce1b8ab42..e217073df5 100644 --- a/packages/medusa-plugin-slack-notification/package-lock.json +++ b/packages/medusa-plugin-slack-notification/package-lock.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-economic", - "version": "1.1.13", + "version": "1.1.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/medusa-plugin-slack-notification/package.json b/packages/medusa-plugin-slack-notification/package.json index 79c2bd39e2..ca9b6bf977 100644 --- a/packages/medusa-plugin-slack-notification/package.json +++ b/packages/medusa-plugin-slack-notification/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-slack-notification", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "moment": "^2.27.0" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-twilio-sms/CHANGELOG.md b/packages/medusa-plugin-twilio-sms/CHANGELOG.md index 295ffcf736..e31d19eb7e 100644 --- a/packages/medusa-plugin-twilio-sms/CHANGELOG.md +++ b/packages/medusa-plugin-twilio-sms/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-twilio-sms@1.1.16...medusa-plugin-twilio-sms@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-twilio-sms + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.15...medusa-plugin-twilio-sms@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-twilio-sms + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.14...medusa-plugin-twilio-sms@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-twilio-sms + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.13...medusa-plugin-twilio-sms@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-twilio-sms + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.12...medusa-plugin-twilio-sms@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-twilio-sms diff --git a/packages/medusa-plugin-twilio-sms/package.json b/packages/medusa-plugin-twilio-sms/package.json index 04ec2415d2..44b2ffb60f 100644 --- a/packages/medusa-plugin-twilio-sms/package.json +++ b/packages/medusa-plugin-twilio-sms/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-twilio-sms", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "twilio": "^3.49.1" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa-plugin-wishlist/CHANGELOG.md b/packages/medusa-plugin-wishlist/CHANGELOG.md index 1737f0a93c..6b092f32bb 100644 --- a/packages/medusa-plugin-wishlist/CHANGELOG.md +++ b/packages/medusa-plugin-wishlist/CHANGELOG.md @@ -3,6 +3,38 @@ 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-plugin-wishlist@1.1.16...medusa-plugin-wishlist@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-wishlist + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.15...medusa-plugin-wishlist@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-wishlist + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.14...medusa-plugin-wishlist@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-wishlist + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.13...medusa-plugin-wishlist@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-plugin-wishlist + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.12...medusa-plugin-wishlist@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-plugin-wishlist diff --git a/packages/medusa-plugin-wishlist/package.json b/packages/medusa-plugin-wishlist/package.json index fed151036f..e5357edc54 100644 --- a/packages/medusa-plugin-wishlist/package.json +++ b/packages/medusa-plugin-wishlist/package.json @@ -1,6 +1,6 @@ { "name": "medusa-plugin-wishlist", - "version": "1.1.13", + "version": "1.1.17", "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.10", - "medusa-test-utils": "^1.1.13" + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" } diff --git a/packages/medusa-test-utils/CHANGELOG.md b/packages/medusa-test-utils/CHANGELOG.md index 3607a7e454..d08bf0db4e 100644 --- a/packages/medusa-test-utils/CHANGELOG.md +++ b/packages/medusa-test-utils/CHANGELOG.md @@ -3,6 +3,38 @@ 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-test-utils@1.1.16...medusa-test-utils@1.1.17) (2021-06-09) + +**Note:** Version bump only for package medusa-test-utils + + + + + +## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.15...medusa-test-utils@1.1.16) (2021-06-09) + +**Note:** Version bump only for package medusa-test-utils + + + + + +## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.14...medusa-test-utils@1.1.15) (2021-06-09) + +**Note:** Version bump only for package medusa-test-utils + + + + + +## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.13...medusa-test-utils@1.1.14) (2021-06-09) + +**Note:** Version bump only for package medusa-test-utils + + + + + ## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.12...medusa-test-utils@1.1.13) (2021-06-08) **Note:** Version bump only for package medusa-test-utils diff --git a/packages/medusa-test-utils/package.json b/packages/medusa-test-utils/package.json index c5fcfa2cf7..c75702292f 100644 --- a/packages/medusa-test-utils/package.json +++ b/packages/medusa-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "medusa-test-utils", - "version": "1.1.13", + "version": "1.1.17", "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.10", + "medusa-core-utils": "^1.1.14", "randomatic": "^3.1.1" }, "gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532" diff --git a/packages/medusa/CHANGELOG.md b/packages/medusa/CHANGELOG.md index 4d82ad5165..88fe6587e5 100644 --- a/packages/medusa/CHANGELOG.md +++ b/packages/medusa/CHANGELOG.md @@ -3,6 +3,109 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.26](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.25...@medusajs/medusa@1.1.26) (2021-06-10) + + +### Bug Fixes + +* avoid error message ([0a62590](https://github.com/medusajs/medusa/commit/0a62590044ab01eb81795de69c0f7017372394cc)) + + + + + +## [1.1.25](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.24...@medusajs/medusa@1.1.25) (2021-06-09) + +**Note:** Version bump only for package @medusajs/medusa + + + + + +## [1.1.24](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.23...@medusajs/medusa@1.1.24) (2021-06-09) + + +### Bug Fixes + +* babel ([813a1c9](https://github.com/medusajs/medusa/commit/813a1c95a86139a3293c6f8d8bc13f4eb76ef96e)) +* bearer user id login development ([df50186](https://github.com/medusajs/medusa/commit/df5018669ce7b727798234e74cda30de262bbb91)) +* common registration name formatter ([f4f67a3](https://github.com/medusajs/medusa/commit/f4f67a376dcb6a4d6734c227ba3c2a9e3353a5ce)) +* migration dirs ([57a2de6](https://github.com/medusajs/medusa/commit/57a2de64b209544c39af5a7dae43f1230cf36058)) +* migration dirs ([e764d8e](https://github.com/medusajs/medusa/commit/e764d8e465fb2ce1a2330cc55097d15dde647074)) +* order order ([245ccdc](https://github.com/medusajs/medusa/commit/245ccdc4774965cdd27d4dbdb5fbb084c8066c66)) +* PR ([e20ba1e](https://github.com/medusajs/medusa/commit/e20ba1e4faa8d13b3fc35c7c2fe8597c6ec8f41c)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) +* test name registration ([e59dc3b](https://github.com/medusajs/medusa/commit/e59dc3b6c85db369c0b7dd3d097578fc2b527431)) +* wip ([42d9a48](https://github.com/medusajs/medusa/commit/42d9a487ff1239f32a00bf47df3218ff3cf03217)) +* **medusa:** Add free shipping functionality ([#241](https://github.com/medusajs/medusa/issues/241)) ([fb0613d](https://github.com/medusajs/medusa/commit/fb0613d3cbbfeb858b4a4a0f4da859b9692379bd)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) +* allow custom address on claims ([586f4d8](https://github.com/medusajs/medusa/commit/586f4d884c4b7b5b84fbd1f4dbf5c6fb2ffccf50)) +* **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345)) + + + + + +## [1.1.23](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.23...@medusajs/medusa@1.1.23) (2021-06-09) + + +### Bug Fixes + +* babel ([813a1c9](https://github.com/medusajs/medusa/commit/813a1c95a86139a3293c6f8d8bc13f4eb76ef96e)) +* bearer user id login development ([df50186](https://github.com/medusajs/medusa/commit/df5018669ce7b727798234e74cda30de262bbb91)) +* common registration name formatter ([f4f67a3](https://github.com/medusajs/medusa/commit/f4f67a376dcb6a4d6734c227ba3c2a9e3353a5ce)) +* migration dirs ([57a2de6](https://github.com/medusajs/medusa/commit/57a2de64b209544c39af5a7dae43f1230cf36058)) +* migration dirs ([e764d8e](https://github.com/medusajs/medusa/commit/e764d8e465fb2ce1a2330cc55097d15dde647074)) +* order order ([245ccdc](https://github.com/medusajs/medusa/commit/245ccdc4774965cdd27d4dbdb5fbb084c8066c66)) +* PR ([e20ba1e](https://github.com/medusajs/medusa/commit/e20ba1e4faa8d13b3fc35c7c2fe8597c6ec8f41c)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) +* test name registration ([e59dc3b](https://github.com/medusajs/medusa/commit/e59dc3b6c85db369c0b7dd3d097578fc2b527431)) +* wip ([42d9a48](https://github.com/medusajs/medusa/commit/42d9a487ff1239f32a00bf47df3218ff3cf03217)) +* **medusa:** Add free shipping functionality ([#241](https://github.com/medusajs/medusa/issues/241)) ([fb0613d](https://github.com/medusajs/medusa/commit/fb0613d3cbbfeb858b4a4a0f4da859b9692379bd)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) +* allow custom address on claims ([586f4d8](https://github.com/medusajs/medusa/commit/586f4d884c4b7b5b84fbd1f4dbf5c6fb2ffccf50)) +* **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345)) + + + + + +## [1.1.22](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.23...@medusajs/medusa@1.1.22) (2021-06-09) + + +### Bug Fixes + +* babel ([813a1c9](https://github.com/medusajs/medusa/commit/813a1c95a86139a3293c6f8d8bc13f4eb76ef96e)) +* bearer user id login development ([df50186](https://github.com/medusajs/medusa/commit/df5018669ce7b727798234e74cda30de262bbb91)) +* common registration name formatter ([f4f67a3](https://github.com/medusajs/medusa/commit/f4f67a376dcb6a4d6734c227ba3c2a9e3353a5ce)) +* migration dirs ([57a2de6](https://github.com/medusajs/medusa/commit/57a2de64b209544c39af5a7dae43f1230cf36058)) +* migration dirs ([e764d8e](https://github.com/medusajs/medusa/commit/e764d8e465fb2ce1a2330cc55097d15dde647074)) +* order order ([245ccdc](https://github.com/medusajs/medusa/commit/245ccdc4774965cdd27d4dbdb5fbb084c8066c66)) +* PR ([e20ba1e](https://github.com/medusajs/medusa/commit/e20ba1e4faa8d13b3fc35c7c2fe8597c6ec8f41c)) +* setup to allow login to Medusa Cloud ([bbd2f02](https://github.com/medusajs/medusa/commit/bbd2f02d549330df160c76cf1f4e4d5e7d08f246)) +* test name registration ([e59dc3b](https://github.com/medusajs/medusa/commit/e59dc3b6c85db369c0b7dd3d097578fc2b527431)) +* wip ([42d9a48](https://github.com/medusajs/medusa/commit/42d9a487ff1239f32a00bf47df3218ff3cf03217)) +* **medusa:** Add free shipping functionality ([#241](https://github.com/medusajs/medusa/issues/241)) ([fb0613d](https://github.com/medusajs/medusa/commit/fb0613d3cbbfeb858b4a4a0f4da859b9692379bd)) + + +### Features + +* **cli:** adds seed script ([5136c77](https://github.com/medusajs/medusa/commit/5136c7740137afcda52393131ef931eb76ea9f5d)) +* allow custom address on claims ([586f4d8](https://github.com/medusajs/medusa/commit/586f4d884c4b7b5b84fbd1f4dbf5c6fb2ffccf50)) +* **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345)) + + + + + ## [1.1.20](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.23...@medusajs/medusa@1.1.20) (2021-06-08) diff --git a/packages/medusa/package.json b/packages/medusa/package.json index 3a25322175..2d565acc81 100644 --- a/packages/medusa/package.json +++ b/packages/medusa/package.json @@ -1,6 +1,6 @@ { "name": "@medusajs/medusa", - "version": "1.1.22-next.12+245ccdc", + "version": "1.1.26", "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.5-next.0", + "babel-preset-medusa-package": "^1.1.8", "cross-env": "^5.2.1", "eslint": "^6.8.0", "jest": "^25.5.2", - "medusa-interfaces": "^1.1.12-next.0", + "medusa-interfaces": "^1.1.15", "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.11-next.0", - "medusa-test-utils": "^1.1.14-next.0", + "medusa-core-utils": "^1.1.14", + "medusa-test-utils": "^1.1.17", "morgan": "^1.9.1", "multer": "^1.4.2", "passport": "^0.4.0", @@ -79,4 +79,4 @@ "winston": "^3.2.1" }, "gitHead": "245ccdc4774965cdd27d4dbdb5fbb084c8066c66" -} \ No newline at end of file +} diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js index 91c5e70197..5e1cbe3b51 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js @@ -1,4 +1,8 @@ -import { MedusaError, Validator } from "medusa-core-utils" +import { + MedusaError, + Validator, + transformIdableFields, +} from "medusa-core-utils" import { defaultFields, defaultRelations } from "." /** @@ -137,11 +141,13 @@ export default async (req, res) => { metadata: Validator.object().optional(), }) - const { value, error } = schema.validate(req.body) + let { value, error } = schema.validate(req.body) if (error) { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } + value = transformIdableFields(value, ["shipping_address", "billing_address"]) + try { const draftOrderService = req.scope.resolve("draftOrderService") let draftOrder = await draftOrderService.create(value) diff --git a/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-session.js b/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-session.js index 487e788cf8..9f1df25640 100644 --- a/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-session.js +++ b/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-session.js @@ -10,10 +10,10 @@ describe("POST /store/carts/:id/payment-session/update", () => { const cartId = IdMap.getId("cartWithPaySessions") subject = await request( "POST", - `/store/carts/${cartId}/payment-session/update`, + `/store/carts/${cartId}/payment-sessions/default_provider`, { payload: { - session: { + data: { data: "Something", }, }, @@ -26,6 +26,12 @@ describe("POST /store/carts/:id/payment-session/update", () => { }) it("calls CartService updatePaymentSession", () => { + expect(CartServiceMock.setPaymentSession).toHaveBeenCalledTimes(1) + expect(CartServiceMock.setPaymentSession).toHaveBeenCalledWith( + IdMap.getId("cartWithPaySessions"), + "default_provider" + ) + expect(CartServiceMock.updatePaymentSession).toHaveBeenCalledTimes(1) expect(CartServiceMock.updatePaymentSession).toHaveBeenCalledWith( IdMap.getId("cartWithPaySessions"), diff --git a/packages/medusa/src/api/routes/store/carts/complete-cart.js b/packages/medusa/src/api/routes/store/carts/complete-cart.js index f3d02f9a61..e1997fcafc 100644 --- a/packages/medusa/src/api/routes/store/carts/complete-cart.js +++ b/packages/medusa/src/api/routes/store/carts/complete-cart.js @@ -1,7 +1,7 @@ import { MedusaError } from "medusa-core-utils" /** - * @oas [post] /carts/{id}/complete-cart + * @oas [post] /carts/{id}/complete * summary: "Complete a Cart" * operationId: "PostCartsCartComplete" * description: "Completes a cart. The following steps will be performed. Payment diff --git a/packages/medusa/src/api/routes/store/carts/index.js b/packages/medusa/src/api/routes/store/carts/index.js index 0ec18e79fe..42363bd12c 100644 --- a/packages/medusa/src/api/routes/store/carts/index.js +++ b/packages/medusa/src/api/routes/store/carts/index.js @@ -24,6 +24,12 @@ export default (app, container) => { route.post("/:id", middlewares.wrap(require("./update-cart").default)) + route.post( + "/:id/complete", + middlewares.wrap(require("./complete-cart").default) + ) + + // DEPRECATION route.post( "/:id/complete-cart", middlewares.wrap(require("./complete-cart").default) @@ -55,7 +61,7 @@ export default (app, container) => { ) route.post( - "/:id/payment-session/update", + "/:id/payment-sessions/:provider_id", middlewares.wrap(require("./update-payment-session").default) ) diff --git a/packages/medusa/src/api/routes/store/carts/update-payment-session.js b/packages/medusa/src/api/routes/store/carts/update-payment-session.js index e86ed96adb..7b9d31b92c 100644 --- a/packages/medusa/src/api/routes/store/carts/update-payment-session.js +++ b/packages/medusa/src/api/routes/store/carts/update-payment-session.js @@ -2,12 +2,13 @@ import { Validator, MedusaError } from "medusa-core-utils" import { defaultFields, defaultRelations } from "./" /** - * @oas [post] /carts/{id}/payment-session/update + * @oas [post] /carts/{id}/payment-sessions/{provider_id} * operationId: PostCartsCartPaymentSessionUpdate * summary: Update a Payment Session * description: "Updates a Payment Session with additional data." * parameters: * - (path) id=* {string} The id of the Cart. + * - (path) provider_id=* {string} The id of the payment provider. * - (body) provider_id=* {string} The id of the Payment Provider responsible for the Payment Session to update. * - (body) data=* {object} The data to update the payment session with. * tags: @@ -23,10 +24,10 @@ import { defaultFields, defaultRelations } from "./" * $ref: "#/components/schemas/cart" */ export default async (req, res) => { - const { id } = req.params + const { id, provider_id } = req.params const schema = Validator.object().keys({ - session: Validator.object().required(), + data: Validator.object().required(), }) const { value, error } = schema.validate(req.body) @@ -37,7 +38,8 @@ export default async (req, res) => { try { const cartService = req.scope.resolve("cartService") - await cartService.updatePaymentSession(id, value.session) + await cartService.setPaymentSession(id, provider_id) + await cartService.updatePaymentSession(id, value.data) const cart = await cartService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/migrations/1624287602631-gc_remove_unique_order.ts b/packages/medusa/src/migrations/1624287602631-gc_remove_unique_order.ts new file mode 100644 index 0000000000..21a0ae3a6c --- /dev/null +++ b/packages/medusa/src/migrations/1624287602631-gc_remove_unique_order.ts @@ -0,0 +1,31 @@ +import { MigrationInterface, QueryRunner } from "typeorm" + +export class gcRemoveUniqueOrder1624287602631 implements MigrationInterface { + name = "gcRemoveUniqueOrder1624287602631" + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "gift_card" DROP CONSTRAINT "FK_dfc1f02bb0552e79076aa58dbb0"` + ) + await queryRunner.query(`COMMENT ON COLUMN "gift_card"."order_id" IS NULL`) + await queryRunner.query( + `ALTER TABLE "gift_card" DROP CONSTRAINT "REL_dfc1f02bb0552e79076aa58dbb"` + ) + await queryRunner.query( + `ALTER TABLE "gift_card" ADD CONSTRAINT "FK_dfc1f02bb0552e79076aa58dbb0" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "gift_card" DROP CONSTRAINT "FK_dfc1f02bb0552e79076aa58dbb0"` + ) + await queryRunner.query( + `ALTER TABLE "gift_card" ADD CONSTRAINT "REL_dfc1f02bb0552e79076aa58dbb" UNIQUE ("order_id")` + ) + await queryRunner.query(`COMMENT ON COLUMN "gift_card"."order_id" IS NULL`) + await queryRunner.query( + `ALTER TABLE "gift_card" ADD CONSTRAINT "FK_dfc1f02bb0552e79076aa58dbb0" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } +} diff --git a/packages/medusa/src/models/gift-card.ts b/packages/medusa/src/models/gift-card.ts index 2fff7d4199..8b763b2dcc 100644 --- a/packages/medusa/src/models/gift-card.ts +++ b/packages/medusa/src/models/gift-card.ts @@ -8,7 +8,6 @@ import { Column, PrimaryColumn, ManyToOne, - OneToOne, JoinColumn, } from "typeorm" import { ulid } from "ulid" @@ -43,7 +42,7 @@ export class GiftCard { @Column({ nullable: true }) order_id: string - @OneToOne(() => Order) + @ManyToOne(() => Order) @JoinColumn({ name: "order_id" }) order: Order diff --git a/packages/medusa/src/services/__mocks__/cart.js b/packages/medusa/src/services/__mocks__/cart.js index 885369456c..b674e63e9b 100644 --- a/packages/medusa/src/services/__mocks__/cart.js +++ b/packages/medusa/src/services/__mocks__/cart.js @@ -323,6 +323,9 @@ export const CartServiceMock = { applyDiscount: jest.fn().mockImplementation((cartId, code) => { return Promise.resolve() }), + setPaymentSession: jest.fn().mockImplementation(cartId => { + return Promise.resolve() + }), setPaymentSessions: jest.fn().mockImplementation(cartId => { return Promise.resolve() }), diff --git a/packages/medusa/src/services/__tests__/region.js b/packages/medusa/src/services/__tests__/region.js index bd23d97285..4ea0efa171 100644 --- a/packages/medusa/src/services/__tests__/region.js +++ b/packages/medusa/src/services/__tests__/region.js @@ -1,6 +1,14 @@ import { IdMap, MockManager, MockRepository } from "medusa-test-utils" import RegionService from "../region" +const eventBusService = { + emit: jest.fn(), + withTransaction: function() { + return this + }, +} + + describe("RegionService", () => { describe("create", () => { const regionRepository = MockRepository({}) @@ -58,6 +66,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, fulfillmentProviderRepository: fpRepository, paymentProviderRepository: ppRepository, currencyRepository, @@ -168,6 +177,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, }) @@ -237,6 +247,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, fulfillmentProviderRepository: fpRepository, paymentProviderRepository: ppRepository, regionRepository, @@ -335,6 +346,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, fulfillmentProviderRepository: fpRepository, paymentProviderRepository: ppRepository, regionRepository, @@ -380,6 +392,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, }) @@ -429,6 +442,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, countryRepository, }) @@ -473,6 +487,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, }) @@ -522,6 +537,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, fulfillmentProviderRepository: fpRepository, paymentProviderRepository: ppRepository, regionRepository, @@ -582,6 +598,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, fulfillmentProviderRepository: fpRepository, regionRepository, }) @@ -631,6 +648,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, }) @@ -665,6 +683,7 @@ describe("RegionService", () => { const regionService = new RegionService({ manager: MockManager, + eventBusService, regionRepository, }) diff --git a/packages/medusa/src/services/cart.js b/packages/medusa/src/services/cart.js index 958b73000d..6c2bd03792 100644 --- a/packages/medusa/src/services/cart.js +++ b/packages/medusa/src/services/cart.js @@ -306,8 +306,8 @@ class CartService extends BaseService { const regCountries = region.countries.map(({ iso_2 }) => iso_2) - if (data.shipping_address && typeof data.shipping_address === `string`) { - const addr = await addressRepo.findOne(data.shipping_address) + if (data.shipping_address_id) { + const addr = await addressRepo.findOne(data.shipping_address_id) data.shipping_address = addr } @@ -650,16 +650,14 @@ class CartService extends BaseService { } const addrRepo = manager.getCustomRepository(this.addressRepository_) - if ("shipping_address" in update) { - await this.updateShippingAddress_( - cart, - update.shipping_address, - addrRepo - ) + if ("shipping_address_id" in update || "shipping_address" in update) { + const address = update.shipping_address_id || update.shipping_address + await this.updateShippingAddress_(cart, address, addrRepo) } - if ("billing_address" in update) { - await this.updateBillingAddress_(cart, update.billing_address, addrRepo) + if ("billing_address_id" in update || "billing_address" in update) { + const address = update.billing_address_id || update.billing_address + await this.updateBillingAddress_(cart, address, addrRepo) } if ("discounts" in update) { diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index a5cd27680a..a0fe677397 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -470,9 +470,9 @@ class OrderService extends BaseService { ) } - const paymentStatus = await this.paymentProviderService_.getStatus( - payment - ) + const paymentStatus = await this.paymentProviderService_ + .withTransaction(manager) + .getStatus(payment) // If payment status is not authorized, we throw if (paymentStatus !== "authorized" && paymentStatus !== "succeeded") { diff --git a/packages/medusa/src/services/region.js b/packages/medusa/src/services/region.js index cec4c6690a..33a56ff3c7 100644 --- a/packages/medusa/src/services/region.js +++ b/packages/medusa/src/services/region.js @@ -8,11 +8,17 @@ import { countries } from "../utils/countries" * @implements BaseService */ class RegionService extends BaseService { + static Events = { + UPDATED: "region.updated", + CREATED: "region.created", + } + constructor({ manager, regionRepository, countryRepository, storeService, + eventBusService, currencyRepository, paymentProviderRepository, fulfillmentProviderRepository, @@ -33,6 +39,9 @@ class RegionService extends BaseService { /** @private @const {StoreService} */ this.storeService_ = storeService + /** @private @const {EventBus} */ + this.eventBus_ = eventBusService + /** @private @const {CurrencyRepository} */ this.currencyRepository_ = currencyRepository @@ -60,6 +69,7 @@ class RegionService extends BaseService { currencyRepository: this.currencyRepository_, countryRepository: this.countryRepository_, storeService: this.storeService_, + eventBusService: this.eventBus_, paymentProviderRepository: this.paymentProviderRepository_, paymentProviderService: this.paymentProviderService_, fulfillmentProviderRepository: this.fulfillmentProviderRepository_, @@ -117,6 +127,13 @@ class RegionService extends BaseService { const created = regionRepository.create(regionObject) const result = await regionRepository.save(created) + + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.CREATED, { + id: result.id, + }) + return result }) } @@ -168,6 +185,14 @@ class RegionService extends BaseService { } const result = await regionRepository.save(region) + + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: result.id, + fields: Object.keys(update), + }) + return result }) } @@ -390,6 +415,14 @@ class RegionService extends BaseService { region.countries = [...(region.countries || []), country] const updated = await regionRepo.save(region) + + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["countries"], + }) + return updated }) } @@ -419,6 +452,12 @@ class RegionService extends BaseService { ) const updated = await regionRepo.save(region) + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["countries"], + }) return updated }) } @@ -458,6 +497,14 @@ class RegionService extends BaseService { region.payment_providers = [...region.payment_providers, pp] const updated = await regionRepo.save(region) + + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["payment_providers"], + }) + return updated }) } @@ -497,6 +544,12 @@ class RegionService extends BaseService { region.fulfillment_providers = [...region.fulfillment_providers, fp] const updated = await regionRepo.save(region) + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["fulfillment_providers"], + }) return updated }) } @@ -525,6 +578,12 @@ class RegionService extends BaseService { ) const updated = await regionRepo.save(region) + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["payment_providers"], + }) return updated }) } @@ -553,23 +612,15 @@ class RegionService extends BaseService { ) const updated = await regionRepo.save(region) + await this.eventBus_ + .withTransaction(manager) + .emit(RegionService.Events.UPDATED, { + id: updated.id, + fields: ["fulfillment_providers"], + }) return updated }) } - - /** - * Decorates a region - * @param {object} region - the region to decorate - * @param {[string]} fields - the fields to include - * @param {[string]} expandFields - the fields to expand - * @return {Region} the region - */ - async decorate(region, fields, expandFields = []) { - const requiredFields = ["id", "metadata"] - const decorated = _.pick(region, fields.concat(requiredFields)) - const final = await this.runDecorators_(decorated) - return final - } } export default RegionService diff --git a/packages/medusa/src/subscribers/order.js b/packages/medusa/src/subscribers/order.js index 8fe2418ec1..01ac3c9cca 100644 --- a/packages/medusa/src/subscribers/order.js +++ b/packages/medusa/src/subscribers/order.js @@ -63,10 +63,9 @@ class OrderSubscriber { updateDraftOrder = async data => { const order = await this.orderService_.retrieve(data.id) - - const draftOrder = await this.draftOrderService_.retrieveByCartId( - order.cart_id - ) + const draftOrder = await this.draftOrderService_ + .retrieveByCartId(order.cart_id) + .catch(_ => null) if (draftOrder) { await this.draftOrderService_.registerCartCompletion(