chore: Rename entity to model (#7977)

**What**
Start renaming `entity` to `model`
This commit is contained in:
Adrien de Peretti
2024-07-08 07:43:49 +00:00
committed by GitHub
parent e11716fa1e
commit 9750047af1
60 changed files with 171 additions and 171 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
export type EntityDateColumns = "created_at" | "updated_at"
export type SoftDeletableEntityDateColumns = "deleted_at" | EntityDateColumns
export type ModelDateColumns = "created_at" | "updated_at"
export type SoftDeletableModelDateColumns = "deleted_at" | ModelDateColumns
@@ -410,7 +410,7 @@ export function buildLinkConfigFromLinkableKeys<
* Reversed map from linkableKeys to entity name to linkable keys
* @param linkableKeys
*/
export function buildEntitiesNameToLinkableKeysMap(
export function buildModelsNameToLinkableKeysMap(
linkableKeys: Record<string, string>
): MapToConfig {
const entityLinkableKeysMap: MapToConfig = {}
@@ -23,13 +23,13 @@ import { InjectManager, MedusaContext } from "./decorators"
import { ModuleRegistrationName } from "./definition"
import {
BaseMethods,
EntitiesConfigTemplate,
ExtractKeysFromConfig,
MedusaServiceReturnType,
ModelConfigurationsToConfigTemplate,
TEntityEntries,
ModelEntries,
ModelsConfigTemplate,
} from "./types/medusa-service"
import { buildEntitiesNameToLinkableKeysMap } from "./joiner-config-builder"
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
const readMethods = ["retrieve", "list", "listAndCount"] as BaseMethods[]
const writeMethods = [
@@ -47,7 +47,7 @@ const methods: BaseMethods[] = [...readMethods, ...writeMethods]
*/
function buildMethodNamesFromModel(
modelName: string,
model: TEntityEntries[keyof TEntityEntries]
model: ModelEntries[keyof ModelEntries]
): Record<string, string> {
return methods.reduce((acc, method) => {
let normalizedModelName: string = ""
@@ -79,11 +79,11 @@ export const MedusaServiceModelObjectsSymbol = Symbol.for(
export const MedusaServiceSymbol = Symbol.for("MedusaServiceSymbol")
/**
* Accessible from the MedusaService, holds the entity name to linkable keys map
* Accessible from the MedusaService, holds the model name to linkable keys map
* to be used for softDelete and restore methods
*/
export const MedusaServiceEntityNameToLinkableKeysMapSymbol = Symbol.for(
"MedusaServiceEntityNameToLinkableKeysMapSymbol"
export const MedusaServiceModelNameToLinkableKeysMapSymbol = Symbol.for(
"MedusaServiceModelNameToLinkableKeysMapSymbol"
)
/**
@@ -103,7 +103,7 @@ export function isMedusaService(
*
* // Here the DTO's and names will be inferred from the arguments
*
* const entities = {
* const models = {
* Currency,
* Price,
* PriceList,
@@ -114,21 +114,21 @@ export function isMedusaService(
* RuleType,
* }
*
* class MyService extends ModulesSdkUtils.MedusaService(entities) {}
* class MyService extends ModulesSdkUtils.MedusaService(models) {}
*
* @param entities
* @param models
*/
export function MedusaService<
const EntitiesConfig extends EntitiesConfigTemplate = { __empty: any },
const TEntities extends TEntityEntries<
ExtractKeysFromConfig<EntitiesConfig>
> = TEntityEntries<ExtractKeysFromConfig<EntitiesConfig>>
const ModelsConfig extends ModelsConfigTemplate = { __empty: any },
const TModels extends ModelEntries<
ExtractKeysFromConfig<ModelsConfig>
> = ModelEntries<ExtractKeysFromConfig<ModelsConfig>>
>(
entities: TEntities
models: TModels
): MedusaServiceReturnType<
EntitiesConfig extends { __empty: any }
? ModelConfigurationsToConfigTemplate<TEntities>
: EntitiesConfig
ModelsConfig extends { __empty: any }
? ModelConfigurationsToConfigTemplate<TModels>
: ModelsConfig
> {
const buildAndAssignMethodImpl = function (
klassPrototype: any,
@@ -168,11 +168,11 @@ export function MedusaService<
config?: FindConfig<any>,
sharedContext: Context = {}
): Promise<T> {
const entities = await this.__container__[
const models = await this.__container__[
serviceRegistrationName
].retrieve(id, config, sharedContext)
return await this.baseRepository_.serialize<T>(entities)
return await this.baseRepository_.serialize<T>(models)
}
applyMethod(methodImplementation, 2)
@@ -186,8 +186,8 @@ export function MedusaService<
): Promise<T | T[]> {
const serviceData = Array.isArray(data) ? data : [data]
const service = this.__container__[serviceRegistrationName]
const entities = await service.create(serviceData, sharedContext)
const response = Array.isArray(data) ? entities : entities[0]
const models = await service.create(serviceData, sharedContext)
const response = Array.isArray(data) ? models : models[0]
return await this.baseRepository_.serialize<T | T[]>(response)
}
@@ -203,8 +203,8 @@ export function MedusaService<
): Promise<T | T[]> {
const serviceData = Array.isArray(data) ? data : [data]
const service = this.__container__[serviceRegistrationName]
const entities = await service.update(serviceData, sharedContext)
const response = Array.isArray(data) ? entities : entities[0]
const models = await service.update(serviceData, sharedContext)
const response = Array.isArray(data) ? models : models[0]
return await this.baseRepository_.serialize<T | T[]>(response)
}
@@ -220,9 +220,9 @@ export function MedusaService<
sharedContext: Context = {}
): Promise<T[]> {
const service = this.__container__[serviceRegistrationName]
const entities = await service.list(filters, config, sharedContext)
const models = await service.list(filters, config, sharedContext)
return await this.baseRepository_.serialize<T[]>(entities)
return await this.baseRepository_.serialize<T[]>(models)
}
applyMethod(methodImplementation, 2)
@@ -235,11 +235,11 @@ export function MedusaService<
config: FindConfig<any> = {},
sharedContext: Context = {}
): Promise<T[]> {
const [entities, count] = await this.__container__[
const [models, count] = await this.__container__[
serviceRegistrationName
].listAndCount(filters, config, sharedContext)
return [await this.baseRepository_.serialize<T[]>(entities), count]
return [await this.baseRepository_.serialize<T[]>(models), count]
}
applyMethod(methodImplementation, 2)
@@ -283,16 +283,16 @@ export function MedusaService<
? primaryKeyValues
: [primaryKeyValues]
const [entities, cascadedEntitiesMap] = await this.__container__[
const [models, cascadedModelsMap] = await this.__container__[
serviceRegistrationName
].softDelete(primaryKeyValues_, sharedContext)
const softDeletedEntities = await this.baseRepository_.serialize<T[]>(
entities
const softDeletedModels = await this.baseRepository_.serialize<T[]>(
models
)
await this.eventBusModuleService_?.emit(
softDeletedEntities.map(({ id }) => ({
softDeletedModels.map(({ id }) => ({
eventName: `${kebabCase(modelName)}.deleted`,
metadata: { source: "", action: "", object: "" },
data: { id },
@@ -301,15 +301,15 @@ export function MedusaService<
// Map internal table/column names to their respective external linkable keys
// eg: product.id = product_id, variant.id = variant_id
const mappedCascadedEntitiesMap = mapObjectTo(
cascadedEntitiesMap,
this[MedusaServiceEntityNameToLinkableKeysMapSymbol],
const mappedCascadedModelsMap = mapObjectTo(
cascadedModelsMap,
this[MedusaServiceModelNameToLinkableKeysMapSymbol],
{
pick: config.returnLinkableKeys,
}
)
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
return mappedCascadedModelsMap ? mappedCascadedModelsMap : void 0
}
applyMethod(methodImplementation, 2)
@@ -326,22 +326,22 @@ export function MedusaService<
? primaryKeyValues
: [primaryKeyValues]
const [_, cascadedEntitiesMap] = await this.__container__[
const [_, cascadedModelsMap] = await this.__container__[
serviceRegistrationName
].restore(primaryKeyValues_, sharedContext)
let mappedCascadedEntitiesMap
let mappedCascadedModelsMap
// Map internal table/column names to their respective external linkable keys
// eg: product.id = product_id, variant.id = variant_id
mappedCascadedEntitiesMap = mapObjectTo(
cascadedEntitiesMap,
this[MedusaServiceEntityNameToLinkableKeysMapSymbol],
mappedCascadedModelsMap = mapObjectTo(
cascadedModelsMap,
this[MedusaServiceModelNameToLinkableKeysMapSymbol],
{
pick: config.returnLinkableKeys,
}
)
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
return mappedCascadedModelsMap ? mappedCascadedModelsMap : void 0
}
applyMethod(methodImplementation, 2)
@@ -354,13 +354,13 @@ export function MedusaService<
[MedusaServiceSymbol] = true
static [MedusaServiceModelObjectsSymbol] =
entities as unknown as MedusaServiceReturnType<
EntitiesConfig extends { __empty: any }
? ModelConfigurationsToConfigTemplate<TEntities>
: EntitiesConfig
models as unknown as MedusaServiceReturnType<
ModelsConfig extends { __empty: any }
? ModelConfigurationsToConfigTemplate<TModels>
: ModelsConfig
>["$modelObjects"];
[MedusaServiceEntityNameToLinkableKeysMapSymbol]: MapToConfig
[MedusaServiceModelNameToLinkableKeysMapSymbol]: MapToConfig
readonly __container__: Record<any, any>
readonly baseRepository_: RepositoryService
@@ -380,8 +380,8 @@ export function MedusaService<
? this.__container__.eventBusModuleService
: undefined
this[MedusaServiceEntityNameToLinkableKeysMapSymbol] =
buildEntitiesNameToLinkableKeysMap(
this[MedusaServiceModelNameToLinkableKeysMapSymbol] =
buildModelsNameToLinkableKeysMap(
this.__joinerConfig?.()?.linkableKeys ?? {}
)
}
@@ -404,18 +404,18 @@ export function MedusaService<
* Build the retrieve/list/listAndCount/delete/softDelete/restore methods for all the other models
*/
const entitiesMethods: [
const modelsMethods: [
string,
TEntities[keyof TEntities],
TModels[keyof TModels],
Record<string, string>
][] = Object.entries(entities as {}).map(([name, config]) => [
][] = Object.entries(models as {}).map(([name, config]) => [
name,
config as TEntities[keyof TEntities],
buildMethodNamesFromModel(name, config as TEntities[keyof TEntities]),
config as TModels[keyof TModels],
buildMethodNamesFromModel(name, config as TModels[keyof TModels]),
])
for (let [modelName, model, modelsMethods] of entitiesMethods) {
Object.entries(modelsMethods).forEach(([method, methodName]) => {
for (let [modelName, model, modelMethods] of modelsMethods) {
Object.entries(modelMethods).forEach(([method, methodName]) => {
buildAndAssignMethodImpl(
AbstractModuleService_.prototype,
method,
@@ -36,9 +36,9 @@ export type ModelDTOConfig = {
plural?: string
}
export type EntitiesConfigTemplate = { [key: string]: ModelDTOConfig }
export type ModelsConfigTemplate = { [key: string]: ModelDTOConfig }
export type ModelConfigurationsToConfigTemplate<T extends TEntityEntries> = {
export type ModelConfigurationsToConfigTemplate<T extends ModelEntries> = {
[Key in keyof T]: {
dto: T[Key] extends Constructor<any> ? InstanceType<T[Key]> : any
model: T[Key] extends { model: infer MODEL }
@@ -90,7 +90,7 @@ export type ExtractPluralName<
>
// TODO: The future expected entry will be a MODEL object but in the meantime we have to maintain backward compatibility for ouw own modules and therefore we need to support Constructor<any> as well as this temporary object
export type TEntityEntries<Keys = string> = Record<
export type ModelEntries<Keys = string> = Record<
Keys & string,
| DmlEntity<any, any>
/**
@@ -103,45 +103,45 @@ export type TEntityEntries<Keys = string> = Record<
| { name?: string; singular?: string; plural?: string }
>
export type ExtractKeysFromConfig<EntitiesConfig> = EntitiesConfig extends {
export type ExtractKeysFromConfig<ModelsConfig> = ModelsConfig extends {
__empty: any
}
? string
: keyof EntitiesConfig
: keyof ModelsConfig
export type AbstractModuleService<
TEntitiesDtoConfig extends Record<string, any>
TModelsDtoConfig extends Record<string, any>
> = {
[TEntityName in keyof TEntitiesDtoConfig as `retrieve${ExtractSingularName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `retrieve${ExtractSingularName<
TModelsDtoConfig,
TModelName
>}`]: (
id: string,
config?: FindConfig<any>,
sharedContext?: Context
) => Promise<TEntitiesDtoConfig[TEntityName]["dto"]>
) => Promise<TModelsDtoConfig[TModelName]["dto"]>
} & {
[TEntityName in keyof TEntitiesDtoConfig as `list${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `list${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: (
filters?: any,
config?: FindConfig<any>,
sharedContext?: Context
) => Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
) => Promise<TModelsDtoConfig[TModelName]["dto"][]>
} & {
[TEntityName in keyof TEntitiesDtoConfig as `listAndCount${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `listAndCount${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(filters?: any, config?: FindConfig<any>, sharedContext?: Context): Promise<
[TEntitiesDtoConfig[TEntityName]["dto"][], number]
[TModelsDtoConfig[TModelName]["dto"][], number]
>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `delete${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `delete${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(
primaryKeyValues: string | object | string[] | object[],
@@ -149,9 +149,9 @@ export type AbstractModuleService<
): Promise<void>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `softDelete${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `softDelete${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
<TReturnableLinkableKeys extends string>(
primaryKeyValues: string | object | string[] | object[],
@@ -160,9 +160,9 @@ export type AbstractModuleService<
): Promise<Record<string, string[]> | void>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `restore${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `restore${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
<TReturnableLinkableKeys extends string>(
primaryKeyValues: string | object | string[] | object[],
@@ -171,16 +171,16 @@ export type AbstractModuleService<
): Promise<Record<string, string[]> | void>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `create${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(...args: any[]): Promise<any>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `update${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(...args: any[]): Promise<any>
}
@@ -190,53 +190,53 @@ export type AbstractModuleService<
// are not consistent accross modules
/* & {
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `create${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(data: any[], sharedContext?: Context): Promise<
TEntitiesDtoConfig[TEntityName]["dto"][]
TModelsDtoConfig[TModelName]["dto"][]
>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `create${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(data: any, sharedContext?: Context): Promise<
TEntitiesDtoConfig[TEntityName]["dto"][]
TModelsDtoConfig[TModelName]["dto"][]
>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `update${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(
data: TEntitiesDtoConfig[TEntityName]["update"][],
data: TModelsDtoConfig[TModelName]["update"][],
sharedContext?: Context
): Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
): Promise<TModelsDtoConfig[TModelName]["dto"][]>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `update${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(
data: TEntitiesDtoConfig[TEntityName]["update"],
data: TModelsDtoConfig[TModelName]["update"],
sharedContext?: Context
): Promise<TEntitiesDtoConfig[TEntityName]["dto"]>
): Promise<TModelsDtoConfig[TModelName]["dto"]>
}
} & {
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
TEntitiesDtoConfig,
TEntityName
[TModelName in keyof TModelsDtoConfig as `update${ExtractPluralName<
TModelsDtoConfig,
TModelName
>}`]: {
(
idOrdSelector: any,
data: TEntitiesDtoConfig[TEntityName]["update"],
data: TModelsDtoConfig[TModelName]["update"],
sharedContext?: Context
): Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
): Promise<TModelsDtoConfig[TModelName]["dto"][]>
}
}*/
+1 -1
View File
@@ -14,7 +14,7 @@ import {
Property,
} from "@mikro-orm/core"
type OptionalAddressProps = DAL.SoftDeletableEntityDateColumns
type OptionalAddressProps = DAL.SoftDeletableModelDateColumns
@Entity({ tableName: "cart_address" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -2,7 +2,7 @@ import { DAL } from "@medusajs/types"
import { BigNumber, MikroOrmBigNumberProperty } from "@medusajs/utils"
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
type OptionalAdjustmentLineProps = DAL.SoftDeletableEntityDateColumns
type OptionalAdjustmentLineProps = DAL.SoftDeletableModelDateColumns
/**
* As per the Mikro ORM docs, superclasses should use the abstract class definition
+1 -1
View File
@@ -25,7 +25,7 @@ import ShippingMethod from "./shipping-method"
type OptionalCartProps =
| "shipping_address"
| "billing_address"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const RegionIdIndex = createPsqlIndexStatementHelper({
name: "IDX_cart_region_id",
@@ -30,7 +30,7 @@ type OptionalLineItemProps =
| "compare_at_unit_price"
| "requires_shipping"
| "cart"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const CartIdIndex = createPsqlIndexStatementHelper({
name: "IDX_line_item_cart_id",
@@ -28,7 +28,7 @@ import ShippingMethodTaxLine from "./shipping-method-tax-line"
type OptionalShippingMethodProps =
| "cart"
| "is_tax_inclusive"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const CartIdIndex = createPsqlIndexStatementHelper({
name: "IDX_shipping_method_cart_id",
+1 -1
View File
@@ -1,7 +1,7 @@
import { DAL } from "@medusajs/types"
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
type OptionalTaxLineProps = DAL.SoftDeletableEntityDateColumns
type OptionalTaxLineProps = DAL.SoftDeletableModelDateColumns
/**
* As per the Mikro ORM docs, superclasses should use the abstract class definition
@@ -16,7 +16,7 @@ import {
} from "@mikro-orm/core"
import Customer from "./customer"
type OptionalAddressProps = DAL.EntityDateColumns // TODO: To be revisited when more clear
type OptionalAddressProps = DAL.ModelDateColumns // TODO: To be revisited when more clear
const CustomerAddressUniqueCustomerShippingAddress =
createPsqlIndexStatementHelper({
@@ -14,7 +14,7 @@ import {
import Customer from "./customer"
import CustomerGroup from "./customer-group"
type OptionalGroupProps = "customer_group" | "customer" | DAL.EntityDateColumns // TODO: To be revisited when more clear
type OptionalGroupProps = "customer_group" | "customer" | DAL.ModelDateColumns // TODO: To be revisited when more clear
@Entity({ tableName: "customer_group_customer" })
export default class CustomerGroupCustomer {
@@ -20,7 +20,7 @@ import {
import Customer from "./customer"
import CustomerGroupCustomer from "./customer-group-customer"
type OptionalGroupProps = DAL.SoftDeletableEntityDateColumns // TODO: To be revisited when more clear
type OptionalGroupProps = DAL.SoftDeletableModelDateColumns // TODO: To be revisited when more clear
const CustomerGroupUniqueName = createPsqlIndexStatementHelper({
tableName: "customer_group",
@@ -26,7 +26,7 @@ import CustomerGroupCustomer from "./customer-group-customer"
type OptionalCustomerProps =
| "groups"
| "addresses"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const CustomerUniqueEmail = createPsqlIndexStatementHelper({
tableName: "customer",
@@ -12,7 +12,7 @@ import {
Property,
} from "@mikro-orm/core"
type OptionalAddressProps = DAL.SoftDeletableEntityDateColumns
type OptionalAddressProps = DAL.SoftDeletableModelDateColumns
const FulfillmentDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "fulfillment_address",
@@ -20,7 +20,7 @@ import {
} from "@mikro-orm/core"
import Fulfillment from "./fulfillment"
type FulfillmentItemOptionalProps = DAL.SoftDeletableEntityDateColumns
type FulfillmentItemOptionalProps = DAL.SoftDeletableModelDateColumns
const FulfillmentIdIndex = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
@@ -18,7 +18,7 @@ import {
} from "@mikro-orm/core"
import Fulfillment from "./fulfillment"
type FulfillmentLabelOptionalProps = DAL.SoftDeletableEntityDateColumns
type FulfillmentLabelOptionalProps = DAL.SoftDeletableModelDateColumns
const FulfillmentIdIndex = createPsqlIndexStatementHelper({
tableName: "fulfillment_label",
@@ -20,7 +20,7 @@ import {
} from "@mikro-orm/core"
import ServiceZone from "./service-zone"
type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
type FulfillmentSetOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "fulfillment_set",
@@ -26,7 +26,7 @@ import FulfillmentLabel from "./fulfillment-label"
import FulfillmentProvider from "./fulfillment-provider"
import ShippingOption from "./shipping-option"
type FulfillmentOptionalProps = DAL.SoftDeletableEntityDateColumns
type FulfillmentOptionalProps = DAL.SoftDeletableModelDateColumns
const FulfillmentDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "fulfillment",
@@ -20,7 +20,7 @@ import {
} from "@mikro-orm/core"
import ServiceZone from "./service-zone"
type GeoZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
type GeoZoneOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "geo_zone",
@@ -24,7 +24,7 @@ import FulfillmentSet from "./fulfillment-set"
import GeoZone from "./geo-zone"
import ShippingOption from "./shipping-option"
type ServiceZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
type ServiceZoneOptionalProps = DAL.SoftDeletableModelDateColumns
const deletedAtIndexName = "IDX_service_zone_deleted_at"
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
@@ -19,7 +19,7 @@ import {
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
type ShippingOptionRuleOptionalProps = DAL.SoftDeletableEntityDateColumns
type ShippingOptionRuleOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "shipping_option_rule",
@@ -18,7 +18,7 @@ import {
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
type ShippingOptionTypeOptionalProps = DAL.SoftDeletableEntityDateColumns
type ShippingOptionTypeOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "shipping_option_type",
@@ -30,7 +30,7 @@ import ShippingOptionRule from "./shipping-option-rule"
import ShippingOptionType from "./shipping-option-type"
import ShippingProfile from "./shipping-profile"
type ShippingOptionOptionalProps = DAL.SoftDeletableEntityDateColumns
type ShippingOptionOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "shipping_option",
@@ -20,7 +20,7 @@ import {
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
type ShippingProfileOptionalProps = DAL.SoftDeletableEntityDateColumns
type ShippingProfileOptionalProps = DAL.SoftDeletableModelDateColumns
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "shipping_profile",
@@ -34,7 +34,7 @@ const InventoryItemSkuIndex = createPsqlIndexStatementHelper({
unique: true,
})
type InventoryItemOptionalProps = DAL.SoftDeletableEntityDateColumns
type InventoryItemOptionalProps = DAL.SoftDeletableModelDateColumns
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
+1 -1
View File
@@ -12,7 +12,7 @@ import {
Property,
} from "@mikro-orm/core"
type OptionalAddressProps = DAL.EntityDateColumns
type OptionalAddressProps = DAL.ModelDateColumns
const CustomerIdIndex = createPsqlIndexStatementHelper({
tableName: "order_address",
@@ -2,7 +2,7 @@ import { BigNumberRawValue, DAL } from "@medusajs/types"
import { BigNumber, MikroOrmBigNumberProperty } from "@medusajs/utils"
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
type OptionalAdjustmentLineProps = DAL.EntityDateColumns
type OptionalAdjustmentLineProps = DAL.ModelDateColumns
/**
* As per the Mikro ORM docs, superclasses should use the abstract class definition
@@ -15,7 +15,7 @@ import {
} from "@mikro-orm/core"
import ClaimItem from "./claim-item"
type OptionalClaimItemImageProps = DAL.EntityDateColumns
type OptionalClaimItemImageProps = DAL.ModelDateColumns
const ClaimItemImageDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "order_claim_item_image",
@@ -23,7 +23,7 @@ import Claim from "./claim"
import ClaimItemImage from "./claim-item-image"
import LineItem from "./line-item"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const ClaimIdIndex = createPsqlIndexStatementHelper({
tableName: "order_claim_item",
+1 -1
View File
@@ -27,7 +27,7 @@ import OrderShippingMethod from "./order-shipping-method"
import Return from "./return"
import Transaction from "./transaction"
type OptionalOrderClaimProps = DAL.EntityDateColumns
type OptionalOrderClaimProps = DAL.ModelDateColumns
const DisplayIdIndex = createPsqlIndexStatementHelper({
tableName: "order_claim",
@@ -16,7 +16,7 @@ import {
import Exchange from "./exchange"
import LineItem from "./line-item"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const ExchangeIdIndex = createPsqlIndexStatementHelper({
tableName: "order_exchange_item",
@@ -24,7 +24,7 @@ import Order from "./order"
import OrderShippingMethod from "./order-shipping-method"
import Return from "./return"
type OptionalOrderExchangeProps = DAL.EntityDateColumns
type OptionalOrderExchangeProps = DAL.ModelDateColumns
const DisplayIdIndex = createPsqlIndexStatementHelper({
tableName: "order_exchange",
@@ -20,7 +20,7 @@ import {
import LineItemAdjustment from "./line-item-adjustment"
import LineItemTaxLine from "./line-item-tax-line"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const ProductIdIndex = createPsqlIndexStatementHelper({
tableName: "order_line_item",
@@ -21,7 +21,7 @@ import Order from "./order"
import OrderChange from "./order-change"
import Return from "./return"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const OrderChangeIdIndex = createPsqlIndexStatementHelper({
tableName: "order_change_action",
@@ -24,7 +24,7 @@ import Order from "./order"
import OrderChangeAction from "./order-change-action"
import Return from "./return"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const OrderIdIndex = createPsqlIndexStatementHelper({
tableName: "order_change",
@@ -18,7 +18,7 @@ import {
import LineItem from "./line-item"
import Order from "./order"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const OrderIdIndex = createPsqlIndexStatementHelper({
tableName: "order_item",
@@ -19,7 +19,7 @@ import Order from "./order"
import Return from "./return"
import ShippingMethod from "./shipping-method"
type OptionalShippingMethodProps = DAL.EntityDateColumns
type OptionalShippingMethodProps = DAL.ModelDateColumns
const OrderIdIndex = createPsqlIndexStatementHelper({
tableName: "order_shipping",
+1 -1
View File
@@ -27,7 +27,7 @@ import Transaction from "./transaction"
type OptionalOrderProps =
| "shipping_address"
| "billing_address"
| DAL.EntityDateColumns
| DAL.ModelDateColumns
const DisplayIdIndex = createPsqlIndexStatementHelper({
tableName: "order",
@@ -17,7 +17,7 @@ import LineItem from "./line-item"
import Return from "./return"
import ReturnReason from "./return-reason"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const ReturnIdIndex = createPsqlIndexStatementHelper({
tableName: "return_item",
@@ -34,7 +34,7 @@ const ParentIndex = createPsqlIndexStatementHelper({
where: "deleted_at IS NOT NULL",
})
type OptionalOrderProps = "parent_return_reason" | DAL.EntityDateColumns
type OptionalOrderProps = "parent_return_reason" | DAL.ModelDateColumns
@Entity({ tableName: "return_reason" })
export default class ReturnReason {
+1 -1
View File
@@ -27,7 +27,7 @@ import Exchange from "./exchange"
import Order from "./order"
import OrderShippingMethod from "./order-shipping-method"
type OptionalReturnProps = DAL.EntityDateColumns
type OptionalReturnProps = DAL.ModelDateColumns
const DisplayIdIndex = createPsqlIndexStatementHelper({
tableName: "return",
@@ -20,7 +20,7 @@ import Exchange from "./exchange"
import Order from "./order"
import Return from "./return"
type OptionalLineItemProps = DAL.EntityDateColumns
type OptionalLineItemProps = DAL.ModelDateColumns
const ReferenceIdIndex = createPsqlIndexStatementHelper({
tableName: "order_transaction",
@@ -25,7 +25,7 @@ import Payment from "./payment"
import PaymentProvider from "./payment-provider"
import PaymentSession from "./payment-session"
type OptionalPaymentCollectionProps = "status" | DAL.EntityDateColumns
type OptionalPaymentCollectionProps = "status" | DAL.ModelDateColumns
@Entity({ tableName: "payment_collection" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -26,7 +26,7 @@ import PaymentCollection from "./payment-collection"
import PaymentSession from "./payment-session"
import Refund from "./refund"
type OptionalPaymentProps = DAL.EntityDateColumns
type OptionalPaymentProps = DAL.ModelDateColumns
@Entity({ tableName: "payment" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -17,7 +17,7 @@ import {
} from "@mikro-orm/core"
import PriceList from "./price-list"
type OptionalFields = DAL.SoftDeletableEntityDateColumns
type OptionalFields = DAL.SoftDeletableModelDateColumns
const tableName = "price_list_rule"
const PriceListRuleDeletedAtIndex = createPsqlIndexStatementHelper({
@@ -27,7 +27,7 @@ import PriceListRule from "./price-list-rule"
type OptionalFields =
| "starts_at"
| "ends_at"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const tableName = "price_list"
const PriceListDeletedAtIndex = createPsqlIndexStatementHelper({
@@ -17,7 +17,7 @@ import {
} from "@mikro-orm/core"
import Price from "./price"
type OptionalFields = DAL.SoftDeletableEntityDateColumns
type OptionalFields = DAL.SoftDeletableModelDateColumns
const tableName = "price_rule"
const PriceRuleDeletedAtIndex = createPsqlIndexStatementHelper({
+1 -1
View File
@@ -24,7 +24,7 @@ import PriceList from "./price-list"
import PriceRule from "./price-rule"
import PriceSet from "./price-set"
type OptionalFields = DAL.SoftDeletableEntityDateColumns
type OptionalFields = DAL.SoftDeletableModelDateColumns
const tableName = "price"
const PriceDeletedAtIndex = createPsqlIndexStatementHelper({
@@ -29,7 +29,7 @@ type OptionalFields =
| "description"
| "limit"
| "used"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
@Entity({ tableName: "promotion_campaign_budget" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -26,7 +26,7 @@ type OptionalFields =
| "description"
| "starts_at"
| "ends_at"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
const tableName = "promotion_campaign"
const CampaignUniqueCampaignIdentifier = createPsqlIndexStatementHelper({
@@ -20,7 +20,7 @@ import ApplicationMethod from "./application-method"
import Promotion from "./promotion"
import PromotionRuleValue from "./promotion-rule-value"
type OptionalFields = "description" | DAL.SoftDeletableEntityDateColumns
type OptionalFields = "description" | DAL.SoftDeletableModelDateColumns
type OptionalRelations = "values" | "promotions"
@Entity({ tableName: "promotion_rule" })
@@ -26,7 +26,7 @@ import ApplicationMethod from "./application-method"
import Campaign from "./campaign"
import PromotionRule from "./promotion-rule"
type OptionalFields = "is_automatic" | DAL.SoftDeletableEntityDateColumns
type OptionalFields = "is_automatic" | DAL.SoftDeletableModelDateColumns
type OptionalRelations = "application_method" | "campaign"
@Entity({ tableName: "promotion" })
@@ -12,7 +12,7 @@ import {
Property,
} from "@mikro-orm/core"
type SalesChannelOptionalProps = "is_disabled" | DAL.EntityDateColumns
type SalesChannelOptionalProps = "is_disabled" | DAL.ModelDateColumns
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
+1 -1
View File
@@ -21,7 +21,7 @@ import {
} from "@mikro-orm/core"
import StoreCurrency from "./currency"
type StoreOptionalProps = DAL.SoftDeletableEntityDateColumns
type StoreOptionalProps = DAL.SoftDeletableModelDateColumns
const StoreDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "store",
@@ -19,7 +19,7 @@ import TaxRate from "./tax-rate"
const TABLE_NAME = "tax_rate_rule"
type OptionalRuleProps = DAL.SoftDeletableEntityDateColumns
type OptionalRuleProps = DAL.SoftDeletableModelDateColumns
const taxRateIdIndexName = "IDX_tax_rate_rule_tax_rate_id"
const taxRateIdIndexStatement = createPsqlIndexStatementHelper({
+1 -1
View File
@@ -22,7 +22,7 @@ import {
import TaxRateRule from "./tax-rate-rule"
import TaxRegion from "./tax-region"
type OptionalTaxRateProps = DAL.SoftDeletableEntityDateColumns
type OptionalTaxRateProps = DAL.SoftDeletableModelDateColumns
const TABLE_NAME = "tax_rate"
@@ -23,7 +23,7 @@ import {
import TaxProvider from "./tax-provider"
import TaxRate from "./tax-rate"
type OptionalTaxRegionProps = DAL.SoftDeletableEntityDateColumns
type OptionalTaxRegionProps = DAL.SoftDeletableModelDateColumns
const TABLE_NAME = "tax_region"
+1 -1
View File
@@ -45,7 +45,7 @@ const inviteDeletedAtIndexStatement = createPsqlIndexStatementHelper({
type OptionalFields =
| "metadata"
| "accepted"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
@Entity({ tableName: "invite" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class Invite {
+1 -1
View File
@@ -39,7 +39,7 @@ type OptionalFields =
| "last_name"
| "metadata"
| "avatar_url"
| DAL.SoftDeletableEntityDateColumns
| DAL.SoftDeletableModelDateColumns
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)