Files
medusa-store/packages/modules/cart/src/models/shipping-method-adjustment.ts
Harminder Virk 48e00169d2 breaking: move shared HTTP utils to the framework (#9402)
Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-03 09:42:00 +00:00

71 lines
1.8 KiB
TypeScript

import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
} from "@medusajs/framework/utils"
import {
BeforeCreate,
Entity,
Filter,
ManyToOne,
OnInit,
Property,
Rel,
} from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line"
import ShippingMethod from "./shipping-method"
const ShippingMethodIdIndex = createPsqlIndexStatementHelper({
name: "IDX_adjustment_shipping_method_id",
tableName: "cart_shipping_method_adjustment",
columns: "shipping_method_id",
where: "deleted_at IS NULL",
}).MikroORMIndex
const PromotionIdIndex = createPsqlIndexStatementHelper({
name: "IDX_shipping_method_adjustment_promotion_id",
tableName: "cart_shipping_method_adjustment",
columns: "promotion_id",
where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
}).MikroORMIndex
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "cart_shipping_method_adjustment",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
}).MikroORMIndex
@Entity({ tableName: "cart_shipping_method_adjustment" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class ShippingMethodAdjustment extends AdjustmentLine {
@ManyToOne({ entity: () => ShippingMethod, persist: false })
shipping_method: Rel<ShippingMethod>
@ShippingMethodIdIndex()
@ManyToOne({
entity: () => ShippingMethod,
columnType: "text",
fieldName: "shipping_method_id",
mapToPk: true,
})
shipping_method_id: string
@PromotionIdIndex()
@Property({ columnType: "text", nullable: true })
promotion_id: string | null = null
@DeletedAtIndex()
@Property({ columnType: "timestamptz", nullable: true })
deleted_at: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "casmadj")
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "casmadj")
}
}