fix: update models
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
import { generateEntityId } from "@medusajs/utils"
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
import Payment from "./payment"
|
import Payment from "./payment"
|
||||||
|
|
||||||
type OptionalCaptureProps = "created_by" | "created_at"
|
type OptionalCaptureProps = "created_at"
|
||||||
|
|
||||||
@Entity({ tableName: "capture" })
|
@Entity({ tableName: "capture" })
|
||||||
export default class Capture {
|
export default class Capture {
|
||||||
@@ -41,7 +41,7 @@ export default class Capture {
|
|||||||
created_at: Date
|
created_at: Date
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
created_by: string | null
|
created_by?: string | null
|
||||||
|
|
||||||
@BeforeCreate()
|
@BeforeCreate()
|
||||||
onCreate() {
|
onCreate() {
|
||||||
|
|||||||
@@ -23,13 +23,7 @@ import PaymentProvider from "./payment-provider"
|
|||||||
import PaymentSession from "./payment-session"
|
import PaymentSession from "./payment-session"
|
||||||
import Payment from "./payment"
|
import Payment from "./payment"
|
||||||
|
|
||||||
type OptionalPaymentCollectionProps =
|
type OptionalPaymentCollectionProps = "status" | DAL.EntityDateColumns
|
||||||
| "authorized_amount"
|
|
||||||
| "refunded_amount"
|
|
||||||
| "region_id"
|
|
||||||
| "completed_at"
|
|
||||||
| "status"
|
|
||||||
| DAL.SoftDeletableEntityDateColumns
|
|
||||||
|
|
||||||
@Entity({ tableName: "payment_collection" })
|
@Entity({ tableName: "payment_collection" })
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
@@ -53,14 +47,14 @@ export default class PaymentCollection {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
serializer: Number,
|
serializer: Number,
|
||||||
})
|
})
|
||||||
authorized_amount: number | null
|
authorized_amount?: number | null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "numeric",
|
columnType: "numeric",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
serializer: Number,
|
serializer: Number,
|
||||||
})
|
})
|
||||||
refunded_amount: number | null
|
refunded_amount?: number | null
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
region_id?: string | null
|
region_id?: string | null
|
||||||
@@ -85,19 +79,19 @@ export default class PaymentCollection {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
index: "IDX_payment_collection_deleted_at",
|
index: "IDX_payment_collection_deleted_at",
|
||||||
})
|
})
|
||||||
deleted_at: Date | null
|
deleted_at?: Date | null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "timestamptz",
|
columnType: "timestamptz",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
completed_at: Date | null
|
completed_at?: Date | null
|
||||||
|
|
||||||
@Enum({
|
@Enum({
|
||||||
items: () => PaymentCollectionStatus,
|
items: () => PaymentCollectionStatus,
|
||||||
default: PaymentCollectionStatus.NOT_PAID,
|
default: PaymentCollectionStatus.NOT_PAID,
|
||||||
})
|
})
|
||||||
status?: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
|
status: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
|
||||||
|
|
||||||
@ManyToMany(() => PaymentProvider)
|
@ManyToMany(() => PaymentProvider)
|
||||||
payment_providers = new Collection<PaymentProvider>(this)
|
payment_providers = new Collection<PaymentProvider>(this)
|
||||||
|
|||||||
@@ -2,23 +2,14 @@ import {
|
|||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
OnInit,
|
OnInit,
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
import { generateEntityId } from "@medusajs/utils"
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
|
|
||||||
type OptionalPaymentMethodTokenProps =
|
|
||||||
| "data"
|
|
||||||
| "type_detail"
|
|
||||||
| "description_detail"
|
|
||||||
| "metadata"
|
|
||||||
|
|
||||||
@Entity({ tableName: "payment_method_token" })
|
@Entity({ tableName: "payment_method_token" })
|
||||||
export default class PaymentMethodToken {
|
export default class PaymentMethodToken {
|
||||||
[OptionalProps]?: OptionalPaymentMethodTokenProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
@@ -32,10 +23,10 @@ export default class PaymentMethodToken {
|
|||||||
name: string
|
name: string
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
type_detail: string | null
|
type_detail?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
description_detail: string | null
|
description_detail?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
metadata?: Record<string, unknown> | null
|
metadata?: Record<string, unknown> | null
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Entity, PrimaryKey, Property } from "@mikro-orm/core"
|
import { Entity, OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
@Entity({ tableName: "payment_provider" })
|
@Entity({ tableName: "payment_provider" })
|
||||||
export default class PaymentProvider {
|
export default class PaymentProvider {
|
||||||
|
[OptionalProps]?: "is_enabled"
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
|
|||||||
@@ -5,26 +5,16 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToOne,
|
OneToOne,
|
||||||
OnInit,
|
OnInit,
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import { generateEntityId, PaymentSessionStatus } from "@medusajs/utils"
|
import { generateEntityId, PaymentSessionStatus } from "@medusajs/utils"
|
||||||
|
|
||||||
import PaymentCollection from "./payment-collection"
|
import PaymentCollection from "./payment-collection"
|
||||||
import Payment from "./payment"
|
import Payment from "./payment"
|
||||||
|
|
||||||
type OptionalPaymentSessionProps =
|
|
||||||
| "data"
|
|
||||||
| "is_selected"
|
|
||||||
| "authorized_at"
|
|
||||||
| DAL.EntityDateColumns
|
|
||||||
|
|
||||||
@Entity({ tableName: "payment_session" })
|
@Entity({ tableName: "payment_session" })
|
||||||
export default class PaymentSession {
|
export default class PaymentSession {
|
||||||
[OptionalProps]?: OptionalPaymentSessionProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
@@ -49,13 +39,13 @@ export default class PaymentSession {
|
|||||||
status: PaymentSessionStatus
|
status: PaymentSessionStatus
|
||||||
|
|
||||||
@Property({ columnType: "boolean", nullable: true })
|
@Property({ columnType: "boolean", nullable: true })
|
||||||
is_selected: boolean | null
|
is_selected?: boolean | null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "timestamptz",
|
columnType: "timestamptz",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
authorized_at: Date | null
|
authorized_at?: Date | null
|
||||||
|
|
||||||
@ManyToOne({
|
@ManyToOne({
|
||||||
index: "IDX_payment_session_payment_collection_id",
|
index: "IDX_payment_session_payment_collection_id",
|
||||||
|
|||||||
@@ -20,15 +20,7 @@ import Capture from "./capture"
|
|||||||
import PaymentSession from "./payment-session"
|
import PaymentSession from "./payment-session"
|
||||||
import PaymentCollection from "./payment-collection"
|
import PaymentCollection from "./payment-collection"
|
||||||
|
|
||||||
type OptionalPaymentProps =
|
type OptionalPaymentProps = DAL.EntityDateColumns
|
||||||
| "authorized_amount"
|
|
||||||
| "cart_id"
|
|
||||||
| "order_id"
|
|
||||||
| "customer_id"
|
|
||||||
| "data"
|
|
||||||
| "captured_at"
|
|
||||||
| "canceled_at"
|
|
||||||
| DAL.SoftDeletableEntityDateColumns
|
|
||||||
|
|
||||||
@Entity({ tableName: "payment" })
|
@Entity({ tableName: "payment" })
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
@@ -49,7 +41,7 @@ export default class Payment {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
serializer: Number,
|
serializer: Number,
|
||||||
})
|
})
|
||||||
authorized_amount: number | null
|
authorized_amount?: number | null
|
||||||
|
|
||||||
@Property({ columnType: "text" })
|
@Property({ columnType: "text" })
|
||||||
currency_code: string
|
currency_code: string
|
||||||
@@ -58,16 +50,16 @@ export default class Payment {
|
|||||||
provider_id: string
|
provider_id: string
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
cart_id: string | null
|
cart_id?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
order_id: string | null
|
order_id?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
order_edit_id: string | null
|
order_edit_id?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
customer_id: string | null
|
customer_id?: string | null
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
data?: Record<string, unknown> | null
|
data?: Record<string, unknown> | null
|
||||||
@@ -92,19 +84,19 @@ export default class Payment {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
index: "IDX_payment_deleted_at",
|
index: "IDX_payment_deleted_at",
|
||||||
})
|
})
|
||||||
deleted_at: Date | null
|
deleted_at?: Date | null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "timestamptz",
|
columnType: "timestamptz",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
captured_at: Date | null
|
captured_at?: Date | null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "timestamptz",
|
columnType: "timestamptz",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
canceled_at: Date | null
|
canceled_at?: Date | null
|
||||||
|
|
||||||
@OneToMany(() => Refund, (refund) => refund.payment, {
|
@OneToMany(() => Refund, (refund) => refund.payment, {
|
||||||
cascade: [Cascade.REMOVE],
|
cascade: [Cascade.REMOVE],
|
||||||
@@ -120,7 +112,7 @@ export default class Payment {
|
|||||||
index: "IDX_payment_payment_collection_id",
|
index: "IDX_payment_payment_collection_id",
|
||||||
fieldName: "payment_collection_id",
|
fieldName: "payment_collection_id",
|
||||||
})
|
})
|
||||||
payment_collection!: PaymentCollection
|
payment_collection: PaymentCollection
|
||||||
|
|
||||||
@OneToOne({ owner: true, fieldName: "session_id" })
|
@OneToOne({ owner: true, fieldName: "session_id" })
|
||||||
session: PaymentSession
|
session: PaymentSession
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
Entity,
|
Entity,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OnInit,
|
OnInit,
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
@@ -11,12 +10,8 @@ import {
|
|||||||
import { generateEntityId } from "@medusajs/utils"
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
import Payment from "./payment"
|
import Payment from "./payment"
|
||||||
|
|
||||||
type OptionalRefundProps = "created_by"
|
|
||||||
|
|
||||||
@Entity({ tableName: "refund" })
|
@Entity({ tableName: "refund" })
|
||||||
export default class Refund {
|
export default class Refund {
|
||||||
[OptionalProps]?: OptionalRefundProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
@@ -41,7 +36,7 @@ export default class Refund {
|
|||||||
created_at: Date
|
created_at: Date
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
@Property({ columnType: "text", nullable: true })
|
||||||
created_by: string | null
|
created_by?: string | null
|
||||||
|
|
||||||
@BeforeCreate()
|
@BeforeCreate()
|
||||||
onCreate() {
|
onCreate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user