chore: Remove remaining V1 plugins (#7255)

This commit is contained in:
Oli Juhl
2024-05-06 17:31:24 +02:00
committed by GitHub
parent 651b953db7
commit 309c04afe8
69 changed files with 55 additions and 4483 deletions

View File

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

View File

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

View File

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

View File

@@ -1,172 +0,0 @@
# Change Log
## 1.1.27
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
## 1.1.26
### Patch Changes
- [#3763](https://github.com/medusajs/medusa/pull/3763) [`4104d9ccb`](https://github.com/medusajs/medusa/commit/4104d9ccb25276c85b5363f85e14b3093e64df85) Thanks [@StephixOne](https://github.com/StephixOne)! - fix(plugin-discount-generator,plugin-economic,plugin-mailchimp,plugin-restock-notification,plugin-sendgrid,plugin-wishlist): Temporarily remove payload validation in some plugins
## 1.1.25
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
## 1.1.25-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
## 1.1.24
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.1.23
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.1.22
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.1.21
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
## 1.1.20
### Patch Changes
- [#2623](https://github.com/medusajs/medusa/pull/2623) [`533208197`](https://github.com/medusajs/medusa/commit/5332081972cdd08b4d718799097d78043279057b) Thanks [@pKorsholm](https://github.com/pKorsholm)! - Bump dependency version for medusa packages
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.18...medusa-plugin-discount-generator@1.1.19) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.17...medusa-plugin-discount-generator@1.1.18) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.15...medusa-plugin-discount-generator@1.1.17) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.15...medusa-plugin-discount-generator@1.1.16) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.14...medusa-plugin-discount-generator@1.1.15) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.13...medusa-plugin-discount-generator@1.1.14) (2021-09-14)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.12...medusa-plugin-discount-generator@1.1.13) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.10...medusa-plugin-discount-generator@1.1.12) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.10...medusa-plugin-discount-generator@1.1.11) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.9...medusa-plugin-discount-generator@1.1.10) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.8...medusa-plugin-discount-generator@1.1.9) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [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
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.0...medusa-plugin-discount-generator@1.1.3) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.1...medusa-plugin-discount-generator@1.1.2) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-discount-generator
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.0...medusa-plugin-discount-generator@1.1.1) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-discount-generator
# 1.1.0 (2021-01-26)
## 1.0.1 (2020-09-05)
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
**Note:** Version bump only for package medusa-plugin-discount-generator

View File

@@ -1,41 +0,0 @@
# Discount Generator
Generate dynamic discount codes in your Medusa backend.
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Provides a service that can be used to generate a dynamic discount with a random code.
- Provides an endpoint that can be used to generate a dynamic discount with a random code.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-discount-generator
```
2\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
`medusa-plugin-discount-generator`
]
```
---
## Test the Plugin
Try using the `DiscountGeneratorService` in your code, or using the `/discount-code` endpoint to generate a random discount code.

View File

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

View File

@@ -1,47 +0,0 @@
{
"name": "medusa-plugin-discount-generator",
"version": "1.1.27",
"main": "index.js",
"license": "MIT",
"author": "Sebastian Rindom",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-discount-generator"
},
"engines": {
"node": ">=16"
},
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.0",
"randomatic": "^3.1.1"
},
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
}

View File

@@ -1,29 +0,0 @@
import { Router } from "express"
import bodyParser from "body-parser"
import { Validator, MedusaError } from "medusa-core-utils"
export default (container) => {
const route = Router()
route.post("/discount-code", bodyParser.json(), async (req, res) => {
const schema = Validator.object().keys({
discount_code: Validator.string().required(),
})
const { value, error } = schema.validate(req.body)
if (error) {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
}
const discountGenerator = req.scope.resolve("discountGeneratorService")
const code = await discountGenerator.generateDiscount(value.discount_code)
res.json({
code
})
})
return route
}

View File

@@ -1,20 +0,0 @@
import randomize from "randomatic"
import { BaseService } from "medusa-interfaces"
class DiscountGeneratorService extends BaseService {
constructor({ discountService }) {
super()
this.discountService_ = discountService
}
async generateDiscount(dynamicDiscountCode) {
const discount = await this.discountService_.retrieveByCode(dynamicDiscountCode)
const data = {
code: randomize("A0", 10)
}
return this.discountService_.createDynamicCode(discount._id, data)
}
}
export default DiscountGeneratorService

View File

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

View File

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

View File

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

View File

@@ -1,203 +0,0 @@
# Change Log
## 1.2.8
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
## 1.2.7
### Patch Changes
- [#3884](https://github.com/medusajs/medusa/pull/3884) [`440f900af`](https://github.com/medusajs/medusa/commit/440f900af03dd0af29c9b16f01576d3eff45cd04) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix(medusa-plugin-ip-lookup): Remove outdated Typeorm usage
## 1.2.6
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724)]:
- medusa-interfaces@1.3.7
## 1.2.6-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724)]:
- medusa-interfaces@1.3.7-rc.0
## 1.2.5
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-interfaces@1.3.6
## 1.2.4
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-interfaces@1.3.5
## 1.2.3
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.2.2
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.2.0...medusa-plugin-ip-lookup@1.2.1) (2022-07-05)
### Bug Fixes
- **medusa:** Remove deps `mongoose` + `mongodb` ([#1218](https://github.com/medusajs/medusa/issues/1218)) ([c76e23e](https://github.com/medusajs/medusa/commit/c76e23e84dd8cb08c3c709f9f95c4c17b9685439))
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.19...medusa-plugin-ip-lookup@1.2.0) (2022-05-01)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.18...medusa-plugin-ip-lookup@1.1.19) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.17...medusa-plugin-ip-lookup@1.1.18) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.15...medusa-plugin-ip-lookup@1.1.17) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.15...medusa-plugin-ip-lookup@1.1.16) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.14...medusa-plugin-ip-lookup@1.1.15) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.13...medusa-plugin-ip-lookup@1.1.14) (2021-09-14)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.12...medusa-plugin-ip-lookup@1.1.13) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.10...medusa-plugin-ip-lookup@1.1.12) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.10...medusa-plugin-ip-lookup@1.1.11) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.9...medusa-plugin-ip-lookup@1.1.10) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.8...medusa-plugin-ip-lookup@1.1.9) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [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
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.0...medusa-plugin-ip-lookup@1.1.3) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.1...medusa-plugin-ip-lookup@1.1.2) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.0...medusa-plugin-ip-lookup@1.1.1) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-ip-lookup
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.0.11...medusa-plugin-ip-lookup@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-ip-lookup
## 1.0.11 (2020-11-02)
### Bug Fixes
- add country code on preCartCreation ([e3faa64](https://github.com/medusajs/medusa/commit/e3faa646a7b91d2686b56718df46bea5b709731b))
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.1 (2020-09-05)
# 1.0.0 (2020-09-03)
### Bug Fixes
- remove debug ([4d575e0](https://github.com/medusajs/medusa/commit/4d575e0a263e1b131242ac97263d643217cbe140))
# 1.0.0-y.25 (2020-09-03)
### Bug Fixes
- **medusa-plugin-ip-lookup:** Adds .npmignore ([ea93943](https://github.com/medusajs/medusa/commit/ea939437f37ecd555169750ca334f1a46346248d))
# 1.0.0-y.24 (2020-09-03)
### Bug Fixes
- debug ([8920a96](https://github.com/medusajs/medusa/commit/8920a96f7caaa46b7d9fe2dbf6b06147d144c499))
# 1.0.0-y.20 (2020-09-03)
### Bug Fixes
- debug ([f0b61e7](https://github.com/medusajs/medusa/commit/f0b61e7654b010d0f9d477bc018523e972ff9ea6))
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.21 (2020-08-25)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,54 +0,0 @@
# ipstack (IP Lookup)
Automatically detect the region and location of your customer using ipstack.
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Look up the location of your customer using ipstack.
- Provides a middleware that can be added to any request to set the region and country of a cart.
- Provides a service that can be used across codebase to detect the location of a user using their IP.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [ipstack account](https://ipstack.com)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-ip-lookup
```
2\. Set the following environment variable in `.env`:
```bash
IPSTACK_ACCESS_KEY=<YOUR_ACCESS_KEY>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// other plugins...
{
resolve: `medusa-plugin-ip-lookup`,
options: {
access_token: process.env.IPSTACK_ACCESS_KEY,
},
},
]
```
---
## Test the Plugin
You can use the `IpLookupService` service to look up the location of an IP, or use the middleware `preCartCreation` on any route.

View File

@@ -1,42 +0,0 @@
{
"name": "medusa-plugin-ip-lookup",
"version": "1.2.8",
"description": "IP lookup middleware for Medusa core",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-ip-lookup"
},
"engines": {
"node": ">=16"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"author": "Oliver Juhl",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/runtime": "^7.7.6",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"axios": "^0.20.0"
},
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
}

View File

@@ -1,38 +0,0 @@
export default {
preCartCreation: async function (req, res, next) {
try {
if (req.body.region_id) {
next()
return
}
const ipLookupService = req.scope.resolve("ipLookupService")
const regionService = req.scope.resolve("regionService")
const ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress
const { data } = await ipLookupService.lookupIp(ip)
if (!data.country_code) {
next()
return
}
const region = await regionService
.retrieveByCountryCode(data.country_code)
.catch(() => void 0)
if (!region) {
next()
return
}
req.body.region_id = region.id
req.body.country_code = data.country_code.toLowerCase()
next()
} catch (error) {
next()
}
},
}

View File

@@ -1,18 +0,0 @@
import { BaseService } from "medusa-interfaces"
import axios from "axios"
class IpLookupService extends BaseService {
constructor({}, options) {
super()
this.options_ = options
}
async lookupIp(ipAddress) {
return axios.get(
`http://api.ipstack.com/${ipAddress}?access_key=${this.options_.access_token}`
)
}
}
export default IpLookupService

View File

@@ -1,12 +0,0 @@
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__`)
}
module.exports = {
presets: [["babel-preset-medusa-package"], ["@babel/preset-typescript"]],
ignore,
}

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -1,98 +0,0 @@
# Restock Notifications
Send notifications to subscribed customers when an item has been restocked.
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Triggers an event when a product variant has been restocked.
- Provides an endpoint to subscribe customers to receive restock notifications.
- Does not implement the email or notification sending mechanisms. Instead, it is compatible with Notification plugins such as [SendGrid](https://docs.medusajs.com/plugins/notifications/sendgrid).
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Redis](https://docs.medusajs.com/development/backend/prepare-environment#redis)
- [PostgreSQL](https://docs.medusajs.com/development/backend/prepare-environment#postgresql)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-restock-notification
```
2\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// other plugins...
{
resolve: `medusa-plugin-restock-notification`,
options: {
trigger_delay, // optional, delay time in milliseconds
inventory_required, // minimum inventory quantity to consider a variant as restocked
},
},
]
```
3\. Run the following command in the directory of the Medusa backend to run the plugin's migrations:
```bash
medusa migrations run
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Subscribe an email or identification username (depends on your notification service) to receive restock notifications using the endpoint `/restock-notifications/variants/<variant_id>`. `<variant_id>` is the ID of the variant you're subscribing to.
2\. Change the inventory quantity of a product variant based on the restock threshold you've set, and see the event `restock-notification.restocked` triggered.
---
## Additional Information
### API endpoint
The plugin exposes an endpoint `/restock-notifications/variants/:variant_id` to sign emails up for restock notifications. It accepts the following request body:
```json
{
"email": "customer@test.com"
}
```
The endpoint responds with `200 OK` on successful signups. If a signup for an already in stock item is attempted the endpoint will have a 400 response code.
### Restock events
The plugin listens for the `product-variant.updated` call and emits a `restock-notification.restocked` event when a variant with restock signups become available.
The data sent with the `restock-notification.restocked` event are:
- `variant_id`: The ID of the variant to listen for restock events for.
- `emails`: An array of emails that are to be notified of restocks.
For example:
```json
{
"variant_id": "variant_1234567890",
"emails": ["seb@test.com", "oli@test.com"]
}
```

View File

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

View File

@@ -1,6 +0,0 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.[jt]s?$": `../../jest-transformer.js`,
},
}

View File

@@ -1,52 +0,0 @@
{
"name": "medusa-plugin-restock-notification",
"version": "7.0.3",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-restock-notification"
},
"engines": {
"node": ">=16"
},
"author": "Sebastian Rindom <seb@medusa-commerce.com>",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-typescript": "^7.13.0",
"@babel/preset-typescript": "^7.12.7",
"@medusajs/medusa": "^1.17.1",
"babel-preset-medusa-package": "^1.1.19",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40",
"pg": "^8.5.1",
"typeorm": "^0.3.16",
"ulid": "^2.3.0"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --silent --bail --maxWorkers=50% --forceExit",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"@medusajs/medusa": "^1.12.0",
"medusa-interfaces": "^1.3.7",
"typeorm": "^0.3.16"
},
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.0"
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
"keywords": [
"medusa-plugin",
"medusa-plugin-notification"
]
}

View File

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

View File

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

View File

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

View File

@@ -1,19 +0,0 @@
export default async (req, res) => {
const { variant_id } = req.params
try {
const restockNotificationService = req.scope.resolve(
"restockNotificationService"
)
let sales_channel_id = req.body.sales_channel_id
if (req.publishableApiKeyScopes?.sales_channel_ids.length === 1) {
sales_channel_id = req.publishableApiKeyScopes.sales_channel_ids[0]
}
await restockNotificationService.addEmail(variant_id, req.body.email, sales_channel_id)
res.sendStatus(201)
} catch (err) {
res.status(400).json({ message: err.message })
}
}

View File

@@ -1,29 +0,0 @@
import { Router } from "express"
import bodyParser from "body-parser"
import cors from "cors"
import { getConfigFile, parseCorsOrigins } from "medusa-core-utils"
import middlewares from "../middleware"
const route = Router()
export default (app, rootDirectory) => {
app.use("/restock-notifications", route)
const { configModule } = getConfigFile(rootDirectory, "medusa-config")
const { projectConfig } = configModule
const corsOptions = {
origin: parseCorsOrigins(projectConfig.store_cors),
credentials: true,
}
route.options("/variants/:variant_id", cors(corsOptions))
route.post(
"/variants/:variant_id",
cors(corsOptions),
bodyParser.json(),
middlewares.wrap(require("./add-email").default)
)
return app
}

View File

@@ -1,21 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class restockNotification1617703530229 implements MigrationInterface {
name = "restockNotification1617703530229"
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "restock_notification" ("variant_id" character varying NOT NULL, "emails" jsonb NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_49181ca04caac807fcec321705a" PRIMARY KEY ("variant_id"))`
)
await queryRunner.query(
`ALTER TABLE "restock_notification" ADD CONSTRAINT "FK_49181ca04caac807fcec321705a" FOREIGN KEY ("variant_id") REFERENCES "product_variant"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "restock_notification" DROP CONSTRAINT "FK_49181ca04caac807fcec321705a"`
)
await queryRunner.query(`DROP TABLE "restock_notification"`)
}
}

View File

@@ -1,56 +0,0 @@
import {
Entity,
Index,
BeforeInsert,
Column,
DeleteDateColumn,
CreateDateColumn,
UpdateDateColumn,
PrimaryColumn,
ManyToOne,
JoinColumn,
} from "typeorm"
import { ProductVariant } from "@medusajs/medusa"
@Entity()
export class RestockNotification {
@PrimaryColumn()
variant_id: string
@ManyToOne(() => ProductVariant)
@JoinColumn({ name: "variant_id" })
variant: ProductVariant
@Column({ type: "jsonb" })
emails: string[]
@CreateDateColumn({ type: "timestamptz" })
created_at: Date
@UpdateDateColumn({ type: "timestamptz" })
updated_at: Date
}
/**
* @schema restock_notification
* title: "Restock Notification"
* description: "Holds a list of emails that wish to be notifed when an item is restocked."
* x-resourceId: restock_notification
* properties:
* variant_id:
* type: string
* description: "The id of the variant that customers have signed up to be notified about,"
* emails:
* description: "The emails of customers who wish to be notified about restocks."
* type: array
* items:
* type: string
* created_at:
* type: string
* format: date-time
* description: "The date time at which the first restock signup was made."
* updated_at:
* type: string
* format: date-time
* description: "The date time at which the first last signup was made."
*/

View File

@@ -1,265 +0,0 @@
import { MockManager, MockRepository } from "medusa-test-utils"
import RestockNotificationService from "../restock-notification"
describe("RestockNotificationService", () => {
const RestockNotificationModel = MockRepository({
findOne: (q) => {
if (q.where.variant_id === "variant_1234") {
return Promise.resolve({
variant_id: "variant_1234",
emails: ["test@tesmail.com"],
})
}
if (q.where.variant_id === "variant_outofstock") {
return Promise.resolve({
variant_id: "variant_outofstock",
emails: ["test@tesmail.com"],
})
}
if (q.where.variant_id === "variant_low_inventory") {
return Promise.resolve({
variant_id: "variant_low_inventory",
email: ["test@tesmail.com"],
})
}
return Promise.resolve()
},
})
const ProductVariantService = {
retrieve: (id) => {
if (id === "variant_instock") {
return {
id,
inventory_quantity: 10,
}
}
if (id === "variant_1234") {
return {
id,
inventory_quantity: 10,
}
}
if (id === "variant_low_inventory") {
return {
id,
inventory_quantity: 2,
}
}
return {
id,
inventory_quantity: 0,
}
},
}
const EventBusService = {
emit: jest.fn(),
withTransaction: function () {
return this
},
}
describe("retrieve", () => {
const restockNotiService = new RestockNotificationService({
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
})
it("successfully retrieves", async () => {
jest.clearAllMocks()
const result = await restockNotiService.retrieve("variant_1234")
expect(result).toEqual({
variant_id: "variant_1234",
emails: ["test@tesmail.com"],
})
})
it("successfully retrieves with empty response", async () => {
jest.clearAllMocks()
const result = await restockNotiService.retrieve("variant_non")
expect(result).toEqual(undefined)
})
})
describe("addEmail", () => {
const restockNotiService = new RestockNotificationService({
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
})
it("successfully adds email to non-existing noti", async () => {
jest.clearAllMocks()
await restockNotiService.addEmail("variant_test", "seb@med-test.com")
expect(RestockNotificationModel.create).toHaveBeenCalledTimes(1)
expect(RestockNotificationModel.create).toHaveBeenCalledWith({
variant_id: "variant_test",
emails: ["seb@med-test.com"],
})
expect(RestockNotificationModel.save).toHaveBeenCalledTimes(1)
})
it("successfully adds email to existing noti", async () => {
jest.clearAllMocks()
await restockNotiService.addEmail("variant_1234", "seb@med-test.com")
expect(RestockNotificationModel.save).toHaveBeenCalledTimes(1)
expect(RestockNotificationModel.save).toHaveBeenCalledWith({
variant_id: "variant_1234",
emails: ["test@tesmail.com", "seb@med-test.com"],
})
})
it("fails to add if in stock", async () => {
jest.clearAllMocks()
await expect(
restockNotiService.addEmail("variant_instock", "seb@med-test.com")
).rejects.toThrow(
"You cannot sign up for restock notifications on a product that is not sold out"
)
})
})
describe("triggerRestock", () => {
afterEach(() => {
jest.useRealTimers()
})
it("trigger delay default to 0", async () => {
const restockNotiService = new RestockNotificationService({
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
})
restockNotiService.restockExecute = jest.fn()
restockNotiService.triggerRestock("variant_test")
expect(restockNotiService.restockExecute).toHaveBeenCalledTimes(1)
})
it("trigger delay 10", async () => {
const restockNotiService = new RestockNotificationService(
{
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
},
{ trigger_delay: 10 }
)
restockNotiService.restockExecute = jest.fn()
restockNotiService.triggerRestock("variant_test")
expect(EventBusService.emit).toHaveBeenCalledTimes(1)
expect(EventBusService.emit).toHaveBeenCalledWith(
"restock-notification.execute",
{ variant_id: "variant_test" },
{ delay: 10 }
)
})
})
describe("restockExecute", () => {
const restockNotiService = new RestockNotificationService({
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
})
it("non-existing noti does nothing", async () => {
jest.clearAllMocks()
await expect(restockNotiService.restockExecute("variant_test")).resolves
})
it("existing noti but out of stock does nothing", async () => {
jest.clearAllMocks()
await expect(restockNotiService.restockExecute("variant_outofstock"))
.resolves
})
it("existing noti emits and deletes", async () => {
jest.clearAllMocks()
await restockNotiService.restockExecute("variant_1234")
expect(EventBusService.emit).toHaveBeenCalledTimes(1)
expect(EventBusService.emit).toHaveBeenCalledWith(
"restock-notification.restocked",
{
variant_id: "variant_1234",
emails: ["test@tesmail.com"],
}
)
expect(RestockNotificationModel.delete).toHaveBeenCalledTimes(1)
expect(RestockNotificationModel.delete).toHaveBeenCalledWith(
"variant_1234"
)
})
it("options inventory_required takes precedence if given", async () => {
jest.clearAllMocks()
const service = new RestockNotificationService(
{
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
},
{ inventory_required: 5 }
)
await service.restockExecute("variant_1234")
expect(EventBusService.emit).toHaveBeenCalledTimes(1)
expect(EventBusService.emit).toHaveBeenCalledWith(
"restock-notification.restocked",
{
variant_id: "variant_1234",
emails: ["test@tesmail.com"],
}
)
expect(RestockNotificationModel.delete).toHaveBeenCalledTimes(1)
expect(RestockNotificationModel.delete).toHaveBeenCalledWith(
"variant_1234"
)
})
it("Inventory requires 5, wont emit when called with variant inventory 2", async () => {
jest.clearAllMocks()
const service = new RestockNotificationService(
{
manager: MockManager,
productVariantService: ProductVariantService,
restockNotificationModel: RestockNotificationModel,
eventBusService: EventBusService,
},
{ inventory_required: 5 }
)
await service.restockExecute("variant_low_inventory")
expect(EventBusService.emit).toHaveBeenCalledTimes(0)
expect(RestockNotificationModel.delete).toHaveBeenCalledTimes(0)
})
})
})

View File

@@ -1,168 +0,0 @@
import { MedusaError } from "medusa-core-utils"
import { BaseService } from "medusa-interfaces"
/**
* Restock notifications can be used to keep track of customers who wish to be
* notified when a certain item is restocked. Restock notifications can only
* apply to sold out items and will be deleted once items are restocked.
*/
class RestockNotificationService extends BaseService {
constructor(
{
manager,
eventBusService,
productVariantService,
productVariantInventoryService,
restockNotificationModel,
},
options
) {
super()
this.manager_ = manager
this.options_ = options
this.productVariantService_ = productVariantService
this.productVariantInventoryService_ = productVariantInventoryService
this.restockNotificationModel_ = restockNotificationModel
this.eventBus_ = eventBusService
}
withTransaction(transactionManager) {
if (!transactionManager) {
return this
}
const cloned = new RestockNotificationService(
{
manager: transactionManager,
options: this.options_,
eventBusService: this.eventBus_,
productVariantService: this.productVariantService_,
restockNotificationModel: this.restockNotificationModel_,
},
this.options_
)
cloned.transactionManager_ = transactionManager
return cloned
}
/**
* Retrieves a restock notification by a given variant id.
* @param {string} variantId - the variant id to retrieve restock notification
* for
* @return {Promise<RestockNotification>} The restock notification
*/
async retrieve(variantId) {
const restockRepo = this.manager_.getRepository(
this.restockNotificationModel_
)
return await restockRepo.findOne({ where: { variant_id: variantId } })
}
/**
* Adds an email to be notified when a certain variant is restocked. Throws if
* the variant is not sold out.
* @param {string} variantId - the variant id to sign up for notifications for
* @param {string} email - the email to signup
* @param {string} salesChannelId - the sales channel id of the variant
* @return {Promise<RestockNotification>} The resulting restock notification
*/
async addEmail(variantId, email, salesChannelId) {
return this.atomicPhase_(async (manager) => {
const restockRepo = manager.getRepository(this.restockNotificationModel_)
const existing = await this.retrieve(variantId)
if (existing) {
// Converting to a set handles duplicates for us
const emailSet = new Set(existing.emails)
emailSet.add(email)
existing.emails = Array.from(emailSet)
return await restockRepo.save(existing)
} else {
let variant = await this.productVariantService_.retrieve(variantId)
if (salesChannelId) {
const variants =
await this.productVariantInventoryService_.setVariantAvailability(
[variant],
salesChannelId
)
if (variants.length) {
variant = variants[0]
}
}
if (variant.inventory_quantity > 0) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
"You cannot sign up for restock notifications on a product that is not sold out"
)
}
const created = restockRepo.create({
variant_id: variant.id,
emails: [email],
})
return await restockRepo.save(created)
}
})
}
/**
* Checks if anyone has signed up for restock notifications on a given variant
* and emits a restocked event to the event bus. After successful emission the
* restock notification is deleted.
* @param {string} variantId - the variant id to trigger restock for
* @return The resulting restock notification
*/
async triggerRestock(variantId) {
const delay = this.options_?.trigger_delay ?? 0
if (delay) {
return await this.eventBus_.emit(
"restock-notification.execute",
{ variant_id: variantId },
{ delay }
)
}
return await this.restockExecute(variantId)
}
async restockExecute(variantId) {
return await this.atomicPhase_(async (manager) => {
const restockRepo = manager.getRepository(this.restockNotificationModel_)
const existing = await this.retrieve(variantId)
if (!existing) {
return
}
const variant = await this.productVariantService_.retrieve(variantId)
if (
variant.inventory_quantity > (this.options_?.inventory_required ?? 0)
) {
await this.eventBus_
.withTransaction(manager)
.emit("restock-notification.restocked", {
variant_id: variantId,
emails: existing.emails,
})
await restockRepo.delete(variantId)
}
})
}
}
export default RestockNotificationService

View File

@@ -1,37 +0,0 @@
class VariantSubscriber {
constructor({ manager, eventBusService, restockNotificationService }) {
this.manager_ = manager
this.restockNotificationService_ = restockNotificationService
eventBusService.subscribe(
"product-variant.updated",
this.handleVariantUpdate
)
eventBusService.subscribe(
"restock-notification.execute",
this.handleDelayedExecute
)
}
handleDelayedExecute = async (data) => {
const { variant_id } = data
return await this.restockNotificationService_.restockExecute(variant_id)
}
handleVariantUpdate = async (data) => {
const { id, fields } = data
if (fields.includes("inventory_quantity")) {
return await this.manager_.transaction(
async (m) =>
await this.restockNotificationService_
.withTransaction(m)
.triggerRestock(id)
)
}
return Promise.resolve()
}
}
export default VariantSubscriber

View File

@@ -1,15 +0,0 @@
{
"compilerOptions": {
"lib": [
"es5",
"es6"
],
"target": "es5",
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true
}
}

View File

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

View File

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

View File

@@ -1,391 +0,0 @@
# Change Log
## 1.3.7
### Patch Changes
- [#4389](https://github.com/medusajs/medusa/pull/4389) [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa, utils): fix the way selects are consumed alongside the relations
## 1.3.6
### Patch Changes
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
## 1.3.5
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
- medusa-test-utils@1.1.40
## 1.3.5-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
- medusa-test-utils@1.1.40-rc.0
## 1.3.4
### Patch Changes
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.3.3
### Patch Changes
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.3.2
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.3.1
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.3.0](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.2.1...medusa-plugin-segment@1.3.0) (2022-05-01)
### Bug Fixes
- ensure customer identify calls before order track ([#1227](https://github.com/medusajs/medusa/issues/1227)) ([fbe3b98](https://github.com/medusajs/medusa/commit/fbe3b987618d28325938e8fe6264b01d4d581c71))
### Features
- Add DiscountConditions ([#1230](https://github.com/medusajs/medusa/issues/1230)) ([a610805](https://github.com/medusajs/medusa/commit/a610805917ee930d4cebde74905e541a468aa83b)), closes [#1146](https://github.com/medusajs/medusa/issues/1146) [#1149](https://github.com/medusajs/medusa/issues/1149) [#1156](https://github.com/medusajs/medusa/issues/1156) [#1170](https://github.com/medusajs/medusa/issues/1170) [#1172](https://github.com/medusajs/medusa/issues/1172) [#1212](https://github.com/medusajs/medusa/issues/1212) [#1224](https://github.com/medusajs/medusa/issues/1224) [#1228](https://github.com/medusajs/medusa/issues/1228)
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.42...medusa-plugin-segment@1.2.1) (2022-02-28)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([47588e7](https://github.com/medusajs/medusa/commit/47588e7a8d3b2ae2fed0c1e87fdf1ee2db6bcdc2)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.42...medusa-plugin-segment@1.2.0) (2022-02-25)
### Features
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([c56660f](https://github.com/medusajs/medusa/commit/c56660fca9921a3f3637bc137d9794781c5b090f)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
## [1.1.42](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.41...medusa-plugin-segment@1.1.42) (2022-02-06)
### Bug Fixes
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
## [1.1.41](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.40...medusa-plugin-segment@1.1.41) (2022-02-06)
### Features
- medusa-react admin hooks ([#978](https://github.com/medusajs/medusa/issues/978)) ([2e38484](https://github.com/medusajs/medusa/commit/2e384842d5b2e9742a86b96f28a8f00357795b86)), closes [#1019](https://github.com/medusajs/medusa/issues/1019)
## [1.1.40](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.39...medusa-plugin-segment@1.1.40) (2022-01-11)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.39](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.38...medusa-plugin-segment@1.1.39) (2021-12-29)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.37...medusa-plugin-segment@1.1.38) (2021-12-17)
### Features
- add medusa-react ([#913](https://github.com/medusajs/medusa/issues/913)) ([d0d8dd7](https://github.com/medusajs/medusa/commit/d0d8dd7bf62eaac71df8714c2dfb4f204d192f51))
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.36...medusa-plugin-segment@1.1.37) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.35...medusa-plugin-segment@1.1.36) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.34...medusa-plugin-segment@1.1.35) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.33...medusa-plugin-segment@1.1.34) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.32...medusa-plugin-segment@1.1.33) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.31...medusa-plugin-segment@1.1.32) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.30...medusa-plugin-segment@1.1.31) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.28...medusa-plugin-segment@1.1.30) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.28...medusa-plugin-segment@1.1.29) (2021-10-18)
### Features
- allow product selection on discounts allocated to a specific item ([#395](https://github.com/medusajs/medusa/issues/395)) ([84d4d79](https://github.com/medusajs/medusa/commit/84d4d791eaf9508367a20d9f930ca959a7b707dd))
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.27...medusa-plugin-segment@1.1.28) (2021-09-15)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.26...medusa-plugin-segment@1.1.27) (2021-09-14)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.25...medusa-plugin-segment@1.1.26) (2021-08-05)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.24...medusa-plugin-segment@1.1.25) (2021-07-26)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.22...medusa-plugin-segment@1.1.24) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.22...medusa-plugin-segment@1.1.23) (2021-07-15)
### Bug Fixes
- sends return reasons to segment on Order Refunded event ([55ba9ba](https://github.com/medusajs/medusa/commit/55ba9bae05527d602d654f99d678b610c5ba7229))
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.21...medusa-plugin-segment@1.1.22) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.20...medusa-plugin-segment@1.1.21) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [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
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.12...medusa-plugin-segment@1.1.15) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.13...medusa-plugin-segment@1.1.14) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.12...medusa-plugin-segment@1.1.13) (2021-04-20)
### Features
- **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345))
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.11...medusa-plugin-segment@1.1.12) (2021-04-13)
### Bug Fixes
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
- **segment:** swap tracking ([295f0f6](https://github.com/medusajs/medusa/commit/295f0f652a0880292a3788b9c65476a3c5c1b8d4))
- scaffolding ([0539a94](https://github.com/medusajs/medusa/commit/0539a949fa208ddbf140823c47abb7589f3c2401))
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.10...medusa-plugin-segment@1.1.11) (2021-04-13)
### Bug Fixes
- **segment:** swap tracking ([295f0f6](https://github.com/medusajs/medusa/commit/295f0f652a0880292a3788b9c65476a3c5c1b8d4))
- scaffolding ([0539a94](https://github.com/medusajs/medusa/commit/0539a949fa208ddbf140823c47abb7589f3c2401))
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.9...medusa-plugin-segment@1.1.10) (2021-04-02)
### Bug Fixes
- adds exchange rates api key ([8eec38a](https://github.com/medusajs/medusa/commit/8eec38af7164fe60106b8dac33ae9acfeb2b0f2e))
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.8...medusa-plugin-segment@1.1.9) (2021-03-30)
### Bug Fixes
- adds tests for segment ([1b00f96](https://github.com/medusajs/medusa/commit/1b00f967dea3dc3aa65fafbe1334492fba5c33c2))
- don't divide zero decimal currencies ([3258955](https://github.com/medusajs/medusa/commit/3258955b462f91fc6f4d807c5cc9b5ad11d6bbdf))
- don't divide zero decimal currencies ([cfab2d4](https://github.com/medusajs/medusa/commit/cfab2d408a296a938266d0989b1de67d060b2ed5))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.7...medusa-plugin-segment@1.1.8) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5...medusa-plugin-segment@1.1.7) (2021-03-17)
### Features
- **medusa:** cart context ([#201](https://github.com/medusajs/medusa/issues/201)) ([dd7b306](https://github.com/medusajs/medusa/commit/dd7b306333fbe1042f5cf2bed614bce84ea9475f))
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5...medusa-plugin-segment@1.1.6) (2021-03-17)
### Features
- **medusa:** cart context ([#201](https://github.com/medusajs/medusa/issues/201)) ([dd7b306](https://github.com/medusajs/medusa/commit/dd7b306333fbe1042f5cf2bed614bce84ea9475f))
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5-next.3...medusa-plugin-segment@1.1.5) (2021-02-25)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.5-next.3](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5-next.2...medusa-plugin-segment@1.1.5-next.3) (2021-02-25)
### Bug Fixes
- normalize currency code ([98aa404](https://github.com/medusajs/medusa/commit/98aa404306d55f0818d48e56c51146351ebfe306))
## [1.1.5-next.2](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5-next.1...medusa-plugin-segment@1.1.5-next.2) (2021-02-25)
### Features
- **segment:** track shipments ([d156911](https://github.com/medusajs/medusa/commit/d15691188348c19fc22806d8cf7584fc5f249ce9))
## [1.1.5-next.1](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.5-next.0...medusa-plugin-segment@1.1.5-next.1) (2021-02-25)
### Bug Fixes
- add subtitle to tracks ([0c294b7](https://github.com/medusajs/medusa/commit/0c294b7b3acbc1b873aab7e90a8e596bdac48899))
- versioning ([262af34](https://github.com/medusajs/medusa/commit/262af34125543d9a80bf469b5d380019b9bc8d3f))
## [1.1.5-next.0](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.4...medusa-plugin-segment@1.1.5-next.0) (2021-02-22)
### Features
- **medusa-plugin-segment:** adds category and type to segment events ([#179](https://github.com/medusajs/medusa/issues/179)) ([e27cf72](https://github.com/medusajs/medusa/commit/e27cf72a8ca49a6586a82dde964d559c40a4415f))
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.3...medusa-plugin-segment@1.1.4) (2021-02-17)
### Bug Fixes
- item reporting revenue discounted ([6e6669d](https://github.com/medusajs/medusa/commit/6e6669dee8cb3f7e044a4001fa1e183bb61766dd))
- price after discounts ([0ed6b4a](https://github.com/medusajs/medusa/commit/0ed6b4a6a09d1d2ef5c9d6a199db1e01234bc3c2))
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.2...medusa-plugin-segment@1.1.3) (2021-02-03)
### Features
- **medusa,brightpearl,segment,webshipper:** claims ([#163](https://github.com/medusajs/medusa/issues/163)) ([690d339](https://github.com/medusajs/medusa/commit/690d33966754a7dbe159c3ac09712a3c3bfaff0b))
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.1...medusa-plugin-segment@1.1.2) (2021-02-01)
**Note:** Version bump only for package medusa-plugin-segment
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.0...medusa-plugin-segment@1.1.1) (2021-01-27)
**Note:** Version bump only for package medusa-plugin-segment
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.16...medusa-plugin-segment@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-segment
## [1.0.16](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.15...medusa-plugin-segment@1.0.16) (2021-01-08)
**Note:** Version bump only for package medusa-plugin-segment
## [1.0.15](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.14...medusa-plugin-segment@1.0.15) (2020-12-17)
**Note:** Version bump only for package medusa-plugin-segment
## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.13...medusa-plugin-segment@1.0.14) (2020-11-24)
**Note:** Version bump only for package medusa-plugin-segment
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.12...medusa-plugin-segment@1.0.13) (2020-10-19)
**Note:** Version bump only for package medusa-plugin-segment
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.0.11...medusa-plugin-segment@1.0.12) (2020-10-17)
**Note:** Version bump only for package medusa-plugin-segment
## 1.0.11 (2020-09-13)
### Bug Fixes
- **medusa-plugin-segment:** Track additional order details ([6a90e94](https://github.com/medusajs/medusa/commit/6a90e94c62f5e300fe970ac5d6b64c8c0e52eb40))
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,65 +0,0 @@
# Segment
Track essential commerce analytics with Segment.
[Segment Plugin Documentation](https://docs.medusajs.com/plugins/analytics/segment) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Automatic analytics tracking for events related to Orders, Swaps, and Claims.
- Flexibility to track analytics for custom events or operations.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Segment account](https://app.segment.com/signup)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-segment
```
2\. Set the following environment variable in `.env`:
```bash
SEGMENT_WRITE_KEY=<YOUR_SEGMENT_WRITE_KEY>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
{
resolve: `medusa-plugin-segment`,
options: {
write_key: process.env.SEGMENT_WRITE_KEY,
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should see the event tracked in Segment.
---
## Additional Resources
- [Segment Plugin Documentation](https://docs.medusajs.com/plugins/analytics/segment)

View File

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

View File

@@ -1,6 +0,0 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.[jt]s?$": `../../jest-transformer.js`,
},
}

View File

@@ -1,45 +0,0 @@
{
"name": "medusa-plugin-segment",
"version": "1.3.7",
"description": "Segment Analytics",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-segment"
},
"engines": {
"node": ">=16"
},
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"cross-env": "^5.2.1",
"eslint": "^6.8.0",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40",
"rimraf": "^5.0.1",
"typescript": "^4.9.5"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"test": "jest --passWithNoTests src",
"build": "rimraf dist && tsc -p ./tsconfig.server.json",
"watch": "tsc --watch"
},
"peerDependencies": {
"@medusajs/medusa": ">= 1.18.0 < 2",
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"analytics-node": "^3.4.0-beta.1",
"axios": "^0.19.2",
"medusa-core-utils": "^1.2.0"
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
"keywords": [
"medusa-plugin",
"medusa-plugin-analytics"
]
}

View File

@@ -1,253 +0,0 @@
import SegmentService from "../segment"
jest.mock("analytics-node")
const orderFactory = (config = {}) => {
return {
id: "12355",
display_id: "1234",
cart_id: "cart_13",
region_id: "reg_123",
items: [
{
title: "Test",
variant: {
product_id: "prod_123",
sku: "TEST",
},
unit_price: 1100,
quantity: 2,
},
],
shipping_methods: [
{
name: "standard",
price: 12399,
},
],
payments: [
{
id: "123",
},
],
tax_rate: 23.1,
currency_code: "DKK",
discounts: [],
shipping_address: {
first_name: "Test",
last_name: "Testson",
address_1: "Test",
address_2: "TEst",
postal_code: "1234",
country_code: "DK",
phone: "12345678",
},
email: "test@example.com",
subtotal: 2200,
total: 12399,
tax_total: 0,
shipping_total: 12399,
discount_total: 0,
gift_card_total: 0,
...config,
}
}
describe("SegmentService", () => {
const ProductService = {
retrieve: () =>
Promise.resolve({
collection: { title: "Collection" },
type: { value: "Type" },
subtitle: "Subtitle",
}),
}
const TotalsService = {
getLineItemTotals: (item) => {
return {
total: item.unit_price,
tax_total: 0,
}
},
}
describe("buildOrder", () => {
const segmentService = new SegmentService(
{
productService: ProductService,
totalsService: TotalsService,
},
{ account: "test" }
)
segmentService.getReportingValue = async (_, v) => {
const num = v
return Promise.resolve(Number(Math.round(num + "e2") + "e-2"))
}
it("successfully builds sales order", async () => {
jest.clearAllMocks()
const order = orderFactory()
const segmentOrder = await segmentService.buildOrder(order)
expect(segmentOrder).toEqual({
checkout_id: "cart_13",
coupon: undefined,
currency: "DKK",
discount: 0,
email: "test@example.com",
order_id: "12355",
payment_provider: "",
products: [
{
category: "Collection",
name: "Test",
price: 5.5,
product_id: "prod_123",
quantity: 2,
reporting_revenue: 11,
sku: "",
subtitle: "Subtitle",
type: "Type",
variant: "TEST",
},
],
region_id: "reg_123",
reporting_discount: 0,
reporting_revenue: 123.99,
reporting_shipping: 123.99,
reporting_subtotal: 22,
reporting_tax: 0,
reporting_total: 123.99,
revenue: 123.99,
shipping: 123.99,
shipping_city: undefined,
shipping_country: "DK",
shipping_methods: [
{
name: "standard",
price: 12399,
},
],
subtotal: 22,
tax: 0,
total: 123.99,
})
})
it("successfully adds return reason and note on buildOrder", async () => {
jest.clearAllMocks()
const order = orderFactory()
order.items = order.items.map((i) => {
i.note = "testing 1234"
i.reason = {
value: "test_reason",
id: "rr_test",
}
return i
})
const segmentOrder = await segmentService.buildOrder(order)
expect(segmentOrder).toEqual({
checkout_id: "cart_13",
coupon: undefined,
currency: "DKK",
discount: 0,
email: "test@example.com",
order_id: "12355",
payment_provider: "",
products: [
{
category: "Collection",
name: "Test",
price: 5.5,
product_id: "prod_123",
quantity: 2,
reporting_revenue: 11,
sku: "",
subtitle: "Subtitle",
type: "Type",
variant: "TEST",
reason_id: "rr_test",
reason_value: "test_reason",
note: "testing 1234",
},
],
region_id: "reg_123",
reporting_discount: 0,
reporting_revenue: 123.99,
reporting_shipping: 123.99,
reporting_subtotal: 22,
reporting_tax: 0,
reporting_total: 123.99,
revenue: 123.99,
shipping: 123.99,
shipping_city: undefined,
shipping_country: "DK",
shipping_methods: [
{
name: "standard",
price: 12399,
},
],
subtotal: 22,
tax: 0,
total: 123.99,
})
})
it("successfully builds order with zero decimal currency", async () => {
jest.clearAllMocks()
const order = orderFactory({ currency_code: "krw" })
const segmentOrder = await segmentService.buildOrder(order)
expect(segmentOrder).toEqual({
checkout_id: "cart_13",
coupon: undefined,
currency: "KRW",
discount: 0,
email: "test@example.com",
order_id: "12355",
payment_provider: "",
products: [
{
category: "Collection",
name: "Test",
price: 550,
product_id: "prod_123",
quantity: 2,
reporting_revenue: 1100,
sku: "",
subtitle: "Subtitle",
type: "Type",
variant: "TEST",
},
],
region_id: "reg_123",
reporting_discount: 0,
reporting_revenue: 12399,
reporting_shipping: 12399,
reporting_subtotal: 2200,
reporting_tax: 0,
reporting_total: 12399,
revenue: 12399,
shipping: 12399,
shipping_city: undefined,
shipping_country: "DK",
shipping_methods: [
{
name: "standard",
price: 12399,
},
],
subtotal: 2200,
tax: 0,
total: 12399,
})
})
})
})

View File

@@ -1,184 +0,0 @@
import Analytics from "analytics-node"
import axios from "axios"
import { BaseService } from "medusa-interfaces"
import { humanizeAmount } from "medusa-core-utils"
class SegmentService extends BaseService {
/**
* @param {Object} options - options defined in `medusa-config.js`
* e.g.
* {
* write_key: Segment write key given in Segment dashboard
* use_ga_id: If set to true the plugin will look for a ga_id in the cart
* context if present this id will be used as the Google Analytics
* client id.
* }
*/
constructor({ totalsService, productService }, options) {
super()
this.totalsService_ = totalsService
this.options_ = options
this.productService_ = productService
this.analytics_ = new Analytics(options.write_key)
}
/**
* Wrapper around segment's identify call
*/
identify(data) {
return this.analytics_.identify(data)
}
track(data) {
return this.analytics_.track(data)
}
async getReportingValue(rawCurrency, value) {
const fromCurrency = rawCurrency.toUpperCase()
const date = "latest"
const toCurrency =
(this.options_.reporting_currency &&
this.options_.reporting_currency.toUpperCase()) ||
"EUR"
if (fromCurrency === toCurrency) {
return this.rounded_(value)
}
const exchangeRate = await axios
.get(
`https://api.exchangeratesapi.io/${date}?symbols=${fromCurrency}&base=${toCurrency}&access_key=${this.options_.exchange_rates_api_key}`
)
.then(({ data }) => {
return data.rates[fromCurrency]
})
return this.rounded_(value / exchangeRate)
}
async buildOrder(order) {
const curr = order.currency_code
const subtotal = humanizeAmount(order.subtotal, curr)
const total = humanizeAmount(order.total, curr)
const tax = humanizeAmount(order.tax_total, curr)
const discount = humanizeAmount(order.discount_total, curr)
const shipping = humanizeAmount(order.shipping_total, curr)
const revenue = total - tax
let coupon
if (order.discounts && order.discounts.length) {
coupon = order.discounts[0] && order.discounts[0].code
}
const orderData = {
checkout_id: order.cart_id,
order_id: order.id,
email: order.email,
region_id: order.region_id,
payment_provider: order.payments?.map((p) => p.provider_id).join(","),
shipping_methods: order.shipping_methods,
shipping_country: order.shipping_address?.country_code,
shipping_city: order.shipping_address?.city,
reporting_total: await this.getReportingValue(order.currency_code, total),
reporting_subtotal: await this.getReportingValue(
order.currency_code,
subtotal
),
reporting_revenue: await this.getReportingValue(
order.currency_code,
revenue
),
reporting_shipping: await this.getReportingValue(
order.currency_code,
shipping
),
reporting_tax: await this.getReportingValue(order.currency_code, tax),
reporting_discount: await this.getReportingValue(
order.currency_code,
discount
),
total,
subtotal,
revenue,
shipping,
tax,
discount,
coupon,
currency: order.currency_code.toUpperCase(),
products: await Promise.all(
order.items.map(async (item) => {
let name = item.title
const totals = await this.totalsService_.getLineItemTotals(
item,
order,
{
include_tax: true,
}
)
const lineTotal = totals.total - totals.tax_total
const revenue = await this.getReportingValue(
curr,
humanizeAmount(lineTotal, curr)
)
let sku = ""
let variant = ""
if (item.variant && item.variant.sku) {
let skuParts = item.variant.sku.split("-")
skuParts.pop()
sku = skuParts.join("-")
variant = item.variant.sku
}
const product = await this.productService_.retrieve(
item.variant.product_id,
{ relations: ["collection", "type"] }
)
const toReturn = {
name,
variant,
price: this.rounded_(
humanizeAmount(lineTotal, curr) / item.quantity
),
reporting_revenue: revenue,
product_id: item.variant.product_id,
category: product.collection?.title,
subtitle: product.subtitle,
type: product.type?.value,
sku,
quantity: item.quantity,
}
// If we are building a refund order include details about
// the reason for return
if (item.reason) {
toReturn.reason_id = item.reason.id
toReturn.reason_value = item.reason.value
}
if (item.note) {
toReturn.note = item.note
}
return toReturn
})
),
}
return orderData
}
rounded_(v) {
return Number(Math.round(v + "e2") + "e-2")
}
}
export default SegmentService

View File

@@ -1,46 +0,0 @@
export default async function handler({ data: { id }, container }) {
const segmentService = container.resolve("segmentService")
const claimService = container.resolve("claimService")
const claim = await claimService.retrieve(id, {
relations: [
"order",
"claim_items",
"claim_items.item",
"claim_items.tags",
"claim_items.variant",
],
})
for (const ci of claim.claim_items) {
const price = ci.item.unit_price / 100
const reporting_price = await segmentService.getReportingValue(
claim.order.currency_code,
price
)
const event = {
event: "Item Claimed",
userId: claim.order.customer_id,
timestamp: claim.created_at,
properties: {
price,
reporting_price,
order_id: claim.order_id,
claim_id: claim.id,
claim_item_id: ci.id,
type: claim.type,
quantity: ci.quantity,
variant: ci.variant.sku,
product_id: ci.variant.product_id,
reason: ci.reason,
note: ci.note,
tags: ci.tags.map((t) => ({ id: t.id, value: t.value })),
},
}
await segmentService.track(event)
}
}
export const config = {
event: "claim.created",
}

View File

@@ -1,21 +0,0 @@
export default async function handler({ data: { id }, container }) {
const orderService = container.resolve("orderService")
const segmentService = container.resolve("segmentService")
const order = await orderService.retrieveWithTotals(id)
const date = new Date()
const orderData = await segmentService.buildOrder(order)
const orderEvent = {
event: "Order Cancelled",
userId: order.customer_id,
properties: orderData,
timestamp: date,
}
segmentService.track(orderEvent)
}
export const config = {
event: "order.canceled",
}

View File

@@ -1,82 +0,0 @@
export default async function handler({ data: { id, return_id }, container }) {
const orderService = container.resolve("orderService")
const returnService = container.resolve("returnService")
const segmentService = container.resolve("segmentService")
const order = await orderService.retrieveWithTotals(id, {
relations: [
"customer",
"billing_address",
"shipping_address",
"discounts",
"discounts.rule",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
"fulfillments",
"returns",
"items",
"gift_cards",
"gift_card_transactions",
"swaps",
"swaps.return_order",
"swaps.payment",
"swaps.shipping_methods",
"swaps.shipping_methods.shipping_option",
"swaps.shipping_address",
"swaps.additional_items",
"swaps.fulfillments",
],
})
const ret = await returnService.retrieve(return_id, {
relations: ["items", "items.reason"],
})
const shipping: object[] = []
if (ret.shipping_method && ret.shipping_method.price) {
shipping.push({
...ret.shipping_method,
price: -1 * (ret.shipping_method.price / 100),
})
}
let merged = [...order.items]
// merge items from order with items from order swaps
if (order.swaps && order.swaps.length) {
for (const s of order.swaps) {
merged = [...merged, ...s.additional_items]
}
}
const toBuildFrom = {
...order,
shipping_methods: shipping,
items: ret.items.map((i) => {
const li = merged.find((l) => l.id === i.item_id)
if (i.reason) {
li.reason = i.reason
}
if (i.note) {
li.note = i.note
}
return li
}),
}
const orderData = await segmentService.buildOrder(toBuildFrom)
const orderEvent = {
event: "Order Refunded",
userId: order.customer_id,
properties: orderData,
timestamp: new Date(),
}
segmentService.track(orderEvent)
}
export const config = {
event: "order.items-returned",
}

View File

@@ -1,87 +0,0 @@
export default async function handler({ data: { id }, container }) {
const orderService = container.resolve("orderService")
const cartService = container.resolve("cartService")
const segmentService = container.resolve("segmentService")
const order = await orderService.retrieveWithTotals(id, {
relations: [
"customer",
"billing_address",
"shipping_address",
"discounts",
"discounts.rule",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
"fulfillments",
"items",
"returns",
"gift_cards",
"gift_card_transactions",
"swaps",
"swaps.return_order",
"swaps.payment",
"swaps.shipping_methods",
"swaps.shipping_methods.shipping_option",
"swaps.shipping_address",
"swaps.additional_items",
"swaps.fulfillments",
],
})
const eventContext: Record<string, unknown> = {}
const integrations: Record<string, unknown> = {}
if (order.cart_id) {
try {
const cart = await cartService.retrieve(order.cart_id, {
select: ["context"],
})
if (cart.context) {
if (cart.context.ip) {
eventContext.ip = cart.context.ip
}
if (cart.context.user_agent) {
eventContext.user_agent = cart.context.user_agent
}
if (segmentService.options_ && segmentService.options_.use_ga_id) {
if (cart.context.ga_id) {
integrations["Google Analytics"] = {
clientId: cart.context.ga_id,
}
}
}
}
} catch (err) {
console.log(err)
console.warn("Failed to gather context for order")
}
}
const orderData = await segmentService.buildOrder(order)
const orderEvent = {
event: "Order Completed",
userId: order.customer_id,
properties: orderData,
timestamp: order.created_at,
context: eventContext,
integrations,
}
segmentService.identify({
userId: order.customer_id,
traits: {
email: order.email,
firstName: order.shipping_address.first_name,
lastName: order.shipping_address.last_name,
},
})
segmentService.track(orderEvent)
}
export const config = {
event: "order.placed",
}

View File

@@ -1,60 +0,0 @@
export default async function handler({
data: { id, fulfillment_id },
container,
}) {
const orderService = container.resolve("orderService")
const fulfillmentService = container.resolve("fulfillmentService")
const segmentService = container.resolve("segmentService")
const order = await orderService.retrieveWithTotals(id, {
relations: [
"customer",
"billing_address",
"shipping_address",
"discounts",
"discounts.rule",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
"fulfillments",
"returns",
"items",
"gift_cards",
"gift_card_transactions",
"swaps",
"swaps.return_order",
"swaps.payment",
"swaps.shipping_methods",
"swaps.shipping_methods.shipping_option",
"swaps.shipping_address",
"swaps.additional_items",
"swaps.fulfillments",
],
})
const fulfillment = await fulfillmentService.retrieve(fulfillment_id, {
relations: ["items"],
})
const toBuildFrom = {
...order,
provider_id: fulfillment.provider,
items: fulfillment.items.map((i) =>
order.items.find((l) => l.id === i.item_id)
),
}
const orderData = await segmentService.buildOrder(toBuildFrom)
const orderEvent = {
event: "Order Shipped",
userId: order.customer_id,
properties: orderData,
timestamp: fulfillment.shipped_at,
}
segmentService.track(orderEvent)
}
export const config = {
event: "order.shipment_created",
}

View File

@@ -1,24 +0,0 @@
import { gatherSwapReport } from "../utils/gather-swap-report"
export default async function handler({ data: { id }, container }) {
const swapService = container.resolve("swapService")
const segmentService = container.resolve("segmentService")
const lineItemService = container.resolve("lineItemService")
const [swap, swapReport] = await gatherSwapReport(id, {
swapService,
segmentService,
lineItemService,
})
return await segmentService.track({
event: "Swap Created",
userId: swap.order.customer_id,
timestamp: swap.created_at,
properties: swapReport,
})
}
export const config = {
event: "swap.created",
}

View File

@@ -1,36 +0,0 @@
import { humanizeAmount } from "medusa-core-utils"
import { gatherSwapReport } from "../utils/gather-swap-report"
export default async function handler({ data: { id }, container }) {
const swapService = container.resolve("swapService")
const segmentService = container.resolve("segmentService")
const lineItemService = container.resolve("lineItemService")
const [swap, swapReport] = await gatherSwapReport(id, {
swapService,
segmentService,
lineItemService,
})
const currency = swapReport.currency
const total = humanizeAmount(swap.difference_due, currency)
const reporting_total = await segmentService.getReportingValue(
currency,
total
)
return await segmentService.track({
event: "Swap Confirmed",
userId: swap.order.customer_id,
timestamp: swap.confirmed_at,
properties: {
reporting_total,
total,
...swapReport,
},
})
}
export const config = {
event: "swap.payment_completed",
}

View File

@@ -1,41 +0,0 @@
import { humanizeAmount } from "medusa-core-utils"
import { gatherSwapReport } from "../utils/gather-swap-report"
export default async function handler({
data: { id, fulfillment_id },
container,
}) {
const segmentService = container.resolve("segmentService")
const fulfillmentService = container.resolve("fulfillmentService")
const swapService = container.resolve("swapService")
const lineItemService = container.resolve("lineItemService")
const [swap, swapReport] = await gatherSwapReport(id, {
swapService,
segmentService,
lineItemService,
})
const fulfillment = await fulfillmentService.retrieve(fulfillment_id)
const currency = swapReport.currency
const total = humanizeAmount(swap.difference_due, currency)
const reporting_total = await segmentService.getReportingValue(
currency,
total
)
return await segmentService.track({
event: "Swap Shipped",
userId: swap.order.customer_id,
timestamp: fulfillment.shipped_at,
properties: {
reporting_total,
total,
...swapReport,
},
})
}
export const config = {
event: "swap.shipment_created",
}

View File

@@ -1,71 +0,0 @@
import { humanizeAmount } from "medusa-core-utils"
export async function gatherSwapReport(
id,
{ swapService, segmentService, lineItemService }
) {
const swap = await swapService.retrieve(id, {
relations: [
"order",
"additional_items",
"additional_items.variant",
"return_order",
"return_order.items",
"return_order.shipping_method",
],
})
const currency = swap.order.currency_code
const newItems = await Promise.all(
swap.additional_items.map(async (i) => {
const price = humanizeAmount(i.unit_price, currency)
const reporting_price = await segmentService.getReportingValue(
currency,
price
)
return {
name: i.title,
product_id: i.variant.product_id,
variant: i.variant.sku,
quantity: i.quantity,
price,
reporting_price,
}
})
)
const returnItems = await Promise.all(
swap.return_order.items.map(async (ri) => {
const i = await lineItemService.retrieve(ri.item_id, {
relations: ["variant"],
})
const price = humanizeAmount(i.unit_price, currency)
const reporting_price = await segmentService.getReportingValue(
currency,
price
)
return {
name: i.title,
product_id: i.variant.product_id,
variant: i.variant.sku,
quantity: ri.quantity,
price,
reporting_price,
}
})
)
return [
swap,
{
swap_id: swap.id,
order_id: swap.order_id,
new_items: newItems,
return_items: returnItems,
currency,
},
]
}

View File

@@ -1,8 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext"
},
"include": ["src/admin"],
"exclude": ["**/*.spec.js"]
}

View File

@@ -1,35 +0,0 @@
{
"compilerOptions": {
"lib": [
"es5",
"es6",
"es2019"
],
"target": "es5",
"jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
"outDir": "./dist",
"esModuleInterop": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"allowJs": true,
"skipLibCheck": true,
"downlevelIteration": true // to use ES5 specific tooling
},
"include": ["src"],
"exclude": [
"dist",
"build",
"src/**/__tests__",
"src/**/__mocks__",
"src/**/__fixtures__",
"node_modules",
".eslintrc.js"
]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */
},
"exclude": ["src/admin", "**/*.spec.js"]
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,287 +0,0 @@
# Change Log
## 1.1.43
### Patch Changes
- [#3763](https://github.com/medusajs/medusa/pull/3763) [`4104d9ccb`](https://github.com/medusajs/medusa/commit/4104d9ccb25276c85b5363f85e14b3093e64df85) Thanks [@StephixOne](https://github.com/StephixOne)! - fix(plugin-discount-generator,plugin-economic,plugin-mailchimp,plugin-restock-notification,plugin-sendgrid,plugin-wishlist): Temporarily remove payload validation in some plugins
## 1.1.42
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0
- medusa-interfaces@1.3.7
- medusa-test-utils@1.1.40
## 1.1.42-rc.0
### Patch Changes
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
- medusa-core-utils@1.2.0-rc.0
- medusa-interfaces@1.3.7-rc.0
- medusa-test-utils@1.1.40-rc.0
## 1.1.41
### Patch Changes
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
- medusa-core-utils@1.1.39
- medusa-interfaces@1.3.6
## 1.1.40
### Patch Changes
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
- medusa-core-utils@1.1.38
- medusa-interfaces@1.3.5
## 1.1.39
### Patch Changes
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
- medusa-interfaces@1.3.4
## 1.1.38
### Patch Changes
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
- medusa-core-utils@1.1.37
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.36...medusa-plugin-wishlist@1.1.37) (2022-01-11)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.35...medusa-plugin-wishlist@1.1.36) (2021-12-29)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.34...medusa-plugin-wishlist@1.1.35) (2021-12-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.33...medusa-plugin-wishlist@1.1.34) (2021-12-08)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.32...medusa-plugin-wishlist@1.1.33) (2021-11-23)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.31...medusa-plugin-wishlist@1.1.32) (2021-11-22)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.30...medusa-plugin-wishlist@1.1.31) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.29...medusa-plugin-wishlist@1.1.30) (2021-11-19)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.28...medusa-plugin-wishlist@1.1.29) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.27...medusa-plugin-wishlist@1.1.28) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.25...medusa-plugin-wishlist@1.1.27) (2021-10-18)
### Features
- update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.25...medusa-plugin-wishlist@1.1.26) (2021-10-18)
### Features
- update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.25...medusa-plugin-wishlist@1.1.25) (2021-09-15)
### Features
- update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.25...medusa-plugin-wishlist@1.1.24) (2021-09-14)
### Features
- update and cancel swaps, claims, and returns ([#310](https://github.com/medusajs/medusa/issues/310)) ([cf66f97](https://github.com/medusajs/medusa/commit/cf66f97758003a41737602d4b1b1051b266d4f81))
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.23...medusa-plugin-wishlist@1.1.25) (2021-09-02)
### Bug Fixes
- 404 ([b1132ee](https://github.com/medusajs/medusa/commit/b1132eec23514a6e7a22fe6653f4a4b4fde0e83f))
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.23...medusa-plugin-wishlist@1.1.24) (2021-08-31)
### Bug Fixes
- 404 ([b1132ee](https://github.com/medusajs/medusa/commit/b1132eec23514a6e7a22fe6653f4a4b4fde0e83f))
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.22...medusa-plugin-wishlist@1.1.23) (2021-08-05)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.21...medusa-plugin-wishlist@1.1.22) (2021-07-26)
### Bug Fixes
- support wishlist ([#325](https://github.com/medusajs/medusa/issues/325)) ([4e003be](https://github.com/medusajs/medusa/commit/4e003bebaac0d84bedf5a2ed6ca94b728b50a9d9))
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.19...medusa-plugin-wishlist@1.1.21) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.19...medusa-plugin-wishlist@1.1.20) (2021-07-15)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.18...medusa-plugin-wishlist@1.1.19) (2021-07-02)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.17...medusa-plugin-wishlist@1.1.18) (2021-06-22)
### Bug Fixes
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-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
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.9...medusa-plugin-wishlist@1.1.12) (2021-04-28)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.10...medusa-plugin-wishlist@1.1.11) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.9...medusa-plugin-wishlist@1.1.10) (2021-04-20)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.8...medusa-plugin-wishlist@1.1.9) (2021-04-13)
### Bug Fixes
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.7...medusa-plugin-wishlist@1.1.8) (2021-04-13)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.6...medusa-plugin-wishlist@1.1.7) (2021-03-30)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.5...medusa-plugin-wishlist@1.1.6) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.3...medusa-plugin-wishlist@1.1.5) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.3...medusa-plugin-wishlist@1.1.4) (2021-03-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.2...medusa-plugin-wishlist@1.1.3) (2021-02-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.1...medusa-plugin-wishlist@1.1.2) (2021-02-03)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.0...medusa-plugin-wishlist@1.1.1) (2021-01-27)
**Note:** Version bump only for package medusa-plugin-wishlist
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.0.13...medusa-plugin-wishlist@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.0.12...medusa-plugin-wishlist@1.0.13) (2020-12-17)
**Note:** Version bump only for package medusa-plugin-wishlist
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.0.11...medusa-plugin-wishlist@1.0.12) (2020-11-24)
**Note:** Version bump only for package medusa-plugin-wishlist
## 1.0.11 (2020-10-19)
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
# 1.0.0-alpha.26 (2020-08-27)
# 1.0.0-alpha.24 (2020-08-27)
# 1.0.0-alpha.3 (2020-08-20)
# 1.0.0-alpha.2 (2020-08-20)
# 1.0.0-alpha.1 (2020-08-20)
# 1.0.0-alpha.0 (2020-08-20)
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))

View File

@@ -1,40 +0,0 @@
# Wishlist
Add wishlist capabilities to your commerce application.
[Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
## Features
- Allow customers to manage items in their wishlist.
---
## Prerequisites
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-wishlist
```
2\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...
`medusa-plugin-wishlist`
]
```
---
## Test the Plugin
Learn about testing the plugin in [the documentation](https://docs.medusajs.com/plugins/other/wishlist)

View File

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

View File

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

View File

@@ -1,51 +0,0 @@
{
"name": "medusa-plugin-wishlist",
"version": "1.1.43",
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-plugin-wishlist"
},
"engines": {
"node": ">=16"
},
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.9.6",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-interfaces": "^1.3.7",
"medusa-test-utils": "^1.1.40"
},
"scripts": {
"prepare": "cross-env NODE_ENV=production yarn run build",
"test": "jest --passWithNoTests src",
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
},
"peerDependencies": {
"medusa-interfaces": "^1.3.7"
},
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"medusa-core-utils": "^1.2.0"
},
"gitHead": "3bbd1e8507e00bc471de6ae3c30207999a4a4011",
"keywords": [
"medusa-plugin"
]
}

View File

@@ -1,50 +0,0 @@
import express, { Router } from "express"
import jwt from "jsonwebtoken"
import cors from "cors"
import { getConfigFile, MedusaError, parseCorsOrigins } from "medusa-core-utils"
const app = Router()
export default (rootDirectory) => {
const { configModule } = getConfigFile(rootDirectory, "medusa-config")
const { projectConfig } = configModule
const corsOptions = {
origin: parseCorsOrigins(projectConfig.store_cors),
credentials: true,
}
const JWT_SECRET = process.env.JWT_SECRET || ""
app.use("/wishlists/:token", cors(corsOptions))
app.get(
"/wishlists/:token",
cors(corsOptions),
express.json(),
async (req, res) => {
const customerService = req.scope.resolve("customerService")
const { token } = req.params
let decode
try {
decode = jwt.decode(token, JWT_SECRET)
if (!decode || !decode.customer_id) {
throw new MedusaError(MedusaError.Types.NOT_FOUND, "Invalid token")
}
} catch (err) {
res.status(400).json({ message: err.message })
}
try {
const customer = await customerService.retrieve(decode.customer_id)
const wishlist = {
items: customer.metadata.wishlist,
first_name: customer.first_name,
}
res.status(200).json({ wishlist })
} catch (err) {
res.status(400).json({ message: err.message })
}
}
)
return app
}

View File

@@ -1,76 +0,0 @@
import bodyParser from "body-parser"
import { Router } from "express"
import jwt from "jsonwebtoken"
import { MedusaError } from "medusa-core-utils"
const JWT_SECRET = process.env.JWT_SECRET || ""
export default () => {
const app = Router()
app.delete("/:id/wishlist", bodyParser.json(), async (req, res) => {
const customerService = req.scope.resolve("customerService")
let customer = await customerService.retrieve(req.params.id)
const wishlist = (customer.metadata && customer.metadata.wishlist) || []
const newWishlist = [...wishlist]
newWishlist.splice(req.body.index, 1)
customer = await customerService.update(customer.id, {
metadata: { wishlist: newWishlist },
})
res.json({ customer })
})
app.post("/:id/wishlist", bodyParser.json(), async (req, res) => {
const lineItemService = req.scope.resolve("lineItemService")
const customerService = req.scope.resolve("customerService")
const regionService = req.scope.resolve("regionService")
let customer = await customerService.retrieve(req.params.id)
const regions = await regionService.list()
if (regions.length) {
const lineItem = await lineItemService.generate(
req.body.variant_id,
regions[0].id,
req.body.quantity,
{ metadata: req.body.metadata }
)
const wishlist = (customer.metadata && customer.metadata.wishlist) || []
customer = await customerService.update(customer.id, {
metadata: { wishlist: [...wishlist, lineItem] },
})
}
res.json({ customer })
})
app.post("/:id/wishlist/share-token", bodyParser.json(), async (req, res) => {
const customerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(req.params.id)
// check customer has wishlist else throw 400 bad request
if (!customer?.metadata?.wishlist) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
"Invalid data - Customer doesn't have a wishlist"
)
}
const token = jwt.sign(
{
customer_id: customer.id,
},
JWT_SECRET
)
res.json({ share_token: token })
})
return app
}

548
yarn.lock
View File

@@ -1876,7 +1876,7 @@ __metadata:
languageName: node
linkType: hard
"@babel/node@npm:^7.12.10, @babel/node@npm:^7.12.6, @babel/node@npm:^7.7.4":
"@babel/node@npm:^7.12.10, @babel/node@npm:^7.12.6":
version: 7.22.5
resolution: "@babel/node@npm:7.22.5"
dependencies:
@@ -3787,20 +3787,6 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-transform-typescript@npm:^7.13.0, @babel/plugin-transform-typescript@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/plugin-transform-typescript@npm:7.22.5"
dependencies:
"@babel/helper-annotate-as-pure": ^7.22.5
"@babel/helper-create-class-features-plugin": ^7.22.5
"@babel/helper-plugin-utils": ^7.22.5
"@babel/plugin-syntax-typescript": ^7.22.5
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 1ee79ead40f8a299dd643d433a514e2bc970f954d27c3a92d62f2139a19128c31d76d094df7e1c1789a70528f349ba536f271a0b47117c77ca49cd26f8b1c66d
languageName: node
linkType: hard
"@babel/plugin-transform-typescript@npm:^7.18.6":
version: 7.24.5
resolution: "@babel/plugin-transform-typescript@npm:7.24.5"
@@ -3815,6 +3801,20 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-transform-typescript@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/plugin-transform-typescript@npm:7.22.5"
dependencies:
"@babel/helper-annotate-as-pure": ^7.22.5
"@babel/helper-create-class-features-plugin": ^7.22.5
"@babel/helper-plugin-utils": ^7.22.5
"@babel/plugin-syntax-typescript": ^7.22.5
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 1ee79ead40f8a299dd643d433a514e2bc970f954d27c3a92d62f2139a19128c31d76d094df7e1c1789a70528f349ba536f271a0b47117c77ca49cd26f8b1c66d
languageName: node
linkType: hard
"@babel/plugin-transform-unicode-escapes@npm:^7.10.4":
version: 7.24.1
resolution: "@babel/plugin-transform-unicode-escapes@npm:7.24.1"
@@ -4267,7 +4267,7 @@ __metadata:
languageName: node
linkType: hard
"@babel/register@npm:^7.11.5, @babel/register@npm:^7.12.1, @babel/register@npm:^7.22.5, @babel/register@npm:^7.7.4":
"@babel/register@npm:^7.11.5, @babel/register@npm:^7.12.1, @babel/register@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/register@npm:7.22.5"
dependencies:
@@ -7983,7 +7983,7 @@ __metadata:
languageName: unknown
linkType: soft
"@medusajs/medusa@^1.17.1, @medusajs/medusa@^1.20.3, @medusajs/medusa@^1.20.4, @medusajs/medusa@^1.20.5, @medusajs/medusa@workspace:*, @medusajs/medusa@workspace:^, @medusajs/medusa@workspace:packages/medusa":
"@medusajs/medusa@^1.20.3, @medusajs/medusa@^1.20.4, @medusajs/medusa@^1.20.5, @medusajs/medusa@workspace:*, @medusajs/medusa@workspace:^, @medusajs/medusa@workspace:packages/medusa":
version: 0.0.0-use.local
resolution: "@medusajs/medusa@workspace:packages/medusa"
dependencies:
@@ -11345,16 +11345,6 @@ __metadata:
languageName: node
linkType: hard
"@segment/loosely-validate-event@npm:^2.0.0":
version: 2.0.0
resolution: "@segment/loosely-validate-event@npm:2.0.0"
dependencies:
component-type: ^1.2.1
join-component: ^1.1.0
checksum: c083c70c5f0a42a2bc5b685f82830b968d01b5b8de2a9a1c362a3952c6bb33ffbdfcf8196c8ce110a5050f78ff9dcf395832eb55687843c80dc77dfe659b0803
languageName: node
linkType: hard
"@sideway/address@npm:^4.1.4":
version: 4.1.4
resolution: "@sideway/address@npm:4.1.4"
@@ -16822,7 +16812,7 @@ __metadata:
languageName: node
linkType: hard
"acorn-jsx@npm:^5.2.0, acorn-jsx@npm:^5.3.1, acorn-jsx@npm:^5.3.2":
"acorn-jsx@npm:^5.3.1, acorn-jsx@npm:^5.3.2":
version: 5.3.2
resolution: "acorn-jsx@npm:5.3.2"
peerDependencies:
@@ -17039,22 +17029,6 @@ __metadata:
languageName: node
linkType: hard
"analytics-node@npm:^3.4.0-beta.1":
version: 3.5.0
resolution: "analytics-node@npm:3.5.0"
dependencies:
"@segment/loosely-validate-event": ^2.0.0
axios: ^0.21.1
axios-retry: ^3.0.2
lodash.isstring: ^4.0.1
md5: ^2.2.1
ms: ^2.0.0
remove-trailing-slash: ^0.1.0
uuid: ^3.2.1
checksum: 041b0ac7d20df2366ebf612f7e088f686241ec57f7f4212252fd896b095210b1464724ababfa3904679e9137ee3ccb64a1ed64c8d69dc222ac1c9d2d6c19e74f
languageName: node
linkType: hard
"ansi-align@npm:^3.0.0":
version: 3.0.1
resolution: "ansi-align@npm:3.0.1"
@@ -17138,7 +17112,7 @@ __metadata:
languageName: node
linkType: hard
"ansi-styles@npm:^3.2.0, ansi-styles@npm:^3.2.1":
"ansi-styles@npm:^3.2.1":
version: 3.2.1
resolution: "ansi-styles@npm:3.2.1"
dependencies:
@@ -17816,7 +17790,7 @@ __metadata:
languageName: node
linkType: hard
"axios-retry@npm:^3.0.2, axios-retry@npm:^3.1.9":
"axios-retry@npm:^3.1.9":
version: 3.5.1
resolution: "axios-retry@npm:3.5.1"
dependencies:
@@ -17837,25 +17811,7 @@ __metadata:
languageName: node
linkType: hard
"axios@npm:^0.19.2":
version: 0.19.2
resolution: "axios@npm:0.19.2"
dependencies:
follow-redirects: 1.5.10
checksum: b775abf2db44ea4f182f4c2bfa4bf84a723b86f5aa001f222f12193fa45ba243b7e3f27b66289c6afa51d696402b05c82715fd621a34add5b538e850adcdbce1
languageName: node
linkType: hard
"axios@npm:^0.20.0":
version: 0.20.0
resolution: "axios@npm:0.20.0"
dependencies:
follow-redirects: ^1.10.0
checksum: 36dffb87c584d75bc5b009165c78031aab113f874b81c510deab369a63a2a27bd241395751a801c79d2ed2dcee55a4d8a557f0c1b9fd7de6c38bdd1ad7f56783
languageName: node
linkType: hard
"axios@npm:^0.21.1, axios@npm:^0.21.4":
"axios@npm:^0.21.4":
version: 0.21.4
resolution: "axios@npm:0.21.4"
dependencies:
@@ -19522,13 +19478,6 @@ __metadata:
languageName: node
linkType: hard
"charenc@npm:0.0.2":
version: 0.0.2
resolution: "charenc@npm:0.0.2"
checksum: a45ec39363a16799d0f9365c8dd0c78e711415113c6f14787a22462ef451f5013efae8a28f1c058f81fc01f2a6a16955f7a5fd0cd56247ce94a45349c89877d8
languageName: node
linkType: hard
"check-error@npm:^1.0.3":
version: 1.0.3
resolution: "check-error@npm:1.0.3"
@@ -19847,15 +19796,6 @@ __metadata:
languageName: node
linkType: hard
"client-sessions@npm:^0.8.0":
version: 0.8.0
resolution: "client-sessions@npm:0.8.0"
dependencies:
cookies: ^0.7.0
checksum: b53995540b212d9c5992d48432eb97aa9a2e8a91c4d487c6a495c3c5b39711789422096b4d24e00b1b3ac41d87a16a4411673fffc2d56f7fb840d15841413b1b
languageName: node
linkType: hard
"cliui@npm:^6.0.0":
version: 6.0.0
resolution: "cliui@npm:6.0.0"
@@ -20242,13 +20182,6 @@ __metadata:
languageName: node
linkType: hard
"component-type@npm:^1.2.1":
version: 1.2.1
resolution: "component-type@npm:1.2.1"
checksum: 8f9537d529d619484b8572cd569f212ea264d8c84dc65ccaaa0136e4a2e06696e9a2b2b1979ef264251f8b4ebfa075f23c860b6e4270385fd7663b42e5727cee
languageName: node
linkType: hard
"compressible@npm:~2.0.16":
version: 2.0.18
resolution: "compressible@npm:2.0.18"
@@ -20457,16 +20390,6 @@ __metadata:
languageName: node
linkType: hard
"cookies@npm:^0.7.0":
version: 0.7.3
resolution: "cookies@npm:0.7.3"
dependencies:
depd: ~1.1.2
keygrip: ~1.0.3
checksum: ecb29d0cb442e530bf3f5642e542346d747de0f9f94c092bba4eebd44d4d55dfde6d2cf20e58387ae8dc5d2e1f1562c6623a5b1df1e4539df2ca021ae27b802c
languageName: node
linkType: hard
"copy-concurrently@npm:^1.0.0":
version: 1.0.5
resolution: "copy-concurrently@npm:1.0.5"
@@ -20837,13 +20760,6 @@ __metadata:
languageName: node
linkType: hard
"crypt@npm:0.0.2":
version: 0.0.2
resolution: "crypt@npm:0.0.2"
checksum: adbf263441dd801665d5425f044647533f39f4612544071b1471962209d235042fb703c27eea2795c7c53e1dfc242405173003f83cf4f4761a633d11f9653f18
languageName: node
linkType: hard
"crypto-browserify@npm:^3.11.0":
version: 3.12.0
resolution: "crypto-browserify@npm:3.12.0"
@@ -21325,15 +21241,6 @@ __metadata:
languageName: node
linkType: hard
"debug@npm:=3.1.0":
version: 3.1.0
resolution: "debug@npm:3.1.0"
dependencies:
ms: 2.0.0
checksum: 5bff34a352d7b2eaa31886eeaf2ee534b5461ec0548315b2f9f80bd1d2533cab7df1fa52e130ce27bc31c3945fbffb0fc72baacdceb274b95ce853db89254ea4
languageName: node
linkType: hard
"debug@npm:^3.0.0, debug@npm:^3.1.0, debug@npm:^3.2.7":
version: 3.2.7
resolution: "debug@npm:3.2.7"
@@ -22180,13 +22087,6 @@ __metadata:
languageName: node
linkType: hard
"emoji-regex@npm:^7.0.1":
version: 7.0.3
resolution: "emoji-regex@npm:7.0.3"
checksum: a8917d695c3a3384e4b7230a6a06fd2de6b3db3709116792e8b7b36ddbb3db4deb28ad3e983e70d4f2a1f9063b5dab9025e4e26e9ca08278da4fbb73e213743f
languageName: node
linkType: hard
"emoji-regex@npm:^8.0.0":
version: 8.0.0
resolution: "emoji-regex@npm:8.0.0"
@@ -22987,7 +22887,7 @@ __metadata:
languageName: node
linkType: hard
"eslint-scope@npm:5.1.1, eslint-scope@npm:^5.0.0, eslint-scope@npm:^5.1.1":
"eslint-scope@npm:5.1.1, eslint-scope@npm:^5.1.1":
version: 5.1.1
resolution: "eslint-scope@npm:5.1.1"
dependencies:
@@ -23027,15 +22927,6 @@ __metadata:
languageName: node
linkType: hard
"eslint-utils@npm:^1.4.3":
version: 1.4.3
resolution: "eslint-utils@npm:1.4.3"
dependencies:
eslint-visitor-keys: ^1.1.0
checksum: ba19a817177d5fc54ae89cd80ecc8bc24eefd640bd8b0db204f29dc79cf9621bb42d68bf31eae6c89ca1f52d748b6583214f57288f9a78d2bd368a2340abe41c
languageName: node
linkType: hard
"eslint-utils@npm:^2.1.0":
version: 2.1.0
resolution: "eslint-utils@npm:2.1.0"
@@ -23123,53 +23014,6 @@ __metadata:
languageName: node
linkType: hard
"eslint@npm:^6.8.0":
version: 6.8.0
resolution: "eslint@npm:6.8.0"
dependencies:
"@babel/code-frame": ^7.0.0
ajv: ^6.10.0
chalk: ^2.1.0
cross-spawn: ^6.0.5
debug: ^4.0.1
doctrine: ^3.0.0
eslint-scope: ^5.0.0
eslint-utils: ^1.4.3
eslint-visitor-keys: ^1.1.0
espree: ^6.1.2
esquery: ^1.0.1
esutils: ^2.0.2
file-entry-cache: ^5.0.1
functional-red-black-tree: ^1.0.1
glob-parent: ^5.0.0
globals: ^12.1.0
ignore: ^4.0.6
import-fresh: ^3.0.0
imurmurhash: ^0.1.4
inquirer: ^7.0.0
is-glob: ^4.0.0
js-yaml: ^3.13.1
json-stable-stringify-without-jsonify: ^1.0.1
levn: ^0.3.0
lodash: ^4.17.14
minimatch: ^3.0.4
mkdirp: ^0.5.1
natural-compare: ^1.4.0
optionator: ^0.8.3
progress: ^2.0.0
regexpp: ^2.0.1
semver: ^6.1.2
strip-ansi: ^5.2.0
strip-json-comments: ^3.0.1
table: ^5.2.3
text-table: ^0.2.0
v8-compile-cache: ^2.0.3
bin:
eslint: ./bin/eslint.js
checksum: 95cd68b3bee8fcabf4468d3fcdfe74baefa878556312ad9ffd25715fe0dc96d6a7d381133bd9307dc24604a14c74fd86ce4fa3851b10783bb69a456b2d7a4acb
languageName: node
linkType: hard
"eslint@npm:^8.23.0":
version: 8.44.0
resolution: "eslint@npm:8.44.0"
@@ -23274,17 +23118,6 @@ __metadata:
languageName: node
linkType: hard
"espree@npm:^6.1.2":
version: 6.2.1
resolution: "espree@npm:6.2.1"
dependencies:
acorn: ^7.1.1
acorn-jsx: ^5.2.0
eslint-visitor-keys: ^1.1.0
checksum: 499b47bc599ac3515598072ca787016bdaf0d463467ee1c7113061949359a26d74b8fb344afdad63e38b0e81c7b068013125f7a123d0776e0d75fffe2fc9cfac
languageName: node
linkType: hard
"espree@npm:^7.3.0, espree@npm:^7.3.1":
version: 7.3.1
resolution: "espree@npm:7.3.1"
@@ -23328,7 +23161,7 @@ __metadata:
languageName: node
linkType: hard
"esquery@npm:^1.0.1, esquery@npm:^1.4.0, esquery@npm:^1.4.2":
"esquery@npm:^1.4.0, esquery@npm:^1.4.2":
version: 1.5.0
resolution: "esquery@npm:1.5.0"
dependencies:
@@ -24081,15 +23914,6 @@ __metadata:
languageName: node
linkType: hard
"file-entry-cache@npm:^5.0.1":
version: 5.0.1
resolution: "file-entry-cache@npm:5.0.1"
dependencies:
flat-cache: ^2.0.1
checksum: 2480fb523a0342b8ede8b17717517f69ce6b775083d06e50e2e10ca45f16c94f1d4d95976ae627735716174033374a2d6717ba4b58569e1fea8564a1b1f2e4c1
languageName: node
linkType: hard
"file-entry-cache@npm:^6.0.1":
version: 6.0.1
resolution: "file-entry-cache@npm:6.0.1"
@@ -24285,17 +24109,6 @@ __metadata:
languageName: node
linkType: hard
"flat-cache@npm:^2.0.1":
version: 2.0.1
resolution: "flat-cache@npm:2.0.1"
dependencies:
flatted: ^2.0.0
rimraf: 2.6.3
write: 1.0.3
checksum: 09e4d2300d05734eb2ac39ea0bb9cc6d64c0c856f6b77d2bdc7734490b4a8f860d721f59ffd5508f6938c577f8394fe7b5f6acf99a5ec4af6478d7c5c8390bcb
languageName: node
linkType: hard
"flat-cache@npm:^3.0.4":
version: 3.0.4
resolution: "flat-cache@npm:3.0.4"
@@ -24306,13 +24119,6 @@ __metadata:
languageName: node
linkType: hard
"flatted@npm:^2.0.0":
version: 2.0.2
resolution: "flatted@npm:2.0.2"
checksum: 1895ac3971c3a71b0384c6d8b8ef1f217dfe7e72bc7dabc51ef532772b761e626dd7cae53a729b9e65389409d7f03fd84f1900bde4f9e719ed04e57e8510e0d4
languageName: node
linkType: hard
"flatted@npm:^3.1.0":
version: 3.2.7
resolution: "flatted@npm:3.2.7"
@@ -24356,16 +24162,7 @@ __metadata:
languageName: node
linkType: hard
"follow-redirects@npm:1.5.10":
version: 1.5.10
resolution: "follow-redirects@npm:1.5.10"
dependencies:
debug: =3.1.0
checksum: f56ca26dcf3c9996a6cf8868b61e369a35d4000ade0292bdd27b5e0934902681b037060b9fabe58e7042bb8b85166d5db8bbcf027f1825c1577e4cffd904fd3f
languageName: node
linkType: hard
"follow-redirects@npm:^1.10.0, follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4":
"follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4":
version: 1.15.2
resolution: "follow-redirects@npm:1.15.2"
peerDependenciesMeta:
@@ -25058,7 +24855,7 @@ __metadata:
languageName: node
linkType: hard
"glob-parent@npm:^5.0.0, glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2":
"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2":
version: 5.1.2
resolution: "glob-parent@npm:5.1.2"
dependencies:
@@ -25228,15 +25025,6 @@ __metadata:
languageName: node
linkType: hard
"globals@npm:^12.1.0":
version: 12.4.0
resolution: "globals@npm:12.4.0"
dependencies:
type-fest: ^0.8.1
checksum: f6731c915f5fde6ac3737016be748682fdf52a436e4f2702d14cec4f15f3aefcc306483bdae4c9195b04848416443f57e9de6771c74fd77becfbba2d2068bc73
languageName: node
linkType: hard
"globals@npm:^13.19.0, globals@npm:^13.6.0, globals@npm:^13.9.0":
version: 13.20.0
resolution: "globals@npm:13.20.0"
@@ -26311,27 +26099,6 @@ __metadata:
languageName: node
linkType: hard
"inquirer@npm:^7.0.0":
version: 7.3.3
resolution: "inquirer@npm:7.3.3"
dependencies:
ansi-escapes: ^4.2.1
chalk: ^4.1.0
cli-cursor: ^3.1.0
cli-width: ^3.0.0
external-editor: ^3.0.3
figures: ^3.0.0
lodash: ^4.17.19
mute-stream: 0.0.8
run-async: ^2.4.0
rxjs: ^6.6.0
string-width: ^4.1.0
strip-ansi: ^6.0.0
through: ^2.3.6
checksum: 96e75974cfd863fe6653c075e41fa5f1a290896df141189816db945debabcd92d3277145f11aef8d2cfca5409ab003ccdd18a099744814057b52a2f27aeb8c94
languageName: node
linkType: hard
"inquirer@npm:^8.0.0, inquirer@npm:^8.1.1":
version: 8.2.5
resolution: "inquirer@npm:8.2.5"
@@ -26732,7 +26499,7 @@ __metadata:
languageName: node
linkType: hard
"is-buffer@npm:^1.1.5, is-buffer@npm:~1.1.6":
"is-buffer@npm:^1.1.5":
version: 1.1.6
resolution: "is-buffer@npm:1.1.6"
checksum: ae18aa0b6e113d6c490ad1db5e8df9bdb57758382b313f5a22c9c61084875c6396d50bbf49315f5b1926d142d74dfb8d31b40d993a383e0a158b15fea7a82234
@@ -26930,13 +26697,6 @@ __metadata:
languageName: node
linkType: hard
"is-fullwidth-code-point@npm:^2.0.0":
version: 2.0.0
resolution: "is-fullwidth-code-point@npm:2.0.0"
checksum: e58f3e4a601fc0500d8b2677e26e9fe0cd450980e66adb29d85b6addf7969731e38f8e43ed2ec868a09c101a55ac3d8b78902209269f38c5286bc98f5bc1b4d9
languageName: node
linkType: hard
"is-fullwidth-code-point@npm:^3.0.0":
version: 3.0.0
resolution: "is-fullwidth-code-point@npm:3.0.0"
@@ -30335,13 +30095,6 @@ __metadata:
languageName: node
linkType: hard
"join-component@npm:^1.1.0":
version: 1.1.0
resolution: "join-component@npm:1.1.0"
checksum: 7319cb1ca6ffc514d82ac1b965c4e6cd6bf852adec1e7833bd8613e17f4965e78e2653c8de75a1fe51d9a2cae36af3298008df4079cfd903ef3ecbd231fe11c1
languageName: node
linkType: hard
"joycon@npm:^3.0.1, joycon@npm:^3.1.1":
version: 3.1.1
resolution: "joycon@npm:3.1.1"
@@ -30853,13 +30606,6 @@ __metadata:
languageName: node
linkType: hard
"keygrip@npm:~1.0.3":
version: 1.0.3
resolution: "keygrip@npm:1.0.3"
checksum: 2a94700bbdd6f53c3f77932aa2d211ff7f537472a21d257203aa48972c2fdc71c60f82e661415887ea068061ce3c7532c5fdd7e8efd4390ad154d51f1a5932a9
languageName: node
linkType: hard
"keygrip@npm:~1.1.0":
version: 1.1.0
resolution: "keygrip@npm:1.1.0"
@@ -31178,16 +30924,6 @@ __metadata:
languageName: node
linkType: hard
"levn@npm:^0.3.0, levn@npm:~0.3.0":
version: 0.3.0
resolution: "levn@npm:0.3.0"
dependencies:
prelude-ls: ~1.1.2
type-check: ~0.3.2
checksum: e440df9de4233da0b389cd55bd61f0f6aaff766400bebbccd1231b81801f6dbc1d816c676ebe8d70566394b749fa624b1ed1c68070e9c94999f0bdecc64cb676
languageName: node
linkType: hard
"levn@npm:^0.4.1":
version: 0.4.1
resolution: "levn@npm:0.4.1"
@@ -31198,6 +30934,16 @@ __metadata:
languageName: node
linkType: hard
"levn@npm:~0.3.0":
version: 0.3.0
resolution: "levn@npm:0.3.0"
dependencies:
prelude-ls: ~1.1.2
type-check: ~0.3.2
checksum: e440df9de4233da0b389cd55bd61f0f6aaff766400bebbccd1231b81801f6dbc1d816c676ebe8d70566394b749fa624b1ed1c68070e9c94999f0bdecc64cb676
languageName: node
linkType: hard
"libphonenumber-js@npm:^1.10.14":
version: 1.10.37
resolution: "libphonenumber-js@npm:1.10.37"
@@ -31530,7 +31276,7 @@ __metadata:
languageName: node
linkType: hard
"lodash@npm:4.17.21, lodash@npm:4.x, lodash@npm:^4.17.11, lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.7.0, lodash@npm:~4.17.21":
"lodash@npm:4.17.21, lodash@npm:4.x, lodash@npm:^4.17.11, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.7.0, lodash@npm:~4.17.21":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
checksum: d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c
@@ -31938,17 +31684,6 @@ __metadata:
languageName: node
linkType: hard
"md5@npm:^2.2.1":
version: 2.3.0
resolution: "md5@npm:2.3.0"
dependencies:
charenc: 0.0.2
crypt: 0.0.2
is-buffer: ~1.1.6
checksum: 14a21d597d92e5b738255fbe7fe379905b8cb97e0a49d44a20b58526a646ec5518c337b817ce0094ca94d3e81a3313879c4c7b510d250c282d53afbbdede9110
languageName: node
linkType: hard
"mdast-squeeze-paragraphs@npm:^4.0.0":
version: 4.0.0
resolution: "mdast-squeeze-paragraphs@npm:4.0.0"
@@ -32071,7 +31806,7 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-interfaces@^1.3.7, medusa-interfaces@^1.3.9, medusa-interfaces@workspace:*, medusa-interfaces@workspace:packages/medusa-interfaces":
"medusa-interfaces@^1.3.9, medusa-interfaces@workspace:*, medusa-interfaces@workspace:packages/medusa-interfaces":
version: 0.0.0-use.local
resolution: "medusa-interfaces@workspace:packages/medusa-interfaces"
dependencies:
@@ -32093,129 +31828,6 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-plugin-discount-generator@workspace:packages/medusa-plugin-discount-generator":
version: 0.0.0-use.local
resolution: "medusa-plugin-discount-generator@workspace:packages/medusa-plugin-discount-generator"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/node": ^7.7.4
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/register": ^7.7.4
"@babel/runtime": ^7.9.6
body-parser: ^1.19.0
client-sessions: ^0.8.0
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
randomatic: ^3.1.1
peerDependencies:
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-plugin-ip-lookup@workspace:packages/medusa-plugin-ip-lookup":
version: 0.0.0-use.local
resolution: "medusa-plugin-ip-lookup@workspace:packages/medusa-plugin-ip-lookup"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/runtime": ^7.7.6
axios: ^0.20.0
cross-env: ^5.2.1
jest: ^25.5.4
medusa-interfaces: ^1.3.7
peerDependencies:
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-plugin-restock-notification@workspace:packages/medusa-plugin-restock-notification":
version: 0.0.0-use.local
resolution: "medusa-plugin-restock-notification@workspace:packages/medusa-plugin-restock-notification"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/plugin-transform-typescript": ^7.13.0
"@babel/preset-typescript": ^7.12.7
"@medusajs/medusa": ^1.17.1
babel-preset-medusa-package: ^1.1.19
body-parser: ^1.19.0
cors: ^2.8.5
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
pg: ^8.5.1
typeorm: ^0.3.16
ulid: ^2.3.0
peerDependencies:
"@medusajs/medusa": ^1.12.0
medusa-interfaces: ^1.3.7
typeorm: ^0.3.16
languageName: unknown
linkType: soft
"medusa-plugin-segment@workspace:packages/medusa-plugin-segment":
version: 0.0.0-use.local
resolution: "medusa-plugin-segment@workspace:packages/medusa-plugin-segment"
dependencies:
analytics-node: ^3.4.0-beta.1
axios: ^0.19.2
cross-env: ^5.2.1
eslint: ^6.8.0
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
rimraf: ^5.0.1
typescript: ^4.9.5
peerDependencies:
"@medusajs/medusa": ">= 1.18.0 < 2"
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-plugin-wishlist@workspace:packages/medusa-plugin-wishlist":
version: 0.0.0-use.local
resolution: "medusa-plugin-wishlist@workspace:packages/medusa-plugin-wishlist"
dependencies:
"@babel/cli": ^7.7.5
"@babel/core": ^7.7.5
"@babel/node": ^7.7.4
"@babel/plugin-proposal-class-properties": ^7.7.4
"@babel/plugin-transform-classes": ^7.9.5
"@babel/plugin-transform-instanceof": ^7.8.3
"@babel/plugin-transform-runtime": ^7.7.6
"@babel/preset-env": ^7.7.5
"@babel/register": ^7.7.4
"@babel/runtime": ^7.9.6
body-parser: ^1.19.0
cors: ^2.8.5
cross-env: ^5.2.1
express: ^4.17.1
jest: ^25.5.4
medusa-core-utils: ^1.2.0
medusa-interfaces: ^1.3.7
medusa-test-utils: ^1.1.40
peerDependencies:
medusa-interfaces: ^1.3.7
languageName: unknown
linkType: soft
"medusa-react@workspace:^, medusa-react@workspace:packages/medusa-react":
version: 0.0.0-use.local
resolution: "medusa-react@workspace:packages/medusa-react"
@@ -32280,7 +31892,7 @@ __metadata:
languageName: unknown
linkType: soft
"medusa-test-utils@^1.1.40, medusa-test-utils@^1.1.42, medusa-test-utils@^1.1.43, medusa-test-utils@^1.1.44, medusa-test-utils@workspace:*, medusa-test-utils@workspace:^, medusa-test-utils@workspace:packages/core/medusa-test-utils":
"medusa-test-utils@^1.1.42, medusa-test-utils@^1.1.43, medusa-test-utils@^1.1.44, medusa-test-utils@workspace:*, medusa-test-utils@workspace:^, medusa-test-utils@workspace:packages/core/medusa-test-utils":
version: 0.0.0-use.local
resolution: "medusa-test-utils@workspace:packages/core/medusa-test-utils"
dependencies:
@@ -34095,7 +33707,7 @@ __metadata:
languageName: node
linkType: hard
"optionator@npm:^0.8.1, optionator@npm:^0.8.3":
"optionator@npm:^0.8.1":
version: 0.8.3
resolution: "optionator@npm:0.8.3"
dependencies:
@@ -37243,13 +36855,6 @@ __metadata:
languageName: node
linkType: hard
"regexpp@npm:^2.0.1":
version: 2.0.1
resolution: "regexpp@npm:2.0.1"
checksum: 4ac2cf4c68941728bffbba5a8f597a23385c2c05afc5bf5de74744ee048765ab84ea3ce3c6a5bdce102a3a54514b75b7add48b4c1abd925ca3afd40e537f2b5f
languageName: node
linkType: hard
"regexpp@npm:^3.1.0":
version: 3.2.0
resolution: "regexpp@npm:3.2.0"
@@ -37383,7 +36988,7 @@ __metadata:
languageName: node
linkType: hard
"remove-trailing-slash@npm:^0.1.0, remove-trailing-slash@npm:^0.1.1":
"remove-trailing-slash@npm:^0.1.1":
version: 0.1.1
resolution: "remove-trailing-slash@npm:0.1.1"
checksum: 6fa91e7b89e0675fdca6ce54af5fad9bd612d51e2251913a2e113b521b157647f1f8c694b55447780b489b30a63ebe949ccda7411ef383d09136bb27121c6c09
@@ -37795,17 +37400,6 @@ __metadata:
languageName: node
linkType: hard
"rimraf@npm:2.6.3, rimraf@npm:~2.6.2":
version: 2.6.3
resolution: "rimraf@npm:2.6.3"
dependencies:
glob: ^7.1.3
bin:
rimraf: ./bin.js
checksum: f1e646f8c567795f2916aef7aadf685b543da6b9a53e482bb04b07472c7eef2b476045ba1e29f401c301c66b630b22b815ab31fdd60c5e1ae6566ff523debf45
languageName: node
linkType: hard
"rimraf@npm:5.0.1, rimraf@npm:^5.0.1":
version: 5.0.1
resolution: "rimraf@npm:5.0.1"
@@ -37850,6 +37444,17 @@ __metadata:
languageName: node
linkType: hard
"rimraf@npm:~2.6.2":
version: 2.6.3
resolution: "rimraf@npm:2.6.3"
dependencies:
glob: ^7.1.3
bin:
rimraf: ./bin.js
checksum: f1e646f8c567795f2916aef7aadf685b543da6b9a53e482bb04b07472c7eef2b476045ba1e29f401c301c66b630b22b815ab31fdd60c5e1ae6566ff523debf45
languageName: node
linkType: hard
"ripemd160@npm:^2.0.0, ripemd160@npm:^2.0.1":
version: 2.0.2
resolution: "ripemd160@npm:2.0.2"
@@ -38245,7 +37850,7 @@ __metadata:
languageName: node
linkType: hard
"rxjs@npm:^6.4.0, rxjs@npm:^6.6.0":
"rxjs@npm:^6.4.0":
version: 6.6.7
resolution: "rxjs@npm:6.6.7"
dependencies:
@@ -38992,17 +38597,6 @@ __metadata:
languageName: node
linkType: hard
"slice-ansi@npm:^2.1.0":
version: 2.1.0
resolution: "slice-ansi@npm:2.1.0"
dependencies:
ansi-styles: ^3.2.0
astral-regex: ^1.0.0
is-fullwidth-code-point: ^2.0.0
checksum: c317b21ec9e3d3968f3d5b548cbfc2eae331f58a03f1352621020799cbe695b3611ee972726f8f32d4ca530065a5ec9c74c97fde711c1f41b4a1585876b2c191
languageName: node
linkType: hard
"slice-ansi@npm:^3.0.0":
version: 3.0.0
resolution: "slice-ansi@npm:3.0.0"
@@ -39677,17 +39271,6 @@ __metadata:
languageName: node
linkType: hard
"string-width@npm:^3.0.0":
version: 3.1.0
resolution: "string-width@npm:3.1.0"
dependencies:
emoji-regex: ^7.0.1
is-fullwidth-code-point: ^2.0.0
strip-ansi: ^5.1.0
checksum: 85fa0d4f106e7999bb68c1c640c76fa69fb8c069dab75b009e29c123914e2d3b532e6cfa4b9d1bd913176fc83dedd7a2d7bf40d21a81a8a1978432cedfb65b91
languageName: node
linkType: hard
"string-width@npm:^5.0.1, string-width@npm:^5.1.2":
version: 5.1.2
resolution: "string-width@npm:5.1.2"
@@ -39817,7 +39400,7 @@ __metadata:
languageName: node
linkType: hard
"strip-ansi@npm:^5.1.0, strip-ansi@npm:^5.2.0":
"strip-ansi@npm:^5.2.0":
version: 5.2.0
resolution: "strip-ansi@npm:5.2.0"
dependencies:
@@ -40246,18 +39829,6 @@ __metadata:
languageName: node
linkType: hard
"table@npm:^5.2.3":
version: 5.4.6
resolution: "table@npm:5.4.6"
dependencies:
ajv: ^6.10.2
lodash: ^4.17.14
slice-ansi: ^2.1.0
string-width: ^3.0.0
checksum: 87ad7b7cc926aa06e0e2a91a0fb4fcb8b365da87969bc5c74b54cae5d518a089245f44bf80f945ec1aa74c405782db15eeb1dd1926315d842cdc9dbb9371672e
languageName: node
linkType: hard
"table@npm:^6.0.9":
version: 6.8.1
resolution: "table@npm:6.8.1"
@@ -42523,7 +42094,7 @@ __metadata:
languageName: node
linkType: hard
"uuid@npm:^3.2.1, uuid@npm:^3.3.2":
"uuid@npm:^3.3.2":
version: 3.4.0
resolution: "uuid@npm:3.4.0"
bin:
@@ -43624,15 +43195,6 @@ __metadata:
languageName: node
linkType: hard
"write@npm:1.0.3":
version: 1.0.3
resolution: "write@npm:1.0.3"
dependencies:
mkdirp: ^0.5.1
checksum: 2ab5472e32ce2d25279a9d22365c5dd5b95fe40497ca43fa329aa61687fca56e36837615a1b6adfc4ca540389383185680a23497d75a1698b1dcbb52741d29a4
languageName: node
linkType: hard
"ws@npm:^6.1.0":
version: 6.2.2
resolution: "ws@npm:6.2.2"