refactor: migrate cart module to DML (#10385)
FIXES: FRMW-2815 This PR has no breaking changes
This commit is contained in:
1 parent
7013c37fda
commit
0a16efa426
16 files changed
+808
-1275
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/cart": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
refactor: migrate cart module to DML
|
||||||
@@ -4,3 +4,4 @@ export * from "./has-many"
|
|||||||
export * from "./has-one"
|
export * from "./has-one"
|
||||||
export * from "./many-to-many"
|
export * from "./many-to-many"
|
||||||
export * from "./nullable"
|
export * from "./nullable"
|
||||||
|
export * from "./has-one-fk"
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
import { CreateCartDTO } from "@medusajs/framework/types"
|
import { CreateCartDTO, InferEntityType } from "@medusajs/framework/types"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import { Cart } from "../../../src/models"
|
import { Cart } from "../../../src/models"
|
||||||
import { defaultCartsData } from "./data"
|
import { defaultCartsData } from "./data"
|
||||||
|
import { toMikroORMEntity } from "@medusajs/framework/utils"
|
||||||
|
|
||||||
export * from "./data"
|
export * from "./data"
|
||||||
|
|
||||||
export async function createCarts(
|
export async function createCarts(
|
||||||
manager: SqlEntityManager,
|
manager: SqlEntityManager,
|
||||||
cartsData: CreateCartDTO[] = defaultCartsData
|
cartsData: CreateCartDTO[] = defaultCartsData
|
||||||
): Promise<Cart[]> {
|
): Promise<InferEntityType<typeof Cart>[]> {
|
||||||
const carts: Cart[] = []
|
const carts: InferEntityType<typeof Cart>[] = []
|
||||||
|
|
||||||
for (let cartData of cartsData) {
|
for (let cartData of cartsData) {
|
||||||
let cart = manager.create(Cart, cartData)
|
let cart = manager.create(toMikroORMEntity(Cart), cartData)
|
||||||
|
|
||||||
await manager.persistAndFlush(cart)
|
await manager.persistAndFlush(cart)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,13 +161,11 @@
|
|||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_address_deleted_at",
|
"keyName": "IDX_cart_address_deleted_at",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_address_deleted_at\" ON \"cart_address\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_address_deleted_at\" ON \"cart_address\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "cart_address_pkey",
|
"keyName": "cart_address_pkey",
|
||||||
@@ -238,24 +236,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "text"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"shipping_address_id": {
|
|
||||||
"name": "shipping_address_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"billing_address_id": {
|
|
||||||
"name": "billing_address_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "jsonb",
|
"type": "jsonb",
|
||||||
@@ -275,6 +255,24 @@
|
|||||||
"length": 6,
|
"length": 6,
|
||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
},
|
},
|
||||||
|
"shipping_address_id": {
|
||||||
|
"name": "shipping_address_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"billing_address_id": {
|
||||||
|
"name": "billing_address_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -312,20 +310,42 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_region_id",
|
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
"region_id"
|
"shipping_address_id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"keyName": "cart_shipping_address_id_unique",
|
||||||
|
"primary": false,
|
||||||
|
"unique": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columnNames": [
|
||||||
|
"billing_address_id"
|
||||||
|
],
|
||||||
|
"composite": false,
|
||||||
|
"keyName": "cart_billing_address_id_unique",
|
||||||
|
"primary": false,
|
||||||
|
"unique": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_deleted_at\" ON \"cart\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_region_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_region_id\" ON \"cart\" (region_id) WHERE deleted_at IS NULL AND region_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_region_id\" ON \"cart\" (region_id) WHERE deleted_at IS NULL AND region_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_customer_id",
|
"keyName": "IDX_cart_customer_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"customer_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -333,9 +353,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_sales_channel_id",
|
"keyName": "IDX_cart_sales_channel_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"sales_channel_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -343,9 +361,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_curency_code",
|
"keyName": "IDX_cart_curency_code",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"currency_code"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -353,9 +369,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_shipping_address_id",
|
"keyName": "IDX_cart_shipping_address_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"shipping_address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -363,24 +377,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_billing_address_id",
|
"keyName": "IDX_cart_billing_address_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"billing_address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_billing_address_id\" ON \"cart\" (billing_address_id) WHERE deleted_at IS NULL AND billing_address_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_billing_address_id\" ON \"cart\" (billing_address_id) WHERE deleted_at IS NULL AND billing_address_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"keyName": "IDX_cart_deleted_at",
|
|
||||||
"columnNames": [
|
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"primary": false,
|
|
||||||
"unique": false,
|
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_deleted_at\" ON \"cart\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "cart_pkey",
|
"keyName": "cart_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
@@ -432,15 +434,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "text"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"cart_id": {
|
|
||||||
"name": "cart_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"title": {
|
"title": {
|
||||||
"name": "title",
|
"name": "title",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -601,6 +594,7 @@
|
|||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
|
"default": "true",
|
||||||
"mappedType": "boolean"
|
"mappedType": "boolean"
|
||||||
},
|
},
|
||||||
"is_discountable": {
|
"is_discountable": {
|
||||||
@@ -610,6 +604,7 @@
|
|||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
|
"default": "true",
|
||||||
"mappedType": "boolean"
|
"mappedType": "boolean"
|
||||||
},
|
},
|
||||||
"is_tax_inclusive": {
|
"is_tax_inclusive": {
|
||||||
@@ -619,6 +614,7 @@
|
|||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
|
"default": "false",
|
||||||
"mappedType": "boolean"
|
"mappedType": "boolean"
|
||||||
},
|
},
|
||||||
"compare_at_unit_price": {
|
"compare_at_unit_price": {
|
||||||
@@ -630,15 +626,6 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
"raw_compare_at_unit_price": {
|
|
||||||
"name": "raw_compare_at_unit_price",
|
|
||||||
"type": "jsonb",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "json"
|
|
||||||
},
|
|
||||||
"unit_price": {
|
"unit_price": {
|
||||||
"name": "unit_price",
|
"name": "unit_price",
|
||||||
"type": "numeric",
|
"type": "numeric",
|
||||||
@@ -648,15 +635,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
"raw_unit_price": {
|
|
||||||
"name": "raw_unit_price",
|
|
||||||
"type": "jsonb",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "json"
|
|
||||||
},
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "jsonb",
|
"type": "jsonb",
|
||||||
@@ -666,6 +644,33 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"cart_id": {
|
||||||
|
"name": "cart_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"raw_compare_at_unit_price": {
|
||||||
|
"name": "raw_compare_at_unit_price",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
|
"raw_unit_price": {
|
||||||
|
"name": "raw_unit_price",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -702,11 +707,25 @@
|
|||||||
"name": "cart_line_item",
|
"name": "cart_line_item",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_line_item_cart_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_cart_id\" ON \"cart_line_item\" (cart_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_line_item_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_deleted_at\" ON \"cart_line_item\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_cart_id",
|
"keyName": "IDX_line_item_cart_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"cart_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -714,9 +733,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_variant_id",
|
"keyName": "IDX_line_item_variant_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"variant_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -724,9 +741,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_product_id",
|
"keyName": "IDX_line_item_product_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"product_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -734,24 +749,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_product_type_id",
|
"keyName": "IDX_line_item_product_type_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"product_type_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"cart_line_item\" (product_type_id) WHERE deleted_at IS NULL AND product_type_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"cart_line_item\" (product_type_id) WHERE deleted_at IS NULL AND product_type_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"keyName": "IDX_cart_line_item_deleted_at",
|
|
||||||
"columnNames": [
|
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"primary": false,
|
|
||||||
"unique": false,
|
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_deleted_at\" ON \"cart_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "cart_line_item_pkey",
|
"keyName": "cart_line_item_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
@@ -774,6 +777,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"referencedTableName": "public.cart",
|
"referencedTableName": "public.cart",
|
||||||
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -816,17 +820,17 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
"raw_amount": {
|
"provider_id": {
|
||||||
"name": "raw_amount",
|
"name": "provider_id",
|
||||||
"type": "jsonb",
|
"type": "text",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"promotion_id": {
|
||||||
"name": "provider_id",
|
"name": "promotion_id",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
@@ -843,6 +847,24 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"item_id": {
|
||||||
|
"name": "item_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"raw_amount": {
|
||||||
|
"name": "raw_amount",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -865,24 +887,6 @@
|
|||||||
"default": "now()",
|
"default": "now()",
|
||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
},
|
},
|
||||||
"item_id": {
|
|
||||||
"name": "item_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"promotion_id": {
|
|
||||||
"name": "promotion_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"deleted_at": {
|
"deleted_at": {
|
||||||
"name": "deleted_at",
|
"name": "deleted_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -898,34 +902,36 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"keyName": "IDX_adjustment_item_id",
|
"keyName": "IDX_cart_line_item_adjustment_item_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"item_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_adjustment_item_id\" ON \"cart_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_adjustment_item_id\" ON \"cart_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_line_item_adjustment_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_adjustment_deleted_at\" ON \"cart_line_item_adjustment\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_adjustment_promotion_id",
|
"keyName": "IDX_line_item_adjustment_promotion_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"promotion_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_adjustment_promotion_id\" ON \"cart_line_item_adjustment\" (promotion_id) WHERE deleted_at IS NULL AND promotion_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_adjustment_promotion_id\" ON \"cart_line_item_adjustment\" (promotion_id) WHERE deleted_at IS NULL AND promotion_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_line_item_adjustment_deleted_at",
|
"keyName": "IDX_adjustment_item_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_adjustment_deleted_at\" ON \"cart_line_item_adjustment\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_adjustment_item_id\" ON \"cart_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "cart_line_item_adjustment_pkey",
|
"keyName": "cart_line_item_adjustment_pkey",
|
||||||
@@ -955,6 +961,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"referencedTableName": "public.cart_line_item",
|
"referencedTableName": "public.cart_line_item",
|
||||||
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -990,12 +997,12 @@
|
|||||||
},
|
},
|
||||||
"rate": {
|
"rate": {
|
||||||
"name": "rate",
|
"name": "rate",
|
||||||
"type": "numeric",
|
"type": "integer",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "integer"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
"name": "provider_id",
|
"name": "provider_id",
|
||||||
@@ -1015,6 +1022,24 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"tax_rate_id": {
|
||||||
|
"name": "tax_rate_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"item_id": {
|
||||||
|
"name": "item_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1037,24 +1062,6 @@
|
|||||||
"default": "now()",
|
"default": "now()",
|
||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
},
|
},
|
||||||
"item_id": {
|
|
||||||
"name": "item_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"tax_rate_id": {
|
|
||||||
"name": "tax_rate_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"deleted_at": {
|
"deleted_at": {
|
||||||
"name": "deleted_at",
|
"name": "deleted_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1070,34 +1077,36 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"keyName": "IDX_tax_line_item_id",
|
"keyName": "IDX_cart_line_item_tax_line_item_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"item_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_tax_line_item_id\" ON \"cart_line_item_tax_line\" (item_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_tax_line_item_id\" ON \"cart_line_item_tax_line\" (item_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_line_item_tax_line_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_tax_line_deleted_at\" ON \"cart_line_item_tax_line\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_line_item_tax_line_tax_rate_id",
|
"keyName": "IDX_line_item_tax_line_tax_rate_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"tax_rate_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_tax_line_tax_rate_id\" ON \"cart_line_item_tax_line\" (tax_rate_id) WHERE deleted_at IS NULL AND tax_rate_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_tax_line_tax_rate_id\" ON \"cart_line_item_tax_line\" (tax_rate_id) WHERE deleted_at IS NULL AND tax_rate_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_line_item_tax_line_deleted_at",
|
"keyName": "IDX_tax_line_item_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_line_item_tax_line_deleted_at\" ON \"cart_line_item_tax_line\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_tax_line_item_id\" ON \"cart_line_item_tax_line\" (item_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "cart_line_item_tax_line_pkey",
|
"keyName": "cart_line_item_tax_line_pkey",
|
||||||
@@ -1121,6 +1130,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"referencedTableName": "public.cart_line_item",
|
"referencedTableName": "public.cart_line_item",
|
||||||
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1136,15 +1146,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "text"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"cart_id": {
|
|
||||||
"name": "cart_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1172,15 +1173,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
"raw_amount": {
|
|
||||||
"name": "raw_amount",
|
|
||||||
"type": "jsonb",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "json"
|
|
||||||
},
|
|
||||||
"is_tax_inclusive": {
|
"is_tax_inclusive": {
|
||||||
"name": "is_tax_inclusive",
|
"name": "is_tax_inclusive",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@@ -1218,6 +1210,24 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"cart_id": {
|
||||||
|
"name": "cart_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"raw_amount": {
|
||||||
|
"name": "raw_amount",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1254,11 +1264,25 @@
|
|||||||
"name": "cart_shipping_method",
|
"name": "cart_shipping_method",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_shipping_method_cart_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_cart_id\" ON \"cart_shipping_method\" (cart_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_shipping_method_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_deleted_at\" ON \"cart_shipping_method\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_method_cart_id",
|
"keyName": "IDX_shipping_method_cart_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"cart_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -1266,24 +1290,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_method_option_id",
|
"keyName": "IDX_shipping_method_option_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"shipping_option_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_option_id\" ON \"cart_shipping_method\" (shipping_option_id) WHERE deleted_at IS NULL AND shipping_option_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_option_id\" ON \"cart_shipping_method\" (shipping_option_id) WHERE deleted_at IS NULL AND shipping_option_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"keyName": "IDX_cart_shipping_method_deleted_at",
|
|
||||||
"columnNames": [
|
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"primary": false,
|
|
||||||
"unique": false,
|
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_deleted_at\" ON \"cart_shipping_method\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "cart_shipping_method_pkey",
|
"keyName": "cart_shipping_method_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
@@ -1312,6 +1324,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"referencedTableName": "public.cart",
|
"referencedTableName": "public.cart",
|
||||||
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1354,15 +1367,6 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
"raw_amount": {
|
|
||||||
"name": "raw_amount",
|
|
||||||
"type": "jsonb",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "json"
|
|
||||||
},
|
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
"name": "provider_id",
|
"name": "provider_id",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1381,6 +1385,33 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"promotion_id": {
|
||||||
|
"name": "promotion_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"shipping_method_id": {
|
||||||
|
"name": "shipping_method_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
|
"raw_amount": {
|
||||||
|
"name": "raw_amount",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1403,24 +1434,6 @@
|
|||||||
"default": "now()",
|
"default": "now()",
|
||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
},
|
},
|
||||||
"shipping_method_id": {
|
|
||||||
"name": "shipping_method_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"promotion_id": {
|
|
||||||
"name": "promotion_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"deleted_at": {
|
"deleted_at": {
|
||||||
"name": "deleted_at",
|
"name": "deleted_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1436,34 +1449,36 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"keyName": "IDX_adjustment_shipping_method_id",
|
"keyName": "IDX_cart_shipping_method_adjustment_shipping_method_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"shipping_method_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_adjustment_shipping_method_id\" ON \"cart_shipping_method_adjustment\" (shipping_method_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_adjustment_shipping_method_id\" ON \"cart_shipping_method_adjustment\" (shipping_method_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_shipping_method_adjustment_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_adjustment_deleted_at\" ON \"cart_shipping_method_adjustment\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_method_adjustment_promotion_id",
|
"keyName": "IDX_shipping_method_adjustment_promotion_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"promotion_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_adjustment_promotion_id\" ON \"cart_shipping_method_adjustment\" (promotion_id) WHERE deleted_at IS NULL AND promotion_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_adjustment_promotion_id\" ON \"cart_shipping_method_adjustment\" (promotion_id) WHERE deleted_at IS NULL AND promotion_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_shipping_method_adjustment_deleted_at",
|
"keyName": "IDX_adjustment_shipping_method_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_adjustment_deleted_at\" ON \"cart_shipping_method_adjustment\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_adjustment_shipping_method_id\" ON \"cart_shipping_method_adjustment\" (shipping_method_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "cart_shipping_method_adjustment_pkey",
|
"keyName": "cart_shipping_method_adjustment_pkey",
|
||||||
@@ -1522,12 +1537,12 @@
|
|||||||
},
|
},
|
||||||
"rate": {
|
"rate": {
|
||||||
"name": "rate",
|
"name": "rate",
|
||||||
"type": "numeric",
|
"type": "integer",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "decimal"
|
"mappedType": "integer"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
"name": "provider_id",
|
"name": "provider_id",
|
||||||
@@ -1538,6 +1553,15 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "text"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
|
"tax_rate_id": {
|
||||||
|
"name": "tax_rate_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "metadata",
|
"name": "metadata",
|
||||||
"type": "jsonb",
|
"type": "jsonb",
|
||||||
@@ -1547,6 +1571,15 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "json"
|
"mappedType": "json"
|
||||||
},
|
},
|
||||||
|
"shipping_method_id": {
|
||||||
|
"name": "shipping_method_id",
|
||||||
|
"type": "text",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": false,
|
||||||
|
"mappedType": "text"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1569,24 +1602,6 @@
|
|||||||
"default": "now()",
|
"default": "now()",
|
||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
},
|
},
|
||||||
"shipping_method_id": {
|
|
||||||
"name": "shipping_method_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"tax_rate_id": {
|
|
||||||
"name": "tax_rate_id",
|
|
||||||
"type": "text",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": true,
|
|
||||||
"mappedType": "text"
|
|
||||||
},
|
|
||||||
"deleted_at": {
|
"deleted_at": {
|
||||||
"name": "deleted_at",
|
"name": "deleted_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -1601,11 +1616,25 @@
|
|||||||
"name": "cart_shipping_method_tax_line",
|
"name": "cart_shipping_method_tax_line",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_shipping_method_tax_line_shipping_method_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_tax_line_shipping_method_id\" ON \"cart_shipping_method_tax_line\" (shipping_method_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_cart_shipping_method_tax_line_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_tax_line_deleted_at\" ON \"cart_shipping_method_tax_line\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_tax_line_shipping_method_id",
|
"keyName": "IDX_tax_line_shipping_method_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"shipping_method_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
@@ -1613,24 +1642,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_method_tax_line_tax_rate_id",
|
"keyName": "IDX_shipping_method_tax_line_tax_rate_id",
|
||||||
"columnNames": [
|
"columnNames": [],
|
||||||
"tax_rate_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_tax_line_tax_rate_id\" ON \"cart_shipping_method_tax_line\" (tax_rate_id) WHERE deleted_at IS NULL AND tax_rate_id IS NOT NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_method_tax_line_tax_rate_id\" ON \"cart_shipping_method_tax_line\" (tax_rate_id) WHERE deleted_at IS NULL AND tax_rate_id IS NOT NULL"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"keyName": "IDX_cart_shipping_method_tax_line_deleted_at",
|
|
||||||
"columnNames": [
|
|
||||||
"deleted_at"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"primary": false,
|
|
||||||
"unique": false,
|
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_cart_shipping_method_tax_line_deleted_at\" ON \"cart_shipping_method_tax_line\" (deleted_at) WHERE deleted_at IS NOT NULL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "cart_shipping_method_tax_line_pkey",
|
"keyName": "cart_shipping_method_tax_line_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20241205095237 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" drop constraint if exists "cart_line_item_cart_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_adjustment" drop constraint if exists "cart_line_item_adjustment_item_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" drop constraint if exists "cart_line_item_tax_line_item_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method" drop constraint if exists "cart_shipping_method_cart_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "requires_shipping" type boolean using ("requires_shipping"::boolean);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "requires_shipping" set default true;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_discountable" type boolean using ("is_discountable"::boolean);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_discountable" set default true;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_tax_inclusive" type boolean using ("is_tax_inclusive"::boolean);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_tax_inclusive" set default false;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" add constraint "cart_line_item_cart_id_foreign" foreign key ("cart_id") references "cart" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_line_item_cart_id" ON "cart_line_item" (cart_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_adjustment" add constraint "cart_line_item_adjustment_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_line_item_adjustment_item_id" ON "cart_line_item_adjustment" (item_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" alter column "rate" type integer using ("rate"::integer);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" add constraint "cart_line_item_tax_line_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_line_item_tax_line_item_id" ON "cart_line_item_tax_line" (item_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method" add constraint "cart_shipping_method_cart_id_foreign" foreign key ("cart_id") references "cart" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_shipping_method_cart_id" ON "cart_shipping_method" (cart_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_shipping_method_adjustment_shipping_method_id" ON "cart_shipping_method_adjustment" (shipping_method_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method_tax_line" alter column "rate" type integer using ("rate"::integer);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_cart_shipping_method_tax_line_shipping_method_id" ON "cart_shipping_method_tax_line" (shipping_method_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" drop constraint if exists "cart_line_item_cart_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_adjustment" drop constraint if exists "cart_line_item_adjustment_item_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" drop constraint if exists "cart_line_item_tax_line_item_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method" drop constraint if exists "cart_shipping_method_cart_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_tax_inclusive" drop default;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" alter column "is_tax_inclusive" type boolean using ("is_tax_inclusive"::boolean);'
|
||||||
|
)
|
||||||
|
this.addSql('drop index if exists "IDX_cart_line_item_cart_id";')
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item" add constraint "cart_line_item_cart_id_foreign" foreign key ("cart_id") references "cart" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_cart_line_item_adjustment_item_id";')
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_adjustment" add constraint "cart_line_item_adjustment_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" alter column "rate" type numeric using ("rate"::numeric);'
|
||||||
|
)
|
||||||
|
this.addSql('drop index if exists "IDX_cart_line_item_tax_line_item_id";')
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_line_item_tax_line" add constraint "cart_line_item_tax_line_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_cart_shipping_method_cart_id";')
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method" add constraint "cart_shipping_method_cart_id_foreign" foreign key ("cart_id") references "cart" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'drop index if exists "IDX_cart_shipping_method_adjustment_shipping_method_id";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart_shipping_method_tax_line" alter column "rate" type numeric using ("rate"::numeric);'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'drop index if exists "IDX_cart_shipping_method_tax_line_shipping_method_id";'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,97 +1,22 @@
|
|||||||
import { DAL } from "@medusajs/framework/types"
|
import { model } from "@medusajs/framework/utils"
|
||||||
import {
|
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
OnInit,
|
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
|
||||||
Property,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
|
|
||||||
type OptionalAddressProps = DAL.SoftDeletableModelDateColumns
|
const Address = model.define(
|
||||||
|
{ tableName: "cart_address", name: "Address" },
|
||||||
const PgIndex = createPsqlIndexStatementHelper({
|
{
|
||||||
tableName: "cart_address",
|
id: model.id({ prefix: "caaddr" }).primaryKey(),
|
||||||
columns: "deleted_at",
|
customer_id: model.text().nullable(),
|
||||||
where: "deleted_at IS NOT NULL",
|
company: model.text().nullable(),
|
||||||
})
|
first_name: model.text().nullable(),
|
||||||
|
last_name: model.text().nullable(),
|
||||||
@Entity({ tableName: "cart_address" })
|
address_1: model.text().nullable(),
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
address_2: model.text().nullable(),
|
||||||
export default class Address {
|
city: model.text().nullable(),
|
||||||
[OptionalProps]: OptionalAddressProps
|
country_code: model.text().nullable(),
|
||||||
|
province: model.text().nullable(),
|
||||||
@PrimaryKey({ columnType: "text" })
|
postal_code: model.text().nullable(),
|
||||||
id!: string
|
phone: model.text().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
customer_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
company: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
first_name: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
last_name: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
address_1: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
address_2: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
city: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
country_code: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
province: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
postal_code: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
phone: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
@PgIndex.MikroORMIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "caaddr")
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@OnInit()
|
export default Address
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "caaddr")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { DAL } from "@medusajs/framework/types"
|
|
||||||
import { BigNumber, MikroOrmBigNumberProperty } from "@medusajs/framework/utils"
|
|
||||||
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
|
|
||||||
|
|
||||||
type OptionalAdjustmentLineProps = DAL.SoftDeletableModelDateColumns
|
|
||||||
|
|
||||||
/**
|
|
||||||
* As per the Mikro ORM docs, superclasses should use the abstract class definition
|
|
||||||
* Source: https://mikro-orm.io/docs/inheritance-mapping
|
|
||||||
*/
|
|
||||||
export default abstract class AdjustmentLine {
|
|
||||||
[OptionalProps]: OptionalAdjustmentLineProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
|
||||||
id: string
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
description: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
code: string | null = null
|
|
||||||
|
|
||||||
@MikroOrmBigNumberProperty()
|
|
||||||
amount: BigNumber | number
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb" })
|
|
||||||
raw_amount: Record<string, unknown>
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
provider_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
@@ -1,181 +1,76 @@
|
|||||||
import { DAL } from "@medusajs/framework/types"
|
import { model } from "@medusajs/framework/utils"
|
||||||
import {
|
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Cascade,
|
|
||||||
Collection,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OneToMany,
|
|
||||||
OnInit,
|
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import Address from "./address"
|
import Address from "./address"
|
||||||
import LineItem from "./line-item"
|
import LineItem from "./line-item"
|
||||||
import ShippingMethod from "./shipping-method"
|
import ShippingMethod from "./shipping-method"
|
||||||
|
|
||||||
type OptionalCartProps =
|
const Cart = model
|
||||||
| "shipping_address"
|
.define("Cart", {
|
||||||
| "billing_address"
|
id: model.id({ prefix: "cart" }).primaryKey(),
|
||||||
| DAL.SoftDeletableModelDateColumns
|
region_id: model.text().nullable(),
|
||||||
|
customer_id: model.text().nullable(),
|
||||||
const RegionIdIndex = createPsqlIndexStatementHelper({
|
sales_channel_id: model.text().nullable(),
|
||||||
name: "IDX_cart_region_id",
|
email: model.text().nullable(),
|
||||||
tableName: "cart",
|
currency_code: model.text(),
|
||||||
columns: "region_id",
|
metadata: model.json().nullable(),
|
||||||
where: "deleted_at IS NULL AND region_id IS NOT NULL",
|
completed_at: model.dateTime().nullable(),
|
||||||
}).MikroORMIndex
|
shipping_address: model
|
||||||
|
.hasOne(() => Address, {
|
||||||
const CustomerIdIndex = createPsqlIndexStatementHelper({
|
mappedBy: undefined,
|
||||||
name: "IDX_cart_customer_id",
|
foreignKey: true,
|
||||||
tableName: "cart",
|
})
|
||||||
columns: "customer_id",
|
.nullable(),
|
||||||
where: "deleted_at IS NULL AND customer_id IS NOT NULL",
|
billing_address: model
|
||||||
}).MikroORMIndex
|
.hasOne(() => Address, {
|
||||||
|
mappedBy: undefined,
|
||||||
const SalesChannelIdIndex = createPsqlIndexStatementHelper({
|
foreignKey: true,
|
||||||
name: "IDX_cart_sales_channel_id",
|
})
|
||||||
tableName: "cart",
|
.nullable(),
|
||||||
columns: "sales_channel_id",
|
items: model.hasMany(() => LineItem, {
|
||||||
where: "deleted_at IS NULL AND sales_channel_id IS NOT NULL",
|
mappedBy: "cart",
|
||||||
}).MikroORMIndex
|
}),
|
||||||
|
shipping_methods: model.hasMany(() => ShippingMethod, {
|
||||||
const CurrencyCodeIndex = createPsqlIndexStatementHelper({
|
mappedBy: "cart",
|
||||||
name: "IDX_cart_curency_code",
|
}),
|
||||||
tableName: "cart",
|
|
||||||
columns: "currency_code",
|
|
||||||
where: "deleted_at IS NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const ShippingAddressIdIndex = createPsqlIndexStatementHelper({
|
|
||||||
name: "IDX_cart_shipping_address_id",
|
|
||||||
tableName: "cart",
|
|
||||||
columns: "shipping_address_id",
|
|
||||||
where: "deleted_at IS NULL AND shipping_address_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const BillingAddressIdIndex = createPsqlIndexStatementHelper({
|
|
||||||
name: "IDX_cart_billing_address_id",
|
|
||||||
tableName: "cart",
|
|
||||||
columns: "billing_address_id",
|
|
||||||
where: "deleted_at IS NULL AND billing_address_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart" })
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class Cart {
|
|
||||||
[OptionalProps]?: OptionalCartProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
|
||||||
id: string
|
|
||||||
|
|
||||||
@RegionIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
region_id: string | null = null
|
|
||||||
|
|
||||||
@CustomerIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
customer_id: string | null = null
|
|
||||||
|
|
||||||
@SalesChannelIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
sales_channel_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
email: string | null = null
|
|
||||||
|
|
||||||
@CurrencyCodeIndex()
|
|
||||||
@Property({ columnType: "text" })
|
|
||||||
currency_code: string
|
|
||||||
|
|
||||||
@ShippingAddressIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => Address,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "shipping_address_id",
|
|
||||||
mapToPk: true,
|
|
||||||
nullable: true,
|
|
||||||
})
|
})
|
||||||
shipping_address_id: string | null
|
.cascades({
|
||||||
|
delete: [
|
||||||
@ManyToOne(() => Address, {
|
"items",
|
||||||
cascade: [Cascade.PERSIST],
|
"shipping_methods",
|
||||||
nullable: true,
|
"shipping_address",
|
||||||
|
"billing_address",
|
||||||
|
],
|
||||||
})
|
})
|
||||||
shipping_address: Rel<Address> | null
|
.indexes([
|
||||||
|
{
|
||||||
|
name: "IDX_cart_region_id",
|
||||||
|
on: ["region_id"],
|
||||||
|
where: "deleted_at IS NULL AND region_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_cart_customer_id",
|
||||||
|
on: ["customer_id"],
|
||||||
|
where: "deleted_at IS NULL AND customer_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_cart_sales_channel_id",
|
||||||
|
on: ["sales_channel_id"],
|
||||||
|
where: "deleted_at IS NULL AND sales_channel_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_cart_curency_code",
|
||||||
|
on: ["currency_code"],
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_cart_shipping_address_id",
|
||||||
|
on: ["shipping_address_id"],
|
||||||
|
where: "deleted_at IS NULL AND shipping_address_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_cart_billing_address_id",
|
||||||
|
on: ["billing_address_id"],
|
||||||
|
where: "deleted_at IS NULL AND billing_address_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
@BillingAddressIdIndex()
|
export default Cart
|
||||||
@ManyToOne({
|
|
||||||
entity: () => Address,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "billing_address_id",
|
|
||||||
mapToPk: true,
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
billing_address_id: string | null
|
|
||||||
|
|
||||||
@ManyToOne(() => Address, {
|
|
||||||
cascade: [Cascade.PERSIST],
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
billing_address: Rel<Address> | null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@OneToMany(() => LineItem, (lineItem) => lineItem.cart, {
|
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
|
||||||
})
|
|
||||||
items = new Collection<Rel<LineItem>>(this)
|
|
||||||
|
|
||||||
@OneToMany(() => ShippingMethod, (shippingMethod) => shippingMethod.cart, {
|
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
|
||||||
})
|
|
||||||
shipping_methods = new Collection<Rel<ShippingMethod>>(this)
|
|
||||||
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
completed_at: Date | null = null
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "cart")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "cart")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +1,34 @@
|
|||||||
import {
|
import { model } from "@medusajs/framework/utils"
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Check,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OnInit,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import AdjustmentLine from "./adjustment-line"
|
|
||||||
import LineItem from "./line-item"
|
import LineItem from "./line-item"
|
||||||
|
|
||||||
const LineItemIdIndex = createPsqlIndexStatementHelper({
|
const LineItemAdjustment = model
|
||||||
name: "IDX_adjustment_item_id",
|
.define(
|
||||||
tableName: "cart_line_item_adjustment",
|
{ name: "LineItemAdjustment", tableName: "cart_line_item_adjustment" },
|
||||||
columns: "item_id",
|
{
|
||||||
where: "deleted_at IS NULL",
|
id: model.id({ prefix: "caliadj" }).primaryKey(),
|
||||||
}).MikroORMIndex
|
description: model.text().nullable(),
|
||||||
|
code: model.text().nullable(),
|
||||||
|
amount: model.bigNumber(),
|
||||||
|
provider_id: model.text().nullable(),
|
||||||
|
promotion_id: model.text().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
|
item: model.belongsTo(() => LineItem, {
|
||||||
|
mappedBy: "adjustments",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.indexes([
|
||||||
|
{
|
||||||
|
name: "IDX_line_item_adjustment_promotion_id",
|
||||||
|
on: ["promotion_id"],
|
||||||
|
where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_adjustment_item_id",
|
||||||
|
on: ["item_id"],
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.checks([(columns) => `${columns.amount} >= 0`])
|
||||||
|
|
||||||
const PromotionIdIndex = createPsqlIndexStatementHelper({
|
export default LineItemAdjustment
|
||||||
name: "IDX_line_item_adjustment_promotion_id",
|
|
||||||
tableName: "cart_line_item_adjustment",
|
|
||||||
columns: "promotion_id",
|
|
||||||
where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart_line_item_adjustment",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart_line_item_adjustment" })
|
|
||||||
@Check<LineItemAdjustment>({
|
|
||||||
expression: (columns) => `${columns.amount} >= 0`,
|
|
||||||
})
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class LineItemAdjustment extends AdjustmentLine {
|
|
||||||
@ManyToOne({ entity: () => LineItem, persist: false })
|
|
||||||
item: Rel<LineItem>
|
|
||||||
|
|
||||||
@LineItemIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => LineItem,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "item_id",
|
|
||||||
mapToPk: true,
|
|
||||||
})
|
|
||||||
item_id: string
|
|
||||||
|
|
||||||
@PromotionIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
promotion_id: string | null = null
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "caliadj")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "caliadj")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +1,36 @@
|
|||||||
import {
|
import { model } from "@medusajs/framework/utils"
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OnInit,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import LineItem from "./line-item"
|
import LineItem from "./line-item"
|
||||||
import TaxLine from "./tax-line"
|
|
||||||
|
|
||||||
const LineItemIdIndex = createPsqlIndexStatementHelper({
|
const LineItemTaxLine = model
|
||||||
name: "IDX_tax_line_item_id",
|
.define(
|
||||||
tableName: "cart_line_item_tax_line",
|
{
|
||||||
columns: "item_id",
|
name: "LineItemTaxLine",
|
||||||
where: "deleted_at IS NULL",
|
tableName: "cart_line_item_tax_line",
|
||||||
}).MikroORMIndex
|
},
|
||||||
|
{
|
||||||
|
id: model.id({ prefix: "calitxl" }).primaryKey(),
|
||||||
|
description: model.text().nullable(),
|
||||||
|
code: model.text(),
|
||||||
|
rate: model.number(),
|
||||||
|
provider_id: model.text().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
|
tax_rate_id: model.text().nullable(),
|
||||||
|
item: model.belongsTo(() => LineItem, {
|
||||||
|
mappedBy: "tax_lines",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.indexes([
|
||||||
|
{
|
||||||
|
name: "IDX_line_item_tax_line_tax_rate_id",
|
||||||
|
on: ["tax_rate_id"],
|
||||||
|
where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_tax_line_item_id",
|
||||||
|
on: ["item_id"],
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const TaxRateIdIndex = createPsqlIndexStatementHelper({
|
export default LineItemTaxLine
|
||||||
name: "IDX_line_item_tax_line_tax_rate_id",
|
|
||||||
tableName: "cart_line_item_tax_line",
|
|
||||||
columns: "tax_rate_id",
|
|
||||||
where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart_line_item_tax_line",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart_line_item_tax_line" })
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class LineItemTaxLine extends TaxLine {
|
|
||||||
@ManyToOne({ entity: () => LineItem, persist: false })
|
|
||||||
item: Rel<LineItem>
|
|
||||||
|
|
||||||
@LineItemIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => LineItem,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "item_id",
|
|
||||||
mapToPk: true,
|
|
||||||
})
|
|
||||||
item_id: string
|
|
||||||
|
|
||||||
@TaxRateIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
tax_rate_id: string | null = null
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "calitxl")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "calitxl")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,205 +1,71 @@
|
|||||||
import { BigNumberRawValue, DAL } from "@medusajs/framework/types"
|
import { model } from "@medusajs/framework/utils"
|
||||||
import {
|
|
||||||
BigNumber,
|
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
MikroOrmBigNumberProperty,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Cascade,
|
|
||||||
Collection,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OneToMany,
|
|
||||||
OnInit,
|
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import Cart from "./cart"
|
import Cart from "./cart"
|
||||||
import LineItemAdjustment from "./line-item-adjustment"
|
|
||||||
import LineItemTaxLine from "./line-item-tax-line"
|
import LineItemTaxLine from "./line-item-tax-line"
|
||||||
|
import LineItemAdjustment from "./line-item-adjustment"
|
||||||
|
|
||||||
type OptionalLineItemProps =
|
const LineItem = model
|
||||||
| "is_discoutable"
|
.define(
|
||||||
| "is_tax_inclusive"
|
{ name: "LineItem", tableName: "cart_line_item" },
|
||||||
| "compare_at_unit_price"
|
{
|
||||||
| "requires_shipping"
|
id: model.id({ prefix: "cali" }).primaryKey(),
|
||||||
| "cart"
|
title: model.text(),
|
||||||
| DAL.SoftDeletableModelDateColumns
|
subtitle: model.text().nullable(),
|
||||||
|
thumbnail: model.text().nullable(),
|
||||||
const CartIdIndex = createPsqlIndexStatementHelper({
|
quantity: model.number(),
|
||||||
name: "IDX_line_item_cart_id",
|
variant_id: model.text().nullable(),
|
||||||
tableName: "cart_line_item",
|
product_id: model.text().nullable(),
|
||||||
columns: "cart_id",
|
product_title: model.text().nullable(),
|
||||||
where: "deleted_at IS NULL",
|
product_description: model.text().nullable(),
|
||||||
}).MikroORMIndex
|
product_subtitle: model.text().nullable(),
|
||||||
|
product_type: model.text().nullable(),
|
||||||
const VariantIdIndex = createPsqlIndexStatementHelper({
|
product_type_id: model.text().nullable(),
|
||||||
name: "IDX_line_item_variant_id",
|
product_collection: model.text().nullable(),
|
||||||
tableName: "cart_line_item",
|
product_handle: model.text().nullable(),
|
||||||
columns: "variant_id",
|
variant_sku: model.text().nullable(),
|
||||||
where: "deleted_at IS NULL AND variant_id IS NOT NULL",
|
variant_barcode: model.text().nullable(),
|
||||||
}).MikroORMIndex
|
variant_title: model.text().nullable(),
|
||||||
|
variant_option_values: model.json().nullable(),
|
||||||
const ProductIdIndex = createPsqlIndexStatementHelper({
|
requires_shipping: model.boolean().default(true),
|
||||||
name: "IDX_line_item_product_id",
|
is_discountable: model.boolean().default(true),
|
||||||
tableName: "cart_line_item",
|
is_tax_inclusive: model.boolean().default(false),
|
||||||
columns: "product_id",
|
compare_at_unit_price: model.bigNumber().nullable(),
|
||||||
where: "deleted_at IS NULL AND product_id IS NOT NULL",
|
unit_price: model.bigNumber(),
|
||||||
}).MikroORMIndex
|
metadata: model.json().nullable(),
|
||||||
|
adjustments: model.hasMany(() => LineItemAdjustment, {
|
||||||
const ProductTypeIdIndex = createPsqlIndexStatementHelper({
|
mappedBy: "item",
|
||||||
name: "IDX_line_item_product_type_id",
|
}),
|
||||||
tableName: "cart_line_item",
|
tax_lines: model.hasMany(() => LineItemTaxLine, {
|
||||||
columns: "product_type_id",
|
mappedBy: "item",
|
||||||
where: "deleted_at IS NULL AND product_type_id IS NOT NULL",
|
}),
|
||||||
}).MikroORMIndex
|
cart: model.belongsTo(() => Cart, {
|
||||||
|
mappedBy: "items",
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
}),
|
||||||
tableName: "cart_line_item",
|
}
|
||||||
columns: "deleted_at",
|
)
|
||||||
where: "deleted_at IS NOT NULL",
|
.indexes([
|
||||||
}).MikroORMIndex
|
{
|
||||||
|
name: "IDX_line_item_cart_id",
|
||||||
@Entity({ tableName: "cart_line_item" })
|
on: ["cart_id"],
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
where: "deleted_at IS NULL",
|
||||||
export default class LineItem {
|
},
|
||||||
[OptionalProps]?: OptionalLineItemProps
|
{
|
||||||
|
name: "IDX_line_item_variant_id",
|
||||||
@PrimaryKey({ columnType: "text" })
|
on: ["variant_id"],
|
||||||
id: string
|
where: "deleted_at IS NULL AND variant_id IS NOT NULL",
|
||||||
|
},
|
||||||
@CartIdIndex()
|
{
|
||||||
@ManyToOne({
|
name: "IDX_line_item_product_id",
|
||||||
entity: () => Cart,
|
on: ["product_id"],
|
||||||
columnType: "text",
|
where: "deleted_at IS NULL AND product_id IS NOT NULL",
|
||||||
fieldName: "cart_id",
|
},
|
||||||
mapToPk: true,
|
{
|
||||||
|
name: "IDX_line_item_product_type_id",
|
||||||
|
on: ["product_type_id"],
|
||||||
|
where: "deleted_at IS NULL AND product_type_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.cascades({
|
||||||
|
delete: ["adjustments", "tax_lines"],
|
||||||
})
|
})
|
||||||
cart_id: string
|
|
||||||
|
|
||||||
@ManyToOne({ entity: () => Cart, persist: false })
|
export default LineItem
|
||||||
cart: Rel<Cart>
|
|
||||||
|
|
||||||
@Property({ columnType: "text" })
|
|
||||||
title: string
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
subtitle: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
thumbnail: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "integer" })
|
|
||||||
quantity: number
|
|
||||||
|
|
||||||
@VariantIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
variant_id: string | null = null
|
|
||||||
|
|
||||||
@ProductIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_title: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_description: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_subtitle: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_type: string | null = null
|
|
||||||
|
|
||||||
@ProductTypeIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_type_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_collection: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
product_handle: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
variant_sku: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
variant_barcode: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
variant_title: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
variant_option_values: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "boolean" })
|
|
||||||
requires_shipping: boolean = true
|
|
||||||
|
|
||||||
@Property({ columnType: "boolean" })
|
|
||||||
is_discountable: boolean = true
|
|
||||||
|
|
||||||
@Property({ columnType: "boolean" })
|
|
||||||
is_tax_inclusive: boolean = false
|
|
||||||
|
|
||||||
@MikroOrmBigNumberProperty({ nullable: true })
|
|
||||||
compare_at_unit_price?: BigNumber | number | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
raw_compare_at_unit_price: BigNumberRawValue | null = null
|
|
||||||
|
|
||||||
@MikroOrmBigNumberProperty()
|
|
||||||
unit_price: BigNumber | number
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb" })
|
|
||||||
raw_unit_price: BigNumberRawValue
|
|
||||||
|
|
||||||
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
|
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
|
||||||
})
|
|
||||||
tax_lines = new Collection<Rel<LineItemTaxLine>>(this)
|
|
||||||
|
|
||||||
@OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, {
|
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
|
||||||
})
|
|
||||||
adjustments = new Collection<Rel<LineItemAdjustment>>(this)
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "cali")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "cali")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +1,36 @@
|
|||||||
import {
|
import { model } from "@medusajs/framework/utils"
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OnInit,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import AdjustmentLine from "./adjustment-line"
|
|
||||||
import ShippingMethod from "./shipping-method"
|
import ShippingMethod from "./shipping-method"
|
||||||
|
|
||||||
const ShippingMethodIdIndex = createPsqlIndexStatementHelper({
|
const ShippingMethodAdjustment = model
|
||||||
name: "IDX_adjustment_shipping_method_id",
|
.define(
|
||||||
tableName: "cart_shipping_method_adjustment",
|
{
|
||||||
columns: "shipping_method_id",
|
name: "ShippingMethodAdjustment",
|
||||||
where: "deleted_at IS NULL",
|
tableName: "cart_shipping_method_adjustment",
|
||||||
}).MikroORMIndex
|
},
|
||||||
|
{
|
||||||
|
id: model.id({ prefix: "casmadj" }).primaryKey(),
|
||||||
|
description: model.text().nullable(),
|
||||||
|
code: model.text().nullable(),
|
||||||
|
amount: model.bigNumber(),
|
||||||
|
provider_id: model.text().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
|
promotion_id: model.text().nullable(),
|
||||||
|
shipping_method: model.belongsTo(() => ShippingMethod, {
|
||||||
|
mappedBy: "adjustments",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.indexes([
|
||||||
|
{
|
||||||
|
name: "IDX_shipping_method_adjustment_promotion_id",
|
||||||
|
on: ["promotion_id"],
|
||||||
|
where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_adjustment_shipping_method_id",
|
||||||
|
on: ["shipping_method_id"],
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const PromotionIdIndex = createPsqlIndexStatementHelper({
|
export default ShippingMethodAdjustment
|
||||||
name: "IDX_shipping_method_adjustment_promotion_id",
|
|
||||||
tableName: "cart_shipping_method_adjustment",
|
|
||||||
columns: "promotion_id",
|
|
||||||
where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart_shipping_method_adjustment",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart_shipping_method_adjustment" })
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class ShippingMethodAdjustment extends AdjustmentLine {
|
|
||||||
@ManyToOne({ entity: () => ShippingMethod, persist: false })
|
|
||||||
shipping_method: Rel<ShippingMethod>
|
|
||||||
|
|
||||||
@ShippingMethodIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => ShippingMethod,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "shipping_method_id",
|
|
||||||
mapToPk: true,
|
|
||||||
})
|
|
||||||
shipping_method_id: string
|
|
||||||
|
|
||||||
@PromotionIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
promotion_id: string | null = null
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "casmadj")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "casmadj")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +1,36 @@
|
|||||||
import {
|
import { model } from "@medusajs/framework/utils"
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OnInit,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import ShippingMethod from "./shipping-method"
|
import ShippingMethod from "./shipping-method"
|
||||||
import TaxLine from "./tax-line"
|
|
||||||
|
|
||||||
const ShippingMethodIdIndex = createPsqlIndexStatementHelper({
|
const ShippingMethodTaxLine = model
|
||||||
name: "IDX_tax_line_shipping_method_id",
|
.define(
|
||||||
tableName: "cart_shipping_method_tax_line",
|
{
|
||||||
columns: "shipping_method_id",
|
name: "ShippingMethodTaxLine",
|
||||||
where: "deleted_at IS NULL",
|
tableName: "cart_shipping_method_tax_line",
|
||||||
}).MikroORMIndex
|
},
|
||||||
|
{
|
||||||
|
id: model.id({ prefix: "casmtxl" }).primaryKey(),
|
||||||
|
description: model.text().nullable(),
|
||||||
|
code: model.text(),
|
||||||
|
rate: model.number(),
|
||||||
|
provider_id: model.text().nullable(),
|
||||||
|
tax_rate_id: model.text().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
|
shipping_method: model.belongsTo(() => ShippingMethod, {
|
||||||
|
mappedBy: "tax_lines",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.indexes([
|
||||||
|
{
|
||||||
|
name: "IDX_tax_line_shipping_method_id",
|
||||||
|
on: ["shipping_method_id"],
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_shipping_method_tax_line_tax_rate_id",
|
||||||
|
on: ["tax_rate_id"],
|
||||||
|
where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const TaxRateIdIndex = createPsqlIndexStatementHelper({
|
export default ShippingMethodTaxLine
|
||||||
name: "IDX_shipping_method_tax_line_tax_rate_id",
|
|
||||||
tableName: "cart_shipping_method_tax_line",
|
|
||||||
columns: "tax_rate_id",
|
|
||||||
where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart_shipping_method_tax_line",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart_shipping_method_tax_line" })
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class ShippingMethodTaxLine extends TaxLine {
|
|
||||||
@ManyToOne({ entity: () => ShippingMethod, persist: false })
|
|
||||||
shipping_method: Rel<ShippingMethod>
|
|
||||||
|
|
||||||
@ShippingMethodIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => ShippingMethod,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "shipping_method_id",
|
|
||||||
mapToPk: true,
|
|
||||||
})
|
|
||||||
shipping_method_id: string
|
|
||||||
|
|
||||||
@TaxRateIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
tax_rate_id: string | null = null
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "casmtxl")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "casmtxl")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,145 +1,46 @@
|
|||||||
import { BigNumberRawValue, DAL } from "@medusajs/framework/types"
|
import { model } from "@medusajs/framework/utils"
|
||||||
import {
|
|
||||||
BigNumber,
|
|
||||||
createPsqlIndexStatementHelper,
|
|
||||||
DALUtils,
|
|
||||||
generateEntityId,
|
|
||||||
MikroOrmBigNumberProperty,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
|
||||||
BeforeCreate,
|
|
||||||
Cascade,
|
|
||||||
Check,
|
|
||||||
Collection,
|
|
||||||
Entity,
|
|
||||||
Filter,
|
|
||||||
ManyToOne,
|
|
||||||
OneToMany,
|
|
||||||
OnInit,
|
|
||||||
OptionalProps,
|
|
||||||
PrimaryKey,
|
|
||||||
Property,
|
|
||||||
Rel,
|
|
||||||
} from "@mikro-orm/core"
|
|
||||||
import Cart from "./cart"
|
import Cart from "./cart"
|
||||||
import ShippingMethodAdjustment from "./shipping-method-adjustment"
|
import ShippingMethodAdjustment from "./shipping-method-adjustment"
|
||||||
import ShippingMethodTaxLine from "./shipping-method-tax-line"
|
import ShippingMethodTaxLine from "./shipping-method-tax-line"
|
||||||
|
|
||||||
type OptionalShippingMethodProps =
|
const ShippingMethod = model
|
||||||
| "cart"
|
.define(
|
||||||
| "is_tax_inclusive"
|
|
||||||
| DAL.SoftDeletableModelDateColumns
|
|
||||||
|
|
||||||
const CartIdIndex = createPsqlIndexStatementHelper({
|
|
||||||
name: "IDX_shipping_method_cart_id",
|
|
||||||
tableName: "cart_shipping_method",
|
|
||||||
columns: "cart_id",
|
|
||||||
where: "deleted_at IS NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const ShippingOptionIdIndex = createPsqlIndexStatementHelper({
|
|
||||||
name: "IDX_shipping_method_option_id",
|
|
||||||
tableName: "cart_shipping_method",
|
|
||||||
columns: "shipping_option_id",
|
|
||||||
where: "deleted_at IS NULL AND shipping_option_id IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
const DeletedAtIndex = createPsqlIndexStatementHelper({
|
|
||||||
tableName: "cart_shipping_method",
|
|
||||||
columns: "deleted_at",
|
|
||||||
where: "deleted_at IS NOT NULL",
|
|
||||||
}).MikroORMIndex
|
|
||||||
|
|
||||||
@Entity({ tableName: "cart_shipping_method" })
|
|
||||||
@Check<ShippingMethod>({ expression: (columns) => `${columns.amount} >= 0` })
|
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
||||||
export default class ShippingMethod {
|
|
||||||
[OptionalProps]?: OptionalShippingMethodProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
|
||||||
id: string
|
|
||||||
|
|
||||||
@CartIdIndex()
|
|
||||||
@ManyToOne({
|
|
||||||
entity: () => Cart,
|
|
||||||
columnType: "text",
|
|
||||||
fieldName: "cart_id",
|
|
||||||
mapToPk: true,
|
|
||||||
})
|
|
||||||
cart_id: string
|
|
||||||
|
|
||||||
@ManyToOne({ entity: () => Cart, persist: false })
|
|
||||||
cart: Rel<Cart>
|
|
||||||
|
|
||||||
@Property({ columnType: "text" })
|
|
||||||
name: string
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
description: string | null = null
|
|
||||||
|
|
||||||
@MikroOrmBigNumberProperty()
|
|
||||||
amount: BigNumber | number
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb" })
|
|
||||||
raw_amount: BigNumberRawValue
|
|
||||||
|
|
||||||
@Property({ columnType: "boolean" })
|
|
||||||
is_tax_inclusive: boolean = false
|
|
||||||
|
|
||||||
@ShippingOptionIdIndex()
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
shipping_option_id: string | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
data: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => ShippingMethodTaxLine,
|
|
||||||
(taxLine) => taxLine.shipping_method,
|
|
||||||
{
|
{
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
name: "ShippingMethod",
|
||||||
|
tableName: "cart_shipping_method",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: model.id({ prefix: "casm" }).primaryKey(),
|
||||||
|
name: model.text(),
|
||||||
|
description: model.json().nullable(),
|
||||||
|
amount: model.bigNumber(),
|
||||||
|
is_tax_inclusive: model.boolean().default(false),
|
||||||
|
shipping_option_id: model.text().nullable(),
|
||||||
|
data: model.json().nullable(),
|
||||||
|
metadata: model.json().nullable(),
|
||||||
|
cart: model.belongsTo(() => Cart, {
|
||||||
|
mappedBy: "shipping_methods",
|
||||||
|
}),
|
||||||
|
tax_lines: model.hasMany(() => ShippingMethodTaxLine, {
|
||||||
|
mappedBy: "shipping_method",
|
||||||
|
}),
|
||||||
|
adjustments: model.hasMany(() => ShippingMethodAdjustment, {
|
||||||
|
mappedBy: "shipping_method",
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
tax_lines = new Collection<Rel<ShippingMethodTaxLine>>(this)
|
.indexes([
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => ShippingMethodAdjustment,
|
|
||||||
(adjustment) => adjustment.shipping_method,
|
|
||||||
{
|
{
|
||||||
cascade: [Cascade.PERSIST, "soft-remove"] as any,
|
name: "IDX_shipping_method_cart_id",
|
||||||
}
|
on: ["cart_id"],
|
||||||
)
|
where: "deleted_at IS NULL",
|
||||||
adjustments = new Collection<Rel<ShippingMethodAdjustment>>(this)
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_shipping_method_option_id",
|
||||||
|
on: ["shipping_option_id"],
|
||||||
|
where: "deleted_at IS NULL AND shipping_option_id IS NOT NULL",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.checks([(columns) => `${columns.amount} >= 0`])
|
||||||
|
|
||||||
@Property({
|
export default ShippingMethod
|
||||||
onCreate: () => new Date(),
|
|
||||||
columnType: "timestamptz",
|
|
||||||
defaultRaw: "now()",
|
|
||||||
})
|
|
||||||
created_at: Date
|
|
||||||
|
|
||||||
@Property({
|
|
||||||
onCreate: () => new Date(),
|
|
||||||
onUpdate: () => new Date(),
|
|
||||||
columnType: "timestamptz",
|
|
||||||
defaultRaw: "now()",
|
|
||||||
})
|
|
||||||
updated_at: Date
|
|
||||||
|
|
||||||
@DeletedAtIndex()
|
|
||||||
@Property({ columnType: "timestamptz", nullable: true })
|
|
||||||
deleted_at: Date | null = null
|
|
||||||
|
|
||||||
@BeforeCreate()
|
|
||||||
onCreate() {
|
|
||||||
this.id = generateEntityId(this.id, "casm")
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnInit()
|
|
||||||
onInit() {
|
|
||||||
this.id = generateEntityId(this.id, "casm")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import { DAL } from "@medusajs/framework/types"
|
|
||||||
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
|
|
||||||
|
|
||||||
type OptionalTaxLineProps = DAL.SoftDeletableModelDateColumns
|
|
||||||
|
|
||||||
/**
|
|
||||||
* As per the Mikro ORM docs, superclasses should use the abstract class definition
|
|
||||||
* Source: https://mikro-orm.io/docs/inheritance-mapping
|
|
||||||
*/
|
|
||||||
export default abstract class TaxLine {
|
|
||||||
[OptionalProps]?: OptionalTaxLineProps
|
|
||||||
|
|
||||||
@PrimaryKey({ columnType: "text" })
|
|
||||||
id: string
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
description?: string | null
|
|
||||||
|
|
||||||
@Property({ columnType: "text" })
|
|
||||||
code: string
|
|
||||||
|
|
||||||
@Property({ columnType: "numeric", serializer: Number })
|
|
||||||
rate: number
|
|
||||||
|
|
||||||
@Property({ columnType: "text", nullable: true })
|
|
||||||
provider_id?: string | null
|
|
||||||
|
|
||||||
@Property({ columnType: "jsonb", nullable: true })
|
|
||||||
metadata: Record<string, unknown> | null = null
|
|
||||||
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
DAL,
|
DAL,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
ICartModuleService,
|
ICartModuleService,
|
||||||
|
InferEntityType,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/framework/types"
|
} from "@medusajs/framework/types"
|
||||||
@@ -76,14 +77,30 @@ export default class CartModuleService
|
|||||||
implements ICartModuleService
|
implements ICartModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected cartService_: ModulesSdkTypes.IMedusaInternalService<Cart>
|
protected cartService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
protected addressService_: ModulesSdkTypes.IMedusaInternalService<Address>
|
InferEntityType<typeof Cart>
|
||||||
protected lineItemService_: ModulesSdkTypes.IMedusaInternalService<LineItem>
|
>
|
||||||
protected shippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<ShippingMethodAdjustment>
|
protected addressService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
protected shippingMethodService_: ModulesSdkTypes.IMedusaInternalService<ShippingMethod>
|
InferEntityType<typeof Address>
|
||||||
protected lineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<LineItemAdjustment>
|
>
|
||||||
protected lineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService<LineItemTaxLine>
|
protected lineItemService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
protected shippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService<ShippingMethodTaxLine>
|
InferEntityType<typeof LineItem>
|
||||||
|
>
|
||||||
|
protected shippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
|
InferEntityType<typeof ShippingMethodAdjustment>
|
||||||
|
>
|
||||||
|
protected shippingMethodService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
|
InferEntityType<typeof ShippingMethod>
|
||||||
|
>
|
||||||
|
protected lineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
|
InferEntityType<typeof LineItemAdjustment>
|
||||||
|
>
|
||||||
|
protected lineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
|
InferEntityType<typeof LineItemTaxLine>
|
||||||
|
>
|
||||||
|
protected shippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService<
|
||||||
|
InferEntityType<typeof ShippingMethodTaxLine>
|
||||||
|
>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -274,7 +291,7 @@ export default class CartModuleService
|
|||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
) {
|
) {
|
||||||
const lineItemsToCreate: CreateLineItemDTO[] = []
|
const lineItemsToCreate: CreateLineItemDTO[] = []
|
||||||
const createdCarts: Cart[] = []
|
const createdCarts: InferEntityType<typeof Cart>[] = []
|
||||||
for (const { items, ...cart } of data) {
|
for (const { items, ...cart } of data) {
|
||||||
const [created] = await this.cartService_.create([cart], sharedContext)
|
const [created] = await this.cartService_.create([cart], sharedContext)
|
||||||
|
|
||||||
@@ -397,7 +414,7 @@ export default class CartModuleService
|
|||||||
data?: CartTypes.CreateLineItemDTO[] | CartTypes.CreateLineItemDTO,
|
data?: CartTypes.CreateLineItemDTO[] | CartTypes.CreateLineItemDTO,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.CartLineItemDTO[]> {
|
): Promise<CartTypes.CartLineItemDTO[]> {
|
||||||
let items: LineItem[] = []
|
let items: InferEntityType<typeof LineItem>[] = []
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
items = await this.addLineItems_(
|
items = await this.addLineItems_(
|
||||||
cartIdOrData,
|
cartIdOrData,
|
||||||
@@ -422,7 +439,7 @@ export default class CartModuleService
|
|||||||
cartId: string,
|
cartId: string,
|
||||||
items: CartTypes.CreateLineItemDTO[],
|
items: CartTypes.CreateLineItemDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<LineItem[]> {
|
): Promise<InferEntityType<typeof LineItem>[]> {
|
||||||
const cart = await this.retrieveCart(
|
const cart = await this.retrieveCart(
|
||||||
cartId,
|
cartId,
|
||||||
{ select: ["id"] },
|
{ select: ["id"] },
|
||||||
@@ -443,7 +460,7 @@ export default class CartModuleService
|
|||||||
protected async addLineItemsBulk_(
|
protected async addLineItemsBulk_(
|
||||||
data: CreateLineItemDTO[],
|
data: CreateLineItemDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<LineItem[]> {
|
): Promise<InferEntityType<typeof LineItem>[]> {
|
||||||
return await this.lineItemService_.create(data, sharedContext)
|
return await this.lineItemService_.create(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +488,7 @@ export default class CartModuleService
|
|||||||
data?: CartTypes.UpdateLineItemDTO | Partial<CartTypes.UpdateLineItemDTO>,
|
data?: CartTypes.UpdateLineItemDTO | Partial<CartTypes.UpdateLineItemDTO>,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.CartLineItemDTO[] | CartTypes.CartLineItemDTO> {
|
): Promise<CartTypes.CartLineItemDTO[] | CartTypes.CartLineItemDTO> {
|
||||||
let items: LineItem[] = []
|
let items: InferEntityType<typeof LineItem>[] = []
|
||||||
if (isString(lineItemIdOrDataOrSelector)) {
|
if (isString(lineItemIdOrDataOrSelector)) {
|
||||||
const item = await this.updateLineItem_(
|
const item = await this.updateLineItem_(
|
||||||
lineItemIdOrDataOrSelector,
|
lineItemIdOrDataOrSelector,
|
||||||
@@ -511,7 +528,7 @@ export default class CartModuleService
|
|||||||
lineItemId: string,
|
lineItemId: string,
|
||||||
data: Partial<CartTypes.UpdateLineItemDTO>,
|
data: Partial<CartTypes.UpdateLineItemDTO>,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<LineItem> {
|
): Promise<InferEntityType<typeof LineItem>> {
|
||||||
const [item] = await this.lineItemService_.update(
|
const [item] = await this.lineItemService_.update(
|
||||||
[{ id: lineItemId, ...data }],
|
[{ id: lineItemId, ...data }],
|
||||||
sharedContext
|
sharedContext
|
||||||
@@ -524,7 +541,7 @@ export default class CartModuleService
|
|||||||
protected async updateLineItemsWithSelector_(
|
protected async updateLineItemsWithSelector_(
|
||||||
updates: CartTypes.UpdateLineItemWithSelectorDTO[],
|
updates: CartTypes.UpdateLineItemWithSelectorDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<LineItem[]> {
|
): Promise<InferEntityType<typeof LineItem>[]> {
|
||||||
let toUpdate: UpdateLineItemDTO[] = []
|
let toUpdate: UpdateLineItemDTO[] = []
|
||||||
for (const { selector, data } of updates) {
|
for (const { selector, data } of updates) {
|
||||||
const items = await this.listLineItems({ ...selector }, {}, sharedContext)
|
const items = await this.listLineItems({ ...selector }, {}, sharedContext)
|
||||||
@@ -639,7 +656,7 @@ export default class CartModuleService
|
|||||||
): Promise<
|
): Promise<
|
||||||
CartTypes.CartShippingMethodDTO[] | CartTypes.CartShippingMethodDTO
|
CartTypes.CartShippingMethodDTO[] | CartTypes.CartShippingMethodDTO
|
||||||
> {
|
> {
|
||||||
let methods: ShippingMethod[]
|
let methods: InferEntityType<typeof ShippingMethod>[]
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
methods = await this.addShippingMethods_(
|
methods = await this.addShippingMethods_(
|
||||||
cartIdOrData,
|
cartIdOrData,
|
||||||
@@ -664,7 +681,7 @@ export default class CartModuleService
|
|||||||
cartId: string,
|
cartId: string,
|
||||||
data: CartTypes.CreateShippingMethodForSingleCartDTO[],
|
data: CartTypes.CreateShippingMethodForSingleCartDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<ShippingMethod[]> {
|
): Promise<InferEntityType<typeof ShippingMethod>[]> {
|
||||||
const cart = await this.retrieveCart(
|
const cart = await this.retrieveCart(
|
||||||
cartId,
|
cartId,
|
||||||
{ select: ["id"] },
|
{ select: ["id"] },
|
||||||
@@ -685,7 +702,7 @@ export default class CartModuleService
|
|||||||
protected async addShippingMethodsBulk_(
|
protected async addShippingMethodsBulk_(
|
||||||
data: CartTypes.CreateShippingMethodDTO[],
|
data: CartTypes.CreateShippingMethodDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<ShippingMethod[]> {
|
): Promise<InferEntityType<typeof ShippingMethod>[]> {
|
||||||
return await this.shippingMethodService_.create(
|
return await this.shippingMethodService_.create(
|
||||||
data as unknown as CreateShippingMethodDTO[],
|
data as unknown as CreateShippingMethodDTO[],
|
||||||
sharedContext
|
sharedContext
|
||||||
@@ -713,7 +730,7 @@ export default class CartModuleService
|
|||||||
adjustments?: CartTypes.CreateLineItemAdjustmentDTO[],
|
adjustments?: CartTypes.CreateLineItemAdjustmentDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.LineItemAdjustmentDTO[]> {
|
): Promise<CartTypes.LineItemAdjustmentDTO[]> {
|
||||||
let addedAdjustments: LineItemAdjustment[] = []
|
let addedAdjustments: InferEntityType<typeof LineItemAdjustment>[] = []
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
const cart = await this.retrieveCart(
|
const cart = await this.retrieveCart(
|
||||||
cartIdOrData,
|
cartIdOrData,
|
||||||
@@ -888,7 +905,8 @@ export default class CartModuleService
|
|||||||
| CartTypes.ShippingMethodAdjustmentDTO[]
|
| CartTypes.ShippingMethodAdjustmentDTO[]
|
||||||
| CartTypes.ShippingMethodAdjustmentDTO
|
| CartTypes.ShippingMethodAdjustmentDTO
|
||||||
> {
|
> {
|
||||||
let addedAdjustments: ShippingMethodAdjustment[] = []
|
let addedAdjustments: InferEntityType<typeof ShippingMethodAdjustment>[] =
|
||||||
|
[]
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
const cart = await this.retrieveCart(
|
const cart = await this.retrieveCart(
|
||||||
cartIdOrData,
|
cartIdOrData,
|
||||||
@@ -961,7 +979,7 @@ export default class CartModuleService
|
|||||||
| CartTypes.CreateLineItemTaxLineDTO,
|
| CartTypes.CreateLineItemTaxLineDTO,
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<CartTypes.LineItemTaxLineDTO[] | CartTypes.LineItemTaxLineDTO> {
|
): Promise<CartTypes.LineItemTaxLineDTO[] | CartTypes.LineItemTaxLineDTO> {
|
||||||
let addedTaxLines: LineItemTaxLine[]
|
let addedTaxLines: InferEntityType<typeof LineItemTaxLine>[]
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
// existence check
|
// existence check
|
||||||
await this.retrieveCart(cartIdOrData, { select: ["id"] }, sharedContext)
|
await this.retrieveCart(cartIdOrData, { select: ["id"] }, sharedContext)
|
||||||
@@ -1077,7 +1095,7 @@ export default class CartModuleService
|
|||||||
): Promise<
|
): Promise<
|
||||||
CartTypes.ShippingMethodTaxLineDTO[] | CartTypes.ShippingMethodTaxLineDTO
|
CartTypes.ShippingMethodTaxLineDTO[] | CartTypes.ShippingMethodTaxLineDTO
|
||||||
> {
|
> {
|
||||||
let addedTaxLines: ShippingMethodTaxLine[]
|
let addedTaxLines: InferEntityType<typeof ShippingMethodTaxLine>[]
|
||||||
if (isString(cartIdOrData)) {
|
if (isString(cartIdOrData)) {
|
||||||
// existence check
|
// existence check
|
||||||
await this.retrieveCart(cartIdOrData, { select: ["id"] }, sharedContext)
|
await this.retrieveCart(cartIdOrData, { select: ["id"] }, sharedContext)
|
||||||
|
|||||||
Reference in new issue
Block a user