chore(): Reorganize modules (#7210)
**What** Move all modules to the modules directory
This commit is contained in:
committed by
GitHub
parent
7a351eef09
commit
4eae25e1ef
2
packages/modules/stock-location-next/src/models/index.ts
Normal file
2
packages/modules/stock-location-next/src/models/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./stock-location"
|
||||
export * from "./stock-location-address"
|
||||
@@ -0,0 +1,79 @@
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
OnInit,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import {
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
const StockLocationAddressDeletedAtIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "stock_location_address",
|
||||
columns: "deleted_at",
|
||||
where: "deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
@Entity()
|
||||
export class StockLocationAddress {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id: string
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
created_at: Date
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
updated_at: Date
|
||||
|
||||
@StockLocationAddressDeletedAtIndex.MikroORMIndex()
|
||||
@Property({ columnType: "timestamptz", nullable: true })
|
||||
deleted_at: Date | null = null
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
address_1: string
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
address_2: string | null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
company: string | null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
city: string | null
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
country_code: string
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
phone: string | null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
province: string | null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
postal_code: string | null
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeCreate()
|
||||
private beforeCreate(): void {
|
||||
this.id = generateEntityId(this.id, "laddr")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
private onInit(): void {
|
||||
this.id = generateEntityId(this.id, "laddr")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import {
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
Searchable,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { StockLocationAddress } from "./stock-location-address"
|
||||
|
||||
const StockLocationDeletedAtIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "stock_location",
|
||||
columns: "deleted_at",
|
||||
where: "deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
@Entity()
|
||||
export class StockLocation {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id: string
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
created_at: Date
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
updated_at: Date
|
||||
|
||||
@StockLocationDeletedAtIndex.MikroORMIndex()
|
||||
@Property({ columnType: "timestamptz", nullable: true })
|
||||
deleted_at: Date | null = null
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text" })
|
||||
name: string
|
||||
|
||||
@ManyToOne(() => StockLocationAddress, {
|
||||
fieldName: "address_id",
|
||||
type: "text",
|
||||
mapToPk: true,
|
||||
nullable: true,
|
||||
onDelete: "cascade",
|
||||
})
|
||||
address_id: string | null
|
||||
|
||||
@ManyToOne(() => StockLocationAddress, {
|
||||
nullable: true,
|
||||
})
|
||||
address: StockLocationAddress | null
|
||||
|
||||
@Property({ columnType: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeCreate()
|
||||
private beforeCreate(): void {
|
||||
this.id = generateEntityId(this.id, "sloc")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
private onInit(): void {
|
||||
this.id = generateEntityId(this.id, "sloc")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user