Chore(medusa,utils,types,inventory,stock-location): remove core dependency modules (#3531)
This commit is contained in:
1 parent
bfef22b33e
commit
4e9d257d3b
159 files changed
+1769
-693
No files matched your search
@@ -19,20 +19,13 @@
|
||||
"author": "Sebastian Rindom",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.14.3",
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"@medusajs/types": "*",
|
||||
"@medusajs/types": "^0.0.1",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/jsonwebtoken": "^8.5.9",
|
||||
"@types/multer": "^1.4.7",
|
||||
"babel-preset-medusa-package": "^1.1.19",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.6",
|
||||
"nodemon": "^2.0.20",
|
||||
"sqlite3": "^5.0.2",
|
||||
"supertest": "^4.0.2",
|
||||
"ts-jest": "^25.5.1",
|
||||
"typescript": "^4.4.4"
|
||||
@@ -46,17 +39,19 @@
|
||||
"test:unit": "jest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@medusajs/types": "^0.0.1",
|
||||
"medusa-interfaces": "1.3.6",
|
||||
"typeorm": "^0.3.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa-cli": "^1.3.8",
|
||||
"@medusajs/modules-sdk": "*",
|
||||
"@medusajs/utils": "*",
|
||||
"@medusajs/modules-sdk": "^0.0.1",
|
||||
"@medusajs/utils": "^0.0.1",
|
||||
"@types/ioredis": "^4.28.10",
|
||||
"@types/lodash": "^4.14.191",
|
||||
"awilix": "^8.0.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"boxen": "^5.0.1",
|
||||
"bullmq": "^3.5.6",
|
||||
"chokidar": "^3.4.2",
|
||||
"class-transformer": "^0.5.1",
|
||||
@@ -66,6 +61,7 @@
|
||||
"core-js": "^3.6.5",
|
||||
"cors": "^2.8.5",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.17.1",
|
||||
"express-session": "^1.17.3",
|
||||
"fs-exists-cached": "^1.0.0",
|
||||
@@ -74,6 +70,7 @@
|
||||
"ioredis-mock": "^5.6.0",
|
||||
"iso8601-duration": "^1.3.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"lodash": "^4.17.21",
|
||||
"medusa-core-utils": "^1.1.39",
|
||||
"medusa-telemetry": "^0.0.16",
|
||||
"medusa-test-utils": "^1.1.39",
|
||||
@@ -85,14 +82,12 @@
|
||||
"passport-http-bearer": "^1.0.1",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.5.1",
|
||||
"randomatic": "^3.1.1",
|
||||
"redis": "^3.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"regenerator-runtime": "^0.13.11",
|
||||
"request-ip": "^2.1.3",
|
||||
"resolve-cwd": "^3.0.0",
|
||||
"scrypt-kdf": "^2.0.1",
|
||||
"sqlite3": "^5.0.2",
|
||||
"ulid": "^2.3.0",
|
||||
"uuid": "^8.3.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 { EntityManager } from "typeorm"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} 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 { validator } from "../../../../utils/validator"
|
||||
import { createInventoryItemTransaction } from "./transaction/create-inventory-item"
|
||||
|
||||
/**
|
||||
* @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 {
|
||||
IInventoryService,
|
||||
IStockLocationService,
|
||||
} from "../../../../interfaces"
|
||||
import { Request, Response } from "express"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Request, Response } from "express"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { ProductVariantInventoryService } from "../../../../services"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Request, Response } from "express"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
|
||||
/**
|
||||
* @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 { FindParams } from "../../../../types/common"
|
||||
import { joinLevels } from "./utils/join-levels"
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
import { InventoryItemDTO, InventoryLevelDTO } from "@medusajs/types"
|
||||
import { Router } from "express"
|
||||
import "reflect-metadata"
|
||||
import { ProductVariant } from "../../../../models"
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import {
|
||||
InventoryItemDTO,
|
||||
InventoryLevelDTO,
|
||||
} from "../../../../types/inventory"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} 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 { ProductVariant } from "../../../../models"
|
||||
import {
|
||||
AdminPostInventoryItemsParams,
|
||||
AdminPostInventoryItemsReq,
|
||||
} 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()
|
||||
|
||||
@@ -281,10 +278,10 @@ export type AdminInventoryItemsLocationLevelsRes = {
|
||||
}
|
||||
}
|
||||
|
||||
export * from "./list-inventory-items"
|
||||
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 "./get-inventory-item"
|
||||
export * from "./list-inventory-items"
|
||||
export * from "./list-location-levels"
|
||||
export * from "./update-inventory-item"
|
||||
export * from "./update-location-level"
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Request, Response } from "express"
|
||||
import { IsBoolean, IsOptional, IsString } from "class-validator"
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Transform } from "class-transformer"
|
||||
import { IsType } from "../../../../utils/validators/is-type"
|
||||
import { getLevelsByInventoryItemId } from "./utils/join-levels"
|
||||
import { getVariantsByInventoryItemId } from "./utils/join-variants"
|
||||
import { IsBoolean, IsOptional, IsString } from "class-validator"
|
||||
import { Request, Response } from "express"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../services"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import {
|
||||
extendedFindParamsMixin,
|
||||
NumericalComparisonOperator,
|
||||
StringComparisonOperator,
|
||||
} 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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Request, Response } from "express"
|
||||
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
|
||||
+9
-10
@@ -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 {
|
||||
DistributedTransaction,
|
||||
TransactionHandlerType,
|
||||
@@ -6,16 +15,6 @@ import {
|
||||
TransactionState,
|
||||
TransactionStepsDefinition,
|
||||
} 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 {
|
||||
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 { IInventoryService } from "../../../../interfaces"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { Request, Response } from "express"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
* @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 { IInventoryService } from "../../../../interfaces"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { Request, Response } from "express"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/inventory-items/{id}/location-levels/{location_id}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { IInventoryService } from "../../../../../interfaces"
|
||||
import {
|
||||
IInventoryService,
|
||||
InventoryItemDTO,
|
||||
InventoryLevelDTO,
|
||||
} from "../../../../../types/inventory"
|
||||
} from "@medusajs/types"
|
||||
import { LevelWithAvailability, ResponseInventoryItem } from "../../variants"
|
||||
|
||||
export const buildLevelsByInventoryItemId = (
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { InventoryItemDTO } from "@medusajs/types"
|
||||
import { ProductVariant } from "../../../../../models"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../../services"
|
||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
||||
import { ProductVariant } from "../../../../../models"
|
||||
|
||||
export type InventoryItemsWithVariants = Partial<InventoryItemDTO> & {
|
||||
variants?: ProductVariant[]
|
||||
|
||||
@@ -4,10 +4,10 @@ import {
|
||||
ProductVariantInventoryService,
|
||||
} from "../../../../services"
|
||||
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { Fulfillment } from "../../../../models"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Request, Response } from "express"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { OrderService } from "../../../../services"
|
||||
import { extendedFindParamsMixin } from "../../../../types/common"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { isDefined, MedusaError } from "@medusajs/utils"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -6,16 +8,13 @@ import {
|
||||
IsString,
|
||||
ValidateNested
|
||||
} from "class-validator"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { Order, Return } from "../../../../models"
|
||||
import {
|
||||
EventBusService,
|
||||
OrderService,
|
||||
ReturnService
|
||||
} 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 { OrdersReturnItem } from "../../../../types/orders"
|
||||
|
||||
|
||||
@@ -28,21 +28,20 @@ import {
|
||||
ProductVariantPricesCreateReq,
|
||||
} from "../../../../types/product-variant"
|
||||
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Type } from "class-transformer"
|
||||
import { EntityManager } from "typeorm"
|
||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
||||
import { ProductStatus } from "../../../../models"
|
||||
import { Logger } from "../../../../types/global"
|
||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||
import { FlagRouter } from "../../../../utils/flag-router"
|
||||
import { DistributedTransaction } from "../../../../utils/transaction"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
|
||||
import {
|
||||
createVariantTransaction,
|
||||
revertVariantTransaction,
|
||||
} 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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -7,24 +9,19 @@ import {
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
import { Type } from "class-transformer"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||
import {
|
||||
PricingService,
|
||||
ProductService,
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../services"
|
||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import {
|
||||
CreateProductVariantInput,
|
||||
ProductVariantPricesCreateReq,
|
||||
} from "../../../../types/product-variant"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
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 { ulid } from "ulid"
|
||||
import { IInventoryService } from "../../../../../interfaces"
|
||||
import { ProductVariant } from "../../../../../models"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../../services"
|
||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
||||
import { CreateProductVariantInput } from "../../../../../types/product-variant"
|
||||
import {
|
||||
DistributedTransaction,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -11,38 +14,34 @@ import {
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
||||
import { ProductStatus } from "../../../../models"
|
||||
import {
|
||||
PricingService,
|
||||
ProductService,
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../services"
|
||||
import { Logger } from "../../../../types/global"
|
||||
import {
|
||||
ProductProductCategoryReq,
|
||||
ProductSalesChannelReq,
|
||||
ProductTagReq,
|
||||
ProductTypeReq,
|
||||
} 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 {
|
||||
CreateProductVariantInput,
|
||||
ProductVariantPricesUpdateReq,
|
||||
} from "../../../../types/product-variant"
|
||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { DistributedTransaction } from "../../../../utils/transaction"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
import {
|
||||
createVariantTransaction,
|
||||
revertVariantTransaction,
|
||||
} from "./transaction/create-product-variant"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { Logger } from "../../../../types/global"
|
||||
|
||||
/**
|
||||
* @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 { isDefined } from "medusa-core-utils"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
|
||||
/**
|
||||
* @oas [delete] /admin/reservations/{id}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
|
||||
/**
|
||||
* @oas [get] /admin/reservations/{id}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { ReservationItemDTO } from "@medusajs/types"
|
||||
import { Router } from "express"
|
||||
import { ReservationItemDTO } from "../../../.."
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import "reflect-metadata"
|
||||
import { AdminPostReservationsReq } from "./create-reservation"
|
||||
import { AdminPostReservationsReservationReq } from "./update-reservation"
|
||||
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
||||
import { AdminPostReservationsReq } from "./create-reservation"
|
||||
import { AdminGetReservationsParams } from "./list-reservations"
|
||||
import { AdminPostReservationsReservationReq } from "./update-reservation"
|
||||
|
||||
const route = Router()
|
||||
|
||||
@@ -133,5 +132,5 @@ export type AdminReservationsDeleteRes = DeleteResponse
|
||||
export * from "./create-reservation"
|
||||
export * from "./delete-reservation"
|
||||
export * from "./get-reservation"
|
||||
export * from "./update-reservation"
|
||||
export * from "./list-reservations"
|
||||
export * from "./update-reservation"
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { Type } from "class-transformer"
|
||||
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||
import { Request, Response } from "express"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import {
|
||||
extendedFindParamsMixin,
|
||||
NumericalComparisonOperator,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { isDefined } from "@medusajs/utils"
|
||||
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { LineItemService } from "../../../../services"
|
||||
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { IInventoryService } from "../../../../../interfaces"
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
import { LineItemService } from "../../../../../services"
|
||||
|
||||
export const validateUpdateReservationQuantity = async (
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Request, Response } from "express"
|
||||
import { IStockLocationService } from "@medusajs/types"
|
||||
import { Type } from "class-transformer"
|
||||
import { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||
|
||||
import { IStockLocationService } from "../../../../interfaces"
|
||||
import { Request, Response } from "express"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { IInventoryService, IStockLocationService } from "@medusajs/types"
|
||||
import { EntityManager } from "typeorm"
|
||||
import {
|
||||
IInventoryService,
|
||||
IStockLocationService,
|
||||
} from "../../../../interfaces"
|
||||
import { SalesChannelLocationService } from "../../../../services"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { IStockLocationService } from "../../../../interfaces"
|
||||
import { IStockLocationService } from "@medusajs/types"
|
||||
import { Request, Response } from "express"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { joinSalesChannels } from "./utils/join-sales-channels"
|
||||
import {
|
||||
SalesChannelLocationService,
|
||||
SalesChannelService,
|
||||
} from "../../../../services"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { joinSalesChannels } from "./utils/join-sales-channels"
|
||||
|
||||
/**
|
||||
* @oas [get] /admin/stock-locations/{id}
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
import { Router } from "express"
|
||||
import "reflect-metadata"
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import {
|
||||
StockLocationDTO,
|
||||
StockLocationExpandedDTO,
|
||||
} from "../../../../types/stock-location"
|
||||
DeleteResponse,
|
||||
PaginatedResponse,
|
||||
StockLocationTypes,
|
||||
} from "@medusajs/types"
|
||||
import { Router } from "express"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { AdminGetStockLocationsParams } from "./list-stock-locations"
|
||||
import { AdminGetStockLocationsLocationParams } from "./get-stock-location"
|
||||
import {
|
||||
AdminPostStockLocationsLocationParams,
|
||||
AdminPostStockLocationsLocationReq,
|
||||
} from "./update-stock-location"
|
||||
import { checkRegisteredModules } from "../../../middlewares/check-registered-modules"
|
||||
import {
|
||||
AdminPostStockLocationsParams,
|
||||
AdminPostStockLocationsReq,
|
||||
} 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()
|
||||
|
||||
@@ -82,14 +81,9 @@ export default (app) => {
|
||||
return app
|
||||
}
|
||||
|
||||
export const defaultAdminStockLocationFields: (keyof StockLocationDTO)[] = [
|
||||
"id",
|
||||
"name",
|
||||
"address_id",
|
||||
"metadata",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
// eslint-disable-next-line max-len
|
||||
export const defaultAdminStockLocationFields: (keyof StockLocationTypes.StockLocationDTO)[] =
|
||||
["id", "name", "address_id", "metadata", "created_at", "updated_at"]
|
||||
|
||||
export const defaultAdminStockLocationRelations = []
|
||||
|
||||
@@ -125,7 +119,7 @@ export type AdminStockLocationsDeleteRes = DeleteResponse
|
||||
* $ref: "#/components/schemas/StockLocationExpandedDTO"
|
||||
*/
|
||||
export type AdminStockLocationsRes = {
|
||||
stock_location: StockLocationExpandedDTO
|
||||
stock_location: StockLocationTypes.StockLocationExpandedDTO
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,10 +146,10 @@ export type AdminStockLocationsRes = {
|
||||
* description: The number of items per page
|
||||
*/
|
||||
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 "./get-stock-location"
|
||||
export * from "./list-stock-locations"
|
||||
export * from "./update-stock-location"
|
||||
@@ -1,13 +1,12 @@
|
||||
import { IStockLocationService } from "@medusajs/types"
|
||||
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 {
|
||||
SalesChannelLocationService,
|
||||
SalesChannelService,
|
||||
} from "../../../../services"
|
||||
import { extendedFindParamsMixin } from "../../../../types/common"
|
||||
import { IsType } from "../../../../utils/validators/is-type"
|
||||
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 { IsObject, IsOptional, IsString, ValidateNested } from "class-validator"
|
||||
|
||||
import { IStockLocationService } from "../../../../interfaces"
|
||||
import { Request, Response } from "express"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { StockLocationDTO, StockLocationExpandedDTO } from "@medusajs/types"
|
||||
import {
|
||||
SalesChannelLocationService,
|
||||
SalesChannelService,
|
||||
} from "../../../../../services"
|
||||
import {
|
||||
StockLocationDTO,
|
||||
StockLocationExpandedDTO,
|
||||
} from "../../../../../types/stock-location"
|
||||
|
||||
const joinSalesChannels = async (
|
||||
locations: StockLocationDTO[],
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { ModulesHelper } from "@medusajs/modules-sdk"
|
||||
import { defaultRelationsExtended } from "."
|
||||
import {
|
||||
FulfillmentProviderService,
|
||||
PaymentProviderService,
|
||||
@@ -5,8 +7,6 @@ import {
|
||||
} from "../../../../services"
|
||||
import { ExtendedStoreDTO } from "../../../../types/store"
|
||||
import { FlagRouter } from "../../../../utils/flag-router"
|
||||
import { ModulesHelper } from "@medusajs/modules-sdk"
|
||||
import { defaultRelationsExtended } from "."
|
||||
|
||||
/**
|
||||
* @oas [get] /admin/store
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
IInventoryService,
|
||||
InventoryItemDTO,
|
||||
InventoryLevelDTO,
|
||||
} from "../../../../types/inventory"
|
||||
import ProductVariantInventoryService from "../../../../services/product-variant-inventory"
|
||||
} from "@medusajs/types"
|
||||
import { SalesChannel } from "../../../../models"
|
||||
import {
|
||||
SalesChannelLocationService,
|
||||
SalesChannelService,
|
||||
} from "../../../../services"
|
||||
import { SalesChannel } from "../../../../models"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import ProductVariantService from "../../../../services/product-variant"
|
||||
import ProductVariantInventoryService from "../../../../services/product-variant-inventory"
|
||||
import { joinLevels } from "../inventory-items/utils/join-levels"
|
||||
|
||||
/**
|
||||
@@ -126,6 +126,7 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
const quantity =
|
||||
// eslint-disable-next-line max-len
|
||||
await productVariantInventoryService.getVariantQuantityFromVariantInventoryItems(
|
||||
variantInventoryItems,
|
||||
channel.id
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { EOL } from "os"
|
||||
import boxen from "boxen"
|
||||
import path from "path"
|
||||
import { execSync } from "child_process"
|
||||
import spawn from "cross-spawn"
|
||||
import chokidar from "chokidar"
|
||||
import spawn from "cross-spawn"
|
||||
import Store from "medusa-telemetry/dist/store"
|
||||
import { EOL } from "os"
|
||||
import path from "path"
|
||||
|
||||
import Logger from "../loaders/logger"
|
||||
|
||||
@@ -50,7 +50,11 @@ export default async function ({ port, directory }) {
|
||||
let child = spawn(cliPath, [`start`, ...args], {
|
||||
cwd: directory,
|
||||
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) => {
|
||||
@@ -65,7 +69,7 @@ export default async function ({ port, directory }) {
|
||||
|
||||
execSync(`${babelPath} src -d dist --extensions ".ts,.js"`, {
|
||||
cwd: directory,
|
||||
stdio: ["pipe", process.stdout, process.stderr],
|
||||
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
||||
})
|
||||
|
||||
Logger.info("Rebuilt")
|
||||
@@ -73,7 +77,11 @@ export default async function ({ port, directory }) {
|
||||
child = spawn(cliPath, [`start`, ...args], {
|
||||
cwd: directory,
|
||||
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 { dbConnection } = await loaders({ directory, expressApp: app })
|
||||
const serverActivity = Logger.activity(`Creating server`)
|
||||
const server = GracefulShutdownServer.create(
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
return
|
||||
}
|
||||
Logger.success(serverActivity, `Server is ready on port: ${port}`)
|
||||
track("CLI_START_COMPLETED")
|
||||
try {
|
||||
const { dbConnection } = await loaders({ directory, expressApp: app })
|
||||
const serverActivity = Logger.activity(`Creating server`)
|
||||
const server = GracefulShutdownServer.create(
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
return
|
||||
}
|
||||
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
|
||||
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)
|
||||
})
|
||||
return { dbConnection, server }
|
||||
} catch (err) {
|
||||
Logger.error("Error starting server", err)
|
||||
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/common"
|
||||
export * from "./types/global"
|
||||
export * from "./types/inventory"
|
||||
export * from "./types/price-list"
|
||||
export * from "./types/stock-location"
|
||||
export * from "./utils"
|
||||
@@ -7,7 +7,6 @@ export * from "./notification-service"
|
||||
export * from "./payment-processor"
|
||||
export * from "./payment-service"
|
||||
export * from "./price-selection-strategy"
|
||||
export * from "./services"
|
||||
export * from "./tax-calculation-strategy"
|
||||
export * from "./tax-service"
|
||||
export * from "./transaction-base-service"
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface ICacheService {
|
||||
get<T>(key: string): Promise<T | null>
|
||||
|
||||
set(key: string, data: unknown, ttl?: number): Promise<void>
|
||||
|
||||
invalidate(key: string): Promise<void>
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./cache"
|
||||
export * from "./inventory"
|
||||
export * from "./stock-location"
|
||||
@@ -1,114 +0,0 @@
|
||||
import { FindConfig } from "../../types/common"
|
||||
|
||||
import {
|
||||
InventoryItemDTO,
|
||||
ReservationItemDTO,
|
||||
InventoryLevelDTO,
|
||||
FilterableInventoryItemProps,
|
||||
CreateInventoryItemInput,
|
||||
CreateReservationItemInput,
|
||||
FilterableInventoryLevelProps,
|
||||
FilterableReservationItemProps,
|
||||
CreateInventoryLevelInput,
|
||||
UpdateInventoryLevelInput,
|
||||
UpdateReservationItemInput,
|
||||
} from "../../types/inventory"
|
||||
|
||||
export interface IInventoryService {
|
||||
listInventoryItems(
|
||||
selector: FilterableInventoryItemProps,
|
||||
config?: FindConfig<InventoryItemDTO>
|
||||
): Promise<[InventoryItemDTO[], number]>
|
||||
|
||||
listReservationItems(
|
||||
selector: FilterableReservationItemProps,
|
||||
config?: FindConfig<ReservationItemDTO>
|
||||
): Promise<[ReservationItemDTO[], number]>
|
||||
|
||||
listInventoryLevels(
|
||||
selector: FilterableInventoryLevelProps,
|
||||
config?: FindConfig<InventoryLevelDTO>
|
||||
): Promise<[InventoryLevelDTO[], number]>
|
||||
|
||||
retrieveInventoryItem(
|
||||
inventoryItemId: string,
|
||||
config?: FindConfig<InventoryItemDTO>
|
||||
): Promise<InventoryItemDTO>
|
||||
|
||||
retrieveInventoryLevel(
|
||||
inventoryItemId: string,
|
||||
locationId: string
|
||||
): Promise<InventoryLevelDTO>
|
||||
|
||||
retrieveReservationItem(reservationId: string): Promise<ReservationItemDTO>
|
||||
|
||||
createReservationItem(
|
||||
input: CreateReservationItemInput
|
||||
): Promise<ReservationItemDTO>
|
||||
|
||||
createInventoryItem(
|
||||
input: CreateInventoryItemInput
|
||||
): Promise<InventoryItemDTO>
|
||||
|
||||
createInventoryLevel(
|
||||
data: CreateInventoryLevelInput
|
||||
): Promise<InventoryLevelDTO>
|
||||
|
||||
updateInventoryLevel(
|
||||
inventoryItemId: string,
|
||||
locationId: string,
|
||||
update: UpdateInventoryLevelInput
|
||||
): Promise<InventoryLevelDTO>
|
||||
|
||||
updateInventoryItem(
|
||||
inventoryItemId: string,
|
||||
input: CreateInventoryItemInput
|
||||
): Promise<InventoryItemDTO>
|
||||
|
||||
updateReservationItem(
|
||||
reservationItemId: string,
|
||||
input: UpdateReservationItemInput
|
||||
): Promise<ReservationItemDTO>
|
||||
|
||||
deleteReservationItemsByLineItem(lineItemId: string): Promise<void>
|
||||
|
||||
deleteReservationItem(reservationItemId: string | string[]): Promise<void>
|
||||
|
||||
deleteInventoryItem(inventoryItemId: string): Promise<void>
|
||||
|
||||
deleteInventoryItemLevelByLocationId(locationId: string): Promise<void>
|
||||
|
||||
deleteReservationItemByLocationId(locationId: string): Promise<void>
|
||||
|
||||
deleteInventoryLevel(
|
||||
inventoryLevelId: string,
|
||||
locationId: string
|
||||
): Promise<void>
|
||||
|
||||
adjustInventory(
|
||||
inventoryItemId: string,
|
||||
locationId: string,
|
||||
adjustment: number
|
||||
): Promise<InventoryLevelDTO>
|
||||
|
||||
confirmInventory(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[],
|
||||
quantity: number
|
||||
): Promise<boolean>
|
||||
|
||||
retrieveAvailableQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[]
|
||||
): Promise<number>
|
||||
|
||||
retrieveStockedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[]
|
||||
): Promise<number>
|
||||
|
||||
retrieveReservedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[]
|
||||
): Promise<number>
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { FindConfig } from "../../types/common"
|
||||
import {
|
||||
CreateStockLocationInput,
|
||||
FilterableStockLocationProps,
|
||||
StockLocationDTO,
|
||||
UpdateStockLocationInput,
|
||||
} from "../../types/stock-location"
|
||||
|
||||
export interface IStockLocationService {
|
||||
list(
|
||||
selector: FilterableStockLocationProps,
|
||||
config?: FindConfig<StockLocationDTO>
|
||||
): Promise<StockLocationDTO[]>
|
||||
|
||||
listAndCount(
|
||||
selector: FilterableStockLocationProps,
|
||||
config?: FindConfig<StockLocationDTO>
|
||||
): Promise<[StockLocationDTO[], number]>
|
||||
|
||||
retrieve(
|
||||
id: string,
|
||||
config?: FindConfig<StockLocationDTO>
|
||||
): Promise<StockLocationDTO>
|
||||
|
||||
create(input: CreateStockLocationInput): Promise<StockLocationDTO>
|
||||
|
||||
update(id: string, input: UpdateStockLocationInput): Promise<StockLocationDTO>
|
||||
|
||||
delete(id: string): Promise<void>
|
||||
}
|
||||
@@ -589,9 +589,9 @@ async function runSetupFunctions(pluginDetails: PluginDetails): Promise<void> {
|
||||
try {
|
||||
await loaded()
|
||||
} catch (err) {
|
||||
throw new Error(`A setup function from ${pluginDetails.name} failed`, {
|
||||
cause: err,
|
||||
})
|
||||
throw new Error(
|
||||
`A setup function from ${pluginDetails.name} failed. ${err}`
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import dotenv from "dotenv"
|
||||
import { AwilixContainer } from "awilix"
|
||||
import dotenv from "dotenv"
|
||||
import express from "express"
|
||||
|
||||
import {
|
||||
ProductVariantService,
|
||||
ProductVariantInventoryService,
|
||||
} from "../services"
|
||||
import { ProductVariant } from "../models"
|
||||
import { IInventoryService, IStockLocationService } from "../interfaces"
|
||||
import { IInventoryService, IStockLocationService } from "@medusajs/types"
|
||||
import loaders from "../loaders"
|
||||
import { ProductVariant } from "../models"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../services"
|
||||
|
||||
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 {
|
||||
EntityManager,
|
||||
FindManyOptions,
|
||||
@@ -8,43 +9,6 @@ import {
|
||||
Not,
|
||||
Raw,
|
||||
} 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 {
|
||||
CartService,
|
||||
CustomerService,
|
||||
@@ -61,8 +25,43 @@ import {
|
||||
ShippingOptionService,
|
||||
ShippingProfileService,
|
||||
TaxProviderService,
|
||||
TotalsService
|
||||
TotalsService,
|
||||
} 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"
|
||||
|
||||
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 {
|
||||
ICacheService,
|
||||
IInventoryService,
|
||||
IStockLocationService,
|
||||
TransactionBaseService,
|
||||
} from "../interfaces"
|
||||
import { LineItem, Product, ProductVariant } from "../models"
|
||||
import { ProductVariantInventoryItem } from "../models/product-variant-inventory-item"
|
||||
import {
|
||||
InventoryItemDTO,
|
||||
IStockLocationService,
|
||||
ReservationItemDTO,
|
||||
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 {
|
||||
ProductVariantService,
|
||||
SalesChannelInventoryService,
|
||||
SalesChannelLocationService,
|
||||
} from "./"
|
||||
import ProductVariantService from "./product-variant"
|
||||
import SalesChannelInventoryService from "./sales-channel-inventory"
|
||||
import SalesChannelLocationService from "./sales-channel-location"
|
||||
|
||||
type InjectedDependencies = {
|
||||
manager: EntityManager
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { EventBusTypes, IInventoryService } from "@medusajs/types"
|
||||
import { TransactionBaseService } from "@medusajs/utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
import { IInventoryService, TransactionBaseService } from "../interfaces"
|
||||
|
||||
import { EventBusTypes } from "@medusajs/types"
|
||||
import { SalesChannelLocationService } from "./"
|
||||
import SalesChannelLocationService from "./sales-channel-location"
|
||||
|
||||
type InjectedDependencies = {
|
||||
inventoryService: IInventoryService
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { EntityManager, In } from "typeorm"
|
||||
import { IStockLocationService, TransactionBaseService } from "../interfaces"
|
||||
import { SalesChannelService } from "./"
|
||||
|
||||
import { EventBusTypes } from "@medusajs/types"
|
||||
|
||||
import { IEventBusService, IStockLocationService } from "@medusajs/types"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager, In } from "typeorm"
|
||||
import { TransactionBaseService } from "../interfaces"
|
||||
import { SalesChannelLocation } from "../models/sales-channel-location"
|
||||
import SalesChannelService from "./sales-channel"
|
||||
|
||||
|
||||
type InjectedDependencies = {
|
||||
stockLocationService: IStockLocationService
|
||||
salesChannelService: SalesChannelService
|
||||
eventBusService: EventBusTypes.IEventBusService
|
||||
eventBusService: IEventBusService
|
||||
manager: EntityManager
|
||||
}
|
||||
|
||||
@@ -20,7 +19,7 @@ type InjectedDependencies = {
|
||||
|
||||
class SalesChannelLocationService extends TransactionBaseService {
|
||||
protected readonly salesChannelService_: SalesChannelService
|
||||
protected readonly eventBusService_: EventBusTypes.IEventBusService
|
||||
protected readonly eventBusService_: IEventBusService
|
||||
protected readonly stockLocationService_: IStockLocationService
|
||||
|
||||
constructor({
|
||||
|
||||
@@ -2,12 +2,12 @@ import { AwilixContainer } from "awilix"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { In } from "typeorm"
|
||||
|
||||
import { ICacheService, IEventBusService } from "@medusajs/types"
|
||||
import {
|
||||
ICacheService,
|
||||
ITaxService,
|
||||
ItemTaxCalculationLine,
|
||||
TaxCalculationContext,
|
||||
TransactionBaseService,
|
||||
TransactionBaseService
|
||||
} from "../interfaces"
|
||||
import {
|
||||
Cart,
|
||||
@@ -16,16 +16,13 @@ import {
|
||||
Region,
|
||||
ShippingMethod,
|
||||
ShippingMethodTaxLine,
|
||||
TaxProvider,
|
||||
TaxProvider
|
||||
} from "../models"
|
||||
import { LineItemTaxLineRepository } from "../repositories/line-item-tax-line"
|
||||
import { ShippingMethodTaxLineRepository } from "../repositories/shipping-method-tax-line"
|
||||
import { TaxProviderRepository } from "../repositories/tax-provider"
|
||||
import { isCart } from "../types/cart"
|
||||
|
||||
import { TaxLinesMaps, TaxServiceRate } from "../types/tax-service"
|
||||
import EventBusService from "./event-bus"
|
||||
|
||||
import TaxRateService from "./tax-rate"
|
||||
|
||||
type RegionDetails = {
|
||||
@@ -43,7 +40,7 @@ class TaxProviderService extends TransactionBaseService {
|
||||
protected readonly taxLineRepo_: typeof LineItemTaxLineRepository
|
||||
protected readonly smTaxLineRepo_: typeof ShippingMethodTaxLineRepository
|
||||
protected readonly taxProviderRepo_: typeof TaxProviderRepository
|
||||
protected readonly eventBus_: EventBusService
|
||||
protected readonly eventBus_: IEventBusService
|
||||
|
||||
constructor(container: AwilixContainer) {
|
||||
super(container)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ICacheService } from "@medusajs/types"
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import {
|
||||
AbstractPriceSelectionStrategy,
|
||||
ICacheService,
|
||||
IPriceSelectionStrategy,
|
||||
PriceSelectionContext,
|
||||
PriceSelectionResult,
|
||||
PriceType,
|
||||
} from "../interfaces"
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||
import { MoneyAmountRepository } from "../repositories/money-amount"
|
||||
import { TaxServiceRate } from "../types/tax-service"
|
||||
@@ -79,9 +79,7 @@ class PriceSelectionStrategy extends AbstractPriceSelectionStrategy {
|
||||
variant_id: string,
|
||||
context: PriceSelectionContext
|
||||
): Promise<PriceSelectionResult> {
|
||||
const moneyRepo = this.manager_.withRepository(
|
||||
this.moneyAmountRepository_
|
||||
)
|
||||
const moneyRepo = this.manager_.withRepository(this.moneyAmountRepository_)
|
||||
|
||||
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
||||
variant_id,
|
||||
@@ -168,9 +166,7 @@ class PriceSelectionStrategy extends AbstractPriceSelectionStrategy {
|
||||
variant_id: string,
|
||||
context: PriceSelectionContext
|
||||
): Promise<PriceSelectionResult> {
|
||||
const moneyRepo = this.manager_.withRepository(
|
||||
this.moneyAmountRepository_
|
||||
)
|
||||
const moneyRepo = this.manager_.withRepository(this.moneyAmountRepository_)
|
||||
|
||||
const [prices, count] = await moneyRepo.findManyForVariantInRegion(
|
||||
variant_id,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ICacheService } from "@medusajs/types"
|
||||
import { EventBusService, ProductVariantService } from "../services"
|
||||
import { ICacheService } from "../interfaces"
|
||||
|
||||
type ProductVariantUpdatedEventData = {
|
||||
id: string
|
||||
|
||||
@@ -15,11 +15,11 @@ import {
|
||||
FindOptionsWhere,
|
||||
OrderByCondition,
|
||||
} 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 { 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
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
import { NumericalComparisonOperator, StringComparisonOperator } from "./common"
|
||||
|
||||
/**
|
||||
* @schema InventoryItemDTO
|
||||
* type: object
|
||||
* required:
|
||||
* - sku
|
||||
* properties:
|
||||
* sku:
|
||||
* description: The Stock Keeping Unit (SKU) code of the Inventory Item.
|
||||
* type: string
|
||||
* hs_code:
|
||||
* description: The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.
|
||||
* type: string
|
||||
* origin_country:
|
||||
* description: The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.
|
||||
* type: string
|
||||
* mid_code:
|
||||
* description: The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.
|
||||
* type: string
|
||||
* material:
|
||||
* description: The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.
|
||||
* type: string
|
||||
* weight:
|
||||
* description: The weight of the Inventory Item. May be used in shipping rate calculations.
|
||||
* type: number
|
||||
* height:
|
||||
* description: The height of the Inventory Item. May be used in shipping rate calculations.
|
||||
* type: number
|
||||
* width:
|
||||
* description: The width of the Inventory Item. May be used in shipping rate calculations.
|
||||
* type: number
|
||||
* length:
|
||||
* description: The length of the Inventory Item. May be used in shipping rate calculations.
|
||||
* type: number
|
||||
* requires_shipping:
|
||||
* description: Whether the item requires shipping.
|
||||
* type: boolean
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
* created_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was created."
|
||||
* format: date-time
|
||||
* updated_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was updated."
|
||||
* format: date-time
|
||||
* deleted_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was deleted."
|
||||
* format: date-time
|
||||
*/
|
||||
export type InventoryItemDTO = {
|
||||
id: string
|
||||
sku?: string | null
|
||||
origin_country?: string | null
|
||||
hs_code?: string | null
|
||||
requires_shipping: boolean
|
||||
mid_code?: string | null
|
||||
material?: string | null
|
||||
weight?: number | null
|
||||
length?: number | null
|
||||
height?: number | null
|
||||
width?: number | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: string | Date | null
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema ReservationItemDTO
|
||||
* title: "Reservation item"
|
||||
* description: "Represents a reservation of an inventory item at a stock location"
|
||||
* type: object
|
||||
* required:
|
||||
* - id
|
||||
* - location_id
|
||||
* - inventory_item_id
|
||||
* - quantity
|
||||
* properties:
|
||||
* id:
|
||||
* description: "The id of the reservation item"
|
||||
* type: string
|
||||
* location_id:
|
||||
* description: "The id of the location of the reservation"
|
||||
* type: string
|
||||
* inventory_item_id:
|
||||
* description: "The id of the inventory item the reservation relates to"
|
||||
* type: string
|
||||
* quantity:
|
||||
* description: "The id of the reservation item"
|
||||
* type: number
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
* created_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was created."
|
||||
* format: date-time
|
||||
* updated_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was updated."
|
||||
* format: date-time
|
||||
* deleted_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was deleted."
|
||||
* format: date-time
|
||||
*/
|
||||
export type ReservationItemDTO = {
|
||||
id: string
|
||||
location_id: string
|
||||
inventory_item_id: string
|
||||
quantity: number
|
||||
line_item_id?: string | null
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: string | Date | null
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema InventoryLevelDTO
|
||||
* type: object
|
||||
* required:
|
||||
* - inventory_item_id
|
||||
* - location_id
|
||||
* - stocked_quantity
|
||||
* - reserved_quantity
|
||||
* - incoming_quantity
|
||||
* properties:
|
||||
* location_id:
|
||||
* description: the item location ID
|
||||
* type: string
|
||||
* stocked_quantity:
|
||||
* description: the total stock quantity of an inventory item at the given location ID
|
||||
* type: number
|
||||
* reserved_quantity:
|
||||
* description: the reserved stock quantity of an inventory item at the given location ID
|
||||
* type: number
|
||||
* incoming_quantity:
|
||||
* description: the incoming stock quantity of an inventory item at the given location ID
|
||||
* type: number
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
* created_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was created."
|
||||
* format: date-time
|
||||
* updated_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was updated."
|
||||
* format: date-time
|
||||
* deleted_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was deleted."
|
||||
* format: date-time
|
||||
*/
|
||||
export type InventoryLevelDTO = {
|
||||
id: string
|
||||
inventory_item_id: string
|
||||
location_id: string
|
||||
stocked_quantity: number
|
||||
reserved_quantity: number
|
||||
incoming_quantity: number
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: string | Date | null
|
||||
}
|
||||
|
||||
export type FilterableReservationItemProps = {
|
||||
id?: string | string[]
|
||||
type?: string | string[]
|
||||
line_item_id?: string | string[]
|
||||
inventory_item_id?: string | string[]
|
||||
location_id?: string | string[]
|
||||
quantity?: number | NumericalComparisonOperator
|
||||
}
|
||||
|
||||
export type FilterableInventoryItemProps = {
|
||||
id?: string | string[]
|
||||
location_id?: string | string[]
|
||||
q?: string
|
||||
sku?: string | string[] | StringComparisonOperator
|
||||
origin_country?: string | string[]
|
||||
hs_code?: string | string[] | StringComparisonOperator
|
||||
requires_shipping?: boolean
|
||||
}
|
||||
|
||||
export type CreateInventoryItemInput = {
|
||||
sku?: string
|
||||
origin_country?: string
|
||||
mid_code?: string
|
||||
material?: string
|
||||
weight?: number
|
||||
length?: number
|
||||
height?: number
|
||||
width?: number
|
||||
metadata?: Record<string, unknown> | null
|
||||
hs_code?: string
|
||||
requires_shipping?: boolean
|
||||
}
|
||||
|
||||
export type CreateReservationItemInput = {
|
||||
line_item_id?: string
|
||||
inventory_item_id: string
|
||||
location_id: string
|
||||
quantity: number
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export type FilterableInventoryLevelProps = {
|
||||
inventory_item_id?: string | string[]
|
||||
location_id?: string | string[]
|
||||
stocked_quantity?: number | NumericalComparisonOperator
|
||||
reserved_quantity?: number | NumericalComparisonOperator
|
||||
incoming_quantity?: number | NumericalComparisonOperator
|
||||
}
|
||||
|
||||
export type CreateInventoryLevelInput = {
|
||||
inventory_item_id: string
|
||||
location_id: string
|
||||
stocked_quantity: number
|
||||
reserved_quantity?: number
|
||||
incoming_quantity?: number
|
||||
}
|
||||
|
||||
export type UpdateInventoryLevelInput = {
|
||||
stocked_quantity?: number
|
||||
incoming_quantity?: number
|
||||
}
|
||||
|
||||
export type UpdateReservationItemInput = {
|
||||
quantity?: number
|
||||
location_id?: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export type ReserveQuantityContext = {
|
||||
locationId?: string
|
||||
lineItemId?: string
|
||||
salesChannelId?: string | null
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
import { SalesChannel } from "../models"
|
||||
import { StringComparisonOperator } from "./common"
|
||||
|
||||
/**
|
||||
* @schema StockLocationAddressDTO
|
||||
* title: "Stock Location Address"
|
||||
* description: "Represents a Stock Location Address"
|
||||
* type: object
|
||||
* required:
|
||||
* - address_1
|
||||
* - country_code
|
||||
* - created_at
|
||||
* - updated_at
|
||||
* properties:
|
||||
* id:
|
||||
* type: string
|
||||
* description: The stock location address' ID
|
||||
* example: laddr_51G4ZW853Y6TFXWPG5ENJ81X42
|
||||
* address_1:
|
||||
* type: string
|
||||
* description: Stock location address
|
||||
* example: 35, Jhon Doe Ave
|
||||
* address_2:
|
||||
* type: string
|
||||
* description: Stock location address' complement
|
||||
* example: apartment 4432
|
||||
* company:
|
||||
* type: string
|
||||
* description: Stock location company' name
|
||||
* example: Medusa
|
||||
* city:
|
||||
* type: string
|
||||
* description: Stock location address' city
|
||||
* example: Mexico city
|
||||
* country_code:
|
||||
* type: string
|
||||
* description: Stock location address' country
|
||||
* example: MX
|
||||
* phone:
|
||||
* type: string
|
||||
* description: Stock location address' phone number
|
||||
* example: +1 555 61646
|
||||
* postal_code:
|
||||
* type: string
|
||||
* description: Stock location address' postal code
|
||||
* example: HD3-1G8
|
||||
* province:
|
||||
* type: string
|
||||
* description: Stock location address' province
|
||||
* example: Sinaloa
|
||||
* created_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was created."
|
||||
* format: date-time
|
||||
* updated_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was updated."
|
||||
* format: date-time
|
||||
* deleted_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was deleted."
|
||||
* format: date-time
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
*/
|
||||
export type StockLocationAddressDTO = {
|
||||
id?: string
|
||||
address_1: string
|
||||
address_2?: string | null
|
||||
company?: string | null
|
||||
country_code: string
|
||||
city?: string | null
|
||||
phone?: string | null
|
||||
postal_code?: string | null
|
||||
province?: string | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: string | Date | null
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema StockLocationDTO
|
||||
* title: "Stock Location"
|
||||
* description: "Represents a Stock Location"
|
||||
* type: object
|
||||
* required:
|
||||
* - id
|
||||
* - name
|
||||
* - address_id
|
||||
* - created_at
|
||||
* - updated_at
|
||||
* properties:
|
||||
* id:
|
||||
* type: string
|
||||
* description: The stock location's ID
|
||||
* example: sloc_51G4ZW853Y6TFXWPG5ENJ81X42
|
||||
* address_id:
|
||||
* type: string
|
||||
* description: Stock location address' ID
|
||||
* example: laddr_05B2ZE853Y6FTXWPW85NJ81A44
|
||||
* name:
|
||||
* type: string
|
||||
* description: The name of the stock location
|
||||
* example: Main Warehouse
|
||||
* address:
|
||||
* description: "The Address of the Stock Location"
|
||||
* allOf:
|
||||
* - $ref: "#/components/schemas/StockLocationAddressDTO"
|
||||
* - type: object
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
* created_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was created."
|
||||
* format: date-time
|
||||
* updated_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was updated."
|
||||
* format: date-time
|
||||
* deleted_at:
|
||||
* type: string
|
||||
* description: "The date with timezone at which the resource was deleted."
|
||||
* format: date-time
|
||||
*/
|
||||
export type StockLocationDTO = {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
address_id: string
|
||||
address?: StockLocationAddressDTO
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: string | Date | null
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema StockLocationExpandedDTO
|
||||
* allOf:
|
||||
* - $ref: "#/components/schemas/StockLocationDTO"
|
||||
* - type: object
|
||||
* properties:
|
||||
* sales_channels:
|
||||
* $ref: "#/components/schemas/SalesChannel"
|
||||
*/
|
||||
export type StockLocationExpandedDTO = StockLocationDTO & {
|
||||
sales_channels?: SalesChannel[]
|
||||
}
|
||||
|
||||
export type FilterableStockLocationProps = {
|
||||
id?: string | string[]
|
||||
name?: string | string[] | StringComparisonOperator
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema StockLocationAddressInput
|
||||
* title: "Stock Location Address Input"
|
||||
* description: "Represents a Stock Location Address Input"
|
||||
* type: object
|
||||
* required:
|
||||
* - address_1
|
||||
* - country_code
|
||||
* properties:
|
||||
* address_1:
|
||||
* type: string
|
||||
* description: Stock location address
|
||||
* example: 35, Jhon Doe Ave
|
||||
* address_2:
|
||||
* type: string
|
||||
* description: Stock location address' complement
|
||||
* example: apartment 4432
|
||||
* city:
|
||||
* type: string
|
||||
* description: Stock location address' city
|
||||
* example: Mexico city
|
||||
* country_code:
|
||||
* type: string
|
||||
* description: Stock location address' country
|
||||
* example: MX
|
||||
* phone:
|
||||
* type: string
|
||||
* description: Stock location address' phone number
|
||||
* example: +1 555 61646
|
||||
* postal_code:
|
||||
* type: string
|
||||
* description: Stock location address' postal code
|
||||
* example: HD3-1G8
|
||||
* province:
|
||||
* type: string
|
||||
* description: Stock location address' province
|
||||
* example: Sinaloa
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
*/
|
||||
export type StockLocationAddressInput = {
|
||||
address_1: string
|
||||
address_2?: string
|
||||
country_code: string
|
||||
city?: string
|
||||
phone?: string
|
||||
province?: string
|
||||
postal_code?: string
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema CreateStockLocationInput
|
||||
* title: "Create Stock Location Input"
|
||||
* description: "Represents the Input to create a Stock Location"
|
||||
* type: object
|
||||
* required:
|
||||
* - name
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* description: The stock location name
|
||||
* address_id:
|
||||
* type: string
|
||||
* description: The Stock location address ID
|
||||
* address:
|
||||
* description: Stock location address object
|
||||
* allOf:
|
||||
* - $ref: "#/components/schemas/StockLocationAddressInput"
|
||||
* - type: object
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
*/
|
||||
export type CreateStockLocationInput = {
|
||||
name: string
|
||||
address_id?: string
|
||||
address?: string | StockLocationAddressInput
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema UpdateStockLocationInput
|
||||
* title: "Update Stock Location Input"
|
||||
* description: "Represents the Input to update a Stock Location"
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* description: The stock location name
|
||||
* address_id:
|
||||
* type: string
|
||||
* description: The Stock location address ID
|
||||
* address:
|
||||
* description: Stock location address object
|
||||
* allOf:
|
||||
* - $ref: "#/components/schemas/StockLocationAddressInput"
|
||||
* - type: object
|
||||
* metadata:
|
||||
* type: object
|
||||
* description: An optional key-value map with additional details
|
||||
* example: {car: "white"}
|
||||
*/
|
||||
export type UpdateStockLocationInput = {
|
||||
name?: string
|
||||
address_id?: string
|
||||
address?: StockLocationAddressInput
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Store, PaymentProvider, FulfillmentProvider } from "../models"
|
||||
import { FeatureFlagsResponse } from "./feature-flags"
|
||||
import { ModulesResponse as sdkModulesResponse } from "@medusajs/modules-sdk"
|
||||
import { FulfillmentProvider, PaymentProvider, Store } from "../models"
|
||||
import { FeatureFlagsResponse } from "./feature-flags"
|
||||
|
||||
export type UpdateStoreInput = {
|
||||
name?: string
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ExtendedFindConfig, FindConfig } from "../types/common"
|
||||
import {
|
||||
FindManyOptions,
|
||||
FindOperator,
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
MoreThanOrEqual,
|
||||
} from "typeorm"
|
||||
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
||||
import { ExtendedFindConfig, FindConfig } from "../types/common"
|
||||
import { isObject } from "./is-object"
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user