feat(medusa,pricing,types): added get endpoints for pricing rule types (#6678)
what: - adds list endpoint for rule types - adds get endpoint for rule types
This commit is contained in:
@@ -116,8 +116,7 @@
|
||||
}
|
||||
],
|
||||
"checks": [],
|
||||
"foreignKeys": {
|
||||
}
|
||||
"foreignKeys": {}
|
||||
},
|
||||
{
|
||||
"columns": {
|
||||
@@ -520,6 +519,28 @@
|
||||
"nullable": false,
|
||||
"default": "0",
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 6,
|
||||
"default": "now()",
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 6,
|
||||
"default": "now()",
|
||||
"mappedType": "datetime"
|
||||
}
|
||||
},
|
||||
"name": "rule_type",
|
||||
|
||||
@@ -24,8 +24,9 @@ export class Migration20230929122253 extends Migration {
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create table "rule_type" ("id" text not null, "name" text not null, "rule_attribute" text not null, "default_priority" integer not null default 0, constraint "rule_type_pkey" primary key ("id"));'
|
||||
'create table "rule_type" ("id" text not null, "name" text not null, "rule_attribute" text not null, "default_priority" integer not null default 0, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), constraint "rule_type_pkey" primary key ("id"));'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'create index "IDX_rule_type_rule_attribute" on "rule_type" ("rule_attribute");'
|
||||
)
|
||||
|
||||
@@ -6,9 +6,8 @@ import {
|
||||
Filter,
|
||||
Index,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
OnInit,
|
||||
OneToOne,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
@@ -30,7 +29,11 @@ class MoneyAmount {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id!: string
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
@Property({
|
||||
columnType: "text",
|
||||
nullable: true,
|
||||
index: "IDX_money_amount_currency_code",
|
||||
})
|
||||
currency_code: string | null
|
||||
|
||||
@ManyToMany({
|
||||
|
||||
@@ -32,6 +32,21 @@ class RuleType {
|
||||
@ManyToMany(() => PriceSet, (priceSet) => priceSet.rule_types)
|
||||
price_sets = new Collection<PriceSet>(this)
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
created_at: Date
|
||||
|
||||
@Property({
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
columnType: "timestamptz",
|
||||
defaultRaw: "now()",
|
||||
})
|
||||
updated_at: Date
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "rul-typ")
|
||||
|
||||
@@ -19,6 +19,15 @@ export interface RuleTypeDTO {
|
||||
name: string
|
||||
rule_attribute: string
|
||||
default_priority: number
|
||||
/**
|
||||
* The creation date of the rule type.
|
||||
*/
|
||||
created_at?: Date | string
|
||||
|
||||
/**
|
||||
* The update date of the rule type.
|
||||
*/
|
||||
updated_at?: Date | string
|
||||
}
|
||||
|
||||
export interface FilterableRuleTypeProps
|
||||
|
||||
Reference in New Issue
Block a user