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:
Riqwan Thamir
2024-03-12 18:35:24 +01:00
committed by GitHub
parent f0c8142635
commit d4b921f3db
14 changed files with 312 additions and 14 deletions

View File

@@ -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",

View File

@@ -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");'
)

View File

@@ -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({

View File

@@ -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")

View File

@@ -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