1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { LINKS, Modules } from "@medusajs/framework/utils"
3
4 export const CartPromotion: ModuleJoinerConfig = {
5 serviceName: LINKS.CartPromotion,
6 isLink: true,
7 databaseConfig: {
8 tableName: "cart_promotion",
9 idPrefix: "cartpromo",
10 },
11 alias: [
12 {
13 name: ["cart_promotion", "cart_promotions"],
14 entity: "LinkCartPromotion",
15 },
16 ],
17 primaryKeys: ["id", "cart_id", "promotion_id"],
18 relationships: [
19 {
20 serviceName: Modules.CART,
21 entity: "Cart",
22 primaryKey: "id",
23 foreignKey: "cart_id",
24 alias: "cart",
25 args: {
26 methodSuffix: "Carts",
27 },
28 hasMany: true,
29 },
30 {
31 serviceName: Modules.PROMOTION,
32 entity: "Promotion",
33 primaryKey: "id",
34 foreignKey: "promotion_id",
35 alias: "promotions",
36 args: {
37 methodSuffix: "Promotions",
38 },
39 hasMany: true,
40 },
41 ],
42 extends: [
43 {
44 serviceName: Modules.CART,
45 entity: "Cart",
46 fieldAlias: {
47 promotions: {
48 path: "cart_link.promotions",
49 isList: true,
50 },
51 },
52 relationship: {
53 serviceName: LINKS.CartPromotion,
54 primaryKey: "cart_id",
55 foreignKey: "id",
56 alias: "cart_link",
57 isList: true,
58 },
59 },
60 ],
61 }