breaking: remove deprecated commands and code (#9521)

* breaking: remove deprecated commands

* feat: remove deprecated code and usages

* refactor: remove more logic around default relations

* fix tests

* remove log

* fix: remove defaultFields usage

* fix: add back accidentally removed code

* refactor: implement feedback

* feat: add --cluster flag to the start command

* refactor: assign limit to defaultLimit property

* fix: breaking code because of removed check

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
This commit is contained in:
Harminder Virk
2024-10-14 20:11:34 +05:30
committed by GitHub
co-authored by adrien2p
parent cea4cdc8d7
commit ad322f2760
37 changed files with 162 additions and 679 deletions
-1
View File
@@ -1,7 +1,6 @@
export * as ApiKeyUtils from "./api-key"
export * as CoreFlowsUitls from "./core-flows"
export * as DALUtils from "./dal"
export * as DecoratorUtils from "./decorators"
export * as DefaultsUtils from "./defaults"
export * as DMLUtils from "./dml"
export * as EventBusUtils from "./event-bus"
@@ -1 +0,0 @@
export * from "./inject-entity-manager"
@@ -1,50 +0,0 @@
import { Context, SharedContext } from "@medusajs/types"
import { MedusaContextType } from "../modules-sdk/decorators"
// @deprecated Use InjectManager instead
export function InjectEntityManager(
shouldForceTransaction: (target: any) => boolean = () => false,
managerProperty: string | false = "manager_"
): MethodDecorator {
return function (
target: any,
propertyKey: string | symbol,
descriptor: any
): void {
if (!target.MedusaContextIndex_) {
throw new Error(
`To apply @InjectEntityManager you have to flag a parameter using @MedusaContext`
)
}
const originalMethod = descriptor.value
const argIndex = target.MedusaContextIndex_[propertyKey]
descriptor.value = async function (...args: any[]) {
const shouldForceTransactionRes = shouldForceTransaction(target)
const context: SharedContext | Context = args[argIndex] ?? {}
if (!shouldForceTransactionRes && context?.transactionManager) {
return await originalMethod.apply(this, args)
}
return await (managerProperty === false
? this
: this[managerProperty]
).transaction(
async (transactionManager) => {
args[argIndex] = args[argIndex] ?? { __type: MedusaContextType }
args[argIndex].transactionManager = transactionManager
return await originalMethod.apply(this, args)
},
{
transaction: context?.transactionManager,
isolationLevel: (context as Context)?.isolationLevel,
enableNestedTransactions:
(context as Context).enableNestedTransactions ?? false,
}
)
}
}
}
-1
View File
@@ -5,7 +5,6 @@ export * from "./bundles"
export * from "./common"
export * from "./core-flows"
export * from "./dal"
export * from "./decorators"
export * from "./defaults"
export * from "./dml"
export * from "./event-bus"
@@ -1,4 +1,4 @@
import { Context, SharedContext } from "@medusajs/types"
import { Context } from "@medusajs/types"
import { MedusaContextType } from "./context-parameter"
export function InjectSharedContext(): MethodDecorator {
@@ -17,7 +17,7 @@ export function InjectSharedContext(): MethodDecorator {
const argIndex = target.MedusaContextIndex_[propertyKey]
descriptor.value = function (...args: any[]) {
const context: SharedContext | Context = {
const context: Context = {
...(args[argIndex] ?? { __type: MedusaContextType }),
}
args[argIndex] = context
@@ -1,5 +1,5 @@
import { Context, EventBusTypes } from "@medusajs/types"
import { buildModuleResourceEventName } from "../event-bus"
import { buildModuleResourceEventName } from "../event-bus/utils"
// TODO should that move closer to the event bus? and maybe be rename to modulemoduleEventBuilderFactory
@@ -28,16 +28,11 @@ import { buildModuleResourceEventName } from "../event-bus"
export function moduleEventBuilderFactory({
action,
object,
eventsEnum,
eventName,
source,
}: {
action: string
object: string
/**
* @deprecated use eventName instead
*/
eventsEnum?: Record<string, string>
eventName?: string
source: string
}) {
@@ -57,14 +52,8 @@ export function moduleEventBuilderFactory({
const aggregator = sharedContext.messageAggregator!
const messages: EventBusTypes.RawMessageFormat[] = []
// The event enums contains event formatted like so [object]_[action] e.g. PRODUCT_CREATED
// We expect the keys of events to be fully uppercased
let eventName_ = eventsEnum
? eventsEnum[`${object.toUpperCase()}_${action.toUpperCase()}`]
: eventName
if (!eventName_) {
eventName_ = buildModuleResourceEventName({
if (!eventName) {
eventName = buildModuleResourceEventName({
prefix: source,
objectName: object,
action,
@@ -77,7 +66,7 @@ export function moduleEventBuilderFactory({
action,
context: sharedContext,
data: { id: dataItem.id },
eventName: eventName_,
eventName: eventName!,
object,
})
})
@@ -25,16 +25,6 @@ export type ModelDTOConfig = {
model?: DmlEntity<any, any>
create?: any
update?: any
/**
* @internal
* @deprecated
*/
singular?: string
/**
* @internal
* @deprecated
*/
plural?: string
}
export type ModelsConfigTemplate = { [key: string]: ModelDTOConfig }
@@ -51,21 +41,6 @@ export type ModelConfigurationsToConfigTemplate<T extends ModelEntries> = {
: T[Key] extends IDmlEntity<any, any>
? T[Key]
: never
/**
* @deprecated
*/
create: any
update: any
/**
* @deprecated
*/
singular: T[Key] extends { singular: string } ? T[Key]["singular"] : Key
/**
* @deprecated
*/
plural: T[Key] extends { plural: string }
? T[Key]["plural"]
: Pluralize<Key & string>
}
}