chore(): start moving some packages to the core directory (#7215)
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
dist/
|
||||
node_modules/
|
||||
@@ -1,340 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.1.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#6864](https://github.com/medusajs/medusa/pull/6864) [`e944a627f0`](https://github.com/medusajs/medusa/commit/e944a627f074fb39a56f4bc7b3d6d315736ebf7c) Thanks [@adrien2p](https://github.com/adrien2p)! - feat: region payment providers management workflows/api
|
||||
|
||||
- [#6919](https://github.com/medusajs/medusa/pull/6919) [`56c04f452c`](https://github.com/medusajs/medusa/commit/56c04f452cb54b4c614531394f3ebb9a2149e608) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Medusa test utils use correct loader to init DB.
|
||||
|
||||
- [#6901](https://github.com/medusajs/medusa/pull/6901) [`82a176e30e`](https://github.com/medusajs/medusa/commit/82a176e30e47a7d11caaf31c3023bd8db588b465) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa-test-utils): Handle errors gracefully + Do not set Distributed storage on partial loading
|
||||
|
||||
- [#6858](https://github.com/medusajs/medusa/pull/6858) [`6bf4d40856`](https://github.com/medusajs/medusa/commit/6bf4d40856839b755ce33f85ee30d046be7341ab) Thanks [@srindom](https://github.com/srindom)! - chore(medusa-test-utils): create declaration file
|
||||
|
||||
- [#6962](https://github.com/medusajs/medusa/pull/6962) [`65794f4bb5`](https://github.com/medusajs/medusa/commit/65794f4bb56e4fd3f0ccb7656a948f856f05324e) Thanks [@adrien2p](https://github.com/adrien2p)! - feat: Create shipping options API
|
||||
|
||||
- [#6917](https://github.com/medusajs/medusa/pull/6917) [`b3a3993423`](https://github.com/medusajs/medusa/commit/b3a3993423f4872c84b52a68cc3e56766f9ad5a1) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa-test-utils): recompute driver options
|
||||
|
||||
- [#6857](https://github.com/medusajs/medusa/pull/6857) [`6ee2ee845c`](https://github.com/medusajs/medusa/commit/6ee2ee845c7044240c521345eb0e296843a67291) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(): medusa test runner
|
||||
|
||||
- [#6865](https://github.com/medusajs/medusa/pull/6865) [`8fd1488938`](https://github.com/medusajs/medusa/commit/8fd148893850eb66c5eae00c4ca9391a80ea2eb9) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: medusa shutdown
|
||||
|
||||
- Updated dependencies [[`20e8df914e`](https://github.com/medusajs/medusa/commit/20e8df914ec5fdf8d562d4fa84f72c58c7056195), [`e0b02a1012`](https://github.com/medusajs/medusa/commit/e0b02a1012981c29830d7779f59ebe805bbfd137), [`e944a627f0`](https://github.com/medusajs/medusa/commit/e944a627f074fb39a56f4bc7b3d6d315736ebf7c), [`cc557c8752`](https://github.com/medusajs/medusa/commit/cc557c8752fd0554f5a1b58522d9a88dc43a8509), [`5d9aea053c`](https://github.com/medusajs/medusa/commit/5d9aea053ce6e04f242f86fb9053c13dec515d5b), [`232322d035`](https://github.com/medusajs/medusa/commit/232322d03515f81e56867ff8c765b8409399ee68), [`c3efac5a0d`](https://github.com/medusajs/medusa/commit/c3efac5a0d6cfa38e1af8d248138fa83934a8ceb), [`4b57c5d286`](https://github.com/medusajs/medusa/commit/4b57c5d286f9dc6e2098c67e9fecb0d93175b5a1), [`a6562d2a41`](https://github.com/medusajs/medusa/commit/a6562d2a41453cbe7aa43be352c4924e3e4c79d5)]:
|
||||
- @medusajs/utils@1.11.9
|
||||
- medusa-core-utils@1.2.2
|
||||
|
||||
## 1.1.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#6803](https://github.com/medusajs/medusa/pull/6803) [`0168c819da`](https://github.com/medusajs/medusa/commit/0168c819da2bcdf2391c5fb5501342ea140882df) Thanks [@srindom](https://github.com/srindom)! - fix(medusa-test-utils): make module test runner models configurable
|
||||
|
||||
- [#6772](https://github.com/medusajs/medusa/pull/6772) [`1ef9c78cea`](https://github.com/medusajs/medusa/commit/1ef9c78cea080c3b7c136f909c6cddec9d8f0c62) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: v2 - deprecate extra in favor of driver options
|
||||
|
||||
- Updated dependencies [[`06f22bb48a`](https://github.com/medusajs/medusa/commit/06f22bb48ad1fe73577657b8c5db055312f16a0d), [`56481e683d`](https://github.com/medusajs/medusa/commit/56481e683d33ff98f0d4c4e144873bb23f993c9c), [`9073d7aba3`](https://github.com/medusajs/medusa/commit/9073d7aba3419e4dc0a206473291a46ebd79b8c1), [`4974f5e455`](https://github.com/medusajs/medusa/commit/4974f5e4557bd64a328a881ec02b91e15485bd23), [`1ef9c78cea`](https://github.com/medusajs/medusa/commit/1ef9c78cea080c3b7c136f909c6cddec9d8f0c62)]:
|
||||
- @medusajs/modules-sdk@1.12.10
|
||||
- @medusajs/utils@1.11.8
|
||||
|
||||
## 1.1.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#6558](https://github.com/medusajs/medusa/pull/6558) [`56d97ebef9`](https://github.com/medusajs/medusa/commit/56d97ebef96a51b4af0939c9cdf4383c33b2ec87) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa-test-utils): Add logger by default
|
||||
|
||||
- [#6595](https://github.com/medusajs/medusa/pull/6595) [`f0ef0a8784`](https://github.com/medusajs/medusa/commit/f0ef0a87845764bae7610ee854592bb9800210f5) Thanks [@adrien2p](https://github.com/adrien2p)! - fix: integration-tests/modules
|
||||
|
||||
- [#6408](https://github.com/medusajs/medusa/pull/6408) [`1d91b7429b`](https://github.com/medusajs/medusa/commit/1d91b7429beebd6f09d5027f7f7e1fe74ce3a8ff) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(fulfillment): implementation part 2
|
||||
|
||||
- [#6524](https://github.com/medusajs/medusa/pull/6524) [`62a7bcc30c`](https://github.com/medusajs/medusa/commit/62a7bcc30cbc7b234b2b51d7858439951a84edeb) Thanks [@adrien2p](https://github.com/adrien2p)! - Feat(fulfillment): service provider registration + fulfillment management
|
||||
|
||||
- [#6700](https://github.com/medusajs/medusa/pull/6700) [`8f8a4f9b13`](https://github.com/medusajs/medusa/commit/8f8a4f9b1353087d98f6cc75346d43a7f49901a8) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Version all modules to allow for initial testing
|
||||
|
||||
- [#6581](https://github.com/medusajs/medusa/pull/6581) [`51bb6f1e89`](https://github.com/medusajs/medusa/commit/51bb6f1e89424c7ae9f566b43ba26b3f5a48e3f6) Thanks [@adrien2p](https://github.com/adrien2p)! - Chore/integration tests modules utils
|
||||
|
||||
- [#6383](https://github.com/medusajs/medusa/pull/6383) [`e85463b2a7`](https://github.com/medusajs/medusa/commit/e85463b2a717751de2e21c39a4c745449b31affe) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(): Fix database test utils and utils
|
||||
|
||||
- Updated dependencies [[`9288f53327`](https://github.com/medusajs/medusa/commit/9288f53327b8ce617af92ed8d14d9459cbfeb13c), [`56cbf88115`](https://github.com/medusajs/medusa/commit/56cbf88115994adea7037c3f2814f0c96af3cfc0), [`36a61658f9`](https://github.com/medusajs/medusa/commit/36a61658f969a7b19c84a1e621ad1464927cafb1), [`c319edb8e0`](https://github.com/medusajs/medusa/commit/c319edb8e0ecd13d086652147667916e5abab2d8), [`0b9fcb6324`](https://github.com/medusajs/medusa/commit/0b9fcb6324eee9f2556c7e6317775fae93b12a47), [`586df9da25`](https://github.com/medusajs/medusa/commit/586df9da250e492442769f5bac2f8b3de1d46f05), [`b3d826497b`](https://github.com/medusajs/medusa/commit/b3d826497b3dae5e1b26b7924706c24fd5e87ca5), [`a86c87fe14`](https://github.com/medusajs/medusa/commit/a86c87fe1442afce9285e39255914e01012b4449), [`640eccd5dd`](https://github.com/medusajs/medusa/commit/640eccd5ddbb163e0f987ce6c772f1129c2e2632), [`8ea37d03c9`](https://github.com/medusajs/medusa/commit/8ea37d03c914a5004a3e42770668b2d1f7f8f564), [`339a946f38`](https://github.com/medusajs/medusa/commit/339a946f389033c21e05338f9dbf07d88e140533), [`9288f53327`](https://github.com/medusajs/medusa/commit/9288f53327b8ce617af92ed8d14d9459cbfeb13c), [`8dad2b51a2`](https://github.com/medusajs/medusa/commit/8dad2b51a26c4c3c14a6c95f70424c8bef2ad63e), [`a6d7070dd6`](https://github.com/medusajs/medusa/commit/a6d7070dd669c21ea19d70434d42c2f8167dc309), [`168f02f138`](https://github.com/medusajs/medusa/commit/168f02f138ad101e1013f2c8c3f8dc19de12accf), [`f5c2256286`](https://github.com/medusajs/medusa/commit/f5c22562867f412040f8bc6c55ab5de3a3735e62), [`000eb61e33`](https://github.com/medusajs/medusa/commit/000eb61e33e0302db95ee6ad1656ea9b430ed471), [`d550be3685`](https://github.com/medusajs/medusa/commit/d550be3685423218d47a20c57a5e06758f4a961a), [`62a7bcc30c`](https://github.com/medusajs/medusa/commit/62a7bcc30cbc7b234b2b51d7858439951a84edeb), [`8f8a4f9b13`](https://github.com/medusajs/medusa/commit/8f8a4f9b1353087d98f6cc75346d43a7f49901a8), [`6500f18b9b`](https://github.com/medusajs/medusa/commit/6500f18b9b80c5c9c473489e7e740d55dca74303), [`ce39b9b66e`](https://github.com/medusajs/medusa/commit/ce39b9b66e8c277ec0691ea6d0a950003be09cc1), [`a6a4b3f01a`](https://github.com/medusajs/medusa/commit/a6a4b3f01a6d2bd97b1580c59134279a1b033a5d), [`4625bd1241`](https://github.com/medusajs/medusa/commit/4625bd12416275b09c22cde4a09cb0f68df5d7c1), [`56b0b45304`](https://github.com/medusajs/medusa/commit/56b0b4530401a6ec5aa155874d371e45bb388fe2), [`cc1b66842c`](https://github.com/medusajs/medusa/commit/cc1b66842cbb37c6eab84e2d8b74844c214f38d7), [`24fb102a56`](https://github.com/medusajs/medusa/commit/24fb102a564b1253d1f8b039bb1e435cc5312fbb), [`e85463b2a7`](https://github.com/medusajs/medusa/commit/e85463b2a717751de2e21c39a4c745449b31affe)]:
|
||||
- @medusajs/utils@1.11.7
|
||||
- @medusajs/modules-sdk@1.12.9
|
||||
|
||||
## 1.1.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5985](https://github.com/medusajs/medusa/pull/5985) [`d16d10619`](https://github.com/medusajs/medusa/commit/d16d10619dfbd3966a4709753de3d8cc37c6f2eb) Thanks [@pKorsholm](https://github.com/pKorsholm)! - fix(medusa-test-utils, utils, link-modules, pricing, product): upgrade mikro-orm version
|
||||
|
||||
- Updated dependencies [[`f86877586`](https://github.com/medusajs/medusa/commit/f86877586147ecedbf7f56a1c57f37ef0c33286c), [`46d610bc5`](https://github.com/medusajs/medusa/commit/46d610bc555797df2ae81eb89b18faf1411b33b8)]:
|
||||
- medusa-core-utils@1.2.1
|
||||
|
||||
## 1.1.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
|
||||
- upgrade typeorm from 0.2.51 to 0.3.11
|
||||
- Plugin repository loader to work with Typeorm update
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
|
||||
## 1.1.40-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
|
||||
- upgrade typeorm from 0.2.51 to 0.3.11
|
||||
- Plugin repository loader to work with Typeorm update
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
|
||||
## 1.1.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3417](https://github.com/medusajs/medusa/pull/3417) [`fa4049cb5`](https://github.com/medusajs/medusa/commit/fa4049cb51232b2ed7091b1322c3fc14cd23e451) Thanks [@adrien2p](https://github.com/adrien2p)! - chores(medusa): Refactoring product update flow to improve handling and performances
|
||||
|
||||
## 1.1.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3407](https://github.com/medusajs/medusa/pull/3407) [`f0a1355fe`](https://github.com/medusajs/medusa/commit/f0a1355feb5160ff7de1f3d3da769efe29d0d8ed) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(medusa): Bulk emit events
|
||||
|
||||
## 1.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2961](https://github.com/medusajs/medusa/pull/2961) [`47d075351`](https://github.com/medusajs/medusa/commit/47d075351fa4fdeaf32d48f2bd7e72943a293d9b) Thanks [@riqwan](https://github.com/riqwan)! - feat(medusa): Admin API endpoint to fetch a Product Category
|
||||
|
||||
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-test-utils@1.1.36...medusa-test-utils@1.1.37) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.35...medusa-test-utils@1.1.36) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.34...medusa-test-utils@1.1.35) (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.34](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.33...medusa-test-utils@1.1.34) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.32...medusa-test-utils@1.1.33) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.31...medusa-test-utils@1.1.32) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.30...medusa-test-utils@1.1.31) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.29...medusa-test-utils@1.1.30) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.28...medusa-test-utils@1.1.29) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.27...medusa-test-utils@1.1.28) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.25...medusa-test-utils@1.1.27) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.25...medusa-test-utils@1.1.26) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.24...medusa-test-utils@1.1.25) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.23...medusa-test-utils@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.22...medusa-test-utils@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.21...medusa-test-utils@1.1.22) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.19...medusa-test-utils@1.1.21) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.19...medusa-test-utils@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.18...medusa-test-utils@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.17...medusa-test-utils@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-test-utils@1.1.16...medusa-test-utils@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.15...medusa-test-utils@1.1.16) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.14...medusa-test-utils@1.1.15) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.13...medusa-test-utils@1.1.14) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.12...medusa-test-utils@1.1.13) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.9...medusa-test-utils@1.1.12) (2021-04-28)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.10...medusa-test-utils@1.1.11) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.9...medusa-test-utils@1.1.10) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.8...medusa-test-utils@1.1.9) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adds tests ([69442a1](https://github.com/medusajs/medusa/commit/69442a1735193aeb010043f114d89037d4d76279))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.7...medusa-test-utils@1.1.8) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adds tests ([69442a1](https://github.com/medusajs/medusa/commit/69442a1735193aeb010043f114d89037d4d76279))
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.6...medusa-test-utils@1.1.7) (2021-03-30)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.5...medusa-test-utils@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.3...medusa-test-utils@1.1.5) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.3...medusa-test-utils@1.1.4) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.2...medusa-test-utils@1.1.3) (2021-02-17)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- use parallel relation fetching ([#173](https://github.com/medusajs/medusa/issues/173)) ([46006e4](https://github.com/medusajs/medusa/commit/46006e4b0647bada1dc2cb417766e22f65bad23e))
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.1...medusa-test-utils@1.1.2) (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.1](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.0...medusa-test-utils@1.1.1) (2021-01-27)
|
||||
|
||||
### Features
|
||||
|
||||
- adds discount code search functionality ([#155](https://github.com/medusajs/medusa/issues/155)) ([7e14da1](https://github.com/medusajs/medusa/commit/7e14da1225983dd58faabbd6d555818277ad4cc8))
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.0.13...medusa-test-utils@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.0.12...medusa-test-utils@1.0.13) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.0.11...medusa-test-utils@1.0.12) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-test-utils
|
||||
|
||||
## 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.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)
|
||||
|
||||
# 0.3.0 (2020-04-06)
|
||||
|
||||
# 0.2.0 (2020-04-06)
|
||||
|
||||
# 0.2.0-alpha.0 (2020-04-04)
|
||||
|
||||
## 0.1.6-alpha.0 (2020-03-24)
|
||||
|
||||
## 0.1.5-alpha.0 (2020-03-24)
|
||||
|
||||
## 0.1.4-alpha.0 (2020-03-24)
|
||||
|
||||
## 0.1.3-alpha.0 (2020-03-24)
|
||||
|
||||
## 0.1.2-alpha.0 (2020-03-24)
|
||||
|
||||
## 0.1.1-alpha.0 (2020-03-24)
|
||||
|
||||
# 0.1.0-alpha.0 (2020-03-24)
|
||||
|
||||
## [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))
|
||||
@@ -1,70 +0,0 @@
|
||||
{
|
||||
"name": "medusa-test-utils",
|
||||
"version": "1.1.44",
|
||||
"description": "Test utils for Medusa",
|
||||
"main": "dist/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-test-utils"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"build": "rimraf dist && tsc --build",
|
||||
"watch": "tsc --build --watch",
|
||||
"test": "jest --passWithNoTests src"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "Sebastian Rindom",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@medusajs/medusa": ">1.19",
|
||||
"@medusajs/modules-sdk": "^1.12.10",
|
||||
"axios": "^0.28.0",
|
||||
"express": "^4.18.3",
|
||||
"get-port": "^5.1.0",
|
||||
"pg-god": "^1.0.12",
|
||||
"typeorm": "^0.2.43"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@medusajs/medusa": {
|
||||
"optional": true
|
||||
},
|
||||
"axios": {
|
||||
"optional": true
|
||||
},
|
||||
"express": {
|
||||
"optional": true
|
||||
},
|
||||
"get-port": {
|
||||
"optional": true
|
||||
},
|
||||
"pg-god": {
|
||||
"optional": true
|
||||
},
|
||||
"typeorm": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"medusa-core-utils": "^1.2.2",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "81a7ff73d012fda722f6e9ef0bd9ba0232d37808"
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
import { MikroORM, Options, SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
|
||||
export function getDatabaseURL(dbName?: string): string {
|
||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
||||
const DB_NAME = dbName ?? process.env.DB_TEMP_NAME
|
||||
|
||||
return `postgres://${DB_USERNAME}${
|
||||
DB_PASSWORD ? `:${DB_PASSWORD}` : ""
|
||||
}@${DB_HOST}/${DB_NAME}`
|
||||
}
|
||||
|
||||
export function getMikroOrmConfig({
|
||||
mikroOrmEntities,
|
||||
pathToMigrations,
|
||||
clientUrl,
|
||||
schema,
|
||||
}: {
|
||||
mikroOrmEntities: any[]
|
||||
pathToMigrations?: string
|
||||
clientUrl?: string
|
||||
schema?: string
|
||||
}): Options {
|
||||
const DB_URL = clientUrl ?? getDatabaseURL()
|
||||
|
||||
return {
|
||||
type: "postgresql",
|
||||
clientUrl: DB_URL,
|
||||
entities: Object.values(mikroOrmEntities),
|
||||
schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
|
||||
debug: false,
|
||||
migrations: {
|
||||
pathTs: pathToMigrations,
|
||||
silent: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export interface TestDatabase {
|
||||
mikroOrmEntities: any[]
|
||||
pathToMigrations?: string
|
||||
schema?: string
|
||||
clientUrl?: string
|
||||
|
||||
orm: MikroORM | null
|
||||
manager: SqlEntityManager | null
|
||||
|
||||
setupDatabase(): Promise<void>
|
||||
clearDatabase(): Promise<void>
|
||||
getManager(): SqlEntityManager
|
||||
forkManager(): SqlEntityManager
|
||||
getOrm(): MikroORM
|
||||
}
|
||||
|
||||
export function getMikroOrmWrapper({
|
||||
mikroOrmEntities,
|
||||
pathToMigrations,
|
||||
clientUrl,
|
||||
schema,
|
||||
}: {
|
||||
mikroOrmEntities: any[]
|
||||
pathToMigrations?: string
|
||||
clientUrl?: string
|
||||
schema?: string
|
||||
}): TestDatabase {
|
||||
return {
|
||||
mikroOrmEntities,
|
||||
pathToMigrations,
|
||||
clientUrl: clientUrl ?? getDatabaseURL(),
|
||||
schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
|
||||
|
||||
orm: null,
|
||||
manager: null,
|
||||
|
||||
getManager() {
|
||||
if (this.manager === null) {
|
||||
throw new Error("manager entity not available")
|
||||
}
|
||||
|
||||
return this.manager
|
||||
},
|
||||
|
||||
forkManager() {
|
||||
if (this.manager === null) {
|
||||
throw new Error("manager entity not available")
|
||||
}
|
||||
|
||||
return this.manager.fork()
|
||||
},
|
||||
|
||||
getOrm() {
|
||||
if (this.orm === null) {
|
||||
throw new Error("orm entity not available")
|
||||
}
|
||||
|
||||
return this.orm
|
||||
},
|
||||
|
||||
async setupDatabase() {
|
||||
const OrmConfig = getMikroOrmConfig({
|
||||
mikroOrmEntities: this.mikroOrmEntities,
|
||||
pathToMigrations: this.pathToMigrations,
|
||||
clientUrl: this.clientUrl,
|
||||
schema: this.schema,
|
||||
})
|
||||
|
||||
// Initializing the ORM
|
||||
this.orm = await MikroORM.init(OrmConfig)
|
||||
|
||||
this.manager = this.orm.em
|
||||
|
||||
try {
|
||||
await this.orm.getSchemaGenerator().ensureDatabase()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
await this.manager?.execute(
|
||||
`CREATE SCHEMA IF NOT EXISTS "${this.schema ?? "public"}";`
|
||||
)
|
||||
|
||||
const pendingMigrations = await this.orm
|
||||
.getMigrator()
|
||||
.getPendingMigrations()
|
||||
|
||||
if (pendingMigrations && pendingMigrations.length > 0) {
|
||||
await this.orm
|
||||
.getMigrator()
|
||||
.up({ migrations: pendingMigrations.map((m) => m.name!) })
|
||||
} else {
|
||||
await this.orm.schema.refreshDatabase() // ensure db exists and is fresh
|
||||
}
|
||||
},
|
||||
|
||||
async clearDatabase() {
|
||||
if (this.orm === null) {
|
||||
throw new Error("ORM not configured")
|
||||
}
|
||||
|
||||
await this.manager?.execute(
|
||||
`DROP SCHEMA IF EXISTS "${this.schema ?? "public"}" CASCADE;`
|
||||
)
|
||||
|
||||
await this.manager?.execute(
|
||||
`CREATE SCHEMA IF NOT EXISTS "${this.schema ?? "public"}";`
|
||||
)
|
||||
|
||||
try {
|
||||
await this.orm.close()
|
||||
} catch {}
|
||||
|
||||
this.orm = null
|
||||
this.manager = null
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import randomize from "randomatic"
|
||||
|
||||
class IdMap {
|
||||
ids = {}
|
||||
|
||||
getId(key, prefix = "", length = 10) {
|
||||
if (this.ids[key]) {
|
||||
return this.ids[key]
|
||||
}
|
||||
|
||||
const id = `${prefix && prefix + "_"}${randomize("Aa0", length)}`
|
||||
this.ids[key] = id
|
||||
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new IdMap()
|
||||
export default instance
|
||||
@@ -1,9 +0,0 @@
|
||||
export * as TestDatabaseUtils from "./database"
|
||||
export { default as IdMap } from "./id-map"
|
||||
export * as JestUtils from "./jest"
|
||||
export { default as MockManager } from "./mock-manager"
|
||||
export { default as MockRepository } from "./mock-repository"
|
||||
export * from "./init-modules"
|
||||
export { default as MockEventBusService } from "./mock-event-bus-service"
|
||||
export * from "./module-test-runner"
|
||||
export * from "./medusa-test-runner"
|
||||
@@ -1,80 +0,0 @@
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
ModulesSdkUtils,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
export interface InitModulesOptions {
|
||||
injectedDependencies?: Record<string, unknown>
|
||||
databaseConfig: {
|
||||
clientUrl: string
|
||||
schema?: string
|
||||
}
|
||||
modulesConfig: {
|
||||
[key: string]:
|
||||
| string
|
||||
| boolean
|
||||
| Partial<InternalModuleDeclaration | ExternalModuleDeclaration>
|
||||
}
|
||||
joinerConfig?: ModuleJoinerConfig[]
|
||||
preventConnectionDestroyWarning?: boolean
|
||||
}
|
||||
|
||||
export async function initModules({
|
||||
injectedDependencies,
|
||||
databaseConfig,
|
||||
modulesConfig,
|
||||
joinerConfig,
|
||||
preventConnectionDestroyWarning = false,
|
||||
}: InitModulesOptions) {
|
||||
const moduleSdkImports = require("@medusajs/modules-sdk")
|
||||
|
||||
injectedDependencies ??= {}
|
||||
|
||||
let sharedPgConnection =
|
||||
injectedDependencies?.[ContainerRegistrationKeys.PG_CONNECTION]
|
||||
|
||||
let shouldDestroyConnectionAutomatically = !sharedPgConnection
|
||||
if (!sharedPgConnection) {
|
||||
sharedPgConnection = ModulesSdkUtils.createPgConnection({
|
||||
clientUrl: databaseConfig.clientUrl,
|
||||
schema: databaseConfig.schema,
|
||||
})
|
||||
|
||||
injectedDependencies[ContainerRegistrationKeys.PG_CONNECTION] =
|
||||
sharedPgConnection
|
||||
}
|
||||
|
||||
const medusaApp = await moduleSdkImports.MedusaApp({
|
||||
modulesConfig,
|
||||
servicesConfig: joinerConfig,
|
||||
injectedDependencies,
|
||||
})
|
||||
|
||||
async function shutdown() {
|
||||
if (shouldDestroyConnectionAutomatically) {
|
||||
await promiseAll([
|
||||
(sharedPgConnection as any).context?.destroy(),
|
||||
(sharedPgConnection as any).destroy(),
|
||||
medusaApp.onApplicationShutdown(),
|
||||
])
|
||||
} else {
|
||||
if (!preventConnectionDestroyWarning) {
|
||||
console.info(
|
||||
`You are using a custom shared connection. The connection won't be destroyed automatically.`
|
||||
)
|
||||
}
|
||||
}
|
||||
moduleSdkImports.MedusaModule.clearInstances()
|
||||
}
|
||||
|
||||
return {
|
||||
medusaApp,
|
||||
shutdown,
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { dropDatabase } from "pg-god"
|
||||
|
||||
export function afterAllHookDropDatabase() {
|
||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||
const DB_USERNAME = process.env.DB_USERNAME ?? "postgres"
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
|
||||
const DB_NAME = process.env.DB_TEMP_NAME || ""
|
||||
|
||||
const pgGodCredentials = {
|
||||
user: DB_USERNAME,
|
||||
password: DB_PASSWORD,
|
||||
host: DB_HOST,
|
||||
}
|
||||
|
||||
afterAll(async () => {
|
||||
try {
|
||||
await dropDatabase({ databaseName: DB_NAME }, pgGodCredentials)
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`This might fail if it is run during the unit tests since there is no database to drop. Otherwise, please check what is the issue. ${e.message}`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
const path = require("path")
|
||||
const express = require("express")
|
||||
const getPort = require("get-port")
|
||||
const { isObject, promiseAll } = require("@medusajs/utils")
|
||||
const { GracefulShutdownServer } = require("medusa-core-utils")
|
||||
|
||||
async function bootstrapApp({ cwd, env = {} } = {}) {
|
||||
const app = express()
|
||||
|
||||
if (isObject(env)) {
|
||||
Object.entries(env).forEach(([k, v]) => (process.env[k] = v))
|
||||
}
|
||||
|
||||
const loaders = require("@medusajs/medusa/dist/loaders").default
|
||||
|
||||
const { container, shutdown } = await loaders({
|
||||
directory: path.resolve(cwd || process.cwd()),
|
||||
expressApp: app,
|
||||
isTest: false,
|
||||
})
|
||||
|
||||
const PORT = await getPort()
|
||||
|
||||
return {
|
||||
shutdown,
|
||||
container,
|
||||
app,
|
||||
port: PORT,
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
startBootstrapApp: async ({
|
||||
cwd,
|
||||
env = {},
|
||||
skipExpressListen = false,
|
||||
} = {}) => {
|
||||
const {
|
||||
app,
|
||||
port,
|
||||
container,
|
||||
shutdown: medusaShutdown,
|
||||
} = await bootstrapApp({
|
||||
cwd,
|
||||
env,
|
||||
})
|
||||
|
||||
let expressServer
|
||||
|
||||
if (skipExpressListen) {
|
||||
return
|
||||
}
|
||||
|
||||
const shutdown = async () => {
|
||||
await promiseAll([expressServer.shutdown(), medusaShutdown()])
|
||||
|
||||
if (typeof global !== "undefined" && global?.gc) {
|
||||
global.gc()
|
||||
}
|
||||
}
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
const server = app.listen(port, async (err) => {
|
||||
if (err) {
|
||||
await shutdown()
|
||||
return reject(err)
|
||||
}
|
||||
process.send(port)
|
||||
resolve({
|
||||
shutdown,
|
||||
container,
|
||||
port,
|
||||
})
|
||||
})
|
||||
|
||||
expressServer = GracefulShutdownServer.create(server)
|
||||
})
|
||||
},
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
const path = require("path")
|
||||
|
||||
const { getConfigFile } = require("medusa-core-utils")
|
||||
const { asValue } = require("awilix")
|
||||
const {
|
||||
isObject,
|
||||
createMedusaContainer,
|
||||
MedusaV2Flag,
|
||||
} = require("@medusajs/utils")
|
||||
const { DataSource } = require("typeorm")
|
||||
const { ContainerRegistrationKeys } = require("@medusajs/utils")
|
||||
const { logger } = require("@medusajs/medusa-cli/dist/reporter")
|
||||
|
||||
module.exports = {
|
||||
initDb: async function ({
|
||||
cwd,
|
||||
// use for v1 datasource only
|
||||
database_extra,
|
||||
env,
|
||||
force_modules_migration,
|
||||
dbUrl = "",
|
||||
dbSchema = "public",
|
||||
}) {
|
||||
if (isObject(env)) {
|
||||
Object.entries(env).forEach(([k, v]) => (process.env[k] = v))
|
||||
}
|
||||
|
||||
const configModuleLoader =
|
||||
require("@medusajs/medusa/dist/loaders/config").default
|
||||
const configModule = configModuleLoader(cwd)
|
||||
|
||||
const featureFlagsLoader =
|
||||
require("@medusajs/medusa/dist/loaders/feature-flags").default
|
||||
|
||||
const featureFlagRouter = featureFlagsLoader(configModule)
|
||||
const modelsLoader = require("@medusajs/medusa/dist/loaders/models").default
|
||||
const entities = modelsLoader({}, { register: false })
|
||||
|
||||
// get migrations with enabled featureflags
|
||||
const migrationDir = path.resolve(
|
||||
path.join(
|
||||
cwd,
|
||||
`../../`,
|
||||
`node_modules`,
|
||||
`@medusajs`,
|
||||
`medusa`,
|
||||
`dist`,
|
||||
`migrations`,
|
||||
`*.js`
|
||||
)
|
||||
)
|
||||
|
||||
const {
|
||||
getEnabledMigrations,
|
||||
getModuleSharedResources,
|
||||
} = require("@medusajs/medusa/dist/commands/utils/get-migrations")
|
||||
|
||||
const { migrations: moduleMigrations, models: moduleModels } =
|
||||
getModuleSharedResources(configModule, featureFlagRouter)
|
||||
|
||||
const enabledMigrations = getEnabledMigrations([migrationDir], (flag) =>
|
||||
featureFlagRouter.isFeatureEnabled(flag)
|
||||
)
|
||||
|
||||
const enabledEntities = entities.filter(
|
||||
(e) => typeof e.isFeatureEnabled === "undefined" || e.isFeatureEnabled()
|
||||
)
|
||||
|
||||
const dbDataSource = new DataSource({
|
||||
type: "postgres",
|
||||
url: dbUrl || configModule.projectConfig.database_url,
|
||||
entities: enabledEntities.concat(moduleModels),
|
||||
migrations: enabledMigrations.concat(moduleMigrations),
|
||||
extra: database_extra ?? {},
|
||||
//name: "integration-tests",
|
||||
schema: dbSchema,
|
||||
})
|
||||
|
||||
await dbDataSource.initialize()
|
||||
|
||||
await dbDataSource.runMigrations()
|
||||
|
||||
if (
|
||||
force_modules_migration ||
|
||||
featureFlagRouter.isFeatureEnabled(MedusaV2Flag.key)
|
||||
) {
|
||||
const pgConnectionLoader =
|
||||
require("@medusajs/medusa/dist/loaders/pg-connection").default
|
||||
|
||||
const featureFlagLoader =
|
||||
require("@medusajs/medusa/dist/loaders/feature-flags").default
|
||||
|
||||
const container = createMedusaContainer()
|
||||
|
||||
const featureFlagRouter = await featureFlagLoader(configModule)
|
||||
|
||||
const pgConnection = await pgConnectionLoader({
|
||||
configModule: {
|
||||
...configModule,
|
||||
projectConfig: {
|
||||
...configModule.projectConfig,
|
||||
database_url: dbUrl || configModule.projectConfig.database_url,
|
||||
},
|
||||
},
|
||||
container,
|
||||
})
|
||||
|
||||
container.register({
|
||||
[ContainerRegistrationKeys.CONFIG_MODULE]: asValue(configModule),
|
||||
[ContainerRegistrationKeys.LOGGER]: asValue(logger),
|
||||
[ContainerRegistrationKeys.MANAGER]: asValue(dbDataSource.manager),
|
||||
[ContainerRegistrationKeys.PG_CONNECTION]: asValue(pgConnection),
|
||||
featureFlagRouter: asValue(featureFlagRouter),
|
||||
})
|
||||
|
||||
const {
|
||||
migrateMedusaApp,
|
||||
} = require("@medusajs/medusa/dist/loaders/medusa-app")
|
||||
await migrateMedusaApp(
|
||||
{ configModule, container },
|
||||
{ registerInContainer: false }
|
||||
)
|
||||
}
|
||||
|
||||
return { dbDataSource, pgConnection }
|
||||
},
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
import { getDatabaseURL } from "./database"
|
||||
import { initDb } from "./medusa-test-runner-utils/use-db"
|
||||
import { startBootstrapApp } from "./medusa-test-runner-utils/bootstrap-app"
|
||||
import { createDatabase, dropDatabase } from "pg-god"
|
||||
import {ContainerLike, MedusaContainer} from "@medusajs/types"
|
||||
import { createMedusaContainer } from "@medusajs/utils"
|
||||
|
||||
const axios = require("axios").default
|
||||
|
||||
const DB_HOST = process.env.DB_HOST
|
||||
const DB_USERNAME = process.env.DB_USERNAME
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
||||
|
||||
const pgGodCredentials = {
|
||||
user: DB_USERNAME,
|
||||
password: DB_PASSWORD,
|
||||
host: DB_HOST,
|
||||
}
|
||||
|
||||
const dbTestUtilFactory = (): any => ({
|
||||
db_: null,
|
||||
pgConnection_: null,
|
||||
|
||||
clear: async function () {
|
||||
this.db_?.synchronize(true)
|
||||
},
|
||||
|
||||
create: async function (dbName: string) {
|
||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||
},
|
||||
|
||||
teardown: async function ({
|
||||
forceDelete,
|
||||
schema,
|
||||
}: { forceDelete?: string[]; schema?: string } = {}) {
|
||||
forceDelete ??= []
|
||||
if (!this.db_) {
|
||||
return
|
||||
}
|
||||
|
||||
const manager = this.db_.manager
|
||||
|
||||
schema ??= "public"
|
||||
|
||||
await manager.query(`SET session_replication_role = 'replica';`)
|
||||
const tableNames = await manager.query(`SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = '${schema}';`)
|
||||
|
||||
for (const { table_name } of tableNames) {
|
||||
await manager.query(`DELETE
|
||||
FROM ${schema}."${table_name}";`)
|
||||
}
|
||||
|
||||
await manager.query(`SET session_replication_role = 'origin';`)
|
||||
},
|
||||
|
||||
shutdown: async function (dbName: string) {
|
||||
await this.db_?.destroy()
|
||||
await this.pgConnection_?.context?.destroy()
|
||||
await this.pgConnection_?.destroy()
|
||||
|
||||
return await dropDatabase(
|
||||
{ databaseName: dbName, errorIfNonExist: false },
|
||||
pgGodCredentials
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
export interface MedusaSuiteOptions<TService = unknown> {
|
||||
dbUtils: any
|
||||
dbConnection: any // Legacy typeorm connection
|
||||
getContainer: () => MedusaContainer
|
||||
api: any
|
||||
dbConfig: {
|
||||
dbName: string
|
||||
schema: string
|
||||
clientUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
export function medusaIntegrationTestRunner({
|
||||
moduleName,
|
||||
dbName,
|
||||
schema = "public",
|
||||
env = {},
|
||||
force_modules_migration = false,
|
||||
debug = false,
|
||||
testSuite,
|
||||
}: {
|
||||
moduleName?: string
|
||||
env?: Record<string, any>
|
||||
dbName?: string
|
||||
schema?: string
|
||||
debug?: boolean
|
||||
force_modules_migration?: boolean
|
||||
testSuite: <TService = unknown>(options: MedusaSuiteOptions<TService>) => void
|
||||
}) {
|
||||
const tempName = parseInt(process.env.JEST_WORKER_ID || "1")
|
||||
moduleName = moduleName ?? Math.random().toString(36).substring(7)
|
||||
dbName ??= `medusa-${moduleName.toLowerCase()}-integration-${tempName}`
|
||||
|
||||
let dbConfig = {
|
||||
dbName,
|
||||
clientUrl: getDatabaseURL(dbName),
|
||||
schema,
|
||||
debug,
|
||||
}
|
||||
|
||||
const originalConfigLoader =
|
||||
require("@medusajs/medusa/dist/loaders/config").default
|
||||
require("@medusajs/medusa/dist/loaders/config").default = (
|
||||
rootDirectory: string
|
||||
) => {
|
||||
const config = originalConfigLoader(rootDirectory)
|
||||
config.projectConfig.database_url = dbConfig.clientUrl
|
||||
config.projectConfig.database_driver_options = dbConfig.clientUrl.includes("localhost") ? {} : {
|
||||
connection: {
|
||||
ssl: { rejectUnauthorized: false },
|
||||
},
|
||||
idle_in_transaction_session_timeout: 20000,
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
const cwd = process.cwd()
|
||||
|
||||
let shutdown = async () => void 0
|
||||
let dbUtils = dbTestUtilFactory()
|
||||
let container: ContainerLike
|
||||
let apiUtils: any
|
||||
|
||||
let options = {
|
||||
dbUtils,
|
||||
api: new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (target, prop) => {
|
||||
return apiUtils[prop]
|
||||
},
|
||||
}
|
||||
),
|
||||
dbConnection: new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (target, prop) => {
|
||||
return dbUtils.db_[prop]
|
||||
},
|
||||
}
|
||||
),
|
||||
getContainer: () => container,
|
||||
} as MedusaSuiteOptions
|
||||
|
||||
let isFirstTime = true
|
||||
|
||||
const beforeAll_ = async () => {
|
||||
await dbUtils.create(dbName)
|
||||
|
||||
let dataSourceRes
|
||||
let pgConnectionRes
|
||||
|
||||
try {
|
||||
const { dbDataSource, pgConnection } = await initDb({
|
||||
cwd,
|
||||
env,
|
||||
force_modules_migration,
|
||||
database_extra: {},
|
||||
dbUrl: dbConfig.clientUrl,
|
||||
dbSchema: dbConfig.schema,
|
||||
})
|
||||
|
||||
dataSourceRes = dbDataSource
|
||||
pgConnectionRes = pgConnection
|
||||
} catch (error) {
|
||||
console.error("Error initializing database", error?.message)
|
||||
throw error
|
||||
}
|
||||
|
||||
dbUtils.db_ = dataSourceRes
|
||||
dbUtils.pgConnection_ = pgConnectionRes
|
||||
|
||||
let containerRes
|
||||
let serverShutdownRes
|
||||
let portRes
|
||||
try {
|
||||
const {
|
||||
shutdown = () => void 0,
|
||||
container,
|
||||
port,
|
||||
} = await startBootstrapApp({
|
||||
cwd,
|
||||
env,
|
||||
})
|
||||
|
||||
containerRes = container
|
||||
serverShutdownRes = shutdown
|
||||
portRes = port
|
||||
} catch (error) {
|
||||
console.error("Error starting the app", error?.message)
|
||||
throw error
|
||||
}
|
||||
|
||||
const cancelTokenSource = axios.CancelToken.source()
|
||||
|
||||
container = containerRes
|
||||
shutdown = async () => {
|
||||
await serverShutdownRes()
|
||||
cancelTokenSource.cancel("Request canceled by shutdown")
|
||||
}
|
||||
|
||||
apiUtils = axios.create({
|
||||
baseURL: `http://localhost:${portRes}`,
|
||||
cancelToken: cancelTokenSource.token,
|
||||
})
|
||||
}
|
||||
|
||||
const beforeEach_ = async () => {
|
||||
// The beforeAll already run everything, so lets not re run the loaders for the first iteration
|
||||
if (isFirstTime) {
|
||||
isFirstTime = false
|
||||
return
|
||||
}
|
||||
|
||||
const container = options.getContainer()
|
||||
const copiedContainer = createMedusaContainer({}, container)
|
||||
|
||||
if (process.env.MEDUSA_FF_MEDUSA_V2 != "true") {
|
||||
try {
|
||||
const defaultLoader =
|
||||
require("@medusajs/medusa/dist/loaders/defaults").default
|
||||
await defaultLoader({
|
||||
container: copiedContainer,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Error runner medusa loaders", error?.message)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const medusaAppLoaderRunner =
|
||||
require("@medusajs/medusa/dist/loaders/medusa-app").runModulesLoader
|
||||
await medusaAppLoaderRunner({
|
||||
container: copiedContainer,
|
||||
configModule: container.resolve("configModule"),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Error runner modules loaders", error?.message)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const afterEach_ = async () => {
|
||||
try {
|
||||
await dbUtils.teardown({ schema })
|
||||
} catch (error) {
|
||||
console.error("Error tearing down database:", error?.message)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
return describe("", () => {
|
||||
beforeAll(beforeAll_)
|
||||
beforeEach(beforeEach_)
|
||||
afterEach(afterEach_)
|
||||
afterAll(async () => {
|
||||
await dbUtils.shutdown(dbName)
|
||||
await shutdown()
|
||||
})
|
||||
|
||||
testSuite(options!)
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import {
|
||||
EmitData,
|
||||
EventBusTypes,
|
||||
IEventBusModuleService,
|
||||
Message,
|
||||
Subscriber,
|
||||
} from "@medusajs/types"
|
||||
|
||||
export default class EventBusService implements IEventBusModuleService {
|
||||
emit<T>(
|
||||
eventName: string,
|
||||
data: T,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<void>
|
||||
emit<T>(data: EmitData<T>[]): Promise<void>
|
||||
emit<T>(data: Message<T>[]): Promise<void>
|
||||
|
||||
async emit<
|
||||
T,
|
||||
TInput extends
|
||||
| string
|
||||
| EventBusTypes.EmitData<T>[]
|
||||
| EventBusTypes.Message<T>[] = string
|
||||
>(
|
||||
eventOrData: TInput,
|
||||
data?: T,
|
||||
options: Record<string, unknown> = {}
|
||||
): Promise<void> {}
|
||||
|
||||
subscribe(event: string | symbol, subscriber: Subscriber): this {
|
||||
return this
|
||||
}
|
||||
|
||||
unsubscribe(
|
||||
event: string | symbol,
|
||||
subscriber: Subscriber,
|
||||
context?: EventBusTypes.SubscriberContext
|
||||
): this {
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
export default {
|
||||
connection: {
|
||||
getMetadata: (target) => {
|
||||
return (
|
||||
target["metadata"] ?? {
|
||||
columns: [],
|
||||
}
|
||||
)
|
||||
},
|
||||
},
|
||||
|
||||
getRepository: function (repo) {
|
||||
return repo
|
||||
},
|
||||
|
||||
withRepository: function (repo) {
|
||||
if (repo) {
|
||||
return Object.assign(repo, { manager: this })
|
||||
}
|
||||
|
||||
return repo
|
||||
},
|
||||
|
||||
transaction: function (isolationOrCb, cb) {
|
||||
if (typeof isolationOrCb === "string") {
|
||||
return cb(this)
|
||||
} else {
|
||||
return isolationOrCb(this)
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
class MockRepo {
|
||||
constructor({
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
softRemove,
|
||||
find,
|
||||
findDescendantsTree,
|
||||
findOne,
|
||||
findOneWithRelations,
|
||||
findOneOrFail,
|
||||
save,
|
||||
findAndCount,
|
||||
del,
|
||||
count,
|
||||
insertBulk,
|
||||
metadata,
|
||||
}) {
|
||||
this.create_ = create
|
||||
this.update_ = update
|
||||
this.remove_ = remove
|
||||
this.delete_ = del
|
||||
this.softRemove_ = softRemove
|
||||
this.find_ = find
|
||||
this.findDescendantsTree_ = findDescendantsTree
|
||||
this.findOne_ = findOne
|
||||
this.findOneOrFail_ = findOneOrFail
|
||||
this.save_ = save
|
||||
this.findAndCount_ = findAndCount
|
||||
this.findOneWithRelations_ = findOneWithRelations
|
||||
this.insertBulk_ = insertBulk
|
||||
this.count_ = count
|
||||
|
||||
this.metadata = metadata ?? {
|
||||
columns: [],
|
||||
}
|
||||
}
|
||||
|
||||
setFindOne(fn) {
|
||||
this.findOne_ = fn
|
||||
}
|
||||
|
||||
insertBulk = jest.fn().mockImplementation((...args) => {
|
||||
if (this.insertBulk_) {
|
||||
return this.insertBulk_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
create = jest.fn().mockImplementation((...args) => {
|
||||
if (this.create_) {
|
||||
return this.create_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
softRemove = jest.fn().mockImplementation((...args) => {
|
||||
if (this.softRemove_) {
|
||||
return this.softRemove_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
remove = jest.fn().mockImplementation((...args) => {
|
||||
if (this.remove_) {
|
||||
return this.remove_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
update = jest.fn().mockImplementation((...args) => {
|
||||
if (this.update_) {
|
||||
return this.update_(...args)
|
||||
}
|
||||
})
|
||||
findOneOrFail = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOneOrFail_) {
|
||||
return this.findOneOrFail_(...args)
|
||||
}
|
||||
})
|
||||
findOneWithRelations = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOneWithRelations_) {
|
||||
return this.findOneWithRelations_(...args)
|
||||
}
|
||||
})
|
||||
findOne = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOne_) {
|
||||
return this.findOne_(...args)
|
||||
}
|
||||
})
|
||||
findDescendantsTree = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findDescendantsTree_) {
|
||||
return this.findDescendantsTree_(...args)
|
||||
}
|
||||
})
|
||||
find = jest.fn().mockImplementation((...args) => {
|
||||
if (this.find_) {
|
||||
return this.find_(...args)
|
||||
}
|
||||
})
|
||||
save = jest.fn().mockImplementation((...args) => {
|
||||
if (this.save_) {
|
||||
return this.save_(...args)
|
||||
}
|
||||
return Promise.resolve(...args)
|
||||
})
|
||||
|
||||
findAndCount = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findAndCount_) {
|
||||
return this.findAndCount_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
count = jest.fn().mockImplementation((...args) => {
|
||||
if (this.count_) {
|
||||
return this.count_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
|
||||
delete = jest.fn().mockImplementation((...args) => {
|
||||
if (this.delete_) {
|
||||
return this.delete_(...args)
|
||||
}
|
||||
return {}
|
||||
})
|
||||
}
|
||||
|
||||
export default (methods = {}) => {
|
||||
return new MockRepo(methods)
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
import { initModules, InitModulesOptions } from "./init-modules"
|
||||
import { getDatabaseURL, getMikroOrmWrapper, TestDatabase } from "./database"
|
||||
|
||||
import { MockEventBusService } from "."
|
||||
import { ContainerRegistrationKeys, ModulesSdkUtils } from "@medusajs/utils"
|
||||
|
||||
export interface SuiteOptions<TService = unknown> {
|
||||
MikroOrmWrapper: TestDatabase
|
||||
medusaApp: any
|
||||
service: TService
|
||||
dbConfig: {
|
||||
schema: string
|
||||
clientUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
export function moduleIntegrationTestRunner({
|
||||
moduleName,
|
||||
moduleModels,
|
||||
moduleOptions = {},
|
||||
joinerConfig = [],
|
||||
schema = "public",
|
||||
debug = false,
|
||||
testSuite,
|
||||
resolve,
|
||||
injectedDependencies = {},
|
||||
}: {
|
||||
moduleName: string
|
||||
moduleModels?: any[]
|
||||
moduleOptions?: Record<string, any>
|
||||
joinerConfig?: any[]
|
||||
schema?: string
|
||||
dbName?: string
|
||||
injectedDependencies?: Record<string, any>
|
||||
resolve?: string
|
||||
debug?: boolean
|
||||
testSuite: <TService = unknown>(options: SuiteOptions<TService>) => void
|
||||
}) {
|
||||
const moduleSdkImports = require("@medusajs/modules-sdk")
|
||||
|
||||
process.env.LOG_LEVEL = "error"
|
||||
|
||||
moduleModels ??= Object.values(require(`${process.cwd()}/src/models`))
|
||||
// migrationPath ??= process.cwd() + "/src/migrations/!(*.d).{js,ts,cjs}"
|
||||
|
||||
const tempName = parseInt(process.env.JEST_WORKER_ID || "1")
|
||||
const dbName = `medusa-${moduleName.toLowerCase()}-integration-${tempName}`
|
||||
|
||||
const dbConfig = {
|
||||
clientUrl: getDatabaseURL(dbName),
|
||||
schema,
|
||||
debug,
|
||||
}
|
||||
|
||||
// Use a unique connection for all the entire suite
|
||||
const connection = ModulesSdkUtils.createPgConnection(dbConfig)
|
||||
|
||||
const MikroOrmWrapper = getMikroOrmWrapper({
|
||||
mikroOrmEntities: moduleModels,
|
||||
clientUrl: dbConfig.clientUrl,
|
||||
schema: dbConfig.schema,
|
||||
})
|
||||
|
||||
const modulesConfig_ = {
|
||||
[moduleName]: {
|
||||
definition: moduleSdkImports.ModulesDefinition[moduleName],
|
||||
resolve,
|
||||
options: {
|
||||
defaultAdapterOptions: {
|
||||
database: dbConfig,
|
||||
},
|
||||
database: dbConfig,
|
||||
...moduleOptions,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const moduleOptions_: InitModulesOptions = {
|
||||
injectedDependencies: {
|
||||
[ContainerRegistrationKeys.PG_CONNECTION]: connection,
|
||||
eventBusService: new MockEventBusService(),
|
||||
[ContainerRegistrationKeys.LOGGER]: console,
|
||||
...injectedDependencies,
|
||||
},
|
||||
modulesConfig: modulesConfig_,
|
||||
databaseConfig: dbConfig,
|
||||
joinerConfig,
|
||||
preventConnectionDestroyWarning: true,
|
||||
}
|
||||
|
||||
let shutdown: () => Promise<void>
|
||||
let moduleService
|
||||
let medusaApp = {}
|
||||
|
||||
const options = {
|
||||
MikroOrmWrapper,
|
||||
medusaApp: new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (target, prop) => {
|
||||
return medusaApp[prop]
|
||||
},
|
||||
}
|
||||
),
|
||||
service: new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (target, prop) => {
|
||||
return moduleService[prop]
|
||||
},
|
||||
}
|
||||
),
|
||||
} as SuiteOptions
|
||||
|
||||
const beforeEach_ = async () => {
|
||||
await MikroOrmWrapper.setupDatabase()
|
||||
const output = await initModules(moduleOptions_)
|
||||
shutdown = output.shutdown
|
||||
medusaApp = output.medusaApp
|
||||
moduleService = output.medusaApp.modules[moduleName]
|
||||
}
|
||||
|
||||
const afterEach_ = async () => {
|
||||
await MikroOrmWrapper.clearDatabase()
|
||||
await shutdown()
|
||||
moduleService = {}
|
||||
medusaApp = {}
|
||||
}
|
||||
|
||||
return describe("", () => {
|
||||
beforeEach(beforeEach_)
|
||||
afterEach(afterEach_)
|
||||
afterAll(async () => {
|
||||
await (connection as any).context?.destroy()
|
||||
await (connection as any).destroy()
|
||||
})
|
||||
|
||||
testSuite(options)
|
||||
})
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es5", "es6", "es2019"],
|
||||
"target": "es5",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitReturns": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user