Chore(medusa,utils,types,inventory,stock-location): remove core dependency modules (#3531)
This commit is contained in:
committed by
GitHub
parent
bfef22b33e
commit
4e9d257d3b
14
.changeset/ten-actors-complain.md
Normal file
14
.changeset/ten-actors-complain.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/cache-inmemory": patch
|
||||||
|
"@medusajs/stock-location": patch
|
||||||
|
"@medusajs/cache-redis": patch
|
||||||
|
"@medusajs/modules-sdk": patch
|
||||||
|
"@medusajs/inventory": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
"@medusajs/admin-ui": patch
|
||||||
|
"@medusajs/medusa-plugin-meilisearch": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Remove dependency on @medusajs/medusa from Inventory and Stock-Location Modules
|
||||||
@@ -14,7 +14,10 @@ packages/*
|
|||||||
!packages/event-bus-local
|
!packages/event-bus-local
|
||||||
!packages/medusa-plugin-meilisearch
|
!packages/medusa-plugin-meilisearch
|
||||||
!packages/medusa-plugin-algolia
|
!packages/medusa-plugin-algolia
|
||||||
|
!packages/inventory
|
||||||
|
!packages/stock-location
|
||||||
|
!packages/cache-redis
|
||||||
|
!packages/cache-inmemory
|
||||||
|
|
||||||
|
|
||||||
**/models/*
|
**/models/*
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ module.exports = {
|
|||||||
"./packages/medusa-plugin-meilisearch/tsconfig.spec.json",
|
"./packages/medusa-plugin-meilisearch/tsconfig.spec.json",
|
||||||
"./packages/medusa-plugin-algolia/tsconfig.spec.json",
|
"./packages/medusa-plugin-algolia/tsconfig.spec.json",
|
||||||
"./packages/admin-ui/tsconfig.json",
|
"./packages/admin-ui/tsconfig.json",
|
||||||
|
"./packages/inventory/tsconfig.spec.json",
|
||||||
|
"./packages/stock-location/tsconfig.spec.json",
|
||||||
|
"./packages/cache-redis/tsconfig.spec.json",
|
||||||
|
"./packages/cache-inmemory/tsconfig.spec.json",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
4
.github/workflows/test-cli-with-database.yml
vendored
4
.github/workflows/test-cli-with-database.yml
vendored
@@ -90,7 +90,7 @@ jobs:
|
|||||||
########################## Test medusa develop ###############################
|
########################## Test medusa develop ###############################
|
||||||
|
|
||||||
- name: Run development server
|
- name: Run development server
|
||||||
run: medusa develop > /dev/null 2>&1 &
|
run: medusa develop &
|
||||||
working-directory: ../cli-test
|
working-directory: ../cli-test
|
||||||
|
|
||||||
- name: Testing development server
|
- name: Testing development server
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
########################### Test medusa start ################################
|
########################### Test medusa start ################################
|
||||||
|
|
||||||
- name: Starting medusa
|
- name: Starting medusa
|
||||||
run: medusa start > /dev/null 2>&1 &
|
run: medusa start &
|
||||||
working-directory: ../cli-test
|
working-directory: ../cli-test
|
||||||
|
|
||||||
- name: Testing server
|
- name: Testing server
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/medusa": "*",
|
"@medusajs/medusa": "*",
|
||||||
|
"@medusajs/types": "^0.0.1",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^14.0.0",
|
"@testing-library/react": "^14.0.0",
|
||||||
"@testing-library/user-event": "^14.4.3",
|
"@testing-library/user-event": "^14.4.3",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Country, StockLocationAddressDTO } from "@medusajs/medusa"
|
import { Country } from "@medusajs/medusa"
|
||||||
|
import { StockLocationAddressDTO } from "@medusajs/types"
|
||||||
import { useAdminRegions } from "medusa-react"
|
import { useAdminRegions } from "medusa-react"
|
||||||
import { useEffect, useMemo, useState } from "react"
|
import { useEffect, useMemo, useState } from "react"
|
||||||
import { Controller, useWatch } from "react-hook-form"
|
import { Controller, useWatch } from "react-hook-form"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { SalesChannel, StockLocationExpandedDTO } from "@medusajs/medusa"
|
import { SalesChannel } from "@medusajs/medusa"
|
||||||
|
import { StockLocationExpandedDTO } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
useAdminAddLocationToSalesChannel,
|
useAdminAddLocationToSalesChannel,
|
||||||
useAdminRemoveLocationFromSalesChannel
|
useAdminRemoveLocationFromSalesChannel
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
|
||||||
import SalesChannelsModal from "../../../../../components/forms/product/sales-channels-modal"
|
import SalesChannelsModal from "../../../../../components/forms/product/sales-channels-modal"
|
||||||
import Button from "../../../../../components/fundamentals/button"
|
import Button from "../../../../../components/fundamentals/button"
|
||||||
import useToggleState from "../../../../../hooks/use-toggle-state"
|
import useToggleState from "../../../../../hooks/use-toggle-state"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { StockLocationDTO } from "@medusajs/medusa"
|
import { StockLocationDTO } from "@medusajs/types"
|
||||||
import { useAdminDeleteStockLocation } from "medusa-react"
|
import { useAdminDeleteStockLocation } from "medusa-react"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import IconBadge from "../../../../../components/fundamentals/icon-badge"
|
import IconBadge from "../../../../../components/fundamentals/icon-badge"
|
||||||
@@ -6,7 +6,7 @@ import BuildingsIcon from "../../../../../components/fundamentals/icons/building
|
|||||||
import EditIcon from "../../../../../components/fundamentals/icons/edit-icon"
|
import EditIcon from "../../../../../components/fundamentals/icons/edit-icon"
|
||||||
import TrashIcon from "../../../../../components/fundamentals/icons/trash-icon"
|
import TrashIcon from "../../../../../components/fundamentals/icons/trash-icon"
|
||||||
import Actionables, {
|
import Actionables, {
|
||||||
ActionType,
|
ActionType
|
||||||
} from "../../../../../components/molecules/actionables"
|
} from "../../../../../components/molecules/actionables"
|
||||||
import useImperativeDialog from "../../../../../hooks/use-imperative-dialog"
|
import useImperativeDialog from "../../../../../hooks/use-imperative-dialog"
|
||||||
import useNotification from "../../../../../hooks/use-notification"
|
import useNotification from "../../../../../hooks/use-notification"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { StockLocationExpandedDTO } from "@medusajs/medusa"
|
import { StockLocationExpandedDTO } from "@medusajs/types"
|
||||||
import SalesChannelsList from "../../../../../components/molecules/sales-channels-list"
|
import SalesChannelsList from "../../../../../components/molecules/sales-channels-list"
|
||||||
import EditSalesChannels from "../edit-sales-channels"
|
import EditSalesChannels from "../edit-sales-channels"
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,27 @@
|
|||||||
import {
|
import { AdminPostStockLocationsReq, SalesChannel } from "@medusajs/medusa"
|
||||||
AdminPostStockLocationsReq,
|
|
||||||
SalesChannel,
|
|
||||||
StockLocationAddressDTO,
|
|
||||||
StockLocationAddressInput,
|
|
||||||
} from "@medusajs/medusa"
|
|
||||||
import GeneralForm, { GeneralFormType } from "../components/general-form"
|
|
||||||
import {
|
import {
|
||||||
useAdminAddLocationToSalesChannel,
|
useAdminAddLocationToSalesChannel,
|
||||||
useAdminCreateStockLocation,
|
useAdminCreateStockLocation
|
||||||
} from "medusa-react"
|
} from "medusa-react"
|
||||||
|
import GeneralForm, { GeneralFormType } from "../components/general-form"
|
||||||
|
|
||||||
import Accordion from "../../../../components/organisms/accordion"
|
import {
|
||||||
import AddressForm from "../components/address-form"
|
StockLocationAddressDTO,
|
||||||
|
StockLocationAddressInput
|
||||||
|
} from "@medusajs/types"
|
||||||
|
import { useForm } from "react-hook-form"
|
||||||
import Button from "../../../../components/fundamentals/button"
|
import Button from "../../../../components/fundamentals/button"
|
||||||
import CrossIcon from "../../../../components/fundamentals/icons/cross-icon"
|
import CrossIcon from "../../../../components/fundamentals/icons/cross-icon"
|
||||||
import DeletePrompt from "../../../../components/organisms/delete-prompt"
|
|
||||||
import FocusModal from "../../../../components/molecules/modal/focus-modal"
|
import FocusModal from "../../../../components/molecules/modal/focus-modal"
|
||||||
import SalesChannelsForm from "../components/sales-channels-form"
|
import Accordion from "../../../../components/organisms/accordion"
|
||||||
import { getErrorMessage } from "../../../../utils/error-messages"
|
import DeletePrompt from "../../../../components/organisms/delete-prompt"
|
||||||
import { nestedForm } from "../../../../utils/nested-form"
|
|
||||||
import { useFeatureFlag } from "../../../../providers/feature-flag-provider"
|
|
||||||
import { useForm } from "react-hook-form"
|
|
||||||
import useNotification from "../../../../hooks/use-notification"
|
import useNotification from "../../../../hooks/use-notification"
|
||||||
import useToggleState from "../../../../hooks/use-toggle-state"
|
import useToggleState from "../../../../hooks/use-toggle-state"
|
||||||
|
import { useFeatureFlag } from "../../../../providers/feature-flag-provider"
|
||||||
|
import { getErrorMessage } from "../../../../utils/error-messages"
|
||||||
|
import { nestedForm } from "../../../../utils/nested-form"
|
||||||
|
import AddressForm from "../components/address-form"
|
||||||
|
import SalesChannelsForm from "../components/sales-channels-form"
|
||||||
|
|
||||||
type NewLocationForm = {
|
type NewLocationForm = {
|
||||||
general: GeneralFormType
|
general: GeneralFormType
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
globals: {
|
globals: {
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
tsConfig: "tsconfig.json",
|
tsConfig: "tsconfig.spec.json",
|
||||||
isolatedModules: false,
|
isolatedModules: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/medusa": "*",
|
"@medusajs/types": "^0.0.1",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"test": "jest --passWithNoTests",
|
"test": "jest --passWithNoTests",
|
||||||
"test:unit": "jest --passWithNoTests"
|
"test:unit": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa": "^1.7.11"
|
"@medusajs/modules-sdk": "^0.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { ICacheService } from "@medusajs/medusa"
|
import { ICacheService } from "@medusajs/types"
|
||||||
|
|
||||||
import { CacheRecord, InMemoryCacheModuleOptions } from "../types"
|
import { CacheRecord, InMemoryCacheModuleOptions } from "../types"
|
||||||
|
|
||||||
const DEFAULT_TTL = 30 // seconds
|
const DEFAULT_TTL = 30 // seconds
|
||||||
|
|||||||
5
packages/cache-inmemory/tsconfig.spec.json
Normal file
5
packages/cache-inmemory/tsconfig.spec.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
globals: {
|
globals: {
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
tsConfig: "tsconfig.json",
|
tsConfig: "tsconfig.spec.json",
|
||||||
isolatedModules: false,
|
isolatedModules: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/medusa": "*",
|
"@medusajs/types": "^0.0.1",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
@@ -30,7 +30,9 @@
|
|||||||
"test": "jest --passWithNoTests",
|
"test": "jest --passWithNoTests",
|
||||||
"test:unit": "jest --passWithNoTests"
|
"test:unit": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa": "^1.7.11"
|
"@medusajs/modules-sdk": "^0.0.1",
|
||||||
|
"awilix": "^8.0.0",
|
||||||
|
"ioredis": "^5.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import Redis from "ioredis"
|
|
||||||
import { asValue } from "awilix"
|
|
||||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||||
|
import { asValue } from "awilix"
|
||||||
|
import Redis from "ioredis"
|
||||||
import { RedisCacheModuleOptions } from "../types"
|
import { RedisCacheModuleOptions } from "../types"
|
||||||
|
|
||||||
export default async ({
|
export default async ({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
import { ICacheService } from "@medusajs/types"
|
||||||
import { Redis } from "ioredis"
|
import { Redis } from "ioredis"
|
||||||
import { ICacheService } from "@medusajs/medusa"
|
|
||||||
|
|
||||||
import { RedisCacheModuleOptions } from "../types"
|
import { RedisCacheModuleOptions } from "../types"
|
||||||
|
|
||||||
const DEFAULT_NAMESPACE = "medusa"
|
const DEFAULT_NAMESPACE = "medusa"
|
||||||
|
|||||||
5
packages/cache-redis/tsconfig.spec.json
Normal file
5
packages/cache-redis/tsconfig.spec.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
|
|
||||||
export default async ({ logger }: LoaderOptions): Promise<void> => {
|
export default async ({ logger }: LoaderOptions): Promise<void> => {
|
||||||
logger?.warn(
|
logger?.warn(
|
||||||
"Local Event Bus installed. This is not recommended for production."
|
"Local Event Bus installed. This is not recommended for production."
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
const eventEmitter = new EventEmitter()
|
const eventEmitter = new EventEmitter()
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
export default class LocalEventBusService extends AbstractEventBusModuleService {
|
export default class LocalEventBusService extends AbstractEventBusModuleService {
|
||||||
protected readonly logger_: Logger
|
protected readonly logger_: Logger
|
||||||
protected readonly eventEmitter_: EventEmitter
|
protected readonly eventEmitter_: EventEmitter
|
||||||
|
|
||||||
constructor({ logger }: MedusaContainer & InjectedDependencies) {
|
constructor({ logger }: MedusaContainer & InjectedDependencies) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// eslint-disable-next-line prefer-rest-params
|
||||||
super(...arguments)
|
super(...arguments)
|
||||||
|
|
||||||
this.logger_ = logger
|
this.logger_ = logger
|
||||||
@@ -57,7 +59,6 @@ export default class LocalEventBusService extends AbstractEventBusModuleService
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.eventEmitter_.emit(event.eventName, event.data)
|
this.eventEmitter_.emit(event.eventName, event.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "*",
|
"@medusajs/modules-sdk": "*",
|
||||||
"@medusajs/utils": "^0.0.1",
|
"@medusajs/utils": "^0.0.1",
|
||||||
|
"awilix": "^8.0.0",
|
||||||
"bullmq": "^3.5.6",
|
"bullmq": "^3.5.6",
|
||||||
"ioredis": "^5.2.5"
|
"ioredis": "^5.2.5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ type InjectedDependencies = {
|
|||||||
* Can keep track of multiple subscribers to different events and run the
|
* Can keep track of multiple subscribers to different events and run the
|
||||||
* subscribers when events happen. Events will run asynchronously.
|
* subscribers when events happen. Events will run asynchronously.
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
export default class RedisEventBusService extends AbstractEventBusModuleService {
|
export default class RedisEventBusService extends AbstractEventBusModuleService {
|
||||||
protected readonly config_: ConfigModule
|
protected readonly config_: ConfigModule
|
||||||
protected readonly logger_: Logger
|
protected readonly logger_: Logger
|
||||||
protected readonly moduleOptions_: EventBusRedisModuleOptions
|
protected readonly moduleOptions_: EventBusRedisModuleOptions
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
protected readonly moduleDeclaration_: InternalModuleDeclaration
|
protected readonly moduleDeclaration_: InternalModuleDeclaration
|
||||||
|
|
||||||
protected queue_: Queue
|
protected queue_: Queue
|
||||||
@@ -29,6 +31,7 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
|
|||||||
moduleDeclaration: InternalModuleDeclaration
|
moduleDeclaration: InternalModuleDeclaration
|
||||||
) {
|
) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// eslint-disable-next-line prefer-rest-params
|
||||||
super(...arguments)
|
super(...arguments)
|
||||||
|
|
||||||
this.moduleOptions_ = moduleOptions
|
this.moduleOptions_ = moduleOptions
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": [
|
"lib": ["es2020"],
|
||||||
"es2019"
|
"target": "ES2020",
|
||||||
],
|
|
||||||
"target": "es5",
|
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
@@ -21,13 +19,8 @@
|
|||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"emitDeclarationOnly": true
|
"emitDeclarationOnly": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["src"],
|
||||||
"src"
|
"exclude": ["node_modules", "**/tests/*"],
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules",
|
|
||||||
"**/tests/*"
|
|
||||||
],
|
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"transpileOnly": true
|
"transpileOnly": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
globals: {
|
globals: {
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
tsConfig: "tsconfig.json",
|
tsConfig: "tsconfig.spec.json",
|
||||||
isolatedModules: false,
|
isolatedModules: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,14 +17,13 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "*",
|
"@medusajs/types": "^0.0.1",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa": "^1.7.7",
|
|
||||||
"@medusajs/modules-sdk": "*",
|
"@medusajs/modules-sdk": "*",
|
||||||
"@medusajs/utils": "^0.0.1",
|
"@medusajs/utils": "^0.0.1",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
@@ -36,8 +35,5 @@
|
|||||||
"build": "tsc --build",
|
"build": "tsc --build",
|
||||||
"test": "jest --passWithNoTests",
|
"test": "jest --passWithNoTests",
|
||||||
"test:unit": "jest --passWithNoTests"
|
"test:unit": "jest --passWithNoTests"
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@medusajs/types": "^0.0.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,3 @@ export default moduleDefinition
|
|||||||
|
|
||||||
export * from "./initialize"
|
export * from "./initialize"
|
||||||
export * from "./types"
|
export * from "./types"
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import { IInventoryService } from "@medusajs/medusa"
|
|
||||||
import {
|
import {
|
||||||
ExternalModuleDeclaration,
|
ExternalModuleDeclaration,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
MedusaModule
|
MedusaModule,
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { EventBusTypes } from "@medusajs/types"
|
import { IEventBusService, IInventoryService } from "@medusajs/types"
|
||||||
import { InventoryServiceInitializeOptions } from "../types"
|
import { InventoryServiceInitializeOptions } from "../types"
|
||||||
|
|
||||||
export const initialize = async (
|
export const initialize = async (
|
||||||
options?: InventoryServiceInitializeOptions | ExternalModuleDeclaration,
|
options?: InventoryServiceInitializeOptions | ExternalModuleDeclaration,
|
||||||
injectedDependencies?: {
|
injectedDependencies?: {
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
}
|
}
|
||||||
): Promise<IInventoryService> => {
|
): Promise<IInventoryService> => {
|
||||||
const serviceKey = "inventoryService"
|
const serviceKey = "inventoryService"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { DataSource, DataSourceOptions } from "typeorm"
|
import { DataSource, DataSourceOptions } from "typeorm"
|
||||||
|
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { MedusaError } from "medusa-core-utils"
|
|
||||||
import * as InventoryModels from "../models"
|
import * as InventoryModels from "../models"
|
||||||
import { InventoryServiceInitializeOptions } from "../types"
|
import { InventoryServiceInitializeOptions } from "../types"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk"
|
|||||||
import {
|
import {
|
||||||
InventoryItemService,
|
InventoryItemService,
|
||||||
InventoryLevelService,
|
InventoryLevelService,
|
||||||
ReservationItemService
|
ReservationItemService,
|
||||||
} from "../services"
|
} from "../services"
|
||||||
|
|
||||||
import { asClass } from "awilix"
|
import { asClass } from "awilix"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Index, BeforeInsert, Column, Entity } from "typeorm"
|
import { generateEntityId, SoftDeletableEntity } from "@medusajs/utils"
|
||||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class InventoryItem extends SoftDeletableEntity {
|
export class InventoryItem extends SoftDeletableEntity {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Index, Unique, BeforeInsert, Column, Entity } from "typeorm"
|
import { generateEntityId, SoftDeletableEntity } from "@medusajs/utils"
|
||||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Index(["inventory_item_id", "location_id"], { unique: true })
|
@Index(["inventory_item_id", "location_id"], { unique: true })
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Index, BeforeInsert, Column, Entity } from "typeorm"
|
import { generateEntityId, SoftDeletableEntity } from "@medusajs/utils"
|
||||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class ReservationItem extends SoftDeletableEntity {
|
export class ReservationItem extends SoftDeletableEntity {
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
buildQuery,
|
|
||||||
CreateInventoryItemInput,
|
CreateInventoryItemInput,
|
||||||
FilterableInventoryItemProps,
|
FilterableInventoryItemProps,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
InventoryItemDTO
|
IEventBusService,
|
||||||
} from "@medusajs/medusa"
|
InventoryItemDTO,
|
||||||
import { EventBusTypes, SharedContext } from "@medusajs/types"
|
SharedContext,
|
||||||
import { InjectEntityManager, MedusaContext } from "@medusajs/utils"
|
} from "@medusajs/types"
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
import {
|
||||||
|
buildQuery,
|
||||||
|
InjectEntityManager,
|
||||||
|
isDefined,
|
||||||
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import { DeepPartial, EntityManager, FindManyOptions } from "typeorm"
|
import { DeepPartial, EntityManager, FindManyOptions } from "typeorm"
|
||||||
import { InventoryItem } from "../models"
|
import { InventoryItem } from "../models"
|
||||||
import { getListQuery } from "../utils/query"
|
import { getListQuery } from "../utils/query"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +30,7 @@ export default class InventoryItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected readonly manager_: EntityManager
|
protected readonly manager_: EntityManager
|
||||||
protected readonly eventBusService_: EventBusTypes.IEventBusService | undefined
|
protected readonly eventBusService_: IEventBusService | undefined
|
||||||
|
|
||||||
constructor({ eventBusService, manager }: InjectedDependencies) {
|
constructor({ eventBusService, manager }: InjectedDependencies) {
|
||||||
this.manager_ = manager
|
this.manager_ = manager
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
import {
|
import {
|
||||||
buildQuery,
|
|
||||||
CreateInventoryLevelInput,
|
CreateInventoryLevelInput,
|
||||||
FilterableInventoryLevelProps,
|
FilterableInventoryLevelProps,
|
||||||
FindConfig
|
FindConfig,
|
||||||
} from "@medusajs/medusa"
|
IEventBusService,
|
||||||
import { EventBusTypes, SharedContext } from "@medusajs/types"
|
SharedContext,
|
||||||
import { InjectEntityManager, MedusaContext } from "@medusajs/utils"
|
} from "@medusajs/types"
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
import {
|
||||||
|
buildQuery,
|
||||||
|
InjectEntityManager,
|
||||||
|
isDefined,
|
||||||
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import { DeepPartial, EntityManager, FindManyOptions, In } from "typeorm"
|
import { DeepPartial, EntityManager, FindManyOptions, In } from "typeorm"
|
||||||
import { InventoryLevel } from "../models"
|
import { InventoryLevel } from "../models"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +28,7 @@ export default class InventoryLevelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected readonly manager_: EntityManager
|
protected readonly manager_: EntityManager
|
||||||
protected readonly eventBusService_: EventBusTypes.IEventBusService | undefined
|
protected readonly eventBusService_: IEventBusService | undefined
|
||||||
|
|
||||||
constructor({ eventBusService, manager }: InjectedDependencies) {
|
constructor({ eventBusService, manager }: InjectedDependencies) {
|
||||||
this.manager_ = manager
|
this.manager_ = manager
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CreateInventoryItemInput,
|
CreateInventoryItemInput,
|
||||||
CreateInventoryLevelInput,
|
CreateInventoryLevelInput,
|
||||||
@@ -8,33 +7,35 @@ import {
|
|||||||
FilterableInventoryLevelProps,
|
FilterableInventoryLevelProps,
|
||||||
FilterableReservationItemProps,
|
FilterableReservationItemProps,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
|
IEventBusService,
|
||||||
IInventoryService,
|
IInventoryService,
|
||||||
InventoryItemDTO,
|
InventoryItemDTO,
|
||||||
InventoryLevelDTO,
|
InventoryLevelDTO,
|
||||||
ReservationItemDTO,
|
ReservationItemDTO,
|
||||||
|
SharedContext,
|
||||||
UpdateInventoryLevelInput,
|
UpdateInventoryLevelInput,
|
||||||
UpdateReservationItemInput
|
UpdateReservationItemInput,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/types"
|
||||||
import { EventBusTypes, SharedContext } from "@medusajs/types"
|
|
||||||
import { InjectEntityManager, MedusaContext } from "@medusajs/utils"
|
|
||||||
import { MedusaError } from "medusa-core-utils"
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import {
|
import {
|
||||||
InventoryItemService,
|
InjectEntityManager,
|
||||||
InventoryLevelService,
|
MedusaContext,
|
||||||
ReservationItemService
|
MedusaError,
|
||||||
} from "./"
|
} from "@medusajs/utils"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
import InventoryItemService from "./inventory-item"
|
||||||
|
import InventoryLevelService from "./inventory-level"
|
||||||
|
import ReservationItemService from "./reservation-item"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
inventoryItemService: InventoryItemService
|
inventoryItemService: InventoryItemService
|
||||||
inventoryLevelService: InventoryLevelService
|
inventoryLevelService: InventoryLevelService
|
||||||
reservationItemService: ReservationItemService
|
reservationItemService: ReservationItemService
|
||||||
}
|
}
|
||||||
export default class InventoryService implements IInventoryService {
|
export default class InventoryService implements IInventoryService {
|
||||||
protected readonly manager_: EntityManager
|
protected readonly manager_: EntityManager
|
||||||
protected readonly eventBusService_: EventBusTypes.IEventBusService | undefined
|
protected readonly eventBusService_: IEventBusService | undefined
|
||||||
protected readonly inventoryItemService_: InventoryItemService
|
protected readonly inventoryItemService_: InventoryItemService
|
||||||
protected readonly reservationItemService_: ReservationItemService
|
protected readonly reservationItemService_: ReservationItemService
|
||||||
protected readonly inventoryLevelService_: InventoryLevelService
|
protected readonly inventoryLevelService_: InventoryLevelService
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
buildQuery,
|
|
||||||
CreateReservationItemInput,
|
CreateReservationItemInput,
|
||||||
FilterableReservationItemProps,
|
FilterableReservationItemProps,
|
||||||
FindConfig, UpdateReservationItemInput
|
FindConfig,
|
||||||
} from "@medusajs/medusa"
|
IEventBusService,
|
||||||
import { EventBusTypes, SharedContext } from "@medusajs/types"
|
SharedContext,
|
||||||
import { InjectEntityManager, MedusaContext } from "@medusajs/utils"
|
UpdateReservationItemInput,
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
} from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
buildQuery,
|
||||||
|
InjectEntityManager,
|
||||||
|
isDefined,
|
||||||
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import { EntityManager, FindManyOptions } from "typeorm"
|
import { EntityManager, FindManyOptions } from "typeorm"
|
||||||
import { InventoryLevelService } from "."
|
import { InventoryLevelService } from "."
|
||||||
import { ReservationItem } from "../models"
|
import { ReservationItem } from "../models"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
inventoryLevelService: InventoryLevelService
|
inventoryLevelService: InventoryLevelService
|
||||||
}
|
}
|
||||||
@@ -25,7 +31,7 @@ export default class ReservationItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected readonly manager_: EntityManager
|
protected readonly manager_: EntityManager
|
||||||
protected readonly eventBusService_: EventBusTypes.IEventBusService | undefined
|
protected readonly eventBusService_: IEventBusService | undefined
|
||||||
protected readonly inventoryLevelService_: InventoryLevelService
|
protected readonly inventoryLevelService_: InventoryLevelService
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { EntityManager, FindOptionsWhere, ILike } from "typeorm"
|
|
||||||
import {
|
import {
|
||||||
buildLegacyFieldsListFrom,
|
|
||||||
buildQuery,
|
|
||||||
ExtendedFindConfig,
|
ExtendedFindConfig,
|
||||||
FilterableInventoryItemProps,
|
FilterableInventoryItemProps,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/types"
|
||||||
|
import { buildLegacyFieldsListFrom, buildQuery } from "@medusajs/utils"
|
||||||
|
import { EntityManager, FindOptionsWhere, ILike } from "typeorm"
|
||||||
import { InventoryItem } from "../models"
|
import { InventoryItem } from "../models"
|
||||||
|
|
||||||
export function getListQuery(
|
export function getListQuery(
|
||||||
|
|||||||
5
packages/inventory/tsconfig.spec.json
Normal file
5
packages/inventory/tsconfig.spec.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -30,15 +30,12 @@
|
|||||||
"@babel/cli": "^7.7.5",
|
"@babel/cli": "^7.7.5",
|
||||||
"@babel/core": "^7.7.5",
|
"@babel/core": "^7.7.5",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||||
"@babel/plugin-transform-classes": "^7.9.5",
|
|
||||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||||
"@babel/preset-env": "^7.7.5",
|
"@babel/preset-env": "^7.7.5",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4"
|
"jest": "^25.5.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/polyfill": "^7.8.7",
|
|
||||||
"@babel/runtime": "^7.9.6",
|
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^4.0.0",
|
||||||
"configstore": "5.0.1",
|
"configstore": "5.0.1",
|
||||||
@@ -53,13 +50,13 @@
|
|||||||
"meant": "^1.0.3",
|
"meant": "^1.0.3",
|
||||||
"medusa-core-utils": "^1.1.39",
|
"medusa-core-utils": "^1.1.39",
|
||||||
"medusa-telemetry": "0.0.16",
|
"medusa-telemetry": "0.0.16",
|
||||||
"netrc-parser": "^3.1.6",
|
|
||||||
"open": "^8.0.6",
|
"open": "^8.0.6",
|
||||||
"ora": "^5.4.1",
|
"ora": "^5.4.1",
|
||||||
"pg-god": "^1.0.12",
|
"pg-god": "^1.0.12",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
"regenerator-runtime": "^0.13.11",
|
"regenerator-runtime": "^0.13.11",
|
||||||
"resolve-cwd": "^3.0.0",
|
"resolve-cwd": "^3.0.0",
|
||||||
|
"sqlite3": "^5.0.2",
|
||||||
"stack-trace": "^0.0.10",
|
"stack-trace": "^0.0.10",
|
||||||
"ulid": "^2.3.0",
|
"ulid": "^2.3.0",
|
||||||
"url": "^0.11.0",
|
"url": "^0.11.0",
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ const { whoami } = require("./commands/whoami")
|
|||||||
const { login } = require("./commands/login")
|
const { login } = require("./commands/login")
|
||||||
const { link } = require("./commands/link")
|
const { link } = require("./commands/link")
|
||||||
|
|
||||||
const handlerP = fn => (...args) => {
|
const handlerP =
|
||||||
Promise.resolve(fn(...args)).then(
|
(fn) =>
|
||||||
() => process.exit(0),
|
(...args) => {
|
||||||
err => console.log(err)
|
Promise.resolve(fn(...args)).then(
|
||||||
)
|
() => process.exit(0),
|
||||||
}
|
(err) => console.log(err)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function buildLocalCommands(cli, isLocalProject) {
|
function buildLocalCommands(cli, isLocalProject) {
|
||||||
const defaultHost = `localhost`
|
const defaultHost = `localhost`
|
||||||
@@ -54,12 +56,17 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
)
|
)
|
||||||
return require(cmdPath).default
|
return require(cmdPath).default
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (process.env.NODE_ENV !== "production") {
|
||||||
|
console.log("--------------- ERROR ---------------------")
|
||||||
|
console.log(err)
|
||||||
|
console.log("-------------------------------------------")
|
||||||
|
}
|
||||||
cli.showHelp()
|
cli.showHelp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommandHandler(command, handler) {
|
function getCommandHandler(command, handler) {
|
||||||
return argv => {
|
return (argv) => {
|
||||||
const localCmd = resolveLocalCommand(command)
|
const localCmd = resolveLocalCommand(command)
|
||||||
const args = { ...argv, ...projectInfo, useYarn }
|
const args = { ...argv, ...projectInfo, useYarn }
|
||||||
|
|
||||||
@@ -70,7 +77,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
cli
|
cli
|
||||||
.command({
|
.command({
|
||||||
command: `new [root] [starter]`,
|
command: `new [root] [starter]`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`seed`, {
|
_.option(`seed`, {
|
||||||
type: `boolean`,
|
type: `boolean`,
|
||||||
describe: `If flag is set the command will attempt to seed the database after setup.`,
|
describe: `If flag is set the command will attempt to seed the database after setup.`,
|
||||||
@@ -123,7 +130,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.command({
|
.command({
|
||||||
command: `telemetry`,
|
command: `telemetry`,
|
||||||
describe: `Enable or disable collection of anonymous usage data.`,
|
describe: `Enable or disable collection of anonymous usage data.`,
|
||||||
builder: yargs =>
|
builder: (yargs) =>
|
||||||
yargs
|
yargs
|
||||||
.option(`enable`, {
|
.option(`enable`, {
|
||||||
type: `boolean`,
|
type: `boolean`,
|
||||||
@@ -145,7 +152,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.command({
|
.command({
|
||||||
command: `seed`,
|
command: `seed`,
|
||||||
desc: `Migrates and populates the database with the provided file.`,
|
desc: `Migrates and populates the database with the provided file.`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`f`, {
|
_.option(`f`, {
|
||||||
alias: `seed-file`,
|
alias: `seed-file`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
@@ -188,7 +195,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.command({
|
.command({
|
||||||
command: `link`,
|
command: `link`,
|
||||||
desc: `Creates your Medusa Cloud user in your local database for local testing.`,
|
desc: `Creates your Medusa Cloud user in your local database for local testing.`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`su`, {
|
_.option(`su`, {
|
||||||
alias: `skip-local-user`,
|
alias: `skip-local-user`,
|
||||||
type: `boolean`,
|
type: `boolean`,
|
||||||
@@ -199,7 +206,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
default: false,
|
default: false,
|
||||||
describe: `If set medusa develop will be run after successful linking.`,
|
describe: `If set medusa develop will be run after successful linking.`,
|
||||||
}),
|
}),
|
||||||
handler: handlerP(argv => {
|
handler: handlerP((argv) => {
|
||||||
if (!isLocalProject) {
|
if (!isLocalProject) {
|
||||||
console.log("must be a local project")
|
console.log("must be a local project")
|
||||||
cli.showHelp()
|
cli.showHelp()
|
||||||
@@ -218,7 +225,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.command({
|
.command({
|
||||||
command: `develop`,
|
command: `develop`,
|
||||||
desc: `Start development server. Watches file and rebuilds when something changes`,
|
desc: `Start development server. Watches file and rebuilds when something changes`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`H`, {
|
_.option(`H`, {
|
||||||
alias: `host`,
|
alias: `host`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
@@ -239,14 +246,14 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
// Return an empty promise to prevent handlerP from exiting early.
|
// Return an empty promise to prevent handlerP from exiting early.
|
||||||
// The development server shouldn't ever exit until the user directly
|
// The development server shouldn't ever exit until the user directly
|
||||||
// kills it so this is fine.
|
// kills it so this is fine.
|
||||||
return new Promise(resolve => {})
|
return new Promise((resolve) => {})
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.command({
|
.command({
|
||||||
command: `start`,
|
command: `start`,
|
||||||
desc: `Start development server.`,
|
desc: `Start development server.`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`H`, {
|
_.option(`H`, {
|
||||||
alias: `host`,
|
alias: `host`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
@@ -267,14 +274,14 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
// Return an empty promise to prevent handlerP from exiting early.
|
// Return an empty promise to prevent handlerP from exiting early.
|
||||||
// The development server shouldn't ever exit until the user directly
|
// The development server shouldn't ever exit until the user directly
|
||||||
// kills it so this is fine.
|
// kills it so this is fine.
|
||||||
return new Promise(resolve => {})
|
return new Promise((resolve) => {})
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.command({
|
.command({
|
||||||
command: `user`,
|
command: `user`,
|
||||||
desc: `Create a user`,
|
desc: `Create a user`,
|
||||||
builder: _ =>
|
builder: (_) =>
|
||||||
_.option(`e`, {
|
_.option(`e`, {
|
||||||
alias: `email`,
|
alias: `email`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
@@ -296,7 +303,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
// Return an empty promise to prevent handlerP from exiting early.
|
// Return an empty promise to prevent handlerP from exiting early.
|
||||||
// The development server shouldn't ever exit until the user directly
|
// The development server shouldn't ever exit until the user directly
|
||||||
// kills it so this is fine.
|
// kills it so this is fine.
|
||||||
return new Promise(resolve => {})
|
return new Promise((resolve) => {})
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
@@ -335,7 +342,7 @@ Medusa version: ${medusaVersion}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = argv => {
|
module.exports = (argv) => {
|
||||||
const cli = yargs()
|
const cli = yargs()
|
||||||
const isLocalProject = isLocalMedusaProject()
|
const isLocalProject = isLocalMedusaProject()
|
||||||
|
|
||||||
@@ -381,13 +388,21 @@ module.exports = argv => {
|
|||||||
.demandCommand(1, `Pass --help to see all available commands and options.`)
|
.demandCommand(1, `Pass --help to see all available commands and options.`)
|
||||||
.strict()
|
.strict()
|
||||||
.fail((msg, err, yargs) => {
|
.fail((msg, err, yargs) => {
|
||||||
const availableCommands = yargs.getCommands().map(commandDescription => {
|
const availableCommands = yargs
|
||||||
const [command] = commandDescription
|
.getCommands()
|
||||||
return command.split(` `)[0]
|
.map((commandDescription) => {
|
||||||
})
|
const [command] = commandDescription
|
||||||
|
return command.split(` `)[0]
|
||||||
|
})
|
||||||
const arg = argv.slice(2)[0]
|
const arg = argv.slice(2)[0]
|
||||||
const suggestion = arg ? didYouMean(arg, availableCommands) : ``
|
const suggestion = arg ? didYouMean(arg, availableCommands) : ``
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== "production") {
|
||||||
|
console.log("--------------- ERROR ---------------------")
|
||||||
|
console.log(err)
|
||||||
|
console.log("-------------------------------------------")
|
||||||
|
}
|
||||||
|
|
||||||
cli.showHelp()
|
cli.showHelp()
|
||||||
reporter.info(suggestion)
|
reporter.info(suggestion)
|
||||||
reporter.info(msg)
|
reporter.info(msg)
|
||||||
|
|||||||
@@ -19,11 +19,12 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/utils": "*",
|
"@medusajs/modules-sdk": "^0.0.1",
|
||||||
|
"@medusajs/utils": "^0.0.1",
|
||||||
"algoliasearch": "^4.15.0"
|
"algoliasearch": "^4.15.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "*",
|
"@medusajs/types": "^0.0.1",
|
||||||
"client-sessions": "^0.8.0",
|
"client-sessions": "^0.8.0",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
|
|||||||
@@ -19,11 +19,14 @@
|
|||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/utils": "*",
|
"@medusajs/utils": "^0.0.1",
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"meilisearch": "^0.31.1"
|
"meilisearch": "^0.31.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "*",
|
"@medusajs/medusa": "^1.7.12",
|
||||||
|
"@medusajs/types": "^0.0.1",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
|
|||||||
@@ -19,20 +19,13 @@
|
|||||||
"author": "Sebastian Rindom",
|
"author": "Sebastian Rindom",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.14.3",
|
"@medusajs/types": "^0.0.1",
|
||||||
"@babel/core": "^7.14.3",
|
|
||||||
"@babel/preset-typescript": "^7.13.0",
|
|
||||||
"@medusajs/types": "*",
|
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/jest": "^27.5.2",
|
|
||||||
"@types/jsonwebtoken": "^8.5.9",
|
"@types/jsonwebtoken": "^8.5.9",
|
||||||
"@types/multer": "^1.4.7",
|
"@types/multer": "^1.4.7",
|
||||||
"babel-preset-medusa-package": "^1.1.19",
|
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"medusa-interfaces": "^1.3.6",
|
"medusa-interfaces": "^1.3.6",
|
||||||
"nodemon": "^2.0.20",
|
|
||||||
"sqlite3": "^5.0.2",
|
|
||||||
"supertest": "^4.0.2",
|
"supertest": "^4.0.2",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
@@ -46,17 +39,19 @@
|
|||||||
"test:unit": "jest"
|
"test:unit": "jest"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"@medusajs/types": "^0.0.1",
|
||||||
"medusa-interfaces": "1.3.6",
|
"medusa-interfaces": "1.3.6",
|
||||||
"typeorm": "^0.3.11"
|
"typeorm": "^0.3.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa-cli": "^1.3.8",
|
"@medusajs/medusa-cli": "^1.3.8",
|
||||||
"@medusajs/modules-sdk": "*",
|
"@medusajs/modules-sdk": "^0.0.1",
|
||||||
"@medusajs/utils": "*",
|
"@medusajs/utils": "^0.0.1",
|
||||||
"@types/ioredis": "^4.28.10",
|
"@types/ioredis": "^4.28.10",
|
||||||
"@types/lodash": "^4.14.191",
|
"@types/lodash": "^4.14.191",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"boxen": "^5.0.1",
|
||||||
"bullmq": "^3.5.6",
|
"bullmq": "^3.5.6",
|
||||||
"chokidar": "^3.4.2",
|
"chokidar": "^3.4.2",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
@@ -66,6 +61,7 @@
|
|||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"fs-exists-cached": "^1.0.0",
|
"fs-exists-cached": "^1.0.0",
|
||||||
@@ -74,6 +70,7 @@
|
|||||||
"ioredis-mock": "^5.6.0",
|
"ioredis-mock": "^5.6.0",
|
||||||
"iso8601-duration": "^1.3.0",
|
"iso8601-duration": "^1.3.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"medusa-core-utils": "^1.1.39",
|
"medusa-core-utils": "^1.1.39",
|
||||||
"medusa-telemetry": "^0.0.16",
|
"medusa-telemetry": "^0.0.16",
|
||||||
"medusa-test-utils": "^1.1.39",
|
"medusa-test-utils": "^1.1.39",
|
||||||
@@ -85,14 +82,12 @@
|
|||||||
"passport-http-bearer": "^1.0.1",
|
"passport-http-bearer": "^1.0.1",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0",
|
||||||
"pg": "^8.5.1",
|
|
||||||
"randomatic": "^3.1.1",
|
"randomatic": "^3.1.1",
|
||||||
"redis": "^3.0.2",
|
"redis": "^3.0.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"regenerator-runtime": "^0.13.11",
|
||||||
"request-ip": "^2.1.3",
|
"request-ip": "^2.1.3",
|
||||||
"resolve-cwd": "^3.0.0",
|
|
||||||
"scrypt-kdf": "^2.0.1",
|
"scrypt-kdf": "^2.0.1",
|
||||||
"sqlite3": "^5.0.2",
|
|
||||||
"ulid": "^2.3.0",
|
"ulid": "^2.3.0",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"winston": "^3.8.2"
|
"winston": "^3.8.2"
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
import {
|
import {
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { validator } from "../../../../utils/validator"
|
|
||||||
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
|
|
||||||
import { createInventoryItemTransaction } from "./transaction/create-inventory-item"
|
|
||||||
import { MedusaError } from "medusa-core-utils"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
import { validator } from "../../../../utils/validator"
|
||||||
|
import { createInventoryItemTransaction } from "./transaction/create-inventory-item"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/inventory-items
|
* @oas [post] /admin/inventory-items
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import { Request, Response } from "express"
|
import { IInventoryService, IStockLocationService } from "@medusajs/types"
|
||||||
import { IsNumber, IsOptional, IsString } from "class-validator"
|
import { IsNumber, IsOptional, IsString } from "class-validator"
|
||||||
|
import { Request, Response } from "express"
|
||||||
import {
|
|
||||||
IInventoryService,
|
|
||||||
IStockLocationService,
|
|
||||||
} from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { ProductVariantInventoryService } from "../../../../services"
|
import { ProductVariantInventoryService } from "../../../../services"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [delete] /admin/inventory-items/{id}/location-levels/{location_id}
|
* @oas [delete] /admin/inventory-items/{id}/location-levels/{location_id}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IInventoryService } from "../../../../interfaces"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
import { joinLevels } from "./utils/join-levels"
|
import { joinLevels } from "./utils/join-levels"
|
||||||
|
|||||||
@@ -1,35 +1,32 @@
|
|||||||
|
import { InventoryItemDTO, InventoryLevelDTO } from "@medusajs/types"
|
||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import "reflect-metadata"
|
import "reflect-metadata"
|
||||||
|
import { ProductVariant } from "../../../../models"
|
||||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||||
import {
|
|
||||||
InventoryItemDTO,
|
|
||||||
InventoryLevelDTO,
|
|
||||||
} from "../../../../types/inventory"
|
|
||||||
import middlewares, {
|
import middlewares, {
|
||||||
transformBody,
|
transformBody,
|
||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import { AdminGetInventoryItemsParams } from "./list-inventory-items"
|
|
||||||
import { AdminGetInventoryItemsItemParams } from "./get-inventory-item"
|
|
||||||
import {
|
|
||||||
AdminPostInventoryItemsInventoryItemParams,
|
|
||||||
AdminPostInventoryItemsInventoryItemReq,
|
|
||||||
} from "./update-inventory-item"
|
|
||||||
import { AdminGetInventoryItemsItemLocationLevelsParams } from "./list-location-levels"
|
|
||||||
import {
|
|
||||||
AdminPostInventoryItemsItemLocationLevelsParams,
|
|
||||||
AdminPostInventoryItemsItemLocationLevelsReq,
|
|
||||||
} from "./create-location-level"
|
|
||||||
import {
|
|
||||||
AdminPostInventoryItemsItemLocationLevelsLevelParams,
|
|
||||||
AdminPostInventoryItemsItemLocationLevelsLevelReq,
|
|
||||||
} from "./update-location-level"
|
|
||||||
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
||||||
import { ProductVariant } from "../../../../models"
|
|
||||||
import {
|
import {
|
||||||
AdminPostInventoryItemsParams,
|
AdminPostInventoryItemsParams,
|
||||||
AdminPostInventoryItemsReq,
|
AdminPostInventoryItemsReq,
|
||||||
} from "./create-inventory-item"
|
} from "./create-inventory-item"
|
||||||
|
import {
|
||||||
|
AdminPostInventoryItemsItemLocationLevelsParams,
|
||||||
|
AdminPostInventoryItemsItemLocationLevelsReq,
|
||||||
|
} from "./create-location-level"
|
||||||
|
import { AdminGetInventoryItemsItemParams } from "./get-inventory-item"
|
||||||
|
import { AdminGetInventoryItemsParams } from "./list-inventory-items"
|
||||||
|
import { AdminGetInventoryItemsItemLocationLevelsParams } from "./list-location-levels"
|
||||||
|
import {
|
||||||
|
AdminPostInventoryItemsInventoryItemParams,
|
||||||
|
AdminPostInventoryItemsInventoryItemReq,
|
||||||
|
} from "./update-inventory-item"
|
||||||
|
import {
|
||||||
|
AdminPostInventoryItemsItemLocationLevelsLevelParams,
|
||||||
|
AdminPostInventoryItemsItemLocationLevelsLevelReq,
|
||||||
|
} from "./update-location-level"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -281,10 +278,10 @@ export type AdminInventoryItemsLocationLevelsRes = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "./list-inventory-items"
|
|
||||||
export * from "./create-inventory-item"
|
export * from "./create-inventory-item"
|
||||||
export * from "./get-inventory-item"
|
|
||||||
export * from "./update-inventory-item"
|
|
||||||
export * from "./list-location-levels"
|
|
||||||
export * from "./create-location-level"
|
export * from "./create-location-level"
|
||||||
|
export * from "./get-inventory-item"
|
||||||
|
export * from "./list-inventory-items"
|
||||||
|
export * from "./list-location-levels"
|
||||||
|
export * from "./update-inventory-item"
|
||||||
export * from "./update-location-level"
|
export * from "./update-location-level"
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import { Request, Response } from "express"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { IsBoolean, IsOptional, IsString } from "class-validator"
|
|
||||||
import { Transform } from "class-transformer"
|
import { Transform } from "class-transformer"
|
||||||
import { IsType } from "../../../../utils/validators/is-type"
|
import { IsBoolean, IsOptional, IsString } from "class-validator"
|
||||||
import { getLevelsByInventoryItemId } from "./utils/join-levels"
|
import { Request, Response } from "express"
|
||||||
import { getVariantsByInventoryItemId } from "./utils/join-variants"
|
|
||||||
import {
|
import {
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import {
|
import {
|
||||||
extendedFindParamsMixin,
|
extendedFindParamsMixin,
|
||||||
NumericalComparisonOperator,
|
NumericalComparisonOperator,
|
||||||
StringComparisonOperator,
|
StringComparisonOperator,
|
||||||
} from "../../../../types/common"
|
} from "../../../../types/common"
|
||||||
import { AdminInventoryItemsListWithVariantsAndLocationLevelsRes } from "."
|
import { IsType } from "../../../../utils/validators/is-type"
|
||||||
|
import { getLevelsByInventoryItemId } from "./utils/join-levels"
|
||||||
|
import { getVariantsByInventoryItemId } from "./utils/join-variants"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/inventory-items
|
* @oas [get] /admin/inventory-items
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
|
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
import { ulid } from "ulid"
|
||||||
|
import { ProductVariant } from "../../../../../models"
|
||||||
|
import {
|
||||||
|
ProductVariantInventoryService,
|
||||||
|
ProductVariantService,
|
||||||
|
} from "../../../../../services"
|
||||||
import {
|
import {
|
||||||
DistributedTransaction,
|
DistributedTransaction,
|
||||||
TransactionHandlerType,
|
TransactionHandlerType,
|
||||||
@@ -6,16 +15,6 @@ import {
|
|||||||
TransactionState,
|
TransactionState,
|
||||||
TransactionStepsDefinition,
|
TransactionStepsDefinition,
|
||||||
} from "../../../../../utils/transaction"
|
} from "../../../../../utils/transaction"
|
||||||
import { ulid } from "ulid"
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import { IInventoryService } from "../../../../../interfaces"
|
|
||||||
import {
|
|
||||||
ProductVariantInventoryService,
|
|
||||||
ProductVariantService,
|
|
||||||
} from "../../../../../services"
|
|
||||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
|
||||||
import { ProductVariant } from "../../../../../models"
|
|
||||||
import { MedusaError } from "medusa-core-utils"
|
|
||||||
|
|
||||||
enum actions {
|
enum actions {
|
||||||
createInventoryItem = "createInventoryItem",
|
createInventoryItem = "createInventoryItem",
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Request, Response } from "express"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { IsBoolean, IsNumber, IsOptional, IsString } from "class-validator"
|
import { IsBoolean, IsNumber, IsOptional, IsString } from "class-validator"
|
||||||
|
import { Request, Response } from "express"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/inventory-items/{id}
|
* @oas [post] /admin/inventory-items/{id}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Request, Response } from "express"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { IsNumber, IsOptional, Min } from "class-validator"
|
import { IsNumber, IsOptional, Min } from "class-validator"
|
||||||
|
import { Request, Response } from "express"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/inventory-items/{id}/location-levels/{location_id}
|
* @oas [post] /admin/inventory-items/{id}/location-levels/{location_id}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { IInventoryService } from "../../../../../interfaces"
|
|
||||||
import {
|
import {
|
||||||
|
IInventoryService,
|
||||||
InventoryItemDTO,
|
InventoryItemDTO,
|
||||||
InventoryLevelDTO,
|
InventoryLevelDTO,
|
||||||
} from "../../../../../types/inventory"
|
} from "@medusajs/types"
|
||||||
import { LevelWithAvailability, ResponseInventoryItem } from "../../variants"
|
import { LevelWithAvailability, ResponseInventoryItem } from "../../variants"
|
||||||
|
|
||||||
export const buildLevelsByInventoryItemId = (
|
export const buildLevelsByInventoryItemId = (
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import { InventoryItemDTO } from "@medusajs/types"
|
||||||
|
import { ProductVariant } from "../../../../../models"
|
||||||
import {
|
import {
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../../services"
|
} from "../../../../../services"
|
||||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
|
||||||
import { ProductVariant } from "../../../../../models"
|
|
||||||
|
|
||||||
export type InventoryItemsWithVariants = Partial<InventoryItemDTO> & {
|
export type InventoryItemsWithVariants = Partial<InventoryItemDTO> & {
|
||||||
variants?: ProductVariant[]
|
variants?: ProductVariant[]
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
|
|
||||||
import { EntityManager } from "typeorm"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
import { Fulfillment } from "../../../../models"
|
import { Fulfillment } from "../../../../models"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { OrderService } from "../../../../services"
|
import { OrderService } from "../../../../services"
|
||||||
import { extendedFindParamsMixin } from "../../../../types/common"
|
import { extendedFindParamsMixin } from "../../../../types/common"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { isDefined, MedusaError } from "@medusajs/utils"
|
||||||
|
import { Type } from "class-transformer"
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
@@ -6,16 +8,13 @@ import {
|
|||||||
IsString,
|
IsString,
|
||||||
ValidateNested
|
ValidateNested
|
||||||
} from "class-validator"
|
} from "class-validator"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
import { Order, Return } from "../../../../models"
|
||||||
import {
|
import {
|
||||||
EventBusService,
|
EventBusService,
|
||||||
OrderService,
|
OrderService,
|
||||||
ReturnService
|
ReturnService
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
|
|
||||||
import { Type } from "class-transformer"
|
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import { Order, Return } from "../../../../models"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
import { OrdersReturnItem } from "../../../../types/orders"
|
import { OrdersReturnItem } from "../../../../types/orders"
|
||||||
|
|
||||||
|
|||||||
@@ -28,21 +28,20 @@ import {
|
|||||||
ProductVariantPricesCreateReq,
|
ProductVariantPricesCreateReq,
|
||||||
} from "../../../../types/product-variant"
|
} from "../../../../types/product-variant"
|
||||||
|
|
||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
||||||
import { ProductStatus } from "../../../../models"
|
import { ProductStatus } from "../../../../models"
|
||||||
|
import { Logger } from "../../../../types/global"
|
||||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||||
|
import { FlagRouter } from "../../../../utils/flag-router"
|
||||||
|
import { DistributedTransaction } from "../../../../utils/transaction"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createVariantTransaction,
|
createVariantTransaction,
|
||||||
revertVariantTransaction,
|
revertVariantTransaction,
|
||||||
} from "./transaction/create-product-variant"
|
} from "./transaction/create-product-variant"
|
||||||
import { DistributedTransaction } from "../../../../utils/transaction"
|
|
||||||
import { Logger } from "../../../../types/global"
|
|
||||||
import { FlagRouter } from "../../../../utils/flag-router"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/products
|
* @oas [post] /admin/products
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { Type } from "class-transformer"
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
@@ -7,24 +9,19 @@ import {
|
|||||||
IsString,
|
IsString,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from "class-validator"
|
} from "class-validator"
|
||||||
import { Type } from "class-transformer"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||||
import {
|
import {
|
||||||
PricingService,
|
PricingService,
|
||||||
ProductService,
|
ProductService,
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
|
||||||
|
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import {
|
import {
|
||||||
CreateProductVariantInput,
|
CreateProductVariantInput,
|
||||||
ProductVariantPricesCreateReq,
|
ProductVariantPricesCreateReq,
|
||||||
} from "../../../../types/product-variant"
|
} from "../../../../types/product-variant"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
|
|
||||||
import { createVariantTransaction } from "./transaction/create-product-variant"
|
import { createVariantTransaction } from "./transaction/create-product-variant"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { MedusaError } from "medusa-core-utils"
|
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { ulid } from "ulid"
|
import { ulid } from "ulid"
|
||||||
import { IInventoryService } from "../../../../../interfaces"
|
|
||||||
import { ProductVariant } from "../../../../../models"
|
import { ProductVariant } from "../../../../../models"
|
||||||
import {
|
import {
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../../services"
|
} from "../../../../../services"
|
||||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
|
||||||
import { CreateProductVariantInput } from "../../../../../types/product-variant"
|
import { CreateProductVariantInput } from "../../../../../types/product-variant"
|
||||||
import {
|
import {
|
||||||
DistributedTransaction,
|
DistributedTransaction,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
import { Type } from "class-transformer"
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
@@ -11,38 +14,34 @@ import {
|
|||||||
ValidateIf,
|
ValidateIf,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from "class-validator"
|
} from "class-validator"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||||
|
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
||||||
|
import { ProductStatus } from "../../../../models"
|
||||||
import {
|
import {
|
||||||
PricingService,
|
PricingService,
|
||||||
ProductService,
|
ProductService,
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
|
import { Logger } from "../../../../types/global"
|
||||||
import {
|
import {
|
||||||
ProductProductCategoryReq,
|
ProductProductCategoryReq,
|
||||||
ProductSalesChannelReq,
|
ProductSalesChannelReq,
|
||||||
ProductTagReq,
|
ProductTagReq,
|
||||||
ProductTypeReq,
|
ProductTypeReq,
|
||||||
} from "../../../../types/product"
|
} from "../../../../types/product"
|
||||||
|
|
||||||
import { Type } from "class-transformer"
|
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
|
||||||
import { ProductStatus } from "../../../../models"
|
|
||||||
import {
|
import {
|
||||||
CreateProductVariantInput,
|
CreateProductVariantInput,
|
||||||
ProductVariantPricesUpdateReq,
|
ProductVariantPricesUpdateReq,
|
||||||
} from "../../../../types/product-variant"
|
} from "../../../../types/product-variant"
|
||||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||||
import { validator } from "../../../../utils/validator"
|
|
||||||
import { MedusaError } from "medusa-core-utils"
|
|
||||||
import { DistributedTransaction } from "../../../../utils/transaction"
|
import { DistributedTransaction } from "../../../../utils/transaction"
|
||||||
|
import { validator } from "../../../../utils/validator"
|
||||||
import {
|
import {
|
||||||
createVariantTransaction,
|
createVariantTransaction,
|
||||||
revertVariantTransaction,
|
revertVariantTransaction,
|
||||||
} from "./transaction/create-product-variant"
|
} from "./transaction/create-product-variant"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { Logger } from "../../../../types/global"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/products/{id}
|
* @oas [post] /admin/products/{id}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { isDefined } from "@medusajs/utils"
|
||||||
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
||||||
import { isDefined } from "medusa-core-utils"
|
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [delete] /admin/reservations/{id}
|
* @oas [delete] /admin/reservations/{id}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { MedusaError } from "medusa-core-utils"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/reservations/{id}
|
* @oas [get] /admin/reservations/{id}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
|
import { ReservationItemDTO } from "@medusajs/types"
|
||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import { ReservationItemDTO } from "../../../.."
|
|
||||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||||
import middlewares, {
|
import middlewares, {
|
||||||
transformBody,
|
transformBody,
|
||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import "reflect-metadata"
|
|
||||||
import { AdminPostReservationsReq } from "./create-reservation"
|
|
||||||
import { AdminPostReservationsReservationReq } from "./update-reservation"
|
|
||||||
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
||||||
|
import { AdminPostReservationsReq } from "./create-reservation"
|
||||||
import { AdminGetReservationsParams } from "./list-reservations"
|
import { AdminGetReservationsParams } from "./list-reservations"
|
||||||
|
import { AdminPostReservationsReservationReq } from "./update-reservation"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -133,5 +132,5 @@ export type AdminReservationsDeleteRes = DeleteResponse
|
|||||||
export * from "./create-reservation"
|
export * from "./create-reservation"
|
||||||
export * from "./delete-reservation"
|
export * from "./delete-reservation"
|
||||||
export * from "./get-reservation"
|
export * from "./get-reservation"
|
||||||
export * from "./update-reservation"
|
|
||||||
export * from "./list-reservations"
|
export * from "./list-reservations"
|
||||||
|
export * from "./update-reservation"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator"
|
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import {
|
import {
|
||||||
extendedFindParamsMixin,
|
extendedFindParamsMixin,
|
||||||
NumericalComparisonOperator,
|
NumericalComparisonOperator,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { isDefined } from "@medusajs/utils"
|
||||||
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import { LineItemService } from "../../../../services"
|
import { LineItemService } from "../../../../services"
|
||||||
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { MedusaError } from "medusa-core-utils"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { IInventoryService } from "../../../../../interfaces"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
import { LineItemService } from "../../../../../services"
|
import { LineItemService } from "../../../../../services"
|
||||||
|
|
||||||
export const validateUpdateReservationQuantity = async (
|
export const validateUpdateReservationQuantity = async (
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Request, Response } from "express"
|
import { IStockLocationService } from "@medusajs/types"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||||
|
import { Request, Response } from "express"
|
||||||
import { IStockLocationService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
|
import { IInventoryService, IStockLocationService } from "@medusajs/types"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import {
|
|
||||||
IInventoryService,
|
|
||||||
IStockLocationService,
|
|
||||||
} from "../../../../interfaces"
|
|
||||||
import { SalesChannelLocationService } from "../../../../services"
|
import { SalesChannelLocationService } from "../../../../services"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { IStockLocationService } from "../../../../interfaces"
|
import { IStockLocationService } from "@medusajs/types"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { FindParams } from "../../../../types/common"
|
|
||||||
import { joinSalesChannels } from "./utils/join-sales-channels"
|
|
||||||
import {
|
import {
|
||||||
SalesChannelLocationService,
|
SalesChannelLocationService,
|
||||||
SalesChannelService,
|
SalesChannelService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
|
import { FindParams } from "../../../../types/common"
|
||||||
|
import { joinSalesChannels } from "./utils/join-sales-channels"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/stock-locations/{id}
|
* @oas [get] /admin/stock-locations/{id}
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
import { Router } from "express"
|
|
||||||
import "reflect-metadata"
|
|
||||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
|
||||||
import {
|
import {
|
||||||
StockLocationDTO,
|
DeleteResponse,
|
||||||
StockLocationExpandedDTO,
|
PaginatedResponse,
|
||||||
} from "../../../../types/stock-location"
|
StockLocationTypes,
|
||||||
|
} from "@medusajs/types"
|
||||||
|
import { Router } from "express"
|
||||||
import middlewares, {
|
import middlewares, {
|
||||||
transformBody,
|
transformBody,
|
||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import { AdminGetStockLocationsParams } from "./list-stock-locations"
|
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
||||||
import { AdminGetStockLocationsLocationParams } from "./get-stock-location"
|
|
||||||
import {
|
|
||||||
AdminPostStockLocationsLocationParams,
|
|
||||||
AdminPostStockLocationsLocationReq,
|
|
||||||
} from "./update-stock-location"
|
|
||||||
import {
|
import {
|
||||||
AdminPostStockLocationsParams,
|
AdminPostStockLocationsParams,
|
||||||
AdminPostStockLocationsReq,
|
AdminPostStockLocationsReq,
|
||||||
} from "./create-stock-location"
|
} from "./create-stock-location"
|
||||||
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
import { AdminGetStockLocationsLocationParams } from "./get-stock-location"
|
||||||
|
import { AdminGetStockLocationsParams } from "./list-stock-locations"
|
||||||
|
import {
|
||||||
|
AdminPostStockLocationsLocationParams,
|
||||||
|
AdminPostStockLocationsLocationReq,
|
||||||
|
} from "./update-stock-location"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -82,14 +81,9 @@ export default (app) => {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultAdminStockLocationFields: (keyof StockLocationDTO)[] = [
|
// eslint-disable-next-line max-len
|
||||||
"id",
|
export const defaultAdminStockLocationFields: (keyof StockLocationTypes.StockLocationDTO)[] =
|
||||||
"name",
|
["id", "name", "address_id", "metadata", "created_at", "updated_at"]
|
||||||
"address_id",
|
|
||||||
"metadata",
|
|
||||||
"created_at",
|
|
||||||
"updated_at",
|
|
||||||
]
|
|
||||||
|
|
||||||
export const defaultAdminStockLocationRelations = []
|
export const defaultAdminStockLocationRelations = []
|
||||||
|
|
||||||
@@ -125,7 +119,7 @@ export type AdminStockLocationsDeleteRes = DeleteResponse
|
|||||||
* $ref: "#/components/schemas/StockLocationExpandedDTO"
|
* $ref: "#/components/schemas/StockLocationExpandedDTO"
|
||||||
*/
|
*/
|
||||||
export type AdminStockLocationsRes = {
|
export type AdminStockLocationsRes = {
|
||||||
stock_location: StockLocationExpandedDTO
|
stock_location: StockLocationTypes.StockLocationExpandedDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,10 +146,10 @@ export type AdminStockLocationsRes = {
|
|||||||
* description: The number of items per page
|
* description: The number of items per page
|
||||||
*/
|
*/
|
||||||
export type AdminStockLocationsListRes = PaginatedResponse & {
|
export type AdminStockLocationsListRes = PaginatedResponse & {
|
||||||
stock_locations: StockLocationExpandedDTO[]
|
stock_locations: StockLocationTypes.StockLocationExpandedDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "./list-stock-locations"
|
|
||||||
export * from "./get-stock-location"
|
|
||||||
export * from "./create-stock-location"
|
export * from "./create-stock-location"
|
||||||
|
export * from "./get-stock-location"
|
||||||
|
export * from "./list-stock-locations"
|
||||||
export * from "./update-stock-location"
|
export * from "./update-stock-location"
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
|
import { IStockLocationService } from "@medusajs/types"
|
||||||
import { IsOptional } from "class-validator"
|
import { IsOptional } from "class-validator"
|
||||||
import { IsType } from "../../../../utils/validators/is-type"
|
|
||||||
|
|
||||||
import { IStockLocationService } from "../../../../interfaces"
|
|
||||||
import { extendedFindParamsMixin } from "../../../../types/common"
|
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import {
|
import {
|
||||||
SalesChannelLocationService,
|
SalesChannelLocationService,
|
||||||
SalesChannelService,
|
SalesChannelService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
|
import { extendedFindParamsMixin } from "../../../../types/common"
|
||||||
|
import { IsType } from "../../../../utils/validators/is-type"
|
||||||
import { joinSalesChannels } from "./utils/join-sales-channels"
|
import { joinSalesChannels } from "./utils/join-sales-channels"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Request, Response } from "express"
|
import { IStockLocationService } from "@medusajs/types"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||||
|
import { Request, Response } from "express"
|
||||||
import { IStockLocationService } from "../../../../interfaces"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
|
import { StockLocationDTO, StockLocationExpandedDTO } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
SalesChannelLocationService,
|
SalesChannelLocationService,
|
||||||
SalesChannelService,
|
SalesChannelService,
|
||||||
} from "../../../../../services"
|
} from "../../../../../services"
|
||||||
import {
|
|
||||||
StockLocationDTO,
|
|
||||||
StockLocationExpandedDTO,
|
|
||||||
} from "../../../../../types/stock-location"
|
|
||||||
|
|
||||||
const joinSalesChannels = async (
|
const joinSalesChannels = async (
|
||||||
locations: StockLocationDTO[],
|
locations: StockLocationDTO[],
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { ModulesHelper } from "@medusajs/modules-sdk"
|
||||||
|
import { defaultRelationsExtended } from "."
|
||||||
import {
|
import {
|
||||||
FulfillmentProviderService,
|
FulfillmentProviderService,
|
||||||
PaymentProviderService,
|
PaymentProviderService,
|
||||||
@@ -5,8 +7,6 @@ import {
|
|||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import { ExtendedStoreDTO } from "../../../../types/store"
|
import { ExtendedStoreDTO } from "../../../../types/store"
|
||||||
import { FlagRouter } from "../../../../utils/flag-router"
|
import { FlagRouter } from "../../../../utils/flag-router"
|
||||||
import { ModulesHelper } from "@medusajs/modules-sdk"
|
|
||||||
import { defaultRelationsExtended } from "."
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/store
|
* @oas [get] /admin/store
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
|
IInventoryService,
|
||||||
InventoryItemDTO,
|
InventoryItemDTO,
|
||||||
InventoryLevelDTO,
|
InventoryLevelDTO,
|
||||||
} from "../../../../types/inventory"
|
} from "@medusajs/types"
|
||||||
import ProductVariantInventoryService from "../../../../services/product-variant-inventory"
|
import { SalesChannel } from "../../../../models"
|
||||||
import {
|
import {
|
||||||
SalesChannelLocationService,
|
SalesChannelLocationService,
|
||||||
SalesChannelService,
|
SalesChannelService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import { SalesChannel } from "../../../../models"
|
|
||||||
import { IInventoryService } from "../../../../interfaces"
|
|
||||||
import ProductVariantService from "../../../../services/product-variant"
|
import ProductVariantService from "../../../../services/product-variant"
|
||||||
|
import ProductVariantInventoryService from "../../../../services/product-variant-inventory"
|
||||||
import { joinLevels } from "../inventory-items/utils/join-levels"
|
import { joinLevels } from "../inventory-items/utils/join-levels"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,6 +126,7 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const quantity =
|
const quantity =
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
await productVariantInventoryService.getVariantQuantityFromVariantInventoryItems(
|
await productVariantInventoryService.getVariantQuantityFromVariantInventoryItems(
|
||||||
variantInventoryItems,
|
variantInventoryItems,
|
||||||
channel.id
|
channel.id
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { EOL } from "os"
|
|
||||||
import boxen from "boxen"
|
import boxen from "boxen"
|
||||||
import path from "path"
|
|
||||||
import { execSync } from "child_process"
|
import { execSync } from "child_process"
|
||||||
import spawn from "cross-spawn"
|
|
||||||
import chokidar from "chokidar"
|
import chokidar from "chokidar"
|
||||||
|
import spawn from "cross-spawn"
|
||||||
import Store from "medusa-telemetry/dist/store"
|
import Store from "medusa-telemetry/dist/store"
|
||||||
|
import { EOL } from "os"
|
||||||
|
import path from "path"
|
||||||
|
|
||||||
import Logger from "../loaders/logger"
|
import Logger from "../loaders/logger"
|
||||||
|
|
||||||
@@ -50,7 +50,11 @@ export default async function ({ port, directory }) {
|
|||||||
let child = spawn(cliPath, [`start`, ...args], {
|
let child = spawn(cliPath, [`start`, ...args], {
|
||||||
cwd: directory,
|
cwd: directory,
|
||||||
env: process.env,
|
env: process.env,
|
||||||
stdio: ["pipe", process.stdout, process.stderr],
|
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
||||||
|
})
|
||||||
|
child.on("error", function (err) {
|
||||||
|
console.log("Error ", err)
|
||||||
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
chokidar.watch(`${directory}/src`).on("change", (file) => {
|
chokidar.watch(`${directory}/src`).on("change", (file) => {
|
||||||
@@ -65,7 +69,7 @@ export default async function ({ port, directory }) {
|
|||||||
|
|
||||||
execSync(`${babelPath} src -d dist --extensions ".ts,.js"`, {
|
execSync(`${babelPath} src -d dist --extensions ".ts,.js"`, {
|
||||||
cwd: directory,
|
cwd: directory,
|
||||||
stdio: ["pipe", process.stdout, process.stderr],
|
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
||||||
})
|
})
|
||||||
|
|
||||||
Logger.info("Rebuilt")
|
Logger.info("Rebuilt")
|
||||||
@@ -73,7 +77,11 @@ export default async function ({ port, directory }) {
|
|||||||
child = spawn(cliPath, [`start`, ...args], {
|
child = spawn(cliPath, [`start`, ...args], {
|
||||||
cwd: directory,
|
cwd: directory,
|
||||||
env: process.env,
|
env: process.env,
|
||||||
stdio: ["pipe", process.stdout, process.stderr],
|
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
||||||
|
})
|
||||||
|
child.on("error", function (err) {
|
||||||
|
console.log("Error ", err)
|
||||||
|
process.exit(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,40 +18,45 @@ export default async function ({ port, directory }) {
|
|||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
const { dbConnection } = await loaders({ directory, expressApp: app })
|
try {
|
||||||
const serverActivity = Logger.activity(`Creating server`)
|
const { dbConnection } = await loaders({ directory, expressApp: app })
|
||||||
const server = GracefulShutdownServer.create(
|
const serverActivity = Logger.activity(`Creating server`)
|
||||||
app.listen(port, (err) => {
|
const server = GracefulShutdownServer.create(
|
||||||
if (err) {
|
app.listen(port, (err) => {
|
||||||
return
|
if (err) {
|
||||||
}
|
return
|
||||||
Logger.success(serverActivity, `Server is ready on port: ${port}`)
|
}
|
||||||
track("CLI_START_COMPLETED")
|
Logger.success(serverActivity, `Server is ready on port: ${port}`)
|
||||||
|
track("CLI_START_COMPLETED")
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
// Handle graceful shutdown
|
||||||
|
const gracefulShutDown = () => {
|
||||||
|
server
|
||||||
|
.shutdown()
|
||||||
|
.then(() => {
|
||||||
|
Logger.info("Gracefully stopping the server.")
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
Logger.error("Error received when shutting down the server.", e)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
process.on("SIGTERM", gracefulShutDown)
|
||||||
|
process.on("SIGINT", gracefulShutDown)
|
||||||
|
|
||||||
|
scheduleJob(CRON_SCHEDULE, () => {
|
||||||
|
track("PING")
|
||||||
})
|
})
|
||||||
)
|
|
||||||
|
|
||||||
// Handle graceful shutdown
|
return { dbConnection, server }
|
||||||
const gracefulShutDown = () => {
|
} catch (err) {
|
||||||
server
|
Logger.error("Error starting server", err)
|
||||||
.shutdown()
|
process.exit(1)
|
||||||
.then(() => {
|
|
||||||
Logger.info("Gracefully stopping the server.")
|
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
Logger.error("Error received when shutting down the server.", e)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
process.on("SIGTERM", gracefulShutDown)
|
|
||||||
process.on("SIGINT", gracefulShutDown)
|
|
||||||
|
|
||||||
scheduleJob(CRON_SCHEDULE, () => {
|
|
||||||
track("PING")
|
|
||||||
})
|
|
||||||
|
|
||||||
return { dbConnection, server }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { dbConnection, server } = await start()
|
await start()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,5 @@ export * from "./services"
|
|||||||
export * from "./types/batch-job"
|
export * from "./types/batch-job"
|
||||||
export * from "./types/common"
|
export * from "./types/common"
|
||||||
export * from "./types/global"
|
export * from "./types/global"
|
||||||
export * from "./types/inventory"
|
|
||||||
export * from "./types/price-list"
|
export * from "./types/price-list"
|
||||||
export * from "./types/stock-location"
|
|
||||||
export * from "./utils"
|
export * from "./utils"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export * from "./notification-service"
|
|||||||
export * from "./payment-processor"
|
export * from "./payment-processor"
|
||||||
export * from "./payment-service"
|
export * from "./payment-service"
|
||||||
export * from "./price-selection-strategy"
|
export * from "./price-selection-strategy"
|
||||||
export * from "./services"
|
|
||||||
export * from "./tax-calculation-strategy"
|
export * from "./tax-calculation-strategy"
|
||||||
export * from "./tax-service"
|
export * from "./tax-service"
|
||||||
export * from "./transaction-base-service"
|
export * from "./transaction-base-service"
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export * from "./cache"
|
|
||||||
export * from "./inventory"
|
|
||||||
export * from "./stock-location"
|
|
||||||
@@ -589,9 +589,9 @@ async function runSetupFunctions(pluginDetails: PluginDetails): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
await loaded()
|
await loaded()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`A setup function from ${pluginDetails.name} failed`, {
|
throw new Error(
|
||||||
cause: err,
|
`A setup function from ${pluginDetails.name} failed. ${err}`
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import dotenv from "dotenv"
|
|
||||||
import { AwilixContainer } from "awilix"
|
import { AwilixContainer } from "awilix"
|
||||||
|
import dotenv from "dotenv"
|
||||||
import express from "express"
|
import express from "express"
|
||||||
|
|
||||||
import {
|
import { IInventoryService, IStockLocationService } from "@medusajs/types"
|
||||||
ProductVariantService,
|
|
||||||
ProductVariantInventoryService,
|
|
||||||
} from "../services"
|
|
||||||
import { ProductVariant } from "../models"
|
|
||||||
import { IInventoryService, IStockLocationService } from "../interfaces"
|
|
||||||
import loaders from "../loaders"
|
import loaders from "../loaders"
|
||||||
|
import { ProductVariant } from "../models"
|
||||||
|
import {
|
||||||
|
ProductVariantInventoryService,
|
||||||
|
ProductVariantService,
|
||||||
|
} from "../services"
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
|
import { isDefined, MedusaError, TransactionBaseService } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
EntityManager,
|
EntityManager,
|
||||||
FindManyOptions,
|
FindManyOptions,
|
||||||
@@ -8,43 +9,6 @@ import {
|
|||||||
Not,
|
Not,
|
||||||
Raw,
|
Raw,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { IInventoryService, TransactionBaseService } from "../interfaces"
|
|
||||||
import SalesChannelFeatureFlag from "../loaders/feature-flags/sales-channels"
|
|
||||||
import {
|
|
||||||
Address,
|
|
||||||
Cart,
|
|
||||||
ClaimOrder,
|
|
||||||
Fulfillment,
|
|
||||||
FulfillmentItem,
|
|
||||||
FulfillmentStatus,
|
|
||||||
GiftCard,
|
|
||||||
LineItem,
|
|
||||||
Order,
|
|
||||||
OrderStatus,
|
|
||||||
Payment,
|
|
||||||
PaymentStatus,
|
|
||||||
Return,
|
|
||||||
Swap,
|
|
||||||
TrackingLink
|
|
||||||
} from "../models"
|
|
||||||
import { AddressRepository } from "../repositories/address"
|
|
||||||
import { OrderRepository } from "../repositories/order"
|
|
||||||
import { FindConfig, QuerySelector, Selector } from "../types/common"
|
|
||||||
import {
|
|
||||||
CreateFulfillmentOrder,
|
|
||||||
FulFillmentItemType
|
|
||||||
} from "../types/fulfillment"
|
|
||||||
import { TotalsContext, UpdateOrderInput } from "../types/orders"
|
|
||||||
import { CreateShippingMethodDto } from "../types/shipping-options"
|
|
||||||
import {
|
|
||||||
buildQuery,
|
|
||||||
buildRelations,
|
|
||||||
buildSelects,
|
|
||||||
isString,
|
|
||||||
setMetadata,
|
|
||||||
} from "../utils"
|
|
||||||
import { FlagRouter } from "../utils/flag-router"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CartService,
|
CartService,
|
||||||
CustomerService,
|
CustomerService,
|
||||||
@@ -61,8 +25,43 @@ import {
|
|||||||
ShippingOptionService,
|
ShippingOptionService,
|
||||||
ShippingProfileService,
|
ShippingProfileService,
|
||||||
TaxProviderService,
|
TaxProviderService,
|
||||||
TotalsService
|
TotalsService,
|
||||||
} from "."
|
} from "."
|
||||||
|
import SalesChannelFeatureFlag from "../loaders/feature-flags/sales-channels"
|
||||||
|
import {
|
||||||
|
Address,
|
||||||
|
Cart,
|
||||||
|
ClaimOrder,
|
||||||
|
Fulfillment,
|
||||||
|
FulfillmentItem,
|
||||||
|
FulfillmentStatus,
|
||||||
|
GiftCard,
|
||||||
|
LineItem,
|
||||||
|
Order,
|
||||||
|
OrderStatus,
|
||||||
|
Payment,
|
||||||
|
PaymentStatus,
|
||||||
|
Return,
|
||||||
|
Swap,
|
||||||
|
TrackingLink,
|
||||||
|
} from "../models"
|
||||||
|
import { AddressRepository } from "../repositories/address"
|
||||||
|
import { OrderRepository } from "../repositories/order"
|
||||||
|
import { FindConfig, QuerySelector, Selector } from "../types/common"
|
||||||
|
import {
|
||||||
|
CreateFulfillmentOrder,
|
||||||
|
FulFillmentItemType,
|
||||||
|
} from "../types/fulfillment"
|
||||||
|
import { TotalsContext, UpdateOrderInput } from "../types/orders"
|
||||||
|
import { CreateShippingMethodDto } from "../types/shipping-options"
|
||||||
|
import {
|
||||||
|
buildQuery,
|
||||||
|
buildRelations,
|
||||||
|
buildSelects,
|
||||||
|
isString,
|
||||||
|
setMetadata,
|
||||||
|
} from "../utils"
|
||||||
|
import { FlagRouter } from "../utils/flag-router"
|
||||||
import EventBusService from "./event-bus"
|
import EventBusService from "./event-bus"
|
||||||
|
|
||||||
export const ORDER_CART_ALREADY_EXISTS_ERROR = "Order from cart already exists"
|
export const ORDER_CART_ALREADY_EXISTS_ERROR = "Order from cart already exists"
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
|
||||||
import { EntityManager, In } from "typeorm"
|
|
||||||
import {
|
import {
|
||||||
ICacheService,
|
ICacheService,
|
||||||
IInventoryService,
|
IInventoryService,
|
||||||
IStockLocationService,
|
|
||||||
TransactionBaseService,
|
|
||||||
} from "../interfaces"
|
|
||||||
import { LineItem, Product, ProductVariant } from "../models"
|
|
||||||
import { ProductVariantInventoryItem } from "../models/product-variant-inventory-item"
|
|
||||||
import {
|
|
||||||
InventoryItemDTO,
|
InventoryItemDTO,
|
||||||
|
IStockLocationService,
|
||||||
ReservationItemDTO,
|
ReservationItemDTO,
|
||||||
ReserveQuantityContext,
|
ReserveQuantityContext,
|
||||||
} from "../types/inventory"
|
} from "@medusajs/types"
|
||||||
|
import { isDefined, MedusaError, TransactionBaseService } from "@medusajs/utils"
|
||||||
|
import { EntityManager, In } from "typeorm"
|
||||||
|
import { LineItem, Product, ProductVariant } from "../models"
|
||||||
|
import { ProductVariantInventoryItem } from "../models/product-variant-inventory-item"
|
||||||
import { PricedProduct, PricedVariant } from "../types/pricing"
|
import { PricedProduct, PricedVariant } from "../types/pricing"
|
||||||
import {
|
import ProductVariantService from "./product-variant"
|
||||||
ProductVariantService,
|
import SalesChannelInventoryService from "./sales-channel-inventory"
|
||||||
SalesChannelInventoryService,
|
import SalesChannelLocationService from "./sales-channel-location"
|
||||||
SalesChannelLocationService,
|
|
||||||
} from "./"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
import { EventBusTypes, IInventoryService } from "@medusajs/types"
|
||||||
|
import { TransactionBaseService } from "@medusajs/utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import SalesChannelLocationService from "./sales-channel-location"
|
||||||
import { IInventoryService, TransactionBaseService } from "../interfaces"
|
|
||||||
|
|
||||||
import { EventBusTypes } from "@medusajs/types"
|
|
||||||
import { SalesChannelLocationService } from "./"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
inventoryService: IInventoryService
|
inventoryService: IInventoryService
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import { EntityManager, In } from "typeorm"
|
import { IEventBusService, IStockLocationService } from "@medusajs/types"
|
||||||
import { IStockLocationService, TransactionBaseService } from "../interfaces"
|
|
||||||
import { SalesChannelService } from "./"
|
|
||||||
|
|
||||||
import { EventBusTypes } from "@medusajs/types"
|
|
||||||
|
|
||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
|
import { EntityManager, In } from "typeorm"
|
||||||
|
import { TransactionBaseService } from "../interfaces"
|
||||||
import { SalesChannelLocation } from "../models/sales-channel-location"
|
import { SalesChannelLocation } from "../models/sales-channel-location"
|
||||||
|
import SalesChannelService from "./sales-channel"
|
||||||
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
stockLocationService: IStockLocationService
|
stockLocationService: IStockLocationService
|
||||||
salesChannelService: SalesChannelService
|
salesChannelService: SalesChannelService
|
||||||
eventBusService: EventBusTypes.IEventBusService
|
eventBusService: IEventBusService
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
class SalesChannelLocationService extends TransactionBaseService {
|
class SalesChannelLocationService extends TransactionBaseService {
|
||||||
protected readonly salesChannelService_: SalesChannelService
|
protected readonly salesChannelService_: SalesChannelService
|
||||||
protected readonly eventBusService_: EventBusTypes.IEventBusService
|
protected readonly eventBusService_: IEventBusService
|
||||||
protected readonly stockLocationService_: IStockLocationService
|
protected readonly stockLocationService_: IStockLocationService
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import { AwilixContainer } from "awilix"
|
|||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
import { In } from "typeorm"
|
import { In } from "typeorm"
|
||||||
|
|
||||||
|
import { ICacheService, IEventBusService } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ICacheService,
|
|
||||||
ITaxService,
|
ITaxService,
|
||||||
ItemTaxCalculationLine,
|
ItemTaxCalculationLine,
|
||||||
TaxCalculationContext,
|
TaxCalculationContext,
|
||||||
TransactionBaseService,
|
TransactionBaseService
|
||||||
} from "../interfaces"
|
} from "../interfaces"
|
||||||
import {
|
import {
|
||||||
Cart,
|
Cart,
|
||||||
@@ -16,16 +16,13 @@ import {
|
|||||||
Region,
|
Region,
|
||||||
ShippingMethod,
|
ShippingMethod,
|
||||||
ShippingMethodTaxLine,
|
ShippingMethodTaxLine,
|
||||||
TaxProvider,
|
TaxProvider
|
||||||
} from "../models"
|
} from "../models"
|
||||||
import { LineItemTaxLineRepository } from "../repositories/line-item-tax-line"
|
import { LineItemTaxLineRepository } from "../repositories/line-item-tax-line"
|
||||||
import { ShippingMethodTaxLineRepository } from "../repositories/shipping-method-tax-line"
|
import { ShippingMethodTaxLineRepository } from "../repositories/shipping-method-tax-line"
|
||||||
import { TaxProviderRepository } from "../repositories/tax-provider"
|
import { TaxProviderRepository } from "../repositories/tax-provider"
|
||||||
import { isCart } from "../types/cart"
|
import { isCart } from "../types/cart"
|
||||||
|
|
||||||
import { TaxLinesMaps, TaxServiceRate } from "../types/tax-service"
|
import { TaxLinesMaps, TaxServiceRate } from "../types/tax-service"
|
||||||
import EventBusService from "./event-bus"
|
|
||||||
|
|
||||||
import TaxRateService from "./tax-rate"
|
import TaxRateService from "./tax-rate"
|
||||||
|
|
||||||
type RegionDetails = {
|
type RegionDetails = {
|
||||||
@@ -43,7 +40,7 @@ class TaxProviderService extends TransactionBaseService {
|
|||||||
protected readonly taxLineRepo_: typeof LineItemTaxLineRepository
|
protected readonly taxLineRepo_: typeof LineItemTaxLineRepository
|
||||||
protected readonly smTaxLineRepo_: typeof ShippingMethodTaxLineRepository
|
protected readonly smTaxLineRepo_: typeof ShippingMethodTaxLineRepository
|
||||||
protected readonly taxProviderRepo_: typeof TaxProviderRepository
|
protected readonly taxProviderRepo_: typeof TaxProviderRepository
|
||||||
protected readonly eventBus_: EventBusService
|
protected readonly eventBus_: IEventBusService
|
||||||
|
|
||||||
constructor(container: AwilixContainer) {
|
constructor(container: AwilixContainer) {
|
||||||
super(container)
|
super(container)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
import { ICacheService } from "@medusajs/types"
|
||||||
|
import { isDefined } from "medusa-core-utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import {
|
import {
|
||||||
AbstractPriceSelectionStrategy,
|
AbstractPriceSelectionStrategy,
|
||||||
ICacheService,
|
|
||||||
IPriceSelectionStrategy,
|
IPriceSelectionStrategy,
|
||||||
PriceSelectionContext,
|
PriceSelectionContext,
|
||||||
PriceSelectionResult,
|
PriceSelectionResult,
|
||||||
PriceType,
|
PriceType,
|
||||||
} from "../interfaces"
|
} from "../interfaces"
|
||||||
import { isDefined } from "medusa-core-utils"
|
|
||||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||||
import { MoneyAmountRepository } from "../repositories/money-amount"
|
import { MoneyAmountRepository } from "../repositories/money-amount"
|
||||||
import { TaxServiceRate } from "../types/tax-service"
|
import { TaxServiceRate } from "../types/tax-service"
|
||||||
@@ -79,9 +79,7 @@ class PriceSelectionStrategy extends AbstractPriceSelectionStrategy {
|
|||||||
variant_id: string,
|
variant_id: string,
|
||||||
context: PriceSelectionContext
|
context: PriceSelectionContext
|
||||||
): Promise<PriceSelectionResult> {
|
): Promise<PriceSelectionResult> {
|
||||||
const moneyRepo = this.manager_.withRepository(
|
const moneyRepo = this.manager_.withRepository(this.moneyAmountRepository_)
|
||||||
this.moneyAmountRepository_
|
|
||||||
)
|
|
||||||
|
|
||||||
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
||||||
variant_id,
|
variant_id,
|
||||||
@@ -168,9 +166,7 @@ class PriceSelectionStrategy extends AbstractPriceSelectionStrategy {
|
|||||||
variant_id: string,
|
variant_id: string,
|
||||||
context: PriceSelectionContext
|
context: PriceSelectionContext
|
||||||
): Promise<PriceSelectionResult> {
|
): Promise<PriceSelectionResult> {
|
||||||
const moneyRepo = this.manager_.withRepository(
|
const moneyRepo = this.manager_.withRepository(this.moneyAmountRepository_)
|
||||||
this.moneyAmountRepository_
|
|
||||||
)
|
|
||||||
|
|
||||||
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
||||||
variant_id,
|
variant_id,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { ICacheService } from "@medusajs/types"
|
||||||
import { EventBusService, ProductVariantService } from "../services"
|
import { EventBusService, ProductVariantService } from "../services"
|
||||||
import { ICacheService } from "../interfaces"
|
|
||||||
|
|
||||||
type ProductVariantUpdatedEventData = {
|
type ProductVariantUpdatedEventData = {
|
||||||
id: string
|
id: string
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ import {
|
|||||||
FindOptionsWhere,
|
FindOptionsWhere,
|
||||||
OrderByCondition,
|
OrderByCondition,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { transformDate } from "../utils/validators/date-transform"
|
|
||||||
import { BaseEntity } from "../interfaces"
|
|
||||||
import { ClassConstructor } from "./global"
|
|
||||||
import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations"
|
|
||||||
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
||||||
|
import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations"
|
||||||
|
import { BaseEntity } from "../interfaces"
|
||||||
|
import { transformDate } from "../utils/validators/date-transform"
|
||||||
|
import { ClassConstructor } from "./global"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility type used to remove some optional attributes (coming from K) from a type T
|
* Utility type used to remove some optional attributes (coming from K) from a type T
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Store, PaymentProvider, FulfillmentProvider } from "../models"
|
|
||||||
import { FeatureFlagsResponse } from "./feature-flags"
|
|
||||||
import { ModulesResponse as sdkModulesResponse } from "@medusajs/modules-sdk"
|
import { ModulesResponse as sdkModulesResponse } from "@medusajs/modules-sdk"
|
||||||
|
import { FulfillmentProvider, PaymentProvider, Store } from "../models"
|
||||||
|
import { FeatureFlagsResponse } from "./feature-flags"
|
||||||
|
|
||||||
export type UpdateStoreInput = {
|
export type UpdateStoreInput = {
|
||||||
name?: string
|
name?: string
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { ExtendedFindConfig, FindConfig } from "../types/common"
|
|
||||||
import {
|
import {
|
||||||
FindManyOptions,
|
FindManyOptions,
|
||||||
FindOperator,
|
FindOperator,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
MoreThanOrEqual,
|
MoreThanOrEqual,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
||||||
|
import { ExtendedFindConfig, FindConfig } from "../types/common"
|
||||||
import { isObject } from "./is-object"
|
import { isObject } from "./is-object"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,9 +23,10 @@
|
|||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@medusajs/types": "^0.0.1",
|
||||||
|
"@medusajs/utils": "^0.0.1",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"glob": "7.1.6",
|
"glob": "7.1.6",
|
||||||
"medusa-core-utils": "^1.1.39",
|
|
||||||
"medusa-telemetry": "^0.0.16",
|
"medusa-telemetry": "^0.0.16",
|
||||||
"resolve-cwd": "^3.0.0"
|
"resolve-cwd": "^3.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { ModuleDefinition, MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
import {
|
||||||
|
ModuleDefinition,
|
||||||
|
MODULE_RESOURCE_TYPE,
|
||||||
|
MODULE_SCOPE,
|
||||||
|
} from "@medusajs/types"
|
||||||
|
|
||||||
export const MODULE_DEFINITIONS: ModuleDefinition[] = [
|
export const MODULE_DEFINITIONS: ModuleDefinition[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
export * from "@medusajs/types/dist/modules-sdk"
|
||||||
export * from "./definitions"
|
export * from "./definitions"
|
||||||
export * from "./loaders"
|
export * from "./loaders"
|
||||||
export * from "./medusa-module"
|
export * from "./medusa-module"
|
||||||
export * from "./module-helper"
|
export * from "./module-helper"
|
||||||
export * from "./types"
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user