Refactor(medusa): Create a BaseEntity and SoftDeletableEntity base class for common columns (#1315)
* refactor(medusa): Move some column to a base entity to make it easier to add new models without forgetting some columns * styles(medusa): Cleanup models * fix(medusa): typings due to model typings update * feat(medusa): Cleanup models * fix(medusa): A model must not return the generateId as part of the entity * fix(medusa): Plugin integration snapshot * fix(medusa): Typings from discount-rule-migration scripts * refactor(medusa): Introduct BaseEntity/SoftDeletableEntity that the entity extends * styles(medusa): Fix models linting * test(medusa): Fix integration plugin tests * feat(medusa): Create generateEntityId standalong function utility and update config to properly supprt ts spec files * feat(medusa): Update entities to use the new utils to generate and apply the id * test(medusa): Fix test suits * feat(medusa): Improve generateEntityId utility
This commit is contained in:
1 parent
2f08167480
commit
3503651ff2
90 files changed
+793
-1601
No files matched your search
@@ -5,6 +5,7 @@ module.exports = {
|
||||
name: "api",
|
||||
testEnvironment: `node`,
|
||||
rootDir: "./",
|
||||
testTimeout: 10000,
|
||||
testPathIgnorePatterns: [
|
||||
`/examples/`,
|
||||
`/www/`,
|
||||
|
||||
@@ -9,6 +9,12 @@ module.exports = {
|
||||
// useCoverage ? `jest-junit` : []
|
||||
// )
|
||||
// : [`default`].concat(useCoverage ? `jest-junit` : []),
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsConfig: 'tsconfig.spec.json',
|
||||
isolatedModules: false
|
||||
}
|
||||
},
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": `../../jest-transformer.js`,
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "^27.0.3",
|
||||
"@types/jest": "^27.5.0",
|
||||
"@types/jsonwebtoken": "^8.5.5",
|
||||
"babel-preset-medusa-package": "^1.1.19",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -32,6 +32,7 @@
|
||||
"prettier": "^1.19.1",
|
||||
"sqlite3": "^5.0.2",
|
||||
"supertest": "^4.0.2",
|
||||
"ts-jest": "^28.0.1",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -56,5 +56,5 @@ export class AdminUpdateUserRequest {
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
CreateDateColumn,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../../utils/db-aware-column"
|
||||
|
||||
/**
|
||||
* Base abstract entity for all entities
|
||||
*/
|
||||
export abstract class BaseEntity {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { BaseEntity } from "./base-entity"
|
||||
import { DeleteDateColumn } from "typeorm"
|
||||
import { resolveDbType } from "../../utils/db-aware-column"
|
||||
|
||||
export abstract class SoftDeletableEntity extends BaseEntity {
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -27,28 +27,22 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Customer } from "./customer"
|
||||
import { Country } from "./country"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Address {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Address extends SoftDeletableEntity {
|
||||
@Index()
|
||||
@Column({ type: "varchar", nullable: true })
|
||||
customer_id: string | null
|
||||
@@ -91,22 +85,11 @@ export class Address {
|
||||
@Column({ type: "varchar", nullable: true })
|
||||
phone: string | null
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date | null
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `addr_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "addr")
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,11 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { BeforeInsert, Column, Entity, PrimaryColumn } from "typeorm"
|
||||
import { BatchJobStatus } from "../types/batch-job"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class BatchJob {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class BatchJob extends SoftDeletableEntity {
|
||||
@DbAwareColumn({ type: "text" })
|
||||
type: string
|
||||
|
||||
@@ -31,20 +21,9 @@ export class BatchJob {
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
result: Record<string, unknown>
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `batch_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "batch")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,6 @@ import {
|
||||
AfterLoad,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
@@ -96,10 +94,7 @@ import {
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { Address } from "./address"
|
||||
import { Customer } from "./customer"
|
||||
@@ -110,6 +105,8 @@ import { Payment } from "./payment"
|
||||
import { PaymentSession } from "./payment-session"
|
||||
import { Region } from "./region"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum CartType {
|
||||
DEFAULT = "default",
|
||||
@@ -120,10 +117,7 @@ export enum CartType {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Cart {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Cart extends SoftDeletableEntity {
|
||||
readonly object = "cart"
|
||||
|
||||
@Column({ nullable: true })
|
||||
@@ -227,23 +221,14 @@ export class Cart {
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
payment_authorized_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
context: any
|
||||
context: Record<string, unknown>
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
shipping_total?: number
|
||||
discount_total?: number
|
||||
@@ -254,19 +239,15 @@ export class Cart {
|
||||
refundable_amount?: number
|
||||
gift_card_total?: number
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): undefined | void {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `cart_${id}`
|
||||
}
|
||||
|
||||
@AfterLoad()
|
||||
private afterLoad(): void {
|
||||
if (this.payment_sessions) {
|
||||
this.payment_session = this.payment_sessions.find((p) => p.is_selected)!
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "cart")
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,35 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
|
||||
import { ClaimItem } from "./claim-item"
|
||||
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ClaimImage {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ClaimImage extends SoftDeletableEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
claim_item_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => ClaimItem,
|
||||
ci => ci.images
|
||||
)
|
||||
@ManyToOne(() => ClaimItem, (ci) => ci.images)
|
||||
@JoinColumn({ name: "claim_item_id" })
|
||||
claim_item: ClaimItem
|
||||
|
||||
@Column()
|
||||
url: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `cimg_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "cimg")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { LineItem } from "./line-item"
|
||||
import { ClaimImage } from "./claim-image"
|
||||
import { ClaimTag } from "./claim-tag"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum ClaimReason {
|
||||
MISSING_ITEM = "missing_item",
|
||||
@@ -30,25 +27,17 @@ export enum ClaimReason {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class ClaimItem {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
@OneToMany(
|
||||
() => ClaimImage,
|
||||
ci => ci.claim_item,
|
||||
{ cascade: ["insert", "remove"] }
|
||||
)
|
||||
export class ClaimItem extends SoftDeletableEntity {
|
||||
@OneToMany(() => ClaimImage, (ci) => ci.claim_item, {
|
||||
cascade: ["insert", "remove"],
|
||||
})
|
||||
images: ClaimImage[]
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
claim_order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => ClaimOrder,
|
||||
co => co.claim_items
|
||||
)
|
||||
@ManyToOne(() => ClaimOrder, (co) => co.claim_items)
|
||||
@JoinColumn({ name: "claim_order_id" })
|
||||
claim_order: ClaimOrder
|
||||
|
||||
@@ -91,23 +80,12 @@ export class ClaimItem {
|
||||
})
|
||||
tags: ClaimTag[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `citm_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "citm")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
OneToOne,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
import { LineItem } from "./line-item"
|
||||
@@ -22,6 +20,8 @@ import { Order } from "./order"
|
||||
import { Return } from "./return"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { Address } from "./address"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum ClaimType {
|
||||
REFUND = "refund",
|
||||
@@ -47,10 +47,7 @@ export enum ClaimFulfillmentStatus {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class ClaimOrder {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ClaimOrder extends SoftDeletableEntity {
|
||||
@DbAwareColumn({
|
||||
type: "enum",
|
||||
enum: ClaimPaymentStatus,
|
||||
@@ -65,17 +62,10 @@ export class ClaimOrder {
|
||||
})
|
||||
fulfillment_status: ClaimFulfillmentStatus
|
||||
|
||||
@OneToMany(
|
||||
() => ClaimItem,
|
||||
ci => ci.claim_order
|
||||
)
|
||||
@OneToMany(() => ClaimItem, (ci) => ci.claim_order)
|
||||
claim_items: ClaimItem[]
|
||||
|
||||
@OneToMany(
|
||||
() => LineItem,
|
||||
li => li.claim_order,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => LineItem, (li) => li.claim_order, { cascade: ["insert"] })
|
||||
additional_items: LineItem[]
|
||||
|
||||
@DbAwareColumn({ type: "enum", enum: ClaimType })
|
||||
@@ -85,17 +75,11 @@ export class ClaimOrder {
|
||||
@Column()
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
o => o.claims
|
||||
)
|
||||
@ManyToOne(() => Order, (o) => o.claims)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@OneToOne(
|
||||
() => Return,
|
||||
ret => ret.claim_order
|
||||
)
|
||||
@OneToOne(() => Return, (ret) => ret.claim_order)
|
||||
return_order: Return
|
||||
|
||||
@Index()
|
||||
@@ -106,18 +90,14 @@ export class ClaimOrder {
|
||||
@JoinColumn({ name: "shipping_address_id" })
|
||||
shipping_address: Address
|
||||
|
||||
@OneToMany(
|
||||
() => ShippingMethod,
|
||||
method => method.claim_order,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => ShippingMethod, (method) => method.claim_order, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
shipping_methods: ShippingMethod[]
|
||||
|
||||
@OneToMany(
|
||||
() => Fulfillment,
|
||||
fulfillment => fulfillment.claim_order,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => Fulfillment, (fulfillment) => fulfillment.claim_order, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
fulfillments: Fulfillment[]
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
@@ -136,19 +116,17 @@ export class ClaimOrder {
|
||||
deleted_at: Date
|
||||
|
||||
@Column({ type: "boolean", nullable: true })
|
||||
no_notification: Boolean
|
||||
no_notification: boolean
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `claim_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "claim")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,20 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
Index,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ClaimTag {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ClaimTag extends SoftDeletableEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
value: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ctag_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ctag")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryColumn } from "typeorm"
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class Currency {
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { Cart } from "./cart"
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
@Unique(["shipping_option_id", "cart_id"])
|
||||
export class CustomShippingOption {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class CustomShippingOption extends SoftDeletableEntity {
|
||||
@Column({ type: "int" })
|
||||
price: number
|
||||
|
||||
@@ -41,23 +35,12 @@ export class CustomShippingOption {
|
||||
@JoinColumn({ name: "cart_id" })
|
||||
cart: Cart
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `cso_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "cso")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
ManyToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, Index, ManyToMany } from "typeorm"
|
||||
import { Customer } from "./customer"
|
||||
import { PriceList } from "./price-list"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class CustomerGroup {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class CustomerGroup extends SoftDeletableEntity {
|
||||
@Index({ unique: true, where: "deleted_at IS NULL" })
|
||||
@Column()
|
||||
name: string
|
||||
@@ -33,24 +21,11 @@ export class CustomerGroup {
|
||||
})
|
||||
price_lists: PriceList[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `cgrp_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "cgrp")
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,24 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Index,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToMany,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Address } from "./address"
|
||||
import { CustomerGroup } from "./customer-group"
|
||||
import { Order } from "./order"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Customer {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Customer extends SoftDeletableEntity {
|
||||
@Index({ unique: true })
|
||||
@Column()
|
||||
email: string
|
||||
@@ -74,25 +68,12 @@ export class Customer {
|
||||
})
|
||||
groups: CustomerGroup[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `cus_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "cus")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class DiscountConditionCustomerGroup {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export class DiscountConditionProductCollection {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export class DiscountConditionProductTag {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export class DiscountConditionProductType {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export class DiscountConditionProduct {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { CustomerGroup } from "./customer-group"
|
||||
import { DiscountRule } from "./discount-rule"
|
||||
import { Product } from "./product"
|
||||
import { ProductCollection } from "./product-collection"
|
||||
import { ProductTag } from "./product-tag"
|
||||
import { ProductType } from "./product-type"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum DiscountConditionType {
|
||||
PRODUCTS = "products",
|
||||
@@ -37,10 +34,7 @@ export enum DiscountConditionOperator {
|
||||
|
||||
@Entity()
|
||||
@Unique("dctypeuniq", ["type", "operator", "discount_rule_id"])
|
||||
export class DiscountCondition {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class DiscountCondition extends SoftDeletableEntity {
|
||||
@DbAwareColumn({
|
||||
type: "enum",
|
||||
enum: DiscountConditionType,
|
||||
@@ -131,26 +125,12 @@ export class DiscountCondition {
|
||||
})
|
||||
customer_groups: CustomerGroup[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
|
||||
const id = ulid()
|
||||
this.id = `discon_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "discon")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
OneToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, OneToMany } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DiscountCondition } from "./discount-condition"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum DiscountRuleType {
|
||||
FIXED = "fixed",
|
||||
@@ -24,10 +16,7 @@ export enum AllocationType {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class DiscountRule {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class DiscountRule extends SoftDeletableEntity {
|
||||
@Column({ nullable: true })
|
||||
description: string
|
||||
|
||||
@@ -50,22 +39,12 @@ export class DiscountRule {
|
||||
@OneToMany(() => DiscountCondition, (conditions) => conditions.discount_rule)
|
||||
conditions: DiscountCondition[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
const id = ulid()
|
||||
this.id = `dru_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "dru")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { DiscountRule } from "./discount-rule"
|
||||
import { Region } from "./region"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Discount {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Discount extends SoftDeletableEntity {
|
||||
@Index({ unique: true, where: "deleted_at IS NULL" })
|
||||
@Column()
|
||||
code: string
|
||||
@@ -79,25 +73,14 @@ export class Discount {
|
||||
@Column({ default: 0 })
|
||||
usage_count: number
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `disc_${id}`
|
||||
private upperCaseCode(): void {
|
||||
if (this.id) return
|
||||
|
||||
this.id = generateEntityId(this.id, "disc")
|
||||
this.code = this.code.toUpperCase()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Generated,
|
||||
Index,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import {
|
||||
DbAwareColumn,
|
||||
resolveDbGenerationStrategy,
|
||||
@@ -19,6 +16,7 @@ import {
|
||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||
import { Cart } from "./cart"
|
||||
import { Order } from "./order"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
enum DraftOrderStatus {
|
||||
OPEN = "open",
|
||||
@@ -26,10 +24,7 @@ enum DraftOrderStatus {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class DraftOrder {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class DraftOrder extends BaseEntity {
|
||||
@DbAwareColumn({ type: "enum", enum: DraftOrderStatus, default: "open" })
|
||||
status: DraftOrderStatus
|
||||
|
||||
@@ -57,12 +52,6 @@ export class DraftOrder {
|
||||
@Column({ nullable: true, type: resolveDbType("timestamptz") })
|
||||
canceled_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
completed_at: Date
|
||||
|
||||
@@ -70,17 +59,14 @@ export class DraftOrder {
|
||||
no_notification_order: boolean
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private async beforeInsert(): Promise<void> {
|
||||
if (!this.id) {
|
||||
const id = ulid()
|
||||
this.id = `dorder_${id}`
|
||||
}
|
||||
this.id = generateEntityId(this.id, "dorder")
|
||||
|
||||
if (process.env.NODE_ENV === "development" && !this.display_id) {
|
||||
const disId = await manualAutoIncrement("draft_order")
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
import {
|
||||
Entity,
|
||||
Generated,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"
|
||||
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
import { LineItem } from "./line-item"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryColumn, OneToOne, JoinColumn } from "typeorm"
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class FulfillmentProvider {
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
import {
|
||||
Entity,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Order } from "./order"
|
||||
import { FulfillmentProvider } from "./fulfillment-provider"
|
||||
@@ -24,20 +15,16 @@ import { FulfillmentItem } from "./fulfillment-item"
|
||||
import { Swap } from "./swap"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { TrackingLink } from "./tracking-link"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Fulfillment {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Fulfillment extends BaseEntity {
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
claim_order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => ClaimOrder,
|
||||
co => co.fulfillments
|
||||
)
|
||||
@ManyToOne(() => ClaimOrder, (co) => co.fulfillments)
|
||||
@JoinColumn({ name: "claim_order_id" })
|
||||
claim_order: ClaimOrder
|
||||
|
||||
@@ -45,10 +32,7 @@ export class Fulfillment {
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Swap,
|
||||
swap => swap.fulfillments
|
||||
)
|
||||
@ManyToOne(() => Swap, (swap) => swap.fulfillments)
|
||||
@JoinColumn({ name: "swap_id" })
|
||||
swap: Swap
|
||||
|
||||
@@ -56,15 +40,12 @@ export class Fulfillment {
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
o => o.fulfillments
|
||||
)
|
||||
@ManyToOne(() => Order, (o) => o.fulfillments)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@Column({ type: "boolean", nullable: true })
|
||||
no_notification: Boolean
|
||||
no_notification: boolean
|
||||
|
||||
@Index()
|
||||
@Column()
|
||||
@@ -74,25 +55,22 @@ export class Fulfillment {
|
||||
@JoinColumn({ name: "provider_id" })
|
||||
provider: FulfillmentProvider
|
||||
|
||||
@OneToMany(
|
||||
() => FulfillmentItem,
|
||||
i => i.fulfillment,
|
||||
{ eager: true, cascade: true }
|
||||
)
|
||||
@OneToMany(() => FulfillmentItem, (i) => i.fulfillment, {
|
||||
eager: true,
|
||||
cascade: true,
|
||||
})
|
||||
items: FulfillmentItem[]
|
||||
|
||||
@OneToMany(
|
||||
() => TrackingLink,
|
||||
tl => tl.fulfillment,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => TrackingLink, (tl) => tl.fulfillment, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
tracking_links: TrackingLink[]
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", default: [] })
|
||||
tracking_numbers: string[]
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
shipped_at: Date
|
||||
@@ -100,23 +78,15 @@ export class Fulfillment {
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
canceled_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ful_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ful")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Index,
|
||||
CreateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
Unique,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { GiftCard } from "./gift-card"
|
||||
import { Order } from "./order"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Unique("gcuniq", ["gift_card_id", "order_id"])
|
||||
@Entity()
|
||||
@@ -43,10 +43,8 @@ export class GiftCardTransaction {
|
||||
created_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `gct_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "gct")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Region } from "./region"
|
||||
import { Order } from "./order"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class GiftCard {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class GiftCard extends SoftDeletableEntity {
|
||||
@Index({ unique: true })
|
||||
@Column()
|
||||
code: string
|
||||
@@ -56,23 +50,12 @@ export class GiftCard {
|
||||
})
|
||||
ends_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `gift_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "gift")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
CreateDateColumn,
|
||||
Index,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class IdempotencyKey {
|
||||
@@ -28,7 +28,7 @@ export class IdempotencyKey {
|
||||
request_method: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
request_params: any
|
||||
request_params: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
request_path: string
|
||||
@@ -37,14 +37,13 @@ export class IdempotencyKey {
|
||||
response_code: number
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
response_body: any
|
||||
response_body: Record<string, unknown>
|
||||
|
||||
@Column({ default: "started" })
|
||||
recovery_point: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
const id = ulid()
|
||||
this.id = `ikey_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ikey")
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,19 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Image {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Image extends SoftDeletableEntity {
|
||||
@Column()
|
||||
url: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `img_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "img")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, CreateDateColumn, Entity, Index } from "typeorm"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { UserRoles } from "./user"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Invite {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Invite extends SoftDeletableEntity {
|
||||
@Index({ unique: true, where: "deleted_at IS NULL" })
|
||||
@Column()
|
||||
user_email: string
|
||||
@@ -40,24 +27,11 @@ export class Invite {
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
expires_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `invite_${id}`
|
||||
this.id = generateEntityId(this.id, "invite")
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@ import {
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { Discount } from "./discount"
|
||||
import { LineItem } from "./line-item"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
@Index(["discount_id", "item_id"], {
|
||||
@@ -26,11 +25,7 @@ export class LineItemAdjustment {
|
||||
@Column()
|
||||
item_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => LineItem,
|
||||
(li) => li.adjustments,
|
||||
{ onDelete: "CASCADE" }
|
||||
)
|
||||
@ManyToOne(() => LineItem, (li) => li.adjustments, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "item_id" })
|
||||
item: LineItem
|
||||
|
||||
@@ -49,12 +44,10 @@ export class LineItemAdjustment {
|
||||
amount: number
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `lia_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "lia")
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
ManyToOne,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
|
||||
import { TaxLine } from "./tax-line"
|
||||
import { LineItem } from "./line-item"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
@Unique(["item_id", "code"])
|
||||
@@ -24,9 +24,7 @@ export class LineItemTaxLine extends TaxLine {
|
||||
item: LineItem
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `litl_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "litl")
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
import {
|
||||
Entity,
|
||||
OneToMany,
|
||||
BeforeInsert,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Check,
|
||||
Index,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { LineItemTaxLine } from "./line-item-tax-line"
|
||||
import { Swap } from "./swap"
|
||||
@@ -21,16 +17,15 @@ import { Order } from "./order"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { LineItemAdjustment } from "./line-item-adjustment"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Check(`"fulfilled_quantity" <= "quantity"`)
|
||||
@Check(`"shipped_quantity" <= "fulfilled_quantity"`)
|
||||
@Check(`"returned_quantity" <= "quantity"`)
|
||||
@Check(`"quantity" > 0`)
|
||||
@Entity()
|
||||
export class LineItem {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class LineItem extends BaseEntity {
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
cart_id: string
|
||||
@@ -66,7 +61,9 @@ export class LineItem {
|
||||
@OneToMany(() => LineItemTaxLine, (tl) => tl.item, { cascade: ["insert"] })
|
||||
tax_lines: LineItemTaxLine[]
|
||||
|
||||
@OneToMany(() => LineItemAdjustment, (lia) => lia.item, { cascade: ["insert"] })
|
||||
@OneToMany(() => LineItemAdjustment, (lia) => lia.item, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
adjustments: LineItemAdjustment[]
|
||||
|
||||
@Column()
|
||||
@@ -116,22 +113,14 @@ export class LineItem {
|
||||
@Column({ nullable: true, type: "int" })
|
||||
shipped_quantity: number
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
refundable: number | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `item_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "item")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,20 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType } from "../utils/db-aware-column"
|
||||
import { Currency } from "./currency"
|
||||
import { PriceList } from "./price-list"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { Region } from "./region"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class MoneyAmount {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class MoneyAmount extends SoftDeletableEntity {
|
||||
@Column()
|
||||
currency_code: string
|
||||
|
||||
@@ -52,13 +45,9 @@ export class MoneyAmount {
|
||||
@Column({ nullable: true })
|
||||
variant_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => ProductVariant,
|
||||
(variant) => variant.prices,
|
||||
{
|
||||
onDelete: "CASCADE",
|
||||
}
|
||||
)
|
||||
@ManyToOne(() => ProductVariant, (variant) => variant.prices, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "variant_id" })
|
||||
variant: ProductVariant
|
||||
|
||||
@@ -70,22 +59,9 @@ export class MoneyAmount {
|
||||
@JoinColumn({ name: "region_id" })
|
||||
region: Region
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): undefined | void {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `ma_${id}`
|
||||
this.id = generateEntityId(this.id, "ma")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { User } from "./user"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Note {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Note extends SoftDeletableEntity {
|
||||
@Column()
|
||||
value: string
|
||||
|
||||
@@ -37,23 +31,12 @@ export class Note {
|
||||
@JoinColumn({ name: "author_id" })
|
||||
author: User
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `note_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "note")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryColumn } from "typeorm"
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class NotificationProvider {
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
PrimaryColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Customer } from "./customer"
|
||||
import { NotificationProvider } from "./notification-provider"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Notification {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Notification extends BaseEntity {
|
||||
@Column({ nullable: true })
|
||||
event_name: string
|
||||
|
||||
@@ -44,7 +39,7 @@ export class Notification {
|
||||
to: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
parent_id: string
|
||||
@@ -53,10 +48,7 @@ export class Notification {
|
||||
@JoinColumn({ name: "parent_id" })
|
||||
parent_notification: Notification
|
||||
|
||||
@OneToMany(
|
||||
() => Notification,
|
||||
noti => noti.parent_notification
|
||||
)
|
||||
@OneToMany(() => Notification, (noti) => noti.parent_notification)
|
||||
resends: Notification[]
|
||||
|
||||
@Column({ nullable: true })
|
||||
@@ -66,17 +58,9 @@ export class Notification {
|
||||
@JoinColumn({ name: "provider_id" })
|
||||
provider: NotificationProvider
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `noti_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "noti")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
RelationId,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { BeforeInsert, Column, Entity, Index, PrimaryColumn } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Oauth {
|
||||
@@ -37,12 +21,10 @@ export class Oauth {
|
||||
uninstall_url: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `oauth_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "oauth")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Generated,
|
||||
Index,
|
||||
@@ -11,10 +10,8 @@ import {
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import {
|
||||
DbAwareColumn,
|
||||
resolveDbGenerationStrategy,
|
||||
@@ -38,6 +35,7 @@ import { Region } from "./region"
|
||||
import { Return } from "./return"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { Swap } from "./swap"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum OrderStatus {
|
||||
PENDING = "pending",
|
||||
@@ -70,10 +68,7 @@ export enum PaymentStatus {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Order {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Order extends BaseEntity {
|
||||
readonly object = "order"
|
||||
|
||||
@DbAwareColumn({ type: "enum", enum: OrderStatus, default: "pending" })
|
||||
@@ -218,14 +213,8 @@ export class Order {
|
||||
@Column({ nullable: true, type: resolveDbType("timestamptz") })
|
||||
canceled_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ type: "boolean", nullable: true })
|
||||
no_notification: boolean
|
||||
@@ -249,10 +238,7 @@ export class Order {
|
||||
|
||||
@BeforeInsert()
|
||||
private async beforeInsert(): Promise<void> {
|
||||
if (!this.id) {
|
||||
const id = ulid()
|
||||
this.id = `order_${id}`
|
||||
}
|
||||
this.id = generateEntityId(this.id, "order")
|
||||
|
||||
if (process.env.NODE_ENV === "development" && !this.display_id) {
|
||||
const disId = await manualAutoIncrement("order")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryColumn, OneToOne, JoinColumn } from "typeorm"
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class PaymentProvider {
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import {
|
||||
Entity,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { Cart } from "./cart"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum PaymentSessionStatus {
|
||||
AUTHORIZED = "authorized",
|
||||
@@ -24,10 +22,7 @@ export enum PaymentSessionStatus {
|
||||
|
||||
@Unique("OneSelected", ["cart_id", "is_selected"])
|
||||
@Entity()
|
||||
export class PaymentSession {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class PaymentSession extends BaseEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
cart_id: string
|
||||
@@ -47,22 +42,14 @@ export class PaymentSession {
|
||||
status: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
data: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ps_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ps")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Swap } from "./swap"
|
||||
import { Currency } from "./currency"
|
||||
import { Cart } from "./cart"
|
||||
import { Order } from "./order"
|
||||
import { DraftOrder } from "./draft-order"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Payment {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Payment extends BaseEntity {
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
@@ -44,10 +38,7 @@ export class Payment {
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
order => order.payments
|
||||
)
|
||||
@ManyToOne(() => Order, (order) => order.payments)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@@ -69,7 +60,7 @@ export class Payment {
|
||||
provider_id: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
captured_at: Date
|
||||
@@ -77,23 +68,15 @@ export class Payment {
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
canceled_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `pay_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "pay")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
OneToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { PriceListStatus, PriceListType } from "../types/price-list"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { CustomerGroup } from "./customer-group"
|
||||
import { MoneyAmount } from "./money-amount"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class PriceList {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class PriceList extends SoftDeletableEntity {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@@ -63,22 +57,9 @@ export class PriceList {
|
||||
})
|
||||
prices: MoneyAmount[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): undefined | void {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `pl_${id}`
|
||||
this.id = generateEntityId(this.id, "pl")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,13 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToMany,
|
||||
Index,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, Index, OneToMany } from "typeorm"
|
||||
import _ from "lodash"
|
||||
|
||||
import { Product } from "./product"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductCollection {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductCollection extends SoftDeletableEntity {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@@ -28,30 +15,17 @@ export class ProductCollection {
|
||||
@Column({ nullable: true })
|
||||
handle: string
|
||||
|
||||
@OneToMany(
|
||||
() => Product,
|
||||
product => product.collection
|
||||
)
|
||||
@OneToMany(() => Product, (product) => product.collection)
|
||||
products: Product[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
private createHandleIfNotProvided(): void {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `pcol_${id}`
|
||||
|
||||
this.id = generateEntityId(this.id, "pcol")
|
||||
if (!this.handle) {
|
||||
this.handle = _.kebabCase(this.title)
|
||||
}
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { ProductOption } from "./product-option"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductOptionValue {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductOptionValue extends SoftDeletableEntity {
|
||||
@Column()
|
||||
value: string
|
||||
|
||||
@@ -41,25 +35,12 @@ export class ProductOptionValue {
|
||||
@JoinColumn({ name: "variant_id" })
|
||||
variant: ProductVariant
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void | undefined {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `optval_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "optval")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +1,39 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
JoinColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Product } from "./product"
|
||||
import { ProductOptionValue } from "./product-option-value"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductOption {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductOption extends SoftDeletableEntity {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@OneToMany(
|
||||
() => ProductOptionValue,
|
||||
value => value.option
|
||||
)
|
||||
@OneToMany(() => ProductOptionValue, (value) => value.option)
|
||||
values: ProductOptionValue[]
|
||||
|
||||
@Column()
|
||||
product_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Product,
|
||||
product => product.options
|
||||
)
|
||||
@ManyToOne(() => Product, (product) => product.options)
|
||||
@JoinColumn({ name: "product_id" })
|
||||
product: Product
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `opt_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "opt")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +1,19 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductTag {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductTag extends SoftDeletableEntity {
|
||||
@Column()
|
||||
value: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ptag_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ptag")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
Entity,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
@@ -36,7 +35,7 @@ export class ProductTaxRate {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {
|
||||
Entity,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { ProductType } from "./product-type"
|
||||
import { TaxRate } from "./tax-rate"
|
||||
@@ -35,7 +34,7 @@ export class ProductTypeTaxRate {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,40 +1,19 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductType {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductType extends SoftDeletableEntity {
|
||||
@Column()
|
||||
value: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ptyp_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ptyp")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Product } from "./product"
|
||||
import { MoneyAmount } from "./money-amount"
|
||||
import { ProductOptionValue } from "./product-option-value"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ProductVariant {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ProductVariant extends SoftDeletableEntity {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@@ -99,25 +91,12 @@ export class ProductVariant {
|
||||
})
|
||||
options: ProductOptionValue[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `variant_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "variant")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ import _ from "lodash"
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
@@ -11,11 +9,8 @@ import {
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { Image } from "./image"
|
||||
import { ProductCollection } from "./product-collection"
|
||||
import { ProductOption } from "./product-option"
|
||||
@@ -23,6 +18,8 @@ import { ProductTag } from "./product-tag"
|
||||
import { ProductType } from "./product-type"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { ShippingProfile } from "./shipping-profile"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum Status {
|
||||
DRAFT = "draft",
|
||||
@@ -32,10 +29,7 @@ export enum Status {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Product {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Product extends SoftDeletableEntity {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@@ -72,17 +66,12 @@ export class Product {
|
||||
@Column({ nullable: true })
|
||||
thumbnail: string
|
||||
|
||||
@OneToMany(
|
||||
() => ProductOption,
|
||||
(productOption) => productOption.product
|
||||
)
|
||||
@OneToMany(() => ProductOption, (productOption) => productOption.product)
|
||||
options: ProductOption[]
|
||||
|
||||
@OneToMany(
|
||||
() => ProductVariant,
|
||||
(variant) => variant.product,
|
||||
{ cascade: true }
|
||||
)
|
||||
@OneToMany(() => ProductVariant, (variant) => variant.product, {
|
||||
cascade: true,
|
||||
})
|
||||
variants: ProductVariant[]
|
||||
|
||||
@Index()
|
||||
@@ -151,24 +140,14 @@ export class Product {
|
||||
@Column({ nullable: true })
|
||||
external_id: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
private beforeInsert(): void {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `prod_${id}`
|
||||
|
||||
this.id = generateEntityId(this.id, "prod")
|
||||
if (!this.handle) {
|
||||
this.handle = _.kebabCase(this.title)
|
||||
}
|
||||
|
||||
@@ -3,19 +3,14 @@ import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Index,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Currency } from "./currency"
|
||||
import { Cart } from "./cart"
|
||||
import { Order } from "./order"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum RefundReason {
|
||||
DISCOUNT = "discount",
|
||||
@@ -26,18 +21,12 @@ export enum RefundReason {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Refund {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Refund extends BaseEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
order => order.payments
|
||||
)
|
||||
@ManyToOne(() => Order, (order) => order.payments)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@@ -50,22 +39,15 @@ export class Refund {
|
||||
@DbAwareColumn({ type: "enum", enum: RefundReason })
|
||||
reason: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
const id = ulid()
|
||||
this.id = `ref_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ref")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinTable,
|
||||
JoinColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Currency } from "./currency"
|
||||
import { TaxRate } from "./tax-rate"
|
||||
@@ -21,12 +15,12 @@ import { Country } from "./country"
|
||||
import { PaymentProvider } from "./payment-provider"
|
||||
import { FulfillmentProvider } from "./fulfillment-provider"
|
||||
import { TaxProvider } from "./tax-provider"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Region {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Region extends SoftDeletableEntity {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@@ -96,23 +90,12 @@ export class Region {
|
||||
})
|
||||
fulfillment_providers: FulfillmentProvider[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `reg_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "reg")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
import {
|
||||
Entity,
|
||||
Generated,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { ReturnReason } from "./return-reason"
|
||||
@@ -60,7 +44,7 @@ export class ReturnItem {
|
||||
note: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class ReturnReason {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ReturnReason extends SoftDeletableEntity {
|
||||
@Index({ unique: true })
|
||||
@Column()
|
||||
value: string
|
||||
@@ -32,35 +26,23 @@ export class ReturnReason {
|
||||
@Column({ nullable: true })
|
||||
parent_return_reason_id: string
|
||||
|
||||
@ManyToOne(() => ReturnReason, {cascade: ['soft-remove']}
|
||||
)
|
||||
@ManyToOne(() => ReturnReason, { cascade: ["soft-remove"] })
|
||||
@JoinColumn({ name: "parent_return_reason_id" })
|
||||
parent_return_reason: ReturnReason
|
||||
|
||||
@OneToMany(
|
||||
() => ReturnReason,
|
||||
return_reason => return_reason.parent_return_reason,
|
||||
{ cascade: ["insert", 'soft-remove'] }
|
||||
(return_reason) => return_reason.parent_return_reason,
|
||||
{ cascade: ["insert", "soft-remove"] }
|
||||
)
|
||||
return_reason_children: ReturnReason[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `rr_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "rr")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,22 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Order } from "./order"
|
||||
import { Swap } from "./swap"
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
import { ReturnItem } from "./return-item"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum ReturnStatus {
|
||||
REQUESTED = "requested",
|
||||
@@ -32,10 +26,7 @@ export enum ReturnStatus {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Return {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Return extends BaseEntity {
|
||||
@DbAwareColumn({
|
||||
type: "enum",
|
||||
enum: ReturnStatus,
|
||||
@@ -43,21 +34,17 @@ export class Return {
|
||||
})
|
||||
status: ReturnStatus
|
||||
|
||||
@OneToMany(
|
||||
() => ReturnItem,
|
||||
item => item.return_order,
|
||||
{ eager: true, cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => ReturnItem, (item) => item.return_order, {
|
||||
eager: true,
|
||||
cascade: ["insert"],
|
||||
})
|
||||
items: ReturnItem[]
|
||||
|
||||
@Index()
|
||||
@Column({ nullable: true })
|
||||
swap_id: string
|
||||
|
||||
@OneToOne(
|
||||
() => Swap,
|
||||
swap => swap.return_order
|
||||
)
|
||||
@OneToOne(() => Swap, (swap) => swap.return_order)
|
||||
@JoinColumn({ name: "swap_id" })
|
||||
swap: Swap
|
||||
|
||||
@@ -65,10 +52,7 @@ export class Return {
|
||||
@Column({ nullable: true })
|
||||
claim_order_id: string
|
||||
|
||||
@OneToOne(
|
||||
() => ClaimOrder,
|
||||
co => co.return_order
|
||||
)
|
||||
@OneToOne(() => ClaimOrder, (co) => co.return_order)
|
||||
@JoinColumn({ name: "claim_order_id" })
|
||||
claim_order: ClaimOrder
|
||||
|
||||
@@ -76,22 +60,17 @@ export class Return {
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
o => o.returns
|
||||
)
|
||||
@ManyToOne(() => Order, (o) => o.returns)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@OneToOne(
|
||||
() => ShippingMethod,
|
||||
method => method.return_order,
|
||||
{ cascade: true }
|
||||
)
|
||||
@OneToOne(() => ShippingMethod, (method) => method.return_order, {
|
||||
cascade: true,
|
||||
})
|
||||
shipping_method: ShippingMethod
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
shipping_data: any
|
||||
shipping_data: Record<string, unknown>
|
||||
|
||||
@Column({ type: "int" })
|
||||
refund_amount: number
|
||||
@@ -99,26 +78,18 @@ export class Return {
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
received_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@Column({ type: "boolean", nullable: true })
|
||||
no_notification: Boolean
|
||||
no_notification: boolean
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `ret_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ret")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
ManyToOne,
|
||||
Unique,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
|
||||
import { TaxLine } from "./tax-line"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
@Unique(["shipping_method_id", "code"])
|
||||
@@ -24,9 +24,7 @@ export class ShippingMethodTaxLine extends TaxLine {
|
||||
shipping_method: ShippingMethod
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `smtl_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "smtl")
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
import {
|
||||
Entity,
|
||||
Check,
|
||||
BeforeInsert,
|
||||
Check,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { ClaimOrder } from "./claim-order"
|
||||
@@ -20,6 +19,7 @@ import { Swap } from "./swap"
|
||||
import { Return } from "./return"
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { ShippingMethodTaxLine } from "./shipping-method-tax-line"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Check(
|
||||
`"claim_order_id" IS NOT NULL OR "order_id" IS NOT NULL OR "cart_id" IS NOT NULL OR "swap_id" IS NOT NULL OR "return_id" IS NOT NULL`
|
||||
@@ -87,13 +87,11 @@ export class ShippingMethod {
|
||||
price: number
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `sm_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "sm")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Index,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
RelationId,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum RequirementType {
|
||||
MIN_SUBTOTAL = "min_subtotal",
|
||||
@@ -48,10 +41,8 @@ export class ShippingOptionRequirement {
|
||||
deleted_at: Date
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `sor_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "sor")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
import {
|
||||
Entity,
|
||||
Check,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Check,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
RelationId,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { ShippingProfile } from "./shipping-profile"
|
||||
import { Region } from "./region"
|
||||
import { FulfillmentProvider } from "./fulfillment-provider"
|
||||
import { ShippingOptionRequirement } from "./shipping-option-requirement"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum ShippingOptionPriceType {
|
||||
FLAT_RATE = "flat_rate",
|
||||
@@ -31,10 +24,7 @@ export enum ShippingOptionPriceType {
|
||||
|
||||
@Check(`"amount" >= 0`)
|
||||
@Entity()
|
||||
export class ShippingOption {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ShippingOption extends SoftDeletableEntity {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@@ -74,33 +64,20 @@ export class ShippingOption {
|
||||
@Column({ default: false })
|
||||
admin_only: boolean
|
||||
|
||||
@OneToMany(
|
||||
() => ShippingOptionRequirement,
|
||||
req => req.shipping_option,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => ShippingOptionRequirement, (req) => req.shipping_option, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
requirements: ShippingOptionRequirement[]
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
data: Record<string, unknown>
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `so_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "so")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToMany,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, OneToMany } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { Product } from "./product"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum ShippingProfileType {
|
||||
DEFAULT = "default",
|
||||
@@ -21,45 +13,25 @@ export enum ShippingProfileType {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class ShippingProfile {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class ShippingProfile extends SoftDeletableEntity {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@DbAwareColumn({ type: "enum", enum: ShippingProfileType })
|
||||
type: ShippingProfileType
|
||||
|
||||
@OneToMany(
|
||||
() => Product,
|
||||
product => product.profile
|
||||
)
|
||||
@OneToMany(() => Product, (product) => product.profile)
|
||||
products: Product[]
|
||||
|
||||
@OneToMany(
|
||||
() => ShippingOption,
|
||||
so => so.profile
|
||||
)
|
||||
@OneToMany(() => ShippingOption, (so) => so.profile)
|
||||
shipping_options: ShippingOption[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `sp_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "sp")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {
|
||||
Entity,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { TaxRate } from "./tax-rate"
|
||||
@@ -35,7 +34,7 @@ export class ShippingTaxRate {
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { BeforeInsert, Column, Entity, PrimaryColumn } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class StagedJob {
|
||||
@@ -26,11 +11,10 @@ export class StagedJob {
|
||||
event_name: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb" })
|
||||
data: any
|
||||
data: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
const id = ulid()
|
||||
this.id = `job_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "job")
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,20 @@
|
||||
import {
|
||||
Entity,
|
||||
RelationId,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Currency } from "./currency"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class Store {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Store extends BaseEntity {
|
||||
@Column({ default: "Medusa Store" })
|
||||
name: string
|
||||
|
||||
@@ -57,19 +48,12 @@ export class Store {
|
||||
@Column({ nullable: true })
|
||||
invite_link_template: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
const id = ulid()
|
||||
this.id = `store_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "store")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
|
||||
import { Order } from "./order"
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
@@ -25,6 +18,8 @@ import { Return } from "./return"
|
||||
import { Cart } from "./cart"
|
||||
import { Payment } from "./payment"
|
||||
import { ShippingMethod } from "./shipping-method"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum SwapFulfillmentStatus {
|
||||
NOT_FULFILLED = "not_fulfilled",
|
||||
@@ -47,10 +42,7 @@ export enum SwapPaymentStatus {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class Swap {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class Swap extends SoftDeletableEntity {
|
||||
@DbAwareColumn({ type: "enum", enum: SwapFulfillmentStatus })
|
||||
fulfillment_status: SwapFulfillmentStatus
|
||||
|
||||
@@ -61,39 +53,22 @@ export class Swap {
|
||||
@Column({ type: "string" })
|
||||
order_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Order,
|
||||
(o) => o.swaps
|
||||
)
|
||||
@ManyToOne(() => Order, (o) => o.swaps)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@OneToMany(
|
||||
() => LineItem,
|
||||
(item) => item.swap,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => LineItem, (item) => item.swap, { cascade: ["insert"] })
|
||||
additional_items: LineItem[]
|
||||
|
||||
@OneToOne(
|
||||
() => Return,
|
||||
(ret) => ret.swap,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToOne(() => Return, (ret) => ret.swap, { cascade: ["insert"] })
|
||||
return_order: Return
|
||||
|
||||
@OneToMany(
|
||||
() => Fulfillment,
|
||||
(fulfillment) => fulfillment.swap,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => Fulfillment, (fulfillment) => fulfillment.swap, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
fulfillments: Fulfillment[]
|
||||
|
||||
@OneToOne(
|
||||
() => Payment,
|
||||
(p) => p.swap,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToOne(() => Payment, (p) => p.swap, { cascade: ["insert"] })
|
||||
payment: Payment
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
@@ -106,11 +81,9 @@ export class Swap {
|
||||
@JoinColumn({ name: "shipping_address_id" })
|
||||
shipping_address: Address
|
||||
|
||||
@OneToMany(
|
||||
() => ShippingMethod,
|
||||
(method) => method.swap,
|
||||
{ cascade: ["insert"] }
|
||||
)
|
||||
@OneToMany(() => ShippingMethod, (method) => method.swap, {
|
||||
cascade: ["insert"],
|
||||
})
|
||||
shipping_methods: ShippingMethod[]
|
||||
|
||||
@Column({ nullable: true })
|
||||
@@ -123,35 +96,24 @@ export class Swap {
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
confirmed_at: Date
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||
canceled_at: Date
|
||||
|
||||
@Column({ type: "boolean", nullable: true })
|
||||
no_notification: Boolean
|
||||
no_notification: boolean
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
allow_backorder: Boolean
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
allow_backorder: boolean
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `swap_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "swap")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
import {
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
export class TaxLine {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
import { Column } from "typeorm"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
export class TaxLine extends BaseEntity {
|
||||
@Column({ type: "real" })
|
||||
rate: number
|
||||
|
||||
@@ -19,14 +12,8 @@ export class TaxLine {
|
||||
@Column({ type: "varchar", nullable: true })
|
||||
code: string | null
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryColumn } from "typeorm"
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class TaxProvider {
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
|
||||
import { Region } from "./region"
|
||||
import { Product } from "./product"
|
||||
import { ProductType } from "./product-type"
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class TaxRate {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class TaxRate extends BaseEntity {
|
||||
@Column({ type: "real", nullable: true })
|
||||
rate: number | null
|
||||
|
||||
@@ -39,14 +34,8 @@ export class TaxRate {
|
||||
@JoinColumn({ name: "region_id" })
|
||||
region: Region
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@ManyToMany(() => Product)
|
||||
@JoinTable({
|
||||
@@ -96,10 +85,8 @@ export class TaxRate {
|
||||
shipping_option_count?: number
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `txr_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "txr")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,12 @@
|
||||
import {
|
||||
Entity,
|
||||
Index,
|
||||
BeforeInsert,
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, JoinColumn, ManyToOne } from "typeorm"
|
||||
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
@Entity()
|
||||
export class TrackingLink {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class TrackingLink extends SoftDeletableEntity {
|
||||
@Column({ nullable: true })
|
||||
url: string
|
||||
|
||||
@@ -33,33 +16,19 @@ export class TrackingLink {
|
||||
@Column()
|
||||
fulfillment_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Fulfillment,
|
||||
ful => ful.tracking_links
|
||||
)
|
||||
@ManyToOne(() => Fulfillment, (ful) => ful.tracking_links)
|
||||
@JoinColumn({ name: "fulfillment_id" })
|
||||
fulfillment: Fulfillment
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `tlink_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "tlink")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import {
|
||||
Entity,
|
||||
BeforeInsert,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Index,
|
||||
Column,
|
||||
PrimaryColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { resolveDbType, DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
|
||||
export enum UserRoles {
|
||||
ADMIN = "admin",
|
||||
@@ -18,10 +10,7 @@ export enum UserRoles {
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
|
||||
export class User extends SoftDeletableEntity {
|
||||
@DbAwareColumn({
|
||||
type: "enum",
|
||||
enum: UserRoles,
|
||||
@@ -46,23 +35,12 @@ export class User {
|
||||
@Column({ nullable: true })
|
||||
api_token: string
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
created_at: Date
|
||||
|
||||
@UpdateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
updated_at: Date
|
||||
|
||||
@DeleteDateColumn({ type: resolveDbType("timestamptz") })
|
||||
deleted_at: Date
|
||||
|
||||
@DbAwareColumn({ type: "jsonb", nullable: true })
|
||||
metadata: any
|
||||
metadata: Record<string, unknown>
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
const id = ulid()
|
||||
this.id = `usr_${id}`
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "usr")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { EntityRepository, Repository } from "typeorm"
|
||||
import { LineItemTaxLine } from "../models/line-item-tax-line"
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"
|
||||
|
||||
@EntityRepository(LineItemTaxLine)
|
||||
export class LineItemTaxLineRepository extends Repository<LineItemTaxLine> {
|
||||
async upsertLines(lines: LineItemTaxLine[]): Promise<LineItemTaxLine[]> {
|
||||
const insertResult = await this.createQueryBuilder()
|
||||
.insert()
|
||||
.values(lines)
|
||||
.values(lines as QueryDeepPartialEntity<LineItemTaxLine>[])
|
||||
.orUpdate({
|
||||
conflict_target: ["item_id", "code"],
|
||||
overwrite: ["rate", "name", "updated_at"],
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
PriceListPriceCreateInput,
|
||||
PriceListPriceUpdateInput,
|
||||
} from "../types/price-list"
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"
|
||||
|
||||
type Price = Partial<
|
||||
Omit<MoneyAmount, "created_at" | "updated_at" | "deleted_at">
|
||||
@@ -84,7 +85,7 @@ export class MoneyAmountRepository extends Repository<MoneyAmount> {
|
||||
.insert()
|
||||
.orIgnore(true)
|
||||
.into(MoneyAmount)
|
||||
.values(toInsert)
|
||||
.values(toInsert as QueryDeepPartialEntity<MoneyAmount>[])
|
||||
.execute()
|
||||
|
||||
if (overrideExisting) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { EntityRepository, Repository } from "typeorm"
|
||||
import { ShippingMethodTaxLine } from "../models/shipping-method-tax-line"
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"
|
||||
|
||||
@EntityRepository(ShippingMethodTaxLine)
|
||||
export class ShippingMethodTaxLineRepository extends Repository<ShippingMethodTaxLine> {
|
||||
@@ -8,7 +9,7 @@ export class ShippingMethodTaxLineRepository extends Repository<ShippingMethodTa
|
||||
): Promise<ShippingMethodTaxLine[]> {
|
||||
const insertResult = await this.createQueryBuilder()
|
||||
.insert()
|
||||
.values(lines)
|
||||
.values(lines as QueryDeepPartialEntity<ShippingMethodTaxLine>[])
|
||||
.orUpdate({
|
||||
conflict_target: ["shipping_method_id", "code"],
|
||||
overwrite: ["rate", "name", "updated_at"],
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
import dotenv from "dotenv"
|
||||
import { createConnection } from "typeorm"
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"
|
||||
import Logger from "../loaders/logger"
|
||||
import {
|
||||
DiscountCondition,
|
||||
@@ -8,6 +10,7 @@ import {
|
||||
} from "../models/discount-condition"
|
||||
import { DiscountConditionProduct } from "../models/discount-condition-product"
|
||||
import { DiscountRule } from "../models/discount-rule"
|
||||
import { DiscountConditionRepository } from "../repositories/discount-condition"
|
||||
dotenv.config()
|
||||
|
||||
const typeormConfig = {
|
||||
@@ -48,18 +51,18 @@ const migrate = async function ({ typeormConfig }): Promise<void> {
|
||||
.offset(offset)
|
||||
.getRawMany()
|
||||
|
||||
const discountConditionRepo = manager
|
||||
.getCustomRepository(DiscountConditionRepository)
|
||||
await manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(DiscountCondition)
|
||||
.values(
|
||||
discountRules.map((dr) =>
|
||||
Object.assign(new DiscountCondition(), {
|
||||
type: DiscountConditionType.PRODUCTS,
|
||||
operator: DiscountConditionOperator.IN,
|
||||
discount_rule_id: dr.dr_id,
|
||||
})
|
||||
)
|
||||
discountRules.map((dr) => discountConditionRepo.create({
|
||||
type: DiscountConditionType.PRODUCTS,
|
||||
operator: DiscountConditionOperator.IN,
|
||||
discount_rule_id: dr.dr_id,
|
||||
}) as QueryDeepPartialEntity<DiscountCondition>)
|
||||
)
|
||||
.orIgnore()
|
||||
.execute()
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
FilterableCartProps,
|
||||
LineItemUpdate,
|
||||
} from "../types/cart"
|
||||
import { FindConfig, TotalField } from "../types/common"
|
||||
import { AddressPayload, FindConfig, TotalField } from "../types/common"
|
||||
import { buildQuery, setMetadata, validateId } from "../utils"
|
||||
import CustomShippingOptionService from "./custom-shipping-option"
|
||||
import CustomerService from "./customer"
|
||||
@@ -404,6 +404,9 @@ class CartService extends TransactionBaseService<CartService> {
|
||||
typeof data[remainingField] !== "undefined" &&
|
||||
remainingField !== "object"
|
||||
) {
|
||||
/* TODO: See how to fix the error TS2590 properly while keeping the DeepPartial type */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
rawCart[remainingField] = data[remainingField]
|
||||
}
|
||||
}
|
||||
@@ -915,7 +918,7 @@ class CartService extends TransactionBaseService<CartService> {
|
||||
*/
|
||||
protected async updateBillingAddress_(
|
||||
cart: Cart,
|
||||
addressOrId: Partial<Address> | string,
|
||||
addressOrId: AddressPayload | Partial<Address> | string,
|
||||
addrRepo: AddressRepository
|
||||
): Promise<void> {
|
||||
let address: Address
|
||||
@@ -955,7 +958,7 @@ class CartService extends TransactionBaseService<CartService> {
|
||||
*/
|
||||
protected async updateShippingAddress_(
|
||||
cart: Cart,
|
||||
addressOrId: Partial<Address> | string,
|
||||
addressOrId: AddressPayload | Partial<Address> | string,
|
||||
addrRepo: AddressRepository
|
||||
): Promise<void> {
|
||||
let address: Address
|
||||
|
||||
@@ -238,8 +238,6 @@ class PriceListService extends BaseService {
|
||||
}
|
||||
|
||||
await priceListRepo.remove(priceList)
|
||||
|
||||
return Promise.resolve()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class CartCompletionStrategy implements ICartCompletionStrategy {
|
||||
const swapId = cart.metadata?.swap_id
|
||||
let swap = await swapService
|
||||
.withTransaction(manager)
|
||||
.registerCartCompletion(swapId)
|
||||
.registerCartCompletion(swapId as string)
|
||||
|
||||
swap = await swapService
|
||||
.withTransaction(manager)
|
||||
|
||||
@@ -29,7 +29,7 @@ export type LineItemUpdate = {
|
||||
title?: string
|
||||
unit_price?: number
|
||||
quantity?: number
|
||||
metadata?: object
|
||||
metadata?: Record<string, unknown>
|
||||
region_id?: string
|
||||
variant_id?: string
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface CreateNoteInput {
|
||||
resource_id: string
|
||||
author_id?: string
|
||||
author?: User
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type selector = {
|
||||
|
||||
@@ -16,7 +16,7 @@ export type ProviderShippingMethodTaxLine = {
|
||||
rate: number
|
||||
name: string
|
||||
code: string | null
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
shipping_method_id: string
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export type ProviderLineItemTaxLine = {
|
||||
name: string
|
||||
code: string | null
|
||||
item_id: string
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface CreateUserInput {
|
||||
last_name?: string
|
||||
api_token?: string
|
||||
role?: UserRoles
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface UpdateUserInput {
|
||||
@@ -18,7 +18,7 @@ export interface UpdateUserInput {
|
||||
readonly password_hash?: string
|
||||
api_token?: string
|
||||
role?: UserRoles
|
||||
metadata?: JSON
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export enum UserRole {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { generateEntityId } from "../generate-entity-id"
|
||||
import { Entity, PrimaryColumn } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
class GenerateIdSpecEntity {
|
||||
@PrimaryColumn()
|
||||
id: string
|
||||
}
|
||||
|
||||
describe("generateAndApplyEntityId", () => {
|
||||
it('should return the id if already set', () => {
|
||||
const entity = new GenerateIdSpecEntity()
|
||||
entity.id = "fakeId"
|
||||
|
||||
const generatedId = generateEntityId(entity.id, "prefix")
|
||||
expect(generatedId).toBe(entity.id)
|
||||
})
|
||||
|
||||
it('should return the new generated id if not set already', () => {
|
||||
const entity = new GenerateIdSpecEntity()
|
||||
|
||||
entity.id = generateEntityId(entity.id, "prefix")
|
||||
expect(entity.id).toBeTruthy()
|
||||
expect(entity.id).toEqual(expect.stringMatching(/prefix_*/))
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ulid } from "ulid"
|
||||
|
||||
/**
|
||||
* Generate a composed id based on the input parameters and return either the is if it exists or the generated one.
|
||||
* @param idProperty
|
||||
* @param prefix
|
||||
*/
|
||||
export function generateEntityId(idProperty: string, prefix?: string): string {
|
||||
if (idProperty) {
|
||||
return idProperty
|
||||
}
|
||||
|
||||
const id = ulid()
|
||||
prefix = prefix ? `${prefix}_` : ''
|
||||
return `${prefix}${id}`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"index.d.ts",
|
||||
"./src/**/__tests__",
|
||||
"./src/**/__mocks__"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -4556,6 +4556,13 @@
|
||||
terminal-link "^2.0.0"
|
||||
v8-to-istanbul "^8.1.0"
|
||||
|
||||
"@jest/schemas@^28.0.2":
|
||||
version "28.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-28.0.2.tgz#08c30df6a8d07eafea0aef9fb222c5e26d72e613"
|
||||
integrity sha512-YVDJZjd4izeTDkij00vHHAymNXQ6WWsdChFRK86qck6Jpr3DCL5W3Is3vslviRlP+bLuMYRLbdp98amMvqudhA==
|
||||
dependencies:
|
||||
"@sinclair/typebox" "^0.23.3"
|
||||
|
||||
"@jest/source-map@^25.5.0":
|
||||
version "25.5.0"
|
||||
resolved "https://registry.npmjs.org/@jest/source-map/-/source-map-25.5.0.tgz"
|
||||
@@ -4741,6 +4748,18 @@
|
||||
"@types/yargs" "^16.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@jest/types@^28.0.2":
|
||||
version "28.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.0.2.tgz#70b9538c1863fb060b2f438ca008b5563d00c5b4"
|
||||
integrity sha512-hi3jUdm9iht7I2yrV5C4s3ucCJHUP8Eh3W6rQ1s4n/Qw9rQgsda4eqCt+r3BKRi7klVmZfQlMx1nGlzNMP2d8A==
|
||||
dependencies:
|
||||
"@jest/schemas" "^28.0.2"
|
||||
"@types/istanbul-lib-coverage" "^2.0.0"
|
||||
"@types/istanbul-reports" "^3.0.0"
|
||||
"@types/node" "*"
|
||||
"@types/yargs" "^17.0.8"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@jsdevtools/ono@^7.1.3":
|
||||
version "7.1.3"
|
||||
resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz"
|
||||
@@ -5985,6 +6004,11 @@
|
||||
resolved "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz"
|
||||
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
|
||||
|
||||
"@sinclair/typebox@^0.23.3":
|
||||
version "0.23.5"
|
||||
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.23.5.tgz#93f7b9f4e3285a7a9ade7557d9a8d36809cbc47d"
|
||||
integrity sha512-AFBVi/iT4g20DHoujvMH1aEDn8fGJh4xsRGCP6d8RpLPMqsNPvW01Jcn0QysXTsg++/xj25NmJsGyH9xug/wKg==
|
||||
|
||||
"@sindresorhus/is@^0.14.0":
|
||||
version "0.14.0"
|
||||
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz"
|
||||
@@ -7624,6 +7648,14 @@
|
||||
jest-diff "^27.0.0"
|
||||
pretty-format "^27.0.0"
|
||||
|
||||
"@types/jest@^27.5.0":
|
||||
version "27.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.5.0.tgz#e04ed1824ca6b1dd0438997ba60f99a7405d4c7b"
|
||||
integrity sha512-9RBFx7r4k+msyj/arpfaa0WOOEcaAZNmN+j80KFbFCoSqCJGHTz7YMAMGQW9Xmqm5w6l5c25vbSjMwlikJi5+g==
|
||||
dependencies:
|
||||
jest-matcher-utils "^27.0.0"
|
||||
pretty-format "^27.0.0"
|
||||
|
||||
"@types/js-levenshtein@^1.1.0":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.npmjs.org/@types/js-levenshtein/-/js-levenshtein-1.1.1.tgz"
|
||||
@@ -7745,6 +7777,11 @@
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-14.18.5.tgz"
|
||||
integrity sha512-LMy+vDDcQR48EZdEx5wRX1q/sEl6NdGuHXPnfeL8ixkwCOSZ2qnIyIZmcCbdX0MeRqHhAcHmX+haCbrS8Run+A==
|
||||
|
||||
"@types/node@^17.0.31":
|
||||
version "17.0.31"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.31.tgz#a5bb84ecfa27eec5e1c802c6bbf8139bdb163a5d"
|
||||
integrity sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==
|
||||
|
||||
"@types/node@^8.5.7":
|
||||
version "8.10.66"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-8.10.66.tgz"
|
||||
@@ -8028,6 +8065,13 @@
|
||||
dependencies:
|
||||
"@types/yargs-parser" "*"
|
||||
|
||||
"@types/yargs@^17.0.8":
|
||||
version "17.0.10"
|
||||
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.10.tgz#591522fce85d8739bca7b8bb90d048e4478d186a"
|
||||
integrity sha512-gmEaFwpj/7f/ROdtIlci1R1VYU1J4j95m8T+Tj3iBgiBFKg1foE/PSl93bBd5T9LDXNPo8UlNN6W0qwD8O5OaA==
|
||||
dependencies:
|
||||
"@types/yargs-parser" "*"
|
||||
|
||||
"@types/yoga-layout@1.9.2":
|
||||
version "1.9.2"
|
||||
resolved "https://registry.npmjs.org/@types/yoga-layout/-/yoga-layout-1.9.2.tgz"
|
||||
@@ -12707,6 +12751,11 @@ diff-sequences@^27.4.0:
|
||||
resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.4.0.tgz"
|
||||
integrity sha512-YqiQzkrsmHMH5uuh8OdQFU9/ZpADnwzml8z0O5HvRNda+5UZsaX/xN+AAxfR2hWq1Y7HZnAzO9J5lJXOuDz2Ww==
|
||||
|
||||
diff-sequences@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327"
|
||||
integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==
|
||||
|
||||
diff@^4.0.1:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz"
|
||||
@@ -15782,6 +15831,11 @@ graceful-fs@^4.2.4:
|
||||
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz"
|
||||
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
|
||||
|
||||
graceful-fs@^4.2.9:
|
||||
version "4.2.10"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
|
||||
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==
|
||||
|
||||
grapheme-splitter@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz"
|
||||
@@ -17767,6 +17821,16 @@ jest-diff@^27.0.0, jest-diff@^27.4.6:
|
||||
jest-get-type "^27.4.0"
|
||||
pretty-format "^27.4.6"
|
||||
|
||||
jest-diff@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def"
|
||||
integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==
|
||||
dependencies:
|
||||
chalk "^4.0.0"
|
||||
diff-sequences "^27.5.1"
|
||||
jest-get-type "^27.5.1"
|
||||
pretty-format "^27.5.1"
|
||||
|
||||
jest-docblock@^25.3.0:
|
||||
version "25.3.0"
|
||||
resolved "https://registry.npmjs.org/jest-docblock/-/jest-docblock-25.3.0.tgz"
|
||||
@@ -17910,6 +17974,11 @@ jest-get-type@^27.4.0:
|
||||
resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.4.0.tgz"
|
||||
integrity sha512-tk9o+ld5TWq41DkK14L4wox4s2D9MtTpKaAVzXfr5CUKm5ZK2ExcaFE0qls2W71zE/6R2TxxrK9w2r6svAFDBQ==
|
||||
|
||||
jest-get-type@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1"
|
||||
integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==
|
||||
|
||||
jest-haste-map@^25.5.1:
|
||||
version "25.5.1"
|
||||
resolved "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-25.5.1.tgz"
|
||||
@@ -18085,6 +18154,16 @@ jest-matcher-utils@^26.6.2:
|
||||
jest-get-type "^26.3.0"
|
||||
pretty-format "^26.6.2"
|
||||
|
||||
jest-matcher-utils@^27.0.0:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab"
|
||||
integrity sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==
|
||||
dependencies:
|
||||
chalk "^4.0.0"
|
||||
jest-diff "^27.5.1"
|
||||
jest-get-type "^27.5.1"
|
||||
pretty-format "^27.5.1"
|
||||
|
||||
jest-matcher-utils@^27.4.6:
|
||||
version "27.4.6"
|
||||
resolved "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.4.6.tgz"
|
||||
@@ -18555,6 +18634,18 @@ jest-util@^27.4.2:
|
||||
graceful-fs "^4.2.4"
|
||||
picomatch "^2.2.3"
|
||||
|
||||
jest-util@^28.0.0:
|
||||
version "28.0.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-28.0.2.tgz#8e22cdd6e0549e0a393055f0e2da7eacc334b143"
|
||||
integrity sha512-EVdpIRCC8lzqhp9A0u0aAKlsFIzufK6xKxNK7awsnebTdOP4hpyQW5o6Ox2qPl8gbeUKYF+POLyItaND53kpGA==
|
||||
dependencies:
|
||||
"@jest/types" "^28.0.2"
|
||||
"@types/node" "*"
|
||||
chalk "^4.0.0"
|
||||
ci-info "^3.2.0"
|
||||
graceful-fs "^4.2.9"
|
||||
picomatch "^2.2.3"
|
||||
|
||||
jest-validate@^25.5.0:
|
||||
version "25.5.0"
|
||||
resolved "https://registry.npmjs.org/jest-validate/-/jest-validate-25.5.0.tgz"
|
||||
@@ -23193,6 +23284,15 @@ pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.4.6:
|
||||
ansi-styles "^5.0.0"
|
||||
react-is "^17.0.1"
|
||||
|
||||
pretty-format@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"
|
||||
integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
ansi-styles "^5.0.0"
|
||||
react-is "^17.0.1"
|
||||
|
||||
pretty-hrtime@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz"
|
||||
@@ -27071,6 +27171,20 @@ ts-jest@^26.5.6:
|
||||
semver "7.x"
|
||||
yargs-parser "20.x"
|
||||
|
||||
ts-jest@^28.0.1:
|
||||
version "28.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-28.0.1.tgz#626b4d7d5c386f88f4813d959ffc4ca0a8ffef96"
|
||||
integrity sha512-PbkbitaT/9ZYAqqzk3UYTvCq080Seo46T3m/AdwcZ0D8WH2uBhG6PvA8oOAWsZIknzPQU66fYobvFCL8IqIhmg==
|
||||
dependencies:
|
||||
bs-logger "0.x"
|
||||
fast-json-stable-stringify "2.x"
|
||||
jest-util "^28.0.0"
|
||||
json5 "2.x"
|
||||
lodash.memoize "4.x"
|
||||
make-error "1.x"
|
||||
semver "7.x"
|
||||
yargs-parser "^20.x"
|
||||
|
||||
ts-node@^9:
|
||||
version "9.1.1"
|
||||
resolved "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz"
|
||||
@@ -28761,7 +28875,7 @@ yargs-parser@18.x, yargs-parser@^18.1.2:
|
||||
camelcase "^5.0.0"
|
||||
decamelize "^1.2.0"
|
||||
|
||||
yargs-parser@20.x, yargs-parser@^20.2.2, yargs-parser@^20.2.3, yargs-parser@^20.2.7:
|
||||
yargs-parser@20.x, yargs-parser@^20.2.2, yargs-parser@^20.2.3, yargs-parser@^20.2.7, yargs-parser@^20.x:
|
||||
version "20.2.9"
|
||||
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz"
|
||||
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
|
||||
|
||||
Reference in new issue
Block a user