chore: Start cleaning up medusa-core-utils (#7450)

**What**
- remove medusa-core-utils
- dispatch the utils where they belongs
- update usage

**NOTE**
I have been wondering if the graceful class should go into the utils package or medusa package, I ve put it in the medusa package as it seems to be the best place I can see for now and is tight to the server as well. Also, I wanted to avoid the utils package to depends on http and net dependencies, happy to change that if you feel like it
This commit is contained in:
Adrien de Peretti
2024-05-27 10:00:15 +02:00
committed by GitHub
parent 28a3f9a3df
commit b8bc3ed16f
69 changed files with 61 additions and 1384 deletions

View File

@@ -17,7 +17,6 @@
"@medusajs/ui": patch
"@medusajs/ui-preset": patch
"@medusajs/medusa": patch
"medusa-core-utils": patch
"medusa-telemetry": patch
"@medusajs/api-key": patch
"@medusajs/auth": patch

View File

@@ -19,9 +19,8 @@ const {
simpleProductFactory,
simpleCartFactory,
simpleShippingOptionFactory,
simpleOrderFactory,
} = require("../../../factories")
const { MedusaError } = require("medusa-core-utils")
const { MedusaError } = require("@medusajs/utils")
jest.setTimeout(30000)

View File

@@ -1,6 +1,6 @@
const path = require("path")
const { getConfigFile } = require("medusa-core-utils")
const { getConfigFile } = require("@medusajs/utils")
const { asValue } = require("awilix")
const {
isObject,

View File

@@ -2,7 +2,7 @@ const path = require("path")
require("dotenv").config({ path: path.join(__dirname, "../.env.test") })
const { getConfigFile } = require("medusa-core-utils")
const { getConfigFile } = require("@medusajs/utils")
const { createDatabase, dropDatabase } = require("pg-god")
const { DataSource } = require("typeorm")

View File

@@ -52,7 +52,6 @@
"inquirer": "^8.0.0",
"is-valid-path": "^0.1.1",
"meant": "^1.0.3",
"medusa-core-utils": "^1.2.0",
"medusa-telemetry": "^0.0.17",
"open": "^8.0.6",
"ora": "^5.4.1",

View File

@@ -4,7 +4,6 @@ import path from "path"
import resolveCwd from "resolve-cwd"
import { didYouMean } from "./did-you-mean"
import { getLocalMedusaVersion } from "./util/version"
import { newStarter } from "./commands/new"
import reporter from "./reporter"
@@ -362,7 +361,17 @@ function getVersionInfo() {
const { version } = require(`../package.json`)
const isMedusaProject = isLocalMedusaProject()
if (isMedusaProject) {
let medusaVersion = getLocalMedusaVersion()
let medusaVersion = ""
try {
medusaVersion = require(path.join(
process.cwd(),
`node_modules`,
`@medusajs/medusa`,
`package.json`
)).version
} catch (e) {
/* noop */
}
if (!medusaVersion) {
medusaVersion = `unknown`

View File

@@ -1,5 +0,0 @@
import { getMedusaVersion } from "medusa-core-utils"
export const getLocalMedusaVersion = (): string => {
return getMedusaVersion()
}

View File

@@ -1,8 +1,7 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IInventoryServiceNext } from "@medusajs/types"
import { promiseAll } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { MedusaError } from "medusa-core-utils"
import { MedusaError, promiseAll } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
interface StepInput {
items: {

View File

@@ -1,5 +1,5 @@
import { BigNumberInput } from "@medusajs/types"
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
interface ConfirmInventoryPreparationInput {
product_variant_inventory_items: {

View File

@@ -1,6 +1,5 @@
import { RegionTypes } from "@medusajs/types"
import { MedusaError } from "@medusajs/utils"
import { isDefined } from "medusa-core-utils"
import { isDefined, MedusaError } from "@medusajs/utils"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

View File

@@ -1,5 +1,4 @@
import { MedusaError } from "@medusajs/utils"
import { isDefined } from "medusa-core-utils"
import { isDefined, MedusaError } from "@medusajs/utils"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

View File

@@ -63,7 +63,6 @@
"@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"

View File

@@ -2,7 +2,10 @@ 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")
// TODO: fix that once we find the appropriate place to put this util
const {
GracefulShutdownServer,
} = require("@medusajs/medusa/dist/utils/graceful-shutdown-server")
async function bootstrapApp({ cwd, env = {} } = {}) {
const app = express()
@@ -16,7 +19,6 @@ async function bootstrapApp({ cwd, env = {} } = {}) {
const { container, shutdown } = await loaders({
directory: path.resolve(cwd || process.cwd()),
expressApp: app,
isTest: false,
})
const PORT = await getPort()

View File

@@ -6,7 +6,7 @@ import { join } from "path"
* @param {string} configName - the name of the config file.
* @return {object} an object containing the config module and its path as well as an error property if the config couldn't be loaded.
*/
function getConfigFile<TConfig = unknown>(
export function getConfigFile<TConfig = unknown>(
rootDir: string,
configName: string
): { configModule: TConfig; configFilePath: string; error?: any } {
@@ -28,5 +28,3 @@ function getConfigFile<TConfig = unknown>(
return { configModule, configFilePath, error: err }
}
export default getConfigFile

View File

@@ -59,3 +59,5 @@ export * from "./upper-case-first"
export * from "./wrap-handler"
export * from "./to-handle"
export * from "./validate-handle"
export * from "./parse-cors-origins"
export * from "./build-regexp-if-valid"

View File

@@ -1,2 +0,0 @@
dist/
node_modules/

View File

@@ -1,380 +0,0 @@
# Change Log
## 1.2.2
### Patch Changes
- [#7003](https://github.com/medusajs/medusa/pull/7003) [`c3efac5a0d`](https://github.com/medusajs/medusa/commit/c3efac5a0d6cfa38e1af8d248138fa83934a8ceb) Thanks [@shahednasser](https://github.com/shahednasser)! - fix(medusa-core-utils): add missing awilix dependency
## 1.2.1
### Patch Changes
- [#5983](https://github.com/medusajs/medusa/pull/5983) [`f86877586`](https://github.com/medusajs/medusa/commit/f86877586147ecedbf7f56a1c57f37ef0c33286c) Thanks [@kasperkristensen](https://github.com/kasperkristensen)! - fix(create-medusa-app,medusa-core-utils): Use NodeJS.Timeout instead of NodeJS.Timer as the latter was deprecated in v14.
chore(icons): Update icons to latest version.
- [#6001](https://github.com/medusajs/medusa/pull/6001) [`46d610bc5`](https://github.com/medusajs/medusa/commit/46d610bc555797df2ae81eb89b18faf1411b33b8) Thanks [@abusaidm](https://github.com/abusaidm)! - Add missing country in admin region and set Libya to formal name
## 1.2.0
### Minor Changes
- [#3408](https://github.com/medusajs/medusa/pull/3408) [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Http Server Graceful Shutdown
- [#3329](https://github.com/medusajs/medusa/pull/3329) [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Inventory and Stock location modules supporting isolated connection
### 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
- [#3352](https://github.com/medusajs/medusa/pull/3352) [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - feat(medusa): Modules initializer
### Loading modules in a project
Example
```typescript
import {
InventoryServiceInitializeOptions,
initialize,
} from "@medusajs/inventory"
const options: InventoryServiceInitializeOptions = {
database: {
type: "postgres",
url: DB_URL,
},
}
const inventoryService = await initialize(options)
const newInventoryItem = await inventoryService.createInventoryItem({
sku: "sku_123",
})
```
## 1.2.0-rc.0
### Minor Changes
- [#3408](https://github.com/medusajs/medusa/pull/3408) [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Http Server Graceful Shutdown
- [#3329](https://github.com/medusajs/medusa/pull/3329) [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - Inventory and Stock location modules supporting isolated connection
### 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
- [#3352](https://github.com/medusajs/medusa/pull/3352) [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5) Thanks [@carlos-r-l-rodrigues](https://github.com/carlos-r-l-rodrigues)! - feat(medusa): Modules initializer
### Loading modules in a project
Example
```typescript
import {
InventoryServiceInitializeOptions,
initialize,
} from "@medusajs/inventory"
const options: InventoryServiceInitializeOptions = {
database: {
type: "postgres",
url: DB_URL,
},
}
const inventoryService = await initialize(options)
const newInventoryItem = await inventoryService.createInventoryItem({
sku: "sku_123",
})
```
## 1.1.39
### 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
## 1.1.38
### 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)
## 1.1.37
### Patch Changes
- [#2783](https://github.com/medusajs/medusa/pull/2783) [`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168) Thanks [@adrien2p](https://github.com/adrien2p)! - fix: getConfigFile typings
## 1.1.36
### Patch Changes
- [#2670](https://github.com/medusajs/medusa/pull/2670) [`1b21af87a`](https://github.com/medusajs/medusa/commit/1b21af87ab80c18013f0f44434e59b873c2313aa) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(medusa-core-utils): Migrate to TS
## 1.1.35
### Patch Changes
- [#2646](https://github.com/medusajs/medusa/pull/2646) [`e7c4cc375`](https://github.com/medusajs/medusa/commit/e7c4cc375174775bb0cfe52e5dc0270237150b3c) Thanks [@pKorsholm](https://github.com/pKorsholm)! - jwt fix
## 1.1.34
### Patch Changes
- [#2514](https://github.com/medusajs/medusa/pull/2514) [`ea3d73882`](https://github.com/medusajs/medusa/commit/ea3d7388234f23c4a5bc7ceb55c493a097b76c12) Thanks [@pKorsholm](https://github.com/pKorsholm)! - Feat(medusa): invalid medusa-config handling in loaders
## 1.1.33
### Patch Changes
- [`5cb7618a2`](https://github.com/medusajs/medusa/commit/5cb7618a220c420ec2917875f91b8c1f814298f2) Thanks [@olivermrbl](https://github.com/olivermrbl)! - Force bump medusa-core-utils
## 1.1.32
### Patch Changes
- [#2210](https://github.com/medusajs/medusa/pull/2210) [`7dc8d3a0c`](https://github.com/medusajs/medusa/commit/7dc8d3a0c90ce06e3f11a6a46dec1f9ec3f26e81) Thanks [@srindom](https://github.com/srindom)! - Adds `computerizeAmount` utility to convert human money format into the DB format Medusa uses (integer of lowest currency unit)
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.30...medusa-core-utils@1.1.31) (2021-12-08)
### Bug Fixes
- **medusa:** migrate cart service to typescript ([#884](https://github.com/medusajs/medusa/issues/884)) ([ed04132](https://github.com/medusajs/medusa/commit/ed041325332e47c5939a301dfd8ace8ad6dbc28d))
### Features
- medusa-source-shopify loader ([#563](https://github.com/medusajs/medusa/issues/563)) ([577bcc2](https://github.com/medusajs/medusa/commit/577bcc23d44c87b91b2b685fd4ddfc5d21a0aa47))
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.29...medusa-core-utils@1.1.30) (2021-11-23)
### Bug Fixes
- bumps class-transformer to 0.5.1 ([#837](https://github.com/medusajs/medusa/issues/837)) ([38b0e29](https://github.com/medusajs/medusa/commit/38b0e295b23eccd281288d854d5876ff418de91d))
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.28...medusa-core-utils@1.1.29) (2021-11-22)
**Note:** Version bump only for package medusa-core-utils
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.27...medusa-core-utils@1.1.28) (2021-11-19)
**Note:** Version bump only for package medusa-core-utils
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.26...medusa-core-utils@1.1.27) (2021-11-19)
### Features
- Typescript for API layer ([#817](https://github.com/medusajs/medusa/issues/817)) ([373532e](https://github.com/medusajs/medusa/commit/373532ecbc8196f47e71af95a8cf82a14a4b1f9e))
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.25...medusa-core-utils@1.1.26) (2021-10-18)
**Note:** Version bump only for package medusa-core-utils
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.24...medusa-core-utils@1.1.25) (2021-10-18)
**Note:** Version bump only for package medusa-core-utils
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.22...medusa-core-utils@1.1.24) (2021-10-18)
### Bug Fixes
- use type to choose transformer before adding or replacing documents ([24eecd2](https://github.com/medusajs/medusa/commit/24eecd2922e0c3425f2d43549b3227c756820387))
### Features
- Product filtering ([#439](https://github.com/medusajs/medusa/issues/439)) ([5ef2a3f](https://github.com/medusajs/medusa/commit/5ef2a3fbcb108c8d49b7754ea14ac890af643950))
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.22...medusa-core-utils@1.1.23) (2021-10-18)
### Bug Fixes
- use type to choose transformer before adding or replacing documents ([24eecd2](https://github.com/medusajs/medusa/commit/24eecd2922e0c3425f2d43549b3227c756820387))
### Features
- Product filtering ([#439](https://github.com/medusajs/medusa/issues/439)) ([5ef2a3f](https://github.com/medusajs/medusa/commit/5ef2a3fbcb108c8d49b7754ea14ac890af643950))
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.21...medusa-core-utils@1.1.22) (2021-09-15)
**Note:** Version bump only for package medusa-core-utils
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.20...medusa-core-utils@1.1.21) (2021-09-14)
**Note:** Version bump only for package medusa-core-utils
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.19...medusa-core-utils@1.1.20) (2021-08-05)
### Features
- In band inventory updates ([#311](https://github.com/medusajs/medusa/issues/311)) ([f07cc0f](https://github.com/medusajs/medusa/commit/f07cc0fa406d8f0fe33f9088fe6cb3ce8e78b05f))
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.18...medusa-core-utils@1.1.19) (2021-07-26)
**Note:** Version bump only for package medusa-core-utils
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.16...medusa-core-utils@1.1.18) (2021-07-15)
**Note:** Version bump only for package medusa-core-utils
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.16...medusa-core-utils@1.1.17) (2021-07-15)
### Bug Fixes
- better store/customer support ([6342e68](https://github.com/medusajs/medusa/commit/6342e68d069636e5eb4877c7ebf7aac952b5e363))
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.15...medusa-core-utils@1.1.16) (2021-07-02)
**Note:** Version bump only for package medusa-core-utils
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.14...medusa-core-utils@1.1.15) (2021-06-22)
### Bug Fixes
- adds transformer to map field names to field_id names ([88d96a2](https://github.com/medusajs/medusa/commit/88d96a29fd8dbc44ed7ba25154850d417577acad))
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.13...medusa-core-utils@1.1.14) (2021-06-09)
**Note:** Version bump only for package medusa-core-utils
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.12...medusa-core-utils@1.1.13) (2021-06-09)
**Note:** Version bump only for package medusa-core-utils
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.11...medusa-core-utils@1.1.12) (2021-06-09)
**Note:** Version bump only for package medusa-core-utils
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.10...medusa-core-utils@1.1.11) (2021-06-09)
**Note:** Version bump only for package medusa-core-utils
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.9...medusa-core-utils@1.1.10) (2021-06-08)
**Note:** Version bump only for package medusa-core-utils
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.6...medusa-core-utils@1.1.9) (2021-04-28)
**Note:** Version bump only for package medusa-core-utils
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.7...medusa-core-utils@1.1.8) (2021-04-20)
**Note:** Version bump only for package medusa-core-utils
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.6...medusa-core-utils@1.1.7) (2021-04-20)
**Note:** Version bump only for package medusa-core-utils
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.5...medusa-core-utils@1.1.6) (2021-04-13)
**Note:** Version bump only for package medusa-core-utils
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.4...medusa-core-utils@1.1.5) (2021-04-09)
**Note:** Version bump only for package medusa-core-utils
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.3...medusa-core-utils@1.1.4) (2021-03-30)
### Bug Fixes
- don't divide zero decimal currencies ([cfab2d4](https://github.com/medusajs/medusa/commit/cfab2d408a296a938266d0989b1de67d060b2ed5))
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.2...medusa-core-utils@1.1.3) (2021-03-17)
**Note:** Version bump only for package medusa-core-utils
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.0...medusa-core-utils@1.1.2) (2021-03-17)
### Features
- **medusa:** Add support for filtering with gt, lt, gte and lte ([#190](https://github.com/medusajs/medusa/issues/190)) ([dd0491f](https://github.com/medusajs/medusa/commit/dd0491f52132aed24f642589b12fcf636b719580))
- **medusa:** cart context ([#201](https://github.com/medusajs/medusa/issues/201)) ([dd7b306](https://github.com/medusajs/medusa/commit/dd7b306333fbe1042f5cf2bed614bce84ea9475f))
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.0...medusa-core-utils@1.1.1) (2021-03-17)
### Features
- **medusa:** Add support for filtering with gt, lt, gte and lte ([#190](https://github.com/medusajs/medusa/issues/190)) ([dd0491f](https://github.com/medusajs/medusa/commit/dd0491f52132aed24f642589b12fcf636b719580))
- **medusa:** cart context ([#201](https://github.com/medusajs/medusa/issues/201)) ([dd7b306](https://github.com/medusajs/medusa/commit/dd7b306333fbe1042f5cf2bed614bce84ea9475f))
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.0.11...medusa-core-utils@1.1.0) (2021-01-26)
**Note:** Version bump only for package medusa-core-utils
## 1.0.11 (2020-11-24)
## 1.0.10 (2020-09-09)
### Bug Fixes
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
## 1.0.7 (2020-09-07)
### Bug Fixes
- **medusa-core-utils:** adds country utils ([00cbf84](https://github.com/medusajs/medusa/commit/00cbf8444d7b64ae8040db187748a63c64509686))
## 1.0.1 (2020-09-05)
## 1.0.1-beta.0 (2020-09-04)
### Bug Fixes
- **medusa:** product variant metadata ([#98](https://github.com/medusajs/medusa/issues/98)) ([520115a](https://github.com/medusajs/medusa/commit/520115a2cef7ee3f0259a682bd82e693c6327790))
# 1.0.0 (2020-09-03)
# 1.0.0-alpha.30 (2020-08-28)
# 1.0.0-alpha.27 (2020-08-27)
### Bug Fixes
- **contentful-plugin:** Keep existing entry fields ([eb47896](https://github.com/medusajs/medusa/commit/eb478966684776bb2aa48e98789519644b05cd33))
# 1.0.0-alpha.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))

View File

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

View File

@@ -1,36 +0,0 @@
{
"name": "medusa-core-utils",
"version": "1.2.2",
"description": "Core utils for Medusa",
"main": "dist/index.js",
"engines": {
"node": ">=16"
},
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/medusa-core-utils"
},
"scripts": {
"test": "jest",
"build": "rimraf dist && tsc --build",
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"watch": "tsc --watch"
},
"files": [
"dist"
],
"author": "Sebastian Rindom",
"license": "MIT",
"devDependencies": {
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"rimraf": "^5.0.1",
"ts-jest": "^25.5.1",
"typescript": "^4.4.4"
},
"gitHead": "a69b1e85be1da3b1b5bc4c5446471252623c8808",
"dependencies": {
"awilix": "^8.0.0"
}
}

View File

@@ -1,105 +0,0 @@
import { transformIdableFields } from "../transform-idable-fields"
describe("transformIdableFields", () => {
test("one field", () => {
const test = {
shipping_address: "test_id",
}
const result = transformIdableFields(test, ["shipping_address"])
expect(test).toEqual(test)
expect(result).toEqual({
shipping_address_id: "test_id",
})
})
test("duplicate field", () => {
const test = {
shipping_address: "test_id",
shipping_address_id: "something else",
}
const result = transformIdableFields(test, ["shipping_address"])
expect(test).toEqual(test)
expect(result).toEqual({
shipping_address_id: "test_id",
})
})
test("many fields", () => {
const test = {
shipping_address: "test_id",
customer: "cus_test",
region: "reg_test",
something: "else",
}
const result = transformIdableFields(test, [
"shipping_address",
"customer",
"region",
])
expect(test).toEqual(test)
expect(result).toEqual({
shipping_address_id: "test_id",
customer_id: "cus_test",
region_id: "reg_test",
something: "else",
})
})
test("mix fields", () => {
const test = {
shipping_address: {
address_1: "my home",
},
customer: "cus_test",
region: "reg_test",
something: "else",
}
const result = transformIdableFields(test, [
"shipping_address",
"customer",
"region",
])
expect(test).toEqual(test)
expect(result).toEqual({
shipping_address: {
address_1: "my home",
},
customer_id: "cus_test",
region_id: "reg_test",
something: "else",
})
})
test("no fields", () => {
const test = {
something: "else",
and: "more",
maybe: "one more",
}
const result = transformIdableFields(test, [
"shipping_address",
"customer",
"region",
])
expect(test).toEqual(test)
expect(result).toEqual({
something: "else",
and: "more",
maybe: "one more",
})
})
})

View File

@@ -1,13 +0,0 @@
import zeroDecimalCurrencies from "./zero-decimal-currencies"
const computerizeAmount = (amount: number, currency: string): number => {
let divisor = 100
if (zeroDecimalCurrencies.includes(currency.toLowerCase())) {
divisor = 1
}
return Math.round(amount * divisor)
}
export default computerizeAmount

View File

@@ -1,423 +0,0 @@
type Country = {
alpha2: string
name: string
alpha3: string
numeric: string
}
export const countries: Country[] = [
{ alpha2: "AF", name: "Afghanistan", alpha3: "AFG", numeric: "004" },
{ alpha2: "AL", name: "Albania", alpha3: "ALB", numeric: "008" },
{ alpha2: "DZ", name: "Algeria", alpha3: "DZA", numeric: "012" },
{ alpha2: "AS", name: "American Samoa", alpha3: "ASM", numeric: "016" },
{ alpha2: "AD", name: "Andorra", alpha3: "AND", numeric: "020" },
{ alpha2: "AO", name: "Angola", alpha3: "AGO", numeric: "024" },
{ alpha2: "AI", name: "Anguilla", alpha3: "AIA", numeric: "660" },
{ alpha2: "AQ", name: "Antarctica", alpha3: "ATA", numeric: "010" },
{ alpha2: "AG", name: "Antigua and Barbuda", alpha3: "ATG", numeric: "028" },
{ alpha2: "AR", name: "Argentina", alpha3: "ARG", numeric: "032" },
{ alpha2: "AM", name: "Armenia", alpha3: "ARM", numeric: "051" },
{ alpha2: "AW", name: "Aruba", alpha3: "ABW", numeric: "533" },
{ alpha2: "AU", name: "Australia", alpha3: "AUS", numeric: "036" },
{ alpha2: "AT", name: "Austria", alpha3: "AUT", numeric: "040" },
{ alpha2: "AZ", name: "Azerbaijan", alpha3: "AZE", numeric: "031" },
{ alpha2: "BS", name: "Bahamas", alpha3: "BHS", numeric: "044" },
{ alpha2: "BH", name: "Bahrain", alpha3: "BHR", numeric: "048" },
{ alpha2: "BD", name: "Bangladesh", alpha3: "BGD", numeric: "050" },
{ alpha2: "BB", name: "Barbados", alpha3: "BRB", numeric: "052" },
{ alpha2: "BY", name: "Belarus", alpha3: "BLR", numeric: "112" },
{ alpha2: "BE", name: "Belgium", alpha3: "BEL", numeric: "056" },
{ alpha2: "BZ", name: "Belize", alpha3: "BLZ", numeric: "084" },
{ alpha2: "BJ", name: "Benin", alpha3: "BEN", numeric: "204" },
{ alpha2: "BM", name: "Bermuda", alpha3: "BMU", numeric: "060" },
{ alpha2: "BT", name: "Bhutan", alpha3: "BTN", numeric: "064" },
{ alpha2: "BO", name: "Bolivia", alpha3: "BOL", numeric: "068" },
{
alpha2: "BQ",
name: "Bonaire, Sint Eustatius and Saba",
alpha3: "BES",
numeric: "535",
},
{
alpha2: "BA",
name: "Bosnia and Herzegovina",
alpha3: "BIH",
numeric: "070",
},
{ alpha2: "BW", name: "Botswana", alpha3: "BWA", numeric: "072" },
{ alpha2: "BV", name: "Bouvet Island", alpha3: "BVD", numeric: "074" },
{ alpha2: "BR", name: "Brazil", alpha3: "BRA", numeric: "076" },
{
alpha2: "IO",
name: "British Indian Ocean Territory",
alpha3: "IOT",
numeric: "086",
},
{ alpha2: "BN", name: "Brunei Darussalam", alpha3: "BRN", numeric: "096" },
{ alpha2: "BG", name: "Bulgaria", alpha3: "BGR", numeric: "100" },
{ alpha2: "BF", name: "Burkina Faso", alpha3: "BFA", numeric: "854" },
{ alpha2: "BI", name: "Burundi", alpha3: "BDI", numeric: "108" },
{ alpha2: "KH", name: "Cambodia", alpha3: "KHM", numeric: "116" },
{ alpha2: "CM", name: "Cameroon", alpha3: "CMR", numeric: "120" },
{ alpha2: "CA", name: "Canada", alpha3: "CAN", numeric: "124" },
{ alpha2: "CV", name: "Cape Verde", alpha3: "CPV", numeric: "132" },
{ alpha2: "KY", name: "Cayman Islands", alpha3: "CYM", numeric: "136" },
{
alpha2: "CF",
name: "Central African Republic",
alpha3: "CAF",
numeric: "140",
},
{ alpha2: "TD", name: "Chad", alpha3: "TCD", numeric: "148" },
{ alpha2: "CL", name: "Chile", alpha3: "CHL", numeric: "152" },
{ alpha2: "CN", name: "China", alpha3: "CHN", numeric: "156" },
{ alpha2: "CX", name: "Christmas Island", alpha3: "CXR", numeric: "162" },
{
alpha2: "CC",
name: "Cocos (Keeling) Islands",
alpha3: "CCK",
numeric: "166",
},
{ alpha2: "CO", name: "Colombia", alpha3: "COL", numeric: "170" },
{ alpha2: "KM", name: "Comoros", alpha3: "COM", numeric: "174" },
{ alpha2: "CG", name: "Congo", alpha3: "COG", numeric: "178" },
{
alpha2: "CD",
name: "Congo, the Democratic Republic of the",
alpha3: "COD",
numeric: "180",
},
{ alpha2: "CK", name: "Cook Islands", alpha3: "COK", numeric: "184" },
{ alpha2: "CR", name: "Costa Rica", alpha3: "CRI", numeric: "188" },
{ alpha2: "CI", name: "Cote D'Ivoire", alpha3: "CIV", numeric: "384" },
{ alpha2: "HR", name: "Croatia", alpha3: "HRV", numeric: "191" },
{ alpha2: "CU", name: "Cuba", alpha3: "CUB", numeric: "192" },
{ alpha2: "CW", name: "Curaçao", alpha3: "CUW", numeric: "531" },
{ alpha2: "CY", name: "Cyprus", alpha3: "CYP", numeric: "196" },
{ alpha2: "CZ", name: "Czech Republic", alpha3: "CZE", numeric: "203" },
{ alpha2: "DK", name: "Denmark", alpha3: "DNK", numeric: "208" },
{ alpha2: "DJ", name: "Djibouti", alpha3: "DJI", numeric: "262" },
{ alpha2: "DM", name: "Dominica", alpha3: "DMA", numeric: "212" },
{ alpha2: "DO", name: "Dominican Republic", alpha3: "DOM", numeric: "214" },
{ alpha2: "EC", name: "Ecuador", alpha3: "ECU", numeric: "218" },
{ alpha2: "EG", name: "Egypt", alpha3: "EGY", numeric: "818" },
{ alpha2: "SV", name: "El Salvador", alpha3: "SLV", numeric: "222" },
{ alpha2: "GQ", name: "Equatorial Guinea", alpha3: "GNQ", numeric: "226" },
{ alpha2: "ER", name: "Eritrea", alpha3: "ERI", numeric: "232" },
{ alpha2: "EE", name: "Estonia", alpha3: "EST", numeric: "233" },
{ alpha2: "ET", name: "Ethiopia", alpha3: "ETH", numeric: "231" },
{
alpha2: "FK",
name: "Falkland Islands (Malvinas)",
alpha3: "FLK",
numeric: "238",
},
{ alpha2: "FO", name: "Faroe Islands", alpha3: "FRO", numeric: "234" },
{ alpha2: "FJ", name: "Fiji", alpha3: "FJI", numeric: "242" },
{ alpha2: "FI", name: "Finland", alpha3: "FIN", numeric: "246" },
{ alpha2: "FR", name: "France", alpha3: "FRA", numeric: "250" },
{ alpha2: "GF", name: "French Guiana", alpha3: "GUF", numeric: "254" },
{ alpha2: "PF", name: "French Polynesia", alpha3: "PYF", numeric: "258" },
{
alpha2: "TF",
name: "French Southern Territories",
alpha3: "ATF",
numeric: "260",
},
{ alpha2: "GA", name: "Gabon", alpha3: "GAB", numeric: "266" },
{ alpha2: "GM", name: "Gambia", alpha3: "GMB", numeric: "270" },
{ alpha2: "GE", name: "Georgia", alpha3: "GEO", numeric: "268" },
{ alpha2: "DE", name: "Germany", alpha3: "DEU", numeric: "276" },
{ alpha2: "GH", name: "Ghana", alpha3: "GHA", numeric: "288" },
{ alpha2: "GI", name: "Gibraltar", alpha3: "GIB", numeric: "292" },
{ alpha2: "GR", name: "Greece", alpha3: "GRC", numeric: "300" },
{ alpha2: "GL", name: "Greenland", alpha3: "GRL", numeric: "304" },
{ alpha2: "GD", name: "Grenada", alpha3: "GRD", numeric: "308" },
{ alpha2: "GP", name: "Guadeloupe", alpha3: "GLP", numeric: "312" },
{ alpha2: "GU", name: "Guam", alpha3: "GUM", numeric: "316" },
{ alpha2: "GT", name: "Guatemala", alpha3: "GTM", numeric: "320" },
{ alpha2: "GG", name: "Guernsey", alpha3: "GGY", numeric: "831" },
{ alpha2: "GN", name: "Guinea", alpha3: "GIN", numeric: "324" },
{ alpha2: "GW", name: "Guinea-Bissau", alpha3: "GNB", numeric: "624" },
{ alpha2: "GY", name: "Guyana", alpha3: "GUY", numeric: "328" },
{ alpha2: "HT", name: "Haiti", alpha3: "HTI", numeric: "332" },
{
alpha2: "HM",
name: "Heard Island And Mcdonald Islands",
alpha3: "HMD",
numeric: "334",
},
{
alpha2: "VA",
name: "Holy See (Vatican City State)",
alpha3: "VAT",
numeric: "336",
},
{ alpha2: "HN", name: "Honduras", alpha3: "HND", numeric: "340" },
{ alpha2: "HK", name: "Hong Kong", alpha3: "HKG", numeric: "344" },
{ alpha2: "HU", name: "Hungary", alpha3: "HUN", numeric: "348" },
{ alpha2: "IS", name: "Iceland", alpha3: "ISL", numeric: "352" },
{ alpha2: "IN", name: "India", alpha3: "IND", numeric: "356" },
{ alpha2: "ID", name: "Indonesia", alpha3: "IDN", numeric: "360" },
{
alpha2: "IR",
name: "Iran, Islamic Republic of",
alpha3: "IRN",
numeric: "364",
},
{ alpha2: "IQ", name: "Iraq", alpha3: "IRQ", numeric: "368" },
{ alpha2: "IE", name: "Ireland", alpha3: "IRL", numeric: "372" },
{ alpha2: "IM", name: "Isle Of Man", alpha3: "IMN", numeric: "833" },
{ alpha2: "IL", name: "Israel", alpha3: "ISR", numeric: "376" },
{ alpha2: "IT", name: "Italy", alpha3: "ITA", numeric: "380" },
{ alpha2: "JM", name: "Jamaica", alpha3: "JAM", numeric: "388" },
{ alpha2: "JP", name: "Japan", alpha3: "JPN", numeric: "392" },
{ alpha2: "JE", name: "Jersey", alpha3: "JEY", numeric: "832" },
{ alpha2: "JO", name: "Jordan", alpha3: "JOR", numeric: "400" },
{ alpha2: "KZ", name: "Kazakhstan", alpha3: "KAZ", numeric: "398" },
{ alpha2: "KE", name: "Kenya", alpha3: "KEN", numeric: "404" },
{ alpha2: "KI", name: "Kiribati", alpha3: "KIR", numeric: "296" },
{
alpha2: "KP",
name: "Korea, Democratic People's Republic of",
alpha3: "PRK",
numeric: "408",
},
{ alpha2: "KR", name: "Korea, Republic of", alpha3: "KOR", numeric: "410" },
{ alpha2: "XK", name: "Kosovo", alpha3: "XKX", numeric: "900" },
{ alpha2: "KW", name: "Kuwait", alpha3: "KWT", numeric: "414" },
{ alpha2: "KG", name: "Kyrgyzstan", alpha3: "KGZ", numeric: "417" },
{
alpha2: "LA",
name: "Lao People's Democratic Republic",
alpha3: "LAO",
numeric: "418",
},
{ alpha2: "LV", name: "Latvia", alpha3: "LVA", numeric: "428" },
{ alpha2: "LB", name: "Lebanon", alpha3: "LBN", numeric: "422" },
{ alpha2: "LS", name: "Lesotho", alpha3: "LSO", numeric: "426" },
{ alpha2: "LR", name: "Liberia", alpha3: "LBR", numeric: "430" },
{ alpha2: "LY", name: "Libya", alpha3: "LBY", numeric: "434" },
{ alpha2: "LI", name: "Liechtenstein", alpha3: "LIE", numeric: "438" },
{ alpha2: "LT", name: "Lithuania", alpha3: "LTU", numeric: "440" },
{ alpha2: "LU", name: "Luxembourg", alpha3: "LUX", numeric: "442" },
{ alpha2: "MO", name: "Macao", alpha3: "MAC", numeric: "446" },
{
alpha2: "MK",
name: "Macedonia, the Former Yugoslav Republic of",
alpha3: "MKD",
numeric: "807",
},
{ alpha2: "MG", name: "Madagascar", alpha3: "MDG", numeric: "450" },
{ alpha2: "MW", name: "Malawi", alpha3: "MWI", numeric: "454" },
{ alpha2: "MY", name: "Malaysia", alpha3: "MYS", numeric: "458" },
{ alpha2: "MV", name: "Maldives", alpha3: "MDV", numeric: "462" },
{ alpha2: "ML", name: "Mali", alpha3: "MLI", numeric: "466" },
{ alpha2: "MT", name: "Malta", alpha3: "MLT", numeric: "470" },
{ alpha2: "MH", name: "Marshall Islands", alpha3: "MHL", numeric: "584" },
{ alpha2: "MQ", name: "Martinique", alpha3: "MTQ", numeric: "474" },
{ alpha2: "MR", name: "Mauritania", alpha3: "MRT", numeric: "478" },
{ alpha2: "MU", name: "Mauritius", alpha3: "MUS", numeric: "480" },
{ alpha2: "YT", name: "Mayotte", alpha3: "MYT", numeric: "175" },
{ alpha2: "MX", name: "Mexico", alpha3: "MEX", numeric: "484" },
{
alpha2: "FM",
name: "Micronesia, Federated States of",
alpha3: "FSM",
numeric: "583",
},
{ alpha2: "MD", name: "Moldova, Republic of", alpha3: "MDA", numeric: "498" },
{ alpha2: "MC", name: "Monaco", alpha3: "MCO", numeric: "492" },
{ alpha2: "MN", name: "Mongolia", alpha3: "MNG", numeric: "496" },
{ alpha2: "ME", name: "Montenegro", alpha3: "MNE", numeric: "499" },
{ alpha2: "MS", name: "Montserrat", alpha3: "MSR", numeric: "500" },
{ alpha2: "MA", name: "Morocco", alpha3: "MAR", numeric: "504" },
{ alpha2: "MZ", name: "Mozambique", alpha3: "MOZ", numeric: "508" },
{ alpha2: "MM", name: "Myanmar", alpha3: "MMR", numeric: "104" },
{ alpha2: "NA", name: "Namibia", alpha3: "NAM", numeric: "516" },
{ alpha2: "NR", name: "Nauru", alpha3: "NRU", numeric: "520" },
{ alpha2: "NP", name: "Nepal", alpha3: "NPL", numeric: "524" },
{ alpha2: "NL", name: "Netherlands", alpha3: "NLD", numeric: "528" },
{ alpha2: "NC", name: "New Caledonia", alpha3: "NCL", numeric: "540" },
{ alpha2: "NZ", name: "New Zealand", alpha3: "NZL", numeric: "554" },
{ alpha2: "NI", name: "Nicaragua", alpha3: "NIC", numeric: "558" },
{ alpha2: "NE", name: "Niger", alpha3: "NER", numeric: "562" },
{ alpha2: "NG", name: "Nigeria", alpha3: "NGA", numeric: "566" },
{ alpha2: "NU", name: "Niue", alpha3: "NIU", numeric: "570" },
{ alpha2: "NF", name: "Norfolk Island", alpha3: "NFK", numeric: "574" },
{
alpha2: "MP",
name: "Northern Mariana Islands",
alpha3: "MNP",
numeric: "580",
},
{ alpha2: "NO", name: "Norway", alpha3: "NOR", numeric: "578" },
{ alpha2: "OM", name: "Oman", alpha3: "OMN", numeric: "512" },
{ alpha2: "PK", name: "Pakistan", alpha3: "PAK", numeric: "586" },
{ alpha2: "PW", name: "Palau", alpha3: "PLW", numeric: "585" },
{
alpha2: "PS",
name: "Palestinian Territory, Occupied",
alpha3: "PSE",
numeric: "275",
},
{ alpha2: "PA", name: "Panama", alpha3: "PAN", numeric: "591" },
{ alpha2: "PG", name: "Papua New Guinea", alpha3: "PNG", numeric: "598" },
{ alpha2: "PY", name: "Paraguay", alpha3: "PRY", numeric: "600" },
{ alpha2: "PE", name: "Peru", alpha3: "PER", numeric: "604" },
{ alpha2: "PH", name: "Philippines", alpha3: "PHL", numeric: "608" },
{ alpha2: "PN", name: "Pitcairn", alpha3: "PCN", numeric: "612" },
{ alpha2: "PL", name: "Poland", alpha3: "POL", numeric: "616" },
{ alpha2: "PT", name: "Portugal", alpha3: "PRT", numeric: "620" },
{ alpha2: "PR", name: "Puerto Rico", alpha3: "PRI", numeric: "630" },
{ alpha2: "QA", name: "Qatar", alpha3: "QAT", numeric: "634" },
{ alpha2: "RE", name: "Reunion", alpha3: "REU", numeric: "638" },
{ alpha2: "RO", name: "Romania", alpha3: "ROU", numeric: "642" },
{ alpha2: "RO", name: "Romania", alpha3: "ROM", numeric: "642" },
{ alpha2: "RU", name: "Russian Federation", alpha3: "RUS", numeric: "643" },
{ alpha2: "RW", name: "Rwanda", alpha3: "RWA", numeric: "646" },
{ alpha2: "BL", name: "Saint Barthélemy", alpha3: "BLM", numeric: "652" },
{ alpha2: "SH", name: "Saint Helena", alpha3: "SHN", numeric: "654" },
{
alpha2: "KN",
name: "Saint Kitts and Nevis",
alpha3: "KNA",
numeric: "659",
},
{ alpha2: "LC", name: "Saint Lucia", alpha3: "LCA", numeric: "662" },
{
alpha2: "MF",
name: "Saint Martin (French part)",
alpha3: "MAF",
numeric: "663",
},
{
alpha2: "PM",
name: "Saint Pierre and Miquelon",
alpha3: "SPM",
numeric: "666",
},
{
alpha2: "VC",
name: "Saint Vincent and the Grenadines",
alpha3: "VCT",
numeric: "670",
},
{ alpha2: "WS", name: "Samoa", alpha3: "WSM", numeric: "882" },
{ alpha2: "SM", name: "San Marino", alpha3: "SMR", numeric: "674" },
{
alpha2: "ST",
name: "Sao Tome and Principe",
alpha3: "STP",
numeric: "678",
},
{ alpha2: "SA", name: "Saudi Arabia", alpha3: "SAU", numeric: "682" },
{ alpha2: "SN", name: "Senegal", alpha3: "SEN", numeric: "686" },
{ alpha2: "RS", name: "Serbia", alpha3: "SRB", numeric: "688" },
{ alpha2: "SC", name: "Seychelles", alpha3: "SYC", numeric: "690" },
{ alpha2: "SL", name: "Sierra Leone", alpha3: "SLE", numeric: "694" },
{ alpha2: "SG", name: "Singapore", alpha3: "SGP", numeric: "702" },
{ alpha2: "SX", name: "Sint Maarten", alpha3: "SXM", numeric: "534" },
{ alpha2: "SK", name: "Slovakia", alpha3: "SVK", numeric: "703" },
{ alpha2: "SI", name: "Slovenia", alpha3: "SVN", numeric: "705" },
{ alpha2: "SB", name: "Solomon Islands", alpha3: "SLB", numeric: "090" },
{ alpha2: "SO", name: "Somalia", alpha3: "SOM", numeric: "706" },
{ alpha2: "ZA", name: "South Africa", alpha3: "ZAF", numeric: "710" },
{
alpha2: "GS",
name: "South Georgia and the South Sandwich Islands",
alpha3: "SGS",
numeric: "239",
},
{ alpha2: "SS", name: "South Sudan", alpha3: "SSD", numeric: "728" },
{ alpha2: "ES", name: "Spain", alpha3: "ESP", numeric: "724" },
{ alpha2: "LK", name: "Sri Lanka", alpha3: "LKA", numeric: "144" },
{ alpha2: "SD", name: "Sudan", alpha3: "SDN", numeric: "729" },
{ alpha2: "SR", name: "Suriname", alpha3: "SUR", numeric: "740" },
{
alpha2: "SJ",
name: "Svalbard and Jan Mayen",
alpha3: "SJM",
numeric: "744",
},
{ alpha2: "SZ", name: "Swaziland", alpha3: "SWZ", numeric: "748" },
{ alpha2: "SE", name: "Sweden", alpha3: "SWE", numeric: "752" },
{ alpha2: "CH", name: "Switzerland", alpha3: "CHE", numeric: "756" },
{ alpha2: "SY", name: "Syrian Arab Republic", alpha3: "SYR", numeric: "760" },
{
alpha2: "TW",
name: "Taiwan, Province of China",
alpha3: "TWN",
numeric: "158",
},
{ alpha2: "TJ", name: "Tajikistan", alpha3: "TJK", numeric: "762" },
{
alpha2: "TZ",
name: "Tanzania, United Republic of",
alpha3: "TZA",
numeric: "834",
},
{ alpha2: "TH", name: "Thailand", alpha3: "THA", numeric: "764" },
{ alpha2: "TL", name: "Timor Leste", alpha3: "TLS", numeric: "626" },
{ alpha2: "TG", name: "Togo", alpha3: "TGO", numeric: "768" },
{ alpha2: "TK", name: "Tokelau", alpha3: "TKL", numeric: "772" },
{ alpha2: "TO", name: "Tonga", alpha3: "TON", numeric: "776" },
{ alpha2: "TT", name: "Trinidad and Tobago", alpha3: "TTO", numeric: "780" },
{ alpha2: "TN", name: "Tunisia", alpha3: "TUN", numeric: "788" },
{ alpha2: "TR", name: "Turkey", alpha3: "TUR", numeric: "792" },
{ alpha2: "TM", name: "Turkmenistan", alpha3: "TKM", numeric: "795" },
{
alpha2: "TC",
name: "Turks and Caicos Islands",
alpha3: "TCA",
numeric: "796",
},
{ alpha2: "TV", name: "Tuvalu", alpha3: "TUV", numeric: "798" },
{ alpha2: "UG", name: "Uganda", alpha3: "UGA", numeric: "800" },
{ alpha2: "UA", name: "Ukraine", alpha3: "UKR", numeric: "804" },
{ alpha2: "AE", name: "United Arab Emirates", alpha3: "ARE", numeric: "784" },
{ alpha2: "GB", name: "United Kingdom", alpha3: "GBR", numeric: "826" },
{ alpha2: "US", name: "United States", alpha3: "USA", numeric: "840" },
{
alpha2: "UM",
name: "United States Minor Outlying Islands",
alpha3: "UMI",
numeric: "581",
},
{ alpha2: "UY", name: "Uruguay", alpha3: "URY", numeric: "858" },
{ alpha2: "UZ", name: "Uzbekistan", alpha3: "UZB", numeric: "860" },
{ alpha2: "VU", name: "Vanuatu", alpha3: "VUT", numeric: "548" },
{ alpha2: "VE", name: "Venezuela", alpha3: "VEN", numeric: "862" },
{ alpha2: "VN", name: "Viet Nam", alpha3: "VNM", numeric: "704" },
{
alpha2: "VG",
name: "Virgin Islands, British",
alpha3: "VGB",
numeric: "092",
},
{ alpha2: "VI", name: "Virgin Islands, U.S.", alpha3: "VIR", numeric: "850" },
{ alpha2: "WF", name: "Wallis and Futuna", alpha3: "WLF", numeric: "876" },
{ alpha2: "EH", name: "Western Sahara", alpha3: "ESH", numeric: "732" },
{ alpha2: "YE", name: "Yemen", alpha3: "YEM", numeric: "887" },
{ alpha2: "ZM", name: "Zambia", alpha3: "ZMB", numeric: "894" },
{ alpha2: "ZW", name: "Zimbabwe", alpha3: "ZWE", numeric: "716" },
{ alpha2: "AX", name: "Åland Islands", alpha3: "ALA", numeric: "248" },
]
export function isoCountryLookup(country: string): string {
const normalizedCountry = country.toUpperCase()
let isoRecord = countries.find((record) => {
return (
record.name.toUpperCase() === normalizedCountry ||
record.alpha2.toUpperCase() === normalizedCountry ||
record.alpha3.toUpperCase() === normalizedCountry
)
})
if (!isoRecord) {
throw new Error("Invalid country name")
}
return isoRecord.alpha2
}

View File

@@ -1,17 +0,0 @@
import Module from "module"
import path from "path"
const fallback = (filename: string) => {
const mod = new Module(filename)
mod.filename = filename
mod.paths = (Module as any)._nodeModulePaths(path.dirname(filename))
;(mod as any)._compile(`module.exports = require;`, filename)
return mod.exports
}
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0)
const createRequireFromPath = Module.createRequire || fallback
export default createRequireFromPath

View File

@@ -1,57 +0,0 @@
/**
* @typedef MedusaErrorType
*
*/
export const MedusaErrorTypes = {
/** Errors stemming from the database */
DB_ERROR: "database_error",
DUPLICATE_ERROR: "duplicate_error",
INVALID_ARGUMENT: "invalid_argument",
INVALID_DATA: "invalid_data",
UNAUTHORIZED: "unauthorized",
NOT_FOUND: "not_found",
NOT_ALLOWED: "not_allowed",
UNEXPECTED_STATE: "unexpected_state",
CONFLICT: "conflict",
PAYMENT_AUTHORIZATION_ERROR: "payment_authorization_error",
}
export const MedusaErrorCodes = {
INSUFFICIENT_INVENTORY: "insufficient_inventory",
CART_INCOMPATIBLE_STATE: "cart_incompatible_state",
}
/**
* Standardized error to be used across Medusa project.
* @extends Error
*/
class MedusaError extends Error {
public type: string
public message: string
public code?: string
public date: Date
public static Types = MedusaErrorTypes
public static Codes = MedusaErrorCodes
/**
* Creates a standardized error to be used across Medusa project.
* @param {string} type - type of error
* @param {string} message - message to go along with error
* @param {string} code - code of error
* @param {Array} params - params
*/
constructor(type: string, message: string, code?: string, ...params: any) {
super(...params)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, MedusaError)
}
this.type = type
this.code = code
this.message = message
this.date = new Date()
}
}
export default MedusaError

View File

@@ -1,32 +0,0 @@
import { join } from "path"
/**
* Attempts to resolve the config file in a given root directory.
* @param {string} rootDir - the directory to find the config file in.
* @param {string} configName - the name of the config file.
* @return {object} an object containing the config module and its path as well as an error property if the config couldn't be loaded.
*/
function getConfigFile<TConfig = unknown>(
rootDir: string,
configName: string
): { configModule: TConfig; configFilePath: string; error?: any } {
const configPath = join(rootDir, configName)
let configFilePath = ``
let configModule
let err
try {
configFilePath = require.resolve(configPath)
configModule = require(configFilePath)
} catch (e) {
err = e
}
if (configModule && typeof configModule.default === "object") {
configModule = configModule.default
}
return { configModule, configFilePath, error: err }
}
export default getConfigFile

View File

@@ -1,14 +0,0 @@
import path from "path"
export const getMedusaVersion = (): string => {
try {
return require(path.join(
process.cwd(),
`node_modules`,
`@medusajs/medusa`,
`package.json`
)).version
} catch (e) {
return ``
}
}

View File

@@ -1,13 +0,0 @@
import zeroDecimalCurrencies from "./zero-decimal-currencies"
const humanizeAmount = (amount: number, currency: string): number => {
let divisor = 100
if (zeroDecimalCurrencies.includes(currency.toLowerCase())) {
divisor = 1
}
return amount / divisor
}
export default humanizeAmount

View File

@@ -1,3 +0,0 @@
export const indexTypes = {
products: "products",
}

View File

@@ -1,15 +0,0 @@
export { buildRegexpIfValid } from "./build-regexp-if-valid"
export { default as computerizeAmount } from "./computerize-amount"
export { countries, isoCountryLookup } from "./countries"
export { default as createRequireFromPath } from "./create-require-from-path"
export { default as MedusaError } from "./errors"
export { default as getConfigFile } from "./get-config-file"
export * from "./graceful-shutdown-server"
export { default as humanizeAmount } from "./humanize-amount"
export { indexTypes } from "./index-types"
export * from "./is-defined"
export * from "./medusa-container"
export { parseCorsOrigins } from "./parse-cors-origins"
export { transformIdableFields } from "./transform-idable-fields"
export { default as zeroDecimalCurrencies } from "./zero-decimal-currencies"
export { getMedusaVersion } from "./get-medusa-version"

View File

@@ -1,5 +0,0 @@
export function isDefined<T = undefined | unknown>(
val: T
): val is T extends undefined ? never : T {
return typeof val !== "undefined"
}

View File

@@ -1,61 +0,0 @@
import {
asFunction,
asValue,
AwilixContainer,
ClassOrFunctionReturning,
createContainer,
Resolver,
} from "awilix"
export type MedusaContainer = AwilixContainer & {
registerAdd: <T>(name: string, registration: T) => MedusaContainer
createScope: () => MedusaContainer
}
function asArray(
resolvers: (ClassOrFunctionReturning<unknown> | Resolver<unknown>)[]
): { resolve: (container: AwilixContainer) => unknown[] } {
return {
resolve: (container: AwilixContainer) =>
resolvers.map((resolver) => container.build(resolver)),
}
}
function registerAdd(
this: MedusaContainer,
name: string,
registration: typeof asFunction | typeof asValue
) {
const storeKey = name + "_STORE"
if (this.registrations[storeKey] === undefined) {
this.register(storeKey, asValue([] as Resolver<unknown>[]))
}
const store = this.resolve(storeKey) as (
| ClassOrFunctionReturning<unknown>
| Resolver<unknown>
)[]
if (this.registrations[name] === undefined) {
this.register(name, asArray(store))
}
store.unshift(registration)
return this
}
export function createMedusaContainer(...args): MedusaContainer {
const container = createContainer.apply(null, args) as MedusaContainer
container.registerAdd = registerAdd.bind(container)
const originalScope = container.createScope
container.createScope = () => {
const scoped = originalScope() as MedusaContainer
scoped.registerAdd = registerAdd.bind(scoped)
return scoped
}
return container
}

View File

@@ -1,50 +0,0 @@
type ComputePropertyNames<
T,
TKey extends keyof T & string,
TFields extends (keyof T | string)[] = (keyof T | string)[]
> = TKey extends TFields[number]
? T[TKey] extends string
? `${TKey}_id`
: TKey
: TKey
/**
* Takes an object and a list of fields to tranform in that object. If the field
* exists on the object and its value is a string it will append `_id` to the
* field name. This is used when allowing API calls to hold either ID or object
* values in the payload. The method returns a new object with the
* transformation.
* @param obj - the object to transform
* @param fields - the fields to apply transformation to
* @returns the transformed object
*
* @example
* ```ts
* const obj = { test: "test", toto: 1, tata: Symbol("tata") }
* const out = transformIdableFields(obj, ["test"]) // out: { test_id: string, toto: number, tata: symbol }
* ```
*/
export const transformIdableFields = <
T extends object = Record<string, unknown>,
TFields extends (keyof T | string)[] = (keyof T | string)[],
TOutput = {
[P in ComputePropertyNames<T, keyof T & string, TFields>]: P extends keyof T
? T[P]
: string
}
>(
obj: T,
fields: TFields
): TOutput => {
const ret = { ...obj }
for (let key of fields) {
key = key as string
if (key in obj && typeof obj[key] === "string") {
ret[`${key.toString()}_id`] = obj[key]
delete ret[key]
}
}
return ret as unknown as TOutput
}

View File

@@ -1,20 +0,0 @@
const zeroDecimalCurrencies = [
"bif",
"clp",
"djf",
"gnf",
"jpy",
"kmf",
"krw",
"mga",
"pyg",
"rwf",
"ugx",
"vnd",
"vuv",
"xaf",
"xof",
"xpf",
]
export default zeroDecimalCurrencies

View File

@@ -1,22 +0,0 @@
{
"compilerOptions": {
"lib": ["es5", "es6"],
"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
},
"include": ["./src/**/*"],
"exclude": ["./dist/**/*", "./src/__tests__", "node_modules"]
}

View File

@@ -1,10 +0,0 @@
{
"extends": "./tsconfig.json",
"include": [
"./src/**/*",
"index.d.ts",
"./src/**/__tests__",
"./src/**/__mocks__"
],
"exclude": ["node_modules"]
}

View File

@@ -30,7 +30,6 @@
"@types/multer": "^1.4.7",
"cross-env": "^5.2.1",
"jest": "^25.5.4",
"medusa-test-utils": "^1.1.44",
"rimraf": "^5.0.1",
"supertest": "^4.0.2",
"ts-jest": "^25.5.1",
@@ -72,7 +71,6 @@
"ioredis-mock": "8.4.0",
"jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21",
"medusa-core-utils": "^1.2.2",
"medusa-telemetry": "^0.0.17",
"morgan": "^1.9.1",
"multer": "^1.4.5-lts.1",

View File

@@ -1,6 +1,6 @@
import { ConfigModule } from "@medusajs/types"
import { transformFile } from "@swc/core"
import { getConfigFile } from "medusa-core-utils"
import { getConfigFile } from "@medusajs/utils"
import { existsSync } from "node:fs"
import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises"
import path from "path"

View File

@@ -3,7 +3,7 @@ import "regenerator-runtime/runtime"
import cluster from "cluster"
import express from "express"
import { GracefulShutdownServer } from "medusa-core-utils"
import { GracefulShutdownServer } from "../utils"
import { track } from "medusa-telemetry"
import { scheduleJob } from "node-schedule"
import os from "os"

View File

@@ -2,7 +2,7 @@ import "core-js/stable"
import "regenerator-runtime/runtime"
import express from "express"
import { GracefulShutdownServer } from "medusa-core-utils"
import { GracefulShutdownServer } from "../utils"
import { track } from "medusa-telemetry"
import { scheduleJob } from "node-schedule"

View File

@@ -1,6 +1,6 @@
import { MedusaModule, registerMedusaModule } from "@medusajs/modules-sdk"
import glob from "glob"
import { isDefined } from "medusa-core-utils"
import { isDefined } from "@medusajs/utils"
export function getInternalModules(configModule) {
const modules = []

View File

@@ -1,5 +1,5 @@
import { ConfigModule } from "@medusajs/types"
import { getConfigFile, isDefined } from "medusa-core-utils"
import { getConfigFile, isDefined } from "@medusajs/utils"
import logger from "./logger"
const isProduction = ["production", "prod"].includes(process.env.NODE_ENV || "")

View File

@@ -5,7 +5,7 @@ import {
objectFromStringPath,
} from "@medusajs/utils"
import glob from "glob"
import { isDefined } from "medusa-core-utils"
import { isDefined } from "@medusajs/utils"
import { trackFeatureFlag } from "medusa-telemetry"
import path from "path"
import { FlagSettings } from "../../types/feature-flags"

View File

@@ -2,7 +2,6 @@ import { ConfigModule, PluginDetails } from "@medusajs/types"
import { isString } from "@medusajs/utils"
import fs from "fs"
import { sync as existsSync } from "fs-exists-cached"
import { createRequireFromPath } from "medusa-core-utils"
import path from "path"
export const MEDUSA_PROJECT_NAME = "project-plugin"
@@ -57,23 +56,14 @@ function resolvePlugin(pluginName: string): {
}
}
const rootDir = path.resolve(".")
/**
* Here we have an absolute path to an internal plugin, or a name of a module
* which should be located in node_modules.
*/
try {
const requireSource =
rootDir !== null
? createRequireFromPath(`${rootDir}/:internal:`)
: require
// If the path is absolute, resolve the directory of the internal plugin,
// otherwise resolve the directory containing the package.json
const resolvedPath = path.dirname(
requireSource.resolve(`${pluginName}/package.json`)
)
const resolvedPath = require.resolve(pluginName)
const packageJSON = JSON.parse(
fs.readFileSync(`${resolvedPath}/package.json`, `utf-8`)

View File

@@ -1,5 +1,5 @@
import { Request, Response } from "express"
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
export const GET = async (req: Request, res: Response) => {
throw new MedusaError(MedusaError.Types.NOT_ALLOWED, "Not allowed")

View File

@@ -10,7 +10,6 @@ import {
import { asValue } from "awilix"
import express from "express"
import jwt from "jsonwebtoken"
import { MockManager } from "medusa-test-utils"
import querystring from "querystring"
import supertest from "supertest"
import apiLoader from "../../../../api"
@@ -70,7 +69,7 @@ export const createServer = async (rootDir) => {
logger: asValue({
error: () => {},
}),
manager: asValue(MockManager),
manager: asValue({}),
})
app.set("trust proxy", 1)

View File

@@ -1,5 +1,4 @@
import express from "express"
import { IdMap } from "medusa-test-utils"
import { resolve } from "path"
import {
config,
@@ -32,7 +31,7 @@ describe("RoutesLoader", function () {
const res = await request("GET", "/admin/orders/1000", {
adminSession: {
jwt: {
userId: IdMap.getId("admin_user"),
userId: "admin_user",
},
},
})
@@ -45,7 +44,7 @@ describe("RoutesLoader", function () {
const res = await request("POST", "/admin/orders/1000", {
adminSession: {
jwt: {
userId: IdMap.getId("admin_user"),
userId: "admin_user",
},
},
})
@@ -132,7 +131,7 @@ describe("RoutesLoader", function () {
const res = await request("GET", "/admin/protected", {
adminSession: {
jwt: {
userId: IdMap.getId("admin_user"),
userId: "admin_user",
},
},
})
@@ -159,7 +158,7 @@ describe("RoutesLoader", function () {
const res = await request("GET", "/store/me/protected", {
clientSession: {
jwt: {
customer_id: IdMap.getId("lebron"),
customer_id: "lebron",
},
},
})

View File

@@ -1,9 +1,8 @@
import { ConfigModule } from "@medusajs/types"
import { promiseAll, wrapHandler } from "@medusajs/utils"
import { parseCorsOrigins, promiseAll, wrapHandler } from "@medusajs/utils"
import cors from "cors"
import { Router, json, text, urlencoded, type Express } from "express"
import { type Express, json, Router, text, urlencoded } from "express"
import { readdir } from "fs/promises"
import { parseCorsOrigins } from "medusa-core-utils"
import { extname, join, sep } from "path"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { errorHandler } from "../../../utils/middlewares"
@@ -13,8 +12,8 @@ import {
GlobalMiddlewareDescriptor,
HTTP_METHODS,
MiddlewareRoute,
MiddlewareVerb,
MiddlewaresConfig,
MiddlewareVerb,
ParserConfigArgs,
RouteConfig,
RouteDescriptor,

View File

@@ -4,7 +4,7 @@ import { ContainerRegistrationKeys, promiseAll } from "@medusajs/utils"
import { asValue } from "awilix"
import { Express, NextFunction, Request, Response } from "express"
import glob from "glob"
import { createMedusaContainer } from "medusa-core-utils"
import { createMedusaContainer } from "@medusajs/utils"
import path from "path"
import requestIp from "request-ip"
import { v4 } from "uuid"

View File

@@ -1,5 +1,7 @@
import { RequestQueryFields } from "@medusajs/types"
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
import {
MedusaContainer as coreMedusaContainer,
RequestQueryFields,
} from "@medusajs/types"
import { FindConfig } from "./common"
declare global {

View File

@@ -1,4 +1,4 @@
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
export enum PostgresError {
DUPLICATE_ERROR = "23505",

View File

@@ -4,7 +4,7 @@ import {
stringToSelectRelationObject,
} from "@medusajs/utils"
import { pick } from "lodash"
import { MedusaError, isDefined } from "medusa-core-utils"
import { MedusaError, isDefined } from "@medusajs/utils"
import { RequestQueryFields } from "@medusajs/types"
import { FindConfig, QueryConfig } from "../types/common"

View File

@@ -3,3 +3,4 @@ export * from "./exception-formatter"
export * from "./middlewares"
export * from "./omit-deep"
export * from "./remove-undefined-properties"
export * from "./graceful-shutdown-server"

View File

@@ -1,6 +1,6 @@
import { NextFunction, Request, Response } from "express"
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
import { Logger } from "../../types/global"
import { formatException } from "../../utils"

View File

@@ -1,4 +1,4 @@
import { isDefined } from "medusa-core-utils"
import { isDefined } from "@medusajs/utils"
export function removeUndefinedProperties<T extends object>(inputObj: T): T {
const removeProperties = (obj: T) => {

View File

@@ -4,7 +4,7 @@ import {
AuthIdentityProviderService,
AuthenticationResponse,
} from "@medusajs/types"
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
import { AuthProviderRegistrationPrefix } from "@types"
type InjectedDependencies = {

View File

@@ -10,7 +10,7 @@ import {
import { joinerConfig } from "../joiner-config"
import FileProviderService from "./file-provider-service"
import { MedusaError } from "medusa-core-utils"
import { MedusaError } from "@medusajs/utils"
type InjectedDependencies = {
fileProviderService: FileProviderService

View File

@@ -1,5 +1,5 @@
import { Constructor, DAL, FileTypes } from "@medusajs/types"
import { MedusaError } from "medusa-core-utils"
import { Constructor, FileTypes } from "@medusajs/types"
import { MedusaError } from "@medusajs/utils"
import { FileProviderRegistrationPrefix } from "@types"
type InjectedDependencies = {

View File

@@ -4,8 +4,7 @@ import {
FulfillmentTypes,
IFulfillmentProvider,
} from "@medusajs/types"
import { ModulesSdkUtils, promiseAll } from "@medusajs/utils"
import { MedusaError } from "medusa-core-utils"
import { ModulesSdkUtils, promiseAll, MedusaError } from "@medusajs/utils"
import { FulfillmentProvider } from "@models"
type InjectedDependencies = {

View File

@@ -1,6 +1,5 @@
import { Constructor, DAL, NotificationTypes } from "@medusajs/types"
import { ModulesSdkUtils } from "@medusajs/utils"
import { MedusaError } from "medusa-core-utils"
import { ModulesSdkUtils, MedusaError } from "@medusajs/utils"
import { NotificationProvider } from "@models"
import { NotificationProviderRegistrationPrefix } from "@types"

View File

@@ -22,10 +22,10 @@ import {
InjectTransactionManager,
isPaymentProviderError,
MedusaContext,
MedusaError,
ModulesSdkUtils,
} from "@medusajs/utils"
import { PaymentProvider } from "@models"
import { MedusaError } from "medusa-core-utils"
import { EOL } from "os"
type InjectedDependencies = {

View File

@@ -17,8 +17,8 @@ import {
MedusaError,
PaymentActions,
isPaymentProviderError,
isDefined
} from "@medusajs/utils"
import { isDefined } from "medusa-core-utils"
import { CreatePaymentProviderSession } from "@medusajs/types"
import {

View File

@@ -78,7 +78,7 @@ import {
ConfigModule,
MiddlewaresConfig,
} from "@medusajs/medusa"
import { parseCorsOrigins } from "medusa-core-utils"
import { parseCorsOrigins } from "@medusajs/utils"
import cors from "cors"
export const config: MiddlewaresConfig = {

View File

@@ -5466,7 +5466,6 @@ __metadata:
is-valid-path: ^0.1.1
jest: ^25.5.4
meant: ^1.0.3
medusa-core-utils: ^1.2.0
medusa-telemetry: ^0.0.17
open: ^8.0.6
ora: ^5.4.1
@@ -5559,9 +5558,7 @@ __metadata:
jest: ^25.5.4
jsonwebtoken: ^9.0.0
lodash: ^4.17.21
medusa-core-utils: ^1.2.2
medusa-telemetry: ^0.0.17
medusa-test-utils: ^1.1.44
morgan: ^1.9.1
multer: ^1.4.5-lts.1
node-schedule: ^2.1.1
@@ -23647,19 +23644,6 @@ __metadata:
languageName: node
linkType: hard
"medusa-core-utils@^1.2.0, medusa-core-utils@^1.2.2, medusa-core-utils@workspace:packages/medusa-core-utils":
version: 0.0.0-use.local
resolution: "medusa-core-utils@workspace:packages/medusa-core-utils"
dependencies:
awilix: ^8.0.0
cross-env: ^5.2.1
jest: ^25.5.4
rimraf: ^5.0.1
ts-jest: ^25.5.1
typescript: ^4.4.4
languageName: unknown
linkType: soft
"medusa-dev-cli@workspace:packages/cli/medusa-dev-cli":
version: 0.0.0-use.local
resolution: "medusa-dev-cli@workspace:packages/cli/medusa-dev-cli"
@@ -23718,7 +23702,6 @@ __metadata:
"@mikro-orm/postgresql": 5.9.7
cross-env: ^5.2.1
jest: ^25.5.4
medusa-core-utils: ^1.2.2
randomatic: ^3.1.1
rimraf: ^3.0.2
typescript: ^5.1.6